@inertiajs/vue3 2.3.17 → 3.0.0-beta.2

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/server.js CHANGED
@@ -1,37 +1,6 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
1
  // src/server.ts
31
- var server_exports = {};
32
- __export(server_exports, {
33
- default: () => import_server.default
34
- });
35
- module.exports = __toCommonJS(server_exports);
36
- var import_server = __toESM(require("@inertiajs/core/server"), 1);
2
+ import { default as default2 } from "@inertiajs/core/server";
3
+ export {
4
+ default2 as default
5
+ };
37
6
  //# sourceMappingURL=server.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/server.ts"],
4
4
  "sourcesContent": ["export { default as default } from '@inertiajs/core/server'\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmC;",
6
- "names": []
5
+ "mappings": ";AAAA,SAAoB,WAAXA,gBAA0B;",
6
+ "names": ["default"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inertiajs/vue3",
3
- "version": "2.3.17",
3
+ "version": "3.0.0-beta.2",
4
4
  "license": "MIT",
5
5
  "description": "The Vue 3 adapter for Inertia.js",
6
6
  "contributors": [
@@ -9,7 +9,7 @@
9
9
  "homepage": "https://inertiajs.com/",
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/inertiajs/inertia.git",
12
+ "url": "git+https://github.com/inertiajs/inertia.git",
13
13
  "directory": "packages/vue3"
14
14
  },
15
15
  "bugs": {
@@ -26,13 +26,11 @@
26
26
  "exports": {
27
27
  ".": {
28
28
  "types": "./types/index.d.ts",
29
- "import": "./dist/index.esm.js",
30
- "require": "./dist/index.js"
29
+ "import": "./dist/index.js"
31
30
  },
32
31
  "./server": {
33
32
  "types": "./types/server.d.ts",
34
- "import": "./dist/server.esm.js",
35
- "require": "./dist/server.js"
33
+ "import": "./dist/server.js"
36
34
  }
37
35
  },
38
36
  "typesVersions": {
@@ -55,9 +53,9 @@
55
53
  },
56
54
  "dependencies": {
57
55
  "@types/lodash-es": "^4.17.12",
58
- "laravel-precognition": "^1.0.2",
56
+ "laravel-precognition": "2.0.0-beta.3",
59
57
  "lodash-es": "^4.17.23",
60
- "@inertiajs/core": "2.3.17"
58
+ "@inertiajs/core": "3.0.0-beta.2"
61
59
  },
62
60
  "scripts": {
63
61
  "build": "pnpm clean && ./build.js && tsc",
@@ -66,6 +64,6 @@
66
64
  "dev": "pnpx concurrently -c \"#ffcf00,#3178c6\" \"pnpm dev:build\" \"pnpm dev:types\" --names build,types",
67
65
  "dev:build": "./build.js --watch",
68
66
  "dev:types": "tsc --watch --preserveWatchOutput",
69
- "es2020-check": "pnpm build:with-deps && es-check es2020 \"dist/index.esm.js\" --checkFeatures --module --noCache --verbose"
67
+ "es2020-check": "pnpm build:with-deps && es-check es2020 \"dist/index.js\" --checkFeatures --module --noCache --verbose"
70
68
  }
71
69
  }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: inertia-vue-development
3
- description: "Develops Inertia.js v2 Vue client-side applications. Activates when creating Vue pages, forms, or navigation; using <Link>, <Form>, useForm, or router; working with deferred props, prefetching, or polling; or when user mentions Vue with Inertia, Vue pages, Vue forms, or Vue navigation."
3
+ description: "Develops Inertia.js v3 Vue client-side applications. Activates when creating Vue pages, forms, or navigation; using <Link>, <Form>, useForm, useHttp, useLayoutProps, or router; working with deferred props, prefetching, optimistic updates, instant visits, or polling; or when user mentions Vue with Inertia, Vue pages, Vue forms, or Vue navigation."
4
4
  license: MIT
5
5
  metadata:
6
6
  author: laravel
@@ -15,14 +15,14 @@ metadata:
15
15
  Activate this skill when:
16
16
 
17
17
  - Creating or modifying Vue page components for Inertia
18
- - Working with forms in Vue (using `<Form>` or `useForm`)
18
+ - Working with forms in Vue (using `<Form>`, `useForm`, or `useHttp`)
19
19
  - Implementing client-side navigation with `<Link>` or `router`
20
- - Using v2 features: deferred props, prefetching, WhenVisible, InfiniteScroll, once props, flash data, or polling
20
+ - Using v3 features: deferred props, prefetching, optimistic updates, instant visits, layout props, HTTP requests, WhenVisible, InfiniteScroll, once props, flash data, or polling
21
21
  - Building Vue-specific features with the Inertia protocol
22
22
 
23
23
  ## Documentation
24
24
 
25
- Use `search-docs` for detailed Inertia v2 Vue patterns and documentation.
25
+ Use `search-docs` for detailed Inertia v3 Vue patterns and documentation.
26
26
 
27
27
  ## Basic Usage
28
28
 
@@ -293,7 +293,134 @@ function submit() {
293
293
  @endboostsnippet
294
294
  @endverbatim
295
295
 
296
- ## Inertia v2 Features
296
+ ## Inertia v3 Features
297
+
298
+ ### HTTP Requests
299
+
300
+ Use the `useHttp` hook for standalone HTTP requests that do not trigger Inertia page visits. It provides the same developer experience as `useForm`, but for plain JSON endpoints.
301
+
302
+ @boostsnippet("useHttp Example", "vue")
303
+ <script setup>
304
+ import { useHttp } from '@inertiajs/vue3'
305
+
306
+ const http = useHttp({
307
+ query: '',
308
+ })
309
+
310
+ function search() {
311
+ http.get('/api/search', {
312
+ onSuccess: (response) => {
313
+ console.log(response)
314
+ },
315
+ })
316
+ }
317
+ </script>
318
+
319
+ <template>
320
+ <input v-model="http.query" @input="search" />
321
+ <div v-if="http.processing">Searching...</div>
322
+ </template>
323
+ @endboostsnippet
324
+
325
+ ### Optimistic Updates
326
+
327
+ Apply data changes instantly before the server responds, with automatic rollback on failure:
328
+
329
+ @boostsnippet("Optimistic Update with Router", "vue")
330
+ <script setup>
331
+ import { router } from '@inertiajs/vue3'
332
+
333
+ function like(post) {
334
+ router.optimistic((props) => ({
335
+ post: {
336
+ ...props.post,
337
+ likes: props.post.likes + 1,
338
+ },
339
+ })).post(`/posts/${post.id}/like`)
340
+ }
341
+ </script>
342
+ @endboostsnippet
343
+
344
+ Optimistic updates also work with `useForm` and the `<Form>` component:
345
+
346
+ @verbatim
347
+ @boostsnippet("Optimistic Update with Form Component", "vue")
348
+ <template>
349
+ <Form
350
+ action="/todos"
351
+ method="post"
352
+ :optimistic="(props, data) => ({
353
+ todos: [...props.todos, { id: Date.now(), name: data.name, done: false }],
354
+ })"
355
+ >
356
+ <input type="text" name="name" />
357
+ <button type="submit">Add Todo</button>
358
+ </Form>
359
+ </template>
360
+ @endboostsnippet
361
+ @endverbatim
362
+
363
+ ### Instant Visits
364
+
365
+ Navigate to a new page immediately without waiting for the server response. The target component renders right away with shared props, while page-specific props load in the background.
366
+
367
+ @boostsnippet("Instant Visit with Link", "vue")
368
+ <script setup>
369
+ import { Link } from '@inertiajs/vue3'
370
+ </script>
371
+
372
+ <template>
373
+ <Link href="/dashboard" component="Dashboard">Dashboard</Link>
374
+
375
+ <Link
376
+ href="/posts/1"
377
+ component="Posts/Show"
378
+ :page-props="{ post: { id: 1, title: 'My Post' } }"
379
+ >
380
+ View Post
381
+ </Link>
382
+ </template>
383
+ @endboostsnippet
384
+
385
+ ### Layout Props
386
+
387
+ Share dynamic data between pages and persistent layouts:
388
+
389
+ @verbatim
390
+ @boostsnippet("Layout Props in Layout", "vue")
391
+ <script setup>
392
+ import { useLayoutProps } from '@inertiajs/vue3'
393
+
394
+ const layout = useLayoutProps({
395
+ title: 'My App',
396
+ showSidebar: true,
397
+ })
398
+ </script>
399
+
400
+ <template>
401
+ <header>{{ layout.title }}</header>
402
+ <aside v-if="layout.showSidebar">Sidebar</aside>
403
+ <main>
404
+ <slot />
405
+ </main>
406
+ </template>
407
+ @endboostsnippet
408
+ @endverbatim
409
+
410
+ @boostsnippet("Setting Layout Props from Page", "vue")
411
+ <script setup>
412
+ import { setLayoutProps } from '@inertiajs/vue3'
413
+
414
+ setLayoutProps({
415
+ title: 'Dashboard',
416
+ showSidebar: false,
417
+ })
418
+ </script>
419
+
420
+ <template>
421
+ <h1>Dashboard</h1>
422
+ </template>
423
+ @endboostsnippet
297
424
 
298
425
  ### Deferred Props
299
426
 
@@ -343,7 +470,7 @@ let interval
343
470
  onMounted(() => {
344
471
  interval = setInterval(() => {
345
472
  router.reload({ only: ['stats'] })
346
- }, 5000) // Poll every 5 seconds
473
+ }, 5000)
347
474
  })
