@inertiajs/core 3.0.0-beta.3 → 3.0.0-beta.5
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 +20 -27
- package/dist/index.js.map +3 -3
- package/package.json +4 -5
- package/types/index.d.ts +1 -1
- package/types/layout.d.ts +3 -18
- package/types/types.d.ts +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A framework for creating server-driven single page apps.",
|
|
6
6
|
"contributors": [
|
|
@@ -50,9 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
53
|
-
"
|
|
54
|
-
"laravel-precognition": "2.0.0-beta.
|
|
55
|
-
"lodash-es": "^4.17.23"
|
|
53
|
+
"es-toolkit": "^1.33.0",
|
|
54
|
+
"laravel-precognition": "2.0.0-beta.5"
|
|
56
55
|
},
|
|
57
56
|
"peerDependencies": {
|
|
58
57
|
"axios": "^1.13.2"
|
|
@@ -78,7 +77,7 @@
|
|
|
78
77
|
"dev": "pnpx concurrently -c \"#ffcf00,#3178c6\" \"pnpm dev:build\" \"pnpm dev:types\" --names build,types",
|
|
79
78
|
"dev:build": "./build.js --watch",
|
|
80
79
|
"dev:types": "tsc --watch --preserveWatchOutput",
|
|
81
|
-
"
|
|
80
|
+
"es2022-check": "pnpm build:with-deps && es-check es2022 \"dist/index.js\" --checkFeatures --module --noCache --verbose",
|
|
82
81
|
"test": "vitest run"
|
|
83
82
|
}
|
|
84
83
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { default as createHeadManager } from './head';
|
|
|
11
11
|
export { http } from './http';
|
|
12
12
|
export { HttpCancelledError, HttpNetworkError, HttpResponseError } from './httpErrors';
|
|
13
13
|
export { default as useInfiniteScroll } from './infiniteScroll';
|
|
14
|
-
export { createLayoutPropsStore,
|
|
14
|
+
export { createLayoutPropsStore, normalizeLayouts, type LayoutDefinition, type LayoutPropsStore } from './layout';
|
|
15
15
|
export { shouldIntercept, shouldNavigate } from './navigationEvents';
|
|
16
16
|
export { progress, default as setupProgress } from './progress';
|
|
17
17
|
export { FormComponentResetSymbol, resetFormFields } from './resetFormFields';
|
package/types/layout.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { LayoutProps, NamedLayoutProps } from './types';
|
|
1
2
|
export interface LayoutDefinition<Component> {
|
|
2
3
|
component: Component;
|
|
3
4
|
props: Record<string, unknown>;
|
|
4
5
|
name?: string;
|
|
5
6
|
}
|
|
6
7
|
export interface LayoutPropsStore {
|
|
7
|
-
set(props:
|
|
8
|
-
setFor(name:
|
|
8
|
+
set(props: Partial<LayoutProps>): void;
|
|
9
|
+
setFor<K extends keyof NamedLayoutProps>(name: K, props: Partial<NamedLayoutProps[K]>): void;
|
|
9
10
|
get(): {
|
|
10
11
|
shared: Record<string, unknown>;
|
|
11
12
|
named: Record<string, Record<string, unknown>>;
|
|
@@ -14,22 +15,6 @@ export interface LayoutPropsStore {
|
|
|
14
15
|
subscribe(callback: () => void): () => void;
|
|
15
16
|
}
|
|
16
17
|
export declare function createLayoutPropsStore(): LayoutPropsStore;
|
|
17
|
-
/**
|
|
18
|
-
* Merges layout props from three sources with priority: dynamic > static > defaults.
|
|
19
|
-
* Only keys present in `defaults` are included in the result.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* mergeLayoutProps(
|
|
24
|
-
* { title: 'Default', showSidebar: true }, // defaults declared in useLayoutProps()
|
|
25
|
-
* { title: 'My Page', color: 'blue' }, // static props from layout definition
|
|
26
|
-
* { showSidebar: false, fontSize: 16 }, // dynamic props from setLayoutProps()
|
|
27
|
-
* )
|
|
28
|
-
* // => { title: 'My Page', showSidebar: false }
|
|
29
|
-
* // 'color' and 'fontSize' are excluded because they're not declared in defaults
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function mergeLayoutProps<T extends Record<string, unknown>>(defaults: T, staticProps: Record<string, unknown>, dynamicProps: Record<string, unknown>): T;
|
|
33
18
|
type ComponentCheck<T> = (value: unknown) => value is T;
|
|
34
19
|
/**
|
|
35
20
|
* Normalizes layout definitions into a consistent structure.
|
package/types/types.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export type DefaultInertiaConfig = {
|
|
|
40
40
|
errorValueType: string;
|
|
41
41
|
flashDataType: PageFlashData;
|
|
42
42
|
sharedPageProps: PageProps;
|
|
43
|
+
layoutProps: Record<string, unknown>;
|
|
44
|
+
namedLayoutProps: Record<string, Record<string, unknown>>;
|
|
43
45
|
};
|
|
44
46
|
/**
|
|
45
47
|
* Designed to allow overriding of some core types using TypeScript
|
|
@@ -60,6 +62,14 @@ export type DefaultInertiaConfig = {
|
|
|
60
62
|
* sharedPageProps: {
|
|
61
63
|
* auth: { user: User | null }
|
|
62
64
|
* }
|
|
65
|
+
* layoutProps: {
|
|
66
|
+
* title: string
|
|
67
|
+
* showSidebar: boolean
|
|
68
|
+
* }
|
|
69
|
+
* namedLayoutProps: {
|
|
70
|
+
* app: { title: string; theme: string }
|
|
71
|
+
* content: { padding: string; maxWidth: string }
|
|
72
|
+
* }
|
|
63
73
|
* }
|
|
64
74
|
* }
|
|
65
75
|
* ```
|
|
@@ -70,6 +80,8 @@ export type InertiaConfigFor<Key extends keyof DefaultInertiaConfig> = Key exten
|
|
|
70
80
|
export type ErrorValue = InertiaConfigFor<'errorValueType'>;
|
|
71
81
|
export type FlashData = InertiaConfigFor<'flashDataType'>;
|
|
72
82
|
export type SharedPageProps = InertiaConfigFor<'sharedPageProps'>;
|
|
83
|
+
export type LayoutProps = InertiaConfigFor<'layoutProps'>;
|
|
84
|
+
export type NamedLayoutProps = InertiaConfigFor<'namedLayoutProps'>;
|
|
73
85
|
export type Errors = Record<string, ErrorValue>;
|
|
74
86
|
export type ErrorBag = Record<string, Errors>;
|
|
75
87
|
export type FormDataConvertibleValue = Blob | FormDataEntryValue | Date | boolean | number | null | undefined;
|
|
@@ -180,7 +192,7 @@ export type CancelToken = {
|
|
|
180
192
|
cancel: VoidFunction;
|
|
181
193
|
};
|
|
182
194
|
export type CancelTokenCallback = (cancelToken: CancelToken) => void;
|
|
183
|
-
export type OptimisticCallback<TProps = Page['props']> = (props: TProps) => Partial<TProps> | void;
|
|
195
|
+
export type OptimisticCallback<TProps = Page<SharedPageProps>['props']> = (props: TProps) => Partial<TProps> | void;
|
|
184
196
|
export type Visit<T extends RequestPayload = RequestPayload> = {
|
|
185
197
|
method: Method;
|
|
186
198
|
data: T;
|
|
@@ -506,7 +518,7 @@ export type UseFormSubmitOptions = Omit<VisitOptions, 'data'>;
|
|
|
506
518
|
export type UseFormSubmitArguments = [Method, string, UseFormSubmitOptions?] | [UrlMethodPair, UseFormSubmitOptions?] | [UseFormSubmitOptions?];
|
|
507
519
|
export type UseHttpSubmitArguments<TResponse = unknown, TForm = unknown> = [Method, string, UseHttpSubmitOptions<TResponse, TForm>?] | [UrlMethodPair, UseHttpSubmitOptions<TResponse, TForm>?] | [UseHttpSubmitOptions<TResponse, TForm>?];
|
|
508
520
|
export type FormComponentOptions = Pick<VisitOptions, 'preserveScroll' | 'preserveState' | 'preserveUrl' | 'replace' | 'only' | 'except' | 'reset' | 'viewTransition'>;
|
|
509
|
-
export type FormComponentOptimisticCallback<TProps = Page['props']> = (props: TProps, formData: Record<string, FormDataConvertible>) => Partial<TProps> | void;
|
|
521
|
+
export type FormComponentOptimisticCallback<TProps = Page<SharedPageProps>['props']> = (props: TProps, formData: Record<string, FormDataConvertible>) => Partial<TProps> | void;
|
|
510
522
|
export type FormComponentProps = Partial<Pick<Visit, 'headers' | 'queryStringArrayFormat' | 'errorBag' | 'showProgress' | 'invalidateCacheTags'> & Omit<VisitCallbacks, 'onPrefetched' | 'onPrefetching'>> & {
|
|
511
523
|
method?: Method | Uppercase<Method>;
|
|
512
524
|
action?: string | UrlMethodPair;
|