@invana/forms 0.0.31 → 0.0.33
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 +467 -317
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -31
- package/dist/index.d.ts +74 -31
- package/dist/index.js +467 -317
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { cn, Accordion, AccordionItem, AccordionTrigger, Badge, AccordionContent, Card, CardContent, Separator, Button } from '@invana/ui';
|
|
2
1
|
import * as React2 from 'react';
|
|
3
2
|
import { useMemo } from 'react';
|
|
3
|
+
import { cn, Eyebrow, Accordion, AccordionItem, AccordionTrigger, Badge, AccordionContent, Button, Card, CardContent, Separator } from '@invana/ui';
|
|
4
4
|
import { Slot } from '@radix-ui/react-slot';
|
|
5
5
|
import { useFormContext, Controller, FormProvider } from 'react-hook-form';
|
|
6
6
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
@@ -67,7 +67,7 @@ var FormLabel = React2.forwardRef(({ className, ...props }, ref) => {
|
|
|
67
67
|
Label,
|
|
68
68
|
{
|
|
69
69
|
ref,
|
|
70
|
-
className: cn(error && "text-destructive"
|
|
70
|
+
className: cn(className, error && "text-destructive"),
|
|
71
71
|
htmlFor: formItemId,
|
|
72
72
|
...props
|
|
73
73
|
}
|
|
@@ -126,8 +126,9 @@ var Input = React2.forwardRef(
|
|
|
126
126
|
{
|
|
127
127
|
type,
|
|
128
128
|
className: cn(
|
|
129
|
-
|
|
130
|
-
"
|
|
129
|
+
"py-0",
|
|
130
|
+
inputSize === "sm" ? "h-control-sm px-2" : inputSize === "lg" ? "h-control-lg px-3" : "h-control-md px-2.5",
|
|
131
|
+
"flex w-full rounded-control border border-input bg-background text-base ring-offset-background file:border-0 file:bg-transparent 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 aria-invalid:border-destructive",
|
|
131
132
|
className
|
|
132
133
|
),
|
|
133
134
|
ref,
|
|
@@ -137,6 +138,176 @@ var Input = React2.forwardRef(
|
|
|
137
138
|
}
|
|
138
139
|
);
|
|
139
140
|
Input.displayName = "Input";
|
|
141
|
+
var Textarea = React2.forwardRef(({ className, inputSize = "default", ...props }, ref) => {
|
|
142
|
+
return /* @__PURE__ */ jsx(
|
|
143
|
+
"textarea",
|
|
144
|
+
{
|
|
145
|
+
className: cn(
|
|
146
|
+
inputSize === "sm" ? "min-h-[52px] px-2 py-1" : "min-h-[80px] px-3 py-2",
|
|
147
|
+
"flex w-full rounded-control border border-input bg-background 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",
|
|
148
|
+
className
|
|
149
|
+
),
|
|
150
|
+
ref,
|
|
151
|
+
...props
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
Textarea.displayName = "Textarea";
|
|
156
|
+
var InputGroupControl = React2.createContext({});
|
|
157
|
+
function InputGroup({
|
|
158
|
+
className,
|
|
159
|
+
id,
|
|
160
|
+
"aria-describedby": describedBy,
|
|
161
|
+
"aria-invalid": invalid,
|
|
162
|
+
...props
|
|
163
|
+
}) {
|
|
164
|
+
const wiring = React2.useMemo(
|
|
165
|
+
() => ({ id, "aria-describedby": describedBy, "aria-invalid": invalid }),
|
|
166
|
+
[id, describedBy, invalid]
|
|
167
|
+
);
|
|
168
|
+
return /* @__PURE__ */ jsx(InputGroupControl.Provider, { value: wiring, children: /* @__PURE__ */ jsx(
|
|
169
|
+
"div",
|
|
170
|
+
{
|
|
171
|
+
"data-slot": "input-group",
|
|
172
|
+
role: "group",
|
|
173
|
+
className: cn(
|
|
174
|
+
"group/input-group border-input dark:bg-input/30 shadow-xs relative flex w-full items-center rounded-control border outline-none transition-[color,box-shadow]",
|
|
175
|
+
"h-control-md has-[>textarea]:h-auto",
|
|
176
|
+
// Variants based on alignment.
|
|
177
|
+
"has-[>[data-align=inline-start]]:[&>input]:pl-2",
|
|
178
|
+
"has-[>[data-align=inline-end]]:[&>input]:pr-2",
|
|
179
|
+
"has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",
|
|
180
|
+
"has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",
|
|
181
|
+
// Focus state.
|
|
182
|
+
"has-[[data-slot=input-group-control]:focus-visible]:ring-ring has-[[data-slot=input-group-control]:focus-visible]:ring-1",
|
|
183
|
+
// Error state.
|
|
184
|
+
"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",
|
|
185
|
+
className
|
|
186
|
+
),
|
|
187
|
+
...props
|
|
188
|
+
}
|
|
189
|
+
) });
|
|
190
|
+
}
|
|
191
|
+
var inputGroupAddonVariants = cva(
|
|
192
|
+
"text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-control [&>svg:not([class*='size-'])]:size-4",
|
|
193
|
+
{
|
|
194
|
+
variants: {
|
|
195
|
+
align: {
|
|
196
|
+
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
197
|
+
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]",
|
|
198
|
+
"block-start": "[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5",
|
|
199
|
+
"block-end": "[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
defaultVariants: {
|
|
203
|
+
align: "inline-start"
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
function InputGroupAddon({
|
|
208
|
+
className,
|
|
209
|
+
align = "inline-start",
|
|
210
|
+
...props
|
|
211
|
+
}) {
|
|
212
|
+
return /* @__PURE__ */ jsx(
|
|
213
|
+
"div",
|
|
214
|
+
{
|
|
215
|
+
role: "group",
|
|
216
|
+
"data-slot": "input-group-addon",
|
|
217
|
+
"data-align": align,
|
|
218
|
+
className: cn(inputGroupAddonVariants({ align }), className),
|
|
219
|
+
onClick: (e) => {
|
|
220
|
+
if (e.target.closest("button")) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
e.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
224
|
+
},
|
|
225
|
+
...props
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
var inputGroupButtonVariants = cva(
|
|
230
|
+
"flex items-center gap-2 shadow-none",
|
|
231
|
+
{
|
|
232
|
+
variants: {
|
|
233
|
+
size: {
|
|
234
|
+
xs: "h-control-xs gap-1 rounded-control px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
235
|
+
sm: "h-control-sm gap-1.5 rounded-control px-2.5 has-[>svg]:px-2.5",
|
|
236
|
+
"icon-xs": "size-control-xs rounded-control p-0 has-[>svg]:p-0",
|
|
237
|
+
"icon-sm": "size-control-sm p-0 has-[>svg]:p-0"
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
defaultVariants: {
|
|
241
|
+
size: "xs"
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
function InputGroupButton({
|
|
246
|
+
className,
|
|
247
|
+
type = "button",
|
|
248
|
+
variant = "ghost",
|
|
249
|
+
size = "xs",
|
|
250
|
+
...props
|
|
251
|
+
}) {
|
|
252
|
+
return /* @__PURE__ */ jsx(
|
|
253
|
+
Button,
|
|
254
|
+
{
|
|
255
|
+
type,
|
|
256
|
+
"data-size": size,
|
|
257
|
+
variant,
|
|
258
|
+
className: cn(inputGroupButtonVariants({ size }), className),
|
|
259
|
+
...props
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
function InputGroupText({ className, ...props }) {
|
|
264
|
+
return /* @__PURE__ */ jsx(
|
|
265
|
+
"span",
|
|
266
|
+
{
|
|
267
|
+
className: cn(
|
|
268
|
+
"text-muted-foreground flex items-center gap-2 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",
|
|
269
|
+
className
|
|
270
|
+
),
|
|
271
|
+
...props
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
function InputGroupInput({
|
|
276
|
+
className,
|
|
277
|
+
...props
|
|
278
|
+
}) {
|
|
279
|
+
const wiring = React2.useContext(InputGroupControl);
|
|
280
|
+
return /* @__PURE__ */ jsx(
|
|
281
|
+
Input,
|
|
282
|
+
{
|
|
283
|
+
...wiring,
|
|
284
|
+
"data-slot": "input-group-control",
|
|
285
|
+
className: cn(
|
|
286
|
+
"flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",
|
|
287
|
+
className
|
|
288
|
+
),
|
|
289
|
+
...props
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
function InputGroupTextarea({
|
|
294
|
+
className,
|
|
295
|
+
...props
|
|
296
|
+
}) {
|
|
297
|
+
const wiring = React2.useContext(InputGroupControl);
|
|
298
|
+
return /* @__PURE__ */ jsx(
|
|
299
|
+
Textarea,
|
|
300
|
+
{
|
|
301
|
+
...wiring,
|
|
302
|
+
"data-slot": "input-group-control",
|
|
303
|
+
className: cn(
|
|
304
|
+
"flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",
|
|
305
|
+
className
|
|
306
|
+
),
|
|
307
|
+
...props
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
}
|
|
140
311
|
var PasswordInput = React2.forwardRef(
|
|
141
312
|
({ className, visible, onVisibleChange, disabled, ...props }, ref) => {
|
|
142
313
|
const [internalVisible, setInternalVisible] = React2.useState(false);
|
|
@@ -175,21 +346,6 @@ var PasswordInput = React2.forwardRef(
|
|
|
175
346
|
}
|
|
176
347
|
);
|
|
177
348
|
PasswordInput.displayName = "PasswordInput";
|
|
178
|
-
var Textarea = React2.forwardRef(({ className, inputSize = "default", ...props }, ref) => {
|
|
179
|
-
return /* @__PURE__ */ jsx(
|
|
180
|
-
"textarea",
|
|
181
|
-
{
|
|
182
|
-
className: cn(
|
|
183
|
-
inputSize === "sm" ? "min-h-[52px] px-2 py-1" : "min-h-[80px] px-3 py-2",
|
|
184
|
-
"flex w-full rounded-control border border-input bg-background 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",
|
|
185
|
-
className
|
|
186
|
-
),
|
|
187
|
-
ref,
|
|
188
|
-
...props
|
|
189
|
-
}
|
|
190
|
-
);
|
|
191
|
-
});
|
|
192
|
-
Textarea.displayName = "Textarea";
|
|
193
349
|
var Switch = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
194
350
|
SwitchPrimitives.Root,
|
|
195
351
|
{
|
|
@@ -263,8 +419,9 @@ var SelectTrigger = React2.forwardRef(({ className, children, triggerSize = "def
|
|
|
263
419
|
{
|
|
264
420
|
ref,
|
|
265
421
|
className: cn(
|
|
266
|
-
|
|
267
|
-
"
|
|
422
|
+
"py-0",
|
|
423
|
+
triggerSize === "sm" ? "h-control-sm px-2" : triggerSize === "lg" ? "h-control-lg px-3" : "h-control-md px-2.5",
|
|
424
|
+
"flex w-full items-center justify-between whitespace-nowrap rounded-control border border-input bg-transparent shadow-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
268
425
|
className
|
|
269
426
|
),
|
|
270
427
|
...props,
|
|
@@ -306,7 +463,7 @@ var SelectContent = React2.forwardRef(({ className, children, position = "popper
|
|
|
306
463
|
{
|
|
307
464
|
ref,
|
|
308
465
|
className: cn(
|
|
309
|
-
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-
|
|
466
|
+
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-surface border bg-popover text-popover-foreground shadow-lg 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",
|
|
310
467
|
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",
|
|
311
468
|
className
|
|
312
469
|
),
|
|
@@ -376,12 +533,15 @@ var ColorSwatches = ({
|
|
|
376
533
|
}) => {
|
|
377
534
|
const [customColor, setCustomColor] = React2.useState(value || defaultValue);
|
|
378
535
|
const [isCustom, setIsCustom] = React2.useState(false);
|
|
379
|
-
React2.
|
|
380
|
-
|
|
536
|
+
const [seen, setSeen] = React2.useState({
|
|
537
|
+
presetColors
|
|
538
|
+
});
|
|
539
|
+
if (value && (value !== seen.value || presetColors !== seen.presetColors)) {
|
|
540
|
+
setSeen({ value, presetColors });
|
|
381
541
|
const isPreset = presetColors.some((c) => c.value === value);
|
|
382
542
|
setIsCustom(!isPreset);
|
|
383
543
|
if (!isPreset) setCustomColor(value);
|
|
384
|
-
}
|
|
544
|
+
}
|
|
385
545
|
const select = (newColor, custom = false) => {
|
|
386
546
|
setIsCustom(custom);
|
|
387
547
|
if (custom) setCustomColor(newColor);
|
|
@@ -458,12 +618,15 @@ var SliderNumber = ({
|
|
|
458
618
|
min = 0,
|
|
459
619
|
max = 100,
|
|
460
620
|
step = 1,
|
|
621
|
+
disabled,
|
|
461
622
|
className
|
|
462
623
|
}) => {
|
|
463
624
|
const [local, setLocal] = React2.useState(value);
|
|
464
|
-
React2.
|
|
625
|
+
const [seen, setSeen] = React2.useState(value);
|
|
626
|
+
if (value !== seen) {
|
|
627
|
+
setSeen(value);
|
|
465
628
|
setLocal(value);
|
|
466
|
-
}
|
|
629
|
+
}
|
|
467
630
|
const set = (n) => {
|
|
468
631
|
setLocal(n);
|
|
469
632
|
onChange?.(n);
|
|
@@ -477,6 +640,7 @@ var SliderNumber = ({
|
|
|
477
640
|
min,
|
|
478
641
|
max,
|
|
479
642
|
step,
|
|
643
|
+
disabled,
|
|
480
644
|
className: "flex-1"
|
|
481
645
|
}
|
|
482
646
|
),
|
|
@@ -489,14 +653,15 @@ var SliderNumber = ({
|
|
|
489
653
|
className: "h-8 w-16",
|
|
490
654
|
min,
|
|
491
655
|
max,
|
|
492
|
-
step
|
|
656
|
+
step,
|
|
657
|
+
disabled
|
|
493
658
|
}
|
|
494
659
|
)
|
|
495
660
|
] });
|
|
496
661
|
};
|
|
497
662
|
var IconInput = ({ value, onChange }) => {
|
|
498
663
|
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
499
|
-
/* @__PURE__ */ jsx("div", { className: "flex
|
|
664
|
+
/* @__PURE__ */ jsx("div", { className: "flex size-control-md shrink-0 items-center justify-center rounded-control border bg-muted", children: value ? value.slice(0, 2) : "\u2013" }),
|
|
500
665
|
/* @__PURE__ */ jsx(
|
|
501
666
|
Input,
|
|
502
667
|
{
|
|
@@ -504,17 +669,21 @@ var IconInput = ({ value, onChange }) => {
|
|
|
504
669
|
value: value ?? "",
|
|
505
670
|
onChange: (e) => onChange?.(e.target.value),
|
|
506
671
|
placeholder: "icon name",
|
|
507
|
-
className: "h-
|
|
672
|
+
className: "h-control-md"
|
|
508
673
|
}
|
|
509
674
|
)
|
|
510
675
|
] });
|
|
511
676
|
};
|
|
512
677
|
var SIZE = {
|
|
678
|
+
// The dense tier — an ask in a conversation, an inspector. Controls are the
|
|
679
|
+
// scale's `sm` (26px), the text stays at the 13px floor; the field label is
|
|
680
|
+
// muted and regular so the values, not the labels, carry the weight.
|
|
513
681
|
xs: {
|
|
514
|
-
input: "h-
|
|
515
|
-
select: "h-
|
|
682
|
+
input: "h-control-sm py-0",
|
|
683
|
+
select: "h-control-sm py-0",
|
|
516
684
|
textarea: "",
|
|
517
685
|
label: "text-base",
|
|
686
|
+
fieldLabel: "font-normal text-muted-foreground",
|
|
518
687
|
desc: "text-base",
|
|
519
688
|
gap: "gap-x-3 gap-y-2.5",
|
|
520
689
|
section: "space-y-3",
|
|
@@ -527,10 +696,11 @@ var SIZE = {
|
|
|
527
696
|
radio: "h-4 w-4"
|
|
528
697
|
},
|
|
529
698
|
sm: {
|
|
530
|
-
input: "h-
|
|
531
|
-
select: "h-
|
|
699
|
+
input: "h-control-md",
|
|
700
|
+
select: "h-control-md",
|
|
532
701
|
textarea: "",
|
|
533
702
|
label: "text-base",
|
|
703
|
+
fieldLabel: "",
|
|
534
704
|
desc: "text-base",
|
|
535
705
|
gap: "gap-x-3 gap-y-2",
|
|
536
706
|
section: "space-y-3",
|
|
@@ -543,10 +713,11 @@ var SIZE = {
|
|
|
543
713
|
radio: "h-4 w-4"
|
|
544
714
|
},
|
|
545
715
|
md: {
|
|
546
|
-
input: "",
|
|
547
|
-
select: "",
|
|
716
|
+
input: "h-control-lg px-3",
|
|
717
|
+
select: "h-control-lg px-3",
|
|
548
718
|
textarea: "",
|
|
549
719
|
label: "text-base",
|
|
720
|
+
fieldLabel: "",
|
|
550
721
|
desc: "text-base",
|
|
551
722
|
gap: "gap-4",
|
|
552
723
|
section: "space-y-4",
|
|
@@ -561,7 +732,9 @@ var SIZE = {
|
|
|
561
732
|
};
|
|
562
733
|
function itemClasses(labelPosition, size, className) {
|
|
563
734
|
return cn(
|
|
564
|
-
|
|
735
|
+
// `space-y-0` undoes FormItem's own stacking, whose margin would push the
|
|
736
|
+
// control below its label in a row.
|
|
737
|
+
labelPosition === "side" && cn("grid grid-cols-3 items-center space-y-0", SIZE[size].sideGap),
|
|
565
738
|
labelPosition === "top" && SIZE[size].stack,
|
|
566
739
|
className
|
|
567
740
|
);
|
|
@@ -583,33 +756,57 @@ function FieldLabel({
|
|
|
583
756
|
label,
|
|
584
757
|
badge,
|
|
585
758
|
size,
|
|
759
|
+
disabled,
|
|
586
760
|
className
|
|
587
761
|
}) {
|
|
588
762
|
if (!label && !badge) return null;
|
|
589
|
-
return /* @__PURE__ */ jsxs(
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
763
|
+
return /* @__PURE__ */ jsxs(
|
|
764
|
+
FormLabel,
|
|
765
|
+
{
|
|
766
|
+
className: cn(SIZE[size].label, SIZE[size].fieldLabel, disabled && "opacity-70", className),
|
|
767
|
+
children: [
|
|
768
|
+
label,
|
|
769
|
+
badge && /* @__PURE__ */ jsx(StatusPill, { badge })
|
|
770
|
+
]
|
|
771
|
+
}
|
|
772
|
+
);
|
|
593
773
|
}
|
|
774
|
+
var AffixedInput = React2.forwardRef(({ unit, aside, className, ...props }, ref) => {
|
|
775
|
+
if (!unit && !aside) return /* @__PURE__ */ jsx(Input, { ref, className, ...props });
|
|
776
|
+
return /* @__PURE__ */ jsxs(InputGroup, { className: cn("bg-background dark:bg-background", className), children: [
|
|
777
|
+
/* @__PURE__ */ jsx(InputGroupInput, { ref, className: "h-full", ...props }),
|
|
778
|
+
/* @__PURE__ */ jsxs(InputGroupAddon, { align: "inline-end", className: "font-mono font-normal", children: [
|
|
779
|
+
unit && /* @__PURE__ */ jsx("span", { children: unit }),
|
|
780
|
+
aside && /* @__PURE__ */ jsx("span", { children: aside })
|
|
781
|
+
] })
|
|
782
|
+
] });
|
|
783
|
+
});
|
|
784
|
+
AffixedInput.displayName = "AffixedInput";
|
|
594
785
|
var InputField = ({
|
|
595
786
|
label,
|
|
596
787
|
description,
|
|
597
788
|
placeholder,
|
|
598
789
|
value,
|
|
599
790
|
onChange,
|
|
791
|
+
unit,
|
|
792
|
+
aside,
|
|
600
793
|
labelPosition = "side",
|
|
601
794
|
size = "sm",
|
|
602
795
|
labelClassName,
|
|
603
796
|
badge,
|
|
604
|
-
className
|
|
797
|
+
className,
|
|
798
|
+
disabled
|
|
605
799
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
|
|
606
|
-
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, className: labelClassName }),
|
|
800
|
+
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, disabled, className: labelClassName }),
|
|
607
801
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition, size), children: [
|
|
608
802
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
609
|
-
|
|
803
|
+
AffixedInput,
|
|
610
804
|
{
|
|
611
805
|
className: SIZE[size].input,
|
|
806
|
+
unit,
|
|
807
|
+
aside,
|
|
612
808
|
placeholder,
|
|
809
|
+
disabled,
|
|
613
810
|
value: value ?? "",
|
|
614
811
|
onChange: (e) => onChange?.(e.target.value)
|
|
615
812
|
}
|
|
@@ -628,15 +825,17 @@ var PasswordField = ({
|
|
|
628
825
|
size = "sm",
|
|
629
826
|
labelClassName,
|
|
630
827
|
badge,
|
|
631
|
-
className
|
|
828
|
+
className,
|
|
829
|
+
disabled
|
|
632
830
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
|
|
633
|
-
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, className: labelClassName }),
|
|
831
|
+
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, disabled, className: labelClassName }),
|
|
634
832
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition, size), children: [
|
|
635
833
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
636
834
|
PasswordInput,
|
|
637
835
|
{
|
|
638
836
|
className: SIZE[size].input,
|
|
639
837
|
placeholder,
|
|
838
|
+
disabled,
|
|
640
839
|
value: value ?? "",
|
|
641
840
|
onChange: (e) => onChange?.(e.target.value)
|
|
642
841
|
}
|
|
@@ -656,9 +855,10 @@ var TextareaField = ({
|
|
|
656
855
|
size = "sm",
|
|
657
856
|
labelClassName,
|
|
658
857
|
badge,
|
|
659
|
-
className
|
|
858
|
+
className,
|
|
859
|
+
disabled
|
|
660
860
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
|
|
661
|
-
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, className: labelClassName }),
|
|
861
|
+
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, disabled, className: labelClassName }),
|
|
662
862
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition, size), children: [
|
|
663
863
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
664
864
|
Textarea,
|
|
@@ -666,6 +866,7 @@ var TextareaField = ({
|
|
|
666
866
|
className: SIZE[size].textarea || void 0,
|
|
667
867
|
rows,
|
|
668
868
|
placeholder,
|
|
869
|
+
disabled,
|
|
669
870
|
value: value ?? "",
|
|
670
871
|
onChange: (e) => onChange?.(e.target.value)
|
|
671
872
|
}
|
|
@@ -685,13 +886,14 @@ var SelectField = ({
|
|
|
685
886
|
size = "sm",
|
|
686
887
|
labelClassName,
|
|
687
888
|
badge,
|
|
688
|
-
className
|
|
889
|
+
className,
|
|
890
|
+
disabled
|
|
689
891
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
|
|
690
|
-
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, className: labelClassName }),
|
|
892
|
+
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, disabled, className: labelClassName }),
|
|
691
893
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition, size), children: [
|
|
692
|
-
/* @__PURE__ */ jsxs(Select, { value: value ?? "", onValueChange: onChange, children: [
|
|
894
|
+
/* @__PURE__ */ jsxs(Select, { value: value ?? "", onValueChange: onChange, disabled, children: [
|
|
693
895
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(SelectTrigger, { className: SIZE[size].select, children: /* @__PURE__ */ jsx(SelectValue, { placeholder }) }) }),
|
|
694
|
-
/* @__PURE__ */ jsx(SelectContent, { children: options.map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o.value, children: o.label }, o.value)) })
|
|
896
|
+
/* @__PURE__ */ jsx(SelectContent, { children: options.map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o.value, disabled: o.disabled, children: o.label }, o.value)) })
|
|
695
897
|
] }),
|
|
696
898
|
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
697
899
|
/* @__PURE__ */ jsx(FormMessage, { className: SIZE[size].desc })
|
|
@@ -708,37 +910,53 @@ var BooleanField = ({
|
|
|
708
910
|
labelClassName,
|
|
709
911
|
badge,
|
|
710
912
|
className,
|
|
711
|
-
boxed = false
|
|
913
|
+
boxed = false,
|
|
914
|
+
disabled
|
|
712
915
|
}) => {
|
|
713
916
|
const boxClass = boxed ? "rounded-md border p-2" : "";
|
|
714
917
|
if (control === "checkbox") {
|
|
715
|
-
return /* @__PURE__ */ jsxs(
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
918
|
+
return /* @__PURE__ */ jsxs(
|
|
919
|
+
FormItem,
|
|
920
|
+
{
|
|
921
|
+
className: cn(
|
|
922
|
+
"flex gap-2 space-y-0",
|
|
923
|
+
description ? "items-start" : "items-center",
|
|
924
|
+
className
|
|
925
|
+
),
|
|
926
|
+
children: [
|
|
927
|
+
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
928
|
+
Checkbox,
|
|
929
|
+
{
|
|
930
|
+
className: SIZE[size].check,
|
|
931
|
+
checked: !!value,
|
|
932
|
+
disabled,
|
|
933
|
+
onCheckedChange: onChange
|
|
934
|
+
}
|
|
935
|
+
) }),
|
|
936
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
937
|
+
/* @__PURE__ */ jsx(
|
|
938
|
+
FieldLabel,
|
|
939
|
+
{
|
|
940
|
+
label,
|
|
941
|
+
badge,
|
|
942
|
+
size,
|
|
943
|
+
disabled,
|
|
944
|
+
className: cn(
|
|
945
|
+
"!mt-0 cursor-pointer font-normal leading-none",
|
|
946
|
+
labelClassName
|
|
947
|
+
)
|
|
948
|
+
}
|
|
949
|
+
),
|
|
950
|
+
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description })
|
|
951
|
+
] })
|
|
952
|
+
]
|
|
953
|
+
}
|
|
954
|
+
);
|
|
737
955
|
}
|
|
738
956
|
if (labelPosition === "side") {
|
|
739
957
|
return /* @__PURE__ */ jsxs(FormItem, { className: cn("flex items-center justify-between", boxClass), children: [
|
|
740
958
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
741
|
-
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, className: labelClassName }),
|
|
959
|
+
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, disabled, className: labelClassName }),
|
|
742
960
|
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description })
|
|
743
961
|
] }),
|
|
744
962
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
@@ -746,19 +964,21 @@ var BooleanField = ({
|
|
|
746
964
|
{
|
|
747
965
|
className: SIZE[size].switch || void 0,
|
|
748
966
|
checked: !!value,
|
|
967
|
+
disabled,
|
|
749
968
|
onCheckedChange: onChange
|
|
750
969
|
}
|
|
751
970
|
) })
|
|
752
971
|
] });
|
|
753
972
|
}
|
|
754
973
|
return /* @__PURE__ */ jsxs(FormItem, { className: SIZE[size].stack, children: [
|
|
755
|
-
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, className: labelClassName }),
|
|
974
|
+
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, disabled, className: labelClassName }),
|
|
756
975
|
/* @__PURE__ */ jsxs("div", { className: cn("flex items-center justify-between", boxClass), children: [
|
|
757
976
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
758
977
|
Switch,
|
|
759
978
|
{
|
|
760
979
|
className: SIZE[size].switch || void 0,
|
|
761
980
|
checked: !!value,
|
|
981
|
+
disabled,
|
|
762
982
|
onCheckedChange: onChange
|
|
763
983
|
}
|
|
764
984
|
) }),
|
|
@@ -777,33 +997,46 @@ var RadioField = ({
|
|
|
777
997
|
orientation = "vertical",
|
|
778
998
|
labelClassName,
|
|
779
999
|
badge,
|
|
780
|
-
className
|
|
1000
|
+
className,
|
|
1001
|
+
disabled
|
|
781
1002
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
|
|
782
|
-
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, className: labelClassName }),
|
|
1003
|
+
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, disabled, className: labelClassName }),
|
|
783
1004
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition, size), children: [
|
|
784
1005
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
785
1006
|
RadioGroup,
|
|
786
1007
|
{
|
|
787
1008
|
value: value ?? "",
|
|
788
1009
|
onValueChange: onChange,
|
|
1010
|
+
disabled,
|
|
789
1011
|
className: orientation === "horizontal" ? "flex flex-row items-center gap-x-4" : cn("flex flex-col", SIZE[size].stack),
|
|
790
|
-
children: options.map((o) =>
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
className: cn("shrink-0", SIZE[size].radio)
|
|
800
|
-
}
|
|
1012
|
+
children: options.map((o) => {
|
|
1013
|
+
const off = disabled || o.disabled;
|
|
1014
|
+
return /* @__PURE__ */ jsxs(
|
|
1015
|
+
"label",
|
|
1016
|
+
{
|
|
1017
|
+
className: cn(
|
|
1018
|
+
"flex gap-2",
|
|
1019
|
+
o.description ? "items-start" : "items-center",
|
|
1020
|
+
off ? "cursor-not-allowed" : "cursor-pointer"
|
|
801
1021
|
),
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
1022
|
+
children: [
|
|
1023
|
+
/* @__PURE__ */ jsx(
|
|
1024
|
+
RadioGroupItem,
|
|
1025
|
+
{
|
|
1026
|
+
value: o.value,
|
|
1027
|
+
disabled: o.disabled,
|
|
1028
|
+
className: cn("shrink-0", SIZE[size].radio)
|
|
1029
|
+
}
|
|
1030
|
+
),
|
|
1031
|
+
/* @__PURE__ */ jsxs("span", { className: cn("flex flex-col gap-1", off && "opacity-50"), children: [
|
|
1032
|
+
/* @__PURE__ */ jsx("span", { className: cn(o.description ? "leading-4" : "leading-none", SIZE[size].label), children: o.label }),
|
|
1033
|
+
o.description && /* @__PURE__ */ jsx("span", { className: cn("text-muted-foreground", SIZE[size].desc), children: o.description })
|
|
1034
|
+
] })
|
|
1035
|
+
]
|
|
1036
|
+
},
|
|
1037
|
+
o.value
|
|
1038
|
+
);
|
|
1039
|
+
})
|
|
807
1040
|
}
|
|
808
1041
|
) }),
|
|
809
1042
|
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
@@ -821,12 +1054,13 @@ var CheckboxGroupField = ({
|
|
|
821
1054
|
orientation = "vertical",
|
|
822
1055
|
labelClassName,
|
|
823
1056
|
badge,
|
|
824
|
-
className
|
|
1057
|
+
className,
|
|
1058
|
+
disabled
|
|
825
1059
|
}) => {
|
|
826
1060
|
const selected = Array.isArray(value) ? value : [];
|
|
827
1061
|
const toggle = (v, checked) => onChange?.(checked ? [...selected, v] : selected.filter((x) => x !== v));
|
|
828
1062
|
return /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
|
|
829
|
-
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, className: labelClassName }),
|
|
1063
|
+
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, disabled, className: labelClassName }),
|
|
830
1064
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition, size), children: [
|
|
831
1065
|
/* @__PURE__ */ jsx(
|
|
832
1066
|
"div",
|
|
@@ -842,6 +1076,7 @@ var CheckboxGroupField = ({
|
|
|
842
1076
|
{
|
|
843
1077
|
className: cn("shrink-0", SIZE[size].check),
|
|
844
1078
|
checked: selected.includes(o.value),
|
|
1079
|
+
disabled: disabled || o.disabled,
|
|
845
1080
|
onCheckedChange: (c) => toggle(o.value, c === true)
|
|
846
1081
|
}
|
|
847
1082
|
),
|
|
@@ -868,9 +1103,10 @@ var ColorField = ({
|
|
|
868
1103
|
size = "sm",
|
|
869
1104
|
labelClassName,
|
|
870
1105
|
badge,
|
|
871
|
-
className
|
|
1106
|
+
className,
|
|
1107
|
+
disabled
|
|
872
1108
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
|
|
873
|
-
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, className: labelClassName }),
|
|
1109
|
+
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, disabled, className: labelClassName }),
|
|
874
1110
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition, size), children: [
|
|
875
1111
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
876
1112
|
ColorSwatches,
|
|
@@ -893,22 +1129,40 @@ var NumberField = ({
|
|
|
893
1129
|
min,
|
|
894
1130
|
max,
|
|
895
1131
|
step,
|
|
1132
|
+
unit,
|
|
1133
|
+
aside,
|
|
896
1134
|
labelPosition = "side",
|
|
897
1135
|
size = "sm",
|
|
898
1136
|
labelClassName,
|
|
899
1137
|
badge,
|
|
900
|
-
className
|
|
1138
|
+
className,
|
|
1139
|
+
disabled
|
|
901
1140
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
|
|
902
|
-
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, className: labelClassName }),
|
|
1141
|
+
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, disabled, className: labelClassName }),
|
|
903
1142
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition, size), children: [
|
|
904
|
-
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
1143
|
+
/* @__PURE__ */ jsx(FormControl, { children: min != null && max != null ? /* @__PURE__ */ jsx(
|
|
905
1144
|
SliderNumber,
|
|
906
1145
|
{
|
|
907
1146
|
value: typeof value === "number" ? value : 0,
|
|
908
1147
|
onChange,
|
|
909
1148
|
min,
|
|
910
1149
|
max,
|
|
911
|
-
step
|
|
1150
|
+
step,
|
|
1151
|
+
disabled
|
|
1152
|
+
}
|
|
1153
|
+
) : /* @__PURE__ */ jsx(
|
|
1154
|
+
AffixedInput,
|
|
1155
|
+
{
|
|
1156
|
+
type: "number",
|
|
1157
|
+
className: SIZE[size].input,
|
|
1158
|
+
unit,
|
|
1159
|
+
aside,
|
|
1160
|
+
min,
|
|
1161
|
+
max,
|
|
1162
|
+
step,
|
|
1163
|
+
disabled,
|
|
1164
|
+
value: typeof value === "number" ? value : "",
|
|
1165
|
+
onChange: (e) => onChange?.(e.target.value === "" ? void 0 : Number(e.target.value))
|
|
912
1166
|
}
|
|
913
1167
|
) }),
|
|
914
1168
|
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
@@ -924,27 +1178,16 @@ var IconField = ({
|
|
|
924
1178
|
size = "sm",
|
|
925
1179
|
labelClassName,
|
|
926
1180
|
badge,
|
|
927
|
-
className
|
|
1181
|
+
className,
|
|
1182
|
+
disabled
|
|
928
1183
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
|
|
929
|
-
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, className: labelClassName }),
|
|
1184
|
+
/* @__PURE__ */ jsx(FieldLabel, { label, badge, size, disabled, className: labelClassName }),
|
|
930
1185
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition, size), children: [
|
|
931
1186
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(IconInput, { value, onChange }) }),
|
|
932
1187
|
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
933
1188
|
/* @__PURE__ */ jsx(FormMessage, { className: SIZE[size].desc })
|
|
934
1189
|
] })
|
|
935
1190
|
] });
|
|
936
|
-
var Field = {
|
|
937
|
-
Input: InputField,
|
|
938
|
-
Password: PasswordField,
|
|
939
|
-
Textarea: TextareaField,
|
|
940
|
-
Boolean: BooleanField,
|
|
941
|
-
Radio: RadioField,
|
|
942
|
-
CheckboxGroup: CheckboxGroupField,
|
|
943
|
-
Color: ColorField,
|
|
944
|
-
Number: NumberField,
|
|
945
|
-
Select: SelectField,
|
|
946
|
-
Icon: IconField
|
|
947
|
-
};
|
|
948
1191
|
function humanize(name) {
|
|
949
1192
|
return name.replace(/([A-Z])/g, " $1").replace(/^./, (c) => c.toUpperCase()).trim();
|
|
950
1193
|
}
|
|
@@ -955,11 +1198,13 @@ function renderField(field, parentName, control, labelPosition, size) {
|
|
|
955
1198
|
control,
|
|
956
1199
|
name: `${parentName}.${field.name}`,
|
|
957
1200
|
defaultValue: field.defaultValue,
|
|
1201
|
+
rules: field.rules,
|
|
958
1202
|
render: ({ field: rhf }) => {
|
|
959
1203
|
const common = {
|
|
960
1204
|
label: field.label ?? humanize(field.name),
|
|
961
1205
|
description: field.description,
|
|
962
1206
|
options: field.options,
|
|
1207
|
+
disabled: field.disabled,
|
|
963
1208
|
min: field.min,
|
|
964
1209
|
max: field.max,
|
|
965
1210
|
step: field.step,
|
|
@@ -971,6 +1216,8 @@ function renderField(field, parentName, control, labelPosition, size) {
|
|
|
971
1216
|
boxed: field.boxed,
|
|
972
1217
|
labelClassName: field.labelClassName,
|
|
973
1218
|
badge: field.badge,
|
|
1219
|
+
unit: field.unit,
|
|
1220
|
+
aside: field.aside,
|
|
974
1221
|
labelPosition,
|
|
975
1222
|
size,
|
|
976
1223
|
value: rhf.value,
|
|
@@ -1022,8 +1269,21 @@ function renderField(field, parentName, control, labelPosition, size) {
|
|
|
1022
1269
|
field.name
|
|
1023
1270
|
);
|
|
1024
1271
|
}
|
|
1025
|
-
function renderGrid(fields, parentName, control, labelPosition, size, columns, key) {
|
|
1272
|
+
function renderGrid(fields, parentName, control, labelPosition, size, columns, key, fit = "viewport") {
|
|
1026
1273
|
const customCols = columns !== 2;
|
|
1274
|
+
if (fit === "container") {
|
|
1275
|
+
return /* @__PURE__ */ jsx("div", { className: "@container", children: /* @__PURE__ */ jsx(
|
|
1276
|
+
"div",
|
|
1277
|
+
{
|
|
1278
|
+
className: cn(
|
|
1279
|
+
"grid grid-cols-1",
|
|
1280
|
+
SIZE[size].gap,
|
|
1281
|
+
columns > 1 && "@min-[280px]:grid-cols-2 @min-[280px]:[&>*:last-child:nth-child(odd)]:col-span-2"
|
|
1282
|
+
),
|
|
1283
|
+
children: fields.map((f) => /* @__PURE__ */ jsx("div", { className: f.className, children: renderField(f, parentName, control, labelPosition, size) }, f.name))
|
|
1284
|
+
}
|
|
1285
|
+
) }, key);
|
|
1286
|
+
}
|
|
1027
1287
|
return /* @__PURE__ */ jsx(
|
|
1028
1288
|
"div",
|
|
1029
1289
|
{
|
|
@@ -1052,9 +1312,9 @@ function renderGrid(fields, parentName, control, labelPosition, size, columns, k
|
|
|
1052
1312
|
key
|
|
1053
1313
|
);
|
|
1054
1314
|
}
|
|
1055
|
-
function renderRows(fields, rowConfig, parentName, control, labelPosition, size, columns) {
|
|
1315
|
+
function renderRows(fields, rowConfig, parentName, control, labelPosition, size, columns, fit = "viewport") {
|
|
1056
1316
|
if (!rowConfig || rowConfig.length === 0) {
|
|
1057
|
-
return renderGrid(fields, parentName, control, labelPosition, size, columns);
|
|
1317
|
+
return renderGrid(fields, parentName, control, labelPosition, size, columns, void 0, fit);
|
|
1058
1318
|
}
|
|
1059
1319
|
const used = new Set(rowConfig.flatMap((r) => r.fields));
|
|
1060
1320
|
const unassigned = fields.filter((f) => !used.has(f.name));
|
|
@@ -1070,7 +1330,8 @@ function renderRows(fields, rowConfig, parentName, control, labelPosition, size,
|
|
|
1070
1330
|
labelPosition,
|
|
1071
1331
|
size,
|
|
1072
1332
|
columns,
|
|
1073
|
-
row.id
|
|
1333
|
+
row.id,
|
|
1334
|
+
fit
|
|
1074
1335
|
);
|
|
1075
1336
|
}),
|
|
1076
1337
|
unassigned.length > 0 && renderGrid(
|
|
@@ -1080,7 +1341,8 @@ function renderRows(fields, rowConfig, parentName, control, labelPosition, size,
|
|
|
1080
1341
|
labelPosition,
|
|
1081
1342
|
size,
|
|
1082
1343
|
columns,
|
|
1083
|
-
"_unassigned"
|
|
1344
|
+
"_unassigned",
|
|
1345
|
+
fit
|
|
1084
1346
|
)
|
|
1085
1347
|
] });
|
|
1086
1348
|
}
|
|
@@ -1092,7 +1354,9 @@ var ObjectField = ({
|
|
|
1092
1354
|
groupConfig,
|
|
1093
1355
|
labelPosition = "side",
|
|
1094
1356
|
size = "sm",
|
|
1095
|
-
columns = 2
|
|
1357
|
+
columns = 2,
|
|
1358
|
+
fit = "viewport",
|
|
1359
|
+
groupAs = "accordion"
|
|
1096
1360
|
}) => {
|
|
1097
1361
|
const grouped = fields.reduce((acc, f) => {
|
|
1098
1362
|
const key = f.group ?? "_ungrouped";
|
|
@@ -1105,60 +1369,70 @@ var ObjectField = ({
|
|
|
1105
1369
|
const groupConfigById = new Map(
|
|
1106
1370
|
(groupConfig ?? []).map((g) => [g.id, g])
|
|
1107
1371
|
);
|
|
1108
|
-
return
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
children: gFields.length
|
|
1142
|
-
}
|
|
1372
|
+
return (
|
|
1373
|
+
// A container has no width of its own, so one fitted to it takes its
|
|
1374
|
+
// parent's: in a row beside a button it would otherwise shrink to nothing.
|
|
1375
|
+
/* @__PURE__ */ jsxs("div", { className: cn(SIZE[size].outer, fit === "container" && "w-full min-w-0"), children: [
|
|
1376
|
+
ungrouped.length > 0 && /* @__PURE__ */ jsx("div", { className: SIZE[size].section, children: renderRows(
|
|
1377
|
+
ungrouped,
|
|
1378
|
+
rowConfig,
|
|
1379
|
+
name,
|
|
1380
|
+
control,
|
|
1381
|
+
labelPosition,
|
|
1382
|
+
size,
|
|
1383
|
+
columns,
|
|
1384
|
+
fit
|
|
1385
|
+
) }),
|
|
1386
|
+
groupedEntries.length > 0 && groupAs === "section" && /* @__PURE__ */ jsx("div", { className: SIZE[size].section, children: groupedEntries.map(([group, gFields]) => /* @__PURE__ */ jsxs("section", { className: SIZE[size].stack, children: [
|
|
1387
|
+
/* @__PURE__ */ jsx(Eyebrow, { children: groupConfigById.get(group)?.label ?? humanize(group) }),
|
|
1388
|
+
renderRows(gFields, rowConfig, name, control, labelPosition, size, columns, fit)
|
|
1389
|
+
] }, group)) }),
|
|
1390
|
+
groupedEntries.length > 0 && groupAs === "accordion" && /* @__PURE__ */ jsx(
|
|
1391
|
+
Accordion,
|
|
1392
|
+
{
|
|
1393
|
+
type: "multiple",
|
|
1394
|
+
defaultValue: groupedEntries.map(([k]) => k),
|
|
1395
|
+
className: "w-full",
|
|
1396
|
+
children: groupedEntries.map(([group, gFields]) => {
|
|
1397
|
+
const gc = groupConfigById.get(group);
|
|
1398
|
+
return /* @__PURE__ */ jsxs(AccordionItem, { value: group, className: "border-b", children: [
|
|
1399
|
+
/* @__PURE__ */ jsx(
|
|
1400
|
+
AccordionTrigger,
|
|
1401
|
+
{
|
|
1402
|
+
className: cn(
|
|
1403
|
+
"font-semibold uppercase tracking-wide text-muted-foreground hover:no-underline",
|
|
1404
|
+
SIZE[size].trigger
|
|
1143
1405
|
),
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1406
|
+
children: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
1407
|
+
gc?.label ?? humanize(group),
|
|
1408
|
+
(gc?.showCount ?? true) && /* @__PURE__ */ jsx(
|
|
1409
|
+
Badge,
|
|
1410
|
+
{
|
|
1411
|
+
variant: "secondary",
|
|
1412
|
+
className: "px-1.5 py-0 text-base font-normal tabular-nums",
|
|
1413
|
+
children: gFields.length
|
|
1414
|
+
}
|
|
1415
|
+
),
|
|
1416
|
+
gc?.badges?.map((b, i) => /* @__PURE__ */ jsx(StatusPill, { badge: b }, i))
|
|
1417
|
+
] })
|
|
1418
|
+
}
|
|
1419
|
+
),
|
|
1420
|
+
/* @__PURE__ */ jsx(AccordionContent, { className: "pb-3 pt-1", children: /* @__PURE__ */ jsx("div", { className: SIZE[size].section, children: renderRows(
|
|
1421
|
+
gFields,
|
|
1422
|
+
rowConfig,
|
|
1423
|
+
name,
|
|
1424
|
+
control,
|
|
1425
|
+
labelPosition,
|
|
1426
|
+
size,
|
|
1427
|
+
columns,
|
|
1428
|
+
fit
|
|
1429
|
+
) }) })
|
|
1430
|
+
] }, group);
|
|
1431
|
+
})
|
|
1432
|
+
}
|
|
1433
|
+
)
|
|
1434
|
+
] })
|
|
1435
|
+
);
|
|
1162
1436
|
};
|
|
1163
1437
|
var FormField2 = Object.assign(FormField, {
|
|
1164
1438
|
ObjectField,
|
|
@@ -1241,7 +1515,7 @@ function FieldGroup({ className, ...props }) {
|
|
|
1241
1515
|
}
|
|
1242
1516
|
);
|
|
1243
1517
|
}
|
|
1244
|
-
cva(
|
|
1518
|
+
var fieldVariants = cva(
|
|
1245
1519
|
"group/field data-[invalid=true]:text-destructive flex w-full gap-3",
|
|
1246
1520
|
{
|
|
1247
1521
|
variants: {
|
|
@@ -1264,6 +1538,22 @@ cva(
|
|
|
1264
1538
|
}
|
|
1265
1539
|
}
|
|
1266
1540
|
);
|
|
1541
|
+
function Field({
|
|
1542
|
+
className,
|
|
1543
|
+
orientation = "vertical",
|
|
1544
|
+
...props
|
|
1545
|
+
}) {
|
|
1546
|
+
return /* @__PURE__ */ jsx(
|
|
1547
|
+
"div",
|
|
1548
|
+
{
|
|
1549
|
+
role: "group",
|
|
1550
|
+
"data-slot": "field",
|
|
1551
|
+
"data-orientation": orientation,
|
|
1552
|
+
className: cn(fieldVariants({ orientation }), className),
|
|
1553
|
+
...props
|
|
1554
|
+
}
|
|
1555
|
+
);
|
|
1556
|
+
}
|
|
1267
1557
|
function FieldContent({ className, ...props }) {
|
|
1268
1558
|
return /* @__PURE__ */ jsx(
|
|
1269
1559
|
"div",
|
|
@@ -1466,146 +1756,6 @@ var ParamRow = React2.forwardRef(
|
|
|
1466
1756
|
)
|
|
1467
1757
|
);
|
|
1468
1758
|
ParamRow.displayName = "ParamRow";
|
|
1469
|
-
function InputGroup({ className, ...props }) {
|
|
1470
|
-
return /* @__PURE__ */ jsx(
|
|
1471
|
-
"div",
|
|
1472
|
-
{
|
|
1473
|
-
"data-slot": "input-group",
|
|
1474
|
-
role: "group",
|
|
1475
|
-
className: cn(
|
|
1476
|
-
"group/input-group border-input dark:bg-input/30 shadow-xs relative flex w-full items-center rounded-control border outline-none transition-[color,box-shadow]",
|
|
1477
|
-
"h-9 has-[>textarea]:h-auto",
|
|
1478
|
-
// Variants based on alignment.
|
|
1479
|
-
"has-[>[data-align=inline-start]]:[&>input]:pl-2",
|
|
1480
|
-
"has-[>[data-align=inline-end]]:[&>input]:pr-2",
|
|
1481
|
-
"has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",
|
|
1482
|
-
"has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",
|
|
1483
|
-
// Focus state.
|
|
1484
|
-
"has-[[data-slot=input-group-control]:focus-visible]:ring-ring has-[[data-slot=input-group-control]:focus-visible]:ring-1",
|
|
1485
|
-
// Error state.
|
|
1486
|
-
"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",
|
|
1487
|
-
className
|
|
1488
|
-
),
|
|
1489
|
-
...props
|
|
1490
|
-
}
|
|
1491
|
-
);
|
|
1492
|
-
}
|
|
1493
|
-
var inputGroupAddonVariants = cva(
|
|
1494
|
-
"text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-control [&>svg:not([class*='size-'])]:size-4",
|
|
1495
|
-
{
|
|
1496
|
-
variants: {
|
|
1497
|
-
align: {
|
|
1498
|
-
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
1499
|
-
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]",
|
|
1500
|
-
"block-start": "[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5",
|
|
1501
|
-
"block-end": "[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"
|
|
1502
|
-
}
|
|
1503
|
-
},
|
|
1504
|
-
defaultVariants: {
|
|
1505
|
-
align: "inline-start"
|
|
1506
|
-
}
|
|
1507
|
-
}
|
|
1508
|
-
);
|
|
1509
|
-
function InputGroupAddon({
|
|
1510
|
-
className,
|
|
1511
|
-
align = "inline-start",
|
|
1512
|
-
...props
|
|
1513
|
-
}) {
|
|
1514
|
-
return /* @__PURE__ */ jsx(
|
|
1515
|
-
"div",
|
|
1516
|
-
{
|
|
1517
|
-
role: "group",
|
|
1518
|
-
"data-slot": "input-group-addon",
|
|
1519
|
-
"data-align": align,
|
|
1520
|
-
className: cn(inputGroupAddonVariants({ align }), className),
|
|
1521
|
-
onClick: (e) => {
|
|
1522
|
-
if (e.target.closest("button")) {
|
|
1523
|
-
return;
|
|
1524
|
-
}
|
|
1525
|
-
e.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
1526
|
-
},
|
|
1527
|
-
...props
|
|
1528
|
-
}
|
|
1529
|
-
);
|
|
1530
|
-
}
|
|
1531
|
-
var inputGroupButtonVariants = cva(
|
|
1532
|
-
"flex items-center gap-2 shadow-none",
|
|
1533
|
-
{
|
|
1534
|
-
variants: {
|
|
1535
|
-
size: {
|
|
1536
|
-
xs: "h-6 gap-1 rounded-control px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
1537
|
-
sm: "h-8 gap-1.5 rounded-control px-2.5 has-[>svg]:px-2.5",
|
|
1538
|
-
"icon-xs": "size-6 rounded-control p-0 has-[>svg]:p-0",
|
|
1539
|
-
"icon-sm": "size-8 p-0 has-[>svg]:p-0"
|
|
1540
|
-
}
|
|
1541
|
-
},
|
|
1542
|
-
defaultVariants: {
|
|
1543
|
-
size: "xs"
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
);
|
|
1547
|
-
function InputGroupButton({
|
|
1548
|
-
className,
|
|
1549
|
-
type = "button",
|
|
1550
|
-
variant = "ghost",
|
|
1551
|
-
size = "xs",
|
|
1552
|
-
...props
|
|
1553
|
-
}) {
|
|
1554
|
-
return /* @__PURE__ */ jsx(
|
|
1555
|
-
Button,
|
|
1556
|
-
{
|
|
1557
|
-
type,
|
|
1558
|
-
"data-size": size,
|
|
1559
|
-
variant,
|
|
1560
|
-
className: cn(inputGroupButtonVariants({ size }), className),
|
|
1561
|
-
...props
|
|
1562
|
-
}
|
|
1563
|
-
);
|
|
1564
|
-
}
|
|
1565
|
-
function InputGroupText({ className, ...props }) {
|
|
1566
|
-
return /* @__PURE__ */ jsx(
|
|
1567
|
-
"span",
|
|
1568
|
-
{
|
|
1569
|
-
className: cn(
|
|
1570
|
-
"text-muted-foreground flex items-center gap-2 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",
|
|
1571
|
-
className
|
|
1572
|
-
),
|
|
1573
|
-
...props
|
|
1574
|
-
}
|
|
1575
|
-
);
|
|
1576
|
-
}
|
|
1577
|
-
function InputGroupInput({
|
|
1578
|
-
className,
|
|
1579
|
-
...props
|
|
1580
|
-
}) {
|
|
1581
|
-
return /* @__PURE__ */ jsx(
|
|
1582
|
-
Input,
|
|
1583
|
-
{
|
|
1584
|
-
"data-slot": "input-group-control",
|
|
1585
|
-
className: cn(
|
|
1586
|
-
"flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",
|
|
1587
|
-
className
|
|
1588
|
-
),
|
|
1589
|
-
...props
|
|
1590
|
-
}
|
|
1591
|
-
);
|
|
1592
|
-
}
|
|
1593
|
-
function InputGroupTextarea({
|
|
1594
|
-
className,
|
|
1595
|
-
...props
|
|
1596
|
-
}) {
|
|
1597
|
-
return /* @__PURE__ */ jsx(
|
|
1598
|
-
Textarea,
|
|
1599
|
-
{
|
|
1600
|
-
"data-slot": "input-group-control",
|
|
1601
|
-
className: cn(
|
|
1602
|
-
"flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",
|
|
1603
|
-
className
|
|
1604
|
-
),
|
|
1605
|
-
...props
|
|
1606
|
-
}
|
|
1607
|
-
);
|
|
1608
|
-
}
|
|
1609
1759
|
|
|
1610
1760
|
export { BooleanField, Checkbox, CheckboxGroupField, ColorField, ColorSwatches, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel2 as FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Form, FormControl, FormDescription, FormField2 as FormField, FormItem, FormLabel, FormMessage, IconField, IconInput, Input, InputField, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, NumberField, ObjectField, PARAM_SOURCES, ParamRow, PasswordField, PasswordInput, RadioField, RadioGroup, RadioGroupItem, Select, SelectContent, SelectField, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SettingsPanel, Slider, SliderNumber, Switch, Textarea, TextareaField, useFormField };
|
|
1611
1761
|
//# sourceMappingURL=index.js.map
|