@saas-ui/forms 2.1.3 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @saas-ui/forms
2
2
 
3
+ ## 2.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 1c64bfaf: Fixed issue where Zod or Yup schemas would not validate in FormDialog
8
+ - Updated dependencies [4a3c9dc7]
9
+ - @saas-ui/core@2.1.3
10
+
11
+ ## 2.2.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 87fcdc2c: FormLayout no longer renders each child in a wrapper div
16
+
17
+ ### Patch Changes
18
+
19
+ - 9ad407a7: Zod schema enum types now render a Select by default
20
+ - 654ad186: Fixed issue where Field would not infer correct onChange handler
21
+ - 87fcdc2c: Fixed issue where not all StepForm data would be passed to onSubmit
22
+ - 9ad407a7: ZodForm now infers defaultValues from the schema
23
+ - be52e785: Fixed issue where placeholder would not be passed to the NumberInputField
24
+
3
25
  ## 2.1.3
4
26
 
5
27
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react_hook_form from 'react-hook-form';
5
5
  import { FieldValues, FieldPath, UseFieldArrayReturn, RegisterOptions, UseFormReturn as UseFormReturn$1, UseFormProps, WatchObserver, SubmitHandler, SubmitErrorHandler, ResolverOptions, ResolverResult, FormProviderProps as FormProviderProps$1 } from 'react-hook-form';
6
6
  export { BatchFieldArrayUpdate, ChangeHandler, Control, Controller, ControllerFieldState, ControllerProps, ControllerRenderProps, CriteriaMode, CustomElement, DeepMap, DeepPartial, DeepPartialSkipArrayKey, DefaultValues, DelayCallback, EmptyObject, ErrorOption, EventType, FieldArray, FieldArrayMethodProps, FieldArrayWithId, Field as FieldDef, FieldElement, FieldError, FieldErrors, FieldName, FieldNamesMarkedBoolean, FieldRefs, FieldValue, FieldValues, FormProviderProps, FormState, FormStateProxy, FormStateSubjectRef, GetIsDirty, InternalFieldErrors, InternalFieldName, InternalNameSet, IsAny, IsFlatObject, KeepStateOptions, LiteralUnion, Message, Mode, MultipleFieldErrors, Names, NativeFieldValue, NestedValue, NonUndefined, Noop, Primitive, ReadFormState, Ref, RefCallBack, RegisterOptions, Resolver, ResolverError, ResolverOptions, ResolverResult, ResolverSuccess, SetFieldValue, SetValueConfig, Subjects, SubmitErrorHandler, SubmitHandler, TriggerConfig, UnpackNestedValue, UseControllerProps, UseControllerReturn, UseFieldArrayProps, UseFieldArrayReturn, UseFormClearErrors, UseFormGetValues, UseFormHandleSubmit, UseFormProps, UseFormRegister, UseFormRegisterReturn, UseFormReset, UseFormResetField, UseFormReturn, UseFormSetError, UseFormSetFocus, UseFormSetValue, UseFormStateProps, UseFormStateReturn, UseFormTrigger, UseFormUnregister, UseFormWatch, UseWatchProps, Validate, ValidateResult, ValidationMode, ValidationRule, ValidationValue, ValidationValueMessage, WatchInternal, WatchObserver, appendErrors, useController, useFieldArray, useForm, useFormState, useWatch } from 'react-hook-form';
7
- import { NumberInputProps as NumberInputProps$1, InputProps, RadioProps, RadioGroupProps, SystemProps, StackDirection, MenuProps, ThemingProps, ButtonProps, MenuListProps, MenuItemOptionProps, SelectProps as SelectProps$1, TextareaProps, SwitchProps, CheckboxProps, UsePinInputProps, ResponsiveValue, FormLabelProps, SimpleGridProps, FormControlProps, HTMLChakraProps } from '@chakra-ui/react';
7
+ import { NumberInputProps as NumberInputProps$1, NumberInputFieldProps as NumberInputFieldProps$1, InputProps, RadioProps, RadioGroupProps, SystemProps, StackDirection, MenuProps, ThemingProps, ButtonProps, MenuListProps, MenuItemOptionProps, SelectProps as SelectProps$1, TextareaProps, SwitchProps, CheckboxProps, UsePinInputProps, ResponsiveValue, FormLabelProps, SimpleGridProps, FormControlProps, HTMLChakraProps } from '@chakra-ui/react';
8
8
  import { UseStepperReturn, UseStepperProps, StepsProps, StepsItemProps } from '@saas-ui/core';
