@invana/forms 0.0.11 → 0.0.13

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 CHANGED
@@ -9,10 +9,10 @@ var classVarianceAuthority = require('class-variance-authority');
9
9
  var jsxRuntime = require('react/jsx-runtime');
10
10
  var lucideReact = require('lucide-react');
11
11
  var SwitchPrimitives = require('@radix-ui/react-switch');
12
- var SelectPrimitive = require('@radix-ui/react-select');
13
- var SliderPrimitive = require('@radix-ui/react-slider');
14
12
  var CheckboxPrimitive = require('@radix-ui/react-checkbox');
15
13
  var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
14
+ var SelectPrimitive = require('@radix-ui/react-select');
15
+ var SliderPrimitive = require('@radix-ui/react-slider');
16
16
 
17
17
  function _interopNamespace(e) {
18
18
  if (e && e.__esModule) return e;
@@ -35,10 +35,10 @@ function _interopNamespace(e) {
35
35
  var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
36
36
  var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
37
37
  var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
38
- var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
39
- var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
40
38
  var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
41
39
  var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
40
+ var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
41
+ var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
42
42
 
43
43
  // src/form-field.tsx
44
44
  var labelVariants = classVarianceAuthority.cva(
@@ -235,6 +235,51 @@ var Switch = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @
235
235
  }
236
236
  ));
237
237
  Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
238
+ var Checkbox = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
239
+ CheckboxPrimitive__namespace.Root,
240
+ {
241
+ ref,
242
+ className: ui.cn(
243
+ "peer h-4 w-4 shrink-0 rounded-md border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
244
+ className
245
+ ),
246
+ ...props,
247
+ children: /* @__PURE__ */ jsxRuntime.jsx(
248
+ CheckboxPrimitive__namespace.Indicator,
249
+ {
250
+ className: ui.cn("flex items-center justify-center text-current"),
251
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" })
252
+ }
253
+ )
254
+ }
255
+ ));
256
+ Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
257
+ var RadioGroup = React2__namespace.forwardRef(({ className, ...props }, ref) => {
258
+ return /* @__PURE__ */ jsxRuntime.jsx(
259
+ RadioGroupPrimitive__namespace.Root,
260
+ {
261
+ className: ui.cn("grid gap-2", className),
262
+ ...props,
263
+ ref
264
+ }
265
+ );
266
+ });
267
+ RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
268
+ var RadioGroupItem = React2__namespace.forwardRef(({ className, ...props }, ref) => {
269
+ return /* @__PURE__ */ jsxRuntime.jsx(
270
+ RadioGroupPrimitive__namespace.Item,
271
+ {
272
+ ref,
273
+ className: ui.cn(
274
+ "aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
275
+ className
276
+ ),
277
+ ...props,
278
+ children: /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Indicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { className: "h-2.5 w-2.5 fill-current text-current" }) })
279
+ }
280
+ );
281
+ });
282
+ RadioGroupItem.displayName = RadioGroupPrimitive__namespace.Item.displayName;
238
283
  var Select = SelectPrimitive__namespace.Root;
239
284
  var SelectGroup = SelectPrimitive__namespace.Group;
240
285
  var SelectValue = SelectPrimitive__namespace.Value;
@@ -489,18 +534,86 @@ var IconInput = ({ value, onChange }) => {
489
534
  ] });
490
535
  };
