@inertiajs/react 2.3.12 → 2.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -255,6 +255,7 @@ var Deferred_default = Deferred;
255
255
 
256
256
  // src/Form.ts
257
257
  import {
258
+ config as config2,
258
259
  FormComponentResetSymbol,
259
260
  formDataToObject,
260
261
  isUrlMethodPair,
@@ -334,7 +335,7 @@ function useForm(...args) {
334
335
  const [validating, setValidating] = useState4(false);
335
336
  const [touchedFields, setTouchedFields] = useState4([]);
336
337
  const [validFields, setValidFields] = useState4([]);
337
- const withAllErrors = useRef(false);
338
+ const withAllErrors = useRef(null);
338
339
  useEffect5(() => {
339
340
  isMounted.current = true;
340
341
  return () => {
@@ -601,18 +602,18 @@ function useForm(...args) {
601
602
  (field) => typeof field === "string" ? touchedFields.includes(field) : touchedFields.length > 0,
602
603
  [touchedFields]
603
604
  );
604
- const validate = (field, config2) => {
605
+ const validate = (field, config3) => {
605
606
  if (typeof field === "object" && !("target" in field)) {
606
- config2 = field;
607
+ config3 = field;
607
608
  field = void 0;
608
609
  }
609
610
  if (field === void 0) {
610
- validatorRef.current.validate(config2);
611
+ validatorRef.current.validate(config3);
611
612
  } else {
612
613
  const fieldName = resolveName(field);
613
614
  const currentData = dataRef.current;
614
615
  const transformedData = transform.current(currentData);
615
- validatorRef.current.validate(fieldName, get(transformedData, fieldName), config2);
616
+ validatorRef.current.validate(fieldName, get(transformedData, fieldName), config3);
616
617
  }
617
618
  return form;
618
619
  };
@@ -633,7 +634,7 @@ function useForm(...args) {
633
634
  }).on("touchedChanged", () => {
634
635
  setTouchedFields(validator.touched());
635
636
  }).on("errorsChanged", () => {
636
- const validationErrors = withAllErrors.current ? validator.errors() : toSimpleValidationErrors(validator.errors());
637
+ const validationErrors = withAllErrors.current ?? config.get("form.withAllErrors") ? validator.errors() : toSimpleValidationErrors(validator.errors());
637
638
  setErrors(validationErrors);
638
639
  setHasErrors(Object.keys(validationErrors).length > 0);
639
640
  setValidFields(validator.valid());
@@ -704,7 +705,7 @@ var Form = forwardRef(
704
705
  invalidateCacheTags = [],
705
706
  validateFiles = false,
706
707
  validationTimeout = 1500,
707
- withAllErrors = false,
708
+ withAllErrors = null,
708
709
  children,
709
710
  ...props
710
711
  }, ref) => {
@@ -719,7 +720,7 @@ var Form = forwardRef(
719
720
  if (validateFiles) {
720
721
  form.validateFiles();
721
722
  }
722
- if (withAllErrors) {
723
+ if (withAllErrors ?? config2.get("form.withAllErrors")) {
723
724
  form.withAllErrors();
724
725
  }
725
726
  form.transform(getTransformedData);
@@ -855,7 +856,7 @@ var Form = forwardRef(
855
856
  validating: form.validating,
856
857
  valid: form.valid,
857
858
  invalid: form.invalid,
858
- validate: (field, config2) => form.validate(...UseFormUtils2.mergeHeadersForValidation(field, config2, headers)),
859
+ validate: (field, config3) => form.validate(...UseFormUtils2.mergeHeadersForValidation(field, config3, headers)),
859
860
  touch: form.touch,
860
861
  touched: form.touched
861
862
  };