9
9
  import { FocusableElement } from '@chakra-ui/utils';
10
10
  import { MaybeRenderProp } from '@chakra-ui/react-utils';
@@ -23,6 +23,14 @@ interface NumberInputOptions {
23
23
  * Render a custom decrement icon.
24
24
  */
25
25
  decrementIcon?: React$1.ReactNode;
26
+ /**
27
+ * The placeholder text when no value is selected.
28
+ */
29
+ placeholder?: string;
30
+ /**
31
+ * Props to pass to the NumberInputField component.
32
+ */
33
+ fieldProps?: NumberInputFieldProps$1;
26
34
  }
27
35
  interface NumberInputProps extends NumberInputProps$1, NumberInputOptions {
28
36
  }
@@ -140,38 +148,42 @@ interface InputFieldProps extends InputProps {
140
148
  leftAddon?: React$1.ReactNode;
141
149
  rightAddon?: React$1.ReactNode;
142
150
  }
143
- declare const InputField: React$1.FC<InputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
151
+ declare const InputField: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof InputFieldProps> & InputFieldProps>;
144
152
  interface NumberInputFieldProps extends NumberInputProps {
145
153
  type: 'number';
146
154
  }
147
- declare const NumberInputField: React$1.FC<NumberInputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
148
- declare const PasswordInputField: React$1.FC<PasswordInputProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
149
- declare const TextareaField: React$1.FC<TextareaProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
150
- declare const SwitchField: React$1.FC<SwitchProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
151
- declare const SelectField: React$1.FC<SelectProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
152
- declare const CheckboxField: React$1.FC<CheckboxProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
153
- declare const RadioField: React$1.FC<RadioInputProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
154
- declare const NativeSelectField: React$1.FC<NativeSelectProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
155
+ declare const NumberInputField: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof NumberInputFieldProps> & NumberInputFieldProps>;
156
+ declare const PasswordInputField: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof PasswordInputProps> & PasswordInputProps>;
157
+ declare const TextareaField: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof TextareaProps> & TextareaProps>;
158
+ declare const SwitchField: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof SwitchProps> & SwitchProps>;
159
+ interface SelectFieldProps extends SelectProps {
160
+ buttonProps?: SelectButtonProps;
161
+ listProps?: SelectListProps;
162
+ }
163
+ declare const SelectField: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof SelectFieldProps> & SelectFieldProps>;
164
+ declare const CheckboxField: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof CheckboxProps> & CheckboxProps>;
165
+ declare const RadioField: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof RadioInputProps> & RadioInputProps>;
166
+ declare const NativeSelectField: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof NativeSelectProps> & NativeSelectProps>;
155
167
  interface PinFieldProps extends Omit<UsePinInputProps, 'type'> {
156
168
  pinLength?: number;
157
169
  pinType?: 'alphanumeric' | 'number';
158
170
  spacing?: SystemProps['margin'];
159
171
  }