491
536
  var SIZE = {
492
- sm: { input: "h-8 text-sm", select: "h-8", label: "text-xs", desc: "text-xs" },
493
- md: { input: "", select: "", label: "", desc: "" }
537
+ xs: {
538
+ input: "h-9",
539
+ select: "h-9",
540
+ textarea: "",
541
+ label: "text-base",
542
+ desc: "text-base",
543
+ gap: "gap-x-3 gap-y-2.5",
544
+ section: "space-y-3",
545
+ outer: "space-y-4",
546
+ stack: "space-y-2",
547
+ sideGap: "gap-x-2",
548
+ trigger: "py-1.5 text-base",
549
+ switch: "scale-90 origin-right",
550
+ check: "h-4 w-4",
551
+ radio: "h-4 w-4"
552
+ },
553
+ sm: {
554
+ input: "h-9",
555
+ select: "h-9",
556
+ textarea: "",
557
+ label: "text-base",
558
+ desc: "text-base",
559
+ gap: "gap-x-3 gap-y-2",
560
+ section: "space-y-3",
561
+ outer: "space-y-4",
562
+ stack: "space-y-1.5",
563
+ sideGap: "gap-x-2",
564
+ trigger: "py-1.5 text-base",
565
+ switch: "scale-90 origin-right",
566
+ check: "h-4 w-4",
567
+ radio: "h-4 w-4"
568
+ },
569
+ md: {
570
+ input: "",
571
+ select: "",
572
+ textarea: "",
573
+ label: "text-base",
574
+ desc: "text-base",
575
+ gap: "gap-4",
576
+ section: "space-y-4",
577
+ outer: "space-y-6",
578
+ stack: "space-y-2",
579
+ sideGap: "gap-2",
580
+ trigger: "py-1.5 text-base",
581
+ switch: "",
582
+ check: "h-4 w-4",
583
+ radio: "h-4 w-4"
584
+ }
494
585
  };
495
- function itemClasses(labelPosition, className) {
586
+ function itemClasses(labelPosition, size, className) {
496
587
  return ui.cn(
497
- labelPosition === "side" && "grid grid-cols-3 items-center gap-2",
498
- labelPosition === "top" && "space-y-2",
588
+ labelPosition === "side" && ui.cn("grid grid-cols-3 items-center", SIZE[size].sideGap),
589
+ labelPosition === "top" && SIZE[size].stack,
499
590
  className
500
591
  );
501
592
  }
502
- function inputWrapper(labelPosition) {
503
- return ui.cn(labelPosition === "side" && "col-span-2", "space-y-1");
593
+ function inputWrapper(labelPosition, size) {
594
+ return ui.cn(labelPosition === "side" && "col-span-2", SIZE[size].stack);
595
+ }
596
+ function StatusPill({ badge }) {
597
+ return /* @__PURE__ */ jsxRuntime.jsx(
598
+ ui.Badge,
599
+ {
600
+ variant: badge.variant ?? "secondary",
601
+ className: "rounded-full px-1.5 py-0 text-base font-medium",
602
+ children: badge.label
603
+ }
604
+ );
605
+ }
606
+ function FieldLabel({
607
+ label,
608
+ badge,
609
+ size,
610
+ className
611
+ }) {
612
+ if (!label && !badge) return null;
613
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormLabel, { className: ui.cn(SIZE[size].label, className), children: [
614
+ label,
615
+ badge && /* @__PURE__ */ jsxRuntime.jsx(StatusPill, { badge })
616
+ ] });
504
617
  }
505
618
  var InputField = ({
506
619
  label,
@@ -510,10 +623,12 @@ var InputField = ({
510
623
  onChange,
511
624
  labelPosition = "side",
512
625
  size = "sm",
626
+ labelClassName,
627
+ badge,
513
628
  className
514
- }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
515
- label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
516
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
629
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
630
+ /* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { label, badge, size, className: labelClassName }),
631
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition, size), children: [
517
632
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
518
633
  Input,
519
634
  {
@@ -535,10 +650,12 @@ var PasswordField = ({
535
650
  onChange,
536
651
  labelPosition = "side",
537
652
  size = "sm",
653
+ labelClassName,
654
+ badge,
538
655
  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: [
656
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
657
+ /* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { label, badge, size, className: labelClassName }),
658
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition, size), children: [
542
659
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
543
660
  PasswordInput,
544
661
  {
@@ -561,14 +678,16 @@ var TextareaField = ({
561
678
  rows,
562
679
  labelPosition = "side",
563
680
  size = "sm",
681
+ labelClassName,
682
+ badge,
564
683
  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: [
684
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
685
+ /* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { label, badge, size, className: labelClassName }),
686
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition, size), children: [
568
687
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
569
688
  Textarea,
570
689
  {
571
- className: size === "sm" ? "text-sm" : void 0,
690
+ className: SIZE[size].textarea || void 0,
572
691
  rows,
573
692
  placeholder,
574
693
  value: value ?? "",
@@ -588,10 +707,12 @@ var SelectField = ({
588
707
  placeholder = "Select type",
589
708
  labelPosition = "side",
590
709
  size = "sm",
710
+ labelClassName,
711
+ badge,
591
712
  className
592
- }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
593
- label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
594
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
713
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
714
+ /* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { label, badge, size, className: labelClassName }),
715
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition, size), children: [
595
716
  /* @__PURE__ */ jsxRuntime.jsxs(Select, { value: value ?? "", onValueChange: onChange, children: [
596
717
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: SIZE[size].select, children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder }) }) }),
597
718
  /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.map((o) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: o.value, children: o.label }, o.value)) })
