rockin 0.0.33 → 0.0.35

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 (90) hide show
  1. package/dist/chunk-3CZ2LLUN.js +198 -0
  2. package/dist/{chunk-7ZCRGTLA.js → chunk-54ZJAEO5.js} +5 -5
  3. package/dist/chunk-5GM3YR42.js +228 -0
  4. package/dist/chunk-6XUTSMTJ.js +183 -0
  5. package/dist/chunk-7JJBATB2.js +35 -0
  6. package/dist/chunk-BITCJZQZ.js +31 -0
  7. package/dist/chunk-COPQJFDI.js +158 -0
  8. package/dist/chunk-D6TULSM6.js +785 -0
  9. package/dist/chunk-DVNTJNDP.js +55 -0
  10. package/dist/chunk-EKDBYSMI.js +87 -0
  11. package/dist/chunk-FGWWRPMR.js +71 -0
  12. package/dist/chunk-G233W3IR.js +17 -0
  13. package/dist/chunk-G4NDAZTB.js +13 -0
  14. package/dist/chunk-GY2BX5SK.js +26 -0
  15. package/dist/chunk-MZBLIA6C.js +20 -0
  16. package/dist/chunk-OSVLAX37.js +101 -0
  17. package/dist/chunk-PRGKTXJU.js +20 -0
  18. package/dist/chunk-RUKQ532H.js +253 -0
  19. package/dist/chunk-S4H2HENE.js +113 -0
  20. package/dist/chunk-UHZTEDHK.js +61 -0
  21. package/dist/chunk-VFDNWPOI.js +293 -0
  22. package/dist/chunk-W4EIJWHF.js +150 -0
  23. package/dist/hooks/index.js +23 -16
  24. package/dist/index.js +4 -4
  25. package/dist/provider.js +3 -3
  26. package/dist/ui/accordion.js +95 -0
  27. package/dist/ui/alert-dialog.js +178 -0
  28. package/dist/ui/apple/english.js +7 -0
  29. package/dist/ui/apple/hindi.js +7 -0
  30. package/dist/ui/apple/index.js +52 -0
  31. package/dist/ui/apple/spanish.js +7 -0
  32. package/dist/ui/ariakit.js +7 -0
  33. package/dist/ui/autocomplete.js +296 -0
  34. package/dist/ui/avatar.js +106 -0
  35. package/dist/ui/badge.js +50 -0
  36. package/dist/ui/bridge.js +109 -0
  37. package/dist/ui/bubble.js +118 -0
  38. package/dist/ui/button-group.js +14 -0
  39. package/dist/ui/button.js +9 -0
  40. package/dist/ui/card.js +102 -0
  41. package/dist/ui/carousel.js +205 -0
  42. package/dist/ui/chart.js +253 -0
  43. package/dist/ui/checkbox.js +34 -0
  44. package/dist/ui/code-block.js +128 -0
  45. package/dist/ui/combobox.js +41 -0
  46. package/dist/ui/command.js +199 -0
  47. package/dist/ui/dashed.js +57 -0
  48. package/dist/ui/data-table/index.js +233 -0
  49. package/dist/ui/dialog.js +26 -0
  50. package/dist/ui/dock.js +86 -0
  51. package/dist/ui/drawer.js +216 -0
  52. package/dist/ui/dropdown-menu.js +35 -0
  53. package/dist/ui/empty.js +17 -0
  54. package/dist/ui/farmer/div.js +38 -0
  55. package/dist/ui/farmer/variants.js +314 -0
  56. package/dist/ui/field.js +224 -0
  57. package/dist/ui/filters.js +1524 -0
  58. package/dist/ui/image.js +88 -0
  59. package/dist/ui/index.d.ts +1 -1
  60. package/dist/ui/index.js +57 -8502
  61. package/dist/ui/input-group.js +20 -0
  62. package/dist/ui/input-otp.js +83 -0
  63. package/dist/ui/input.js +7 -0
  64. package/dist/ui/item.js +200 -0
  65. package/dist/ui/jelly.js +30 -0
  66. package/dist/ui/kbd.js +9 -0
  67. package/dist/ui/label.js +7 -0
  68. package/dist/ui/message-scroller.js +122 -0
  69. package/dist/ui/message.js +93 -0
  70. package/dist/ui/numberstepper.js +416 -0
  71. package/dist/ui/otp.js +403 -0
  72. package/dist/ui/popover.js +83 -0
  73. package/dist/ui/qr-code.js +124 -0
  74. package/dist/ui/quantity.js +48 -0
  75. package/dist/ui/radio-group.js +42 -0
  76. package/dist/ui/resizable.js +52 -0
  77. package/dist/ui/scroll-area.js +9 -0
  78. package/dist/ui/select.js +194 -0
  79. package/dist/ui/separator.js +7 -0
  80. package/dist/ui/skeleton.js +25 -0
  81. package/dist/ui/sonner.js +22 -0
  82. package/dist/ui/sortable.js +503 -0
  83. package/dist/ui/swipe-actions.js +45 -0
  84. package/dist/ui/switch.js +34 -0
  85. package/dist/ui/textarea.js +7 -0
  86. package/dist/ui/theme-toggle.js +141 -0
  87. package/dist/ui/tooltip.js +13 -0
  88. package/package.json +1 -1
  89. package/dist/chunk-4KFB6AJH.js +0 -1330
  90. /package/dist/{chunk-FYFBWCMJ.js → chunk-GBVAFFZR.js} +0 -0
