@storybook/tanstack-react 10.6.0-alpha.0 → 10.6.0-alpha.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/_browser-chunks/{chunk-WQHJSC2D.js → chunk-FF4C4TUQ.js} +51 -9
- package/dist/_browser-chunks/{chunk-XKNIZ3MM.js → chunk-LTDGLEVR.js} +9 -1
- package/dist/chunk-B2-fTWlC.d.ts +131 -0
- package/dist/export-mocks/react-router.d.ts +294 -291
- package/dist/export-mocks/react-router.js +16 -12
- package/dist/export-mocks/start-storage-context.d.ts +12 -10
- package/dist/export-mocks/start.d.ts +61 -49
- package/dist/export-mocks/start.js +3 -2
- package/dist/index.d.ts +54 -186
- package/dist/index.js +2 -2
- package/dist/node/index.d.ts +4 -26
- package/dist/node/index.js +6 -6
- package/dist/preset.d.ts +5 -4
- package/dist/preset.js +16 -7
- package/dist/preview.d.ts +6 -106
- package/dist/preview.js +2 -2
- package/package.json +6 -6
- package/template/stories/PathlessLayout.stories.tsx +150 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
isPathlessFileRouteId,
|
|
2
3
|
normalizeFileRoutePath
|
|
3
|
-
} from "../_browser-chunks/chunk-
|
|
4
|
+
} from "../_browser-chunks/chunk-LTDGLEVR.js";
|
|
4
5
|
import {
|
|
5
6
|
onNavigate
|
|
6
7
|
} from "../_browser-chunks/chunk-4CKCBIXI.js";
|
|
@@ -51,17 +52,20 @@ var useNavigate = fn(_useNavigate).mockName("@tanstack/react-router::useNavigate
|
|
|
51
52
|
);
|
|
52
53
|
};
|
|
53
54
|
function createFileRoute(path) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
return (options) => {
|
|
56
|
+
let pathless = isPathlessFileRouteId(path) && options?.path == null, routePath = options?.path ?? normalizeFileRoutePath(path);
|
|
57
|
+
return createRoute({
|
|
58
|
+
...pathless ? { id: path } : { path: routePath },
|
|
59
|
+
...options,
|
|
60
|
+
isRoot: !1
|
|
61
|
+
}).update({
|
|
62
|
+
// routeTree.gen re-updates these later; set them here so route files
|
|
63
|
+
// imported without the generated tree still carry their identity
|
|
64
|
+
id: path,
|
|
65
|
+
...pathless ? {} : { path: routePath, fullPath: routePath }
|
|
66
|
+
// any because tanstack router does that
|
|
67
|
+
});
|
|
68
|
+
};
|
|
65
69
|
}
|
|
66
70
|
export {
|
|
67
71
|
Link,
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { Awaitable, RegisteredRouter } from
|
|
1
|
+
import { Awaitable, RegisteredRouter } from "@tanstack/router-core";
|
|
2
2
|
|
|
3
|
+
//#region node_modules/@tanstack/start-storage-context/dist/esm/async-local-storage.d.ts
|
|
3
4
|
interface StartStorageContext {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
getRouter: () => Awaitable<RegisteredRouter>;
|
|
6
|
+
request: Request;
|
|
7
|
+
startOptions: any;
|
|
8
|
+
contextAfterGlobalMiddlewares: any;
|
|
9
|
+
executedRequestMiddlewares: Set<any>;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region code/frameworks/tanstack-react/.dts-emit/code/frameworks/tanstack-react/src/export-mocks/start-storage-context.d.ts
|
|
11
13
|
declare function runWithStartContext<T>(context: StartStorageContext, fn: () => T | Promise<T>): Promise<T>;
|
|
12
14
|
declare function getStartContext<TThrow extends boolean = true>(opts?: {
|
|
13
|
-
|
|
15
|
+
throwIfNotFound?: TThrow;
|
|
14
16
|
}): TThrow extends false ? StartStorageContext | undefined : StartStorageContext;
|
|
15
|
-
|
|
16
|
-
export { type StartStorageContext, getStartContext, runWithStartContext };
|
|
17
|
+
//#endregion
|
|
18
|
+
export { type StartStorageContext, getStartContext, runWithStartContext };
|
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { createServerFn as createServerFn$1 } from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { createServerFn as createServerFn$1 } from "@tanstack/start-client-core";
|
|
3
|
+
export * from "@tanstack/start-client-core";
|
|
4
|
+
export * from "@tanstack/react-start";
|
|
5
5
|
|
|
6
|
+
//#region code/frameworks/tanstack-react/.dts-emit/code/frameworks/tanstack-react/src/export-mocks/start.d.ts
|
|
6
7
|
type RequestOptions<TRegister = unknown> = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
context?: TRegister extends {
|
|
9
|
+
server: {
|
|
10
|
+
requestContext: infer TRequestContext;
|
|
11
|
+
};
|
|
12
|
+
} ? TRequestContext : unknown;
|
|
12
13
|
};
|
|
13
14
|
type MockRequestExecutor<TRegister = unknown> = (request: Request, opts?: RequestOptions<TRegister>) => Promise<unknown> | unknown;
|
|
14
15
|
type HandlerContext = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
request: Request;
|
|
17
|
+
responseHeaders: Headers;
|
|
18
|
+
router?: unknown;
|
|
19
|
+
context?: unknown;
|
|
20
|
+
requestContext?: unknown;
|
|
20
21
|
};
|
|
21
22
|
type HandlerCallback<TRouter = unknown> = (context: HandlerContext & {
|
|
22
|
-
|
|
23
|
+
router?: TRouter;
|
|
23
24
|
}) => Promise<unknown> | unknown;
|
|
24
25
|
type SessionConfig = Record<string, unknown>;
|
|
25
26
|
type MockSession<TSessionData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
data: Partial<TSessionData>;
|
|
28
|
+
update: (update?: Partial<TSessionData> | ((prev: Partial<TSessionData>) => Partial<TSessionData>)) => Promise<MockSession<TSessionData>>;
|
|
29
|
+
save: () => Promise<void>;
|
|
30
|
+
clear: () => Promise<void>;
|
|
30
31
|
};
|
|
31
32
|
declare const HEADERS: {
|
|
32
|
-
|
|
33
|
+
readonly TSS_SHELL: 'X-TSS_SHELL';
|
|
33
34
|
};
|
|
34
35
|
declare const VIRTUAL_MODULES: {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
readonly startManifest: 'tanstack-start-manifest:v';
|
|
37
|
+
readonly injectedHeadScripts: 'tanstack-start-injected-head-scripts:v';
|
|
38
|
+
readonly serverFnResolver: '#tanstack-start-server-fn-resolver';
|
|
38
39
|
};
|
|
39
40
|
declare function StartServer(): null;
|
|
40
41
|
declare const defineHandlerCallback: <TRouter = unknown>(handler: HandlerCallback<TRouter>) => HandlerCallback<TRouter>;
|
|
@@ -43,7 +44,7 @@ declare const defaultRenderHandler: () => Promise<Response>;
|
|
|
43
44
|
declare const requestHandler: <TRegister = unknown>(handler: MockRequestExecutor<TRegister>) => (request: Request, requestOpts?: RequestOptions<TRegister>) => Promise<Response>;
|
|
44
45
|
declare const createRequestHandler: <TRegister = unknown>(handler: MockRequestExecutor<TRegister>) => (request: Request, requestOpts?: RequestOptions<TRegister> | undefined) => Promise<Response>;
|
|
45
46
|
declare const createStartHandler: <TRegister = unknown>(cbOrOptions: HandlerCallback | {
|
|
46
|
-
|
|
47
|
+
handler?: HandlerCallback;
|
|
47
48
|
}) => (request: Request, requestOpts?: RequestOptions<TRegister> | undefined) => Promise<Response>;
|
|
48
49
|
declare const attachRouterServerSsrUtils: <TRouter>(router: TRouter) => TRouter;
|
|
49
50
|
declare const transformReadableStreamWithRouter: <TReadableStream>(stream: TReadableStream) => TReadableStream;
|
|
@@ -52,17 +53,17 @@ declare const getRequest: () => Request;
|
|
|
52
53
|
declare const getRequestHeaders: () => Headers;
|
|
53
54
|
declare const getRequestHeader: (name: string) => string | undefined;
|
|
54
55
|
declare const getRequestIP: (opts?: {
|
|
55
|
-
|
|
56
|
+
xForwardedFor?: boolean;
|
|
56
57
|
}) => string | undefined;
|
|
57
58
|
declare const getRequestHost: (opts?: {
|
|
58
|
-
|
|
59
|
+
xForwardedHost?: boolean;
|
|
59
60
|
}) => string;
|
|
60
61
|
declare const getRequestUrl: (opts?: {
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
xForwardedHost?: boolean;
|
|
63
|
+
xForwardedProto?: boolean;
|
|
63
64
|
}) => URL;
|
|
64
65
|
declare const getRequestProtocol: (opts?: {
|
|
65
|
-
|
|
66
|
+
xForwardedProto?: boolean;
|
|
66
67
|
}) => string;
|
|
67
68
|
declare const setResponseHeaders: (headers: HeadersInit) => void;
|
|
68
69
|
declare const getResponseHeaders: () => Headers;
|
|
@@ -73,7 +74,7 @@ declare const clearResponseHeaders: (headerNames?: Array<string>) => void;
|
|
|
73
74
|
declare const getResponseStatus: () => number;
|
|
74
75
|
declare const setResponseStatus: (code?: number, text?: string) => void;
|
|
75
76
|
declare const getCookies: () => {
|
|
76
|
-
|
|
77
|
+
[k: string]: string;
|
|
77
78
|
};
|
|
78
79
|
declare const getCookie: (name: string) => string | undefined;
|
|
79
80
|
declare const setCookie: (name: string, value: string, options?: Record<string, unknown>) => void;
|
|
@@ -85,36 +86,47 @@ declare const sealSession: (_config: SessionConfig) => Promise<string>;
|
|
|
85
86
|
declare const unsealSession: (_config: SessionConfig, sealed: string) => Promise<any>;
|
|
86
87
|
declare const clearSession: (_config: Partial<SessionConfig>) => Promise<void>;
|
|
87
88
|
declare const getResponse: () => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
status: number | undefined;
|
|
90
|
+
statusText: string | undefined;
|
|
91
|
+
readonly headers: Headers;
|
|
91
92
|
};
|
|
92
93
|
declare const getValidatedQuery: (schema: {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
parse?: (value: Record<string, string>) => unknown;
|
|
95
|
+
safeParse?: (value: Record<string, string>) => unknown;
|
|
96
|
+
['~standard']?: {
|
|
97
|
+
validate?: (value: Record<string, string>) => Promise<unknown> | unknown;
|
|
98
|
+
};
|
|
98
99
|
}) => Promise<unknown>;
|
|
99
100
|
declare function useServerFn<T extends (...args: Array<any>) => Promise<any>>(serverFn: T): (...args: Parameters<T>) => ReturnType<T>;
|
|
100
101
|
declare const createServerFn: typeof createServerFn$1;
|
|
101
|
-
declare const Link: ({
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
declare const Link: ({
|
|
103
|
+
to,
|
|
104
|
+
children,
|
|
105
|
+
...props
|
|
106
|
+
}: {
|
|
107
|
+
to: string;
|
|
108
|
+
children?: React.ReactNode;
|
|
109
|
+
[key: string]: unknown;
|
|
105
110
|
}) => React.ReactElement<{
|
|
106
|
-
|
|
111
|
+
href: string;
|
|
107
112
|
}, string | React.JSXElementConstructor<any>>;
|
|
108
|
-
declare const Navigate: ({
|
|
109
|
-
|
|
113
|
+
declare const Navigate: ({
|
|
114
|
+
to
|
|
115
|
+
}: {
|
|
116
|
+
to: string;
|
|
110
117
|
}) => null;
|
|
118
|
+
declare const Hydrate: ({
|
|
119
|
+
children
|
|
120
|
+
}: {
|
|
121
|
+
children?: React.ReactNode;
|
|
122
|
+
[key: string]: unknown;
|
|
123
|
+
}) => string | number | boolean | Iterable<React.ReactNode> | React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
111
124
|
declare const notFound: () => never;
|
|
112
125
|
declare const createStart: () => {};
|
|
113
126
|
declare const clearCookieStore: () => void;
|
|
114
127
|
declare const fetchHandler: () => Promise<Response>;
|
|
115
|
-
|
|
116
128
|
declare const _default: {
|
|
117
|
-
|
|
129
|
+
fetch: typeof fetchHandler;
|
|
118
130
|
};
|
|
119
|
-
|
|
120
|
-
export { HEADERS, Link, Navigate, StartServer, VIRTUAL_MODULES, attachRouterServerSsrUtils, clearCookieStore, clearResponseHeaders, clearSession, createRequestHandler, createServerFn, createStart, createStartHandler, _default as default, defaultRenderHandler, defaultStreamHandler, defineHandlerCallback, deleteCookie, fetchHandler as fetch, getCookie, getCookies, getRequest, getRequestHeader, getRequestHeaders, getRequestHost, getRequestIP, getRequestProtocol, getRequestUrl, getResponse, getResponseHeader, getResponseHeaders, getResponseStatus, getSession, getValidatedQuery, notFound, removeResponseHeader, requestHandler, sealSession, setCookie, setResponseHeader, setResponseHeaders, setResponseStatus, transformPipeableStreamWithRouter, transformReadableStreamWithRouter, unsealSession, updateSession, useServerFn, useSession };
|
|
131
|
+
//#endregion
|
|
132
|
+
export { HEADERS, Hydrate, Link, Navigate, StartServer, VIRTUAL_MODULES, attachRouterServerSsrUtils, clearCookieStore, clearResponseHeaders, clearSession, createRequestHandler, createServerFn, createStart, createStartHandler, _default as default, defaultRenderHandler, defaultStreamHandler, defineHandlerCallback, deleteCookie, fetchHandler as fetch, getCookie, getCookies, getRequest, getRequestHeader, getRequestHeaders, getRequestHost, getRequestIP, getRequestProtocol, getRequestUrl, getResponse, getResponseHeader, getResponseHeaders, getResponseStatus, getSession, getValidatedQuery, notFound, removeResponseHeader, requestHandler, sealSession, setCookie, setResponseHeader, setResponseHeaders, setResponseStatus, transformPipeableStreamWithRouter, transformReadableStreamWithRouter, unsealSession, updateSession, useServerFn, useSession };
|
|
@@ -262,7 +262,7 @@ function useServerFn(serverFn) {
|
|
|
262
262
|
}
|
|
263
263
|
function createMockServerFnBuilder() {
|
|
264
264
|
let builder = () => createMockServerFnBuilder(), _storedOptions;
|
|
265
|
-
return builder.options = (opts) => (_storedOptions = opts, builder), builder.middleware = () => createMockServerFnBuilder(), builder.inputValidator = () => createMockServerFnBuilder(), builder.handler = (handlerFn) => {
|
|
265
|
+
return builder.options = (opts) => (_storedOptions = opts, builder), builder.middleware = () => createMockServerFnBuilder(), builder.inputValidator = () => createMockServerFnBuilder(), builder.validator = () => createMockServerFnBuilder(), builder.handler = (handlerFn) => {
|
|
266
266
|
let mock = fn().mockName("@tanstack/start-client-core::createServerFn.handler()");
|
|
267
267
|
return handlerFn && mock.mockImplementation(async (opts) => handlerFn(opts)), mock;
|
|
268
268
|
}, builder._getOptions = () => _storedOptions, builder;
|
|
@@ -276,7 +276,7 @@ var createServerFn = (options) => {
|
|
|
276
276
|
...props
|
|
277
277
|
}) => React.createElement("a", { href: to, ...props }, children), Navigate = ({ to }) => (React.useEffect(() => {
|
|
278
278
|
onNavigate({ to });
|
|
279
|
-
}, [to]), null), notFound = () => {
|
|
279
|
+
}, [to]), null), Hydrate = ({ children }) => children ?? null, notFound = () => {
|
|
280
280
|
throw new Error("Not found");
|
|
281
281
|
}, createStart = () => ({}), clientCookieStore = /* @__PURE__ */ new Map(), clearCookieStore = () => {
|
|
282
282
|
clientCookieStore.clear();
|
|
@@ -284,6 +284,7 @@ var createServerFn = (options) => {
|
|
|
284
284
|
var start_default = { fetch: fetchHandler };
|
|
285
285
|
export {
|
|
286
286
|
HEADERS,
|
|
287
|
+
Hydrate,
|
|
287
288
|
Link,
|
|
288
289
|
Navigate,
|
|
289
290
|
StartServer,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { a as TanStackPreviewOptions, c as IsRoute, d as StoryRouteOptions, i as TanStackParameters, l as RouterParameters, n as FrameworkOptions, o as TanStackTypes, r as StorybookConfig, s as CreateStoryRouteOptions, t as DefaultStoryPath, u as StoryRouteFileOptions } from "./chunk-B2-fTWlC.js";
|
|
2
|
+
import { ComponentType } from "react";
|
|
3
|
+
import { AddonTypes, InferTypes, PreviewAddon } from "storybook/internal/csf";
|
|
4
|
+
import { Args, ArgsStoryFn, ComponentAnnotations, DecoratorFunction, Parameters, ProjectAnnotations, Renderer, StoryAnnotations } from "storybook/internal/types";
|
|
5
|
+
import { AnyRoute } from "@tanstack/react-router";
|
|
6
|
+
import { Meta as Meta$1, ReactMeta, ReactPreview, ReactRenderer, ReactTypes, StoryObj as StoryObj$1 } from "@storybook/react";
|
|
7
|
+
export * from "@storybook/react";
|
|
8
|
+
|
|
9
|
+
//#region node_modules/type-fest/source/union-to-intersection.d.ts
|
|
11
10
|
/**
|
|
12
11
|
Convert a union type to an intersection type.
|
|
13
12
|
|
|
@@ -25,23 +24,18 @@ type Intersection = UnionToIntersection<Union>;
|
|
|
25
24
|
|
|
26
25
|
@category Type
|
|
27
26
|
*/
|
|
28
|
-
type UnionToIntersection<Union> = (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
) extends ((mergedIntersection: infer Intersection) => void)
|
|
41
|
-
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
42
|
-
? Intersection & Union
|
|
43
|
-
: never;
|
|
44
|
-
|
|
27
|
+
type UnionToIntersection<Union> = (// `extends unknown` is always going to be the case and is used to convert the
|
|
28
|
+
// `Union` into a [distributive conditional
|
|
29
|
+
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
30
|
+
Union extends unknown // The union type is used as the only argument to a function since the union
|
|
31
|
+
// of function arguments is an intersection.
|
|
32
|
+
? (distributedUnion: Union) => void // This won't happen.
|
|
33
|
+
: never // Infer the `Intersection` type since TypeScript represents the positional
|
|
34
|
+
// arguments of unions of functions as an intersection of the union.
|
|
35
|
+
) extends ((mergedIntersection: infer Intersection) => void) // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
36
|
+
? Intersection & Union : never;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region node_modules/type-fest/source/simplify.d.ts
|
|
45
39
|
/**
|
|
46
40
|
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
47
41
|
|
|
@@ -100,8 +94,9 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
100
94
|
@see {@link SimplifyDeep}
|
|
101
95
|
@category Object
|
|
102
96
|
*/
|
|
103
|
-
type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
|
|
104
|
-
|
|
97
|
+
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region node_modules/type-fest/source/omit-index-signature.d.ts
|
|
105
100
|
/**
|
|
106
101
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
107
102
|
|
|
@@ -193,143 +188,18 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
193
188
|
@see {@link PickIndexSignature}
|
|
194
189
|
@category Object
|
|
195
190
|
*/
|
|
196
|
-
type OmitIndexSignature<ObjectType> = {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
: KeyType]: ObjectType[KeyType];
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
/** Union of every registered full path (e.g. `'/' | '/admin/users' | '/$libraryId/$version'`). */
|
|
203
|
-
type RegisteredFullPath = keyof Register['router']['routesByPath'];
|
|
204
|
-
type IsAppRouteTree<TRoute> = TRoute extends Register['router']['routeTree'] ? true : false;
|
|
205
|
-
type IsRoute<T> = T extends AnyRoute ? true : T extends FileRoutesByPath[keyof FileRoutesByPath] ? true : false;
|
|
206
|
-
type ExtractAllPathsFromFileRoutes<TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] | AnyRoute> = TRoute['path'];
|
|
207
|
-
type StoryRoutePath<TRoute = undefined> = TRoute extends FileRoutesByPath[keyof FileRoutesByPath] ? ExtractAllPathsFromFileRoutes<TRoute> : keyof FileRoutesByPath | `/${string}`;
|
|
208
|
-
type StoryRouteSearch<TRoute> = IsAppRouteTree<TRoute> extends true ? Record<string, unknown> : TRoute extends FileRoutesByPath[keyof FileRoutesByPath] ? TRoute['preLoaderRoute'] extends {
|
|
209
|
-
types: {
|
|
210
|
-
allSearch: infer A;
|
|
211
|
-
};
|
|
212
|
-
} ? A : never : Record<string, unknown>;
|
|
213
|
-
type StoryRouteFileOptions<TRoute = undefined> = IsRoute<TRoute> extends true ? TRoute extends {
|
|
214
|
-
options: infer O;
|
|
215
|
-
} ? Pick<O, Extract<keyof O, 'loader' | 'beforeLoad' | 'validateSearch' | 'loaderDeps' | 'context' | 'params' | 'head' | 'search' | 'parseParams' | 'context'>> : Pick<RouteOptions<unknown>, 'loader' | 'beforeLoad' | 'validateSearch' | 'loaderDeps' | 'context' | 'params' | 'head' | 'search' | 'parseParams' | 'context'> : Pick<RouteOptions<unknown>, 'loader' | 'beforeLoad' | 'validateSearch' | 'loaderDeps' | 'context' | 'params' | 'head' | 'search' | 'parseParams' | 'context'>;
|
|
216
|
-
type CreateStoryRouteOptions<TRoute = undefined> = StoryRouteFileOptions<TRoute> & {
|
|
217
|
-
path?: StoryRoutePath<TRoute>;
|
|
218
|
-
};
|
|
219
|
-
type StoryRouteOptions<TRoute = undefined> = CreateStoryRouteOptions<TRoute> | (TRoute extends AnyRoute ? TRoute : AnyRoute);
|
|
220
|
-
/**
|
|
221
|
-
* Per-route override options for use inside `RouteTreeOverrides`.
|
|
222
|
-
* Users can override `loader`, `beforeLoad`, etc. for a specific route.
|
|
223
|
-
*/
|
|
224
|
-
interface RouteOverrideOptions<TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] | undefined = undefined> {
|
|
225
|
-
/** Override the route's loader function. */
|
|
226
|
-
loader?: TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] ? TRoute['options']['loader'] | ((ctx: unknown) => Promise<unknown> | unknown) : (ctx: unknown) => Promise<unknown> | unknown;
|
|
227
|
-
/** Override the route's beforeLoad function. */
|
|
228
|
-
beforeLoad?: TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] ? TRoute['options']['beforeLoad'] | ((ctx: unknown) => Promise<void> | void) : (ctx: unknown) => Promise<void> | void;
|
|
229
|
-
/** Override the route's search params validation. */
|
|
230
|
-
validateSearch?: TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] ? TRoute['options']['validateSearch'] | ((search: unknown) => Promise<void> | void) : (search: unknown) => Promise<void> | void;
|
|
231
|
-
/** Override the route's loader dependencies. */
|
|
232
|
-
loaderDeps?: TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] ? TRoute['options']['loaderDeps'] | string[] : string[];
|
|
233
|
-
/** Override the route's context function. */
|
|
234
|
-
context?: TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] ? TRoute['options']['context'] | ((ctx: unknown) => Promise<unknown> | unknown) : (ctx: unknown) => Promise<unknown> | unknown;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* A map of route overrides keyed by route ID.
|
|
238
|
-
* Each entry can override `loader`, `beforeLoad`, etc. for that route.
|
|
239
|
-
*
|
|
240
|
-
* @example
|
|
241
|
-
* ```ts
|
|
242
|
-
* routeOverrides: {
|
|
243
|
-
* '/_authed': { beforeLoad: () => {} },
|
|
244
|
-
* '/demo/form/simple/$id': {
|
|
245
|
-
* loader: async () => ({ name: 'Mock User' }),
|
|
246
|
-
* },
|
|
247
|
-
* }
|
|
248
|
-
* ```
|
|
249
|
-
*/
|
|
250
|
-
type RouteTreeOverrides = Partial<{
|
|
251
|
-
[routePath in keyof FileRoutesByPath]: RouteOverrideOptions<FileRoutesByPath[routePath]['preLoaderRoute']> | undefined;
|
|
252
|
-
}>;
|
|
253
|
-
interface RouterParameters<TRoute = undefined, Path extends TRoute extends AnyRoute ? keyof RoutesByPath<TRoute> : RegisteredFullPath = TRoute extends AnyRoute ? keyof RoutesByPath<TRoute> : keyof FileRoutesByPath> {
|
|
254
|
-
route?: StoryRouteOptions<TRoute>;
|
|
255
|
-
/**
|
|
256
|
-
* Path to resolve the story route against.
|
|
257
|
-
* Constrained to known registered paths in route tree mode, but can be any string in app route mode (since the user may be passing a custom `route` that doesn't exist in the registered tree).
|
|
258
|
-
*/
|
|
259
|
-
path?: Path;
|
|
260
|
-
/** URL params to interpolate into the path (e.g. `{ id: '42' }` for `/$id`). */
|
|
261
|
-
params?: ResolveParams<Path>;
|
|
262
|
-
/** Search/query params to append to the URL (e.g. `{ tab: 'details' }`). */
|
|
263
|
-
query?: Partial<StoryRouteSearch<TRoute>>;
|
|
264
|
-
/**
|
|
265
|
-
* Override options for specific routes in the app route tree (route tree mode only).
|
|
266
|
-
*
|
|
267
|
-
* Each key is a route ID (e.g. `'/about'`, `'__root__'`, `'/demo/form/simple/$id'`).
|
|
268
|
-
* Values can override `loader`, `beforeLoad`, etc. for that route.
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* ```ts
|
|
272
|
-
* routeOverrides: {
|
|
273
|
-
* '/_authed': { beforeLoad: () => {} },
|
|
274
|
-
* '/demo/form/simple/$id': {
|
|
275
|
-
* loader: async () => ({ name: 'Mock User' }),
|
|
276
|
-
* },
|
|
277
|
-
* }
|
|
278
|
-
* ```
|
|
279
|
-
*/
|
|
280
|
-
routeOverrides?: RouteTreeOverrides;
|
|
281
|
-
context?: Record<string, unknown>;
|
|
282
|
-
/**
|
|
283
|
-
*
|
|
284
|
-
*/
|
|
285
|
-
useRouterContext?: ({ storyContext }: {
|
|
286
|
-
storyContext: Parameters<Decorator>[1];
|
|
287
|
-
}) => AnyContext;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
type FrameworkName = CompatibleString<'@storybook/tanstack-react'>;
|
|
291
|
-
type BuilderName = CompatibleString<'@storybook/builder-vite'>;
|
|
292
|
-
type FrameworkOptions = {
|
|
293
|
-
/** Builder options passed through to @storybook/builder-vite. */
|
|
294
|
-
builder?: BuilderOptions;
|
|
295
|
-
};
|
|
296
|
-
type StorybookConfigFramework = {
|
|
297
|
-
framework: FrameworkName | {
|
|
298
|
-
name: FrameworkName;
|
|
299
|
-
options: FrameworkOptions;
|
|
300
|
-
};
|
|
301
|
-
core?: StorybookConfig$1['core'] & {
|
|
302
|
-
builder?: BuilderName | {
|
|
303
|
-
name: BuilderName;
|
|
304
|
-
options: BuilderOptions;
|
|
305
|
-
};
|
|
306
|
-
};
|
|
307
|
-
};
|
|
308
|
-
/** The interface for Storybook configuration in `main.ts` files. */
|
|
309
|
-
type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigFramework> & StorybookConfigFramework;
|
|
310
|
-
/** Path constraint mirroring `RouterParameters`'s second generic. */
|
|
311
|
-
type DefaultStoryPath<TRoute> = TRoute extends AnyRoute ? keyof RoutesByPath<TRoute> : RegisteredFullPath;
|
|
312
|
-
interface TanStackPreviewOptions<TRoute = undefined, Path extends DefaultStoryPath<TRoute> = DefaultStoryPath<TRoute>> {
|
|
313
|
-
/** Router configuration for stories */
|
|
314
|
-
router?: RouterParameters<TRoute, Path>;
|
|
315
|
-
}
|
|
316
|
-
interface TanStackParameters<TRoute = undefined, Path extends DefaultStoryPath<TRoute> = DefaultStoryPath<TRoute>> {
|
|
317
|
-
/** TanStack framework configuration (router integration). */
|
|
318
|
-
tanstack?: TanStackPreviewOptions<TRoute, Path>;
|
|
319
|
-
}
|
|
320
|
-
interface TanStackTypes<TRoute = undefined, Path extends DefaultStoryPath<TRoute> = DefaultStoryPath<TRoute>> {
|
|
321
|
-
parameters: TanStackParameters<TRoute, Path>;
|
|
322
|
-
}
|
|
323
|
-
|
|
191
|
+
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region code/frameworks/tanstack-react/.dts-emit/code/frameworks/tanstack-react/src/index.d.ts
|
|
324
194
|
/** Extracts and unions all args types from an array of decorators. */
|
|
325
195
|
type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
|
|
326
196
|
type InferCombinedTypes<T, TArgs, Decorators> = ReactTypes & T & {
|
|
327
|
-
|
|
197
|
+
args: Simplify<TArgs & Simplify<OmitIndexSignature<DecoratorsArgs<ReactTypes & T, Decorators>>>>;
|
|
328
198
|
};
|
|
329
199
|
type Preview<TRoute extends AnyRoute | undefined = undefined> = ProjectAnnotations<ReactTypes & TanStackTypes<TRoute>>;
|
|
330
200
|
declare function definePreview<TRoute extends AnyRoute | undefined = undefined, const TPath extends DefaultStoryPath<TRoute> = DefaultStoryPath<TRoute>, Addons extends PreviewAddon<never>[] = []>(preview: {
|
|
331
|
-
|
|
332
|
-
|
|
201
|
+
addons?: Addons;
|
|
202
|
+
route?: TRoute;
|
|
333
203
|
} & ProjectAnnotations<ReactTypes & TanStackTypes<NoInfer<TRoute>, TPath> & InferTypes<Addons>>): TanStackPreview<InferTypes<Addons>, TRoute>;
|
|
334
204
|
/**
|
|
335
205
|
* Metadata to configure stories for a component or a TanStack Route.
|
|
@@ -343,31 +213,29 @@ type Meta<TCmpOrArgs = Args> = IsRoute<TCmpOrArgs> extends true ? Omit<Component
|
|
|
343
213
|
* When the meta's `component` is a TanStack Route, the story inherits
|
|
344
214
|
* TanStack parameter types for type-safe params/query/loader configuration.
|
|
345
215
|
*/
|
|
346
|
-
type StoryObj<TMetaOrCmpOrArgs = unknown> = [TMetaOrCmpOrArgs] extends [
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
] ? IsRoute<Component> extends true ? StoryAnnotations<ReactRenderer, Args, Partial<Args>> & Partial<TanStackTypes<Component>> : StoryObj$1<TMetaOrCmpOrArgs> & Partial<TanStackTypes> : IsRoute<TMetaOrCmpOrArgs> extends true ? StoryAnnotations<ReactRenderer, Args, Partial<Args>> & Partial<TanStackTypes<TMetaOrCmpOrArgs>> : StoryObj$1<TMetaOrCmpOrArgs> & Partial<TanStackTypes>;
|
|
216
|
+
type StoryObj<TMetaOrCmpOrArgs = unknown> = [TMetaOrCmpOrArgs] extends [{
|
|
217
|
+
component?: infer Component;
|
|
218
|
+
}] ? IsRoute<Component> extends true ? StoryAnnotations<ReactRenderer, Args, Partial<Args>> & Partial<TanStackTypes<Component>> : StoryObj$1<TMetaOrCmpOrArgs> & Partial<TanStackTypes> : IsRoute<TMetaOrCmpOrArgs> extends true ? StoryAnnotations<ReactRenderer, Args, Partial<Args>> & Partial<TanStackTypes<TMetaOrCmpOrArgs>> : StoryObj$1<TMetaOrCmpOrArgs> & Partial<TanStackTypes>;
|
|
351
219
|
interface TanStackPreview<T extends AddonTypes, TRoute extends AnyRoute | undefined = undefined> extends ReactPreview<TanStackTypes<TRoute> & T> {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
220
|
+
type<R>(): TanStackPreview<T & R, TRoute>;
|
|
221
|
+
meta<TMetaRoute extends AnyRoute, const TPath extends DefaultStoryPath<TMetaRoute> = DefaultStoryPath<TMetaRoute>, TArgs extends Args = Args, Decorators extends DecoratorFunction<ReactTypes & TanStackTypes<TMetaRoute, TPath> & T, any> = DecoratorFunction<ReactTypes & TanStackTypes<TMetaRoute, TPath> & T, any>, TMetaArgs extends Partial<TArgs & (TanStackTypes<TMetaRoute, TPath> & T)['args']> = Partial<TArgs & (TanStackTypes<TMetaRoute, TPath> & T)['args']>>(meta: {
|
|
222
|
+
render?: ArgsStoryFn<ReactTypes & TanStackTypes<TMetaRoute, TPath> & T, TArgs & (TanStackTypes<TMetaRoute, TPath> & T)['args']>;
|
|
223
|
+
component?: ComponentType<TArgs>;
|
|
224
|
+
decorators?: Decorators | Decorators[];
|
|
225
|
+
args?: TMetaArgs;
|
|
226
|
+
parameters?: TanStackParameters<TMetaRoute, TPath> & Parameters & (ReactTypes & T)['parameters'];
|
|
227
|
+
} & Omit<ComponentAnnotations<ReactTypes & TanStackTypes<TMetaRoute, TPath> & T, TArgs>, 'decorators' | 'component' | 'args' | 'render' | 'parameters'>): ReactMeta<InferCombinedTypes<TanStackTypes<TMetaRoute, TPath> & T, TArgs, Decorators>, Omit<ComponentAnnotations<InferCombinedTypes<TanStackTypes<TMetaRoute, TPath> & T, TArgs, Decorators>>, 'args'> & {
|
|
228
|
+
args: Partial<TArgs> extends TMetaArgs ? {} : TMetaArgs;
|
|
229
|
+
}>;
|
|
230
|
+
meta<const TPath extends DefaultStoryPath<TRoute> = DefaultStoryPath<TRoute>, TArgs extends Args = Args, Decorators extends DecoratorFunction<ReactTypes & TanStackTypes<TRoute, TPath> & T, any> = DecoratorFunction<ReactTypes & TanStackTypes<TRoute, TPath> & T, any>, TMetaArgs extends Partial<TArgs & (TanStackTypes<TRoute, TPath> & T)['args']> = Partial<TArgs & (TanStackTypes<TRoute, TPath> & T)['args']>>(meta: {
|
|
231
|
+
render?: ArgsStoryFn<ReactTypes & TanStackTypes<TRoute, TPath> & T, TArgs & (TanStackTypes<TRoute, TPath> & T)['args']>;
|
|
232
|
+
component?: ComponentType<TArgs>;
|
|
233
|
+
decorators?: Decorators | Decorators[];
|
|
234
|
+
args?: TMetaArgs;
|
|
235
|
+
parameters?: TanStackParameters<TRoute, TPath> & Parameters & (ReactTypes & T)['parameters'];
|
|
236
|
+
} & Omit<ComponentAnnotations<ReactTypes & TanStackTypes<TRoute, TPath> & T, TArgs>, 'decorators' | 'component' | 'args' | 'render' | 'parameters'>): ReactMeta<InferCombinedTypes<TanStackTypes<TRoute, TPath> & T, TArgs, Decorators>, Omit<ComponentAnnotations<InferCombinedTypes<TanStackTypes<TRoute, TPath> & T, TArgs, Decorators>>, 'args'> & {
|
|
237
|
+
args: Partial<TArgs> extends TMetaArgs ? {} : TMetaArgs;
|
|
238
|
+
}>;
|
|
371
239
|
}
|
|
372
|
-
|
|
373
|
-
export { type CreateStoryRouteOptions,
|
|
240
|
+
//#endregion
|
|
241
|
+
export { type CreateStoryRouteOptions, DefaultStoryPath, FrameworkOptions, type IsRoute, Meta, Preview, type RouterParameters, StoryObj, type StoryRouteFileOptions, type StoryRouteOptions, StorybookConfig, TanStackParameters, TanStackPreview, TanStackPreviewOptions, TanStackTypes, definePreview };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
preview_exports
|
|
3
|
-
} from "./_browser-chunks/chunk-
|
|
4
|
-
import "./_browser-chunks/chunk-
|
|
3
|
+
} from "./_browser-chunks/chunk-FF4C4TUQ.js";
|
|
4
|
+
import "./_browser-chunks/chunk-LTDGLEVR.js";
|
|
5
5
|
import "./_browser-chunks/chunk-4BE7D4DS.js";
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,28 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BuilderOptions } from '@storybook/builder-vite';
|
|
3
|
-
import { StorybookConfig as StorybookConfig$1 } from '@storybook/react-vite';
|
|
4
|
-
|
|
5
|
-
type FrameworkName = CompatibleString<'@storybook/tanstack-react'>;
|
|
6
|
-
type BuilderName = CompatibleString<'@storybook/builder-vite'>;
|
|
7
|
-
type FrameworkOptions = {
|
|
8
|
-
/** Builder options passed through to @storybook/builder-vite. */
|
|
9
|
-
builder?: BuilderOptions;
|
|
10
|
-
};
|
|
11
|
-
type StorybookConfigFramework = {
|
|
12
|
-
framework: FrameworkName | {
|
|
13
|
-
name: FrameworkName;
|
|
14
|
-
options: FrameworkOptions;
|
|
15
|
-
};
|
|
16
|
-
core?: StorybookConfig$1['core'] & {
|
|
17
|
-
builder?: BuilderName | {
|
|
18
|
-
name: BuilderName;
|
|
19
|
-
options: BuilderOptions;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
/** The interface for Storybook configuration in `main.ts` files. */
|
|
24
|
-
type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigFramework> & StorybookConfigFramework;
|
|
1
|
+
import { r as StorybookConfig } from "../chunk-B2-fTWlC.js";
|
|
25
2
|
|
|
3
|
+
//#region code/frameworks/tanstack-react/.dts-emit/code/frameworks/tanstack-react/src/node/index.d.ts
|
|
26
4
|
declare function defineMain(config: StorybookConfig): StorybookConfig;
|
|
27
|
-
|
|
28
|
-
export { type StorybookConfig, defineMain };
|
|
5
|
+
//#endregion
|
|
6
|
+
export { type StorybookConfig, defineMain };
|
package/dist/node/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_u7g6u19rsi from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_u7g6u19rsi from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_u7g6u19rsi from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_u7g6u19rsi.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_u7g6u19rsi.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_u7g6u19rsi.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|