@inertiajs/react 3.0.0-beta.2 → 3.0.0-beta.4
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.js +185 -93
- package/dist/index.js.map +3 -3
- package/package.json +5 -6
- package/types/createInertiaApp.d.ts +14 -5
- package/types/index.d.ts +2 -2
- package/types/layoutProps.d.ts +4 -7
- package/types/types.d.ts +3 -2
- package/types/useFormState.d.ts +2 -2
- package/types/useHttp.d.ts +6 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/react",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The React adapter for Inertia.js",
|
|
6
6
|
"contributors": [
|
|
@@ -57,10 +57,9 @@
|
|
|
57
57
|
"react-dom": "^19.0.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"
|
|
61
|
-
"laravel-precognition": "2.0.0-beta.
|
|
62
|
-
"
|
|
63
|
-
"@inertiajs/core": "3.0.0-beta.2"
|
|
60
|
+
"es-toolkit": "^1.33.0",
|
|
61
|
+
"laravel-precognition": "2.0.0-beta.5",
|
|
62
|
+
"@inertiajs/core": "3.0.0-beta.4"
|
|
64
63
|
},
|
|
65
64
|
"scripts": {
|
|
66
65
|
"build": "pnpm clean && ./build.js && tsc",
|
|
@@ -69,6 +68,6 @@
|
|
|
69
68
|
"dev": "pnpx concurrently -c \"#ffcf00,#3178c6\" \"pnpm dev:build\" \"pnpm dev:types\" --names build,types",
|
|
70
69
|
"dev:build": "./build.js --watch",
|
|
71
70
|
"dev:types": "tsc --watch --preserveWatchOutput",
|
|
72
|
-
"
|
|
71
|
+
"es2022-check": "pnpm build:with-deps && es-check es2022 \"dist/index.js\" --checkFeatures --module --noCache --verbose"
|
|
73
72
|
}
|
|
74
73
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateInertiaAppOptions, CreateInertiaAppOptionsForCSR, CreateInertiaAppOptionsForSSR, InertiaAppSSRResponse, Page, PageProps } from '@inertiajs/core';
|
|
1
|
+
import { CreateInertiaAppOptions, CreateInertiaAppOptionsForCSR, CreateInertiaAppOptionsForSSR, InertiaAppSSRResponse, Page, PageProps, SharedPageProps } from '@inertiajs/core';
|
|
2
2
|
import { ReactElement } from 'react';
|
|
3
3
|
import { renderToString } from 'react-dom/server';
|
|
4
4
|
import { InertiaAppProps, type InertiaApp } from './App';
|
|
@@ -8,24 +8,33 @@ export type SetupOptions<ElementType, SharedProps extends PageProps> = {
|
|
|
8
8
|
App: InertiaApp;
|
|
9
9
|
props: InertiaAppProps<SharedProps>;
|
|
10
10
|
};
|
|
11
|
-
type ComponentResolver = (name: string, page?: Page) => ReactComponent | Promise<ReactComponent> | {
|
|
11
|
+
type ComponentResolver = (name: string, page?: Page<SharedPageProps>) => ReactComponent | Promise<ReactComponent> | {
|
|
12
12
|
default: ReactComponent;
|
|
13
13
|
};
|
|
14
14
|
type InertiaAppOptionsForCSR<SharedProps extends PageProps> = CreateInertiaAppOptionsForCSR<SharedProps, ComponentResolver, SetupOptions<HTMLElement, SharedProps>, void, ReactInertiaAppConfig> & {
|
|
15
15
|
strictMode?: undefined;
|
|
16
|
+
withApp?: (app: ReactElement, options: {
|
|
17
|
+
ssr: boolean;
|
|
18
|
+
}) => ReactElement;
|
|
16
19
|
};
|
|
17
20
|
type InertiaAppOptionsForSSR<SharedProps extends PageProps> = CreateInertiaAppOptionsForSSR<SharedProps, ComponentResolver, SetupOptions<null, SharedProps>, ReactElement, ReactInertiaAppConfig> & {
|
|
18
21
|
render: typeof renderToString;
|
|
19
22
|
strictMode?: undefined;
|
|
23
|
+
withApp?: (app: ReactElement, options: {
|
|
24
|
+
ssr: boolean;
|
|
25
|
+
}) => ReactElement;
|
|
20
26
|
};
|
|
21
27
|
type InertiaAppOptionsAuto<SharedProps extends PageProps> = CreateInertiaAppOptions<ComponentResolver, SetupOptions<HTMLElement | null, SharedProps>, ReactElement | void, ReactInertiaAppConfig> & {
|
|
22
28
|
page?: Page<SharedProps>;
|
|
23
29
|
render?: undefined;
|
|
24
30
|
strictMode?: boolean;
|
|
31
|
+
withApp?: (app: ReactElement, options: {
|
|
32
|
+
ssr: boolean;
|
|
33
|
+
}) => ReactElement;
|
|
25
34
|
};
|
|
26
35
|
type RenderToString = (element: ReactElement) => string;
|
|
27
36
|
type RenderFunction<SharedProps extends PageProps> = (page: Page<SharedProps>, renderToString: RenderToString) => Promise<InertiaAppSSRResponse>;
|
|
28
|
-
export default function createInertiaApp<SharedProps extends PageProps = PageProps>(options: InertiaAppOptionsForCSR<SharedProps>): Promise<void>;
|
|
29
|
-
export default function createInertiaApp<SharedProps extends PageProps = PageProps>(options: InertiaAppOptionsForSSR<SharedProps>): Promise<InertiaAppSSRResponse>;
|
|
30
|
-
export default function createInertiaApp<SharedProps extends PageProps = PageProps>(options?: InertiaAppOptionsAuto<SharedProps>): Promise<void | RenderFunction<SharedProps>>;
|
|
37
|
+
export default function createInertiaApp<SharedProps extends PageProps = PageProps & SharedPageProps>(options: InertiaAppOptionsForCSR<SharedProps>): Promise<void>;
|
|
38
|
+
export default function createInertiaApp<SharedProps extends PageProps = PageProps & SharedPageProps>(options: InertiaAppOptionsForSSR<SharedProps>): Promise<InertiaAppSSRResponse>;
|
|
39
|
+
export default function createInertiaApp<SharedProps extends PageProps = PageProps & SharedPageProps>(options?: InertiaAppOptionsAuto<SharedProps>): Promise<void | RenderFunction<SharedProps>>;
|
|
31
40
|
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ export { default as Deferred } from './Deferred';
|
|
|
6
6
|
export { default as Form, useFormContext } from './Form';
|
|
7
7
|
export { default as Head } from './Head';
|
|
8
8
|
export { default as InfiniteScroll } from './InfiniteScroll';
|
|
9
|
-
export { resetLayoutProps, setLayoutProps, setLayoutPropsFor
|
|
9
|
+
export { resetLayoutProps, setLayoutProps, setLayoutPropsFor } from './layoutProps';
|
|
10
10
|
export { InertiaLinkProps, default as Link } from './Link';
|
|
11
|
-
export { ReactComponent as ResolvedComponent } from './types';
|
|
11
|
+
export { LayoutCallback, ReactComponent as ResolvedComponent } from './types';
|
|
12
12
|
export { InertiaForm, InertiaFormProps, InertiaPrecognitiveFormProps, SetDataAction, SetDataByKeyValuePair, SetDataByMethod, SetDataByObject, default as useForm, } from './useForm';
|
|
13
13
|
export { default as useHttp } from './useHttp';
|
|
14
14
|
export { default as usePage } from './usePage';
|
package/types/layoutProps.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
1
|
+
import { type LayoutProps, type NamedLayoutProps } from '@inertiajs/core';
|
|
2
|
+
export declare const store: import("@inertiajs/core").LayoutPropsStore;
|
|
3
|
+
export declare function setLayoutProps(props: Partial<LayoutProps>): void;
|
|
4
|
+
export declare function setLayoutPropsFor<K extends keyof NamedLayoutProps>(name: K, props: Partial<NamedLayoutProps[K]>): void;
|
|
3
5
|
export declare function resetLayoutProps(): void;
|
|
4
|
-
export declare const LayoutPropsContext: import("react").Context<{
|
|
5
|
-
staticProps: Record<string, unknown>;
|
|
6
|
-
name?: string;
|
|
7
|
-
}>;
|
|
8
|
-
export declare function useLayoutProps<T extends Record<string, unknown>>(defaults: T): T;
|
package/types/types.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { PageHandler } from '@inertiajs/core';
|
|
1
|
+
import { PageHandler, SharedPageProps } from '@inertiajs/core';
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
3
|
export type LayoutFunction = (page: ReactNode) => ReactNode;
|
|
4
|
+
export type LayoutCallback = (props: SharedPageProps) => unknown;
|
|
4
5
|
export type LayoutComponent = ComponentType<{
|
|
5
6
|
children: ReactNode;
|
|
6
7
|
}>;
|
|
7
8
|
export type ReactComponent = ComponentType<any> & {
|
|
8
|
-
layout?: LayoutComponent | LayoutComponent[] | LayoutFunction;
|
|
9
|
+
layout?: LayoutComponent | LayoutComponent[] | LayoutFunction | LayoutCallback;
|
|
9
10
|
};
|
|
10
11
|
export type ReactPageHandlerArgs = Parameters<PageHandler<ComponentType>>[0];
|
|
11
12
|
export type ReactInertiaAppConfig = {
|
package/types/useFormState.d.ts
CHANGED
|
@@ -62,8 +62,8 @@ export interface UseFormStateReturn<TForm extends object> {
|
|
|
62
62
|
precognitionEndpointRef: React.MutableRefObject<(() => UrlMethodPair) | null>;
|
|
63
63
|
dataRef: React.MutableRefObject<TForm>;
|
|
64
64
|
isMounted: React.MutableRefObject<boolean>;
|
|
65
|
-
setProcessing:
|
|
66
|
-
setProgress:
|
|
65
|
+
setProcessing: (value: boolean) => void;
|
|
66
|
+
setProgress: (value: Progress | null) => void;
|
|
67
67
|
markAsSuccessful: () => void;
|
|
68
68
|
clearErrors: (...fields: string[]) => void;
|
|
69
69
|
setError: (fieldOrFields: FormDataKeys<TForm> | FormDataErrors<TForm>, maybeValue?: ErrorValue) => void;
|
package/types/useHttp.d.ts
CHANGED
|
@@ -28,12 +28,12 @@ export interface UseHttpProps<TForm extends object, TResponse = unknown> {
|
|
|
28
28
|
<K extends FormDataKeys<TForm>>(field: K, value: ErrorValue): void;
|
|
29
29
|
(errors: FormDataErrors<TForm>): void;
|
|
30
30
|
};
|
|
31
|
-
submit: (...args: UseHttpSubmitArguments<
|
|
32
|
-
get: (url: string, options?: UseHttpSubmitOptions<
|
|
33
|
-
post: (url: string, options?: UseHttpSubmitOptions<
|
|
34
|
-
put: (url: string, options?: UseHttpSubmitOptions<
|
|
35
|
-
patch: (url: string, options?: UseHttpSubmitOptions<
|
|
36
|
-
delete: (url: string, options?: UseHttpSubmitOptions<
|
|
31
|
+
submit: <R = TResponse>(...args: UseHttpSubmitArguments<R, TForm>) => Promise<R>;
|
|
32
|
+
get: <R = TResponse>(url: string, options?: UseHttpSubmitOptions<R, TForm>) => Promise<R>;
|
|
33
|
+
post: <R = TResponse>(url: string, options?: UseHttpSubmitOptions<R, TForm>) => Promise<R>;
|
|
34
|
+
put: <R = TResponse>(url: string, options?: UseHttpSubmitOptions<R, TForm>) => Promise<R>;
|
|
35
|
+
patch: <R = TResponse>(url: string, options?: UseHttpSubmitOptions<R, TForm>) => Promise<R>;
|
|
36
|
+
delete: <R = TResponse>(url: string, options?: UseHttpSubmitOptions<R, TForm>) => Promise<R>;
|
|
37
37
|
cancel: () => void;
|
|
38
38
|
dontRemember: <K extends FormDataKeys<TForm>>(...fields: K[]) => UseHttpProps<TForm, TResponse>;
|
|
39
39
|
optimistic: (callback: (currentData: TForm) => Partial<TForm>) => UseHttpProps<TForm, TResponse>;
|