@storybook/react 11.0.0-beta.0 → 11.0.0-beta.2
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-2TQVKMJE.js → chunk-EA5DV32Q.js} +36 -1
- package/dist/_browser-chunks/{chunk-EZD3TIPB.js → chunk-I62VTYU3.js} +17 -4
- package/dist/_browser-chunks/{chunk-7QIM3PHH.js → chunk-U7XUEUFQ.js} +3 -3
- package/dist/_browser-chunks/{chunk-LGSTPTL6.js → chunk-WWHCZJWM.js} +10 -9
- package/dist/_node-chunks/{chunk-27VFNEPI.js → chunk-2DNUEB5U.js} +6798 -15258
- package/dist/_node-chunks/chunk-ASUAJQT5.js +63 -0
- package/dist/_node-chunks/chunk-BWU7O3KC.js +61 -0
- package/dist/_node-chunks/chunk-DW2HJ23M.js +1674 -0
- package/dist/_node-chunks/chunk-PXKXGEPO.js +6643 -0
- package/dist/_node-chunks/chunk-QRCEILHM.js +93 -0
- package/dist/_node-chunks/chunk-TP7UUO2M.js +18 -0
- package/dist/_node-chunks/chunk-VQBUQHU3.js +33 -0
- package/dist/_node-chunks/chunk-XIFLZILW.js +65 -0
- package/dist/_node-chunks/chunk-XQPV7U3R.js +1395 -0
- package/dist/_node-chunks/extractArgTypesFromComponentFile-PKEIPQGN.js +44 -0
- package/dist/_node-chunks/extractReactDocgenInfo-J6CKNSQN.js +59 -0
- package/dist/_node-chunks/extractReactTypescriptDocgenInfo-AJTC3KA3.js +105 -0
- package/dist/_node-chunks/reactDocgen-YAGNM6ZQ.js +26 -0
- package/dist/builder-docgen.d.ts +51 -0
- package/dist/builder-docgen.js +25 -0
- package/dist/{chunk-DwM7QKaD.d.ts → chunk-6b3AvPEC.d.ts} +66 -1
- package/dist/docgen/docgen-worker.js +23 -87
- package/dist/entry-preview-argtypes.js +1 -1
- package/dist/entry-preview-docs.js +1 -1
- package/dist/entry-preview.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/preset.js +79 -1363
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js +4 -4
- package/package.json +21 -6
- package/template/cli/js/Button.stories.js +11 -10
- package/template/cli/js/Header.stories.js +6 -5
- package/template/cli/js/Page.stories.js +6 -5
- package/template/cli/ts/Button.stories.ts +11 -14
- package/template/cli/ts/Header.stories.ts +6 -9
- package/template/cli/ts/Page.stories.ts +6 -9
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_0pbco1v5vos from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_0pbco1v5vos from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_0pbco1v5vos from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_0pbco1v5vos.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_0pbco1v5vos.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_0pbco1v5vos.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
buildComponentDocgenFromResolved,
|
|
14
|
+
posix,
|
|
15
|
+
resolveStoryFileComponents
|
|
16
|
+
} from "./chunk-PXKXGEPO.js";
|
|
17
|
+
import {
|
|
18
|
+
extractArgTypes
|
|
19
|
+
} from "./chunk-2DNUEB5U.js";
|
|
20
|
+
|
|
21
|
+
// src/docgen/buildDocgen.ts
|
|
22
|
+
import { getStoryImportPathFromEntry } from "storybook/internal/common";
|
|
23
|
+
var REACT_ATTRIBUTE_INTERFACES = /* @__PURE__ */ new Set(["Attributes", "RefAttributes", "ClassAttributes"]);
|
|
24
|
+
function isReactAttribute(prop) {
|
|
25
|
+
return !!prop.parent && REACT_ATTRIBUTE_INTERFACES.has(prop.parent.name) && /(^|[\\/])node_modules[\\/]/.test(prop.parent.fileName);
|
|
26
|
+
}
|
|
27
|
+
function extractArgTypesFromComponentMeta(componentMeta) {
|
|
28
|
+
if (!componentMeta)
|
|
29
|
+
return;
|
|
30
|
+
let props = Object.fromEntries(
|
|
31
|
+
Object.entries(componentMeta.props).filter(([, prop]) => !isReactAttribute(prop)).map(([name, prop]) => [
|
|
32
|
+
name,
|
|
33
|
+
prop.defaultValue ? { ...prop, defaultValue: { ...prop.defaultValue, computed: !1 } } : prop
|
|
34
|
+
])
|
|
35
|
+
);
|
|
36
|
+
return extractArgTypes({ __docgenInfo: { ...componentMeta, props } }) ?? void 0;
|
|
37
|
+
}
|
|
38
|
+
function addArgTypesFromComponentMeta(payload) {
|
|
39
|
+
let argTypes = extractArgTypesFromComponentMeta(payload.reactComponentMeta), subcomponents = payload.subcomponents ? Object.fromEntries(
|
|
40
|
+
Object.entries(payload.subcomponents).map(([name, subcomponent]) => [
|
|
41
|
+
name,
|
|
42
|
+
{
|
|
43
|
+
...subcomponent,
|
|
44
|
+
argTypes: extractArgTypesFromComponentMeta(subcomponent.reactComponentMeta)
|
|
45
|
+
}
|
|
46
|
+
])
|
|
47
|
+
) : void 0;
|
|
48
|
+
return {
|
|
49
|
+
...payload,
|
|
50
|
+
...argTypes ? { argTypes } : {},
|
|
51
|
+
...subcomponents ? { subcomponents } : {}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function buildDocgenPayload(input, context) {
|
|
55
|
+
let storyFilePath = getStoryImportPathFromEntry(input.entry);
|
|
56
|
+
if (!storyFilePath)
|
|
57
|
+
return;
|
|
58
|
+
let storyPath = (context.resolvePath ?? ((importPath) => posix.join(process.cwd(), importPath)))(storyFilePath), resolved;
|
|
59
|
+
try {
|
|
60
|
+
resolved = await resolveStoryFileComponents({
|
|
61
|
+
storyPath,
|
|
62
|
+
title: input.entry.title,
|
|
63
|
+
typescriptOptions: context.typescriptOptions,
|
|
64
|
+
docgenEngine: "react-component-meta"
|
|
65
|
+
});
|
|
66
|
+
} catch {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
let { csf, componentName, component, subcomponents, storyFile } = resolved, usableSubcomponents = subcomponents.filter(
|
|
70
|
+
(sub) => sub.component !== void 0
|
|
71
|
+
), storyRefs = [
|
|
72
|
+
...component ? [{ storyPath, component }] : [],
|
|
73
|
+
...usableSubcomponents.map((sub) => ({ storyPath, component: sub.component }))
|
|
74
|
+
];
|
|
75
|
+
storyRefs.length > 0 && context.componentMetaManager.batchExtract(storyRefs);
|
|
76
|
+
let componentDocgen = buildComponentDocgenFromResolved({
|
|
77
|
+
entry: input.entry,
|
|
78
|
+
storyPath,
|
|
79
|
+
storyFilePath,
|
|
80
|
+
storyFile,
|
|
81
|
+
csf,
|
|
82
|
+
componentName,
|
|
83
|
+
component,
|
|
84
|
+
subcomponents,
|
|
85
|
+
docgenEngine: "react-component-meta"
|
|
86
|
+
});
|
|
87
|
+
return addArgTypesFromComponentMeta(componentDocgen);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export {
|
|
91
|
+
extractArgTypesFromComponentMeta,
|
|
92
|
+
buildDocgenPayload
|
|
93
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_0pbco1v5vos from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_0pbco1v5vos from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_0pbco1v5vos from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_0pbco1v5vos.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_0pbco1v5vos.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_0pbco1v5vos.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
// src/docgen-typescript-apis.ts
|
|
14
|
+
var REACT_DOCGEN_TYPESCRIPT_APIS = ["compiler", "native"];
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
REACT_DOCGEN_TYPESCRIPT_APIS
|
|
18
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_0pbco1v5vos from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_0pbco1v5vos from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_0pbco1v5vos from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_0pbco1v5vos.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_0pbco1v5vos.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_0pbco1v5vos.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
ComponentMetaManager,
|
|
14
|
+
loadDocgenTypeScript
|
|
15
|
+
} from "./chunk-PXKXGEPO.js";
|
|
16
|
+
|
|
17
|
+
// src/componentManifest/componentMetaManagerSingleton.ts
|
|
18
|
+
import { logger } from "storybook/internal/node-logger";
|
|
19
|
+
var componentMetaManagerPromise;
|
|
20
|
+
function getSharedComponentMetaManager(typeScriptSpecifier) {
|
|
21
|
+
return componentMetaManagerPromise || (componentMetaManagerPromise = (async () => {
|
|
22
|
+
try {
|
|
23
|
+
return new ComponentMetaManager(await loadDocgenTypeScript(typeScriptSpecifier));
|
|
24
|
+
} catch (err) {
|
|
25
|
+
logger.debug(`[reactComponentMeta] Skipping component metadata extraction: ${err}`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
})()), componentMetaManagerPromise;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
getSharedComponentMetaManager
|
|
33
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_0pbco1v5vos from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_0pbco1v5vos from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_0pbco1v5vos from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_0pbco1v5vos.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_0pbco1v5vos.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_0pbco1v5vos.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
REACT_DOCGEN_TYPESCRIPT_APIS
|
|
14
|
+
} from "./chunk-TP7UUO2M.js";
|
|
15
|
+
|
|
16
|
+
// src/builder-docgen.ts
|
|
17
|
+
import {
|
|
18
|
+
checkBuilderDocgenPackages,
|
|
19
|
+
getTypeScriptForDocgenError,
|
|
20
|
+
isPackageInstalledInRange
|
|
21
|
+
} from "storybook/internal/common";
|
|
22
|
+
var REACT_BUILDER_DOCGEN_PACKAGES = {
|
|
23
|
+
"react-docgen": "^8.0.2",
|
|
24
|
+
"react-docgen-typescript": "^2.2.2",
|
|
25
|
+
// TEMPORARY(ts-7.1): 0.7 only. 0.9 accepts TypeScript `>=7.1.0-0`; npm resolves optional peers when
|
|
26
|
+
// it checks for conflicts, picks a 7.1 prerelease, and fails to install a project without its own
|
|
27
|
+
// `typescript`. Once TypeScript 7.1.0 is stable, allow 0.8 and 0.9 again and drop `@^0.7.0` from the
|
|
28
|
+
// docs and MIGRATION.md.
|
|
29
|
+
"@joshwooding/vite-plugin-react-docgen-typescript": "^0.7.0",
|
|
30
|
+
"@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.0c3f3b7.0"
|
|
31
|
+
};
|
|
32
|
+
function getReactBuilderDocgenPackages(reactDocgen, builder) {
|
|
33
|
+
return reactDocgen === "react-docgen" ? ["react-docgen"] : reactDocgen === "react-docgen-typescript" ? [
|
|
34
|
+
builder === "vite" ? "@joshwooding/vite-plugin-react-docgen-typescript" : "@storybook/react-docgen-typescript-plugin",
|
|
35
|
+
"react-docgen-typescript"
|
|
36
|
+
] : [];
|
|
37
|
+
}
|
|
38
|
+
var isReactBuilderDocgenPackageInstalled = (resolve, packageName) => isPackageInstalledInRange(resolve, packageName, REACT_BUILDER_DOCGEN_PACKAGES[packageName]);
|
|
39
|
+
async function prepareReactBuilderDocgen({
|
|
40
|
+
reactDocgen,
|
|
41
|
+
builder,
|
|
42
|
+
resolve,
|
|
43
|
+
options
|
|
44
|
+
}) {
|
|
45
|
+
let mode = reactDocgen === "react-docgen-typescript" && getTypeScriptForDocgenError(resolve) ? "react-docgen" : reactDocgen, packages = getReactBuilderDocgenPackages(mode, builder);
|
|
46
|
+
return (await checkBuilderDocgenPackages({
|
|
47
|
+
packages: Object.fromEntries(
|
|
48
|
+
packages.map((name) => [name, REACT_BUILDER_DOCGEN_PACKAGES[name]])
|
|
49
|
+
),
|
|
50
|
+
resolve,
|
|
51
|
+
options,
|
|
52
|
+
builderDocgen: `typescript.reactDocgen: '${reactDocgen}'`,
|
|
53
|
+
disableBuilderDocgen: "typescript.reactDocgen: false",
|
|
54
|
+
documentation: "https://storybook.js.org/docs/api/main-config/main-config-typescript#reactdocgen",
|
|
55
|
+
note: mode !== reactDocgen ? "`react-docgen-typescript` needs the TypeScript compiler API, which your `typescript` package does not have, so builder docgen uses `react-docgen` instead." : void 0,
|
|
56
|
+
apis: REACT_DOCGEN_TYPESCRIPT_APIS
|
|
57
|
+
})).length > 0 ? void 0 : mode;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
REACT_BUILDER_DOCGEN_PACKAGES,
|
|
62
|
+
getReactBuilderDocgenPackages,
|
|
63
|
+
isReactBuilderDocgenPackageInstalled,
|
|
64
|
+
prepareReactBuilderDocgen
|
|
65
|
+
};
|