@invana/forms 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,1157 @@
1
+ 'use strict';
2
+
3
+ var ui = require('@invana/ui');
4
+ var React2 = require('react');
5
+ var reactSlot = require('@radix-ui/react-slot');
6
+ var reactHookForm = require('react-hook-form');
7
+ var LabelPrimitive = require('@radix-ui/react-label');
8
+ var classVarianceAuthority = require('class-variance-authority');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+ var SwitchPrimitives = require('@radix-ui/react-switch');
11
+ var SelectPrimitive = require('@radix-ui/react-select');
12
+ var lucideReact = require('lucide-react');
13
+ var SliderPrimitive = require('@radix-ui/react-slider');
14
+ var CheckboxPrimitive = require('@radix-ui/react-checkbox');
15
+ var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
16
+
17
+ function _interopNamespace(e) {
18
+ if (e && e.__esModule) return e;
19
+ var n = Object.create(null);
20
+ if (e) {
21
+ Object.keys(e).forEach(function (k) {
22
+ if (k !== 'default') {
23
+ var d = Object.getOwnPropertyDescriptor(e, k);
24
+ Object.defineProperty(n, k, d.get ? d : {
25
+ enumerable: true,
26
+ get: function () { return e[k]; }
27
+ });
28
+ }
29
+ });
30
+ }
31
+ n.default = e;
32
+ return Object.freeze(n);
33
+ }
34
+
35
+ var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
36
+ var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
37
+ var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
38
+ var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
39
+ var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
40
+ var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
41
+ var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
42
+
43
+ // src/form-field.tsx
44
+ var labelVariants = classVarianceAuthority.cva(
45
+ "font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
46
+ );
47
+ var Label = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
48
+ LabelPrimitive__namespace.Root,
49
+ {
50
+ ref,
51
+ className: ui.cn(labelVariants(), className),
52
+ ...props
53
+ }
54
+ ));
55
+ Label.displayName = LabelPrimitive__namespace.Root.displayName;
56
+ var Form = reactHookForm.FormProvider;
57
+ var FormFieldContext = React2__namespace.createContext(
58
+ {}
59
+ );
60
+ var FormField = ({
61
+ ...props
62
+ }) => {
63
+ return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
64
+ };
65
+ var useFormField = () => {
66
+ const fieldContext = React2__namespace.useContext(FormFieldContext);
67
+ const itemContext = React2__namespace.useContext(FormItemContext);
68
+ const { getFieldState, formState } = reactHookForm.useFormContext();
69
+ const fieldState = getFieldState(fieldContext.name, formState);
70
+ if (!fieldContext) {
71
+ throw new Error("useFormField should be used within <FormField>");
72
+ }
73
+ const { id } = itemContext;
74
+ return {
75
+ id,
76
+ name: fieldContext.name,
77
+ formItemId: `${id}-form-item`,
78
+ formDescriptionId: `${id}-form-item-description`,
79
+ formMessageId: `${id}-form-item-message`,
80
+ ...fieldState
81
+ };
82
+ };
83
+ var FormItemContext = React2__namespace.createContext(
84
+ {}
85
+ );
86
+ var FormItem = React2__namespace.forwardRef(({ className, ...props }, ref) => {
87
+ const id = React2__namespace.useId();
88
+ return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: ui.cn("space-y-2", className), ...props }) });
89
+ });
90
+ FormItem.displayName = "FormItem";
91
+ var FormLabel = React2__namespace.forwardRef(({ className, ...props }, ref) => {
92
+ const { error, formItemId } = useFormField();
93
+ return /* @__PURE__ */ jsxRuntime.jsx(
94
+ Label,
95
+ {
96
+ ref,
97
+ className: ui.cn(error && "text-destructive", className),
98
+ htmlFor: formItemId,
99
+ ...props
100
+ }
101
+ );
102
+ });
103
+ FormLabel.displayName = "FormLabel";
104
+ var FormControl = React2__namespace.forwardRef(({ ...props }, ref) => {
105
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
106
+ return /* @__PURE__ */ jsxRuntime.jsx(
107
+ reactSlot.Slot,
108
+ {
109
+ ref,
110
+ id: formItemId,
111
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
112
+ "aria-invalid": !!error,
113
+ ...props
114
+ }
115
+ );
116
+ });
117
+ FormControl.displayName = "FormControl";
118
+ var FormDescription = React2__namespace.forwardRef(({ className, ...props }, ref) => {
119
+ const { formDescriptionId } = useFormField();
120
+ return /* @__PURE__ */ jsxRuntime.jsx(
121
+ "p",
122
+ {
123
+ ref,
124
+ id: formDescriptionId,
125
+ className: ui.cn("text-[0.8rem] text-muted-foreground", className),
126
+ ...props
127
+ }
128
+ );
129
+ });
130
+ FormDescription.displayName = "FormDescription";
131
+ var FormMessage = React2__namespace.forwardRef(({ className, children, ...props }, ref) => {
132
+ const { error, formMessageId } = useFormField();
133
+ const body = error ? String(error?.message) : children;
134
+ if (!body) {
135
+ return null;
136
+ }
137
+ return /* @__PURE__ */ jsxRuntime.jsx(
138
+ "p",
139
+ {
140
+ ref,
141
+ id: formMessageId,
142
+ className: ui.cn("text-[0.8rem] font-medium text-destructive", className),
143
+ ...props,
144
+ children: body
145
+ }
146
+ );
147
+ });
148
+ FormMessage.displayName = "FormMessage";
149
+ var Input = React2__namespace.forwardRef(
150
+ ({ className, type, ...props }, ref) => {
151
+ return /* @__PURE__ */ jsxRuntime.jsx(
152
+ "input",
153
+ {
154
+ type,
155
+ className: ui.cn(
156
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
157
+ className
158
+ ),
159
+ ref,
160
+ ...props
161
+ }
162
+ );
163
+ }
164
+ );
165
+ Input.displayName = "Input";
166
+ var Switch = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
167
+ SwitchPrimitives__namespace.Root,
168
+ {
169
+ className: ui.cn(
170
+ "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border border-border shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:border-primary data-[state=unchecked]:bg-input",
171
+ className
172
+ ),
173
+ ...props,
174
+ ref,
175
+ children: /* @__PURE__ */ jsxRuntime.jsx(
176
+ SwitchPrimitives__namespace.Thumb,
177
+ {
178
+ className: ui.cn(
179
+ "pointer-events-none block h-5 w-5 rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 data-[state=checked]:bg-primary-foreground data-[state=unchecked]:bg-foreground"
180
+ )
181
+ }
182
+ )
183
+ }
184
+ ));
185
+ Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
186
+ var Select = SelectPrimitive__namespace.Root;
187
+ var SelectGroup = SelectPrimitive__namespace.Group;
188
+ var SelectValue = SelectPrimitive__namespace.Value;
189
+ var SelectTrigger = React2__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
190
+ SelectPrimitive__namespace.Trigger,
191
+ {
192
+ ref,
193
+ className: ui.cn(
194
+ "flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
195
+ className
196
+ ),
197
+ ...props,
198
+ children: [
199
+ children,
200
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4 opacity-50" }) })
201
+ ]
202
+ }
203
+ ));
204
+ SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
205
+ var SelectScrollUpButton = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
206
+ SelectPrimitive__namespace.ScrollUpButton,
207
+ {
208
+ ref,
209
+ className: ui.cn(
210
+ "flex cursor-default items-center justify-center py-1",
211
+ className
212
+ ),
213
+ ...props,
214
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "h-4 w-4" })
215
+ }
216
+ ));
217
+ SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
218
+ var SelectScrollDownButton = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
219
+ SelectPrimitive__namespace.ScrollDownButton,
220
+ {
221
+ ref,
222
+ className: ui.cn(
223
+ "flex cursor-default items-center justify-center py-1",
224
+ className
225
+ ),
226
+ ...props,
227
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4" })
228
+ }
229
+ ));
230
+ SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
231
+ var SelectContent = React2__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
232
+ SelectPrimitive__namespace.Content,
233
+ {
234
+ ref,
235
+ className: ui.cn(
236
+ "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-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",
237
+ position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
238
+ className
239
+ ),
240
+ position,
241
+ ...props,
242
+ children: [
243
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton, {}),
244
+ /* @__PURE__ */ jsxRuntime.jsx(
245
+ SelectPrimitive__namespace.Viewport,
246
+ {
247
+ className: ui.cn(
248
+ "p-1",
249
+ position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
250
+ ),
251
+ children
252
+ }
253
+ ),
254
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollDownButton, {})
255
+ ]
256
+ }
257
+ ) }));
258
+ SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
259
+ var SelectLabel = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
260
+ SelectPrimitive__namespace.Label,
261
+ {
262
+ ref,
263
+ className: ui.cn("px-2 py-1.5 text-sm font-semibold", className),
264
+ ...props
265
+ }
266
+ ));
267
+ SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
268
+ var SelectItem = React2__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
269
+ SelectPrimitive__namespace.Item,
270
+ {
271
+ ref,
272
+ className: ui.cn(
273
+ "relative flex w-full cursor-default select-none items-center rounded-md py-1.5 pl-2 pr-8 outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
274
+ className
275
+ ),
276
+ ...props,
277
+ children: [
278
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) }),
279
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children })
280
+ ]
281
+ }
282
+ ));
283
+ SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
284
+ var SelectSeparator = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
285
+ SelectPrimitive__namespace.Separator,
286
+ {
287
+ ref,
288
+ className: ui.cn("-mx-1 my-1 h-px bg-muted", className),
289
+ ...props
290
+ }
291
+ ));
292
+ SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
293
+ var DEFAULT_PRESETS = [
294
+ { label: "Black", value: "rgb(0, 0, 0)", darkValue: "rgb(255, 255, 255)" },
295
+ { label: "Red", value: "rgb(239, 68, 68)" },
296
+ { label: "Blue", value: "rgb(59, 130, 246)" }
297
+ ];
298
+ var ColorSwatches = ({
299
+ value,
300
+ onChange,
301
+ presetColors = DEFAULT_PRESETS,
302
+ defaultValue = "rgb(0, 0, 0)"
303
+ }) => {
304
+ const [customColor, setCustomColor] = React2__namespace.useState(value || defaultValue);
305
+ const [isCustom, setIsCustom] = React2__namespace.useState(false);
306
+ React2__namespace.useEffect(() => {
307
+ if (!value) return;
308
+ const isPreset = presetColors.some((c) => c.value === value);
309
+ setIsCustom(!isPreset);
310
+ if (!isPreset) setCustomColor(value);
311
+ }, [value, presetColors]);
312
+ const select = (newColor, custom = false) => {
313
+ setIsCustom(custom);
314
+ if (custom) setCustomColor(newColor);
315
+ onChange?.(newColor);
316
+ };
317
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
318
+ presetColors.map((color) => /* @__PURE__ */ jsxRuntime.jsxs(
319
+ "button",
320
+ {
321
+ type: "button",
322
+ onClick: () => select(color.value),
323
+ className: ui.cn(
324
+ "group relative h-8 w-8 overflow-hidden rounded-md border",
325
+ "ring-offset-background transition-all hover:scale-105",
326
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
327
+ !isCustom && value === color.value && "ring-2 ring-ring ring-offset-2"
328
+ ),
329
+ children: [
330
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-full", style: { backgroundColor: color.value } }),
331
+ !isCustom && value === color.value && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/30", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4 text-white" }) }),
332
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sr-only", children: [
333
+ "Select ",
334
+ color.label
335
+ ] })
336
+ ]
337
+ },
338
+ color.label
339
+ )),
340
+ /* @__PURE__ */ jsxRuntime.jsxs(
341
+ "div",
342
+ {
343
+ className: ui.cn(
344
+ "group relative h-8 w-8 overflow-hidden rounded-md border",
345
+ "ring-offset-background transition-all hover:scale-105",
346
+ isCustom && "ring-2 ring-ring ring-offset-2"
347
+ ),
348
+ children: [
349
+ /* @__PURE__ */ jsxRuntime.jsx(
350
+ "input",
351
+ {
352
+ type: "color",
353
+ value: customColor,
354
+ onChange: (e) => select(e.target.value, true),
355
+ className: "absolute inset-0 cursor-pointer opacity-0"
356
+ }
357
+ ),
358
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-full", style: { backgroundColor: customColor } }),
359
+ isCustom && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/30", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4 text-white" }) }),
360
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Custom color" })
361
+ ]
362
+ }
363
+ )
364
+ ] });
365
+ };
366
+ var Slider = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
367
+ SliderPrimitive__namespace.Root,
368
+ {
369
+ ref,
370
+ className: ui.cn(
371
+ "relative flex w-full touch-none select-none items-center",
372
+ className
373
+ ),
374
+ ...props,
375
+ children: [
376
+ /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Track, { className: "relative h-2 w-full grow overflow-hidden rounded-full bg-secondary", children: /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Range, { className: "absolute h-full bg-primary" }) }),
377
+ /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Thumb, { className: "block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" })
378
+ ]
379
+ }
380
+ ));
381
+ Slider.displayName = SliderPrimitive__namespace.Root.displayName;
382
+ var SliderNumber = ({
383
+ value = 0,
384
+ onChange,
385
+ min = 0,
386
+ max = 100,
387
+ step = 1,
388
+ className
389
+ }) => {
390
+ const [local, setLocal] = React2__namespace.useState(value);
391
+ React2__namespace.useEffect(() => {
392
+ setLocal(value);
393
+ }, [value]);
394
+ const set = (n) => {
395
+ setLocal(n);
396
+ onChange?.(n);
397
+ };
398
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cn("flex items-center gap-2", className), children: [
399
+ /* @__PURE__ */ jsxRuntime.jsx(
400
+ Slider,
401
+ {
402
+ value: [local],
403
+ onValueChange: ([n]) => set(n),
404
+ min,
405
+ max,
406
+ step,
407
+ className: "flex-1"
408
+ }
409
+ ),
410
+ /* @__PURE__ */ jsxRuntime.jsx(
411
+ Input,
412
+ {
413
+ type: "number",
414
+ value: local,
415
+ onChange: (e) => set(Number(e.target.value)),
416
+ className: "h-8 w-16",
417
+ min,
418
+ max,
419
+ step
420
+ }
421
+ )
422
+ ] });
423
+ };
424
+ var IconInput = ({ value, onChange }) => {
425
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
426
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md border bg-muted text-sm", children: value ? value.slice(0, 2) : "\u2013" }),
427
+ /* @__PURE__ */ jsxRuntime.jsx(
428
+ Input,
429
+ {
430
+ type: "text",
431
+ value: value ?? "",
432
+ onChange: (e) => onChange?.(e.target.value),
433
+ placeholder: "icon name",
434
+ className: "h-8 text-sm"
435
+ }
436
+ )
437
+ ] });
438
+ };
439
+ function itemClasses(labelPosition, className) {
440
+ return ui.cn(
441
+ labelPosition === "side" && "grid grid-cols-3 items-center gap-2",
442
+ labelPosition === "top" && "space-y-2",
443
+ className
444
+ );
445
+ }
446
+ function inputWrapper(labelPosition) {
447
+ return ui.cn(labelPosition === "side" && "col-span-2", "space-y-1");
448
+ }
449
+ var InputField = ({
450
+ label,
451
+ description,
452
+ placeholder,
453
+ value,
454
+ onChange,
455
+ labelPosition = "side",
456
+ className
457
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
458
+ label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: "text-xs", children: label }),
459
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
460
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
461
+ Input,
462
+ {
463
+ className: "h-8 text-sm",
464
+ placeholder,
465
+ value: value ?? "",
466
+ onChange: (e) => onChange?.(e.target.value)
467
+ }
468
+ ) }),
469
+ description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: "text-xs", children: description }),
470
+ /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: "text-xs" })
471
+ ] })
472
+ ] });
473
+ var SelectField = ({
474
+ label,
475
+ description,
476
+ options = [],
477
+ value,
478
+ onChange,
479
+ placeholder = "Select type",
480
+ labelPosition = "side",
481
+ className
482
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
483
+ label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: "text-xs", children: label }),
484
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
485
+ /* @__PURE__ */ jsxRuntime.jsxs(Select, { value: value ?? "", onValueChange: onChange, children: [
486
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder }) }) }),
487
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.map((o) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: o.value, children: o.label }, o.value)) })
488
+ ] }),
489
+ description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: "text-xs", children: description }),
490
+ /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: "text-xs" })
491
+ ] })
492
+ ] });
493
+ var BooleanField = ({
494
+ label,
495
+ description,
496
+ value,
497
+ onChange,
498
+ labelPosition = "side"
499
+ }) => {
500
+ if (labelPosition === "side") {
501
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "flex items-center justify-between rounded-md border p-2", children: [
502
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
503
+ label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: "text-xs", children: label }),
504
+ description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: "text-xs", children: description })
505
+ ] }),
506
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(Switch, { checked: !!value, onCheckedChange: onChange }) })
507
+ ] });
508
+ }
509
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "space-y-2", children: [
510
+ label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: "text-xs", children: label }),
511
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between rounded-md border p-2", children: [
512
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(Switch, { checked: !!value, onCheckedChange: onChange }) }),
513
+ description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: "ml-2 text-xs", children: description })
514
+ ] })
515
+ ] });
516
+ };
517
+ var ColorField = ({
518
+ label,
519
+ description,
520
+ value,
521
+ onChange,
522
+ presetColors,
523
+ defaultValue,
524
+ labelPosition = "side",
525
+ className
526
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
527
+ label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: "text-xs", children: label }),
528
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
529
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
530
+ ColorSwatches,
531
+ {
532
+ value,
533
+ onChange,
534
+ presetColors,
535
+ defaultValue
536
+ }
537
+ ) }),
538
+ description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: "text-xs", children: description }),
539
+ /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: "text-xs" })
540
+ ] })
541
+ ] });
542
+ var NumberField = ({
543
+ label,
544
+ description,
545
+ value,
546
+ onChange,
547
+ min,
548
+ max,
549
+ step,
550
+ labelPosition = "side",
551
+ className
552
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
553
+ label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: "text-xs", children: label }),
554
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
555
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
556
+ SliderNumber,
557
+ {
558
+ value: typeof value === "number" ? value : 0,
559
+ onChange,
560
+ min,
561
+ max,
562
+ step
563
+ }
564
+ ) }),
565
+ description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: "text-xs", children: description }),
566
+ /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: "text-xs" })
567
+ ] })
568
+ ] });
569
+ var IconField = ({
570
+ label,
571
+ description,
572
+ value,
573
+ onChange,
574
+ labelPosition = "side",
575
+ className
576
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
577
+ label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: "text-xs", children: label }),
578
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
579
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(IconInput, { value, onChange }) }),
580
+ description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: "text-xs", children: description }),
581
+ /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: "text-xs" })
582
+ ] })
583
+ ] });
584
+ var Field = {
585
+ Input: InputField,
586
+ Boolean: BooleanField,
587
+ Color: ColorField,
588
+ Number: NumberField,
589
+ Select: SelectField,
590
+ Icon: IconField
591
+ };
592
+ function humanize(name) {
593
+ return name.replace(/([A-Z])/g, " $1").replace(/^./, (c) => c.toUpperCase()).trim();
594
+ }
595
+ function chunk(arr, size) {
596
+ const out = [];
597
+ for (let i = 0; i < arr.length; i += size) out.push(arr.slice(i, i + size));
598
+ return out;
599
+ }
600
+ function renderField(field, parentName, control, labelPosition) {
601
+ return /* @__PURE__ */ jsxRuntime.jsx(
602
+ FormField,
603
+ {
604
+ control,
605
+ name: `${parentName}.${field.name}`,
606
+ defaultValue: field.defaultValue,
607
+ render: ({ field: rhf }) => {
608
+ const common = {
609
+ label: field.label ?? humanize(field.name),
610
+ description: field.description,
611
+ options: field.options,
612
+ min: field.min,
613
+ max: field.max,
614
+ step: field.step,
615
+ presetColors: field.presetColors,
616
+ defaultValue: field.defaultValue,
617
+ labelPosition,
618
+ value: rhf.value,
619
+ onChange: rhf.onChange
620
+ };
621
+ switch (field.type) {
622
+ case "boolean":
623
+ return /* @__PURE__ */ jsxRuntime.jsx(BooleanField, { ...common });
624
+ case "color":
625
+ return /* @__PURE__ */ jsxRuntime.jsx(ColorField, { ...common });
626
+ case "number":
627
+ return /* @__PURE__ */ jsxRuntime.jsx(NumberField, { ...common });
628
+ case "select":
629
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectField, { ...common });
630
+ case "icon":
631
+ return /* @__PURE__ */ jsxRuntime.jsx(IconField, { ...common });
632
+ case "text":
633
+ default:
634
+ return /* @__PURE__ */ jsxRuntime.jsx(
635
+ InputField,
636
+ {
637
+ ...common,
638
+ placeholder: field.placeholder ?? `Enter ${field.name}`
639
+ }
640
+ );
641
+ }
642
+ }
643
+ },
644
+ field.name
645
+ );
646
+ }
647
+ function renderRows(fields, rowConfig, parentName, control, labelPosition) {
648
+ if (!rowConfig || rowConfig.length === 0) {
649
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-4", children: chunk(fields, 2).map((row, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: row.map((f) => renderField(f, parentName, control, labelPosition)) }, i)) });
650
+ }
651
+ const used = new Set(rowConfig.flatMap((r) => r.fields));
652
+ const unassigned = fields.filter((f) => !used.has(f.name));
653
+ const byName = new Map(fields.map((f) => [f.name, f]));
654
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
655
+ rowConfig.map((row) => {
656
+ const rowFields = row.fields.map((n) => byName.get(n)).filter((f) => !!f);
657
+ return chunk(rowFields, 2).map((cnk, idx) => /* @__PURE__ */ jsxRuntime.jsx(
658
+ "div",
659
+ {
660
+ className: "grid grid-cols-1 gap-4 md:grid-cols-2",
661
+ children: cnk.map((f) => renderField(f, parentName, control, labelPosition))
662
+ },
663
+ `${row.id}-${idx}`
664
+ ));
665
+ }),
666
+ unassigned.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-4", children: chunk(unassigned, 2).map((row, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: row.map((f) => renderField(f, parentName, control, labelPosition)) }, `u-${i}`)) })
667
+ ] });
668
+ }
669
+ var ObjectField = ({
670
+ control,
671
+ name,
672
+ fields,
673
+ rowConfig,
674
+ labelPosition = "side"
675
+ }) => {
676
+ const grouped = fields.reduce((acc, f) => {
677
+ const key = f.group ?? "_ungrouped";
678
+ (acc[key] ??= []).push(f);
679
+ return acc;
680
+ }, {});
681
+ const ungrouped = grouped["_ungrouped"] ?? [];
682
+ delete grouped["_ungrouped"];
683
+ const groupedEntries = Object.entries(grouped);
684
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
685
+ ungrouped.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: renderRows(ungrouped, rowConfig, name, control, labelPosition) }),
686
+ groupedEntries.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
687
+ ui.Accordion,
688
+ {
689
+ type: "multiple",
690
+ defaultValue: groupedEntries.map(([k]) => k),
691
+ className: "w-full space-y-2",
692
+ children: groupedEntries.map(([group, gFields]) => /* @__PURE__ */ jsxRuntime.jsxs(ui.AccordionItem, { value: group, className: "rounded-md border", children: [
693
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.AccordionTrigger, { className: "px-3 text-sm font-medium hover:no-underline", children: [
694
+ humanize(group),
695
+ " Settings"
696
+ ] }),
697
+ /* @__PURE__ */ jsxRuntime.jsx(ui.AccordionContent, { className: "px-3 pb-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: renderRows(gFields, rowConfig, name, control, labelPosition) }) })
698
+ ] }, group))
699
+ }
700
+ )
701
+ ] });
702
+ };
703
+ var FormField2 = Object.assign(FormField, {
704
+ ObjectField,
705
+ Input: InputField,
706
+ Boolean: BooleanField,
707
+ Color: ColorField,
708
+ Number: NumberField,
709
+ Select: SelectField,
710
+ Icon: IconField
711
+ });
712
+ var Textarea = React2__namespace.forwardRef(({ className, ...props }, ref) => {
713
+ return /* @__PURE__ */ jsxRuntime.jsx(
714
+ "textarea",
715
+ {
716
+ className: ui.cn(
717
+ "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
718
+ className
719
+ ),
720
+ ref,
721
+ ...props
722
+ }
723
+ );
724
+ });
725
+ Textarea.displayName = "Textarea";
726
+ var Checkbox = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
727
+ CheckboxPrimitive__namespace.Root,
728
+ {
729
+ ref,
730
+ className: ui.cn(
731
+ "peer h-4 w-4 shrink-0 rounded-md border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
732
+ className
733
+ ),
734
+ ...props,
735
+ children: /* @__PURE__ */ jsxRuntime.jsx(
736
+ CheckboxPrimitive__namespace.Indicator,
737
+ {
738
+ className: ui.cn("flex items-center justify-center text-current"),
739
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" })
740
+ }
741
+ )
742
+ }
743
+ ));
744
+ Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
745
+ var RadioGroup = React2__namespace.forwardRef(({ className, ...props }, ref) => {
746
+ return /* @__PURE__ */ jsxRuntime.jsx(
747
+ RadioGroupPrimitive__namespace.Root,
748
+ {
749
+ className: ui.cn("grid gap-2", className),
750
+ ...props,
751
+ ref
752
+ }
753
+ );
754
+ });
755
+ RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
756
+ var RadioGroupItem = React2__namespace.forwardRef(({ className, ...props }, ref) => {
757
+ return /* @__PURE__ */ jsxRuntime.jsx(
758
+ RadioGroupPrimitive__namespace.Item,
759
+ {
760
+ ref,
761
+ className: ui.cn(
762
+ "aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
763
+ className
764
+ ),
765
+ ...props,
766
+ children: /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Indicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { className: "h-2.5 w-2.5 fill-current text-current" }) })
767
+ }
768
+ );
769
+ });
770
+ RadioGroupItem.displayName = RadioGroupPrimitive__namespace.Item.displayName;
771
+ function FieldSet({ className, ...props }) {
772
+ return /* @__PURE__ */ jsxRuntime.jsx(
773
+ "fieldset",
774
+ {
775
+ "data-slot": "field-set",
776
+ className: ui.cn(
777
+ "flex flex-col gap-6",
778
+ "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
779
+ className
780
+ ),
781
+ ...props
782
+ }
783
+ );
784
+ }
785
+ function FieldLegend({
786
+ className,
787
+ variant = "legend",
788
+ ...props
789
+ }) {
790
+ return /* @__PURE__ */ jsxRuntime.jsx(
791
+ "legend",
792
+ {
793
+ "data-slot": "field-legend",
794
+ "data-variant": variant,
795
+ className: ui.cn(
796
+ "mb-3 font-medium",
797
+ "data-[variant=legend]:text-base",
798
+ "data-[variant=label]:text-sm",
799
+ className
800
+ ),
801
+ ...props
802
+ }
803
+ );
804
+ }
805
+ function FieldGroup({ className, ...props }) {
806
+ return /* @__PURE__ */ jsxRuntime.jsx(
807
+ "div",
808
+ {
809
+ "data-slot": "field-group",
810
+ className: ui.cn(
811
+ "group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
812
+ className
813
+ ),
814
+ ...props
815
+ }
816
+ );
817
+ }
818
+ classVarianceAuthority.cva(
819
+ "group/field data-[invalid=true]:text-destructive flex w-full gap-3",
820
+ {
821
+ variants: {
822
+ orientation: {
823
+ vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
824
+ horizontal: [
825
+ "flex-row items-center",
826
+ "[&>[data-slot=field-label]]:flex-auto",
827
+ "has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px has-[>[data-slot=field-content]]:items-start"
828
+ ],
829
+ responsive: [
830
+ "@md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto flex-col [&>*]:w-full [&>.sr-only]:w-auto",
831
+ "@md/field-group:[&>[data-slot=field-label]]:flex-auto",
832
+ "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
833
+ ]
834
+ }
835
+ },
836
+ defaultVariants: {
837
+ orientation: "vertical"
838
+ }
839
+ }
840
+ );
841
+ function FieldContent({ className, ...props }) {
842
+ return /* @__PURE__ */ jsxRuntime.jsx(
843
+ "div",
844
+ {
845
+ "data-slot": "field-content",
846
+ className: ui.cn(
847
+ "group/field-content flex flex-1 flex-col gap-1.5 leading-snug",
848
+ className
849
+ ),
850
+ ...props
851
+ }
852
+ );
853
+ }
854
+ function FieldLabel({
855
+ className,
856
+ ...props
857
+ }) {
858
+ return /* @__PURE__ */ jsxRuntime.jsx(
859
+ Label,
860
+ {
861
+ "data-slot": "field-label",
862
+ className: ui.cn(
863
+ "group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",
864
+ "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>[data-slot=field]]:p-4",
865
+ "has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10",
866
+ className
867
+ ),
868
+ ...props
869
+ }
870
+ );
871
+ }
872
+ function FieldTitle({ className, ...props }) {
873
+ return /* @__PURE__ */ jsxRuntime.jsx(
874
+ "div",
875
+ {
876
+ "data-slot": "field-label",
877
+ className: ui.cn(
878
+ "flex w-fit items-center gap-2 text-sm font-medium leading-snug group-data-[disabled=true]/field:opacity-50",
879
+ className
880
+ ),
881
+ ...props
882
+ }
883
+ );
884
+ }
885
+ function FieldDescription({ className, ...props }) {
886
+ return /* @__PURE__ */ jsxRuntime.jsx(
887
+ "p",
888
+ {
889
+ "data-slot": "field-description",
890
+ className: ui.cn(
891
+ "text-muted-foreground text-sm font-normal leading-normal group-has-[[data-orientation=horizontal]]/field:text-balance",
892
+ "nth-last-2:-mt-1 last:mt-0 [[data-variant=legend]+&]:-mt-1.5",
893
+ "[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",
894
+ className
895
+ ),
896
+ ...props
897
+ }
898
+ );
899
+ }
900
+ function FieldSeparator({
901
+ children,
902
+ className,
903
+ ...props
904
+ }) {
905
+ return /* @__PURE__ */ jsxRuntime.jsxs(
906
+ "div",
907
+ {
908
+ "data-slot": "field-separator",
909
+ "data-content": !!children,
910
+ className: ui.cn(
911
+ "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
912
+ className
913
+ ),
914
+ ...props,
915
+ children: [
916
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Separator, { className: "absolute inset-0 top-1/2" }),
917
+ children && /* @__PURE__ */ jsxRuntime.jsx(
918
+ "span",
919
+ {
920
+ className: "bg-background text-muted-foreground relative mx-auto block w-fit px-2",
921
+ "data-slot": "field-separator-content",
922
+ children
923
+ }
924
+ )
925
+ ]
926
+ }
927
+ );
928
+ }
929
+ function FieldError({
930
+ className,
931
+ children,
932
+ errors,
933
+ ...props
934
+ }) {
935
+ const content = React2.useMemo(() => {
936
+ if (children) {
937
+ return children;
938
+ }
939
+ if (!errors) {
940
+ return null;
941
+ }
942
+ if (errors?.length === 1 && errors[0]?.message) {
943
+ return errors[0].message;
944
+ }
945
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "ml-4 flex list-disc flex-col gap-1", children: errors.map(
946
+ (error, index) => error?.message && /* @__PURE__ */ jsxRuntime.jsx("li", { children: error.message }, index)
947
+ ) });
948
+ }, [children, errors]);
949
+ if (!content) {
950
+ return null;
951
+ }
952
+ return /* @__PURE__ */ jsxRuntime.jsx(
953
+ "div",
954
+ {
955
+ role: "alert",
956
+ "data-slot": "field-error",
957
+ className: ui.cn("text-destructive text-sm font-normal", className),
958
+ ...props,
959
+ children: content
960
+ }
961
+ );
962
+ }
963
+ function InputGroup({ className, ...props }) {
964
+ return /* @__PURE__ */ jsxRuntime.jsx(
965
+ "div",
966
+ {
967
+ "data-slot": "input-group",
968
+ role: "group",
969
+ className: ui.cn(
970
+ "group/input-group border-input dark:bg-input/30 shadow-xs relative flex w-full items-center rounded-md border outline-none transition-[color,box-shadow]",
971
+ "h-9 has-[>textarea]:h-auto",
972
+ // Variants based on alignment.
973
+ "has-[>[data-align=inline-start]]:[&>input]:pl-2",
974
+ "has-[>[data-align=inline-end]]:[&>input]:pr-2",
975
+ "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",
976
+ "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",
977
+ // Focus state.
978
+ "has-[[data-slot=input-group-control]:focus-visible]:ring-ring has-[[data-slot=input-group-control]:focus-visible]:ring-1",
979
+ // Error state.
980
+ "has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",
981
+ className
982
+ ),
983
+ ...props
984
+ }
985
+ );
986
+ }
987
+ var inputGroupAddonVariants = classVarianceAuthority.cva(
988
+ "text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
989
+ {
990
+ variants: {
991
+ align: {
992
+ "inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
993
+ "inline-end": "order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]",
994
+ "block-start": "[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5",
995
+ "block-end": "[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"
996
+ }
997
+ },
998
+ defaultVariants: {
999
+ align: "inline-start"
1000
+ }
1001
+ }
1002
+ );
1003
+ function InputGroupAddon({
1004
+ className,
1005
+ align = "inline-start",
1006
+ ...props
1007
+ }) {
1008
+ return /* @__PURE__ */ jsxRuntime.jsx(
1009
+ "div",
1010
+ {
1011
+ role: "group",
1012
+ "data-slot": "input-group-addon",
1013
+ "data-align": align,
1014
+ className: ui.cn(inputGroupAddonVariants({ align }), className),
1015
+ onClick: (e) => {
1016
+ if (e.target.closest("button")) {
1017
+ return;
1018
+ }
1019
+ e.currentTarget.parentElement?.querySelector("input")?.focus();
1020
+ },
1021
+ ...props
1022
+ }
1023
+ );
1024
+ }
1025
+ var inputGroupButtonVariants = classVarianceAuthority.cva(
1026
+ "flex items-center gap-2 text-sm shadow-none",
1027
+ {
1028
+ variants: {
1029
+ size: {
1030
+ xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
1031
+ sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
1032
+ "icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
1033
+ "icon-sm": "size-8 p-0 has-[>svg]:p-0"
1034
+ }
1035
+ },
1036
+ defaultVariants: {
1037
+ size: "xs"
1038
+ }
1039
+ }
1040
+ );
1041
+ function InputGroupButton({
1042
+ className,
1043
+ type = "button",
1044
+ variant = "ghost",
1045
+ size = "xs",
1046
+ ...props
1047
+ }) {
1048
+ return /* @__PURE__ */ jsxRuntime.jsx(
1049
+ ui.Button,
1050
+ {
1051
+ type,
1052
+ "data-size": size,
1053
+ variant,
1054
+ className: ui.cn(inputGroupButtonVariants({ size }), className),
1055
+ ...props
1056
+ }
1057
+ );
1058
+ }
1059
+ function InputGroupText({ className, ...props }) {
1060
+ return /* @__PURE__ */ jsxRuntime.jsx(
1061
+ "span",
1062
+ {
1063
+ className: ui.cn(
1064
+ "text-muted-foreground flex items-center gap-2 text-sm [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",
1065
+ className
1066
+ ),
1067
+ ...props
1068
+ }
1069
+ );
1070
+ }
1071
+ function InputGroupInput({
1072
+ className,
1073
+ ...props
1074
+ }) {
1075
+ return /* @__PURE__ */ jsxRuntime.jsx(
1076
+ Input,
1077
+ {
1078
+ "data-slot": "input-group-control",
1079
+ className: ui.cn(
1080
+ "flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",
1081
+ className
1082
+ ),
1083
+ ...props
1084
+ }
1085
+ );
1086
+ }
1087
+ function InputGroupTextarea({
1088
+ className,
1089
+ ...props
1090
+ }) {
1091
+ return /* @__PURE__ */ jsxRuntime.jsx(
1092
+ Textarea,
1093
+ {
1094
+ "data-slot": "input-group-control",
1095
+ className: ui.cn(
1096
+ "flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",
1097
+ className
1098
+ ),
1099
+ ...props
1100
+ }
1101
+ );
1102
+ }
1103
+
1104
+ exports.BooleanField = BooleanField;
1105
+ exports.Checkbox = Checkbox;
1106
+ exports.ColorField = ColorField;
1107
+ exports.ColorSwatches = ColorSwatches;
1108
+ exports.Field = Field;
1109
+ exports.FieldContent = FieldContent;
1110
+ exports.FieldDescription = FieldDescription;
1111
+ exports.FieldError = FieldError;
1112
+ exports.FieldGroup = FieldGroup;
1113
+ exports.FieldLabel = FieldLabel;
1114
+ exports.FieldLegend = FieldLegend;
1115
+ exports.FieldSeparator = FieldSeparator;
1116
+ exports.FieldSet = FieldSet;
1117
+ exports.FieldTitle = FieldTitle;
1118
+ exports.Form = Form;
1119
+ exports.FormControl = FormControl;
1120
+ exports.FormDescription = FormDescription;
1121
+ exports.FormField = FormField2;
1122
+ exports.FormItem = FormItem;
1123
+ exports.FormLabel = FormLabel;
1124
+ exports.FormMessage = FormMessage;
1125
+ exports.IconField = IconField;
1126
+ exports.IconInput = IconInput;
1127
+ exports.Input = Input;
1128
+ exports.InputField = InputField;
1129
+ exports.InputGroup = InputGroup;
1130
+ exports.InputGroupAddon = InputGroupAddon;
1131
+ exports.InputGroupButton = InputGroupButton;
1132
+ exports.InputGroupInput = InputGroupInput;
1133
+ exports.InputGroupText = InputGroupText;
1134
+ exports.InputGroupTextarea = InputGroupTextarea;
1135
+ exports.Label = Label;
1136
+ exports.NumberField = NumberField;
1137
+ exports.ObjectField = ObjectField;
1138
+ exports.RadioGroup = RadioGroup;
1139
+ exports.RadioGroupItem = RadioGroupItem;
1140
+ exports.Select = Select;
1141
+ exports.SelectContent = SelectContent;
1142
+ exports.SelectField = SelectField;
1143
+ exports.SelectGroup = SelectGroup;
1144
+ exports.SelectItem = SelectItem;
1145
+ exports.SelectLabel = SelectLabel;
1146
+ exports.SelectScrollDownButton = SelectScrollDownButton;
1147
+ exports.SelectScrollUpButton = SelectScrollUpButton;
1148
+ exports.SelectSeparator = SelectSeparator;
1149
+ exports.SelectTrigger = SelectTrigger;
1150
+ exports.SelectValue = SelectValue;
1151
+ exports.Slider = Slider;
1152
+ exports.SliderNumber = SliderNumber;
1153
+ exports.Switch = Switch;
1154
+ exports.Textarea = Textarea;
1155
+ exports.useFormField = useFormField;
1156
+ //# sourceMappingURL=index.cjs.map
1157
+ //# sourceMappingURL=index.cjs.map