@inertiajs/react 2.2.8 → 2.2.9
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/index.esm.js +65 -43
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +58 -41
- package/dist/index.js.map +3 -3
- package/dist/server.js +1 -0
- package/dist/server.js.map +1 -1
- package/package.json +8 -8
- package/types/App.d.ts +17 -8
- package/types/Head.d.ts +2 -2
- package/types/HeadContext.d.ts +2 -1
- package/types/Link.d.ts +1 -1
- package/types/PageContext.d.ts +2 -1
- package/types/createInertiaApp.d.ts +13 -49
- package/types/types.d.ts +10 -0
- package/types/useForm.d.ts +4 -2
- package/types/usePage.d.ts +2 -2
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PageHandler } from '@inertiajs/core';
|
|
2
|
+
import { ComponentType, ReactNode } from 'react';
|
|
3
|
+
export type LayoutFunction = (page: ReactNode) => ReactNode;
|
|
4
|
+
export type LayoutComponent = ComponentType<{
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}>;
|
|
7
|
+
export type ReactComponent = ComponentType<any> & {
|
|
8
|
+
layout?: LayoutComponent | LayoutComponent[] | LayoutFunction;
|
|
9
|
+
};
|
|
10
|
+
export type ReactPageHandlerArgs = Parameters<PageHandler<ComponentType>>[0];
|
package/types/useForm.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export type SetDataByMethod<TForm> = (data: (previousData: TForm) => TForm) => v
|
|
|
4
4
|
export type SetDataByKeyValuePair<TForm> = <K extends FormDataKeys<TForm>>(key: K, value: FormDataValues<TForm, K>) => void;
|
|
5
5
|
export type SetDataAction<TForm extends Record<any, any>> = SetDataByObject<TForm> & SetDataByMethod<TForm> & SetDataByKeyValuePair<TForm>;
|
|
6
6
|
type FormOptions = Omit<VisitOptions, 'data'>;
|
|
7
|
+
type SubmitArgs = [Method, string, FormOptions?] | [UrlMethodPair, FormOptions?];
|
|
8
|
+
type TransformCallback<TForm> = (data: TForm) => object;
|
|
7
9
|
export interface InertiaFormProps<TForm extends object> {
|
|
8
10
|
data: TForm;
|
|
9
11
|
isDirty: boolean;
|
|
@@ -14,7 +16,7 @@ export interface InertiaFormProps<TForm extends object> {
|
|
|
14
16
|
wasSuccessful: boolean;
|
|
15
17
|
recentlySuccessful: boolean;
|
|
16
18
|
setData: SetDataAction<TForm>;
|
|
17
|
-
transform: (callback:
|
|
19
|
+
transform: (callback: TransformCallback<TForm>) => void;
|
|
18
20
|
setDefaults(): void;
|
|
19
21
|
setDefaults<T extends FormDataKeys<TForm>>(field: T, value: FormDataValues<TForm, T>): void;
|
|
20
22
|
setDefaults(fields: Partial<TForm>): void;
|
|
@@ -23,7 +25,7 @@ export interface InertiaFormProps<TForm extends object> {
|
|
|
23
25
|
resetAndClearErrors<K extends FormDataKeys<TForm>>(...fields: K[]): void;
|
|
24
26
|
setError<K extends FormDataKeys<TForm>>(field: K, value: ErrorValue): void;
|
|
25
27
|
setError(errors: FormDataErrors<TForm>): void;
|
|
26
|
-
submit: (...args:
|
|
28
|
+
submit: (...args: SubmitArgs) => void;
|
|
27
29
|
get: (url: string, options?: FormOptions) => void;
|
|
28
30
|
patch: (url: string, options?: FormOptions) => void;
|
|
29
31
|
post: (url: string, options?: FormOptions) => void;
|
package/types/usePage.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Page, PageProps } from '@inertiajs/core';
|
|
2
|
-
export default function usePage<TPageProps extends PageProps = PageProps>(): Page<TPageProps>;
|
|
1
|
+
import { Page, PageProps, SharedPageProps } from '@inertiajs/core';
|
|
2
|
+
export default function usePage<TPageProps extends PageProps = PageProps>(): Page<TPageProps & SharedPageProps>;
|