@inertiajs/react
Advanced tools
+10
-9
@@ -258,2 +258,3 @@ // src/index.ts | ||
| import { | ||
| config as config2, | ||
| FormComponentResetSymbol, | ||
@@ -338,3 +339,3 @@ formDataToObject, | ||
| const [validFields, setValidFields] = useState4([]); | ||
| const withAllErrors = useRef(false); | ||
| const withAllErrors = useRef(null); | ||
| useEffect5(() => { | ||
@@ -606,9 +607,9 @@ isMounted.current = true; | ||
| ); | ||
| const validate = (field, config2) => { | ||
| const validate = (field, config3) => { | ||
| if (typeof field === "object" && !("target" in field)) { | ||
| config2 = field; | ||
| config3 = field; | ||
| field = void 0; | ||
| } | ||
| if (field === void 0) { | ||
| validatorRef.current.validate(config2); | ||
| validatorRef.current.validate(config3); | ||
| } else { | ||
@@ -618,3 +619,3 @@ const fieldName = resolveName(field); | ||
| const transformedData = transform.current(currentData); | ||
| validatorRef.current.validate(fieldName, get(transformedData, fieldName), config2); | ||
| validatorRef.current.validate(fieldName, get(transformedData, fieldName), config3); | ||
| } | ||
@@ -640,3 +641,3 @@ return form; | ||
| }).on("errorsChanged", () => { | ||
| const validationErrors = withAllErrors.current ? validator.errors() : toSimpleValidationErrors(validator.errors()); | ||
| const validationErrors = withAllErrors.current ?? config.get("form.withAllErrors") ? validator.errors() : toSimpleValidationErrors(validator.errors()); | ||
| setErrors(validationErrors); | ||
@@ -712,3 +713,3 @@ setHasErrors(Object.keys(validationErrors).length > 0); | ||
| validationTimeout = 1500, | ||
| withAllErrors = false, | ||
| withAllErrors = null, | ||
| children, | ||
@@ -728,3 +729,3 @@ ...props | ||
| } | ||
| if (withAllErrors) { | ||
| if (withAllErrors ?? config2.get("form.withAllErrors")) { | ||
| form.withAllErrors(); | ||
@@ -865,3 +866,3 @@ } | ||
| invalid: form.invalid, | ||
| validate: (field, config2) => form.validate(...UseFormUtils2.mergeHeadersForValidation(field, config2, headers)), | ||
| validate: (field, config3) => form.validate(...UseFormUtils2.mergeHeadersForValidation(field, config3, headers)), | ||
| touch: form.touch, | ||
@@ -868,0 +869,0 @@ touched: form.touched |
+9
-9
@@ -356,3 +356,3 @@ "use strict"; | ||
| const [validFields, setValidFields] = (0, import_react10.useState)([]); | ||
| const withAllErrors = (0, import_react10.useRef)(false); | ||
| const withAllErrors = (0, import_react10.useRef)(null); | ||
| (0, import_react10.useEffect)(() => { | ||
@@ -624,9 +624,9 @@ isMounted.current = true; | ||
| ); | ||
| const validate = (field, config2) => { | ||
| const validate = (field, config3) => { | ||
| if (typeof field === "object" && !("target" in field)) { | ||
| config2 = field; | ||
| config3 = field; | ||
| field = void 0; | ||
| } | ||
| if (field === void 0) { | ||
| validatorRef.current.validate(config2); | ||
| validatorRef.current.validate(config3); | ||
| } else { | ||
@@ -636,3 +636,3 @@ const fieldName = (0, import_laravel_precognition.resolveName)(field); | ||
| const transformedData = transform.current(currentData); | ||
| validatorRef.current.validate(fieldName, (0, import_lodash_es.get)(transformedData, fieldName), config2); | ||
| validatorRef.current.validate(fieldName, (0, import_lodash_es.get)(transformedData, fieldName), config3); | ||
| } | ||
@@ -658,3 +658,3 @@ return form; | ||
| }).on("errorsChanged", () => { | ||
| const validationErrors = withAllErrors.current ? validator.errors() : (0, import_laravel_precognition.toSimpleValidationErrors)(validator.errors()); | ||
| const validationErrors = withAllErrors.current ?? config.get("form.withAllErrors") ? validator.errors() : (0, import_laravel_precognition.toSimpleValidationErrors)(validator.errors()); | ||
| setErrors(validationErrors); | ||
@@ -730,3 +730,3 @@ setHasErrors(Object.keys(validationErrors).length > 0); | ||
| validationTimeout = 1500, | ||
| withAllErrors = false, | ||
| withAllErrors = null, | ||
| children, | ||
@@ -746,3 +746,3 @@ ...props | ||
| } | ||
| if (withAllErrors) { | ||
| if (withAllErrors ?? import_core5.config.get("form.withAllErrors")) { | ||
| form.withAllErrors(); | ||
@@ -883,3 +883,3 @@ } | ||
| invalid: form.invalid, | ||
| validate: (field, config2) => form.validate(...import_core5.UseFormUtils.mergeHeadersForValidation(field, config2, headers)), | ||
| validate: (field, config3) => form.validate(...import_core5.UseFormUtils.mergeHeadersForValidation(field, config3, headers)), | ||
| touch: form.touch, | ||
@@ -886,0 +886,0 @@ touched: form.touched |
+2
-2
| { | ||
| "name": "@inertiajs/react", | ||
| "version": "2.3.13", | ||
| "version": "2.3.14", | ||
| "license": "MIT", | ||
@@ -64,3 +64,3 @@ "description": "The React adapter for Inertia.js", | ||
| "lodash-es": "^4.17.23", | ||
| "@inertiajs/core": "2.3.13" | ||
| "@inertiajs/core": "2.3.14" | ||
| }, | ||
@@ -67,0 +67,0 @@ "scripts": { |
+2
-2
@@ -15,4 +15,4 @@ import { FormComponentRef, FormComponentSlotProps, FormDataConvertible, Method } from '@inertiajs/core'; | ||
| validationTimeout?: number; | ||
| withAllErrors?: boolean; | ||
| } & Omit<React.FormHTMLAttributes<HTMLFormElement>, "children" | "method" | "headers" | "errorBag" | "queryStringArrayFormat" | "showProgress" | "invalidateCacheTags" | "onCancelToken" | "onBefore" | "onBeforeUpdate" | "onStart" | "onProgress" | "onFinish" | "onCancel" | "onSuccess" | "onError" | "onFlash" | "options" | "action" | "transform" | "onSubmitComplete" | "disableWhileProcessing" | "resetOnSuccess" | "resetOnError" | "setDefaultsOnSuccess" | "validateFiles" | "validationTimeout" | "withAllErrors"> & Omit<React.AllHTMLAttributes<HTMLFormElement>, "children" | "method" | "headers" | "errorBag" | "queryStringArrayFormat" | "showProgress" | "invalidateCacheTags" | "onCancelToken" | "onBefore" | "onBeforeUpdate" | "onStart" | "onProgress" | "onFinish" | "onCancel" | "onSuccess" | "onError" | "onFlash" | "options" | "action" | "transform" | "onSubmitComplete" | "disableWhileProcessing" | "resetOnSuccess" | "resetOnError" | "setDefaultsOnSuccess" | "validateFiles" | "validationTimeout" | "withAllErrors"> & { | ||
| withAllErrors?: boolean | null; | ||
| } & Omit<React.FormHTMLAttributes<HTMLFormElement>, "children" | "method" | "headers" | "errorBag" | "queryStringArrayFormat" | "showProgress" | "invalidateCacheTags" | "onCancelToken" | "onBefore" | "onBeforeUpdate" | "onStart" | "onProgress" | "onFinish" | "onCancel" | "onSuccess" | "onError" | "onFlash" | "withAllErrors" | "options" | "action" | "transform" | "onSubmitComplete" | "disableWhileProcessing" | "resetOnSuccess" | "resetOnError" | "setDefaultsOnSuccess" | "validateFiles" | "validationTimeout"> & Omit<React.AllHTMLAttributes<HTMLFormElement>, "children" | "method" | "headers" | "errorBag" | "queryStringArrayFormat" | "showProgress" | "invalidateCacheTags" | "onCancelToken" | "onBefore" | "onBeforeUpdate" | "onStart" | "onProgress" | "onFinish" | "onCancel" | "onSuccess" | "onError" | "onFlash" | "withAllErrors" | "options" | "action" | "transform" | "onSubmitComplete" | "disableWhileProcessing" | "resetOnSuccess" | "resetOnError" | "setDefaultsOnSuccess" | "validateFiles" | "validationTimeout"> & { | ||
| children: ReactNode | ((props: FormComponentSlotProps) => ReactNode); | ||
@@ -19,0 +19,0 @@ } & React.RefAttributes<FormComponentSlotProps>>; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
342200
0.16%3539
0.03%+ Added
- Removed
Updated