@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.
Files changed (149) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +34 -14
  3. package/dist/components/accordion.d.ts +29 -10
  4. package/dist/components/accordion.js +38 -37
  5. package/dist/components/alert-dialog.d.ts +60 -24
  6. package/dist/components/alert-dialog.js +69 -72
  7. package/dist/components/alert.d.ts +27 -15
  8. package/dist/components/alert.js +29 -31
  9. package/dist/components/aspect-ratio.d.ts +8 -4
  10. package/dist/components/aspect-ratio.js +7 -5
  11. package/dist/components/avatar.d.ts +17 -6
  12. package/dist/components/avatar.js +19 -17
  13. package/dist/components/badge.d.ts +21 -14
  14. package/dist/components/badge.js +19 -22
  15. package/dist/components/breadcrumb.d.ts +35 -12
  16. package/dist/components/breadcrumb.js +48 -54
  17. package/dist/components/button-group.d.ts +29 -14
  18. package/dist/components/button-group.js +27 -32
  19. package/dist/components/button.d.ts +35 -25
  20. package/dist/components/button.js +50 -48
  21. package/dist/components/calendar.d.ts +24 -9
  22. package/dist/components/calendar.js +92 -98
  23. package/dist/components/card.d.ts +34 -10
  24. package/dist/components/card.js +39 -37
  25. package/dist/components/carousel.d.ts +55 -24
  26. package/dist/components/carousel.js +113 -130
  27. package/dist/components/chart.d.ts +72 -36
  28. package/dist/components/chart.js +154 -166
  29. package/dist/components/checkbox-cards.d.ts +15 -8
  30. package/dist/components/checkbox-cards.js +22 -25
  31. package/dist/components/checkbox-group.d.ts +16 -8
  32. package/dist/components/checkbox-group.js +19 -19
  33. package/dist/components/checkbox.d.ts +9 -4
  34. package/dist/components/checkbox.js +14 -14
  35. package/dist/components/collapsible.d.ts +14 -6
  36. package/dist/components/collapsible.js +18 -16
  37. package/dist/components/command.d.ts +55 -23
  38. package/dist/components/command.js +70 -85
  39. package/dist/components/context-menu.d.ts +72 -22
  40. package/dist/components/context-menu.js +88 -109
  41. package/dist/components/dialog.d.ts +53 -22
  42. package/dist/components/dialog.js +71 -85
  43. package/dist/components/drawer.d.ts +60 -28
  44. package/dist/components/drawer.js +59 -67
  45. package/dist/components/dropdown-menu.d.ts +73 -22
  46. package/dist/components/dropdown-menu.js +95 -112
  47. package/dist/components/empty.d.ts +37 -15
  48. package/dist/components/empty.js +43 -45
  49. package/dist/components/field.d.ts +63 -25
  50. package/dist/components/field.js +88 -104
  51. package/dist/components/form.d.ts +37 -15
  52. package/dist/components/form.js +65 -70
  53. package/dist/components/hover-card.d.ts +21 -7
  54. package/dist/components/hover-card.js +24 -24
  55. package/dist/components/input-group.d.ts +53 -28
  56. package/dist/components/input-group.js +63 -77
  57. package/dist/components/input-number.d.ts +28 -7
  58. package/dist/components/input-number.js +55 -59
  59. package/dist/components/input-otp.d.ts +24 -10
  60. package/dist/components/input-otp.js +33 -37
  61. package/dist/components/input-password.d.ts +12 -5
  62. package/dist/components/input-password.js +31 -32
  63. package/dist/components/input-search.d.ts +18 -8
  64. package/dist/components/input-search.js +43 -41
  65. package/dist/components/input.d.ts +10 -4
  66. package/dist/components/input.js +9 -7
  67. package/dist/components/item.d.ts +69 -32
  68. package/dist/components/item.js +89 -92
  69. package/dist/components/kbd.d.ts +13 -5
  70. package/dist/components/kbd.js +13 -11
  71. package/dist/components/label.d.ts +9 -4
  72. package/dist/components/label.js +9 -7
  73. package/dist/components/menubar.d.ts +80 -23
  74. package/dist/components/menubar.js +97 -118
  75. package/dist/components/native-select.d.ts +16 -6
  76. package/dist/components/native-select.js +25 -26
  77. package/dist/components/navigation-menu.d.ts +36 -12
  78. package/dist/components/navigation-menu.js +60 -75
  79. package/dist/components/pagination.d.ts +35 -14
  80. package/dist/components/pagination.js +54 -69
  81. package/dist/components/popover.d.ts +24 -8
  82. package/dist/components/popover.js +28 -28
  83. package/dist/components/progress-circle.d.ts +106 -88
  84. package/dist/components/progress-circle.js +106 -138
  85. package/dist/components/progress.d.ts +10 -4
  86. package/dist/components/progress.js +14 -14
  87. package/dist/components/radio-cards.d.ts +10 -4
  88. package/dist/components/radio-cards.js +22 -23
  89. package/dist/components/radio-group.d.ts +13 -5
  90. package/dist/components/radio-group.js +18 -16
  91. package/dist/components/radio.d.ts +12 -5
  92. package/dist/components/radio.js +10 -8
  93. package/dist/components/resizable.d.ts +18 -7
  94. package/dist/components/resizable.js +22 -22
  95. package/dist/components/scroll-area.d.ts +33 -20
  96. package/dist/components/scroll-area.js +84 -88
  97. package/dist/components/select.d.ts +50 -16
  98. package/dist/components/select.js +77 -96
  99. package/dist/components/separator.d.ts +29 -19
  100. package/dist/components/separator.js +36 -34
  101. package/dist/components/sheet.d.ts +62 -29
  102. package/dist/components/sheet.js +79 -100
  103. package/dist/components/sidebar.d.ts +160 -66
  104. package/dist/components/sidebar.js +294 -336
  105. package/dist/components/skeleton.d.ts +9 -4
  106. package/dist/components/skeleton.js +8 -6
  107. package/dist/components/slider.d.ts +13 -4
  108. package/dist/components/slider.js +34 -40
  109. package/dist/components/sonner.d.ts +10 -7
  110. package/dist/components/sonner.js +16 -14
  111. package/dist/components/spinner.d.ts +12 -5
  112. package/dist/components/spinner.js +33 -35
  113. package/dist/components/switch.d.ts +9 -4
  114. package/dist/components/switch.js +13 -11
  115. package/dist/components/table.d.ts +37 -11
  116. package/dist/components/table.js +47 -45
  117. package/dist/components/tabs.d.ts +21 -7
  118. package/dist/components/tabs.js +24 -22
  119. package/dist/components/textarea.d.ts +9 -4
  120. package/dist/components/textarea.js +8 -6
  121. package/dist/components/toggle-group.d.ts +24 -9
  122. package/dist/components/toggle-group.js +41 -42
  123. package/dist/components/toggle.d.ts +25 -17
  124. package/dist/components/toggle.js +30 -28
  125. package/dist/components/tooltip.d.ts +24 -8
  126. package/dist/components/tooltip.js +29 -32
  127. package/dist/hooks/use-animated-value.d.ts +4 -1
  128. package/dist/hooks/use-animated-value.js +57 -36
  129. package/dist/hooks/use-copy-to-clipboard.d.ts +11 -5
  130. package/dist/hooks/use-copy-to-clipboard.js +39 -20
  131. package/dist/hooks/use-is-mobile.d.ts +4 -1
  132. package/dist/hooks/use-is-mobile.js +21 -1
  133. package/dist/hooks/use-media-query.d.ts +4 -1
  134. package/dist/hooks/use-media-query.js +45 -18
  135. package/dist/hooks/use-mutation-observer.d.ts +6 -2
  136. package/dist/hooks/use-mutation-observer.js +34 -16
  137. package/dist/hooks/use-pagination.d.ts +22 -14
  138. package/dist/hooks/use-pagination.js +100 -49
  139. package/dist/index.d.ts +69 -130
  140. package/dist/index.js +11 -11
  141. package/dist/primitives/checkbox-group.d.ts +105 -83
  142. package/dist/primitives/checkbox-group.js +111 -84
  143. package/dist/primitives/input-number.d.ts +51 -40
  144. package/dist/primitives/input-number.js +483 -350
  145. package/dist/primitives/input.d.ts +48 -42
  146. package/dist/primitives/input.js +65 -43
  147. package/dist/primitives/progress-circle.d.ts +79 -48
  148. package/dist/primitives/progress-circle.js +154 -105
  149. package/package.json +6 -7
