@invana/forms 0.0.7 → 0.0.12
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 +235 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -2
- package/dist/index.d.ts +52 -2
- package/dist/index.js +233 -59
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -7,9 +7,9 @@ var reactHookForm = require('react-hook-form');
|
|
|
7
7
|
var LabelPrimitive = require('@radix-ui/react-label');
|
|
8
8
|
var classVarianceAuthority = require('class-variance-authority');
|
|
9
9
|
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
+
var lucideReact = require('lucide-react');
|
|
10
11
|
var SwitchPrimitives = require('@radix-ui/react-switch');
|
|
11
12
|
var SelectPrimitive = require('@radix-ui/react-select');
|
|
12
|
-
var lucideReact = require('lucide-react');
|
|
13
13
|
var SliderPrimitive = require('@radix-ui/react-slider');
|
|
14
14
|
var CheckboxPrimitive = require('@radix-ui/react-checkbox');
|
|
15
15
|
var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
|
|
@@ -153,7 +153,7 @@ var Input = React2__namespace.forwardRef(
|
|
|
153
153
|
{
|
|
154
154
|
type,
|
|
155
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
|
|
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",
|
|
157
157
|
className
|
|
158
158
|
),
|
|
159
159
|
ref,
|
|
@@ -163,6 +163,58 @@ var Input = React2__namespace.forwardRef(
|
|
|
163
163
|
}
|
|
164
164
|
);
|
|
165
165
|
Input.displayName = "Input";
|
|
166
|
+
var PasswordInput = React2__namespace.forwardRef(
|
|
167
|
+
({ className, visible, onVisibleChange, disabled, ...props }, ref) => {
|
|
168
|
+
const [internalVisible, setInternalVisible] = React2__namespace.useState(false);
|
|
169
|
+
const isControlled = visible !== void 0;
|
|
170
|
+
const show = isControlled ? visible : internalVisible;
|
|
171
|
+
const toggle = () => {
|
|
172
|
+
const next = !show;
|
|
173
|
+
if (!isControlled) setInternalVisible(next);
|
|
174
|
+
onVisibleChange?.(next);
|
|
175
|
+
};
|
|
176
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
177
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
178
|
+
Input,
|
|
179
|
+
{
|
|
180
|
+
type: show ? "text" : "password",
|
|
181
|
+
className: ui.cn("pr-10", className),
|
|
182
|
+
disabled,
|
|
183
|
+
ref,
|
|
184
|
+
...props
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
188
|
+
"button",
|
|
189
|
+
{
|
|
190
|
+
type: "button",
|
|
191
|
+
onClick: toggle,
|
|
192
|
+
disabled,
|
|
193
|
+
tabIndex: -1,
|
|
194
|
+
"aria-label": show ? "Hide password" : "Show password",
|
|
195
|
+
"aria-pressed": show,
|
|
196
|
+
className: "absolute inset-y-0 right-0 flex items-center justify-center px-3 text-muted-foreground transition-colors hover:text-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",
|
|
197
|
+
children: show ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { className: "size-4", "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: "size-4", "aria-hidden": "true" })
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] });
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
PasswordInput.displayName = "PasswordInput";
|
|
204
|
+
var Textarea = React2__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
205
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
206
|
+
"textarea",
|
|
207
|
+
{
|
|
208
|
+
className: ui.cn(
|
|
209
|
+
"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",
|
|
210
|
+
className
|
|
211
|
+
),
|
|
212
|
+
ref,
|
|
213
|
+
...props
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
Textarea.displayName = "Textarea";
|
|
166
218
|
var Switch = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
167
219
|
SwitchPrimitives__namespace.Root,
|
|
168
220
|
{
|
|
@@ -436,6 +488,10 @@ var IconInput = ({ value, onChange }) => {
|
|
|
436
488
|
)
|
|
437
489
|
] });
|
|
438
490
|
};
|
|
491
|
+
var SIZE = {
|
|
492
|
+
sm: { input: "h-8 text-sm", select: "h-8", label: "text-xs", desc: "text-xs" },
|
|
493
|
+
md: { input: "", select: "", label: "", desc: "" }
|
|
494
|
+
};
|
|
439
495
|
function itemClasses(labelPosition, className) {
|
|
440
496
|
return ui.cn(
|
|
441
497
|
labelPosition === "side" && "grid grid-cols-3 items-center gap-2",
|
|
@@ -453,21 +509,74 @@ var InputField = ({
|
|
|
453
509
|
value,
|
|
454
510
|
onChange,
|
|
455
511
|
labelPosition = "side",
|
|
512
|
+
size = "sm",
|
|
456
513
|
className
|
|
457
514
|
}) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
458
|
-
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className:
|
|
515
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
459
516
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
460
517
|
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
461
518
|
Input,
|
|
462
519
|
{
|
|
463
|
-
className:
|
|
520
|
+
className: SIZE[size].input,
|
|
521
|
+
placeholder,
|
|
522
|
+
value: value ?? "",
|
|
523
|
+
onChange: (e) => onChange?.(e.target.value)
|
|
524
|
+
}
|
|
525
|
+
) }),
|
|
526
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
527
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: SIZE[size].desc })
|
|
528
|
+
] })
|
|
529
|
+
] });
|
|
530
|
+
var PasswordField = ({
|
|
531
|
+
label,
|
|
532
|
+
description,
|
|
533
|
+
placeholder,
|
|
534
|
+
value,
|
|
535
|
+
onChange,
|
|
536
|
+
labelPosition = "side",
|
|
537
|
+
size = "sm",
|
|
538
|
+
className
|
|
539
|
+
}) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
540
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
541
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
542
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
543
|
+
PasswordInput,
|
|
544
|
+
{
|
|
545
|
+
className: SIZE[size].input,
|
|
546
|
+
placeholder,
|
|
547
|
+
value: value ?? "",
|
|
548
|
+
onChange: (e) => onChange?.(e.target.value)
|
|
549
|
+
}
|
|
550
|
+
) }),
|
|
551
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
552
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: SIZE[size].desc })
|
|
553
|
+
] })
|
|
554
|
+
] });
|
|
555
|
+
var TextareaField = ({
|
|
556
|
+
label,
|
|
557
|
+
description,
|
|
558
|
+
placeholder,
|
|
559
|
+
value,
|
|
560
|
+
onChange,
|
|
561
|
+
rows,
|
|
562
|
+
labelPosition = "side",
|
|
563
|
+
size = "sm",
|
|
564
|
+
className
|
|
565
|
+
}) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
566
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
567
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
568
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
569
|
+
Textarea,
|
|
570
|
+
{
|
|
571
|
+
className: size === "sm" ? "text-sm" : void 0,
|
|
572
|
+
rows,
|
|
464
573
|
placeholder,
|
|
465
574
|
value: value ?? "",
|
|
466
575
|
onChange: (e) => onChange?.(e.target.value)
|
|
467
576
|
}
|
|
468
577
|
) }),
|
|
469
|
-
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className:
|
|
470
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className:
|
|
578
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
579
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: SIZE[size].desc })
|
|
471
580
|
] })
|
|
472
581
|
] });
|
|
473
582
|
var SelectField = ({
|
|
@@ -478,16 +587,17 @@ var SelectField = ({
|
|
|
478
587
|
onChange,
|
|
479
588
|
placeholder = "Select type",
|
|
480
589
|
labelPosition = "side",
|
|
590
|
+
size = "sm",
|
|
481
591
|
className
|
|
482
592
|
}) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
483
|
-
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className:
|
|
593
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
484
594
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
485
595
|
/* @__PURE__ */ jsxRuntime.jsxs(Select, { value: value ?? "", onValueChange: onChange, children: [
|
|
486
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className:
|
|
596
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: SIZE[size].select, children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder }) }) }),
|
|
487
597
|
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.map((o) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: o.value, children: o.label }, o.value)) })
|
|
488
598
|
] }),
|
|
489
|
-
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className:
|
|
490
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className:
|
|
599
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
600
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: SIZE[size].desc })
|
|
491
601
|
] })
|
|
492
602
|
] });
|
|
493
603
|
var BooleanField = ({
|
|
@@ -495,22 +605,23 @@ var BooleanField = ({
|
|
|
495
605
|
description,
|
|
496
606
|
value,
|
|
497
607
|
onChange,
|
|
498
|
-
labelPosition = "side"
|
|
608
|
+
labelPosition = "side",
|
|
609
|
+
size = "sm"
|
|
499
610
|
}) => {
|
|
500
611
|
if (labelPosition === "side") {
|
|
501
612
|
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "flex items-center justify-between rounded-md border p-2", children: [
|
|
502
613
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
503
|
-
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className:
|
|
504
|
-
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className:
|
|
614
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
615
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description })
|
|
505
616
|
] }),
|
|
506
617
|
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(Switch, { checked: !!value, onCheckedChange: onChange }) })
|
|
507
618
|
] });
|
|
508
619
|
}
|
|
509
620
|
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "space-y-2", children: [
|
|
510
|
-
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className:
|
|
621
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
511
622
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between rounded-md border p-2", children: [
|
|
512
623
|
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(Switch, { checked: !!value, onCheckedChange: onChange }) }),
|
|
513
|
-
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: "ml-2
|
|
624
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: ui.cn("ml-2", SIZE[size].desc), children: description })
|
|
514
625
|
] })
|
|
515
626
|
] });
|
|
516
627
|
};
|
|
@@ -522,9 +633,10 @@ var ColorField = ({
|
|
|
522
633
|
presetColors,
|
|
523
634
|
defaultValue,
|
|
524
635
|
labelPosition = "side",
|
|
636
|
+
size = "sm",
|
|
525
637
|
className
|
|
526
638
|
}) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
527
|
-
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className:
|
|
639
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
528
640
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
529
641
|
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
530
642
|
ColorSwatches,
|
|
@@ -535,8 +647,8 @@ var ColorField = ({
|
|
|
535
647
|
defaultValue
|
|
536
648
|
}
|
|
537
649
|
) }),
|
|
538
|
-
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className:
|
|
539
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className:
|
|
650
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
651
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: SIZE[size].desc })
|
|
540
652
|
] })
|
|
541
653
|
] });
|
|
542
654
|
var NumberField = ({
|
|
@@ -548,9 +660,10 @@ var NumberField = ({
|
|
|
548
660
|
max,
|
|
549
661
|
step,
|
|
550
662
|
labelPosition = "side",
|
|
663
|
+
size = "sm",
|
|
551
664
|
className
|
|
552
665
|
}) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
553
|
-
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className:
|
|
666
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
554
667
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
555
668
|
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
556
669
|
SliderNumber,
|
|
@@ -562,8 +675,8 @@ var NumberField = ({
|
|
|
562
675
|
step
|
|
563
676
|
}
|
|
564
677
|
) }),
|
|
565
|
-
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className:
|
|
566
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className:
|
|
678
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
679
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: SIZE[size].desc })
|
|
567
680
|
] })
|
|
568
681
|
] });
|
|
569
682
|
var IconField = ({
|
|
@@ -572,17 +685,20 @@ var IconField = ({
|
|
|
572
685
|
value,
|
|
573
686
|
onChange,
|
|
574
687
|
labelPosition = "side",
|
|
688
|
+
size = "sm",
|
|
575
689
|
className
|
|
576
690
|
}) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
577
|
-
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className:
|
|
691
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
578
692
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
579
693
|
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(IconInput, { value, onChange }) }),
|
|
580
|
-
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className:
|
|
581
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className:
|
|
694
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
695
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: SIZE[size].desc })
|
|
582
696
|
] })
|
|
583
697
|
] });
|
|
584
698
|
var Field = {
|
|
585
699
|
Input: InputField,
|
|
700
|
+
Password: PasswordField,
|
|
701
|
+
Textarea: TextareaField,
|
|
586
702
|
Boolean: BooleanField,
|
|
587
703
|
Color: ColorField,
|
|
588
704
|
Number: NumberField,
|
|
@@ -592,12 +708,7 @@ var Field = {
|
|
|
592
708
|
function humanize(name) {
|
|
593
709
|
return name.replace(/([A-Z])/g, " $1").replace(/^./, (c) => c.toUpperCase()).trim();
|
|
594
710
|
}
|
|
595
|
-
function
|
|
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) {
|
|
711
|
+
function renderField(field, parentName, control, labelPosition, size) {
|
|
601
712
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
602
713
|
FormField,
|
|
603
714
|
{
|
|
@@ -614,11 +725,21 @@ function renderField(field, parentName, control, labelPosition) {
|
|
|
614
725
|
step: field.step,
|
|
615
726
|
presetColors: field.presetColors,
|
|
616
727
|
defaultValue: field.defaultValue,
|
|
728
|
+
rows: field.rows,
|
|
617
729
|
labelPosition,
|
|
730
|
+
size,
|
|
618
731
|
value: rhf.value,
|
|
619
732
|
onChange: rhf.onChange
|
|
620
733
|
};
|
|
621
734
|
switch (field.type) {
|
|
735
|
+
case "password":
|
|
736
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
737
|
+
PasswordField,
|
|
738
|
+
{
|
|
739
|
+
...common,
|
|
740
|
+
placeholder: field.placeholder ?? `Enter ${field.name}`
|
|
741
|
+
}
|
|
742
|
+
);
|
|
622
743
|
case "boolean":
|
|
623
744
|
return /* @__PURE__ */ jsxRuntime.jsx(BooleanField, { ...common });
|
|
624
745
|
case "color":
|
|
@@ -629,6 +750,14 @@ function renderField(field, parentName, control, labelPosition) {
|
|
|
629
750
|
return /* @__PURE__ */ jsxRuntime.jsx(SelectField, { ...common });
|
|
630
751
|
case "icon":
|
|
631
752
|
return /* @__PURE__ */ jsxRuntime.jsx(IconField, { ...common });
|
|
753
|
+
case "textarea":
|
|
754
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
755
|
+
TextareaField,
|
|
756
|
+
{
|
|
757
|
+
...common,
|
|
758
|
+
placeholder: field.placeholder ?? `Enter ${field.name}`
|
|
759
|
+
}
|
|
760
|
+
);
|
|
632
761
|
case "text":
|
|
633
762
|
default:
|
|
634
763
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -644,9 +773,38 @@ function renderField(field, parentName, control, labelPosition) {
|
|
|
644
773
|
field.name
|
|
645
774
|
);
|
|
646
775
|
}
|
|
647
|
-
function
|
|
776
|
+
function renderGrid(fields, parentName, control, labelPosition, size, columns, key) {
|
|
777
|
+
const customCols = columns !== 2;
|
|
778
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
779
|
+
"div",
|
|
780
|
+
{
|
|
781
|
+
className: ui.cn(
|
|
782
|
+
"grid grid-cols-1 gap-4",
|
|
783
|
+
customCols ? "md:[grid-template-columns:repeat(var(--ff-cols),minmax(0,1fr))]" : "md:grid-cols-2"
|
|
784
|
+
),
|
|
785
|
+
style: customCols ? { "--ff-cols": columns } : void 0,
|
|
786
|
+
children: fields.map((f) => {
|
|
787
|
+
const span = f.colSpan && f.colSpan > 1 ? f.colSpan : void 0;
|
|
788
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
789
|
+
"div",
|
|
790
|
+
{
|
|
791
|
+
className: ui.cn(
|
|
792
|
+
span && "md:[grid-column:span_var(--ff-span)/span_var(--ff-span)]",
|
|
793
|
+
f.className
|
|
794
|
+
),
|
|
795
|
+
style: span ? { "--ff-span": span } : void 0,
|
|
796
|
+
children: renderField(f, parentName, control, labelPosition, size)
|
|
797
|
+
},
|
|
798
|
+
f.name
|
|
799
|
+
);
|
|
800
|
+
})
|
|
801
|
+
},
|
|
802
|
+
key
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
function renderRows(fields, rowConfig, parentName, control, labelPosition, size, columns) {
|
|
648
806
|
if (!rowConfig || rowConfig.length === 0) {
|
|
649
|
-
return
|
|
807
|
+
return renderGrid(fields, parentName, control, labelPosition, size, columns);
|
|
650
808
|
}
|
|
651
809
|
const used = new Set(rowConfig.flatMap((r) => r.fields));
|
|
652
810
|
const unassigned = fields.filter((f) => !used.has(f.name));
|
|
@@ -654,16 +812,26 @@ function renderRows(fields, rowConfig, parentName, control, labelPosition) {
|
|
|
654
812
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
655
813
|
rowConfig.map((row) => {
|
|
656
814
|
const rowFields = row.fields.map((n) => byName.get(n)).filter((f) => !!f);
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
815
|
+
if (rowFields.length === 0) return null;
|
|
816
|
+
return renderGrid(
|
|
817
|
+
rowFields,
|
|
818
|
+
parentName,
|
|
819
|
+
control,
|
|
820
|
+
labelPosition,
|
|
821
|
+
size,
|
|
822
|
+
columns,
|
|
823
|
+
row.id
|
|
824
|
+
);
|
|
665
825
|
}),
|
|
666
|
-
unassigned.length > 0 &&
|
|
826
|
+
unassigned.length > 0 && renderGrid(
|
|
827
|
+
unassigned,
|
|
828
|
+
parentName,
|
|
829
|
+
control,
|
|
830
|
+
labelPosition,
|
|
831
|
+
size,
|
|
832
|
+
columns,
|
|
833
|
+
"_unassigned"
|
|
834
|
+
)
|
|
667
835
|
] });
|
|
668
836
|
}
|
|
669
837
|
var ObjectField = ({
|
|
@@ -671,7 +839,9 @@ var ObjectField = ({
|
|
|
671
839
|
name,
|
|
672
840
|
fields,
|
|
673
841
|
rowConfig,
|
|
674
|
-
labelPosition = "side"
|
|
842
|
+
labelPosition = "side",
|
|
843
|
+
size = "sm",
|
|
844
|
+
columns = 2
|
|
675
845
|
}) => {
|
|
676
846
|
const grouped = fields.reduce((acc, f) => {
|
|
677
847
|
const key = f.group ?? "_ungrouped";
|
|
@@ -682,7 +852,15 @@ var ObjectField = ({
|
|
|
682
852
|
delete grouped["_ungrouped"];
|
|
683
853
|
const groupedEntries = Object.entries(grouped);
|
|
684
854
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
|
|
685
|
-
ungrouped.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: renderRows(
|
|
855
|
+
ungrouped.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: renderRows(
|
|
856
|
+
ungrouped,
|
|
857
|
+
rowConfig,
|
|
858
|
+
name,
|
|
859
|
+
control,
|
|
860
|
+
labelPosition,
|
|
861
|
+
size,
|
|
862
|
+
columns
|
|
863
|
+
) }),
|
|
686
864
|
groupedEntries.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
687
865
|
ui.Accordion,
|
|
688
866
|
{
|
|
@@ -694,7 +872,15 @@ var ObjectField = ({
|
|
|
694
872
|
humanize(group),
|
|
695
873
|
" Settings"
|
|
696
874
|
] }),
|
|
697
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.AccordionContent, { className: "px-3 pb-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: renderRows(
|
|
875
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.AccordionContent, { className: "px-3 pb-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: renderRows(
|
|
876
|
+
gFields,
|
|
877
|
+
rowConfig,
|
|
878
|
+
name,
|
|
879
|
+
control,
|
|
880
|
+
labelPosition,
|
|
881
|
+
size,
|
|
882
|
+
columns
|
|
883
|
+
) }) })
|
|
698
884
|
] }, group))
|
|
699
885
|
}
|
|
700
886
|
)
|
|
@@ -703,26 +889,14 @@ var ObjectField = ({
|
|
|
703
889
|
var FormField2 = Object.assign(FormField, {
|
|
704
890
|
ObjectField,
|
|
705
891
|
Input: InputField,
|
|
892
|
+
Password: PasswordField,
|
|
893
|
+
Textarea: TextareaField,
|
|
706
894
|
Boolean: BooleanField,
|
|
707
895
|
Color: ColorField,
|
|
708
896
|
Number: NumberField,
|
|
709
897
|
Select: SelectField,
|
|
710
898
|
Icon: IconField
|
|
711
899
|
});
|
|
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
900
|
var Checkbox = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
727
901
|
CheckboxPrimitive__namespace.Root,
|
|
728
902
|
{
|
|
@@ -1135,6 +1309,8 @@ exports.InputGroupTextarea = InputGroupTextarea;
|
|
|
1135
1309
|
exports.Label = Label;
|
|
1136
1310
|
exports.NumberField = NumberField;
|
|
1137
1311
|
exports.ObjectField = ObjectField;
|
|
1312
|
+
exports.PasswordField = PasswordField;
|
|
1313
|
+
exports.PasswordInput = PasswordInput;
|
|
1138
1314
|
exports.RadioGroup = RadioGroup;
|
|
1139
1315
|
exports.RadioGroupItem = RadioGroupItem;
|
|
1140
1316
|
exports.Select = Select;
|
|
@@ -1152,6 +1328,7 @@ exports.Slider = Slider;
|
|
|
1152
1328
|
exports.SliderNumber = SliderNumber;
|
|
1153
1329
|
exports.Switch = Switch;
|
|
1154
1330
|
exports.Textarea = Textarea;
|
|
1331
|
+
exports.TextareaField = TextareaField;
|
|
1155
1332
|
exports.useFormField = useFormField;
|
|
1156
1333
|
//# sourceMappingURL=index.cjs.map
|
|
1157
1334
|
//# sourceMappingURL=index.cjs.map
|