@storybook/tanstack-react 10.5.0-alpha.3 → 10.5.0-alpha.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.
@@ -172,12 +172,17 @@ function resolveTree(Story, context) {
172
172
  let tree = duplicateRouteTree(syntheticRoot2, { overrides: routeOverrides }), leaf = tree.byId.get(routerParameterRoute.id) ?? tree.root;
173
173
  return injectStoryComponent(leaf, Story, routeOverrides, leaf.id), { tree, leaf };
174
174
  }
175
- let plainOptions = routerParameterRoute ?? {}, syntheticRoot = createRootRoute(
175
+ let plainOptions = routerParameterRoute ?? {}, {
176
+ path: plainRoutePath,
177
+ id: plainRouteId,
178
+ ...plainRouteRest
179
+ } = plainOptions, syntheticRouteId = plainRoutePath ? void 0 : plainRouteId ?? "storybook-story", syntheticRoot = createRootRoute(
176
180
  routeOverrides?.__root__ ?? {}
177
181
  ), syntheticChild = createRoute2({
178
182
  component: () => React.createElement(Story, null),
179
- id: "storybook-story",
180
- ...plainOptions,
183
+ id: syntheticRouteId,
184
+ path: plainRoutePath,
185
+ ...plainRouteRest,
181
186
  getParentRoute: () => syntheticRoot
182
187
  });
183
188
  return syntheticRoot.addChildren([syntheticChild]), injectStoryComponent(syntheticChild, Story, routeOverrides, syntheticChild.id), {
@@ -325,7 +325,6 @@ declare const useLoaderDeps: Mock<typeof useLoaderDeps$1>;
325
325
  declare const useRouteContext: Mock<typeof useRouteContext$1>;
326
326
  declare const useCanGoBack: Mock<typeof useCanGoBack$1>;
327
327
  declare const useLinkProps: Mock<typeof useLinkProps$1>;
328
- declare const Outlet: () => null;
329
328
  declare const Navigate: typeof Navigate$1;
330
329
  declare const Link: ({ to, children, ...props }: {
331
330
  to: string;
@@ -341,4 +340,4 @@ declare const Link: ({ to, children, ...props }: {
341
340
  */
342
341
  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>;
343
342
 
344
- export { Link, Navigate, Outlet, createFileRoute, useBlocker, useCanGoBack, useLinkProps, useLoaderData, useLoaderDeps, useLocation, useNavigate, useParams, useRouteContext, useRouter, useRouterState, useSearch };
343
+ export { Link, Navigate, createFileRoute, useBlocker, useCanGoBack, useLinkProps, useLoaderData, useLoaderDeps, useLocation, useNavigate, useParams, useRouteContext, useRouter, useRouterState, useSearch };
@@ -27,7 +27,7 @@ var useNavigate = fn(_useNavigate).mockName("@tanstack/react-router::useNavigate
27
27
  "@tanstack/react-router::useRouterState"
28
28
  ), useLoaderData = fn(_useLoaderData).mockName("@tanstack/react-router::useLoaderData"), useLoaderDeps = fn(_useLoaderDeps).mockName("@tanstack/react-router::useLoaderDeps"), useRouteContext = fn(_useRouteContext).mockName(
29
29
  "@tanstack/react-router::useRouteContext"
30
- ), useCanGoBack = fn(_useCanGoBack).mockName("@tanstack/react-router::useCanGoBack"), useLinkProps = fn(_useLinkProps).mockName("@tanstack/react-router::useLinkProps"), Outlet = () => null, Navigate = ({ to, href }) => (useEffect(() => {
30
+ ), useCanGoBack = fn(_useCanGoBack).mockName("@tanstack/react-router::useCanGoBack"), useLinkProps = fn(_useLinkProps).mockName("@tanstack/react-router::useLinkProps"), Navigate = ({ to, href }) => (useEffect(() => {
31
31
  onNavigate({ to: to || href });
32
32
  }, [to, href]), null), Link = ({
33
33
  to,
@@ -62,7 +62,6 @@ function createFileRoute(path) {
62
62
  export {
63
63
  Link,
64
64
  Navigate,
65
- Outlet,
66
65
  createFileRoute,
67
66
  useBlocker,
68
67
  useCanGoBack,
package/dist/index.d.ts CHANGED
@@ -370,4 +370,4 @@ interface TanStackPreview<T extends AddonTypes, TRoute extends AnyRoute | undefi
370
370
  }>;
371
371
  }
372
372
 
373
- export { type CreateStoryRouteOptions, type DefaultStoryPath, type FrameworkOptions, type IsRoute, type Meta, type Preview, type RouterParameters, type StoryObj, type StoryRouteFileOptions, type StoryRouteOptions, type StorybookConfig, type TanStackParameters, type TanStackPreviewOptions, type TanStackTypes, definePreview };
373
+ export { type CreateStoryRouteOptions, type DefaultStoryPath, type FrameworkOptions, type IsRoute, type Meta, type Preview, type RouterParameters, type StoryObj, type StoryRouteFileOptions, type StoryRouteOptions, type StorybookConfig, type TanStackParameters, type TanStackPreview, type TanStackPreviewOptions, type TanStackTypes, definePreview };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  preview_exports
3
- } from "./_browser-chunks/chunk-73EPJ7AY.js";
3
+ } from "./_browser-chunks/chunk-SNKUITN7.js";
4
4
  import "./_browser-chunks/chunk-4BE7D4DS.js";
5
5
 
6
6
  // src/index.ts
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_0nhffdv299qa from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_0nhffdv299qa from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_0nhffdv299qa from "node:module";
1
+ import CJS_COMPAT_NODE_URL_k79t92w4o from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_k79t92w4o from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_k79t92w4o from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_0nhffdv299qa.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_0nhffdv299qa.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_0nhffdv299qa.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_k79t92w4o.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_k79t92w4o.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_k79t92w4o.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_0nhffdv299qa from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_0nhffdv299qa from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_0nhffdv299qa from "node:module";
1
+ import CJS_COMPAT_NODE_URL_k79t92w4o from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_k79t92w4o from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_k79t92w4o from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_0nhffdv299qa.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_0nhffdv299qa.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_0nhffdv299qa.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_k79t92w4o.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_k79t92w4o.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_k79t92w4o.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
package/dist/preview.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  loaders,
4
4
  optimizeDeps,
5
5
  parameters
6
- } from "./_browser-chunks/chunk-73EPJ7AY.js";
6
+ } from "./_browser-chunks/chunk-SNKUITN7.js";
7
7
  import "./_browser-chunks/chunk-4BE7D4DS.js";
8
8
  export {
9
9
  applyDecorators,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/tanstack-react",
3
- "version": "10.5.0-alpha.3",
3
+ "version": "10.5.0-alpha.4",
4
4
  "description": "Storybook for TanStack (React, Vite): Router and Start ready Storybook framework",
5
5
  "keywords": [
6
6
  "storybook",
@@ -75,9 +75,9 @@
75
75
  "!src/**/*"
76
76
  ],
77
77
  "dependencies": {
78
- "@storybook/builder-vite": "10.5.0-alpha.3",
79
- "@storybook/react": "10.5.0-alpha.3",
80
- "@storybook/react-vite": "10.5.0-alpha.3"
78
+ "@storybook/builder-vite": "10.5.0-alpha.4",
79
+ "@storybook/react": "10.5.0-alpha.4",
80
+ "@storybook/react-vite": "10.5.0-alpha.4"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@tanstack/react-router": "^1.168.10",
@@ -95,7 +95,7 @@
95
95
  "@tanstack/start-client-core": "^1.167.9",
96
96
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
97
97
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
98
- "storybook": "^10.5.0-alpha.3",
98
+ "storybook": "^10.5.0-alpha.4",
99
99
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
100
100
  },
101
101
  "peerDependenciesMeta": {
@@ -14,7 +14,7 @@ const meta = {
14
14
  },
15
15
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
16
16
  tags: ['autodocs'],
17
- // More on argTypes: https://storybook.js.org/docs/api/argtypes
17
+ // More on argTypes: https://storybook.js.org/docs/api/arg-types
18
18
  argTypes: {
19
19
  backgroundColor: { control: 'color' },
20
20
  },
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+
3
+ import type { Meta, StoryObj } from '@storybook/tanstack-react';
4
+
5
+ import { Outlet, createRootRoute, createRoute } from '@tanstack/react-router';
6
+ import { expect, within } from 'storybook/test';
7
+
8
+ // Regression coverage for https://github.com/storybookjs/storybook/issues/35007
9
+ // `@tanstack/react-router`'s `Outlet` used to be mocked as `() => null`, which
10
+ // silently swallowed any leaf content rendered inside a root layout. These
11
+ // stories assert that both the root layout and the leaf content render.
12
+
13
+ function LeafContent() {
14
+ return <p data-testid="tanstack-outlet-leaf">leaf rendered inside root outlet</p>;
15
+ }
16
+
17
+ const RootRoute = createRootRoute({
18
+ component: () => (
19
+ <div data-testid="tanstack-outlet-root">
20
+ <h1>root layout</h1>
21
+ <Outlet />
22
+ </div>
23
+ ),
24
+ });
25
+
26
+ const LeafRoute = createRoute({
27
+ getParentRoute: () => RootRoute,
28
+ path: '/',
29
+ component: LeafContent,
30
+ });
31
+
32
+ RootRoute.addChildren([LeafRoute]);
33
+
34
+ const meta = {
35
+ component: LeafContent,
36
+ parameters: { layout: 'fullscreen' },
37
+ } satisfies Meta<typeof LeafContent>;
38
+
39
+ export default meta;
40
+
41
+ type Story = StoryObj<typeof meta>;
42
+
43
+ /** Passing the leaf `Route` should render it inside the root layout's `<Outlet />`. */
44
+ export const RendersLeafInsideRootOutlet: Story = {
45
+ parameters: {
46
+ tanstack: { router: { route: LeafRoute } },
47
+ },
48
+ play: async ({ canvasElement }) => {
49
+ const canvas = within(canvasElement);
50
+ await expect(canvas.getByTestId('tanstack-outlet-root')).toBeInTheDocument();
51
+ await expect(
52
+ canvas.getByRole('heading', { level: 1, name: 'root layout' })
53
+ ).toBeInTheDocument();
54
+ await expect(canvas.getByTestId('tanstack-outlet-leaf')).toBeInTheDocument();
55
+ },
56
+ };
57
+
58
+ /** Passing the whole route tree plus an explicit `path` resolves through the same outlet. */
59
+ export const RendersLeafViaRouteTreePath: Story = {
60
+ parameters: {
61
+ tanstack: {
62
+ router: { route: RootRoute, path: '/' },
63
+ },
64
+ },
65
+ play: async ({ canvasElement }) => {
66
+ const canvas = within(canvasElement);
67
+ await expect(canvas.getByTestId('tanstack-outlet-root')).toBeInTheDocument();
68
+ await expect(
69
+ canvas.getByRole('heading', { level: 1, name: 'root layout' })
70
+ ).toBeInTheDocument();
71
+ await expect(canvas.getByTestId('tanstack-outlet-leaf')).toBeInTheDocument();
72
+ },
73
+ };