@rachelallyson/hero-hook-form 2.3.0 → 2.4.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.
@@ -6,7 +6,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  });
7
7
 
8
8
  // src/components/Form.tsx
9
- import React17 from "react";
9
+ import React18 from "react";
10
10
  import { Button as Button3 } from "@heroui/react";
11
11
 
12
12
  // src/hooks/useFormHelper.ts
@@ -75,19 +75,104 @@ function useFormHelper({
75
75
  }
76
76
 
77
77
  // src/components/FormField.tsx
78
- import React16 from "react";
78
+ import React17 from "react";
79
79
  import { useWatch as useWatch3 } from "react-hook-form";
80
80
 
81
- // src/fields/CheckboxField.tsx
82
- import React2 from "react";
81
+ // src/fields/AutocompleteField.tsx
82
+ import React from "react";
83
83
  import { Controller } from "react-hook-form";
84
84
 
85
+ // src/ui/react.ts
86
+ import {
87
+ Autocomplete,
88
+ AutocompleteItem,
89
+ Button,
90
+ Checkbox,
91
+ DateInput,
92
+ DatePicker,
93
+ Input,
94
+ Radio,
95
+ RadioGroup,
96
+ Select,
97
+ SelectItem,
98
+ Slider,
99
+ Spinner,
100
+ Switch,
101
+ Textarea
102
+ } from "@heroui/react";
103
+
104
+ // src/fields/AutocompleteField.tsx
105
+ function AutocompleteField(props) {
106
+ const {
107
+ autocompleteProps,
108
+ children,
109
+ className,
110
+ control,
111
+ description,
112
+ isDisabled,
113
+ items,
114
+ label,
115
+ name,
116
+ placeholder,
117
+ rules
118
+ } = props;
119
+ return /* @__PURE__ */ React.createElement(
120
+ Controller,
121
+ {
122
+ control,
123
+ name,
124
+ render: ({ field: field2, fieldState }) => {
125
+ const selectedKey = field2.value;
126
+ return /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement(
127
+ Autocomplete,
128
+ {
129
+ ...autocompleteProps,
130
+ description,
131
+ errorMessage: fieldState.error?.message,
132
+ isDisabled,
133
+ isInvalid: Boolean(fieldState.error),
134
+ label,
135
+ placeholder,
136
+ selectedKey: selectedKey != null ? String(selectedKey) : void 0,
137
+ inputValue: selectedKey != null ? void 0 : field2.value ?? "",
138
+ onSelectionChange: (key) => {
139
+ const next = key ?? "";
140
+ field2.onChange(next);
141
+ },
142
+ onInputChange: (value) => {
143
+ if (autocompleteProps?.allowsCustomValue) {
144
+ field2.onChange(value);
145
+ }
146
+ },
147
+ defaultItems: items
148
+ },
149
+ children ? children : (item) => /* @__PURE__ */ React.createElement(
150
+ AutocompleteItem,
151
+ {
152
+ key: String(item.value),
153
+ textValue: String(item.value),
154
+ description: item.description,
155
+ isDisabled: item.disabled
156
+ },
157
+ item.label
158
+ )
159
+ ));
160
+ },
161
+ rules
162
+ }
163
+ );
164
+ }
165
+
166
+ // src/fields/CheckboxField.tsx
167
+ import React3 from "react";
168
+ import { Controller as Controller2 } from "react-hook-form";
169
+
85
170
  // src/providers/ConfigProvider.tsx
86
- import React, { createContext, useContext, useMemo } from "react";
171
+ import React2, { createContext, useContext, useMemo } from "react";
87
172
  var DefaultsContext = createContext(null);
88
173
  function HeroHookFormProvider(props) {
89
174
  const value = useMemo(() => props.defaults ?? {}, [props.defaults]);
90
- return /* @__PURE__ */ React.createElement(DefaultsContext.Provider, { value }, props.children);
175
+ return /* @__PURE__ */ React2.createElement(DefaultsContext.Provider, { value }, props.children);
91
176
  }
92
177
  function useHeroHookFormDefaults() {
93
178
  const cfg = useContext(DefaultsContext) ?? {};
@@ -168,23 +253,6 @@ function useHeroHookFormDefaults() {
168
253
  };
169
254
  }
170
255
 
171
- // src/ui/react.ts
172
- import {
173
- Button,
174
- Checkbox,
175
- DateInput,
176
- DatePicker,
177
- Input,
178
- Radio,
179
- RadioGroup,
180
- Select,
181
- SelectItem,
182
- Slider,
183
- Spinner,
184
- Switch,
185
- Textarea
186
- } from "@heroui/react";
187
-
188
256
  // src/fields/CheckboxField.tsx
