@storybook/react 11.0.0-alpha.9 → 11.0.0-beta.1

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.
Files changed (32) hide show
  1. package/dist/_browser-chunks/{chunk-7QIM3PHH.js → chunk-6MBKXM7O.js} +1 -1
  2. package/dist/_browser-chunks/{chunk-EZD3TIPB.js → chunk-I62VTYU3.js} +17 -4
  3. package/dist/_node-chunks/{chunk-AV7GEKV7.js → chunk-37XDLJI5.js} +6788 -15249
  4. package/dist/_node-chunks/chunk-FCIBS77S.js +61 -0
  5. package/dist/_node-chunks/chunk-FUHORIY7.js +1395 -0
  6. package/dist/_node-chunks/chunk-GQOGANUK.js +35 -0
  7. package/dist/_node-chunks/chunk-IYZUDUNZ.js +1674 -0
  8. package/dist/_node-chunks/chunk-PPFRYFMF.js +57 -0
  9. package/dist/_node-chunks/chunk-RVHW3VEA.js +63 -0
  10. package/dist/_node-chunks/chunk-U53ZMSA3.js +5442 -0
  11. package/dist/_node-chunks/chunk-YNIH7TZQ.js +93 -0
  12. package/dist/_node-chunks/extractArgTypesFromComponentFile-EQEZZAHL.js +42 -0
  13. package/dist/_node-chunks/extractReactDocgenInfo-COAPYCG6.js +59 -0
  14. package/dist/_node-chunks/extractReactTypescriptDocgenInfo-7FFDIBEA.js +105 -0
  15. package/dist/_node-chunks/reactDocgen-6ZJPM2YE.js +26 -0
  16. package/dist/builder-docgen.d.ts +51 -0
  17. package/dist/builder-docgen.js +24 -0
  18. package/dist/{chunk-DwM7QKaD.d.ts → chunk-6b3AvPEC.d.ts} +66 -1
  19. package/dist/docgen/docgen-worker.js +15 -83
  20. package/dist/entry-preview.js +1 -1
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +2 -2
  23. package/dist/preset.js +59 -1353
  24. package/dist/preview.d.ts +1 -1
  25. package/dist/preview.js +2 -2
  26. package/package.json +18 -5
  27. package/template/cli/js/Button.stories.js +11 -10
  28. package/template/cli/js/Header.stories.js +6 -5
  29. package/template/cli/js/Page.stories.js +6 -5
  30. package/template/cli/ts/Button.stories.ts +11 -14
  31. package/template/cli/ts/Header.stories.ts +6 -9
  32. package/template/cli/ts/Page.stories.ts +6 -9
