@saas-ui/forms 2.0.0-next.1 → 2.0.0-next.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +53 -6
  3. package/dist/ajv/index.d.ts +359 -11
  4. package/dist/ajv/index.js +7 -9
  5. package/dist/ajv/index.js.map +1 -1
  6. package/dist/ajv/index.mjs +7 -10
  7. package/dist/ajv/index.mjs.map +1 -1
  8. package/dist/index.d.ts +448 -247
  9. package/dist/index.js +708 -682
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +688 -662
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/yup/index.d.ts +581 -21
  14. package/dist/yup/index.js +6 -10
  15. package/dist/yup/index.js.map +1 -1
  16. package/dist/yup/index.mjs +4 -8
  17. package/dist/yup/index.mjs.map +1 -1
  18. package/dist/zod/index.d.ts +581 -11
  19. package/dist/zod/index.js +5 -0
  20. package/dist/zod/index.js.map +1 -1
  21. package/dist/zod/index.mjs +5 -1
  22. package/dist/zod/index.mjs.map +1 -1
  23. package/package.json +19 -10
  24. package/src/array-field.tsx +82 -45
  25. package/src/auto-form.tsx +7 -3
  26. package/src/base-field.tsx +54 -0
  27. package/src/create-field.tsx +144 -0
  28. package/src/create-form.tsx +54 -0
  29. package/src/default-fields.tsx +163 -0
  30. package/src/display-field.tsx +9 -11
  31. package/src/display-if.tsx +20 -13
  32. package/src/field-resolver.ts +10 -8
  33. package/src/field.tsx +18 -445
  34. package/src/fields-context.tsx +23 -0
  35. package/src/fields.tsx +34 -21
  36. package/src/form-context.tsx +84 -0
  37. package/src/form.tsx +72 -52
  38. package/src/index.ts +44 -4
  39. package/src/input-right-button/input-right-button.stories.tsx +2 -2
  40. package/src/input-right-button/input-right-button.tsx +0 -2
  41. package/src/layout.tsx +16 -11
  42. package/src/number-input/number-input.stories.tsx +3 -3
  43. package/src/number-input/number-input.tsx +9 -5
  44. package/src/object-field.tsx +13 -8
  45. package/src/password-input/password-input.stories.tsx +23 -2
  46. package/src/password-input/password-input.tsx +6 -6
  47. package/src/pin-input/pin-input.tsx +1 -5
  48. package/src/radio/radio-input.stories.tsx +1 -1
  49. package/src/radio/radio-input.tsx +12 -10
  50. package/src/select/native-select.tsx +1 -4
  51. package/src/select/select-context.tsx +130 -0
  52. package/src/select/select.stories.tsx +117 -86
  53. package/src/select/select.test.tsx +1 -1
  54. package/src/select/select.tsx +162 -146
  55. package/src/step-form.tsx +29 -11
  56. package/src/submit-button.tsx +5 -1
  57. package/src/types.ts +144 -0
  58. package/src/use-array-field.tsx +9 -3
  59. package/src/utils.ts +23 -1
  60. package/src/watch-field.tsx +2 -6
  61. /package/src/radio/{radio.test.tsx → radio-input.test.tsx} +0 -0
