@inertiajs/svelte
Advanced tools
@@ -38,6 +38,6 @@ <script>import { | ||
| export let withAllErrors = false; | ||
| function getTransformedData() { | ||
| const getTransformedData = () => { | ||
| const [_url, data] = getUrlAndData(); | ||
| return transform(data); | ||
| } | ||
| }; | ||
| const form = useForm({}).withPrecognition( | ||
@@ -59,10 +59,10 @@ () => _method, | ||
| $: _action = isUrlMethodPair(action) ? action.url : action; | ||
| export function getFormData() { | ||
| return new FormData(formElement); | ||
| export function getFormData(submitter) { | ||
| return new FormData(formElement, submitter); | ||
| } | ||
| export function getData() { | ||
| return formDataToObject(getFormData()); | ||
| export function getData(submitter) { | ||
| return formDataToObject(getFormData(submitter)); | ||
| } | ||
| function getUrlAndData() { | ||
| return mergeDataIntoQueryString(_method, _action, getData(), queryStringArrayFormat); | ||
| function getUrlAndData(submitter) { | ||
| return mergeDataIntoQueryString(_method, _action, getData(submitter), queryStringArrayFormat); | ||
| } | ||
@@ -72,4 +72,4 @@ function updateDirtyState(event) { | ||
| } | ||
| export function submit() { | ||
| const [url, _data] = getUrlAndData(); | ||
| export function submit(submitter) { | ||
| const [url, data] = getUrlAndData(submitter); | ||
| const maybeReset = (resetOption) => { | ||
@@ -120,7 +120,8 @@ if (!resetOption) { | ||
| }; | ||
| $form.transform(() => transform(_data)).submit(_method, url, submitOptions); | ||
| $form.transform(() => transform(data)).submit(_method, url, submitOptions); | ||
| $form.transform(getTransformedData); | ||
| } | ||
| function handleSubmit(event) { | ||
| event.preventDefault(); | ||
| submit(); | ||
| submit(event.submitter); | ||
| } | ||
@@ -127,0 +128,0 @@ function handleReset(event) { |
@@ -32,5 +32,5 @@ import { SvelteComponent } from "svelte"; | ||
| withAllErrors?: boolean | undefined; | ||
| getFormData?: (() => FormData) | undefined; | ||
| getData?: (() => Record<string, FormDataConvertible>) | undefined; | ||
| submit?: (() => void) | undefined; | ||
| getFormData?: ((submitter?: HTMLElement | null) => FormData) | undefined; | ||
| getData?: ((submitter?: HTMLElement | null) => Record<string, FormDataConvertible>) | undefined; | ||
| submit?: ((submitter?: HTMLElement | null) => void) | undefined; | ||
| reset?: ((...fields: string[]) => void) | undefined; | ||
@@ -63,7 +63,7 @@ clearErrors?: ((...fields: string[]) => void) | undefined; | ||
| isDirty: boolean; | ||
| submit: () => void; | ||
| submit: (submitter?: HTMLElement | null) => void; | ||
| defaults: () => void; | ||
| reset: (...fields: string[]) => void; | ||
| getData: () => Record<string, FormDataConvertible>; | ||
| getFormData: () => FormData; | ||
| getData: (submitter?: HTMLElement | null) => Record<string, FormDataConvertible>; | ||
| getFormData: (submitter?: HTMLElement | null) => FormData; | ||
| validator: () => Validator; | ||
@@ -85,5 +85,5 @@ validate: (field?: string | NamedInputEvent | ValidationConfig, config?: ValidationConfig) => import("svelte/store").Writable<import("../useForm").InertiaPrecognitiveForm<Record<string, any>>> & import("../useForm").InertiaFormProps<Record<string, any>> & Record<string, any> & import("../useForm").InertiaFormValidationProps<Record<string, any>>; | ||
| export default class Form extends SvelteComponent<FormProps, FormEvents, FormSlots> { | ||
| get getFormData(): () => FormData; | ||
| get getData(): () => Record<string, FormDataConvertible>; | ||
| get submit(): () => void; | ||
| get getFormData(): (submitter?: HTMLElement | null) => FormData; | ||
| get getData(): (submitter?: HTMLElement | null) => Record<string, FormDataConvertible>; | ||
| get submit(): (submitter?: HTMLElement | null) => void; | ||
| get reset(): (...fields: string[]) => void; | ||
@@ -90,0 +90,0 @@ get clearErrors(): (...fields: string[]) => void; |
@@ -33,12 +33,12 @@ import { SvelteComponent } from "svelte"; | ||
| mouseup: MouseEvent; | ||
| 'cancel-token': Event | InputEvent | UIEvent | ProgressEvent<EventTarget> | SubmitEvent | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| before: Event | InputEvent | UIEvent | ProgressEvent<EventTarget> | SubmitEvent | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| start: Event | InputEvent | UIEvent | ProgressEvent<EventTarget> | SubmitEvent | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| 'cancel-token': Event | InputEvent | UIEvent | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| before: Event | InputEvent | UIEvent | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| start: Event | InputEvent | UIEvent | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| progress: ProgressEvent<EventTarget>; | ||
| finish: Event | InputEvent | UIEvent | ProgressEvent<EventTarget> | SubmitEvent | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| finish: Event | InputEvent | UIEvent | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| cancel: Event; | ||
| success: Event | InputEvent | UIEvent | ProgressEvent<EventTarget> | SubmitEvent | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| success: Event | InputEvent | UIEvent | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| error: ErrorEvent; | ||
| prefetching: Event | InputEvent | UIEvent | ProgressEvent<EventTarget> | SubmitEvent | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| prefetched: Event | InputEvent | UIEvent | ProgressEvent<EventTarget> | SubmitEvent | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| prefetching: Event | InputEvent | UIEvent | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| prefetched: Event | InputEvent | UIEvent | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent; | ||
| } & { | ||
@@ -45,0 +45,0 @@ [evt: string]: CustomEvent<any>; |
@@ -77,5 +77,5 @@ <script>import { router } from "@inertiajs/core"; | ||
| {#if loaded} | ||
| <slot /> | ||
| <slot {fetching} /> | ||
| {:else if $$slots.fallback} | ||
| <slot name="fallback" /> | ||
| {/if} |
@@ -15,3 +15,5 @@ import { SvelteComponent } from "svelte"; | ||
| slots: { | ||
| default: {}; | ||
| default: { | ||
| fetching: boolean; | ||
| }; | ||
| fallback: {}; | ||
@@ -18,0 +20,0 @@ }; |
+1
-1
@@ -12,3 +12,3 @@ export { progress, router } from '@inertiajs/core'; | ||
| export { type ResolvedComponent, type SvelteInertiaAppConfig } from './types'; | ||
| export { default as useForm, type InertiaForm, type InertiaFormProps } from './useForm'; | ||
| export { default as useForm, type InertiaForm, type InertiaFormProps, type InertiaPrecognitiveForm } from './useForm'; | ||
| export { default as usePoll } from './usePoll'; | ||
@@ -15,0 +15,0 @@ export { default as usePrefetch } from './usePrefetch'; |
+2
-2
| { | ||
| "name": "@inertiajs/svelte", | ||
| "version": "2.3.1", | ||
| "version": "2.3.2", | ||
| "license": "MIT", | ||
@@ -58,3 +58,3 @@ "description": "The Svelte adapter for Inertia.js", | ||
| "lodash-es": "^4.17.21", | ||
| "@inertiajs/core": "2.3.1" | ||
| "@inertiajs/core": "2.3.2" | ||
| }, | ||
@@ -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
75272
0.64%1164
0.17%+ Added
- Removed
Updated