rockin 0.0.18 → 0.0.20

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.
@@ -0,0 +1,1019 @@
1
+ // src/ui/button.tsx
2
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
3
+ import { cva } from "class-variance-authority";
4
+ import { cn } from "cn";
5
+ import { jsx } from "react/jsx-runtime";
6
+ var buttonVariants = cva(
7
+ "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-[background-color,border-color,color,box-shadow,opacity,transform] duration-150 ease-[var(--ease-out)] outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 motion-reduce:transition-none dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:opacity-70 [&_svg:not([class*='size-'])]:size-4",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
12
+ outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
13
+ secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
14
+ ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
15
+ destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
16
+ link: "text-primary underline-offset-4 hover:underline"
17
+ },
18
+ size: {
19
+ default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
20
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
21
+ sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
22
+ lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
23
+ icon: "size-8",
24
+ "icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
25
+ "icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
26
+ "icon-lg": "size-9",
27
+ "icon-title": "size-8 sm:h-8 sm:w-auto sm:gap-1.5 sm:px-2.5 sm:has-data-[icon=inline-end]:pr-2 sm:has-data-[icon=inline-start]:pl-2"
28
+ }
29
+ },
30
+ defaultVariants: {
31
+ variant: "default",
32
+ size: "default"
33
+ }
34
+ }
35
+ );
36
+ function Button({
37
+ className,
38
+ variant = "default",
39
+ size = "default",
40
+ ...props
41
+ }) {
42
+ return /* @__PURE__ */ jsx(
43
+ ButtonPrimitive,
44
+ {
45
+ "data-slot": "button",
46
+ className: cn(buttonVariants({ variant, size, className })),
47
+ ...props
48
+ }
49
+ );
50
+ }
51
+
52
+ // src/ui/input.tsx
53
+ import { Input as InputPrimitive } from "@base-ui/react/input";
54
+ import { cn as cn2 } from "cn";
55
+ import { jsx as jsx2 } from "react/jsx-runtime";
56
+ function Input({
57
+ className,
58
+ type,
59
+ inputMode,
60
+ onWheel,
61
+ ...props
62
+ }) {
63
+ const isNumberInput = type === "number";
64
+ return /* @__PURE__ */ jsx2(
65
+ InputPrimitive,
66
+ {
67
+ type,
68
+ "data-slot": "input",
69
+ inputMode: isNumberInput ? "decimal" : inputMode,
70
+ onWheel: isNumberInput ? (event) => {
71
+ event.currentTarget.blur();
72
+ onWheel?.(event);
73
+ } : onWheel,
74
+ className: cn2(
75
+ "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
76
+ isNumberInput && "[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
77
+ className
78
+ ),
79
+ ...props
80
+ }
81
+ );
82
+ }
83
+
84
+ // src/ui/textarea.tsx
85
+ import { cn as cn3 } from "cn";
86
+ import { jsx as jsx3 } from "react/jsx-runtime";
87
+ function Textarea({ className, ...props }) {
88
+ return /* @__PURE__ */ jsx3(
89
+ "textarea",
90
+ {
91
+ "data-slot": "textarea",
92
+ className: cn3(
93
+ "flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
94
+ className
95
+ ),
96
+ ...props
97
+ }
98
+ );
99
+ }
100
+
101
+ // src/ui/input-group.tsx
102
+ import { cva as cva2 } from "class-variance-authority";
103
+ import { cn as cn4 } from "cn";
104
+ import { jsx as jsx4 } from "react/jsx-runtime";
105
+ function InputGroup({ className, ...props }) {
106
+ return /* @__PURE__ */ jsx4(
107
+ "div",
108
+ {
109
+ "data-slot": "input-group",
110
+ role: "group",
111
+ className: cn4(
112
+ "group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-2 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",
113
+ className
114
+ ),
115
+ ...props
116
+ }
117
+ );
118
+ }
119
+ var inputGroupAddonVariants = cva2(
120
+ "flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
121
+ {
122
+ variants: {
123
+ align: {
124
+ "inline-start": "order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]",
125
+ "inline-end": "order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]",
126
+ "block-start": "order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
127
+ "block-end": "order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"
128
+ }
129
+ },
130
+ defaultVariants: {
131
+ align: "inline-start"
132
+ }
133
+ }
134
+ );
135
+ function InputGroupAddon({
136
+ className,
137
+ align = "inline-start",
138
+ focusInput = true,
139
+ ...props
140
+ }) {
141
+ return /* @__PURE__ */ jsx4(
142
+ "div",
143
+ {
144
+ role: "group",
145
+ "data-slot": "input-group-addon",
146
+ "data-align": align,
147
+ className: cn4(inputGroupAddonVariants({ align }), className),
148
+ onClick: (e) => {
149
+ if (e.target.closest("button")) {
150
+ return;
151
+ }
152
+ if (!focusInput) {
153
+ return;
154
+ }
155
+ e.currentTarget.parentElement?.querySelector("input")?.focus();
156
+ },
157
+ ...props
158
+ }
159
+ );
160
+ }
161
+ var inputGroupButtonVariants = cva2(
162
+ "flex items-center gap-2 text-sm shadow-none",
163
+ {
164
+ variants: {
165
+ size: {
166
+ xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
167
+ sm: "",
168
+ "icon-xs": "size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0",
169
+ "icon-sm": "size-8 p-0 has-[>svg]:p-0",
170
+ "bar-icon": "size-7 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0"
171
+ }
172
+ },
173
+ defaultVariants: {
174
+ size: "xs"
175
+ }
176
+ }
177
+ );
178
+ function InputGroupButton({
179
+ className,
180
+ type = "button",
181
+ variant = "ghost",
182
+ size = "xs",
183
+ ...props
184
+ }) {
185
+ return /* @__PURE__ */ jsx4(
186
+ Button,
187
+ {
188
+ type,
189
+ "data-size": size,
190
+ variant,
191
+ className: cn4(inputGroupButtonVariants({ size }), className),
192
+ ...props
193
+ }
194
+ );
195
+ }
196
+ function InputGroupText({ className, ...props }) {
197
+ return /* @__PURE__ */ jsx4(
198
+ "span",
199
+ {
200
+ className: cn4(
201
+ "flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
202
+ className
203
+ ),
204
+ ...props
205
+ }
206
+ );
207
+ }
208
+ function InputGroupInput({
209
+ className,
210
+ ...props
211
+ }) {
212
+ return /* @__PURE__ */ jsx4(
213
+ Input,
214
+ {
215
+ "data-slot": "input-group-control",
216
+ className: cn4(
217
+ "flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
218
+ className
219
+ ),
220
+ ...props
221
+ }
222
+ );
223
+ }
224
+ function InputGroupTextarea({
225
+ className,
226
+ ...props
227
+ }) {
228
+ return /* @__PURE__ */ jsx4(
229
+ Textarea,
230
+ {
231
+ "data-slot": "input-group-control",
232
+ className: cn4(
233
+ "flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
234
+ className
235
+ ),
236
+ ...props
237
+ }
238
+ );
239
+ }
240
+
241
+ // src/ui/combobox.tsx
242
+ import { Combobox as ComboboxPrimitive } from "@base-ui/react";
243
+ import * as React from "react";
244
+ import { cn as cn5 } from "cn";
245
+ import { Check, ChevronDown, Xmark } from "@gravity-ui/icons";
246
+ import { jsx as jsx5, jsxs } from "react/jsx-runtime";
247
+ var Combobox = ComboboxPrimitive.Root;
248
+ function ComboboxValue({ ...props }) {
249
+ return /* @__PURE__ */ jsx5(ComboboxPrimitive.Value, { "data-slot": "combobox-value", ...props });
250
+ }
251
+ function ComboboxTrigger({
252
+ className,
253
+ children,
254
+ ...props
255
+ }) {
256
+ return /* @__PURE__ */ jsxs(
257
+ ComboboxPrimitive.Trigger,
258
+ {
259
+ "data-slot": "combobox-trigger",
260
+ className: cn5("[&_svg:not([class*='size-'])]:size-4", className),
261
+ ...props,
262
+ children: [
263
+ children,
264
+ /* @__PURE__ */ jsx5(ChevronDown, { className: "pointer-events-none size-4 text-muted-foreground" })
265
+ ]
266
+ }
267
+ );
268
+ }
269
+ function ComboboxClear({ className, ...props }) {
270
+ return /* @__PURE__ */ jsx5(
271
+ ComboboxPrimitive.Clear,
272
+ {
273
+ "data-slot": "combobox-clear",
274
+ render: /* @__PURE__ */ jsx5(InputGroupButton, { variant: "ghost", size: "icon-xs" }),
275
+ className: cn5(className),
276
+ ...props,
277
+ children: /* @__PURE__ */ jsx5(Xmark, { className: "pointer-events-none" })
278
+ }
279
+ );
280
+ }
281
+ function ComboboxInput({
282
+ className,
283
+ children,
284
+ disabled = false,
285
+ showTrigger = true,
286
+ showClear = false,
287
+ startContent,
288
+ endContent,
289
+ ...props
290
+ }) {
291
+ return /* @__PURE__ */ jsxs(InputGroup, { className: cn5("w-auto", className), children: [
292
+ /* @__PURE__ */ jsx5(
293
+ ComboboxPrimitive.Input,
294
+ {
295
+ render: /* @__PURE__ */ jsx5(InputGroupInput, { disabled }),
296
+ ...props
297
+ }
298
+ ),
299
+ startContent && /* @__PURE__ */ jsx5(InputGroupAddon, { align: "inline-start", children: startContent }),
300
+ /* @__PURE__ */ jsxs(InputGroupAddon, { align: "inline-end", className: "pr-0", children: [
301
+ showTrigger && /* @__PURE__ */ jsx5(
302
+ InputGroupButton,
303
+ {
304
+ size: "icon-xs",
305
+ variant: "ghost",
306
+ render: /* @__PURE__ */ jsx5(ComboboxTrigger, {}),
307
+ "data-slot": "input-group-button",
308
+ className: "group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent",
309
+ disabled
310
+ }
311
+ ),
312
+ showClear && /* @__PURE__ */ jsx5(ComboboxClear, { disabled })
313
+ ] }),
314
+ /* @__PURE__ */ jsx5(InputGroupAddon, { align: "inline-end", children: endContent }),
315
+ children
316
+ ] });
317
+ }
318
+ function ComboboxContent({
319
+ className,
320
+ side = "bottom",
321
+ sideOffset = 6,
322
+ align = "start",
323
+ alignOffset = 0,
324
+ anchor,
325
+ ...props
326
+ }) {
327
+ return /* @__PURE__ */ jsx5(ComboboxPrimitive.Portal, { children: /* @__PURE__ */ jsx5(
328
+ ComboboxPrimitive.Positioner,
329
+ {
330
+ side,
331
+ sideOffset,
332
+ align,
333
+ alignOffset,
334
+ anchor,
335
+ className: "isolate z-50",
336
+ children: /* @__PURE__ */ jsx5(
337
+ ComboboxPrimitive.Popup,
338
+ {
339
+ "data-slot": "combobox-content",
340
+ "data-chips": !!anchor,
341
+ className: cn5(
342
+ "group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+(--spacing(7)))] origin-(--transform-origin) overflow-hidden rounded-lg bg-background text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
343
+ className
344
+ ),
345
+ ...props
346
+ }
347
+ )
348
+ }
349
+ ) });
350
+ }
351
+ function ComboboxList({ className, ...props }) {
352
+ return /* @__PURE__ */ jsx5(
353
+ ComboboxPrimitive.List,
354
+ {
355
+ "data-slot": "combobox-list",
356
+ className: cn5(
357
+ "no-scrollbar max-h-[min(calc(--spacing(72)-(--spacing(9))),calc(var(--available-height)-(--spacing(9))))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",
358
+ className
359
+ ),
360
+ ...props
361
+ }
362
+ );
363
+ }
364
+ function ComboboxItem({
365
+ className,
366
+ children,
367
+ ...props
368
+ }) {
369
+ return /* @__PURE__ */ jsxs(
370
+ ComboboxPrimitive.Item,
371
+ {
372
+ "data-slot": "combobox-item",
373
+ className: cn5(
374
+ "relative flex w-full cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
375
+ className
376
+ ),
377
+ ...props,
378
+ children: [
379
+ children,
380
+ /* @__PURE__ */ jsx5(
381
+ ComboboxPrimitive.ItemIndicator,
382
+ {
383
+ render: /* @__PURE__ */ jsx5("span", { className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center" }),
384
+ children: /* @__PURE__ */ jsx5(Check, { className: "pointer-events-none" })
385
+ }
386
+ )
387
+ ]
388
+ }
389
+ );
390
+ }
391
+ function ComboboxGroup({ className, ...props }) {
392
+ return /* @__PURE__ */ jsx5(
393
+ ComboboxPrimitive.Group,
394
+ {
395
+ "data-slot": "combobox-group",
396
+ className: cn5(className),
397
+ ...props
398
+ }
399
+ );
400
+ }
401
+ function ComboboxLabel({
402
+ className,
403
+ ...props
404
+ }) {
405
+ return /* @__PURE__ */ jsx5(
406
+ ComboboxPrimitive.GroupLabel,
407
+ {
408
+ "data-slot": "combobox-label",
409
+ className: cn5("px-2 py-1.5 text-xs text-muted-foreground", className),
410
+ ...props
411
+ }
412
+ );
413
+ }
414
+ function ComboboxCollection({ ...props }) {
415
+ return /* @__PURE__ */ jsx5(ComboboxPrimitive.Collection, { "data-slot": "combobox-collection", ...props });
416
+ }
417
+ function ComboboxEmpty({ className, ...props }) {
418
+ return /* @__PURE__ */ jsx5(
419
+ ComboboxPrimitive.Empty,
420
+ {
421
+ "data-slot": "combobox-empty",
422
+ className: cn5(
423
+ "hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex",
424
+ className
425
+ ),
426
+ ...props
427
+ }
428
+ );
429
+ }
430
+ function ComboboxSeparator({
431
+ className,
432
+ ...props
433
+ }) {
434
+ return /* @__PURE__ */ jsx5(
435
+ ComboboxPrimitive.Separator,
436
+ {
437
+ "data-slot": "combobox-separator",
438
+ className: cn5("-mx-1 my-1 h-px bg-border", className),
439
+ ...props
440
+ }
441
+ );
442
+ }
443
+ function ComboboxChips({
444
+ className,
445
+ ...props
446
+ }) {
447
+ return /* @__PURE__ */ jsx5(
448
+ ComboboxPrimitive.Chips,
449
+ {
450
+ "data-slot": "combobox-chips",
451
+ className: cn5(
452
+ "flex min-h-8 flex-wrap items-center gap-1 rounded-lg border border-input bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-2 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40",
453
+ className
454
+ ),
455
+ ...props
456
+ }
457
+ );
458
+ }
459
+ function ComboboxChip({
460
+ className,
461
+ children,
462
+ showRemove = true,
463
+ ...props
464
+ }) {
465
+ return /* @__PURE__ */ jsxs(
466
+ ComboboxPrimitive.Chip,
467
+ {
468
+ "data-slot": "combobox-chip",
469
+ className: cn5(
470
+ "flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",
471
+ className
472
+ ),
473
+ ...props,
474
+ children: [
475
+ children,
476
+ showRemove && /* @__PURE__ */ jsx5(
477
+ ComboboxPrimitive.ChipRemove,
478
+ {
479
+ render: /* @__PURE__ */ jsx5(Button, { variant: "ghost", size: "icon-xs" }),
480
+ className: "-ml-1 opacity-50 hover:opacity-100",
481
+ "data-slot": "combobox-chip-remove",
482
+ children: /* @__PURE__ */ jsx5(Xmark, { className: "pointer-events-none" })
483
+ }
484
+ )
485
+ ]
486
+ }
487
+ );
488
+ }
489
+ function ComboboxChipsInput({
490
+ className,
491
+ ...props
492
+ }) {
493
+ return /* @__PURE__ */ jsx5(
494
+ ComboboxPrimitive.Input,
495
+ {
496
+ "data-slot": "combobox-chip-input",
497
+ className: cn5("min-w-16 flex-1 outline-none", className),
498
+ ...props
499
+ }
500
+ );
501
+ }
502
+ function useComboboxAnchor() {
503
+ return React.useRef(null);
504
+ }
505
+
506
+ // src/ui/data-table/core/data-table-root.tsx
507
+ import * as React2 from "react";
508
+ import { cn as cn6 } from "cn";
509
+ import { jsx as jsx6 } from "react/jsx-runtime";
510
+ var DataTableContext = React2.createContext(
511
+ null
512
+ );
513
+ function useDataTable() {
514
+ const context = React2.useContext(DataTableContext);
515
+ if (!context) {
516
+ throw new Error(
517
+ "DataTable components must be rendered inside DataTableRoot"
518
+ );
519
+ }
520
+ return context;
521
+ }
522
+ function DataTableRoot({
523
+ data,
524
+ columns,
525
+ children,
526
+ isLoading = false,
527
+ pageSize = 10,
528
+ getRowId = (_, index) => String(index),
529
+ className
530
+ }) {
531
+ const [globalFilter, setGlobalFilterState] = React2.useState("");
532
+ const [pageIndex, setPageIndexState] = React2.useState(0);
533
+ const filteredData = React2.useMemo(() => {
534
+ const query = globalFilter.trim().toLowerCase();
535
+ if (!query) return data;
536
+ return data.filter(
537
+ (row) => columns.some((column) => {
538
+ if (column.enableSearch === false) return false;
539
+ const value = column.accessorFn ? column.accessorFn(row) : column.accessorKey ? row[column.accessorKey] : void 0;
540
+ return String(value ?? "").toLowerCase().includes(query);
541
+ })
542
+ );
543
+ }, [columns, data, globalFilter]);
544
+ const safePageSize = Math.max(1, pageSize);
545
+ const pageCount = Math.max(1, Math.ceil(filteredData.length / safePageSize));
546
+ const safePageIndex = Math.min(pageIndex, pageCount - 1);
547
+ const pageData = filteredData.slice(
548
+ safePageIndex * safePageSize,
549
+ (safePageIndex + 1) * safePageSize
550
+ );
551
+ React2.useEffect(() => {
552
+ setPageIndexState((current) => Math.min(current, pageCount - 1));
553
+ }, [pageCount]);
554
+ const contextValue = React2.useMemo(
555
+ () => ({
556
+ data,
557
+ columns,
558
+ filteredData,
559
+ pageData,
560
+ pageIndex: safePageIndex,
561
+ pageSize: safePageSize,
562
+ pageCount,
563
+ globalFilter,
564
+ isLoading,
565
+ getRowId,
566
+ setGlobalFilter: (value) => {
567
+ setGlobalFilterState(value);
568
+ setPageIndexState(0);
569
+ },
570
+ setPageIndex: (value) => setPageIndexState(Math.max(0, Math.min(value, pageCount - 1)))
571
+ }),
572
+ [
573
+ columns,
574
+ filteredData,
575
+ pageCount,
576
+ pageData,
577
+ safePageIndex,
578
+ safePageSize,
579
+ globalFilter,
580
+ isLoading,
581
+ getRowId
582
+ ]
583
+ );
584
+ return /* @__PURE__ */ jsx6(DataTableContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx6("div", { className: cn6("w-full space-y-3", className), children }) });
585
+ }
586
+
587
+ // src/ui/data-table/hooks/use-data-table-pagination.ts
588
+ function useDataTablePagination() {
589
+ const { pageIndex, pageSize, pageCount, setPageIndex } = useDataTable();
590
+ return {
591
+ pageIndex,
592
+ pageSize,
593
+ pageCount,
594
+ canPreviousPage: pageIndex > 0,
595
+ canNextPage: pageIndex < pageCount - 1,
596
+ goToPage: setPageIndex,
597
+ previousPage: () => setPageIndex(pageIndex - 1),
598
+ nextPage: () => setPageIndex(pageIndex + 1),
599
+ firstPage: () => setPageIndex(0),
600
+ lastPage: () => setPageIndex(pageCount - 1)
601
+ };
602
+ }
603
+
604
+ // src/ui/data-table/hooks/use-data-table-rows.ts
605
+ function useDataTableRows() {
606
+ const { data, filteredData, pageData, isLoading } = useDataTable();
607
+ return {
608
+ data,
609
+ rows: pageData,
610
+ pageRows: pageData,
611
+ filteredRows: filteredData,
612
+ totalRows: filteredData.length,
613
+ isLoading
614
+ };
615
+ }
616
+
617
+ // src/ui/data-table/hooks/use-data-table-search.ts
618
+ function useDataTableSearch() {
619
+ const { globalFilter, setGlobalFilter } = useDataTable();
620
+ return {
621
+ search: globalFilter,
622
+ setSearch: setGlobalFilter,
623
+ clearSearch: () => setGlobalFilter("")
624
+ };
625
+ }
626
+
627
+ // src/ui/data-table/data-grid.tsx
628
+ import * as React3 from "react";
629
+ import { cn as cn7 } from "cn";
630
+ import { Fragment, jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
631
+ function useDataGrid({
632
+ columnIds = [],
633
+ columns,
634
+ initialRows = [],
635
+ getRowId = (row, index) => String(row.id ?? index)
636
+ } = {}) {
637
+ const [rows, setRows] = React3.useState(initialRows);
638
+ const resolvedColumns = React3.useMemo(
639
+ () => columns ?? columnIds.map((id) => ({
640
+ id,
641
+ accessorKey: id,
642
+ header: id
643
+ })),
644
+ [columnIds, columns]
645
+ );
646
+ const getRow = React3.useCallback(
647
+ (rowId) => rows.find((row, index) => getRowId(row, index) === rowId),
648
+ [getRowId, rows]
649
+ );
650
+ const getCellValue = React3.useCallback(
651
+ (rowId, columnId) => {
652
+ const row = getRow(rowId);
653
+ return row?.[columnId];
654
+ },
655
+ [getRow]
656
+ );
657
+ const updateCell = React3.useCallback(
658
+ (rowId, columnId, value) => {
659
+ setRows(
660
+ (current) => current.map(
661
+ (row, index) => getRowId(row, index) === rowId ? { ...row, [columnId]: value } : row
662
+ )
663
+ );
664
+ },
665
+ [getRowId]
666
+ );
667
+ const updateRows = React3.useCallback(
668
+ (updater) => setRows(updater),
669
+ []
670
+ );
671
+ return React3.useMemo(
672
+ () => ({
673
+ rows,
674
+ columns: resolvedColumns,
675
+ getRowId,
676
+ getRow,
677
+ getCellValue,
678
+ updateCell,
679
+ updateRows
680
+ }),
681
+ [
682
+ getCellValue,
683
+ getRow,
684
+ getRowId,
685
+ resolvedColumns,
686
+ rows,
687
+ updateCell,
688
+ updateRows
689
+ ]
690
+ );
691
+ }
692
+ var DataGridContext = React3.createContext(null);
693
+ function useDataGridContext() {
694
+ const context = React3.useContext(DataGridContext);
695
+ if (!context) throw new Error("DataGrid components must be inside DataGrid");
696
+ return context;
697
+ }
698
+ var DataGridCellContext = React3.createContext(null);
699
+ function DataGrid({
700
+ grid,
701
+ children,
702
+ className
703
+ }) {
704
+ return /* @__PURE__ */ jsx7(DataGridContext.Provider, { value: grid, children: /* @__PURE__ */ jsx7("div", { className: cn7("w-full space-y-2 outline-none", className), children }) });
705
+ }
706
+ function DataGridRow({
707
+ row,
708
+ rowId,
709
+ children,
710
+ className
711
+ }) {
712
+ const grid = useDataGridContext();
713
+ const resolvedRowId = rowId ?? (row ? grid.getRowId(row, 0) : "");
714
+ const resolvedRow = row ?? grid.getRow(resolvedRowId);
715
+ return /* @__PURE__ */ jsx7(
716
+ "div",
717
+ {
718
+ className: cn7(
719
+ "grid grid-cols-[repeat(var(--data-grid-columns),minmax(9rem,1fr))]",
720
+ className
721
+ ),
722
+ children: resolvedRow && children
723
+ }
724
+ );
725
+ }
726
+ function DataGridColumn({
727
+ column,
728
+ children,
729
+ className
730
+ }) {
731
+ return /* @__PURE__ */ jsx7("div", { className: cn7("min-w-0", className), children: children ?? column.header });
732
+ }
733
+ function DataGridCell({
734
+ row,
735
+ rowId,
736
+ columnId,
737
+ children,
738
+ state = "valid",
739
+ className
740
+ }) {
741
+ const grid = useDataGridContext();
742
+ const resolvedRowId = rowId ?? (row ? grid.getRowId(row, 0) : "");
743
+ const value = grid.getCellValue(resolvedRowId, columnId);
744
+ return /* @__PURE__ */ jsx7(
745
+ DataGridCellContext.Provider,
746
+ {
747
+ value: { rowId: resolvedRowId, columnId, value },
748
+ children: /* @__PURE__ */ jsx7(
749
+ "div",
750
+ {
751
+ "aria-invalid": state === "invalid" || void 0,
752
+ className: cn7(
753
+ "min-h-9 border-r border-b px-2 py-1.5",
754
+ state === "invalid" && "border-destructive/60 bg-destructive/10",
755
+ state === "pending" && "opacity-70",
756
+ className
757
+ ),
758
+ children
759
+ }
760
+ )
761
+ }
762
+ );
763
+ }
764
+ function useGridCell() {
765
+ const cell = React3.useContext(DataGridCellContext);
766
+ const grid = useDataGridContext();
767
+ if (!cell) throw new Error("Grid cell components must be inside DataGridCell");
768
+ return { ...cell, grid };
769
+ }
770
+ function GridTextCell({
771
+ value,
772
+ onChange,
773
+ placeholder
774
+ }) {
775
+ const cell = useGridCell();
776
+ const currentValue = value ?? String(cell.value ?? "");
777
+ return /* @__PURE__ */ jsx7(
778
+ Input,
779
+ {
780
+ className: "h-7 w-full min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground",
781
+ onChange: (event) => {
782
+ const nextValue = event.target.value;
783
+ onChange?.(nextValue);
784
+ cell.grid.updateCell(cell.rowId, cell.columnId, nextValue);
785
+ },
786
+ placeholder,
787
+ value: currentValue
788
+ }
789
+ );
790
+ }
791
+ function GridNumberCell({
792
+ value,
793
+ onChange
794
+ }) {
795
+ const cell = useGridCell();
796
+ const currentValue = value ?? (typeof cell.value === "number" ? cell.value : "");
797
+ return /* @__PURE__ */ jsx7(
798
+ Input,
799
+ {
800
+ className: "h-7 w-full min-w-0 bg-transparent text-sm outline-none",
801
+ onChange: (event) => {
802
+ const nextValue = event.target.valueAsNumber;
803
+ if (Number.isNaN(nextValue)) return;
804
+ onChange?.(nextValue);
805
+ cell.grid.updateCell(cell.rowId, cell.columnId, nextValue);
806
+ },
807
+ type: "number",
808
+ value: currentValue
809
+ }
810
+ );
811
+ }
812
+ function GridComboboxCell({
813
+ options,
814
+ value,
815
+ onChange
816
+ }) {
817
+ const cell = useGridCell();
818
+ const currentValue = value ?? String(cell.value ?? "");
819
+ return /* @__PURE__ */ jsxs2(
820
+ Combobox,
821
+ {
822
+ onValueChange: (nextValue) => {
823
+ if (nextValue === null) return;
824
+ onChange?.(nextValue);
825
+ cell.grid.updateCell(cell.rowId, cell.columnId, nextValue);
826
+ },
827
+ value: currentValue,
828
+ children: [
829
+ /* @__PURE__ */ jsx7(
830
+ ComboboxInput,
831
+ {
832
+ className: "h-7 w-full min-w-0 border-0 bg-transparent px-0 shadow-none",
833
+ showClear: false
834
+ }
835
+ ),
836
+ /* @__PURE__ */ jsx7(ComboboxContent, { children: /* @__PURE__ */ jsx7(ComboboxList, { children: options.map((option) => /* @__PURE__ */ jsx7(ComboboxItem, { value: option.value, children: option.label }, option.value)) }) })
837
+ ]
838
+ }
839
+ );
840
+ }
841
+ function GridAsyncComboboxCell({
842
+ value,
843
+ onChange,
844
+ loadOptions,
845
+ placeholder = "Search...",
846
+ minQueryLength = 0,
847
+ debounceMs = 250
848
+ }) {
849
+ const cell = useGridCell();
850
+ const selectedValue = value ?? String(cell.value ?? "");
851
+ const [query, setQuery] = React3.useState("");
852
+ const [options, setOptions] = React3.useState([]);
853
+ const [selectedOption, setSelectedOption] = React3.useState(null);
854
+ const [isLoading, setIsLoading] = React3.useState(false);
855
+ const requestId = React3.useRef(0);
856
+ const loadOptionsRef = React3.useRef(loadOptions);
857
+ React3.useEffect(() => {
858
+ loadOptionsRef.current = loadOptions;
859
+ }, [loadOptions]);
860
+ const stableLoadOptions = React3.useCallback(
861
+ (search) => loadOptionsRef.current(search),
862
+ []
863
+ );
864
+ React3.useEffect(() => {
865
+ const currentRequestId = ++requestId.current;
866
+ const normalizedQuery = query.trim();
867
+ if (normalizedQuery.length < minQueryLength) {
868
+ setOptions([]);
869
+ setIsLoading(false);
870
+ return;
871
+ }
872
+ const timeout = window.setTimeout(async () => {
873
+ setIsLoading(true);
874
+ try {
875
+ const nextOptions = await stableLoadOptions(normalizedQuery);
876
+ if (currentRequestId === requestId.current) {
877
+ setOptions(nextOptions);
878
+ }
879
+ } catch {
880
+ if (currentRequestId === requestId.current) {
881
+ setOptions([]);
882
+ }
883
+ } finally {
884
+ if (currentRequestId === requestId.current) {
885
+ setIsLoading(false);
886
+ }
887
+ }
888
+ }, debounceMs);
889
+ return () => {
890
+ window.clearTimeout(timeout);
891
+ if (requestId.current === currentRequestId) {
892
+ requestId.current += 1;
893
+ }
894
+ };
895
+ }, [debounceMs, minQueryLength, query, stableLoadOptions]);
896
+ const selectedItem = options.find((option) => option.value === selectedValue) ?? (selectedOption?.value === selectedValue ? selectedOption : null);
897
+ return /* @__PURE__ */ jsxs2(
898
+ Combobox,
899
+ {
900
+ items: options,
901
+ itemToStringLabel: (item) => item?.label ?? "",
902
+ itemToStringValue: (item) => item?.value ?? "",
903
+ onValueChange: (nextOption) => {
904
+ if (nextOption === null) return;
905
+ setSelectedOption(nextOption);
906
+ onChange?.(nextOption.value, nextOption);
907
+ cell.grid.updateCell(cell.rowId, cell.columnId, nextOption.value);
908
+ setQuery(nextOption.label);
909
+ },
910
+ value: selectedItem,
911
+ children: [
912
+ /* @__PURE__ */ jsx7(
913
+ ComboboxInput,
914
+ {
915
+ className: "h-7 w-full min-w-0 border-0 bg-transparent px-0 shadow-none",
916
+ onChange: (event) => setQuery(event.target.value),
917
+ placeholder,
918
+ showClear: false,
919
+ value: query
920
+ }
921
+ ),
922
+ /* @__PURE__ */ jsxs2(ComboboxContent, { children: [
923
+ isLoading && /* @__PURE__ */ jsx7(ComboboxEmpty, { children: "Loading..." }),
924
+ !isLoading && query.trim().length >= minQueryLength && options.length === 0 && /* @__PURE__ */ jsx7(ComboboxEmpty, { children: "No results found." }),
925
+ /* @__PURE__ */ jsx7(ComboboxList, { children: options.map((option) => /* @__PURE__ */ jsx7(ComboboxItem, { value: option, children: option.label }, option.value)) })
926
+ ] })
927
+ ]
928
+ }
929
+ );
930
+ }
931
+ function DataTableColumnResize() {
932
+ return /* @__PURE__ */ jsx7("span", { "aria-hidden": true, className: "absolute inset-y-0 right-0 w-px" });
933
+ }
934
+ function DataGridClipboard({
935
+ children
936
+ }) {
937
+ return /* @__PURE__ */ jsx7(Fragment, { children });
938
+ }
939
+ function DataGridFillHandle({
940
+ children
941
+ }) {
942
+ return /* @__PURE__ */ jsx7(Fragment, { children });
943
+ }
944
+ function DataGridMove({ children }) {
945
+ return /* @__PURE__ */ jsx7(Fragment, { children });
946
+ }
947
+
948
+ // src/hooks/useMediaQuery.ts
949
+ import { useEffect as useEffect3, useState as useState3 } from "react";
950
+ function useMediaQuery(query) {
951
+ const [matches, setMatches] = useState3(false);
952
+ useEffect3(() => {
953
+ const mediaQuery = window.matchMedia(query);
954
+ const handleChange = () => setMatches(mediaQuery.matches);
955
+ handleChange();
956
+ mediaQuery.addEventListener("change", handleChange);
957
+ return () => mediaQuery.removeEventListener("change", handleChange);
958
+ }, [query]);
959
+ return matches;
960
+ }
961
+
962
+ // src/hooks/useMounted.ts
963
+ import { useEffect as useEffect4, useState as useState4 } from "react";
964
+ function useMounted() {
965
+ const [mounted, setMounted] = useState4(false);
966
+ useEffect4(() => {
967
+ setMounted(true);
968
+ }, []);
969
+ return { mounted };
970
+ }
971
+
972
+ export {
973
+ buttonVariants,
974
+ Button,
975
+ Input,
976
+ Textarea,
977
+ InputGroup,
978
+ InputGroupAddon,
979
+ InputGroupButton,
980
+ InputGroupText,
981
+ InputGroupInput,
982
+ InputGroupTextarea,
983
+ Combobox,
984
+ ComboboxValue,
985
+ ComboboxTrigger,
986
+ ComboboxInput,
987
+ ComboboxContent,
988
+ ComboboxList,
989
+ ComboboxItem,
990
+ ComboboxGroup,
991
+ ComboboxLabel,
992
+ ComboboxCollection,
993
+ ComboboxEmpty,
994
+ ComboboxSeparator,
995
+ ComboboxChips,
996
+ ComboboxChip,
997
+ ComboboxChipsInput,
998
+ useComboboxAnchor,
999
+ useDataTable,
1000
+ DataTableRoot,
1001
+ useDataTablePagination,
1002
+ useDataTableRows,
1003
+ useDataTableSearch,
1004
+ useDataGrid,
1005
+ DataGrid,
1006
+ DataGridRow,
1007
+ DataGridColumn,
1008
+ DataGridCell,
1009
+ GridTextCell,
1010
+ GridNumberCell,
1011
+ GridComboboxCell,
1012
+ GridAsyncComboboxCell,
1013
+ DataTableColumnResize,
1014
+ DataGridClipboard,
1015
+ DataGridFillHandle,
1016
+ DataGridMove,
1017
+ useMediaQuery,
1018
+ useMounted
1019
+ };