@@ -0,0 +1,93 @@
1
+ import CJS_COMPAT_NODE_URL_19uq4gz0tcr from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_19uq4gz0tcr from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_19uq4gz0tcr from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_19uq4gz0tcr.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_19uq4gz0tcr.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_19uq4gz0tcr.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-U53ZMSA3.js";
17
+ import {
18
+ extractArgTypes
19
+ } from "./chunk-37XDLJI5.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,42 @@
1
+ import CJS_COMPAT_NODE_URL_19uq4gz0tcr from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_19uq4gz0tcr from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_19uq4gz0tcr from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_19uq4gz0tcr.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_19uq4gz0tcr.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_19uq4gz0tcr.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ getSharedComponentMetaManager
14
+ } from "./chunk-GQOGANUK.js";
15
+ import {
16
+ extractArgTypesFromComponentMeta
17
+ } from "./chunk-YNIH7TZQ.js";
18
+ import "./chunk-U53ZMSA3.js";
19
+ import "./chunk-IYZUDUNZ.js";
20
+ import "./chunk-37XDLJI5.js";
21
+ import "./chunk-FCIBS77S.js";
22
+ import "./chunk-RVHW3VEA.js";
23
+
24
+ // src/docgen/extractArgTypesFromComponentFile.ts
25
+ async function extractArgTypesFromComponentFile({
26
+ componentFilePath,
27
+ componentExportName = "default"
28
+ }) {
29
+ let manager = await getSharedComponentMetaManager();
30
+ if (!manager)
31
+ return null;
32
+ let component = {
33
+ componentName: componentExportName,
34
+ importName: componentExportName,
35
+ path: componentFilePath,
36
+ isPackage: !1
37
+ };
38
+ return manager.batchExtract([{ storyPath: componentFilePath, component }]), extractArgTypesFromComponentMeta(component.reactComponentMeta) ?? null;
39
+ }
40
+ export {
41
+ extractArgTypesFromComponentFile
42
+ };
@@ -0,0 +1,59 @@
1
+ import CJS_COMPAT_NODE_URL_19uq4gz0tcr from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_19uq4gz0tcr from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_19uq4gz0tcr from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_19uq4gz0tcr.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_19uq4gz0tcr.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_19uq4gz0tcr.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ parseWithReactDocgen
14
+ } from "./chunk-FUHORIY7.js";
15
+ import {
16
+ cachedReadFileSync
17
+ } from "./chunk-IYZUDUNZ.js";
18
+ import {
19
+ extractArgTypes
20
+ } from "./chunk-37XDLJI5.js";
21
+ import "./chunk-FCIBS77S.js";
22
+ import "./chunk-RVHW3VEA.js";
23
+
24
+ // src/componentManifest/reactDocgen/extractReactDocgenInfo.ts
25
+ import { logger } from "storybook/internal/node-logger";
26
+ function getComponentDocgen(filePath, componentName) {
27
+ try {
28
+ let code = cachedReadFileSync(filePath, "utf-8"), docgens = parseWithReactDocgen(code, filePath);
29
+ if (docgens.length === 0)
30
+ return null;
31
+ if (componentName) {
32
+ let matchingDocgen = docgens.find(
33
+ (docgen) => docgen.actualName === componentName || docgen.displayName === componentName || docgen.exportName === componentName
34
+ );
35
+ return matchingDocgen ? {
36
+ componentName: matchingDocgen.actualName || matchingDocgen.displayName || componentName,
37
+ reactDocgen: { type: "success", data: matchingDocgen }
38
+ } : null;
39
+ }
40
+ let firstDocgen = docgens[0];
41
+ return {
42
+ componentName: firstDocgen.actualName || firstDocgen.displayName || "Unknown",
43
+ reactDocgen: { type: "success", data: firstDocgen }
44
+ };
45
+ } catch (error) {
46
+ return logger.debug(`Error parsing component file for docgen ${filePath}: ${error}`), null;
47
+ }
48
+ }
49
+ var extractArgTypesFromDocgen = ({
50
+ componentFilePath,
51
+ componentExportName
52
+ }) => {
53
+ let docgen = getComponentDocgen(componentFilePath, componentExportName);
54
+ return !docgen || docgen.reactDocgen.type !== "success" ? null : extractArgTypes({ __docgenInfo: docgen.reactDocgen.data }) ?? {};
55
+ };
56
+ export {
57
+ extractArgTypesFromDocgen,
58
+ getComponentDocgen
59
+ };
@@ -0,0 +1,105 @@
1
+ import CJS_COMPAT_NODE_URL_19uq4gz0tcr from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_19uq4gz0tcr from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_19uq4gz0tcr from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_19uq4gz0tcr.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_19uq4gz0tcr.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_19uq4gz0tcr.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ extractArgTypes
14
+ } from "./chunk-37XDLJI5.js";
15
+ import "./chunk-FCIBS77S.js";
16
+ import "./chunk-RVHW3VEA.js";
17
+
18
+ // src/componentManifest/reactDocgen/extractReactTypescriptDocgenInfo.ts
19
+ import { logger } from "storybook/internal/node-logger";
20
+
21
+ // src/componentManifest/reactDocgen/utils.ts
22
+ import { findTsconfigPathForFile } from "storybook/internal/common";
23
+ import { dirname } from "node:path";
24
+ var REACT_NODE_TYPES = /* @__PURE__ */ new Set([
25
+ "JSX.Element",
26
+ "ComponentType",
27
+ "ReactComponentType",
28
+ "ReactElement",
29
+ "ReactReactElement",
30
+ "ElementType",
31
+ "ReactElementType",
32
+ "ReactNode",
33
+ "ReactReactNode"
34
+ ]), KNOWN_TYPE_NAMES = /* @__PURE__ */ new Set([
35
+ "boolean",
36
+ "string",
37
+ "number",
38
+ "Date",
39
+ ...REACT_NODE_TYPES,
40
+ "signature",
41
+ "union",
42
+ "Array",
43
+ "tuple",
44
+ "literal",
45
+ "null",
46
+ "void",
47
+ "any",
48
+ "unknown"
49
+ ]);
50
+ var getTsConfig = async (componentFilePath) => {
51
+ try {
52
+ let imported = await import("typescript"), ts = imported.default ?? imported, tsconfigPath = componentFilePath ? findTsconfigPathForFile(dirname(componentFilePath), componentFilePath) : ts.findConfigFile(process.cwd(), ts.sys.fileExists);
53
+ if (tsconfigPath === void 0)
54
+ return {};
55
+ let basePath = dirname(tsconfigPath), { config, error } = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
56
+ return error ? {} : ts.parseJsonConfigFileContent(config, ts.sys, basePath, {}, tsconfigPath).options;
57
+ } catch {
58
+ return {};
59
+ }
60
+ };
61
+
62
+ // src/componentManifest/reactDocgen/extractReactTypescriptDocgenInfo.ts
63
+ var extractArgTypesFromDocgenTypescript = async ({
64
+ componentFilePath,
65
+ componentExportName,
66
+ reactDocgenTypescriptOptions
67
+ }) => {
68
+ try {
69
+ let { withCompilerOptions } = (await import("react-docgen-typescript")).default, defaultOptions = {
70
+ shouldExtractLiteralValuesFromEnum: !0,
71
+ shouldRemoveUndefinedFromOptional: !0,
72
+ propFilter: (prop) => prop.parent ? !/node_modules/.test(prop.parent.fileName) : !0,
73
+ // We *need* this set so that RDT returns default values in the same format as react-docgen
74
+ savePropValueAsString: !0
75
+ }, tsConfig = await getTsConfig(componentFilePath), mergedOptions = {
76
+ ...defaultOptions,
77
+ ...reactDocgenTypescriptOptions,
78
+ // Always ensure savePropValueAsString is true for consistency
79
+ savePropValueAsString: !0
80
+ }, docgens = withCompilerOptions(
81
+ { ...tsConfig, noErrorTruncation: !0, strict: !0 },
82
+ mergedOptions
83
+ ).parse(componentFilePath);
84
+ if (!docgens || docgens.length === 0)
85
+ return null;
86
+ let targetDocgen = docgens[0];
87
+ if (componentExportName) {
88
+ let match = docgens.find(
89
+ (d) => d.displayName === componentExportName || d.filePath?.includes(componentExportName)
90
+ );
91
+ if (match)
92
+ targetDocgen = match;
93
+ else
94
+ return null;
95
+ }
96
+ return extractArgTypes({ __docgenInfo: targetDocgen }) ?? {};
97
+ } catch (error) {
98
+ return logger.debug(
99
+ `Error parsing component file with react-docgen-typescript ${componentFilePath}: ${error}`
100
+ ), null;
101
+ }
102
+ };
103
+ export {
104
+ extractArgTypesFromDocgenTypescript
105
+ };
@@ -0,0 +1,26 @@
1
+ import CJS_COMPAT_NODE_URL_19uq4gz0tcr from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_19uq4gz0tcr from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_19uq4gz0tcr from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_19uq4gz0tcr.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_19uq4gz0tcr.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_19uq4gz0tcr.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ getMatchingDocgen,
14
+ getReactDocgen,
15
+ getReactDocgenImporter,
16
+ parseWithReactDocgen
17
+ } from "./chunk-FUHORIY7.js";
18
+ import "./chunk-IYZUDUNZ.js";
19
+ import "./chunk-FCIBS77S.js";
20
+ import "./chunk-RVHW3VEA.js";
21
+ export {
22
+ getMatchingDocgen,
23
+ getReactDocgen,
24
+ getReactDocgenImporter,
25
+ parseWithReactDocgen
26
+ };
@@ -0,0 +1,51 @@
1
+ import { Options } from "storybook/internal/types";
2
+
3
+ //#region code/renderers/react/.dts-emit/code/renderers/react/src/componentManifest/reactDocgen/utils.d.ts
4
+ type ReactDocgenConfig = 'react-docgen' | 'react-docgen-typescript' | false;
5
+ //#endregion
6
+ //#region code/renderers/react/.dts-emit/code/renderers/react/src/builder-docgen.d.ts
7
+ /**
8
+ * Packages that only React's deprecated builder docgen (`features.docgenServer: false`) uses, with
9
+ * the version range Storybook supports. `@storybook/react`, `@storybook/react-vite`,
10
+ * `@storybook/preset-react-webpack` and the React frameworks declare them as optional peer
11
+ * dependencies with these ranges, which a test checks.
12
+ */
13
+ declare const REACT_BUILDER_DOCGEN_PACKAGES: {
14
+ readonly 'react-docgen': '^8.0.2';
15
+ readonly 'react-docgen-typescript': '^2.2.2';
16
+ readonly '@joshwooding/vite-plugin-react-docgen-typescript': '^0.7.0 || ^0.8.0 || ^0.9.0';
17
+ readonly '@storybook/react-docgen-typescript-plugin': '1.0.6--canary.9.0c3f3b7.0';
18
+ };
19
+ type ReactBuilderDocgenPackage = keyof typeof REACT_BUILDER_DOCGEN_PACKAGES;
20
+ /**
21
+ * Return the packages that builder docgen needs for a `typescript.reactDocgen` mode.
22
+ *
23
+ * `react-docgen-typescript` mode needs the builder plugin and `react-docgen-typescript` itself,
24
+ * which `@storybook/react` loads for the components manifest. In that mode the `react-docgen` pass
25
+ * over JavaScript files is optional.
26
+ */
27
+ declare function getReactBuilderDocgenPackages(reactDocgen: ReactDocgenConfig | undefined, builder: 'vite' | 'webpack'): ReactBuilderDocgenPackage[];
28
+ /** Return whether a builder docgen package resolves in a version Storybook supports. */
29
+ declare const isReactBuilderDocgenPackageInstalled: (resolve: (specifier: string) => string, packageName: ReactBuilderDocgenPackage) => boolean;
30
+ /**
31
+ * Decide which `typescript.reactDocgen` mode builder docgen runs in, check that its packages are
32
+ * installed, and report it when they are not. Call it from a framework preset once builder docgen
33
+ * is active.
34
+ *
35
+ * @returns The mode builder docgen runs in, or `undefined` when it must not run.
36
+ * @throws {BuilderDocgenPackagesMissingError} When the main config sets `features.docgenServer:
37
+ * false` and packages are missing.
38
+ */
39
+ declare function prepareReactBuilderDocgen({
40
+ reactDocgen,
41
+ builder,
42
+ resolve,
43
+ options
44
+ }: {
45
+ reactDocgen: Exclude<ReactDocgenConfig, false>;
46
+ builder: 'vite' | 'webpack'; /** Resolve from the framework package, which declares the packages as optional peers. */
47
+ resolve: (specifier: string) => string;
48
+ options: Pick<Options, 'configDir'>;
49
+ }): Promise<Exclude<ReactDocgenConfig, false> | undefined>;
50
+ //#endregion
51
+ export { REACT_BUILDER_DOCGEN_PACKAGES, ReactBuilderDocgenPackage, getReactBuilderDocgenPackages, isReactBuilderDocgenPackageInstalled, prepareReactBuilderDocgen };
@@ -0,0 +1,24 @@
1
+ import CJS_COMPAT_NODE_URL_19uq4gz0tcr from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_19uq4gz0tcr from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_19uq4gz0tcr from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_19uq4gz0tcr.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_19uq4gz0tcr.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_19uq4gz0tcr.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ REACT_BUILDER_DOCGEN_PACKAGES,
14
+ getReactBuilderDocgenPackages,
15
+ isReactBuilderDocgenPackageInstalled,
16
+ prepareReactBuilderDocgen
17
+ } from "./_node-chunks/chunk-PPFRYFMF.js";
18
+ import "./_node-chunks/chunk-RVHW3VEA.js";
19
+ export {
20
+ REACT_BUILDER_DOCGEN_PACKAGES,
21
+ getReactBuilderDocgenPackages,
22
+ isReactBuilderDocgenPackageInstalled,
23
+ prepareReactBuilderDocgen
24
+ };
@@ -86,6 +86,71 @@ interface ReactTypes extends ReactRenderer {
86
86
  parameters: ReactParameters;
87
87
  }