@@ -606,25 +727,160 @@ var BooleanField = ({
606
727
  value,
607
728
  onChange,
608
729
  labelPosition = "side",
609
- size = "sm"
730
+ size = "sm",
731
+ control = "switch",
732
+ labelClassName,
733
+ badge,
734
+ className,
735
+ boxed = false
610
736
  }) => {
737
+ const boxClass = boxed ? "rounded-md border p-2" : "";
738
+ if (control === "checkbox") {
739
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: ui.cn("flex items-center gap-2 space-y-0", className), children: [
740
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
741
+ Checkbox,
742
+ {
743
+ className: SIZE[size].check,
744
+ checked: !!value,
745
+ onCheckedChange: onChange
746
+ }
747
+ ) }),
748
+ /* @__PURE__ */ jsxRuntime.jsx(
749
+ FieldLabel,
750
+ {
751
+ label,
752
+ badge,
753
+ size,
754
+ className: ui.cn(
755
+ "!mt-0 cursor-pointer font-normal leading-none",
756
+ labelClassName
757
+ )
758
+ }
759
+ )
760
+ ] });
761
+ }
611
762
  if (labelPosition === "side") {
612
- return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "flex items-center justify-between rounded-md border p-2", children: [
763
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: ui.cn("flex items-center justify-between", boxClass), children: [
613
764
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
614
- label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
765
+ /* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { label, badge, size, className: labelClassName }),
615
766
  description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description })
616
767
  ] }),
617
- /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(Switch, { checked: !!value, onCheckedChange: onChange }) })
768
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
769
+ Switch,
770
+ {
771
+ className: SIZE[size].switch || void 0,
772
+ checked: !!value,
773
+ onCheckedChange: onChange
774
+ }
775
+ ) })
618
776
  ] });
619
777
  }
620
- return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "space-y-2", children: [
621
- label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
622
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between rounded-md border p-2", children: [
623
- /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(Switch, { checked: !!value, onCheckedChange: onChange }) }),
778
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: SIZE[size].stack, children: [
779
+ /* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { label, badge, size, className: labelClassName }),
780
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cn("flex items-center justify-between", boxClass), children: [
781
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
782
+ Switch,
783
+ {
784
+ className: SIZE[size].switch || void 0,
785
+ checked: !!value,
786
+ onCheckedChange: onChange
787
+ }
788
+ ) }),
624
789
  description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: ui.cn("ml-2", SIZE[size].desc), children: description })
625
790
  ] })
626
791
  ] });
627
792
  };
793
+ var RadioField = ({
794
+ label,
795
+ description,
796
+ options = [],
797
+ value,
798
+ onChange,
799
+ labelPosition = "side",
800
+ size = "sm",
801
+ orientation = "vertical",
802
+ labelClassName,
803
+ badge,
804
+ className
805
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
806
+ /* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { label, badge, size, className: labelClassName }),
807
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition, size), children: [
808
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
809
+ RadioGroup,
810
+ {
811
+ value: value ?? "",
812
+ onValueChange: onChange,
813
+ className: orientation === "horizontal" ? "flex flex-row items-center gap-x-4" : ui.cn("flex flex-col", SIZE[size].stack),
814
+ children: options.map((o) => /* @__PURE__ */ jsxRuntime.jsxs(
815
+ "label",
816
+ {
817
+ className: "flex cursor-pointer items-center gap-2",
818
+ children: [
819
+ /* @__PURE__ */ jsxRuntime.jsx(
820
+ RadioGroupItem,
821
+ {
822
+ value: o.value,
823
+ className: ui.cn("shrink-0", SIZE[size].radio)
824
+ }
825
+ ),
826
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: ui.cn("leading-none", SIZE[size].label), children: o.label })
827
+ ]
828
+ },
829
+ o.value
830
+ ))
831
+ }
832
+ ) }),
833
+ description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description }),
834
+ /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: SIZE[size].desc })
835
+ ] })
836
+ ] });
837
+ var CheckboxGroupField = ({
838
+ label,
839
+ description,
840
+ options = [],
841
+ value,
842
+ onChange,
843
+ labelPosition = "side",
844
+ size = "sm",
845
+ orientation = "vertical",
846
+ labelClassName,
847
+ badge,
848
+ className
849
+ }) => {
850
+ const selected = Array.isArray(value) ? value : [];
851
+ const toggle = (v, checked) => onChange?.(checked ? [...selected, v] : selected.filter((x) => x !== v));
852
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
853
+ /* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { label, badge, size, className: labelClassName }),
854
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition, size), children: [
855
+ /* @__PURE__ */ jsxRuntime.jsx(
856
+ "div",
857
+ {
858
+ className: orientation === "horizontal" ? "flex flex-row items-center gap-x-4" : ui.cn("flex flex-col", SIZE[size].stack),
859
+ children: options.map((o) => /* @__PURE__ */ jsxRuntime.jsxs(
860
+ "label",
861
+ {
862
+ className: "flex cursor-pointer items-center gap-2",
863
+ children: [
864
+ /* @__PURE__ */ jsxRuntime.jsx(
865
+ Checkbox,
866
+ {
867
+ className: ui.cn("shrink-0", SIZE[size].check),
868
+ checked: selected.includes(o.value),
869
+ onCheckedChange: (c) => toggle(o.value, c === true)
870
+ }
871
+ ),
872
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: ui.cn("leading-none", SIZE[size].label), children: o.label })
873
+ ]
874
+ },
875
+ o.value
876
+ ))
877
+ }
878
+ ),
879
+ description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description }),
880
+ /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: SIZE[size].desc })
881
+ ] })
882
+ ] });
883
+ };
628
884
  var ColorField = ({
629
885
  label,
630
886
  description,
@@ -634,10 +890,12 @@ var ColorField = ({
634
890
  defaultValue,
635
891
  labelPosition = "side",
636
892
  size = "sm",
893
+ labelClassName,
894
+ badge,
637
895
  className
638
- }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
639
- label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
640
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
896
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
897
+ /* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { label, badge, size, className: labelClassName }),
898
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition, size), children: [
641
899
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
642
900
  ColorSwatches,
643
901
  {
@@ -661,10 +919,12 @@ var NumberField = ({
661
919
  step,
662
920
  labelPosition = "side",
663
921
  size = "sm",
922
+ labelClassName,
923
+ badge,
664
924
  className
665
- }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
666
- label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
667
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
925
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
926
+ /* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { label, badge, size, className: labelClassName }),
927
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition, size), children: [
668
928
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
669
929
  SliderNumber,
670
930
  {
@@ -686,10 +946,12 @@ var IconField = ({
686
946
  onChange,
687
947
  labelPosition = "side",
688
948
  size = "sm",
949
+ labelClassName,
950
+ badge,
689
951
  className
690
- }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, className), children: [
691
- label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: SIZE[size].label, children: label }),
692
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition), children: [
952
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: itemClasses(labelPosition, size, className), children: [
953
+ /* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { label, badge, size, className: labelClassName }),
954
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: inputWrapper(labelPosition, size), children: [
693
955
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(IconInput, { value, onChange }) }),
694
956
  description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { className: SIZE[size].desc, children: description }),
695
957
  /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: SIZE[size].desc })
@@ -700,6 +962,8 @@ var Field = {
700
962
  Password: PasswordField,
701
963
  Textarea: TextareaField,
702
964
  Boolean: BooleanField,
965
+ Radio: RadioField,
966
+ CheckboxGroup: CheckboxGroupField,
703
967
  Color: ColorField,
704
968
  Number: NumberField,
705
969
  Select: SelectField,
@@ -708,11 +972,6 @@ var Field = {
708
972
  function humanize(name) {
709
973
  return name.replace(/([A-Z])/g, " $1").replace(/^./, (c) => c.toUpperCase()).trim();
710
974
  }
711
- function chunk(arr, size) {
712
- const out = [];
713
- for (let i = 0; i < arr.length; i += size) out.push(arr.slice(i, i + size));
714
- return out;
715
- }
716
975
  function renderField(field, parentName, control, labelPosition, size) {
717
976
  return /* @__PURE__ */ jsxRuntime.jsx(
718
977
  FormField,
@@ -731,6 +990,11 @@ function renderField(field, parentName, control, labelPosition, size) {
731
990
  presetColors: field.presetColors,
732
991
  defaultValue: field.defaultValue,
733
992
  rows: field.rows,
993
+ control: field.control,
994
+ orientation: field.orientation,
995
+ boxed: field.boxed,
996
+ labelClassName: field.labelClassName,
997
+ badge: field.badge,
734
998
  labelPosition,
735
999
  size,
736
1000
  value: rhf.value,
@@ -747,6 +1011,10 @@ function renderField(field, parentName, control, labelPosition, size) {
747
1011
  );
748
1012
  case "boolean":
749
1013
  return /* @__PURE__ */ jsxRuntime.jsx(BooleanField, { ...common });
1014
+ case "radio":
1015
+ return /* @__PURE__ */ jsxRuntime.jsx(RadioField, { ...common });
1016
+ case "checkbox":
1017
+ return /* @__PURE__ */ jsxRuntime.jsx(CheckboxGroupField, { ...common });
750
1018
  case "color":
751
1019
  return /* @__PURE__ */ jsxRuntime.jsx(ColorField, { ...common });
752
1020
  case "number":
@@ -778,26 +1046,66 @@ function renderField(field, parentName, control, labelPosition, size) {
778
1046
  field.name
779
1047
  );
780
1048
  }
781
- function renderRows(fields, rowConfig, parentName, control, labelPosition, size) {
1049
+ function renderGrid(fields, parentName, control, labelPosition, size, columns, key) {
1050
+ const customCols = columns !== 2;
1051
+ return /* @__PURE__ */ jsxRuntime.jsx(
1052
+ "div",
1053
+ {
1054
+ className: ui.cn(
1055
+ "grid grid-cols-1",
1056
+ SIZE[size].gap,
1057
+ customCols ? "md:[grid-template-columns:repeat(var(--ff-cols),minmax(0,1fr))]" : "md:grid-cols-2"
1058
+ ),
1059
+ style: customCols ? { "--ff-cols": columns } : void 0,
1060
+ children: fields.map((f) => {
1061
+ const span = f.colSpan && f.colSpan > 1 ? f.colSpan : void 0;
1062
+ return /* @__PURE__ */ jsxRuntime.jsx(
1063
+ "div",
1064
+ {
1065
+ className: ui.cn(
1066
+ span && "md:[grid-column:span_var(--ff-span)/span_var(--ff-span)]",
1067
+ f.className
1068
+ ),
1069
+ style: span ? { "--ff-span": span } : void 0,
1070
+ children: renderField(f, parentName, control, labelPosition, size)
1071
+ },
1072
+ f.name
1073
+ );
1074
+ })
1075
+ },
1076
+ key
1077
+ );
1078
+ }
1079
+ function renderRows(fields, rowConfig, parentName, control, labelPosition, size, columns) {
782
1080
  if (!rowConfig || rowConfig.length === 0) {
783
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-4", children: chunk(fields, 2).map((row, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: row.map((f) => renderField(f, parentName, control, labelPosition, size)) }, i)) });
1081
+ return renderGrid(fields, parentName, control, labelPosition, size, columns);
784
1082
  }
785
1083
  const used = new Set(rowConfig.flatMap((r) => r.fields));
786
1084
  const unassigned = fields.filter((f) => !used.has(f.name));
787
1085
  const byName = new Map(fields.map((f) => [f.name, f]));
788
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
1086
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: SIZE[size].section, children: [
789
1087
  rowConfig.map((row) => {
790
1088
  const rowFields = row.fields.map((n) => byName.get(n)).filter((f) => !!f);
791
- return chunk(rowFields, 2).map((cnk, idx) => /* @__PURE__ */ jsxRuntime.jsx(
792
- "div",
793
- {
794
- className: "grid grid-cols-1 gap-4 md:grid-cols-2",
795
- children: cnk.map((f) => renderField(f, parentName, control, labelPosition, size))
796
- },
797
- `${row.id}-${idx}`
798
- ));
1089
+ if (rowFields.length === 0) return null;
1090
+ return renderGrid(
1091
+ rowFields,
1092
+ parentName,
1093
+ control,
1094
+ labelPosition,
1095
+ size,
1096
+ columns,
1097
+ row.id
1098
+ );
799
1099
  }),
800
- unassigned.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-4", children: chunk(unassigned, 2).map((row, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: row.map((f) => renderField(f, parentName, control, labelPosition, size)) }, `u-${i}`)) })
1100
+ unassigned.length > 0 && renderGrid(
1101
+ unassigned,
1102
+ parentName,
1103
+ control,
1104
+ labelPosition,
1105
+ size,
1106
+ columns,
1107
+ "_unassigned"
1108
+ )
801
1109
  ] });
802
1110
  }
803
1111
  var ObjectField = ({
@@ -805,8 +1113,10 @@ var ObjectField = ({
805
1113
  name,
806
1114
  fields,
807
1115
  rowConfig,
1116
+ groupConfig,
808
1117
  labelPosition = "side",
809
- size = "sm"
1118
+ size = "sm",
1119
+ columns = 2
810
1120
  }) => {
811
1121
  const grouped = fields.reduce((acc, f) => {
812
1122
  const key = f.group ?? "_ungrouped";
@@ -816,21 +1126,60 @@ var ObjectField = ({
816
1126
  const ungrouped = grouped["_ungrouped"] ?? [];
817
1127
  delete grouped["_ungrouped"];
818
1128
  const groupedEntries = Object.entries(grouped);
819
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
820
- ungrouped.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: renderRows(ungrouped, rowConfig, name, control, labelPosition, size) }),
1129
+ const groupConfigById = new Map(
1130
+ (groupConfig ?? []).map((g) => [g.id, g])
1131
+ );
1132
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: SIZE[size].outer, children: [
1133
+ ungrouped.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: SIZE[size].section, children: renderRows(
1134
+ ungrouped,
1135
+ rowConfig,
1136
+ name,
1137
+ control,
1138
+ labelPosition,
1139
+ size,
1140
+ columns
1141
+ ) }),
821
1142
  groupedEntries.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
822
1143
  ui.Accordion,
823
1144
  {
824
1145
  type: "multiple",
825
1146
  defaultValue: groupedEntries.map(([k]) => k),
826
- className: "w-full space-y-2",
827
- children: groupedEntries.map(([group, gFields]) => /* @__PURE__ */ jsxRuntime.jsxs(ui.AccordionItem, { value: group, className: "rounded-md border", children: [
828
- /* @__PURE__ */ jsxRuntime.jsxs(ui.AccordionTrigger, { className: "px-3 text-sm font-medium hover:no-underline", children: [
829
- humanize(group),
830
- " Settings"
831
- ] }),
832
- /* @__PURE__ */ jsxRuntime.jsx(ui.AccordionContent, { className: "px-3 pb-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: renderRows(gFields, rowConfig, name, control, labelPosition, size) }) })
833
- ] }, group))
1147
+ className: "w-full",
1148
+ children: groupedEntries.map(([group, gFields]) => {
1149
+ const gc = groupConfigById.get(group);
1150
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.AccordionItem, { value: group, className: "border-b", children: [
1151
+ /* @__PURE__ */ jsxRuntime.jsx(
1152
+ ui.AccordionTrigger,
1153
+ {
1154
+ className: ui.cn(
1155
+ "font-semibold uppercase tracking-wide text-muted-foreground hover:no-underline",
1156
+ SIZE[size].trigger
1157
+ ),
1158
+ children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
1159
+ gc?.label ?? humanize(group),
1160
+ (gc?.showCount ?? true) && /* @__PURE__ */ jsxRuntime.jsx(
1161
+ ui.Badge,
1162
+ {
1163
+ variant: "secondary",
1164
+ className: "rounded-full px-1.5 py-0 text-base font-normal tabular-nums",
1165
+ children: gFields.length
1166
+ }
1167
+ ),
1168
+ gc?.badges?.map((b, i) => /* @__PURE__ */ jsxRuntime.jsx(StatusPill, { badge: b }, i))
1169
+ ] })
1170
+ }
1171
+ ),
1172
+ /* @__PURE__ */ jsxRuntime.jsx(ui.AccordionContent, { className: "pb-3 pt-1", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: SIZE[size].section, children: renderRows(
1173
+ gFields,
1174
+ rowConfig,
1175
+ name,
1176
+ control,
1177
+ labelPosition,
1178
+ size,
1179
+ columns
1180
+ ) }) })
1181
+ ] }, group);
1182
+ })
834
1183
  }
835
1184
  )
836
1185
  ] });