160
- declare const PinField: React$1.FC<PinFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
172
+ declare const PinField: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof PinFieldProps> & PinFieldProps>;
161
173
  declare const defaultFieldTypes: {
162
- text: React$1.FC<InputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
163
- email: React$1.FC<InputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
164
- url: React$1.FC<InputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
165
- phone: React$1.FC<InputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
166
- number: React$1.FC<NumberInputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
167
- password: React$1.FC<PasswordInputProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
168
- textarea: React$1.FC<TextareaProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
169
- switch: React$1.FC<SwitchProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
170
- select: React$1.FC<SelectProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
171
- checkbox: React$1.FC<CheckboxProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
172
- radio: React$1.FC<RadioInputProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
173
- pin: React$1.FC<PinFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
174
- 'native-select': React$1.FC<NativeSelectProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
174
+ text: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof InputFieldProps> & InputFieldProps>;
175
+ email: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof InputFieldProps> & InputFieldProps>;
176
+ url: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof InputFieldProps> & InputFieldProps>;
177
+ phone: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof InputFieldProps> & InputFieldProps>;
178
+ number: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof NumberInputFieldProps> & NumberInputFieldProps>;
179
+ password: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof PasswordInputProps> & PasswordInputProps>;
180
+ textarea: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof TextareaProps> & TextareaProps>;
181
+ switch: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof SwitchProps> & SwitchProps>;
182
+ select: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof SelectFieldProps> & SelectFieldProps>;
183
+ checkbox: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof CheckboxProps> & CheckboxProps>;
184
+ radio: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof RadioInputProps> & RadioInputProps>;
185
+ pin: React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof PinFieldProps> & PinFieldProps>;
186
+ 'native-select': React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof NativeSelectProps> & NativeSelectProps>;
175
187
  };
176
188
  type DefaultFields = typeof defaultFieldTypes;
177
189
 
@@ -432,7 +444,7 @@ type Split<S extends string, D extends string> = string extends S ? string[] : S
432
444
  type MapPath<T extends string[]> = T extends [infer U, ...infer R] ? U extends string ? `${U extends `${number}` ? '$' : U}${R[0] extends string ? '.' : ''}${R extends string[] ? MapPath<R> : ''}` : '' : '';
433
445
  type TransformPath<T extends string> = MapPath<Split<T, '.'>>;
434
446
  type ArrayFieldPath<Name extends string> = Name extends string ? TransformPath<Name> : never;
