@storybook/tanstack-react 0.0.0-pr-34403-sha-e7426ce1 → 0.0.0-pr-34403-sha-b08cb0b7

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.
@@ -0,0 +1,209 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-4BE7D4DS.js";
4
+
5
+ // src/preview.tsx
6
+ var preview_exports = {};
7
+ __export(preview_exports, {
8
+ applyDecorators: () => applyDecorators,
9
+ loaders: () => loaders,
10
+ parameters: () => parameters
11
+ });
12
+ import { defaultDecorateStory } from "storybook/preview-api";
13
+
14
+ // src/routing/decorator.tsx
15
+ import React from "react";
16
+ import {
17
+ createMemoryHistory,
18
+ createRootRoute as createRootRoute2,
19
+ createRoute as createRoute2,
20
+ createRouter,
21
+ Route,
22
+ RouterProvider,
23
+ RootRoute as RootRoute2,
24
+ interpolatePath,
25
+ defaultStringifySearch
26
+ } from "@tanstack/react-router";
27
+
28
+ // src/routing/duplicate-tree.ts
29
+ import {
30
+ createRoute,
31
+ RootRoute,
32
+ createRootRouteWithContext
33
+ } from "@tanstack/react-router";
34
+ var MAX_PARENT_WALK = 50;
35
+ function findRootRoute(route) {
36
+ let current = route;
37
+ for (let i = 0; i < MAX_PARENT_WALK && current; i += 1) {
38
+ if (current instanceof RootRoute)
39
+ return current;
40
+ let getParent = current.options?.getParentRoute;
41
+ current = typeof getParent == "function" ? getParent() : void 0;
42
+ }
43
+ }
44
+ function getOverrideFor(overrides, routeId) {
45
+ return overrides ? overrides[routeId] ?? {} : {};
46
+ }
47
+ function cloneChild(oldRoute, parent, overrides, byId) {
48
+ let options = oldRoute.options ?? {}, { id: _id, getParentRoute: _g, ...rest } = options, override = getOverrideFor(overrides, oldRoute.id), cloned = createRoute({
49
+ ...rest,
50
+ ...override,
51
+ getParentRoute: () => parent
52
+ });
53
+ byId.set(oldRoute.id, cloned);
54
+ let children = oldRoute.children;
55
+ if (children?.length) {
56
+ let clonedChildren = children.map(
57
+ (child) => cloneChild(child, cloned, overrides, byId)
58
+ );
59
+ cloned.addChildren(clonedChildren);
60
+ }
61
+ return cloned;
62
+ }
63
+ function duplicateRouteTree(rootRoute, { overrides } = {}) {
64
+ let byId = /* @__PURE__ */ new Map(), rootOptions = rootRoute.options ?? {}, rootOverride = getOverrideFor(overrides, "__root__"), { id: _rootId, getParentRoute: _rootGetParent, ...restRoot } = rootOptions, newRoot = createRootRouteWithContext()({
65
+ ...restRoot,
66
+ ...rootOverride
67
+ });
68
+ byId.set("__root__", newRoot);
69
+ let children = rootRoute.children;
70
+ if (children?.length) {
71
+ let clonedChildren = children.map(
72
+ (child) => cloneChild(child, newRoot, overrides, byId)
73
+ );
74
+ newRoot.addChildren(clonedChildren);
75
+ }
76
+ return { root: newRoot, byId };
77
+ }
78
+ function resolveStoryLeaf(tree, { path, boundRouteId }) {
79
+ let { root, byId } = tree;
80
+ if (path) {
81
+ let bestMatch, bestMatchLength = -1;
82
+ for (let route of byId.values()) {
83
+ let fullPath = route.fullPath;
84
+ fullPath && fullPath === path && fullPath.length > bestMatchLength && (bestMatch = route, bestMatchLength = fullPath.length);
85
+ }
86
+ if (bestMatch)
87
+ return bestMatch;
88
+ }
89
+ if (boundRouteId) {
90
+ let bound = byId.get(boundRouteId);
91
+ if (bound)
92
+ return bound;
93
+ }
94
+ let firstChild = root.children?.[0];
95
+ return firstChild || root;
96
+ }
97
+
98
+ // src/routing/decorator.tsx
99
+ function isRoute(value) {
100
+ return value instanceof Route || value instanceof RootRoute2;
101
+ }
102
+ function injectStoryComponent(leaf, Story, overrides, leafId) {
103
+ let userOverride = overrides?.[leafId];
104
+ userOverride && "component" in userOverride && userOverride.component !== void 0 || leaf.update({ component: () => React.createElement(Story, null) });
105
+ }
106
+ function resolveTree(Story, context) {
107
+ let metaRoute = context.route, routerParameters = context.parameters.tanstack?.router ?? {}, routerParameterRoute = routerParameters.route, routeOverrides = routerParameters.routeOverrides, resolvedRoute = isRoute(routerParameterRoute) ? routerParameterRoute : isRoute(metaRoute) ? metaRoute : void 0, rootRoute = resolvedRoute ? findRootRoute(resolvedRoute) : void 0;
108
+ if (rootRoute) {
109
+ let tree2 = duplicateRouteTree(rootRoute, { overrides: routeOverrides }), leaf2 = resolveStoryLeaf(tree2, {
110
+ path: routerParameters.path,
111
+ boundRouteId: resolvedRoute && resolvedRoute !== rootRoute ? resolvedRoute.id : void 0
112
+ });
113
+ return injectStoryComponent(leaf2, Story, routeOverrides, leaf2.id), { tree: tree2, leaf: leaf2 };
114
+ }
115
+ let plainOptions = routerParameterRoute ?? {}, { children: plainChildren, ...plainRest } = plainOptions, syntheticRoot = createRootRoute2(
116
+ routeOverrides?.__root__ ?? {}
117
+ ), syntheticChild = createRoute2({
118
+ component: () => React.createElement(Story, null),
119
+ ...plainRest,
120
+ path: plainRest.path ?? "/",
121
+ getParentRoute: () => syntheticRoot
122
+ });
123
+ if (plainChildren?.length) {
124
+ for (let child of plainChildren)
125
+ child.options.getParentRoute = () => syntheticChild, child.update({ getParentRoute: () => syntheticChild });
126
+ syntheticChild.addChildren(plainChildren);
127
+ }
128
+ syntheticRoot.addChildren([syntheticChild]);
129
+ let tree = duplicateRouteTree(syntheticRoot, { overrides: routeOverrides }), leaf = tree.byId.get(syntheticChild.id) ?? tree.root;
130
+ return injectStoryComponent(leaf, Story, routeOverrides, leaf.id), { tree, leaf };
131
+ }
132
+ function createStoryRouter({
133
+ Story,
134
+ context,
135
+ routerContext
136
+ }) {
137
+ let routerParameters = context.parameters.tanstack?.router ?? {}, { tree, leaf } = resolveTree(Story, context), routeTree = tree.root, inferredPath = routerParameters?.path || leaf.fullPath || routeTree.children?.[0]?.fullPath || "/", resolvedPath = interpolatePath({
138
+ path: inferredPath,
139
+ params: routerParameters?.params ?? {}
140
+ }).interpolatedPath, search = routerParameters?.query ? defaultStringifySearch(routerParameters.query) : "";
141
+ search && (resolvedPath += search);
142
+ let history = createMemoryHistory({
143
+ initialEntries: [resolvedPath]
144
+ });
145
+ return history.replace(resolvedPath), createRouter({
146
+ routeTree,
147
+ history,
148
+ defaultNotFoundComponent(props) {
149
+ return React.createElement("div", null, "Route not found: ", props.routeId);
150
+ },
151
+ defaultErrorComponent({ error }) {
152
+ return React.createElement("div", null, "Story did something wrong : ", String(error));
153
+ },
154
+ context: routerContext
155
+ });
156
+ }
157
+ var tanstackRouteDecorator = (Story, context) => {
158
+ let routerContext = context.parameters.tanstack.router?.useRouterContext?.({
159
+ storyContext: context
160
+ }), router = createStoryRouter({
161
+ Story,
162
+ context,
163
+ routerContext
164
+ });
165
+ return React.createElement(
166
+ RouterProvider,
167
+ {
168
+ router,
169
+ context: {
170
+ ...context.parameters.tanstack?.router?.context,
171
+ ...routerContext
172
+ }
173
+ }
174
+ );
175
+ };
176
+
177
+ // src/routing/loader.ts
178
+ import { Route as Route2, RootRoute as RootRoute3 } from "@tanstack/react-router";
179
+ function isRoute2(value) {
180
+ return value instanceof Route2 || value instanceof RootRoute3;
181
+ }
182
+ function getComponentFromRoute(route) {
183
+ if (route.options?.component)
184
+ return route.options.component;
185
+ if (route instanceof RootRoute3)
186
+ return route.children?.[0]?.options?.component;
187
+ }
188
+ var routeComponentLoader = (context) => {
189
+ let componentRoute = isRoute2(context.component) ? context.component : void 0, routerParameters = context.parameters.tanstack?.router ?? {}, resolvedRoute = (isRoute2(routerParameters.route) ? routerParameters.route : void 0) ?? componentRoute;
190
+ if (resolvedRoute) {
191
+ if (!context.component) {
192
+ let component = getComponentFromRoute(resolvedRoute);
193
+ component && (componentRoute || !context.component) && (context.component = component);
194
+ }
195
+ context.route || (context.route = resolvedRoute);
196
+ }
197
+ };
198
+
199
+ // src/preview.tsx
200
+ var loaders = [routeComponentLoader], applyDecorators = (storyFn, allDecorators) => defaultDecorateStory(storyFn, [tanstackRouteDecorator, ...allDecorators]), parameters = {
201
+ tanstack: {}
202
+ };
203
+
204
+ export {
205
+ loaders,
206
+ applyDecorators,
207
+ parameters,
208
+ preview_exports
209
+ };
@@ -0,0 +1,38 @@
1
+ import CJS_COMPAT_NODE_URL_dxww6fnj7fh from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_dxww6fnj7fh from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_dxww6fnj7fh from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_dxww6fnj7fh.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_dxww6fnj7fh.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_dxww6fnj7fh.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ var __create = Object.create;
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __commonJS = (cb, mod) => function() {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from == "object" || typeof from == "function")
22
+ for (let key of __getOwnPropNames(from))
23
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
32
+ mod
33
+ ));
34
+
35
+ export {
36
+ __commonJS,
37
+ __toESM
38
+ };
@@ -1,5 +1,5 @@
1
1
  import * as _tanstack_react_router from '@tanstack/react-router';
