@inertiajs/svelte 2.3.11 → 2.3.13
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.
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
<script>import { page } from "../index";
|
|
2
|
-
import { onDestroy } from "svelte";
|
|
3
2
|
export let data;
|
|
4
3
|
const keys = Array.isArray(data) ? data : [data];
|
|
5
|
-
|
|
6
|
-
const isServer = typeof window === "undefined";
|
|
7
|
-
if (!isServer) {
|
|
8
|
-
const unsubscribe = page.subscribe(({ props }) => {
|
|
9
|
-
window.queueMicrotask(() => {
|
|
10
|
-
loaded = keys.every((key) => typeof props[key] !== "undefined");
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
onDestroy(() => {
|
|
14
|
-
unsubscribe();
|
|
15
|
-
});
|
|
16
|
-
}
|
|
4
|
+
$: loaded = keys.every((key) => typeof $page.props[key] !== "undefined");
|
|
17
5
|
if (!$$slots.fallback) {
|
|
18
6
|
throw new Error('`<Deferred>` requires a `<svelte:fragment slot="fallback">` slot');
|
|
19
7
|
}
|
|
@@ -75,6 +75,11 @@ function updateDirtyState(event) {
|
|
|
75
75
|
}
|
|
76
76
|
export function submit(submitter) {
|
|
77
77
|
const [url, data] = getUrlAndData(submitter);
|
|
78
|
+
const formTarget = submitter?.getAttribute("formtarget");
|
|
79
|
+
if (formTarget === "_blank" && _method === "get") {
|
|
80
|
+
window.open(url, "_blank");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
78
83
|
const maybeReset = (resetOption) => {
|
|
79
84
|
if (!resetOption) {
|
|
80
85
|
return;
|
|
@@ -30,16 +30,16 @@ declare const __propDef: {
|
|
|
30
30
|
mouseout: MouseEvent;
|
|
31
31
|
mouseover: MouseEvent;
|
|
32
32
|
mouseup: MouseEvent;
|
|
33
|
-
'cancel-token':
|
|
34
|
-
before:
|
|
35
|
-
start:
|
|
33
|
+
'cancel-token': InputEvent | UIEvent | Event | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
34
|
+
before: InputEvent | UIEvent | Event | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
35
|
+
start: InputEvent | UIEvent | Event | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
36
36
|
progress: ProgressEvent<EventTarget>;
|
|
37
|
-
finish:
|
|
37
|
+
finish: InputEvent | UIEvent | Event | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
38
38
|
cancel: Event;
|
|
39
|
-
success:
|
|
39
|
+
success: InputEvent | UIEvent | Event | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
40
40
|
error: ErrorEvent;
|
|
41
|
-
prefetching:
|
|
42
|
-
prefetched:
|
|
41
|
+
prefetching: InputEvent | UIEvent | Event | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
42
|
+
prefetched: InputEvent | UIEvent | Event | SubmitEvent | ProgressEvent<EventTarget> | ErrorEvent | FormDataEvent | AnimationEvent | PointerEvent | MouseEvent | ToggleEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | KeyboardEvent | SecurityPolicyViolationEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
43
43
|
} & {
|
|
44
44
|
[evt: string]: CustomEvent<any>;
|
|
45
45
|
};
|
package/dist/useForm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ErrorValue, FormDataErrors, FormDataKeys, FormDataType, FormDataValues, Method, Progress, UrlMethodPair, UseFormSubmitArguments, UseFormSubmitOptions, UseFormTransformCallback, UseFormWithPrecognitionArguments } from '@inertiajs/core';
|
|
2
|
-
import type { NamedInputEvent, ValidationConfig, Validator } from 'laravel-precognition';
|
|
2
|
+
import type { NamedInputEvent, PrecognitionPath, ValidationConfig, Validator } from 'laravel-precognition';
|
|
3
3
|
import { type Writable } from 'svelte/store';
|
|
4
4
|
type InertiaFormStore<TForm extends object> = Writable<InertiaForm<TForm>> & InertiaForm<TForm>;
|
|
5
5
|
type InertiaPrecognitiveFormStore<TForm extends object> = Writable<InertiaPrecognitiveForm<TForm>> & InertiaPrecognitiveForm<TForm>;
|
|
@@ -42,7 +42,7 @@ export interface InertiaFormValidationProps<TForm extends object> {
|
|
|
42
42
|
touch<K extends FormDataKeys<TForm>>(field: K | NamedInputEvent | Array<K>, ...fields: K[]): this;
|
|
43
43
|
touched<K extends FormDataKeys<TForm>>(field?: K): boolean;
|
|
44
44
|
valid<K extends FormDataKeys<TForm>>(field: K): boolean;
|
|
45
|
-
validate<K extends FormDataKeys<TForm>>(field?: K | NamedInputEvent | PrecognitionValidationConfig<K>, config?: PrecognitionValidationConfig<K>): this;
|
|
45
|
+
validate<K extends FormDataKeys<TForm> | PrecognitionPath<TForm>>(field?: K | NamedInputEvent | PrecognitionValidationConfig<K>, config?: PrecognitionValidationConfig<K>): this;
|
|
46
46
|
validateFiles(): this;
|
|
47
47
|
validating: boolean;
|
|
48
48
|
validator: () => Validator;
|
|
@@ -54,7 +54,7 @@ export interface InertiaFormValidationProps<TForm extends object> {
|
|
|
54
54
|
export type InertiaForm<TForm extends object> = InertiaFormProps<TForm> & TForm;
|
|
55
55
|
export type InertiaPrecognitiveForm<TForm extends object> = InertiaForm<TForm> & InertiaFormValidationProps<TForm>;
|
|
56
56
|
type ReservedFormKeys = keyof InertiaFormProps<any>;
|
|
57
|
-
type ValidateFormData<T> = {
|
|
57
|
+
type ValidateFormData<T> = string extends keyof T ? T : {
|
|
58
58
|
[K in keyof T]: K extends ReservedFormKeys ? ['Error: This field name is reserved by useForm:', K] : T[K];
|
|
59
59
|
};
|
|
60
60
|
export default function useForm<TForm extends FormDataType<TForm>>(method: Method | (() => Method), url: string | (() => string), data: ValidateFormData<TForm> | (() => ValidateFormData<TForm>)): InertiaPrecognitiveFormStore<TForm>;
|
package/dist/useForm.js
CHANGED
|
@@ -263,7 +263,8 @@ export default function useForm(...args) {
|
|
|
263
263
|
onError: (errors) => {
|
|
264
264
|
setFormState('processing', false);
|
|
265
265
|
setFormState('progress', null);
|
|
266
|
-
|
|
266
|
+
setFormState('errors', errors);
|
|
267
|
+
validatorRef?.setErrors(errors);
|
|
267
268
|
if (options.onError) {
|
|
268
269
|
return options.onError(errors);
|
|
269
270
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/svelte",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The Svelte adapter for Inertia.js",
|
|
6
6
|
"contributors": [
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@types/lodash-es": "^4.17.12",
|
|
56
|
-
"laravel-precognition": "^1.0.
|
|
57
|
-
"lodash-es": "^4.17.
|
|
58
|
-
"@inertiajs/core": "2.3.
|
|
56
|
+
"laravel-precognition": "^1.0.1",
|
|
57
|
+
"lodash-es": "^4.17.23",
|
|
58
|
+
"@inertiajs/core": "2.3.13"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "pnpm package && svelte-check --tsconfig ./tsconfig.json && publint",
|