Skip to content

Commit 30908c2

Browse files
committed
Remove global visit options hook (added in #1052)
1 parent 769f643 commit 30908c2

File tree

14 files changed

+56
-209
lines changed

14 files changed

+56
-209
lines changed

packages/inertia-react/index.d.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ export interface InertiaFormProps<TForm = Record<string, any>> {
9494
clearErrors: (...fields: (keyof TForm)[]) => void
9595
setError(field: keyof TForm, value: string): void
9696
setError(errors: Record<keyof TForm, string>): void
97-
submit: (method: Inertia.Method, url: string, options?: Inertia.VisitParams) => void
98-
get: (url: string, options?: Inertia.VisitParams) => void
99-
patch: (url: string, options?: Inertia.VisitParams) => void
100-
post: (url: string, options?: Inertia.VisitParams) => void
101-
put: (url: string, options?: Inertia.VisitParams) => void
102-
delete: (url: string, options?: Inertia.VisitParams) => void
97+
submit: (method: Inertia.Method, url: string, options?: Inertia.VisitOptions) => void
98+
get: (url: string, options?: Inertia.VisitOptions) => void
99+
patch: (url: string, options?: Inertia.VisitOptions) => void
100+
post: (url: string, options?: Inertia.VisitOptions) => void
101+
put: (url: string, options?: Inertia.VisitOptions) => void
102+
delete: (url: string, options?: Inertia.VisitOptions) => void
103103
}
104104

105105
export function useForm<TForm = Record<string, any>>(initialValues?: TForm): InertiaFormProps<TForm>;
@@ -127,7 +127,6 @@ export type InertiaAppOptionsForCSR<SharedProps> = BaseInertiaAppOptions & {
127127
id?: string,
128128
page?: Inertia.Page|string,
129129
render?: undefined,
130-
visitOptions?: Inertia.VisitOptions,
131130
setup(options: SetupOptions<HTMLElement, SharedProps>): CreateInertiaAppSetupReturnType
132131
}
133132

packages/inertia-react/src/App.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export default function App({
1010
resolveComponent,
1111
titleCallback,
1212
onHeadUpdate,
13-
visitOptions,
1413
}) {
1514
const [current, setCurrent] = useState({
1615
component: initialComponent || null,
@@ -37,7 +36,6 @@ export default function App({
3736
key: preserveState ? current.key : Date.now(),
3837
}))
3938
},
40-
visitOptions: visitOptions || (() => undefined),
4139
})
4240

4341
Inertia.on('navigate', () => headManager.forceUpdate())

packages/inertia-react/src/createInertiaApp.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import App from './App'
22
import { createElement } from 'react'
33

4-
export default async function createInertiaApp({ id = 'app', resolve, setup, title, visitOptions, page, render }) {
4+
export default async function createInertiaApp({ id = 'app', resolve, setup, title, page, render }) {
55
const isServer = typeof window === 'undefined'
66
const el = isServer ? null : document.getElementById(id)
77
const initialPage = page || JSON.parse(el.dataset.page)
@@ -19,7 +19,6 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, tit
1919
resolveComponent,
2020
titleCallback: title,
2121
onHeadUpdate: isServer ? elements => (head = elements) : null,
22-
visitOptions,
2322
},
2423
})
2524
})
@@ -29,7 +28,7 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, tit
2928
createElement('div', {
3029
id,
3130
'data-page': JSON.stringify(initialPage),
32-
}, reactApp),
31+
}, reactApp)
3332
)
3433

3534
return { head, body }

packages/inertia-svelte/src/App.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import Render, { h } from './Render.svelte'
44
import { Inertia } from '@inertiajs/inertia'
55
6-
export let initialPage, resolveComponent, visitOptions
6+
export let initialPage, resolveComponent
77
88
Inertia.init({
99
initialPage,
@@ -14,8 +14,7 @@
1414
page,
1515
key: preserveState ? current.key : Date.now()
1616
}))
17-
},
18-
visitOptions,
17+
}
1918
})
2019
2120
$: child = $store.component && h($store.component.default, $store.page.props)

packages/inertia-svelte/src/createInertiaApp.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import App from './App.svelte'
22

