@zentauri-ui/zentauri-components 1.4.63 → 1.4.70
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-TTYZBO4E.mjs → chunk-2BAMNRAL.mjs} +20 -20
- package/dist/chunk-2BAMNRAL.mjs.map +1 -0
- package/dist/{chunk-Z7PHKV2T.js → chunk-AD2LA3XN.js} +11 -11
- package/dist/chunk-AD2LA3XN.js.map +1 -0
- package/dist/{chunk-G3B6OHFG.js → chunk-AUGLZ3AN.js} +20 -20
- package/dist/chunk-AUGLZ3AN.js.map +1 -0
- package/dist/{chunk-LJ7AAIA3.mjs → chunk-C5L465FW.mjs} +11 -11
- package/dist/chunk-C5L465FW.mjs.map +1 -0
- package/dist/chunk-CIN5JDN4.js +174 -0
- package/dist/chunk-CIN5JDN4.js.map +1 -0
- package/dist/{chunk-H2I54QPJ.mjs → chunk-FQBMIZH2.mjs} +11 -11
- package/dist/{chunk-H2I54QPJ.mjs.map → chunk-FQBMIZH2.mjs.map} +1 -1
- package/dist/{chunk-4LT2GNJL.mjs → chunk-INMNX3HQ.mjs} +11 -11
- package/dist/{chunk-4LT2GNJL.mjs.map → chunk-INMNX3HQ.mjs.map} +1 -1
- package/dist/chunk-IQZROQNJ.mjs +165 -0
- package/dist/chunk-IQZROQNJ.mjs.map +1 -0
- package/dist/{chunk-ZIDKBEQJ.mjs → chunk-JBAUEGYD.mjs} +20 -20
- package/dist/chunk-JBAUEGYD.mjs.map +1 -0
- package/dist/{chunk-KEKNNZD3.js → chunk-OLEMP2HL.js} +11 -11
- package/dist/{chunk-KEKNNZD3.js.map → chunk-OLEMP2HL.js.map} +1 -1
- package/dist/{chunk-SKPZCISM.js → chunk-Q5B44QW7.js} +20 -20
- package/dist/chunk-Q5B44QW7.js.map +1 -0
- package/dist/{chunk-MXLRXYIX.js → chunk-S7WKFNPT.js} +11 -11
- package/dist/{chunk-MXLRXYIX.js.map → chunk-S7WKFNPT.js.map} +1 -1
- package/dist/{chunk-QEGACUFU.mjs → chunk-TINHLHCN.mjs} +11 -11
- package/dist/chunk-TINHLHCN.mjs.map +1 -0
- package/dist/{chunk-MXKGDFQH.js → chunk-Y745GQR2.js} +11 -11
- package/dist/chunk-Y745GQR2.js.map +1 -0
- package/dist/ui/accordion/animated.js +7 -7
- package/dist/ui/accordion/animated.mjs +2 -2
- package/dist/ui/accordion/variants.d.ts +2 -2
- package/dist/ui/accordion.js +9 -9
- package/dist/ui/accordion.mjs +2 -2
- package/dist/ui/alert/animated.js +2 -2
- package/dist/ui/alert/animated.mjs +1 -1
- package/dist/ui/alert/variants.d.ts +1 -1
- package/dist/ui/alert.js +10 -10
- package/dist/ui/alert.mjs +2 -2
- 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/animated.js +7 -7
- package/dist/ui/card/animated.mjs +2 -2
- package/dist/ui/card/variants.d.ts +1 -1
- package/dist/ui/card.js +12 -12
- package/dist/ui/card.mjs +2 -2
- package/dist/ui/divider/variants.d.ts +2 -2
- package/dist/ui/drawer/animated.js +11 -11
- package/dist/ui/drawer/animated.mjs +2 -2
- package/dist/ui/drawer/variants.d.ts +3 -3
- package/dist/ui/drawer.js +11 -11
- package/dist/ui/drawer.mjs +1 -1
- package/dist/ui/dropdown/variants.d.ts +4 -4
- package/dist/ui/dropdown.js +9 -9
- package/dist/ui/dropdown.js.map +1 -1
- package/dist/ui/dropdown.mjs +9 -9
- package/dist/ui/dropdown.mjs.map +1 -1
- package/dist/ui/file-upload/variants.d.ts +1 -1
- package/dist/ui/inputs/variants.d.ts +2 -2
- package/dist/ui/modal/animated.js +4 -4
- package/dist/ui/modal/animated.mjs +1 -1
- package/dist/ui/modal/variants.d.ts +2 -2
- package/dist/ui/modal.js +12 -12
- package/dist/ui/modal.mjs +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/select.js +27 -27
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/select.mjs +27 -27
- package/dist/ui/select.mjs.map +1 -1
- 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/animated.js +7 -7
- package/dist/ui/toast/animated.mjs +1 -1
- package/dist/ui/toast/variants.d.ts +1 -1
- package/dist/ui/toast.js +12 -12
- package/dist/ui/toast.mjs +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
- package/src/ui/accordion/variants.ts +9 -9
- package/src/ui/alert/variants.ts +9 -9
- package/src/ui/card/variants.ts +9 -9
- package/src/ui/drawer/variants.ts +18 -18
- package/src/ui/dropdown/variants.ts +9 -9
- package/src/ui/modal/variants.ts +18 -18
- package/src/ui/select/variants.ts +27 -27
- package/src/ui/toast/variants.ts +9 -9
- package/dist/chunk-G3B6OHFG.js.map +0 -1
- package/dist/chunk-LJ7AAIA3.mjs.map +0 -1
- package/dist/chunk-MXKGDFQH.js.map +0 -1
- package/dist/chunk-QEGACUFU.mjs.map +0 -1
- package/dist/chunk-SKPZCISM.js.map +0 -1
- package/dist/chunk-TTYZBO4E.mjs.map +0 -1
- package/dist/chunk-Z7PHKV2T.js.map +0 -1
- package/dist/chunk-ZIDKBEQJ.mjs.map +0 -1
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ChartColor, ChartSeries } from "./types";
|
|
2
|
+
import { chartPalette } from "./variants";
|
|
3
|
+
|
|
4
|
+
export function resolveColor(
|
|
5
|
+
color: ChartColor | string | undefined,
|
|
6
|
+
index: number,
|
|
7
|
+
) {
|
|
8
|
+
if (color && color in chartPalette) {
|
|
9
|
+
return chartPalette[color as ChartColor];
|
|
10
|
+
}
|
|
11
|
+
if (color) {
|
|
12
|
+
return { stroke: color, fill: color };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const paletteValues = Object.values(chartPalette);
|
|
16
|
+
return paletteValues[index % paletteValues.length] ?? chartPalette.cyan;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getSeriesFill(
|
|
20
|
+
series: ChartSeries,
|
|
21
|
+
index: number,
|
|
22
|
+
opacity = 0.18,
|
|
23
|
+
) {
|
|
24
|
+
const color = resolveColor(series.color, index);
|
|
25
|
+
return (
|
|
26
|
+
series.fill ??
|
|
27
|
+
`${color.fill}${Math.round(opacity * 255)
|
|
28
|
+
.toString(16)
|
|
29
|
+
.padStart(2, "0")}`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { VariantProps } from "class-variance-authority";
|
|
2
|
+
import type { CSSProperties, HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import type { chartPalette, chartVariants } from "./variants";
|
|
5
|
+
|
|
6
|
+
export type ChartType = "area" | "bar" | "bubble" | "line";
|
|
7
|
+
|
|
8
|
+
export type ChartColor = keyof typeof chartPalette;
|
|
9
|
+
|
|
10
|
+
export type ChartDatum = Record<string, number | string | null | undefined>;
|
|
11
|
+
|
|
12
|
+
export type ChartMargin = {
|
|
13
|
+
top?: number;
|
|
14
|
+
right?: number;
|
|
15
|
+
bottom?: number;
|
|
16
|
+
left?: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type ChartSeries = {
|
|
20
|
+
dataKey: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
color?: ChartColor | string;
|
|
23
|
+
textColor?: string;
|
|
24
|
+
fill?: string;
|
|
25
|
+
stackId?: string;
|
|
26
|
+
zKey?: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type ChartSharedStatic = VariantProps<typeof chartVariants>;
|
|
30
|
+
|
|
31
|
+
export type BaseChartProps<TDatum extends ChartDatum = ChartDatum> =
|
|
32
|
+
ChartSharedStatic &
|
|
33
|
+
Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
34
|
+
data: TDatum[];
|
|
35
|
+
series: ChartSeries[];
|
|
36
|
+
xKey: keyof TDatum & string;
|
|
37
|
+
height?: number;
|
|
38
|
+
showGrid?: boolean;
|
|
39
|
+
showLegend?: boolean;
|
|
40
|
+
showTooltip?: boolean;
|
|
41
|
+
tooltipColor?: string;
|
|
42
|
+
stacked?: boolean;
|
|
43
|
+
syncId?: string;
|
|
44
|
+
margin?: ChartMargin;
|
|
45
|
+
emptyState?: ReactNode;
|
|
46
|
+
containerStyle?: CSSProperties;
|
|
47
|
+
strokeDasharray?: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type AreaChartProps<TDatum extends ChartDatum = ChartDatum> =
|
|
51
|
+
BaseChartProps<TDatum>;
|
|
52
|
+
|
|
53
|
+
export type BarChartProps<TDatum extends ChartDatum = ChartDatum> =
|
|
54
|
+
BaseChartProps<TDatum>;
|
|
55
|
+
|
|
56
|
+
export type LineChartProps<TDatum extends ChartDatum = ChartDatum> =
|
|
57
|
+
BaseChartProps<TDatum>;
|
|
58
|
+
|
|
59
|
+
export type BubbleChartProps<TDatum extends ChartDatum = ChartDatum> =
|
|
60
|
+
BaseChartProps<TDatum>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export const chartVariants = cva(
|
|
4
|
+
[
|
|
5
|
+
"relative w-full min-w-0 overflow-hidden rounded-xl",
|
|
6
|
+
"h-[var(--chart-height)] min-h-64 sm:min-h-72 md:min-h-80",
|
|
7
|
+
"[&_.recharts-default-tooltip]:rounded-lg [&_.recharts-default-tooltip]:border [&_.recharts-default-tooltip]:border-slate-200",
|
|
8
|
+
"[&_.recharts-default-tooltip]:bg-white/95 [&_.recharts-default-tooltip]:shadow-lg",
|
|
9
|
+
"[&_.recharts-default-tooltip]:text-slate-900",
|
|
10
|
+
],
|
|
11
|
+
{
|
|
12
|
+
variants: {
|
|
13
|
+
appearance: {
|
|
14
|
+
default:
|
|
15
|
+
"bg-white text-slate-600 [&_.recharts-cartesian-axis-tick-value]:fill-slate-900",
|
|
16
|
+
muted:
|
|
17
|
+
"bg-slate-50 text-slate-500 [&_.recharts-cartesian-axis-tick-value]:fill-slate-900",
|
|
18
|
+
outline:
|
|
19
|
+
"border border-slate-200 bg-white text-slate-600 [&_.recharts-cartesian-axis-tick-value]:fill-slate-900",
|
|
20
|
+
glass:
|
|
21
|
+
"border border-white/15 bg-white/10 text-slate-100 backdrop-blur-md [&_.recharts-cartesian-axis-tick-value]:fill-white",
|
|
22
|
+
sky: "bg-sky-50 text-sky-500 [&_.recharts-cartesian-axis-tick-value]:fill-slate-900",
|
|
23
|
+
emerald:
|
|
24
|
+
"bg-emerald-50 text-emerald-500 [&_.recharts-cartesian-axis-tick-value]:fill-slate-900",
|
|
25
|
+
violet:
|
|
26
|
+
"bg-violet-50 text-violet-500 [&_.recharts-cartesian-axis-tick-value]:fill-slate-900",
|
|
27
|
+
amber:
|
|
28
|
+
"bg-amber-50 text-amber-500 [&_.recharts-cartesian-axis-tick-value]:fill-slate-900",
|
|
29
|
+
rose: "bg-rose-50 text-rose-500 [&_.recharts-cartesian-axis-tick-value]:fill-slate-900",
|
|
30
|
+
slate:
|
|
31
|
+
"bg-slate-50 text-slate-500 [&_.recharts-cartesian-axis-tick-value]:fill-slate-900",
|
|
32
|
+
gray: "bg-gray-50 text-gray-500 [&_.recharts-cartesian-axis-tick-value]:fill-slate-900",
|
|
33
|
+
indigo:
|
|
34
|
+
"bg-indigo-50 text-indigo-500 [&_.recharts-cartesian-axis-tick-value]:fill-slate-900",
|
|
35
|
+
"gradient-cyan-violet":
|
|
36
|
+
"bg-gradient-to-r from-cyan-500 to-violet-500 text-white [&_.recharts-cartesian-axis-tick-value]:fill-white",
|
|
37
|
+
"gradient-emerald-violet":
|
|
38
|
+
"bg-gradient-to-r from-emerald-500 to-violet-500 text-white [&_.recharts-cartesian-axis-tick-value]:fill-white",
|
|
39
|
+
"gradient-amber-rose":
|
|
40
|
+
"bg-gradient-to-r from-amber-500 to-rose-500 text-white [&_.recharts-cartesian-axis-tick-value]:fill-white",
|
|
41
|
+
"gradient-slate-gray":
|
|
42
|
+
"bg-gradient-to-r from-slate-500 to-gray-500 text-white [&_.recharts-cartesian-axis-tick-value]:fill-white",
|
|
43
|
+
"gradient-indigo-purple":
|
|
44
|
+
"bg-gradient-to-r from-indigo-500 to-purple-500 text-white [&_.recharts-cartesian-axis-tick-value]:fill-white",
|
|
45
|
+
"gradient-cyan-blue":
|
|
46
|
+
"bg-gradient-to-r from-cyan-500 to-blue-500 text-white [&_.recharts-cartesian-axis-tick-value]:fill-white",
|
|
47
|
+
"gradient-emerald-blue":
|
|
48
|
+
"bg-gradient-to-r from-emerald-500 to-blue-500 text-white [&_.recharts-cartesian-axis-tick-value]:fill-white",
|
|
49
|
+
"gradient-amber-blue":
|
|
50
|
+
"bg-gradient-to-r from-amber-500 to-blue-500 text-white [&_.recharts-cartesian-axis-tick-value]:fill-white",
|
|
51
|
+
},
|
|
52
|
+
density: {
|
|
53
|
+
compact: "p-2 sm:p-3",
|
|
54
|
+
comfortable: "p-3 sm:p-4",
|
|
55
|
+
spacious: "p-4 sm:p-5 md:p-6",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
defaultVariants: {
|
|
59
|
+
appearance: "default",
|
|
60
|
+
density: "comfortable",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export const chartPalette = {
|
|
66
|
+
cyan: { stroke: "#0891b2", fill: "#67e8f9", textColor: "#0891b2" },
|
|
67
|
+
emerald: { stroke: "#059669", fill: "#6ee7b7", textColor: "#059669" },
|
|
68
|
+
violet: { stroke: "#7c3aed", fill: "#c4b5fd", textColor: "#7c3aed" },
|
|
69
|
+
amber: { stroke: "#d97706", fill: "#fcd34d", textColor: "#d97706" },
|
|
70
|
+
rose: { stroke: "#e11d48", fill: "#fda4af", textColor: "#e11d48" },
|
|
71
|
+
slate: { stroke: "#475569", fill: "#cbd5e1", textColor: "#475569" },
|
|
72
|
+
gray: { stroke: "#6b7280", fill: "#d1d5db", textColor: "#6b7280" },
|
|
73
|
+
white: { stroke: "#ffffff", fill: "#ffffff", textColor: "#ffffff" },
|
|
74
|
+
indigo: { stroke: "#6366f1", fill: "#c7d2fe", textColor: "#6366f1" },
|
|
75
|
+
"gradient-cyan-violet": { stroke: "#0891b2", fill: "#67e8f9", textColor: "#0891b2" },
|
|
76
|
+
"gradient-emerald-violet": { stroke: "#059669", fill: "#6ee7b7", textColor: "#059669" },
|
|
77
|
+
"gradient-amber-rose": { stroke: "#d97706", fill: "#fcd34d", textColor: "#d97706" },
|
|
78
|
+
"gradient-slate-gray": { stroke: "#475569", fill: "#cbd5e1", textColor: "#475569" },
|
|
79
|
+
"gradient-indigo-purple": { stroke: "#6366f1", fill: "#c7d2fe", textColor: "#6366f1" },
|
|
80
|
+
"gradient-cyan-blue": { stroke: "#0891b2", fill: "#67e8f9", textColor: "#0891b2" },
|
|
81
|
+
"gradient-emerald-blue": { stroke: "#059669", fill: "#6ee7b7", textColor: "#059669" },
|
|
82
|
+
"gradient-amber-blue": { stroke: "#d97706", fill: "#fcd34d", textColor: "#d97706" },
|
|
83
|
+
} as const;
|
|
84
|
+
|
|
85
|
+
export const chartColorValues = Object.keys(chartPalette) as Array<
|
|
86
|
+
keyof typeof chartPalette
|
|
87
|
+
>;
|
|
@@ -19,23 +19,23 @@ export const accordionVariants = cva("w-full", {
|
|
|
19
19
|
emerald:
|
|
20
20
|
"divide-y divide-emerald-600 rounded-xl border border-emerald-600",
|
|
21
21
|
"gradient-blue":
|
|
22
|
-
"divide-y divide-
|
|
22
|
+
"divide-y divide-blue-600 rounded-xl border border-blue-600",
|
|
23
23
|
"gradient-green":
|
|
24
|
-
"divide-y divide-
|
|
24
|
+
"divide-y divide-green-600 rounded-xl border border-green-600",
|
|
25
25
|
"gradient-red":
|
|
26
|
-
"divide-y divide-
|
|
26
|
+
"divide-y divide-red-600 rounded-xl border border-red-600",
|
|
27
27
|
"gradient-yellow":
|
|
28
|
-
"divide-y divide-
|
|
28
|
+
"divide-y divide-yellow-600 rounded-xl border border-yellow-600",
|
|
29
29
|
"gradient-purple":
|
|
30
|
-
"divide-y divide-
|
|
30
|
+
"divide-y divide-purple-600 rounded-xl border border-purple-600",
|
|
31
31
|
"gradient-teal":
|
|
32
|
-
"divide-y divide-
|
|
32
|
+
"divide-y divide-teal-600 rounded-xl border border-teal-600",
|
|
33
33
|
"gradient-indigo":
|
|
34
|
-
"divide-y divide-
|
|
34
|
+
"divide-y divide-indigo-600 rounded-xl border border-indigo-600",
|
|
35
35
|
"gradient-pink":
|
|
36
|
-
"divide-y divide-
|
|
36
|
+
"divide-y divide-pink-600 rounded-xl border border-pink-600",
|
|
37
37
|
"gradient-orange":
|
|
38
|
-
"divide-y divide-
|
|
38
|
+
"divide-y divide-orange-600 rounded-xl border border-orange-600",
|
|
39
39
|
},
|
|
40
40
|
size: {
|
|
41
41
|
sm: "px-3 py-2 text-sm",
|