189
257
  function CheckboxField(props) {
190
258
  const {
@@ -198,12 +266,12 @@ function CheckboxField(props) {
198
266
  rules
199
267
  } = props;
200
268
  const defaults = useHeroHookFormDefaults();
201
- return /* @__PURE__ */ React2.createElement(
202
- Controller,
269
+ return /* @__PURE__ */ React3.createElement(
270
+ Controller2,
203
271
  {
204
272
  control,
205
273
  name,
206
- render: ({ field: field2, fieldState }) => /* @__PURE__ */ React2.createElement("div", { className }, /* @__PURE__ */ React2.createElement(
274
+ render: ({ field: field2, fieldState }) => /* @__PURE__ */ React3.createElement("div", { className }, /* @__PURE__ */ React3.createElement(
207
275
  Checkbox,
208
276
  {
209
277
  ...defaults.checkbox,
@@ -215,14 +283,14 @@ function CheckboxField(props) {
215
283
  onValueChange: (val) => field2.onChange(val)
216
284
  },
217
285
  label
218
- ), description ? /* @__PURE__ */ React2.createElement("p", { className: "text-small text-default-400" }, description) : null, fieldState.error?.message ? /* @__PURE__ */ React2.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
286
+ ), description ? /* @__PURE__ */ React3.createElement("p", { className: "text-small text-default-400" }, description) : null, fieldState.error?.message ? /* @__PURE__ */ React3.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
219
287
  rules
220
288
  }
221
289
  );
222
290
  }
223
291
 
224
292
  // src/fields/ConditionalField.tsx
225
- import React3 from "react";
293
+ import React4 from "react";
226
294
  import { useWatch, useFormContext } from "react-hook-form";
227
295
  function ConditionalField({
228
296
  className,
@@ -236,7 +304,7 @@ function ConditionalField({
236
304
  if (!shouldShow) {
237
305
  return null;
238
306
  }
239
- return /* @__PURE__ */ React3.createElement("div", { className }, /* @__PURE__ */ React3.createElement(
307
+ return /* @__PURE__ */ React4.createElement("div", { className }, /* @__PURE__ */ React4.createElement(
240
308
  FormField,
241
309
  {
242
310
  config: field2,
@@ -252,29 +320,29 @@ function ConditionalField({
252
320
  }
253
321
 
254
322
  // src/fields/ContentField.tsx
255
- import React4 from "react";
323
+ import React5 from "react";
256
324
  function ContentField({
257
325
  config,
258
326
  form,
259
327
  submissionState
260
328
  }) {
261
329
  if (config.render) {
262
- return /* @__PURE__ */ React4.createElement("div", { className: config.className }, config.render({
330
+ return /* @__PURE__ */ React5.createElement("div", { className: config.className }, config.render({
263
331
  errors: form.formState.errors,
264
332
  form,
265
333
  isSubmitting: submissionState.isSubmitting
266
334
  }));
267
335
  }
268
- return /* @__PURE__ */ React4.createElement("div", { className: config.className }, config.title && /* @__PURE__ */ React4.createElement("h3", { className: "text-lg font-semibold text-foreground mb-2" }, config.title), config.description && /* @__PURE__ */ React4.createElement("p", { className: "text-sm text-muted-foreground" }, config.description));
336
+ return /* @__PURE__ */ React5.createElement("div", { className: config.className }, config.title && /* @__PURE__ */ React5.createElement("h3", { className: "text-lg font-semibold text-foreground mb-2" }, config.title), config.description && /* @__PURE__ */ React5.createElement("p", { className: "text-sm text-muted-foreground" }, config.description));
269
337
  }
270
338
 
271
339
  // src/fields/DateField.tsx
272
- import React5 from "react";
273
- import { Controller as Controller2 } from "react-hook-form";
340
+ import React6 from "react";
341
+ import { Controller as Controller3 } from "react-hook-form";
274
342
  function CoercedDateInput(props) {
275
343
  const { dateProps, description, disabled, errorMessage, field: field2, label } = props;
276
344
  const defaults = useHeroHookFormDefaults();
277
- return /* @__PURE__ */ React5.createElement(
345
+ return /* @__PURE__ */ React6.createElement(
278
346
  DateInput,
279
347
  {
280
348
  ...defaults.dateInput,
@@ -302,12 +370,12 @@ function DateField(props) {
302
370
  rules,
303
371
  transform
304
372
  } = props;
305
- return /* @__PURE__ */ React5.createElement(
306
- Controller2,
373
+ return /* @__PURE__ */ React6.createElement(
374
+ Controller3,
307
375
  {
308
376
  control,
309
377
  name,
310
- render: ({ field: field2, fieldState }) => /* @__PURE__ */ React5.createElement("div", { className }, /* @__PURE__ */ React5.createElement(
378
+ render: ({ field: field2, fieldState }) => /* @__PURE__ */ React6.createElement("div", { className }, /* @__PURE__ */ React6.createElement(
311
379
  CoercedDateInput,
312
380
  {
313
381
  dateProps,
@@ -327,7 +395,7 @@ function DateField(props) {
327
395
  }
328
396
 
329
397
  // src/fields/DynamicSectionField.tsx
330
- import React6 from "react";
398
+ import React7 from "react";
331
399
  import { useWatch as useWatch2, useFormContext as useFormContext2 } from "react-hook-form";
332
400
  function DynamicSectionField({
333
401
  className,
@@ -341,7 +409,7 @@ function DynamicSectionField({
341
409
  if (!shouldShow) {
342
410
  return null;
343
411
  }
344
- return /* @__PURE__ */ React6.createElement("div", { className }, (title || description) && /* @__PURE__ */ React6.createElement("div", { className: "mb-6" }, title && /* @__PURE__ */ React6.createElement("h3", { className: "text-lg font-semibold text-gray-900 mb-2" }, title), description && /* @__PURE__ */ React6.createElement("p", { className: "text-sm text-gray-600" }, description)), /* @__PURE__ */ React6.createElement("div", { className: "space-y-4" }, fields.map((fieldConfig, index) => /* @__PURE__ */ React6.createElement(
412
+ return /* @__PURE__ */ React7.createElement("div", { className }, (title || description) && /* @__PURE__ */ React7.createElement("div", { className: "mb-6" }, title && /* @__PURE__ */ React7.createElement("h3", { className: "text-lg font-semibold text-gray-900 mb-2" }, title), description && /* @__PURE__ */ React7.createElement("p", { className: "text-sm text-gray-600" }, description)), /* @__PURE__ */ React7.createElement("div", { className: "space-y-4" }, fields.map((fieldConfig, index) => /* @__PURE__ */ React7.createElement(
345
413
  FormField,
346
414
  {
347
415
  key: `${fieldConfig.name}-${index}`,
@@ -358,7 +426,7 @@ function DynamicSectionField({
358
426
  }
359
427
 
360
428
  // src/fields/FieldArrayField.tsx
361
- import React7 from "react";
429
+ import React8 from "react";
362
430
  import { useFieldArray, useFormContext as useFormContext3 } from "react-hook-form";
363
431
  import { Button as Button2 } from "@heroui/react";
364
432
  function FieldArrayField({
@@ -406,13 +474,13 @@ function FieldArrayField({
406
474
  remove(index);
407
475
  }
408
476
  };
409
- return /* @__PURE__ */ React7.createElement("div", { className }, /* @__PURE__ */ React7.createElement("div", { className: "space-y-4" }, fields.map((field2, index) => /* @__PURE__ */ React7.createElement(
477
+ return /* @__PURE__ */ React8.createElement("div", { className }, /* @__PURE__ */ React8.createElement("div", { className: "space-y-4" }, fields.map((field2, index) => /* @__PURE__ */ React8.createElement(
410
478
  "div",
411
479
  {
412
480
  key: field2.id,
413
481
  className: "border border-gray-200 rounded-lg p-4 space-y-4"
414
482
  },
415
- /* @__PURE__ */ React7.createElement("div", { className: "flex justify-between items-center" }, /* @__PURE__ */ React7.createElement("h4", { className: "text-sm font-medium text-gray-700" }, config.label, " #", index + 1), canRemove && /* @__PURE__ */ React7.createElement(
483
+ /* @__PURE__ */ React8.createElement("div", { className: "flex justify-between items-center" }, /* @__PURE__ */ React8.createElement("h4", { className: "text-sm font-medium text-gray-700" }, config.label, " #", index + 1), canRemove && /* @__PURE__ */ React8.createElement(
416
484
  Button2,
417
485
  {
418
486
  size: "sm",
@@ -424,7 +492,7 @@ function FieldArrayField({
424
492
  },
425
493
  removeButtonText
426
494
  )),
427
- /* @__PURE__ */ React7.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4" }, fieldConfigs.map((fieldConfig) => /* @__PURE__ */ React7.createElement(
495
+ /* @__PURE__ */ React8.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4" }, fieldConfigs.map((fieldConfig) => /* @__PURE__ */ React8.createElement(
428
496
  FormField,
429
497
  {
430
498
  key: `${fieldConfig.name}-${index}`,
@@ -441,7 +509,7 @@ function FieldArrayField({
441
509
  }
442
510
  }
443
511
  )))
444
- )), canAdd && /* @__PURE__ */ React7.createElement(
512
+ )), canAdd && /* @__PURE__ */ React8.createElement(
445
513
  Button2,
446
514
  {
447
515
  variant: "bordered",
@@ -450,7 +518,7 @@ function FieldArrayField({
450
518
  className: "w-full"
451
519
  },
452
520
  addButtonText
453
- ), fields.length === 0 && /* @__PURE__ */ React7.createElement("div", { className: "text-center py-8 text-gray-500" }, /* @__PURE__ */ React7.createElement("p", null, "No ", config.label?.toLowerCase(), " added yet."), /* @__PURE__ */ React7.createElement(
521
+ ), fields.length === 0 && /* @__PURE__ */ React8.createElement("div", { className: "text-center py-8 text-gray-500" }, /* @__PURE__ */ React8.createElement("p", null, "No ", config.label?.toLowerCase(), " added yet."), /* @__PURE__ */ React8.createElement(
454
522
  Button2,
455
523
  {
456
524
  variant: "bordered",
@@ -463,8 +531,8 @@ function FieldArrayField({
463
531
  }
464
532
 
465
533
  // src/fields/FileField.tsx
466
- import React8 from "react";
467
- import { Controller as Controller3 } from "react-hook-form";
534
+ import React9 from "react";
535
+ import { Controller as Controller4 } from "react-hook-form";
468
536
  function CoercedFileInput(props) {
469
537
  const {
470
538
  accept,
@@ -477,7 +545,7 @@ function CoercedFileInput(props) {
477
545
  multiple
478
546
  } = props;
479
547
  const defaults = useHeroHookFormDefaults();
480
- return /* @__PURE__ */ React8.createElement(
548
+ return /* @__PURE__ */ React9.createElement(
481
549
  Input,
482
550
  {
483
551
  ...defaults.input,
@@ -513,12 +581,12 @@ function FileField(props) {
513
581
  rules,
514
582
  transform
515
583
  } = props;
516
- return /* @__PURE__ */ React8.createElement(
517
- Controller3,
584
+ return /* @__PURE__ */ React9.createElement(
585
+ Controller4,
518
586
  {
519
587
  control,
520
588
  name,
521
- render: ({ field: field2, fieldState }) => /* @__PURE__ */ React8.createElement("div", { className }, /* @__PURE__ */ React8.createElement(
589
+ render: ({ field: field2, fieldState }) => /* @__PURE__ */ React9.createElement("div", { className }, /* @__PURE__ */ React9.createElement(
522
590
  CoercedFileInput,
523
591
  {
524
592
  accept,
@@ -540,8 +608,8 @@ function FileField(props) {
540
608
  }
541
609
 
542
610
  // src/fields/FontPickerField.tsx
543
- import React9 from "react";
544
- import { Controller as Controller4 } from "react-hook-form";
611
+ import React10 from "react";
612
+ import { Controller as Controller5 } from "react-hook-form";
545
613
  var FontPickerComponent = null;
546
614
  var fontPickerLoaded = false;
547
615
  var fontPickerLoading = false;
@@ -557,12 +625,12 @@ function FontPickerField(props) {
557
625
  name,
558
626
  rules
559
627
  } = props;
560
- const [fontPickerState, setFontPickerState] = React9.useState({
628
+ const [fontPickerState, setFontPickerState] = React10.useState({
561
629
  component: FontPickerComponent,
562
630
  error: null,
563
631
  loading: false
564
632
  });
565
- React9.useEffect(() => {
633
+ React10.useEffect(() => {
566
634
  if (fontPickerLoaded && FontPickerComponent) {
567
635
  setFontPickerState({
568
636
  component: FontPickerComponent,
@@ -620,17 +688,17 @@ function FontPickerField(props) {
620
688
  void loadFontPicker();
621
689
  }, []);
622
690
  if (fontPickerState.loading) {
623
- return /* @__PURE__ */ React9.createElement("div", { className }, /* @__PURE__ */ React9.createElement("div", { className: "space-y-2" }, label && /* @__PURE__ */ React9.createElement("label", { className: "block text-sm font-medium text-foreground" }, label), description && /* @__PURE__ */ React9.createElement("p", { className: "text-sm text-muted-foreground" }, description), /* @__PURE__ */ React9.createElement("div", { className: "p-4 border border-default-200 bg-default-50 rounded-medium" }, /* @__PURE__ */ React9.createElement("p", { className: "text-default-600 text-sm" }, "Loading font picker..."))));
691
+ return /* @__PURE__ */ React10.createElement("div", { className }, /* @__PURE__ */ React10.createElement("div", { className: "space-y-2" }, label && /* @__PURE__ */ React10.createElement("label", { className: "block text-sm font-medium text-foreground" }, label), description && /* @__PURE__ */ React10.createElement("p", { className: "text-sm text-muted-foreground" }, description), /* @__PURE__ */ React10.createElement("div", { className: "p-4 border border-default-200 bg-default-50 rounded-medium" }, /* @__PURE__ */ React10.createElement("p", { className: "text-default-600 text-sm" }, "Loading font picker..."))));
624
692
  }
625
693
  if (!fontPickerState.component) {
626
- return /* @__PURE__ */ React9.createElement("div", { className }, /* @__PURE__ */ React9.createElement("div", { className: "space-y-2" }, label && /* @__PURE__ */ React9.createElement("label", { className: "block text-sm font-medium text-foreground" }, label), description && /* @__PURE__ */ React9.createElement("p", { className: "text-sm text-muted-foreground" }, description), /* @__PURE__ */ React9.createElement("div", { className: "p-4 border border-warning-200 bg-warning-50 rounded-medium" }, /* @__PURE__ */ React9.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."))));
694
+ return /* @__PURE__ */ React10.createElement("div", { className }, /* @__PURE__ */ React10.createElement("div", { className: "space-y-2" }, label && /* @__PURE__ */ React10.createElement("label", { className: "block text-sm font-medium text-foreground" }, label), description && /* @__PURE__ */ React10.createElement("p", { className: "text-sm text-muted-foreground" }, description), /* @__PURE__ */ React10.createElement("div", { className: "p-4 border border-warning-200 bg-warning-50 rounded-medium" }, /* @__PURE__ */ React10.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."))));
627
695
  }
628
- return /* @__PURE__ */ React9.createElement(
629
- Controller4,
696
+ return /* @__PURE__ */ React10.createElement(
697
+ Controller5,
630
698
  {
631
699
  control,
632
700
  name,
633
- render: ({ field: field2, fieldState }) => /* @__PURE__ */ React9.createElement(
701
+ render: ({ field: field2, fieldState }) => /* @__PURE__ */ React10.createElement(
634
702
  fontPickerState.component,
635
703
  {
636
704
  label,
@@ -649,12 +717,12 @@ function FontPickerField(props) {
649
717
  }
650
718
 
651
719
  // src/fields/InputField.tsx
652
- import React10 from "react";
653
- import { Controller as Controller5 } from "react-hook-form";
720
+ import React11 from "react";
721
+ import { Controller as Controller6 } from "react-hook-form";
654
722
  function CoercedInput(props) {
655
723
  const { description, disabled, errorMessage, field: field2, inputProps, label } = props;
656
724
  const defaults = useHeroHookFormDefaults();
657
- return /* @__PURE__ */ React10.createElement(
725
+ return /* @__PURE__ */ React11.createElement(
658
726
  Input,
659
727
  {
660
728
  ...defaults.input,
@@ -670,7 +738,7 @@ function CoercedInput(props) {
670
738
  }
671
739
  );
672
740
  }
673
- var InputField = React10.memo(
741
+ var InputField = React11.memo(
674
742
  (props) => {
675
743
  const {
676
744
  className,
@@ -683,12 +751,12 @@ var InputField = React10.memo(
683
751
  rules,
684
752
  transform
685
753
  } = props;
686
- return /* @__PURE__ */ React10.createElement(
687
- Controller5,
754
+ return /* @__PURE__ */ React11.createElement(
755
+ Controller6,
688
756
  {
689
757
  control,
690
758
  name,
691
- render: ({ field: field2, fieldState }) => /* @__PURE__ */ React10.createElement("div", { className }, /* @__PURE__ */ React10.createElement(
759
+ render: ({ field: field2, fieldState }) => /* @__PURE__ */ React11.createElement("div", { className }, /* @__PURE__ */ React11.createElement(
692
760
  CoercedInput,
693
761
  {
694
762
  description,
@@ -718,8 +786,8 @@ var InputField = React10.memo(
718
786
  );
719
787
 
720
788
  // src/fields/RadioGroupField.tsx
721
- import React11 from "react";
722
- import { Controller as Controller6 } from "react-hook-form";
789
+ import React12 from "react";
790
+ import { Controller as Controller7 } from "react-hook-form";
723
791
  function RadioGroupField(props) {
724
792
  const {
725
793
  className,
@@ -733,12 +801,12 @@ function RadioGroupField(props) {
733
801
  rules
734
802
  } = props;
735
803
  const defaults = useHeroHookFormDefaults();
736
- return /* @__PURE__ */ React11.createElement(
737
- Controller6,
804
+ return /* @__PURE__ */ React12.createElement(
805
+ Controller7,
738
806
  {
739
807
  control,
740
808
  name,
741
- render: ({ field: field2, fieldState }) => /* @__PURE__ */ React11.createElement("div", { className }, /* @__PURE__ */ React11.createElement(
809
+ render: ({ field: field2, fieldState }) => /* @__PURE__ */ React12.createElement("div", { className }, /* @__PURE__ */ React12.createElement(
742
810
  RadioGroup,
743
811
  {
744
812
  ...defaults.radioGroup,
@@ -751,7 +819,7 @@ function RadioGroupField(props) {
751
819
  onBlur: field2.onBlur,
752
820
  onValueChange: (val) => field2.onChange(val)
753
821
  },
754
- options.map((opt) => /* @__PURE__ */ React11.createElement(
822
+ options.map((opt) => /* @__PURE__ */ React12.createElement(
755
823
  Radio,
756
824
  {
757
825
  key: String(opt.value),
@@ -760,15 +828,15 @@ function RadioGroupField(props) {
760
828
  },
761
829
  opt.label
762
830
  ))
763
- ), fieldState.error?.message ? /* @__PURE__ */ React11.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
831
+ ), fieldState.error?.message ? /* @__PURE__ */ React12.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
764
832
  rules
765
833
  }
766
834
  );
767
835
  }
768
836
 
769
837
  // src/fields/SelectField.tsx
770
- import React12 from "react";
771
- import { Controller as Controller7 } from "react-hook-form";
838
+ import React13 from "react";
839
+ import { Controller as Controller8 } from "react-hook-form";
772
840
  function SelectField(props) {
773
841
  const {
774
842
  className,
@@ -783,14 +851,14 @@ function SelectField(props) {
783
851
  selectProps
784
852
  } = props;
785
853
  const defaults = useHeroHookFormDefaults();
786
- return /* @__PURE__ */ React12.createElement(
787
- Controller7,
854
+ return /* @__PURE__ */ React13.createElement(
855
+ Controller8,
788
856
  {
789
857
  control,
790
858
  name,
791
859
  render: ({ field: field2, fieldState }) => {
792
860
  const selectedKey = field2.value;
793
- return /* @__PURE__ */ React12.createElement("div", { className }, /* @__PURE__ */ React12.createElement(
861
+ return /* @__PURE__ */ React13.createElement("div", { className }, /* @__PURE__ */ React13.createElement(
794
862
  Select,
795
863
  {
796
864
  ...defaults.select,
@@ -808,7 +876,7 @@ function SelectField(props) {
808
876
  field2.onChange(next);
809
877
  }
810
878
  },
811
- options.map((opt) => /* @__PURE__ */ React12.createElement(
879
+ options.map((opt) => /* @__PURE__ */ React13.createElement(
812
880
  SelectItem,
813
881
  {
814
882
  key: String(opt.value),
@@ -825,12 +893,12 @@ function SelectField(props) {
825
893
  }
826
894
 
827
895
  // src/fields/SliderField.tsx
828
- import React13 from "react";
829
- import { Controller as Controller8 } from "react-hook-form";
896
+ import React14 from "react";
897
+ import { Controller as Controller9 } from "react-hook-form";
830
898
  function CoercedSlider(props) {
831
899
  const { description, disabled, errorMessage, field: field2, label, sliderProps } = props;
832
900
  const defaults = useHeroHookFormDefaults();
833
- return /* @__PURE__ */ React13.createElement(
901
+ return /* @__PURE__ */ React14.createElement(
834
902
  Slider,
835
903
  {
836
904
  ...defaults.slider,
@@ -858,12 +926,12 @@ function SliderField(props) {
858
926
  sliderProps,
859
927
  transform
860
928
  } = props;
861
- return /* @__PURE__ */ React13.createElement(
862
- Controller8,
929
+ return /* @__PURE__ */ React14.createElement(
930
+ Controller9,
863
931
  {
864
932
  control,
865
933
  name,
866
- render: ({ field: field2, fieldState }) => /* @__PURE__ */ React13.createElement("div", { className }, /* @__PURE__ */ React13.createElement(
934
+ render: ({ field: field2, fieldState }) => /* @__PURE__ */ React14.createElement("div", { className }, /* @__PURE__ */ React14.createElement(
867
935
  CoercedSlider,
868
936
  {
869
937
  description,
@@ -883,8 +951,8 @@ function SliderField(props) {
883
951
  }
884
952
 
885
953
  // src/fields/SwitchField.tsx
886
- import React14 from "react";
887
- import { Controller as Controller9 } from "react-hook-form";
954
+ import React15 from "react";
955
+ import { Controller as Controller10 } from "react-hook-form";
888
956
  function SwitchField(props) {
889
957
  const {
890
958
  className,
@@ -897,12 +965,12 @@ function SwitchField(props) {
897
965
  switchProps
898
966
  } = props;
899
967
  const defaults = useHeroHookFormDefaults();
900
- return /* @__PURE__ */ React14.createElement(
901
- Controller9,
968
+ return /* @__PURE__ */ React15.createElement(
969
+ Controller10,
902
970
  {
903
971
  control,
904
972
  name,
905
- render: ({ field: field2, fieldState }) => /* @__PURE__ */ React14.createElement("div", { className }, /* @__PURE__ */ React14.createElement(
973
+ render: ({ field: field2, fieldState }) => /* @__PURE__ */ React15.createElement("div", { className }, /* @__PURE__ */ React15.createElement(
906
974
  Switch,
907
975
  {
908
976
  ...defaults.switch,
@@ -913,15 +981,15 @@ function SwitchField(props) {
913
981
  onValueChange: (val) => field2.onChange(val)
914
982
  },
915
983
  label
916
- ), description ? /* @__PURE__ */ React14.createElement("p", { className: "text-small text-default-400" }, description) : null, fieldState.error?.message ? /* @__PURE__ */ React14.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
984
+ ), description ? /* @__PURE__ */ React15.createElement("p", { className: "text-small text-default-400" }, description) : null, fieldState.error?.message ? /* @__PURE__ */ React15.createElement("p", { className: "text-tiny text-danger mt-1" }, fieldState.error.message) : null),
917
985
  rules
918
986
  }
919
987
  );
920
988
  }
921
989
 
922
990
  // src/fields/TextareaField.tsx
923
- import React15 from "react";
924
- import { Controller as Controller10 } from "react-hook-form";
991
+ import React16 from "react";
992
+ import { Controller as Controller11 } from "react-hook-form";
925
993
  function TextareaField(props) {
926
994
  const {
927
995
  className,
@@ -934,12 +1002,12 @@ function TextareaField(props) {
934
1002
  textareaProps
935
1003
  } = props;
936
1004
  const defaults = useHeroHookFormDefaults();
937
- return /* @__PURE__ */ React15.createElement(
938
- Controller10,
1005
+ return /* @__PURE__ */ React16.createElement(
1006
+ Controller11,
939
1007
  {
940
1008
  control,
941
1009
  name,
942
- render: ({ field: field2, fieldState }) => /* @__PURE__ */ React15.createElement("div", { className }, /* @__PURE__ */ React15.createElement(
1010
+ render: ({ field: field2, fieldState }) => /* @__PURE__ */ React16.createElement("div", { className }, /* @__PURE__ */ React16.createElement(
943
1011
  Textarea,
944
1012
  {
945
1013
  ...defaults.textarea,
@@ -960,7 +1028,7 @@ function TextareaField(props) {
960
1028
  }
961
1029
 
962
1030
  // src/components/FormField.tsx
963
- var FormField = React16.memo(
1031
+ var FormField = React17.memo(
964
1032
  ({
965
1033
  config,
966
1034
  form,
@@ -972,7 +1040,7 @@ var FormField = React16.memo(
972
1040
  const { control } = form;
973
1041
  const watchedValues = useWatch3({ control });
974
1042
  if (config.type === "content") {
975
- return /* @__PURE__ */ React16.createElement(
1043
+ return /* @__PURE__ */ React17.createElement(
976
1044
  ContentField,
977
1045
  {
978
1046
  config,
@@ -1002,7 +1070,7 @@ var FormField = React16.memo(
1002
1070
  };
1003
1071
  switch (config.type) {
1004
1072
  case "input":
1005
- return /* @__PURE__ */ React16.createElement(
1073
+ return /* @__PURE__ */ React17.createElement(
1006
1074
  InputField,
1007
1075
  {
1008
1076
  ...baseProps,
@@ -1012,7 +1080,7 @@ var FormField = React16.memo(
1012
1080
  }
1013
1081
  );
1014
1082
  case "textarea":
1015
- return /* @__PURE__ */ React16.createElement(
1083
+ return /* @__PURE__ */ React17.createElement(
1016
1084
  TextareaField,
1017
1085
  {
1018
1086
  ...baseProps,
@@ -1022,7 +1090,7 @@ var FormField = React16.memo(
1022
1090
  }
1023
1091
  );
1024
1092
  case "select":
1025
- return /* @__PURE__ */ React16.createElement(
1093
+ return /* @__PURE__ */ React17.createElement(
1026
1094
  SelectField,
1027
1095
  {
1028
1096
  ...baseProps,
@@ -1035,8 +1103,22 @@ var FormField = React16.memo(
1035
1103
  selectProps: config.selectProps
1036
1104
  }
1037
1105
  );
1106
+ case "autocomplete":
1107
+ return /* @__PURE__ */ React17.createElement(
1108
+ AutocompleteField,
1109
+ {
1110
+ ...baseProps,
1111
+ control,
1112
+ defaultValue: config.defaultValue,
1113
+ items: (config.options ?? []).map((opt) => ({
1114
+ label: opt.label,
1115
+ value: String(opt.value)
1116
+ })),
1117
+ autocompleteProps: config.autocompleteProps
1118
+ }
1119
+ );
1038
1120
  case "checkbox":
1039
- return /* @__PURE__ */ React16.createElement(
1121
+ return /* @__PURE__ */ React17.createElement(
1040
1122
  CheckboxField,
1041
1123
  {
1042
1124
  ...baseProps,
@@ -1046,7 +1128,7 @@ var FormField = React16.memo(
1046
1128
  }
1047
1129
  );
1048
1130
  case "radio":
1049
- return /* @__PURE__ */ React16.createElement(
1131
+ return /* @__PURE__ */ React17.createElement(
1050
1132
  RadioGroupField,
1051
1133
  {
1052
1134
  ...baseProps,
@@ -1060,7 +1142,7 @@ var FormField = React16.memo(
1060
1142
  }
1061
1143
  );
1062
1144
  case "switch":
1063
- return /* @__PURE__ */ React16.createElement(
1145
+ return /* @__PURE__ */ React17.createElement(
1064
1146
  SwitchField,
1065
1147
  {
1066
1148
  ...baseProps,
@@ -1070,7 +1152,7 @@ var FormField = React16.memo(
1070
1152
  }
1071
1153
  );
1072
1154
  case "slider":
1073
- return /* @__PURE__ */ React16.createElement(
1155
+ return /* @__PURE__ */ React17.createElement(
1074
1156
  SliderField,
1075
1157
  {
1076
1158
  ...baseProps,
@@ -1080,7 +1162,7 @@ var FormField = React16.memo(
1080
1162
  }
1081
1163
  );
1082
1164
  case "date":
1083
- return /* @__PURE__ */ React16.createElement(
1165
+ return /* @__PURE__ */ React17.createElement(
1084
1166
  DateField,
1085
1167
  {
1086
1168
  ...baseProps,
@@ -1090,7 +1172,7 @@ var FormField = React16.memo(
1090
1172
  }
1091
1173
  );
1092
1174
  case "file":
1093
- return /* @__PURE__ */ React16.createElement(
1175
+ return /* @__PURE__ */ React17.createElement(
1094
1176
  FileField,
1095
1177
  {
1096
1178
  ...baseProps,
@@ -1102,7 +1184,7 @@ var FormField = React16.memo(
1102
1184
  }
1103
1185
  );
1104
1186
  case "fontPicker":
1105
- return /* @__PURE__ */ React16.createElement(
1187
+ return /* @__PURE__ */ React17.createElement(
1106
1188
  FontPickerField,
1107
1189
  {
1108
1190
  ...baseProps,
@@ -1120,7 +1202,7 @@ var FormField = React16.memo(
1120
1202
  name: config.name
1121
1203
  });
1122
1204
  case "conditional":
1123
- return /* @__PURE__ */ React16.createElement(
1205
+ return /* @__PURE__ */ React17.createElement(
1124
1206
  ConditionalField,
1125
1207
  {
1126
1208
  config,
@@ -1129,7 +1211,7 @@ var FormField = React16.memo(
1129
1211
  }
1130
1212
  );
1131
1213
  case "fieldArray":
1132
- return /* @__PURE__ */ React16.createElement(
1214
+ return /* @__PURE__ */ React17.createElement(
1133
1215
  FieldArrayField,
1134
1216
  {
1135
1217
  config,
@@ -1137,7 +1219,7 @@ var FormField = React16.memo(
1137
1219
  }
1138
1220
  );
1139
1221
  case "dynamicSection":
1140
- return /* @__PURE__ */ React16.createElement(
1222
+ return /* @__PURE__ */ React17.createElement(
1141
1223
  DynamicSectionField,
1142
1224
  {
1143
1225
  config,
@@ -1189,12 +1271,12 @@ function ConfigurableForm({
1189
1271
  });
1190
1272
  const renderFields = () => {
1191
1273
  if (layout === "grid") {
1192
- return /* @__PURE__ */ React17.createElement(
1274
+ return /* @__PURE__ */ React18.createElement(
1193
1275
  "div",
1194
1276
  {
1195
1277
  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"}`
1196
1278
  },
1197
- fields.map((field2) => /* @__PURE__ */ React17.createElement(
1279
+ fields.map((field2) => /* @__PURE__ */ React18.createElement(
1198
1280
  FormField,
1199
1281
  {
1200
1282
  key: field2.name,
@@ -1206,7 +1288,7 @@ function ConfigurableForm({
1206
1288
  );
1207
1289
  }
1208
1290
  if (layout === "horizontal") {
1209
- return /* @__PURE__ */ React17.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, fields.map((field2) => /* @__PURE__ */ React17.createElement(
1291
+ return /* @__PURE__ */ React18.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, fields.map((field2) => /* @__PURE__ */ React18.createElement(
1210
1292
  FormField,
1211
1293
  {
1212
1294
  key: field2.name,
@@ -1216,7 +1298,7 @@ function ConfigurableForm({
1216
1298
  }
1217
1299
  )));
1218
1300
  }
1219
- return /* @__PURE__ */ React17.createElement("div", { className: `space-y-${spacing}` }, fields.map((field2) => /* @__PURE__ */ React17.createElement(
1301
+ return /* @__PURE__ */ React18.createElement("div", { className: `space-y-${spacing}` }, fields.map((field2) => /* @__PURE__ */ React18.createElement(
1220
1302
  FormField,
1221
1303
  {
1222
1304
  key: field2.name,
@@ -1230,23 +1312,23 @@ function ConfigurableForm({
1230
1312
  e.preventDefault();
1231
1313
  void handleSubmit();
1232
1314
  };
1233
- return /* @__PURE__ */ React17.createElement("form", { className, role: "form", onSubmit: handleFormSubmit }, title && /* @__PURE__ */ React17.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React17.createElement("h2", { className: "text-xl font-semibold text-foreground mb-2" }, title), subtitle && /* @__PURE__ */ React17.createElement("p", { className: "text-sm text-muted-foreground" }, subtitle)), isSubmitted && isSuccess && /* @__PURE__ */ React17.createElement(
1315
+ return /* @__PURE__ */ React18.createElement("form", { className, role: "form", onSubmit: handleFormSubmit }, title && /* @__PURE__ */ React18.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React18.createElement("h2", { className: "text-xl font-semibold text-foreground mb-2" }, title), subtitle && /* @__PURE__ */ React18.createElement("p", { className: "text-sm text-muted-foreground" }, subtitle)), isSubmitted && isSuccess && /* @__PURE__ */ React18.createElement(
1234
1316
  "div",
1235
1317
  {
1236
1318
  className: "mb-6 p-4 bg-success-50 border border-success-200 rounded-lg",
1237
1319
  "data-testid": "success-message"
1238
1320
  },
1239
- /* @__PURE__ */ React17.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
1240
- /* @__PURE__ */ React17.createElement("p", { className: "text-success-700 text-sm mt-1" }, "Your request has been processed successfully.")
1241
- ), error && /* @__PURE__ */ React17.createElement(
1321
+ /* @__PURE__ */ React18.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
1322
+ /* @__PURE__ */ React18.createElement("p", { className: "text-success-700 text-sm mt-1" }, "Your request has been processed successfully.")
1323
+ ), error && /* @__PURE__ */ React18.createElement(
1242
1324
  "div",
1243
1325
  {
1244
1326
  className: "mb-6 p-4 bg-danger-50 border border-danger-200 rounded-lg",
1245
1327
  "data-testid": "error-message"
1246
1328
  },
1247
- /* @__PURE__ */ React17.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
1248
- /* @__PURE__ */ React17.createElement("p", { className: "text-danger-700 text-sm mt-1" }, error)
1249
- ), renderFields(), /* @__PURE__ */ React17.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React17.createElement(
1329
+ /* @__PURE__ */ React18.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
1330
+ /* @__PURE__ */ React18.createElement("p", { className: "text-danger-700 text-sm mt-1" }, error)
1331
+ ), renderFields(), /* @__PURE__ */ React18.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React18.createElement(
1250
1332
  Button3,
1251
1333
  {
1252
1334
  color: "primary",
@@ -1256,7 +1338,7 @@ function ConfigurableForm({
1256
1338
  ...submitButtonProps
1257
1339
  },
1258
1340
  submitButtonText
1259
- ), showResetButton && /* @__PURE__ */ React17.createElement(
1341
+ ), showResetButton && /* @__PURE__ */ React18.createElement(
1260
1342
  Button3,
1261
1343
  {
1262
1344
  isDisabled: isSubmitting,
@@ -1269,7 +1351,7 @@ function ConfigurableForm({
1269
1351
  }
1270
1352
 
1271
1353
  // src/components/ServerActionForm.tsx
1272
- import React18 from "react";
1354
+ import React19 from "react";
1273
1355
  import { useActionState } from "react";
1274
1356
  function ServerActionForm({
1275
1357
  action,
@@ -1294,10 +1376,10 @@ function ServerActionForm({
1294
1376
  action,
1295
1377
  initialState ?? { errors: void 0, message: void 0, success: false }
1296
1378
  );
1297
- const formRef = React18.useRef(null);
1298
- const [clientErrors, setClientErrors] = React18.useState({});
1299
- const lastSubmittedFormData = React18.useRef(null);
1300
- React18.useEffect(() => {
1379
+ const formRef = React19.useRef(null);
1380
+ const [clientErrors, setClientErrors] = React19.useState({});
1381
+ const lastSubmittedFormData = React19.useRef(null);
1382
+ React19.useEffect(() => {
1301
1383
  if (state && (state.errors || state.message && !state.success)) {
1302
1384
  onError?.({
1303
1385
  errors: state.errors,
@@ -1305,7 +1387,7 @@ function ServerActionForm({
1305
1387
  });
1306
1388
  }
1307
1389
  }, [state, onError]);
1308
- React18.useEffect(() => {
1390
+ React19.useEffect(() => {
1309
1391
  if (state?.success && lastSubmittedFormData.current) {
1310
1392
  onSuccess?.(lastSubmittedFormData.current);
1311
1393
  }
@@ -1348,12 +1430,12 @@ function ServerActionForm({
1348
1430
  };
1349
1431
  const renderFields = () => {
1350
1432
  if (layout === "grid") {
1351
- return /* @__PURE__ */ React18.createElement(
1433
+ return /* @__PURE__ */ React19.createElement(
1352
1434
  "div",
1353
1435
  {
1354
1436
  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"}`
1355
1437
  },
1356
- fields.map((field2) => /* @__PURE__ */ React18.createElement(
1438
+ fields.map((field2) => /* @__PURE__ */ React19.createElement(
1357
1439
  ServerActionField,
1358
1440
  {
1359
1441
  key: field2.name,
@@ -1366,7 +1448,7 @@ function ServerActionForm({
1366
1448
  );
1367
1449
  }
1368
1450
  if (layout === "horizontal") {
1369
- return /* @__PURE__ */ React18.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, fields.map((field2) => /* @__PURE__ */ React18.createElement(
1451
+ return /* @__PURE__ */ React19.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, fields.map((field2) => /* @__PURE__ */ React19.createElement(
1370
1452
  ServerActionField,
1371
1453
  {
1372
1454
  key: field2.name,
@@ -1377,7 +1459,7 @@ function ServerActionForm({
1377
1459
  }
1378
1460
  )));
1379
1461
  }
1380
- return /* @__PURE__ */ React18.createElement("div", { className: `space-y-${spacing}` }, fields.map((field2) => /* @__PURE__ */ React18.createElement(
1462
+ return /* @__PURE__ */ React19.createElement("div", { className: `space-y-${spacing}` }, fields.map((field2) => /* @__PURE__ */ React19.createElement(
1381
1463
  ServerActionField,
1382
1464
  {
1383
1465
  key: field2.name,
@@ -1388,7 +1470,7 @@ function ServerActionForm({
1388
1470
  }
1389
1471
  )));
1390
1472
  };
1391
- return /* @__PURE__ */ React18.createElement(
1473
+ return /* @__PURE__ */ React19.createElement(
1392
1474
  "form",
1393
1475
  {
1394
1476
  ref: formRef,
@@ -1396,27 +1478,27 @@ function ServerActionForm({
1396
1478
  role: "form",
1397
1479
  onSubmit: handleSubmit
1398
1480
  },
1399
- title && /* @__PURE__ */ React18.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React18.createElement("h2", { className: "text-xl font-semibold text-foreground mb-2" }, title), subtitle && /* @__PURE__ */ React18.createElement("p", { className: "text-sm text-muted-foreground" }, subtitle)),
1400
- state?.success && !pending && /* @__PURE__ */ React18.createElement(
1481
+ title && /* @__PURE__ */ React19.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React19.createElement("h2", { className: "text-xl font-semibold text-foreground mb-2" }, title), subtitle && /* @__PURE__ */ React19.createElement("p", { className: "text-sm text-muted-foreground" }, subtitle)),
1482
+ state?.success && !pending && /* @__PURE__ */ React19.createElement(
1401
1483
  "div",
1402
1484
  {
1403
1485
  className: "mb-6 p-4 bg-success-50 border border-success-200 rounded-lg",
1404
1486
  "data-testid": "success-message"
1405
1487
  },
1406
- /* @__PURE__ */ React18.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
1407
- state.message && /* @__PURE__ */ React18.createElement("p", { className: "text-success-700 text-sm mt-1" }, state.message)
1488
+ /* @__PURE__ */ React19.createElement("p", { className: "text-success-800 font-medium" }, "Success!"),
1489
+ state.message && /* @__PURE__ */ React19.createElement("p", { className: "text-success-700 text-sm mt-1" }, state.message)
1408
1490
  ),
1409
- state?.message && !state.success && /* @__PURE__ */ React18.createElement(
1491
+ state?.message && !state.success && /* @__PURE__ */ React19.createElement(
1410
1492
  "div",
1411
1493
  {
1412
1494
  className: "mb-6 p-4 bg-danger-50 border border-danger-200 rounded-lg",
1413
1495
  "data-testid": "error-message"
1414
1496
  },
1415
- /* @__PURE__ */ React18.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
1416
- /* @__PURE__ */ React18.createElement("p", { className: "text-danger-700 text-sm mt-1" }, state.message)
1497
+ /* @__PURE__ */ React19.createElement("p", { className: "text-danger-800 font-medium" }, "Error"),
1498
+ /* @__PURE__ */ React19.createElement("p", { className: "text-danger-700 text-sm mt-1" }, state.message)
1417
1499
  ),
1418
1500
  renderFields(),
1419
- /* @__PURE__ */ React18.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React18.createElement(
1501
+ /* @__PURE__ */ React19.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React19.createElement(
1420
1502
  Button,
1421
1503
  {
1422
1504
  color: "primary",
@@ -1426,7 +1508,7 @@ function ServerActionForm({
1426
1508
  ...submitButtonProps
1427
1509
  },
1428
1510
  submitButtonText
1429
- ), showResetButton && /* @__PURE__ */ React18.createElement(
1511
+ ), showResetButton && /* @__PURE__ */ React19.createElement(
1430
1512
  Button,
1431
1513
  {
1432
1514
  isDisabled: pending,
@@ -1447,13 +1529,13 @@ function ServerActionField({
1447
1529
  if (field2.type === "content") {
1448
1530
  const contentField2 = field2;
1449
1531
  if (contentField2.render) {
1450
- return /* @__PURE__ */ React18.createElement("div", { className: contentField2.className }, contentField2.render({
1532
+ return /* @__PURE__ */ React19.createElement("div", { className: contentField2.className }, contentField2.render({
1451
1533
  errors: {},
1452
1534
  form: null,
1453
1535
  isSubmitting: false
1454
1536
  }));
1455
1537
  }
1456
- return /* @__PURE__ */ React18.createElement("div", { className: contentField2.className }, contentField2.title && /* @__PURE__ */ React18.createElement("h3", { className: "text-lg font-semibold text-foreground mb-2" }, contentField2.title), contentField2.description && /* @__PURE__ */ React18.createElement("p", { className: "text-sm text-muted-foreground" }, contentField2.description));
1538
+ return /* @__PURE__ */ React19.createElement("div", { className: contentField2.className }, contentField2.title && /* @__PURE__ */ React19.createElement("h3", { className: "text-lg font-semibold text-foreground mb-2" }, contentField2.title), contentField2.description && /* @__PURE__ */ React19.createElement("p", { className: "text-sm text-muted-foreground" }, contentField2.description));
1457
1539
  }
1458
1540
  const fieldName = field2.name;
1459
1541
  const fieldErrors = errors?.[fieldName];
@@ -1481,9 +1563,9 @@ function ServerActionField({
1481
1563
  }
1482
1564
  return false;
1483
1565
  };
1484
- const [value, setValue] = React18.useState(getDefaultValue);
1485
- const [checked, setChecked] = React18.useState(getDefaultChecked);
1486
- React18.useEffect(() => {
1566
+ const [value, setValue] = React19.useState(getDefaultValue);
1567
+ const [checked, setChecked] = React19.useState(getDefaultChecked);
1568
+ React19.useEffect(() => {
1487
1569
  const newDefaultValue = defaultValues?.[fieldName];
1488
1570
  if (newDefaultValue !== void 0 && newDefaultValue !== null) {
1489
1571
  if (field2.type === "checkbox") {
@@ -1497,7 +1579,7 @@ function ServerActionField({
1497
1579
  }
1498
1580
  }
1499
1581
  }, [defaultValues, fieldName, field2.type]);
1500
- React18.useEffect(() => {
1582
+ React19.useEffect(() => {
1501
1583
  const hiddenInput = document.querySelector(
1502
1584
  `input[type="hidden"][name="${fieldName}"]`
1503
1585
  );
@@ -1512,7 +1594,7 @@ function ServerActionField({
1512
1594
  switch (field2.type) {
1513
1595
  case "input": {
1514
1596
  const inputType = field2.inputProps?.type || "text";
1515
- return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("input", { type: "hidden", name: fieldName, value }), /* @__PURE__ */ React18.createElement(
1597
+ return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement("input", { type: "hidden", name: fieldName, value }), /* @__PURE__ */ React19.createElement(
1516
1598
  Input,
1517
1599
  {
1518
1600
  ...field2.inputProps,
@@ -1529,7 +1611,7 @@ function ServerActionField({
1529
1611
  ));
1530
1612
  }
1531
1613
  case "textarea": {
1532
- return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("input", { type: "hidden", name: fieldName, value }), /* @__PURE__ */ React18.createElement(
1614
+ return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement("input", { type: "hidden", name: fieldName, value }), /* @__PURE__ */ React19.createElement(
1533
1615
  Textarea,
1534
1616
  {
1535
1617
  ...field2.textareaProps,
@@ -1545,7 +1627,7 @@ function ServerActionField({
1545
1627
  ));
1546
1628
  }
1547
1629
  case "checkbox": {
1548
- return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("input", { type: "hidden", name: fieldName, value: checked ? "on" : "" }), /* @__PURE__ */ React18.createElement(
1630
+ return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement("input", { type: "hidden", name: fieldName, value: checked ? "on" : "" }), /* @__PURE__ */ React19.createElement(
1549
1631
  Checkbox,
1550
1632
  {
1551
1633
  ...field2.checkboxProps,
@@ -1561,7 +1643,7 @@ function ServerActionField({
1561
1643
  }
1562
1644
  case "select": {
1563
1645
  const options = field2.options || [];
1564
- return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("input", { type: "hidden", name: fieldName, value }), /* @__PURE__ */ React18.createElement(
1646
+ return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement("input", { type: "hidden", name: fieldName, value }), /* @__PURE__ */ React19.createElement(
1565
1647
  Select,
1566
1648
  {
1567
1649
  ...field2.selectProps,
@@ -1578,12 +1660,12 @@ function ServerActionField({
1578
1660
  }
1579
1661
  },
1580
1662
  options.map(
1581
- (option) => /* @__PURE__ */ React18.createElement(SelectItem, { key: String(option.value) }, option.label)
1663
+ (option) => /* @__PURE__ */ React19.createElement(SelectItem, { key: String(option.value) }, option.label)
1582
1664
  )
1583
1665
  ));
1584
1666
  }
1585
1667
  default:
1586
- return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("input", { type: "hidden", name: fieldName, value }), /* @__PURE__ */ React18.createElement(
1668
+ return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement("input", { type: "hidden", name: fieldName, value }), /* @__PURE__ */ React19.createElement(
1587
1669
  Input,
1588
1670
  {
1589
1671
  "data-field-name": fieldName,
@@ -1613,10 +1695,10 @@ function useHeroForm() {
1613
1695
  }
1614
1696
 
1615
1697
  // src/providers/FormProvider.tsx
1616
- import React19 from "react";
1698
+ import React20 from "react";
1617
1699
  import { FormProvider as RHFProvider } from "react-hook-form";
1618
1700
  function FormProvider(props) {
1619
- return /* @__PURE__ */ React19.createElement(RHFProvider, { ...props.methods }, /* @__PURE__ */ React19.createElement(
1701
+ return /* @__PURE__ */ React20.createElement(RHFProvider, { ...props.methods }, /* @__PURE__ */ React20.createElement(
1620
1702
  "form",
1621
1703
  {
1622
1704
  className: props.className,
@@ -1629,7 +1711,7 @@ function FormProvider(props) {
1629
1711
  }
1630
1712
 
1631
1713
  // src/submit/SubmitButton.tsx
1632
- import React20 from "react";
1714
+ import React21 from "react";
1633
1715
  function SubmitButton(props) {
1634
1716
  const ctx = useFormContext5();
1635
1717
  const loading = props.isLoading ?? ctx.formState.isSubmitting;
@@ -1639,10 +1721,10 @@ function SubmitButton(props) {
1639
1721
  const defaults = useHeroHookFormDefaults();
1640
1722
  const getButtonContent = () => {
1641
1723
  if (enhancedState?.isSuccess) {
1642
- return /* @__PURE__ */ React20.createElement("span", { className: "inline-flex items-center gap-2" }, "\u2705", props.successText || "Success!");
1724
+ return /* @__PURE__ */ React21.createElement("span", { className: "inline-flex items-center gap-2" }, "\u2705", props.successText || "Success!");
1643
1725
  }
1644
1726
  if (loading) {
1645
- return /* @__PURE__ */ React20.createElement("span", { className: "inline-flex items-center gap-2" }, "\u23F3", props.loadingText || "Submitting...");
1727
+ return /* @__PURE__ */ React21.createElement("span", { className: "inline-flex items-center gap-2" }, "\u23F3", props.loadingText || "Submitting...");
1646
1728
  }
1647
1729
  return props.children;
1648
1730
  };
@@ -1655,7 +1737,7 @@ function SubmitButton(props) {
1655
1737
  }
1656
1738
  return props.buttonProps?.color || defaults.submitButton.color;
1657
1739
  };
1658
- return /* @__PURE__ */ React20.createElement(
1740
+ return /* @__PURE__ */ React21.createElement(
1659
1741
  Button,
1660
1742
  {
1661
1743
  type: "submit",
@@ -1896,7 +1978,7 @@ var commonValidations = {
1896
1978
  import { useFormContext as useFormContext5 } from "react-hook-form";
1897
1979
 
1898
1980
  // src/components/ZodForm.tsx
1899
- import React22 from "react";
1981
+ import React23 from "react";
1900
1982
  import { Button as Button5 } from "@heroui/react";
1901
1983
  import {
1902
1984
  FormProvider as FormProvider2
@@ -2019,7 +2101,7 @@ function useEnhancedFormState(form, options = {}) {
2019
2101
  }
2020
2102
 
2021
2103
  // src/components/FormStatus.tsx
2022
- import React21 from "react";
2104
+ import React22 from "react";
2023
2105
  import { Button as Button4 } from "@heroui/react";
2024
2106
  function FormStatus({
2025
2107
  className = "",
@@ -2032,25 +2114,25 @@ function FormStatus({
2032
2114
  return null;
2033
2115
  }
2034
2116
  if (isSubmitting) {
2035
- return /* @__PURE__ */ React21.createElement(
2117
+ return /* @__PURE__ */ React22.createElement(
2036
2118
  "div",
2037
2119
  {
2038
2120
  className: `flex items-center gap-3 p-4 bg-blue-50 border border-blue-200 rounded-lg ${className}`
2039
2121
  },
2040
- /* @__PURE__ */ React21.createElement("span", { className: "text-blue-600" }, "\u23F3"),
2041
- /* @__PURE__ */ React21.createElement("div", null, /* @__PURE__ */ React21.createElement("p", { className: "text-sm font-medium text-blue-900" }, "Submitting form..."), showDetails && /* @__PURE__ */ React21.createElement("p", { className: "text-xs text-blue-700" }, "Please wait while we process your request."))
2122
+ /* @__PURE__ */ React22.createElement("span", { className: "text-blue-600" }, "\u23F3"),
2123
+ /* @__PURE__ */ React22.createElement("div", null, /* @__PURE__ */ React22.createElement("p", { className: "text-sm font-medium text-blue-900" }, "Submitting form..."), showDetails && /* @__PURE__ */ React22.createElement("p", { className: "text-xs text-blue-700" }, "Please wait while we process your request."))
2042
2124
  );
2043
2125
  }
2044
2126
  if (isSuccess) {
2045
- return /* @__PURE__ */ React21.createElement(
2127
+ return /* @__PURE__ */ React22.createElement(
2046
2128
  "div",
2047
2129
  {
2048
2130
  className: `flex items-center gap-3 p-4 bg-green-50 border border-green-200 rounded-lg ${className}`,
2049
2131
  "data-testid": "success-message"
2050
2132
  },
2051
- /* @__PURE__ */ React21.createElement("span", { className: "text-green-600" }, "\u2705"),
2052
- /* @__PURE__ */ React21.createElement("div", { className: "flex-1" }, /* @__PURE__ */ React21.createElement("p", { className: "text-sm font-medium text-green-900" }, "Form submitted successfully!"), showDetails && submittedData && /* @__PURE__ */ React21.createElement("p", { className: "text-xs text-green-700" }, "Your data has been saved. Thank you for your submission.")),
2053
- onDismiss && /* @__PURE__ */ React21.createElement(
2133
+ /* @__PURE__ */ React22.createElement("span", { className: "text-green-600" }, "\u2705"),
2134
+ /* @__PURE__ */ React22.createElement("div", { className: "flex-1" }, /* @__PURE__ */ React22.createElement("p", { className: "text-sm font-medium text-green-900" }, "Form submitted successfully!"), showDetails && submittedData && /* @__PURE__ */ React22.createElement("p", { className: "text-xs text-green-700" }, "Your data has been saved. Thank you for your submission.")),
2135
+ onDismiss && /* @__PURE__ */ React22.createElement(
2054
2136
  Button4,
2055
2137
  {
2056
2138
  size: "sm",
@@ -2064,15 +2146,15 @@ function FormStatus({
2064
2146
  );
2065
2147
  }
2066
2148
  if (isError && error) {
2067
- return /* @__PURE__ */ React21.createElement(
2149
+ return /* @__PURE__ */ React22.createElement(
2068
2150
  "div",
2069
2151
  {
2070
2152
  className: `flex items-center gap-3 p-4 bg-red-50 border border-red-200 rounded-lg ${className}`,
2071
2153
  "data-testid": "error-message"
2072
2154
  },
2073
- /* @__PURE__ */ React21.createElement("span", { className: "text-red-600" }, "\u26A0\uFE0F"),
2074
- /* @__PURE__ */ React21.createElement("div", { className: "flex-1" }, /* @__PURE__ */ React21.createElement("p", { className: "text-sm font-medium text-red-900" }, "Error submitting form"), /* @__PURE__ */ React21.createElement("p", { className: "text-xs text-red-700" }, error)),
2075
- onDismiss && /* @__PURE__ */ React21.createElement(
2155
+ /* @__PURE__ */ React22.createElement("span", { className: "text-red-600" }, "\u26A0\uFE0F"),
2156
+ /* @__PURE__ */ React22.createElement("div", { className: "flex-1" }, /* @__PURE__ */ React22.createElement("p", { className: "text-sm font-medium text-red-900" }, "Error submitting form"), /* @__PURE__ */ React22.createElement("p", { className: "text-xs text-red-700" }, error)),
2157
+ onDismiss && /* @__PURE__ */ React22.createElement(
2076
2158
  Button4,
2077
2159
  {
2078
2160
  size: "sm",
@@ -2093,8 +2175,8 @@ function FormToast({
2093
2175
  position = "top-right",
2094
2176
  state
2095
2177
  }) {
2096
- const [isVisible, setIsVisible] = React21.useState(false);
2097
- React21.useEffect(() => {
2178
+ const [isVisible, setIsVisible] = React22.useState(false);
2179
+ React22.useEffect(() => {
2098
2180
  if (state.isSuccess || state.isError) {
2099
2181
  setIsVisible(true);
2100
2182
  if (duration > 0) {
@@ -2115,7 +2197,7 @@ function FormToast({
2115
2197
  "top-left": "top-4 left-4",
2116
2198
  "top-right": "top-4 right-4"
2117
2199
  };
2118
- return /* @__PURE__ */ React21.createElement("div", { className: `fixed z-50 ${positionClasses[position]}` }, /* @__PURE__ */ React21.createElement(FormStatus, { state, onDismiss }));
2200
+ return /* @__PURE__ */ React22.createElement("div", { className: `fixed z-50 ${positionClasses[position]}` }, /* @__PURE__ */ React22.createElement(FormStatus, { state, onDismiss }));
2119
2201
  }
2120
2202
 
2121
2203
  // src/components/ZodForm.tsx
@@ -2165,12 +2247,12 @@ function ZodForm({
2165
2247
  };
2166
2248
  const renderFields = () => {
2167
2249
  if (layout === "grid") {
2168
- return /* @__PURE__ */ React22.createElement(
2250
+ return /* @__PURE__ */ React23.createElement(
2169
2251
  "div",
2170
2252
  {
2171
2253
  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"}`
2172
2254
  },
2173
- config.fields.map((field2) => /* @__PURE__ */ React22.createElement(
2255
+ config.fields.map((field2) => /* @__PURE__ */ React23.createElement(
2174
2256
  FormField,
2175
2257
  {
2176
2258
  key: field2.name,
@@ -2187,7 +2269,7 @@ function ZodForm({
2187
2269
  );
2188
2270
  }
2189
2271
  if (layout === "horizontal") {
2190
- return /* @__PURE__ */ React22.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, config.fields.map((field2) => /* @__PURE__ */ React22.createElement(
2272
+ return /* @__PURE__ */ React23.createElement("div", { className: `grid gap-${spacing} grid-cols-1 md:grid-cols-2` }, config.fields.map((field2) => /* @__PURE__ */ React23.createElement(
2191
2273
  FormField,
2192
2274
  {
2193
2275
  key: field2.name,
@@ -2202,7 +2284,7 @@ function ZodForm({
2202
2284
  }
2203
2285
  )));
2204
2286
  }
2205
- return /* @__PURE__ */ React22.createElement("div", { className: `space-y-${spacing}` }, config.fields.map((field2) => /* @__PURE__ */ React22.createElement(
2287
+ return /* @__PURE__ */ React23.createElement("div", { className: `space-y-${spacing}` }, config.fields.map((field2) => /* @__PURE__ */ React23.createElement(
2206
2288
  FormField,
2207
2289
  {
2208
2290
  key: field2.name,
@@ -2221,19 +2303,19 @@ function ZodForm({
2221
2303
  e.preventDefault();
2222
2304
  void handleSubmit();
2223
2305
  };
2224
- React22.useEffect(() => {
2306
+ React23.useEffect(() => {
2225
2307
  if (config.onError && Object.keys(form.formState.errors).length > 0) {
2226
2308
  config.onError(form.formState.errors);
2227
2309
  }
2228
2310
  }, [form.formState.errors, config.onError]);
2229
- return /* @__PURE__ */ React22.createElement(FormProvider2, { ...form }, /* @__PURE__ */ React22.createElement("form", { className, role: "form", onSubmit: handleFormSubmit }, title && /* @__PURE__ */ React22.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React22.createElement("h2", { className: "text-xl font-semibold text-foreground mb-2" }, title), subtitle && /* @__PURE__ */ React22.createElement("p", { className: "text-sm text-muted-foreground" }, subtitle)), /* @__PURE__ */ React22.createElement(
2311
+ return /* @__PURE__ */ React23.createElement(FormProvider2, { ...form }, /* @__PURE__ */ React23.createElement("form", { className, role: "form", onSubmit: handleFormSubmit }, title && /* @__PURE__ */ React23.createElement("div", { className: "mb-6" }, /* @__PURE__ */ React23.createElement("h2", { className: "text-xl font-semibold text-foreground mb-2" }, title), subtitle && /* @__PURE__ */ React23.createElement("p", { className: "text-sm text-muted-foreground" }, subtitle)), /* @__PURE__ */ React23.createElement(
2230
2312
  FormStatus,
2231
2313
  {
2232
2314
  state: enhancedState,
2233
2315
  onDismiss: () => enhancedState.reset(),
2234
2316
  showDetails: true
2235
2317
  }
2236
- ), renderFields(), /* @__PURE__ */ React22.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React22.createElement(
2318
+ ), renderFields(), /* @__PURE__ */ React23.createElement("div", { className: "mt-6 flex gap-3 justify-end" }, /* @__PURE__ */ React23.createElement(
2237
2319
  Button5,
2238
2320
  {
2239
2321
  color: "primary",
@@ -2243,7 +2325,7 @@ function ZodForm({
2243
2325
  ...submitButtonProps
2244
2326
  },
2245
2327
  enhancedState.isSuccess ? "Success!" : submitButtonText
2246
- ), showResetButton && /* @__PURE__ */ React22.createElement(
2328
+ ), showResetButton && /* @__PURE__ */ React23.createElement(
2247
2329
  Button5,
2248
2330
  {
2249
2331
  isDisabled: enhancedState.isSubmitting,
@@ -2324,8 +2406,9 @@ var BasicFormBuilder = class {
2324
2406
  /**
2325
2407
  * Add a switch field
2326
2408
  */
2327
- switch(name, label) {
2409
+ switch(name, label, description) {
2328
2410
  this.fields.push({
2411
+ description,
2329
2412
  label,
2330
2413
  name,
2331
2414
  type: "switch"
@@ -2343,6 +2426,16 @@ function createBasicFormBuilder() {
2343
2426
  return new BasicFormBuilder();
2344
2427
  }
2345
2428
  var FormFieldHelpers = {
2429
+ /**
2430
+ * Create an autocomplete field
2431
+ */
2432
+ autocomplete: (name, label, items, placeholder) => ({
2433
+ autocompleteProps: placeholder ? { placeholder } : void 0,
2434
+ label,
2435
+ name,
2436
+ options: items,
2437
+ type: "autocomplete"
2438
+ }),
2346
2439
  /**
2347
2440
  * Create a checkbox field
2348
2441
  */
@@ -2351,6 +2444,24 @@ var FormFieldHelpers = {
2351
2444
  name,
2352
2445
  type: "checkbox"
2353
2446
  }),
2447
+ /**
2448
+ * Create a conditional field that shows/hides based on form data
2449
+ *
2450
+ * @example
2451
+ * ```tsx
2452
+ * FormFieldHelpers.conditional(
2453
+ * "phone",
2454
+ * (values) => values.hasPhone === true,
2455
+ * FormFieldHelpers.input("phone", "Phone Number", "tel")
2456
+ * )
2457
+ * ```
2458
+ */
2459
+ conditional: (name, condition, field2) => ({
2460
+ condition,
2461
+ field: field2,
2462
+ name,
2463
+ type: "conditional"
2464
+ }),
2354
2465
  /**
2355
2466
  * Create a content field for headers, questions, or custom content between fields
2356
2467
  *
@@ -2405,7 +2516,8 @@ var FormFieldHelpers = {
2405
2516
  /**
2406
2517
  * Create a switch field
2407
2518
  */
2408
- switch: (name, label) => ({
2519
+ switch: (name, label, description) => ({
2520
+ description,
2409
2521
  label,
2410
2522
  name,
2411
2523
  type: "switch"
@@ -2523,13 +2635,14 @@ function checkboxField(name, label, props) {
2523
2635
  }
2524
2636
  function switchField(name, label, props) {
2525
2637
  return {
2638
+ description: props?.description,
2639
+ isDisabled: props?.isDisabled,
2526
2640
  label,
2527
2641
  name,
2528
2642
  type: "switch",
2529
- ...props && {
2643
+ ...props?.className && {
2530
2644
  switchProps: {
2531
- className: props.className,
2532
- disabled: props.isDisabled
2645
+ className: props.className
2533
2646
  }
2534
2647
  }
2535
2648
  };
@@ -3540,6 +3653,7 @@ var validationUtils = {
3540
3653
  };
3541
3654
  export {
3542
3655
  AdvancedFieldBuilder,
3656
+ AutocompleteField,
3543
3657
  BasicFormBuilder,
3544
3658
  CheckboxField,
3545
3659
  CommonFields,