88
88
  type StoryFnReactReturnType = JSX.Element;
89
+ /**
90
+ * A prop as `react-docgen-typescript` passes it to a `propFilter` function.
91
+ *
92
+ * @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
93
+ */
94
+ interface ReactDocgenTypescriptPropItem {
95
+ name: string;
96
+ required: boolean;
97
+ type: {
98
+ name: string;
99
+ value?: any;
100
+ raw?: string;
101
+ };
102
+ description: string;
103
+ defaultValue: any;
104
+ parent?: {
105
+ name: string;
106
+ fileName: string;
107
+ };
108
+ declarations?: {
109
+ name: string;
110
+ fileName: string;
111
+ }[];
112
+ tags?: object;
113
+ }
114
+ /**
115
+ * The `react-docgen-typescript` parser options, which the deprecated builder docgen plugins of
116
+ * `@storybook/react-vite` and `@storybook/preset-react-webpack` accept.
117
+ *
118
+ * Copied from `react-docgen-typescript`'s declarations instead of imported: it is an optional peer
119
+ * dependency, and a `.d.ts` import of a missing package fails `tsc` without `skipLibCheck`. The
120
+ * TypeScript symbol and source file are typed structurally, because the TypeScript 7 `typescript`
121
+ * package has no compiler API types. Type tests in the frameworks keep this assignable both ways
122
+ * with the originals.
123
+ *
124
+ * @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
125
+ */
126
+ interface ReactDocgenTypescriptParserOptions {
127
+ propFilter?: {
128
+ skipPropsWithName?: string[] | string;
129
+ skipPropsWithoutDoc?: boolean;
130
+ } | {
131
+ bivarianceHack(prop: ReactDocgenTypescriptPropItem, component: {
132
+ name: string;
133
+ }): boolean;
134
+ }['bivarianceHack'];
135
+ componentNameResolver?: {
136
+ bivarianceHack(symbol: {
137
+ readonly name: string;
138
+ getName(): string;
139
+ }, source: {
140
+ readonly fileName: string;
141
+ readonly text: string;
142
+ }): string | undefined | null | false;
143
+ }['bivarianceHack'];
144
+ shouldExtractLiteralValuesFromEnum?: boolean;
145
+ shouldRemoveUndefinedFromOptional?: boolean;
146
+ shouldExtractValuesFromUnion?: boolean;
147
+ shouldSortUnions?: boolean;
148
+ skipChildrenPropWithoutDoc?: boolean;
149
+ savePropValueAsString?: boolean;
150
+ shouldIncludePropTagMap?: boolean;
151
+ shouldIncludeExpression?: boolean;
152
+ customComponentTypes?: string[];
153
+ }
89
154
  //#endregion
