@storybook/tanstack-react 10.5.0-alpha.4 → 10.5.0-alpha.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.
@@ -1,3 +1,6 @@
1
+ import {
2
+ normalizeFileRoutePath
3
+ } from "./chunk-XKNIZ3MM.js";
1
4
  import {
2
5
  __export
3
6
  } from "./chunk-4BE7D4DS.js";
@@ -131,7 +134,7 @@ function createStoryRouter({
131
134
  context,
132
135
  routerContext
133
136
  }) {
134
- 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({
137
+ let routerParameters = context.parameters.tanstack?.router ?? {}, { tree, leaf } = resolveTree(Story, context), routeTree = tree.root, inferredPath = routerParameters?.path || leaf.fullPath || (leaf.id ? normalizeFileRoutePath(leaf.id) : void 0) || routeTree.children?.[0]?.fullPath || "/", resolvedPath = interpolatePath({
135
138
  path: inferredPath,
136
139
  params: routerParameters?.params ?? {}
137
140
  }).interpolatedPath, search = routerParameters?.query ? defaultStringifySearch(routerParameters.query) : "";
@@ -0,0 +1,19 @@
1
+ // src/routing/path-utils.ts
2
+ var possiblyNestedRouteGroupPatternRegex = /\([^/]+\)\/?/g;
3
+ function removeGroups(s) {
4
+ return s.replace(possiblyNestedRouteGroupPatternRegex, "");
5
+ }
6
+ function removeLayoutSegments(routePath = "/") {
7
+ return routePath.split("/").filter((segment) => !segment.startsWith("_")).join("/");
8
+ }
9
+ var underscoreStartEndRegex = /(^_|_$)/gi, underscoreSlashRegex = /(\/_|_\/)/gi;
10
+ function removeUnderscores(s) {
11
+ return s?.replace(underscoreStartEndRegex, "").replace(underscoreSlashRegex, "/");
12
+ }
13
+ function normalizeFileRoutePath(path) {
14
+ return removeGroups(removeUnderscores(removeLayoutSegments(path)) ?? "") || "/";
15
+ }
16
+
17
+ export {
18
+ normalizeFileRoutePath
19
+ };
@@ -1,3 +1,6 @@
1
+ import {
2
+ normalizeFileRoutePath
3
+ } from "../_browser-chunks/chunk-XKNIZ3MM.js";
1
4
  import {
2
5
  onNavigate
3
6
  } from "../_browser-chunks/chunk-4CKCBIXI.js";
@@ -48,14 +51,15 @@ var useNavigate = fn(_useNavigate).mockName("@tanstack/react-router::useNavigate
48
51
  );
49
52
  };
50
53
  function createFileRoute(path) {
54
+ let normalizedPath = normalizeFileRoutePath(path);
51
55
  return (options) => createRoute({
52
- path,
56
+ path: normalizedPath,
53
57
  ...options,
54
58
  isRoot: !1
55
59
  }).update({
56
60
  id: path,
57
- path,
58
- fullPath: path
61
+ path: normalizedPath,
62
+ fullPath: normalizedPath
59
63
  // any because tanstack router does that
60
64
  });
61
65
  }
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  preview_exports
3
- } from "./_browser-chunks/chunk-SNKUITN7.js";
3
+ } from "./_browser-chunks/chunk-WQHJSC2D.js";
4
+ import "./_browser-chunks/chunk-XKNIZ3MM.js";
4
5
  import "./_browser-chunks/chunk-4BE7D4DS.js";
5
6
 
6
7
  // src/index.ts
@@ -1,10 +1,10 @@
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";
1
+ import CJS_COMPAT_NODE_URL_axsjtcsu0p5 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_axsjtcsu0p5 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_axsjtcsu0p5 from "node:module";
4
4
 
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);
5
+ var __filename = CJS_COMPAT_NODE_URL_axsjtcsu0p5.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_axsjtcsu0p5.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_axsjtcsu0p5.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_k79t92w4o from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_k79t92w4o from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_k79t92w4o from "node:module";
1
+ import CJS_COMPAT_NODE_URL_axsjtcsu0p5 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_axsjtcsu0p5 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_axsjtcsu0p5 from "node:module";
4
4
 
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);
5
+ var __filename = CJS_COMPAT_NODE_URL_axsjtcsu0p5.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_axsjtcsu0p5.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_axsjtcsu0p5.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,8 @@ import {
3
3
  loaders,
4
4
  optimizeDeps,
5
5
  parameters
6
- } from "./_browser-chunks/chunk-SNKUITN7.js";
6
+ } from "./_browser-chunks/chunk-WQHJSC2D.js";
7
+ import "./_browser-chunks/chunk-XKNIZ3MM.js";
7
8
  import "./_browser-chunks/chunk-4BE7D4DS.js";
8
9
  export {
9
10
  applyDecorators,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/tanstack-react",
3
- "version": "10.5.0-alpha.4",
3
+ "version": "10.5.0-alpha.5",
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.4",
79
- "@storybook/react": "10.5.0-alpha.4",
80
- "@storybook/react-vite": "10.5.0-alpha.4"
78
+ "@storybook/builder-vite": "10.5.0-alpha.5",
79
+ "@storybook/react": "10.5.0-alpha.5",
80
+ "@storybook/react-vite": "10.5.0-alpha.5"
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.4",
98
+ "storybook": "^10.5.0-alpha.5",
99
99
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
100
100
  },
101
101
  "peerDependenciesMeta": {