3-
export default async function createInertiaApp({ id = 'app', resolve, setup, visitOptions, page, render }) {
3+
export default async function createInertiaApp({ id = 'app', resolve, setup, page, render }) {
44
const isServer = typeof window === 'undefined'
55
const el = isServer ? null : document.getElementById(id)
66
const initialPage = page || JSON.parse(el.dataset.page)
@@ -17,7 +17,6 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, vis
1717
initialComponent,
1818
resolveComponent,
1919
onHeadUpdate: isServer ? elements => (head = elements) : null,
20-
visitOptions,
2120
},
2221
})
2322
})

packages/inertia-vue/index.d.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export interface CreateInertiaAppProps {
4040
title?: (title: string) => string
4141
page?: Inertia.Page
4242
render?: (vm: Vue) => Promise<string>
43-
visitOptions?: Inertia.VisitOptions
4443
}
4544

4645
export declare function createInertiaApp(props: CreateInertiaAppProps): Promise<{ head: string[], body: string } | void>
@@ -86,12 +85,12 @@ export interface InertiaFormProps<TForm> {
8685
clearErrors(...fields: (keyof TForm)[]): this
8786
setError(field: keyof TForm, value: string): this
8887
setError(errors: Record<keyof TForm, string>): this
89-
submit(method: string, url: string, options?: Partial<Inertia.VisitParams>): void
90-
get(url: string, options?: Partial<Inertia.VisitParams>): void
91-
post(url: string, options?: Partial<Inertia.VisitParams>): void
92-
put(url: string, options?: Partial<Inertia.VisitParams>): void
93-
patch(url: string, options?: Partial<Inertia.VisitParams>): void
94-
delete(url: string, options?: Partial<Inertia.VisitParams>): void
88+
submit(method: string, url: string, options?: Partial<Inertia.VisitOptions>): void
89+
get(url: string, options?: Partial<Inertia.VisitOptions>): void
90+
post(url: string, options?: Partial<Inertia.VisitOptions>): void
91+
put(url: string, options?: Partial<Inertia.VisitOptions>): void
92+
patch(url: string, options?: Partial<Inertia.VisitOptions>): void
93+
delete(url: string, options?: Partial<Inertia.VisitOptions>): void
9594
cancel(): void
9695
}
9796

packages/inertia-vue/src/app.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ export default {
3030
required: false,
3131
default: () => () => {},
3232
},
33-
visitOptions: {
34-
type: Function,
35-
required: false,
36-
default: () => undefined,
37-
},
3833
},
3934
data() {
4035
return {
@@ -56,7 +51,6 @@ export default {
5651
this.page = page
5752
this.key = preserveState ? this.key : Date.now()
5853
},
59-
visitOptions: this.visitOptions,
6054
})
6155

6256
Inertia.on('navigate', () => headManager.forceUpdate())

packages/inertia-vue/src/createInertiaApp.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import App, { plugin } from './app'
22

3-
export default async function createInertiaApp({ id = 'app', resolve, setup, title, visitOptions, page, render }) {
3+
export default async function createInertiaApp({ id = 'app', resolve, setup, title, page, render }) {
44
const isServer = typeof window === 'undefined'
55
const el = isServer ? null : document.getElementById(id)
66
const initialPage = page || JSON.parse(el.dataset.page)
@@ -24,7 +24,6 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, tit
2424
resolveComponent,
2525
titleCallback: title,
2626
onHeadUpdate: isServer ? elements => (head = elements) : null,
27-
visitOptions,
2827
},
2928
},
3029
plugin,

