@storybook/react 11.0.0-beta.4 → 11.0.0-rc.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.
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-WWHCZJWM.js";
7
7
  import {
8
8
  entry_preview_docs_exports
9
- } from "./chunk-EA5DV32Q.js";
9
+ } from "./chunk-XQNZ5YRO.js";
10
10
 
11
11
  // src/preview.tsx
12
12
  import { definePreview as definePreviewBase } from "storybook/internal/csf";
@@ -17,6 +17,7 @@ __export(entry_preview_docs_exports, {
17
17
  decorators: () => decorators,
18
18
  parameters: () => parameters
19
19
  });
20
+ import { getSourceSnippetRuntime } from "storybook/internal/docs-tools";
20
21
 
21
22
  // src/docs/print-hole.ts
22
23
  import { printValue, unknownHoleKind } from "storybook/internal/docs-tools";
@@ -163,10 +164,10 @@ var applyDecorators2 = (storyFn, decorators2) => {
163
164
  };
164
165
 
165
166
  // src/entry-preview-docs.ts
166
- var useStaticServiceSnippets = "FEATURES" in globalThis && globalThis?.FEATURES?.docgenServer, useCompileTimeSnippets = "FEATURES" in globalThis && globalThis?.FEATURES?.experimentalCodeExamples, decorators = useStaticServiceSnippets || useCompileTimeSnippets ? [] : [jsxDecorator], parameters = {
167
+ var snippetRuntime = getSourceSnippetRuntime(), useCompileTimeSnippets = "FEATURES" in globalThis && globalThis?.FEATURES?.experimentalCodeExamples, decorators = snippetRuntime === "preview" && !useCompileTimeSnippets ? [jsxDecorator] : [], parameters = {
167
168
  docs: {
168
169
  story: { inline: !0 },
169
- ...useStaticServiceSnippets ? { source: { printHole } } : {}
170
+ ...snippetRuntime === "server" ? { source: { printHole } } : {}
170
171
  }
171
172
  };
172
173
 
@@ -4202,7 +4202,7 @@ import { logger as logger2 } from "storybook/internal/node-logger";
4202
4202
 
4203
4203
  // src/componentManifest/componentMeta/componentMetaExtractor.ts
4204
4204
  import { extractComponentJsDocInfo } from "storybook/internal/component-meta";
4205
- var LARGE_SOURCE_THRESHOLD = 30, MAX_UNWRAP_DEPTH = 5, MAX_SERIALIZATION_DEPTH = 5;
4205
+ var LARGE_SOURCE_THRESHOLD = 30, MAX_UNWRAP_DEPTH = 5, MAX_SERIALIZATION_DEPTH = 5, ARRAY_SYMBOL_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
4206
4206
  function isLiteralType(type) {
4207
4207
  return type.isStringLiteral() || type.isNumberLiteral();
4208
4208
  }
@@ -4465,7 +4465,42 @@ function getAllDeclarationParents(typescript, prop) {
4465
4465
  }
4466
4466
  return parents.length > 0 ? parents : void 0;
4467
4467
  }
