@inertiajs/svelte 3.0.2 → 3.0.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.
@@ -13,7 +13,7 @@
13
13
  <script lang="ts">
14
14
  import type { Component } from 'svelte'
15
15
  import type { LayoutType, LayoutResolver } from '../types'
16
- import { isPropsObject, normalizeLayouts } from '@inertiajs/core'
16
+ import { isPropsObjectOrCallback, isPropsObject, normalizeLayouts } from '@inertiajs/core'
17
17
  import { router } from '@inertiajs/core'
18
18
  import Render, { h, type RenderProps } from './Render.svelte'
19
19
  import { setPage } from '../page.svelte'
@@ -110,7 +110,7 @@
110
110
  ) {
111
111
  const result = (layoutValue as Function)(page.props)
112
112
 
113
- if (isPropsObject(result, isComponent)) {
113
+ if (isPropsObjectOrCallback(result, isComponent)) {
114
114
  effectiveLayout = defaultLayout?.(page.component, page) as LayoutType | undefined
115
115
  callbackProps = result as Record<string, unknown>
116
116
  } else {
@@ -1,9 +1,12 @@
1
1
  import type { FormComponentProps, FormComponentSlotProps } from '@inertiajs/core';
2
2
  import type { Component, ComponentProps, Snippet } from 'svelte';
3
3
  import Form from './Form.svelte';
4
- type TypedFormComponent<TForm extends Record<string, any>> = Component<Omit<ComponentProps<typeof Form>, 'children' | 'optimistic' | 'transform'> & {
4
+ type TypedFormComponent<TForm extends Record<string, any>> = Component<Omit<ComponentProps<typeof Form>, 'children' | 'optimistic' | 'transform' | 'resetOnSuccess' | 'resetOnError' | 'onSubmitComplete'> & {
5
5
  optimistic?: FormComponentProps<TForm>['optimistic'];
6
6
  transform?: FormComponentProps<TForm>['transform'];
7
+ resetOnSuccess?: FormComponentProps<TForm>['resetOnSuccess'];
8
+ resetOnError?: FormComponentProps<TForm>['resetOnError'];
9
+ onSubmitComplete?: FormComponentProps<TForm>['onSubmitComplete'];
7
10
  children?: Snippet<[FormComponentSlotProps<TForm>]>;
8
11
  }>;
9
12
  export declare function createForm<TForm extends Record<string, any> = Record<string, any>>(): TypedFormComponent<TForm>;
@@ -78,7 +78,7 @@ export default function useHttp(...args) {
78
78
  if (response.status >= 200 && response.status < 300) {
79
79
  markAsSuccessful();
80
80
  setFormState('response', responseData);
81
- options.onSuccess?.(responseData);
81
+ options.onSuccess?.(responseData, response);
82
82
  if (!wasDefaultsCalledInOnSuccess()) {
83
83
  setDefaults(cloneDeep(form.data()));
84
84
  }
@@ -102,12 +102,16 @@ export default function useHttp(...args) {
102
102
  form.clearErrors().setError(processedErrors);
103
103
  options.onError?.(processedErrors);
104
104
  }
105
+ else {
106
+ options.onHttpException?.(error.response);
107
+ }
105
108
  throw error;
106
109
  }
107
110
  if (error instanceof HttpCancelledError || (error instanceof Error && error.name === 'AbortError')) {
108
111
  options.onCancel?.();
109
112
  throw new HttpCancelledError('Request was cancelled', url);
110
113
  }
114
+ options.onNetworkError?.(error instanceof Error ? error : new Error('Unknown error'));
111
115
  throw error;
112
116
  }
113
117
  finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inertiajs/svelte",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "license": "MIT",
5
5
  "description": "The Svelte adapter for Inertia.js",
6
6
  "contributors": [
@@ -39,7 +39,7 @@
39
39
  "@sveltejs/adapter-auto": "^7.0.1",
40
40
  "@sveltejs/kit": "^2.53.2",
41
41
  "@sveltejs/package": "^2.5.7",
42
- "@sveltejs/vite-plugin-svelte": "^6.2.4",
42
+ "@sveltejs/vite-plugin-svelte": "^7.0.0",
43
43
  "axios": "^1.13.5",
44
44
  "es-check": "9.5.3",
45
45
  "publint": "^0.3.17",
@@ -47,7 +47,7 @@
47
47
  "svelte-check": "^4.4.3",
48
48
  "tslib": "^2.8.1",
49
49
  "typescript": "^5.9.3",
50
- "vite": "^7.3.1"
50
+ "vite": "^8.0.5"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "svelte": "^5.0.0"
@@ -55,7 +55,7 @@
55
55
  "dependencies": {
56
56
  "es-toolkit": "^1.33.0",
57
57
  "laravel-precognition": "^2.0.0",
58
- "@inertiajs/core": "3.0.2"
58
+ "@inertiajs/core": "3.0.3"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "pnpm package && svelte-check --tsconfig ./tsconfig.json && publint",