@storybook/react 11.0.0-beta.4 → 11.0.0-beta.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.
@@ -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
 
@@ -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",
@@ -4676,7 +4716,7 @@ function getJSDocDefault(typescript, prop, checker) {
4676
4716
  return typescript.displayPartsToString(tag.text) || void 0;
4677
4717
  }
4678
4718
  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(
4719
+ 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
4720
  prop.getDocumentationComment(checker)
4681
4721
  ), parent = getParentType(typescript, prop), declarations = getAllDeclarationParents(typescript, prop), propName = prop.getName(), destructuringDefault = defaultsMap?.get(propName), jsDocDefault = getJSDocDefault(typescript, prop, checker), defaultStr = destructuringDefault ?? jsDocDefault;
4682
4722
  return {
@@ -4689,6 +4729,11 @@ function extractPropItem(typescript, checker, prop, contextNode, defaultsMap, ty
4689
4729
  declarations
4690
4730
  };
4691
4731
  }
4732
+ function orderByDeclaration(properties) {
4733
+ return [...groupByToMap(properties, (prop) => prop.declarations?.[0]?.parent ?? prop).values()].flatMap(
4734
+ (group) => group.toSorted((a, b) => (a.declarations?.[0]?.pos ?? 0) - (b.declarations?.[0]?.pos ?? 0))
4735
+ );
4736
+ }
4692
4737
  function getBulkSourceExclusions(typescript, properties) {
4693
4738
  let bulkCandidates = properties.flatMap((prop) => {
4694
4739
  let source = getPropSourceFile(prop);
@@ -4749,6 +4794,7 @@ function serializeComponentDoc(typescript, checker, {
4749
4794
  allProperties = Array.from(seen.values()), unionForceOptional = forceOptional;
4750
4795
  } else
4751
4796
  allProperties = propsType.getApparentProperties();
4797
+ allProperties = orderByDeclaration(allProperties);
4752
4798
  let excluded = getBulkSourceExclusions(typescript, allProperties), implementation = followVariableReferences(typescript, checker, resolved), defaultsMap = extractDestructuringDefaults(typescript, implementation, checker);
4753
4799
  if (defaultsMap.size === 0 && defaultsSourcePath) {
4754
4800
  let fallbackDefaults = extractDefaultsFromSourceFile(typescript, defaultsSourcePath, {
@@ -5180,22 +5226,31 @@ var ComponentMetaManager = class extends BaseComponentMetaManager {
5180
5226
  * Batch-extract component props across all entries, grouping by tsconfig project so each project
5181
5227
  * builds its TS program only once.
5182
5228
  */
5183
- batchExtract(entries) {
5184
- let extractableEntries = entries.filter(
5185
- (storyRef) => storyRef.component?.path && storyRef.component.importName
5186
- ), byProject = groupByToMap(
5187
- extractableEntries,
5229
+ batchExtract(entries, batchFiles) {
5230
+ let byProject = groupByToMap(
5231
+ entries.filter(isExtractable),
5188
5232
  (storyRef) => this.getProjectForFile(storyRef.storyPath)
5189
5233
  );
5190
- for (let [project, projectEntries] of byProject)
5234
+ for (let [project, projectEntries] of byProject) {
5235
+ this.addBatchFiles(project, batchFiles);
5191
5236
  try {
5192
5237
  project.extractPropsFromStories(projectEntries);
5193
5238
  } catch (err) {
5194
5239
  logger3.debug(`[reactComponentMeta] Batch extraction failed: ${err}`);
5195
5240
  }
5196
- this.recycleProjectsIfHeapPressured();
5241
+ }
5242
+ this.recycleProjectsIfHeapPressured() && batchFiles?.clear();
5197
5243
  }
5198
- };
5244
+ addBatchFiles(project, batchFiles) {
5245
+ let files = batchFiles?.get(project) ?? [];
5246
+ batchFiles?.delete(project);
5247
+ try {
5248
+ project.ensureFiles(files);
5249
+ } catch (err) {
5250
+ logger3.debug(`[reactComponentMeta] Adding the batch files failed: ${err}`);
5251
+ }
5252
+ }
5253
+ }, isExtractable = (storyRef) => !!storyRef.component?.path && !!storyRef.component.importName;
5199
5254
 
5200
5255
  // ../../../node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
5201
5256
  var _lazyMatch = () => {
@@ -6450,5 +6505,6 @@ export {
6450
6505
  buildComponentDocgenFromResolved,
6451
6506
  buildReactComponentDocgenFromResolved,
6452
6507
  loadDocgenTypeScript,
6453
- ComponentMetaManager
6508
+ ComponentMetaManager,
6509
+ isExtractable
6454
6510
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ComponentMetaManager,
3
3
  loadDocgenTypeScript
4
- } from "./chunk-MZA63NMI.js";
4
+ } from "./chunk-2DC27WWN.js";
5
5
 
6
6
  // src/componentManifest/componentMetaManagerSingleton.ts
7
7
  import { logger } from "storybook/internal/node-logger";
@@ -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_h7kvzawybx6 } from "node:module";var require = CJS_COMPAT_CREATE_REQUIRE_h7kvzawybx6(import.meta.url);
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -0,0 +1,120 @@
1
+ import {
2
+ buildComponentDocgenFromResolved,
3
+ isExtractable,
4
+ posix,
5
+ resolveStoryFileComponents
6
+ } from "./chunk-2DC27WWN.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 extractArgTypesFromComponentMeta(componentMeta) {
19
+ if (!componentMeta)
20
+ return;
21
+ let props = Object.fromEntries(
22
+ Object.entries(componentMeta.props).filter(([, prop]) => !isReactAttribute(prop)).map(([name, prop]) => [
23
+ name,
24
+ prop.defaultValue ? { ...prop, defaultValue: { ...prop.defaultValue, computed: !1 } } : prop
25
+ ])
26
+ );
27
+ return extractArgTypes({ __docgenInfo: { ...componentMeta, props } }) ?? void 0;
28
+ }
29
+ function addArgTypesFromComponentMeta(payload) {
30
+ let argTypes = extractArgTypesFromComponentMeta(payload.reactComponentMeta), subcomponents = payload.subcomponents ? Object.fromEntries(
31
+ Object.entries(payload.subcomponents).map(([name, subcomponent]) => [
32
+ name,
33
+ {
34
+ ...subcomponent,
35
+ argTypes: extractArgTypesFromComponentMeta(subcomponent.reactComponentMeta)
36
+ }
37
+ ])
38
+ ) : void 0;
39
+ return {
40
+ ...payload,
41
+ ...argTypes ? { argTypes } : {},
42
+ ...subcomponents ? { subcomponents } : {}
43
+ };
44
+ }
45
+ function toStoryRefs(storyPath, { component, subcomponents }) {
46
+ return [component, ...subcomponents.map((sub) => sub.component)].filter((ref) => ref !== void 0).map((ref) => ({ storyPath, component: ref }));
47
+ }
48
+ async function resolveStory({ entry }, context) {
49
+ let storyFilePath = getStoryImportPathFromEntry(entry);
50
+ if (!storyFilePath)
51
+ return;
52
+ let storyPath = resolveStoryPath(storyFilePath, context);
53
+ try {
54
+ let resolved = await resolveStoryFileComponents({
55
+ storyPath,
56
+ title: entry.title,
57
+ typescriptOptions: context.typescriptOptions,
58
+ docgenEngine: "react-component-meta"
59
+ });
60
+ return { storyFilePath, storyPath, resolved };
61
+ } catch {
62
+ return;
63
+ }
64
+ }
65
+ var resolveStoryPath = (storyFilePath, { resolvePath }) => resolvePath ? resolvePath(storyFilePath) : posix.join(process.cwd(), storyFilePath);
66
+ async function extractEach(inputs, extractOne) {
67
+ let results = [];
68
+ for (let input of inputs)
69
+ try {
70
+ results.push({ status: "fulfilled", value: await extractOne(input) });
71
+ } catch (reason) {
72
+ results.push({ status: "rejected", reason });
73
+ }
74
+ return results;
75
+ }
76
+ async function buildDocgenPayloads(inputs, context) {
77
+ if (inputs.length === 1)
78
+ return extractEach(inputs, (input) => buildDocgenPayload(input, context));
79
+ let refs = (await Promise.all(
80
+ inputs.map(async (input) => {
81
+ let story = await resolveStory(input, context);
82
+ return story ? toStoryRefs(story.storyPath, story.resolved) : [];
83
+ })
84
+ )).flat(), batchFiles;
85
+ try {
86
+ batchFiles = context.componentMetaManager.groupFilesByProject(
87
+ refs.filter(isExtractable).map(({ storyPath, component }) => ({
88
+ projectFile: storyPath,
89
+ files: [storyPath, component.path]
90
+ }))
91
+ );
92
+ } catch (err) {
93
+ logger.debug(`[reactComponentMeta] Grouping the batch files failed: ${err}`);
94
+ }
95
+ return extractEach(inputs, (input) => buildDocgenPayload(input, { ...context, batchFiles }));
96
+ }
97
+ async function buildDocgenPayload(input, context) {
98
+ let story = await resolveStory(input, context);
99
+ if (!story)
100
+ return;
101
+ let { storyFilePath, storyPath, resolved } = story, { csf, componentName, component, subcomponents, storyFile } = resolved, storyRefs = toStoryRefs(storyPath, resolved);
102
+ storyRefs.length > 0 && context.componentMetaManager.batchExtract(storyRefs, context.batchFiles);
103
+ let componentDocgen = buildComponentDocgenFromResolved({
104
+ entry: input.entry,
105
+ storyPath,
106
+ storyFilePath,
107
+ storyFile,
108
+ csf,
109
+ componentName,
110
+ component,
111
+ subcomponents,
112
+ docgenEngine: "react-component-meta"
113
+ });
114
+ return addArgTypesFromComponentMeta(componentDocgen);
115
+ }
116
+
117
+ export {
118
+ extractArgTypesFromComponentMeta,
119
+ buildDocgenPayloads
120
+ };
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getSharedComponentMetaManager
3
- } from "./chunk-3ZQP5GHE.js";
3
+ } from "./chunk-2NYPPHY3.js";
4
4
  import {
5
5
  extractArgTypesFromComponentMeta
6
- } from "./chunk-6ZKSWYLW.js";
7
- import "./chunk-MZA63NMI.js";
6
+ } from "./chunk-WSXDRG6X.js";
7
+ import "./chunk-2DC27WWN.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-WSXDRG6X.js";
4
4
  import {
5
5
  ComponentMetaManager,
6
6
  loadDocgenTypeScript
7
- } from "../_node-chunks/chunk-MZA63NMI.js";
7
+ } from "../_node-chunks/chunk-2DC27WWN.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-2NYPPHY3.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-2DC27WWN.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-E3P24DW4.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-beta.5",
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-beta.5",
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-beta.5",
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
- };