@saas-ui/forms 3.0.0-alpha.2 → 3.0.0-alpha.20

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -82,10 +82,11 @@ __export(src_exports, {
82
82
  module.exports = __toCommonJS(src_exports);
83
83
 
84
84
  // src/create-form.tsx
85
- var import_react13 = require("react");
85
+ var import_react14 = require("react");
86
86
 
87
87
  // src/default-fields.tsx
88
- var import_react4 = require("@chakra-ui/react");
88
+ var import_react4 = require("react");
89
+ var import_react5 = require("@chakra-ui/react");
89
90
  var import_checkbox = require("@saas-ui/react/checkbox");
90
91
  var import_input_group = require("@saas-ui/react/input-group");
91
92
  var import_number_input = require("@saas-ui/react/number-input");
@@ -138,35 +139,38 @@ var isTouched = (name, formState) => {
138
139
  return (0, import_react_hook_form2.get)(formState.touchedFields, name);
139
140
  };
140
141
  var useBaseField = (props) => {
141
- const [fieldProps] = (0, import_utils.splitProps)(props, ["name", "label", "help", "hideLabel"]);
142
- const [controlProps] = (0, import_utils.splitProps)(props, [
143
- // 'id',
144
- // 'orientation',
145
- // 'disabled',
146
- // 'invalid',
147
- // 'readOnly',
148
- // 'required',
142
+ const [fieldProps, rootProps] = (0, import_utils.splitProps)(props, [
143
+ "name",
144
+ "label",
145
+ "help",
146
+ "hideLabel",
147
+ "placeholder",
148
+ "rules",
149
+ "type",
150
+ "children"
149
151
  ]);
150
152
  const { formState } = useFormContext();
151
153
  const error = getError(fieldProps.name, formState);
152
154
  const touched = isTouched(fieldProps.name, formState);
153
155
  return {
154
156
  ...fieldProps,
155
- controlProps,
157
+ rootProps,
156
158
  error,
157
159
  touched
158
160
  };
159
161
  };
160
162
  var BaseField = (props) => {
161
- const { label, help, hideLabel, error } = useBaseField(props);
163
+ const { rootProps, label, hideLabel, help, error } = useBaseField(props);
162
164
  const isInvalid = !!error;
163
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Field.Root, { invalid: isInvalid, ...props, children: [
164
- label && !hideLabel ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.Field.Label, { children: label }) : null,
165
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Box, { width: "full", children: [
166
- props.children,
167
- help && !(error == null ? void 0 : error.message) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.Field.HelperText, { children: help }) : null,
168
- (error == null ? void 0 : error.message) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.Field.ErrorText, { children: error == null ? void 0 : error.message })
169
- ] })
165
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Field.Root, { invalid: isInvalid, ...rootProps, children: [
166
+ label && !hideLabel ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Field.Label, { children: [
167
+ label,
168
+ " ",
169
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.Field.RequiredIndicator, {})
170
+ ] }) : null,
171
+ props.children,
172
+ help && !(error == null ? void 0 : error.message) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.Field.HelperText, { children: help }) : null,
173
+ (error == null ? void 0 : error.message) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.Field.ErrorText, { children: error == null ? void 0 : error.message })
170
174
  ] });
171
175
  };
172
176
  BaseField.displayName = "BaseField";
