@inertiajs/svelte 2.0.13 → 2.0.15

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/LICENSE CHANGED
File without changes
@@ -13,11 +13,11 @@ 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;
18
- $: asProp = method !== "get" ? "button" : as.toLowerCase();
16
+ $: _method = typeof href === "object" ? href.method : method;
17
+ $: _href = typeof href === "object" ? href.url : href;
18
+ $: asProp = _method !== "get" ? "button" : as.toLowerCase();
19
19
  $: elProps = {
20
- a: { href },
20
+ a: { href: _href },
21
21
  button: { type: "button" }
22
22
  }[asProp] || {};
23
23
  </script>
@@ -26,12 +26,12 @@ $: elProps = {
26
26
  <svelte:element
27
27
  this={asProp}
28
28
  use:inertia={{
29
- ...(as !== 'a' ? { href } : {}),
29
+ ...(asProp !== 'a' ? { href: _href } : {}),
30
30
  data,
31
- method,
31
+ method: _method,
32
32
  replace,
33
33
  preserveScroll,
34
- preserveState: preserveState ?? method !== 'get',
34
+ preserveState: preserveState ?? _method !== 'get',
35
35
  only,
36
36
  except,
37
37
  headers,
@@ -1,6 +1,6 @@
1
1
  import { router, setupProgress } from '@inertiajs/core';
2
2
  import escape from 'html-escape';
3
- import App, {} from './components/App.svelte';
3
+ import App from './components/App.svelte';
4
4
  export default async function createInertiaApp({ id = 'app', resolve, setup, progress = {}, page, }) {
5
5
  const isServer = typeof window === 'undefined';
6
6
  const el = isServer ? null : document.getElementById(id);
package/dist/index.js CHANGED
@@ -5,7 +5,6 @@ export { default as WhenVisible } from './components/WhenVisible.svelte';
5
5
  export { default as createInertiaApp } from './createInertiaApp';
6
6
  export { default as inertia } from './link';
7
7
  export { default as page } from './page';
8
- export {} from './types';
9
8
  export { default as useForm } from './useForm';
10
9
  export { default as usePoll } from './usePoll';
11
10
  export { default as usePrefetch } from './usePrefetch';
package/dist/page.js CHANGED
@@ -1,4 +1,3 @@
1
- import {} from '@inertiajs/core';
2
1
  import { writable } from 'svelte/store';
3
2
  const { set, subscribe } = writable();
4
3
  export const setPage = set;
package/dist/useForm.d.ts CHANGED
@@ -19,6 +19,7 @@ export interface InertiaFormProps<TForm extends FormDataType> {
19
19
  defaults(field?: FormDataKeys<TForm>, value?: FormDataConvertible): this;
20
20
  reset(...fields: FormDataKeys<TForm>[]): this;
21
21
  clearErrors(...fields: FormDataKeys<TForm>[]): this;
22
+ resetAndClearErrors(...fields: FormDataKeys<TForm>[]): this;
22
23
  setError(field: FormDataKeys<TForm>, value: string): this;
23
24
  setError(errors: Errors): this;
24
25
  submit: (...args: [Method, string, FormOptions?] | [{
package/dist/useForm.js CHANGED
@@ -76,6 +76,11 @@ export default function useForm(rememberKeyOrData, maybeData) {
76
76
  }), {}));
77
77
  return this;
78
78
  },
79
+ resetAndClearErrors(...fields) {
80
+ this.reset(...fields);
81
+ this.clearErrors(...fields);
82
+ return this;
83
+ },
79
84
  submit(...args) {
80
85
  const objectPassed = typeof args[0] === 'object';
81
86
  const method = objectPassed ? args[0].method : args[0];
@@ -118,11 +123,10 @@ export default function useForm(rememberKeyOrData, maybeData) {
118
123
  this.clearErrors();
119
124
  this.setStore('wasSuccessful', true);
120
125
  this.setStore('recentlySuccessful', true);
121
- this.defaults(cloneDeep(this.data()));
122
126
  recentlySuccessfulTimeoutId = setTimeout(() => this.setStore('recentlySuccessful', false), 2000);
123
- if (options.onSuccess) {
124
- return options.onSuccess(page);
125
- }
127
+ const onSuccess = options.onSuccess ? await options.onSuccess(page) : null;
128
+ this.defaults(cloneDeep(this.data()));
129
+ return onSuccess;
126
130
  },
127
131
  onError: (errors) => {
128
132
  this.setStore('processing', false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inertiajs/svelte",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
4
4
  "license": "MIT",
5
5
  "description": "The Svelte adapter for Inertia.js",
6
6
  "contributors": [
@@ -16,14 +16,6 @@
16
16
  "bugs": {
17
17
  "url": "https://github.com/inertiajs/inertia/issues"
18
18
  },
19
- "scripts": {
20
- "dev": "npm run package -- --watch",
21
- "build": "npm run package && publint",
22
- "package": "svelte-kit sync && svelte-package --input src",
23
- "prepublishOnly": "npm run build",
24
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
25
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
26
- },
27
19
  "exports": {
28
20
  ".": {
29
21
  "types": "./dist/index.d.ts",
@@ -43,9 +35,9 @@
43
35
  "svelte": "^4.0.0 || ^5.0.0 || ^5.0.0-next.244"
44
36
  },
45
37
  "dependencies": {
46
- "@inertiajs/core": "2.0.13",
47
38
  "es-toolkit": "^1.33.0",
48
- "html-escape": "^2.0.0"
39
+ "html-escape": "^2.0.0",
40
+ "@inertiajs/core": "2.0.15"
49
41
  },
50
42
  "devDependencies": {
51
43
  "@sveltejs/adapter-auto": "^3.2.0",
@@ -63,5 +55,12 @@
63
55
  },
64
56
  "svelte": "./dist/index.js",
65
57
  "types": "./dist/index.d.ts",
66
- "type": "module"
58
+ "type": "module",
59
+ "scripts": {
60
+ "dev": "pnpm package --watch",
61
+ "build": "pnpm package && publint",
62
+ "package": "svelte-kit sync && svelte-package --input src",
63
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
64
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
65
+ }
67
66
  }
package/readme.md CHANGED
File without changes