@@ -841,56 +1190,35 @@ var FormField2 = Object.assign(FormField, {
841
1190
  Password: PasswordField,
842
1191
  Textarea: TextareaField,
843
1192
  Boolean: BooleanField,
1193
+ Radio: RadioField,
1194
+ CheckboxGroup: CheckboxGroupField,
844
1195
  Color: ColorField,
845
1196
  Number: NumberField,
846
1197
  Select: SelectField,
847
1198
  Icon: IconField
848
1199
  });
849
- var Checkbox = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
850
- CheckboxPrimitive__namespace.Root,
851
- {
852
- ref,
853
- className: ui.cn(
854
- "peer h-4 w-4 shrink-0 rounded-md border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
855
- className
856
- ),
857
- ...props,
858
- children: /* @__PURE__ */ jsxRuntime.jsx(
859
- CheckboxPrimitive__namespace.Indicator,
860
- {
861
- className: ui.cn("flex items-center justify-center text-current"),
862
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" })
863
- }
864
- )
865
- }
866
- ));
867
- Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
868
- var RadioGroup = React2__namespace.forwardRef(({ className, ...props }, ref) => {
869
- return /* @__PURE__ */ jsxRuntime.jsx(
870
- RadioGroupPrimitive__namespace.Root,
871
- {
872
- className: ui.cn("grid gap-2", className),
873
- ...props,
874
- ref
875
- }
876
- );
877
- });
878
- RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
879
- var RadioGroupItem = React2__namespace.forwardRef(({ className, ...props }, ref) => {
880
- return /* @__PURE__ */ jsxRuntime.jsx(
881
- RadioGroupPrimitive__namespace.Item,
1200
+ function SettingsPanel({
1201
+ form,
1202
+ title,
1203
+ className,
1204
+ contentClassName,
1205
+ children,
1206
+ ...objectField
1207
+ }) {
1208
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { className, children: /* @__PURE__ */ jsxRuntime.jsxs(
1209
+ ui.CardContent,
882
1210
  {
883
- ref,
884
- className: ui.cn(
885
- "aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
886
- className
887
- ),
888
- ...props,
889
- children: /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Indicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { className: "h-2.5 w-2.5 fill-current text-current" }) })
1211
+ className: ui.cn("max-h-[80vh] overflow-y-auto p-4", contentClassName),
1212
+ children: [
1213
+ title && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mb-3 text-base font-semibold uppercase tracking-wide text-muted-foreground", children: title }),
1214
+ /* @__PURE__ */ jsxRuntime.jsxs(Form, { ...form, children: [
1215
+ /* @__PURE__ */ jsxRuntime.jsx(ObjectField, { control: form.control, ...objectField }),
1216
+ children
1217
+ ] })
1218
+ ]
890
1219
  }
891
- );
892
- });
893
- RadioGroupItem.displayName = RadioGroupPrimitive__namespace.Item.displayName;
1220
+ ) });
1221
+ }
894
1222
  function FieldSet({ className, ...props }) {
895
1223
  return /* @__PURE__ */ jsxRuntime.jsx(
896
1224
  "fieldset",
@@ -974,7 +1302,7 @@ function FieldContent({ className, ...props }) {
974
1302
  }
975
1303
  );
976
1304
  }
