@inertiajs/svelte 2.3.8 → 2.3.10
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,5 +1,6 @@
|
|
|
1
1
|
<script>import {
|
|
2
2
|
formDataToObject,
|
|
3
|
+
FormComponentResetSymbol,
|
|
3
4
|
resetFormFields,
|
|
4
5
|
mergeDataIntoQueryString,
|
|
5
6
|
isUrlMethodPair,
|
|
@@ -7,7 +8,9 @@
|
|
|
7
8
|
} from "@inertiajs/core";
|
|
8
9
|
import {} from "laravel-precognition";
|
|
9
10
|
import { isEqual } from "lodash-es";
|
|
10
|
-
import { onMount } from "svelte";
|
|
11
|
+
import { onMount, setContext } from "svelte";
|
|
12
|
+
import { writable } from "svelte/store";
|
|
13
|
+
import { FormContextKey } from "./formContext";
|
|
11
14
|
import useForm from "../useForm";
|
|
12
15
|
const noop = () => void 0;
|
|
13
16
|
export let action = "";
|
|
@@ -65,6 +68,9 @@ function getUrlAndData(submitter) {
|
|
|
65
68
|
return mergeDataIntoQueryString(_method, _action, getData(submitter), queryStringArrayFormat);
|
|
66
69
|
}
|
|
67
70
|
function updateDirtyState(event) {
|
|
71
|
+
if (event.type === "reset" && event.detail?.[FormComponentResetSymbol]) {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
}
|
|
68
74
|
isDirty = event.type === "reset" ? false : !isEqual(getData(), formDataToObject(defaultData));
|
|
69
75
|
}
|
|
70
76
|
export function submit(submitter) {
|
|
@@ -181,6 +187,33 @@ $: {
|
|
|
181
187
|
}
|
|
182
188
|
}
|
|
183
189
|
$: slotErrors = $form.errors;
|
|
190
|
+
const formContextStore = writable(void 0);
|
|
191
|
+
$: formContextStore.set({
|
|
192
|
+
errors: $form.errors,
|
|
193
|
+
hasErrors: $form.hasErrors,
|
|
194
|
+
processing: $form.processing,
|
|
195
|
+
progress: $form.progress,
|
|
196
|
+
wasSuccessful: $form.wasSuccessful,
|
|
197
|
+
recentlySuccessful: $form.recentlySuccessful,
|
|
198
|
+
isDirty,
|
|
199
|
+
clearErrors,
|
|
200
|
+
resetAndClearErrors,
|
|
201
|
+
setError,
|
|
202
|
+
reset,
|
|
203
|
+
submit,
|
|
204
|
+
defaults,
|
|
205
|
+
getData,
|
|
206
|
+
getFormData,
|
|
207
|
+
// Precognition
|
|
208
|
+
validator,
|
|
209
|
+
validate,
|
|
210
|
+
touch,
|
|
211
|
+
validating: $form.validating,
|
|
212
|
+
valid,
|
|
213
|
+
invalid,
|
|
214
|
+
touched
|
|
215
|
+
});
|
|
216
|
+
setContext(FormContextKey, formContextStore);
|
|
184
217
|
</script>
|
|
185
218
|
|
|
186
219
|
<form
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { progress, router } from '@inertiajs/core';
|
|
|
2
2
|
export { default as App } from './components/App.svelte';
|
|
3
3
|
export { default as Deferred } from './components/Deferred.svelte';
|
|
4
4
|
export { default as Form } from './components/Form.svelte';
|
|
5
|
+
export { useFormContext } from './components/formContext';
|
|
5
6
|
export { default as InfiniteScroll } from './components/InfiniteScroll.svelte';
|
|
6
7
|
export { default as Link } from './components/Link.svelte';
|
|
7
8
|
export { default as WhenVisible } from './components/WhenVisible.svelte';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { progress, router } from '@inertiajs/core';
|
|
|
3
3
|
export { default as App } from './components/App.svelte';
|
|
4
4
|
export { default as Deferred } from './components/Deferred.svelte';
|
|
5
5
|
export { default as Form } from './components/Form.svelte';
|
|
6
|
+
export { useFormContext } from './components/formContext';
|
|
6
7
|
export { default as InfiniteScroll } from './components/InfiniteScroll.svelte';
|
|
7
8
|
export { default as Link } from './components/Link.svelte';
|
|
8
9
|
export { default as WhenVisible } from './components/WhenVisible.svelte';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/svelte",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The Svelte adapter for Inertia.js",
|
|
6
6
|
"contributors": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@types/lodash-es": "^4.17.12",
|
|
56
56
|
"laravel-precognition": "^1.0.0",
|
|
57
57
|
"lodash-es": "^4.17.21",
|
|
58
|
-
"@inertiajs/core": "2.3.
|
|
58
|
+
"@inertiajs/core": "2.3.10"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "pnpm package && svelte-check --tsconfig ./tsconfig.json && publint",
|