@inertiajs/svelte
Advanced tools
| <script>import { | ||
| config, | ||
| formDataToObject, | ||
@@ -40,3 +41,3 @@ FormComponentResetSymbol, | ||
| export let validationTimeout = 1500; | ||
| export let withAllErrors = false; | ||
| export let withAllErrors = null; | ||
| const getTransformedData = () => { | ||
@@ -53,3 +54,3 @@ const [_url, data] = getUrlAndData(); | ||
| } | ||
| if (withAllErrors) { | ||
| if (withAllErrors ?? config.get("form.withAllErrors")) { | ||
| form.withAllErrors(); | ||
@@ -161,4 +162,4 @@ } | ||
| } | ||
| export function validate(field, config) { | ||
| return form.validate(...UseFormUtils.mergeHeadersForValidation(field, config, headers)); | ||
| export function validate(field, config2) { | ||
| return form.validate(...UseFormUtils.mergeHeadersForValidation(field, config2, headers)); | ||
| } | ||
@@ -165,0 +166,0 @@ export function valid(field) { |
@@ -31,3 +31,3 @@ import { SvelteComponent } from "svelte"; | ||
| validationTimeout?: number | undefined; | ||
| withAllErrors?: boolean | undefined; | ||
| withAllErrors?: boolean | null | undefined; | ||
| getFormData?: ((submitter?: HTMLElement | null) => FormData) | undefined; | ||
@@ -34,0 +34,0 @@ getData?: ((submitter?: HTMLElement | null) => Record<string, FormDataConvertible>) | undefined; |
@@ -57,10 +57,10 @@ import type { ErrorValue, FormDataErrors, FormDataKeys, FormDataType, FormDataValues, Method, Progress, UrlMethodPair, UseFormSubmitArguments, UseFormSubmitOptions, UseFormTransformCallback, UseFormWithPrecognitionArguments } from '@inertiajs/core'; | ||
| type ReservedFormKeys = keyof InertiaFormProps<any>; | ||
| type ValidateFormData<T> = string extends keyof T ? T : { | ||
| type ValidateFormData<T> = { | ||
| [K in keyof T]: K extends ReservedFormKeys ? ['Error: This field name is reserved by useForm:', K] : T[K]; | ||
| }; | ||
| export default function useForm<TForm extends FormDataType<TForm>>(method: Method | (() => Method), url: string | (() => string), data: ValidateFormData<TForm> | (() => ValidateFormData<TForm>)): InertiaPrecognitiveFormStore<TForm>; | ||
| export default function useForm<TForm extends FormDataType<TForm>>(urlMethodPair: UrlMethodPair | (() => UrlMethodPair), data: ValidateFormData<TForm> | (() => ValidateFormData<TForm>)): InertiaPrecognitiveFormStore<TForm>; | ||
| export default function useForm<TForm extends FormDataType<TForm>>(rememberKey: string, data: ValidateFormData<TForm> | (() => ValidateFormData<TForm>)): InertiaFormStore<TForm>; | ||
| export default function useForm<TForm extends FormDataType<TForm>>(data: ValidateFormData<TForm> | (() => ValidateFormData<TForm>)): InertiaFormStore<TForm>; | ||
| export default function useForm<TForm extends FormDataType<TForm> & ValidateFormData<TForm>>(method: Method | (() => Method), url: string | (() => string), data: TForm | (() => TForm)): InertiaPrecognitiveFormStore<TForm>; | ||
| export default function useForm<TForm extends FormDataType<TForm> & ValidateFormData<TForm>>(urlMethodPair: UrlMethodPair | (() => UrlMethodPair), data: TForm | (() => TForm)): InertiaPrecognitiveFormStore<TForm>; | ||
| export default function useForm<TForm extends FormDataType<TForm> & ValidateFormData<TForm>>(rememberKey: string, data: TForm | (() => TForm)): InertiaFormStore<TForm>; | ||
| export default function useForm<TForm extends FormDataType<TForm> & ValidateFormData<TForm>>(data: TForm | (() => TForm)): InertiaFormStore<TForm>; | ||
| export default function useForm<TForm extends FormDataType<TForm>>(): InertiaFormStore<TForm>; | ||
| export {}; |
+4
-2
@@ -44,3 +44,3 @@ import { router, UseFormUtils } from '@inertiajs/core'; | ||
| const formWithPrecognition = () => getStore(store); | ||
| let withAllErrors = false; | ||
| let withAllErrors = null; | ||
| if (!validatorRef) { | ||
@@ -65,3 +65,5 @@ const validator = createValidator((client) => { | ||
| .on('errorsChanged', () => { | ||
| const validationErrors = withAllErrors ? validator.errors() : toSimpleValidationErrors(validator.errors()); | ||
| const validationErrors = (withAllErrors ?? config.get('form.withAllErrors')) | ||
| ? validator.errors() | ||
| : toSimpleValidationErrors(validator.errors()); | ||
| setFormState('errors', {}); | ||
@@ -68,0 +70,0 @@ formWithPrecognition().setError(validationErrors); |
+2
-2
| { | ||
| "name": "@inertiajs/svelte", | ||
| "version": "2.3.13", | ||
| "version": "2.3.14", | ||
| "license": "MIT", | ||
@@ -58,3 +58,3 @@ "description": "The Svelte adapter for Inertia.js", | ||
| "lodash-es": "^4.17.23", | ||
| "@inertiajs/core": "2.3.13" | ||
| "@inertiajs/core": "2.3.14" | ||
| }, | ||
@@ -61,0 +61,0 @@ "scripts": { |
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
78822
0.08%1223
0.16%+ Added
- Removed
Updated