977
- function FieldLabel({
1305
+ function FieldLabel2({
978
1306
  className,
979
1307
  ...props
980
1308
  }) {
@@ -1226,6 +1554,7 @@ function InputGroupTextarea({
1226
1554
 
1227
1555
  exports.BooleanField = BooleanField;
1228
1556
  exports.Checkbox = Checkbox;
1557
+ exports.CheckboxGroupField = CheckboxGroupField;
1229
1558
  exports.ColorField = ColorField;
1230
1559
  exports.ColorSwatches = ColorSwatches;
1231
1560
  exports.Field = Field;
@@ -1233,7 +1562,7 @@ exports.FieldContent = FieldContent;
1233
1562
  exports.FieldDescription = FieldDescription;
1234
1563
  exports.FieldError = FieldError;
1235
1564
  exports.FieldGroup = FieldGroup;
1236
- exports.FieldLabel = FieldLabel;
1565
+ exports.FieldLabel = FieldLabel2;
1237
1566
  exports.FieldLegend = FieldLegend;
1238
1567
  exports.FieldSeparator = FieldSeparator;
1239
1568
  exports.FieldSet = FieldSet;
@@ -1260,6 +1589,7 @@ exports.NumberField = NumberField;
1260
1589
  exports.ObjectField = ObjectField;
1261
1590
  exports.PasswordField = PasswordField;
1262
1591
  exports.PasswordInput = PasswordInput;
1592
+ exports.RadioField = RadioField;
1263
1593
  exports.RadioGroup = RadioGroup;
1264
1594
  exports.RadioGroupItem = RadioGroupItem;
1265
1595
  exports.Select = Select;
@@ -1273,6 +1603,7 @@ exports.SelectScrollUpButton = SelectScrollUpButton;
1273
1603
  exports.SelectSeparator = SelectSeparator;
1274
1604
  exports.SelectTrigger = SelectTrigger;
1275
1605
  exports.SelectValue = SelectValue;
1606
+ exports.SettingsPanel = SettingsPanel;
1276
1607
  exports.Slider = Slider;
1277
1608
  exports.SliderNumber = SliderNumber;
1278
1609
  exports.Switch = Switch;