@@ -192,37 +196,34 @@ var import_jsx_runtime4 = require("react/jsx-runtime");
192
196
  var _createField = (InputComponent, { displayName, hideLabel, getBaseField: getBaseFieldProp }) => {
193
197
  const Field3 = (0, import_react3.forwardRef)((props, ref) => {
194
198
  var _a;
195
- const { id, name, label, isRequired, rules } = props;
199
+ const { id, label, required, rules } = props;
196
200
  const inputRules = {
197
- required: isRequired,
201
+ required,
198
202
  ...rules
199
203
  };
200
204
  const fieldContext = useFieldsContext();
201
205
  const getBaseField = (_a = fieldContext == null ? void 0 : fieldContext.getBaseField) != null ? _a : getBaseFieldProp;
202
- const { extraProps, BaseField: BaseField2 } = import_react3.default.useMemo(
206
+ const { props: extraProps, Component } = import_react3.default.useMemo(
203
207
  () => getBaseField(),
204
208
  [getBaseField]
205
209
  );
206
- const [, inputProps] = (0, import_utils2.splitProps)(
210
+ const rootProps = {
211
+ name: props.name,
212
+ label: props.label,
213
+ disabled: props.disabled,
214
+ invalid: props.invalid,
215
+ readOnly: props.readOnly,
216
+ required: props.required
217
+ };
218
+ const [baseFieldProps, inputProps] = (0, import_utils2.splitProps)(
207
219
  props,
208
- [
209
- "children",
210
- "name",
211
- "label",
212
- "required",
213
- "disabled",
214
- "invalid",
215
- "readOnly",
216
- "help",
217
- "hideLabel"
218
- ].concat(extraProps)
220
+ ["orientation", "help", "hideLabel"].concat(extraProps)
219
221
  );
220
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(BaseField2, { name, hideLabel, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
222
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Component, { ...rootProps, ...baseFieldProps, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
221
223
  InputComponent,
222
224
  {
223
225
  ref,
224
226
  id,
225
- name,
226
227
  label: hideLabel ? label : void 0,
227
228
  ...inputProps,
228
229
  rules: inputRules
@@ -288,8 +289,8 @@ var createField = (component, options) => {
288
289
  displayName: `${(_a = component.displayName) != null ? _a : "Custom"}Field`,
289
290
  hideLabel: options == null ? void 0 : options.hideLabel,
290
291
  getBaseField: () => ({
291
- extraProps: [],
292
- BaseField
292
+ props: [],
293
+ Component: BaseField
293
294
  })
294
295
  });
295
296
  return Field3;
@@ -299,14 +300,22 @@ var createField = (component, options) => {
299
300
  var import_jsx_runtime5 = require("react/jsx-runtime");
300
301
  var InputField = createField(
301
302
  ({ type = "text", startElement, endElement, size, ...rest }, ref) => {
302
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_input_group.InputGroup, { startElement, endElement, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react4.Input, { type, size, ...rest, ref }) });
303
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
304
+ import_input_group.InputGroup,
305
+ {
306
+ startElement,
307
+ endElement,
308
+ width: "full",
309
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react5.Input, { type, size, ...rest, ref })
310
+ }
311
+ );
303
312
  }
304
313
  );
305
314
  var NumberInputField = createField((props, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_number_input.NumberInput, { ...props, ref }), {
306
315
  isControlled: true
307
316
  });
308
317
  var PasswordInputField = createField(({ type = "password", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_password_input.PasswordInput, { ref, ...props }));
309
- var TextareaField = createField((props, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react4.Textarea, { ...props, ref }));
318
+ var TextareaField = createField((props, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react5.Textarea, { ...props, ref }));
310
319
  var SwitchField = createField(
311
320
  ({ type, value, ...rest }, ref) => {
312
321
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_switch.Switch, { checked: !!value, ...rest, ref });
@@ -323,22 +332,28 @@ var SelectField = createField(
323
332
  options,
324
333
  placeholder,
325
334
  onChange,
326
- onValueChange,
327
335
  onBlur,
336
+ multiple = false,
337
+ value: valueProp,
328
338
  ...rest
329
339
  } = props;
330
- const collection = (0, import_react4.createListCollection)({
331
- items: options
332
- });
340
+ const collection = (0, import_react4.useMemo)(
341
+ () => (0, import_react5.createListCollection)({
342
+ items: options
343
+ }),
344
+ [options]
345
+ );
346
+ const value = multiple ? [...valueProp != null ? valueProp : []] : valueProp ? [valueProp] : [];
333
347
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
334
348
  import_select.Select.Root,
335
349
  {
336
350
  ref,
337
351
  collection,
338
352
  onValueChange: (details) => {
339
- onChange(details.value);
353
+ onChange(multiple ? details.value : details.value[0]);
340
354
  },
341
355
  onInteractOutside: () => onBlur(),
356
+ value,
342
357
  ...rest,
343
358
  children: [
344
359
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_select.Select.Trigger, { ...triggerProps, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_select.Select.ValueText, { placeholder }) }),
@@ -370,7 +385,7 @@ var RadioField = createField(
370
385
  onChange == null ? void 0 : onChange(value);
371
386
  },
372
387
  ...rest,
373
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react4.Stack, { flexDirection, gap, children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_radio.Radio, { value: option.value, children: option.label || option.value }, option.value)) })
388
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react5.Stack, { flexDirection, gap, children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_radio.Radio, { value: option.value, children: option.label || option.value }, option.value)) })
374
389
  }
