@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.
package/dist/index.js CHANGED
@@ -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
@@ -344,13 +344,122 @@ function FileField(props) {
344
344
  );
345
345
  }
346
346
 
347
- // src/fields/InputField.tsx
347
+ // src/fields/FontPickerField.tsx
348
348
  import React5 from "react";
349
349
  import { Controller as Controller4 } from "react-hook-form";
350
+ var FontPickerComponent = null;
351
+ var fontPickerLoaded = false;
352
+ var fontPickerLoading = false;
353
+ var loadingCallbacks = [];
354
+ function FontPickerField(props) {
355
+ const {
356
+ className,
357
+ control,
358
+ description,
359
+ fontPickerProps,
360
+ isDisabled,
361
+ label,
362
+ name,
363
+ rules
364
+ } = props;
365
+ const [fontPickerState, setFontPickerState] = React5.useState({
366
+ component: FontPickerComponent,
367
+ loading: false,
368
+ error: null
369
+ });
370
+ React5.useEffect(() => {
371
+ if (fontPickerLoaded && FontPickerComponent) {
372
+ setFontPickerState({
373
+ component: FontPickerComponent,
374
+ loading: false,
375
+ error: null
376
+ });
377
+ return;
378
+ }
379
+ if (fontPickerLoading) {
380
+ setFontPickerState((prev) => ({ ...prev, loading: true }));
381
+ const callback = () => {
382
+ if (fontPickerLoaded && FontPickerComponent) {
383
+ setFontPickerState({
384
+ component: FontPickerComponent,
385
+ loading: false,
386
+ error: null
387
+ });
388
+ } else {
389
+ setFontPickerState({
390
+ component: null,
391
+ loading: false,
392
+ error: "Font picker package not found"
393
+ });
394
+ }
395
+ };
396
+ loadingCallbacks.push(callback);
397
+ return;
398
+ }
399
+ const loadFontPicker = async () => {
400
+ fontPickerLoading = true;
401
+ setFontPickerState((prev) => ({ ...prev, loading: true }));
402
+ try {
403
+ const fontPickerModule = await import("@rachelallyson/heroui-font-picker");
404
+ FontPickerComponent = fontPickerModule.FontPicker || fontPickerModule.default;
405
+ fontPickerLoaded = true;
406
+ fontPickerLoading = false;
407
+ setFontPickerState({
408
+ component: FontPickerComponent,
409
+ loading: false,
410
+ error: null
411
+ });
412
+ loadingCallbacks.forEach((callback) => callback());
413
+ loadingCallbacks.length = 0;
414
+ } catch (error) {
415
+ fontPickerLoading = false;
416
+ setFontPickerState({
417
+ component: null,
418
+ loading: false,
419
+ error: "Font picker package not found"
420
+ });
421
+ loadingCallbacks.forEach((callback) => callback());
422
+ loadingCallbacks.length = 0;
423
+ }
424
+ };
425
+ void loadFontPicker();
426
+ }, []);
427
+ if (fontPickerState.loading) {
428
+ 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..."))));
429
+ }
430
+ if (!fontPickerState.component) {
431
+ 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."))));
432
+ }
433
+ return /* @__PURE__ */ React5.createElement(
434
+ Controller4,
435
+ {
436
+ control,
437
+ name,
438
+ render: ({ field, fieldState }) => /* @__PURE__ */ React5.createElement(
439
+ fontPickerState.component,
440
+ {
441
+ label,
442
+ description,
443
+ value: field.value ?? "",
444
+ onSelectionChange: (value) => field.onChange(value),
445
+ errorMessage: fieldState.error?.message,
446
+ isDisabled,
447
+ className,
448
+ ...fontPickerProps
449
+ }
450
+ ),
451
+ rules
452
+ }
453
+ );
454
+ }
455
+
456
+ // src/fields/InputField.tsx
457
+ import React6 from "react";
458
+ import { Controller as Controller5 } from "react-hook-form";
350
459
  function CoercedInput(props) {
351
460
  const { description, disabled, errorMessage, field, inputProps, label } = props;
352
461
  const defaults = useHeroHookFormDefaults();
353
- return /* @__PURE__ */ React5.createElement(
462
+ return /* @__PURE__ */ React6.createElement(
354
463
  Input,
355
464
  {
356
465
  ...defaults.input,
@@ -378,12 +487,12 @@ function InputField(props) {
378
487
  rules,
379
488
  transform
380
489
  } = props;
381
- return /* @__PURE__ */ React5.createElement(
382
- Controller4,
490
+ return /* @__PURE__ */ React6.createElement(
491
+ Controller5,
383
492
  {
384
493
  control,
385
494
  name,
386
- render: ({ field, fieldState }) => /* @__PURE__ */ React5.createElement("div", { className }, /* @__PURE__ */ React5.createElement(
495
+ render: ({ field, fieldState }) => /* @__PURE__ */ React6.createElement("div", { className }, /* @__PURE__ */ React6.createElement(
387
496
  CoercedInput,
388
497
  {
389
498
  description,
@@ -412,8 +521,8 @@ function InputField(props) {
412
521
  }
413
522
 
414
523
  // src/fields/RadioGroupField.tsx
415
- import React6 from "react";
416
- import { Controller as Controller5 } from "react-hook-form";
524
+ import React7 from "react";
525
+ import { Controller as Controller6 } from "react-hook-form";
417
526
  function RadioGroupField(props) {
418
527
  const {
419
528
  className,
@@ -427,12 +536,12 @@ function RadioGroupField(props) {
427
536
  rules
428
537
  } = props;
429
538
  const defaults = useHeroHookFormDefaults();
430
- return /* @__PURE__ */ React6.createElement(
431
- Controller5,
539
+ return /* @__PURE__ */ React7.createElement(
540
+ Controller6,
432
541
  {
433
542
  control,
434
543
  name,
435
- render: ({ field, fieldState }) => /* @__PURE__ */ React6.createElement("div", { className }, /* @__PURE__ */ React6.createElement(
544
+ render: ({ field, fieldState }) => /* @__PURE__ */ React7.createElement("div", { className }, /* @__PURE__ */ React7.createElement(
436
545
  RadioGroup,
437
546
  {
438
547
  ...defaults.radioGroup,
@@ -445,7 +554,7 @@ function RadioGroupField(props) {
445
554
  onBlur: field.onBlur,
446
555
  onValueChange: (val) => field.onChange(val)
447
556
  },
448
- options.map((opt) => /* @__PURE__ */ React6.createElement(
557
+ options.map((opt) => /* @__PURE__ */ React7.createElement(
449
558
  Radio,
450
559
  {
451
560
  key: String(opt.value),
@@ -454,15 +563,15 @@ function RadioGroupField(props) {
454
563
  },
455
564
  opt.label
456
565
  ))
457
- ), fieldState.error?.message ? /* @__PURE__ */ React6.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
566
+ ), fieldState.error?.message ? /* @__PURE__ */ React7.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
458
567
  rules
459
568
  }
460
569
  );
461
570
  }
462
571
 
463
572
  // src/fields/SelectField.tsx
464
- import React7 from "react";
465
- import { Controller as Controller6 } from "react-hook-form";
573
+ import React8 from "react";
574
+ import { Controller as Controller7 } from "react-hook-form";
466
575
  function SelectField(props) {
467
576
  const {
468
577
  className,
@@ -477,14 +586,14 @@ function SelectField(props) {
477
586
  selectProps
478
587
  } = props;
479
588
  const defaults = useHeroHookFormDefaults();
480
- return /* @__PURE__ */ React7.createElement(
481
- Controller6,
589
+ return /* @__PURE__ */ React8.createElement(
590
+ Controller7,
482
591
  {
483
592
  control,
484
593
  name,
485
594
  render: ({ field, fieldState }) => {
486
595
  const selectedKey = field.value;
487
- return /* @__PURE__ */ React7.createElement("div", { className }, /* @__PURE__ */ React7.createElement(
596
+ return /* @__PURE__ */ React8.createElement("div", { className }, /* @__PURE__ */ React8.createElement(
488
597
  Select,
489
598
  {
490
599
  ...defaults.select,
@@ -502,7 +611,7 @@ function SelectField(props) {
502
611
  field.onChange(next);
503
612
  }
504
613
  },
505
- options.map((opt) => /* @__PURE__ */ React7.createElement(
614
+ options.map((opt) => /* @__PURE__ */ React8.createElement(
506
615
  SelectItem,
507
616
  {
508
617
  key: String(opt.value),
@@ -519,12 +628,12 @@ function SelectField(props) {
519
628
  }
520
629
 
521
630
  // src/fields/SliderField.tsx
522
- import React8 from "react";
523
- import { Controller as Controller7 } from "react-hook-form";
631
+ import React9 from "react";
632
+ import { Controller as Controller8 } from "react-hook-form";
524
633
  function CoercedSlider(props) {
525
634
  const { description, disabled, errorMessage, field, label, sliderProps } = props;
526
635
  const defaults = useHeroHookFormDefaults();
527
- return /* @__PURE__ */ React8.createElement(
636
+ return /* @__PURE__ */ React9.createElement(
528
637
  Slider,
529
638
  {
530
639
  ...defaults.slider,
@@ -552,12 +661,12 @@ function SliderField(props) {
552
661
  sliderProps,
553
662
  transform
554
663
  } = props;
555
- return /* @__PURE__ */ React8.createElement(
556
- Controller7,
664
+ return /* @__PURE__ */ React9.createElement(
665
+ Controller8,
557
666
  {
558
667
  control,
559
668
  name,
560
- render: ({ field, fieldState }) => /* @__PURE__ */ React8.createElement("div", { className }, /* @__PURE__ */ React8.createElement(
669
+ render: ({ field, fieldState }) => /* @__PURE__ */ React9.createElement("div", { className }, /* @__PURE__ */ React9.createElement(
561
670
  CoercedSlider,
562
671
  {
563
672
  description,
@@ -577,8 +686,8 @@ function SliderField(props) {
577
686
  }
578
687
 
579
688
  // src/fields/SwitchField.tsx
580
- import React9 from "react";
581
- import { Controller as Controller8 } from "react-hook-form";
689
+ import React10 from "react";
690
+ import { Controller as Controller9 } from "react-hook-form";
582
691
  function SwitchField(props) {
583
692
  const {
584
693
  className,
@@ -591,12 +700,12 @@ function SwitchField(props) {
591
700
  switchProps
592
701
  } = props;
593
702
  const defaults = useHeroHookFormDefaults();
594
- return /* @__PURE__ */ React9.createElement(
595
- Controller8,
703
+ return /* @__PURE__ */ React10.createElement(
704
+ Controller9,
596
705
  {
597
706
  control,
598
707
  name,
599
- render: ({ field, fieldState }) => /* @__PURE__ */ React9.createElement("div", { className }, /* @__PURE__ */ React9.createElement(
708
+ render: ({ field, fieldState }) => /* @__PURE__ */ React10.createElement("div", { className }, /* @__PURE__ */ React10.createElement(
600
709
  Switch,
601
710
  {
602
711
  ...defaults.switch,
@@ -607,15 +716,15 @@ function SwitchField(props) {
607
716
  onValueChange: (val) => field.onChange(val)
608
717
  },
609
718
  label
610
- ), 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),
719
+ ), 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),
611
720
  rules
612
721
  }
613
722
  );
614
723
  }
615
724
 
616
725
  // src/fields/TextareaField.tsx
617
- import React10 from "react";
618
- import { Controller as Controller9 } from "react-hook-form";
726
+ import React11 from "react";
727
+ import { Controller as Controller10 } from "react-hook-form";
619
728
  function TextareaField(props) {
620
729
  const {
621
730
  className,
@@ -628,12 +737,12 @@ function TextareaField(props) {
628
737
  textareaProps
629
738
  } = props;
630
739
  const defaults = useHeroHookFormDefaults();
631
- return /* @__PURE__ */ React10.createElement(
632
- Controller9,
740
+ return /* @__PURE__ */ React11.createElement(
741
+ Controller10,
633
742
  {
634
743
  control,
635
744
  name,
636
- render: ({ field, fieldState }) => /* @__PURE__ */ React10.createElement("div", { className }, /* @__PURE__ */ React10.createElement(
745
+ render: ({ field, fieldState }) => /* @__PURE__ */ React11.createElement("div", { className }, /* @__PURE__ */ React11.createElement(
637
746
  Textarea,
638
747
  {
639
748
  ...defaults.textarea,
@@ -682,7 +791,7 @@ function FormField({
682
791
  };
683
792
  switch (config.type) {
684
793
  case "input":
685
- return /* @__PURE__ */ React11.createElement(
794
+ return /* @__PURE__ */ React12.createElement(
686
795
  InputField,
687
796
  {
688
797
  ...baseProps,
@@ -692,7 +801,7 @@ function FormField({
692
801
  }
693
802
  );
694
803
  case "textarea":
695
- return /* @__PURE__ */ React11.createElement(
804
+ return /* @__PURE__ */ React12.createElement(
696
805
  TextareaField,
697
806
  {
698
807
  ...baseProps,
@@ -702,7 +811,7 @@ function FormField({
702
811
  }
703
812
  );
704
813
  case "select":
705
- return /* @__PURE__ */ React11.createElement(
814
+ return /* @__PURE__ */ React12.createElement(
706
815
  SelectField,
707
816
  {
708
817
  ...baseProps,
@@ -716,7 +825,7 @@ function FormField({
716
825
  }
717
826
  );
718
827
  case "checkbox":
719
- return /* @__PURE__ */ React11.createElement(
828
+ return /* @__PURE__ */ React12.createElement(
720
829
  CheckboxField,
721
830
  {
722
831
  ...baseProps,
@@ -726,7 +835,7 @@ function FormField({
726
835
  }
727
836
  );
728
837
  case "radio":
729
- return /* @__PURE__ */ React11.createElement(
838
+ return /* @__PURE__ */ React12.createElement(
730
839
  RadioGroupField,
731
840
  {
732
841
  ...baseProps,
@@ -740,7 +849,7 @@ function FormField({
740
849
  }
741
850
  );
742
851
  case "switch":
743
- return /* @__PURE__ */ React11.createElement(
852
+ return /* @__PURE__ */ React12.createElement(
744
853
  SwitchField,
745
854
  {
746
855
  ...baseProps,
@@ -750,7 +859,7 @@ function FormField({
750
859
  }
751
860
  );
752
861
  case "slider":
753
- return /* @__PURE__ */ React11.createElement(
862
+ return /* @__PURE__ */ React12.createElement(
754
863
  SliderField,
755
864
  {
756
865
  ...baseProps,
@@ -760,7 +869,7 @@ function FormField({
760
869
  }
761
870
  );
762
871
  case "date":
763
- return /* @__PURE__ */ React11.createElement(
872
+ return /* @__PURE__ */ React12.createElement(
764
873
  DateField,
765
874
  {
766
875
  ...baseProps,
@@ -770,7 +879,7 @@ function FormField({
770
879
  }
771
880
  );
772
881
  case "file":
773
- return /* @__PURE__ */ React11.createElement(
882
+ return /* @__PURE__ */ React12.createElement(
774
883
  FileField,
775
884
  {
776
885
  ...baseProps,
@@ -781,6 +890,16 @@ function FormField({
781
890
  multiple: config.multiple
782
891
  }
783
892
  );
893
+ case "fontPicker":
894
+ return /* @__PURE__ */ React12.createElement(
895
+ FontPickerField,
896
+ {
897
+ ...baseProps,
898
+ control,
899
+ defaultValue: config.defaultValue,
900
+ fontPickerProps: config.fontPickerProps
901
+ }
902
+ );
784
903
  case "custom":
785
904
  return config.render({
786
905
  control,
@@ -832,12 +951,12 @@ function ConfigurableForm({
832
951
  });
833
952
  const renderFields = () => {
834
953
  if (layout === "grid") {
835
- return /* @__PURE__ */ React12.createElement(
954
+ return /* @__PURE__ */ React13.createElement(
836
955
  "div",
837
956
  {
838
957
  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"}`
839
958
  },
840
- fields.map((field) => /* @__PURE__ */ React12.createElement(
959
+ fields.map((field) => /* @__PURE__ */ React13.createElement(
841
960
  FormField,
842
961
  {
843
962
  key: field.name,
@@ -849,7 +968,7 @@ function ConfigurableForm({
849
968
  );
850
969
  }
851
970
  if (layout === "horizontal") {
852
- return /* @__PURE__ */ React12.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, fields.map((field) => /* @__PURE__ */ React12.createElement(
971
+ return /* @__PURE__ */ React13.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, fields.map((field) => /* @__PURE__ */ React13.createElement(
853
972
  FormField,
854
973
  {
855
974
  key: field.name,
@@ -859,7 +978,7 @@ function ConfigurableForm({
859
978
  }
860
979
  )));
861
980
  }
862
- return /* @__PURE__ */ React12.createElement("div", { className: `space-y-${spacing}` }, fields.map((field) => /* @__PURE__ */ React12.createElement(
981
+ return /* @__PURE__ */ React13.createElement("div", { className: `space-y-${spacing}` }, fields.map((field) => /* @__PURE__ */ React13.createElement(
863
982
  FormField,
864
983
  {
865
984
  key: field.name,
@@ -873,23 +992,23 @@ function ConfigurableForm({
873
992
  e.preventDefault();
874
993
  void handleSubmit();
875
994
  };
876
- 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(
995
+ 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(
877
996
  "div",
878
997
  {
879
998
  className: "mb-6 p-4 bg-success-50 border border-success-200 rounded-lg",
880
999
  "data-testid": "success-message"
881
1000
  },
882
- /* @__PURE__ */ React12.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
883
- /* @__PURE__ */ React12.createElement("p", { className: "text-success-700 text-sm mt-1" }, "Your request has been processed successfully.")
884
- ), error && /* @__PURE__ */ React12.createElement(
1001
+ /* @__PURE__ */ React13.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
1002
+ /* @__PURE__ */ React13.createElement("p", { className: "text-success-700 text-sm mt-1" }, "Your request has been processed successfully.")
1003
+ ), error && /* @__PURE__ */ React13.createElement(
885
1004
  "div",
886
1005
  {
887
1006
  className: "mb-6 p-4 bg-danger-50 border border-danger-200 rounded-lg",
888
1007
  "data-testid": "error-message"
889
1008
  },
890
- /* @__PURE__ */ React12.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
891
- /* @__PURE__ */ React12.createElement("p", { className: "text-danger-700 text-sm mt-1" }, error)
892
- ), renderFields(), /* @__PURE__ */ React12.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React12.createElement(
1009
+ /* @__PURE__ */ React13.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
1010
+ /* @__PURE__ */ React13.createElement("p", { className: "text-danger-700 text-sm mt-1" }, error)
1011
+ ), renderFields(), /* @__PURE__ */ React13.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React13.createElement(
893
1012
  Button2,
894
1013
  {
895
1014
  color: "primary",
@@ -899,7 +1018,7 @@ function ConfigurableForm({
899
1018
  ...submitButtonProps
900
1019
  },
901
1020
  submitButtonText
902
- ), showResetButton && /* @__PURE__ */ React12.createElement(
1021
+ ), showResetButton && /* @__PURE__ */ React13.createElement(
903
1022
  Button2,
904
1023
  {
905
1024
  isDisabled: isSubmitting,
@@ -911,11 +1030,24 @@ function ConfigurableForm({
911
1030
  )));
912
1031
  }
913
1032
 
1033
+ // src/hooks/useHeroForm.ts
1034
+ import { useFormContext } from "react-hook-form";
1035
+ function useHeroForm() {
1036
+ const form = useFormContext();
1037
+ const defaults = useHeroHookFormDefaults();
1038
+ return {
1039
+ // All React Hook Form methods and state
1040
+ ...form,
1041
+ // Hero Hook Form styling defaults
1042
+ defaults
1043
+ };
1044
+ }
1045
+
914
1046
  // src/providers/FormProvider.tsx
915
- import React13 from "react";
1047
+ import React14 from "react";
916
1048
  import { FormProvider as RHFProvider } from "react-hook-form";
917
1049
  function FormProvider(props) {
918
- return /* @__PURE__ */ React13.createElement(RHFProvider, { ...props.methods }, /* @__PURE__ */ React13.createElement(
1050
+ return /* @__PURE__ */ React14.createElement(RHFProvider, { ...props.methods }, /* @__PURE__ */ React14.createElement(
919
1051
  "form",
920
1052
  {
921
1053
  className: props.className,
@@ -928,15 +1060,14 @@ function FormProvider(props) {
928
1060
  }
929
1061
 
930
1062
  // src/submit/SubmitButton.tsx
931
- import React14 from "react";
932
- import { useFormContext } from "react-hook-form";
1063
+ import React15 from "react";
933
1064
  function SubmitButton(props) {
934
- const ctx = useFormContext();
1065
+ const ctx = useFormContext2();
935
1066
  const loading = props.isLoading ?? ctx.formState.isSubmitting;
936
1067
  const isDisabledFromProps = props.buttonProps?.isDisabled ?? false;
937
1068
  const isDisabled = Boolean(isDisabledFromProps) || Boolean(loading);
938
1069
  const defaults = useHeroHookFormDefaults();
939
- return /* @__PURE__ */ React14.createElement(
1070
+ return /* @__PURE__ */ React15.createElement(
940
1071
  Button,
941
1072
  {
942
1073
  type: "submit",
@@ -944,7 +1075,7 @@ function SubmitButton(props) {
944
1075
  ...props.buttonProps,
945
1076
  isDisabled
946
1077
  },
947
- loading ? /* @__PURE__ */ React14.createElement("span", { className: "inline-flex items-center gap-2" }, /* @__PURE__ */ React14.createElement(Spinner, { size: "sm" }), "Submitting\u2026") : props.children
1078
+ loading ? /* @__PURE__ */ React15.createElement("span", { className: "inline-flex items-center gap-2" }, /* @__PURE__ */ React15.createElement(Spinner, { size: "sm" }), "Submitting\u2026") : props.children
948
1079
  );
949
1080
  }
950
1081
 
@@ -1136,8 +1267,11 @@ var commonValidations = {
1136
1267
  url: createUrlSchema()
1137
1268
  };
1138
1269
 
1270
+ // src/index.ts
1271
+ import { useFormContext as useFormContext2 } from "react-hook-form";
1272
+
1139
1273
  // src/components/ZodForm.tsx
1140
- import React15 from "react";
1274
+ import React16 from "react";
1141
1275
  import { Button as Button3 } from "@heroui/react";
1142
1276
 
1143
1277
  // src/zod-integration.ts
@@ -1173,6 +1307,13 @@ function useZodForm(config) {
1173
1307
  }
1174
1308
  return useForm2(config);
1175
1309
  }
1310
+ function createZodFormConfig(schema, fields, defaultValues) {
1311
+ return {
1312
+ schema,
1313
+ fields,
1314
+ ...defaultValues && { defaultValues }
1315
+ };
1316
+ }
1176
1317
 
1177
1318
  // src/components/ZodForm.tsx
1178
1319
  function ZodForm({
@@ -1194,7 +1335,7 @@ function ZodForm({
1194
1335
  title
1195
1336
  }) {
1196
1337
  const form = useZodForm(config);
1197
- const [submissionState, setSubmissionState] = React15.useState({
1338
+ const [submissionState, setSubmissionState] = React16.useState({
1198
1339
  error: void 0,
1199
1340
  isSubmitted: false,
1200
1341
  isSubmitting: false,
@@ -1251,12 +1392,12 @@ function ZodForm({
1251
1392
  };
1252
1393
  const renderFields = () => {
1253
1394
  if (layout === "grid") {
1254
- return /* @__PURE__ */ React15.createElement(
1395
+ return /* @__PURE__ */ React16.createElement(
1255
1396
  "div",
1256
1397
  {
1257
1398
  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"}`
1258
1399
  },
1259
- config.fields.map((field) => /* @__PURE__ */ React15.createElement(
1400
+ config.fields.map((field) => /* @__PURE__ */ React16.createElement(
1260
1401
  FormField,
1261
1402
  {
1262
1403
  key: field.name,
@@ -1268,7 +1409,7 @@ function ZodForm({
1268
1409
  );
1269
1410
  }
1270
1411
  if (layout === "horizontal") {
1271
- return /* @__PURE__ */ React15.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, config.fields.map((field) => /* @__PURE__ */ React15.createElement(
1412
+ return /* @__PURE__ */ React16.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, config.fields.map((field) => /* @__PURE__ */ React16.createElement(
1272
1413
  FormField,
1273
1414
  {
1274
1415
  key: field.name,
@@ -1278,7 +1419,7 @@ function ZodForm({
1278
1419
  }
1279
1420
  )));
1280
1421
  }
1281
- return /* @__PURE__ */ React15.createElement("div", { className: `space-y-${spacing}` }, config.fields.map((field) => /* @__PURE__ */ React15.createElement(
1422
+ return /* @__PURE__ */ React16.createElement("div", { className: `space-y-${spacing}` }, config.fields.map((field) => /* @__PURE__ */ React16.createElement(
1282
1423
  FormField,
1283
1424
  {
1284
1425
  key: field.name,
@@ -1292,7 +1433,7 @@ function ZodForm({
1292
1433
  e.preventDefault();
1293
1434
  void handleSubmit();
1294
1435
  };
1295
- React15.useEffect(() => {
1436
+ React16.useEffect(() => {
1296
1437
  if (config.onError && Object.keys(form.formState.errors).length > 0) {
1297
1438
  config.onError(form.formState.errors);
1298
1439
  }
@@ -1307,23 +1448,23 @@ function ZodForm({
1307
1448
  values: form.getValues()
1308
1449
  });
1309
1450
  }
1310
- 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(
1451
+ 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(
1311
1452
  "div",
1312
1453
  {
1313
1454
  className: "mb-6 p-4 bg-success-50 border border-success-200 rounded-lg",
1314
1455
  "data-testid": "success-message"
1315
1456
  },
1316
- /* @__PURE__ */ React15.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
1317
- /* @__PURE__ */ React15.createElement("p", { className: "text-success-700 text-sm mt-1" }, "Your request has been processed successfully.")
1318
- ), submissionState.error && errorDisplay !== "none" && /* @__PURE__ */ React15.createElement(
1457
+ /* @__PURE__ */ React16.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
1458
+ /* @__PURE__ */ React16.createElement("p", { className: "text-success-700 text-sm mt-1" }, "Your request has been processed successfully.")
1459
+ ), submissionState.error && errorDisplay !== "none" && /* @__PURE__ */ React16.createElement(
1319
1460
  "div",
1320
1461
  {
1321
1462
  className: "mb-6 p-4 bg-danger-50 border border-danger-200 rounded-lg",
1322
1463
  "data-testid": "error-message"
1323
1464
  },
1324
- /* @__PURE__ */ React15.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
1325
- /* @__PURE__ */ React15.createElement("p", { className: "text-danger-700 text-sm mt-1" }, submissionState.error)
1326
- ), renderFields(), /* @__PURE__ */ React15.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React15.createElement(
1465
+ /* @__PURE__ */ React16.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
1466
+ /* @__PURE__ */ React16.createElement("p", { className: "text-danger-700 text-sm mt-1" }, submissionState.error)
1467
+ ), renderFields(), /* @__PURE__ */ React16.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React16.createElement(
1327
1468
  Button3,
1328
1469
  {
1329
1470
  color: "primary",
@@ -1333,7 +1474,7 @@ function ZodForm({
1333
1474
  ...submitButtonProps
1334
1475
  },
1335
1476
  submitButtonText
1336
- ), showResetButton && /* @__PURE__ */ React15.createElement(
1477
+ ), showResetButton && /* @__PURE__ */ React16.createElement(
1337
1478
  Button3,
1338
1479
  {
1339
1480
  isDisabled: submissionState.isSubmitting,
@@ -1349,6 +1490,7 @@ export {
1349
1490
  ConfigurableForm,
1350
1491
  DateField,
1351
1492
  FileField,
1493
+ FontPickerField,
1352
1494
  FormField,
1353
1495
  FormProvider,
1354
1496
  HeroHookFormProvider,
@@ -1380,13 +1522,16 @@ export {
1380
1522
  createRequiredCheckboxSchema,
1381
1523
  createRequiredSchema,
1382
1524
  createUrlSchema,
1525
+ createZodFormConfig,
1383
1526
  getFieldError,
1384
1527
  getFormErrors,
1385
1528
  hasFieldError,
1386
1529
  hasFormErrors,
1387
1530
  simulateFieldInput,
1388
1531
  simulateFormSubmission,
1532
+ useFormContext2 as useFormContext,
1389
1533
  useFormHelper,
1534
+ useHeroForm,
1390
1535
  useHeroHookFormDefaults,
1391
1536
  useZodForm,
1392
1537
  waitForFormState