4468
- function serializeType(typescript, checker, type, isRequired, depth = 0) {
4468
+ function getDeclaredLiterals(typescript, checker, node, depth = 0) {
4469
+ if (!node || depth > MAX_SERIALIZATION_DEPTH)
4470
+ return [];
4471
+ if (typescript.isParenthesizedTypeNode(node))
4472
+ return getDeclaredLiterals(typescript, checker, node.type, depth);
4473
+ if (typescript.isUnionTypeNode(node))
4474
+ return node.types.flatMap((member) => getDeclaredLiterals(typescript, checker, member, depth));
4475
+ if (typescript.isLiteralTypeNode(node)) {
4476
+ let { literal } = node;
4477
+ return typescript.isStringLiteralLike(literal) ? [literal.text] : typescript.isNumericLiteral(literal) ? [Number(literal.text)] : typescript.isPrefixUnaryExpression(literal) && literal.operator === typescript.SyntaxKind.MinusToken && typescript.isNumericLiteral(literal.operand) ? [-Number(literal.operand.text)] : [];
4478
+ }
4479
+ if (typescript.isTypeReferenceNode(node)) {
4480
+ let symbol = checker.getSymbolAtLocation(node.typeName);
4481
+ return ((symbol ? resolveAliasedSymbol(typescript, checker, symbol).declarations : void 0) ?? []).flatMap(
4482
+ (declaration) => typescript.isTypeAliasDeclaration(declaration) ? getDeclaredLiterals(typescript, checker, declaration.type, depth + 1) : []
4483
+ );
4484
+ }
4485
+ return [];
4486
+ }
4487
+ function compareNumericOrByCodeUnit(a, b) {
4488
+ if (typeof a == "number" && typeof b == "number")
4489
+ return a - b;
4490
+ let [textA, textB] = [String(a), String(b)];
4491
+ return textA < textB ? -1 : textA > textB ? 1 : 0;
4492
+ }
4493
+ function compareEnumMembers(typescript, a, b) {
4494
+ let [memberA, memberB] = [a, b].map((type) => {
4495
+ let declaration = type.symbol?.declarations?.[0];
4496
+ return declaration && typescript.isEnumMember(declaration) ? declaration : void 0;
4497
+ });
4498
+ if (!memberA || !memberB)
4499
+ return +!memberA - +!memberB;
4500
+ let [enumA, enumB] = [memberA.parent, memberB.parent];
4501
+ return compareNumericOrByCodeUnit(enumA.getSourceFile().fileName, enumB.getSourceFile().fileName) || enumA.pos - enumB.pos || memberA.pos - memberB.pos;
4502
+ }
4503
+ function serializeType(typescript, checker, type, isRequired, depth = 0, declaredTypeNode) {
4469
4504
  if (depth > MAX_SERIALIZATION_DEPTH)
4470
4505
  return { name: checker.typeToString(type) };
4471
4506
  if (type.isUnion()) {
@@ -4476,7 +4511,12 @@ function serializeType(typescript, checker, type, isRequired, depth = 0) {
4476
4511
  );
4477
4512
  if (booleanLiterals.length === 2 && booleanLiterals.length === nonUndefinedTypes.length)
4478
4513
  return { name: "boolean" };
4479
- let literalMembers = nonUndefinedTypes.filter(isLiteralType);
4514
+ let declaredLiterals = getDeclaredLiterals(typescript, checker, declaredTypeNode), declaredPosition = (member) => {
4515
+ let index = declaredLiterals.indexOf(member.value);
4516
+ return index === -1 ? declaredLiterals.length : index;
4517
+ }, literalMembers = nonUndefinedTypes.filter(isLiteralType).toSorted(
4518
+ (a, b) => declaredPosition(a) - declaredPosition(b) || compareEnumMembers(typescript, a, b) || compareNumericOrByCodeUnit(a.value, b.value)
4519
+ );
4480
4520
  if (literalMembers.length > 0 && literalMembers.length === nonUndefinedTypes.length)
4481
4521
  return {
4482
4522
  name: "enum",
@@ -4486,10 +4526,29 @@ function serializeType(typescript, checker, type, isRequired, depth = 0) {
4486
4526
  }))
4487
4527
  };
4488
4528
  if (!isRequired && nonUndefinedTypes.length === 1 && nonUndefinedTypes.length < type.types.length)
4489
- return { name: checker.typeToString(nonUndefinedTypes[0]) };
4529
+ return serializeLeaf(typescript, checker, nonUndefinedTypes[0], depth);
4530
+ let nonNullishTypes = nonUndefinedTypes.filter(
4531
+ (t) => !(t.getFlags() & typescript.TypeFlags.Null)
4532
+ );
4533
+ if (nonNullishTypes.length === 1 && isArrayType(nonNullishTypes[0]))
4534
+ return {
4535
+ name: checker.typeToString(type),
4536
+ element: serializeElement(typescript, checker, nonNullishTypes[0], depth)
4537
+ };
4490
4538
  }
