@invana/forms 0.0.12 → 0.0.14

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,
@@ -726,6 +990,11 @@ function renderField(field, parentName, control, labelPosition, size) {
726
990
  presetColors: field.presetColors,
727
991
  defaultValue: field.defaultValue,
728
992
  rows: field.rows,
993
+ control: field.control,
994
+ orientation: field.orientation,
995
+ boxed: field.boxed,
996
+ labelClassName: field.labelClassName,
997
+ badge: field.badge,
729
998
  labelPosition,
730
999
  size,
731
1000
  value: rhf.value,
@@ -742,6 +1011,10 @@ function renderField(field, parentName, control, labelPosition, size) {
742
1011
  );
743
1012
  case "boolean":
744
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 });
745
1018
  case "color":
746
1019
  return /* @__PURE__ */ jsxRuntime.jsx(ColorField, { ...common });
747
1020
  case "number":
@@ -779,7 +1052,8 @@ function renderGrid(fields, parentName, control, labelPosition, size, columns, k
779
1052
  "div",
780
1053
  {
781
1054
  className: ui.cn(
782
- "grid grid-cols-1 gap-4",
1055
+ "grid grid-cols-1",
1056
+ SIZE[size].gap,
783
1057
  customCols ? "md:[grid-template-columns:repeat(var(--ff-cols),minmax(0,1fr))]" : "md:grid-cols-2"
784
1058
  ),
785
1059
  style: customCols ? { "--ff-cols": columns } : void 0,
@@ -809,7 +1083,7 @@ function renderRows(fields, rowConfig, parentName, control, labelPosition, size,
809
1083
  const used = new Set(rowConfig.flatMap((r) => r.fields));
810
1084
  const unassigned = fields.filter((f) => !used.has(f.name));
811
1085
  const byName = new Map(fields.map((f) => [f.name, f]));
812
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
1086
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: SIZE[size].section, children: [
813
1087
  rowConfig.map((row) => {
814
1088
  const rowFields = row.fields.map((n) => byName.get(n)).filter((f) => !!f);
815
1089
  if (rowFields.length === 0) return null;
@@ -839,6 +1113,7 @@ var ObjectField = ({
839
1113
  name,
840
1114
  fields,
841
1115
  rowConfig,
1116
+ groupConfig,
842
1117
  labelPosition = "side",
843
1118
  size = "sm",
844
1119
  columns = 2
@@ -851,8 +1126,11 @@ var ObjectField = ({
851
1126
  const ungrouped = grouped["_ungrouped"] ?? [];
852
1127
  delete grouped["_ungrouped"];
853
1128
  const groupedEntries = Object.entries(grouped);
854
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
855
- ungrouped.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: renderRows(
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(
856
1134
  ungrouped,
857
1135
  rowConfig,
858
1136
  name,
@@ -866,22 +1144,42 @@ var ObjectField = ({
866
1144
  {
867
1145
  type: "multiple",
868
1146
  defaultValue: groupedEntries.map(([k]) => k),
869
- className: "w-full space-y-2",
870
- children: groupedEntries.map(([group, gFields]) => /* @__PURE__ */ jsxRuntime.jsxs(ui.AccordionItem, { value: group, className: "rounded-md border", children: [
871
- /* @__PURE__ */ jsxRuntime.jsxs(ui.AccordionTrigger, { className: "px-3 text-sm font-medium hover:no-underline", children: [
872
- humanize(group),
873
- " Settings"
874
- ] }),
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
- ) }) })
884
- ] }, 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
+ })
885
1183
  }
886
1184
  )
887
1185
  ] });
@@ -892,56 +1190,35 @@ var FormField2 = Object.assign(FormField, {
892
1190
  Password: PasswordField,
893
1191
  Textarea: TextareaField,
894
1192
  Boolean: BooleanField,
1193
+ Radio: RadioField,
1194
+ CheckboxGroup: CheckboxGroupField,
895
1195
  Color: ColorField,
896
1196
  Number: NumberField,
897
1197
  Select: SelectField,
898
1198
  Icon: IconField
899
1199
  });
900
- var Checkbox = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
901
- CheckboxPrimitive__namespace.Root,
902
- {
903
- ref,
904
- className: ui.cn(
905
- "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",
906
- className
907
- ),
908
- ...props,
909
- children: /* @__PURE__ */ jsxRuntime.jsx(
910
- CheckboxPrimitive__namespace.Indicator,
911
- {
912
- className: ui.cn("flex items-center justify-center text-current"),
913
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" })
914
- }
915
- )
916
- }
917
- ));
918
- Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
919
- var RadioGroup = React2__namespace.forwardRef(({ className, ...props }, ref) => {
920
- return /* @__PURE__ */ jsxRuntime.jsx(
921
- RadioGroupPrimitive__namespace.Root,
922
- {
923
- className: ui.cn("grid gap-2", className),
924
- ...props,
925
- ref
926
- }
927
- );
928
- });
929
- RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
930
- var RadioGroupItem = React2__namespace.forwardRef(({ className, ...props }, ref) => {
931
- return /* @__PURE__ */ jsxRuntime.jsx(
932
- 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,
933
1210
  {
934
- ref,
935
- className: ui.cn(
936
- "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",
937
- className
938
- ),
939
- ...props,
940
- 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
+ ]
941
1219
  }
942
- );
943
- });
944
- RadioGroupItem.displayName = RadioGroupPrimitive__namespace.Item.displayName;
1220
+ ) });
1221
+ }
945
1222
  function FieldSet({ className, ...props }) {
946
1223
  return /* @__PURE__ */ jsxRuntime.jsx(
947
1224
  "fieldset",
@@ -1025,7 +1302,7 @@ function FieldContent({ className, ...props }) {
1025
1302
  }
1026
1303
  );
1027
1304
  }
