@storybook/react 11.0.0-rc.3 → 11.0.0-rc.4
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.
- package/dist/_browser-chunks/{chunk-KI7YBTX7.js → chunk-VG7VCVF3.js} +2 -2
- package/dist/_node-chunks/{chunk-RNO52GGS.js → chunk-6DVQPLAK.js} +1 -1
- package/dist/_node-chunks/chunk-PQZIOGBY.js +1 -1
- package/dist/_node-chunks/{chunk-4UV6B7T7.js → chunk-PVKC5GIW.js} +16 -3
- package/dist/_node-chunks/{chunk-XMHC3CJ5.js → chunk-ZGMTV3ZQ.js} +231 -128
- package/dist/_node-chunks/{extractArgTypesFromComponentFile-UJJRVMGW.js → extractArgTypesFromComponentFile-2KTCTT6A.js} +3 -3
- package/dist/docgen/docgen-worker.js +4 -2
- package/dist/docs/register-print-hole.js +1 -1
- package/dist/entry-preview-docs.js +1 -1
- package/dist/index.js +1 -1
- package/dist/preset.js +3 -3
- package/dist/preview.js +1 -1
- package/package.json +3 -3
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "storybook/internal/docs-tools/snippets";
|
|
9
9
|
|
|
10
10
|
// src/snippet-values.ts
|
|
11
|
-
var unmarked = (_, text) => text, isAttributeName = (name) => /^[A-Za-z_][A-Za-z0-9_:-]*$/.test(name), isAttributeText = (text) => !/["&\r\n]/.test(text), isChildText = (text) => !/[{}<>&\r\n]
|
|
11
|
+
var unmarked = (_, text) => text, isAttributeName = (name) => /^[A-Za-z_][A-Za-z0-9_:-]*$/.test(name), isAttributeText = (text) => !/["&\r\n]/.test(text), isChildText = (text) => !/[{}<>&\r\n]|^\s|\s$/.test(text), valueCode = (value) => value.kind === "boolean" ? String(value.value) : value.code, printAttribute = (name, value) => value.kind === "boolean" ? value.value ? name : `${name}={false}` : value.kind === "string" && isAttributeText(value.value) ? `${name}="${value.value}"` : `${name}={${value.code}}`, printAttributes = (args, mark = unmarked) => {
|
|
12
12
|
let unnamed = args.filter(([name]) => !isAttributeName(name)), attributes = args.filter(([name]) => isAttributeName(name)).map(([name, value]) => mark({ kind: "attr", arg: name }, printAttribute(name, value)));
|
|
13
13
|
if (unnamed.length !== 0) {
|
|
14
14
|
let members = unnamed.map(
|
|
@@ -32,7 +32,7 @@ var printHole = (hole, value) => {
|
|
|
32
32
|
case "attrs":
|
|
33
33
|
return printAttributes(
|
|
34
34
|
Object.entries(value).filter(([name]) => !hole.except.includes(name)).map(([name, item]) => [name, toJsxValue(name, item)])
|
|
35
|
-
).
|
|
35
|
+
).join(hole.separator);
|
|
36
36
|
default:
|
|
37
37
|
return unknownHoleKind(hole);
|
|
38
38
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRequire as
|
|
1
|
+
import { createRequire as CJS_COMPAT_CREATE_REQUIRE_ndexerj3ny } from "node:module";var require = CJS_COMPAT_CREATE_REQUIRE_ndexerj3ny(import.meta.url);
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildComponentDocgenFromResolved,
|
|
3
|
+
describeComponent,
|
|
3
4
|
isExtractable,
|
|
4
5
|
resolveStoryFileComponents
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZGMTV3ZQ.js";
|
|
6
7
|
import {
|
|
7
8
|
posix
|
|
8
9
|
} from "./chunk-M3SEC5XW.js";
|
|
@@ -11,7 +12,10 @@ import {
|
|
|
11
12
|
} from "./chunk-SC3QXTHH.js";
|
|
12
13
|
|
|
13
14
|
// src/docgen/buildDocgen.ts
|
|
14
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
getComponentIdFromEntry,
|
|
17
|
+
getStoryImportPathFromEntry
|
|
18
|
+
} from "storybook/internal/common";
|
|
15
19
|
import { logger } from "storybook/internal/node-logger";
|
|
16
20
|
var REACT_ATTRIBUTE_INTERFACES = /* @__PURE__ */ new Set(["Attributes", "RefAttributes", "ClassAttributes"]);
|
|
17
21
|
function isReactAttribute(prop) {
|
|
@@ -107,6 +111,14 @@ async function buildDocgenPayloads(inputs, context) {
|
|
|
107
111
|
}
|
|
108
112
|
return extractEach(inputs, (input) => buildDocgenPayload(input, { ...context, batchFiles }));
|
|
109
113
|
}
|
|
114
|
+
async function buildBasicDocgen(input, context = {}) {
|
|
115
|
+
let story = await resolveStory(input, context);
|
|
116
|
+
return story && {
|
|
117
|
+
id: getComponentIdFromEntry(input.entry),
|
|
118
|
+
path: story.storyFilePath,
|
|
119
|
+
...describeComponent({ entry: input.entry, ...story.resolved })
|
|
120
|
+
};
|
|
121
|
+
}
|
|
110
122
|
async function buildDocgenPayload(input, context) {
|
|
111
123
|
let story = await resolveStory(input, context);
|
|
112
124
|
if (!story)
|
|
@@ -129,5 +141,6 @@ async function buildDocgenPayload(input, context) {
|
|
|
129
141
|
|
|
130
142
|
export {
|
|
131
143
|
extractArgTypesFromComponentMeta,
|
|
132
|
-
buildDocgenPayloads
|
|
144
|
+
buildDocgenPayloads,
|
|
145
|
+
buildBasicDocgen
|
|
133
146
|
};
|
|
@@ -4203,7 +4203,6 @@ import * as path from "path";
|
|
|
4203
4203
|
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
4204
4204
|
|
|
4205
4205
|
// src/componentManifest/componentMeta/componentMetaExtractor.ts
|
|
4206
|
-
import { extractComponentJsDocInfo } from "storybook/internal/component-meta";
|
|
4207
4206
|
var LARGE_SOURCE_THRESHOLD = 30, MAX_UNWRAP_DEPTH = 5, MAX_SERIALIZATION_DEPTH = 5, ARRAY_SYMBOL_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
4208
4207
|
function isLiteralType(type) {
|
|
4209
4208
|
return type.isStringLiteral() || type.isNumberLiteral();
|
|
@@ -4843,19 +4842,13 @@ function serializeComponentDoc(typescript, checker, {
|
|
|
4843
4842
|
);
|
|
4844
4843
|
unionForceOptional?.has(prop.getName()) && (item.required = !1), props[prop.getName()] = item;
|
|
4845
4844
|
}
|
|
4846
|
-
let displayName = (isMemberSelection ? displayNameOverride : void 0) ?? computeDisplayName({
|
|
4847
|
-
exportSymbol,
|
|
4848
|
-
resolvedSymbol: resolved
|
|
4849
|
-
}) ?? displayNameOverride, resolvedJsDocInfo = extractComponentJsDocInfo(typescript, checker, resolved), description = resolvedJsDocInfo.description, selectedJsDocTags = resolvedJsDocInfo.jsDocTags, exportResolved = exportSymbol && exportSymbol !== resolved ? resolveAliasedSymbol(typescript, checker, exportSymbol) : void 0, exportJsDocTags = exportResolved ? extractComponentJsDocInfo(typescript, checker, exportResolved).jsDocTags : void 0, jsDocTags = selectedJsDocTags?.import || !exportJsDocTags?.import ? selectedJsDocTags : {
|
|
4850
|
-
...selectedJsDocTags ?? {},
|
|
4851
|
-
import: exportJsDocTags.import
|
|
4852
|
-
};
|
|
4853
4845
|
return {
|
|
4854
|
-
displayName
|
|
4846
|
+
displayName: (isMemberSelection ? displayNameOverride : void 0) ?? computeDisplayName({
|
|
4847
|
+
exportSymbol,
|
|
4848
|
+
resolvedSymbol: resolved
|
|
4849
|
+
}) ?? displayNameOverride,
|
|
4855
4850
|
exportName,
|
|
4856
4851
|
filePath,
|
|
4857
|
-
description,
|
|
4858
|
-
jsDocTags,
|
|
4859
4852
|
props
|
|
4860
4853
|
};
|
|
4861
4854
|
}
|
|
@@ -5002,7 +4995,7 @@ function extractEntries({ typescript, checker, program, resolveModule }, entries
|
|
|
5002
4995
|
resolvedComponent,
|
|
5003
4996
|
defaultsSourcePath: serializationContext.defaultsSourcePath
|
|
5004
4997
|
});
|
|
5005
|
-
doc && (entryComponent.reactComponentMeta = doc
|
|
4998
|
+
doc && (entryComponent.reactComponentMeta = doc);
|
|
5006
4999
|
} catch (error) {
|
|
5007
5000
|
logger2.debug(`[reactComponentMeta] Extraction failed for ${entry.storyPath}: ${error}`);
|
|
5008
5001
|
continue;
|
|
@@ -5304,13 +5297,17 @@ import {
|
|
|
5304
5297
|
walk
|
|
5305
5298
|
} from "storybook/internal/csf-tools";
|
|
5306
5299
|
import {
|
|
5300
|
+
SNIPPET_INDENT,
|
|
5307
5301
|
createHoleMarks,
|
|
5302
|
+
fitsOnLine,
|
|
5303
|
+
layOutWrittenTag,
|
|
5304
|
+
printOpeningTag,
|
|
5308
5305
|
stripHoles,
|
|
5309
5306
|
withHoleSpace
|
|
5310
5307
|
} from "storybook/internal/docs-tools";
|
|
5311
5308
|
|
|
5312
5309
|
// src/snippet-values.ts
|
|
5313
|
-
var unmarked = (_, text) => text, isAttributeName = (name) => /^[A-Za-z_][A-Za-z0-9_:-]*$/.test(name), isAttributeText = (text) => !/["&\r\n]/.test(text), isChildText = (text) => !/[{}<>&\r\n]
|
|
5310
|
+
var unmarked = (_, text) => text, isAttributeName = (name) => /^[A-Za-z_][A-Za-z0-9_:-]*$/.test(name), isAttributeText = (text) => !/["&\r\n]/.test(text), isChildText = (text) => !/[{}<>&\r\n]|^\s|\s$/.test(text), valueCode = (value) => value.kind === "boolean" ? String(value.value) : value.code, printAttribute = (name, value) => value.kind === "boolean" ? value.value ? name : `${name}={false}` : value.kind === "string" && isAttributeText(value.value) ? `${name}="${value.value}"` : `${name}={${value.code}}`, printAttributes = (args, mark = unmarked) => {
|
|
5314
5311
|
let unnamed = args.filter(([name]) => !isAttributeName(name)), attributes = args.filter(([name]) => isAttributeName(name)).map(([name, value]) => mark({ kind: "attr", arg: name }, printAttribute(name, value)));
|
|
5315
5312
|
if (unnamed.length !== 0) {
|
|
5316
5313
|
let members = unnamed.map(
|
|
@@ -5326,7 +5323,7 @@ function renderFunctionOf(resolution) {
|
|
|
5326
5323
|
return resolution.kind === "resolved" ? resolution.node : resolution.kind === "unresolved" ? resolution.shadowedRender : void 0;
|
|
5327
5324
|
}
|
|
5328
5325
|
function getCodeSnippet(csf, storyName, componentName, resolver = createStoryArgsResolver(csf)) {
|
|
5329
|
-
let { args, imports, unresolved } = resolver.resolve(storyName), importedBind = importedBoundStory(csf, storyName, args), sources = [csf.editor.code, ...Object.values(args).map(detachedTextOf)], marks = createHoleMarks(sources, (mark) => `/*${mark}*/`), marked = importedBind ? importedBind.print(marks.mark) : buildSnippet(csf, storyName, componentName, args, resolver, marks.mark), holes = marks.toTemplate(marked);
|
|
5326
|
+
let { args, imports, unresolved } = resolver.resolve(storyName), importedBind = importedBoundStory(csf, storyName, args), sources = [csf.editor.code, ...Object.values(args).map(detachedTextOf)], marks = createHoleMarks(sources, (mark) => `/*${mark}*/`), marked = importedBind ? importedBind.print(marks.mark) : buildSnippet(csf, storyName, componentName, args, resolver, marks.mark, marks.unmark), holes = marks.toTemplate(marked);
|
|
5330
5327
|
invariant(holes, "A place an arg prints was printed inside another.");
|
|
5331
5328
|
let template = withHoleSpace(
|
|
5332
5329
|
holes,
|
|
@@ -5367,7 +5364,7 @@ function importedBoundStory(csf, storyName, args) {
|
|
|
5367
5364
|
}
|
|
5368
5365
|
};
|
|
5369
5366
|
}
|
|
5370
|
-
function buildSnippet(csf, storyName, componentName, merged, resolver, mark) {
|
|
5367
|
+
function buildSnippet(csf, storyName, componentName, merged, resolver, mark, measure) {
|
|
5371
5368
|
let editor = csf.editor, storyDeclaration = csf._storyExports[storyName];
|
|
5372
5369
|
if (!storyDeclaration) {
|
|
5373
5370
|
let message = "Expected story to be a function or variable declaration", statement = csf.program.body.find(
|
|
@@ -5378,31 +5375,55 @@ function buildSnippet(csf, storyName, componentName, merged, resolver, mark) {
|
|
|
5378
5375
|
throw statement ? storyShapeError(message, statement, editor) : message;
|
|
5379
5376
|
}
|
|
5380
5377
|
let normalizedStory = normalizeStoryDeclaration(storyDeclaration, editor), storyFn = normalizedStory.type === "fn" ? normalizedStory.node : void 0, storyConfig = normalizedStory.type === "config" ? normalizedStory.node : void 0, metaRender = resolveRenderFunction(metaObject(csf), editor, resolver.ctx), storyRender = resolveRenderFunction(storyConfig, editor, resolver.ctx);
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5378
|
+
return storyFn || (storyFn = renderFunctionOf(storyRender) ?? (storyRender.kind === "missing" ? renderFunctionOf(metaRender) : void 0)), storyFn ? functionSnippet(
|
|
5379
|
+
editor.code,
|
|
5380
|
+
storyName,
|
|
5381
|
+
storyFn,
|
|
5382
|
+
isMethod(editor.parentOf(storyFn)),
|
|
5383
|
+
merged,
|
|
5384
|
+
mark,
|
|
5385
|
+
measure
|
|
5386
|
+
) : (invariant(componentName, "Could not generate snippet without component name."), synthesizedSnippet(storyName, componentName, merged, mark, measure));
|
|
5387
|
+
}
|
|
5388
|
+
function synthesizedSnippet(storyName, componentName, merged, mark, measure) {
|
|
5389
|
+
let declaration = `const ${storyName} = () => `, contentIndent = `${SNIPPET_INDENT}${SNIPPET_INDENT}`, print = valuePrinter(contentIndent), tag = {
|
|
5390
|
+
open: `<${componentName}`,
|
|
5391
|
+
attributes: [
|
|
5392
|
+
...injectedAttributes(merged, /* @__PURE__ */ new Set(), print, mark),
|
|
5393
|
+
(separator) => addedAttributes(
|
|
5394
|
+
injectedNames(merged, /* @__PURE__ */ new Set()),
|
|
5395
|
+
!!merged.children,
|
|
5396
|
+
mark,
|
|
5397
|
+
separator
|
|
5398
|
+
)
|
|
5399
|
+
],
|
|
5400
|
+
close: merged.children ? ">" : "/>"
|
|
5401
|
+
}, closing = `</${componentName}>`, content = merged.children ? childrenHole(merged.children, print, mark) : "", inline = `${printOpeningTag(tag, { broken: !1 }).text}${merged.children ? `${content}${closing}` : ""}`;
|
|
5402
|
+
if (fitsOnLine(measure(`${declaration}${inline};`)))
|
|
5403
|
+
return `${declaration}${inline};`;
|
|
5404
|
+
let opening = printOpeningTag(tag, { indent: SNIPPET_INDENT, measure }).text, line = `
|
|
5405
|
+
${contentIndent}`, children = merged.children ? `${childrenHole(merged.children, print, mark, { written: line, space: line })}
|
|
5406
|
+
${SNIPPET_INDENT}${closing}` : "";
|
|
5407
|
+
return `${declaration}(
|
|
5408
|
+
${SNIPPET_INDENT}${opening}${children}
|
|
5409
|
+
);`;
|
|
5393
5410
|
}
|
|
5394
5411
|
var isMethod = (parent) => parent?.type === "Property" && (parent.method || parent.kind !== "init");
|
|
5395
|
-
function functionSnippet(code, storyName, fn, method, merged, mark) {
|
|
5396
|
-
let asyncPrefix = fn.async ? "async " : "", params = fn.params.length ? code.slice(fn.params[0].start, fn.params[fn.params.length - 1].end) : "", edits = []
|
|
5412
|
+
function functionSnippet(code, storyName, fn, method, merged, mark, measure) {
|
|
5413
|
+
let asyncPrefix = fn.async ? "async " : "", params = fn.params.length ? code.slice(fn.params[0].start, fn.params[fn.params.length - 1].end) : "", edits = [], bodyStart = fn.body?.start ?? fn.start, layout = {
|
|
5414
|
+
measure,
|
|
5415
|
+
base: lineIndent(code, bodyStart),
|
|
5416
|
+
first: { start: bodyStart, prefix: `const ${storyName} = () => ` }
|
|
5417
|
+
};
|
|
5397
5418
|
if (fn.type === "ArrowFunctionExpression" && isJsx(fn.body)) {
|
|
5398
|
-
if (rewriteJsx(code, fn.body, merged, edits, mark)) {
|
|
5419
|
+
if (rewriteJsx(code, fn.body, merged, edits, mark, layout)) {
|
|
5399
5420
|
let body = printRange(code, fn.body, edits), kept = readsArgs(`${asyncPrefix}() => (${body});`) ? params : "";
|
|
5400
5421
|
return `const ${storyName} = ${asyncPrefix}(${kept}) => ${body};`;
|
|
5401
5422
|
}
|
|
5402
5423
|
} else if (fn.body?.type === "BlockStatement") {
|
|
5403
5424
|
let changed = !1;
|
|
5404
5425
|
for (let statement of fn.body.body)
|
|
5405
|
-
statement.type === "ReturnStatement" && isJsx(statement.argument) && (changed = rewriteJsx(code, statement.argument, merged, edits, mark) || changed);
|
|
5426
|
+
statement.type === "ReturnStatement" && isJsx(statement.argument) && (changed = rewriteJsx(code, statement.argument, merged, edits, mark, layout) || changed);
|
|
5406
5427
|
if (changed) {
|
|
5407
5428
|
let body = printRange(code, fn.body, edits), head = `${asyncPrefix}function${fn.generator ? "*" : ""}`, kept = readsArgs(`${head} f() ${body}`) ? params : "";
|
|
5408
5429
|
return fn.type === "FunctionDeclaration" ? `${asyncPrefix}function${fn.generator ? "*" : ""} ${storyName}(${kept}) ${body}` : `const ${storyName} = ${asyncPrefix}(${kept}) => ${body};`;
|
|
@@ -5426,30 +5447,79 @@ function readsArgs(source) {
|
|
|
5426
5447
|
var valuePrinter = (indent) => (node) => reindent(detachedTextOf(node), "", indent), toJsxValue = (node, print) => node.type === "Literal" && typeof node.value == "boolean" ? { kind: "boolean", value: node.value } : isStringLiteral(node) ? { kind: "string", value: node.value, code: print(node) } : { kind: isJsx(node) ? "jsx" : "code", code: print(node) }, toAttr = (key, value, print) => printAttribute(key, toJsxValue(value, print)), injectedArgs = (merged, existing) => Object.entries(merged).filter(([k, v]) => v != null && k !== "children" && !existing.has(k)), injectedNames = (merged, existing) => injectedArgs(merged, existing).map(([k]) => k), injectedAttributes = (merged, existing, print, mark) => printAttributes(
|
|
5427
5448
|
injectedArgs(merged, existing).map(([k, v]) => [k, toJsxValue(v, print)]),
|
|
5428
5449
|
mark
|
|
5429
|
-
), addedAttributes = (printed, hasContent, mark) => mark(
|
|
5430
|
-
{
|
|
5431
|
-
|
|
5432
|
-
|
|
5450
|
+
), addedAttributes = (printed, hasContent, mark, separator) => mark(
|
|
5451
|
+
{
|
|
5452
|
+
kind: "attrs",
|
|
5453
|
+
spread: !0,
|
|
5454
|
+
except: hasContent ? [...printed, "children"] : printed,
|
|
5455
|
+
separator
|
|
5456
|
+
},
|
|
5457
|
+
"",
|
|
5458
|
+
separator
|
|
5459
|
+
), childrenHole = (node, print, mark, { written, space } = { written: "", space: "" }) => mark({ kind: "text", arg: "children" }, `${written}${toJsxChildren(node, print)}`, space), toJsxChildren = (node, print) => node ? printChildren(toJsxValue(node, print)) : "";
|
|
5460
|
+
function layOutOpening(code, opening, spread, own, { measure, base, first }) {
|
|
5461
|
+
let close = opening.selfClosing ? "/>" : ">", closeStart = opening.end - close.length, nameEnd = (opening.typeArguments ?? opening.name).end, indent = lineIndent(code, opening.start), attributes = opening.attributes.flatMap((attribute, index) => {
|
|
5462
|
+
if (index === spread.index)
|
|
5463
|
+
return [
|
|
5464
|
+
...spread.attributes(`${indent}${SNIPPET_INDENT}`),
|
|
5465
|
+
(separator) => spread.added(
|
|
5466
|
+
separator.startsWith(`
|
|
5467
|
+
`) ? `
|
|
5468
|
+
${indent.slice(base.length)}${SNIPPET_INDENT}` : separator
|
|
5469
|
+
)
|
|
5470
|
+
];
|
|
5471
|
+
let removed = own.some(
|
|
5472
|
+
(edit) => edit.text === "" && edit.start < attribute.start && edit.end >= attribute.end
|
|
5473
|
+
), text2 = own.filter((edit) => edit.start >= attribute.start && edit.end <= attribute.end).sort((a, b) => b.start - a.start).reduce(
|
|
5474
|
+
(printed, edit) => printed.slice(0, edit.start - attribute.start) + edit.text + printed.slice(edit.end - attribute.start),
|
|
5475
|
+
code.slice(attribute.start, attribute.end)
|
|
5476
|
+
);
|
|
5477
|
+
return removed || text2 === "" ? [] : [text2];
|
|
5478
|
+
}), onFirstLine = code.lastIndexOf(`
|
|
5479
|
+
`, opening.start - 1) + 1 <= first.start, text = layOutWrittenTag(
|
|
5480
|
+
code,
|
|
5481
|
+
{ start: opening.start, nameEnd, closeStart, close },
|
|
5482
|
+
attributes,
|
|
5483
|
+
{
|
|
5484
|
+
measure,
|
|
5485
|
+
before: (written) => onFirstLine ? `${first.prefix}${code.slice(first.start, opening.start)}` : written.slice(base.length)
|
|
5486
|
+
}
|
|
5487
|
+
);
|
|
5488
|
+
return text === void 0 ? { edits: own } : {
|
|
5489
|
+
edits: [
|
|
5490
|
+
...own.filter((edit) => edit.start < nameEnd || edit.end > closeStart),
|
|
5491
|
+
{ start: nameEnd, end: closeStart, text }
|
|
5492
|
+
],
|
|
5493
|
+
broken: { indent, closeStart }
|
|
5494
|
+
};
|
|
5495
|
+
}
|
|
5433
5496
|
function getArgsMemberKey(expr) {
|
|
5434
5497
|
let member = expr.type === "ChainExpression" ? expr.expression : expr;
|
|
5435
5498
|
return member.type !== "MemberExpression" || member.object.type !== "Identifier" || member.object.name !== "args" ? null : member.property.type === "Identifier" && !member.computed ? member.property.name : isStringLiteral(member.property) && member.computed ? member.property.value : null;
|
|
5436
5499
|
}
|
|
5437
|
-
function rewriteJsx(code, node, merged, edits, mark) {
|
|
5500
|
+
function rewriteJsx(code, node, merged, edits, mark, layout) {
|
|
5438
5501
|
let changed = !1, printAt = (offset) => valuePrinter(lineIndent(code, offset));
|
|
5439
5502
|
if (node.type === "JSXElement") {
|
|
5440
|
-
let opening = node.openingElement, attrs = opening.attributes, isArgsSpread = (a) => a.type === "JSXSpreadAttribute" && a.argument.type === "Identifier" && a.argument.name === "args", firstSpread = attrs.findIndex(isArgsSpread), tagEnd = (opening.typeArguments ?? opening.name).end;
|
|
5503
|
+
let opening = node.openingElement, attrs = opening.attributes, isArgsSpread = (a) => a.type === "JSXSpreadAttribute" && a.argument.type === "Identifier" && a.argument.name === "args", firstSpread = attrs.findIndex(isArgsSpread), tagEnd = (opening.typeArguments ?? opening.name).end, elementEdits = edits.length, spread;
|
|
5441
5504
|
if (firstSpread !== -1) {
|
|
5442
5505
|
changed = !0;
|
|
5443
5506
|
let existing = new Set(
|
|
5444
5507
|
attrs.flatMap(
|
|
5445
5508
|
(a) => a.type === "JSXAttribute" && a.name.type === "JSXIdentifier" ? [a.name.name] : []
|
|
5446
5509
|
)
|
|
5447
|
-
),
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
mark
|
|
5451
|
-
|
|
5452
|
-
|
|
5510
|
+
), injected = injectedNames(merged, existing);
|
|
5511
|
+
spread = {
|
|
5512
|
+
index: firstSpread,
|
|
5513
|
+
attributes: (indent) => injectedAttributes(merged, existing, valuePrinter(indent), mark),
|
|
5514
|
+
added: (separator) => addedAttributes(
|
|
5515
|
+
[...existing, ...injected],
|
|
5516
|
+
!!merged.children || node.children.length > 0,
|
|
5517
|
+
mark,
|
|
5518
|
+
separator
|
|
5519
|
+
)
|
|
5520
|
+
};
|
|
5521
|
+
let pieces = spread.attributes(lineIndent(code, attrs[firstSpread].start)).join(" ") + spread.added(" ");
|
|
5522
|
+
attrs.forEach((a, index) => {
|
|
5453
5523
|
if (isArgsSpread(a))
|
|
5454
5524
|
if (index === firstSpread && injected.length > 0)
|
|
5455
5525
|
edits.push({ start: a.start, end: a.end, text: pieces });
|
|
@@ -5457,17 +5527,10 @@ function rewriteJsx(code, node, merged, edits, mark) {
|
|
|
5457
5527
|
let start = index > 0 ? attrs[index - 1].end : tagEnd;
|
|
5458
5528
|
edits.push({ start, end: a.end, text: index === firstSpread ? pieces : "" });
|
|
5459
5529
|
}
|
|
5460
|
-
})
|
|
5461
|
-
let name = code.slice(opening.name.start, opening.name.end), children = childrenHole(merged.children, printAt(opening.start), mark);
|
|
5462
|
-
if (opening.selfClosing) {
|
|
5463
|
-
let start = attrs.length > 0 ? attrs[attrs.length - 1].end : tagEnd;
|
|
5464
|
-
edits.push({ start, end: opening.end, text: `>${children}</${name}>` });
|
|
5465
|
-
} else
|
|
5466
|
-
edits.push({ start: opening.end, end: opening.end, text: children });
|
|
5467
|
-
}
|
|
5530
|
+
});
|
|
5468
5531
|
}
|
|
5469
5532
|
let lastSpread = attrs.findLastIndex(isArgsSpread);
|
|
5470
|
-
attrs.forEach((a, index) => {
|
|
5533
|
+
if (attrs.forEach((a, index) => {
|
|
5471
5534
|
if (a.type !== "JSXAttribute" || a.name.type !== "JSXIdentifier")
|
|
5472
5535
|
return;
|
|
5473
5536
|
let name = a.name.name, key = a.value?.type === "JSXExpressionContainer" ? getArgsMemberKey(a.value.expression) : null, arg = index < lastSpread ? name : key;
|
|
@@ -5479,11 +5542,31 @@ function rewriteJsx(code, node, merged, edits, mark) {
|
|
|
5479
5542
|
end: a.end,
|
|
5480
5543
|
text: mark({ kind: "attr", arg, ...arg !== name && { name } }, text)
|
|
5481
5544
|
}), changed ||= set;
|
|
5482
|
-
})
|
|
5545
|
+
}), spread) {
|
|
5546
|
+
let { edits: laidOut, broken } = layOutOpening(
|
|
5547
|
+
code,
|
|
5548
|
+
opening,
|
|
5549
|
+
spread,
|
|
5550
|
+
edits.splice(elementEdits),
|
|
5551
|
+
layout
|
|
5552
|
+
);
|
|
5553
|
+
if (edits.push(...laidOut), node.children.length === 0 && merged.children) {
|
|
5554
|
+
let name = code.slice(opening.name.start, opening.name.end), inner = broken && `${broken.indent}${SNIPPET_INDENT}`, children = inner ? `${childrenHole(merged.children, valuePrinter(inner), mark, {
|
|
5555
|
+
written: `
|
|
5556
|
+
${inner}`,
|
|
5557
|
+
space: `
|
|
5558
|
+
${inner.slice(layout.base.length)}`
|
|
5559
|
+
})}
|
|
5560
|
+
${broken.indent}` : childrenHole(merged.children, printAt(opening.start), mark), start = broken ? broken.closeStart : attrs.length > 0 ? attrs[attrs.length - 1].end : tagEnd;
|
|
5561
|
+
edits.push(
|
|
5562
|
+
opening.selfClosing ? { start, end: opening.end, text: `>${children}</${name}>` } : { start: opening.end, end: opening.end, text: children }
|
|
5563
|
+
);
|
|
5564
|
+
}
|
|
5565
|
+
}
|
|
5483
5566
|
}
|
|
5484
5567
|
for (let child of node.children)
|
|
5485
5568
|
if (isJsx(child))
|
|
5486
|
-
changed = rewriteJsx(code, child, merged, edits, mark) || changed;
|
|
5569
|
+
changed = rewriteJsx(code, child, merged, edits, mark, layout) || changed;
|
|
5487
5570
|
else if (child.type === "JSXExpressionContainer") {
|
|
5488
5571
|
let key = getArgsMemberKey(child.expression);
|
|
5489
5572
|
if (key === null)
|
|
@@ -5500,10 +5583,6 @@ function rewriteJsx(code, node, merged, edits, mark) {
|
|
|
5500
5583
|
|
|
5501
5584
|
// src/componentManifest/reactDocgenTypescript.ts
|
|
5502
5585
|
import { dirname as dirname3, join as join2, resolve } from "node:path";
|
|
5503
|
-
import {
|
|
5504
|
-
extractComponentJsDocInfo as extractComponentJsDocInfo2,
|
|
5505
|
-
resolveExportedSymbol
|
|
5506
|
-
} from "storybook/internal/component-meta";
|
|
5507
5586
|
import { logger as logger4 } from "storybook/internal/node-logger";
|
|
5508
5587
|
var typeScriptPromise, reactDocgenTypescriptPromise, loadTypeScript = () => typeScriptPromise ??= import("typescript").then((ts) => ts.default ?? ts), loadReactDocgenTypescript = () => reactDocgenTypescriptPromise ??= import("react-docgen-typescript"), LARGE_NON_USER_SOURCE_THRESHOLD = 30, getPropSource = (prop) => prop.parent?.fileName ?? prop.declarations?.[0]?.fileName, getLargeNonUserPropSources = (props) => {
|
|
5509
5588
|
let countBySource = /* @__PURE__ */ new Map();
|
|
@@ -5635,11 +5714,10 @@ var parseWithReactDocgenTypescript = asyncCache(
|
|
|
5635
5714
|
async (filePath, userOptions) => {
|
|
5636
5715
|
let { program, fileParser, typescript } = await getParser(filePath, userOptions), checker = program.getTypeChecker(), sourceFile = program.getSourceFile(filePath), docs = fileParser.parseWithProgramProvider(filePath, () => program), exportNameMap = sourceFile ? getExportNameMap(typescript, checker, sourceFile) : /* @__PURE__ */ new Map();
|
|
5637
5716
|
return docs.map((doc) => {
|
|
5638
|
-
let largeNonUserSources = getLargeNonUserPropSources(doc.props), exportName = exportNameMap.get(doc.displayName) ?? doc.displayName
|
|
5717
|
+
let largeNonUserSources = getLargeNonUserPropSources(doc.props), exportName = exportNameMap.get(doc.displayName) ?? doc.displayName;
|
|
5639
5718
|
return {
|
|
5640
5719
|
...doc,
|
|
5641
5720
|
exportName,
|
|
5642
|
-
componentJsDocTags,
|
|
5643
5721
|
// Filter out bulk props from non-user sources (React built-ins, DOM, CSS-in-JS system props)
|
|
5644
5722
|
props: Object.fromEntries(
|
|
5645
5723
|
Object.entries(doc.props).filter(([, prop]) => {
|
|
@@ -5712,10 +5790,9 @@ function normalizeFileName(typescript, fileName) {
|
|
|
5712
5790
|
|
|
5713
5791
|
// src/componentManifest/resolveComponents.ts
|
|
5714
5792
|
import {
|
|
5715
|
-
createMetaComponentResolver,
|
|
5716
|
-
createModuleResolver,
|
|
5717
5793
|
extractDeclaredSubcomponents,
|
|
5718
|
-
|
|
5794
|
+
readDeclarationDocs as readDeclarationDocs2,
|
|
5795
|
+
resolveFileOrUndefined
|
|
5719
5796
|
} from "storybook/internal/common";
|
|
5720
5797
|
import { storyNameFromExport } from "storybook/internal/csf/csf-utils";
|
|
5721
5798
|
import {
|
|
@@ -5734,7 +5811,15 @@ import {
|
|
|
5734
5811
|
resolveComponentImport,
|
|
5735
5812
|
walk as walk2
|
|
5736
5813
|
} from "storybook/internal/csf-tools";
|
|
5737
|
-
import {
|
|
5814
|
+
import {
|
|
5815
|
+
createDocsModuleResolver,
|
|
5816
|
+
createMetaComponentResolver,
|
|
5817
|
+
createModuleResolver,
|
|
5818
|
+
followExport,
|
|
5819
|
+
isModuleNotFoundError as isModuleNotFoundError3,
|
|
5820
|
+
readDeclarationDocs,
|
|
5821
|
+
supportedExtensions
|
|
5822
|
+
} from "storybook/internal/common";
|
|
5738
5823
|
import { logger as logger6 } from "storybook/internal/node-logger";
|
|
5739
5824
|
|
|
5740
5825
|
// src/componentManifest/loadReactDocgen.ts
|
|
@@ -5770,7 +5855,34 @@ var isReactDocgenTypescriptResolvable = () => {
|
|
|
5770
5855
|
} catch {
|
|
5771
5856
|
return !1;
|
|
5772
5857
|
}
|
|
5773
|
-
}, baseIdentifier = (component) => component.split(".")[0] ?? component,
|
|
5858
|
+
}, baseIdentifier = (component) => component.split(".")[0] ?? component, followWith = (resolver) => {
|
|
5859
|
+
let reader = { resolver };
|
|
5860
|
+
return { reader, resolveMetaComponent: createMetaComponentResolver({ reader }) };
|
|
5861
|
+
}, followers = {
|
|
5862
|
+
// react-docgen and react-docgen-typescript document the source. Extensions are tried in the order
|
|
5863
|
+
// React's own lookup does, `.js` first as Vite does, so when `ui.js` sits next to `ui.tsx` both
|
|
5864
|
+
// pick the same file.
|
|
5865
|
+
source: followWith(
|
|
5866
|
+
createModuleResolver({
|
|
5867
|
+
extensions: [...supportedExtensions],
|
|
5868
|
+
extensionAlias: {
|
|
5869
|
+
".js": [".js", ".ts", ".tsx"],
|
|
5870
|
+
".jsx": [".jsx", ".tsx"],
|
|
5871
|
+
".mjs": [".mjs", ".mts"],
|
|
5872
|
+
".cjs": [".cjs", ".cts"]
|
|
5873
|
+
},
|
|
5874
|
+
mainFields: ["module", "main"],
|
|
5875
|
+
tsconfig: "auto"
|
|
5876
|
+
})
|
|
5877
|
+
),
|
|
5878
|
+
// react-component-meta documents what TypeScript does: the declaration file of a package.
|
|
5879
|
+
types: followWith(createDocsModuleResolver())
|
|
5880
|
+
};
|
|
5881
|
+
function readExportDocs(reader, filePath, exportName) {
|
|
5882
|
+
let origin = followExport(reader, filePath, exportName);
|
|
5883
|
+
return origin?.kind === "declaration" ? readDeclarationDocs({ path: origin.filePath, exportName: origin.exportName }) : void 0;
|
|
5884
|
+
}
|
|
5885
|
+
var getComponents = async ({
|
|
5774
5886
|
csf,
|
|
5775
5887
|
storyFilePath,
|
|
5776
5888
|
typescriptOptions = {},
|
|
@@ -5836,13 +5948,17 @@ var isReactDocgenTypescriptResolvable = () => {
|
|
|
5836
5948
|
} : componentWithPackage, docgenPath = target?.path ?? path2;
|
|
5837
5949
|
if (path2 ??= docgenPath, path2 && docgenPath) {
|
|
5838
5950
|
if (docgenEngine === "react-docgen-typescript") {
|
|
5839
|
-
let reactDocgenTypescript, reactDocgenTypescriptError;
|
|
5951
|
+
let reactDocgenTypescript, reactDocgenTypescriptError, jsDoc;
|
|
5840
5952
|
try {
|
|
5841
5953
|
let docs = await parseWithReactDocgenTypescript(
|
|
5842
5954
|
docgenPath,
|
|
5843
5955
|
reactDocgenTypescriptOptions
|
|
5844
5956
|
);
|
|
5845
|
-
reactDocgenTypescript = matchComponentDoc(docs, docgenRef),
|
|
5957
|
+
reactDocgenTypescript = matchComponentDoc(docs, docgenRef), jsDoc = reactDocgenTypescript && readExportDocs(
|
|
5958
|
+
followers.source.reader,
|
|
5959
|
+
docgenPath,
|
|
5960
|
+
reactDocgenTypescript.exportName
|
|
5961
|
+
), reactDocgenTypescript || (reactDocgenTypescriptError = getReactDocgenTypescriptError(
|
|
5846
5962
|
docgenPath,
|
|
5847
5963
|
docgenRef,
|
|
5848
5964
|
docs
|
|
@@ -5855,18 +5971,13 @@ var isReactDocgenTypescriptResolvable = () => {
|
|
|
5855
5971
|
${message}`
|
|
5856
5972
|
};
|
|
5857
5973
|
}
|
|
5858
|
-
let reactDocgenTypescriptDoc, componentJsDocTags = reactDocgenTypescript?.componentJsDocTags;
|
|
5859
|
-
if (reactDocgenTypescript) {
|
|
5860
|
-
let { componentJsDocTags: _tags, ...doc } = reactDocgenTypescript;
|
|
5861
|
-
reactDocgenTypescriptDoc = doc, componentJsDocTags = _tags;
|
|
5862
|
-
}
|
|
5863
5974
|
return {
|
|
5864
5975
|
...componentWithPackage,
|
|
5865
5976
|
path: path2,
|
|
5866
|
-
...
|
|
5977
|
+
...reactDocgenTypescript ? { reactDocgenTypescript } : {},
|
|
5867
5978
|
...reactDocgenTypescriptError ? { reactDocgenTypescriptError } : {},
|
|
5868
|
-
...
|
|
5869
|
-
importOverride:
|
|
5979
|
+
...jsDoc ? { jsDoc } : {},
|
|
5980
|
+
importOverride: jsDoc?.tags.import?.[0]?.trim()
|
|
5870
5981
|
};
|
|
5871
5982
|
}
|
|
5872
5983
|
if (docgenEngine === "react-docgen") {
|
|
@@ -5896,21 +6007,6 @@ function findExactComponentMatch(components, componentName) {
|
|
|
5896
6007
|
}
|
|
5897
6008
|
|
|
5898
6009
|
// src/componentManifest/resolveComponents.ts
|
|
5899
|
-
var resolveMetaComponent = createMetaComponentResolver({
|
|
5900
|
-
reader: {
|
|
5901
|
-
resolver: createModuleResolver({
|
|
5902
|
-
extensions: [...supportedExtensions],
|
|
5903
|
-
extensionAlias: {
|
|
5904
|
-
".js": [".js", ".ts", ".tsx"],
|
|
5905
|
-
".jsx": [".jsx", ".tsx"],
|
|
5906
|
-
".mjs": [".mjs", ".mts"],
|
|
5907
|
-
".cjs": [".cjs", ".cts"]
|
|
5908
|
-
},
|
|
5909
|
-
mainFields: ["module", "main"],
|
|
5910
|
-
tsconfig: "auto"
|
|
5911
|
-
})
|
|
5912
|
-
}
|
|
5913
|
-
});
|
|
5914
6010
|
function findMatchingComponent(components, componentName, title) {
|
|
5915
6011
|
let exactMatch = findExactComponentMatch(components, componentName);
|
|
5916
6012
|
if (exactMatch)
|
|
@@ -5929,14 +6025,14 @@ function findMatchingComponent(components, componentName, title) {
|
|
|
5929
6025
|
return best;
|
|
5930
6026
|
}
|
|
5931
6027
|
async function resolveStoryFileComponents(options) {
|
|
5932
|
-
let { storyPath, title, typescriptOptions, docgenEngine } = options, storyFile = cachedReadTextFileSync(storyPath), csf = loadCsf(storyFile, { makeTitle: () => title, fileName: storyPath }).parse(), componentName = csf._meta?.component, declaredSubcomponents = extractDeclaredSubcomponents(csf), docgenTargets = /* @__PURE__ */ new Map(), storyImports = collectImportBindings3(csf.editor.program), resolveName = (name, node) => {
|
|
6028
|
+
let { storyPath, title, typescriptOptions, docgenEngine } = options, { reader, resolveMetaComponent } = docgenEngine === "react-component-meta" ? followers.types : followers.source, { resolver } = reader, storyFile = cachedReadTextFileSync(storyPath), csf = loadCsf(storyFile, { makeTitle: () => title, fileName: storyPath }).parse(), componentName = csf._meta?.component, declaredSubcomponents = extractDeclaredSubcomponents(csf), declarations = /* @__PURE__ */ new Map(), docgenTargets = /* @__PURE__ */ new Map(), storyImports = collectImportBindings3(csf.editor.program), resolveName = (name, node) => {
|
|
5933
6029
|
let resolved = resolveMetaComponent(csf, storyPath, node);
|
|
5934
6030
|
if ("reason" in resolved)
|
|
5935
6031
|
return resolved.reason === "missing-export" && docgenTargets.set(name, {
|
|
5936
6032
|
missing: `"${resolved.importId}" has no export "${resolved.exportName}", which ${resolved.expression} reads.`
|
|
5937
6033
|
}), name;
|
|
5938
6034
|
let { localName, importId, importer, path: path2, exportName } = resolved.component, ownName = importer === storyPath && storyImports.get(localName)?.importId === importId && !storyImports.has(name.split(".")[0]) ? localName : name;
|
|
5939
|
-
return importId && path2 && docgenTargets.set(ownName, { path: path2, exportName }), ownName;
|
|
6035
|
+
return declarations.set(ownName, resolved.component), importId && path2 && docgenTargets.set(ownName, { path: path2, exportName }), ownName;
|
|
5940
6036
|
}, metaComponentName = componentName && resolveName(componentName), declared = declaredSubcomponents.map((subcomponent) => ({
|
|
5941
6037
|
name: subcomponent.name,
|
|
5942
6038
|
componentName: resolveName(subcomponent.componentName, subcomponent.node)
|
|
@@ -5954,6 +6050,20 @@ async function resolveStoryFileComponents(options) {
|
|
|
5954
6050
|
name: subcomponent.name,
|
|
5955
6051
|
component: findExactComponentMatch(allComponents, subcomponent.componentName)
|
|
5956
6052
|
}));
|
|
6053
|
+
if (docgenEngine === "react-component-meta") {
|
|
6054
|
+
let readImportDocs = (ref) => {
|
|
6055
|
+
let filePath = ref.importId && resolveFileOrUndefined(resolver, storyPath, ref.importId);
|
|
6056
|
+
return filePath && ref.importName ? readExportDocs(reader, filePath, ref.importName) : void 0;
|
|
6057
|
+
};
|
|
6058
|
+
for (let ref of /* @__PURE__ */ new Set([component, ...subcomponents.map((sub) => sub.component)])) {
|
|
6059
|
+
if (!ref)
|
|
6060
|
+
continue;
|
|
6061
|
+
let isMemberOfImport = !!ref.member && !ref.namespace, declaration = declarations.get(ref.componentName);
|
|
6062
|
+
declaration?.path ? ref.jsDoc = readDeclarationDocs2(declaration) : !declaration && !isMemberOfImport && (ref.jsDoc = readImportDocs(ref));
|
|
6063
|
+
let importTag = ref.jsDoc?.tags.import ?? (ref.member ? readImportDocs(ref)?.tags.import : void 0);
|
|
6064
|
+
ref.importOverride = importTag?.[0]?.trim();
|
|
6065
|
+
}
|
|
6066
|
+
}
|
|
5957
6067
|
return { storyPath, storyFile, csf, componentName, allComponents, component, subcomponents };
|
|
5958
6068
|
}
|
|
5959
6069
|
function extractStorySnippets(csf, componentName, filterStoryIds, references, withTemplate = !1) {
|
|
@@ -6047,19 +6157,18 @@ function relativizeComponentMetaPaths(doc) {
|
|
|
6047
6157
|
)
|
|
6048
6158
|
};
|
|
6049
6159
|
}
|
|
6160
|
+
var getJsDoc = (component) => component?.jsDoc ?? (component?.reactDocgen?.type === "success" ? { description: component.reactDocgen.data.description, tags: void 0 } : void 0);
|
|
6050
6161
|
function getComponentDocgenData(component, docgenEngine) {
|
|
6051
|
-
let reactDocgen, reactDocgenTypescript, reactComponentMeta,
|
|
6162
|
+
let reactDocgen, reactDocgenTypescript, reactComponentMeta, docgenError;
|
|
6052
6163
|
if (docgenEngine === "react-docgen") {
|
|
6053
6164
|
let result = component?.reactDocgen;
|
|
6054
|
-
reactDocgen = result?.type === "success" ? { ...result.data, definedInFile: relativize(result.data.definedInFile) } : void 0,
|
|
6165
|
+
reactDocgen = result?.type === "success" ? { ...result.data, definedInFile: relativize(result.data.definedInFile) } : void 0, docgenError = result?.type === "error" ? result.error : void 0;
|
|
6055
6166
|
} else docgenEngine === "react-docgen-typescript" ? (reactDocgenTypescript = component?.reactDocgenTypescript && {
|
|
6056
6167
|
...component.reactDocgenTypescript,
|
|
6057
6168
|
filePath: relativize(component.reactDocgenTypescript.filePath)
|
|
6058
|
-
},
|
|
6169
|
+
}, docgenError = component?.reactDocgenTypescriptError) : reactComponentMeta = component?.reactComponentMeta ? relativizeComponentMetaPaths(component.reactComponentMeta) : void 0;
|
|
6059
6170
|
return {
|
|
6060
|
-
docgenDescription,
|
|
6061
6171
|
docgenError,
|
|
6062
|
-
docgenJsDocTags,
|
|
6063
6172
|
reactComponentMeta,
|
|
6064
6173
|
reactDocgen,
|
|
6065
6174
|
reactDocgenTypescript
|
|
@@ -6074,17 +6183,10 @@ function createSubcomponentDocgen({
|
|
|
6074
6183
|
storyFilePath
|
|
6075
6184
|
}) {
|
|
6076
6185
|
let imports = buildImportStatements2({ refs: component ? [component] : [], packageName }).join(`
|
|
6077
|
-
`).trim() || getFallbackImport(packageName, component?.componentName), {
|
|
6078
|
-
reactDocgen,
|
|
6079
|
-
reactDocgenTypescript,
|
|
6080
|
-
reactComponentMeta,
|
|
6081
|
-
docgenDescription,
|
|
6082
|
-
docgenJsDocTags,
|
|
6083
|
-
docgenError
|
|
6084
|
-
} = getComponentDocgenData(component, docgenEngine), { description, summary, jsDocTags } = extractComponentDescription(
|
|
6186
|
+
`).trim() || getFallbackImport(packageName, component?.componentName), { reactDocgen, reactDocgenTypescript, reactComponentMeta, docgenError } = getComponentDocgenData(component, docgenEngine), jsDoc = getJsDoc(component), { description, summary, jsDocTags } = extractComponentDescription(
|
|
6085
6187
|
void 0,
|
|
6086
|
-
|
|
6087
|
-
|
|
6188
|
+
jsDoc?.description,
|
|
6189
|
+
jsDoc?.tags
|
|
6088
6190
|
);
|
|
6089
6191
|
return {
|
|
6090
6192
|
name: declaredName,
|
|
@@ -6102,6 +6204,22 @@ function createSubcomponentDocgen({
|
|
|
6102
6204
|
})
|
|
6103
6205
|
};
|
|
6104
6206
|
}
|
|
6207
|
+
function describeComponent({
|
|
6208
|
+
entry,
|
|
6209
|
+
csf,
|
|
6210
|
+
componentName,
|
|
6211
|
+
component
|
|
6212
|
+
}) {
|
|
6213
|
+
let jsDoc = getJsDoc(component);
|
|
6214
|
+
return {
|
|
6215
|
+
name: componentName ?? entry.title.split("/").at(-1).replace(/\s+/g, ""),
|
|
6216
|
+
...extractComponentDescription(
|
|
6217
|
+
extractDescription(csf._metaStatement, csf.editor) || void 0,
|
|
6218
|
+
jsDoc?.description,
|
|
6219
|
+
jsDoc?.tags
|
|
6220
|
+
)
|
|
6221
|
+
};
|
|
6222
|
+
}
|
|
6105
6223
|
function buildStoryDocsFromResolved({
|
|
6106
6224
|
entry,
|
|
6107
6225
|
storyPath,
|
|
@@ -6143,19 +6261,11 @@ function buildComponentDocgenFromResolved({
|
|
|
6143
6261
|
subcomponents,
|
|
6144
6262
|
docgenEngine
|
|
6145
6263
|
}) {
|
|
6146
|
-
let
|
|
6147
|
-
id,
|
|
6148
|
-
name: componentName ?? title,
|
|
6264
|
+
let packageName = getImportablePackageName(component?.path, storyPath), base = {
|
|
6265
|
+
id: getComponentIdFromEntry(entry),
|
|
6149
6266
|
path: storyFilePath,
|
|
6150
|
-
|
|
6151
|
-
}, {
|
|
6152
|
-
reactDocgen,
|
|
6153
|
-
reactDocgenTypescript,
|
|
6154
|
-
reactComponentMeta,
|
|
6155
|
-
docgenDescription,
|
|
6156
|
-
docgenJsDocTags,
|
|
6157
|
-
docgenError
|
|
6158
|
-
} = getComponentDocgenData(component, docgenEngine);
|
|
6267
|
+
...describeComponent({ entry, csf, componentName, component })
|
|
6268
|
+
}, { reactDocgen, reactDocgenTypescript, reactComponentMeta, docgenError } = getComponentDocgenData(component, docgenEngine);
|
|
6159
6269
|
if (!reactDocgen && !reactDocgenTypescript && !reactComponentMeta) {
|
|
6160
6270
|
let error = csf._meta?.component ? {
|
|
6161
6271
|
name: "No component import found",
|
|
@@ -6166,7 +6276,6 @@ function buildComponentDocgenFromResolved({
|
|
|
6166
6276
|
};
|
|
6167
6277
|
return {
|
|
6168
6278
|
...base,
|
|
6169
|
-
jsDocTags: base.jsDocTags ?? {},
|
|
6170
6279
|
error: docgenError ?? {
|
|
6171
6280
|
name: error.name,
|
|
6172
6281
|
message: (csf._metaStatement ? storyShapeError2(error.message, csf._metaStatement, csf.editor).message : error.message) + `
|
|
@@ -6176,11 +6285,7 @@ ${storyFile}`
|
|
|
6176
6285
|
}
|
|
6177
6286
|
};
|
|
6178
6287
|
}
|
|
6179
|
-
let
|
|
6180
|
-
metaJsDoc,
|
|
6181
|
-
docgenDescription,
|
|
6182
|
-
docgenJsDocTags
|
|
6183
|
-
), subcomponentEntries = Object.fromEntries(
|
|
6288
|
+
let subcomponentEntries = Object.fromEntries(
|
|
6184
6289
|
subcomponents.map((subcomponent) => [
|
|
6185
6290
|
subcomponent.name,
|
|
6186
6291
|
createSubcomponentDocgen({
|
|
@@ -6195,12 +6300,9 @@ ${storyFile}`
|
|
|
6195
6300
|
);
|
|
6196
6301
|
return {
|
|
6197
6302
|
...base,
|
|
6198
|
-
description,
|
|
6199
|
-
summary,
|
|
6200
6303
|
reactDocgen,
|
|
6201
6304
|
reactDocgenTypescript,
|
|
6202
6305
|
reactComponentMeta,
|
|
6203
|
-
jsDocTags,
|
|
6204
6306
|
...Object.keys(subcomponentEntries).length > 0 ? { subcomponents: subcomponentEntries } : {},
|
|
6205
6307
|
error: docgenError
|
|
6206
6308
|
};
|
|
@@ -6250,6 +6352,7 @@ export {
|
|
|
6250
6352
|
getCodeSnippet,
|
|
6251
6353
|
invalidateParser,
|
|
6252
6354
|
resolveStoryFileComponents,
|
|
6355
|
+
describeComponent,
|
|
6253
6356
|
buildStoryDocsFromResolved,
|
|
6254
6357
|
buildComponentDocgenFromResolved,
|
|
6255
6358
|
buildReactComponentDocgenFromResolved,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSharedComponentMetaManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6DVQPLAK.js";
|
|
4
4
|
import {
|
|
5
5
|
extractArgTypesFromComponentMeta
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-PVKC5GIW.js";
|
|
7
|
+
import "./chunk-ZGMTV3ZQ.js";
|
|
8
8
|
import "./chunk-MYBSMCSW.js";
|
|
9
9
|
import "./chunk-M3SEC5XW.js";
|
|
10
10
|
import "./chunk-SC3QXTHH.js";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
buildBasicDocgen,
|
|
2
3
|
buildDocgenPayloads
|
|
3
|
-
} from "../_node-chunks/chunk-
|
|
4
|
+
} from "../_node-chunks/chunk-PVKC5GIW.js";
|
|
4
5
|
import {
|
|
5
6
|
ComponentMetaManager,
|
|
6
7
|
loadDocgenTypeScript
|
|
7
|
-
} from "../_node-chunks/chunk-
|
|
8
|
+
} from "../_node-chunks/chunk-ZGMTV3ZQ.js";
|
|
8
9
|
import "../_node-chunks/chunk-MYBSMCSW.js";
|
|
9
10
|
import "../_node-chunks/chunk-M3SEC5XW.js";
|
|
10
11
|
import "../_node-chunks/chunk-SC3QXTHH.js";
|
|
@@ -31,6 +32,7 @@ var createDocgenProvider = ({
|
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
34
|
},
|
|
35
|
+
extractBasic: (input) => buildBasicDocgen(input),
|
|
34
36
|
extractBatch: (componentMetaManager, inputs) => buildDocgenPayloads(inputs, { componentMetaManager })
|
|
35
37
|
});
|
|
36
38
|
export {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "../_browser-chunks/chunk-
|
|
1
|
+
import "../_browser-chunks/chunk-VG7VCVF3.js";
|
|
2
2
|
import "../_browser-chunks/chunk-UAWMPV5J.js";
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
decorators,
|
|
4
4
|
parameters
|
|
5
5
|
} from "./_browser-chunks/chunk-GBFPEOJZ.js";
|
|
6
|
-
import "./_browser-chunks/chunk-
|
|
6
|
+
import "./_browser-chunks/chunk-VG7VCVF3.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/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
entry_preview_argtypes_exports
|
|
10
10
|
} from "./_browser-chunks/chunk-WWHCZJWM.js";
|
|
11
11
|
import "./_browser-chunks/chunk-GBFPEOJZ.js";
|
|
12
|
-
import "./_browser-chunks/chunk-
|
|
12
|
+
import "./_browser-chunks/chunk-VG7VCVF3.js";
|
|
13
13
|
import "./_browser-chunks/chunk-DDIRQRCA.js";
|
|
14
14
|
import "./_browser-chunks/chunk-B3FR4PBN.js";
|
|
15
15
|
import "./_browser-chunks/chunk-UAWMPV5J.js";
|
package/dist/preset.js
CHANGED
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
} from "./_node-chunks/chunk-HRHJMJC7.js";
|
|
4
4
|
import {
|
|
5
5
|
getSharedComponentMetaManager
|
|
6
|
-
} from "./_node-chunks/chunk-
|
|
6
|
+
} from "./_node-chunks/chunk-6DVQPLAK.js";
|
|
7
7
|
import {
|
|
8
8
|
buildReactComponentDocgenFromResolved,
|
|
9
9
|
buildStoryDocsFromResolved,
|
|
10
10
|
getCodeSnippet,
|
|
11
11
|
invalidateParser,
|
|
12
12
|
resolveStoryFileComponents
|
|
13
|
-
} from "./_node-chunks/chunk-
|
|
13
|
+
} from "./_node-chunks/chunk-ZGMTV3ZQ.js";
|
|
14
14
|
import {
|
|
15
15
|
REACT_DOCGEN_TYPESCRIPT_APIS
|
|
16
16
|
} from "./_node-chunks/chunk-MYBSMCSW.js";
|
|
@@ -384,7 +384,7 @@ async function internal_getArgTypesData(_input, options) {
|
|
|
384
384
|
return null;
|
|
385
385
|
let absoluteComponentFilePath = path2.isAbsolute(componentFilePath) ? componentFilePath : join3(getProjectRoot(), componentFilePath);
|
|
386
386
|
if ((await presets?.apply("features", {}))?.docgenServer) {
|
|
387
|
-
let { extractArgTypesFromComponentFile } = await import("./_node-chunks/extractArgTypesFromComponentFile-
|
|
387
|
+
let { extractArgTypesFromComponentFile } = await import("./_node-chunks/extractArgTypesFromComponentFile-2KTCTT6A.js");
|
|
388
388
|
return extractArgTypesFromComponentFile({
|
|
389
389
|
componentFilePath: absoluteComponentFilePath,
|
|
390
390
|
componentExportName,
|
package/dist/preview.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import "./_browser-chunks/chunk-MB4PPIXP.js";
|
|
5
5
|
import "./_browser-chunks/chunk-WWHCZJWM.js";
|
|
6
6
|
import "./_browser-chunks/chunk-GBFPEOJZ.js";
|
|
7
|
-
import "./_browser-chunks/chunk-
|
|
7
|
+
import "./_browser-chunks/chunk-VG7VCVF3.js";
|
|
8
8
|
import "./_browser-chunks/chunk-DDIRQRCA.js";
|
|
9
9
|
import "./_browser-chunks/chunk-B3FR4PBN.js";
|
|
10
10
|
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-rc.
|
|
3
|
+
"version": "11.0.0-rc.4",
|
|
4
4
|
"description": "Storybook React renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"!src/**/*"
|
|
55
55
|
],
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@storybook/component-meta-typescript": "11.0.0-rc.
|
|
57
|
+
"@storybook/component-meta-typescript": "11.0.0-rc.4",
|
|
58
58
|
"@types/babel-plugin-react-docgen": "^4.2.3",
|
|
59
59
|
"@types/escodegen": "^0.0.6",
|
|
60
60
|
"@types/estree": "^1.0.6",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"react-docgen": "^8.0.2",
|
|
89
89
|
"react-docgen-typescript": "^2.2.2",
|
|
90
90
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
91
|
-
"storybook": "^11.0.0-rc.
|
|
91
|
+
"storybook": "^11.0.0-rc.4",
|
|
92
92
|
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
|
|
93
93
|
},
|
|
94
94
|
"peerDependenciesMeta": {
|