@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.mjs CHANGED
@@ -1,18 +1,18 @@
1
- import * as React13 from 'react';
2
- import React13__default, { useState } from 'react';
1
+ import * as React12 from 'react';
2
+ import React12__default, { useState, useMemo } from 'react';
3
3
  import { useFormContext as useFormContext$1, useForm, FormProvider as FormProvider$1, useFieldArray, useWatch, get, Controller } from 'react-hook-form';
4
4
  export { Controller, appendErrors, useController, useFieldArray, useForm, useFormState, useWatch } from 'react-hook-form';
5
5
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
6
  import { forwardRef, NumberInput as NumberInput$1, NumberInputField, NumberInputStepper, NumberIncrementStepper, NumberDecrementStepper, InputRightElement, Button, InputGroup, Input, RadioGroup, Stack, Radio, useMultiStyleConfig, useFormControlContext, MenuButton, omitThemingProps, Menu, chakra, MenuItemOption, Select as Select$1, Switch, Checkbox, HStack, PinInput, FormControl, FormLabel, Text, useControllableState, useFormControl, MenuList, MenuOptionGroup, Box, FormHelperText, FormErrorMessage, PinInputField, useTheme, SimpleGrid, useStyleConfig, useMergeRefs, Textarea } from '@chakra-ui/react';
7
- import { StepperProvider, ChevronUpIcon, ChevronDownIcon, useStepper, useStep, useStepperContext, StepperStep, StepperContainer, StepperSteps } from '@saas-ui/core';
7
+ import { ChevronUpIcon, ChevronDownIcon, useStepper, useStep, useStepperContext, StepsItem, Steps, StepperProvider } from '@saas-ui/core';
8
8
  import { ViewIcon, ViewOffIcon, MinusIcon, PlusIcon } from '@saas-ui/core/icons';
9
9
  import { dataAttr, cx, isFunction, runIfFn, callAllHandlers, get as get$1 } from '@chakra-ui/utils';
10
10
  import { createContext } from '@chakra-ui/react-utils';
11
11
 
12
12
  // src/form-context.tsx