348
475
 
349
476
  onUnmounted(() => {
@@ -378,7 +505,6 @@ defineProps({
378
505
  <div>
379
506
  <h1>Dashboard</h1>
380
507
 
381
- <!-- stats prop is loaded only when this section scrolls into view -->
382
508
  <WhenVisible data="stats" :buffer="200">
383
509
  <template #fallback>
384
510
  <div class="animate-pulse">Loading stats...</div>
@@ -409,3 +535,5 @@ Server-side patterns (Inertia::render, props, middleware) are covered in inertia
409
535
  - Not handling the `undefined` state of deferred props before data loads
410
536
  - Using `<form>` without preventing default submission (use `<Form>` component or `@submit.prevent`)
411
537
  - Forgetting to check if `<Form>` component is available in your Inertia version
538
+ - Using `router.cancel()` instead of `router.cancelAll()` (v3 breaking change)
539
+ - Using `router.on('invalid', ...)` or `router.on('exception', ...)` instead of the renamed `httpException` and `networkError` events
package/types/app.d.ts CHANGED
@@ -3,9 +3,10 @@ import { DefineComponent, Plugin } from 'vue';
3
3
  export interface InertiaAppProps<SharedProps extends PageProps = PageProps> {
4
4
  initialPage: Page<SharedProps>;
5
5
  initialComponent?: DefineComponent;
6
- resolveComponent?: (name: string) => DefineComponent | Promise<DefineComponent>;
6
+ resolveComponent?: (name: string, page?: Page) => DefineComponent | Promise<DefineComponent>;
7
7
  titleCallback?: HeadManagerTitleCallback;
8
8
  onHeadUpdate?: HeadManagerOnUpdateCallback;
9
+ defaultLayout?: (name: string, page: Page) => unknown;
9
10
  }
10
11
  export type InertiaApp = DefineComponent<InertiaAppProps>;
11
12
  declare const App: InertiaApp;
@@ -1,9 +1,9 @@
1
- import { CreateInertiaAppOptionsForCSR, CreateInertiaAppOptionsForSSR, InertiaAppSSRResponse, PageProps } from '@inertiajs/core';
1
+ import { CreateInertiaAppOptions, CreateInertiaAppOptionsForCSR, CreateInertiaAppOptionsForSSR, InertiaAppSSRResponse, Page, PageProps } from '@inertiajs/core';
2
2
  import { DefineComponent, Plugin, App as VueApp } from 'vue';
3
3
  import { renderToString } from 'vue/server-renderer';
4
4
  import { InertiaApp, InertiaAppProps } from './app';
5
5
  import { VueInertiaAppConfig } from './types';
6
- type ComponentResolver = (name: string) => DefineComponent | Promise<DefineComponent> | {
6
+ type ComponentResolver = (name: string, page?: Page) => DefineComponent | Promise<DefineComponent> | {
7
7
  default: DefineComponent;
8
8
  };
9
9
  type SetupOptions<ElementType, SharedProps extends PageProps> = {
@@ -16,6 +16,13 @@ type InertiaAppOptionsForCSR<SharedProps extends PageProps> = CreateInertiaAppOp
16
16
  type InertiaAppOptionsForSSR<SharedProps extends PageProps> = CreateInertiaAppOptionsForSSR<SharedProps, ComponentResolver, SetupOptions<null, SharedProps>, VueApp, VueInertiaAppConfig> & {
17
17
  render: typeof renderToString;
18
18
  };
19
+ type InertiaAppOptionsAuto<SharedProps extends PageProps> = CreateInertiaAppOptions<ComponentResolver, SetupOptions<HTMLElement | null, SharedProps>, VueApp | void, VueInertiaAppConfig> & {
20
+ page?: Page<SharedProps>;
21
+ render?: undefined;
22
+ };
23
+ type RenderToString = (app: VueApp) => Promise<string>;
24
+ type RenderFunction<SharedProps extends PageProps> = (page: Page<SharedProps>, renderToString: RenderToString) => Promise<InertiaAppSSRResponse>;
19
25
  export default function createInertiaApp<SharedProps extends PageProps = PageProps>(options: InertiaAppOptionsForCSR<SharedProps>): Promise<void>;
20
26
  export default function createInertiaApp<SharedProps extends PageProps = PageProps>(options: InertiaAppOptionsForSSR<SharedProps>): Promise<InertiaAppSSRResponse>;
27
+ export default function createInertiaApp<SharedProps extends PageProps = PageProps>(options?: InertiaAppOptionsAuto<SharedProps>): Promise<void | RenderFunction<SharedProps>>;
21
28
  export {};
@@ -1,3 +1,4 @@
1
+ import { type SlotsType } from 'vue';
1
2
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
3
  data: {
3
4
  type: (StringConstructor | {
@@ -16,7 +17,15 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
16
17
  })[];
17
18
  required: true;
18
19
  };
19
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
+ }>, {
21
+ reloading: import("vue").Ref<boolean, boolean>;
22
+ slots: Readonly<{
23
+ default: import("vue").Slot<{
24
+ reloading: boolean;
25
+ }>;
26
+ fallback: import("vue").Slot<{}>;
27
+ }>;
28
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
29
  data: {
21
30
  type: (StringConstructor | {
22
31
  (arrayLength: number): String[];
@@ -34,5 +43,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
34
43
  })[];
35
44
  required: true;
36
45
  };
37
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
46
+ }>> & Readonly<{}>, {}, SlotsType<{
47
+ default: {
48
+ reloading: boolean;
49
+ };
50
+ fallback: {};
51
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
38
52
  export default _default;
package/types/form.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FormComponentProps, FormComponentRef, FormComponentSlotProps, FormDataConvertible, Method } from '@inertiajs/core';
1
+ import { Errors, FormComponentProps, FormComponentRef, FormComponentSlotProps, FormDataConvertible, Method, VisitOptions } from '@inertiajs/core';
2
2
  import { PropType, SlotsType } from 'vue';
3
3
  declare const Form: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
4
  action: {
@@ -97,10 +97,22 @@ declare const Form: import("vue").DefineComponent<import("vue").ExtractPropTypes
97
97
  type: PropType<FormComponentProps["validationTimeout"]>;
98
98
  default: number;
99
99
  };
100
+ optimistic: {
101
+ type: PropType<FormComponentProps["optimistic"]>;
102
+ default: undefined;
103
+ };
100
104
  withAllErrors: {
101
105
  type: PropType<FormComponentProps["withAllErrors"]>;
102
106
  default: null;
103
107
  };
108
+ component: {
109
+ type: PropType<FormComponentProps["component"]>;
110
+ default: null;
111
+ };
112
+ instant: {
113
+ type: PropType<FormComponentProps["instant"]>;
114
+ default: boolean;
115
+ };
104
116
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
105
117
  [key: string]: any;
106
118
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -200,18 +212,36 @@ declare const Form: import("vue").DefineComponent<import("vue").ExtractPropTypes
200
212
  type: PropType<FormComponentProps["validationTimeout"]>;
201
213
  default: number;
202
214
  };
215
+ optimistic: {
216
+ type: PropType<FormComponentProps["optimistic"]>;
217
+ default: undefined;
218
+ };
203
219
  withAllErrors: {
204
220
  type: PropType<FormComponentProps["withAllErrors"]>;
205
221
  default: null;
206
222
  };
223
+ component: {
224
+ type: PropType<FormComponentProps["component"]>;
225
+ default: null;
226
+ };
227
+ instant: {
228
+ type: PropType<FormComponentProps["instant"]>;
229
+ default: boolean;
230
+ };
207
231
  }>> & Readonly<{}>, {
208
232
  transform: ((data: Record<string, FormDataConvertible>) => Record<string, FormDataConvertible>) | undefined;
233
+ withAllErrors: boolean | null | undefined;
209
234
  method: Method | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | undefined;
235
+ optimistic: import("@inertiajs/core").FormComponentOptimisticCallback<import("@inertiajs/core").PageProps & {
236
+ errors: Errors & import("@inertiajs/core").ErrorBag;
237
+ deferred?: Record<string, VisitOptions["only"]>;
238
+ }> | undefined;
210
239
  headers: Record<string, string> | undefined;
211
240
  errorBag: string | null | undefined;
212
241
  queryStringArrayFormat: import("@inertiajs/core").QueryStringArrayFormatOption | undefined;
213
242
  showProgress: boolean;
214
243
  invalidateCacheTags: string | string[] | undefined;
244
+ component: string | undefined;
215
245
  onCancelToken: import("@inertiajs/core").CancelTokenCallback | undefined;
216
246
  onBefore: import("@inertiajs/core").GlobalEventCallback<"before", import("@inertiajs/core").RequestPayload> | undefined;
217
247
  onStart: import("@inertiajs/core").GlobalEventCallback<"start", import("@inertiajs/core").RequestPayload> | undefined;
@@ -221,17 +251,25 @@ declare const Form: import("vue").DefineComponent<import("vue").ExtractPropTypes
221
251
  onSuccess: import("@inertiajs/core").GlobalEventCallback<"success", import("@inertiajs/core").RequestPayload> | undefined;
222
252
  onError: import("@inertiajs/core").GlobalEventCallback<"error", import("@inertiajs/core").RequestPayload> | undefined;
223
253
  options: import("@inertiajs/core").FormComponentOptions | undefined;
224
- withAllErrors: boolean | null | undefined;
225
254
  action: string | import("@inertiajs/core").UrlMethodPair | undefined;
226
255
  resetOnError: boolean | string[] | undefined;
227
256
  resetOnSuccess: boolean | string[] | undefined;
228
257
  setDefaultsOnSuccess: boolean | undefined;
229
- onSubmitComplete: ((props: import("@inertiajs/core").FormComponentonSubmitCompleteArguments) => void) | undefined;
258
+ onSubmitComplete: ((props: import("@inertiajs/core").FormComponentOnSubmitCompleteArguments) => void) | undefined;
230
259
  validateFiles: boolean | undefined;
231
260
  validationTimeout: number | undefined;
261
+ instant: boolean | undefined;
232
262
  disableWhileProcessing: boolean;
233
263
  }, SlotsType<{
234
264
  default: FormComponentSlotProps;
235
265
  }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
236
- export declare function useFormContext(): FormComponentRef | undefined;
266
+ export declare function useFormContext<TForm extends object = Record<string, any>>(): FormComponentRef<TForm> | undefined;
267
+ type TypedFormComponent<TForm extends Record<string, any>> = typeof Form & {
268
+ new (): {
269
+ $slots: {
270
+ default: (props: FormComponentSlotProps<TForm>) => any;
271
+ };
272
+ };
273
+ };
274
+ export declare function createForm<TForm extends Record<string, any>>(): TypedFormComponent<TForm>;
237
275
  export default Form;
package/types/index.d.ts CHANGED
@@ -1,13 +1,15 @@
1
- export { progress, router } from '@inertiajs/core';
1
+ export { http, progress, router } from '@inertiajs/core';
2
2
  export { default as App, usePage } from './app';
3
3
  export { default as createInertiaApp } from './createInertiaApp';
4
4
  export { default as Deferred } from './deferred';
5
- export { default as Form, useFormContext } from './form';
5
+ export { createForm, default as Form, useFormContext } from './form';
6
6
  export { default as Head } from './head';
7
7
  export { default as InfiniteScroll } from './infiniteScroll';
8
+ export { resetLayoutProps, setLayoutProps, setLayoutPropsFor, useLayoutProps } from './layoutProps';
8
9
  export { InertiaLinkProps, default as Link } from './link';
9
- export * from './types';
10
+ export { type VueInertiaAppConfig, type VuePageHandlerArgs } from './types';
10
11
  export { InertiaForm, InertiaFormProps, InertiaPrecognitiveForm, default as useForm } from './useForm';
12
+ export { default as useHttp } from './useHttp';
11
13
  export { default as usePoll } from './usePoll';
12
14
  export { default as usePrefetch } from './usePrefetch';
13
15
  export { default as useRemember } from './useRemember';
@@ -1,4 +1,4 @@
1
- import { InfiniteScrollActionSlotProps, InfiniteScrollComponentBaseProps, InfiniteScrollSlotProps } from '@inertiajs/core';
1
+ import { InfiniteScrollActionSlotProps, InfiniteScrollComponentBaseProps, InfiniteScrollSlotProps, ReloadOptions } from '@inertiajs/core';
2
2
  import { PropType, SlotsType } from 'vue';
3
3
  declare const InfiniteScroll: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
4
  data: {
@@ -53,6 +53,10 @@ declare const InfiniteScroll: import("vue").DefineComponent<import("vue").Extrac
53
53
  type: PropType<string | (() => HTMLElement | null | undefined)>;
54
54
  default: null;
55
55
  };
56
+ params: {
57
+ type: PropType<ReloadOptions>;
58
+ default: () => {};
59
+ };
56
60
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
57
61
  [key: string]: any;
58
62
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -108,9 +112,14 @@ declare const InfiniteScroll: import("vue").DefineComponent<import("vue").Extrac
108
112
  type: PropType<string | (() => HTMLElement | null | undefined)>;
109
113
  default: null;
110
114
  };
115
+ params: {
116
+ type: PropType<ReloadOptions>;
117
+ default: () => {};
118
+ };
111
119
  }>> & Readonly<{}>, {
112
120
  reverse: boolean | undefined;
113
121
  preserveUrl: boolean | undefined;
122
+ params: ReloadOptions;
114
123
  buffer: number | undefined;
115
124
  as: string | undefined;
116
125
  manual: boolean | undefined;
@@ -0,0 +1,13 @@
1
+ import { ComputedRef, InjectionKey } from 'vue';
2
+ export declare function setLayoutProps(props: Record<string, unknown>): void;
3
+ export declare function setLayoutPropsFor(name: string, props: Record<string, unknown>): void;
4
+ export declare function resetLayoutProps(): void;
5
+ export declare const LAYOUT_CONTEXT_KEY: InjectionKey<string | undefined>;
6
+ export declare const LayoutProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
7
+ layoutName: StringConstructor;
8
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
9
+ [key: string]: any;
10
+ }>[] | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
11
+ layoutName: StringConstructor;
12
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
13
+ export declare function useLayoutProps<T extends Record<string, unknown>>(defaults: T): ComputedRef<T>;
@@ -1,4 +1,4 @@
1
- import { ErrorValue, FormDataErrors, FormDataKeys, FormDataType, FormDataValues, Method, Progress, UrlMethodPair, UseFormSubmitArguments, UseFormSubmitOptions, UseFormTransformCallback, UseFormWithPrecognitionArguments } from '@inertiajs/core';
1
+ import { ErrorValue, FormDataErrors, FormDataKeys, FormDataType, FormDataValues, Method, OptimisticCallback, Progress, UrlMethodPair, UseFormSubmitArguments, UseFormSubmitOptions, UseFormTransformCallback, UseFormWithPrecognitionArguments } from '@inertiajs/core';
2
2
  import { NamedInputEvent, PrecognitionPath, ValidationConfig, Validator } from 'laravel-precognition';
3
3
  export interface InertiaFormProps<TForm extends object> {
4
4
  isDirty: boolean;
@@ -26,6 +26,7 @@ export interface InertiaFormProps<TForm extends object> {
26
26
  delete(url: string, options?: UseFormSubmitOptions): void;
27
27
  cancel(): void;
28
28
  dontRemember<K extends FormDataKeys<TForm>>(...fields: K[]): this;
29
+ optimistic<TProps>(callback: OptimisticCallback<TProps>): this;
29
30
  withPrecognition(...args: UseFormWithPrecognitionArguments): InertiaPrecognitiveForm<TForm>;
30
31
  }
31
32
  type PrecognitionValidationConfig<TKeys> = ValidationConfig & {
@@ -0,0 +1,80 @@
1
+ import { ErrorValue, FormDataErrors, FormDataKeys, FormDataValues, Progress, UrlMethodPair, UseFormTransformCallback, UseFormWithPrecognitionArguments } from '@inertiajs/core';
2
+ import { NamedInputEvent, ValidationConfig, Validator } from 'laravel-precognition';
3
+ type PrecognitionValidationConfig<TKeys> = ValidationConfig & {
4
+ only?: TKeys[] | Iterable<TKeys> | ArrayLike<TKeys>;
5
+ };
6
+ export interface FormStateProps<TForm extends object> {
7
+ isDirty: boolean;
8
+ errors: FormDataErrors<TForm>;
9
+ hasErrors: boolean;
10
+ processing: boolean;
11
+ progress: Progress | null;
12
+ wasSuccessful: boolean;
13
+ recentlySuccessful: boolean;
14
+ data(): TForm;
15
+ transform(callback: UseFormTransformCallback<TForm>): this;
16
+ defaults(): this;
17
+ defaults<T extends FormDataKeys<TForm>>(field: T, value: FormDataValues<TForm, T>): this;
18
+ defaults(fields: Partial<TForm>): this;
19
+ reset<K extends FormDataKeys<TForm>>(...fields: K[]): this;
20
+ clearErrors<K extends FormDataKeys<TForm>>(...fields: K[]): this;
21
+ resetAndClearErrors<K extends FormDataKeys<TForm>>(...fields: K[]): this;
22
+ setError<K extends FormDataKeys<TForm>>(field: K, value: ErrorValue): this;
23
+ setError(errors: FormDataErrors<TForm>): this;
24
+ withPrecognition(...args: UseFormWithPrecognitionArguments): this & FormStateValidationProps<TForm>;
25
+ }
26
+ export interface FormStateValidationProps<TForm extends object> {
27
+ invalid<K extends FormDataKeys<TForm>>(field: K): boolean;
28
+ setValidationTimeout(duration: number): this;
29
+ touch<K extends FormDataKeys<TForm>>(field: K | NamedInputEvent | Array<K>, ...fields: K[]): this;
30
+ touched<K extends FormDataKeys<TForm>>(field?: K): boolean;
31
+ valid<K extends FormDataKeys<TForm>>(field: K): boolean;
32
+ validate<K extends FormDataKeys<TForm>>(field?: K | NamedInputEvent | PrecognitionValidationConfig<K>, config?: PrecognitionValidationConfig<K>): this;
33
+ validateFiles(): this;
34
+ validating: boolean;
35
+ validator: () => Validator;
36
+ withAllErrors(): this;
37
+ withoutFileValidation(): this;
38
+ setErrors(errors: FormDataErrors<TForm> | Record<string, string | string[]>): this;
39
+ forgetError<K extends FormDataKeys<TForm> | NamedInputEvent>(field: K): this;
40
+ }
41
+ interface InternalPrecognitionState {
42
+ __touched: string[];
43
+ __valid: string[];
44
+ }
45
+ export type FormState<TForm extends object> = TForm & FormStateProps<TForm>;
46
+ export type FormStateWithPrecognition<TForm extends object> = FormState<TForm> & FormStateValidationProps<TForm> & InternalPrecognitionState;
47
+ interface InternalRememberState<TForm extends object> {
48
+ __rememberable: boolean;
49
+ __remember: () => {
50
+ data: TForm;
51
+ errors: FormDataErrors<TForm>;
52
+ };
53
+ __restore: (restored: {
54
+ data: TForm;
55
+ errors: FormDataErrors<TForm>;
56
+ }) => void;
57
+ }
58
+ export interface UseFormStateOptions<TForm extends object> {
59
+ data: TForm | (() => TForm);
60
+ rememberKey?: string | null;
61
+ precognitionEndpoint?: (() => UrlMethodPair) | null;
62
+ }
63
+ export interface UseFormStateReturn<TForm extends object> {
64
+ form: FormState<TForm> & InternalRememberState<TForm>;
65
+ setDefaults: (newDefaults: TForm) => void;
66
+ getTransform: () => UseFormTransformCallback<TForm>;
67
+ getPrecognitionEndpoint: () => (() => UrlMethodPair) | null;
68
+ markAsSuccessful: () => void;
69
+ wasDefaultsCalledInOnSuccess: () => boolean;
70
+ resetDefaultsCalledInOnSuccess: () => void;
71
+ setRememberExcludeKeys: (keys: FormDataKeys<TForm>[]) => void;
72
+ resetBeforeSubmit: () => void;
73
+ finishProcessing: () => void;
74
+ withAllErrors: {
75
+ enabled: () => boolean;
76
+ enable: () => void;
77
+ };
78
+ }
79
+ export default function useFormState<TForm extends object>(options: UseFormStateOptions<TForm>): UseFormStateReturn<TForm>;
80
+ export {};