@storybook/react 10.2.13 → 10.2.15

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,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_3ptwm6qscl8 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_3ptwm6qscl8 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_3ptwm6qscl8 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_2iul9a4d31m from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_2iul9a4d31m from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_2iul9a4d31m from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_3ptwm6qscl8.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_3ptwm6qscl8.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_3ptwm6qscl8.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_2iul9a4d31m.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_2iul9a4d31m.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_2iul9a4d31m.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_3ptwm6qscl8 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_3ptwm6qscl8 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_3ptwm6qscl8 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_2iul9a4d31m from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_2iul9a4d31m from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_2iul9a4d31m from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_3ptwm6qscl8.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_3ptwm6qscl8.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_3ptwm6qscl8.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_2iul9a4d31m.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_2iul9a4d31m.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_2iul9a4d31m.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -12,7 +12,7 @@ var require = CJS_COMPAT_NODE_MODULE_3ptwm6qscl8.createRequire(import.meta.url);
12
12
  import {
13
13
  __commonJS,
14
14
  __require
15
- } from "./chunk-HE74TL6X.js";
15
+ } from "./chunk-DQZQYEBP.js";
16
16
 
17
17
  // ../../../node_modules/react-docgen-typescript/lib/buildFilter.js
18
18
  var require_buildFilter = __commonJS({
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_3ptwm6qscl8 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_3ptwm6qscl8 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_3ptwm6qscl8 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_2iul9a4d31m from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_2iul9a4d31m from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_2iul9a4d31m from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_3ptwm6qscl8.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_3ptwm6qscl8.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_3ptwm6qscl8.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_2iul9a4d31m.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_2iul9a4d31m.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_2iul9a4d31m.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -13,7 +13,7 @@ import {
13
13
  __commonJS,
14
14
  __require,
15
15
  __toESM
16
- } from "./_node-chunks/chunk-HE74TL6X.js";
16
+ } from "./_node-chunks/chunk-DQZQYEBP.js";
17
17
 
18
18
  // ../../../node_modules/estraverse/estraverse.js
19
19
  var require_estraverse = __commonJS({
@@ -11193,7 +11193,7 @@ var extractArgTypesFromDocgenTypescript = async ({
11193
11193
  reactDocgenTypescriptOptions
11194
11194
  }) => {
11195
11195
  try {
11196
- let { withCompilerOptions } = (await import("./_node-chunks/lib-TDB6XXX5.js")).default, defaultOptions = {
11196
+ let { withCompilerOptions } = (await import("./_node-chunks/lib-AQMY2DBK.js")).default, defaultOptions = {
11197
11197
  shouldExtractLiteralValuesFromEnum: !0,
11198
11198
  shouldRemoveUndefinedFromOptional: !0,
11199
11199
  propFilter: (prop) => prop.parent ? !/node_modules/.test(prop.parent.fileName) : !0,
@@ -11272,7 +11272,7 @@ function getCodeSnippet(csf, storyName, componentName) {
11272
11272
  if (callee.isMemberExpression()) {
11273
11273
  let obj = callee.get("object"), prop = callee.get("property"), isBind = prop.isIdentifier() && prop.node.name === "bind" || t2.isStringLiteral(prop.node) && prop.node.value === "bind";
11274
11274
  if (obj.isIdentifier() && isBind) {
11275
- let resolved = resolveBindIdentifierInit(storyDeclaration, obj);
11275
+ let resolved = resolveIdentifierInit(storyDeclaration, obj);
11276
11276
  resolved && (normalizedPath = resolved);
11277
11277
  }
11278
11278
  }
@@ -11300,14 +11300,20 @@ function getCodeSnippet(csf, storyName, componentName) {
11300
11300
  "Expected story to be csf factory, function or an object expression"
11301
11301
  );
11302
11302
  let storyProps = normalizedPath.isObjectExpression() ? normalizedPath.get("properties").filter((p) => p.isObjectProperty()) : [], metaPath = pathForNode(csf._file.path, metaObj), metaProps = metaPath?.isObjectExpression() ? metaPath.get("properties").filter((p) => p.isObjectProperty()) : [], getRenderPath = (object) => {
11303
- let renderPath2 = object.find((p) => keyOf(p.node) === "render")?.get("value");
11304
- if (renderPath2?.isIdentifier() && (componentName = renderPath2.node.name), renderPath2 && !(renderPath2.isArrowFunctionExpression() || renderPath2.isFunctionExpression()))
11305
- throw renderPath2.buildCodeFrameError(
11303
+ let renderPath = object.find((p) => keyOf(p.node) === "render")?.get("value");
11304
+ if (!renderPath)
11305
+ return { kind: "missing" };
11306
+ if (renderPath.isIdentifier()) {
11307
+ let resolved = resolveIdentifierInit(storyDeclaration, renderPath);
11308
+ return resolved && (resolved.isArrowFunctionExpression() || resolved.isFunctionExpression() || resolved.isFunctionDeclaration()) ? { kind: "resolved", path: resolved } : { kind: "unresolved" };
11309
+ }
11310
+ if (!(renderPath.isArrowFunctionExpression() || renderPath.isFunctionExpression()))
11311
+ throw renderPath.buildCodeFrameError(
11306
11312
  "Expected render to be an arrow function or function expression"
11307
11313
  );
11308
- return renderPath2;
11309
- }, metaRenderPath = getRenderPath(metaProps), renderPath = getRenderPath(storyProps);
11310
- storyFn ??= renderPath ?? metaRenderPath;
11314
+ return { kind: "resolved", path: renderPath };
11315
+ }, metaRender = getRenderPath(metaProps), storyRender = getRenderPath(storyProps);
11316
+ storyFn || (storyFn = storyRender.kind === "resolved" ? storyRender.path : storyRender.kind === "missing" && metaRender.kind === "resolved" ? metaRender.path : void 0);
11311
11317
  let metaArgs = metaArgsRecord(metaObj ?? null), storyArgsPath = storyProps.filter((p) => keyOf(p.node) === "args").map((p) => p.get("value")).find((v) => v.isObjectExpression()), storyArgs = argsRecordFromObjectPath(storyArgsPath), storyAssignedArgsPath = storyArgsAssignmentPath(csf._file.path, storyName), storyAssignedArgs = argsRecordFromObjectPath(storyAssignedArgsPath), merged = { ...metaArgs, ...storyArgs, ...storyAssignedArgs }, entries = Object.entries(merged).filter(([k]) => k !== "children"), validEntries = entries.filter(([k, v]) => isValidJsxAttrName(k) && v != null), invalidEntries = entries.filter(([k, v]) => !isValidJsxAttrName(k) && v != null), injectedAttrs = validEntries.map(([k, v]) => toAttr(k, v)).filter((a) => a != null);
11312
11318
  if (storyFn) {
11313
11319
  let fn = storyFn.node;
@@ -11331,14 +11337,20 @@ function getCodeSnippet(csf, storyName, componentName) {
11331
11337
  return stmt;
11332
11338
  });
11333
11339
  if (changed)
11334
- return t2.isFunctionDeclaration(fn) ? t2.functionDeclaration(fn.id, [], t2.blockStatement(newBody), fn.generator, fn.async) : t2.variableDeclaration("const", [
11340
+ return t2.isFunctionDeclaration(fn) ? t2.functionDeclaration(
11341
+ t2.identifier(storyName),
11342
+ [],
11343
+ t2.blockStatement(newBody),
11344
+ fn.generator,
11345
+ fn.async
11346
+ ) : t2.variableDeclaration("const", [
11335
11347
  t2.variableDeclarator(
11336
11348
  t2.identifier(storyName),
11337
11349
  t2.arrowFunctionExpression([], t2.blockStatement(newBody), fn.async)
11338
11350
  )
11339
11351
  ]);
11340
11352
  }
11341
- return t2.isFunctionDeclaration(fn) ? fn : t2.variableDeclaration("const", [t2.variableDeclarator(t2.identifier(storyName), fn)]);
11353
+ return t2.isFunctionDeclaration(fn) ? t2.functionDeclaration(t2.identifier(storyName), fn.params, fn.body, fn.generator, fn.async) : t2.variableDeclaration("const", [t2.variableDeclarator(t2.identifier(storyName), fn)]);
11342
11354
  }
11343
11355
  invariant(componentName, "Could not generate snippet without component name.");
11344
11356
  let invalidSpread = buildInvalidSpread(invalidEntries), name = t2.jsxIdentifier(componentName), openingElAttrs = invalidSpread ? [...injectedAttrs, invalidSpread] : injectedAttrs, children = toJsxChildren(merged.children), selfClosing = children.length === 0, arrow = t2.arrowFunctionExpression(
@@ -11482,10 +11494,19 @@ function transformArgsSpreadsInJsx(node, merged) {
11482
11494
  });
11483
11495
  return { node: t2.jsxFragment(node.openingFragment, node.closingFragment, fragChildren), changed };
11484
11496
  }
11485
- function resolveBindIdentifierInit(storyPath, identifier) {
11497
+ function resolveIdentifierInit(storyPath, identifier) {
11486
11498
  let programPath = storyPath.findParent((p) => p.isProgram());
11487
11499
  if (!programPath)
11488
11500
  return null;
11501
+ for (let stmt of programPath.get("body")) {
11502
+ if (stmt.isFunctionDeclaration() && stmt.node.id?.name === identifier.node.name)
11503
+ return stmt;
11504
+ if (stmt.isExportNamedDeclaration()) {
11505
+ let decl = stmt.get("declaration");
11506
+ if (decl.isFunctionDeclaration() && decl.node.id?.name === identifier.node.name)
11507
+ return decl;
11508
+ }
11509
+ }
11489
11510
  let match = programPath.get("body").flatMap((stmt) => {
11490
11511
  if (stmt.isVariableDeclaration())
11491
11512
  return stmt.get("declarations");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react",
3
- "version": "10.2.13",
3
+ "version": "10.2.15",
4
4
  "description": "Storybook React renderer",
5
5
  "keywords": [
6
6
  "storybook"
@@ -50,7 +50,7 @@
50
50
  ],
51
51
  "dependencies": {
52
52
  "@storybook/global": "^5.0.0",
53
- "@storybook/react-dom-shim": "10.2.13",
53
+ "@storybook/react-dom-shim": "10.2.15",
54
54
  "react-docgen": "^8.0.2"
55
55
  },
56
56
  "devDependencies": {
@@ -77,7 +77,7 @@
77
77
  "peerDependencies": {
78
78
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
79
79
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
80
- "storybook": "^10.2.13",
80
+ "storybook": "^10.2.15",
81
81
  "typescript": ">= 4.9.x"
82
82
  },
83
83
  "peerDependenciesMeta": {