375
390
  );
376
391
  },
@@ -445,37 +460,37 @@ var objectFieldResolver = (schema) => {
445
460
  };
446
461
 
447
462
  // src/form.tsx
448
- var import_react11 = __toESM(require("react"));
449
- var import_react12 = require("@chakra-ui/react");
463
+ var import_react12 = __toESM(require("react"));
464
+ var import_react13 = require("@chakra-ui/react");
450
465
  var import_utils9 = require("@saas-ui/core/utils");
451
466
  var import_react_hook_form7 = require("react-hook-form");
452
467
 
453
468
  // src/array-field.tsx
454
- var import_react7 = __toESM(require("react"));
455
- var import_react8 = require("@chakra-ui/react");
469
+ var import_react8 = __toESM(require("react"));
470
+ var import_react9 = require("@chakra-ui/react");
456
471
  var import_icons = require("@saas-ui/react/icons");
457
472
 
458
473
  // src/form-layout.tsx
459
- var import_react5 = require("react");
460
- var import_react6 = require("@chakra-ui/react");
474
+ var import_react6 = require("react");
475
+ var import_react7 = require("@chakra-ui/react");
461
476
  var import_utils4 = require("@saas-ui/core/utils");
462
477
  var import_jsx_runtime6 = require("react/jsx-runtime");