13
- var FormContext = React13.createContext(null);
13
+ var FormContext = React12.createContext(null);
14
14
  var useFormContext = () => {
15
- const context = React13.useContext(FormContext);
15
+ const context = React12.useContext(FormContext);
16
16
  const hookContext = useFormContext$1();
17
17
  if (!context) {
18
18
  throw new Error("FormProvider must be used within a Form component");
@@ -26,7 +26,7 @@ var useFieldProps = (name) => {
26
26
  var _a;
27
27
  const parsedName = name == null ? void 0 : name.replace(/\.[0-9]/g, ".$");
28
28
  const context = useFormContext();
29
- return (_a = context == null ? void 0 : context.fields) == null ? void 0 : _a[parsedName];
29
+ return ((_a = context == null ? void 0 : context.fields) == null ? void 0 : _a[parsedName]) || {};
30
30
  };
31
31
  var FormProvider = (props) => {
32
32
  const { children, fieldResolver, schema, fields, ...rest } = props;
@@ -127,15 +127,15 @@ var PasswordInput = forwardRef(
127
127
  );
128
128
  PasswordInput.displayName = "PasswordInput";
129
129
  var mapNestedFields = (name, children) => {
130
- return React13.Children.map(children, (child) => {
131
- if (React13.isValidElement(child) && child.props.name) {
130
+ return React12.Children.map(children, (child) => {
131
+ if (React12.isValidElement(child) && child.props.name) {
132
132
  let childName = child.props.name;
133
133
  if (childName.includes(".")) {
134
134
  childName = childName.replace(/^.*\.(.*)/, "$1");
135
135
  } else if (childName.includes(".$")) {
136
136
  childName = childName.replace(/^.*\.\$(.*)/, "$1");
137
137
  }
138
- return React13.cloneElement(child, {
138
+ return React12.cloneElement(child, {
139
139
  ...child.props,
140
140
  name: `${name}.${childName}`
141
141
  });
@@ -195,14 +195,14 @@ var useSelect = (props) => {
195
195
  onChange
196
196
  });
197
197
  const controlProps = useFormControl({ name });
198
- const options = React13__default.useMemo(
198
+ const options = React12__default.useMemo(
199
199
  () => optionsProp && mapOptions(optionsProp),
200
200
  [optionsProp]
201
201
  );
202
202
  const handleChange = (value2) => {
203
203
  setCurrentValue(value2);
204
204
  };
205
- const getDisplayValue = React13__default.useCallback(
205
+ const getDisplayValue = React12__default.useCallback(
206
206
  (value2) => {
207
207
  if (!options) {
208
208
  return value2;
@@ -216,7 +216,7 @@ var useSelect = (props) => {
216
216
  },
217
217
  [options]
218
218
  );
219
- const displayValue = React13__default.useMemo(
219
+ const displayValue = React12__default.useMemo(
220
220
  () => currentValue ? (Array.isArray(currentValue) ? currentValue : [currentValue]).map(
221
221
  getDisplayValue
222
222
  ) : [],
@@ -280,7 +280,8 @@ var SelectButton = forwardRef(
280
280
  MenuButton,
281
281
  {
282
282
  as: Button,
283
- id: id || React13.useId(),
283
+ id: id || React12.useId(),
284
+ ...buttonStyles,
284
285
  ...rest,
285
286
  onFocus,
286
287
  onBlur,
@@ -291,7 +292,6 @@ var SelectButton = forwardRef(
291
292
  "data-required": dataAttr(isRequired),
292
293
  rightIcon,
293
294
  ref,
294
- sx: buttonStyles,
295
295
  children: renderValue(displayValue) || placeholder
296
296
  }
297
297
  );
@@ -553,7 +553,7 @@ var defaultFieldTypes = {
553
553
  pin: PinField,
554
554
  "native-select": NativeSelectField
555
555
  };
556
- var FieldsContext = React13__default.createContext(
556
+ var FieldsContext = React12__default.createContext(
557
557
  null
558
558
  );
559
559
  var FieldsProvider = (props) => {
@@ -561,11 +561,11 @@ var FieldsProvider = (props) => {
561
561
  return /* @__PURE__ */ jsx(FieldsContext.Provider, { value: fields, children: props.children });
562
562
  };
563
563
  var useField = (type) => {
564
- const context = React13__default.useContext(FieldsContext);
564
+ const context = React12__default.useContext(FieldsContext);
565
565
  return (context == null ? void 0 : context[type]) || InputField;
566
566
  };
567
567
  var defaultInputType = "text";
568
- var Field = React13.forwardRef(
568
+ var Field = React12.forwardRef(
569
569
  (props, ref) => {
570
570
  const { type = defaultInputType, name } = props;
571
571
  const overrides = useFieldProps(name);
@@ -592,8 +592,8 @@ var FormLayout = ({ children, ...props }) => {
592
592
  {
593
593
  ...gridProps,
594
594
  className: cx("sui-form__layout", props.className),
595
- children: React13.Children.map(children, (child) => {
596
- if (React13.isValidElement(child)) {
595
+ children: React12.Children.map(children, (child) => {
596
+ if (React12.isValidElement(child)) {
597
597
  return /* @__PURE__ */ jsx(FormLayoutItem, { children: child });
598
598
  }
599
599
  return child;
@@ -632,7 +632,7 @@ var useArrayField = ({
632
632
  var useArrayFieldRow = ({ index }) => {
633
633
  const { clearErrors } = useFormContext();
634
634
  const { name, remove, fields } = useArrayFieldContext();
635
- React13.useEffect(() => {
635
+ React12.useEffect(() => {
636
636
  clearErrors(name);
637
637
  }, []);
638
638
  return {
@@ -640,7 +640,7 @@ var useArrayFieldRow = ({ index }) => {
640
640
  isFirst: index === 0,
641
641
  isLast: index === fields.length - 1,
642
642
  name: `${name}.${index}`,
643
- remove: React13.useCallback(() => {
643
+ remove: React12.useCallback(() => {
644
644
  clearErrors(name);
645
645
  remove(index);
646
646
  }, [index])
@@ -735,7 +735,7 @@ var ArrayFieldRows = ({
735
735
  return children(fields);
736
736
  };
737
737
  ArrayFieldRows.displayName = "ArrayFieldRows";
738
- var ArrayFieldContainer = React13.forwardRef(
738
+ var ArrayFieldContainer = React12.forwardRef(
739
739
  ({
740
740
  name,
741
741
  defaultValue,
@@ -745,15 +745,16 @@ var ArrayFieldContainer = React13.forwardRef(
745
745
  children,
746
746
  ...fieldProps
747
747
  }, ref) => {
748
+ const overrides = useFieldProps(name);
748
749
  const context = useArrayField({
749
750
  name,
750
751
  defaultValue,
751
752
  keyName,
752
- min,
753
- max
753
+ min: min || (overrides == null ? void 0 : overrides.min),
754
+ max: max || (overrides == null ? void 0 : overrides.max)
754
755
  });
755
- React13.useImperativeHandle(ref, () => context, [ref, context]);
756
- return /* @__PURE__ */ jsx(ArrayFieldProvider, { value: context, children: /* @__PURE__ */ jsx(BaseField, { name, ...fieldProps, children }) });
756
+ React12.useImperativeHandle(ref, () => context, [ref, context]);
757
+ return /* @__PURE__ */ jsx(ArrayFieldProvider, { value: context, children: /* @__PURE__ */ jsx(BaseField, { name, ...fieldProps, ...overrides, children }) });
757
758
  }
758
759
  );
759
760
  ArrayFieldContainer.displayName = "ArrayFieldContainer";
@@ -762,10 +763,28 @@ var FormLegend = (props) => {
762
763
  return /* @__PURE__ */ jsx(FormLabel, { as: "legend", sx: styles, ...props });
763
764
  };
764
765
  var ObjectField = (props) => {
765
- const { name, label, hideLabel, children, columns, spacing, ...fieldProps } = props;
766
- return /* @__PURE__ */ jsxs(FormControl, { name, as: "fieldset", ...fieldProps, children: [
767
- /* @__PURE__ */ jsx(FormLegend, { display: hideLabel ? "none" : "block", children: label }),
768
- /* @__PURE__ */ jsx(FormLayout, { columns, gridGap: spacing, children: mapNestedFields(name, children) })
766
+ const {
767
+ name,
768
+ label,
769
+ hideLabel: hideLabelProp,
770
+ children,
771
+ columns: columnsProp,
772
+ spacing: spacingProp,
773
+ ...fieldProps
774
+ } = props;
775
+ const { hideLabel, columns, spacing, ...overrides } = useFieldProps(
776
+ name
777
+ );
778
+ return /* @__PURE__ */ jsxs(FormControl, { name, as: "fieldset", ...fieldProps, ...overrides, children: [
779
+ /* @__PURE__ */ jsx(FormLegend, { display: hideLabelProp || hideLabel ? "none" : "block", children: label }),
780
+ /* @__PURE__ */ jsx(
781
+ FormLayout,
782
+ {
783
+ columns: columnsProp || columns,
784
+ gridGap: spacingProp || spacing,
785
+ children: mapNestedFields(name, children)
786
+ }
787
+ )
769
788
  ] });
770
789
  };
771
790
  ObjectField.displayName = "ObjectField";
@@ -792,10 +811,10 @@ var AutoFields = ({
792
811
  const context = useFormContext();
793
812
  const schema = schemaProp || context.schema;
794
813
  const fieldResolver = fieldResolverProp || context.fieldResolver;
795
- const resolver = React13.useMemo(() => fieldResolver, [schema, fieldResolver]);
796
- const fields = React13.useMemo(() => resolver == null ? void 0 : resolver.getFields(), [resolver]);
814
+ const resolver = React12.useMemo(() => fieldResolver, [schema, fieldResolver]);
815
+ const fields = React12.useMemo(() => resolver == null ? void 0 : resolver.getFields(), [resolver]);
797
816
  const form = useFormContext();
798
- React13.useEffect(() => {
817
+ React12.useEffect(() => {
799
818
  var _a;
800
819
  if (focusFirstField && ((_a = fields == null ? void 0 : fields[0]) == null ? void 0 : _a.name)) {
801
820
  form.setFocus(fields[0].name);
@@ -870,100 +889,17 @@ var DisplayIf = ({
870
889
  return condition(value, context) ? children : null;
871
890
  };
872
891
  DisplayIf.displayName = "DisplayIf";
873
- var Form = forwardRef(
874
- (props, ref) => {
875
- const {
876
- mode = "all",
877
- resolver,
878
- fieldResolver,
879
- fields,
880
- reValidateMode,
881
- shouldFocusError,
882
- shouldUnregister,
883
- shouldUseNativeValidation,
884
- criteriaMode,
885
- delayError,
886
- schema,
887
- defaultValues,
888
- values,
889
- context,
890
- resetOptions,
891
- onChange,
892
- onSubmit,
893
- onError,
894
- formRef,
895
- children,
896
- ...rest
897
- } = props;
898
- const form = {
899
- mode,
900
- resolver,
901
- defaultValues,
902
- values,
903
- reValidateMode,
904
- shouldFocusError,
905
- shouldUnregister,
906
- shouldUseNativeValidation,
907
- criteriaMode,
908
- delayError,
909
- context,
910
- resetOptions
911
- };
912
- const methods = useForm(form);
913
- const { handleSubmit } = methods;
914
- React13.useImperativeHandle(formRef, () => methods, [formRef, methods]);
915
- React13.useEffect(() => {
916
- let subscription;
917
- if (onChange) {
918
- subscription = methods.watch(onChange);
919
- }
920
- return () => subscription == null ? void 0 : subscription.unsubscribe();
921
- }, [methods, onChange]);
922
- let _children = children;
923
- if (!_children && fieldResolver) {
924
- _children = /* @__PURE__ */ jsxs(FormLayout, { children: [
925
- /* @__PURE__ */ jsx(AutoFields, {}),
926
- /* @__PURE__ */ jsx(SubmitButton, { ...fields == null ? void 0 : fields.submit })
927
- ] });
928
- }
929
- return /* @__PURE__ */ jsx(
930
- FormProvider,
931
- {
932
- ...methods,
933
- schema,
934
- fieldResolver,
935
- fields,
936
- children: /* @__PURE__ */ jsx(
937
- chakra.form,
938
- {
939
- ref,
940
- onSubmit: handleSubmit(onSubmit, onError),
941
- ...rest,
942
- className: cx("sui-form", props.className),
943
- children: runIfFn(_children, {
944
- Field,
945
- DisplayIf,
946
- ArrayField,
947
- ObjectField,
948
- ...methods
949
- })
950
- }
951
- )
952
- }
953
- );
954
- }
955
- );
956
- Form.displayName = "Form";
957
892
  var [StepFormProvider, useStepFormContext] = createContext({
958
893
  name: "StepFormContext",
959
894
  errorMessage: "useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`"
960
895
  });
961
896
  function useStepForm(props) {
962
- const { onChange, ...rest } = props;
897
+ const { onChange, steps: stepsOptions, resolver, ...rest } = props;
963
898
  const stepper = useStepper(rest);
899
+ const [options, setOptions] = React12.useState(stepsOptions);
964
900
  const { activeStep, isLastStep, nextStep } = stepper;
965
- const [steps, updateSteps] = React13.useState({});
966
- const onSubmitStep = React13.useCallback(
901
+ const [steps, updateSteps] = React12.useState({});
902
+ const onSubmitStep = React12.useCallback(
967
903
  async (data) => {
968
904
  var _a, _b;
969
905
  try {
@@ -984,24 +920,31 @@ function useStepForm(props) {
984
920
  },
985
921
  [steps, activeStep, isLastStep]
986
922
  );
987
- const getFormProps = React13.useCallback(() => {
923
+ const getFormProps = React12.useCallback(() => {
988
924
  const step = steps[activeStep];
989
925
  return {
990
926
  onSubmit: onSubmitStep,
991
927
  schema: step == null ? void 0 : step.schema,
992
- resolver: step == null ? void 0 : step.resolver
928
+ resolver: (step == null ? void 0 : step.schema) ? (
929
+ /* @todo fix resolver type */
930
+ resolver == null ? void 0 : resolver(step.schema)
931
+ ) : void 0
993
932
  };
994
933
  }, [steps, onSubmitStep, activeStep]);
995
- const updateStep = React13.useCallback(
934
+ const updateStep = React12.useCallback(
996
935
  (step) => {
936
+ const stepOptions = options == null ? void 0 : options.find((s) => s.name === step.name);
997
937
  updateSteps((steps2) => {
998
938
  return {
999
939
  ...steps2,
1000
- [step.name]: step
940
+ [step.name]: {
941
+ ...step,
942
+ schema: stepOptions == null ? void 0 : stepOptions.schema
943
+ }
1001
944
  };
1002
945
  });
1003
946
  },
1004
- [steps]
947
+ [steps, options]
1005
948
  );
1006
949
  return {
1007
950
  getFormProps,
@@ -1014,7 +957,7 @@ function useFormStep(props) {
1014
957
  const { name, schema, resolver, onSubmit } = props;
1015
958
  const step = useStep({ name });
1016
959
  const { steps, updateStep } = useStepFormContext();
1017
- React13.useEffect(() => {
960
+ React12.useEffect(() => {
1018
961
  updateStep({ name, schema, resolver, onSubmit });
1019
962
  }, [name, schema]);
1020
963
  return {
@@ -1022,24 +965,25 @@ function useFormStep(props) {
1022
965
  ...steps[name] || { name, schema }
1023
966
  };
1024
967
  }
1025
- var StepForm = React13.forwardRef(
1026
- (props, ref) => {
1027
- const { children, ...rest } = props;
1028
- const stepper = useStepForm(props);
1029
- const { getFormProps, ...ctx } = stepper;
1030
- const context = React13.useMemo(() => ctx, [ctx]);
1031
- return /* @__PURE__ */ jsx(StepperProvider, { value: context, children: /* @__PURE__ */ jsx(StepFormProvider, { value: context, children: /* @__PURE__ */ jsx(Form, { ref, ...rest, ...getFormProps(), children: runIfFn(children, stepper) }) }) });
1032
- }
1033
- );
1034
968
  var FormStepper = (props) => {
1035
969
  const { activeIndex, setIndex } = useStepperContext();
1036
- const { children, orientation, variant, colorScheme, size, ...rest } = props;
1037
- const elements = React13.Children.map(children, (child) => {
1038
- if (React13.isValidElement(child) && (child == null ? void 0 : child.type) === FormStep) {
970
+ const {
971
+ children,
972
+ orientation,
973
+ variant,
974
+ colorScheme,
975
+ size,
976
+ onChange: onChangeProp,
977
+ render,
978
+ ...rest
979
+ } = props;
980
+ const elements = React12.Children.map(children, (child) => {
981
+ if (React12.isValidElement(child) && (child == null ? void 0 : child.type) === FormStep) {
1039
982
  const { isCompleted } = useFormStep(child.props);
1040
983
  return /* @__PURE__ */ jsx(
1041
- StepperStep,
984
+ StepsItem,
1042
985
  {
986
+ render,
1043
987
  name: child.props.name,
1044
988
  title: child.props.title,
1045
989
  isCompleted,
@@ -1050,11 +994,12 @@ var FormStepper = (props) => {
1050
994
  }
1051
995
  return child;
1052
996
  });
1053
- const onChange = React13.useCallback((i) => {
997
+ const onChange = React12.useCallback((i) => {
1054
998
  setIndex(i);
999
+ onChangeProp == null ? void 0 : onChangeProp(i);
1055
1000
  }, []);
1056
1001
  return /* @__PURE__ */ jsx(
1057
- StepperContainer,
1002
+ Steps,
1058
1003
  {
1059
1004
  orientation,
1060
1005
  step: activeIndex,
@@ -1062,13 +1007,13 @@ var FormStepper = (props) => {
1062
1007
  colorScheme,
1063
1008
  size,
1064
1009
  onChange,
1065
- children: /* @__PURE__ */ jsx(StepperSteps, { mb: "4", ...props, children: elements })
1010
+ children: elements
1066
1011
  }
1067
1012
  );
1068
1013
  };
1069
1014
  var FormStep = (props) => {
1070
- const { name, schema, resolver, children, className, onSubmit, ...rest } = props;
1071
- const step = useFormStep({ name, schema, resolver, onSubmit });
1015
+ const { name, children, className, onSubmit, ...rest } = props;
1016
+ const step = useFormStep({ name, onSubmit });
1072
1017
  const { isActive } = step;
1073
1018
  return isActive ? /* @__PURE__ */ jsx(chakra.div, { ...rest, className: cx("sui-form__step", className), children }) : null;
1074
1019
  };
@@ -1079,7 +1024,7 @@ var PrevButton = (props) => {
1079
1024
  Button,
1080
1025
  {
1081
1026
  isDisabled: isFirstStep || isCompleted,
1082
- label: "Back",
1027
+ children: "Back",
1083
1028
  ...props,
1084
1029
  className: cx("sui-form__prev-button", props.className),
1085
1030
  onClick: callAllHandlers(props.onClick, prevStep)
@@ -1138,12 +1083,96 @@ var WatchField = (props) => {
1138
1083
  });
1139
1084
  return props.children(field, form) || null;
1140
1085
  };
1086
+ var Form = forwardRef(
1087
+ (props, ref) => {
1088
+ const {
1089
+ mode = "all",
1090
+ resolver,
1091
+ fieldResolver,
1092
+ fields,
1093
+ reValidateMode,
1094
+ shouldFocusError,
1095
+ shouldUnregister,
1096
+ shouldUseNativeValidation,
1097
+ criteriaMode,
1098
+ delayError,
1099
+ schema,
1100
+ defaultValues,
1101
+ values,
1102
+ context,
1103
+ resetOptions,
1104
+ onChange,
1105
+ onSubmit,
1106
+ onError,
1107
+ formRef,
1108
+ children,
1109
+ ...rest
1110
+ } = props;
1111
+ const form = {
1112
+ mode,
1113
+ resolver,
1114
+ defaultValues,
1115
+ values,
1116
+ reValidateMode,
1117
+ shouldFocusError,
1118
+ shouldUnregister,
1119
+ shouldUseNativeValidation,
1120
+ criteriaMode,
1121
+ delayError,
1122
+ context,
1123
+ resetOptions
1124
+ };
1125
+ const methods = useForm(form);
1126
+ const { handleSubmit } = methods;
1127
+ React12.useImperativeHandle(formRef, () => methods, [formRef, methods]);
1128
+ React12.useEffect(() => {
1129
+ let subscription;
1130
+ if (onChange) {
1131
+ subscription = methods.watch(onChange);
1132
+ }
1133
+ return () => subscription == null ? void 0 : subscription.unsubscribe();
1134
+ }, [methods, onChange]);
1135
+ let _children = children;
1136
+ if (!_children && fieldResolver) {
1137
+ _children = /* @__PURE__ */ jsxs(FormLayout, { children: [
1138
+ /* @__PURE__ */ jsx(AutoFields, {}),
1139
+ /* @__PURE__ */ jsx(SubmitButton, { ...fields == null ? void 0 : fields.submit })
1140
+ ] });
1141
+ }
1142
+ return /* @__PURE__ */ jsx(
1143
+ FormProvider,
1144
+ {
1145
+ ...methods,
1146
+ schema,
1147
+ fieldResolver,
1148
+ fields,
1149
+ children: /* @__PURE__ */ jsx(
1150
+ chakra.form,
1151
+ {
1152
+ ref,
1153
+ onSubmit: handleSubmit(onSubmit, onError),
1154
+ ...rest,
1155
+ className: cx("sui-form", props.className),
1156
+ children: runIfFn(_children, {
1157
+ Field,
1158
+ DisplayIf,
1159
+ ArrayField,
1160
+ ObjectField,
1161
+ ...methods
1162
+ })
1163
+ }
1164
+ )
1165
+ }
1166
+ );
1167
+ }
1168
+ );
1169
+ Form.displayName = "Form";
1141
1170
  function createForm({
1142
1171
  resolver,
1143
1172
  fieldResolver = objectFieldResolver,
1144
1173
  fields
1145
1174
  } = {}) {
1146
- const CreateForm = forwardRef(
1175
+ const DefaultForm = forwardRef(
1147
1176
  (props, ref) => {
1148
1177
  const { schema, ...rest } = props;
1149
1178
  return /* @__PURE__ */ jsx(FieldsProvider, { value: fields || {}, children: /* @__PURE__ */ jsx(
@@ -1157,10 +1186,35 @@ function createForm({
1157
1186
  ) });
1158
1187
  }
1159
1188
  );
1160
- return CreateForm;
1189
+ DefaultForm.displayName = "Form";
1190
+ DefaultForm.id = "Form";
1191
+ return DefaultForm;
1192
+ }
1193
+ function createStepForm({ fields, resolver, fieldResolver } = {}) {
1194
+ const StepForm2 = forwardRef((props, ref) => {
1195
+ const { children, steps, ...rest } = props;
1196
+ const stepper = useStepForm({
1197
+ resolver,
1198
+ fieldResolver,
1199
+ ...props
1200
+ });
1201
+ const { getFormProps, ...ctx } = stepper;
1202
+ const context = useMemo(() => ctx, [ctx]);
1203
+ return /* @__PURE__ */ jsx(StepperProvider, { value: context, children: /* @__PURE__ */ jsx(StepFormProvider, { value: context, children: /* @__PURE__ */ jsx(FieldsProvider, { value: fields || {}, children: /* @__PURE__ */ jsx(Form2, { ref, ...rest, ...getFormProps(), children: runIfFn(children, {
1204
+ ...stepper,
1205
+ Field,
1206
+ FormStep,
1207
+ DisplayIf,
1208
+ ArrayField,
1209
+ ObjectField
1210
+ }) }) }) }) });
1211
+ });
1212
+ StepForm2.displayName = `Step${Form2.displayName || Form2.name}`;
1213
+ return StepForm2;
1161
1214
  }
1162
1215
  var Form2 = createForm();
1216
+ var StepForm = createStepForm();
1163
1217
 
1164
- export { ArrayField, ArrayFieldAddButton, ArrayFieldContainer, ArrayFieldProvider, ArrayFieldRemoveButton, ArrayFieldRow, ArrayFieldRowContainer, ArrayFieldRowFields, ArrayFieldRowProvider, ArrayFieldRows, AutoFields, BaseField, Form as BaseForm, CheckboxField, DisplayField, DisplayIf, Field, FieldsProvider, Form2 as Form, FormLayout, FormLegend, FormProvider, FormStep, FormStepper, FormValue, InputField, InputRightButton, NativeSelect, NativeSelectField, NextButton, NumberInputField2 as NumberInputField, ObjectField, PasswordInput, PasswordInputField, PinField, PrevButton, RadioField, RadioInput, Select, SelectButton, SelectField, SelectList, SelectOption, StepForm, StepFormProvider, SubmitButton, SwitchField, TextareaField, WatchField, createField, createForm, defaultFieldTypes, objectFieldResolver, useArrayField, useArrayFieldAddButton, useArrayFieldContext, useArrayFieldRemoveButton, useArrayFieldRow, useArrayFieldRowContext, useField, useFormContext, useFormStep, useStepForm, useStepFormContext };
1218
+ export { ArrayField, ArrayFieldAddButton, ArrayFieldContainer, ArrayFieldProvider, ArrayFieldRemoveButton, ArrayFieldRow, ArrayFieldRowContainer, ArrayFieldRowFields, ArrayFieldRowProvider, ArrayFieldRows, AutoFields, BaseField, Form as BaseForm, CheckboxField, DisplayField, DisplayIf, Field, FieldsProvider, Form2 as Form, FormLayout, FormLegend, FormProvider, FormStep, FormStepper, FormValue, InputField, InputRightButton, NativeSelect, NativeSelectField, NextButton, NumberInputField2 as NumberInputField, ObjectField, PasswordInput, PasswordInputField, PinField, PrevButton, RadioField, RadioInput, Select, SelectButton, SelectField, SelectList, SelectOption, StepForm, StepFormProvider, SubmitButton, SwitchField, TextareaField, WatchField, createField, createForm, createStepForm, defaultFieldTypes, objectFieldResolver, useArrayField, useArrayFieldAddButton, useArrayFieldContext, useArrayFieldRemoveButton, useArrayFieldRow, useArrayFieldRowContext, useField, useFormContext, useFormStep, useStepForm, useStepFormContext };
1165
1219
  //# sourceMappingURL=out.js.map
1166
1220
  //# sourceMappingURL=index.mjs.map