90
155
  //#region code/renderers/react/.dts-emit/code/renderers/react/src/preview.d.ts
91
156
  /**
@@ -236,4 +301,4 @@ interface ReactStory<T extends ReactTypes, TInput extends {
236
301
  Component: ComponentType<Partial<T['args']>>;
237
302
  }
238
303
  //#endregion
239
- export { ReactRenderer as a, __definePreview as i, ReactPreview as n, ReactTypes as o, ReactStory as r, Simplify as s, ReactMeta as t };
304
+ export { ReactDocgenTypescriptParserOptions as a, ReactTypes as c, __definePreview as i, Simplify as l, ReactPreview as n, ReactDocgenTypescriptPropItem as o, ReactStory as r, ReactRenderer as s, ReactMeta as t };
@@ -1,96 +1,28 @@
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";
1
+ import CJS_COMPAT_NODE_URL_19uq4gz0tcr from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_19uq4gz0tcr from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_19uq4gz0tcr from "node:module";
4
4
 
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);
5
+ var __filename = CJS_COMPAT_NODE_URL_19uq4gz0tcr.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_19uq4gz0tcr.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_19uq4gz0tcr.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
12
  import {
13
- ComponentMetaManager,
14
- buildComponentDocgenFromResolved,
15
- extractArgTypes,
16
- posix,
17
- resolveStoryFileComponents
18
- } from "../_node-chunks/chunk-AV7GEKV7.js";
13
+ buildDocgenPayload
14
+ } from "../_node-chunks/chunk-YNIH7TZQ.js";
15
+ import {
16
+ ComponentMetaManager
17
+ } from "../_node-chunks/chunk-U53ZMSA3.js";
18
+ import "../_node-chunks/chunk-IYZUDUNZ.js";
19
+ import "../_node-chunks/chunk-37XDLJI5.js";
20
+ import "../_node-chunks/chunk-FCIBS77S.js";
21
+ import "../_node-chunks/chunk-RVHW3VEA.js";
19
22
 
20
23
  // src/docgen/docgen-worker.ts
21
24
  import { createLazyDocgenMiddleware, loadTypeScriptCompilerApi } from "storybook/internal/common";
22
25
  import { logger } from "storybook/internal/node-logger";
23
-
24
- // src/docgen/buildDocgen.ts
25
- import { getStoryImportPathFromEntry } from "storybook/internal/common";
26
- var REACT_ATTRIBUTE_INTERFACES = /* @__PURE__ */ new Set(["Attributes", "RefAttributes", "ClassAttributes"]);
27
- function isReactAttribute(prop) {
28
- return !!prop.parent && REACT_ATTRIBUTE_INTERFACES.has(prop.parent.name) && /(^|[\\/])node_modules[\\/]/.test(prop.parent.fileName);
29
- }
30
- function extractArgTypesFromComponentMeta(componentMeta) {
31
- if (!componentMeta)
32
- return;
33
- let props = Object.fromEntries(
34
- Object.entries(componentMeta.props).filter(([, prop]) => !isReactAttribute(prop)).map(([name, prop]) => [
35
- name,
36
- prop.defaultValue ? { ...prop, defaultValue: { ...prop.defaultValue, computed: !1 } } : prop
37
- ])
38
- );
39
- return extractArgTypes({ __docgenInfo: { ...componentMeta, props } }) ?? void 0;
40
- }
41
- function addArgTypesFromComponentMeta(payload) {
42
- let argTypes = extractArgTypesFromComponentMeta(payload.reactComponentMeta), subcomponents = payload.subcomponents ? Object.fromEntries(
43
- Object.entries(payload.subcomponents).map(([name, subcomponent]) => [
44
- name,
45
- {
46
- ...subcomponent,
47
- argTypes: extractArgTypesFromComponentMeta(subcomponent.reactComponentMeta)
48
- }
49
- ])
50
- ) : void 0;
51
- return {
52
- ...payload,
53
- ...argTypes ? { argTypes } : {},
54
- ...subcomponents ? { subcomponents } : {}
55
- };
56
- }
57
- async function buildDocgenPayload(input, context) {
58
- let storyFilePath = getStoryImportPathFromEntry(input.entry);
59
- if (!storyFilePath)
60
- return;
61
- let storyPath = (context.resolvePath ?? ((importPath) => posix.join(process.cwd(), importPath)))(storyFilePath), resolved;
62
- try {
63
- resolved = await resolveStoryFileComponents({
64
- storyPath,
65
- title: input.entry.title,
66
- typescriptOptions: context.typescriptOptions,
67
- docgenEngine: "react-component-meta"
68
- });
69
- } catch {
70
- return;
71
- }
72
- let { csf, componentName, component, subcomponents, storyFile } = resolved, usableSubcomponents = subcomponents.filter(
73
- (sub) => sub.component !== void 0
74
- ), storyRefs = [
75
- ...component ? [{ storyPath, component }] : [],
76
- ...usableSubcomponents.map((sub) => ({ storyPath, component: sub.component }))
77
- ];
78
- storyRefs.length > 0 && context.componentMetaManager.batchExtract(storyRefs);
79
- let componentDocgen = buildComponentDocgenFromResolved({
80
- entry: input.entry,
81
- storyPath,
82
- storyFilePath,
83
- storyFile,
84
- csf,
85
- componentName,
86
- component,
87
- subcomponents,
88
- docgenEngine: "react-component-meta"
89
- });
90
- return addArgTypesFromComponentMeta(componentDocgen);
91
- }
92
-
93
- // src/docgen/docgen-worker.ts
94
26
  var createDocgenProvider = () => createLazyDocgenMiddleware({
95
27
  createManager: async () => {
96
28
  try {
@@ -5,7 +5,7 @@ import {
5
5
  parameters,
6
6
  render,
7
7
  renderToCanvas
8
- } from "./_browser-chunks/chunk-EZD3TIPB.js";
8
+ } from "./_browser-chunks/chunk-I62VTYU3.js";
9
9
  import {
10
10
  applyDecorators
11
11
  } from "./_browser-chunks/chunk-DDIRQRCA.js";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ReactRenderer, i as __definePreview, n as ReactPreview, o as ReactTypes, r as ReactStory, s as Simplify, t as ReactMeta } from "./chunk-DwM7QKaD.js";
1
+ import { a as ReactDocgenTypescriptParserOptions, c as ReactTypes, i as __definePreview, l as Simplify, n as ReactPreview, o as ReactDocgenTypescriptPropItem, r as ReactStory, s as ReactRenderer, t as ReactMeta } from "./chunk-6b3AvPEC.js";
2
2
  import { ComponentProps, ComponentType } from "react";
3
3
  import { AnnotatedStoryFn, ArgTypes, Args, Args as Args$1, ArgsFromMeta, ArgsStoryFn, ComponentAnnotations, ComposedStoryFn, DecoratorFunction, LoaderFunction, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, Parameters as Parameters$1, ProjectAnnotations, Store_CSFExports, StoriesWithPartialProps, StoryAnnotations, StoryAnnotationsOrFn, StoryContext as StoryContext$1, StrictArgs, StrictArgs as StrictArgs$1 } from "storybook/internal/types";
4
4
 
@@ -945,4 +945,4 @@ declare function composeStory<TArgs extends Args$1 = Args$1>(story: StoryAnnotat
945
945
  */
946
946
  declare function composeStories<TModule extends Store_CSFExports<ReactRenderer, any>>(csfExports: TModule, projectAnnotations?: ProjectAnnotations<ReactRenderer>): Omit<StoriesWithPartialProps<ReactRenderer, TModule>, keyof Store_CSFExports>;
947
947
  //#endregion
948
- export { AddMocks, type ArgTypes, type Args, Decorator, INTERNAL_DEFAULT_PROJECT_ANNOTATIONS, Loader, Meta, type Parameters$1 as Parameters, Preview, ReactMeta, ReactPreview, type ReactRenderer, ReactStory, type ReactTypes, StoryContext, StoryFn, StoryObj, type StrictArgs, __definePreview, composeStories, composeStory, setProjectAnnotations };
948
+ export { AddMocks, type ArgTypes, type Args, Decorator, INTERNAL_DEFAULT_PROJECT_ANNOTATIONS, Loader, Meta, type Parameters$1 as Parameters, Preview, type ReactDocgenTypescriptParserOptions, type ReactDocgenTypescriptPropItem, ReactMeta, ReactPreview, type ReactRenderer, ReactStory, type ReactTypes, StoryContext, StoryFn, StoryObj, type StrictArgs, __definePreview, composeStories, composeStory, setProjectAnnotations };
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  __definePreview
3
- } from "./_browser-chunks/chunk-7QIM3PHH.js";
3
+ } from "./_browser-chunks/chunk-6MBKXM7O.js";
4
4
  import {
5
5
  entry_preview_exports,
6
6
  renderToCanvas
7
- } from "./_browser-chunks/chunk-EZD3TIPB.js";
7
+ } from "./_browser-chunks/chunk-I62VTYU3.js";
8
8
  import {
9
9
  entry_preview_argtypes_exports
10
10
  } from "./_browser-chunks/chunk-LGSTPTL6.js";