463
- var FormLayout = (0, import_react5.forwardRef)(
464
- ({ children, rowGap = 4, ...props }, ref) => {
465
- const recipe = (0, import_react6.useRecipe)({
466
- key: "formLayout"
478
+ var FormLayout = (0, import_react6.forwardRef)(
479
+ ({ children, gap = 4, ...props }, ref) => {
480
+ const recipe = (0, import_react7.useRecipe)({
481
+ key: "suiFormLayout"
467
482
  });
468
483
  const [variantProps, gridProps] = recipe.splitVariantProps(props);
469
484
  const styles = recipe(variantProps);
470
485
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
471
- import_react6.SimpleGrid,
486
+ import_react7.SimpleGrid,
472
487
  {
473
488
  ref,
474
489
  ...gridProps,
475
490
  className: (0, import_utils4.cx)("sui-form-layout", props.className),
476
491
  css: [
477
492
  {
478
- rowGap
493
+ gap
479
494
  },
480
495
  styles,
481
496
  props.css
@@ -488,7 +503,7 @@ var FormLayout = (0, import_react5.forwardRef)(
488
503
  FormLayout.displayName = "FormLayout";
489
504
 
490
505
  // src/use-array-field.tsx
491
- var React4 = __toESM(require("react"));
506
+ var React5 = __toESM(require("react"));
492
507
  var import_utils5 = require("@saas-ui/core/utils");
493
508
  var import_react_hook_form4 = require("react-hook-form");
494
509
  var [ArrayFieldProvider, useArrayFieldContext] = (0, import_utils5.createContext)({
@@ -521,7 +536,7 @@ var useArrayField = ({
521
536
  var useArrayFieldRow = ({ index }) => {
522
537
  const { clearErrors } = useFormContext();
523
538
  const { name, remove, fields } = useArrayFieldContext();
524
- React4.useEffect(() => {
539
+ React5.useEffect(() => {
525
540
  clearErrors(name);
526
541
  }, []);
527
542
  return {
@@ -529,7 +544,7 @@ var useArrayFieldRow = ({ index }) => {
529
544
  isFirst: index === 0,
530
545
  isLast: index === fields.length - 1,
531
546
  name: `${name}.${index}`,
532
- remove: React4.useCallback(() => {
547
+ remove: React5.useCallback(() => {
533
548
  clearErrors(name);
534
549
  remove(index);
535
550
  }, [index])
@@ -556,17 +571,17 @@ var useArrayFieldAddButton = () => {
556
571
  };
557
572
 
558
573
  // src/utils.ts
559
- var React5 = __toESM(require("react"));
574
+ var React6 = __toESM(require("react"));
560
575
  var mapNestedFields = (name, children) => {
561
- return React5.Children.map(children, (child) => {
562
- if (React5.isValidElement(child) && child.props.name) {
576
+ return React6.Children.map(children, (child) => {
577
+ if (React6.isValidElement(child) && child.props.name) {
563
578
  let childName = child.props.name;
564
579
  if (childName.includes(".")) {
565
580
  childName = childName.replace(/^.*\.(.*)/, "$1");
566
581
  } else if (childName.includes(".$")) {
567
582
  childName = childName.replace(/^.*\.\$(.*)/, "$1");
568
583
  }
569
- return React5.cloneElement(child, {
584
+ return React6.cloneElement(child, {
570
585
  ...child.props,
571
586
  name: `${name}.${childName}`
572
587
  });
@@ -609,16 +624,16 @@ var ArrayFieldRowContainer = ({
609
624
  width: "100%",
610
625
  mb: 4
611
626
  };
612
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ArrayFieldRowProvider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react8.chakra.div, { ...rest, css: styles, children }) });
627
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ArrayFieldRowProvider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react9.chakra.div, { ...rest, css: styles, children }) });
613
628
  };
614
629
  ArrayFieldRowContainer.displayName = "ArrayFieldRowContainer";
615
630
  var ArrayFieldRemoveButton = (props) => {
616
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react8.Button, { "aria-label": "Remove row", ...useArrayFieldRemoveButton(), ...props, children: props.children || /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons.MinusIcon, {}) });
631
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react9.Button, { "aria-label": "Remove row", ...useArrayFieldRemoveButton(), ...props, children: props.children || /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons.MinusIcon, {}) });
617
632
  };
618
633
  ArrayFieldRemoveButton.displayName = "ArrayFieldRemoveButton";
619
634
  var ArrayFieldAddButton = (props) => {
620
635
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
621
- import_react8.Button,
636
+ import_react9.Button,
622
637
  {
623
638
  "aria-label": "Add row",
624
639
  float: "right",
@@ -629,7 +644,7 @@ var ArrayFieldAddButton = (props) => {
629
644
  );
630
645
  };
631
646
  ArrayFieldAddButton.displayName = "ArrayFieldAddButton";
632
- var ArrayField = (0, import_react7.forwardRef)(
647
+ var ArrayField = (0, import_react8.forwardRef)(
633
648
  (props, ref) => {
634
649
  const { children, ...containerProps } = props;
635
650
  const rowFn = typeof children === "function" ? children : (fields) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: fields.map(({ id }, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ArrayFieldRow, { index, children }, id)) || null });
@@ -647,7 +662,7 @@ var ArrayFieldRows = ({
647
662
  return children(fields);
648
663
  };
649
664
  ArrayFieldRows.displayName = "ArrayFieldRows";
650
- var ArrayFieldContainer = import_react7.default.forwardRef(
665
+ var ArrayFieldContainer = import_react8.default.forwardRef(
651
666
  ({
652
667
  name,
653
668
  defaultValue,
@@ -665,14 +680,14 @@ var ArrayFieldContainer = import_react7.default.forwardRef(
665
680
  min: min || (overrides == null ? void 0 : overrides.min),
666
681
  max: max || (overrides == null ? void 0 : overrides.max)
667
682
  });
668
- import_react7.default.useImperativeHandle(ref, () => context, [ref, context]);
683
+ import_react8.default.useImperativeHandle(ref, () => context, [ref, context]);
669
684
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ArrayFieldProvider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(BaseField, { name, ...fieldProps, ...overrides, children }) });
670
685
  }
671
686
  );
672
687
  ArrayFieldContainer.displayName = "ArrayFieldContainer";
673
688
 
674
689
  // src/display-if.tsx
675
- var React7 = __toESM(require("react"));
690
+ var React8 = __toESM(require("react"));
676
691
  var import_react_hook_form5 = require("react-hook-form");
677
692
  var DisplayIf = ({
678
693
  children,
@@ -683,8 +698,8 @@ var DisplayIf = ({
683
698
  condition = (value) => !!value,
684
699
  onToggle
685
700
  }) => {
686
- const initializedRef = React7.useRef(false);
687
- const matchesRef = React7.useRef(false);
701
+ const initializedRef = React8.useRef(false);
702
+ const matchesRef = React8.useRef(false);
688
703
  const value = (0, import_react_hook_form5.useWatch)({
689
704
  name,
690
705
  defaultValue,
@@ -693,7 +708,7 @@ var DisplayIf = ({
693
708
  });
694
709
  const context = useFormContext();
695
710
  const matches = condition(value, context);
696
- React7.useEffect(() => {
711
+ React8.useEffect(() => {
697
712
  if (!initializedRef.current) {
698
713
  initializedRef.current = true;
699
714
  return;
@@ -707,10 +722,10 @@ var DisplayIf = ({
707
722
  DisplayIf.displayName = "DisplayIf";
708
723
 
709
724
  // src/field.tsx
710
- var React8 = __toESM(require("react"));
725
+ var React9 = __toESM(require("react"));
711
726
  var import_jsx_runtime8 = require("react/jsx-runtime");
712
727
  var defaultInputType = "text";
713
- var Field2 = React8.forwardRef(
728
+ var Field2 = React9.forwardRef(
714
729
  (props, ref) => {
715
730
  const { type = defaultInputType, name } = props;
716
731
  const overrides = useFieldProps(name);
@@ -720,14 +735,14 @@ var Field2 = React8.forwardRef(
720
735
  );
721
736
 
722
737
  // src/fields.tsx
723
- var React9 = __toESM(require("react"));
738
+ var React10 = __toESM(require("react"));
724
739
 
725
740
  // src/object-field.tsx
726
- var import_react9 = require("@chakra-ui/react");
741
+ var import_react10 = require("@chakra-ui/react");
727
742
  var import_utils7 = require("@saas-ui/core/utils");
728
743
  var import_jsx_runtime9 = require("react/jsx-runtime");
729
744
  var FormLegend = (props) => {
730
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react9.Field.Label, { as: "legend", ...props });
745
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react10.Field.Label, { as: "legend", ...props });
731
746
  };
732
747
  var ObjectField = (props) => {
733
748
  const {
@@ -741,7 +756,7 @@ var ObjectField = (props) => {
741
756
  } = props;
742
757
  const { hideLabel, columns, gap, ...overrides } = useFieldProps(name);
743
758
  const hidden = hideLabelProp || hideLabel;
744
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react9.Field.Root, { as: "fieldset", ...fieldProps, ...overrides, children: [
759
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react10.Field.Root, { as: "fieldset", ...fieldProps, ...overrides, children: [
745
760
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FormLegend, { "data-hidden": (0, import_utils7.dataAttr)(hidden), children: label }),
746
761
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FormLayout, { columns: columnsProp || columns, gridGap: gapProp || gap, children: mapNestedFields(name, children) })
747
762
  ] });
@@ -773,10 +788,10 @@ var AutoFields = ({
773
788
  const context = useFormContext();
774
789
  const schema = schemaProp || context.schema;
775
790
  const fieldResolver = fieldResolverProp || context.fieldResolver;
776
- const resolver = React9.useMemo(() => fieldResolver, [schema, fieldResolver]);
777
- const fields = React9.useMemo(() => resolver == null ? void 0 : resolver.getFields(), [resolver]);
791
+ const resolver = React10.useMemo(() => fieldResolver, [schema, fieldResolver]);
792
+ const fields = React10.useMemo(() => resolver == null ? void 0 : resolver.getFields(), [resolver]);
778
793
  const form = useFormContext();
779
- React9.useEffect(() => {
794
+ React10.useEffect(() => {
780
795
  var _a;
781
796
  if (focusFirstField && ((_a = fields == null ? void 0 : fields[0]) == null ? void 0 : _a.name)) {
782
797
  form.setFocus(fields[0].name);
@@ -807,11 +822,11 @@ var AutoFields = ({
807
822
  AutoFields.displayName = "Fields";
808
823
 
809
824
  // src/submit-button.tsx
810
- var import_react10 = require("react");
825
+ var import_react11 = require("react");
811
826
  var import_button = require("@saas-ui/react/button");
812
827
  var import_react_hook_form6 = require("react-hook-form");
813
828
  var import_jsx_runtime11 = require("react/jsx-runtime");
814
- var SubmitButton = (0, import_react10.forwardRef)(
829
+ var SubmitButton = (0, import_react11.forwardRef)(
815
830
  (props, ref) => {
816
831
  const {
817
832
  variant = "glass",
@@ -853,7 +868,7 @@ SubmitButton.displayName = "SubmitButton";
853
868
 
854
869
  // src/form.tsx
855
870
  var import_jsx_runtime12 = require("react/jsx-runtime");
856
- var Form = (0, import_react11.forwardRef)(
871
+ var Form = (0, import_react12.forwardRef)(
857
872
  (props, ref) => {
858
873
  const {
859
874
  mode = "all",
@@ -894,8 +909,8 @@ var Form = (0, import_react11.forwardRef)(
894
909
  };
895
910
  const methods = (0, import_react_hook_form7.useForm)(form);
896
911
  const { handleSubmit } = methods;
897
- import_react11.default.useImperativeHandle(formRef, () => methods, [formRef, methods]);
898
- import_react11.default.useEffect(() => {
912
+ import_react12.default.useImperativeHandle(formRef, () => methods, [formRef, methods]);
913
+ import_react12.default.useEffect(() => {
899
914
  let subscription;
900
915
  if (onChange) {
901
916
  subscription = methods.watch(onChange);
@@ -917,7 +932,7 @@ var Form = (0, import_react11.forwardRef)(
917
932
  fieldResolver,
918
933
  fields,
919
934
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
920
- import_react12.chakra.form,
935
+ import_react13.chakra.form,
921
936
  {
922
937
  ref,
923
938
  onSubmit: handleSubmit(onSubmit, onError),
@@ -946,7 +961,7 @@ function createForm({
946
961
  fields,
947
962
  getBaseField
948
963
  } = {}) {
949
- const DefaultForm = (0, import_react13.forwardRef)(
964
+ const DefaultForm = (0, import_react14.forwardRef)(
950
965
  (props, ref) => {
951
966
  const {
952
967
  schema,
@@ -954,7 +969,7 @@ function createForm({
954
969
  fieldResolver: fieldResolverProp,
955
970
  ...rest
956
971
  } = props;
957
- const fieldsContext = (0, import_react13.useMemo)(
972
+ const fieldsContext = (0, import_react14.useMemo)(
958
973
  () => ({
959
974
  fields: { ...defaultFieldTypes, ...fields },
960
975
  getBaseField
@@ -978,16 +993,16 @@ function createForm({
978
993
  }
979
994
 
980
995
  // src/display-field.tsx
981
- var import_react14 = require("@chakra-ui/react");
996
+ var import_react15 = require("@chakra-ui/react");
982
997
  var import_jsx_runtime14 = require("react/jsx-runtime");
983
998
  var DisplayField = ({
984
999
  name,
985
1000
  label,
986
1001
  ...props
987
1002
  }) => {
988
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react14.Field.Root, { ...props, children: [
989
- label ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react14.Field.Label, { htmlFor: name, children: label }) : null,
990
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react14.Text, { fontSize: "md", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FormValue, { name }) })
1003
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react15.Field.Root, { ...props, children: [
1004
+ label ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react15.Field.Label, { htmlFor: name, children: label }) : null,
1005
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react15.Text, { fontSize: "md", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FormValue, { name }) })
991
1006
  ] });
992
1007
  };
993
1008
  DisplayField.displayName = "DisplayField";