@zentauri-ui/zentauri-components 1.4.64 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -51
- package/cli/index.mjs +45 -26
- package/cli/registry.json +9 -1
- package/cli/rewrite-imports.mjs +8 -3
- package/dist/charts/area/Area.d.ts +6 -0
- package/dist/charts/area/Area.d.ts.map +1 -0
- package/dist/charts/area/index.d.ts +4 -0
- package/dist/charts/area/index.d.ts.map +1 -0
- package/dist/charts/area.js +119 -0
- package/dist/charts/area.js.map +1 -0
- package/dist/charts/area.mjs +106 -0
- package/dist/charts/area.mjs.map +1 -0
- package/dist/charts/bar/Bar.d.ts +6 -0
- package/dist/charts/bar/Bar.d.ts.map +1 -0
- package/dist/charts/bar/index.d.ts +4 -0
- package/dist/charts/bar/index.d.ts.map +1 -0
- package/dist/charts/bar.js +110 -0
- package/dist/charts/bar.js.map +1 -0
- package/dist/charts/bar.mjs +97 -0
- package/dist/charts/bar.mjs.map +1 -0
- package/dist/charts/bubble/Bubble.d.ts +6 -0
- package/dist/charts/bubble/Bubble.d.ts.map +1 -0
- package/dist/charts/bubble/index.d.ts +4 -0
- package/dist/charts/bubble/index.d.ts.map +1 -0
- package/dist/charts/bubble.js +122 -0
- package/dist/charts/bubble.js.map +1 -0
- package/dist/charts/bubble.mjs +109 -0
- package/dist/charts/bubble.mjs.map +1 -0
- package/dist/charts/line/Line.d.ts +6 -0
- package/dist/charts/line/Line.d.ts.map +1 -0
- package/dist/charts/line/index.d.ts +4 -0
- package/dist/charts/line/index.d.ts.map +1 -0
- package/dist/charts/line.js +113 -0
- package/dist/charts/line.js.map +1 -0
- package/dist/charts/line.mjs +100 -0
- package/dist/charts/line.mjs.map +1 -0
- package/dist/charts/shared/chart-frame.d.ts +32 -0
- package/dist/charts/shared/chart-frame.d.ts.map +1 -0
- package/dist/charts/shared/colors.d.ts +43 -0
- package/dist/charts/shared/colors.d.ts.map +1 -0
- package/dist/charts/shared/types.d.ts +43 -0
- package/dist/charts/shared/types.d.ts.map +1 -0
- package/dist/charts/shared/variants.d.ts +93 -0
- package/dist/charts/shared/variants.d.ts.map +1 -0
- package/dist/chunk-CIN5JDN4.js +174 -0
- package/dist/chunk-CIN5JDN4.js.map +1 -0
- package/dist/chunk-IQZROQNJ.mjs +165 -0
- package/dist/chunk-IQZROQNJ.mjs.map +1 -0
- package/dist/ui/accordion/variants.d.ts +2 -2
- package/dist/ui/alert/variants.d.ts +1 -1
- package/dist/ui/avatar/variants.d.ts +1 -1
- package/dist/ui/badge/variants.d.ts +2 -2
- package/dist/ui/breadcrumb/variants.d.ts +1 -1
- package/dist/ui/buttons/variants.d.ts +2 -2
- package/dist/ui/card/variants.d.ts +1 -1
- package/dist/ui/divider/variants.d.ts +2 -2
- package/dist/ui/drawer/variants.d.ts +3 -3
- package/dist/ui/dropdown/variants.d.ts +4 -4
- package/dist/ui/file-upload/variants.d.ts +1 -1
- package/dist/ui/inputs/variants.d.ts +2 -2
- package/dist/ui/modal/variants.d.ts +2 -2
- package/dist/ui/pagination/pagination.d.ts +2 -2
- package/dist/ui/pagination/variants.d.ts +3 -3
- package/dist/ui/progress/variants.d.ts +1 -1
- package/dist/ui/select/variants.d.ts +4 -4
- package/dist/ui/skeleton/variants.d.ts +2 -2
- package/dist/ui/slider/variants.d.ts +1 -1
- package/dist/ui/spinner/animated/variants.d.ts +1 -1
- package/dist/ui/stepper/variants.d.ts +1 -1
- package/dist/ui/table/variants.d.ts +3 -3
- package/dist/ui/tabs/variants.d.ts +1 -1
- package/dist/ui/toast/variants.d.ts +1 -1
- package/dist/ui/toggle/variants.d.ts +1 -1
- package/dist/ui/tooltip/variants.d.ts +1 -1
- package/dist/ui/typography/variants.d.ts +3 -3
- package/package.json +32 -12
- package/src/charts/area/Area.tsx +103 -0
- package/src/charts/area/index.ts +9 -0
- package/src/charts/bar/Bar.tsx +94 -0
- package/src/charts/bar/index.ts +9 -0
- package/src/charts/bubble/Bubble.tsx +113 -0
- package/src/charts/bubble/index.ts +9 -0
- package/src/charts/line/Line.tsx +97 -0
- package/src/charts/line/index.ts +9 -0
- package/src/charts/shared/chart-frame.tsx +107 -0
- package/src/charts/shared/colors.ts +31 -0
- package/src/charts/shared/types.ts +60 -0
- package/src/charts/shared/variants.ts +87 -0
|
@@ -2,7 +2,7 @@ export declare const toastViewportVariants: (props?: ({
|
|
|
2
2
|
position?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | null | undefined;
|
|
3
3
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
4
4
|
export declare const toastRootVariants: (props?: ({
|
|
5
|
-
appearance?: "
|
|
5
|
+
appearance?: "default" | "emerald" | "violet" | "amber" | "gray" | "indigo" | "orange" | "pink" | "purple" | "teal" | "yellow" | "error" | "ghost" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | "gradient-orange" | "success" | "warning" | "info" | null | undefined;
|
|
6
6
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
8
|
//# sourceMappingURL=variants.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const toggleTrackVariants: (props?: ({
|
|
2
2
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
3
|
-
appearance?: "default" | "
|
|
3
|
+
appearance?: "default" | "emerald" | "rose" | "slate" | "gray" | "indigo" | "cyan" | "green" | "lime" | "orange" | "pink" | "purple" | "teal" | "yellow" | "destructive" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | "gradient-orange" | "success" | "neutral" | "zinc" | "stone" | null | undefined;
|
|
4
4
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
5
|
export declare const toggleThumbVariants: (props?: ({
|
|
6
6
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const tooltipVariants: (props?: ({
|
|
2
|
-
variant?: "default" | "outline" | "
|
|
2
|
+
variant?: "default" | "outline" | "glass" | "sky" | "emerald" | "rose" | "indigo" | "green" | "orange" | "pink" | "purple" | "teal" | "yellow" | "ghost" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | "gradient-orange" | null | undefined;
|
|
3
3
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
4
4
|
width?: "sm" | "md" | "lg" | "xl" | "2xl" | "xs" | "fit" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/** Semantic text colors aligned with slate/cyan/violet accents used across the kit (dark-first). */
|
|
2
2
|
export declare const typographyToneVariants: (props?: ({
|
|
3
|
-
tone?: "
|
|
3
|
+
tone?: "default" | "muted" | "gradient-cyan-violet" | "gradient-cyan-blue" | "error" | "secondary" | "destructive" | "success" | "warning" | "info" | "primary" | "accent" | "gradient-pink-violet" | "gradient-cyan-green" | "gradient-cyan-orange" | "gradient-cyan-red" | "gradient-cyan-purple" | "gradient-cyan-pink" | null | undefined;
|
|
4
4
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
5
|
export declare const headingLevelVariants: (props?: ({
|
|
6
|
-
level?: 1 | 2 |
|
|
6
|
+
level?: 1 | 2 | 4 | 6 | 5 | 3 | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
8
|
export declare const textSizeVariants: (props?: ({
|
|
9
9
|
size?: "base" | "sm" | "lg" | null | undefined;
|
|
10
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
11
|
/** Marker style for unordered lists; ignored when `ordered` is true (decimal numbering). */
|
|
12
12
|
export declare const unorderedListMarkerVariants: (props?: ({
|
|
13
|
-
marker?: "
|
|
13
|
+
marker?: "none" | "circle" | "disc" | null | undefined;
|
|
14
14
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
15
15
|
export declare const orderedListVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
16
16
|
//# sourceMappingURL=variants.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zentauri-ui/zentauri-components",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "React + Tailwind UI kit with ESM/CJS builds, per-entry exports, and a zentauri-components / zentauri-ui CLI to vendor UI or hook source into your app",
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "React + Tailwind UI kit with charts, ESM/CJS builds, per-entry exports, and a zentauri-components / zentauri-ui CLI to vendor UI or hook source into your app",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"files": [
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"src/ui",
|
|
9
|
+
"src/charts",
|
|
10
|
+
"src/lib",
|
|
11
|
+
"src/hooks",
|
|
12
|
+
"cli"
|
|
13
|
+
],
|
|
7
14
|
"sideEffects": false,
|
|
8
15
|
"bin": {
|
|
9
16
|
"zentauri-components": "cli/index.mjs",
|
|
@@ -23,6 +30,11 @@
|
|
|
23
30
|
"import": "./dist/ui/*/animated.mjs",
|
|
24
31
|
"require": "./dist/ui/*/animated.js"
|
|
25
32
|
},
|
|
33
|
+
"./charts/*": {
|
|
34
|
+
"types": "./dist/charts/*/index.d.ts",
|
|
35
|
+
"import": "./dist/charts/*.mjs",
|
|
36
|
+
"require": "./dist/charts/*.js"
|
|
37
|
+
},
|
|
26
38
|
"./hooks/utils": {
|
|
27
39
|
"types": "./dist/lib/utils.d.ts",
|
|
28
40
|
"import": "./dist/hooks/utils.mjs",
|
|
@@ -45,17 +57,25 @@
|
|
|
45
57
|
"test:watch": "vitest"
|
|
46
58
|
},
|
|
47
59
|
"peerDependencies": {
|
|
48
|
-
"react": ">18",
|
|
49
|
-
"react-dom": ">18",
|
|
50
60
|
"class-variance-authority": "*",
|
|
51
61
|
"clsx": "*",
|
|
52
|
-
"tailwind-merge": "*",
|
|
53
62
|
"framer-motion": "*",
|
|
54
|
-
"react
|
|
63
|
+
"react": ">18",
|
|
64
|
+
"react-dom": ">18",
|
|
65
|
+
"react-icons": "*",
|
|
66
|
+
"recharts": "*",
|
|
67
|
+
"tailwind-merge": "*"
|
|
55
68
|
},
|
|
56
69
|
"peerDependenciesMeta": {
|
|
57
|
-
"framer-motion": {
|
|
58
|
-
|
|
70
|
+
"framer-motion": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"react-icons": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"recharts": {
|
|
77
|
+
"optional": true
|
|
78
|
+
}
|
|
59
79
|
},
|
|
60
80
|
"devDependencies": {
|
|
61
81
|
"@repo/typescript-config": "workspace:*",
|
|
@@ -66,8 +86,8 @@
|
|
|
66
86
|
"@types/react": "^19",
|
|
67
87
|
"@types/react-dom": "^19",
|
|
68
88
|
"jsdom": "^26.1.0",
|
|
89
|
+
"tsup": "^8.5.1",
|
|
69
90
|
"typescript": "^5",
|
|
70
|
-
"vitest": "^4.1.4"
|
|
71
|
-
"tsup": "^8.5.1"
|
|
91
|
+
"vitest": "^4.1.4"
|
|
72
92
|
}
|
|
73
|
-
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Area, AreaChart as RechartsAreaChart, XAxis, YAxis } from "recharts";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
ChartDecorators,
|
|
7
|
+
ChartFrame,
|
|
8
|
+
defaultChartMargin,
|
|
9
|
+
} from "../shared/chart-frame";
|
|
10
|
+
import { getSeriesFill, resolveColor } from "../shared/colors";
|
|
11
|
+
import type { AreaChartProps } from "../shared/types";
|
|
12
|
+
|
|
13
|
+
export function AreaChart<
|
|
14
|
+
TDatum extends Record<string, number | string | null | undefined>,
|
|
15
|
+
>({
|
|
16
|
+
appearance,
|
|
17
|
+
className,
|
|
18
|
+
containerStyle,
|
|
19
|
+
data,
|
|
20
|
+
density,
|
|
21
|
+
emptyState = null,
|
|
22
|
+
height = 320,
|
|
23
|
+
margin = defaultChartMargin,
|
|
24
|
+
series,
|
|
25
|
+
showGrid = true,
|
|
26
|
+
showLegend = false,
|
|
27
|
+
showTooltip = true,
|
|
28
|
+
tooltipColor = "#0f172a",
|
|
29
|
+
stacked = false,
|
|
30
|
+
style,
|
|
31
|
+
syncId,
|
|
32
|
+
xKey,
|
|
33
|
+
...props
|
|
34
|
+
}: AreaChartProps<TDatum>) {
|
|
35
|
+
const hasData = data.length > 0 && series.length > 0;
|
|
36
|
+
const xAxisKey = String(xKey);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<ChartFrame
|
|
40
|
+
appearance={appearance}
|
|
41
|
+
className={className}
|
|
42
|
+
containerStyle={containerStyle}
|
|
43
|
+
density={density}
|
|
44
|
+
emptyState={emptyState}
|
|
45
|
+
hasData={hasData}
|
|
46
|
+
height={height}
|
|
47
|
+
style={style}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
<RechartsAreaChart data={data} margin={margin} syncId={syncId}>
|
|
51
|
+
<ChartDecorators
|
|
52
|
+
axis={
|
|
53
|
+
<>
|
|
54
|
+
<XAxis
|
|
55
|
+
dataKey={xAxisKey}
|
|
56
|
+
minTickGap={24}
|
|
57
|
+
tickLine={false}
|
|
58
|
+
tickMargin={10}
|
|
59
|
+
axisLine={false}
|
|
60
|
+
fontSize={12}
|
|
61
|
+
fill="#ffffff"
|
|
62
|
+
color="#ffffff"
|
|
63
|
+
/>
|
|
64
|
+
<YAxis
|
|
65
|
+
width={40}
|
|
66
|
+
tickLine={false}
|
|
67
|
+
tickMargin={8}
|
|
68
|
+
axisLine={false}
|
|
69
|
+
fontSize={12}
|
|
70
|
+
fill="#ffffff"
|
|
71
|
+
color="#ffffff"
|
|
72
|
+
/>
|
|
73
|
+
</>
|
|
74
|
+
}
|
|
75
|
+
showGrid={showGrid}
|
|
76
|
+
showLegend={showLegend}
|
|
77
|
+
showTooltip={showTooltip}
|
|
78
|
+
tooltipColor={tooltipColor}
|
|
79
|
+
/>
|
|
80
|
+
{series.map((item, index) => {
|
|
81
|
+
const color = resolveColor(item.color, index);
|
|
82
|
+
const fill = getSeriesFill(item, index)
|
|
83
|
+
console.log(fill)
|
|
84
|
+
return (
|
|
85
|
+
<Area
|
|
86
|
+
key={item.dataKey}
|
|
87
|
+
type="monotone"
|
|
88
|
+
dataKey={item.dataKey}
|
|
89
|
+
name={item.name}
|
|
90
|
+
stackId={stacked ? (item.stackId ?? "stack") : item.stackId}
|
|
91
|
+
stroke={color.stroke}
|
|
92
|
+
fill={fill}
|
|
93
|
+
fillOpacity={1}
|
|
94
|
+
strokeWidth={2}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
})}
|
|
98
|
+
</RechartsAreaChart>
|
|
99
|
+
</ChartFrame>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
AreaChart.displayName = "AreaChart";
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Bar, BarChart as RechartsBarChart, XAxis, YAxis } from "recharts";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
ChartDecorators,
|
|
7
|
+
ChartFrame,
|
|
8
|
+
defaultChartMargin,
|
|
9
|
+
} from "../shared/chart-frame";
|
|
10
|
+
import { resolveColor } from "../shared/colors";
|
|
11
|
+
import type { BarChartProps } from "../shared/types";
|
|
12
|
+
|
|
13
|
+
export function BarChart<
|
|
14
|
+
TDatum extends Record<string, number | string | null | undefined>,
|
|
15
|
+
>({
|
|
16
|
+
appearance,
|
|
17
|
+
className,
|
|
18
|
+
containerStyle,
|
|
19
|
+
data,
|
|
20
|
+
density,
|
|
21
|
+
emptyState = null,
|
|
22
|
+
height = 320,
|
|
23
|
+
margin = defaultChartMargin,
|
|
24
|
+
series,
|
|
25
|
+
showGrid = true,
|
|
26
|
+
showLegend = false,
|
|
27
|
+
showTooltip = true,
|
|
28
|
+
tooltipColor = "#0f172a",
|
|
29
|
+
stacked = false,
|
|
30
|
+
style,
|
|
31
|
+
syncId,
|
|
32
|
+
xKey,
|
|
33
|
+
...props
|
|
34
|
+
}: BarChartProps<TDatum>) {
|
|
35
|
+
const hasData = data.length > 0 && series.length > 0;
|
|
36
|
+
const xAxisKey = String(xKey);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<ChartFrame
|
|
40
|
+
appearance={appearance}
|
|
41
|
+
className={className}
|
|
42
|
+
containerStyle={containerStyle}
|
|
43
|
+
density={density}
|
|
44
|
+
emptyState={emptyState}
|
|
45
|
+
hasData={hasData}
|
|
46
|
+
height={height}
|
|
47
|
+
style={style}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
<RechartsBarChart data={data} margin={margin} syncId={syncId}>
|
|
51
|
+
<ChartDecorators
|
|
52
|
+
axis={
|
|
53
|
+
<>
|
|
54
|
+
<XAxis
|
|
55
|
+
dataKey={xAxisKey}
|
|
56
|
+
minTickGap={24}
|
|
57
|
+
tickLine={false}
|
|
58
|
+
tickMargin={10}
|
|
59
|
+
axisLine={false}
|
|
60
|
+
fontSize={12}
|
|
61
|
+
/>
|
|
62
|
+
<YAxis
|
|
63
|
+
width={40}
|
|
64
|
+
tickLine={false}
|
|
65
|
+
tickMargin={8}
|
|
66
|
+
axisLine={false}
|
|
67
|
+
fontSize={12}
|
|
68
|
+
/>
|
|
69
|
+
</>
|
|
70
|
+
}
|
|
71
|
+
showGrid={showGrid}
|
|
72
|
+
showLegend={showLegend}
|
|
73
|
+
showTooltip={showTooltip}
|
|
74
|
+
tooltipColor={tooltipColor}
|
|
75
|
+
/>
|
|
76
|
+
{series.map((item, index) => {
|
|
77
|
+
const color = resolveColor(item.color, index);
|
|
78
|
+
return (
|
|
79
|
+
<Bar
|
|
80
|
+
key={item.dataKey}
|
|
81
|
+
dataKey={item.dataKey}
|
|
82
|
+
name={item.name}
|
|
83
|
+
stackId={stacked ? (item.stackId ?? "stack") : item.stackId}
|
|
84
|
+
fill={item.fill ?? color.stroke}
|
|
85
|
+
radius={[6, 6, 0, 0]}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
})}
|
|
89
|
+
</RechartsBarChart>
|
|
90
|
+
</ChartFrame>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
BarChart.displayName = "BarChart";
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Scatter,
|
|
5
|
+
ScatterChart as RechartsScatterChart,
|
|
6
|
+
XAxis,
|
|
7
|
+
YAxis,
|
|
8
|
+
ZAxis,
|
|
9
|
+
Bar,
|
|
10
|
+
} from "recharts";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
ChartDecorators,
|
|
14
|
+
ChartFrame,
|
|
15
|
+
defaultChartMargin,
|
|
16
|
+
} from "../shared/chart-frame";
|
|
17
|
+
import { resolveColor } from "../shared/colors";
|
|
18
|
+
import type { BubbleChartProps } from "../shared/types";
|
|
19
|
+
|
|
20
|
+
export function BubbleChart<
|
|
21
|
+
TDatum extends Record<string, number | string | null | undefined>,
|
|
22
|
+
>({
|
|
23
|
+
appearance,
|
|
24
|
+
className,
|
|
25
|
+
containerStyle,
|
|
26
|
+
data,
|
|
27
|
+
density,
|
|
28
|
+
emptyState = null,
|
|
29
|
+
height = 320,
|
|
30
|
+
margin = defaultChartMargin,
|
|
31
|
+
series,
|
|
32
|
+
showGrid = true,
|
|
33
|
+
showLegend = false,
|
|
34
|
+
showTooltip = true,
|
|
35
|
+
tooltipColor = "#0f172a",
|
|
36
|
+
style,
|
|
37
|
+
syncId,
|
|
38
|
+
xKey,
|
|
39
|
+
...props
|
|
40
|
+
}: BubbleChartProps<TDatum>) {
|
|
41
|
+
const hasData = data.length > 0 && series.length > 0;
|
|
42
|
+
const xAxisKey = String(xKey);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<ChartFrame
|
|
46
|
+
appearance={appearance}
|
|
47
|
+
className={className}
|
|
48
|
+
containerStyle={containerStyle}
|
|
49
|
+
density={density}
|
|
50
|
+
emptyState={emptyState}
|
|
51
|
+
hasData={hasData}
|
|
52
|
+
height={height}
|
|
53
|
+
style={style}
|
|
54
|
+
{...props}
|
|
55
|
+
>
|
|
56
|
+
<RechartsScatterChart data={data} margin={margin} syncId={syncId}>
|
|
57
|
+
<ChartDecorators
|
|
58
|
+
axis={
|
|
59
|
+
<>
|
|
60
|
+
<XAxis
|
|
61
|
+
dataKey={xAxisKey}
|
|
62
|
+
type="number"
|
|
63
|
+
minTickGap={24}
|
|
64
|
+
tickLine={false}
|
|
65
|
+
tickMargin={10}
|
|
66
|
+
axisLine={false}
|
|
67
|
+
fontSize={12}
|
|
68
|
+
/>
|
|
69
|
+
<YAxis
|
|
70
|
+
dataKey="__chartY"
|
|
71
|
+
type="number"
|
|
72
|
+
width={40}
|
|
73
|
+
tickLine={false}
|
|
74
|
+
tickMargin={8}
|
|
75
|
+
axisLine={false}
|
|
76
|
+
fontSize={12}
|
|
77
|
+
/>
|
|
78
|
+
</>
|
|
79
|
+
}
|
|
80
|
+
showGrid={showGrid}
|
|
81
|
+
showLegend={showLegend}
|
|
82
|
+
showTooltip={showTooltip}
|
|
83
|
+
tooltipColor={tooltipColor}
|
|
84
|
+
/>
|
|
85
|
+
{series.map((item, index) => {
|
|
86
|
+
const color = resolveColor(item.color, index);
|
|
87
|
+
return (
|
|
88
|
+
<Scatter
|
|
89
|
+
key={item.dataKey}
|
|
90
|
+
data={data.map((entry) => ({
|
|
91
|
+
...entry,
|
|
92
|
+
__chartY: entry[item.dataKey],
|
|
93
|
+
__chartZ: item.zKey ? entry[item.zKey] : undefined,
|
|
94
|
+
}))}
|
|
95
|
+
name={item.name}
|
|
96
|
+
fill={item.fill ?? color.stroke}
|
|
97
|
+
>
|
|
98
|
+
{data.map((_entry, cellIndex) => (
|
|
99
|
+
<Bar
|
|
100
|
+
key={`${item.dataKey}-${cellIndex}`}
|
|
101
|
+
fill={item.fill ?? color.stroke}
|
|
102
|
+
/>
|
|
103
|
+
))}
|
|
104
|
+
</Scatter>
|
|
105
|
+
);
|
|
106
|
+
})}
|
|
107
|
+
<ZAxis dataKey="__chartZ" range={[64, 720]} />
|
|
108
|
+
</RechartsScatterChart>
|
|
109
|
+
</ChartFrame>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
BubbleChart.displayName = "BubbleChart";
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Line, LineChart as RechartsLineChart, XAxis, YAxis } from "recharts";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
ChartDecorators,
|
|
7
|
+
ChartFrame,
|
|
8
|
+
defaultChartMargin,
|
|
9
|
+
} from "../shared/chart-frame";
|
|
10
|
+
import { resolveColor } from "../shared/colors";
|
|
11
|
+
import type { LineChartProps } from "../shared/types";
|
|
12
|
+
|
|
13
|
+
export function LineChart<
|
|
14
|
+
TDatum extends Record<string, number | string | null | undefined>,
|
|
15
|
+
>({
|
|
16
|
+
appearance,
|
|
17
|
+
className,
|
|
18
|
+
containerStyle,
|
|
19
|
+
data,
|
|
20
|
+
density,
|
|
21
|
+
emptyState = null,
|
|
22
|
+
height = 320,
|
|
23
|
+
margin = defaultChartMargin,
|
|
24
|
+
series,
|
|
25
|
+
showGrid = true,
|
|
26
|
+
showLegend = false,
|
|
27
|
+
showTooltip = true,
|
|
28
|
+
tooltipColor = "#0f172a",
|
|
29
|
+
style,
|
|
30
|
+
syncId,
|
|
31
|
+
xKey,
|
|
32
|
+
strokeDasharray,
|
|
33
|
+
...props
|
|
34
|
+
}: LineChartProps<TDatum>) {
|
|
35
|
+
const hasData = data.length > 0 && series.length > 0;
|
|
36
|
+
const xAxisKey = String(xKey);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<ChartFrame
|
|
40
|
+
appearance={appearance}
|
|
41
|
+
className={className}
|
|
42
|
+
containerStyle={containerStyle}
|
|
43
|
+
density={density}
|
|
44
|
+
emptyState={emptyState}
|
|
45
|
+
hasData={hasData}
|
|
46
|
+
height={height}
|
|
47
|
+
style={style}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
<RechartsLineChart data={data} margin={margin} syncId={syncId}>
|
|
51
|
+
<ChartDecorators
|
|
52
|
+
axis={
|
|
53
|
+
<>
|
|
54
|
+
<XAxis
|
|
55
|
+
dataKey={xAxisKey}
|
|
56
|
+
minTickGap={24}
|
|
57
|
+
tickLine={false}
|
|
58
|
+
tickMargin={10}
|
|
59
|
+
axisLine={false}
|
|
60
|
+
fontSize={12}
|
|
61
|
+
/>
|
|
62
|
+
<YAxis
|
|
63
|
+
width={40}
|
|
64
|
+
tickLine={false}
|
|
65
|
+
tickMargin={8}
|
|
66
|
+
axisLine={false}
|
|
67
|
+
fontSize={12}
|
|
68
|
+
/>
|
|
69
|
+
</>
|
|
70
|
+
}
|
|
71
|
+
showGrid={showGrid}
|
|
72
|
+
showLegend={showLegend}
|
|
73
|
+
showTooltip={showTooltip}
|
|
74
|
+
tooltipColor={tooltipColor}
|
|
75
|
+
/>
|
|
76
|
+
{series.map((item, index) => {
|
|
77
|
+
const color = resolveColor(item.color, index);
|
|
78
|
+
return (
|
|
79
|
+
<Line
|
|
80
|
+
key={item.dataKey}
|
|
81
|
+
type="monotone"
|
|
82
|
+
dataKey={item.dataKey}
|
|
83
|
+
name={item.name}
|
|
84
|
+
stroke={color.stroke}
|
|
85
|
+
strokeWidth={2}
|
|
86
|
+
dot={false}
|
|
87
|
+
activeDot={{ r: 5 }}
|
|
88
|
+
strokeDasharray={strokeDasharray ?? undefined}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
})}
|
|
92
|
+
</RechartsLineChart>
|
|
93
|
+
</ChartFrame>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
LineChart.displayName = "LineChart";
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { CSSProperties, HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import { CartesianGrid, Legend, ResponsiveContainer, Tooltip } from "recharts";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
import { chartVariants } from "./variants";
|
|
6
|
+
import { VariantProps } from "class-variance-authority";
|
|
7
|
+
|
|
8
|
+
type ChartFrameProps = HTMLAttributes<HTMLDivElement> & {
|
|
9
|
+
appearance?: VariantProps<typeof chartVariants>["appearance"];
|
|
10
|
+
containerStyle?: CSSProperties;
|
|
11
|
+
density?: "compact" | "comfortable" | "spacious" | null;
|
|
12
|
+
emptyState?: ReactNode;
|
|
13
|
+
hasData: boolean;
|
|
14
|
+
height: number;
|
|
15
|
+
showGrid?: boolean;
|
|
16
|
+
showLegend?: boolean;
|
|
17
|
+
showTooltip?: boolean;
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const defaultChartMargin = { top: 16, right: 16, bottom: 8, left: 0 };
|
|
23
|
+
|
|
24
|
+
export function ChartFrame({
|
|
25
|
+
appearance,
|
|
26
|
+
children,
|
|
27
|
+
className,
|
|
28
|
+
containerStyle,
|
|
29
|
+
density,
|
|
30
|
+
emptyState = null,
|
|
31
|
+
hasData,
|
|
32
|
+
height,
|
|
33
|
+
style,
|
|
34
|
+
...props
|
|
35
|
+
}: ChartFrameProps) {
|
|
36
|
+
const chartStyle = {
|
|
37
|
+
"--chart-height": `${height}px`,
|
|
38
|
+
...style,
|
|
39
|
+
} as CSSProperties;
|
|
40
|
+
|
|
41
|
+
if (!hasData) {
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
className={cn(chartVariants({ appearance, density }), className)}
|
|
45
|
+
style={chartStyle}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
<div className="flex h-full min-h-48 items-center justify-center text-sm text-slate-500">
|
|
49
|
+
{emptyState}
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div
|
|
57
|
+
className={cn(chartVariants({ appearance, density }), className)}
|
|
58
|
+
style={chartStyle}
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
<ResponsiveContainer
|
|
62
|
+
width="100%"
|
|
63
|
+
height="100%"
|
|
64
|
+
debounce={80}
|
|
65
|
+
style={containerStyle}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</ResponsiveContainer>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function ChartDecorators({
|
|
74
|
+
axis,
|
|
75
|
+
showGrid,
|
|
76
|
+
showLegend,
|
|
77
|
+
showTooltip,
|
|
78
|
+
tooltipColor = "#0f172a",
|
|
79
|
+
}: {
|
|
80
|
+
axis: ReactNode;
|
|
81
|
+
showGrid: boolean;
|
|
82
|
+
showLegend: boolean;
|
|
83
|
+
showTooltip: boolean;
|
|
84
|
+
tooltipColor?: string;
|
|
85
|
+
}) {
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
{showGrid ? (
|
|
89
|
+
<CartesianGrid
|
|
90
|
+
strokeDasharray="3 3"
|
|
91
|
+
stroke="currentColor"
|
|
92
|
+
opacity={0.16}
|
|
93
|
+
/>
|
|
94
|
+
) : null}
|
|
95
|
+
{axis}
|
|
96
|
+
{showTooltip ? (
|
|
97
|
+
<Tooltip
|
|
98
|
+
cursor={{ opacity: 0.12 }}
|
|
99
|
+
contentStyle={{ color: tooltipColor }}
|
|
100
|
+
labelStyle={{ color: tooltipColor }}
|
|
101
|
+
itemStyle={{ color: tooltipColor }}
|
|
102
|
+
/>
|
|
103
|
+
) : null}
|
|
104
|
+
{showLegend ? <Legend /> : null}
|
|
105
|
+
</>
|
|
106
|
+
);
|
|
107
|
+
}
|