4491
4539
  let constraint = type.getConstraint?.();
4492
- return constraint && constraint !== type ? serializeType(typescript, checker, constraint, isRequired, depth + 1) : { name: checker.typeToString(type) };
4540
+ return constraint && constraint !== type ? serializeType(typescript, checker, constraint, isRequired, depth + 1) : serializeLeaf(typescript, checker, type, depth);
4541
+ }
4542
+ function isArrayType(type) {
4543
+ return ARRAY_SYMBOL_NAMES.has(type.getSymbol()?.getName() ?? "");
4544
+ }
4545
+ function serializeLeaf(typescript, checker, type, depth) {
4546
+ let name = checker.typeToString(type);
4547
+ return isArrayType(type) ? { name, element: serializeElement(typescript, checker, type, depth) } : { name };
4548
+ }
4549
+ function serializeElement(typescript, checker, arrayType, depth) {
4550
+ let [element] = checker.getTypeArguments(arrayType);
4551
+ return serializeType(typescript, checker, element, !0, depth + 1);
4493
4552
  }
4494
4553
  function unwrapToFunction(typescript, node, depth = 0, checker) {
4495
4554
  if (!(depth > MAX_UNWRAP_DEPTH)) {
@@ -4676,7 +4735,7 @@ function getJSDocDefault(typescript, prop, checker) {
4676
4735
  return typescript.displayPartsToString(tag.text) || void 0;
4677
4736
  }
4678
4737
  function extractPropItem(typescript, checker, prop, contextNode, defaultsMap, typeOverride) {
4679
- let isRequired = !!!(prop.flags & typescript.SymbolFlags.Optional), propType = typeOverride ?? checker.getTypeOfSymbolAtLocation(prop, contextNode), type = serializeType(typescript, checker, propType, isRequired), description = typescript.displayPartsToString(
4738
+ let isRequired = !!!(prop.flags & typescript.SymbolFlags.Optional), propType = typeOverride ?? checker.getTypeOfSymbolAtLocation(prop, contextNode), declaration = prop.declarations?.[0], declaredTypeNode = declaration && (typescript.isPropertySignature(declaration) || typescript.isPropertyDeclaration(declaration)) ? declaration.type : void 0, type = serializeType(typescript, checker, propType, isRequired, 0, declaredTypeNode), description = typescript.displayPartsToString(
4680
4739
  prop.getDocumentationComment(checker)
4681
4740
  ), parent = getParentType(typescript, prop), declarations = getAllDeclarationParents(typescript, prop), propName = prop.getName(), destructuringDefault = defaultsMap?.get(propName), jsDocDefault = getJSDocDefault(typescript, prop, checker), defaultStr = destructuringDefault ?? jsDocDefault;
4682
4741
  return {
@@ -4689,6 +4748,11 @@ function extractPropItem(typescript, checker, prop, contextNode, defaultsMap, ty
4689
4748
  declarations
4690
4749
  };
4691
4750
  }
4751
+ function orderByDeclaration(properties) {
4752
+ return [...groupByToMap(properties, (prop) => prop.declarations?.[0]?.parent ?? prop).values()].flatMap(
4753
+ (group) => group.toSorted((a, b) => (a.declarations?.[0]?.pos ?? 0) - (b.declarations?.[0]?.pos ?? 0))
4754
+ );
4755
+ }
4692
4756
  function getBulkSourceExclusions(typescript, properties) {
4693
4757
  let bulkCandidates = properties.flatMap((prop) => {
4694
4758
  let source = getPropSourceFile(prop);
@@ -4749,6 +4813,7 @@ function serializeComponentDoc(typescript, checker, {
4749
4813
  allProperties = Array.from(seen.values()), unionForceOptional = forceOptional;
4750
4814
  } else
4751
4815
  allProperties = propsType.getApparentProperties();
4816
+ allProperties = orderByDeclaration(allProperties);
4752
4817
  let excluded = getBulkSourceExclusions(typescript, allProperties), implementation = followVariableReferences(typescript, checker, resolved), defaultsMap = extractDestructuringDefaults(typescript, implementation, checker);
4753
4818
  if (defaultsMap.size === 0 && defaultsSourcePath) {
4754
4819
  let fallbackDefaults = extractDefaultsFromSourceFile(typescript, defaultsSourcePath, {
@@ -5180,22 +5245,31 @@ var ComponentMetaManager = class extends BaseComponentMetaManager {
5180
5245
  * Batch-extract component props across all entries, grouping by tsconfig project so each project
5181
5246
  * builds its TS program only once.
5182
5247
  */
5183
- batchExtract(entries) {
5184
- let extractableEntries = entries.filter(
5185
- (storyRef) => storyRef.component?.path && storyRef.component.importName
5186
- ), byProject = groupByToMap(
5187
- extractableEntries,
5248
+ batchExtract(entries, batchFiles) {
5249
+ let byProject = groupByToMap(
5250
+ entries.filter(isExtractable),
5188
5251
  (storyRef) => this.getProjectForFile(storyRef.storyPath)
5189
5252
  );
5190
- for (let [project, projectEntries] of byProject)
5253
+ for (let [project, projectEntries] of byProject) {
5254
+ this.addBatchFiles(project, batchFiles);
5191
5255
  try {
5192
5256
  project.extractPropsFromStories(projectEntries);
5193
5257
  } catch (err) {
5194
5258
  logger3.debug(`[reactComponentMeta] Batch extraction failed: ${err}`);
5195
5259
  }
5196
- this.recycleProjectsIfHeapPressured();
5260
+ }
5261
+ this.recycleProjectsIfHeapPressured() && batchFiles?.clear();
5197
5262
  }
5198
- };
5263
+ addBatchFiles(project, batchFiles) {
5264
+ let files = batchFiles?.get(project) ?? [];
5265
+ batchFiles?.delete(project);
5266
+ try {
5267
+ project.ensureFiles(files);
5268
+ } catch (err) {
5269
+ logger3.debug(`[reactComponentMeta] Adding the batch files failed: ${err}`);
5270
+ }
5271
+ }
5272
+ }, isExtractable = (storyRef) => !!storyRef.component?.path && !!storyRef.component.importName;
5199
5273
 
5200
5274
  // ../../../node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
5201
5275
  var _lazyMatch = () => {
@@ -6450,5 +6524,6 @@ export {
6450
6524
  buildComponentDocgenFromResolved,
6451
6525
  buildReactComponentDocgenFromResolved,
6452
6526
  loadDocgenTypeScript,
6453
- ComponentMetaManager
6527
+ ComponentMetaManager,
6528
+ isExtractable
6454
6529
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ComponentMetaManager,
3
3
  loadDocgenTypeScript
4
- } from "./chunk-MZA63NMI.js";
4
+ } from "./chunk-2I5WCK5H.js";
5
5
 
6
6
  // src/componentManifest/componentMetaManagerSingleton.ts
7
7
  import { logger } from "storybook/internal/node-logger";
@@ -0,0 +1,131 @@
1
+ import {
2
+ buildComponentDocgenFromResolved,
3
+ isExtractable,
4
+ posix,
5
+ resolveStoryFileComponents
6
+ } from "./chunk-2I5WCK5H.js";
7
+ import {
8
+ extractArgTypes
9
+ } from "./chunk-SC3QXTHH.js";
10
+
11
+ // src/docgen/buildDocgen.ts
12
+ import { getStoryImportPathFromEntry } from "storybook/internal/common";
13
+ import { logger } from "storybook/internal/node-logger";
14
+ var REACT_ATTRIBUTE_INTERFACES = /* @__PURE__ */ new Set(["Attributes", "RefAttributes", "ClassAttributes"]);
15
+ function isReactAttribute(prop) {
16
+ return !!prop.parent && REACT_ATTRIBUTE_INTERFACES.has(prop.parent.name) && /(^|[\\/])node_modules[\\/]/.test(prop.parent.fileName);
17
+ }
18
+ function toDocgenType({ element, ...type }) {
19
+ return element ? { name: "array", raw: type.name, value: toDocgenType(element) } : type;
20
+ }
21
+ function extractArgTypesFromComponentMeta(componentMeta) {
22
+ if (!componentMeta)
23
+ return;
24
+ let props = Object.fromEntries(
25
+ Object.entries(componentMeta.props).filter(([, prop]) => !isReactAttribute(prop)).map(([name, prop]) => [
26
+ name,
27
+ {
28
+ ...prop,
29
+ type: toDocgenType(prop.type),
30
+ defaultValue: prop.defaultValue && { ...prop.defaultValue, computed: !1 }
31
+ }
32
+ ])
33
+ ), argTypes = extractArgTypes({ __docgenInfo: { ...componentMeta, props } }) ?? void 0;
34
+ for (let [name, prop] of Object.entries(componentMeta.props)) {
35
+ let table = argTypes?.[name]?.table;
36
+ prop.type.element && table && (table.type = { summary: prop.type.name });
37
+ }
38
+ return argTypes;
39
+ }
40
+ function addArgTypesFromComponentMeta(payload) {
41
+ let argTypes = extractArgTypesFromComponentMeta(payload.reactComponentMeta), subcomponents = payload.subcomponents ? Object.fromEntries(
42
+ Object.entries(payload.subcomponents).map(([name, subcomponent]) => [
43
+ name,
44
+ {
45
+ ...subcomponent,
46
+ argTypes: extractArgTypesFromComponentMeta(subcomponent.reactComponentMeta)
47
+ }
48
+ ])
49
+ ) : void 0;
50
+ return {
51
+ ...payload,
52
+ ...argTypes ? { argTypes } : {},
53
+ ...subcomponents ? { subcomponents } : {}
54
+ };
55
+ }
56
+ function toStoryRefs(storyPath, { component, subcomponents }) {
57
+ return [component, ...subcomponents.map((sub) => sub.component)].filter((ref) => ref !== void 0).map((ref) => ({ storyPath, component: ref }));
58
+ }
59
+ async function resolveStory({ entry }, context) {
60
+ let storyFilePath = getStoryImportPathFromEntry(entry);
61
+ if (!storyFilePath)
62
+ return;
63
+ let storyPath = resolveStoryPath(storyFilePath, context);
64
+ try {
65
+ let resolved = await resolveStoryFileComponents({
66
+ storyPath,
67
+ title: entry.title,
68
+ typescriptOptions: context.typescriptOptions,
69
+ docgenEngine: "react-component-meta"
70
+ });
71
+ return { storyFilePath, storyPath, resolved };
72
+ } catch {
73
+ return;
74
+ }
75
+ }
76
+ var resolveStoryPath = (storyFilePath, { resolvePath }) => resolvePath ? resolvePath(storyFilePath) : posix.join(process.cwd(), storyFilePath);
77
+ async function extractEach(inputs, extractOne) {
78
+ let results = [];
79
+ for (let input of inputs)
80
+ try {
81
+ results.push({ status: "fulfilled", value: await extractOne(input) });
82
+ } catch (reason) {
83
+ results.push({ status: "rejected", reason });
84
+ }
85
+ return results;
86
+ }
87
+ async function buildDocgenPayloads(inputs, context) {
88
+ if (inputs.length === 1)
89
+ return extractEach(inputs, (input) => buildDocgenPayload(input, context));
90
+ let refs = (await Promise.all(
91
+ inputs.map(async (input) => {
92
+ let story = await resolveStory(input, context);
93
+ return story ? toStoryRefs(story.storyPath, story.resolved) : [];
94
+ })
95
+ )).flat(), batchFiles;
96
+ try {
97
+ batchFiles = context.componentMetaManager.groupFilesByProject(
98
+ refs.filter(isExtractable).map(({ storyPath, component }) => ({
99
+ projectFile: storyPath,
100
+ files: [storyPath, component.path]
101
+ }))
102
+ );
103
+ } catch (err) {
104
+ logger.debug(`[reactComponentMeta] Grouping the batch files failed: ${err}`);
105
+ }
106
+ return extractEach(inputs, (input) => buildDocgenPayload(input, { ...context, batchFiles }));
107
+ }
108
+ async function buildDocgenPayload(input, context) {
109
+ let story = await resolveStory(input, context);
110
+ if (!story)
111
+ return;
112
+ let { storyFilePath, storyPath, resolved } = story, { csf, componentName, component, subcomponents, storyFile } = resolved, storyRefs = toStoryRefs(storyPath, resolved);
113
+ storyRefs.length > 0 && context.componentMetaManager.batchExtract(storyRefs, context.batchFiles);
114
+ let componentDocgen = buildComponentDocgenFromResolved({
115
+ entry: input.entry,
116
+ storyPath,
117
+ storyFilePath,
118
+ storyFile,
119
+ csf,
120
+ componentName,
121
+ component,
122
+ subcomponents,
123
+ docgenEngine: "react-component-meta"
124
+ });
125
+ return addArgTypesFromComponentMeta(componentDocgen);
126
+ }
127
+
128
+ export {
129
+ extractArgTypesFromComponentMeta,
130
+ buildDocgenPayloads
131
+ };
@@ -1,4 +1,4 @@
1
- import { createRequire as CJS_COMPAT_CREATE_REQUIRE_xwvv63aul3 } from "node:module";var require = CJS_COMPAT_CREATE_REQUIRE_xwvv63aul3(import.meta.url);
1
+ import { createRequire as CJS_COMPAT_CREATE_REQUIRE_irrednmjp7d } from "node:module";var require = CJS_COMPAT_CREATE_REQUIRE_irrednmjp7d(import.meta.url);
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getSharedComponentMetaManager
3
- } from "./chunk-3ZQP5GHE.js";
3
+ } from "./chunk-ITCF7APG.js";
4
4
  import {
5
5
  extractArgTypesFromComponentMeta
6
- } from "./chunk-6ZKSWYLW.js";
7
- import "./chunk-MZA63NMI.js";
6
+ } from "./chunk-LZBEMUVF.js";
7
+ import "./chunk-2I5WCK5H.js";
8
8
  import "./chunk-MYBSMCSW.js";
9
9
  import "./chunk-CJ2XYAXX.js";
10
10
  import "./chunk-SC3QXTHH.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
- buildDocgenPayload
3
- } from "../_node-chunks/chunk-6ZKSWYLW.js";
2
+ buildDocgenPayloads
3
+ } from "../_node-chunks/chunk-LZBEMUVF.js";
4
4
  import {
5
5
  ComponentMetaManager,
6
6
  loadDocgenTypeScript
7
- } from "../_node-chunks/chunk-MZA63NMI.js";
7
+ } from "../_node-chunks/chunk-2I5WCK5H.js";
8
8
  import "../_node-chunks/chunk-MYBSMCSW.js";
9
9
  import "../_node-chunks/chunk-CJ2XYAXX.js";
10
10
  import "../_node-chunks/chunk-SC3QXTHH.js";
@@ -27,7 +27,7 @@ var createDocgenProvider = ({
27
27
  return;
28
28
  }
29
29
  },
30
- extract: (componentMetaManager, input) => buildDocgenPayload(input, { componentMetaManager })
30
+ extractBatch: (componentMetaManager, inputs) => buildDocgenPayloads(inputs, { componentMetaManager })
31
31
  });
32
32
  export {
33
33
  createDocgenProvider
@@ -2,7 +2,7 @@ import {
2
2
  applyDecorators,
3
3
  decorators,
4
4
  parameters
5
- } from "./_browser-chunks/chunk-EA5DV32Q.js";
5
+ } from "./_browser-chunks/chunk-XQNZ5YRO.js";
6
6
  import "./_browser-chunks/chunk-DDIRQRCA.js";
7
7
  import "./_browser-chunks/chunk-B3FR4PBN.js";
8
8
  import "./_browser-chunks/chunk-UAWMPV5J.js";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __definePreview
3
- } from "./_browser-chunks/chunk-U7XUEUFQ.js";
3
+ } from "./_browser-chunks/chunk-LK5PKCYS.js";
4
4
  import {
5
5
  entry_preview_exports,
6
6
  renderToCanvas
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  entry_preview_argtypes_exports
10
10
  } from "./_browser-chunks/chunk-WWHCZJWM.js";
11
- import "./_browser-chunks/chunk-EA5DV32Q.js";
11
+ import "./_browser-chunks/chunk-XQNZ5YRO.js";
12
12
  import "./_browser-chunks/chunk-DDIRQRCA.js";
13
13
  import "./_browser-chunks/chunk-B3FR4PBN.js";
14
14
  import "./_browser-chunks/chunk-UAWMPV5J.js";
package/dist/preset.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  } from "./_node-chunks/chunk-HRHJMJC7.js";
4
4
  import {
5
5
  getSharedComponentMetaManager
6
- } from "./_node-chunks/chunk-3ZQP5GHE.js";
6
+ } from "./_node-chunks/chunk-ITCF7APG.js";
7
7
  import {
8
8
  buildReactComponentDocgenFromResolved,
9
9
  buildStoryDocsFromResolved,
@@ -13,7 +13,7 @@ import {
13
13
  join,
14
14
  posix,
15
15
  resolveStoryFileComponents
16
- } from "./_node-chunks/chunk-MZA63NMI.js";
16
+ } from "./_node-chunks/chunk-2I5WCK5H.js";
17
17
  import {
18
18
  REACT_DOCGEN_TYPESCRIPT_APIS
19
19
  } from "./_node-chunks/chunk-MYBSMCSW.js";
@@ -379,7 +379,7 @@ async function internal_getArgTypesData(_input, options) {
379
379
  return null;
380
380
  let absoluteComponentFilePath = path2.isAbsolute(componentFilePath) ? componentFilePath : join3(getProjectRoot(), componentFilePath);
381
381
  if ((await presets?.apply("features", {}))?.docgenServer) {
382
- let { extractArgTypesFromComponentFile } = await import("./_node-chunks/extractArgTypesFromComponentFile-2DRDUH5M.js");
382
+ let { extractArgTypesFromComponentFile } = await import("./_node-chunks/extractArgTypesFromComponentFile-BBV3XDO4.js");
383
383
  return extractArgTypesFromComponentFile({
384
384
  componentFilePath: absoluteComponentFilePath,
385
385
  componentExportName,
package/dist/preview.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  __definePreview
3
- } from "./_browser-chunks/chunk-U7XUEUFQ.js";
3
+ } from "./_browser-chunks/chunk-LK5PKCYS.js";
4
4
  import "./_browser-chunks/chunk-I62VTYU3.js";
5
5
  import "./_browser-chunks/chunk-WWHCZJWM.js";
6
- import "./_browser-chunks/chunk-EA5DV32Q.js";
6
+ import "./_browser-chunks/chunk-XQNZ5YRO.js";
7
7
  import "./_browser-chunks/chunk-DDIRQRCA.js";
8
8
  import "./_browser-chunks/chunk-B3FR4PBN.js";
9
9
  import "./_browser-chunks/chunk-UAWMPV5J.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react",
3
- "version": "11.0.0-beta.4",
3
+ "version": "11.0.0-rc.0",
4
4
  "description": "Storybook React renderer",
5
5
  "keywords": [
6
6
  "storybook"
@@ -56,7 +56,7 @@
56
56
  "@storybook/global": "^5.0.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@storybook/component-meta-typescript": "11.0.0-beta.4",
59
+ "@storybook/component-meta-typescript": "11.0.0-rc.0",
60
60
  "@types/babel-plugin-react-docgen": "^4.2.3",
61
61
  "@types/escodegen": "^0.0.6",
62
62
  "@types/estree": "^1.0.6",
@@ -90,7 +90,7 @@
90
90
  "react-docgen": "^8.0.2",
91
91
  "react-docgen-typescript": "^2.2.2",
92
92
  "react-dom": "^18.0.0 || ^19.0.0",
93
- "storybook": "^11.0.0-beta.4",
93
+ "storybook": "^11.0.0-rc.0",
94
94
  "typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
95
95
  },
96
96
  "peerDependenciesMeta": {
@@ -1,82 +0,0 @@
1
- import {
2
- buildComponentDocgenFromResolved,
3
- posix,
4
- resolveStoryFileComponents
5
- } from "./chunk-MZA63NMI.js";
6
- import {
7
- extractArgTypes
8
- } from "./chunk-SC3QXTHH.js";
9
-
10
- // src/docgen/buildDocgen.ts
11
- import { getStoryImportPathFromEntry } from "storybook/internal/common";
12
- var REACT_ATTRIBUTE_INTERFACES = /* @__PURE__ */ new Set(["Attributes", "RefAttributes", "ClassAttributes"]);
13
- function isReactAttribute(prop) {
14
- return !!prop.parent && REACT_ATTRIBUTE_INTERFACES.has(prop.parent.name) && /(^|[\\/])node_modules[\\/]/.test(prop.parent.fileName);
15
- }
16
- function extractArgTypesFromComponentMeta(componentMeta) {
17
- if (!componentMeta)
18
- return;
19
- let props = Object.fromEntries(
20
- Object.entries(componentMeta.props).filter(([, prop]) => !isReactAttribute(prop)).map(([name, prop]) => [
21
- name,
22
- prop.defaultValue ? { ...prop, defaultValue: { ...prop.defaultValue, computed: !1 } } : prop
23
- ])
24
- );
25
- return extractArgTypes({ __docgenInfo: { ...componentMeta, props } }) ?? void 0;
26
- }
27
- function addArgTypesFromComponentMeta(payload) {
28
- let argTypes = extractArgTypesFromComponentMeta(payload.reactComponentMeta), subcomponents = payload.subcomponents ? Object.fromEntries(
29
- Object.entries(payload.subcomponents).map(([name, subcomponent]) => [
30
- name,
31
- {
32
- ...subcomponent,
33
- argTypes: extractArgTypesFromComponentMeta(subcomponent.reactComponentMeta)
34
- }
35
- ])
36
- ) : void 0;
37
- return {
38
- ...payload,
39
- ...argTypes ? { argTypes } : {},
40
- ...subcomponents ? { subcomponents } : {}
41
- };
42
- }
43
- async function buildDocgenPayload(input, context) {
44
- let storyFilePath = getStoryImportPathFromEntry(input.entry);
45
- if (!storyFilePath)
46
- return;
47
- let storyPath = (context.resolvePath ?? ((importPath) => posix.join(process.cwd(), importPath)))(storyFilePath), resolved;
48
- try {
49
- resolved = await resolveStoryFileComponents({
50
- storyPath,
51
- title: input.entry.title,
52
- typescriptOptions: context.typescriptOptions,
53
- docgenEngine: "react-component-meta"
54
- });
55
- } catch {
56
- return;
57
- }
58
- let { csf, componentName, component, subcomponents, storyFile } = resolved, usableSubcomponents = subcomponents.filter(
59
- (sub) => sub.component !== void 0
60
- ), storyRefs = [
61
- ...component ? [{ storyPath, component }] : [],
62
- ...usableSubcomponents.map((sub) => ({ storyPath, component: sub.component }))
63
- ];
64
- storyRefs.length > 0 && context.componentMetaManager.batchExtract(storyRefs);
65
- let componentDocgen = buildComponentDocgenFromResolved({
66
- entry: input.entry,
67
- storyPath,
68
- storyFilePath,
69
- storyFile,
70
- csf,
71
- componentName,
72
- component,
73
- subcomponents,
74
- docgenEngine: "react-component-meta"
75
- });
76
- return addArgTypesFromComponentMeta(componentDocgen);
77
- }
78
-
79
- export {
80
- extractArgTypesFromComponentMeta,
81
- buildDocgenPayload
82
- };