@inertiajs/svelte 2.0.4 → 2.0.6
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/Link.svelte +3 -1
- package/dist/components/Link.svelte.d.ts +4 -1
- package/dist/link.d.ts +5 -2
- package/dist/link.js +2 -2
- package/dist/useForm.d.ts +4 -1
- package/dist/useForm.js +6 -1
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>import { inertia } from "../index";
|
|
2
|
-
export let href;
|
|
2
|
+
export let href = "";
|
|
3
3
|
export let as = "a";
|
|
4
4
|
export let data = {};
|
|
5
5
|
export let method = "get";
|
|
@@ -13,6 +13,8 @@ export let queryStringArrayFormat = "brackets";
|
|
|
13
13
|
export let async = false;
|
|
14
14
|
export let prefetch = false;
|
|
15
15
|
export let cacheFor = 0;
|
|
16
|
+
method = typeof href === "object" ? href.method : method;
|
|
17
|
+
href = typeof href === "object" ? href.url : href;
|
|
16
18
|
$: asProp = method !== "get" ? "button" : as.toLowerCase();
|
|
17
19
|
$: elProps = {
|
|
18
20
|
a: { href },
|
|
@@ -3,7 +3,10 @@ import type { CacheForOption, FormDataConvertible, LinkPrefetchOption, Method, P
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
[x: string]: any;
|
|
6
|
-
href
|
|
6
|
+
href?: string | {
|
|
7
|
+
url: string;
|
|
8
|
+
method: Method;
|
|
9
|
+
} | undefined;
|
|
7
10
|
as?: keyof HTMLElementTagNameMap | undefined;
|
|
8
11
|
data?: Record<string, FormDataConvertible> | undefined;
|
|
9
12
|
method?: Method | undefined;
|
package/dist/link.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { type CacheForOption, type FormDataConvertible, type GlobalEventsMap, type LinkPrefetchOption, type VisitOptions } from '@inertiajs/core';
|
|
1
|
+
import { type CacheForOption, type FormDataConvertible, type GlobalEventsMap, type LinkPrefetchOption, type Method, type VisitOptions } from '@inertiajs/core';
|
|
2
2
|
import type { CancelTokenSource } from 'axios';
|
|
3
3
|
import type { ActionReturn } from 'svelte/action';
|
|
4
4
|
interface ActionElement extends HTMLElement {
|
|
5
5
|
href?: string;
|
|
6
6
|
}
|
|
7
7
|
type ActionParameters = Omit<VisitOptions, 'data' | 'prefetch'> & {
|
|
8
|
-
href?: string
|
|
8
|
+
href?: string | {
|
|
9
|
+
url: string;
|
|
10
|
+
method: Method;
|
|
11
|
+
};
|
|
9
12
|
data?: Record<string, FormDataConvertible>;
|
|
10
13
|
prefetch?: boolean | LinkPrefetchOption | LinkPrefetchOption[];
|
|
11
14
|
cacheFor?: CacheForOption | CacheForOption[];
|
package/dist/link.js
CHANGED
|
@@ -58,7 +58,7 @@ function link(node, initialParams = {}) {
|
|
|
58
58
|
}
|
|
59
59
|
return 30_000;
|
|
60
60
|
})();
|
|
61
|
-
method = (params.method?.toLowerCase() || 'get');
|
|
61
|
+
method = typeof params.href === 'object' ? params.href.method : (params.method?.toLowerCase() || 'get');
|
|
62
62
|
[href, data] = hrefAndData(method, params);
|
|
63
63
|
if (node.tagName === 'A') {
|
|
64
64
|
node.href = href;
|
|
@@ -99,7 +99,7 @@ function link(node, initialParams = {}) {
|
|
|
99
99
|
return node.dispatchEvent(new CustomEvent(type, detail));
|
|
100
100
|
}
|
|
101
101
|
function hrefAndData(method, params) {
|
|
102
|
-
return mergeDataIntoQueryString(method, node.href || params.href || '', params.data || {}, params.queryStringArrayFormat || 'brackets');
|
|
102
|
+
return mergeDataIntoQueryString(method, typeof params.href === 'object' ? params.href.url : node.href || params.href || '', params.data || {}, params.queryStringArrayFormat || 'brackets');
|
|
103
103
|
}
|
|
104
104
|
function prefetch() {
|
|
105
105
|
router.prefetch(href, baseParams, { cacheFor: cacheForValue });
|
package/dist/useForm.d.ts
CHANGED
|
@@ -21,7 +21,10 @@ export interface InertiaFormProps<TForm extends FormDataType> {
|
|
|
21
21
|
clearErrors(...fields: (keyof TForm)[]): this;
|
|
22
22
|
setError(field: keyof TForm, value: string): this;
|
|
23
23
|
setError(errors: Errors): this;
|
|
24
|
-
submit(
|
|
24
|
+
submit: (...args: [Method, string, FormOptions?] | [{
|
|
25
|
+
url: string;
|
|
26
|
+
method: Method;
|
|
27
|
+
}, FormOptions?]) => void;
|
|
25
28
|
get(url: string, options?: FormOptions): void;
|
|
26
29
|
post(url: string, options?: FormOptions): void;
|
|
27
30
|
put(url: string, options?: FormOptions): void;
|
package/dist/useForm.js
CHANGED
|
@@ -73,7 +73,11 @@ export default function useForm(rememberKeyOrData, maybeData) {
|
|
|
73
73
|
}), {}));
|
|
74
74
|
return this;
|
|
75
75
|
},
|
|
76
|
-
submit(
|
|
76
|
+
submit(...args) {
|
|
77
|
+
const objectPassed = typeof args[0] === 'object';
|
|
78
|
+
const method = objectPassed ? args[0].method : args[0];
|
|
79
|
+
const url = objectPassed ? args[0].url : args[1];
|
|
80
|
+
const options = (objectPassed ? args[1] : args[2]) ?? {};
|
|
77
81
|
const data = transform(this.data());
|
|
78
82
|
const _options = {
|
|
79
83
|
...options,
|
|
@@ -111,6 +115,7 @@ export default function useForm(rememberKeyOrData, maybeData) {
|
|
|
111
115
|
this.clearErrors();
|
|
112
116
|
this.setStore('wasSuccessful', true);
|
|
113
117
|
this.setStore('recentlySuccessful', true);
|
|
118
|
+
this.defaults(cloneDeep(this.data()));
|
|
114
119
|
recentlySuccessfulTimeoutId = setTimeout(() => this.setStore('recentlySuccessful', false), 2000);
|
|
115
120
|
if (options.onSuccess) {
|
|
116
121
|
return options.onSuccess(page);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/svelte",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The Svelte adapter for Inertia.js",
|
|
6
6
|
"contributors": [
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"svelte": "^4.0.0 || ^5.0.0 || ^5.0.0-next.244"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@inertiajs/core": "2.0.
|
|
46
|
+
"@inertiajs/core": "2.0.6",
|
|
47
47
|
"html-escape": "^2.0.0",
|
|
48
48
|
"lodash": "^4.5.0"
|
|
49
49
|
},
|
|
@@ -54,13 +54,13 @@
|
|
|
54
54
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
|
55
55
|
"@types/html-escape": "^2.0.2",
|
|
56
56
|
"@types/lodash": "^4.17.7",
|
|
57
|
-
"axios": "^1.
|
|
57
|
+
"axios": "^1.8.2",
|
|
58
58
|
"publint": "^0.2.10",
|
|
59
59
|
"svelte": "^4.2.16",
|
|
60
60
|
"svelte-check": "^4.0.0",
|
|
61
61
|
"tslib": "^2.7.0",
|
|
62
62
|
"typescript": "^5.5.4",
|
|
63
|
-
"vite": "^5.4.
|
|
63
|
+
"vite": "^5.4.16"
|
|
64
64
|
},
|
|
65
65
|
"svelte": "./dist/index.js",
|
|
66
66
|
"types": "./dist/index.d.ts",
|