435
- interface BaseFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<FormControlProps, 'label' | 'type'> {
447
+ interface BaseFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<FormControlProps, 'label' | 'type' | 'onChange'> {
436
448
  /**
437
449
  * The field name
438
450
  */
@@ -728,10 +740,10 @@ type FormType<FieldDefs, ExtraProps = object, ExtraOverrides = object> = (<TSche
728
740
  };
729
741
  declare function createForm<FieldDefs>({ resolver, fieldResolver, fields, }?: CreateFormProps<FieldDefs>): FormType<FieldDefs, object, object>;
730
742
 
731
- interface DisplayFieldProps extends FormControlProps, Omit<FieldProps, 'type' | 'label'> {
743
+ interface DisplayFieldProps extends Omit<FormControlProps, 'onChange'>, Omit<FieldProps, 'type' | 'label' | 'onChange'> {
732
744
  }
733
745
  /**
734
- *
746
+ * Display a field value.
735
747
  *
736
748
  * @see Docs https://saas-ui.dev/
737
749
  */
@@ -838,7 +850,7 @@ interface CreateFieldOptions {
838
850
  * @param options.isControlled Set this to true if this is a controlled field.
839
851
  * @param options.hideLabel Hide the field label, for example for the checkbox field.
840
852
  */
841
- declare const createField: <TProps extends object>(component: React$1.FC<TProps>, options?: CreateFieldOptions) => React$1.FC<TProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
853
+ declare const createField: <TProps extends object>(component: React$1.FC<TProps>, options?: CreateFieldOptions) => React$1.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof TProps> & TProps>;
842
854
 
843
855
  /**
844
856
  * Form component.
@@ -854,4 +866,4 @@ declare const Form: FormType<unknown, object, object>;
854
866
  */
855
867
  declare const StepForm: StepFormType<unknown, object, object>;
856
868
 
857
- export { ArrayField, ArrayFieldAddButton, ArrayFieldButtonProps, ArrayFieldContainer, ArrayFieldContainerProps, ArrayFieldOptions, ArrayFieldProps, ArrayFieldProvider, ArrayFieldRemoveButton, ArrayFieldRow, ArrayFieldRowContainer, ArrayFieldRowFields, ArrayFieldRowFieldsProps, ArrayFieldRowProvider, ArrayFieldRows, ArrayFieldRowsProps, AutoFields, BaseField, BaseFieldProps, Form$1 as BaseForm, CheckboxField, CreateFieldOptions, CreateFormProps, CreateStepFormProps, DefaultFieldOverrides, DefaultFields, DisplayField, DisplayFieldProps, DisplayIf, DisplayIfProps, Field, FieldOptions, FieldProps, FieldResolver, FieldRules, FieldsProps, FieldsProvider, Form, FormComponent, FormLayout, FormLayoutProps, FormLegend, FormProps, FormProvider, FormRenderContext, FormStep, FormStepOptions, FormStepProps, FormStepSubmitHandler, FormStepper, FormStepperProps, FormType, FormValue, GetFieldResolver, InputField, InputFieldProps, InputRightButton, InputRightButtonProps, NativeSelect, NativeSelectField, NativeSelectProps, NextButton, NextButtonProps, NumberInputField, NumberInputFieldProps, ObjectField, ObjectFieldProps, ObjectSchema, Option, PasswordInput, PasswordInputField, PasswordInputProps, PinField, PinFieldProps, PrevButton, RadioField, RadioInput, RadioInputProps, RadioOption, RadioOptions, Select, SelectButton, SelectButtonProps, SelectField, SelectList, SelectListProps, SelectOption, SelectProps, StepForm, StepFormContext, StepFormProps, StepFormProvider, StepFormRenderContext, StepState, StepsOptions, SubmitButton, SubmitButtonProps, SwitchField, TextareaField, UseArrayFieldReturn, UseArrayFieldRowProps, UseArrayFieldRowReturn, UseFormStepProps, UseStepFormProps, UseStepFormReturn, WatchField, WatchFieldProps, WithFields, WithStepFields, createField, createForm, createStepForm, defaultFieldTypes, objectFieldResolver, useArrayField, useArrayFieldAddButton, useArrayFieldContext, useArrayFieldRemoveButton, useArrayFieldRow, useArrayFieldRowContext, useField, useFormContext, useFormStep, useStepForm, useStepFormContext };
869
+ export { ArrayField, ArrayFieldAddButton, ArrayFieldButtonProps, ArrayFieldContainer, ArrayFieldContainerProps, ArrayFieldOptions, ArrayFieldProps, ArrayFieldProvider, ArrayFieldRemoveButton, ArrayFieldRow, ArrayFieldRowContainer, ArrayFieldRowFields, ArrayFieldRowFieldsProps, ArrayFieldRowProvider, ArrayFieldRows, ArrayFieldRowsProps, AutoFields, BaseField, BaseFieldProps, Form$1 as BaseForm, CheckboxField, CreateFieldOptions, CreateFormProps, CreateStepFormProps, DefaultFieldOverrides, DefaultFields, DisplayField, DisplayFieldProps, DisplayIf, DisplayIfProps, Field, FieldOptions, FieldProps, FieldResolver, FieldRules, FieldsProps, FieldsProvider, Form, FormComponent, FormLayout, FormLayoutProps, FormLegend, FormProps, FormProvider, FormRenderContext, FormStep, FormStepOptions, FormStepProps, FormStepSubmitHandler, FormStepper, FormStepperProps, FormType, FormValue, GetFieldResolver, InputField, InputFieldProps, InputRightButton, InputRightButtonProps, NativeSelect, NativeSelectField, NativeSelectProps, NextButton, NextButtonProps, NumberInputField, NumberInputFieldProps, ObjectField, ObjectFieldProps, ObjectSchema, Option, PasswordInput, PasswordInputField, PasswordInputProps, PinField, PinFieldProps, PrevButton, RadioField, RadioInput, RadioInputProps, RadioOption, RadioOptions, Select, SelectButton, SelectButtonProps, SelectField, SelectFieldProps, SelectList, SelectListProps, SelectOption, SelectProps, StepForm, StepFormContext, StepFormProps, StepFormProvider, StepFormRenderContext, StepState, StepsOptions, SubmitButton, SubmitButtonProps, SwitchField, TextareaField, UseArrayFieldReturn, UseArrayFieldRowProps, UseArrayFieldRowReturn, UseFormStepProps, UseStepFormProps, UseStepFormReturn, WatchField, WatchFieldProps, WithFields, WithStepFields, createField, createForm, createStepForm, defaultFieldTypes, objectFieldResolver, useArrayField, useArrayFieldAddButton, useArrayFieldContext, useArrayFieldRemoveButton, useArrayFieldRow, useArrayFieldRowContext, useField, useFormContext, useFormStep, useStepForm, useStepFormContext };
package/dist/index.js CHANGED
@@ -172,10 +172,13 @@ var NumberInput = (0, import_react2.forwardRef)((props, ref) => {
172
172
  hideStepper,
173
173
  incrementIcon = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core.ChevronUpIcon, {}),
174
174
  decrementIcon = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core.ChevronDownIcon, {}),
175
+ placeholder,
176
+ fieldProps: _fieldProps,
175
177
  ...rest
176
178
  } = props;
179
+ const fieldProps = { placeholder, ..._fieldProps };
177
180
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react2.NumberInput, { ...rest, ref, children: [
178
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.NumberInputField, {}),
181
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.NumberInputField, { ...fieldProps }),
179
182
  !hideStepper && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react2.NumberInputStepper, { children: [
180
183
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.NumberIncrementStepper, { children: incrementIcon }),
181
184
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.NumberDecrementStepper, { children: decrementIcon })
@@ -601,6 +604,7 @@ var withControlledInput = (InputComponent) => {
601
604
  return (0, import_react12.forwardRef)(
602
605
  ({ name, rules, ...inputProps }, ref) => {
603
606
  const { control } = useFormContext();
607
+ const onChange = inputProps.onChange;
604
608
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
605
609
  import_react_hook_form3.Controller,
606
610
  {
@@ -612,7 +616,7 @@ var withControlledInput = (InputComponent) => {
612
616
  {
613
617
  ...field,
614
618
  ...inputProps,
615
- onChange: (0, import_utils4.callAllHandlers)(inputProps.onChange, field.onChange),
619
+ onChange: (0, import_utils4.callAllHandlers)(onChange, field.onChange),
616
620
  onBlur: (0, import_utils4.callAllHandlers)(inputProps.onBlur, field.onBlur),
617
621
  ref: (0, import_react12.useMergeRefs)(ref, _ref)
618
622
  }
@@ -627,12 +631,13 @@ var withUncontrolledInput = (InputComponent) => {
627
631
  ({ name, rules, ...inputProps }, ref) => {
628
632
  const { register } = useFormContext();
629
633
  const { ref: _ref, ...field } = register(name, rules);
634
+ const onChange = inputProps.onChange;
630
635
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
631
636
  InputComponent,
632
637
  {
633
638
  ...field,
634
639
  ...inputProps,
635
- onChange: (0, import_utils4.callAllHandlers)(inputProps.onChange, field.onChange),
640
+ onChange: (0, import_utils4.callAllHandlers)(onChange, field.onChange),
636
641
  onBlur: (0, import_utils4.callAllHandlers)(inputProps.onBlur, field.onBlur),
637
642
  ref: (0, import_react12.useMergeRefs)(ref, _ref)
638
643
  }
@@ -691,9 +696,10 @@ var SwitchField = createField(
691
696
  );
692
697
  var SelectField = createField(
693
698
  (0, import_react13.forwardRef)((props, ref) => {
694
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Select, { ref, ...props, children: [
695
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SelectButton, {}),
696
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SelectList, {})
699
+ const { buttonProps, listProps, ...rest } = props;
700
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Select, { ref, ...rest, children: [
701
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SelectButton, { ...buttonProps }),
702
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SelectList, { ...listProps })
697
703
  ] });
698
704
  }),
699
705
  {
@@ -770,10 +776,9 @@ var Field = React6.forwardRef(
770
776
  );
771
777
 
772
778
  // src/fields.tsx
773
- var React10 = __toESM(require("react"));
779
+ var React9 = __toESM(require("react"));
774
780
 
775
781
  // src/layout.tsx
776
- var React7 = __toESM(require("react"));
777
782
  var import_react15 = require("@chakra-ui/react");
778
783
  var import_utils5 = require("@chakra-ui/utils");
779
784
  var import_jsx_runtime14 = require("react/jsx-runtime");
@@ -796,24 +801,19 @@ var FormLayout = ({ children, ...props }) => {
796
801
  {
797
802
  ...gridProps,
798
803
  className: (0, import_utils5.cx)("sui-form__layout", props.className),
799
- children: React7.Children.map(children, (child) => {
800
- if (React7.isValidElement(child)) {
801
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FormLayoutItem, { children: child });
802
- }
803
- return child;
804
- })
804
+ children
805
805
  }
806
806
  );
807
807
  };
808
808
  FormLayout.displayName = "FormLayout";
809
809
 
810
810
  // src/array-field.tsx
811
- var React9 = __toESM(require("react"));
811
+ var React8 = __toESM(require("react"));
812
812
  var import_react16 = require("@chakra-ui/react");
813
813
  var import_icons2 = require("@saas-ui/core/icons");
814
814
 
815
815
  // src/use-array-field.tsx
816
- var React8 = __toESM(require("react"));
816
+ var React7 = __toESM(require("react"));
817
817
  var import_react_hook_form4 = require("react-hook-form");
818
818
  var import_react_utils2 = require("@chakra-ui/react-utils");
819
819
  var [ArrayFieldProvider, useArrayFieldContext] = (0, import_react_utils2.createContext)({
@@ -846,7 +846,7 @@ var useArrayField = ({
846
846
  var useArrayFieldRow = ({ index }) => {
847
847
  const { clearErrors } = useFormContext();
848
848
  const { name, remove, fields } = useArrayFieldContext();
849
- React8.useEffect(() => {
849
+ React7.useEffect(() => {
850
850
  clearErrors(name);
851
851
  }, []);
852
852
  return {
@@ -854,7 +854,7 @@ var useArrayFieldRow = ({ index }) => {
854
854
  isFirst: index === 0,
855
855
  isLast: index === fields.length - 1,
856
856
  name: `${name}.${index}`,
857
- remove: React8.useCallback(() => {
857
+ remove: React7.useCallback(() => {
858
858
  clearErrors(name);
859
859
  remove(index);
860
860
  }, [index])
@@ -953,7 +953,7 @@ var ArrayFieldRows = ({
953
953
  return children(fields);
954
954
  };
955
955
  ArrayFieldRows.displayName = "ArrayFieldRows";
956
- var ArrayFieldContainer = React9.forwardRef(
956
+ var ArrayFieldContainer = React8.forwardRef(
957
957
  ({
958
958
  name,
959
959
  defaultValue,
@@ -971,7 +971,7 @@ var ArrayFieldContainer = React9.forwardRef(
971
971
  min: min || (overrides == null ? void 0 : overrides.min),
972
972
  max: max || (overrides == null ? void 0 : overrides.max)
973
973
  });
974
- React9.useImperativeHandle(ref, () => context, [ref, context]);
974
+ React8.useImperativeHandle(ref, () => context, [ref, context]);
975
975
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ArrayFieldProvider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(BaseField, { name, ...fieldProps, ...overrides, children }) });
976
976
  }
977
977
  );
@@ -1036,10 +1036,10 @@ var AutoFields = ({
1036
1036
  const context = useFormContext();
1037
1037
  const schema = schemaProp || context.schema;
1038
1038
  const fieldResolver = fieldResolverProp || context.fieldResolver;
1039
- const resolver = React10.useMemo(() => fieldResolver, [schema, fieldResolver]);
1040
- const fields = React10.useMemo(() => resolver == null ? void 0 : resolver.getFields(), [resolver]);
1039
+ const resolver = React9.useMemo(() => fieldResolver, [schema, fieldResolver]);
1040
+ const fields = React9.useMemo(() => resolver == null ? void 0 : resolver.getFields(), [resolver]);
1041
1041
  const form = useFormContext();
1042
- React10.useEffect(() => {
1042
+ React9.useEffect(() => {
1043
1043
  var _a;
1044
1044
  if (focusFirstField && ((_a = fields == null ? void 0 : fields[0]) == null ? void 0 : _a.name)) {
1045
1045
  form.setFocus(fields[0].name);
@@ -1060,7 +1060,16 @@ var AutoFields = ({
1060
1060
  } else if (type === "object") {
1061
1061
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ObjectField, { name, ...fieldProps, children: mapNestedFields2(resolver, name) }, name);
1062
1062
  }
1063
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Field, { name, type, ...fieldProps }, name);
1063
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1064
+ Field,
1065
+ {
1066
+ name,
1067
+ type,
1068
+ defaultValue,
1069
+ ...fieldProps
1070
+ },
1071
+ name
1072
+ );
1064
1073
  }
1065
1074
  ) });
1066
1075
  };
@@ -1124,13 +1133,13 @@ var DisplayIf = ({
1124
1133
  DisplayIf.displayName = "DisplayIf";
1125
1134
 
1126
1135
  // src/step-form.tsx
1127
- var React12 = __toESM(require("react"));
1136
+ var React11 = __toESM(require("react"));
1128
1137
  var import_react19 = require("@chakra-ui/react");
1129
1138
  var import_utils9 = require("@chakra-ui/utils");
1130
1139
  var import_core4 = require("@saas-ui/core");
1131
1140
 
1132
1141
  // src/use-step-form.tsx
1133
- var React11 = __toESM(require("react"));
1142
+ var React10 = __toESM(require("react"));
1134
1143
  var import_react_utils3 = require("@chakra-ui/react-utils");
1135
1144
  var import_core3 = require("@saas-ui/core");
1136
1145
  var [StepFormProvider, useStepFormContext] = (0, import_react_utils3.createContext)({
@@ -1138,18 +1147,29 @@ var [StepFormProvider, useStepFormContext] = (0, import_react_utils3.createConte
1138
1147
  errorMessage: "useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`"
1139
1148
  });
1140
1149
  function useStepForm(props) {
1141
- const { onChange, steps: stepsOptions, resolver, ...rest } = props;
1150
+ const {
1151
+ onChange,
1152
+ steps: stepsOptions,
1153
+ resolver,
1154
+ fieldResolver,
1155
+ ...rest
1156
+ } = props;
1142
1157
  const stepper = (0, import_core3.useStepper)(rest);
1143
- const [options, setOptions] = React11.useState(stepsOptions);
1158
+ const [options, setOptions] = React10.useState(stepsOptions);
1144
1159
  const { activeStep, isLastStep, nextStep } = stepper;
1145
- const [steps, updateSteps] = React11.useState({});
1146
- const onSubmitStep = React11.useCallback(
1160
+ const [steps, updateSteps] = React10.useState({});
1161
+ const mergedData = React10.useRef({});
1162
+ const onSubmitStep = React10.useCallback(
1147
1163
  async (data) => {
1148
1164
  var _a, _b;
1149
1165
  try {
1150
1166
  const step = steps[activeStep];
1167
+ mergedData.current = {
1168
+ ...mergedData.current,
1169
+ ...data
1170
+ };
1151
1171
  if (isLastStep) {
1152
- await ((_a = props.onSubmit) == null ? void 0 : _a.call(props, data));
1172
+ await ((_a = props.onSubmit) == null ? void 0 : _a.call(props, mergedData.current));
1153
1173
  updateStep({
1154
1174
  ...step,
1155
1175
  isCompleted: true
@@ -1162,9 +1182,9 @@ function useStepForm(props) {
1162
1182
  } catch (e) {
1163
1183
  }
1164
1184
  },
1165
- [steps, activeStep, isLastStep]
1185
+ [steps, activeStep, isLastStep, mergedData]
1166
1186
  );
1167
- const getFormProps = React11.useCallback(() => {
1187
+ const getFormProps = React10.useCallback(() => {
1168
1188
  const step = steps[activeStep];
1169
1189
  return {
1170
1190
  onSubmit: onSubmitStep,
@@ -1172,10 +1192,11 @@ function useStepForm(props) {
1172
1192
  resolver: (step == null ? void 0 : step.schema) ? (
1173
1193
  /* @todo fix resolver type */
1174
1194
  resolver == null ? void 0 : resolver(step.schema)
1175
- ) : void 0
1195
+ ) : void 0,
1196
+ fieldResolver: (step == null ? void 0 : step.schema) ? fieldResolver == null ? void 0 : fieldResolver(step.schema) : void 0
1176
1197
  };
1177
- }, [steps, onSubmitStep, activeStep]);
1178
- const updateStep = React11.useCallback(
1198
+ }, [steps, onSubmitStep, activeStep, resolver, fieldResolver]);
1199
+ const updateStep = React10.useCallback(
1179
1200
  (step) => {
1180
1201
  const stepOptions = options == null ? void 0 : options.find((s) => s.name === step.name);
1181
1202
  updateSteps((steps2) => {
@@ -1201,7 +1222,7 @@ function useFormStep(props) {
1201
1222
  const { name, schema, resolver, onSubmit } = props;
1202
1223
  const step = (0, import_core3.useStep)({ name });
1203
1224
  const { steps, updateStep } = useStepFormContext();
1204
- React11.useEffect(() => {
1225
+ React10.useEffect(() => {
1205
1226
  updateStep({ name, schema, resolver, onSubmit });
1206
1227
  }, [name, schema]);
1207
1228
  return {
@@ -1224,8 +1245,8 @@ var FormStepper = (props) => {
1224
1245
  render,
1225
1246
  ...rest
1226
1247
  } = props;
1227
- const elements = React12.Children.map(children, (child) => {
1228
- if (React12.isValidElement(child) && (child == null ? void 0 : child.type) === FormStep) {
1248
+ const elements = React11.Children.map(children, (child) => {
1249
+ if (React11.isValidElement(child) && (child == null ? void 0 : child.type) === FormStep) {
1229
1250
  const { isCompleted } = useFormStep(child.props);
1230
1251
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1231
1252
  import_core4.StepsItem,
@@ -1241,7 +1262,7 @@ var FormStepper = (props) => {
1241
1262
  }
1242
1263
  return child;
1243
1264
  });
1244
- const onChange = React12.useCallback((i) => {
1265
+ const onChange = React11.useCallback((i) => {
1245
1266
  setIndex(i);
1246
1267
  onChangeProp == null ? void 0 : onChangeProp(i);
1247
1268
  }, []);
@@ -1338,7 +1359,7 @@ var WatchField = (props) => {
1338
1359
  };
1339
1360
 
1340
1361
  // src/form.tsx
1341
- var React13 = __toESM(require("react"));
1362
+ var React12 = __toESM(require("react"));
1342
1363
  var import_react20 = require("@chakra-ui/react");
1343
1364
  var import_utils11 = require("@chakra-ui/utils");
1344
1365
  var import_react_hook_form8 = require("react-hook-form");
@@ -1384,8 +1405,8 @@ var Form = (0, import_react20.forwardRef)(
1384
1405
  };
1385
1406
  const methods = (0, import_react_hook_form8.useForm)(form);
1386
1407
  const { handleSubmit } = methods;
1387
- React13.useImperativeHandle(formRef, () => methods, [formRef, methods]);
1388
- React13.useEffect(() => {
1408
+ React12.useImperativeHandle(formRef, () => methods, [formRef, methods]);
1409
+ React12.useEffect(() => {
1389
1410
  let subscription;
1390
1411
  if (onChange) {
1391
1412
  subscription = methods.watch(onChange);
@@ -1438,13 +1459,18 @@ function createForm({
1438
1459
  } = {}) {
1439
1460
  const DefaultForm = (0, import_react21.forwardRef)(
1440
1461
  (props, ref) => {
1441
- const { schema, ...rest } = props;
1462
+ const {
1463
+ schema,
1464
+ resolver: resolverProp,
1465
+ fieldResolver: fieldResolverProp,
1466
+ ...rest
1467
+ } = props;
1442
1468
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(FieldsProvider, { value: fields || {}, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1443
1469
  Form,
1444
1470
  {
1445
1471
  ref,
1446
- resolver: resolver == null ? void 0 : resolver(props.schema),
1447
- fieldResolver: fieldResolver == null ? void 0 : fieldResolver(schema),
1472
+ resolver: resolverProp != null ? resolverProp : resolver == null ? void 0 : resolver(props.schema),
1473
+ fieldResolver: fieldResolverProp != null ? fieldResolverProp : fieldResolver == null ? void 0 : fieldResolver(schema),
1448
1474
  ...rest
1449
1475
  }
1450
1476
  ) });