@@ -0,0 +1,205 @@
1
+ "use client";
2
+ import {
3
+ Button
4
+ } from "../chunk-DVNTJNDP.js";
5
+
6
+ // src/ui/carousel.tsx
7
+ import useEmblaCarousel from "embla-carousel-react";
8
+ import { ChevronLeft, ChevronRight } from "lucide-react";
9
+ import * as React from "react";
10
+ import { cn } from "cn";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ var CarouselContext = React.createContext(null);
13
+ function useCarousel() {
14
+ const context = React.useContext(CarouselContext);
15
+ if (!context) {
16
+ throw new Error("useCarousel must be used within a <Carousel />");
17
+ }
18
+ return context;
19
+ }
20
+ function Carousel({
21
+ orientation = "horizontal",
22
+ opts,
23
+ setApi,
24
+ plugins,
25
+ className,
26
+ children,
27
+ ...props
28
+ }) {
29
+ const [carouselRef, api] = useEmblaCarousel(
30
+ {
31
+ ...opts,
32
+ axis: orientation === "horizontal" ? "x" : "y"
33
+ },
34
+ plugins
35
+ );
36
+ const [canScrollPrev, setCanScrollPrev] = React.useState(false);
37
+ const [canScrollNext, setCanScrollNext] = React.useState(false);
38
+ const onSelect = React.useCallback((api2) => {
39
+ if (!api2) return;
40
+ setCanScrollPrev(api2.canScrollPrev());
41
+ setCanScrollNext(api2.canScrollNext());
42
+ }, []);
43
+ const scrollPrev = React.useCallback(() => {
44
+ api?.scrollPrev();
45
+ }, [api]);
46
+ const scrollNext = React.useCallback(() => {
47
+ api?.scrollNext();
48
+ }, [api]);
49
+ const handleKeyDown = React.useCallback(
50
+ (event) => {
51
+ if (event.key === "ArrowLeft") {
52
+ event.preventDefault();
53
+ scrollPrev();
54
+ } else if (event.key === "ArrowRight") {
55
+ event.preventDefault();
56
+ scrollNext();
57
+ }
58
+ },
59
+ [scrollPrev, scrollNext]
60
+ );
61
+ React.useEffect(() => {
62
+ if (!api || !setApi) return;
63
+ setApi(api);
64
+ }, [api, setApi]);
65
+ React.useEffect(() => {
66
+ if (!api) return;
67
+ api.on("reInit", onSelect);
68
+ api.on("select", onSelect);
69
+ queueMicrotask(() => onSelect(api));
70
+ return () => {
71
+ api.off("reInit", onSelect);
72
+ api.off("select", onSelect);
73
+ };
74
+ }, [api, onSelect]);
75
+ return /* @__PURE__ */ jsx(
76
+ CarouselContext.Provider,
77
+ {
78
+ value: {
79
+ carouselRef,
80
+ api,
81
+ opts,
82
+ orientation: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
83
+ scrollPrev,
84
+ scrollNext,
85
+ canScrollPrev,
86
+ canScrollNext
87
+ },
88
+ children: /* @__PURE__ */ jsx(
89
+ "div",
90
+ {
91
+ onKeyDownCapture: handleKeyDown,
92
+ className: cn("relative", className),
93
+ role: "region",
94
+ "aria-roledescription": "carousel",
95
+ "data-slot": "carousel",
96
+ ...props,
97
+ children
98
+ }
99
+ )
100
+ }
101
+ );
102
+ }
103
+ function CarouselContent({ className, ...props }) {
104
+ const { carouselRef, orientation } = useCarousel();
105
+ return /* @__PURE__ */ jsx(
106
+ "div",
107
+ {
108
+ ref: carouselRef,
109
+ className: "overflow-hidden",
110
+ "data-slot": "carousel-content",
111
+ children: /* @__PURE__ */ jsx(
112
+ "div",
113
+ {
114
+ className: cn(
115
+ "flex",
116
+ orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
117
+ className
118
+ ),
119
+ ...props
120
+ }
121
+ )
122
+ }
123
+ );
124
+ }
125
+ function CarouselItem({ className, ...props }) {
126
+ const { orientation } = useCarousel();
127
+ return /* @__PURE__ */ jsx(
128
+ "div",
129
+ {
130
+ role: "group",
131
+ "aria-roledescription": "slide",
132
+ "data-slot": "carousel-item",
133
+ className: cn(
134
+ "min-w-0 shrink-0 grow-0 basis-full",
135
+ orientation === "horizontal" ? "pl-4" : "pt-4",
136
+ className
137
+ ),
138
+ ...props
139
+ }
140
+ );
141
+ }
142
+ function CarouselPrevious({
143
+ className,
144
+ variant = "outline",
145
+ size = "icon-sm",
146
+ ...props
147
+ }) {
148
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel();
149
+ return /* @__PURE__ */ jsxs(
150
+ Button,
151
+ {
152
+ "data-slot": "carousel-previous",
153
+ variant,
154
+ size,
155
+ className: cn(
156
+ "absolute touch-manipulation rounded-full",
157
+ orientation === "horizontal" ? "top-1/2 left-2 z-10 -translate-y-1/2 sm:left-3" : "top-2 left-1/2 -translate-x-1/2 rotate-90",
158
+ className
159
+ ),
160
+ disabled: !canScrollPrev,
161
+ onClick: scrollPrev,
162
+ ...props,
163
+ children: [
164
+ /* @__PURE__ */ jsx(ChevronLeft, { className: "cn-rtl-flip" }),
165
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Previous slide" })
166
+ ]
167
+ }
168
+ );
169
+ }
170
+ function CarouselNext({
171
+ className,
172
+ variant = "outline",
173
+ size = "icon-sm",
174
+ ...props
175
+ }) {
176
+ const { orientation, scrollNext, canScrollNext } = useCarousel();
177
+ return /* @__PURE__ */ jsxs(
178
+ Button,
179
+ {
180
+ "data-slot": "carousel-next",
181
+ variant,
182
+ size,
183
+ className: cn(
184
+ "absolute touch-manipulation rounded-full",
185
+ orientation === "horizontal" ? "top-1/2 right-2 z-10 -translate-y-1/2 sm:right-3" : "bottom-2 left-1/2 -translate-x-1/2 rotate-90",
186
+ className
187
+ ),
188
+ disabled: !canScrollNext,
189
+ onClick: scrollNext,
190
+ ...props,
191
+ children: [
192
+ /* @__PURE__ */ jsx(ChevronRight, { className: "cn-rtl-flip" }),
193
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Next slide" })
194
+ ]
195
+ }
196
+ );
197
+ }
198
+ export {
199
+ Carousel,
200
+ CarouselContent,
201
+ CarouselItem,
202
+ CarouselNext,
203
+ CarouselPrevious,
204
+ useCarousel
205
+ };
@@ -0,0 +1,253 @@
1
+ "use client";
2
+
3
+ // src/ui/chart.tsx
4
+ import * as React from "react";
5
+ import * as RechartsPrimitive from "recharts";
6
+ import { cn } from "cn";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ var THEMES = { light: "", dark: ".dark" };
9
+ var INITIAL_DIMENSION = { width: 320, height: 200 };
10
+ var ChartContext = React.createContext(null);
11
+ function useChart() {
12
+ const context = React.useContext(ChartContext);
13
+ if (!context) {
14
+ throw new Error("useChart must be used within a <ChartContainer />");
15
+ }
16
+ return context;
17
+ }
18
+ function ChartContainer({
19
+ id,
20
+ className,
21
+ children,
22
+ config,
23
+ initialDimension = INITIAL_DIMENSION,
24
+ ...props
25
+ }) {
26
+ const uniqueId = React.useId();
27
+ const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`;
28
+ return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
29
+ "div",
30
+ {
31
+ "data-slot": "chart",
32
+ "data-chart": chartId,
33
+ className: cn(
34
+ "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",
35
+ className
36
+ ),
37
+ ...props,
38
+ children: [
39
+ /* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
40
+ /* @__PURE__ */ jsx(
41
+ RechartsPrimitive.ResponsiveContainer,
42
+ {
43
+ initialDimension,
44
+ children
45
+ }
46
+ )
47
+ ]
48
+ }
49
+ ) });
50
+ }
51
+ var ChartStyle = ({ id, config }) => {
52
+ const colorConfig = Object.entries(config).filter(
53
+ ([, config2]) => config2.theme ?? config2.color
54
+ );
55
+ if (!colorConfig.length) {
56
+ return null;
57
+ }
58
+ return /* @__PURE__ */ jsx(
59
+ "style",
60
+ {
61
+ dangerouslySetInnerHTML: {
62
+ __html: Object.entries(THEMES).map(
63
+ ([theme, prefix]) => `
64
+ ${prefix} [data-chart=${id}] {
65
+ ${colorConfig.map(([key, itemConfig]) => {
66
+ const color = itemConfig.theme?.[theme] ?? itemConfig.color;
67
+ return color ? ` --color-${key}: ${color};` : null;
68
+ }).join("\n")}
69
+ }
70
+ `
71
+ ).join("\n")
72
+ }
73
+ }
74
+ );
75
+ };
76
+ var ChartTooltip = RechartsPrimitive.Tooltip;
77
+ function ChartTooltipContent({
78
+ active,
79
+ payload,
80
+ className,
81
+ indicator = "dot",
82
+ hideLabel = false,
83
+ hideIndicator = false,
84
+ label,
85
+ labelFormatter,
86
+ labelClassName,
87
+ formatter,
88
+ color,
89
+ nameKey,
90
+ labelKey
91
+ }) {
92
+ const { config } = useChart();
93
+ const tooltipLabel = React.useMemo(() => {
94
+ if (hideLabel || !payload?.length) {
95
+ return null;
96
+ }
97
+ const [item] = payload;
98
+ const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`;
99
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
100
+ const value = !labelKey && typeof label === "string" ? config[label]?.label ?? label : itemConfig?.label;
101
+ if (labelFormatter) {
102
+ return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
103
+ }
104
+ if (!value) {
105
+ return null;
106
+ }
107
+ return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: value });
108
+ }, [
109
+ label,
110
+ labelFormatter,
111
+ payload,
112
+ hideLabel,
113
+ labelClassName,
114
+ config,
115
+ labelKey
116
+ ]);
117
+ if (!active || !payload?.length) {
118
+ return null;
119
+ }
120
+ const nestLabel = payload.length === 1 && indicator !== "dot";
121
+ return /* @__PURE__ */ jsxs(
122
+ "div",
123
+ {
124
+ className: cn(
125
+ "grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
126
+ className
127
+ ),
128
+ children: [
129
+ !nestLabel ? tooltipLabel : null,
130
+ /* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: payload.filter((item) => item.type !== "none").map((item, index) => {
131
+ const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`;
132
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
133
+ const indicatorColor = color ?? item.payload?.fill ?? item.color;
134
+ return /* @__PURE__ */ jsx(
135
+ "div",
136
+ {
137
+ className: cn(
138
+ "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
139
+ indicator === "dot" && "items-center"
140
+ ),
141
+ children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs(Fragment, { children: [
142
+ itemConfig?.icon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx(
143
+ "div",
144
+ {
145
+ className: cn(
146
+ "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
147
+ {
148
+ "h-2.5 w-2.5": indicator === "dot",
149
+ "w-1": indicator === "line",
150
+ "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
151
+ "my-0.5": nestLabel && indicator === "dashed"
152
+ }
153
+ ),
154
+ style: {
155
+ "--color-bg": indicatorColor,
156
+ "--color-border": indicatorColor
157
+ }
158
+ }
159
+ ),
160
+ /* @__PURE__ */ jsxs(
161
+ "div",
162
+ {
163
+ className: cn(
164
+ "flex flex-1 justify-between leading-none",
165
+ nestLabel ? "items-end" : "items-center"
166
+ ),
167
+ children: [
168
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
169
+ nestLabel ? tooltipLabel : null,
170
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: itemConfig?.label ?? item.name })
171
+ ] }),
172
+ item.value != null && /* @__PURE__ */ jsx("span", { className: "font-medium text-foreground tabular-nums", children: typeof item.value === "number" ? item.value.toLocaleString() : String(item.value) })
173
+ ]
174
+ }
175
+ )
176
+ ] })
177
+ },
178
+ index
179
+ );
180
+ }) })
181
+ ]
182
+ }
183
+ );
184
+ }
185
+ var ChartLegend = RechartsPrimitive.Legend;
186
+ function ChartLegendContent({
187
+ className,
188
+ hideIcon = false,
189
+ payload,
190
+ verticalAlign = "bottom",
191
+ nameKey
192
+ }) {
193
+ const { config } = useChart();
194
+ if (!payload?.length) {
195
+ return null;
196
+ }
197
+ return /* @__PURE__ */ jsx(
198
+ "div",
199
+ {
200
+ className: cn(
201
+ "flex items-center justify-center gap-4",
202
+ verticalAlign === "top" ? "pb-3" : "pt-3",
203
+ className
204
+ ),
205
+ children: payload.filter((item) => item.type !== "none").map((item, index) => {
206
+ const key = `${nameKey ?? item.dataKey ?? "value"}`;
207
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
208
+ return /* @__PURE__ */ jsxs(
209
+ "div",
210
+ {
211
+ className: cn(
212
+ "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
213
+ ),
214
+ children: [
215
+ itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx(
216
+ "div",
217
+ {
218
+ className: "h-2 w-2 shrink-0 rounded-[2px]",
219
+ style: {
220
+ backgroundColor: item.color
221
+ }
222
+ }
223
+ ),
224
+ itemConfig?.label
225
+ ]
226
+ },
227
+ index
228
+ );
229
+ })
230
+ }
231
+ );
232
+ }
233
+ function getPayloadConfigFromPayload(config, payload, key) {
234
+ if (typeof payload !== "object" || payload === null) {
235
+ return void 0;
236
+ }
237
+ const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
238
+ let configLabelKey = key;
239
+ if (key in payload && typeof payload[key] === "string") {
240
+ configLabelKey = payload[key];
241
+ } else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
242
+ configLabelKey = payloadPayload[key];
243
+ }
244
+ return configLabelKey in config ? config[configLabelKey] : config[key];
245
+ }
246
+ export {
247
+ ChartContainer,
248
+ ChartLegend,
249
+ ChartLegendContent,
250
+ ChartStyle,
251
+ ChartTooltip,
252
+ ChartTooltipContent
253
+ };
@@ -0,0 +1,34 @@
1
+ "use client";
2
+
3
+ // src/ui/checkbox.tsx
4
+ import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";
5
+ import { cn } from "cn";
6
+ import { jsx } from "react/jsx-runtime";
7
+ function Checkbox({
8
+ className,
9
+ children,
10
+ ...props
11
+ }) {
12
+ return /* @__PURE__ */ jsx(
13
+ CheckboxPrimitive.Root,
14
+ {
15
+ "data-slot": "checkbox",
16
+ className: cn(
17
+ "peer inline-flex size-5 shrink-0 items-center justify-center rounded border border-border bg-background text-primary transition-[background-color,border-color,box-shadow,opacity] duration-150 ease-out outline-none focus-visible:ring-2 focus-visible:ring-ring/50 motion-reduce:transition-none data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground data-disabled:cursor-not-allowed data-disabled:opacity-50",
18
+ className
19
+ ),
20
+ ...props,
21
+ children: /* @__PURE__ */ jsx(
22
+ CheckboxPrimitive.Indicator,
23
+ {
24
+ "data-slot": "checkbox-indicator",
25
+ className: "flex items-center justify-center",
26
+ children
27
+ }
28
+ )
29
+ }
30
+ );
31
+ }
32
+ export {
33
+ Checkbox
34
+ };
@@ -0,0 +1,128 @@
1
+ "use client";
2
+ import {
3
+ IconSwap
4
+ } from "../chunk-5QSYZSVL.js";
5
+ import {
6
+ Button
7
+ } from "../chunk-DVNTJNDP.js";
8
+
9
+ // src/ui/code-block.tsx
10
+ import { cn } from "cn";
11
+ import { Check, Copy } from "lucide-react";
12
+ import { useTheme } from "next-themes";
13
+ import * as React from "react";
14
+ import { codeToHtml } from "shiki";
15
+ import { jsx, jsxs } from "react/jsx-runtime";
16
+ var highlightCache = /* @__PURE__ */ new Map();
17
+ function CodeBlock({
18
+ code,
19
+ language = "tsx",
20
+ className,
21
+ showLineNumbers = true,
22
+ maxHeight = 400
23
+ }) {
24
+ const { resolvedTheme } = useTheme();
25
+ const [highlighted, setHighlighted] = React.useState(null);
26
+ const [highlightErrorKey, setHighlightErrorKey] = React.useState(null);
27
+ const [copied, setCopied] = React.useState(false);
28
+ const value = code.trim();
29
+ const isDark = resolvedTheme === "dark";
30
+ const highlightKey = `${language}:${isDark ? "dark" : "light"}:${value}`;
31
+ React.useEffect(() => {
32
+ let cancelled = false;
33
+ const cached = highlightCache.get(highlightKey);
34
+ if (cached) {
35
+ setHighlighted({ key: highlightKey, html: cached });
36
+ return;
37
+ }
38
+ async function highlight() {
39
+ try {
40
+ const result = await codeToHtml(value, {
41
+ lang: language,
42
+ theme: isDark ? "github-dark" : "github-light"
43
+ });
44
+ if (!cancelled) {
45
+ highlightCache.set(highlightKey, result);
46
+ setHighlighted({ key: highlightKey, html: result });
47
+ setHighlightErrorKey(null);
48
+ }
49
+ } catch (error) {
50
+ console.error("Failed to highlight code:", error);
51
+ if (!cancelled) {
52
+ setHighlightErrorKey(highlightKey);
53
+ }
54
+ }
55
+ }
56
+ highlight();
57
+ return () => {
58
+ cancelled = true;
59
+ };
60
+ }, [highlightKey, value, language, isDark]);
61
+ async function copy() {
62
+ try {
63
+ await navigator.clipboard.writeText(value);
64
+ setCopied(true);
65
+ window.setTimeout(() => {
66
+ setCopied(false);
67
+ }, 1500);
68
+ } catch (error) {
69
+ console.error("Failed to copy code:", error);
70
+ }
71
+ }
72
+ const scrollStyle = {
73
+ maxHeight: typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight
74
+ };
75
+ const isHighlighted = highlighted?.key === highlightKey;
76
+ const showFallback = highlightErrorKey === highlightKey;
77
+ const fallbackStyle = {
78
+ ...scrollStyle,
79
+ visibility: showFallback ? "visible" : "hidden"
80
+ };
81
+ return /* @__PURE__ */ jsxs(
82
+ "div",
83
+ {
84
+ className: cn(
85
+ "code-block relative overflow-hidden rounded-lg",
86
+ "bg-[#f7f7f7] dark:bg-[#111]",
87
+ className
88
+ ),
89
+ children: [
90
+ /* @__PURE__ */ jsx(
91
+ Button,
92
+ {
93
+ onClick: copy,
94
+ "aria-label": copied ? "Copied" : "Copy code",
95
+ variant: "secondary",
96
+ className: "absolute top-1 right-1 z-20",
97
+ size: "icon-sm",
98
+ children: /* @__PURE__ */ jsx(IconSwap, { active: copied, first: /* @__PURE__ */ jsx(Copy, {}), second: /* @__PURE__ */ jsx(Check, {}) })
99
+ }
100
+ ),
101
+ isHighlighted ? /* @__PURE__ */ jsx(
102
+ "div",
103
+ {
104
+ style: scrollStyle,
105
+ className: cn(
106
+ "code-block-content scroll-fade overflow-auto",
107
+ showLineNumbers && "code-block-line-numbers"
108
+ ),
109
+ dangerouslySetInnerHTML: { __html: highlighted.html }
110
+ }
111
+ ) : /* @__PURE__ */ jsx(
112
+ "pre",
113
+ {
114
+ style: fallbackStyle,
115
+ className: "code-block-fallback scroll-fade overflow-auto",
116
+ children: /* @__PURE__ */ jsx("code", { children: value.split("\n").map((line, index) => /* @__PURE__ */ jsxs("span", { className: "block min-w-max", children: [
117
+ showLineNumbers && /* @__PURE__ */ jsx("span", { className: "code-block-fallback-number", children: index + 1 }),
118
+ line || " "
119
+ ] }, index)) })
120
+ }
121
+ )
122
+ ]
123
+ }
124
+ );
125
+ }
126
+ export {
127
+ CodeBlock
128
+ };
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import {
3
+ Combobox,
4
+ ComboboxChip,
5
+ ComboboxChips,
6
+ ComboboxChipsInput,
7
+ ComboboxCollection,
8
+ ComboboxContent,
9
+ ComboboxEmpty,
10
+ ComboboxGroup,
11
+ ComboboxInput,
12
+ ComboboxItem,
13
+ ComboboxLabel,
14
+ ComboboxList,
15
+ ComboboxSeparator,
16
+ ComboboxTrigger,
17
+ ComboboxValue,
18
+ useComboboxAnchor
19
+ } from "../chunk-VFDNWPOI.js";
20
+ import "../chunk-COPQJFDI.js";
21
+ import "../chunk-MZBLIA6C.js";
22
+ import "../chunk-7JJBATB2.js";
23
+ import "../chunk-DVNTJNDP.js";
24
+ export {
25
+ Combobox,
26
+ ComboboxChip,
27
+ ComboboxChips,
28
+ ComboboxChipsInput,
29
+ ComboboxCollection,
30
+ ComboboxContent,
31
+ ComboboxEmpty,
32
+ ComboboxGroup,
33
+ ComboboxInput,
34
+ ComboboxItem,
35
+ ComboboxLabel,
36
+ ComboboxList,
37
+ ComboboxSeparator,
38
+ ComboboxTrigger,
39
+ ComboboxValue,
40
+ useComboboxAnchor
41
+ };