@@ -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 { createContextScope } from "@radix-ui/react-context";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
4
  import { useId, useMemo } from "react";
6
- import { Legend, ResponsiveContainer, Tooltip } from "recharts";
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
- dark: ".dark",
9
- light: ""
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
- const uniqueId = useId();
16
- const chartId = `chart-${id ?? uniqueId}`;
17
- return /*#__PURE__*/ jsx(ChartContextProvider, {
18
- config: config,
19
- scope: __scopeChart,
20
- children: /*#__PURE__*/ jsxs("div", {
21
- 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),
22
- "data-chart": chartId,
23
- "data-slot": "chart",
24
- ...props,
25
- children: [
26
- /*#__PURE__*/ jsx(ChartStyle, {
27
- config: config,
28
- id: chartId
29
- }),
30
- /*#__PURE__*/ jsx(ResponsiveContainer, {
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
- const colorConfig = Object.entries(config).filter(([, itemConfig])=>itemConfig.theme ?? itemConfig.color);
39
- if (0 === colorConfig.length) return null;
40
- return /*#__PURE__*/ jsx("style", {
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
- const { config } = useChartContext(CHART_TOOLTIP_CONTENT_NAME, __scopeChart);
50
- const tooltipLabel = useMemo(()=>{
51
- if (hideLabel || 0 === payload.length) return null;
52
- const [item] = payload;
53
- const key = safeToString(labelKey ?? item.dataKey ?? item.name ?? "value");
54
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
55
- const value = labelKey || "string" != typeof label ? itemConfig?.label : label in config ? config[label].label ?? label : label;
56
- if (labelFormatter) return /*#__PURE__*/ jsx("div", {
57
- className: cn("font-medium", labelClassName),
58
- children: labelFormatter(value, payload)
59
- });
60
- if (!value) return null;
61
- return /*#__PURE__*/ jsx("div", {
62
- className: cn("font-medium", labelClassName),
63
- children: value
64
- });
65
- }, [
66
- label,
67
- labelFormatter,
68
- payload,
69
- hideLabel,
70
- labelClassName,
71
- config,
72
- labelKey
73
- ]);
74
- if (!active || 0 === payload.length) return null;
75
- const nestLabel = 1 === payload.length && "dot" !== indicator;
76
- return /*#__PURE__*/ jsxs("div", {
77
- 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),
78
- children: [
79
- nestLabel ? null : tooltipLabel,
80
- /*#__PURE__*/ jsx("div", {
81
- className: "grid gap-1.5",
82
- children: payload.map((item, index)=>{
83
- const key = safeToString(nameKey ?? item.name ?? item.dataKey ?? "value");
84
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
85
- const indicatorColor = color ?? (isRecord(item.payload) && "fill" in item.payload && "string" == typeof item.payload.fill ? item.payload.fill : void 0) ?? item.color;
86
- return /*#__PURE__*/ jsx("div", {
87
- className: cn("flex w-full flex-wrap items-stretch gap-2 [&>svg]:size-2.5 [&>svg]:text-muted-foreground", "dot" === indicator && "items-center"),
88
- children: formatter && void 0 !== item.value && item.name ? formatter(item.value, item.name, item, index, [
89
- item
90
- ]) : /*#__PURE__*/ jsxs(Fragment, {
91
- children: [
92
- itemConfig?.icon ? /*#__PURE__*/ jsx(itemConfig.icon, {}) : !hideIndicator && /*#__PURE__*/ jsx("div", {
93
- className: cn("shrink-0 rounded-xs border-(--color-border) bg-(--color-bg)", {
94
- "h-2.5 w-2.5": "dot" === indicator,
95
- "my-0.5": nestLabel && "dashed" === indicator,
96
- "border-1.5 w-0 border-dashed bg-transparent": "dashed" === indicator,
97
- "w-1": "line" === indicator
98
- }),
99
- style: {
100
- "--color-bg": indicatorColor,
101
- "--color-border": indicatorColor
102
- }
103
- }),
104
- /*#__PURE__*/ jsxs("div", {
105
- className: cn("flex flex-1 justify-between leading-none", nestLabel ? "items-end" : "items-center"),
106
- children: [
107
- /*#__PURE__*/ jsxs("div", {
108
- className: "grid gap-1.5",
109
- children: [
110
- nestLabel ? tooltipLabel : null,
111
- /*#__PURE__*/ jsx("span", {
112
- className: "text-muted-foreground",
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
- const { config } = useChartContext(CHART_LEGEND_CONTENT_NAME, __scopeChart);
135
- if (!payload?.length) return null;
136
- return /*#__PURE__*/ jsx("div", {
137
- className: cn("flex items-center justify-center gap-4", "top" === verticalAlign ? "pb-3" : "pt-3", className),
138
- children: payload.map((item)=>{
139
- let key = "value";
140
- if (nameKey) key = nameKey;
141
- else if (null != item.dataKey) key = safeToString(item.dataKey);
142
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
143
- return /*#__PURE__*/ jsxs("div", {
144
- className: cn("flex items-center gap-1.5 [&>svg]:size-3 [&>svg]:text-muted-foreground"),
145
- children: [
146
- itemConfig?.icon && !hideIcon ? /*#__PURE__*/ jsx(itemConfig.icon, {}) : /*#__PURE__*/ jsx("div", {
147
- className: "size-2 shrink-0 rounded-md",
148
- style: {
149
- backgroundColor: item.color
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
- return "object" == typeof value && null !== value;
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
- if (key in record) {
163
- const value = record[key];
164
- return "string" == typeof value ? value : void 0;
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
- if ("string" == typeof value) return value;
169
- if ("number" == typeof value) return value.toString();
170
- if (null == value) return "";
171
- if ("boolean" == typeof value) return value.toString();
172
- if ("bigint" == typeof value) return value.toString();
173
- if ("symbol" == typeof value) return value.toString();
174
- return "";
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
- if (!isRecord(payload)) return;
178
- const payloadPayload = isRecord(payload.payload) ? payload.payload : void 0;
179
- let configLabelKey = key;
180
- const payloadValue = getStringValue(payload, key);
181
- if (payloadValue) configLabelKey = payloadValue;
182
- else if (payloadPayload) {
183
- const nestedValue = getStringValue(payloadPayload, key);
184
- if (nestedValue) configLabelKey = nestedValue;
185
- }
186
- return configLabelKey in config ? config[configLabelKey] : config[key];
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
- const color = itemConfig.theme?.[theme] ?? itemConfig.color;
190
- return color ? ` --color-${key}: ${color};` : null;
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
- const cssVariables = colorConfig.map(([key, itemConfig])=>generateCssVariable(key, itemConfig, theme)).filter(Boolean).join("\n");
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
- return Object.entries(THEMES).map(([theme, prefix])=>generateThemeStyles(theme, prefix, id, colorConfig)).join("\n\n");
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 type { ComponentProps, JSX } from "react";
2
- import * as CheckboxGroupPrimitive from "../primitives/checkbox-group";
3
- type CheckboxCardsProps = ComponentProps<typeof CheckboxGroupPrimitive.Root>;
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 CheckboxGroupPrimitive.Item> {
6
- checkboxClassName?: string;
7
+ interface CheckboxCardsItemProps extends ComponentProps<typeof CheckboxGroupItem> {
8
+ checkboxClassName?: string;
7
9
  }
8
- declare function CheckboxCardsItem({ checkboxClassName, children, className, ...props }: CheckboxCardsItemProps): JSX.Element;
9
- export { CheckboxCards, CheckboxCardsItem };
10
- export type { CheckboxCardsItemProps, CheckboxCardsProps };
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 { jsx, jsxs } from "react/jsx-runtime";
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 { Label } from "./label.js";
6
- import { CheckboxGroupIndicator, Item, Root } from "../primitives/checkbox-group.js";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ //#region src/components/checkbox-cards.tsx
7
8
  function CheckboxCards(props) {
8
- return /*#__PURE__*/ jsx(Root, {
9
- "data-slot": "checkbox-cards",
10
- ...props
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
- return /*#__PURE__*/ jsxs(Label, {
15
- 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),
16
- "data-slot": "checkbox-card",
17
- children: [
18
- /*#__PURE__*/ jsx(Item, {
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, {
25
- className: "size-3.5"
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 type { ComponentProps, JSX } from "react";
2
- import * as CheckboxGroupPrimitive from "../primitives/checkbox-group";
3
- type CheckboxGroupProps = ComponentProps<typeof CheckboxGroupPrimitive.Root>;
4
- declare function CheckboxGroup({ className, ...props }: CheckboxGroupProps): JSX.Element;
5
- type CheckboxGroupItemProps = ComponentProps<typeof CheckboxGroupPrimitive.Item>;
6
- declare function CheckboxGroupItem({ className, ...props }: CheckboxGroupItemProps): JSX.Element;
7
- export { CheckboxGroup, CheckboxGroupItem };
8
- export type { CheckboxGroupItemProps, CheckboxGroupProps };
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 { jsx } from "react/jsx-runtime";
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 { CheckboxGroupIndicator, Item, Root } from "../primitives/checkbox-group.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/components/checkbox-group.tsx
6
7
  function CheckboxGroup({ className, ...props }) {
7
- return /*#__PURE__*/ jsx(Root, {
8
- className: cn("grid gap-2", className),
9
- "data-slot": "checkbox-group",
10
- ...props
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
- return /*#__PURE__*/ jsx(Item, {
15
- 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),
16
- "data-slot": "checkbox-group-item",
17
- ...props,
18
- children: /*#__PURE__*/ jsx(CheckboxGroupIndicator, {
19
- className: "flex items-center justify-center text-current transition-none",
20
- "data-slot": "checkbox-group-indicator",
21
- children: /*#__PURE__*/ jsx(CheckIcon, {
22
- className: "size-3.5"
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 type { ComponentProps, JSX } from "react";
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({ className, ...props }: CheckboxProps): JSX.Element;
5
- export { Checkbox };
6
- export type { CheckboxProps };
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
- return /*#__PURE__*/ jsx(Root, {
8
- 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),
9
- "data-slot": "checkbox",
10
- ...props,
11
- children: /*#__PURE__*/ jsx(Indicator, {
12
- className: "flex items-center justify-center text-current transition-none",
13
- "data-slot": "checkbox-indicator",
14
- children: /*#__PURE__*/ jsx(CheckIcon, {
15
- className: "size-3.5"
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 type { ComponentProps, JSX } from "react";
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({ ...props }: CollapsibleProps): JSX.Element;
6
+ declare function Collapsible({
7
+ ...props
8
+ }: CollapsibleProps): JSX.Element;
5
9
  type CollapsibleTriggerProps = ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>;
6
- declare function CollapsibleTrigger({ ...props }: CollapsibleTriggerProps): JSX.Element;
10
+ declare function CollapsibleTrigger({
11
+ ...props
12
+ }: CollapsibleTriggerProps): JSX.Element;
7
13
  type CollapsibleContentProps = ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>;
8
- declare function CollapsibleContent({ ...props }: CollapsibleContentProps): JSX.Element;
9
- export { Collapsible, CollapsibleContent, CollapsibleTrigger };
10
- export type { CollapsibleContentProps, CollapsibleProps, CollapsibleTriggerProps };
14
+ declare function CollapsibleContent({
15
+ ...props
16
+ }: CollapsibleContentProps): JSX.Element;
17
+ //#endregion
18
+ export { Collapsible, CollapsibleContent, type CollapsibleContentProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps };