@storybook/react 10.3.0-alpha.9 → 10.3.0-beta.0

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.
Files changed (2) hide show
  1. package/dist/preset.js +110 -83
  2. package/package.json +3 -3
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_4h3pb8d4ylr from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_4h3pb8d4ylr from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_4h3pb8d4ylr from "node:module";
1
+ import CJS_COMPAT_NODE_URL_2m7iyc5vv9a from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_2m7iyc5vv9a from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_2m7iyc5vv9a from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_4h3pb8d4ylr.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_4h3pb8d4ylr.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_4h3pb8d4ylr.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_2m7iyc5vv9a.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_2m7iyc5vv9a.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_2m7iyc5vv9a.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1638,8 +1638,8 @@ var require_source_node = __commonJS({
1638
1638
  };
1639
1639
  SourceNode.prototype.add = function(aChunk) {
1640
1640
  if (Array.isArray(aChunk))
1641
- aChunk.forEach(function(chunk2) {
1642
- this.add(chunk2);
1641
+ aChunk.forEach(function(chunk) {
1642
+ this.add(chunk);
1643
1643
  }, this);
1644
1644
  else if (aChunk[isSourceNode] || typeof aChunk == "string")
1645
1645
  aChunk && this.children.push(aChunk);
@@ -1662,8 +1662,8 @@ var require_source_node = __commonJS({
1662
1662
  return this;
1663
1663
  };
1664
1664
  SourceNode.prototype.walk = function(aFn) {
1665
- for (var chunk2, i = 0, len = this.children.length; i < len; i++)
1666
- chunk2 = this.children[i], chunk2[isSourceNode] ? chunk2.walk(aFn) : chunk2 !== "" && aFn(chunk2, {
1665
+ for (var chunk, i = 0, len = this.children.length; i < len; i++)
1666
+ chunk = this.children[i], chunk[isSourceNode] ? chunk.walk(aFn) : chunk !== "" && aFn(chunk, {
1667
1667
  source: this.source,
1668
1668
  line: this.line,
1669
1669
  column: this.column,
@@ -1694,8 +1694,8 @@ var require_source_node = __commonJS({
1694
1694
  };
1695
1695
  SourceNode.prototype.toString = function() {
1696
1696
  var str = "";
1697
- return this.walk(function(chunk2) {
1698
- str += chunk2;
1697
+ return this.walk(function(chunk) {
1698
+ str += chunk;
1699
1699
  }), str;
1700
1700
  };
1701
1701
  SourceNode.prototype.toStringWithSourceMap = function(aArgs) {
@@ -1704,8 +1704,8 @@ var require_source_node = __commonJS({
1704
1704
  line: 1,
1705
1705
  column: 0
1706
1706
  }, map = new SourceMapGenerator(aArgs), sourceMappingActive = !1, lastOriginalSource = null, lastOriginalLine = null, lastOriginalColumn = null, lastOriginalName = null;
1707
- return this.walk(function(chunk2, original) {
1708
- generated.code += chunk2, original.source !== null && original.line !== null && original.column !== null ? ((lastOriginalSource !== original.source || lastOriginalLine !== original.line || lastOriginalColumn !== original.column || lastOriginalName !== original.name) && map.addMapping({
1707
+ return this.walk(function(chunk, original) {
1708
+ generated.code += chunk, original.source !== null && original.line !== null && original.column !== null ? ((lastOriginalSource !== original.source || lastOriginalLine !== original.line || lastOriginalColumn !== original.column || lastOriginalName !== original.name) && map.addMapping({
1709
1709
  source: original.source,
1710
1710
  original: {
1711
1711
  line: original.line,
@@ -1722,8 +1722,8 @@ var require_source_node = __commonJS({
1722
1722
  column: generated.column
1723
1723
  }
1724
1724
  }), lastOriginalSource = null, sourceMappingActive = !1);
1725
- for (var idx = 0, length = chunk2.length; idx < length; idx++)
1726
- chunk2.charCodeAt(idx) === NEWLINE_CODE ? (generated.line++, generated.column = 0, idx + 1 === length ? (lastOriginalSource = null, sourceMappingActive = !1) : sourceMappingActive && map.addMapping({
1725
+ for (var idx = 0, length = chunk.length; idx < length; idx++)
1726
+ chunk.charCodeAt(idx) === NEWLINE_CODE ? (generated.line++, generated.column = 0, idx + 1 === length ? (lastOriginalSource = null, sourceMappingActive = !1) : sourceMappingActive && map.addMapping({
1727
1727
  source: original.source,
1728
1728
  original: {
1729
1729
  line: original.line,
@@ -3600,8 +3600,8 @@ var require_acorn = __commonJS({
3600
3600
  elt && this.toAssignable(elt, isBinding);
3601
3601
  }
3602
3602
  if (end) {
3603
- var last2 = exprList[end - 1];
3604
- this.options.ecmaVersion === 6 && isBinding && last2 && last2.type === "RestElement" && last2.argument.type !== "Identifier" && this.unexpected(last2.argument.start);
3603
+ var last = exprList[end - 1];
3604
+ this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier" && this.unexpected(last.argument.start);
3605
3605
  }
3606
3606
  return exprList;
3607
3607
  }, pp$2.parseSpread = function(refDestructuringErrors) {
@@ -6291,7 +6291,7 @@ var require_dist2 = __commonJS({
6291
6291
  return "{}";
6292
6292
  seen.push(input);
6293
6293
  var ret = "{" + tokens.newLine + objKeys_1.map(function(el, i) {
6294
- var eol = objKeys_1.length - 1 === i ? tokens.newLine : "," + tokens.newLineOrSpace, isSymbol3 = typeof el == "symbol", isClassic = !isSymbol3 && /^[a-z$_][a-z$_0-9]*$/i.test(el.toString()), key = isSymbol3 || isClassic ? el : prettyPrint2(el, combinedOptions), value = prettyPrint2(input[el], combinedOptions, pad + combinedOptions.indent);
6294
+ var eol = objKeys_1.length - 1 === i ? tokens.newLine : "," + tokens.newLineOrSpace, isSymbol2 = typeof el == "symbol", isClassic = !isSymbol2 && /^[a-z$_][a-z$_0-9]*$/i.test(el.toString()), key = isSymbol2 || isClassic ? el : prettyPrint2(el, combinedOptions), value = prettyPrint2(input[el], combinedOptions, pad + combinedOptions.indent);
6295
6295
  return combinedOptions.transform && (value = combinedOptions.transform(input, el, value)), tokens.indent + String(key) + ": " + value + eol;
6296
6296
  }).join("") + tokens.pad + "}";
6297
6297
  return seen.pop(), expandWhiteSpace(ret);
@@ -7941,7 +7941,7 @@ var require_register = __commonJS({
7941
7941
  }
7942
7942
  return coreModules;
7943
7943
  }
7944
- function register(params) {
7944
+ function register2(params) {
7945
7945
  var cwd2, explicitParams;
7946
7946
  if (params)
7947
7947
  cwd2 = params.cwd, (params.baseUrl || params.paths) && (explicitParams = params);
@@ -7976,7 +7976,7 @@ var require_register = __commonJS({
7976
7976
  Module._resolveFilename = originalResolveFilename;
7977
7977
  };
7978
7978
  }
7979
- exports.register = register;
7979
+ exports.register = register2;
7980
7980
  }
7981
7981
  });
7982
7982
 
@@ -9005,6 +9005,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
9005
9005
  import { getProjectRoot as getProjectRoot2 } from "storybook/internal/common";
9006
9006
 
9007
9007
  // ../../core/src/shared/utils/module.ts
9008
+ import { createRequire, register } from "node:module";
9008
9009
  import { fileURLToPath, pathToFileURL } from "node:url";
9009
9010
 
9010
9011
  // ../../../node_modules/exsolve/dist/index.mjs
@@ -9255,7 +9256,12 @@ var importMetaResolve = (...args) => typeof import.meta.resolve != "function" &&
9255
9256
  try {
9256
9257
  return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"), parent)));
9257
9258
  } catch {
9258
- return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"))));
9259
+ try {
9260
+ return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"))));
9261
+ } catch {
9262
+ let req = createRequire(parent ?? import.meta.url);
9263
+ return dirname(req.resolve(join(pkg, "package.json")));
9264
+ }
9259
9265
  }
9260
9266
  };
9261
9267
 
@@ -9297,18 +9303,18 @@ var import_escodegen = __toESM(require_escodegen(), 1), import_ts_dedent = __toE
9297
9303
  }, PRETTY_OPTIONS = {
9298
9304
  ...BASIC_OPTIONS
9299
9305
  };
9300
- function generateCode(ast, compact2 = !1) {
9301
- return (0, import_escodegen.generate)(ast, compact2 ? COMPACT_OPTIONS : PRETTY_OPTIONS);
9306
+ function generateCode(ast, compact = !1) {
9307
+ return (0, import_escodegen.generate)(ast, compact ? COMPACT_OPTIONS : PRETTY_OPTIONS);
9302
9308
  }
9303
- function generateObjectCode(ast, compact2 = !1) {
9304
- return compact2 ? generateCompactObjectCode(ast) : generateCode(ast);
9309
+ function generateObjectCode(ast, compact = !1) {
9310
+ return compact ? generateCompactObjectCode(ast) : generateCode(ast);
9305
9311
  }
9306
9312
  function generateCompactObjectCode(ast) {
9307
9313
  let result = generateCode(ast, !0);
9308
9314
  return result.endsWith(" }") || (result = `${result.slice(0, -1)} }`), result;
9309
9315
  }
9310
- function generateArrayCode(ast, compact2 = !1) {
9311
- return compact2 ? generateCompactArrayCode(ast) : generateMultilineArrayCode(ast);
9316
+ function generateArrayCode(ast, compact = !1) {
9317
+ return compact ? generateCompactArrayCode(ast) : generateMultilineArrayCode(ast);
9312
9318
  }
9313
9319
  function generateMultilineArrayCode(ast) {
9314
9320
  let result = generateCode(ast);
@@ -10099,14 +10105,14 @@ var MAX_FUNC_LENGTH = 150;
10099
10105
  function createTypeDef({
10100
10106
  name,
10101
10107
  short,
10102
- compact: compact2,
10108
+ compact,
10103
10109
  full,
10104
10110
  inferredType
10105
10111
  }) {
10106
10112
  return {
10107
10113
  name,
10108
10114
  short,
10109
- compact: compact2,
10115
+ compact,
10110
10116
  full: full ?? short,
10111
10117
  inferredType
10112
10118
  };
@@ -10117,11 +10123,11 @@ function cleanPropTypes(value) {
10117
10123
  function splitIntoLines(value) {
10118
10124
  return value.split(/\r?\n/);
10119
10125
  }
10120
- function prettyObject(ast, compact2 = !1) {
10121
- return cleanPropTypes(generateObjectCode(ast, compact2));
10126
+ function prettyObject(ast, compact = !1) {
10127
+ return cleanPropTypes(generateObjectCode(ast, compact));
10122
10128
  }
10123
- function prettyArray(ast, compact2 = !1) {
10124
- return cleanPropTypes(generateCode(ast, compact2));
10129
+ function prettyArray(ast, compact = !1) {
10130
+ return cleanPropTypes(generateCode(ast, compact));
10125
10131
  }
10126
10132
  function getCaptionForInspectionType(type) {
10127
10133
  switch (type) {
@@ -10140,35 +10146,35 @@ function getCaptionForInspectionType(type) {
10140
10146
  }
10141
10147
  }
10142
10148
  function generateTypeFromString(value, originalTypeName) {
10143
- let { inferredType, ast } = inspectValue(value), { type } = inferredType, short, compact2, full;
10149
+ let { inferredType, ast } = inspectValue(value), { type } = inferredType, short, compact, full;
10144
10150
  switch (type) {
10145
10151
  case "Identifier" /* IDENTIFIER */:
10146
10152
  case "Literal" /* LITERAL */:
10147
- short = value, compact2 = value;
10153
+ short = value, compact = value;
10148
10154
  break;
10149
10155
  case "Object" /* OBJECT */: {
10150
10156
  let { depth } = inferredType;
10151
- short = OBJECT_CAPTION, compact2 = depth === 1 ? prettyObject(ast, !0) : null, full = prettyObject(ast);
10157
+ short = OBJECT_CAPTION, compact = depth === 1 ? prettyObject(ast, !0) : null, full = prettyObject(ast);
10152
10158
  break;
10153
10159
  }
10154
10160
  case "Element" /* ELEMENT */: {
10155
10161
  let { identifier } = inferredType;
10156
- short = identifier != null && !isHtmlTag(identifier) ? identifier : ELEMENT_CAPTION, compact2 = splitIntoLines(value).length === 1 ? value : null, full = value;
10162
+ short = identifier != null && !isHtmlTag(identifier) ? identifier : ELEMENT_CAPTION, compact = splitIntoLines(value).length === 1 ? value : null, full = value;
10157
10163
  break;
10158
10164
  }
10159
10165
  case "Array" /* ARRAY */: {
10160
10166
  let { depth } = inferredType;
10161
- short = ARRAY_CAPTION, compact2 = depth <= 2 ? prettyArray(ast, !0) : null, full = prettyArray(ast);
10167
+ short = ARRAY_CAPTION, compact = depth <= 2 ? prettyArray(ast, !0) : null, full = prettyArray(ast);
10162
10168
  break;
10163
10169
  }
10164
10170
  default:
10165
- short = getCaptionForInspectionType(type), compact2 = splitIntoLines(value).length === 1 ? value : null, full = value;
10171
+ short = getCaptionForInspectionType(type), compact = splitIntoLines(value).length === 1 ? value : null, full = value;
10166
10172
  break;
10167
10173
  }
10168
10174
  return createTypeDef({
10169
10175
  name: originalTypeName,
10170
10176
  short,
10171
- compact: compact2,
10177
+ compact,
10172
10178
  full,
10173
10179
  inferredType: type
10174
10180
  });
@@ -10208,11 +10214,11 @@ function objectOf(of) {
10208
10214
  return `objectOf(${of})`;
10209
10215
  }
10210
10216
  function generateObjectOf(type, extractedProp) {
10211
- let { short, compact: compact2, full } = generateType(type.value, extractedProp);
10217
+ let { short, compact, full } = generateType(type.value, extractedProp);
10212
10218
  return createTypeDef({
10213
10219
  name: "objectOf" /* OBJECTOF */,
10214
10220
  short: objectOf(short),
10215
- compact: compact2 != null ? objectOf(compact2) : null,
10221
+ compact: compact != null ? objectOf(compact) : null,
10216
10222
  full: full && objectOf(full)
10217
10223
  });
10218
10224
  }
@@ -10220,8 +10226,8 @@ function generateUnion(type, extractedProp) {
10220
10226
  if (Array.isArray(type.value)) {
10221
10227
  let values = type.value.reduce(
10222
10228
  (acc, v) => {
10223
- let { short, compact: compact2, full } = generateType(v, extractedProp);
10224
- return acc.short.push(short), acc.compact.push(compact2), acc.full.push(full), acc;
10229
+ let { short, compact, full } = generateType(v, extractedProp);
10230
+ return acc.short.push(short), acc.compact.push(compact), acc.full.push(full), acc;
10225
10231
  },
10226
10232
  { short: [], compact: [], full: [] }
10227
10233
  );
@@ -10241,8 +10247,8 @@ function generateEnum(type) {
10241
10247
  if (Array.isArray(type.value)) {
10242
10248
  let values = type.value.reduce(
10243
10249
  (acc, v) => {
10244
- let { short, compact: compact2, full } = generateEnumValue(v);
10245
- return acc.short.push(short), acc.compact.push(compact2), acc.full.push(full), acc;
10250
+ let { short, compact, full } = generateEnumValue(v);
10251
+ return acc.short.push(short), acc.compact.push(compact), acc.full.push(full), acc;
10246
10252
  },
10247
10253
  { short: [], compact: [], full: [] }
10248
10254
  );
@@ -10261,21 +10267,21 @@ function braceAfter(of) {
10261
10267
  function braceAround(of) {
10262
10268
  return `[${of}]`;
10263
10269
  }
10264
- function createArrayOfObjectTypeDef(short, compact2, full) {
10270
+ function createArrayOfObjectTypeDef(short, compact, full) {
10265
10271
  return createTypeDef({
10266
10272
  name: "arrayOf" /* ARRAYOF */,
10267
10273
  short: braceAfter(short),
10268
- compact: compact2 != null ? braceAround(compact2) : null,
10274
+ compact: compact != null ? braceAround(compact) : null,
10269
10275
  full: full && braceAround(full)
10270
10276
  });
10271
10277
  }
10272
10278
  function generateArray2(type, extractedProp) {
10273
- let { name, short, compact: compact2, full, inferredType } = generateType(type.value, extractedProp);
10279
+ let { name, short, compact, full, inferredType } = generateType(type.value, extractedProp);
10274
10280
  if (name === "custom" /* CUSTOM */) {
10275
10281
  if (inferredType === "Object" /* OBJECT */)
10276
- return createArrayOfObjectTypeDef(short, compact2, full);
10282
+ return createArrayOfObjectTypeDef(short, compact, full);
10277
10283
  } else if (name === "shape" /* SHAPE */)
10278
- return createArrayOfObjectTypeDef(short, compact2, full);
10284
+ return createArrayOfObjectTypeDef(short, compact, full);
10279
10285
  return createTypeDef({
10280
10286
  name: "arrayOf" /* ARRAYOF */,
10281
10287
  short: braceAfter(short),
@@ -10326,8 +10332,8 @@ function createType(extractedProp) {
10326
10332
  case "union" /* UNION */:
10327
10333
  case "enum" /* ENUM */:
10328
10334
  case "arrayOf" /* ARRAYOF */: {
10329
- let { short, compact: compact2, full } = generateType(type, extractedProp);
10330
- return compact2 != null && !isTooLongForTypeSummary(compact2) ? createSummaryValue5(compact2) : full ? createSummaryValue5(short, full) : createSummaryValue5(short);
10335
+ let { short, compact, full } = generateType(type, extractedProp);
10336
+ return compact != null && !isTooLongForTypeSummary(compact) ? createSummaryValue5(compact) : full ? createSummaryValue5(short, full) : createSummaryValue5(short);
10331
10337
  }
10332
10338
  case "func" /* FUNC */: {
10333
10339
  let { short, full } = generateType(type, extractedProp), summary = short, detail;
@@ -10743,7 +10749,7 @@ function absolute(input, root) {
10743
10749
 
10744
10750
  // ../../../node_modules/empathic/walk.mjs
10745
10751
  function up(base2, options) {
10746
- let { last: last2, cwd: cwd2 } = options || {}, tmp = absolute(base2, cwd2), root = absolute(last2 || "/", cwd2), prev, arr = [];
10752
+ let { last, cwd: cwd2 } = options || {}, tmp = absolute(base2, cwd2), root = absolute(last || "/", cwd2), prev, arr = [];
10747
10753
  for (; prev !== root && (arr.push(tmp), tmp = dirname2(prev = tmp), tmp !== prev); )
10748
10754
  ;
10749
10755
  return arr;
@@ -11260,16 +11266,6 @@ import { Tag } from "storybook/internal/core-server";
11260
11266
  import { storyNameFromExport } from "storybook/internal/csf";
11261
11267
  import { extractDescription, loadCsf } from "storybook/internal/csf-tools";
11262
11268
 
11263
- // ../../../node_modules/es-toolkit/dist/array/uniqBy.mjs
11264
- function uniqBy(arr, mapper) {
11265
- let map = /* @__PURE__ */ new Map();
11266
- for (let i = 0; i < arr.length; i++) {
11267
- let item = arr[i], key = mapper(item);
11268
- map.has(key) || map.set(key, item);
11269
- }
11270
- return Array.from(map.values());
11271
- }
11272
-
11273
11269
  // src/componentManifest/generateCodeSnippet.ts
11274
11270
  import { types as t2 } from "storybook/internal/babel";
11275
11271
  function getCodeSnippet(csf, storyName, componentName) {
@@ -11297,7 +11293,7 @@ function getCodeSnippet(csf, storyName, componentName) {
11297
11293
  if (callee.isMemberExpression()) {
11298
11294
  let obj = callee.get("object"), prop = callee.get("property"), isBind = prop.isIdentifier() && prop.node.name === "bind" || t2.isStringLiteral(prop.node) && prop.node.value === "bind";
11299
11295
  if (obj.isIdentifier() && isBind) {
11300
- let resolved = resolveBindIdentifierInit(storyDeclaration, obj);
11296
+ let resolved = resolveIdentifierInit(storyDeclaration, obj);
11301
11297
  resolved && (normalizedPath = resolved);
11302
11298
  }
11303
11299
  }
@@ -11325,14 +11321,20 @@ function getCodeSnippet(csf, storyName, componentName) {
11325
11321
  "Expected story to be csf factory, function or an object expression"
11326
11322
  );
11327
11323
  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) => {
11328
- let renderPath2 = object.find((p) => keyOf(p.node) === "render")?.get("value");
11329
- if (renderPath2?.isIdentifier() && (componentName = renderPath2.node.name), renderPath2 && !(renderPath2.isArrowFunctionExpression() || renderPath2.isFunctionExpression()))
11330
- throw renderPath2.buildCodeFrameError(
11324
+ let renderPath = object.find((p) => keyOf(p.node) === "render")?.get("value");
11325
+ if (!renderPath)
11326
+ return { kind: "missing" };
11327
+ if (renderPath.isIdentifier()) {
11328
+ let resolved = resolveIdentifierInit(storyDeclaration, renderPath);
11329
+ return resolved && (resolved.isArrowFunctionExpression() || resolved.isFunctionExpression() || resolved.isFunctionDeclaration()) ? { kind: "resolved", path: resolved } : { kind: "unresolved" };
11330
+ }
11331
+ if (!(renderPath.isArrowFunctionExpression() || renderPath.isFunctionExpression()))
11332
+ throw renderPath.buildCodeFrameError(
11331
11333
  "Expected render to be an arrow function or function expression"
11332
11334
  );
11333
- return renderPath2;
11334
- }, metaRenderPath = getRenderPath(metaProps), renderPath = getRenderPath(storyProps);
11335
- storyFn ??= renderPath ?? metaRenderPath;
11335
+ return { kind: "resolved", path: renderPath };
11336
+ }, metaRender = getRenderPath(metaProps), storyRender = getRenderPath(storyProps);
11337
+ storyFn || (storyFn = storyRender.kind === "resolved" ? storyRender.path : storyRender.kind === "missing" && metaRender.kind === "resolved" ? metaRender.path : void 0);
11336
11338
  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);
11337
11339
  if (storyFn) {
11338
11340
  let fn = storyFn.node;
@@ -11356,14 +11358,20 @@ function getCodeSnippet(csf, storyName, componentName) {
11356
11358
  return stmt;
11357
11359
  });
11358
11360
  if (changed)
11359
- return t2.isFunctionDeclaration(fn) ? t2.functionDeclaration(fn.id, [], t2.blockStatement(newBody), fn.generator, fn.async) : t2.variableDeclaration("const", [
11361
+ return t2.isFunctionDeclaration(fn) ? t2.functionDeclaration(
11362
+ t2.identifier(storyName),
11363
+ [],
11364
+ t2.blockStatement(newBody),
11365
+ fn.generator,
11366
+ fn.async
11367
+ ) : t2.variableDeclaration("const", [
11360
11368
  t2.variableDeclarator(
11361
11369
  t2.identifier(storyName),
11362
11370
  t2.arrowFunctionExpression([], t2.blockStatement(newBody), fn.async)
11363
11371
  )
11364
11372
  ]);
11365
11373
  }
11366
- return t2.isFunctionDeclaration(fn) ? fn : t2.variableDeclaration("const", [t2.variableDeclarator(t2.identifier(storyName), fn)]);
11374
+ 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)]);
11367
11375
  }
11368
11376
  invariant(componentName, "Could not generate snippet without component name.");
11369
11377
  let invalidSpread = buildInvalidSpread(invalidEntries), name = t2.jsxIdentifier(componentName), openingElAttrs = invalidSpread ? [...injectedAttrs, invalidSpread] : injectedAttrs, children = toJsxChildren(merged.children), selfClosing = children.length === 0, arrow = t2.arrowFunctionExpression(
@@ -11507,10 +11515,19 @@ function transformArgsSpreadsInJsx(node, merged) {
11507
11515
  });
11508
11516
  return { node: t2.jsxFragment(node.openingFragment, node.closingFragment, fragChildren), changed };
11509
11517
  }
11510
- function resolveBindIdentifierInit(storyPath, identifier) {
11518
+ function resolveIdentifierInit(storyPath, identifier) {
11511
11519
  let programPath = storyPath.findParent((p) => p.isProgram());
11512
11520
  if (!programPath)
11513
11521
  return null;
11522
+ for (let stmt of programPath.get("body")) {
11523
+ if (stmt.isFunctionDeclaration() && stmt.node.id?.name === identifier.node.name)
11524
+ return stmt;
11525
+ if (stmt.isExportNamedDeclaration()) {
11526
+ let decl = stmt.get("declaration");
11527
+ if (decl.isFunctionDeclaration() && decl.node.id?.name === identifier.node.name)
11528
+ return decl;
11529
+ }
11530
+ }
11514
11531
  let match = programPath.get("body").flatMap((stmt) => {
11515
11532
  if (stmt.isVariableDeclaration())
11516
11533
  return stmt.get("declarations");
@@ -11930,6 +11947,21 @@ ${message}`
11930
11947
  };
11931
11948
 
11932
11949
  // src/componentManifest/generator.ts
11950
+ function selectComponentEntries(manifestEntries) {
11951
+ let entriesByComponentId = /* @__PURE__ */ new Map();
11952
+ return manifestEntries.filter(
11953
+ (entry) => entry.type === "story" && entry.subtype === "story" || // Attached docs entries are the only docs entries that can contribute to a
11954
+ // component manifest, because they point back to a story file through storiesImports.
11955
+ entry.type === "docs" && entry.tags?.includes(Tag.ATTACHED_MDX) && entry.storiesImports.length > 0
11956
+ ).forEach((entry) => {
11957
+ let componentId = entry.id.split("--")[0], existingEntry = entriesByComponentId.get(componentId);
11958
+ if (!existingEntry) {
11959
+ entriesByComponentId.set(componentId, entry);
11960
+ return;
11961
+ }
11962
+ existingEntry.type === "docs" && entry.type === "story" && entriesByComponentId.set(componentId, entry);
11963
+ }), [...entriesByComponentId.values()];
11964
+ }
11933
11965
  function findMatchingComponent(components, componentName, trimmedTitle) {
11934
11966
  return components.find(
11935
11967
  (it) => componentName ? [it.componentName, it.localImportName, it.importName].includes(componentName) : trimmedTitle.includes(it.componentName) || it.localImportName && trimmedTitle.includes(it.localImportName) || it.importName && trimmedTitle.includes(it.importName)
@@ -11982,14 +12014,7 @@ function extractComponentDescription(csf, docgen) {
11982
12014
  var manifests = async (existingManifests = {}, options) => {
11983
12015
  let { manifestEntries, presets } = options, typescriptOptions = await presets?.apply("typescript", {}) ?? {};
11984
12016
  invalidateCache(), invalidateParser();
11985
- let startTime = performance.now(), components = uniqBy(
11986
- manifestEntries.filter(
11987
- (entry) => entry.type === "story" && entry.subtype === "story" || // addon-docs will add docs entries to these manifest entries afterwards
11988
- // Docs entries have importPath pointing to MDX file, but storiesImports[0] points to the story file
11989
- entry.type === "docs" && entry.tags?.includes(Tag.ATTACHED_MDX) && entry.storiesImports.length > 0
11990
- ),
11991
- (entry) => entry.id.split("--")[0]
11992
- ).map((entry) => {
12017
+ let startTime = performance.now(), components = selectComponentEntries(manifestEntries).map((entry) => {
11993
12018
  let storyFilePath = entry.type === "story" ? entry.importPath : (
11994
12019
  // For attached docs entries, storiesImports[0] points to the stories file being attached to
11995
12020
  entry.storiesImports[0]
@@ -12180,11 +12205,13 @@ async function internal_getArgTypesData(_input, options) {
12180
12205
  componentExportName
12181
12206
  }), argTypesData;
12182
12207
  }
12208
+ var optimizeViteDeps = ["react-dom/test-utils"];
12183
12209
  export {
12184
12210
  addons,
12185
12211
  enrichCsf as experimental_enrichCsf,
12186
12212
  manifests as experimental_manifests,
12187
12213
  internal_getArgTypesData,
12214
+ optimizeViteDeps,
12188
12215
  previewAnnotations,
12189
12216
  resolvedReact
12190
12217
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react",
3
- "version": "10.3.0-alpha.9",
3
+ "version": "10.3.0-beta.0",
4
4
  "description": "Storybook React renderer",
5
5
  "keywords": [
6
6
  "storybook"
@@ -53,7 +53,7 @@
53
53
  ],
54
54
  "dependencies": {
55
55
  "@storybook/global": "^5.0.0",
56
- "@storybook/react-dom-shim": "10.3.0-alpha.9",
56
+ "@storybook/react-dom-shim": "10.3.0-beta.0",
57
57
  "react-docgen": "^8.0.2",
58
58
  "react-docgen-typescript": "^2.2.2"
59
59
  },
@@ -81,7 +81,7 @@
81
81
  "peerDependencies": {
82
82
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
83
83
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
84
- "storybook": "^10.3.0-alpha.9",
84
+ "storybook": "^10.3.0-beta.0",
85
85
  "typescript": ">= 4.9.x"
86
86
  },
87
87
  "peerDependenciesMeta": {