@invana/forms 0.0.6 → 0.0.11
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 +172 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -2
- package/dist/index.d.ts +32 -2
- package/dist/index.js +170 -47
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@ import { useFormContext, Controller, FormProvider } from 'react-hook-form';
|
|
|
6
6
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
7
7
|
import { cva } from 'class-variance-authority';
|
|
8
8
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
9
|
+
import { EyeOff, Eye, ChevronDown, ChevronUp, Check, Circle } from 'lucide-react';
|
|
9
10
|
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
10
11
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
11
|
-
import { ChevronDown, ChevronUp, Check, Circle } from 'lucide-react';
|
|
12
12
|
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
13
13
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
14
14
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
@@ -126,7 +126,7 @@ var Input = React2.forwardRef(
|
|
|
126
126
|
{
|
|
127
127
|
type,
|
|
128
128
|
className: cn(
|
|
129
|
-
"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
|
|
129
|
+
"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",
|
|
130
130
|
className
|
|
131
131
|
),
|
|
132
132
|
ref,
|
|
@@ -136,6 +136,58 @@ var Input = React2.forwardRef(
|
|
|
136
136
|
}
|
|
137
137
|
);
|
|
138
138
|
Input.displayName = "Input";
|
|
139
|
+
var PasswordInput = React2.forwardRef(
|
|
140
|
+
({ className, visible, onVisibleChange, disabled, ...props }, ref) => {
|
|
141
|
+
const [internalVisible, setInternalVisible] = React2.useState(false);
|
|
142
|
+
const isControlled = visible !== void 0;
|
|
143
|
+
const show = isControlled ? visible : internalVisible;
|
|
144
|
+
const toggle = () => {
|
|
145
|
+
const next = !show;
|
|
146
|
+
if (!isControlled) setInternalVisible(next);
|
|
147
|
+
onVisibleChange?.(next);
|
|
148
|
+
};
|
|
149
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
Input,
|
|
152
|
+
{
|
|
153
|
+
type: show ? "text" : "password",
|
|
154
|
+
className: cn("pr-10", className),
|
|
155
|
+
disabled,
|
|
156
|
+
ref,
|
|
157
|
+
...props
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ jsx(
|
|
161
|
+
"button",
|
|
162
|
+
{
|
|
163
|
+
type: "button",
|
|
164
|
+
onClick: toggle,
|
|
165
|
+
disabled,
|
|
166
|
+
tabIndex: -1,
|
|
167
|
+
"aria-label": show ? "Hide password" : "Show password",
|
|
168
|
+
"aria-pressed": show,
|
|
169
|
+
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",
|
|
170
|
+
children: show ? /* @__PURE__ */ jsx(EyeOff, { className: "size-4", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(Eye, { className: "size-4", "aria-hidden": "true" })
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
] });
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
PasswordInput.displayName = "PasswordInput";
|
|
177
|
+
var Textarea = React2.forwardRef(({ className, ...props }, ref) => {
|
|
178
|
+
return /* @__PURE__ */ jsx(
|
|
179
|
+
"textarea",
|
|
180
|
+
{
|
|
181
|
+
className: cn(
|
|
182
|
+
"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",
|
|
183
|
+
className
|
|
184
|
+
),
|
|
185
|
+
ref,
|
|
186
|
+
...props
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
Textarea.displayName = "Textarea";
|
|
139
191
|
var Switch = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
140
192
|
SwitchPrimitives.Root,
|
|
141
193
|
{
|
|
@@ -409,6 +461,10 @@ var IconInput = ({ value, onChange }) => {
|
|
|
409
461
|
)
|
|
410
462
|
] });
|
|
411
463
|
};
|
|
464
|
+
var SIZE = {
|
|
465
|
+
sm: { input: "h-8 text-sm", select: "h-8", label: "text-xs", desc: "text-xs" },
|
|
466
|
+
md: { input: "", select: "", label: "", desc: "" }
|
|
467
|
+
};
|
|
412
468
|
function itemClasses(labelPosition, className) {
|
|
413
469
|
return cn(
|
|
414
470
|
labelPosition === "side" && "grid grid-cols-3 items-center gap-2",
|
|
@@ -426,21 +482,74 @@ var InputField = ({
|
|
|
426
482
|
value,
|
|
427
483
|
onChange,
|
|
428
484
|
labelPosition = "side",
|
|
485
|
+
size = "sm",
|
|
429
486
|
className
|
|
430
487
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
431
|
-
label && /* @__PURE__ */ jsx(FormLabel, { className:
|
|
488
|
+
label && /* @__PURE__ */ jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
432
489
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
433
490
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
434
491
|
Input,
|
|
435
492
|
{
|
|
436
|
-
className:
|
|
493
|
+
className: SIZE[size].input,
|
|
494
|
+
placeholder,
|
|
495
|
+
value: value ?? "",
|
|
496
|
+
onChange: (e) => onChange?.(e.target.value)
|
|
497
|
+
}
|
|
498
|
+
) }),
|
|
499
|
+
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
500
|
+
/* @__PURE__ */ jsx(FormMessage, { className: SIZE[size].desc })
|
|
501
|
+
] })
|
|
502
|
+
] });
|
|
503
|
+
var PasswordField = ({
|
|
504
|
+
label,
|
|
505
|
+
description,
|
|
506
|
+
placeholder,
|
|
507
|
+
value,
|
|
508
|
+
onChange,
|
|
509
|
+
labelPosition = "side",
|
|
510
|
+
size = "sm",
|
|
511
|
+
className
|
|
512
|
+
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
513
|
+
label && /* @__PURE__ */ jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
514
|
+
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
515
|
+
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
516
|
+
PasswordInput,
|
|
517
|
+
{
|
|
518
|
+
className: SIZE[size].input,
|
|
437
519
|
placeholder,
|
|
438
520
|
value: value ?? "",
|
|
439
521
|
onChange: (e) => onChange?.(e.target.value)
|
|
440
522
|
}
|
|
441
523
|
) }),
|
|
442
|
-
description && /* @__PURE__ */ jsx(FormDescription, { className:
|
|
443
|
-
/* @__PURE__ */ jsx(FormMessage, { className:
|
|
524
|
+
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
525
|
+
/* @__PURE__ */ jsx(FormMessage, { className: SIZE[size].desc })
|
|
526
|
+
] })
|
|
527
|
+
] });
|
|
528
|
+
var TextareaField = ({
|
|
529
|
+
label,
|
|
530
|
+
description,
|
|
531
|
+
placeholder,
|
|
532
|
+
value,
|
|
533
|
+
onChange,
|
|
534
|
+
rows,
|
|
535
|
+
labelPosition = "side",
|
|
536
|
+
size = "sm",
|
|
537
|
+
className
|
|
538
|
+
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
539
|
+
label && /* @__PURE__ */ jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
540
|
+
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
541
|
+
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
542
|
+
Textarea,
|
|
543
|
+
{
|
|
544
|
+
className: size === "sm" ? "text-sm" : void 0,
|
|
545
|
+
rows,
|
|
546
|
+
placeholder,
|
|
547
|
+
value: value ?? "",
|
|
548
|
+
onChange: (e) => onChange?.(e.target.value)
|
|
549
|
+
}
|
|
550
|
+
) }),
|
|
551
|
+
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
552
|
+
/* @__PURE__ */ jsx(FormMessage, { className: SIZE[size].desc })
|
|
444
553
|
] })
|
|
445
554
|
] });
|
|
446
555
|
var SelectField = ({
|
|
@@ -451,16 +560,17 @@ var SelectField = ({
|
|
|
451
560
|
onChange,
|
|
452
561
|
placeholder = "Select type",
|
|
453
562
|
labelPosition = "side",
|
|
563
|
+
size = "sm",
|
|
454
564
|
className
|
|
455
565
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
456
|
-
label && /* @__PURE__ */ jsx(FormLabel, { className:
|
|
566
|
+
label && /* @__PURE__ */ jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
457
567
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
458
568
|
/* @__PURE__ */ jsxs(Select, { value: value ?? "", onValueChange: onChange, children: [
|
|
459
|
-
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(SelectTrigger, { className:
|
|
569
|
+
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(SelectTrigger, { className: SIZE[size].select, children: /* @__PURE__ */ jsx(SelectValue, { placeholder }) }) }),
|
|
460
570
|
/* @__PURE__ */ jsx(SelectContent, { children: options.map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o.value, children: o.label }, o.value)) })
|
|
461
571
|
] }),
|
|
462
|
-
description && /* @__PURE__ */ jsx(FormDescription, { className:
|
|
463
|
-
/* @__PURE__ */ jsx(FormMessage, { className:
|
|
572
|
+
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
573
|
+
/* @__PURE__ */ jsx(FormMessage, { className: SIZE[size].desc })
|
|
464
574
|
] })
|
|
465
575
|
] });
|
|
466
576
|
var BooleanField = ({
|
|
@@ -468,22 +578,23 @@ var BooleanField = ({
|
|
|
468
578
|
description,
|
|
469
579
|
value,
|
|
470
580
|
onChange,
|
|
471
|
-
labelPosition = "side"
|
|
581
|
+
labelPosition = "side",
|
|
582
|
+
size = "sm"
|
|
472
583
|
}) => {
|
|
473
584
|
if (labelPosition === "side") {
|
|
474
585
|
return /* @__PURE__ */ jsxs(FormItem, { className: "flex items-center justify-between rounded-md border p-2", children: [
|
|
475
586
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
476
|
-
label && /* @__PURE__ */ jsx(FormLabel, { className:
|
|
477
|
-
description && /* @__PURE__ */ jsx(FormDescription, { className:
|
|
587
|
+
label && /* @__PURE__ */ jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
588
|
+
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description })
|
|
478
589
|
] }),
|
|
479
590
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Switch, { checked: !!value, onCheckedChange: onChange }) })
|
|
480
591
|
] });
|
|
481
592
|
}
|
|
482
593
|
return /* @__PURE__ */ jsxs(FormItem, { className: "space-y-2", children: [
|
|
483
|
-
label && /* @__PURE__ */ jsx(FormLabel, { className:
|
|
594
|
+
label && /* @__PURE__ */ jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
484
595
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-md border p-2", children: [
|
|
485
596
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Switch, { checked: !!value, onCheckedChange: onChange }) }),
|
|
486
|
-
description && /* @__PURE__ */ jsx(FormDescription, { className: "ml-2
|
|
597
|
+
description && /* @__PURE__ */ jsx(FormDescription, { className: cn("ml-2", SIZE[size].desc), children: description })
|
|
487
598
|
] })
|
|
488
599
|
] });
|
|
489
600
|
};
|
|
@@ -495,9 +606,10 @@ var ColorField = ({
|
|
|
495
606
|
presetColors,
|
|
496
607
|
defaultValue,
|
|
497
608
|
labelPosition = "side",
|
|
609
|
+
size = "sm",
|
|
498
610
|
className
|
|
499
611
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
500
|
-
label && /* @__PURE__ */ jsx(FormLabel, { className:
|
|
612
|
+
label && /* @__PURE__ */ jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
501
613
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
502
614
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
503
615
|
ColorSwatches,
|
|
@@ -508,8 +620,8 @@ var ColorField = ({
|
|
|
508
620
|
defaultValue
|
|
509
621
|
}
|
|
510
622
|
) }),
|
|
511
|
-
description && /* @__PURE__ */ jsx(FormDescription, { className:
|
|
512
|
-
/* @__PURE__ */ jsx(FormMessage, { className:
|
|
623
|
+
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
624
|
+
/* @__PURE__ */ jsx(FormMessage, { className: SIZE[size].desc })
|
|
513
625
|
] })
|
|
514
626
|
] });
|
|
515
627
|
var NumberField = ({
|
|
@@ -521,9 +633,10 @@ var NumberField = ({
|
|
|
521
633
|
max,
|
|
522
634
|
step,
|
|
523
635
|
labelPosition = "side",
|
|
636
|
+
size = "sm",
|
|
524
637
|
className
|
|
525
638
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
526
|
-
label && /* @__PURE__ */ jsx(FormLabel, { className:
|
|
639
|
+
label && /* @__PURE__ */ jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
527
640
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
528
641
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
529
642
|
SliderNumber,
|
|
@@ -535,8 +648,8 @@ var NumberField = ({
|
|
|
535
648
|
step
|
|
536
649
|
}
|
|
537
650
|
) }),
|
|
538
|
-
description && /* @__PURE__ */ jsx(FormDescription, { className:
|
|
539
|
-
/* @__PURE__ */ jsx(FormMessage, { className:
|
|
651
|
+
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
652
|
+
/* @__PURE__ */ jsx(FormMessage, { className: SIZE[size].desc })
|
|
540
653
|
] })
|
|
541
654
|
] });
|
|
542
655
|
var IconField = ({
|
|
@@ -545,17 +658,20 @@ var IconField = ({
|
|
|
545
658
|
value,
|
|
546
659
|
onChange,
|
|
547
660
|
labelPosition = "side",
|
|
661
|
+
size = "sm",
|
|
548
662
|
className
|
|
549
663
|
}) => /* @__PURE__ */ jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
|
|
550
|
-
label && /* @__PURE__ */ jsx(FormLabel, { className:
|
|
664
|
+
label && /* @__PURE__ */ jsx(FormLabel, { className: SIZE[size].label, children: label }),
|
|
551
665
|
/* @__PURE__ */ jsxs("div", { className: inputWrapper(labelPosition), children: [
|
|
552
666
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(IconInput, { value, onChange }) }),
|
|
553
|
-
description && /* @__PURE__ */ jsx(FormDescription, { className:
|
|
554
|
-
/* @__PURE__ */ jsx(FormMessage, { className:
|
|
667
|
+
description && /* @__PURE__ */ jsx(FormDescription, { className: SIZE[size].desc, children: description }),
|
|
668
|
+
/* @__PURE__ */ jsx(FormMessage, { className: SIZE[size].desc })
|
|
555
669
|
] })
|
|
556
670
|
] });
|
|
557
671
|
var Field = {
|
|
558
672
|
Input: InputField,
|
|
673
|
+
Password: PasswordField,
|
|
674
|
+
Textarea: TextareaField,
|
|
559
675
|
Boolean: BooleanField,
|
|
560
676
|
Color: ColorField,
|
|
561
677
|
Number: NumberField,
|
|
@@ -570,7 +686,7 @@ function chunk(arr, size) {
|
|
|
570
686
|
for (let i = 0; i < arr.length; i += size) out.push(arr.slice(i, i + size));
|
|
571
687
|
return out;
|
|
572
688
|
}
|
|
573
|
-
function renderField(field, parentName, control, labelPosition) {
|
|
689
|
+
function renderField(field, parentName, control, labelPosition, size) {
|
|
574
690
|
return /* @__PURE__ */ jsx(
|
|
575
691
|
FormField,
|
|
576
692
|
{
|
|
@@ -587,11 +703,21 @@ function renderField(field, parentName, control, labelPosition) {
|
|
|
587
703
|
step: field.step,
|
|
588
704
|
presetColors: field.presetColors,
|
|
589
705
|
defaultValue: field.defaultValue,
|
|
706
|
+
rows: field.rows,
|
|
590
707
|
labelPosition,
|
|
708
|
+
size,
|
|
591
709
|
value: rhf.value,
|
|
592
710
|
onChange: rhf.onChange
|
|
593
711
|
};
|
|
594
712
|
switch (field.type) {
|
|
713
|
+
case "password":
|
|
714
|
+
return /* @__PURE__ */ jsx(
|
|
715
|
+
PasswordField,
|
|
716
|
+
{
|
|
717
|
+
...common,
|
|
718
|
+
placeholder: field.placeholder ?? `Enter ${field.name}`
|
|
719
|
+
}
|
|
720
|
+
);
|
|
595
721
|
case "boolean":
|
|
596
722
|
return /* @__PURE__ */ jsx(BooleanField, { ...common });
|
|
597
723
|
case "color":
|
|
@@ -602,6 +728,14 @@ function renderField(field, parentName, control, labelPosition) {
|
|
|
602
728
|
return /* @__PURE__ */ jsx(SelectField, { ...common });
|
|
603
729
|
case "icon":
|
|
604
730
|
return /* @__PURE__ */ jsx(IconField, { ...common });
|
|
731
|
+
case "textarea":
|
|
732
|
+
return /* @__PURE__ */ jsx(
|
|
733
|
+
TextareaField,
|
|
734
|
+
{
|
|
735
|
+
...common,
|
|
736
|
+
placeholder: field.placeholder ?? `Enter ${field.name}`
|
|
737
|
+
}
|
|
738
|
+
);
|
|
605
739
|
case "text":
|
|
606
740
|
default:
|
|
607
741
|
return /* @__PURE__ */ jsx(
|
|
@@ -617,9 +751,9 @@ function renderField(field, parentName, control, labelPosition) {
|
|
|
617
751
|
field.name
|
|
618
752
|
);
|
|
619
753
|
}
|
|
620
|
-
function renderRows(fields, rowConfig, parentName, control, labelPosition) {
|
|
754
|
+
function renderRows(fields, rowConfig, parentName, control, labelPosition, size) {
|
|
621
755
|
if (!rowConfig || rowConfig.length === 0) {
|
|
622
|
-
return /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: chunk(fields, 2).map((row, i) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: row.map((f) => renderField(f, parentName, control, labelPosition)) }, i)) });
|
|
756
|
+
return /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: chunk(fields, 2).map((row, i) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: row.map((f) => renderField(f, parentName, control, labelPosition, size)) }, i)) });
|
|
623
757
|
}
|
|
624
758
|
const used = new Set(rowConfig.flatMap((r) => r.fields));
|
|
625
759
|
const unassigned = fields.filter((f) => !used.has(f.name));
|
|
@@ -631,12 +765,12 @@ function renderRows(fields, rowConfig, parentName, control, labelPosition) {
|
|
|
631
765
|
"div",
|
|
632
766
|
{
|
|
633
767
|
className: "grid grid-cols-1 gap-4 md:grid-cols-2",
|
|
634
|
-
children: cnk.map((f) => renderField(f, parentName, control, labelPosition))
|
|
768
|
+
children: cnk.map((f) => renderField(f, parentName, control, labelPosition, size))
|
|
635
769
|
},
|
|
636
770
|
`${row.id}-${idx}`
|
|
637
771
|
));
|
|
638
772
|
}),
|
|
639
|
-
unassigned.length > 0 && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: chunk(unassigned, 2).map((row, i) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: row.map((f) => renderField(f, parentName, control, labelPosition)) }, `u-${i}`)) })
|
|
773
|
+
unassigned.length > 0 && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: chunk(unassigned, 2).map((row, i) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: row.map((f) => renderField(f, parentName, control, labelPosition, size)) }, `u-${i}`)) })
|
|
640
774
|
] });
|
|
641
775
|
}
|
|
642
776
|
var ObjectField = ({
|
|
@@ -644,7 +778,8 @@ var ObjectField = ({
|
|
|
644
778
|
name,
|
|
645
779
|
fields,
|
|
646
780
|
rowConfig,
|
|
647
|
-
labelPosition = "side"
|
|
781
|
+
labelPosition = "side",
|
|
782
|
+
size = "sm"
|
|
648
783
|
}) => {
|
|
649
784
|
const grouped = fields.reduce((acc, f) => {
|
|
650
785
|
const key = f.group ?? "_ungrouped";
|
|
@@ -655,7 +790,7 @@ var ObjectField = ({
|
|
|
655
790
|
delete grouped["_ungrouped"];
|
|
656
791
|
const groupedEntries = Object.entries(grouped);
|
|
657
792
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
658
|
-
ungrouped.length > 0 && /* @__PURE__ */ jsx("div", { className: "space-y-4", children: renderRows(ungrouped, rowConfig, name, control, labelPosition) }),
|
|
793
|
+
ungrouped.length > 0 && /* @__PURE__ */ jsx("div", { className: "space-y-4", children: renderRows(ungrouped, rowConfig, name, control, labelPosition, size) }),
|
|
659
794
|
groupedEntries.length > 0 && /* @__PURE__ */ jsx(
|
|
660
795
|
Accordion,
|
|
661
796
|
{
|
|
@@ -667,7 +802,7 @@ var ObjectField = ({
|
|
|
667
802
|
humanize(group),
|
|
668
803
|
" Settings"
|
|
669
804
|
] }),
|
|
670
|
-
/* @__PURE__ */ jsx(AccordionContent, { className: "px-3 pb-3", children: /* @__PURE__ */ jsx("div", { className: "space-y-4", children: renderRows(gFields, rowConfig, name, control, labelPosition) }) })
|
|
805
|
+
/* @__PURE__ */ jsx(AccordionContent, { className: "px-3 pb-3", children: /* @__PURE__ */ jsx("div", { className: "space-y-4", children: renderRows(gFields, rowConfig, name, control, labelPosition, size) }) })
|
|
671
806
|
] }, group))
|
|
672
807
|
}
|
|
673
808
|
)
|
|
@@ -676,26 +811,14 @@ var ObjectField = ({
|
|
|
676
811
|
var FormField2 = Object.assign(FormField, {
|
|
677
812
|
ObjectField,
|
|
678
813
|
Input: InputField,
|
|
814
|
+
Password: PasswordField,
|
|
815
|
+
Textarea: TextareaField,
|
|
679
816
|
Boolean: BooleanField,
|
|
680
817
|
Color: ColorField,
|
|
681
818
|
Number: NumberField,
|
|
682
819
|
Select: SelectField,
|
|
683
820
|
Icon: IconField
|
|
684
821
|
});
|
|
685
|
-
var Textarea = React2.forwardRef(({ className, ...props }, ref) => {
|
|
686
|
-
return /* @__PURE__ */ jsx(
|
|
687
|
-
"textarea",
|
|
688
|
-
{
|
|
689
|
-
className: cn(
|
|
690
|
-
"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",
|
|
691
|
-
className
|
|
692
|
-
),
|
|
693
|
-
ref,
|
|
694
|
-
...props
|
|
695
|
-
}
|
|
696
|
-
);
|
|
697
|
-
});
|
|
698
|
-
Textarea.displayName = "Textarea";
|
|
699
822
|
var Checkbox = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
700
823
|
CheckboxPrimitive.Root,
|
|
701
824
|
{
|
|
@@ -1074,6 +1197,6 @@ function InputGroupTextarea({
|
|
|
1074
1197
|
);
|
|
1075
1198
|
}
|
|
1076
1199
|
|
|
1077
|
-
export { BooleanField, Checkbox, ColorField, ColorSwatches, Field, FieldContent, FieldDescription, FieldError, FieldGroup, 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, RadioGroup, RadioGroupItem, Select, SelectContent, SelectField, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Slider, SliderNumber, Switch, Textarea, useFormField };
|
|
1200
|
+
export { BooleanField, Checkbox, ColorField, ColorSwatches, Field, FieldContent, FieldDescription, FieldError, FieldGroup, 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, PasswordField, PasswordInput, RadioGroup, RadioGroupItem, Select, SelectContent, SelectField, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Slider, SliderNumber, Switch, Textarea, TextareaField, useFormField };
|
|
1078
1201
|
//# sourceMappingURL=index.js.map
|
|
1079
1202
|
//# sourceMappingURL=index.js.map
|