From ae983897590258a49cd834e219fec04294e607d2 Mon Sep 17 00:00:00 2001 From: Innei Date: Sat, 3 Oct 2026 03:20:51 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20feat:=20migrate=20to=20@lobehub?= =?UTF-8?q?/ui/base-ui=20components?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Skeleton, Tooltip, TooltipGroup, Segmented, Button and Text from @lobehub/ui/base-ui - NoData renders the root Empty instead of antd Empty - enforce the restrictedImports preset from @lobehub/ui/eslint - raise the @lobehub/ui peer range to ^5.54.0 --- .eslintrc.js | 19 ++++++++++++++++- package.json | 4 ++-- react-router.config.mjs | 3 +++ src/AccuracyBarChart/index.tsx | 5 +++-- src/AreaChart/demos/customTooltip.tsx | 10 ++++----- src/AreaChart/index.tsx | 5 +++-- src/BarChart/demos/customTooltip.tsx | 10 ++++----- src/BarChart/index.tsx | 5 +++-- src/BarList/index.tsx | 5 +++-- src/BenchmarkColumnChart/index.tsx | 5 +++-- src/BenchmarkRankingChart/index.tsx | 6 +++--- src/BenchmarkScatterChart/index.tsx | 6 +++--- src/ComposedChart/index.tsx | 5 +++-- src/DataBars/CategoryBar.tsx | 3 ++- src/DataBars/DeltaBar.tsx | 3 ++- src/DataBars/MarkerBar.tsx | 3 ++- src/DataBars/ProgressBar.tsx | 3 ++- src/DonutChart/demos/customTooltip.tsx | 10 ++++----- src/DonutChart/index.tsx | 5 +++-- src/FunnelChart/index.tsx | 5 +++-- src/Heatmaps/Calendar.tsx | 2 +- src/Heatmaps/demos/customTooltip.tsx | 13 +++++------- src/Heatmaps/index.tsx | 3 ++- src/Legend/LegendItem.tsx | 6 +++--- src/Legend/ScrollButton.tsx | 2 +- src/LineChart/demos/customTooltip.tsx | 10 ++++----- src/LineChart/index.tsx | 5 +++-- src/RadarChart/index.tsx | 5 +++-- src/ScatterChart/ScatterChartTooltip.tsx | 6 +++--- src/ScatterChart/ScatterChartTooltipRow.tsx | 10 ++++----- src/ScatterChart/demos/customTooltip.tsx | 17 ++++++--------- src/ScatterChart/index.tsx | 5 +++-- src/SparkChart/SparkAreaChart.tsx | 5 +++-- src/SparkChart/SparkBarChart.tsx | 5 +++-- src/SparkChart/SparkLineChart.tsx | 5 +++-- src/Tracker/TrackerBlock.tsx | 3 ++- src/Tracker/demos/customTooltip.tsx | 13 +++++------- src/Tracker/index.tsx | 3 ++- src/common/ChartTooltip/ChartTooltipRow.tsx | 10 ++++----- src/common/ChartTooltip/index.tsx | 6 +++--- src/common/NoData.tsx | 23 +++++---------------- tests/BenchmarkRankingChart.test.tsx | 6 +++++- tests/BenchmarkScatterChart.test.tsx | 6 +++++- 43 files changed, 157 insertions(+), 132 deletions(-) create mode 100644 react-router.config.mjs diff --git a/.eslintrc.js b/.eslintrc.js index bc75953..c8ffb93 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1 +1,18 @@ -module.exports = require('@lobehub/lint').eslint; +const config = require('@lobehub/lint').eslint; +const { restrictedImports } = require('./node_modules/@lobehub/ui/es/eslint/index.mjs'); + +// ESLint 8 keys `paths` by module name, so a second `antd` entry would overwrite the first. +const [level, options] = restrictedImports.rules['no-restricted-imports']; +const paths = Object.values( + options.paths.reduce((acc, path) => { + const prev = acc[path.name]; + acc[path.name] = + prev?.importNames && path.importNames + ? { ...prev, importNames: [...prev.importNames, ...path.importNames] } + : path; + return acc; + }, {}), +); +config.rules['no-restricted-imports'] = [level, { ...options, paths }]; + +module.exports = config; diff --git a/package.json b/package.json index a1ccd57..533de34 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "@lobehub/docs-kit": "^5.27.4", "@lobehub/icons": "^5.19.3", "@lobehub/lint": "^1.26.3", - "@lobehub/ui": "^5.49.0", + "@lobehub/ui": "^5.54.0", "@react-router/dev": "8.2.0", "@testing-library/react": "^16.3.3", "@types/chroma-js": "^3.1.2", @@ -121,7 +121,7 @@ "vitest": "~1.2.2" }, "peerDependencies": { - "@lobehub/ui": "^4.3.3", + "@lobehub/ui": "^5.54.0", "antd": "^6.1.1", "react": "^19.0.0", "react-dom": "^19.0.0" diff --git a/react-router.config.mjs b/react-router.config.mjs new file mode 100644 index 0000000..91deca3 --- /dev/null +++ b/react-router.config.mjs @@ -0,0 +1,3 @@ +// @lobehub/docs-kit generated react-router config +// This file is managed by `lobedocs` and is removed when the command exits. +export { default } from "file:///Users/innei/git/work/lobe-charts-base-ui/node_modules/.pnpm/@lobehub+docs-kit@5.27.4_d495276118c53ab09a95e6184a3b9a38/node_modules/@lobehub/docs-kit/site/react-router.config.ts"; diff --git a/src/AccuracyBarChart/index.tsx b/src/AccuracyBarChart/index.tsx index 7aed125..6348cf1 100644 --- a/src/AccuracyBarChart/index.tsx +++ b/src/AccuracyBarChart/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { css, cssVar, cx } from 'antd-style'; import { MouseEvent, forwardRef, useMemo, useState } from 'react'; import { @@ -147,7 +148,7 @@ const AccuracyBarChart = forwardRef((prop return getMaxLabelLength({ data, index, layout, valueFormatter: xAxisLabelFormatter }); }, [yAxisWidth, layout, data, xAxisLabelFormatter, index]); - if (loading || !data) return ; + if (loading || !data) return ; const CustomTooltip = customTooltip; const paddingValue = !showXAxis && !showYAxis ? 0 : 20; diff --git a/src/AreaChart/demos/customTooltip.tsx b/src/AreaChart/demos/customTooltip.tsx index f8de054..fe591b7 100644 --- a/src/AreaChart/demos/customTooltip.tsx +++ b/src/AreaChart/demos/customTooltip.tsx @@ -1,6 +1,6 @@ import { AreaChart, AreaChartProps, ChartTooltipFrame } from '@lobehub/charts'; import { Flexbox } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { useTheme } from 'antd-style'; const data: AreaChartProps['data'] = [ @@ -45,12 +45,12 @@ export default () => { width={4} /> - + {category.dataKey} - - + + {category.value} bpm - + ))} diff --git a/src/AreaChart/index.tsx b/src/AreaChart/index.tsx index c23d365..b00d055 100644 --- a/src/AreaChart/index.tsx +++ b/src/AreaChart/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { css, cssVar, cx } from 'antd-style'; import { Fragment, MouseEvent, forwardRef, useMemo, useState } from 'react'; import { @@ -96,7 +97,7 @@ const AreaChart = forwardRef((props, ref) => { return getMaxLabelLength({ data, index, margin: 16, valueFormatter }); }, [yAxisWidth, data, valueFormatter, index]); - if (loading || !data) return ; + if (loading || !data) return ; const CustomTooltip = customTooltip; const paddingValue = (!showXAxis && !showYAxis) || (startEndOnly && !showYAxis) ? 0 : 20; diff --git a/src/BarChart/demos/customTooltip.tsx b/src/BarChart/demos/customTooltip.tsx index 277fa19..476d5d8 100644 --- a/src/BarChart/demos/customTooltip.tsx +++ b/src/BarChart/demos/customTooltip.tsx @@ -1,6 +1,6 @@ import { BarChart, BarChartProps, ChartTooltipFrame } from '@lobehub/charts'; import { Flexbox } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { useTheme } from 'antd-style'; const data: BarChartProps['data'] = [ @@ -57,12 +57,12 @@ export default () => { width={4} /> - + {category.dataKey} - - + + {category.value} bpm - + ))} diff --git a/src/BarChart/index.tsx b/src/BarChart/index.tsx index 415f893..b416971 100644 --- a/src/BarChart/index.tsx +++ b/src/BarChart/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { css, cssVar, cx } from 'antd-style'; import { MouseEvent, forwardRef, useMemo, useState } from 'react'; import { @@ -87,7 +88,7 @@ const BarChart = forwardRef((props, ref) => { return getMaxLabelLength({ data, index, layout, valueFormatter }); }, [yAxisWidth, layout, data, valueFormatter, index]); - if (loading || !data) return ; + if (loading || !data) return ; const CustomTooltip = customTooltip; const paddingValue = !showXAxis && !showYAxis ? 0 : 20; diff --git a/src/BarList/index.tsx b/src/BarList/index.tsx index da9a60b..098909e 100644 --- a/src/BarList/index.tsx +++ b/src/BarList/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { A, Flexbox, Skeleton } from '@lobehub/ui'; +import { A, Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { cssVar, cx } from 'antd-style'; import React, { HTMLAttributes, ReactNode, forwardRef, useMemo } from 'react'; @@ -73,7 +74,7 @@ const BarList = forwardRef((props, ref) => { ); }, [sortedData]); - if (loading || !data) return ; + if (loading || !data) return ; const rowHeight = 32; const labelHeight = 20; diff --git a/src/BenchmarkColumnChart/index.tsx b/src/BenchmarkColumnChart/index.tsx index b96580c..78ad460 100644 --- a/src/BenchmarkColumnChart/index.tsx +++ b/src/BenchmarkColumnChart/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { cssVar, cx, useTheme } from 'antd-style'; import { readableColor } from 'polished'; import { type CSSProperties, MouseEvent, ReactNode, forwardRef, useMemo, useState } from 'react'; @@ -401,7 +402,7 @@ const BenchmarkColumnChart = forwardRef; + if (loading || !data) return ; const hasOnValueChange = !!onValueChange; diff --git a/src/BenchmarkRankingChart/index.tsx b/src/BenchmarkRankingChart/index.tsx index 33076cf..2e9f864 100644 --- a/src/BenchmarkRankingChart/index.tsx +++ b/src/BenchmarkRankingChart/index.tsx @@ -1,7 +1,7 @@ 'use client'; -import { A, Flexbox, Skeleton } from '@lobehub/ui'; -import { Tooltip } from 'antd'; +import { A, Flexbox } from '@lobehub/ui'; +import { Skeleton, Tooltip } from '@lobehub/ui/base-ui'; import { cssVar, cx, useTheme } from 'antd-style'; import { type CSSProperties, type ReactNode, forwardRef, useMemo, useState } from 'react'; @@ -201,7 +201,7 @@ const BenchmarkRankingChart = forwardRef tick > 0 && tick < resolvedMaxValue); - if (loading || !data) return ; + if (loading || !data) return ; const handleClick = (item: NormalizedBenchmarkItem) => { if (!onValueChange) return; diff --git a/src/BenchmarkScatterChart/index.tsx b/src/BenchmarkScatterChart/index.tsx index 54795f4..fa29856 100644 --- a/src/BenchmarkScatterChart/index.tsx +++ b/src/BenchmarkScatterChart/index.tsx @@ -1,8 +1,8 @@ 'use client'; -import { A, Skeleton } from '@lobehub/ui'; +import { A } from '@lobehub/ui'; +import { Segmented, Skeleton, Tooltip } from '@lobehub/ui/base-ui'; import { useSize } from 'ahooks'; -import { Segmented, Tooltip } from 'antd'; import { cssVar, cx, useTheme } from 'antd-style'; import { type CSSProperties, type ReactNode, forwardRef, useMemo, useRef, useState } from 'react'; @@ -545,7 +545,7 @@ const BenchmarkScatterChart = forwardRef; + if (loading || !data) return ; const focusKey = hoverKey ?? selectedKey; const focusPoint = diff --git a/src/ComposedChart/index.tsx b/src/ComposedChart/index.tsx index ef4c1ac..d58ddbf 100644 --- a/src/ComposedChart/index.tsx +++ b/src/ComposedChart/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { css, cssVar, cx } from 'antd-style'; import { forwardRef, useMemo, useState } from 'react'; import { @@ -94,7 +95,7 @@ const ComposedChart = forwardRef((props, ref return getMaxLabelLength({ data, index, layout: 'horizontal', valueFormatter: rightFormatter }); }, [yAxisRight, data, index]); - if (loading || !data) return ; + if (loading || !data) return ; const paddingValue = !showXAxis && !showYAxis ? 0 : 20; diff --git a/src/DataBars/CategoryBar.tsx b/src/DataBars/CategoryBar.tsx index 2836647..070b22b 100644 --- a/src/DataBars/CategoryBar.tsx +++ b/src/DataBars/CategoryBar.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, FlexboxProps, Tooltip } from '@lobehub/ui'; +import { Flexbox, FlexboxProps } from '@lobehub/ui'; +import { Tooltip } from '@lobehub/ui/base-ui'; import { cssVar, cx } from 'antd-style'; import { forwardRef, memo, useMemo } from 'react'; diff --git a/src/DataBars/DeltaBar.tsx b/src/DataBars/DeltaBar.tsx index 625e50f..d23bb50 100644 --- a/src/DataBars/DeltaBar.tsx +++ b/src/DataBars/DeltaBar.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, FlexboxProps, Tooltip } from '@lobehub/ui'; +import { Flexbox, FlexboxProps } from '@lobehub/ui'; +import { Tooltip } from '@lobehub/ui/base-ui'; import { cssVar, cx } from 'antd-style'; import { ReactNode, forwardRef } from 'react'; diff --git a/src/DataBars/MarkerBar.tsx b/src/DataBars/MarkerBar.tsx index 19abb63..f84577d 100644 --- a/src/DataBars/MarkerBar.tsx +++ b/src/DataBars/MarkerBar.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, FlexboxProps, Tooltip } from '@lobehub/ui'; +import { Flexbox, FlexboxProps } from '@lobehub/ui'; +import { Tooltip } from '@lobehub/ui/base-ui'; import { cssVar, cx } from 'antd-style'; import { ReactNode, forwardRef } from 'react'; diff --git a/src/DataBars/ProgressBar.tsx b/src/DataBars/ProgressBar.tsx index d0a7568..a9ccfc0 100644 --- a/src/DataBars/ProgressBar.tsx +++ b/src/DataBars/ProgressBar.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, FlexboxProps, Tooltip } from '@lobehub/ui'; +import { Flexbox, FlexboxProps } from '@lobehub/ui'; +import { Tooltip } from '@lobehub/ui/base-ui'; import { cssVar, cx } from 'antd-style'; import { ReactNode, forwardRef } from 'react'; diff --git a/src/DonutChart/demos/customTooltip.tsx b/src/DonutChart/demos/customTooltip.tsx index 433867c..a3cf894 100644 --- a/src/DonutChart/demos/customTooltip.tsx +++ b/src/DonutChart/demos/customTooltip.tsx @@ -1,6 +1,6 @@ import { ChartTooltipFrame, DonutChart, DonutChartProps } from '@lobehub/charts'; import { Flexbox } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { useTheme } from 'antd-style'; const data: DonutChartProps['data'] = [ @@ -48,12 +48,12 @@ export default () => { width={4} /> - + {category.dataKey} - - + + {category.value} bpm - + ))} diff --git a/src/DonutChart/index.tsx b/src/DonutChart/index.tsx index 6fdee02..47f63a4 100644 --- a/src/DonutChart/index.tsx +++ b/src/DonutChart/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { css, cssVar, cx, useThemeMode } from 'antd-style'; import { CSSProperties, ComponentType, MouseEvent, forwardRef, useEffect, useState } from 'react'; import { Pie, PieChart as ReChartsDonutChart, ResponsiveContainer, Tooltip } from 'recharts'; @@ -87,7 +88,7 @@ const DonutChart = forwardRef((props, ref) => { } }, [activeIndex]); - if (loading || !data) return ; + if (loading || !data) return ; const onShapeClick = (data: any, index: number, event: MouseEvent) => { event.stopPropagation(); diff --git a/src/FunnelChart/index.tsx b/src/FunnelChart/index.tsx index 0d34115..ac933e3 100644 --- a/src/FunnelChart/index.tsx +++ b/src/FunnelChart/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { useSize } from 'ahooks'; import { css, cssVar, cx } from 'antd-style'; import { @@ -272,7 +273,7 @@ const FunnelChart = forwardRef((props, ref) => }); }; - if (loading || !data) return ; + if (loading || !data) return ; const errorMessage = data ? validateData(data, calculateFrom) : null; diff --git a/src/Heatmaps/Calendar.tsx b/src/Heatmaps/Calendar.tsx index 687494b..b551195 100644 --- a/src/Heatmaps/Calendar.tsx +++ b/src/Heatmaps/Calendar.tsx @@ -1,4 +1,4 @@ -import { Tooltip } from '@lobehub/ui'; +import { Tooltip } from '@lobehub/ui/base-ui'; import { keyframes } from 'antd-style'; import isEqual from 'fast-deep-equal'; import { CSSProperties, ReactNode, memo, useMemo } from 'react'; diff --git a/src/Heatmaps/demos/customTooltip.tsx b/src/Heatmaps/demos/customTooltip.tsx index 372de37..3e73dbe 100644 --- a/src/Heatmaps/demos/customTooltip.tsx +++ b/src/Heatmaps/demos/customTooltip.tsx @@ -1,6 +1,6 @@ import { Heatmaps, HeatmapsProps } from '@lobehub/charts'; import { Flexbox } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { cssVar } from 'antd-style'; import { yearData } from './data'; @@ -16,15 +16,12 @@ export default () => { width={4} /> - + {payload.date} - - + + {payload.count} - + ); diff --git a/src/Heatmaps/index.tsx b/src/Heatmaps/index.tsx index a3e5858..521ba2b 100644 --- a/src/Heatmaps/index.tsx +++ b/src/Heatmaps/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, FlexboxProps, TooltipGroup } from '@lobehub/ui'; +import { Flexbox, FlexboxProps } from '@lobehub/ui'; +import { TooltipGroup } from '@lobehub/ui/base-ui'; import { cx, useTheme, useThemeMode } from 'antd-style'; import type { Day as WeekDay } from 'date-fns'; import { getYear, parseISO } from 'date-fns'; diff --git a/src/Legend/LegendItem.tsx b/src/Legend/LegendItem.tsx index 02af9cf..08307ce 100644 --- a/src/Legend/LegendItem.tsx +++ b/src/Legend/LegendItem.tsx @@ -1,5 +1,5 @@ import { Flexbox, Icon } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { createStaticStyles, cssVar, cx } from 'antd-style'; import { Circle } from 'lucide-react'; import { memo } from 'react'; @@ -63,7 +63,7 @@ const LegendItem = memo(({ label, name, color, onClick, activeL opacity: activeLegend && activeLegend !== name ? 0.4 : 1, }} /> - (({ label, name, color, onClick, activeL }} > {label} - + ); }); diff --git a/src/Legend/ScrollButton.tsx b/src/Legend/ScrollButton.tsx index 60fdf0c..ecff298 100644 --- a/src/Legend/ScrollButton.tsx +++ b/src/Legend/ScrollButton.tsx @@ -1,5 +1,5 @@ import { Icon } from '@lobehub/ui'; -import { Button } from 'antd'; +import { Button } from '@lobehub/ui/base-ui'; import { LucideIcon } from 'lucide-react'; import { memo, useEffect, useRef, useState } from 'react'; diff --git a/src/LineChart/demos/customTooltip.tsx b/src/LineChart/demos/customTooltip.tsx index 00a44d5..758ff8a 100644 --- a/src/LineChart/demos/customTooltip.tsx +++ b/src/LineChart/demos/customTooltip.tsx @@ -1,6 +1,6 @@ import { ChartTooltipFrame, LineChart, LineChartProps } from '@lobehub/charts'; import { Flexbox } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { useTheme } from 'antd-style'; const data: LineChartProps['data'] = [ @@ -45,12 +45,12 @@ export default () => { width={4} /> - + {category.dataKey} - - + + {category.value} bpm - + ))} diff --git a/src/LineChart/index.tsx b/src/LineChart/index.tsx index 38100db..1b9cfde 100644 --- a/src/LineChart/index.tsx +++ b/src/LineChart/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { css, cssVar, cx } from 'antd-style'; import { Fragment, MouseEvent, forwardRef, useMemo, useState } from 'react'; import { @@ -91,7 +92,7 @@ const LineChart = forwardRef((props, ref) => { return getMaxLabelLength({ data, index, margin: 16, valueFormatter }); }, [yAxisWidth, data, valueFormatter, index]); - if (loading || !data) return ; + if (loading || !data) return ; const CustomTooltip = customTooltip; const paddingValue = !showXAxis && !showYAxis ? 0 : 20; diff --git a/src/RadarChart/index.tsx b/src/RadarChart/index.tsx index ecac989..ce42912 100644 --- a/src/RadarChart/index.tsx +++ b/src/RadarChart/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { cssVar } from 'antd-style'; import { ReactNode, forwardRef, useState } from 'react'; import { @@ -87,7 +88,7 @@ const RadarChart = forwardRef((props, ref) => { const [activeLegend, setActiveLegend] = useState(); const [legendHeight, setLegendHeight] = useState(60); - if (loading || !data) return ; + if (loading || !data) return ; const CustomTooltip = customTooltip; const categoryColors = constructCategoryColors(categories, colors); diff --git a/src/ScatterChart/ScatterChartTooltip.tsx b/src/ScatterChart/ScatterChartTooltip.tsx index 68ed347..74f99b6 100644 --- a/src/ScatterChart/ScatterChartTooltip.tsx +++ b/src/ScatterChart/ScatterChartTooltip.tsx @@ -1,5 +1,5 @@ import { Flexbox, Icon } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { createStaticStyles, cssVar, cx } from 'antd-style'; import { Circle } from 'lucide-react'; import React, { memo } from 'react'; @@ -56,9 +56,9 @@ const ScatterChartTooltip = memo( paddingInline={16} > - + {label} - + {payload.map(({ value, name }: { name: string; value: number }, idx: number) => { diff --git a/src/ScatterChart/ScatterChartTooltipRow.tsx b/src/ScatterChart/ScatterChartTooltipRow.tsx index a51d0a8..d6b443d 100644 --- a/src/ScatterChart/ScatterChartTooltipRow.tsx +++ b/src/ScatterChart/ScatterChartTooltipRow.tsx @@ -1,5 +1,5 @@ import { Flexbox } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { createStaticStyles, cssVar } from 'antd-style'; import React, { memo } from 'react'; @@ -20,12 +20,12 @@ export interface ChartTooltipRowProps { const ChartTooltipRow = memo(({ value, name }) => { return ( - + {name} - - + + {value} - + ); }); diff --git a/src/ScatterChart/demos/customTooltip.tsx b/src/ScatterChart/demos/customTooltip.tsx index d061c73..7a99992 100644 --- a/src/ScatterChart/demos/customTooltip.tsx +++ b/src/ScatterChart/demos/customTooltip.tsx @@ -1,6 +1,6 @@ import { ChartTooltipFrame, ScatterChart, ScatterChartProps } from '@lobehub/charts'; import { Flexbox } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { useTheme } from 'antd-style'; const data: ScatterChartProps['data'] = [ @@ -80,21 +80,16 @@ export default () => { width={4} /> - - {label} - + {label} {payload.map((payloadItem: any, idx: number) => ( - + {payloadItem.dataKey} - - + + {payloadItem.value} - + ))} diff --git a/src/ScatterChart/index.tsx b/src/ScatterChart/index.tsx index f35ddd5..89f6029 100644 --- a/src/ScatterChart/index.tsx +++ b/src/ScatterChart/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { css, cssVar, cx } from 'antd-style'; import { ComponentType, HTMLAttributes, MouseEvent, forwardRef, useMemo, useState } from 'react'; import { @@ -154,7 +155,7 @@ const ScatterChart = forwardRef((props, ref) }); }, [yAxisWidth, data, valueFormatter, y]); - if (loading || !data) return ; + if (loading || !data) return ; const CustomTooltip = customTooltip; const hasOnValueChange = !!onValueChange; diff --git a/src/SparkChart/SparkAreaChart.tsx b/src/SparkChart/SparkAreaChart.tsx index 1bc3051..dc04ce1 100644 --- a/src/SparkChart/SparkAreaChart.tsx +++ b/src/SparkChart/SparkAreaChart.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { css, cssVar, cx } from 'antd-style'; import { forwardRef } from 'react'; import { Area, AreaChart as ReChartsAreaChart, ResponsiveContainer, XAxis, YAxis } from 'recharts'; @@ -46,7 +47,7 @@ const SparkAreaChart = forwardRef((props, r ...rest } = props; - if (loading || !data) return ; + if (loading || !data) return ; const categoryColors = constructCategoryColors(categories, colors); const yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue); diff --git a/src/SparkChart/SparkBarChart.tsx b/src/SparkChart/SparkBarChart.tsx index 8d86968..682336e 100644 --- a/src/SparkChart/SparkBarChart.tsx +++ b/src/SparkChart/SparkBarChart.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { css, cssVar, cx } from 'antd-style'; import { forwardRef } from 'react'; import { Bar, BarChart as ReChartsBarChart, ResponsiveContainer, XAxis, YAxis } from 'recharts'; @@ -40,7 +41,7 @@ const SparkBarChart = forwardRef((props, ref ...rest } = props; - if (loading || !data) return ; + if (loading || !data) return ; const categoryColors = constructCategoryColors(categories, colors); const yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue); diff --git a/src/SparkChart/SparkLineChart.tsx b/src/SparkChart/SparkLineChart.tsx index 99ed8a8..f811ede 100644 --- a/src/SparkChart/SparkLineChart.tsx +++ b/src/SparkChart/SparkLineChart.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, Skeleton } from '@lobehub/ui'; +import { Flexbox } from '@lobehub/ui'; +import { Skeleton } from '@lobehub/ui/base-ui'; import { css, cssVar, cx } from 'antd-style'; import { forwardRef } from 'react'; import { Line, LineChart as ReChartsLineChart, ResponsiveContainer, XAxis, YAxis } from 'recharts'; @@ -41,7 +42,7 @@ const SparkLineChart = forwardRef((props, r ...rest } = props; - if (loading || !data) return ; + if (loading || !data) return ; const categoryColors = constructCategoryColors(categories, colors); const yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue); diff --git a/src/Tracker/TrackerBlock.tsx b/src/Tracker/TrackerBlock.tsx index f1ff667..782a571 100644 --- a/src/Tracker/TrackerBlock.tsx +++ b/src/Tracker/TrackerBlock.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, FlexboxProps, Tooltip } from '@lobehub/ui'; +import { Flexbox, FlexboxProps } from '@lobehub/ui'; +import { Tooltip } from '@lobehub/ui/base-ui'; import { createStaticStyles, cssVar } from 'antd-style'; import { ReactNode, forwardRef, useMemo } from 'react'; diff --git a/src/Tracker/demos/customTooltip.tsx b/src/Tracker/demos/customTooltip.tsx index 60c462a..a91fdf5 100644 --- a/src/Tracker/demos/customTooltip.tsx +++ b/src/Tracker/demos/customTooltip.tsx @@ -1,6 +1,6 @@ import { Tracker, TrackerProps } from '@lobehub/charts'; import { Flexbox } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { useTheme } from 'antd-style'; const data: TrackerProps['data'] = [ @@ -59,15 +59,12 @@ export default () => { width={4} /> - + {item.tooltip} - - + + {item.color?.toUpperCase()} - + ); diff --git a/src/Tracker/index.tsx b/src/Tracker/index.tsx index 0861be8..1bafa29 100644 --- a/src/Tracker/index.tsx +++ b/src/Tracker/index.tsx @@ -1,6 +1,7 @@ 'use client'; -import { Flexbox, FlexboxProps, TooltipGroup } from '@lobehub/ui'; +import { Flexbox, FlexboxProps } from '@lobehub/ui'; +import { TooltipGroup } from '@lobehub/ui/base-ui'; import { cx } from 'antd-style'; import { ReactNode, forwardRef } from 'react'; diff --git a/src/common/ChartTooltip/ChartTooltipRow.tsx b/src/common/ChartTooltip/ChartTooltipRow.tsx index 9b057f0..68c65c4 100644 --- a/src/common/ChartTooltip/ChartTooltipRow.tsx +++ b/src/common/ChartTooltip/ChartTooltipRow.tsx @@ -1,5 +1,5 @@ import { Flexbox, Icon } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { createStaticStyles } from 'antd-style'; import { Circle } from 'lucide-react'; import { memo } from 'react'; @@ -25,13 +25,13 @@ const ChartTooltipRow = memo(({ value, name, color }) => { - + {name} - + - + {value} - + ); }); diff --git a/src/common/ChartTooltip/index.tsx b/src/common/ChartTooltip/index.tsx index 47896bb..9c5c229 100644 --- a/src/common/ChartTooltip/index.tsx +++ b/src/common/ChartTooltip/index.tsx @@ -1,5 +1,5 @@ import { Flexbox } from '@lobehub/ui'; -import { Typography } from 'antd'; +import { Text } from '@lobehub/ui/base-ui'; import { createStaticStyles, cssVar, cx } from 'antd-style'; import { ReactNode } from 'react'; @@ -42,9 +42,9 @@ const ChartTooltip = ({ return ( - + {label} - + (
-
- {(noDataText as any)?.title} -
-
- {(noDataText as any)?.desc} -
- - ) - } - image={Empty.PRESENTED_IMAGE_SIMPLE} + description={isReactNodeText ? noDataText : (noDataText as any)?.desc} + icon={Inbox} + title={isReactNodeText ? undefined : (noDataText as any)?.title} />
); diff --git a/tests/BenchmarkRankingChart.test.tsx b/tests/BenchmarkRankingChart.test.tsx index 227dcb1..55f01cc 100644 --- a/tests/BenchmarkRankingChart.test.tsx +++ b/tests/BenchmarkRankingChart.test.tsx @@ -20,7 +20,11 @@ vi.mock('@lobehub/ui', () => ({ } return
{children}
; }, - Skeleton: { Block: () =>
}, +})); + +vi.mock('@lobehub/ui/base-ui', async (importOriginal) => ({ + ...(await importOriginal()), + Skeleton: () =>
, })); describe('BenchmarkRankingChart', () => { diff --git a/tests/BenchmarkScatterChart.test.tsx b/tests/BenchmarkScatterChart.test.tsx index 8b2a448..005c76e 100644 --- a/tests/BenchmarkScatterChart.test.tsx +++ b/tests/BenchmarkScatterChart.test.tsx @@ -11,7 +11,11 @@ import { vi.mock('@lobehub/ui', () => ({ A: ({ children, ...rest }: any) => {children}, - Skeleton: { Block: () =>
}, +})); + +vi.mock('@lobehub/ui/base-ui', async (importOriginal) => ({ + ...(await importOriginal()), + Skeleton: () =>
, })); const data = [ From 6ff29291685b856a01ecf2684ca6a2745734401c Mon Sep 17 00:00:00 2001 From: Innei Date: Sat, 3 Oct 2026 03:21:23 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=94=A7=20chore:=20drop=20generated=20?= =?UTF-8?q?react-router=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-router.config.mjs | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 react-router.config.mjs diff --git a/react-router.config.mjs b/react-router.config.mjs deleted file mode 100644 index 91deca3..0000000 --- a/react-router.config.mjs +++ /dev/null @@ -1,3 +0,0 @@ -// @lobehub/docs-kit generated react-router config -// This file is managed by `lobedocs` and is removed when the command exits. -export { default } from "file:///Users/innei/git/work/lobe-charts-base-ui/node_modules/.pnpm/@lobehub+docs-kit@5.27.4_d495276118c53ab09a95e6184a3b9a38/node_modules/@lobehub/docs-kit/site/react-router.config.ts"; From e36163545fcaf4a0c0d65f18710fd3ec8585b462 Mon Sep 17 00:00:00 2001 From: Innei Date: Sat, 3 Oct 2026 03:59:15 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=90=9B=20fix(benchmark):=20unclamp=20?= =?UTF-8?q?base-ui=20tooltip=20content=20for=20ChartTooltip=20cards?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The base-ui tooltip viewport caps width at 318px, pads and clips its content, and inherits a 12px label font. --- src/BenchmarkRankingChart/index.tsx | 8 ++++++++ src/BenchmarkScatterChart/index.tsx | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/BenchmarkRankingChart/index.tsx b/src/BenchmarkRankingChart/index.tsx index 2e9f864..4888a10 100644 --- a/src/BenchmarkRankingChart/index.tsx +++ b/src/BenchmarkRankingChart/index.tsx @@ -257,6 +257,14 @@ const BenchmarkRankingChart = forwardRef