@saas-ui/forms 2.0.0-next.9 → 2.0.0-rc.23

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React13 = require('react');
3
+ var React12 = require('react');
4
4
  var reactHookForm = require('react-hook-form');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var react = require('@chakra-ui/react');
@@ -27,12 +27,12 @@ function _interopNamespace(e) {
27
27
  return Object.freeze(n);
28
28
  }
29
29
 
30
- var React13__namespace = /*#__PURE__*/_interopNamespace(React13);
30
+ var React12__namespace = /*#__PURE__*/_interopNamespace(React12);
31
31
 
32
32
  // src/form-context.tsx
33
- var FormContext = React13__namespace.createContext(null);
33
+ var FormContext = React12__namespace.createContext(null);
34
34
  var useFormContext = () => {
35
- const context = React13__namespace.useContext(FormContext);
35
+ const context = React12__namespace.useContext(FormContext);
36
36
  const hookContext = reactHookForm.useFormContext();
37
37
  if (!context) {
38
38
  throw new Error("FormProvider must be used within a Form component");
@@ -46,7 +46,7 @@ var useFieldProps = (name) => {
46
46
  var _a;
47
47
  const parsedName = name == null ? void 0 : name.replace(/\.[0-9]/g, ".$");
48
48
  const context = useFormContext();
49
- return (_a = context == null ? void 0 : context.fields) == null ? void 0 : _a[parsedName];
49
+ return ((_a = context == null ? void 0 : context.fields) == null ? void 0 : _a[parsedName]) || {};
50
50
  };
51
51
  var FormProvider = (props) => {
52
52
  const { children, fieldResolver, schema, fields, ...rest } = props;
@@ -108,7 +108,7 @@ var PasswordInput = react.forwardRef(
108
108
  leftAddon,
109
109
  ...inputProps
110
110
  } = props;
111
- const [show, setShow] = React13.useState(false);
111
+ const [show, setShow] = React12.useState(false);
112
112
  const handleClick = () => setShow(!show);
113
113
  const label = show ? "Hide password" : "Show password";
114
114
  let icon;
@@ -147,15 +147,15 @@ var PasswordInput = react.forwardRef(
147
147
  );
148
148
  PasswordInput.displayName = "PasswordInput";
149
149
  var mapNestedFields = (name, children) => {
150
- return React13__namespace.Children.map(children, (child) => {
151
- if (React13__namespace.isValidElement(child) && child.props.name) {
150
+ return React12__namespace.Children.map(children, (child) => {
151
+ if (React12__namespace.isValidElement(child) && child.props.name) {
152
152
  let childName = child.props.name;
153
153
  if (childName.includes(".")) {
154
154
  childName = childName.replace(/^.*\.(.*)/, "$1");
155
155
  } else if (childName.includes(".$")) {
156
156
  childName = childName.replace(/^.*\.\$(.*)/, "$1");
157
157
  }
158
- return React13__namespace.cloneElement(child, {
158
+ return React12__namespace.cloneElement(child, {
159
159
  ...child.props,
160
160
  name: `${name}.${childName}`
161
161
  });
@@ -215,14 +215,14 @@ var useSelect = (props) => {
215
215
  onChange
216
216
  });
217
217
  const controlProps = react.useFormControl({ name });
218
- const options = React13__namespace.default.useMemo(
218
+ const options = React12__namespace.default.useMemo(
219
219
  () => optionsProp && mapOptions(optionsProp),
220
220
  [optionsProp]
221
221
  );
222
222
  const handleChange = (value2) => {
223
223
  setCurrentValue(value2);
224
224
  };
225
- const getDisplayValue = React13__namespace.default.useCallback(
225
+ const getDisplayValue = React12__namespace.default.useCallback(
226
226
  (value2) => {
227
227
  if (!options) {
228
228
  return value2;
@@ -236,7 +236,7 @@ var useSelect = (props) => {
236
236
  },
237
237
  [options]
238
238
  );
239
- const displayValue = React13__namespace.default.useMemo(
239
+ const displayValue = React12__namespace.default.useMemo(
240
240
  () => currentValue ? (Array.isArray(currentValue) ? currentValue : [currentValue]).map(
241
241
  getDisplayValue
242
242
  ) : [],
@@ -300,7 +300,8 @@ var SelectButton = react.forwardRef(
300
300
  react.MenuButton,
301
301
  {
302
302
  as: react.Button,
303
- id: id || React13__namespace.useId(),
303
+ id: id || React12__namespace.useId(),
304
+ ...buttonStyles,
304
305
  ...rest,
305
306
  onFocus,
306
307
  onBlur,
@@ -311,7 +312,6 @@ var SelectButton = react.forwardRef(
311
312
  "data-required": utils.dataAttr(isRequired),
312
313
  rightIcon,
313
314
  ref,
314
- sx: buttonStyles,
315
315
  children: renderValue(displayValue) || placeholder
316
316
  }
317
317
  );
@@ -573,7 +573,7 @@ var defaultFieldTypes = {
573
573
  pin: PinField,
574
574
  "native-select": NativeSelectField
575
575
  };
576
- var FieldsContext = React13__namespace.default.createContext(
576
+ var FieldsContext = React12__namespace.default.createContext(
577
577
  null
578
578
  );
579
579
  var FieldsProvider = (props) => {
@@ -581,11 +581,11 @@ var FieldsProvider = (props) => {
581
581
  return /* @__PURE__ */ jsxRuntime.jsx(FieldsContext.Provider, { value: fields, children: props.children });
582
582
  };
583
583
  var useField = (type) => {
584
- const context = React13__namespace.default.useContext(FieldsContext);
584
+ const context = React12__namespace.default.useContext(FieldsContext);
585
585
  return (context == null ? void 0 : context[type]) || InputField;
586
586
  };
587
587
  var defaultInputType = "text";
588
- var Field = React13__namespace.forwardRef(
588
+ var Field = React12__namespace.forwardRef(
589
589
  (props, ref) => {
590
590
  const { type = defaultInputType, name } = props;
591
591
  const overrides = useFieldProps(name);
@@ -612,8 +612,8 @@ var FormLayout = ({ children, ...props }) => {
612
612
  {
613
613
  ...gridProps,
614
614
  className: utils.cx("sui-form__layout", props.className),
615
- children: React13__namespace.Children.map(children, (child) => {
616
- if (React13__namespace.isValidElement(child)) {
615
+ children: React12__namespace.Children.map(children, (child) => {
616
+ if (React12__namespace.isValidElement(child)) {
617
617
  return /* @__PURE__ */ jsxRuntime.jsx(FormLayoutItem, { children: child });
618
618
  }
619
619
  return child;
@@ -652,7 +652,7 @@ var useArrayField = ({
652
652
  var useArrayFieldRow = ({ index }) => {
653
653
  const { clearErrors } = useFormContext();
654
654
  const { name, remove, fields } = useArrayFieldContext();
655
- React13__namespace.useEffect(() => {
655
+ React12__namespace.useEffect(() => {
656
656
  clearErrors(name);
657
657
  }, []);
658
658
  return {
@@ -660,7 +660,7 @@ var useArrayFieldRow = ({ index }) => {
660
660
  isFirst: index === 0,
661
661
  isLast: index === fields.length - 1,
662
662
  name: `${name}.${index}`,
663
- remove: React13__namespace.useCallback(() => {
663
+ remove: React12__namespace.useCallback(() => {
664
664
  clearErrors(name);
665
665
  remove(index);
666
666
  }, [index])
@@ -755,7 +755,7 @@ var ArrayFieldRows = ({
755
755
  return children(fields);
756
756
  };
757
757
  ArrayFieldRows.displayName = "ArrayFieldRows";
758
- var ArrayFieldContainer = React13__namespace.forwardRef(
758
+ var ArrayFieldContainer = React12__namespace.forwardRef(
759
759
  ({
760
760
  name,
761
761
  defaultValue,
@@ -765,15 +765,16 @@ var ArrayFieldContainer = React13__namespace.forwardRef(
765
765
  children,
766
766
  ...fieldProps
767
767
  }, ref) => {
768
+ const overrides = useFieldProps(name);
768
769
  const context = useArrayField({
769
770
  name,
770
771
  defaultValue,
771
772
  keyName,
772
- min,
773
- max
773
+ min: min || (overrides == null ? void 0 : overrides.min),
774
+ max: max || (overrides == null ? void 0 : overrides.max)
774
775
  });
775
- React13__namespace.useImperativeHandle(ref, () => context, [ref, context]);
776
- return /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(BaseField, { name, ...fieldProps, children }) });
776
+ React12__namespace.useImperativeHandle(ref, () => context, [ref, context]);
777
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(BaseField, { name, ...fieldProps, ...overrides, children }) });
777
778
  }
778
779
  );
779
780
  ArrayFieldContainer.displayName = "ArrayFieldContainer";
@@ -782,10 +783,28 @@ var FormLegend = (props) => {
782
783
  return /* @__PURE__ */ jsxRuntime.jsx(react.FormLabel, { as: "legend", sx: styles, ...props });
783
784
  };
784
785
  var ObjectField = (props) => {
785
- const { name, label, hideLabel, children, columns, spacing, ...fieldProps } = props;
786
- return /* @__PURE__ */ jsxRuntime.jsxs(react.FormControl, { name, as: "fieldset", ...fieldProps, children: [
787
- /* @__PURE__ */ jsxRuntime.jsx(FormLegend, { display: hideLabel ? "none" : "block", children: label }),
788
- /* @__PURE__ */ jsxRuntime.jsx(FormLayout, { columns, gridGap: spacing, children: mapNestedFields(name, children) })
786
+ const {
787
+ name,
788
+ label,
789
+ hideLabel: hideLabelProp,
790
+ children,
791
+ columns: columnsProp,
792
+ spacing: spacingProp,
793
+ ...fieldProps
794
+ } = props;
795
+ const { hideLabel, columns, spacing, ...overrides } = useFieldProps(
796
+ name
797
+ );
798
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.FormControl, { name, as: "fieldset", ...fieldProps, ...overrides, children: [
799
+ /* @__PURE__ */ jsxRuntime.jsx(FormLegend, { display: hideLabelProp || hideLabel ? "none" : "block", children: label }),
800
+ /* @__PURE__ */ jsxRuntime.jsx(
801
+ FormLayout,
802
+ {
803
+ columns: columnsProp || columns,
804
+ gridGap: spacingProp || spacing,
805
+ children: mapNestedFields(name, children)
806
+ }
807
+ )
789
808
  ] });
790
809
  };
791
810
  ObjectField.displayName = "ObjectField";
@@ -812,10 +831,10 @@ var AutoFields = ({
812
831
  const context = useFormContext();
813
832
  const schema = schemaProp || context.schema;
814
833
  const fieldResolver = fieldResolverProp || context.fieldResolver;
815
- const resolver = React13__namespace.useMemo(() => fieldResolver, [schema, fieldResolver]);
816
- const fields = React13__namespace.useMemo(() => resolver == null ? void 0 : resolver.getFields(), [resolver]);
834
+ const resolver = React12__namespace.useMemo(() => fieldResolver, [schema, fieldResolver]);
835
+ const fields = React12__namespace.useMemo(() => resolver == null ? void 0 : resolver.getFields(), [resolver]);
817
836
  const form = useFormContext();
818
- React13__namespace.useEffect(() => {
837
+ React12__namespace.useEffect(() => {
819
838
  var _a;
820
839
  if (focusFirstField && ((_a = fields == null ? void 0 : fields[0]) == null ? void 0 : _a.name)) {
821
840
  form.setFocus(fields[0].name);
@@ -890,100 +909,17 @@ var DisplayIf = ({
890
909
  return condition(value, context) ? children : null;
891
910
  };
892
911
  DisplayIf.displayName = "DisplayIf";
893
- var Form = react.forwardRef(
894
- (props, ref) => {
895
- const {
896
- mode = "all",
897
- resolver,
898
- fieldResolver,
899
- fields,
900
- reValidateMode,
901
- shouldFocusError,
902
- shouldUnregister,
903
- shouldUseNativeValidation,
904
- criteriaMode,
905
- delayError,
906
- schema,
907
- defaultValues,
908
- values,
909
- context,
910
- resetOptions,
911
- onChange,
912
- onSubmit,
913
- onError,
914
- formRef,
915
- children,
916
- ...rest
917
- } = props;
918
- const form = {
919
- mode,
920
- resolver,
921
- defaultValues,
922
- values,
923
- reValidateMode,
924
- shouldFocusError,
925
- shouldUnregister,
926
- shouldUseNativeValidation,
927
- criteriaMode,
928
- delayError,
929
- context,
930
- resetOptions
931
- };
932
- const methods = reactHookForm.useForm(form);
933
- const { handleSubmit } = methods;
934
- React13__namespace.useImperativeHandle(formRef, () => methods, [formRef, methods]);
935
- React13__namespace.useEffect(() => {
936
- let subscription;
937
- if (onChange) {
938
- subscription = methods.watch(onChange);
939
- }
940
- return () => subscription == null ? void 0 : subscription.unsubscribe();
941
- }, [methods, onChange]);
942
- let _children = children;
943
- if (!_children && fieldResolver) {
944
- _children = /* @__PURE__ */ jsxRuntime.jsxs(FormLayout, { children: [
945
- /* @__PURE__ */ jsxRuntime.jsx(AutoFields, {}),
946
- /* @__PURE__ */ jsxRuntime.jsx(SubmitButton, { ...fields == null ? void 0 : fields.submit })
947
- ] });
948
- }
949
- return /* @__PURE__ */ jsxRuntime.jsx(
950
- FormProvider,
951
- {
952
- ...methods,
953
- schema,
954
- fieldResolver,
955
- fields,
956
- children: /* @__PURE__ */ jsxRuntime.jsx(
957
- react.chakra.form,
958
- {
959
- ref,
960
- onSubmit: handleSubmit(onSubmit, onError),
961
- ...rest,
962
- className: utils.cx("sui-form", props.className),
963
- children: utils.runIfFn(_children, {
964
- Field,
965
- DisplayIf,
966
- ArrayField,
967
- ObjectField,
968
- ...methods
969
- })
970
- }
971
- )
972
- }
973
- );
974
- }
975
- );
976
- Form.displayName = "Form";
977
912
  var [StepFormProvider, useStepFormContext] = reactUtils.createContext({
978
913
  name: "StepFormContext",
979
914
  errorMessage: "useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`"
980
915
  });
981
916
  function useStepForm(props) {
982
- const { onChange, ...rest } = props;
917
+ const { onChange, steps: stepsOptions, resolver, ...rest } = props;
983
918
  const stepper = core.useStepper(rest);
919
+ const [options, setOptions] = React12__namespace.useState(stepsOptions);
984
920
  const { activeStep, isLastStep, nextStep } = stepper;
985
- const [steps, updateSteps] = React13__namespace.useState({});
986
- const onSubmitStep = React13__namespace.useCallback(
921
+ const [steps, updateSteps] = React12__namespace.useState({});
922
+ const onSubmitStep = React12__namespace.useCallback(
987
923
  async (data) => {
988
924
  var _a, _b;
989
925
  try {
@@ -1004,24 +940,31 @@ function useStepForm(props) {
1004
940
  },
1005
941
  [steps, activeStep, isLastStep]
1006
942
  );
1007
- const getFormProps = React13__namespace.useCallback(() => {
943
+ const getFormProps = React12__namespace.useCallback(() => {
1008
944
  const step = steps[activeStep];
1009
945
  return {
1010
946
  onSubmit: onSubmitStep,
1011
947
  schema: step == null ? void 0 : step.schema,
1012
- resolver: step == null ? void 0 : step.resolver
948
+ resolver: (step == null ? void 0 : step.schema) ? (
949
+ /* @todo fix resolver type */
950
+ resolver == null ? void 0 : resolver(step.schema)
951
+ ) : void 0
1013
952
  };
1014
953
  }, [steps, onSubmitStep, activeStep]);
1015
- const updateStep = React13__namespace.useCallback(
954
+ const updateStep = React12__namespace.useCallback(
1016
955
  (step) => {
956
+ const stepOptions = options == null ? void 0 : options.find((s) => s.name === step.name);
1017
957
  updateSteps((steps2) => {
1018
958
  return {
1019
959
  ...steps2,
1020
- [step.name]: step
960
+ [step.name]: {
961
+ ...step,
962
+ schema: stepOptions == null ? void 0 : stepOptions.schema
963
+ }
1021
964
  };
1022
965
  });
1023
966
  },
1024
- [steps]
967
+ [steps, options]
1025
968
  );
1026
969
  return {
1027
970
  getFormProps,
@@ -1034,7 +977,7 @@ function useFormStep(props) {
1034
977
  const { name, schema, resolver, onSubmit } = props;
1035
978
  const step = core.useStep({ name });
1036
979
  const { steps, updateStep } = useStepFormContext();
1037
- React13__namespace.useEffect(() => {
980
+ React12__namespace.useEffect(() => {
1038
981
  updateStep({ name, schema, resolver, onSubmit });
1039
982
  }, [name, schema]);
1040
983
  return {
@@ -1042,24 +985,25 @@ function useFormStep(props) {
1042
985
  ...steps[name] || { name, schema }
1043
986
  };
1044
987
  }
1045
- var StepForm = React13__namespace.forwardRef(
1046
- (props, ref) => {
1047
- const { children, ...rest } = props;
1048
- const stepper = useStepForm(props);
1049
- const { getFormProps, ...ctx } = stepper;
1050
- const context = React13__namespace.useMemo(() => ctx, [ctx]);
1051
- return /* @__PURE__ */ jsxRuntime.jsx(core.StepperProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(StepFormProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(Form, { ref, ...rest, ...getFormProps(), children: utils.runIfFn(children, stepper) }) }) });
1052
- }
1053
- );
1054
988
  var FormStepper = (props) => {
1055
989
  const { activeIndex, setIndex } = core.useStepperContext();
1056
- const { children, orientation, variant, colorScheme, size, ...rest } = props;
1057
- const elements = React13__namespace.Children.map(children, (child) => {
1058
- if (React13__namespace.isValidElement(child) && (child == null ? void 0 : child.type) === FormStep) {
990
+ const {
991
+ children,
992
+ orientation,
993
+ variant,
994
+ colorScheme,
995
+ size,
996
+ onChange: onChangeProp,
997
+ render,
998
+ ...rest
999
+ } = props;
1000
+ const elements = React12__namespace.Children.map(children, (child) => {
1001
+ if (React12__namespace.isValidElement(child) && (child == null ? void 0 : child.type) === FormStep) {
1059
1002
  const { isCompleted } = useFormStep(child.props);
1060
1003
  return /* @__PURE__ */ jsxRuntime.jsx(
1061
- core.StepperStep,
1004
+ core.StepsItem,
1062
1005
  {
1006
+ render,
1063
1007
  name: child.props.name,
1064
1008
  title: child.props.title,
1065
1009
  isCompleted,
@@ -1070,11 +1014,12 @@ var FormStepper = (props) => {
1070
1014
  }
1071
1015
  return child;
1072
1016
  });
1073
- const onChange = React13__namespace.useCallback((i) => {
1017
+ const onChange = React12__namespace.useCallback((i) => {
1074
1018
  setIndex(i);
1019
+ onChangeProp == null ? void 0 : onChangeProp(i);
1075
1020
  }, []);
1076
1021
  return /* @__PURE__ */ jsxRuntime.jsx(
1077
- core.StepperContainer,
1022
+ core.Steps,
1078
1023
  {
1079
1024
  orientation,
1080
1025
  step: activeIndex,
@@ -1082,13 +1027,13 @@ var FormStepper = (props) => {
1082
1027
  colorScheme,
1083
1028
  size,
1084
1029
  onChange,
1085
- children: /* @__PURE__ */ jsxRuntime.jsx(core.StepperSteps, { mb: "4", ...props, children: elements })
1030
+ children: elements
1086
1031
  }
1087
1032
  );
1088
1033
  };
1089
1034
  var FormStep = (props) => {
1090
- const { name, schema, resolver, children, className, onSubmit, ...rest } = props;
1091
- const step = useFormStep({ name, schema, resolver, onSubmit });
1035
+ const { name, children, className, onSubmit, ...rest } = props;
1036
+ const step = useFormStep({ name, onSubmit });
1092
1037
  const { isActive } = step;
1093
1038
  return isActive ? /* @__PURE__ */ jsxRuntime.jsx(react.chakra.div, { ...rest, className: utils.cx("sui-form__step", className), children }) : null;
1094
1039
  };
@@ -1099,7 +1044,7 @@ var PrevButton = (props) => {
1099
1044
  react.Button,
1100
1045
  {
1101
1046
  isDisabled: isFirstStep || isCompleted,
1102
- label: "Back",
1047
+ children: "Back",
1103
1048
  ...props,
1104
1049
  className: utils.cx("sui-form__prev-button", props.className),
1105
1050
  onClick: utils.callAllHandlers(props.onClick, prevStep)
@@ -1158,12 +1103,96 @@ var WatchField = (props) => {
1158
1103
  });
1159
1104
  return props.children(field, form) || null;
1160
1105
  };
1106
+ var Form = react.forwardRef(
1107
+ (props, ref) => {
1108
+ const {
1109
+ mode = "all",
1110
+ resolver,
1111
+ fieldResolver,
1112
+ fields,
1113
+ reValidateMode,
1114
+ shouldFocusError,
1115
+ shouldUnregister,
1116
+ shouldUseNativeValidation,
1117
+ criteriaMode,
1118
+ delayError,
1119
+ schema,
1120
+ defaultValues,
1121
+ values,
1122
+ context,
1123
+ resetOptions,
1124
+ onChange,
1125
+ onSubmit,
1126
+ onError,
1127
+ formRef,
1128
+ children,
1129
+ ...rest
1130
+ } = props;
1131
+ const form = {
1132
+ mode,
1133
+ resolver,
1134
+ defaultValues,
1135
+ values,
1136
+ reValidateMode,
1137
+ shouldFocusError,
1138
+ shouldUnregister,
1139
+ shouldUseNativeValidation,
1140
+ criteriaMode,
1141
+ delayError,
1142
+ context,
1143
+ resetOptions
1144
+ };
1145
+ const methods = reactHookForm.useForm(form);
1146
+ const { handleSubmit } = methods;
1147
+ React12__namespace.useImperativeHandle(formRef, () => methods, [formRef, methods]);
1148
+ React12__namespace.useEffect(() => {
1149
+ let subscription;
1150
+ if (onChange) {
1151
+ subscription = methods.watch(onChange);
1152
+ }
1153
+ return () => subscription == null ? void 0 : subscription.unsubscribe();
1154
+ }, [methods, onChange]);
1155
+ let _children = children;
1156
+ if (!_children && fieldResolver) {
1157
+ _children = /* @__PURE__ */ jsxRuntime.jsxs(FormLayout, { children: [
1158
+ /* @__PURE__ */ jsxRuntime.jsx(AutoFields, {}),
1159
+ /* @__PURE__ */ jsxRuntime.jsx(SubmitButton, { ...fields == null ? void 0 : fields.submit })
1160
+ ] });
1161
+ }
1162
+ return /* @__PURE__ */ jsxRuntime.jsx(
1163
+ FormProvider,
1164
+ {
1165
+ ...methods,
1166
+ schema,
1167
+ fieldResolver,
1168
+ fields,
1169
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1170
+ react.chakra.form,
1171
+ {
1172
+ ref,
1173
+ onSubmit: handleSubmit(onSubmit, onError),
1174
+ ...rest,
1175
+ className: utils.cx("sui-form", props.className),
1176
+ children: utils.runIfFn(_children, {
1177
+ Field,
1178
+ DisplayIf,
1179
+ ArrayField,
1180
+ ObjectField,
1181
+ ...methods
1182
+ })
1183
+ }
1184
+ )
1185
+ }
1186
+ );
1187
+ }
1188
+ );
1189
+ Form.displayName = "Form";
1161
1190
  function createForm({
1162
1191
  resolver,
1163
1192
  fieldResolver = objectFieldResolver,
1164
1193
  fields
1165
1194
  } = {}) {
1166
- const CreateForm = react.forwardRef(
1195
+ const DefaultForm = react.forwardRef(
1167
1196
  (props, ref) => {
1168
1197
  const { schema, ...rest } = props;
1169
1198
  return /* @__PURE__ */ jsxRuntime.jsx(FieldsProvider, { value: fields || {}, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -1177,9 +1206,34 @@ function createForm({
1177
1206
  ) });
1178
1207
  }
1179
1208
  );
1180
- return CreateForm;
1209
+ DefaultForm.displayName = "Form";
1210
+ DefaultForm.id = "Form";
1211
+ return DefaultForm;
1212
+ }
1213
+ function createStepForm({ fields, resolver, fieldResolver } = {}) {
1214
+ const StepForm2 = react.forwardRef((props, ref) => {
1215
+ const { children, steps, ...rest } = props;
1216
+ const stepper = useStepForm({
1217
+ resolver,
1218
+ fieldResolver,
1219
+ ...props
1220
+ });
1221
+ const { getFormProps, ...ctx } = stepper;
1222
+ const context = React12.useMemo(() => ctx, [ctx]);
1223
+ return /* @__PURE__ */ jsxRuntime.jsx(core.StepperProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(StepFormProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(FieldsProvider, { value: fields || {}, children: /* @__PURE__ */ jsxRuntime.jsx(Form2, { ref, ...rest, ...getFormProps(), children: utils.runIfFn(children, {
1224
+ ...stepper,
1225
+ Field,
1226
+ FormStep,
1227
+ DisplayIf,
1228
+ ArrayField,
1229
+ ObjectField
1230
+ }) }) }) }) });
1231
+ });
1232
+ StepForm2.displayName = `Step${Form2.displayName || Form2.name}`;
1233
+ return StepForm2;
1181
1234
  }
1182
1235
  var Form2 = createForm();
1236
+ var StepForm = createStepForm();
1183
1237
 
1184
1238
  Object.defineProperty(exports, 'Controller', {
1185
1239
  enumerable: true,
@@ -1260,6 +1314,7 @@ exports.TextareaField = TextareaField;
1260
1314
  exports.WatchField = WatchField;
1261
1315
  exports.createField = createField;
1262
1316
  exports.createForm = createForm;
1317
+ exports.createStepForm = createStepForm;
1263
1318
  exports.defaultFieldTypes = defaultFieldTypes;
1264
1319
  exports.objectFieldResolver = objectFieldResolver;
1265
1320
  exports.useArrayField = useArrayField;