@inertiajs/svelte 2.1.2 → 2.1.3
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/components/Form.svelte +10 -2
- package/dist/createInertiaApp.js +1 -1
- package/dist/link.js +13 -1
- package/dist/page.d.ts +7 -2
- package/dist/useForm.js +7 -3
- package/package.json +26 -22
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
resetFormFields,
|
|
4
4
|
mergeDataIntoQueryString
|
|
5
5
|
} from "@inertiajs/core";
|
|
6
|
-
import { isEqual } from "es
|
|
6
|
+
import { isEqual } from "lodash-es";
|
|
7
7
|
import { onMount } from "svelte";
|
|
8
8
|
import useForm from "../useForm";
|
|
9
9
|
const noop = () => void 0;
|
|
@@ -96,6 +96,12 @@ function handleSubmit(event) {
|
|
|
96
96
|
event.preventDefault();
|
|
97
97
|
submit();
|
|
98
98
|
}
|
|
99
|
+
function handleReset(event) {
|
|
100
|
+
if (event.isTrusted) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
reset();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
99
105
|
export function reset(...fields) {
|
|
100
106
|
resetFormFields(formElement, defaultData, fields);
|
|
101
107
|
}
|
|
@@ -132,7 +138,9 @@ $: slotErrors = $form.errors;
|
|
|
132
138
|
bind:this={formElement}
|
|
133
139
|
action={_action}
|
|
134
140
|
method={_method}
|
|
135
|
-
on:submit={handleSubmit}
|
|
141
|
+
on:submit={handleSubmit}
|
|
142
|
+
on:reset={handleReset}
|
|
143
|
+
{...$$restProps}
|
|
136
144
|
inert={disableWhileProcessing && $form.processing ? true : undefined}
|
|
137
145
|
>
|
|
138
146
|
<slot
|
package/dist/createInertiaApp.js
CHANGED
package/dist/link.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mergeDataIntoQueryString, router, shouldIntercept, } from '@inertiajs/core';
|
|
1
|
+
import { mergeDataIntoQueryString, router, shouldIntercept, shouldNavigate, } from '@inertiajs/core';
|
|
2
2
|
function link(node, initialParams = {}) {
|
|
3
3
|
let inFlightCount = 0;
|
|
4
4
|
let hoverTimeout;
|
|
@@ -30,10 +30,22 @@ function link(node, initialParams = {}) {
|
|
|
30
30
|
prefetch();
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
+
keydown: (event) => {
|
|
34
|
+
if (shouldIntercept(event) && shouldNavigate(event)) {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
prefetch();
|
|
37
|
+
}
|
|
38
|
+
},
|
|
33
39
|
mouseup: (event) => {
|
|
34
40
|
event.preventDefault();
|
|
35
41
|
router.visit(href, visitParams);
|
|
36
42
|
},
|
|
43
|
+
keyup: (event) => {
|
|
44
|
+
if (shouldNavigate(event)) {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
router.visit(href, visitParams);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
37
49
|
click: (event) => {
|
|
38
50
|
if (shouldIntercept(event)) {
|
|
39
51
|
event.preventDefault();
|
package/dist/page.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { type Page } from '@inertiajs/core';
|
|
2
|
-
|
|
2
|
+
type SveltePage = Omit<Page, 'props'> & {
|
|
3
|
+
props: Page['props'] & {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export declare const setPage: (this: void, value: SveltePage) => void;
|
|
3
8
|
declare const _default: {
|
|
4
|
-
subscribe: (this: void, run: import("svelte/store").Subscriber<
|
|
9
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<SveltePage>, invalidate?: import("svelte/store").Invalidator<SveltePage> | undefined) => import("svelte/store").Unsubscriber;
|
|
5
10
|
};
|
|
6
11
|
export default _default;
|
package/dist/useForm.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { router } from '@inertiajs/core';
|
|
2
|
-
import { cloneDeep, isEqual } from 'es
|
|
3
|
-
import { get, has, set } from 'es-toolkit/compat';
|
|
2
|
+
import { cloneDeep, get, has, isEqual, set } from 'lodash-es';
|
|
4
3
|
import { writable } from 'svelte/store';
|
|
5
4
|
export default function useForm(rememberKeyOrData, maybeData) {
|
|
6
5
|
const rememberKey = typeof rememberKeyOrData === 'string' ? rememberKeyOrData : null;
|
|
@@ -13,6 +12,7 @@ export default function useForm(rememberKeyOrData, maybeData) {
|
|
|
13
12
|
let cancelToken = null;
|
|
14
13
|
let recentlySuccessfulTimeoutId = null;
|
|
15
14
|
let transform = (data) => data;
|
|
15
|
+
let defaultsCalledInOnSuccess = false;
|
|
16
16
|
const store = writable({
|
|
17
17
|
...(restored ? restored.data : data),
|
|
18
18
|
isDirty: false,
|
|
@@ -37,6 +37,7 @@ export default function useForm(rememberKeyOrData, maybeData) {
|
|
|
37
37
|
return this;
|
|
38
38
|
},
|
|
39
39
|
defaults(fieldOrFields, maybeValue) {
|
|
40
|
+
defaultsCalledInOnSuccess = true;
|
|
40
41
|
if (typeof fieldOrFields === 'undefined') {
|
|
41
42
|
defaults = cloneDeep(this.data());
|
|
42
43
|
}
|
|
@@ -86,6 +87,7 @@ export default function useForm(rememberKeyOrData, maybeData) {
|
|
|
86
87
|
const method = objectPassed ? args[0].method : args[0];
|
|
87
88
|
const url = objectPassed ? args[0].url : args[1];
|
|
88
89
|
const options = (objectPassed ? args[1] : args[2]) ?? {};
|
|
90
|
+
defaultsCalledInOnSuccess = false;
|
|
89
91
|
const data = transform(this.data());
|
|
90
92
|
const _options = {
|
|
91
93
|
...options,
|
|
@@ -125,7 +127,9 @@ export default function useForm(rememberKeyOrData, maybeData) {
|
|
|
125
127
|
this.setStore('recentlySuccessful', true);
|
|
126
128
|
recentlySuccessfulTimeoutId = setTimeout(() => this.setStore('recentlySuccessful', false), 2000);
|
|
127
129
|
const onSuccess = options.onSuccess ? await options.onSuccess(page) : null;
|
|
128
|
-
|
|
130
|
+
if (!defaultsCalledInOnSuccess) {
|
|
131
|
+
this.defaults(cloneDeep(this.data()));
|
|
132
|
+
}
|
|
129
133
|
return onSuccess;
|
|
130
134
|
},
|
|
131
135
|
onError: (errors) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/svelte",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The Svelte adapter for Inertia.js",
|
|
6
6
|
"contributors": [
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/inertiajs/inertia/issues"
|
|
18
18
|
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"!dist/**/*.test.*",
|
|
22
|
+
"!dist/**/*.spec.*"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"svelte": "./dist/index.js",
|
|
19
27
|
"exports": {
|
|
20
28
|
".": {
|
|
21
29
|
"types": "./dist/index.d.ts",
|
|
@@ -26,26 +34,14 @@
|
|
|
26
34
|
"svelte": "./dist/server.js"
|
|
27
35
|
}
|
|
28
36
|
},
|
|
29
|
-
"files": [
|
|
30
|
-
"dist",
|
|
31
|
-
"!dist/**/*.test.*",
|
|
32
|
-
"!dist/**/*.spec.*"
|
|
33
|
-
],
|
|
34
|
-
"peerDependencies": {
|
|
35
|
-
"svelte": "^4.0.0 || ^5.0.0 || ^5.0.0-next.244"
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"es-toolkit": "^1.33.0",
|
|
39
|
-
"html-escape": "^2.0.0",
|
|
40
|
-
"@inertiajs/core": "2.1.2"
|
|
41
|
-
},
|
|
42
37
|
"devDependencies": {
|
|
43
38
|
"@sveltejs/adapter-auto": "^3.2.0",
|
|
44
|
-
"@sveltejs/kit": "^2.
|
|
39
|
+
"@sveltejs/kit": "^2.36.3",
|
|
45
40
|
"@sveltejs/package": "^2.3.4",
|
|
46
41
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
|
47
42
|
"@types/html-escape": "^2.0.2",
|
|
48
|
-
"axios": "^1.
|
|
43
|
+
"axios": "^1.11.0",
|
|
44
|
+
"es-check": "^9.3.1",
|
|
49
45
|
"publint": "^0.2.10",
|
|
50
46
|
"svelte": "^4.2.19",
|
|
51
47
|
"svelte-check": "^4.0.0",
|
|
@@ -53,14 +49,22 @@
|
|
|
53
49
|
"typescript": "^5.5.4",
|
|
54
50
|
"vite": "^5.4.19"
|
|
55
51
|
},
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"svelte": "^4.0.0 || ^5.0.0"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@types/lodash-es": "^4.17.12",
|
|
57
|
+
"html-escape": "^2.0.0",
|
|
58
|
+
"lodash-es": "^4.17.21",
|
|
59
|
+
"@inertiajs/core": "2.1.3"
|
|
60
|
+
},
|
|
59
61
|
"scripts": {
|
|
60
|
-
"dev": "pnpm package --watch",
|
|
61
62
|
"build": "pnpm package && publint",
|
|
62
|
-
"
|
|
63
|
+
"build:with-deps": "svelte-kit sync && vite build --config vite-with-deps.config.js",
|
|
63
64
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
64
|
-
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
|
65
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
66
|
+
"dev": "pnpm package --watch",
|
|
67
|
+
"es2020-check": "pnpm build:with-deps && es-check es2020 \"dist/**/*.js\" --checkFeatures --module --noCache --verbose",
|
|
68
|
+
"package": "svelte-kit sync && svelte-package --input src"
|
|
65
69
|
}
|
|
66
70
|
}
|