@codefast/ui 0.3.11-canary.1 → 0.3.11
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/CHANGELOG.md +36 -0
- package/README.md +34 -14
- package/dist/components/accordion.d.ts +29 -10
- package/dist/components/accordion.js +38 -37
- package/dist/components/alert-dialog.d.ts +60 -24
- package/dist/components/alert-dialog.js +69 -72
- package/dist/components/alert.d.ts +27 -15
- package/dist/components/alert.js +29 -31
- package/dist/components/aspect-ratio.d.ts +8 -4
- package/dist/components/aspect-ratio.js +7 -5
- package/dist/components/avatar.d.ts +17 -6
- package/dist/components/avatar.js +19 -17
- package/dist/components/badge.d.ts +21 -14
- package/dist/components/badge.js +19 -22
- package/dist/components/breadcrumb.d.ts +35 -12
- package/dist/components/breadcrumb.js +48 -54
- package/dist/components/button-group.d.ts +29 -14
- package/dist/components/button-group.js +27 -32
- package/dist/components/button.d.ts +35 -25
- package/dist/components/button.js +50 -48
- package/dist/components/calendar.d.ts +24 -9
- package/dist/components/calendar.js +92 -98
- package/dist/components/card.d.ts +34 -10
- package/dist/components/card.js +39 -37
- package/dist/components/carousel.d.ts +55 -24
- package/dist/components/carousel.js +113 -130
- package/dist/components/chart.d.ts +72 -36
- package/dist/components/chart.js +154 -166
- package/dist/components/checkbox-cards.d.ts +15 -8
- package/dist/components/checkbox-cards.js +22 -25
- package/dist/components/checkbox-group.d.ts +16 -8
- package/dist/components/checkbox-group.js +19 -19
- package/dist/components/checkbox.d.ts +9 -4
- package/dist/components/checkbox.js +14 -14
- package/dist/components/collapsible.d.ts +14 -6
- package/dist/components/collapsible.js +18 -16
- package/dist/components/command.d.ts +55 -23
- package/dist/components/command.js +70 -85
- package/dist/components/context-menu.d.ts +72 -22
- package/dist/components/context-menu.js +88 -109
- package/dist/components/dialog.d.ts +53 -22
- package/dist/components/dialog.js +71 -85
- package/dist/components/drawer.d.ts +60 -28
- package/dist/components/drawer.js +59 -67
- package/dist/components/dropdown-menu.d.ts +73 -22
- package/dist/components/dropdown-menu.js +95 -112
- package/dist/components/empty.d.ts +37 -15
- package/dist/components/empty.js +43 -45
- package/dist/components/field.d.ts +63 -25
- package/dist/components/field.js +88 -104
- package/dist/components/form.d.ts +37 -15
- package/dist/components/form.js +65 -70
- package/dist/components/hover-card.d.ts +21 -7
- package/dist/components/hover-card.js +24 -24
- package/dist/components/input-group.d.ts +53 -28
- package/dist/components/input-group.js +63 -77
- package/dist/components/input-number.d.ts +28 -7
- package/dist/components/input-number.js +55 -59
- package/dist/components/input-otp.d.ts +24 -10
- package/dist/components/input-otp.js +33 -37
- package/dist/components/input-password.d.ts +12 -5
- package/dist/components/input-password.js +31 -32
- package/dist/components/input-search.d.ts +18 -8
- package/dist/components/input-search.js +43 -41
- package/dist/components/input.d.ts +10 -4
- package/dist/components/input.js +9 -7
- package/dist/components/item.d.ts +69 -32
- package/dist/components/item.js +89 -92
- package/dist/components/kbd.d.ts +13 -5
- package/dist/components/kbd.js +13 -11
- package/dist/components/label.d.ts +9 -4
- package/dist/components/label.js +9 -7
- package/dist/components/menubar.d.ts +80 -23
- package/dist/components/menubar.js +97 -118
- package/dist/components/native-select.d.ts +16 -6
- package/dist/components/native-select.js +25 -26
- package/dist/components/navigation-menu.d.ts +36 -12
- package/dist/components/navigation-menu.js +60 -75
- package/dist/components/pagination.d.ts +35 -14
- package/dist/components/pagination.js +54 -69
- package/dist/components/popover.d.ts +24 -8
- package/dist/components/popover.js +28 -28
- package/dist/components/progress-circle.d.ts +106 -88
- package/dist/components/progress-circle.js +106 -138
- package/dist/components/progress.d.ts +10 -4
- package/dist/components/progress.js +14 -14
- package/dist/components/radio-cards.d.ts +10 -4
- package/dist/components/radio-cards.js +22 -23
- package/dist/components/radio-group.d.ts +13 -5
- package/dist/components/radio-group.js +18 -16
- package/dist/components/radio.d.ts +12 -5
- package/dist/components/radio.js +10 -8
- package/dist/components/resizable.d.ts +18 -7
- package/dist/components/resizable.js +22 -22
- package/dist/components/scroll-area.d.ts +33 -20
- package/dist/components/scroll-area.js +84 -88
- package/dist/components/select.d.ts +50 -16
- package/dist/components/select.js +77 -96
- package/dist/components/separator.d.ts +29 -19
- package/dist/components/separator.js +36 -34
- package/dist/components/sheet.d.ts +62 -29
- package/dist/components/sheet.js +79 -100
- package/dist/components/sidebar.d.ts +160 -66
- package/dist/components/sidebar.js +294 -336
- package/dist/components/skeleton.d.ts +9 -4
- package/dist/components/skeleton.js +8 -6
- package/dist/components/slider.d.ts +13 -4
- package/dist/components/slider.js +34 -40
- package/dist/components/sonner.d.ts +10 -7
- package/dist/components/sonner.js +16 -14
- package/dist/components/spinner.d.ts +12 -5
- package/dist/components/spinner.js +33 -35
- package/dist/components/switch.d.ts +9 -4
- package/dist/components/switch.js +13 -11
- package/dist/components/table.d.ts +37 -11
- package/dist/components/table.js +47 -45
- package/dist/components/tabs.d.ts +21 -7
- package/dist/components/tabs.js +24 -22
- package/dist/components/textarea.d.ts +9 -4
- package/dist/components/textarea.js +8 -6
- package/dist/components/toggle-group.d.ts +24 -9
- package/dist/components/toggle-group.js +41 -42
- package/dist/components/toggle.d.ts +25 -17
- package/dist/components/toggle.js +30 -28
- package/dist/components/tooltip.d.ts +24 -8
- package/dist/components/tooltip.js +29 -32
- package/dist/hooks/use-animated-value.d.ts +4 -1
- package/dist/hooks/use-animated-value.js +57 -36
- package/dist/hooks/use-copy-to-clipboard.d.ts +11 -5
- package/dist/hooks/use-copy-to-clipboard.js +39 -20
- package/dist/hooks/use-is-mobile.d.ts +4 -1
- package/dist/hooks/use-is-mobile.js +21 -1
- package/dist/hooks/use-media-query.d.ts +4 -1
- package/dist/hooks/use-media-query.js +45 -18
- package/dist/hooks/use-mutation-observer.d.ts +6 -2
- package/dist/hooks/use-mutation-observer.js +34 -16
- package/dist/hooks/use-pagination.d.ts +22 -14
- package/dist/hooks/use-pagination.js +100 -49
- package/dist/index.d.ts +69 -130
- package/dist/index.js +11 -11
- package/dist/primitives/checkbox-group.d.ts +105 -83
- package/dist/primitives/checkbox-group.js +111 -84
- package/dist/primitives/input-number.d.ts +51 -40
- package/dist/primitives/input-number.js +483 -350
- package/dist/primitives/input.d.ts +48 -42
- package/dist/primitives/input.js +65 -43
- package/dist/primitives/progress-circle.d.ts +79 -48
- package/dist/primitives/progress-circle.js +154 -105
- package/package.json +6 -7
package/dist/components/chart.js
CHANGED
|
@@ -1,199 +1,187 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { cn } from "@codefast/tailwind-variants";
|
|
4
|
-
import {
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
4
|
import { useId, useMemo } from "react";
|
|
6
|
-
import {
|
|
5
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
6
|
+
import * as RechartsPrimitive from "recharts";
|
|
7
|
+
//#region src/components/chart.tsx
|
|
7
8
|
const THEMES = {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
dark: ".dark",
|
|
10
|
+
light: ""
|
|
10
11
|
};
|
|
11
12
|
const CHART_PROVIDER_NAME = "ChartProvider";
|
|
12
13
|
const [createChartContext, createChartScope] = createContextScope(CHART_PROVIDER_NAME);
|
|
13
14
|
const [ChartContextProvider, useChartContext] = createChartContext(CHART_PROVIDER_NAME);
|
|
14
15
|
function ChartContainer({ __scopeChart, children, className, config, id, ...props }) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
children: children
|
|
32
|
-
})
|
|
33
|
-
]
|
|
34
|
-
})
|
|
35
|
-
});
|
|
16
|
+
const uniqueId = useId();
|
|
17
|
+
const chartId = `chart-${id ?? uniqueId}`;
|
|
18
|
+
return /* @__PURE__ */ jsx(ChartContextProvider, {
|
|
19
|
+
config,
|
|
20
|
+
scope: __scopeChart,
|
|
21
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
22
|
+
className: cn("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", className),
|
|
23
|
+
"data-chart": chartId,
|
|
24
|
+
"data-slot": "chart",
|
|
25
|
+
...props,
|
|
26
|
+
children: [/* @__PURE__ */ jsx(ChartStyle, {
|
|
27
|
+
config,
|
|
28
|
+
id: chartId
|
|
29
|
+
}), /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { children })]
|
|
30
|
+
})
|
|
31
|
+
});
|
|
36
32
|
}
|
|
37
33
|
function ChartStyle({ config, id }) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
dangerouslySetInnerHTML: {
|
|
42
|
-
__html: generateChartStyles(id, colorConfig)
|
|
43
|
-
}
|
|
44
|
-
});
|
|
34
|
+
const colorConfig = Object.entries(config).filter(([, itemConfig]) => itemConfig.theme ?? itemConfig.color);
|
|
35
|
+
if (colorConfig.length === 0) return null;
|
|
36
|
+
return /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: generateChartStyles(id, colorConfig) } });
|
|
45
37
|
}
|
|
46
|
-
const ChartTooltip = Tooltip;
|
|
38
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
47
39
|
const CHART_TOOLTIP_CONTENT_NAME = "ChartTooltipContent";
|
|
48
40
|
function ChartTooltipContent({ __scopeChart, active, className, color, formatter, hideIndicator = false, hideLabel = false, indicator = "dot", label, labelClassName, labelFormatter, labelKey, nameKey, payload = [] }) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
children: itemConfig?.label ?? item.name
|
|
114
|
-
})
|
|
115
|
-
]
|
|
116
|
-
}),
|
|
117
|
-
null != item.value && /*#__PURE__*/ jsx("span", {
|
|
118
|
-
className: "font-mono font-medium text-foreground tabular-nums",
|
|
119
|
-
children: "number" == typeof item.value ? item.value.toLocaleString() : safeToString(item.value)
|
|
120
|
-
})
|
|
121
|
-
]
|
|
122
|
-
})
|
|
123
|
-
]
|
|
124
|
-
})
|
|
125
|
-
}, key);
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
]
|
|
129
|
-
});
|
|
41
|
+
const { config } = useChartContext(CHART_TOOLTIP_CONTENT_NAME, __scopeChart);
|
|
42
|
+
const tooltipLabel = useMemo(() => {
|
|
43
|
+
if (hideLabel || payload.length === 0) return null;
|
|
44
|
+
const [item] = payload;
|
|
45
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, safeToString(labelKey ?? item.dataKey ?? item.name ?? "value"));
|
|
46
|
+
const value = !labelKey && typeof label === "string" ? label in config ? config[label].label ?? label : label : itemConfig?.label;
|
|
47
|
+
if (labelFormatter) return /* @__PURE__ */ jsx("div", {
|
|
48
|
+
className: cn("font-medium", labelClassName),
|
|
49
|
+
children: labelFormatter(value, payload)
|
|
50
|
+
});
|
|
51
|
+
if (!value) return null;
|
|
52
|
+
return /* @__PURE__ */ jsx("div", {
|
|
53
|
+
className: cn("font-medium", labelClassName),
|
|
54
|
+
children: value
|
|
55
|
+
});
|
|
56
|
+
}, [
|
|
57
|
+
label,
|
|
58
|
+
labelFormatter,
|
|
59
|
+
payload,
|
|
60
|
+
hideLabel,
|
|
61
|
+
labelClassName,
|
|
62
|
+
config,
|
|
63
|
+
labelKey
|
|
64
|
+
]);
|
|
65
|
+
if (!active || payload.length === 0) return null;
|
|
66
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
67
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
68
|
+
className: cn("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl", className),
|
|
69
|
+
children: [nestLabel ? null : tooltipLabel, /* @__PURE__ */ jsx("div", {
|
|
70
|
+
className: "grid gap-1.5",
|
|
71
|
+
children: payload.map((item, index) => {
|
|
72
|
+
const key = safeToString(nameKey ?? item.name ?? item.dataKey ?? "value");
|
|
73
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
74
|
+
const indicatorColor = color ?? (isRecord(item.payload) && "fill" in item.payload && typeof item.payload.fill === "string" ? item.payload.fill : void 0) ?? item.color;
|
|
75
|
+
return /* @__PURE__ */ jsx("div", {
|
|
76
|
+
className: cn("flex w-full flex-wrap items-stretch gap-2 [&>svg]:size-2.5 [&>svg]:text-muted-foreground", indicator === "dot" && "items-center"),
|
|
77
|
+
children: formatter && item.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, [item]) : /* @__PURE__ */ jsxs(Fragment, { children: [itemConfig?.icon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx("div", {
|
|
78
|
+
className: cn("shrink-0 rounded-xs border-(--color-border) bg-(--color-bg)", {
|
|
79
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
80
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
81
|
+
"border-1.5 w-0 border-dashed bg-transparent": indicator === "dashed",
|
|
82
|
+
"w-1": indicator === "line"
|
|
83
|
+
}),
|
|
84
|
+
style: {
|
|
85
|
+
"--color-bg": indicatorColor,
|
|
86
|
+
"--color-border": indicatorColor
|
|
87
|
+
}
|
|
88
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
89
|
+
className: cn("flex flex-1 justify-between leading-none", nestLabel ? "items-end" : "items-center"),
|
|
90
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
91
|
+
className: "grid gap-1.5",
|
|
92
|
+
children: [nestLabel ? tooltipLabel : null, /* @__PURE__ */ jsx("span", {
|
|
93
|
+
className: "text-muted-foreground",
|
|
94
|
+
children: itemConfig?.label ?? item.name
|
|
95
|
+
})]
|
|
96
|
+
}), item.value != null && /* @__PURE__ */ jsx("span", {
|
|
97
|
+
className: "font-mono font-medium text-foreground tabular-nums",
|
|
98
|
+
children: typeof item.value === "number" ? item.value.toLocaleString() : safeToString(item.value)
|
|
99
|
+
})]
|
|
100
|
+
})] })
|
|
101
|
+
}, key);
|
|
102
|
+
})
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
130
105
|
}
|
|
131
|
-
const ChartLegend = Legend;
|
|
106
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
132
107
|
const CHART_LEGEND_CONTENT_NAME = "ChartLegendContent";
|
|
133
108
|
function ChartLegendContent({ __scopeChart, className, hideIcon = false, nameKey, payload, verticalAlign = "bottom" }) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
itemConfig?.label
|
|
153
|
-
]
|
|
154
|
-
}, nameKey ? safeToString(itemConfig?.color ?? "") : safeToString(item.value ?? ""));
|
|
155
|
-
})
|
|
156
|
-
});
|
|
109
|
+
const { config } = useChartContext(CHART_LEGEND_CONTENT_NAME, __scopeChart);
|
|
110
|
+
if (!payload?.length) return null;
|
|
111
|
+
return /* @__PURE__ */ jsx("div", {
|
|
112
|
+
className: cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className),
|
|
113
|
+
children: payload.map((item) => {
|
|
114
|
+
let key = "value";
|
|
115
|
+
if (nameKey) key = nameKey;
|
|
116
|
+
else if (item.dataKey != null) key = safeToString(item.dataKey);
|
|
117
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
118
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
119
|
+
className: cn("flex items-center gap-1.5 [&>svg]:size-3 [&>svg]:text-muted-foreground"),
|
|
120
|
+
children: [itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx("div", {
|
|
121
|
+
className: "size-2 shrink-0 rounded-md",
|
|
122
|
+
style: { backgroundColor: item.color }
|
|
123
|
+
}), itemConfig?.label]
|
|
124
|
+
}, nameKey ? safeToString(itemConfig?.color ?? "") : safeToString(item.value ?? ""));
|
|
125
|
+
})
|
|
126
|
+
});
|
|
157
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Type guard to check if an unknown value is a record with string keys
|
|
130
|
+
*/
|
|
158
131
|
function isRecord(value) {
|
|
159
|
-
|
|
132
|
+
return typeof value === "object" && value !== null;
|
|
160
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Safely gets a string value from a record by key
|
|
136
|
+
*/
|
|
161
137
|
function getStringValue(record, key) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
138
|
+
if (key in record) {
|
|
139
|
+
const value = record[key];
|
|
140
|
+
return typeof value === "string" ? value : void 0;
|
|
141
|
+
}
|
|
166
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Safely converts a value to string without type coercion
|
|
145
|
+
*/
|
|
167
146
|
function safeToString(value) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
147
|
+
if (typeof value === "string") return value;
|
|
148
|
+
if (typeof value === "number") return value.toString();
|
|
149
|
+
if (value === null || value === void 0) return "";
|
|
150
|
+
if (typeof value === "boolean") return value.toString();
|
|
151
|
+
if (typeof value === "bigint") return value.toString();
|
|
152
|
+
if (typeof value === "symbol") return value.toString();
|
|
153
|
+
return "";
|
|
175
154
|
}
|
|
176
155
|
function getPayloadConfigFromPayload(config, payload, key) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
156
|
+
if (!isRecord(payload)) return;
|
|
157
|
+
const payloadPayload = isRecord(payload.payload) ? payload.payload : void 0;
|
|
158
|
+
let configLabelKey = key;
|
|
159
|
+
const payloadValue = getStringValue(payload, key);
|
|
160
|
+
if (payloadValue) configLabelKey = payloadValue;
|
|
161
|
+
else if (payloadPayload) {
|
|
162
|
+
const nestedValue = getStringValue(payloadPayload, key);
|
|
163
|
+
if (nestedValue) configLabelKey = nestedValue;
|
|
164
|
+
}
|
|
165
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
187
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Generates CSS custom property for a specific theme and config item
|
|
169
|
+
*/
|
|
188
170
|
function generateCssVariable(key, itemConfig, theme) {
|
|
189
|
-
|
|
190
|
-
|
|
171
|
+
const color = itemConfig.theme?.[theme] ?? itemConfig.color;
|
|
172
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
191
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Generates CSS rules for a specific theme
|
|
176
|
+
*/
|
|
192
177
|
function generateThemeStyles(theme, prefix, id, colorConfig) {
|
|
193
|
-
|
|
194
|
-
return `${prefix} [data-chart=${id}] {\n${cssVariables}\n}`;
|
|
178
|
+
return `${prefix} [data-chart=${id}] {\n${colorConfig.map(([key, itemConfig]) => generateCssVariable(key, itemConfig, theme)).filter(Boolean).join("\n")}\n}`;
|
|
195
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Generates complete CSS styles for all themes
|
|
182
|
+
*/
|
|
196
183
|
function generateChartStyles(id, colorConfig) {
|
|
197
|
-
|
|
184
|
+
return Object.entries(THEMES).map(([theme, prefix]) => generateThemeStyles(theme, prefix, id, colorConfig)).join("\n\n");
|
|
198
185
|
}
|
|
186
|
+
//#endregion
|
|
199
187
|
export { ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, createChartScope };
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { CheckboxGroup, CheckboxGroupItem } from "../primitives/checkbox-group.js";
|
|
2
|
+
import { ComponentProps, JSX } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/checkbox-cards.d.ts
|
|
5
|
+
type CheckboxCardsProps = ComponentProps<typeof CheckboxGroup>;
|
|
4
6
|
declare function CheckboxCards(props: CheckboxCardsProps): JSX.Element;
|
|
5
|
-
interface CheckboxCardsItemProps extends ComponentProps<typeof
|
|
6
|
-
|
|
7
|
+
interface CheckboxCardsItemProps extends ComponentProps<typeof CheckboxGroupItem> {
|
|
8
|
+
checkboxClassName?: string;
|
|
7
9
|
}
|
|
8
|
-
declare function CheckboxCardsItem({
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
declare function CheckboxCardsItem({
|
|
11
|
+
checkboxClassName,
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
...props
|
|
15
|
+
}: CheckboxCardsItemProps): JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { CheckboxCards, CheckboxCardsItem, type CheckboxCardsItemProps, type CheckboxCardsProps };
|
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { Label } from "./label.js";
|
|
3
|
+
import { CheckboxGroup, CheckboxGroupIndicator, CheckboxGroupItem } from "../primitives/checkbox-group.js";
|
|
3
4
|
import { cn } from "@codefast/tailwind-variants";
|
|
4
5
|
import { CheckIcon } from "lucide-react";
|
|
5
|
-
import {
|
|
6
|
-
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/checkbox-cards.tsx
|
|
7
8
|
function CheckboxCards(props) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
return /* @__PURE__ */ jsx(CheckboxGroup, {
|
|
10
|
+
"data-slot": "checkbox-cards",
|
|
11
|
+
...props
|
|
12
|
+
});
|
|
12
13
|
}
|
|
13
14
|
function CheckboxCardsItem({ checkboxClassName, children, className, ...props }) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
}),
|
|
29
|
-
children
|
|
30
|
-
]
|
|
31
|
-
});
|
|
15
|
+
return /* @__PURE__ */ jsxs(Label, {
|
|
16
|
+
className: cn("flex items-start gap-3 rounded-lg border border-input p-3 transition hover:not-has-disabled:not-has-aria-checked:bg-secondary has-focus-visible:border-ring has-disabled:opacity-50 has-aria-checked:border-primary has-aria-checked:bg-primary/10", className),
|
|
17
|
+
"data-slot": "checkbox-card",
|
|
18
|
+
children: [/* @__PURE__ */ jsx(CheckboxGroupItem, {
|
|
19
|
+
className: cn("peer flex size-4 shrink-0 rounded-sm border border-input text-primary-foreground shadow-xs outline-hidden transition focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-checked:border-primary aria-checked:bg-primary focus-visible:aria-checked:ring-primary/20 dark:bg-input/30 dark:focus-visible:aria-checked:ring-primary/40", checkboxClassName),
|
|
20
|
+
"data-slot": "checkbox-card-item",
|
|
21
|
+
...props,
|
|
22
|
+
children: /* @__PURE__ */ jsx(CheckboxGroupIndicator, {
|
|
23
|
+
"data-slot": "checkbox-card-indicator",
|
|
24
|
+
children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-3.5" })
|
|
25
|
+
})
|
|
26
|
+
}), children]
|
|
27
|
+
});
|
|
32
28
|
}
|
|
29
|
+
//#endregion
|
|
33
30
|
export { CheckboxCards, CheckboxCardsItem };
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
declare function
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { CheckboxGroup as CheckboxGroup$1, CheckboxGroupItem as CheckboxGroupItem$1 } from "../primitives/checkbox-group.js";
|
|
2
|
+
import { ComponentProps, JSX } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/checkbox-group.d.ts
|
|
5
|
+
type CheckboxGroupProps = ComponentProps<typeof CheckboxGroup$1>;
|
|
6
|
+
declare function CheckboxGroup({
|
|
7
|
+
className,
|
|
8
|
+
...props
|
|
9
|
+
}: CheckboxGroupProps): JSX.Element;
|
|
10
|
+
type CheckboxGroupItemProps = ComponentProps<typeof CheckboxGroupItem$1>;
|
|
11
|
+
declare function CheckboxGroupItem({
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}: CheckboxGroupItemProps): JSX.Element;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { CheckboxGroup, CheckboxGroupItem, type CheckboxGroupItemProps, type CheckboxGroupProps };
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { CheckboxGroup as CheckboxGroup$1, CheckboxGroupIndicator, CheckboxGroupItem as CheckboxGroupItem$1 } from "../primitives/checkbox-group.js";
|
|
3
3
|
import { cn } from "@codefast/tailwind-variants";
|
|
4
4
|
import { CheckIcon } from "lucide-react";
|
|
5
|
-
import {
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/checkbox-group.tsx
|
|
6
7
|
function CheckboxGroup({ className, ...props }) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
return /* @__PURE__ */ jsx(CheckboxGroup$1, {
|
|
9
|
+
className: cn("grid gap-2", className),
|
|
10
|
+
"data-slot": "checkbox-group",
|
|
11
|
+
...props
|
|
12
|
+
});
|
|
12
13
|
}
|
|
13
14
|
function CheckboxGroupItem({ className, ...props }) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
-
});
|
|
15
|
+
return /* @__PURE__ */ jsx(CheckboxGroupItem$1, {
|
|
16
|
+
className: cn("peer flex size-4 shrink-0 items-center justify-center rounded-sm border border-input text-primary-foreground shadow-xs outline-hidden transition hover:not-disabled:not-aria-checked:border-ring/60 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50 aria-checked:border-primary aria-checked:bg-primary focus-visible:aria-checked:ring-primary/20 aria-invalid:border-destructive aria-invalid:ring-destructive/20 hover:not-disabled:not-aria-checked:aria-invalid:border-destructive/60 aria-checked:aria-invalid:bg-destructive dark:bg-input/30 dark:focus-visible:aria-checked:ring-primary/40 dark:aria-invalid:ring-destructive/40", className),
|
|
17
|
+
"data-slot": "checkbox-group-item",
|
|
18
|
+
...props,
|
|
19
|
+
children: /* @__PURE__ */ jsx(CheckboxGroupIndicator, {
|
|
20
|
+
className: "flex items-center justify-center text-current transition-none",
|
|
21
|
+
"data-slot": "checkbox-group-indicator",
|
|
22
|
+
children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-3.5" })
|
|
23
|
+
})
|
|
24
|
+
});
|
|
26
25
|
}
|
|
26
|
+
//#endregion
|
|
27
27
|
export { CheckboxGroup, CheckboxGroupItem };
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentProps, JSX } from "react";
|
|
2
2
|
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
3
|
+
|
|
4
|
+
//#region src/components/checkbox.d.ts
|
|
3
5
|
type CheckboxProps = ComponentProps<typeof CheckboxPrimitive.Root>;
|
|
4
|
-
declare function Checkbox({
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
declare function Checkbox({
|
|
7
|
+
className,
|
|
8
|
+
...props
|
|
9
|
+
}: CheckboxProps): JSX.Element;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Checkbox, type CheckboxProps };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
2
|
import { cn } from "@codefast/tailwind-variants";
|
|
4
|
-
import { Indicator, Root } from "@radix-ui/react-checkbox";
|
|
5
3
|
import { CheckIcon } from "lucide-react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
6
|
+
//#region src/components/checkbox.tsx
|
|
6
7
|
function Checkbox({ className, ...props }) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})
|
|
18
|
-
});
|
|
8
|
+
return /* @__PURE__ */ jsx(CheckboxPrimitive.Root, {
|
|
9
|
+
className: cn("peer flex size-4 shrink-0 items-center justify-center rounded-sm border border-input text-primary-foreground shadow-xs outline-hidden transition hover:not-disabled:not-aria-checked:border-ring/60 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50 aria-checked:border-primary aria-checked:bg-primary aria-checked:focus-visible:ring-primary/20 aria-invalid:border-destructive aria-invalid:ring-destructive/20 hover:not-disabled:not-aria-checked:aria-invalid:border-destructive/60 aria-checked:aria-invalid:bg-destructive dark:bg-input/30 dark:aria-checked:focus-visible:ring-primary/40 dark:aria-invalid:ring-destructive/40", className),
|
|
10
|
+
"data-slot": "checkbox",
|
|
11
|
+
...props,
|
|
12
|
+
children: /* @__PURE__ */ jsx(CheckboxPrimitive.Indicator, {
|
|
13
|
+
className: "flex items-center justify-center text-current transition-none",
|
|
14
|
+
"data-slot": "checkbox-indicator",
|
|
15
|
+
children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-3.5" })
|
|
16
|
+
})
|
|
17
|
+
});
|
|
19
18
|
}
|
|
19
|
+
//#endregion
|
|
20
20
|
export { Checkbox };
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentProps, JSX } from "react";
|
|
2
2
|
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
3
|
+
|
|
4
|
+
//#region src/components/collapsible.d.ts
|
|
3
5
|
type CollapsibleProps = ComponentProps<typeof CollapsiblePrimitive.Root>;
|
|
4
|
-
declare function Collapsible({
|
|
6
|
+
declare function Collapsible({
|
|
7
|
+
...props
|
|
8
|
+
}: CollapsibleProps): JSX.Element;
|
|
5
9
|
type CollapsibleTriggerProps = ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>;
|
|
6
|
-
declare function CollapsibleTrigger({
|
|
10
|
+
declare function CollapsibleTrigger({
|
|
11
|
+
...props
|
|
12
|
+
}: CollapsibleTriggerProps): JSX.Element;
|
|
7
13
|
type CollapsibleContentProps = ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>;
|
|
8
|
-
declare function CollapsibleContent({
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
declare function CollapsibleContent({
|
|
15
|
+
...props
|
|
16
|
+
}: CollapsibleContentProps): JSX.Element;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { Collapsible, CollapsibleContent, type CollapsibleContentProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps };
|