1028
- function FieldLabel({
1305
+ function FieldLabel2({
1029
1306
  className,
1030
1307
  ...props
1031
1308
  }) {
@@ -1277,6 +1554,7 @@ function InputGroupTextarea({
1277
1554
 
1278
1555
  exports.BooleanField = BooleanField;
1279
1556
  exports.Checkbox = Checkbox;
1557
+ exports.CheckboxGroupField = CheckboxGroupField;
1280
1558
  exports.ColorField = ColorField;
1281
1559
  exports.ColorSwatches = ColorSwatches;
1282
1560
  exports.Field = Field;
@@ -1284,7 +1562,7 @@ exports.FieldContent = FieldContent;
1284
1562
  exports.FieldDescription = FieldDescription;
1285
1563
  exports.FieldError = FieldError;
1286
1564
  exports.FieldGroup = FieldGroup;
1287
- exports.FieldLabel = FieldLabel;
1565
+ exports.FieldLabel = FieldLabel2;
1288
1566
  exports.FieldLegend = FieldLegend;
1289
1567
  exports.FieldSeparator = FieldSeparator;
1290
1568
  exports.FieldSet = FieldSet;
@@ -1311,6 +1589,7 @@ exports.NumberField = NumberField;
1311
1589
  exports.ObjectField = ObjectField;
1312
1590
  exports.PasswordField = PasswordField;
1313
1591
  exports.PasswordInput = PasswordInput;
1592
+ exports.RadioField = RadioField;
1314
1593
  exports.RadioGroup = RadioGroup;
1315
1594
  exports.RadioGroupItem = RadioGroupItem;
1316
1595
  exports.Select = Select;
@@ -1324,6 +1603,7 @@ exports.SelectScrollUpButton = SelectScrollUpButton;
1324
1603
  exports.SelectSeparator = SelectSeparator;
1325
1604
  exports.SelectTrigger = SelectTrigger;
1326
1605
  exports.SelectValue = SelectValue;
1606
+ exports.SettingsPanel = SettingsPanel;
1327
1607
  exports.Slider = Slider;
1328
1608
  exports.SliderNumber = SliderNumber;
1329
1609
  exports.Switch = Switch;