2
- import { useNavigate as useNavigate$1, useRouter as useRouter$1, useBlocker as useBlocker$1, useMatch as useMatch$1, useSearch as useSearch$1, useParams as useParams$1, useLocation as useLocation$1, useRouterState as useRouterState$1, useMatchRoute as useMatchRoute$1, useLoaderData as useLoaderData$1, useLoaderDeps as useLoaderDeps$1, useRouteContext as useRouteContext$1, useMatches as useMatches$1, useParentMatches as useParentMatches$1, useChildMatches as useChildMatches$1, useCanGoBack as useCanGoBack$1, useLinkProps as useLinkProps$1, Navigate as Navigate$1 } from '@tanstack/react-router';
2
+ import { useNavigate as useNavigate$1, useRouter as useRouter$1, useBlocker as useBlocker$1, useSearch as useSearch$1, useParams as useParams$1, useLocation as useLocation$1, useRouterState as useRouterState$1, useLoaderData as useLoaderData$1, useLoaderDeps as useLoaderDeps$1, useRouteContext as useRouteContext$1, useCanGoBack as useCanGoBack$1, useLinkProps as useLinkProps$1, Navigate as Navigate$1 } from '@tanstack/react-router';
3
3
  export * from '@tanstack/react-router';
4
4
  import * as _tanstack_router_core from '@tanstack/router-core';