packages/inertia-vue/src/link.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export default {
4747
data.on = {
4848
click: () => ({}),
4949
cancelToken: () => ({}),
50-
before: () => ({}),
5150
start: () => ({}),
5251
progress: () => ({}),
5352
finish: () => ({}),

packages/inertia-vue3/index.d.ts

Lines changed: 6 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,6 @@
1-
import * as Inertia from '@inertiajs/inertia'
2-
import { Ref, ComputedRef, App as VueApp, DefineComponent, Plugin } from 'vue'
3-
4-
export interface InertiaAppProps {
5-
initialPage: Inertia.Page
6-
initialComponent?: object
7-
resolveComponent?: (name: string) => DefineComponent | Promise<DefineComponent>
8-
onHeadUpdate?: (elements: string[]) => void
9-
}
10-
11-
type InertiaApp = DefineComponent<InertiaAppProps>
12-
13-
export declare const App: InertiaApp
14-
15-
export declare const plugin: Plugin
16-
17-
export interface CreateInertiaAppProps {
18-
id?: string
19-
resolve: (name: string) =>
20-
DefineComponent |
21-
Promise<DefineComponent> |
22-
{ default: DefineComponent }
23-
setup: (props: {
24-
el: Element
25-
app: InertiaApp
26-
props: InertiaAppProps
27-
plugin: Plugin
28-
}) => void | VueApp
29-
title?: (title: string) => string
30-
page?: Inertia.Page
31-
render?: (app: VueApp) => Promise<string>
32-
visitOptions?: Inertia.VisitOptions
33-
}
34-
35-
export declare function createInertiaApp(props: CreateInertiaAppProps): Promise<{ head: string[], body: string } | void>
36-
37-
export interface InertiaLinkProps {
38-
as?: string
39-
data?: object
40-
href: string
41-
method?: string
42-
headers?: object
43-
onClick?: (event: MouseEvent | KeyboardEvent) => void
44-
preserveScroll?: boolean | ((props: Inertia.PageProps) => boolean)
45-
preserveState?: boolean | ((props: Inertia.PageProps) => boolean) | null
46-
replace?: boolean
47-
only?: string[]
48-
onCancelToken?: (cancelToken: import('axios').CancelTokenSource) => void
49-
onBefore?: () => void
50-
onStart?: () => void
51-
onProgress?: (progress: Inertia.Progress) => void
52-
onFinish?: () => void
53-
onCancel?: () => void
54-
onSuccess?: () => void
55-
}
56-
57-
export type InertiaLink = DefineComponent<InertiaLinkProps>
58-
59-
export declare const Link: InertiaLink
60-
61-
export interface InertiaFormProps<TForm> {
62-
isDirty: boolean
63-
errors: Record<keyof TForm, string>
64-
hasErrors: boolean
65-
processing: boolean
66-
progress: Inertia.Progress | null
67-
wasSuccessful: boolean
68-
recentlySuccessful: boolean
69-
data(): TForm
70-
transform(callback: (data: TForm) => object): this
71-
defaults(): this
72-
defaults(field: keyof TForm, value: string): this
73-
defaults(fields: Record<keyof TForm, string>): this
74-
reset(...fields: (keyof TForm)[]): this
75-
clearErrors(...fields: (keyof TForm)[]): this
76-
setError(field: keyof TForm, value: string): this
77-
setError(errors: Record<keyof TForm, string>): this
78-
submit(method: string, url: string, options?: Partial<Inertia.VisitParams>): void
79-
get(url: string, options?: Partial<Inertia.VisitParams>): void
80-
post(url: string, options?: Partial<Inertia.VisitParams>): void
81-
put(url: string, options?: Partial<Inertia.VisitParams>): void
82-
patch(url: string, options?: Partial<Inertia.VisitParams>): void
83-
delete(url: string, options?: Partial<Inertia.VisitParams>): void
84-
cancel(): void
85-
}
86-
87-
export type InertiaForm<TForm> = TForm & InertiaFormProps<TForm>
88-
89-
export declare function useForm<TForm>(data: TForm): InertiaForm<TForm>
90-
91-
export declare function useForm<TForm>(rememberKey: string, data: TForm): InertiaForm<TForm>
92-
93-
export declare function useRemember(data: object, key?: string): Ref<object>
94-
95-
export declare function usePage<PageProps>(): {
96-
props: ComputedRef<PageProps & Inertia.PageProps>
97-
url: ComputedRef<string>
98-
component: ComputedRef<string>
99-
version: ComputedRef<string | null>
100-
}
101-
102-
export type InertiaHead = DefineComponent<{
103-
title?: string
104-
}>
105-
106-
export declare const Head: InertiaHead
107-
108-
declare module '@vue/runtime-core' {
109-
export interface ComponentCustomProperties {
110-
$inertia: typeof Inertia.Inertia
111-
$page: Inertia.Page
112-
$headManager: ReturnType<typeof Inertia.createHeadManager>
113-
}
114-
115-
export interface ComponentCustomOptions {
116-
remember?:
117-
string |
118-
string[] |
119-
{
120-
data: string | string[]
121-
key?: string | (() => string)
122-
}
123-
}
124-
}
1+
export { default as useForm } from "./useForm";
2+
export { default as useRemember } from "./useRemember";
3+
export { default as createInertiaApp } from "./createInertiaApp";
4+
export { default as Head, default as InertiaHead } from "./head";
5+
export { default as Link, default as InertiaLink, default as link } from "./link";
6+
export { default as App, default as InertiaApp, default as app, plugin, usePage } from "./app";

0 commit comments

Comments
 (0)