package/dist/index.mjs CHANGED
@@ -1,75 +1,80 @@
1
- import * as React8 from 'react';
2
- import React8__default, { useState } from 'react';
3
- import { __DEV__, cx, runIfFn, callAllHandlers, get as get$1 } from '@chakra-ui/utils';
4
- import { useForm, FormProvider, useFormContext, Controller, useFieldArray, useWatch, get } from 'react-hook-form';
5
- export { Controller, FormProvider, appendErrors, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from 'react-hook-form';
6
- import { forwardRef, NumberInput as NumberInput$1, NumberInputField, NumberInputStepper, NumberIncrementStepper, NumberDecrementStepper, InputRightElement, Button, InputGroup, Input, RadioGroup, Stack, Radio, useMultiStyleConfig, MenuButton, omitThemingProps, useFormControl, Menu, chakra, MenuList, MenuOptionGroup, MenuItemOption, Select as Select$1, Switch, Checkbox, HStack, PinInput, FormControl, FormLabel, Text, Box, FormHelperText, FormErrorMessage, useMergeRefs, Textarea, PinInputField, useTheme, SimpleGrid, useStyleConfig } from '@chakra-ui/react';
7
- import { ViewIcon, ViewOffIcon, ChevronDownIcon, MinusIcon, AddIcon } from '@chakra-ui/icons';
1
+ import * as React13 from 'react';
2
+ import React13__default, { useState } from 'react';
3
+ import { useFormContext as useFormContext$1, useForm, FormProvider as FormProvider$1, useFieldArray, useWatch, get, Controller } from 'react-hook-form';
4
+ export { Controller, appendErrors, useController, useFieldArray, useForm, useFormState, useWatch } from 'react-hook-form';
5
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
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';
8
+ import { ViewIcon, ViewOffIcon, MinusIcon, PlusIcon } from '@saas-ui/core/icons';
9
+ import { dataAttr, cx, isFunction, runIfFn, callAllHandlers, get as get$1 } from '@chakra-ui/utils';
8
10
  import { createContext } from '@chakra-ui/react-utils';
9
- import { StepperProvider, useStepper, useStep, useStepperContext, StepperStep, StepperContainer, StepperSteps } from '@saas-ui/core';
10
11
 
11
- // src/display-field.tsx
12
+ // src/form-context.tsx
13
+ var FormContext = React13.createContext(null);
14
+ var useFormContext = () => {
15
+ const context = React13.useContext(FormContext);
16
+ const hookContext = useFormContext$1();
17
+ if (!context) {
18
+ throw new Error("FormProvider must be used within a Form component");
19
+ }
20
+ return {
21
+ ...hookContext,
22
+ ...context
23
+ };
24
+ };
25
+ var useFieldProps = (name) => {
26
+ var _a;
27
+ const parsedName = name == null ? void 0 : name.replace(/\.[0-9]/g, ".$");
28
+ const context = useFormContext();
29
+ return (_a = context == null ? void 0 : context.fields) == null ? void 0 : _a[parsedName];
30
+ };
31
+ var FormProvider = (props) => {
32
+ const { children, fieldResolver, schema, fields, ...rest } = props;
33
+ return /* @__PURE__ */ jsx(FormProvider$1, { ...rest, children: /* @__PURE__ */ jsx(FormContext.Provider, { value: { fieldResolver, schema, fields }, children }) });
34
+ };
12
35
  var DisplayField = ({
13
36
  name,
14
37
  label,
15
38
  placeholder,
16
39
  ...props
17
40
  }) => {
18
- return /* @__PURE__ */ React8.createElement(FormControl, {
19
- ...props
20
- }, label ? /* @__PURE__ */ React8.createElement(FormLabel, {
21
- htmlFor: name
22
- }, label) : null, /* @__PURE__ */ React8.createElement(Text, {
23
- fontSize: "md"
24
- }, /* @__PURE__ */ React8.createElement(FormValue, {
25
- name
26
- })));
41
+ return /* @__PURE__ */ jsxs(FormControl, { ...props, children: [
42
+ label ? /* @__PURE__ */ jsx(FormLabel, { htmlFor: name, children: label }) : null,
43
+ /* @__PURE__ */ jsx(Text, { fontSize: "md", children: /* @__PURE__ */ jsx(FormValue, { name }) })
44
+ ] });
27
45
  };
28
- if (__DEV__) {
29
- DisplayField.displayName = "DisplayField";
30
- }
46
+ DisplayField.displayName = "DisplayField";
31
47
  var FormValue = ({ name }) => {
32
48
  const { getValues } = useFormContext();
33
49
  return getValues(name) || null;
34
50
  };
35
- if (__DEV__) {
36
- FormValue.displayName = "FormValue";
37
- }
51
+ FormValue.displayName = "FormValue";
38
52
  var NumberInput = forwardRef((props, ref) => {
39
- const { hideStepper, incrementIcon, decrementIcon, ...rest } = props;
40
- return /* @__PURE__ */ React8.createElement(NumberInput$1, {
41
- ...rest,
42
- ref
43
- }, /* @__PURE__ */ React8.createElement(NumberInputField, null), !hideStepper && /* @__PURE__ */ React8.createElement(NumberInputStepper, null, /* @__PURE__ */ React8.createElement(NumberIncrementStepper, {
44
- children: incrementIcon
45
- }), /* @__PURE__ */ React8.createElement(NumberDecrementStepper, {
46
- children: decrementIcon
47
- })));
53
+ const {
54
+ hideStepper,
55
+ incrementIcon = /* @__PURE__ */ jsx(ChevronUpIcon, {}),
56
+ decrementIcon = /* @__PURE__ */ jsx(ChevronDownIcon, {}),
57
+ ...rest
58
+ } = props;
59
+ return /* @__PURE__ */ jsxs(NumberInput$1, { ...rest, ref, children: [
60
+ /* @__PURE__ */ jsx(NumberInputField, {}),
61
+ !hideStepper && /* @__PURE__ */ jsxs(NumberInputStepper, { children: [
62
+ /* @__PURE__ */ jsx(NumberIncrementStepper, { children: incrementIcon }),
63
+ /* @__PURE__ */ jsx(NumberDecrementStepper, { children: decrementIcon })
64
+ ] })
65
+ ] });
48
66
  });
49
67
  NumberInput.defaultProps = {
50
68
  hideStepper: false
51
69
  };
52
- if (__DEV__) {
53
- NumberInput.displayName = "NumberInput";
54
- }
70
+ NumberInput.displayName = "NumberInput";
55
71
  var InputRightButton = forwardRef(
56
72
  (props, ref) => {
57
- return /* @__PURE__ */ React8.createElement(InputRightElement, {
58
- w: "auto",
59
- px: "1",
60
- py: "1",
61
- alignItems: "stretch"
62
- }, /* @__PURE__ */ React8.createElement(Button, {
63
- ref,
64
- height: "auto",
65
- ...props
66
- }));
73
+ return /* @__PURE__ */ jsx(InputRightElement, { w: "auto", px: "1", py: "1", alignItems: "stretch", children: /* @__PURE__ */ jsx(Button, { ref, height: "auto", ...props }) });
67
74
  }
68
75
  );
69
76
  InputRightButton.id = "InputRightElement";
70
77
  InputRightButton.displayName = "InputRightButton";
71
-
72
- // src/password-input/password-input.tsx
73
78
  var PasswordInput = forwardRef(
74
79
  (props, ref) => {
75
80
  const {
@@ -80,6 +85,7 @@ var PasswordInput = forwardRef(
80
85
  width,
81
86
  size,
82
87
  variant,
88
+ leftAddon,
83
89
  ...inputProps
84
90
  } = props;
85
91
  const [show, setShow] = useState(false);
@@ -87,186 +93,260 @@ var PasswordInput = forwardRef(
87
93
  const label = show ? "Hide password" : "Show password";
88
94
  let icon;
89
95
  if (show) {
90
- icon = viewIcon || /* @__PURE__ */ React8__default.createElement(ViewIcon, null);
96
+ icon = viewIcon || /* @__PURE__ */ jsx(ViewIcon, {});
91
97
  } else {
92
- icon = viewOffIcon || /* @__PURE__ */ React8__default.createElement(ViewOffIcon, null);
98
+ icon = viewOffIcon || /* @__PURE__ */ jsx(ViewOffIcon, {});
93
99
  }
94
100
  const groupProps = {
95
101
  width: w || width,
96
102
  size,
97
103
  variant
98
104
  };
99
- return /* @__PURE__ */ React8__default.createElement(InputGroup, {
100
- ...groupProps
101
- }, /* @__PURE__ */ React8__default.createElement(Input, {
102
- ...inputProps,
103
- ref,
104
- type: show ? "text" : "password",
105
- autoComplete: show ? "off" : autoComplete
106
- }), /* @__PURE__ */ React8__default.createElement(InputRightButton, {
107
- onClick: handleClick,
108
- "aria-label": label,
109
- variant: "ghost"
110
- }, icon));
105
+ return /* @__PURE__ */ jsxs(InputGroup, { ...groupProps, children: [
106
+ leftAddon,
107
+ /* @__PURE__ */ jsx(
108
+ Input,
109
+ {
110
+ ...inputProps,
111
+ ref,
112
+ type: show ? "text" : "password",
113
+ autoComplete: show ? "off" : autoComplete
114
+ }
115
+ ),
116
+ /* @__PURE__ */ jsx(
117
+ InputRightButton,
118
+ {
119
+ onClick: handleClick,
120
+ "aria-label": label,
121
+ variant: "ghost",
122
+ children: icon
123
+ }
124
+ )
125
+ ] });
111
126
  }
112
127
  );
113
- if (__DEV__) {
114
- PasswordInput.displayName = "PasswordInput";
115
- }
128
+ PasswordInput.displayName = "PasswordInput";
129
+ var mapNestedFields = (name, children) => {
130
+ return React13.Children.map(children, (child) => {
131
+ if (React13.isValidElement(child) && child.props.name) {
132
+ let childName = child.props.name;
133
+ if (childName.includes(".")) {
134
+ childName = childName.replace(/^.*\.(.*)/, "$1");
135
+ } else if (childName.includes(".$")) {
136
+ childName = childName.replace(/^.*\.\$(.*)/, "$1");
137
+ }
138
+ return React13.cloneElement(child, {
139
+ ...child.props,
140
+ name: `${name}.${childName}`
141
+ });
142
+ }
143
+ return child;
144
+ });
145
+ };
146
+ var mapOptions = (options) => {
147
+ return options.map((option) => {
148
+ if (typeof option === "string") {
149
+ return {
150
+ label: option,
151
+ value: option
152
+ };
153
+ }
154
+ return option;
155
+ });
156
+ };
116
157
  var RadioInput = forwardRef(
117
- ({ options, spacing, direction, ...props }, ref) => {
158
+ ({ options: optionsProp, spacing, direction, ...props }, ref) => {
118
159
  const { onBlur, onChange, ...groupProps } = props;
119
- return /* @__PURE__ */ React8.createElement(RadioGroup, {
120
- onChange,
121
- ...groupProps
122
- }, /* @__PURE__ */ React8.createElement(Stack, {
123
- spacing,
124
- direction
125
- }, options.map(({ value, label, ...radioProps }, i) => {
126
- return /* @__PURE__ */ React8.createElement(Radio, {
127
- key: i,
128
- onBlur,
129
- value,
130
- ref,
131
- ...radioProps
132
- }, label || value);
133
- })));
160
+ const options = mapOptions(optionsProp);
161
+ return /* @__PURE__ */ jsx(RadioGroup, { onChange, ...groupProps, children: /* @__PURE__ */ jsx(Stack, { spacing, direction, children: options.map(({ value, label, ...radioProps }, i) => {
162
+ return /* @__PURE__ */ jsx(
163
+ Radio,
164
+ {
165
+ onBlur,
166
+ value,
167
+ ref,
168
+ ...radioProps,
169
+ children: label || value
170
+ },
171
+ i
172
+ );
173
+ }) }) });
134
174
  }
135
175
  );
136
- if (__DEV__) {
137
- RadioInput.displayName = "RadioInput";
138
- }
139
- var SelectButton = forwardRef((props, ref) => {
140
- const styles = useMultiStyleConfig("Input", props);
141
- const focusStyles = styles.field._focusVisible;
142
- const height = styles.field.h || styles.field.height;
143
- const buttonStyles = {
144
- fontWeight: "normal",
145
- textAlign: "left",
146
- color: "inherit",
147
- _active: {
148
- bg: "transparent"
149
- },
150
- minH: height,
151
- _focus: focusStyles,
152
- _expanded: focusStyles,
153
- ...styles.field,
154
- h: "auto"
155
- };
156
- return /* @__PURE__ */ React8.createElement(MenuButton, {
157
- as: Button,
158
- ...props,
159
- ref,
160
- sx: buttonStyles
161
- });
176
+ RadioInput.displayName = "RadioInput";
177
+ var [SelectProvider, useSelectContext] = createContext({
178
+ strict: true
162
179
  });
163
- if (__DEV__) {
164
- SelectButton.displayName = "SelectButton";
165
- }
166
- var Select = forwardRef((props, ref) => {
180
+ var useSelect = (props) => {
167
181
  const {
168
182
  name,
169
- options,
170
- children,
171
- onChange,
172
- defaultValue,
173
183
  value,
184
+ defaultValue,
185
+ onChange,
186
+ multiple,
174
187
  placeholder,
188
+ options: optionsProp,
175
189
  isDisabled,
176
- leftIcon,
177
- rightIcon = /* @__PURE__ */ React8.createElement(ChevronDownIcon, null),
178
- multiple,
179
- size,
180
- variant,
181
- menuListProps,
182
- renderValue = (value2) => value2 == null ? void 0 : value2.join(", "),
183
- ...rest
190
+ renderValue = (value2) => typeof value2 === "string" ? value2 : value2 == null ? void 0 : value2.join(", ")
184
191
  } = props;
185
- const menuProps = omitThemingProps(rest);
186
- const [currentValue, setCurrentValue] = React8.useState(value || defaultValue);
192
+ const [currentValue, setCurrentValue] = useControllableState({
193
+ value,
194
+ defaultValue,
195
+ onChange
196
+ });
187
197
  const controlProps = useFormControl({ name });
198
+ const options = React13__default.useMemo(
199
+ () => optionsProp && mapOptions(optionsProp),
200
+ [optionsProp]
201
+ );
188
202
  const handleChange = (value2) => {
189
203
  setCurrentValue(value2);
190
- onChange == null ? void 0 : onChange(value2);
191
204
  };
192
- const buttonProps = {
193
- isDisabled,
194
- leftIcon,
195
- rightIcon,
196
- size,
197
- variant
198
- };
199
- const getDisplayValue = React8.useCallback(
205
+ const getDisplayValue = React13__default.useCallback(
200
206
  (value2) => {
201
207
  if (!options) {
202
208
  return value2;
203
209
  }
204
210
  for (const option of options) {
205
- if (option.label && option.value === value2) {
206
- return option.label;
211
+ if (option.value === value2) {
212
+ return option.label || option.value;
207
213
  }
208
214
  }
209
215
  return value2;
210
216
  },
211
217
  [options]
212
218
  );
213
- const displayValue = currentValue ? (Array.isArray(currentValue) ? currentValue : [currentValue]).map(
214
- getDisplayValue
215
- ) : [];
216
- return /* @__PURE__ */ React8.createElement(Menu, {
217
- ...menuProps,
218
- closeOnSelect: !multiple
219
- }, /* @__PURE__ */ React8.createElement(chakra.div, {
220
- className: cx("sui-select")
221
- }, /* @__PURE__ */ React8.createElement(SelectButton, {
222
- ref,
223
- ...buttonProps
224
- }, renderValue(displayValue) || placeholder), /* @__PURE__ */ React8.createElement(MenuList, {
225
- maxH: "60vh",
226
- overflowY: "auto",
227
- ...menuListProps
228
- }, /* @__PURE__ */ React8.createElement(MenuOptionGroup, {
229
- defaultValue: defaultValue || value,
230
- onChange: handleChange,
231
- type: multiple ? "checkbox" : "radio"
232
- }, options ? options.map(({ value: value2, label, ...rest2 }, i) => /* @__PURE__ */ React8.createElement(MenuItemOption, {
233
- key: i,
234
- value: value2,
235
- ...rest2
236
- }, label || value2)) : children)), /* @__PURE__ */ React8.createElement(chakra.input, {
237
- ...controlProps,
238
- name,
239
- type: "hidden",
219
+ const displayValue = React13__default.useMemo(
220
+ () => currentValue ? (Array.isArray(currentValue) ? currentValue : [currentValue]).map(
221
+ getDisplayValue
222
+ ) : [],
223
+ [currentValue, getDisplayValue]
224
+ );
225
+ return {
226
+ defaultValue,
240
227
  value: currentValue,
241
- className: "saas-select__input"
242
- })));
228
+ displayValue,
229
+ renderValue,
230
+ onChange: handleChange,
231
+ options,
232
+ multiple,
233
+ controlProps,
234
+ placeholder,
235
+ isDisabled
236
+ };
237
+ };
238
+ var SelectButton = forwardRef(
239
+ (props, ref) => {
240
+ var _a, _b, _c, _d, _e;
241
+ const styles = useMultiStyleConfig("SuiSelect", props);
242
+ const {
243
+ displayValue,
244
+ renderValue,
245
+ placeholder,
246
+ isDisabled: isSelectDisabled
247
+ } = useSelectContext();
248
+ const context = useFormControlContext();
249
+ const {
250
+ isInvalid,
251
+ isReadOnly,
252
+ isDisabled,
253
+ isFocused,
254
+ isRequired,
255
+ id,
256
+ onBlur,
257
+ onFocus
258
+ } = context || {};
259
+ const { rightIcon = /* @__PURE__ */ jsx(ChevronDownIcon, {}), ...rest } = props;
260
+ const focusStyles = (_a = styles.field) == null ? void 0 : _a._focusVisible;
261
+ const readOnlyStyles = (_b = styles.field) == null ? void 0 : _b._readOnly;
262
+ const invalid = (_c = styles.field) == null ? void 0 : _c._invalid;
263
+ const height = ((_d = styles.field) == null ? void 0 : _d.h) || ((_e = styles.field) == null ? void 0 : _e.height);
264
+ const buttonStyles = {
265
+ fontWeight: "normal",
266
+ textAlign: "left",
267
+ color: "inherit",
268
+ _active: {
269
+ bg: "transparent"
270
+ },
271
+ minH: height,
272
+ _focus: focusStyles,
273
+ _expanded: focusStyles,
274
+ _readOnly: readOnlyStyles,
275
+ _invalid: invalid,
276
+ ...styles.field,
277
+ h: "auto"
278
+ };
279
+ return /* @__PURE__ */ jsx(
280
+ MenuButton,
281
+ {
282
+ as: Button,
283
+ id: id || React13.useId(),
284
+ ...rest,
285
+ onFocus,
286
+ onBlur,
287
+ isDisabled: isDisabled || isSelectDisabled,
288
+ "data-invalid": dataAttr(isInvalid),
289
+ "data-read-only": dataAttr(isReadOnly),
290
+ "data-focus": dataAttr(isFocused),
291
+ "data-required": dataAttr(isRequired),
292
+ rightIcon,
293
+ ref,
294
+ sx: buttonStyles,
295
+ children: renderValue(displayValue) || placeholder
296
+ }
297
+ );
298
+ }
299
+ );
300
+ SelectButton.displayName = "SelectButton";
301
+ var Select = forwardRef((props, ref) => {
302
+ const { name, children, isDisabled, multiple, ...rest } = props;
303
+ const menuProps = omitThemingProps(rest);
304
+ const context = useSelect(props);
305
+ const { value, controlProps } = context;
306
+ return /* @__PURE__ */ jsx(SelectProvider, { value: context, children: /* @__PURE__ */ jsx(Menu, { ...menuProps, closeOnSelect: !multiple, children: /* @__PURE__ */ jsxs(chakra.div, { className: cx("sui-select"), children: [
307
+ children,
308
+ /* @__PURE__ */ jsx(
309
+ chakra.input,
310
+ {
311
+ ...controlProps,
312
+ ref,
313
+ name,
314
+ type: "hidden",
315
+ value: value || "",
316
+ className: "saas-select__input"
317
+ }
318
+ )
319
+ ] }) }) });
243
320
  });
244
- if (__DEV__) {
245
- Select.displayName = "Select";
246
- }
321
+ var SelectList = (props) => {
322
+ const { defaultValue, value, options, multiple, onChange } = useSelectContext();
323
+ return /* @__PURE__ */ jsx(MenuList, { maxH: "100vh", overflowY: "auto", ...props, children: /* @__PURE__ */ jsx(
324
+ MenuOptionGroup,
325
+ {
326
+ defaultValue: defaultValue || value,
327
+ value,
328
+ onChange,
329
+ type: multiple ? "checkbox" : "radio",
330
+ children: options ? options.map(({ value: value2, label, ...rest }, i) => /* @__PURE__ */ jsx(SelectOption, { value: value2, ...rest, children: label || value2 }, i)) : props.children
331
+ }
332
+ ) });
333
+ };
334
+ Select.displayName = "Select";
335
+ var SelectOption = forwardRef(
336
+ (props, ref) => {
337
+ return /* @__PURE__ */ jsx(MenuItemOption, { ref, ...props });
338
+ }
339
+ );
340
+ SelectOption.id = "MenuItemOption";
341
+ SelectOption.displayName = "SelectOption";
247
342
  var NativeSelect = forwardRef(
248
343
  ({ options, children, ...props }, ref) => {
249
- return /* @__PURE__ */ React8.createElement(Select$1, {
250
- ref,
251
- ...props
252
- }, children || (options == null ? void 0 : options.map(({ value, label }) => {
253
- return /* @__PURE__ */ React8.createElement("option", {
254
- key: value,
255
- value
256
- }, label || value);
257
- })));
344
+ return /* @__PURE__ */ jsx(Select$1, { ref, ...props, children: children || (options == null ? void 0 : options.map(({ value, label }) => {
345
+ return /* @__PURE__ */ jsx("option", { value, children: label || value }, value);
346
+ })) });
258
347
  }
259
348
  );
260
- if (__DEV__) {
261
- NativeSelect.displayName = "NativeSelect";
262
- }
263
-
264
- // src/field.tsx
265
- var inputTypes = {};
266
- var defaultInputType = "text";
267
- var getInput = (type) => {
268
- return inputTypes[type] || inputTypes[defaultInputType];
269
- };
349
+ NativeSelect.displayName = "NativeSelect";
270
350
  var getError = (name, formState) => {
271
351
  return get(formState.errors, name);
272
352
  };
@@ -274,25 +354,17 @@ var BaseField = (props) => {
274
354
  const { name, label, help, hideLabel, children, ...controlProps } = props;
275
355
  const { formState } = useFormContext();
276
356
  const error = getError(name, formState);
277
- return /* @__PURE__ */ React8.createElement(FormControl, {
278
- ...controlProps,
279
- isInvalid: !!error
280
- }, label && !hideLabel ? /* @__PURE__ */ React8.createElement(FormLabel, null, label) : null, /* @__PURE__ */ React8.createElement(Box, null, children, help && !(error == null ? void 0 : error.message) ? /* @__PURE__ */ React8.createElement(FormHelperText, null, help) : null, (error == null ? void 0 : error.message) && /* @__PURE__ */ React8.createElement(FormErrorMessage, null, error == null ? void 0 : error.message)));
357
+ return /* @__PURE__ */ jsxs(FormControl, { ...controlProps, isInvalid: !!error, children: [
358
+ label && !hideLabel ? /* @__PURE__ */ jsx(FormLabel, { children: label }) : null,
359
+ /* @__PURE__ */ jsxs(Box, { children: [
360
+ children,
361
+ help && !(error == null ? void 0 : error.message) ? /* @__PURE__ */ jsx(FormHelperText, { children: help }) : null,
362
+ (error == null ? void 0 : error.message) && /* @__PURE__ */ jsx(FormErrorMessage, { children: error == null ? void 0 : error.message })
363
+ ] })
364
+ ] });
281
365
  };
282
- if (__DEV__) {
283
- BaseField.displayName = "BaseField";
284
- }
285
- var Field = React8.forwardRef(
286
- (props, ref) => {
287
- const { type = defaultInputType } = props;
288
- const InputComponent = getInput(type);
289
- return /* @__PURE__ */ React8.createElement(InputComponent, {
290
- ref,
291
- ...props
292
- });
293
- }
294
- );
295
- var createField = (InputComponent, { displayName, hideLabel, BaseField: BaseField2 }) => {
366
+ BaseField.displayName = "BaseField";
367
+ var _createField = (InputComponent, { displayName, hideLabel, BaseField: BaseField2 }) => {
296
368
  const Field2 = forwardRef((props, ref) => {
297
369
  const {
298
370
  id,
@@ -310,24 +382,31 @@ var createField = (InputComponent, { displayName, hideLabel, BaseField: BaseFiel
310
382
  required: isRequired,
311
383
  ...rules
312
384
  };
313
- return /* @__PURE__ */ React8.createElement(BaseField2, {
314
- id,
315
- name,
316
- label,
317
- help,
318
- hideLabel,
319
- isDisabled,
320
- isInvalid,
321
- isReadOnly,
322
- isRequired
323
- }, /* @__PURE__ */ React8.createElement(InputComponent, {
324
- ref,
325
- id,
326
- name,
327
- label: hideLabel ? label : void 0,
328
- rules: inputRules,
329
- ...inputProps
330
- }));
385
+ return /* @__PURE__ */ jsx(
386
+ BaseField2,
387
+ {
388
+ id,
389
+ name,
390
+ label,
391
+ help,
392
+ hideLabel,
393
+ isDisabled,
394
+ isInvalid,
395
+ isReadOnly,
396
+ isRequired,
397
+ children: /* @__PURE__ */ jsx(
398
+ InputComponent,
399
+ {
400
+ ref,
401
+ id,
402
+ name,
403
+ label: hideLabel ? label : void 0,
404
+ rules: inputRules,
405
+ ...inputProps
406
+ }
407
+ )
408
+ }
409
+ );
331
410
  });
332
411
  Field2.displayName = displayName;
333
412
  return Field2;
@@ -336,18 +415,24 @@ var withControlledInput = (InputComponent) => {
336
415
  return forwardRef(
337
416
  ({ name, rules, ...inputProps }, ref) => {
338
417
  const { control } = useFormContext();
339
- return /* @__PURE__ */ React8.createElement(Controller, {
340
- name,
341
- control,
342
- rules,
343
- render: ({ field: { ref: _ref, ...field } }) => /* @__PURE__ */ React8.createElement(InputComponent, {
344
- ...field,
345
- ...inputProps,
346
- onChange: callAllHandlers(inputProps.onChange, field.onChange),
347
- onBlur: callAllHandlers(inputProps.onBlur, field.onBlur),
348
- ref: useMergeRefs(ref, _ref)
349
- })
350
- });
418
+ return /* @__PURE__ */ jsx(
419
+ Controller,
420
+ {
421
+ name,
422
+ control,
423
+ rules,
424
+ render: ({ field: { ref: _ref, ...field } }) => /* @__PURE__ */ jsx(
425
+ InputComponent,
426
+ {
427
+ ...field,
428
+ ...inputProps,
429
+ onChange: callAllHandlers(inputProps.onChange, field.onChange),
430
+ onBlur: callAllHandlers(inputProps.onBlur, field.onBlur),
431
+ ref: useMergeRefs(ref, _ref)
432
+ }
433
+ )
434
+ }
435
+ );
351
436
  }
352
437
  );
353
438
  };
@@ -356,277 +441,167 @@ var withUncontrolledInput = (InputComponent) => {
356
441
  ({ name, rules, ...inputProps }, ref) => {
357
442
  const { register } = useFormContext();
358
443
  const { ref: _ref, ...field } = register(name, rules);
359
- return /* @__PURE__ */ React8.createElement(InputComponent, {
360
- ...field,
361
- ...inputProps,
362
- onChange: callAllHandlers(inputProps.onChange, field.onChange),
363
- onBlur: callAllHandlers(inputProps.onBlur, field.onBlur),
364
- ref: useMergeRefs(ref, _ref)
365
- });
444
+ return /* @__PURE__ */ jsx(
445
+ InputComponent,
446
+ {
447
+ ...field,
448
+ ...inputProps,
449
+ onChange: callAllHandlers(inputProps.onChange, field.onChange),
450
+ onBlur: callAllHandlers(inputProps.onBlur, field.onBlur),
451
+ ref: useMergeRefs(ref, _ref)
452
+ }
453
+ );
366
454
  }
367
455
  );
368
456
  };
369
- var registerFieldType = (type, component, options) => {
457
+ var createField = (component, options) => {
458
+ var _a;
370
459
  let InputComponent;
371
460
  if (options == null ? void 0 : options.isControlled) {
372
461
  InputComponent = withControlledInput(component);
373
462
  } else {
374
463
  InputComponent = withUncontrolledInput(component);
375
464
  }
376
- const Field2 = createField(InputComponent, {
377
- displayName: `${type.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")}Field`,
465
+ const Field2 = _createField(InputComponent, {
466
+ displayName: `${(_a = component.displayName) != null ? _a : "Custom"}Field`,
378
467
  hideLabel: options == null ? void 0 : options.hideLabel,
379
468
  BaseField: (options == null ? void 0 : options.BaseField) || BaseField
380
469
  });
381
- inputTypes[type] = Field2;
382
470
  return Field2;
383
471
  };
384
- var InputField = registerFieldType(
385
- "text",
472
+ var InputField = createField(
386
473
  forwardRef(({ type = "text", leftAddon, rightAddon, size, ...rest }, ref) => {
387
- const input = /* @__PURE__ */ React8.createElement(Input, {
388
- type,
389
- size,
390
- ...rest,
391
- ref
392
- });
474
+ const input = /* @__PURE__ */ jsx(Input, { type, size, ...rest, ref });
393
475
  if (leftAddon || rightAddon) {
394
- return /* @__PURE__ */ React8.createElement(InputGroup, {
395
- size
396
- }, leftAddon, input, rightAddon);
476
+ return /* @__PURE__ */ jsxs(InputGroup, { size, children: [
477
+ leftAddon,
478
+ input,
479
+ rightAddon
480
+ ] });
397
481
  }
398
482
  return input;
399
483
  })
400
484
  );
401
- var NumberInputField2 = registerFieldType(
402
- "number",
485
+ var NumberInputField2 = createField(
403
486
  NumberInput,
404
487
  {
405
488
  isControlled: true
406
489
  }
407
490
  );
408
- var PasswordInputField = registerFieldType(
409
- "password",
410
- forwardRef((props, ref) => /* @__PURE__ */ React8.createElement(PasswordInput, {
411
- ref,
412
- ...props
413
- }))
414
- );
415
- var TextareaField = registerFieldType(
416
- "textarea",
417
- Textarea
491
+ var PasswordInputField = createField(
492
+ forwardRef((props, ref) => /* @__PURE__ */ jsx(PasswordInput, { ref, ...props }))
418
493
  );
419
- var SwitchField = registerFieldType(
420
- "switch",
494
+ var TextareaField = createField(Textarea);
495
+ var SwitchField = createField(
421
496
  forwardRef(({ type, value, ...rest }, ref) => {
422
- return /* @__PURE__ */ React8.createElement(Switch, {
423
- isChecked: !!value,
424
- ...rest,
425
- ref
426
- });
497
+ return /* @__PURE__ */ jsx(Switch, { isChecked: !!value, ...rest, ref });
427
498
  }),
428
499
  {
429
500
  isControlled: true
430
501
  }
431
502
  );
432
- var SelectField = registerFieldType("select", Select, {
433
- isControlled: true
434
- });
435
- var CheckboxField = registerFieldType(
436
- "checkbox",
437
- forwardRef(({ label, type, ...props }, ref) => {
438
- return /* @__PURE__ */ React8.createElement(Checkbox, {
439
- ref,
440
- ...props
441
- }, label);
503
+ var SelectField = createField(
504
+ forwardRef((props, ref) => {
505
+ return /* @__PURE__ */ jsxs(Select, { ref, ...props, children: [
506
+ /* @__PURE__ */ jsx(SelectButton, {}),
507
+ /* @__PURE__ */ jsx(SelectList, {})
508
+ ] });
442
509
  }),
443
510
  {
444
- hideLabel: true
511
+ isControlled: true
445
512
  }
446
513
  );
447
- var RadioField = registerFieldType(
448
- "radio",
449
- RadioInput,
514
+ var CheckboxField = createField(
515
+ forwardRef(({ label, type, ...props }, ref) => {
516
+ return /* @__PURE__ */ jsx(Checkbox, { ref, ...props, children: label });
517
+ }),
450
518
  {
451
- isControlled: true
519
+ hideLabel: true
452
520
  }
453
521
  );
454
- var NativeSelectField = registerFieldType(
455
- "native-select",
456
- NativeSelect,
457
- { isControlled: true }
458
- );
459
- var PinField = registerFieldType(
460
- "pin",
522
+ var RadioField = createField(RadioInput, {
523
+ isControlled: true
524
+ });
525
+ var NativeSelectField = createField(NativeSelect, {
526
+ isControlled: true
527
+ });
528
+ var PinField = createField(
461
529
  forwardRef((props, ref) => {
462
530
  const { pinLength = 4, pinType, spacing, ...inputProps } = props;
463
531
  const inputs = [];
464
532
  for (let i = 0; i < pinLength; i++) {
465
- inputs.push(/* @__PURE__ */ React8.createElement(PinInputField, {
466
- key: i,
467
- ref
468
- }));
533
+ inputs.push(/* @__PURE__ */ jsx(PinInputField, { ref }, i));
469
534
  }
470
- return /* @__PURE__ */ React8.createElement(HStack, {
471
- spacing
472
- }, /* @__PURE__ */ React8.createElement(PinInput, {
473
- ...inputProps,
474
- type: pinType
475
- }, inputs));
535
+ return /* @__PURE__ */ jsx(HStack, { spacing, children: /* @__PURE__ */ jsx(PinInput, { ...inputProps, type: pinType, children: inputs }) });
476
536
  }),
477
537
  {
478
538
  isControlled: true
479
539
  }
480
540
  );
481
- var mapFields = (schema) => schema && Object.entries(schema).map(([name, { items, label, title, ...field }]) => {
482
- return {
483
- ...field,
484
- name,
485
- label: label || title || name
486
- };
487
- });
488
- var objectFieldResolver = (schema) => {
489
- const getFields = () => {
490
- return mapFields(schema);
491
- };
492
- const getNestedFields = (name) => {
493
- var _a;
494
- const field = get$1(schema, name);
495
- if (!field)
496
- return [];
497
- if (((_a = field.items) == null ? void 0 : _a.type) === "object") {
498
- return mapFields(field.items.properties);
499
- } else if (field.type === "object") {
500
- return mapFields(field.properties);
501
- }
502
- return [field.items];
503
- };
504
- return { getFields, getNestedFields };
541
+ var defaultFieldTypes = {
542
+ text: InputField,
543
+ email: InputField,
544
+ url: InputField,
545
+ phone: InputField,
546
+ number: NumberInputField2,
547
+ password: PasswordInputField,
548
+ textarea: TextareaField,
549
+ switch: SwitchField,
550
+ select: SelectField,
551
+ checkbox: CheckboxField,
552
+ radio: RadioField,
553
+ pin: PinField,
554
+ "native-select": NativeSelectField
505
555
  };
506
-
507
- // src/form.tsx
508
- var Form = forwardRef(
556
+ var FieldsContext = React13__default.createContext(
557
+ null
558
+ );
559
+ var FieldsProvider = (props) => {
560
+ const fields = { ...defaultFieldTypes, ...props.value };
561
+ return /* @__PURE__ */ jsx(FieldsContext.Provider, { value: fields, children: props.children });
562
+ };
563
+ var useField = (type) => {
564
+ const context = React13__default.useContext(FieldsContext);
565
+ return (context == null ? void 0 : context[type]) || InputField;
566
+ };
567
+ var defaultInputType = "text";
568
+ var Field = React13.forwardRef(
509
569
  (props, ref) => {
510
- var _a;
511
- const {
512
- mode = "all",
513
- resolver,
514
- reValidateMode,
515
- shouldFocusError,
516
- shouldUnregister,
517
- shouldUseNativeValidation,
518
- criteriaMode,
519
- delayError,
520
- schema,
521
- defaultValues,
522
- values,
523
- context,
524
- resetOptions,
525
- onChange,
526
- onSubmit,
527
- onError,
528
- formRef,
529
- children,
530
- ...rest
531
- } = props;
532
- const form = {
533
- mode,
534
- resolver,
535
- defaultValues,
536
- values,
537
- reValidateMode,
538
- shouldFocusError,
539
- shouldUnregister,
540
- shouldUseNativeValidation,
541
- criteriaMode,
542
- delayError,
543
- context,
544
- resetOptions
545
- };
546
- if (schema && !resolver) {
547
- form.resolver = (_a = Form.getResolver) == null ? void 0 : _a.call(Form, schema);
548
- }
549
- const methods = useForm(form);
550
- const { handleSubmit } = methods;
551
- React8.useImperativeHandle(formRef, () => methods, [formRef, methods]);
552
- React8.useEffect(() => {
553
- let subscription;
554
- if (onChange) {
555
- subscription = methods.watch(onChange);
556
- }
557
- return () => subscription == null ? void 0 : subscription.unsubscribe();
558
- }, [methods, onChange]);
559
- const Field2 = React8.useMemo(
560
- () => (props2) => /* @__PURE__ */ React8.createElement(Field, {
561
- ...props2
562
- }),
563
- []
564
- );
565
- return /* @__PURE__ */ React8.createElement(FormProvider, {
566
- ...methods
567
- }, /* @__PURE__ */ React8.createElement(chakra.form, {
568
- ref,
569
- onSubmit: handleSubmit(onSubmit, onError),
570
- ...rest,
571
- className: cx("sui-form", props.className)
572
- }, runIfFn(children, {
573
- Field: Field2,
574
- ...methods
575
- })));
570
+ const { type = defaultInputType, name } = props;
571
+ const overrides = useFieldProps(name);
572
+ const InputComponent = useField((overrides == null ? void 0 : overrides.type) || type);
573
+ return /* @__PURE__ */ jsx(InputComponent, { ref, ...props, ...overrides });
576
574
  }
577
575
  );
578
- Form.getFieldResolver = objectFieldResolver;
579
- Form.displayName = "Form";
580
- function createForm({ resolver }) {
581
- const CreateForm = (props) => {
582
- const { schema, ...rest } = props;
583
- return /* @__PURE__ */ React8.createElement(Form, {
584
- resolver: resolver == null ? void 0 : resolver(props.schema),
585
- ...rest
586
- });
587
- };
588
- return CreateForm;
589
- }
590
576
  var FormLayoutItem = ({ children }) => {
591
- return /* @__PURE__ */ React8.createElement(chakra.div, null, children);
577
+ return /* @__PURE__ */ jsx(chakra.div, { children });
592
578
  };
593
- if (__DEV__) {
594
- FormLayoutItem.displayName = "FormLayoutItem";
595
- }
579
+ FormLayoutItem.displayName = "FormLayoutItem";
596
580
  var FormLayout = ({ children, ...props }) => {
597
581
  var _a, _b, _c;
598
582
  const theme = useTheme();
599
- const defaultProps = (_c = (_b = (_a = theme.components) == null ? void 0 : _a.FormLayout) == null ? void 0 : _b.defaultProps) != null ? _c : {
583
+ const defaultProps = (_c = (_b = (_a = theme.components) == null ? void 0 : _a.SuiFormLayout) == null ? void 0 : _b.defaultProps) != null ? _c : {
600
584
  spacing: 4
601
585
  };
602
586
  const gridProps = {
603
587
  ...defaultProps,
604
588
  ...props
605
589
  };
606
- return /* @__PURE__ */ React8.createElement(SimpleGrid, {
607
- ...gridProps,
608
- className: cx("sui-form__layout", props.className)
609
- }, React8.Children.map(children, (child) => {
610
- if (React8.isValidElement(child)) {
611
- return /* @__PURE__ */ React8.createElement(FormLayoutItem, null, child);
612
- }
613
- return child;
614
- }));
615
- };
616
- if (__DEV__) {
617
- FormLayout.displayName = "FormLayout";
618
- }
619
- var mapNestedFields = (name, children) => {
620
- return React8.Children.map(children, (child) => {
621
- if (React8.isValidElement(child) && child.props.name) {
622
- return React8.cloneElement(child, {
623
- ...child.props,
624
- name: `${name}.${child.props.name}`
625
- });
590
+ return /* @__PURE__ */ jsx(
591
+ SimpleGrid,
592
+ {
593
+ ...gridProps,
594
+ className: cx("sui-form__layout", props.className),
595
+ children: React13.Children.map(children, (child) => {
596
+ if (React13.isValidElement(child)) {
597
+ return /* @__PURE__ */ jsx(FormLayoutItem, { children: child });
598
+ }
599
+ return child;
600
+ })
626
601
  }
627
- return child;
628
- });
602
+ );
629
603
  };
604
+ FormLayout.displayName = "FormLayout";
630
605
  var [ArrayFieldProvider, useArrayFieldContext] = createContext({
631
606
  name: "ArrayFieldContext"
632
607
  });
@@ -657,7 +632,7 @@ var useArrayField = ({
657
632
  var useArrayFieldRow = ({ index }) => {
658
633
  const { clearErrors } = useFormContext();
659
634
  const { name, remove, fields } = useArrayFieldContext();
660
- React8.useEffect(() => {
635
+ React13.useEffect(() => {
661
636
  clearErrors(name);
662
637
  }, []);
663
638
  return {
@@ -665,7 +640,7 @@ var useArrayFieldRow = ({ index }) => {
665
640
  isFirst: index === 0,
666
641
  isLast: index === fields.length - 1,
667
642
  name: `${name}.${index}`,
668
- remove: React8.useCallback(() => {
643
+ remove: React13.useCallback(() => {
669
644
  clearErrors(name);
670
645
  remove(index);
671
646
  }, [index])
@@ -690,39 +665,29 @@ var useArrayFieldAddButton = () => {
690
665
  isDisabled
691
666
  };
692
667
  };
693
-
694
- // src/array-field.tsx
695
668
  var ArrayFieldRow = ({
696
669
  children,
697
670
  index,
698
671
  ...rowFieldsProps
699
672
  }) => {
700
- return /* @__PURE__ */ React8.createElement(ArrayFieldRowContainer, {
701
- index
702
- }, /* @__PURE__ */ React8.createElement(ArrayFieldRowFields, {
703
- ...rowFieldsProps
704
- }, children), /* @__PURE__ */ React8.createElement(ArrayFieldRemoveButton, null));
673
+ return /* @__PURE__ */ jsxs(ArrayFieldRowContainer, { index, children: [
674
+ /* @__PURE__ */ jsx(ArrayFieldRowFields, { ...rowFieldsProps, children }),
675
+ /* @__PURE__ */ jsx(ArrayFieldRemoveButton, {})
676
+ ] });
705
677
  };
706
- if (__DEV__) {
707
- ArrayFieldRow.displayName = "ArrayFieldRow";
708
- }
678
+ ArrayFieldRow.displayName = "ArrayFieldRow";
709
679
  var ArrayFieldRowFields = ({
710
680
  children,
711
681
  ...layoutProps
712
682
  }) => {
713
683
  const { name } = useArrayFieldRowContext();
714
- return /* @__PURE__ */ React8.createElement(FormLayout, {
715
- flex: "1",
716
- mr: "2",
717
- ...layoutProps
718
- }, mapNestedFields(name, children));
684
+ return /* @__PURE__ */ jsx(FormLayout, { flex: "1", mr: "2", ...layoutProps, children: mapNestedFields(name, children) });
719
685
  };
720
- if (__DEV__) {
721
- ArrayFieldRowFields.displayName = "ArrayFieldRowFields";
722
- }
686
+ ArrayFieldRowFields.displayName = "ArrayFieldRowFields";
723
687
  var ArrayFieldRowContainer = ({
724
688
  children,
725
- index
689
+ index,
690
+ ...rest
726
691
  }) => {
727
692
  const context = useArrayFieldRow({ index });
728
693
  const styles = {
@@ -732,61 +697,45 @@ var ArrayFieldRowContainer = ({
732
697
  width: "100%",
733
698
  mb: 4
734
699
  };
735
- return /* @__PURE__ */ React8.createElement(ArrayFieldRowProvider, {
736
- value: context
737
- }, /* @__PURE__ */ React8.createElement(chakra.div, {
738
- __css: styles
739
- }, children));
700
+ return /* @__PURE__ */ jsx(ArrayFieldRowProvider, { value: context, children: /* @__PURE__ */ jsx(chakra.div, { ...rest, __css: styles, children }) });
740
701
  };
741
- if (__DEV__) {
742
- ArrayFieldRowContainer.displayName = "ArrayFieldRowContainer";
743
- }
702
+ ArrayFieldRowContainer.displayName = "ArrayFieldRowContainer";
744
703
  var ArrayFieldRemoveButton = (props) => {
745
- return /* @__PURE__ */ React8.createElement(Button, {
746
- "aria-label": "Remove row",
747
- ...useArrayFieldRemoveButton(),
748
- ...props
749
- }, props.children || /* @__PURE__ */ React8.createElement(MinusIcon, null));
704
+ return /* @__PURE__ */ jsx(Button, { "aria-label": "Remove row", ...useArrayFieldRemoveButton(), ...props, children: props.children || /* @__PURE__ */ jsx(MinusIcon, {}) });
750
705
  };
751
- if (__DEV__) {
752
- ArrayFieldRemoveButton.displayName = "ArrayFieldRemoveButton";
753
- }
706
+ ArrayFieldRemoveButton.displayName = "ArrayFieldRemoveButton";
754
707
  var ArrayFieldAddButton = (props) => {
755
- return /* @__PURE__ */ React8.createElement(Button, {
756
- "aria-label": "Add row",
757
- float: "right",
758
- ...useArrayFieldAddButton(),
759
- ...props
760
- }, props.children || /* @__PURE__ */ React8.createElement(AddIcon, null));
708
+ return /* @__PURE__ */ jsx(
709
+ Button,
710
+ {
711
+ "aria-label": "Add row",
712
+ float: "right",
713
+ ...useArrayFieldAddButton(),
714
+ ...props,
715
+ children: props.children || /* @__PURE__ */ jsx(PlusIcon, {})
716
+ }
717
+ );
761
718
  };
762
- if (__DEV__) {
763
- ArrayFieldAddButton.displayName = "ArrayFieldAddButton";
764
- }
719
+ ArrayFieldAddButton.displayName = "ArrayFieldAddButton";
765
720
  var ArrayField = forwardRef(
766
721
  (props, ref) => {
767
722
  const { children, ...containerProps } = props;
768
- return /* @__PURE__ */ React8.createElement(ArrayFieldContainer, {
769
- ref,
770
- ...containerProps
771
- }, /* @__PURE__ */ React8.createElement(ArrayFieldRows, null, (fields) => /* @__PURE__ */ React8.createElement(React8.Fragment, null, fields.map(({ id }, index) => /* @__PURE__ */ React8.createElement(ArrayFieldRow, {
772
- key: id,
773
- index
774
- }, children)))), /* @__PURE__ */ React8.createElement(ArrayFieldAddButton, null));
723
+ const rowFn = isFunction(children) ? children : (fields) => /* @__PURE__ */ jsx(Fragment, { children: fields.map(({ id }, index) => /* @__PURE__ */ jsx(ArrayFieldRow, { index, children }, id)) || null });
724
+ return /* @__PURE__ */ jsxs(ArrayFieldContainer, { ref, ...containerProps, children: [
725
+ /* @__PURE__ */ jsx(ArrayFieldRows, { children: rowFn }),
726
+ /* @__PURE__ */ jsx(ArrayFieldAddButton, {})
727
+ ] });
775
728
  }
776
729
  );
777
- if (__DEV__) {
778
- ArrayField.displayName = "ArrayField";
779
- }
730
+ ArrayField.displayName = "ArrayField";
780
731
  var ArrayFieldRows = ({
781
732
  children
782
733
  }) => {
783
734
  const { fields } = useArrayFieldContext();
784
735
  return children(fields);
785
736
  };
786
- if (__DEV__) {
787
- ArrayFieldRows.displayName = "ArrayFieldRows";
788
- }
789
- var ArrayFieldContainer = React8.forwardRef(
737
+ ArrayFieldRows.displayName = "ArrayFieldRows";
738
+ var ArrayFieldContainer = React13.forwardRef(
790
739
  ({
791
740
  name,
792
741
  defaultValue,
@@ -803,74 +752,59 @@ var ArrayFieldContainer = React8.forwardRef(
803
752
  min,
804
753
  max
805
754
  });
806
- React8.useImperativeHandle(ref, () => context, [ref, context]);
807
- return /* @__PURE__ */ React8.createElement(ArrayFieldProvider, {
808
- value: context
809
- }, /* @__PURE__ */ React8.createElement(BaseField, {
810
- name,
811
- ...fieldProps
812
- }, children));
755
+ React13.useImperativeHandle(ref, () => context, [ref, context]);
756
+ return /* @__PURE__ */ jsx(ArrayFieldProvider, { value: context, children: /* @__PURE__ */ jsx(BaseField, { name, ...fieldProps, children }) });
813
757
  }
814
758
  );
815
- if (__DEV__) {
816
- ArrayFieldContainer.displayName = "ArrayFieldContainer";
817
- }
759
+ ArrayFieldContainer.displayName = "ArrayFieldContainer";
818
760
  var FormLegend = (props) => {
819
761
  const styles = useStyleConfig("SuiFormLegend");
820
- return /* @__PURE__ */ React8.createElement(FormLabel, {
821
- as: "legend",
822
- sx: styles,
823
- ...props
824
- });
762
+ return /* @__PURE__ */ jsx(FormLabel, { as: "legend", sx: styles, ...props });
825
763
  };
826
764
  var ObjectField = (props) => {
827
765
  const { name, label, hideLabel, children, columns, spacing, ...fieldProps } = props;
828
- return /* @__PURE__ */ React8.createElement(FormControl, {
829
- name,
830
- as: "fieldset",
831
- ...fieldProps
832
- }, /* @__PURE__ */ React8.createElement(FormLegend, {
833
- display: hideLabel ? "none" : "block"
834
- }, label), /* @__PURE__ */ React8.createElement(FormLayout, {
835
- columns,
836
- gridGap: spacing
837
- }, mapNestedFields(name, children)));
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) })
769
+ ] });
838
770
  };
839
- if (__DEV__) {
840
- ObjectField.displayName = "ObjectField";
841
- }
771
+ ObjectField.displayName = "ObjectField";
842
772
  var mapNestedFields2 = (resolver, name) => {
843
773
  var _a;
844
774
  return (_a = resolver.getNestedFields(name)) == null ? void 0 : _a.map(
845
- ({ name: name2, type, ...nestedFieldProps }, i) => /* @__PURE__ */ React8.createElement(Field, {
846
- key: name2 || i,
847
- name: name2,
848
- type,
849
- ...nestedFieldProps
850
- })
775
+ ({ name: name2, type, ...nestedFieldProps }, i) => /* @__PURE__ */ jsx(
776
+ Field,
777
+ {
778
+ name: name2,
779
+ type,
780
+ ...nestedFieldProps
781
+ },
782
+ name2 || i
783
+ )
851
784
  );
852
785
  };
853
- var Fields = ({
854
- schema,
855
- fieldResolver,
786
+ var AutoFields = ({
787
+ schema: schemaProp,
788
+ fieldResolver: fieldResolverProp,
856
789
  focusFirstField,
857
790
  ...props
858
791
  }) => {
859
- const resolver = React8.useMemo(
860
- () => fieldResolver || Form.getFieldResolver(schema),
861
- [schema, fieldResolver]
862
- );
863
- const fields = React8.useMemo(() => resolver.getFields(), [resolver]);
792
+ const context = useFormContext();
793
+ const schema = schemaProp || context.schema;
794
+ 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]);
864
797
  const form = useFormContext();
865
- React8.useEffect(() => {
798
+ React13.useEffect(() => {
866
799
  var _a;
867
- if (focusFirstField && ((_a = fields[0]) == null ? void 0 : _a.name)) {
800
+ if (focusFirstField && ((_a = fields == null ? void 0 : fields[0]) == null ? void 0 : _a.name)) {
868
801
  form.setFocus(fields[0].name);
869
802
  }
870
803
  }, [schema, fieldResolver, focusFirstField]);
871
- return /* @__PURE__ */ React8.createElement(FormLayout, {
872
- ...props
873
- }, fields.map(
804
+ if (!resolver) {
805
+ return null;
806
+ }
807
+ return /* @__PURE__ */ jsx(FormLayout, { ...props, children: fields == null ? void 0 : fields.map(
874
808
  ({
875
809
  name,
876
810
  type,
@@ -878,28 +812,15 @@ var Fields = ({
878
812
  ...fieldProps
879
813
  }) => {
880
814
  if (type === "array") {
881
- return /* @__PURE__ */ React8.createElement(ArrayField, {
882
- key: name,
883
- name,
884
- ...fieldProps
885
- }, mapNestedFields2(resolver, name));
815
+ return /* @__PURE__ */ jsx(ArrayField, { name, ...fieldProps, children: mapNestedFields2(resolver, name) }, name);
886
816
  } else if (type === "object") {
887
- return /* @__PURE__ */ React8.createElement(ObjectField, {
888
- key: name,
889
- name,
890
- ...fieldProps
891
- }, mapNestedFields2(resolver, name));
817
+ return /* @__PURE__ */ jsx(ObjectField, { name, ...fieldProps, children: mapNestedFields2(resolver, name) }, name);
892
818
  }
893
- return /* @__PURE__ */ React8.createElement(Field, {
894
- key: name,
895
- name,
896
- type,
897
- ...fieldProps
898
- });
819
+ return /* @__PURE__ */ jsx(Field, { name, type, ...fieldProps }, name);
899
820
  }
900
- ));
821
+ ) });
901
822
  };
902
- Fields.displayName = "Fields";
823
+ AutoFields.displayName = "Fields";
903
824
  var SubmitButton = forwardRef(
904
825
  (props, ref) => {
905
826
  const {
@@ -910,15 +831,19 @@ var SubmitButton = forwardRef(
910
831
  isLoading,
911
832
  ...rest
912
833
  } = props;
913
- const { formState } = useFormContext();
834
+ const { formState } = useFormContext$1();
914
835
  const isDisabled = disableIfUntouched && !formState.isDirty || disableIfInvalid && !formState.isValid || isDisabledProp;
915
- return /* @__PURE__ */ React8.createElement(Button, {
916
- ...rest,
917
- ref,
918
- type: "submit",
919
- isLoading: formState.isSubmitting || isLoading,
920
- isDisabled
921
- }, children);
836
+ return /* @__PURE__ */ jsx(
837
+ Button,
838
+ {
839
+ ...rest,
840
+ ref,
841
+ type: "submit",
842
+ isLoading: formState.isSubmitting || isLoading,
843
+ isDisabled,
844
+ children
845
+ }
846
+ );
922
847
  }
923
848
  );
924
849
  SubmitButton.defaultProps = {
@@ -927,28 +852,6 @@ SubmitButton.defaultProps = {
927
852
  disableIfInvalid: false
928
853
  };
929
854
  SubmitButton.displayName = "SubmitButton";
930
-
931
- // src/auto-form.tsx
932
- var AutoForm = forwardRef(
933
- (props, ref) => {
934
- const {
935
- schema,
936
- submitLabel = "Submit",
937
- fieldResolver,
938
- children,
939
- ...rest
940
- } = props;
941
- return /* @__PURE__ */ React8.createElement(Form, {
942
- ...rest,
943
- schema,
944
- ref
945
- }, /* @__PURE__ */ React8.createElement(FormLayout, null, /* @__PURE__ */ React8.createElement(Fields, {
946
- schema,
947
- fieldResolver
948
- }), submitLabel && /* @__PURE__ */ React8.createElement(SubmitButton, null, submitLabel), children));
949
- }
950
- );
951
- AutoForm.displayName = "AutoForm";
952
855
  var DisplayIf = ({
953
856
  children,
954
857
  name,
@@ -966,9 +869,91 @@ var DisplayIf = ({
966
869
  const context = useFormContext();
967
870
  return condition(value, context) ? children : null;
968
871
  };
969
- if (__DEV__) {
970
- DisplayIf.displayName = "DisplayIf";
971
- }
872
+ 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";
972
957
  var [StepFormProvider, useStepFormContext] = createContext({
973
958
  name: "StepFormContext",
974
959
  errorMessage: "useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`"
@@ -977,8 +962,8 @@ function useStepForm(props) {
977
962
  const { onChange, ...rest } = props;
978
963
  const stepper = useStepper(rest);
979
964
  const { activeStep, isLastStep, nextStep } = stepper;
980
- const [steps, updateSteps] = React8.useState({});
981
- const onSubmitStep = React8.useCallback(
965
+ const [steps, updateSteps] = React13.useState({});
966
+ const onSubmitStep = React13.useCallback(
982
967
  async (data) => {
983
968
  var _a, _b;
984
969
  try {
@@ -999,7 +984,7 @@ function useStepForm(props) {
999
984
  },
1000
985
  [steps, activeStep, isLastStep]
1001
986
  );
1002
- const getFormProps = React8.useCallback(() => {
987
+ const getFormProps = React13.useCallback(() => {
1003
988
  const step = steps[activeStep];
1004
989
  return {
1005
990
  onSubmit: onSubmitStep,
@@ -1007,7 +992,7 @@ function useStepForm(props) {
1007
992
  resolver: step == null ? void 0 : step.resolver
1008
993
  };
1009
994
  }, [steps, onSubmitStep, activeStep]);
1010
- const updateStep = React8.useCallback(
995
+ const updateStep = React13.useCallback(
1011
996
  (step) => {
1012
997
  updateSteps((steps2) => {
1013
998
  return {
@@ -1029,7 +1014,7 @@ function useFormStep(props) {
1029
1014
  const { name, schema, resolver, onSubmit } = props;
1030
1015
  const step = useStep({ name });
1031
1016
  const { steps, updateStep } = useStepFormContext();
1032
- React8.useEffect(() => {
1017
+ React13.useEffect(() => {
1033
1018
  updateStep({ name, schema, resolver, onSubmit });
1034
1019
  }, [name, schema]);
1035
1020
  return {
@@ -1037,92 +1022,111 @@ function useFormStep(props) {
1037
1022
  ...steps[name] || { name, schema }
1038
1023
  };
1039
1024
  }
1040
-
1041
- // src/step-form.tsx
1042
- var StepForm = React8.forwardRef(
1025
+ var StepForm = React13.forwardRef(
1043
1026
  (props, ref) => {
1044
1027
  const { children, ...rest } = props;
1045
1028
  const stepper = useStepForm(props);
1046
1029
  const { getFormProps, ...ctx } = stepper;
1047
- const context = React8.useMemo(() => ctx, [ctx]);
1048
- return /* @__PURE__ */ React8.createElement(StepperProvider, {
1049
- value: context
1050
- }, /* @__PURE__ */ React8.createElement(StepFormProvider, {
1051
- value: context
1052
- }, /* @__PURE__ */ React8.createElement(Form, {
1053
- ref,
1054
- ...rest,
1055
- ...getFormProps()
1056
- }, runIfFn(children, 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) }) }) });
1057
1032
  }
1058
1033
  );
1059
1034
  var FormStepper = (props) => {
1060
1035
  const { activeIndex, setIndex } = useStepperContext();
1061
1036
  const { children, orientation, variant, colorScheme, size, ...rest } = props;
1062
- const elements = React8.Children.map(children, (child) => {
1063
- if (React8.isValidElement(child) && (child == null ? void 0 : child.type) === FormStep) {
1037
+ const elements = React13.Children.map(children, (child) => {
1038
+ if (React13.isValidElement(child) && (child == null ? void 0 : child.type) === FormStep) {
1064
1039
  const { isCompleted } = useFormStep(child.props);
1065
- return /* @__PURE__ */ React8.createElement(StepperStep, {
1066
- name: child.props.name,
1067
- title: child.props.title,
1068
- isCompleted,
1069
- ...rest
1070
- }, child.props.children);
1040
+ return /* @__PURE__ */ jsx(
1041
+ StepperStep,
1042
+ {
1043
+ name: child.props.name,
1044
+ title: child.props.title,
1045
+ isCompleted,
1046
+ ...rest,
1047
+ children: child.props.children
1048
+ }
1049
+ );
1071
1050
  }
1072
1051
  return child;
1073
1052
  });
1074
- const onChange = React8.useCallback((i) => {
1053
+ const onChange = React13.useCallback((i) => {
1075
1054
  setIndex(i);
1076
1055
  }, []);
1077
- return /* @__PURE__ */ React8.createElement(StepperContainer, {
1078
- orientation,
1079
- step: activeIndex,
1080
- variant,
1081
- colorScheme,
1082
- size,
1083
- onChange
1084
- }, /* @__PURE__ */ React8.createElement(StepperSteps, {
1085
- mb: "4",
1086
- ...props
1087
- }, elements));
1056
+ return /* @__PURE__ */ jsx(
1057
+ StepperContainer,
1058
+ {
1059
+ orientation,
1060
+ step: activeIndex,
1061
+ variant,
1062
+ colorScheme,
1063
+ size,
1064
+ onChange,
1065
+ children: /* @__PURE__ */ jsx(StepperSteps, { mb: "4", ...props, children: elements })
1066
+ }
1067
+ );
1088
1068
  };
1089
1069
  var FormStep = (props) => {
1090
1070
  const { name, schema, resolver, children, className, onSubmit, ...rest } = props;
1091
1071
  const step = useFormStep({ name, schema, resolver, onSubmit });
1092
1072
  const { isActive } = step;
1093
- return isActive ? /* @__PURE__ */ React8.createElement(chakra.div, {
1094
- ...rest,
1095
- className: cx("sui-form__step", className)
1096
- }, children) : null;
1073
+ return isActive ? /* @__PURE__ */ jsx(chakra.div, { ...rest, className: cx("sui-form__step", className), children }) : null;
1097
1074
  };
1098
- if (__DEV__) {
1099
- FormStep.displayName = "FormStep";
1100
- }
1075
+ FormStep.displayName = "FormStep";
1101
1076
  var PrevButton = (props) => {
1102
1077
  const { isFirstStep, isCompleted, prevStep } = useStepperContext();
1103
- return /* @__PURE__ */ React8.createElement(Button, {
1104
- isDisabled: isFirstStep || isCompleted,
1105
- label: "Back",
1106
- ...props,
1107
- className: cx("sui-form__prev-button", props.className),
1108
- onClick: callAllHandlers(props.onClick, prevStep)
1109
- });
1078
+ return /* @__PURE__ */ jsx(
1079
+ Button,
1080
+ {
1081
+ isDisabled: isFirstStep || isCompleted,
1082
+ label: "Back",
1083
+ ...props,
1084
+ className: cx("sui-form__prev-button", props.className),
1085
+ onClick: callAllHandlers(props.onClick, prevStep)
1086
+ }
1087
+ );
1110
1088
  };
1111
- if (__DEV__) {
1112
- PrevButton.displayName = "PrevButton";
1113
- }
1089
+ PrevButton.displayName = "PrevButton";
1114
1090
  var NextButton = (props) => {
1115
1091
  const { label = "Next", submitLabel = "Complete", ...rest } = props;
1116
1092
  const { isLastStep, isCompleted } = useStepperContext();
1117
- return /* @__PURE__ */ React8.createElement(SubmitButton, {
1118
- ...rest,
1119
- isDisabled: isCompleted,
1120
- className: cx("sui-form__next-button", props.className)
1121
- }, isLastStep || isCompleted ? submitLabel : label);
1093
+ return /* @__PURE__ */ jsx(
1094
+ SubmitButton,
1095
+ {
1096
+ ...rest,
1097
+ isDisabled: isCompleted,
1098
+ className: cx("sui-form__next-button", props.className),
1099
+ children: isLastStep || isCompleted ? submitLabel : label
1100
+ }
1101
+ );
1102
+ };
1103
+ NextButton.displayName = "NextButton";
1104
+ var mapFields = (schema) => schema && Object.entries(schema).map(([name, { items, label, title, ...field }]) => {
1105
+ return {
1106
+ ...field,
1107
+ name,
1108
+ label: label || title || name
1109
+ // json schema compatibility
1110
+ };
1111
+ });
1112
+ var objectFieldResolver = (schema) => {
1113
+ const getFields = () => {
1114
+ return mapFields(schema);
1115
+ };
1116
+ const getNestedFields = (name) => {
1117
+ var _a;
1118
+ const field = get$1(schema, name);
1119
+ if (!field)
1120
+ return [];
1121
+ if (((_a = field.items) == null ? void 0 : _a.type) === "object") {
1122
+ return mapFields(field.items.properties);
1123
+ } else if (field.type === "object") {
1124
+ return mapFields(field.properties);
1125
+ }
1126
+ return [field.items];
1127
+ };
1128
+ return { getFields, getNestedFields };
1122
1129
  };
1123
- if (__DEV__) {
1124
- NextButton.displayName = "NextButton";
1125
- }
1126
1130
  var WatchField = (props) => {
1127
1131
  const { name, defaultValue, isDisabled, isExact } = props;
1128
1132
  const form = useFormContext();
@@ -1134,7 +1138,29 @@ var WatchField = (props) => {
1134
1138
  });
1135
1139
  return props.children(field, form) || null;
1136
1140
  };
1141
+ function createForm({
1142
+ resolver,
1143
+ fieldResolver = objectFieldResolver,
1144
+ fields
1145
+ } = {}) {
1146
+ const CreateForm = forwardRef(
1147
+ (props, ref) => {
1148
+ const { schema, ...rest } = props;
1149
+ return /* @__PURE__ */ jsx(FieldsProvider, { value: fields || {}, children: /* @__PURE__ */ jsx(
1150
+ Form,
1151
+ {
1152
+ ref,
1153
+ resolver: resolver == null ? void 0 : resolver(props.schema),
1154
+ fieldResolver: fieldResolver == null ? void 0 : fieldResolver(schema),
1155
+ ...rest
1156
+ }
1157
+ ) });
1158
+ }
1159
+ );
1160
+ return CreateForm;
1161
+ }
1162
+ var Form2 = createForm();
1137
1163
 
1138
- export { ArrayField, ArrayFieldAddButton, ArrayFieldContainer, ArrayFieldProvider, ArrayFieldRemoveButton, ArrayFieldRow, ArrayFieldRowContainer, ArrayFieldRowFields, ArrayFieldRowProvider, ArrayFieldRows, AutoForm, BaseField, CheckboxField, DisplayField, DisplayIf, Field, Fields, Form, FormLayout, FormLegend, FormStep, FormStepper, FormValue, InputField, InputRightButton, NativeSelect, NativeSelectField, NextButton, NumberInputField2 as NumberInputField, ObjectField, PasswordInput, PasswordInputField, PinField, PrevButton, RadioField, Select, SelectField, StepForm, StepFormProvider, SubmitButton, SwitchField, TextareaField, WatchField, createForm, objectFieldResolver, registerFieldType, useArrayField, useArrayFieldAddButton, useArrayFieldContext, useArrayFieldRemoveButton, useArrayFieldRow, useArrayFieldRowContext, useFormStep, useStepForm, useStepFormContext, withControlledInput, withUncontrolledInput };
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 };
1139
1165
  //# sourceMappingURL=out.js.map
1140
1166
  //# sourceMappingURL=index.mjs.map