@storybook/react 11.0.0-alpha.8 → 11.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ynn8fkacxge from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ynn8fkacxge from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ynn8fkacxge from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ynn8fkacxge.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ynn8fkacxge.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ynn8fkacxge.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -14097,12 +14097,6 @@ function createReactProjectFactory(typescript) {
|
|
|
14097
14097
|
}
|
|
14098
14098
|
};
|
|
14099
14099
|
}
|
|
14100
|
-
function assertTypeScriptCompilerApi(typescript) {
|
|
14101
|
-
if (typeof typescript?.sys?.fileExists != "function")
|
|
14102
|
-
throw new Error(
|
|
14103
|
-
"The resolved `typescript` package does not expose the compiler API (`ts.sys` is undefined). This happens when `typescript` resolves to a build without the full API, such as the TypeScript 7 native-preview package. Component metadata extraction requires a standard TypeScript installation."
|
|
14104
|
-
);
|
|
14105
|
-
}
|
|
14106
14100
|
var ComponentMetaManager = class extends BaseComponentMetaManager {
|
|
14107
14101
|
/**
|
|
14108
14102
|
* @param recycleHeapPressureRatio Fraction of the V8 heap limit at which the shared program(s)
|
|
@@ -14110,7 +14104,6 @@ var ComponentMetaManager = class extends BaseComponentMetaManager {
|
|
|
14110
14104
|
* to disable recycling and assert the OOM still happens without the fix.
|
|
14111
14105
|
*/
|
|
14112
14106
|
constructor(typescript, recycleHeapPressureRatio) {
|
|
14113
|
-
assertTypeScriptCompilerApi(typescript);
|
|
14114
14107
|
let { factory, fsFileSnapshots } = createReactProjectFactory(typescript);
|
|
14115
14108
|
super(typescript, factory, recycleHeapPressureRatio), this.fsFileSnapshots = fsFileSnapshots;
|
|
14116
14109
|
}
|
|
@@ -15985,13 +15978,13 @@ import {
|
|
|
15985
15978
|
textOf,
|
|
15986
15979
|
collectImportBindings,
|
|
15987
15980
|
createStoryArgsResolver,
|
|
15981
|
+
detachedTextOf,
|
|
15988
15982
|
isCanonicalCsf2BindCall,
|
|
15989
15983
|
isStringLiteral,
|
|
15990
15984
|
lineIndent,
|
|
15991
15985
|
metaObject,
|
|
15992
15986
|
normalizeStoryDeclaration,
|
|
15993
15987
|
parseModule as parseModule2,
|
|
15994
|
-
placeableTextOf,
|
|
15995
15988
|
reindent,
|
|
15996
15989
|
resolveRenderFunction,
|
|
15997
15990
|
storyShapeError,
|
|
@@ -16019,8 +16012,8 @@ function importedBoundStory(csf, storyName, args) {
|
|
|
16019
16012
|
let local = declaration.init.callee.object.name, binding = collectImportBindings(csf.program).get(local);
|
|
16020
16013
|
if (!binding)
|
|
16021
16014
|
return;
|
|
16022
|
-
let values = Object.entries(args).map(
|
|
16023
|
-
([key, value]) => ` ${JSON.stringify(key)}: ${
|
|
16015
|
+
let print = valuePrinter(" "), values = Object.entries(args).map(
|
|
16016
|
+
([key, value]) => ` ${JSON.stringify(key)}: ${print(value)}`
|
|
16024
16017
|
), argsObject = values.length ? `{
|
|
16025
16018
|
${values.join(`,
|
|
16026
16019
|
`)}
|
|
@@ -16055,7 +16048,7 @@ function buildSnippet(csf, storyName, componentName, merged, resolver) {
|
|
|
16055
16048
|
merged
|
|
16056
16049
|
);
|
|
16057
16050
|
invariant(componentName, "Could not generate snippet without component name.");
|
|
16058
|
-
let attrs = injectedAttributes(merged, /* @__PURE__ */ new Set()), children = toJsxChildren(merged.children), opening = [componentName, ...attrs].join(" "), element = children ? `<${opening}>${children}</${componentName}>` : `<${opening} />`;
|
|
16051
|
+
let print = valuePrinter(""), attrs = injectedAttributes(merged, /* @__PURE__ */ new Set(), print), children = toJsxChildren(merged.children, print), opening = [componentName, ...attrs].join(" "), element = children ? `<${opening}>${children}</${componentName}>` : `<${opening} />`;
|
|
16059
16052
|
return `const ${storyName} = () => ${element};`;
|
|
16060
16053
|
}
|
|
16061
16054
|
var isMethod = (parent) => parent?.type === "Property" && (parent.method || parent.kind !== "init");
|
|
@@ -16090,24 +16083,24 @@ function readsArgs(source) {
|
|
|
16090
16083
|
current2.type === "MemberExpression" && !current2.computed && named.add(current2.property), current2.type === "Property" && !current2.computed && !current2.shorthand && named.add(current2.key), current2.type === "Identifier" && current2.name === "args" && !named.has(current2) && (reads = !0);
|
|
16091
16084
|
}), reads;
|
|
16092
16085
|
}
|
|
16093
|
-
var isValidJsxAttrName = (n) => /^[A-Za-z_][A-Za-z0-9_:-]*$/.test(n), toAttr = (key, value) => value.type === "Literal" && typeof value.value == "boolean" ? value.value ? key : `${key}={false}` : isStringLiteral(value) && !/["&\r\n]/.test(value.value) ? `${key}="${value.value}"` : `${key}={${
|
|
16094
|
-
function injectedAttributes(merged, existing) {
|
|
16086
|
+
var valuePrinter = (indent) => (node) => reindent(detachedTextOf(node), "", indent), isValidJsxAttrName = (n) => /^[A-Za-z_][A-Za-z0-9_:-]*$/.test(n), toAttr = (key, value, print) => value.type === "Literal" && typeof value.value == "boolean" ? value.value ? key : `${key}={false}` : isStringLiteral(value) && !/["&\r\n]/.test(value.value) ? `${key}="${value.value}"` : `${key}={${print(value)}}`;
|
|
16087
|
+
function injectedAttributes(merged, existing, print) {
|
|
16095
16088
|
let entries = Object.entries(merged).filter(
|
|
16096
16089
|
([k, v]) => v != null && k !== "children" && !existing.has(k)
|
|
16097
|
-
), attrs = entries.filter(([k]) => isValidJsxAttrName(k)).map(([k, v]) => toAttr(k, v)), invalid = entries.filter(([k]) => !isValidJsxAttrName(k));
|
|
16090
|
+
), attrs = entries.filter(([k]) => isValidJsxAttrName(k)).map(([k, v]) => toAttr(k, v, print)), invalid = entries.filter(([k]) => !isValidJsxAttrName(k));
|
|
16098
16091
|
if (invalid.length > 0) {
|
|
16099
|
-
let members = invalid.map(([k, v]) => `${JSON.stringify(k)}: ${
|
|
16092
|
+
let members = invalid.map(([k, v]) => `${JSON.stringify(k)}: ${print(v)}`);
|
|
16100
16093
|
attrs.push(`{...{ ${members.join(", ")} }}`);
|
|
16101
16094
|
}
|
|
16102
16095
|
return attrs;
|
|
16103
16096
|
}
|
|
16104
|
-
var toJsxChildren = (node) => node ? isStringLiteral(node) && !/[{}<>&\r\n]/.test(node.value) ? node.value : isJsx(node) ?
|
|
16097
|
+
var toJsxChildren = (node, print) => node ? isStringLiteral(node) && !/[{}<>&\r\n]/.test(node.value) ? node.value : isJsx(node) ? print(node) : `{${print(node)}}` : "";
|
|
16105
16098
|
function getArgsMemberKey(expr) {
|
|
16106
16099
|
let member = expr.type === "ChainExpression" ? expr.expression : expr;
|
|
16107
16100
|
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;
|
|
16108
16101
|
}
|
|
16109
16102
|
function rewriteJsx(code, node, merged, edits) {
|
|
16110
|
-
let changed = !1;
|
|
16103
|
+
let changed = !1, printAt = (offset2) => valuePrinter(lineIndent(code, offset2));
|
|
16111
16104
|
if (node.type === "JSXElement") {
|
|
16112
16105
|
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;
|
|
16113
16106
|
if (firstSpread !== -1) {
|
|
@@ -16116,11 +16109,11 @@ function rewriteJsx(code, node, merged, edits) {
|
|
|
16116
16109
|
attrs.flatMap(
|
|
16117
16110
|
(a) => a.type === "JSXAttribute" && a.name.type === "JSXIdentifier" ? [a.name.name] : []
|
|
16118
16111
|
)
|
|
16119
|
-
), pieces = injectedAttributes(merged, existing).join(" ");
|
|
16112
|
+
), print = printAt(attrs[firstSpread].start), pieces = injectedAttributes(merged, existing, print).join(" ");
|
|
16120
16113
|
if (attrs.forEach((a, index) => {
|
|
16121
16114
|
isArgsSpread(a) && (index === firstSpread && pieces ? edits.push({ start: a.start, end: a.end, text: pieces }) : edits.push({ start: index > 0 ? attrs[index - 1].end : tagEnd, end: a.end, text: "" }));
|
|
16122
16115
|
}), node.children.length === 0 && merged.children) {
|
|
16123
|
-
let children = toJsxChildren(merged.children);
|
|
16116
|
+
let children = toJsxChildren(merged.children, printAt(opening.start));
|
|
16124
16117
|
if (opening.selfClosing) {
|
|
16125
16118
|
let name = code.slice(opening.name.start, opening.name.end), lastEnd = attrs.length > 0 ? attrs[attrs.length - 1].end : tagEnd;
|
|
16126
16119
|
edits.push({ start: lastEnd, end: opening.end, text: `>${children}</${name}>` });
|
|
@@ -16132,16 +16125,28 @@ function rewriteJsx(code, node, merged, edits) {
|
|
|
16132
16125
|
if (a.type !== "JSXAttribute" || a.name.type !== "JSXIdentifier" || a.value?.type !== "JSXExpressionContainer")
|
|
16133
16126
|
continue;
|
|
16134
16127
|
let key = getArgsMemberKey(a.value.expression);
|
|
16135
|
-
key !== null && Object.hasOwn(merged, key) && (edits.push({
|
|
16128
|
+
key !== null && Object.hasOwn(merged, key) && (edits.push({
|
|
16129
|
+
start: a.start,
|
|
16130
|
+
end: a.end,
|
|
16131
|
+
text: toAttr(a.name.name, merged[key], printAt(a.start))
|
|
16132
|
+
}), changed = !0);
|
|
16136
16133
|
}
|
|
16137
16134
|
}
|
|
16138
16135
|
for (let child of node.children)
|
|
16139
|
-
isJsx(child) ? changed = rewriteJsx(code, child, merged, edits) || changed : child.type === "JSXExpressionContainer" && getArgsMemberKey(child.expression) === "children" && merged.children && (edits.push({
|
|
16136
|
+
isJsx(child) ? changed = rewriteJsx(code, child, merged, edits) || changed : child.type === "JSXExpressionContainer" && getArgsMemberKey(child.expression) === "children" && merged.children && (edits.push({
|
|
16137
|
+
start: child.start,
|
|
16138
|
+
end: child.end,
|
|
16139
|
+
text: toJsxChildren(merged.children, printAt(child.start))
|
|
16140
|
+
}), changed = !0);
|
|
16140
16141
|
return changed;
|
|
16141
16142
|
}
|
|
16142
16143
|
|
|
16143
16144
|
// src/componentManifest/reactDocgenTypescript.ts
|
|
16144
16145
|
import { dirname as dirname5, join as join4, resolve as resolve4 } from "node:path";
|
|
16146
|
+
import {
|
|
16147
|
+
extractComponentJsDocInfo as extractComponentJsDocInfo2,
|
|
16148
|
+
resolveExportedSymbol
|
|
16149
|
+
} from "storybook/internal/component-meta";
|
|
16145
16150
|
import { logger as logger4 } from "storybook/internal/node-logger";
|
|
16146
16151
|
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) => {
|
|
16147
16152
|
let countBySource = /* @__PURE__ */ new Map();
|
|
@@ -16187,9 +16192,9 @@ function getExportNameMap(typescript, checker, sourceFile) {
|
|
|
16187
16192
|
}
|
|
16188
16193
|
return result;
|
|
16189
16194
|
}
|
|
16190
|
-
var previousProgramsByConfigKey = /* @__PURE__ */ new Map(), parserCache = /* @__PURE__ */ new Map(), parserBuilds = /* @__PURE__ */ new Map();
|
|
16195
|
+
var previousProgramsByConfigKey = /* @__PURE__ */ new Map(), parserCache = /* @__PURE__ */ new Map(), parserBuilds = /* @__PURE__ */ new Map(), tsconfigCache = /* @__PURE__ */ new Map();
|
|
16191
16196
|
function invalidateParser() {
|
|
16192
|
-
parserCache = /* @__PURE__ */ new Map(), parserBuilds = /* @__PURE__ */ new Map(), previousProgramsByConfigKey.clear();
|
|
16197
|
+
parserCache = /* @__PURE__ */ new Map(), parserBuilds = /* @__PURE__ */ new Map(), tsconfigCache = /* @__PURE__ */ new Map(), previousProgramsByConfigKey.clear();
|
|
16193
16198
|
}
|
|
16194
16199
|
async function getParser(filePath, userOptions) {
|
|
16195
16200
|
let [typescript, reactDocgenTypescript] = await Promise.all([
|
|
@@ -16272,12 +16277,11 @@ var parseWithReactDocgenTypescript = asyncCache(
|
|
|
16272
16277
|
async (filePath, userOptions) => {
|
|
16273
16278
|
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();
|
|
16274
16279
|
return docs.map((doc) => {
|
|
16275
|
-
let largeNonUserSources = getLargeNonUserPropSources(doc.props);
|
|
16280
|
+
let largeNonUserSources = getLargeNonUserPropSources(doc.props), exportName = exportNameMap.get(doc.displayName) ?? doc.displayName, symbol = sourceFile ? resolveExportedSymbol(typescript, checker, sourceFile, exportName) : void 0, componentJsDocTags = symbol ? extractComponentJsDocInfo2(typescript, checker, symbol).jsDocTags : void 0;
|
|
16276
16281
|
return {
|
|
16277
16282
|
...doc,
|
|
16278
|
-
|
|
16279
|
-
|
|
16280
|
-
exportName: exportNameMap.get(doc.displayName) ?? doc.displayName,
|
|
16283
|
+
exportName,
|
|
16284
|
+
componentJsDocTags,
|
|
16281
16285
|
// Filter out bulk props from non-user sources (React built-ins, DOM, CSS-in-JS system props)
|
|
16282
16286
|
props: Object.fromEntries(
|
|
16283
16287
|
Object.entries(doc.props).filter(([, prop]) => {
|
|
@@ -16331,11 +16335,14 @@ function parseTsconfig(typescript, configPath) {
|
|
|
16331
16335
|
return readTsconfig(typescript, configPath).parsed;
|
|
16332
16336
|
}
|
|
16333
16337
|
function readTsconfig(typescript, configPath) {
|
|
16334
|
-
let
|
|
16335
|
-
|
|
16338
|
+
let cacheKey = normalizeFileName(typescript, configPath), cachedTsconfig = tsconfigCache.get(cacheKey);
|
|
16339
|
+
if (cachedTsconfig)
|
|
16340
|
+
return cachedTsconfig;
|
|
16341
|
+
let { config } = typescript.readConfigFile(configPath, typescript.sys.readFile), state = {
|
|
16336
16342
|
config,
|
|
16337
16343
|
parsed: typescript.parseJsonConfigFileContent(config, typescript.sys, dirname5(configPath))
|
|
16338
16344
|
};
|
|
16345
|
+
return tsconfigCache.set(cacheKey, state), state;
|
|
16339
16346
|
}
|
|
16340
16347
|
function isSameFileName(typescript, left, right) {
|
|
16341
16348
|
return normalizeFileName(typescript, left) === normalizeFileName(typescript, right);
|
|
@@ -16430,13 +16437,18 @@ var baseIdentifier = (component) => component.split(".")[0] ?? component, getCom
|
|
|
16430
16437
|
${message}`
|
|
16431
16438
|
};
|
|
16432
16439
|
}
|
|
16433
|
-
let
|
|
16440
|
+
let reactDocgenTypescriptDoc, componentJsDocTags = reactDocgenTypescript?.componentJsDocTags;
|
|
16441
|
+
if (reactDocgenTypescript) {
|
|
16442
|
+
let { componentJsDocTags: _tags, ...doc } = reactDocgenTypescript;
|
|
16443
|
+
reactDocgenTypescriptDoc = doc, componentJsDocTags = _tags;
|
|
16444
|
+
}
|
|
16434
16445
|
return {
|
|
16435
16446
|
...componentWithPackage,
|
|
16436
16447
|
path: path2,
|
|
16437
|
-
...
|
|
16448
|
+
...reactDocgenTypescriptDoc ? { reactDocgenTypescript: reactDocgenTypescriptDoc } : {},
|
|
16438
16449
|
...reactDocgenTypescriptError ? { reactDocgenTypescriptError } : {},
|
|
16439
|
-
|
|
16450
|
+
...componentJsDocTags ? { componentJsDocTags } : {},
|
|
16451
|
+
importOverride: componentJsDocTags?.import?.[0]?.trim()
|
|
16440
16452
|
};
|
|
16441
16453
|
}
|
|
16442
16454
|
if (docgenEngine === "react-docgen") {
|
|
@@ -16586,7 +16598,7 @@ function getComponentDocgenData(component, docgenEngine) {
|
|
|
16586
16598
|
if (docgenEngine === "react-docgen") {
|
|
16587
16599
|
let result = component?.reactDocgen;
|
|
16588
16600
|
reactDocgen = result?.type === "success" ? result.data : void 0, docgenDescription = reactDocgen?.description, docgenError = result?.type === "error" ? result.error : void 0;
|
|
16589
|
-
} else docgenEngine === "react-docgen-typescript" ? (reactDocgenTypescript = component?.reactDocgenTypescript, docgenDescription = reactDocgenTypescript?.description, docgenError = component?.reactDocgenTypescriptError) : (reactComponentMeta = component?.reactComponentMeta ? relativizeComponentMetaPaths(component.reactComponentMeta) : void 0, docgenDescription = reactComponentMeta?.description, docgenJsDocTags = component?.componentJsDocTags);
|
|
16601
|
+
} else docgenEngine === "react-docgen-typescript" ? (reactDocgenTypescript = component?.reactDocgenTypescript, docgenDescription = reactDocgenTypescript?.description, docgenJsDocTags = component?.componentJsDocTags, docgenError = component?.reactDocgenTypescriptError) : (reactComponentMeta = component?.reactComponentMeta ? relativizeComponentMetaPaths(component.reactComponentMeta) : void 0, docgenDescription = reactComponentMeta?.description, docgenJsDocTags = component?.componentJsDocTags);
|
|
16590
16602
|
return {
|
|
16591
16603
|
docgenDescription,
|
|
16592
16604
|
docgenError,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ynn8fkacxge from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ynn8fkacxge from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ynn8fkacxge from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ynn8fkacxge.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ynn8fkacxge.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ynn8fkacxge.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
extractArgTypes,
|
|
16
16
|
posix,
|
|
17
17
|
resolveStoryFileComponents
|
|
18
|
-
} from "../_node-chunks/chunk-
|
|
18
|
+
} from "../_node-chunks/chunk-AV7GEKV7.js";
|
|
19
19
|
|
|
20
20
|
// src/docgen/docgen-worker.ts
|
|
21
|
-
import { createLazyDocgenMiddleware } from "storybook/internal/common";
|
|
21
|
+
import { createLazyDocgenMiddleware, loadTypeScriptCompilerApi } from "storybook/internal/common";
|
|
22
22
|
import { logger } from "storybook/internal/node-logger";
|
|
23
23
|
|
|
24
24
|
// src/docgen/buildDocgen.ts
|
|
@@ -94,10 +94,11 @@ async function buildDocgenPayload(input, context) {
|
|
|
94
94
|
var createDocgenProvider = () => createLazyDocgenMiddleware({
|
|
95
95
|
createManager: async () => {
|
|
96
96
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
return new ComponentMetaManager(
|
|
98
|
+
await loadTypeScriptCompilerApi(() => import("typescript"))
|
|
99
|
+
);
|
|
99
100
|
} catch (err) {
|
|
100
|
-
logger.
|
|
101
|
+
logger.warn(`React docgen is unavailable. ${err instanceof Error ? err.message : err}`);
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
104
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -837,19 +837,19 @@ Except<BaseType, Keys> // Pick the keys that should be mutable from the base typ
|
|
|
837
837
|
/**
|
|
838
838
|
* Metadata to configure the stories for a component.
|
|
839
839
|
*
|
|
840
|
-
* @see [
|
|
840
|
+
* @see [Meta](https://storybook.js.org/docs/writing-stories/csf#meta)
|
|
841
841
|
*/
|
|
842
842
|
type Meta<TCmpOrArgs = Args$1> = [TCmpOrArgs] extends [ComponentType<any>] ? ComponentAnnotations<ReactRenderer, ComponentProps<TCmpOrArgs>> : ComponentAnnotations<ReactRenderer, TCmpOrArgs>;
|
|
843
843
|
/**
|
|
844
844
|
* Story function that represents a CSFv2 component example.
|
|
845
845
|
*
|
|
846
|
-
* @see [
|
|
846
|
+
* @see [Stories](https://storybook.js.org/docs/writing-stories/csf#stories)
|
|
847
847
|
*/
|
|
848
848
|
type StoryFn<TCmpOrArgs = Args$1> = [TCmpOrArgs] extends [ComponentType<any>] ? AnnotatedStoryFn<ReactRenderer, ComponentProps<TCmpOrArgs>> : AnnotatedStoryFn<ReactRenderer, TCmpOrArgs>;
|
|
849
849
|
/**
|
|
850
850
|
* Story object that represents a CSFv3 component example.
|
|
851
851
|
*
|
|
852
|
-
* @see [
|
|
852
|
+
* @see [Stories](https://storybook.js.org/docs/writing-stories/csf#stories)
|
|
853
853
|
*/
|
|
854
854
|
type StoryObj<TMetaOrCmpOrArgs = Args$1> = [TMetaOrCmpOrArgs] extends [{
|
|
855
855
|
render?: ArgsStoryFn<ReactRenderer, any>;
|
package/dist/preset.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ynn8fkacxge from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ynn8fkacxge from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ynn8fkacxge from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ynn8fkacxge.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ynn8fkacxge.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ynn8fkacxge.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
parseWithReactDocgen,
|
|
26
26
|
posix,
|
|
27
27
|
resolveStoryFileComponents
|
|
28
|
-
} from "./_node-chunks/chunk-
|
|
28
|
+
} from "./_node-chunks/chunk-AV7GEKV7.js";
|
|
29
29
|
|
|
30
30
|
// ../../../node_modules/semver/internal/constants.js
|
|
31
31
|
var require_constants = __commonJS({
|
|
@@ -1217,7 +1217,7 @@ var require_semver2 = __commonJS({
|
|
|
1217
1217
|
// src/preset.ts
|
|
1218
1218
|
import path2, { join as join3 } from "node:path";
|
|
1219
1219
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
1220
|
-
import { getProjectRoot } from "storybook/internal/common";
|
|
1220
|
+
import { getProjectRoot, isTypeScriptReadyForDocgen } from "storybook/internal/common";
|
|
1221
1221
|
|
|
1222
1222
|
// ../../core/src/shared/utils/module.ts
|
|
1223
1223
|
import nodeModule, { createRequire } from "node:module";
|
|
@@ -1584,13 +1584,15 @@ import {
|
|
|
1584
1584
|
} from "storybook/internal/common";
|
|
1585
1585
|
|
|
1586
1586
|
// src/componentManifest/componentMetaManagerSingleton.ts
|
|
1587
|
+
import { loadTypeScriptCompilerApi } from "storybook/internal/common";
|
|
1587
1588
|
import { logger as logger3 } from "storybook/internal/node-logger";
|
|
1588
1589
|
var componentMetaManagerPromise;
|
|
1589
1590
|
function getSharedComponentMetaManager() {
|
|
1590
1591
|
return componentMetaManagerPromise || (componentMetaManagerPromise = (async () => {
|
|
1591
1592
|
try {
|
|
1592
|
-
|
|
1593
|
-
|
|
1593
|
+
return new ComponentMetaManager(
|
|
1594
|
+
await loadTypeScriptCompilerApi(() => import("typescript"))
|
|
1595
|
+
);
|
|
1594
1596
|
} catch (err) {
|
|
1595
1597
|
logger3.debug(`[reactComponentMeta] Skipping component metadata extraction: ${err}`);
|
|
1596
1598
|
return;
|
|
@@ -1775,13 +1777,7 @@ var experimental_storyDocsProvider = async (nextStoryDocs, options) => {
|
|
|
1775
1777
|
};
|
|
1776
1778
|
|
|
1777
1779
|
// src/preset.ts
|
|
1778
|
-
var isDocgenProviderEnabled = () => {
|
|
1779
|
-
try {
|
|
1780
|
-
return import.meta.resolve("typescript"), !0;
|
|
1781
|
-
} catch {
|
|
1782
|
-
return !1;
|
|
1783
|
-
}
|
|
1784
|
-
}, features = async (existing) => ({
|
|
1780
|
+
var isDocgenProviderEnabled = (_existing, options) => isTypeScriptReadyForDocgen((specifier) => import.meta.resolve(specifier), options), features = async (existing) => ({
|
|
1785
1781
|
...existing,
|
|
1786
1782
|
componentsManifest: !0
|
|
1787
1783
|
}), previewAnnotations = async (input = [], options) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react",
|
|
3
|
-
"version": "11.0.0-alpha.
|
|
3
|
+
"version": "11.0.0-alpha.9",
|
|
4
4
|
"description": "Storybook React renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@types/react-dom": "^18.0.0 || ^19.0.0",
|
|
82
82
|
"react": "^18.0.0 || ^19.0.0",
|
|
83
83
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
84
|
-
"storybook": "^11.0.0-alpha.
|
|
84
|
+
"storybook": "^11.0.0-alpha.9",
|
|
85
85
|
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependenciesMeta": {
|
|
@@ -90,9 +90,6 @@
|
|
|
90
90
|
},
|
|
91
91
|
"@types/react-dom": {
|
|
92
92
|
"optional": true
|
|
93
|
-
},
|
|
94
|
-
"typescript": {
|
|
95
|
-
"optional": true
|
|
96
93
|
}
|
|
97
94
|
},
|
|
98
95
|
"publishConfig": {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
3
|
import './button.css';
|
|
6
4
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
5
|
+
/**
|
|
6
|
+
* Primary UI component for user interaction
|
|
7
|
+
*
|
|
8
|
+
* @param {object} props
|
|
9
|
+
* @param {boolean} [props.primary=false] Is this the principal call to action on the page?
|
|
10
|
+
* @param {string} [props.backgroundColor] What background color to use
|
|
11
|
+
* @param {'small' | 'medium' | 'large'} [props.size='medium'] How large should the button be?
|
|
12
|
+
* @param {string} props.label Button contents
|
|
13
|
+
* @param {() => void} [props.onClick] Optional click handler
|
|
14
|
+
*/
|
|
15
|
+
export const Button = ({ primary = false, backgroundColor, size = 'medium', label, ...props }) => {
|
|
15
16
|
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
16
17
|
return (
|
|
17
18
|
<button
|
|
@@ -24,16 +25,3 @@ export const Button = ({
|
|
|
24
25
|
</button>
|
|
25
26
|
);
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
-
Button.propTypes = {
|
|
29
|
-
/** Is this the principal call to action on the page? */
|
|
30
|
-
primary: PropTypes.bool,
|
|
31
|
-
/** What background color to use */
|
|
32
|
-
backgroundColor: PropTypes.string,
|
|
33
|
-
/** How large should the button be? */
|
|
34
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
35
|
-
/** Button contents */
|
|
36
|
-
label: PropTypes.string.isRequired,
|
|
37
|
-
/** Optional click handler */
|
|
38
|
-
onClick: PropTypes.func,
|
|
39
|
-
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
3
|
import { Button } from './Button';
|
|
6
4
|
import './header.css';
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @param {object} props
|
|
8
|
+
* @param {{ name: string }} [props.user] The signed-in user, if any
|
|
9
|
+
* @param {() => void} props.onLogin Called when the user clicks Log in
|
|
10
|
+
* @param {() => void} props.onLogout Called when the user clicks Log out
|
|
11
|
+
* @param {() => void} props.onCreateAccount Called when the user clicks Sign up
|
|
12
|
+
*/
|
|
13
|
+
export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (
|
|
9
14
|
<header>
|
|
10
15
|
<div className="storybook-header">
|
|
11
16
|
<div>
|
|
@@ -45,12 +50,3 @@ export const Header = ({ user = null, onLogin, onLogout, onCreateAccount }) => (
|
|
|
45
50
|
</div>
|
|
46
51
|
</header>
|
|
47
52
|
);
|
|
48
|
-
|
|
49
|
-
Header.propTypes = {
|
|
50
|
-
user: PropTypes.shape({
|
|
51
|
-
name: PropTypes.string.isRequired,
|
|
52
|
-
}),
|
|
53
|
-
onLogin: PropTypes.func.isRequired,
|
|
54
|
-
onLogout: PropTypes.func.isRequired,
|
|
55
|
-
onCreateAccount: PropTypes.func.isRequired,
|
|
56
|
-
};
|