@alpic-ai/ui 1.142.3 → 1.144.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/dist/components/area-chart.mjs +1 -3
- package/dist/components/bar-chart.mjs +1 -3
- package/dist/components/bar-list.mjs +2 -9
- package/dist/components/chart-tooltip.mjs +5 -3
- package/dist/components/donut-chart.mjs +1 -3
- package/dist/components/form.mjs +2 -0
- package/dist/components/line-chart.mjs +1 -3
- package/dist/lib/chart-palette.mjs +16 -16
- package/package.json +1 -1
- package/src/components/area-chart.tsx +1 -4
- package/src/components/bar-chart.tsx +1 -4
- package/src/components/bar-list.tsx +1 -9
- package/src/components/chart-tooltip.tsx +6 -6
- package/src/components/donut-chart.tsx +1 -4
- package/src/components/form.tsx +3 -1
- package/src/components/line-chart.tsx +1 -4
- package/src/lib/chart-palette.ts +16 -16
- package/dist/hooks/use-reduced-motion.d.mts +0 -4
- package/dist/hooks/use-reduced-motion.mjs +0 -16
- package/src/hooks/use-reduced-motion.ts +0 -17
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.mjs";
|
|
3
|
-
import { useReducedMotion } from "../hooks/use-reduced-motion.mjs";
|
|
4
3
|
import { makeXAxisTick, orderByLuminance, resolveSeries } from "../lib/chart.mjs";
|
|
5
4
|
import { useChartContext } from "./chart-container.mjs";
|
|
6
5
|
import { ChartLegend } from "./chart-legend.mjs";
|
|
@@ -17,7 +16,6 @@ const CURVE_TYPE = {
|
|
|
17
16
|
function AreaChart({ data, index, series, variant = "stacked", curve = "monotone", legend = false, legendAlign = "left", valueFlags = false, height = 200, yAxisWidth = 48, palette, referenceLine, markers, lastValueLabel = false, texture = false, loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
18
17
|
const { palette: paletteColors, theme } = useChartContext(palette);
|
|
19
18
|
const reactId = React$1.useId().replace(/:/g, "");
|
|
20
|
-
const animated = !useReducedMotion();
|
|
21
19
|
const resolved = resolveSeries(series, paletteColors, theme);
|
|
22
20
|
const stacked = variant === "stacked" || variant === "expand";
|
|
23
21
|
const rendered = stacked ? orderByLuminance(resolved) : resolved;
|
|
@@ -238,7 +236,7 @@ function AreaChart({ data, index, series, variant = "stacked", curve = "monotone
|
|
|
238
236
|
fill: fillFor(entry, slot),
|
|
239
237
|
dot: false,
|
|
240
238
|
activeDot: activeDotFor(entry),
|
|
241
|
-
isAnimationActive:
|
|
239
|
+
isAnimationActive: false,
|
|
242
240
|
animationDuration: 650,
|
|
243
241
|
animationEasing: "ease-out",
|
|
244
242
|
children: lastValueLabel && /* @__PURE__ */ jsx(LabelList, {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.mjs";
|
|
3
|
-
import { useReducedMotion } from "../hooks/use-reduced-motion.mjs";
|
|
4
3
|
import { makeXAxisTick, orderByLuminance, resolveSeries } from "../lib/chart.mjs";
|
|
5
4
|
import { useChartContext } from "./chart-container.mjs";
|
|
6
5
|
import { ChartLegend } from "./chart-legend.mjs";
|
|
@@ -14,7 +13,6 @@ const MAX_BAR_SIZE = 48;
|
|
|
14
13
|
function BarChart({ data, index, series, variant = "stacked", legend = false, legendAlign = "left", valueLabels = false, height = 200, yAxisWidth = 48, palette, referenceLine, markers, texture = false, loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
15
14
|
const { palette: paletteColors, theme } = useChartContext(palette);
|
|
16
15
|
const reactId = React$1.useId().replace(/:/g, "");
|
|
17
|
-
const animated = !useReducedMotion();
|
|
18
16
|
const resolved = resolveSeries(series, paletteColors, theme);
|
|
19
17
|
const stacked = variant === "stacked" || variant === "expand";
|
|
20
18
|
const rendered = stacked ? orderByLuminance(resolved) : resolved;
|
|
@@ -225,7 +223,7 @@ function BarChart({ data, index, series, variant = "stacked", legend = false, le
|
|
|
225
223
|
stroke: theme.card,
|
|
226
224
|
strokeWidth: 1
|
|
227
225
|
},
|
|
228
|
-
isAnimationActive:
|
|
226
|
+
isAnimationActive: false,
|
|
229
227
|
animationDuration: 650,
|
|
230
228
|
animationEasing: "ease-out",
|
|
231
229
|
children: valueLabels && (!stacked || rendered.length === 1) && /* @__PURE__ */ jsx(LabelList, {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.mjs";
|
|
3
|
-
import { useReducedMotion } from "../hooks/use-reduced-motion.mjs";
|
|
4
3
|
import { rampColor } from "../lib/chart-palette.mjs";
|
|
5
4
|
import { formatShare } from "../lib/chart.mjs";
|
|
6
5
|
import { useChartContext } from "./chart-container.mjs";
|
|
@@ -19,12 +18,7 @@ const IN_FILL_SHADOW = "0 1px 2px rgb(0 0 0 / 0.28)";
|
|
|
19
18
|
function BarList({ data, index, dataKey = "value", maxItems, palette, semantic, loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
20
19
|
const { paletteName, theme } = useChartContext(palette);
|
|
21
20
|
const accent = semantic ? theme[SEMANTIC_KEY[semantic]] : null;
|
|
22
|
-
const reducedMotion = useReducedMotion();
|
|
23
|
-
const [mounted, setMounted] = React$1.useState(false);
|
|
24
21
|
const [active, setActive] = React$1.useState(null);
|
|
25
|
-
React$1.useEffect(() => {
|
|
26
|
-
setMounted(true);
|
|
27
|
-
}, []);
|
|
28
22
|
const total = React$1.useMemo(() => data.reduce((sum, row) => sum + (Number(row[dataKey]) || 0), 0), [data, dataKey]);
|
|
29
23
|
const rows = React$1.useMemo(() => {
|
|
30
24
|
const mapped = data.map((row) => ({
|
|
@@ -67,7 +61,7 @@ function BarList({ data, index, dataKey = "value", maxItems, palette, semantic,
|
|
|
67
61
|
className: cn("flex w-full flex-col", className),
|
|
68
62
|
children: rows.map((row, slot) => {
|
|
69
63
|
const fraction = maxValue > 0 ? row.value / maxValue : 0;
|
|
70
|
-
const fillWidth =
|
|
64
|
+
const fillWidth = `${fraction * 100}%`;
|
|
71
65
|
const dimmed = active !== null && active !== slot;
|
|
72
66
|
const isActive = active === slot;
|
|
73
67
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -85,8 +79,7 @@ function BarList({ data, index, dataKey = "value", maxItems, palette, semantic,
|
|
|
85
79
|
width: fillWidth,
|
|
86
80
|
background: `linear-gradient(90deg, ${row.color}, color-mix(in oklab, ${row.color} 82%, transparent))`,
|
|
87
81
|
boxShadow: `inset 0 0 0 1px ${row.color}`,
|
|
88
|
-
opacity: dimmed ? .45 : 1
|
|
89
|
-
transition: reducedMotion ? void 0 : "width 700ms ease-out"
|
|
82
|
+
opacity: dimmed ? .45 : 1
|
|
90
83
|
},
|
|
91
84
|
children: /* @__PURE__ */ jsx("span", {
|
|
92
85
|
className: "pointer-events-none absolute top-1/2 -translate-y-1/2 truncate type-text-xs font-medium text-white",
|
|
@@ -6,7 +6,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
function ChartTooltipContent({ active, payload, label, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, hideLabel, showTotal, totalLabel = "Total", className }) {
|
|
7
7
|
const { theme } = useChartContext();
|
|
8
8
|
if (!active || !payload?.length) return null;
|
|
9
|
-
const
|
|
9
|
+
const toNumber = (value) => typeof value === "number" ? value : Number(value ?? 0);
|
|
10
|
+
const total = payload.reduce((sum, item) => sum + toNumber(item.value), 0);
|
|
11
|
+
const rows = [...payload].sort((lower, upper) => toNumber(upper.value) - toNumber(lower.value));
|
|
10
12
|
return /* @__PURE__ */ jsxs("div", {
|
|
11
13
|
className: cn("min-w-[130px] rounded-lg border px-3 py-2.5 shadow-lg", "border-border bg-popover text-popover-foreground", className),
|
|
12
14
|
children: [!hideLabel && label !== void 0 && /* @__PURE__ */ jsx("p", {
|
|
@@ -14,13 +16,13 @@ function ChartTooltipContent({ active, payload, label, valueFormatter = (value)
|
|
|
14
16
|
children: labelFormatter ? labelFormatter(label) : label
|
|
15
17
|
}), /* @__PURE__ */ jsxs("div", {
|
|
16
18
|
className: "flex flex-col gap-1",
|
|
17
|
-
children: [
|
|
19
|
+
children: [rows.map((item, index) => {
|
|
18
20
|
const swatch = [
|
|
19
21
|
item.color,
|
|
20
22
|
item.stroke,
|
|
21
23
|
item.fill
|
|
22
24
|
].find((candidate) => typeof candidate === "string" && candidate.length > 0 && !candidate.startsWith("url(")) ?? theme.mutedForeground;
|
|
23
|
-
const numeric =
|
|
25
|
+
const numeric = toNumber(item.value);
|
|
24
26
|
return /* @__PURE__ */ jsxs("div", {
|
|
25
27
|
className: "flex items-center justify-between gap-4 text-text-xs",
|
|
26
28
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.mjs";
|
|
3
|
-
import { useReducedMotion } from "../hooks/use-reduced-motion.mjs";
|
|
4
3
|
import { paletteColor } from "../lib/chart-palette.mjs";
|
|
5
4
|
import { formatShare } from "../lib/chart.mjs";
|
|
6
5
|
import { useChartContext } from "./chart-container.mjs";
|
|
@@ -21,7 +20,6 @@ const GEOMETRY = {
|
|
|
21
20
|
function DonutChart({ data, index, dataKey = "value", variant = "donut", legend = false, paddingAngle = 1, height = 220, palette, centerLabel = "total", loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
22
21
|
const { palette: paletteColors, theme } = useChartContext(palette);
|
|
23
22
|
const reactId = React$1.useId().replace(/:/g, "");
|
|
24
|
-
const animated = !useReducedMotion();
|
|
25
23
|
const [active, setActive] = React$1.useState(null);
|
|
26
24
|
const rowRefs = React$1.useRef([]);
|
|
27
25
|
const slices = React$1.useMemo(() => {
|
|
@@ -104,7 +102,7 @@ function DonutChart({ data, index, dataKey = "value", variant = "donut", legend
|
|
|
104
102
|
cornerRadius: 2,
|
|
105
103
|
stroke: theme.card,
|
|
106
104
|
strokeWidth: 1.5,
|
|
107
|
-
isAnimationActive:
|
|
105
|
+
isAnimationActive: false,
|
|
108
106
|
animationDuration: 650,
|
|
109
107
|
animationEasing: "ease-out",
|
|
110
108
|
onMouseEnter: (_entry, sliceIndex) => setActive(sliceIndex),
|
package/dist/components/form.mjs
CHANGED
|
@@ -41,10 +41,12 @@ const useFormField = () => {
|
|
|
41
41
|
const FormItemContext = React$1.createContext({});
|
|
42
42
|
function FormItem({ className, ...props }) {
|
|
43
43
|
const id = React$1.useId();
|
|
44
|
+
const { name } = React$1.useContext(FormFieldContext);
|
|
44
45
|
return /* @__PURE__ */ jsx(FormItemContext.Provider, {
|
|
45
46
|
value: { id },
|
|
46
47
|
children: /* @__PURE__ */ jsx("div", {
|
|
47
48
|
"data-slot": "form-item",
|
|
49
|
+
"data-field-name": name,
|
|
48
50
|
className: cn("grid gap-2", className),
|
|
49
51
|
...props
|
|
50
52
|
})
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.mjs";
|
|
3
|
-
import { useReducedMotion } from "../hooks/use-reduced-motion.mjs";
|
|
4
3
|
import { makeXAxisTick, resolveSeries } from "../lib/chart.mjs";
|
|
5
4
|
import { useChartContext } from "./chart-container.mjs";
|
|
6
5
|
import { ChartLegend } from "./chart-legend.mjs";
|
|
@@ -16,7 +15,6 @@ const CURVE_TYPE = {
|
|
|
16
15
|
};
|
|
17
16
|
function LineChart({ data, index, series, curve = "monotone", legend = false, legendAlign = "left", valueFlags = false, dots = false, height = 200, yAxisWidth = 48, palette, referenceLine, markers, lastValueLabel = false, loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
18
17
|
const { palette: paletteColors, theme } = useChartContext(palette);
|
|
19
|
-
const animated = !useReducedMotion();
|
|
20
18
|
const resolved = resolveSeries(series, paletteColors, theme);
|
|
21
19
|
const numericMax = React$1.useMemo(() => {
|
|
22
20
|
let max = 0;
|
|
@@ -181,7 +179,7 @@ function LineChart({ data, index, series, curve = "monotone", legend = false, le
|
|
|
181
179
|
strokeWidth: 0
|
|
182
180
|
} : false,
|
|
183
181
|
activeDot: activeDotFor(entry),
|
|
184
|
-
isAnimationActive:
|
|
182
|
+
isAnimationActive: false,
|
|
185
183
|
animationDuration: 650,
|
|
186
184
|
animationEasing: "ease-out",
|
|
187
185
|
children: lastValueLabel && /* @__PURE__ */ jsx(LabelList, {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
const CHART_PALETTES = {
|
|
2
2
|
magenta: [
|
|
3
|
-
"#
|
|
4
|
-
"#
|
|
5
|
-
"#
|
|
6
|
-
"#
|
|
7
|
-
"#
|
|
8
|
-
"#
|
|
9
|
-
"#
|
|
10
|
-
"#
|
|
3
|
+
"#da1b6a",
|
|
4
|
+
"#ec82b0",
|
|
5
|
+
"#9a67d7",
|
|
6
|
+
"#668fdf",
|
|
7
|
+
"#47bde0",
|
|
8
|
+
"#75ddd8",
|
|
9
|
+
"#cd8c4d",
|
|
10
|
+
"#3eb0a1"
|
|
11
11
|
],
|
|
12
12
|
cyan: [
|
|
13
|
-
"#
|
|
14
|
-
"#
|
|
15
|
-
"#
|
|
16
|
-
"#
|
|
17
|
-
"#
|
|
18
|
-
"#
|
|
19
|
-
"#
|
|
20
|
-
"#
|
|
13
|
+
"#2eb2c5",
|
|
14
|
+
"#50d0c0",
|
|
15
|
+
"#4f90e0",
|
|
16
|
+
"#8d74e0",
|
|
17
|
+
"#bc73e0",
|
|
18
|
+
"#ec82b0",
|
|
19
|
+
"#da1b6a",
|
|
20
|
+
"#c08dd3"
|
|
21
21
|
]
|
|
22
22
|
};
|
|
23
23
|
const heatRampMagenta = (empty) => [
|
package/package.json
CHANGED
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
YAxis,
|
|
16
16
|
} from "recharts";
|
|
17
17
|
|
|
18
|
-
import { useReducedMotion } from "../hooks/use-reduced-motion";
|
|
19
18
|
import { type ChartSeries, makeXAxisTick, orderByLuminance, resolveSeries } from "../lib/chart";
|
|
20
19
|
import type { ChartPaletteName } from "../lib/chart-palette";
|
|
21
20
|
import { cn } from "../lib/cn";
|
|
@@ -77,8 +76,6 @@ function AreaChart({
|
|
|
77
76
|
}: AreaChartProps) {
|
|
78
77
|
const { palette: paletteColors, theme } = useChartContext(palette);
|
|
79
78
|
const reactId = React.useId().replace(/:/g, "");
|
|
80
|
-
const reducedMotion = useReducedMotion();
|
|
81
|
-
const animated = !reducedMotion;
|
|
82
79
|
|
|
83
80
|
const resolved = resolveSeries(series, paletteColors, theme);
|
|
84
81
|
const stacked = variant === "stacked" || variant === "expand";
|
|
@@ -304,7 +301,7 @@ function AreaChart({
|
|
|
304
301
|
fill={fillFor(entry, slot)}
|
|
305
302
|
dot={false}
|
|
306
303
|
activeDot={activeDotFor(entry)}
|
|
307
|
-
isAnimationActive={
|
|
304
|
+
isAnimationActive={false}
|
|
308
305
|
animationDuration={650}
|
|
309
306
|
animationEasing="ease-out"
|
|
310
307
|
>
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
YAxis,
|
|
16
16
|
} from "recharts";
|
|
17
17
|
|
|
18
|
-
import { useReducedMotion } from "../hooks/use-reduced-motion";
|
|
19
18
|
import { type ChartSeries, makeXAxisTick, orderByLuminance, resolveSeries } from "../lib/chart";
|
|
20
19
|
import type { ChartPaletteName } from "../lib/chart-palette";
|
|
21
20
|
import { cn } from "../lib/cn";
|
|
@@ -68,8 +67,6 @@ function BarChart({
|
|
|
68
67
|
}: BarChartProps) {
|
|
69
68
|
const { palette: paletteColors, theme } = useChartContext(palette);
|
|
70
69
|
const reactId = React.useId().replace(/:/g, "");
|
|
71
|
-
const reducedMotion = useReducedMotion();
|
|
72
|
-
const animated = !reducedMotion;
|
|
73
70
|
|
|
74
71
|
const resolved = resolveSeries(series, paletteColors, theme);
|
|
75
72
|
const stacked = variant === "stacked" || variant === "expand";
|
|
@@ -272,7 +269,7 @@ function BarChart({
|
|
|
272
269
|
radius={radiusFor(slot)}
|
|
273
270
|
maxBarSize={MAX_BAR_SIZE}
|
|
274
271
|
activeBar={{ fillOpacity: 1, stroke: theme.card, strokeWidth: 1 }}
|
|
275
|
-
isAnimationActive={
|
|
272
|
+
isAnimationActive={false}
|
|
276
273
|
animationDuration={650}
|
|
277
274
|
animationEasing="ease-out"
|
|
278
275
|
>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
|
|
5
|
-
import { useReducedMotion } from "../hooks/use-reduced-motion";
|
|
6
5
|
import { formatShare } from "../lib/chart";
|
|
7
6
|
import type { ChartPaletteName } from "../lib/chart-palette";
|
|
8
7
|
import { rampColor } from "../lib/chart-palette";
|
|
@@ -47,14 +46,8 @@ function BarList({
|
|
|
47
46
|
}: BarListProps) {
|
|
48
47
|
const { paletteName, theme } = useChartContext(palette);
|
|
49
48
|
const accent = semantic ? theme[SEMANTIC_KEY[semantic]] : null;
|
|
50
|
-
const reducedMotion = useReducedMotion();
|
|
51
|
-
const [mounted, setMounted] = React.useState(false);
|
|
52
49
|
const [active, setActive] = React.useState<number | null>(null);
|
|
53
50
|
|
|
54
|
-
React.useEffect(() => {
|
|
55
|
-
setMounted(true);
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
51
|
const total = React.useMemo(() => data.reduce((sum, row) => sum + (Number(row[dataKey]) || 0), 0), [data, dataKey]);
|
|
59
52
|
|
|
60
53
|
const rows = React.useMemo(() => {
|
|
@@ -113,7 +106,7 @@ function BarList({
|
|
|
113
106
|
<div data-slot="bar-list" className={cn("flex w-full flex-col", className)}>
|
|
114
107
|
{rows.map((row, slot) => {
|
|
115
108
|
const fraction = maxValue > 0 ? row.value / maxValue : 0;
|
|
116
|
-
const fillWidth =
|
|
109
|
+
const fillWidth = `${fraction * 100}%`;
|
|
117
110
|
const dimmed = active !== null && active !== slot;
|
|
118
111
|
const isActive = active === slot;
|
|
119
112
|
return (
|
|
@@ -135,7 +128,6 @@ function BarList({
|
|
|
135
128
|
background: `linear-gradient(90deg, ${row.color}, color-mix(in oklab, ${row.color} 82%, transparent))`,
|
|
136
129
|
boxShadow: `inset 0 0 0 1px ${row.color}`,
|
|
137
130
|
opacity: dimmed ? 0.45 : 1,
|
|
138
|
-
transition: reducedMotion ? undefined : "width 700ms ease-out",
|
|
139
131
|
}}
|
|
140
132
|
>
|
|
141
133
|
<span
|
|
@@ -41,10 +41,10 @@ function ChartTooltipContent({
|
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
);
|
|
44
|
+
const toNumber = (value: ChartTooltipItem["value"]) => (typeof value === "number" ? value : Number(value ?? 0));
|
|
45
|
+
const total = payload.reduce((sum, item) => sum + toNumber(item.value), 0);
|
|
46
|
+
|
|
47
|
+
const rows = [...payload].sort((lower, upper) => toNumber(upper.value) - toNumber(lower.value));
|
|
48
48
|
|
|
49
49
|
return (
|
|
50
50
|
<div
|
|
@@ -60,13 +60,13 @@ function ChartTooltipContent({
|
|
|
60
60
|
</p>
|
|
61
61
|
)}
|
|
62
62
|
<div className="flex flex-col gap-1">
|
|
63
|
-
{
|
|
63
|
+
{rows.map((item, index) => {
|
|
64
64
|
const swatch =
|
|
65
65
|
[item.color, item.stroke, item.fill].find(
|
|
66
66
|
(candidate): candidate is string =>
|
|
67
67
|
typeof candidate === "string" && candidate.length > 0 && !candidate.startsWith("url("),
|
|
68
68
|
) ?? theme.mutedForeground;
|
|
69
|
-
const numeric =
|
|
69
|
+
const numeric = toNumber(item.value);
|
|
70
70
|
return (
|
|
71
71
|
<div key={`${item.dataKey ?? index}`} className="flex items-center justify-between gap-4 text-text-xs">
|
|
72
72
|
<span className="inline-flex items-center gap-2 text-muted-foreground">
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Cell, Pie, PieChart as RechartsPieChart, ResponsiveContainer } from "recharts";
|
|
5
5
|
|
|
6
|
-
import { useReducedMotion } from "../hooks/use-reduced-motion";
|
|
7
6
|
import { formatShare } from "../lib/chart";
|
|
8
7
|
import type { ChartPaletteName } from "../lib/chart-palette";
|
|
9
8
|
import { paletteColor } from "../lib/chart-palette";
|
|
@@ -48,8 +47,6 @@ function DonutChart({
|
|
|
48
47
|
}: DonutChartProps) {
|
|
49
48
|
const { palette: paletteColors, theme } = useChartContext(palette);
|
|
50
49
|
const reactId = React.useId().replace(/:/g, "");
|
|
51
|
-
const reducedMotion = useReducedMotion();
|
|
52
|
-
const animated = !reducedMotion;
|
|
53
50
|
const [active, setActive] = React.useState<number | null>(null);
|
|
54
51
|
const rowRefs = React.useRef<Array<HTMLDivElement | null>>([]);
|
|
55
52
|
|
|
@@ -121,7 +118,7 @@ function DonutChart({
|
|
|
121
118
|
cornerRadius={2}
|
|
122
119
|
stroke={theme.card}
|
|
123
120
|
strokeWidth={1.5}
|
|
124
|
-
isAnimationActive={
|
|
121
|
+
isAnimationActive={false}
|
|
125
122
|
animationDuration={650}
|
|
126
123
|
animationEasing="ease-out"
|
|
127
124
|
onMouseEnter={(_entry, sliceIndex) => setActive(sliceIndex)}
|
package/src/components/form.tsx
CHANGED
|
@@ -78,10 +78,12 @@ const FormItemContext = React.createContext<FormItemContextValue>({} as FormItem
|
|
|
78
78
|
|
|
79
79
|
function FormItem({ className, ...props }: React.ComponentProps<"div">) {
|
|
80
80
|
const id = React.useId();
|
|
81
|
+
const { name } = React.useContext(FormFieldContext);
|
|
81
82
|
|
|
82
83
|
return (
|
|
83
84
|
<FormItemContext.Provider value={{ id }}>
|
|
84
|
-
|
|
85
|
+
{/* Expose the field name as generic metadata so hosts can react to focus without per-field wiring. */}
|
|
86
|
+
<div data-slot="form-item" data-field-name={name} className={cn("grid gap-2", className)} {...props} />
|
|
85
87
|
</FormItemContext.Provider>
|
|
86
88
|
);
|
|
87
89
|
}
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
YAxis,
|
|
16
16
|
} from "recharts";
|
|
17
17
|
|
|
18
|
-
import { useReducedMotion } from "../hooks/use-reduced-motion";
|
|
19
18
|
import { type ChartSeries, makeXAxisTick, resolveSeries } from "../lib/chart";
|
|
20
19
|
import type { ChartPaletteName } from "../lib/chart-palette";
|
|
21
20
|
import { cn } from "../lib/cn";
|
|
@@ -68,8 +67,6 @@ function LineChart({
|
|
|
68
67
|
className,
|
|
69
68
|
}: LineChartProps) {
|
|
70
69
|
const { palette: paletteColors, theme } = useChartContext(palette);
|
|
71
|
-
const reducedMotion = useReducedMotion();
|
|
72
|
-
const animated = !reducedMotion;
|
|
73
70
|
|
|
74
71
|
const resolved = resolveSeries(series, paletteColors, theme);
|
|
75
72
|
|
|
@@ -234,7 +231,7 @@ function LineChart({
|
|
|
234
231
|
strokeDasharray={entry.dashed ? "5 3" : undefined}
|
|
235
232
|
dot={dots ? { r: 2.5, fill: entry.color, strokeWidth: 0 } : false}
|
|
236
233
|
activeDot={activeDotFor(entry)}
|
|
237
|
-
isAnimationActive={
|
|
234
|
+
isAnimationActive={false}
|
|
238
235
|
animationDuration={650}
|
|
239
236
|
animationEasing="ease-out"
|
|
240
237
|
>
|
package/src/lib/chart-palette.ts
CHANGED
|
@@ -15,25 +15,25 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
export const MAGENTA_PALETTE = [
|
|
18
|
-
"#
|
|
19
|
-
"#
|
|
20
|
-
"#
|
|
21
|
-
"#
|
|
22
|
-
"#
|
|
23
|
-
"#
|
|
24
|
-
"#
|
|
25
|
-
"#
|
|
18
|
+
"#da1b6a",
|
|
19
|
+
"#ec82b0",
|
|
20
|
+
"#9a67d7",
|
|
21
|
+
"#668fdf",
|
|
22
|
+
"#47bde0",
|
|
23
|
+
"#75ddd8",
|
|
24
|
+
"#cd8c4d",
|
|
25
|
+
"#3eb0a1",
|
|
26
26
|
] as const;
|
|
27
27
|
|
|
28
28
|
export const CYAN_PALETTE = [
|
|
29
|
-
"#
|
|
30
|
-
"#
|
|
31
|
-
"#
|
|
32
|
-
"#
|
|
33
|
-
"#
|
|
34
|
-
"#
|
|
35
|
-
"#
|
|
36
|
-
"#
|
|
29
|
+
"#2eb2c5",
|
|
30
|
+
"#50d0c0",
|
|
31
|
+
"#4f90e0",
|
|
32
|
+
"#8d74e0",
|
|
33
|
+
"#bc73e0",
|
|
34
|
+
"#ec82b0",
|
|
35
|
+
"#da1b6a",
|
|
36
|
+
"#c08dd3",
|
|
37
37
|
] as const;
|
|
38
38
|
|
|
39
39
|
export type ChartPaletteName = "magenta" | "cyan";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import * as React$1 from "react";
|
|
3
|
-
//#region src/hooks/use-reduced-motion.ts
|
|
4
|
-
function useReducedMotion() {
|
|
5
|
-
const [reduced, setReduced] = React$1.useState(false);
|
|
6
|
-
React$1.useEffect(() => {
|
|
7
|
-
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
8
|
-
const update = () => setReduced(query.matches);
|
|
9
|
-
update();
|
|
10
|
-
query.addEventListener("change", update);
|
|
11
|
-
return () => query.removeEventListener("change", update);
|
|
12
|
-
}, []);
|
|
13
|
-
return reduced;
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
export { useReducedMotion };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
export function useReducedMotion() {
|
|
6
|
-
const [reduced, setReduced] = React.useState(false);
|
|
7
|
-
|
|
8
|
-
React.useEffect(() => {
|
|
9
|
-
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
10
|
-
const update = () => setReduced(query.matches);
|
|
11
|
-
update();
|
|
12
|
-
query.addEventListener("change", update);
|
|
13
|
-
return () => query.removeEventListener("change", update);
|
|
14
|
-
}, []);
|
|
15
|
-
|
|
16
|
-
return reduced;
|
|
17
|
-
}
|