@rachelallyson/hero-hook-form 1.0.1 → 1.2.0

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.
@@ -1,5 +1,5 @@
1
1
  // src/components/Form.tsx
2
- import React12 from "react";
2
+ import React13 from "react";
3
3
  import { Button as Button2 } from "@heroui/react";
4
4
 
5
5
  // src/hooks/useFormHelper.ts
@@ -68,7 +68,7 @@ function useFormHelper({
68
68
  }
69
69
 
70
70
  // src/components/FormField.tsx
71
- import React11 from "react";
71
+ import React12 from "react";
72
72
  import { useWatch } from "react-hook-form";
73
73
 
74
74
  // src/fields/CheckboxField.tsx
@@ -349,13 +349,122 @@ function FileField(props) {
349
349
  );
350
350
  }
351
351
 
352
- // src/fields/InputField.tsx
352
+ // src/fields/FontPickerField.tsx
353
353
  import React5 from "react";
354
354
  import { Controller as Controller4 } from "react-hook-form";
355
+ var FontPickerComponent = null;
356
+ var fontPickerLoaded = false;
357
+ var fontPickerLoading = false;
358
+ var loadingCallbacks = [];
359
+ function FontPickerField(props) {
360
+ const {
361
+ className,
362
+ control,
363
+ description,
364
+ fontPickerProps,
365
+ isDisabled,
366
+ label,
367
+ name,
368
+ rules
369
+ } = props;
370
+ const [fontPickerState, setFontPickerState] = React5.useState({
371
+ component: FontPickerComponent,
372
+ loading: false,
373
+ error: null
374
+ });
375
+ React5.useEffect(() => {
376
+ if (fontPickerLoaded && FontPickerComponent) {
377
+ setFontPickerState({
378
+ component: FontPickerComponent,
379
+ loading: false,
380
+ error: null
381
+ });
382
+ return;
383
+ }
384
+ if (fontPickerLoading) {
385
+ setFontPickerState((prev) => ({ ...prev, loading: true }));
386
+ const callback = () => {
387
+ if (fontPickerLoaded && FontPickerComponent) {
388
+ setFontPickerState({
389
+ component: FontPickerComponent,
390
+ loading: false,
391
+ error: null
392
+ });
393
+ } else {
394
+ setFontPickerState({
395
+ component: null,
396
+ loading: false,
397
+ error: "Font picker package not found"
398
+ });
399
+ }
400
+ };
401
+ loadingCallbacks.push(callback);
402
+ return;
403
+ }
404
+ const loadFontPicker = async () => {
405
+ fontPickerLoading = true;
406
+ setFontPickerState((prev) => ({ ...prev, loading: true }));
407
+ try {
408
+ const fontPickerModule = await import("@rachelallyson/heroui-font-picker");
409
+ FontPickerComponent = fontPickerModule.FontPicker || fontPickerModule.default;
410
+ fontPickerLoaded = true;
411
+ fontPickerLoading = false;
412
+ setFontPickerState({
413
+ component: FontPickerComponent,
414
+ loading: false,
415
+ error: null
416
+ });
417
+ loadingCallbacks.forEach((callback) => callback());
418
+ loadingCallbacks.length = 0;
419
+ } catch (error) {
420
+ fontPickerLoading = false;
421
+ setFontPickerState({
422
+ component: null,
423
+ loading: false,
424
+ error: "Font picker package not found"
425
+ });
426
+ loadingCallbacks.forEach((callback) => callback());
427
+ loadingCallbacks.length = 0;
428
+ }
429
+ };
430
+ void loadFontPicker();
431
+ }, []);
432
+ if (fontPickerState.loading) {
433
+ return /* @__PURE__ */ React5.createElement("div", { className }, /* @__PURE__ */ React5.createElement("div", { className: "space-y-2" }, label && /* @__PURE__ */ React5.createElement("label", { className: "block text-sm font-medium text-foreground" }, label), description && /* @__PURE__ */ React5.createElement("p", { className: "text-sm text-muted-foreground" }, description), /* @__PURE__ */ React5.createElement("div", { className: "p-4 border border-default-200 bg-default-50 rounded-medium" }, /* @__PURE__ */ React5.createElement("p", { className: "text-default-600 text-sm" }, "Loading font picker..."))));
434
+ }
435
+ if (!fontPickerState.component) {
436
+ return /* @__PURE__ */ React5.createElement("div", { className }, /* @__PURE__ */ React5.createElement("div", { className: "space-y-2" }, label && /* @__PURE__ */ React5.createElement("label", { className: "block text-sm font-medium text-foreground" }, label), description && /* @__PURE__ */ React5.createElement("p", { className: "text-sm text-muted-foreground" }, description), /* @__PURE__ */ React5.createElement("div", { className: "p-4 border border-warning-200 bg-warning-50 rounded-medium" }, /* @__PURE__ */ React5.createElement("p", { className: "text-warning-800 text-sm" }, "Font picker requires the @rachelallyson/heroui-font-picker package. Please install it as a peer dependency for advanced font selection features."))));
437
+ }
438
+ return /* @__PURE__ */ React5.createElement(
439
+ Controller4,
440
+ {
441
+ control,
442
+ name,
443
+ render: ({ field, fieldState }) => /* @__PURE__ */ React5.createElement(
444
+ fontPickerState.component,
445
+ {
446
+ label,
447
+ description,
448
+ value: field.value ?? "",
449
+ onSelectionChange: (value) => field.onChange(value),
450
+ errorMessage: fieldState.error?.message,
451
+ isDisabled,
452
+ className,
453
+ ...fontPickerProps
454
+ }
455
+ ),
456
+ rules
457
+ }
458
+ );
459
+ }
460
+
461
+ // src/fields/InputField.tsx
462
+ import React6 from "react";
463
+ import { Controller as Controller5 } from "react-hook-form";
355
464
  function CoercedInput(props) {
356
465
  const { description, disabled, errorMessage, field, inputProps, label } = props;
357
466
  const defaults = useHeroHookFormDefaults();
358
- return /* @__PURE__ */ React5.createElement(
467
+ return /* @__PURE__ */ React6.createElement(
359
468
  Input,
360
469
  {
361
470
  ...defaults.input,
@@ -383,12 +492,12 @@ function InputField(props) {
383
492
  rules,
384
493
  transform
385
494
  } = props;
386
- return /* @__PURE__ */ React5.createElement(
387
- Controller4,
495
+ return /* @__PURE__ */ React6.createElement(
496
+ Controller5,
388
497
  {
389
498
  control,
390
499
  name,
391
- render: ({ field, fieldState }) => /* @__PURE__ */ React5.createElement("div", { className }, /* @__PURE__ */ React5.createElement(
500
+ render: ({ field, fieldState }) => /* @__PURE__ */ React6.createElement("div", { className }, /* @__PURE__ */ React6.createElement(
392
501
  CoercedInput,
393
502
  {
394
503
  description,
@@ -417,8 +526,8 @@ function InputField(props) {
417
526
  }
418
527
 
419
528
  // src/fields/RadioGroupField.tsx
420
- import React6 from "react";
421
- import { Controller as Controller5 } from "react-hook-form";
529
+ import React7 from "react";
530
+ import { Controller as Controller6 } from "react-hook-form";
422
531
  function RadioGroupField(props) {
423
532
  const {
424
533
  className,
@@ -432,12 +541,12 @@ function RadioGroupField(props) {
432
541
  rules
433
542
  } = props;
434
543
  const defaults = useHeroHookFormDefaults();
435
- return /* @__PURE__ */ React6.createElement(
436
- Controller5,
544
+ return /* @__PURE__ */ React7.createElement(
545
+ Controller6,
437
546
  {
438
547
  control,
439
548
  name,
440
- render: ({ field, fieldState }) => /* @__PURE__ */ React6.createElement("div", { className }, /* @__PURE__ */ React6.createElement(
549
+ render: ({ field, fieldState }) => /* @__PURE__ */ React7.createElement("div", { className }, /* @__PURE__ */ React7.createElement(
441
550
  RadioGroup,
442
551
  {
443
552
  ...defaults.radioGroup,
@@ -450,7 +559,7 @@ function RadioGroupField(props) {
450
559
  onBlur: field.onBlur,
451
560
  onValueChange: (val) => field.onChange(val)
452
561
  },
453
- options.map((opt) => /* @__PURE__ */ React6.createElement(
562
+ options.map((opt) => /* @__PURE__ */ React7.createElement(
454
563
  Radio,
455
564
  {
456
565
  key: String(opt.value),
@@ -459,15 +568,15 @@ function RadioGroupField(props) {
459
568
  },
460
569
  opt.label
461
570
  ))
462
- ), fieldState.error?.message ? /* @__PURE__ */ React6.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
571
+ ), fieldState.error?.message ? /* @__PURE__ */ React7.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
463
572
  rules
464
573
  }
465
574
  );
466
575
  }
467
576
 
468
577
  // src/fields/SelectField.tsx
469
- import React7 from "react";
470
- import { Controller as Controller6 } from "react-hook-form";
578
+ import React8 from "react";
579
+ import { Controller as Controller7 } from "react-hook-form";
471
580
  function SelectField(props) {
472
581
  const {
473
582
  className,
@@ -482,14 +591,14 @@ function SelectField(props) {
482
591
  selectProps
483
592
  } = props;
484
593
  const defaults = useHeroHookFormDefaults();
485
- return /* @__PURE__ */ React7.createElement(
486
- Controller6,
594
+ return /* @__PURE__ */ React8.createElement(
595
+ Controller7,
487
596
  {
488
597
  control,
489
598
  name,
490
599
  render: ({ field, fieldState }) => {
491
600
  const selectedKey = field.value;
492
- return /* @__PURE__ */ React7.createElement("div", { className }, /* @__PURE__ */ React7.createElement(
601
+ return /* @__PURE__ */ React8.createElement("div", { className }, /* @__PURE__ */ React8.createElement(
493
602
  Select,
494
603
  {
495
604
  ...defaults.select,
@@ -507,7 +616,7 @@ function SelectField(props) {
507
616
  field.onChange(next);
508
617
  }
509
618
  },
510
- options.map((opt) => /* @__PURE__ */ React7.createElement(
619
+ options.map((opt) => /* @__PURE__ */ React8.createElement(
511
620
  SelectItem,
512
621
  {
513
622
  key: String(opt.value),
@@ -524,12 +633,12 @@ function SelectField(props) {
524
633
  }
525
634
 
526
635
  // src/fields/SliderField.tsx
527
- import React8 from "react";
528
- import { Controller as Controller7 } from "react-hook-form";
636
+ import React9 from "react";
637
+ import { Controller as Controller8 } from "react-hook-form";
529
638
  function CoercedSlider(props) {
530
639
  const { description, disabled, errorMessage, field, label, sliderProps } = props;
531
640
  const defaults = useHeroHookFormDefaults();
532
- return /* @__PURE__ */ React8.createElement(
641
+ return /* @__PURE__ */ React9.createElement(
533
642
  Slider,
534
643
  {
535
644
  ...defaults.slider,
@@ -557,12 +666,12 @@ function SliderField(props) {
557
666
  sliderProps,
558
667
  transform
559
668
  } = props;
560
- return /* @__PURE__ */ React8.createElement(
561
- Controller7,
669
+ return /* @__PURE__ */ React9.createElement(
670
+ Controller8,
562
671
  {
563
672
  control,
564
673
  name,
565
- render: ({ field, fieldState }) => /* @__PURE__ */ React8.createElement("div", { className }, /* @__PURE__ */ React8.createElement(
674
+ render: ({ field, fieldState }) => /* @__PURE__ */ React9.createElement("div", { className }, /* @__PURE__ */ React9.createElement(
566
675
  CoercedSlider,
567
676
  {
568
677
  description,
@@ -582,8 +691,8 @@ function SliderField(props) {
582
691
  }
583
692
 
584
693
  // src/fields/SwitchField.tsx
585
- import React9 from "react";
586
- import { Controller as Controller8 } from "react-hook-form";
694
+ import React10 from "react";
695
+ import { Controller as Controller9 } from "react-hook-form";
587
696
  function SwitchField(props) {
588
697
  const {
589
698
  className,
@@ -596,12 +705,12 @@ function SwitchField(props) {
596
705
  switchProps
597
706
  } = props;
598
707
  const defaults = useHeroHookFormDefaults();
599
- return /* @__PURE__ */ React9.createElement(
600
- Controller8,
708
+ return /* @__PURE__ */ React10.createElement(
709
+ Controller9,
601
710
  {
602
711
  control,
603
712
  name,
604
- render: ({ field, fieldState }) => /* @__PURE__ */ React9.createElement("div", { className }, /* @__PURE__ */ React9.createElement(
713
+ render: ({ field, fieldState }) => /* @__PURE__ */ React10.createElement("div", { className }, /* @__PURE__ */ React10.createElement(
605
714
  Switch,
606
715
  {
607
716
  ...defaults.switch,
@@ -612,15 +721,15 @@ function SwitchField(props) {
612
721
  onValueChange: (val) => field.onChange(val)
613
722
  },
614
723
  label
615
- ), description ? /* @__PURE__ */ React9.createElement("p", { className: "text-small text-default-400" }, description) : null, fieldState.error?.message ? /* @__PURE__ */ React9.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
724
+ ), description ? /* @__PURE__ */ React10.createElement("p", { className: "text-small text-default-400" }, description) : null, fieldState.error?.message ? /* @__PURE__ */ React10.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
616
725
  rules
617
726
  }
618
727
  );
619
728
  }
620
729
 
621
730
  // src/fields/TextareaField.tsx
622
- import React10 from "react";
623
- import { Controller as Controller9 } from "react-hook-form";
731
+ import React11 from "react";
732
+ import { Controller as Controller10 } from "react-hook-form";
624
733
  function TextareaField(props) {
625
734
  const {
626
735
  className,
@@ -633,12 +742,12 @@ function TextareaField(props) {
633
742
  textareaProps
634
743
  } = props;
635
744
  const defaults = useHeroHookFormDefaults();
636
- return /* @__PURE__ */ React10.createElement(
637
- Controller9,
745
+ return /* @__PURE__ */ React11.createElement(
746
+ Controller10,
638
747
  {
639
748
  control,
640
749
  name,
641
- render: ({ field, fieldState }) => /* @__PURE__ */ React10.createElement("div", { className }, /* @__PURE__ */ React10.createElement(
750
+ render: ({ field, fieldState }) => /* @__PURE__ */ React11.createElement("div", { className }, /* @__PURE__ */ React11.createElement(
642
751
  Textarea,
643
752
  {
644
753
  ...defaults.textarea,
@@ -687,7 +796,7 @@ function FormField({
687
796
  };
688
797
  switch (config.type) {
689
798
  case "input":
690
- return /* @__PURE__ */ React11.createElement(
799
+ return /* @__PURE__ */ React12.createElement(
691
800
  InputField,
692
801
  {
693
802
  ...baseProps,
@@ -697,7 +806,7 @@ function FormField({
697
806
  }
698
807
  );
699
808
  case "textarea":
700
- return /* @__PURE__ */ React11.createElement(
809
+ return /* @__PURE__ */ React12.createElement(
701
810
  TextareaField,
702
811
  {
703
812
  ...baseProps,
@@ -707,7 +816,7 @@ function FormField({
707
816
  }
708
817
  );
709
818
  case "select":
710
- return /* @__PURE__ */ React11.createElement(
819
+ return /* @__PURE__ */ React12.createElement(
711
820
  SelectField,
712
821
  {
713
822
  ...baseProps,
@@ -721,7 +830,7 @@ function FormField({
721
830
  }
722
831
  );
723
832
  case "checkbox":
724
- return /* @__PURE__ */ React11.createElement(
833
+ return /* @__PURE__ */ React12.createElement(
725
834
  CheckboxField,
726
835
  {
727
836
  ...baseProps,
@@ -731,7 +840,7 @@ function FormField({
731
840
  }
732
841
  );
733
842
  case "radio":
734
- return /* @__PURE__ */ React11.createElement(
843
+ return /* @__PURE__ */ React12.createElement(
735
844
  RadioGroupField,
736
845
  {
737
846
  ...baseProps,
@@ -745,7 +854,7 @@ function FormField({
745
854
  }
746
855
  );
747
856
  case "switch":
748
- return /* @__PURE__ */ React11.createElement(
857
+ return /* @__PURE__ */ React12.createElement(
749
858
  SwitchField,
750
859
  {
751
860
  ...baseProps,
@@ -755,7 +864,7 @@ function FormField({
755
864
  }
756
865
  );
757
866
  case "slider":
758
- return /* @__PURE__ */ React11.createElement(
867
+ return /* @__PURE__ */ React12.createElement(
759
868
  SliderField,
760
869
  {
761
870
  ...baseProps,
@@ -765,7 +874,7 @@ function FormField({
765
874
  }
766
875
  );
767
876
  case "date":
768
- return /* @__PURE__ */ React11.createElement(
877
+ return /* @__PURE__ */ React12.createElement(
769
878
  DateField,
770
879
  {
771
880
  ...baseProps,
@@ -775,7 +884,7 @@ function FormField({
775
884
  }
776
885
  );
777
886
  case "file":
778
- return /* @__PURE__ */ React11.createElement(
887
+ return /* @__PURE__ */ React12.createElement(
779
888
  FileField,
780
889
  {
781
890
  ...baseProps,
@@ -786,6 +895,16 @@ function FormField({
786
895
  multiple: config.multiple
787
896
  }
788
897
  );
898
+ case "fontPicker":
899
+ return /* @__PURE__ */ React12.createElement(
900
+ FontPickerField,
901
+ {
902
+ ...baseProps,
903
+ control,
904
+ defaultValue: config.defaultValue,
905
+ fontPickerProps: config.fontPickerProps
906
+ }
907
+ );
789
908
  case "custom":
790
909
  return config.render({
791
910
  control,
@@ -837,12 +956,12 @@ function ConfigurableForm({
837
956
  });
838
957
  const renderFields = () => {
839
958
  if (layout === "grid") {
840
- return /* @__PURE__ */ React12.createElement(
959
+ return /* @__PURE__ */ React13.createElement(
841
960
  "div",
842
961
  {
843
962
  className: `grid gap-${spacing} ${columns === 1 ? "grid-cols-1" : columns === 2 ? "grid-cols-1 md:grid-cols-2" : "grid-cols-1 md:grid-cols-2 lg:grid-cols-3"}`
844
963
  },
845
- fields.map((field) => /* @__PURE__ */ React12.createElement(
964
+ fields.map((field) => /* @__PURE__ */ React13.createElement(
846
965
  FormField,
847
966
  {
848
967
  key: field.name,
@@ -854,7 +973,7 @@ function ConfigurableForm({
854
973
  );
855
974
  }
856
975
  if (layout === "horizontal") {
857
- return /* @__PURE__ */ React12.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, fields.map((field) => /* @__PURE__ */ React12.createElement(
976
+ return /* @__PURE__ */ React13.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, fields.map((field) => /* @__PURE__ */ React13.createElement(
858
977
  FormField,
859
978
  {
860
979
  key: field.name,
@@ -864,7 +983,7 @@ function ConfigurableForm({
864
983
  }
865
984
  )));
866
985
  }
867
- return /* @__PURE__ */ React12.createElement("div", { className: `space-y-${spacing}` }, fields.map((field) => /* @__PURE__ */ React12.createElement(
986
+ return /* @__PURE__ */ React13.createElement("div", { className: `space-y-${spacing}` }, fields.map((field) => /* @__PURE__ */ React13.createElement(
868
987
  FormField,
869
988
  {
870
989
  key: field.name,
@@ -878,23 +997,23 @@ function ConfigurableForm({
878
997
  e.preventDefault();
879
998
  void handleSubmit();
880
999
  };
881
- return /* @__PURE__ */ React12.createElement("form", { className, role: "form", onSubmit: handleFormSubmit }, title && /* @__PURE__ */ React12.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React12.createElement("h2", { className: "text-xl font-semibold text-foreground mb-2" }, title), subtitle && /* @__PURE__ */ React12.createElement("p", { className: "text-sm text-muted-foreground" }, subtitle)), isSubmitted && isSuccess && /* @__PURE__ */ React12.createElement(
1000
+ return /* @__PURE__ */ React13.createElement("form", { className, role: "form", onSubmit: handleFormSubmit }, title && /* @__PURE__ */ React13.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React13.createElement("h2", { className: "text-xl font-semibold text-foreground mb-2" }, title), subtitle && /* @__PURE__ */ React13.createElement("p", { className: "text-sm text-muted-foreground" }, subtitle)), isSubmitted && isSuccess && /* @__PURE__ */ React13.createElement(
882
1001
  "div",
883
1002
  {
884
1003
  className: "mb-6 p-4 bg-success-50 border border-success-200 rounded-lg",
885
1004
  "data-testid": "success-message"
886
1005
  },
887
- /* @__PURE__ */ React12.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
888
- /* @__PURE__ */ React12.createElement("p", { className: "text-success-700 text-sm mt-1" }, "Your request has been processed successfully.")
889
- ), error && /* @__PURE__ */ React12.createElement(
1006
+ /* @__PURE__ */ React13.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
1007
+ /* @__PURE__ */ React13.createElement("p", { className: "text-success-700 text-sm mt-1" }, "Your request has been processed successfully.")
1008
+ ), error && /* @__PURE__ */ React13.createElement(
890
1009
  "div",
891
1010
  {
892
1011
  className: "mb-6 p-4 bg-danger-50 border border-danger-200 rounded-lg",
893
1012
  "data-testid": "error-message"
894
1013
  },
895
- /* @__PURE__ */ React12.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
896
- /* @__PURE__ */ React12.createElement("p", { className: "text-danger-700 text-sm mt-1" }, error)
897
- ), renderFields(), /* @__PURE__ */ React12.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React12.createElement(
1014
+ /* @__PURE__ */ React13.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
1015
+ /* @__PURE__ */ React13.createElement("p", { className: "text-danger-700 text-sm mt-1" }, error)
1016
+ ), renderFields(), /* @__PURE__ */ React13.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React13.createElement(
898
1017
  Button2,
899
1018
  {
900
1019
  color: "primary",
@@ -904,7 +1023,7 @@ function ConfigurableForm({
904
1023
  ...submitButtonProps
905
1024
  },
906
1025
  submitButtonText
907
- ), showResetButton && /* @__PURE__ */ React12.createElement(
1026
+ ), showResetButton && /* @__PURE__ */ React13.createElement(
908
1027
  Button2,
909
1028
  {
910
1029
  isDisabled: isSubmitting,
@@ -916,11 +1035,24 @@ function ConfigurableForm({
916
1035
  )));
917
1036
  }
918
1037
 
1038
+ // src/hooks/useHeroForm.ts
1039
+ import { useFormContext } from "react-hook-form";
1040
+ function useHeroForm() {
1041
+ const form = useFormContext();
1042
+ const defaults = useHeroHookFormDefaults();
1043
+ return {
1044
+ // All React Hook Form methods and state
1045
+ ...form,
1046
+ // Hero Hook Form styling defaults
1047
+ defaults
1048
+ };
1049
+ }
1050
+
919
1051
  // src/providers/FormProvider.tsx
920
- import React13 from "react";
1052
+ import React14 from "react";
921
1053
  import { FormProvider as RHFProvider } from "react-hook-form";
922
1054
  function FormProvider(props) {
923
- return /* @__PURE__ */ React13.createElement(RHFProvider, { ...props.methods }, /* @__PURE__ */ React13.createElement(
1055
+ return /* @__PURE__ */ React14.createElement(RHFProvider, { ...props.methods }, /* @__PURE__ */ React14.createElement(
924
1056
  "form",
925
1057
  {
926
1058
  className: props.className,
@@ -933,15 +1065,14 @@ function FormProvider(props) {
933
1065
  }
934
1066
 
935
1067
  // src/submit/SubmitButton.tsx
936
- import React14 from "react";
937
- import { useFormContext } from "react-hook-form";
1068
+ import React15 from "react";
938
1069
  function SubmitButton(props) {
939
- const ctx = useFormContext();
1070
+ const ctx = useFormContext2();
940
1071
  const loading = props.isLoading ?? ctx.formState.isSubmitting;
941
1072
  const isDisabledFromProps = props.buttonProps?.isDisabled ?? false;
942
1073
  const isDisabled = Boolean(isDisabledFromProps) || Boolean(loading);
943
1074
  const defaults = useHeroHookFormDefaults();
944
- return /* @__PURE__ */ React14.createElement(
1075
+ return /* @__PURE__ */ React15.createElement(
945
1076
  Button,
946
1077
  {
947
1078
  type: "submit",
@@ -949,7 +1080,7 @@ function SubmitButton(props) {
949
1080
  ...props.buttonProps,
950
1081
  isDisabled
951
1082
  },
952
- loading ? /* @__PURE__ */ React14.createElement("span", { className: "inline-flex items-center gap-2" }, /* @__PURE__ */ React14.createElement(Spinner, { size: "sm" }), "Submitting\u2026") : props.children
1083
+ loading ? /* @__PURE__ */ React15.createElement("span", { className: "inline-flex items-center gap-2" }, /* @__PURE__ */ React15.createElement(Spinner, { size: "sm" }), "Submitting\u2026") : props.children
953
1084
  );
954
1085
  }
955
1086
 
@@ -1141,8 +1272,11 @@ var commonValidations = {
1141
1272
  url: createUrlSchema()
1142
1273
  };
1143
1274
 
1275
+ // src/index.ts
1276
+ import { useFormContext as useFormContext2 } from "react-hook-form";
1277
+
1144
1278
  // src/components/ZodForm.tsx
1145
- import React15 from "react";
1279
+ import React16 from "react";
1146
1280
  import { Button as Button3 } from "@heroui/react";
1147
1281
 
1148
1282
  // src/zod-integration.ts
@@ -1178,6 +1312,13 @@ function useZodForm(config) {
1178
1312
  }
1179
1313
  return useForm2(config);
1180
1314
  }
1315
+ function createZodFormConfig(schema, fields, defaultValues) {
1316
+ return {
1317
+ schema,
1318
+ fields,
1319
+ ...defaultValues && { defaultValues }
1320
+ };
1321
+ }
1181
1322
 
1182
1323
  // src/components/ZodForm.tsx
1183
1324
  function ZodForm({
@@ -1199,7 +1340,7 @@ function ZodForm({
1199
1340
  title
1200
1341
  }) {
1201
1342
  const form = useZodForm(config);
1202
- const [submissionState, setSubmissionState] = React15.useState({
1343
+ const [submissionState, setSubmissionState] = React16.useState({
1203
1344
  error: void 0,
1204
1345
  isSubmitted: false,
1205
1346
  isSubmitting: false,
@@ -1256,12 +1397,12 @@ function ZodForm({
1256
1397
  };
1257
1398
  const renderFields = () => {
1258
1399
  if (layout === "grid") {
1259
- return /* @__PURE__ */ React15.createElement(
1400
+ return /* @__PURE__ */ React16.createElement(
1260
1401
  "div",
1261
1402
  {
1262
1403
  className: `grid gap-${spacing} ${columns === 1 ? "grid-cols-1" : columns === 2 ? "grid-cols-1 md:grid-cols-2" : "grid-cols-1 md:grid-cols-2 lg:grid-cols-3"}`
1263
1404
  },
1264
- config.fields.map((field) => /* @__PURE__ */ React15.createElement(
1405
+ config.fields.map((field) => /* @__PURE__ */ React16.createElement(
1265
1406
  FormField,
1266
1407
  {
1267
1408
  key: field.name,
@@ -1273,7 +1414,7 @@ function ZodForm({
1273
1414
  );
1274
1415
  }
1275
1416
  if (layout === "horizontal") {
1276
- return /* @__PURE__ */ React15.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, config.fields.map((field) => /* @__PURE__ */ React15.createElement(
1417
+ return /* @__PURE__ */ React16.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, config.fields.map((field) => /* @__PURE__ */ React16.createElement(
1277
1418
  FormField,
1278
1419
  {
1279
1420
  key: field.name,
@@ -1283,7 +1424,7 @@ function ZodForm({
1283
1424
  }
1284
1425
  )));
1285
1426
  }
1286
- return /* @__PURE__ */ React15.createElement("div", { className: `space-y-${spacing}` }, config.fields.map((field) => /* @__PURE__ */ React15.createElement(
1427
+ return /* @__PURE__ */ React16.createElement("div", { className: `space-y-${spacing}` }, config.fields.map((field) => /* @__PURE__ */ React16.createElement(
1287
1428
  FormField,
1288
1429
  {
1289
1430
  key: field.name,
@@ -1297,7 +1438,7 @@ function ZodForm({
1297
1438
  e.preventDefault();
1298
1439
  void handleSubmit();
1299
1440
  };
1300
- React15.useEffect(() => {
1441
+ React16.useEffect(() => {
1301
1442
  if (config.onError && Object.keys(form.formState.errors).length > 0) {
1302
1443
  config.onError(form.formState.errors);
1303
1444
  }
@@ -1312,23 +1453,23 @@ function ZodForm({
1312
1453
  values: form.getValues()
1313
1454
  });
1314
1455
  }
1315
- return /* @__PURE__ */ React15.createElement("form", { className, role: "form", onSubmit: handleFormSubmit }, title && /* @__PURE__ */ React15.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React15.createElement("h2", { className: "text-xl font-semibold text-foreground mb-2" }, title), subtitle && /* @__PURE__ */ React15.createElement("p", { className: "text-sm text-muted-foreground" }, subtitle)), submissionState.isSubmitted && submissionState.isSuccess && /* @__PURE__ */ React15.createElement(
1456
+ return /* @__PURE__ */ React16.createElement("form", { className, role: "form", onSubmit: handleFormSubmit }, title && /* @__PURE__ */ React16.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React16.createElement("h2", { className: "text-xl font-semibold text-foreground mb-2" }, title), subtitle && /* @__PURE__ */ React16.createElement("p", { className: "text-sm text-muted-foreground" }, subtitle)), submissionState.isSubmitted && submissionState.isSuccess && /* @__PURE__ */ React16.createElement(
1316
1457
  "div",
1317
1458
  {
1318
1459
  className: "mb-6 p-4 bg-success-50 border border-success-200 rounded-lg",
1319
1460
  "data-testid": "success-message"
1320
1461
  },
1321
- /* @__PURE__ */ React15.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
1322
- /* @__PURE__ */ React15.createElement("p", { className: "text-success-700 text-sm mt-1" }, "Your request has been processed successfully.")
1323
- ), submissionState.error && errorDisplay !== "none" && /* @__PURE__ */ React15.createElement(
1462
+ /* @__PURE__ */ React16.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
1463
+ /* @__PURE__ */ React16.createElement("p", { className: "text-success-700 text-sm mt-1" }, "Your request has been processed successfully.")
1464
+ ), submissionState.error && errorDisplay !== "none" && /* @__PURE__ */ React16.createElement(
1324
1465
  "div",
1325
1466
  {
1326
1467
  className: "mb-6 p-4 bg-danger-50 border border-danger-200 rounded-lg",
1327
1468
  "data-testid": "error-message"
1328
1469
  },
1329
- /* @__PURE__ */ React15.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
1330
- /* @__PURE__ */ React15.createElement("p", { className: "text-danger-700 text-sm mt-1" }, submissionState.error)
1331
- ), renderFields(), /* @__PURE__ */ React15.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React15.createElement(
1470
+ /* @__PURE__ */ React16.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
1471
+ /* @__PURE__ */ React16.createElement("p", { className: "text-danger-700 text-sm mt-1" }, submissionState.error)
1472
+ ), renderFields(), /* @__PURE__ */ React16.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React16.createElement(
1332
1473
  Button3,
1333
1474
  {
1334
1475
  color: "primary",
@@ -1338,7 +1479,7 @@ function ZodForm({
1338
1479
  ...submitButtonProps
1339
1480
  },
1340
1481
  submitButtonText
1341
- ), showResetButton && /* @__PURE__ */ React15.createElement(
1482
+ ), showResetButton && /* @__PURE__ */ React16.createElement(
1342
1483
  Button3,
1343
1484
  {
1344
1485
  isDisabled: submissionState.isSubmitting,
@@ -1354,6 +1495,7 @@ export {
1354
1495
  ConfigurableForm,
1355
1496
  DateField,
1356
1497
  FileField,
1498
+ FontPickerField,
1357
1499
  FormField,
1358
1500
  FormProvider,
1359
1501
  HeroHookFormProvider,
@@ -1385,13 +1527,16 @@ export {
1385
1527
  createRequiredCheckboxSchema,
1386
1528
  createRequiredSchema,
1387
1529
  createUrlSchema,
1530
+ createZodFormConfig,
1388
1531
  getFieldError,
1389
1532
  getFormErrors,
1390
1533
  hasFieldError,
1391
1534
  hasFormErrors,
1392
1535
  simulateFieldInput,
1393
1536
  simulateFormSubmission,
1537
+ useFormContext2 as useFormContext,
1394
1538
  useFormHelper,
1539
+ useHeroForm,
1395
1540
  useHeroHookFormDefaults,
1396
1541
  useZodForm,
1397
1542
  waitForFormState