5
5
  import React from 'react';
@@ -316,18 +316,13 @@ interface Mock<T extends Procedure = Procedure> extends MockInstance<T> {
316
316
  declare const useNavigate: Mock<typeof useNavigate$1>;
317
317
  declare const useRouter: Mock<typeof useRouter$1>;
318
318
  declare const useBlocker: Mock<typeof useBlocker$1>;
319
- declare const useMatch: Mock<typeof useMatch$1>;
320
319
  declare const useSearch: Mock<typeof useSearch$1>;
321
320
  declare const useParams: Mock<typeof useParams$1>;
322
321
  declare const useLocation: Mock<typeof useLocation$1>;
323
322
  declare const useRouterState: Mock<typeof useRouterState$1>;
324
- declare const useMatchRoute: Mock<typeof useMatchRoute$1>;
325
323
  declare const useLoaderData: Mock<typeof useLoaderData$1>;
326
324
  declare const useLoaderDeps: Mock<typeof useLoaderDeps$1>;
327
325
  declare const useRouteContext: Mock<typeof useRouteContext$1>;
328
- declare const useMatches: Mock<typeof useMatches$1>;
329
- declare const useParentMatches: Mock<typeof useParentMatches$1>;
330
- declare const useChildMatches: Mock<typeof useChildMatches$1>;
331
326
  declare const useCanGoBack: Mock<typeof useCanGoBack$1>;
332
327
  declare const useLinkProps: Mock<typeof useLinkProps$1>;
333
328
  declare const Outlet: () => null;
@@ -346,4 +341,4 @@ declare const Link: ({ to, children, ...props }: {
346
341
  */
347
342
  declare function createFileRoute(path: string): (options: any) => _tanstack_react_router.Route<unknown, _tanstack_router_core.AnyRoute, "/", "/" | `/${any}/`, string, "/" | `/${any}/`, undefined, _tanstack_router_core.ResolveParams<"/">, _tanstack_router_core.AnyContext, _tanstack_router_core.AnyContext, _tanstack_router_core.AnyContext, {}, undefined, unknown, unknown, unknown, unknown, undefined>;
348
343
 
349
- export { Link, Navigate, Outlet, createFileRoute, useBlocker, useCanGoBack, useChildMatches, useLinkProps, useLoaderData, useLoaderDeps, useLocation, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useParentMatches, useRouteContext, useRouter, useRouterState, useSearch };
344
+ export { Link, Navigate, Outlet, createFileRoute, useBlocker, useCanGoBack, useLinkProps, useLoaderData, useLoaderDeps, useLocation, useNavigate, useParams, useRouteContext, useRouter, useRouterState, useSearch };
@@ -13,29 +13,20 @@ import {
13
13
  useNavigate as _useNavigate,
14
14
  useRouter as _useRouter,
15
15
  useBlocker as _useBlocker,
16
- useMatch as _useMatch,
17
16
  useSearch as _useSearch,
18
17
  useParams as _useParams,
19
18
  useLocation as _useLocation,
20
19
  useRouterState as _useRouterState,
21
- useMatchRoute as _useMatchRoute,
22
20
  useLoaderData as _useLoaderData,
23
21
  useLoaderDeps as _useLoaderDeps,
24
22
  useRouteContext as _useRouteContext,
25
- useMatches as _useMatches,
26
- useParentMatches as _useParentMatches,
27
- useChildMatches as _useChildMatches,
28
23
  useCanGoBack as _useCanGoBack,
29
24
  useLinkProps as _useLinkProps
30
25
  } from "@tanstack/react-router";
31
- var useNavigate = fn(_useNavigate).mockName("@tanstack/react-router::useNavigate"), useRouter = fn(_useRouter).mockName("@tanstack/react-router::useRouter"), useBlocker = fn(_useBlocker).mockName("@tanstack/react-router::useBlocker"), useMatch = fn(_useMatch).mockName("@tanstack/react-router::useMatch"), useSearch = fn(_useSearch).mockName("@tanstack/react-router::useSearch"), useParams = fn(_useParams).mockName("@tanstack/react-router::useParams"), useLocation = fn(_useLocation).mockName("@tanstack/react-router::useLocation"), useRouterState = fn(_useRouterState).mockName(
26
+ var useNavigate = fn(_useNavigate).mockName("@tanstack/react-router::useNavigate"), useRouter = fn(_useRouter).mockName("@tanstack/react-router::useRouter"), useBlocker = fn(_useBlocker).mockName("@tanstack/react-router::useBlocker"), useSearch = fn(_useSearch).mockName("@tanstack/react-router::useSearch"), useParams = fn(_useParams).mockName("@tanstack/react-router::useParams"), useLocation = fn(_useLocation).mockName("@tanstack/react-router::useLocation"), useRouterState = fn(_useRouterState).mockName(
32
27
  "@tanstack/react-router::useRouterState"
33
- ), useMatchRoute = fn(_useMatchRoute).mockName("@tanstack/react-router::useMatchRoute"), useLoaderData = fn(_useLoaderData).mockName("@tanstack/react-router::useLoaderData"), useLoaderDeps = fn(_useLoaderDeps).mockName("@tanstack/react-router::useLoaderDeps"), useRouteContext = fn(_useRouteContext).mockName(
28
+ ), useLoaderData = fn(_useLoaderData).mockName("@tanstack/react-router::useLoaderData"), useLoaderDeps = fn(_useLoaderDeps).mockName("@tanstack/react-router::useLoaderDeps"), useRouteContext = fn(_useRouteContext).mockName(
34
29
  "@tanstack/react-router::useRouteContext"
35
- ), useMatches = fn(_useMatches).mockName("@tanstack/react-router::useMatches"), useParentMatches = fn(_useParentMatches).mockName(
36
- "@tanstack/react-router::useParentMatches"
37
- ), useChildMatches = fn(_useChildMatches).mockName(
38
- "@tanstack/react-router::useChildMatches"
39
30
  ), useCanGoBack = fn(_useCanGoBack).mockName("@tanstack/react-router::useCanGoBack"), useLinkProps = fn(_useLinkProps).mockName("@tanstack/react-router::useLinkProps"), Outlet = () => null, Navigate = ({ to, href }) => (useEffect(() => {
40
31
  onNavigate({ to: to || href });
41
32
  }, [to, href]), null), Link = ({
@@ -75,17 +66,12 @@ export {
75
66
  createFileRoute,
76
67
  useBlocker,
77
68
  useCanGoBack,
78
- useChildMatches,
79
69
  useLinkProps,
80
70
  useLoaderData,
81
71
  useLoaderDeps,
82
72
  useLocation,
83
- useMatch,
84
- useMatchRoute,
85
- useMatches,
86
73
  useNavigate,
87
74
  useParams,
88
- useParentMatches,
89
75
  useRouteContext,
90
76
  useRouter,
91
77
  useRouterState,
package/dist/index.d.ts CHANGED
@@ -2,11 +2,11 @@ import { ComponentType } from 'react';
2
2
  import { PreviewAddon, InferTypes, AddonTypes } from 'storybook/internal/csf';
3
3
  import { CompatibleString, ProjectAnnotations, Args, DecoratorFunction, ArgsStoryFn, ComponentAnnotations, Renderer, StoryAnnotations } from 'storybook/internal/types';
4
4
  import { AnyRoute, FileRoutesByPath } from '@tanstack/react-router';
5
- import { ReactTypes, ReactPreview, ReactMeta, ReactRenderer, Meta as Meta$1, StoryObj as StoryObj$1 } from '@storybook/react';
5
+ import { Decorator, ReactTypes, ReactPreview, ReactMeta, ReactRenderer, Meta as Meta$1, StoryObj as StoryObj$1 } from '@storybook/react';
6
6
  export * from '@storybook/react';
7
7
  import { BuilderOptions } from '@storybook/builder-vite';
8
8
  import { StorybookConfig as StorybookConfig$1 } from '@storybook/react-vite';
9
- import { RouteOptions, ResolveParams } from '@tanstack/router-core';
9
+ import { RouteOptions, ResolveParams, AnyContext } from '@tanstack/router-core';
10
10
 
11
11
  declare global {
12
12
  interface SymbolConstructor {
@@ -248,7 +248,7 @@ type Intersection = UnionToIntersection<Union>;
248
248
 
249
249
  @category Type
250
250
  */
251
- type UnionToIntersection<Union> = (
251
+ type UnionToIntersection$1<Union> = (
252
252
  // `extends unknown` is always going to be the case and is used to convert the
253
253
  // `Union` into a [distributive conditional
254
254
  // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
@@ -267,11 +267,33 @@ type UnionToIntersection<Union> = (
267
267
  type IsRoute<T> = T extends AnyRoute ? true : T extends FileRoutesByPath[keyof FileRoutesByPath] ? true : false;
268
268
  type ExtractAllPathsFromFileRoutes<TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] | AnyRoute> = TRoute['path'];
269
269
  type StoryRoutePath<TRoute = undefined> = TRoute extends FileRoutesByPath[keyof FileRoutesByPath] ? ExtractAllPathsFromFileRoutes<TRoute> : keyof FileRoutesByPath | `/${string}`;
270
+ /**
271
+ * Helper: convert a union `A | B | C` into an intersection `A & B & C`.
272
+ *
273
+ * Used to gather all per-route `allParams` shapes from the registered file
274
+ * route tree into a single object whose keys are the union of every nested
275
+ * route's params.
276
+ */
277
+ type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
278
+ /**
279
+ * Union of `allParams` from every registered nested file route.
280
+ *
281
+ * This is used when the bound route is a `RootRoute` / route tree (whose own
282
+ * `allParams` is empty), so users can still pass params for any nested route
283
+ * matched via `path`. The result is `Partial` so every key is optional.
284
+ */
285
+ type AllRegisteredParams = Partial<UnionToIntersection<{
286
+ [K in keyof FileRoutesByPath]: FileRoutesByPath[K]['preLoaderRoute'] extends {
287
+ types: {
288
+ allParams: infer A;
289
+ };
290
+ } ? A : never;
291
+ }[keyof FileRoutesByPath]>>;
270
292
  type StoryRouteParams<TRoute> = TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] ? ResolveParams<ExtractAllPathsFromFileRoutes<TRoute>> : IsRoute<TRoute> extends true ? TRoute extends {
271
293
  types: {
272
294
  allParams: infer P;
273
295
  };
274
- } ? unknown extends P ? never : P : never : never;
296
+ } ? unknown extends P ? AllRegisteredParams : keyof P extends never ? AllRegisteredParams : P : AllRegisteredParams : AllRegisteredParams;
275
297
  type StoryRouteSearch<TRoute> = IsRoute<TRoute> extends true ? TRoute extends {
276
298
  types: {
277
299
  fullSearchSchema: infer S;
@@ -318,7 +340,6 @@ type RouteTreeOverrides = Partial<{
318
340
  [routePath in keyof FileRoutesByPath]: RouteOverrideOptions<FileRoutesByPath[routePath]['preLoaderRoute']> | undefined;
319
341
  }>;
320
342
  interface RouterParameters<TRoute = undefined> {
321
- /** A route object or route options to use for this story. */
322
343
  route?: StoryRouteOptions<TRoute>;
323
344
  /** The initial URL path to render. */
324
345
  path?: StoryRoutePath<TRoute>;
@@ -344,6 +365,12 @@ interface RouterParameters<TRoute = undefined> {
344
365
  */
345
366
  routeOverrides?: RouteTreeOverrides;
346
367
  context?: Record<string, unknown>;
368
+ /**
369
+ *
370
+ */
371
+ useRouterContext?: ({ storyContext }: {
372
+ storyContext: Parameters<Decorator>[1];
373
+ }) => AnyContext;
347
374
  }
348
375
 
349
376
  type FrameworkName = CompatibleString<'@storybook/tanstack-react'>;
@@ -379,7 +406,7 @@ interface TanStackTypes<TRoute = undefined> {
379
406
  }
380
407
 
381
408
  /** Extracts and unions all args types from an array of decorators. */
382
- type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
409
+ type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection$1<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
383
410
  type InferCombinedTypes<T, TArgs, Decorators> = ReactTypes & T & {
384
411
  args: Simplify<TArgs & Simplify<RemoveIndexSignature<DecoratorsArgs<ReactTypes & T, Decorators>>>>;
385
412
  };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  preview_exports
3
- } from "./_browser-chunks/chunk-UYQAUY5K.js";
3
+ } from "./_browser-chunks/chunk-CGO22LCN.js";
4
4
  import "./_browser-chunks/chunk-4BE7D4DS.js";
5
5
 
6
6
  // src/index.ts
@@ -1,14 +1,15 @@
1
- import CJS_COMPAT_NODE_URL_t4g8ab37o6 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_t4g8ab37o6 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_t4g8ab37o6 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_dxww6fnj7fh from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_dxww6fnj7fh from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_dxww6fnj7fh from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_t4g8ab37o6.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_t4g8ab37o6.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_t4g8ab37o6.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_dxww6fnj7fh.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_dxww6fnj7fh.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_dxww6fnj7fh.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
+ import "../_node-chunks/chunk-FNV2OQ7E.js";
12
13
 
13
14
  // src/node/index.ts
14
15
  function defineMain(config) {