@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
|
@@ -18,6 +18,40 @@ __export(entry_preview_docs_exports, {
|
|
|
18
18
|
parameters: () => parameters
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
// src/docs/print-hole.ts
|
|
22
|
+
import { printValue, unknownHoleKind } from "storybook/internal/docs-tools";
|
|
23
|
+
|
|
24
|
+
// src/snippet-values.ts
|
|
25
|
+
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]/.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) => {
|
|
26
|
+
let unnamed = args.filter(([name]) => !isAttributeName(name)), attributes = args.filter(([name]) => isAttributeName(name)).map(([name, value]) => mark({ kind: "attr", arg: name }, printAttribute(name, value)));
|
|
27
|
+
if (unnamed.length !== 0) {
|
|
28
|
+
let members = unnamed.map(
|
|
29
|
+
([name, value]) => `${JSON.stringify(name)}: ${mark({ kind: "value", arg: name }, valueCode(value))}`
|
|
30
|
+
);
|
|
31
|
+
attributes.push(`{...{ ${members.join(", ")} }}`);
|
|
32
|
+
}
|
|
33
|
+
return attributes;
|
|
34
|
+
}, printChildren = (value) => value.kind === "string" && isChildText(value.value) ? value.value : value.kind === "jsx" ? value.code : `{${valueCode(value)}}`;
|
|
35
|
+
|
|
36
|
+
// src/docs/print-hole.ts
|
|
37
|
+
var printHole = (hole, value) => {
|
|
38
|
+
let arg = hole.arg ?? "";
|
|
39
|
+
switch (hole.kind) {
|
|
40
|
+
case "attr":
|
|
41
|
+
return value === void 0 ? "" : printAttribute(hole.name ?? arg, toJsxValue(arg, value));
|
|
42
|
+
case "text":
|
|
43
|
+
return value === void 0 ? "" : printChildren(toJsxValue(arg, value));
|
|
44
|
+
case "value":
|
|
45
|
+
return printValue(value, arg);
|
|
46
|
+
case "attrs":
|
|
47
|
+
return printAttributes(
|
|
48
|
+
Object.entries(value).filter(([name]) => !hole.except.includes(name)).map(([name, item]) => [name, toJsxValue(name, item)])
|
|
49
|
+
).map((attribute) => ` ${attribute}`).join("");
|
|
50
|
+
default:
|
|
51
|
+
return unknownHoleKind(hole);
|
|
52
|
+
}
|
|
53
|
+
}, toJsxValue = (name, value) => typeof value == "boolean" ? { kind: "boolean", value } : typeof value == "string" ? { kind: "string", value, code: printValue(value, name) } : { kind: "code", code: printValue(value, name) };
|
|
54
|
+
|
|
21
55
|
// src/docs/jsxDecorator.tsx
|
|
22
56
|
import React, { createElement, isValidElement } from "react";
|
|
23
57
|
import { logger } from "storybook/internal/client-logger";
|
|
@@ -131,7 +165,8 @@ var applyDecorators2 = (storyFn, decorators2) => {
|
|
|
131
165
|
// src/entry-preview-docs.ts
|
|
132
166
|
var useStaticServiceSnippets = "FEATURES" in globalThis && globalThis?.FEATURES?.docgenServer, useCompileTimeSnippets = "FEATURES" in globalThis && globalThis?.FEATURES?.experimentalCodeExamples, decorators = useStaticServiceSnippets || useCompileTimeSnippets ? [] : [jsxDecorator], parameters = {
|
|
133
167
|
docs: {
|
|
134
|
-
story: { inline: !0 }
|
|
168
|
+
story: { inline: !0 },
|
|
169
|
+
...useStaticServiceSnippets ? { source: { printHole } } : {}
|
|
135
170
|
}
|
|
136
171
|
};
|
|
137
172
|
|
|
@@ -60,6 +60,22 @@ function withGlobalActEnvironment(actImplementation) {
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
+
function createEventWrapper(act) {
|
|
64
|
+
let isInsideAct = !1;
|
|
65
|
+
return (cb) => {
|
|
66
|
+
if (isInsideAct)
|
|
67
|
+
return cb();
|
|
68
|
+
isInsideAct = !0;
|
|
69
|
+
try {
|
|
70
|
+
let result;
|
|
71
|
+
return act(() => {
|
|
72
|
+
result = cb();
|
|
73
|
+
}), result;
|
|
74
|
+
} finally {
|
|
75
|
+
isInsideAct = !1;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
63
79
|
var getAct = async ({ disableAct = !1 } = {}) => {
|
|
64
80
|
if (process.env.NODE_ENV === "production" || disableAct)
|
|
65
81
|
return (cb) => cb();
|
|
@@ -196,10 +212,7 @@ var decorators = [
|
|
|
196
212
|
setReactActEnvironment(previousActEnvironment);
|
|
197
213
|
}
|
|
198
214
|
},
|
|
199
|
-
eventWrapper: (
|
|
200
|
-
let result;
|
|
201
|
-
return act(() => (result = cb(), result)), result;
|
|
202
|
-
}
|
|
215
|
+
eventWrapper: createEventWrapper(act)
|
|
203
216
|
});
|
|
204
217
|
} catch {
|
|
205
218
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
entry_preview_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-I62VTYU3.js";
|
|
4
4
|
import {
|
|
5
5
|
entry_preview_argtypes_exports
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WWHCZJWM.js";
|
|
7
7
|
import {
|
|
8
8
|
entry_preview_docs_exports
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EA5DV32Q.js";
|
|
10
10
|
|
|
11
11
|
// src/preview.tsx
|
|
12
12
|
import { definePreview as definePreviewBase } from "storybook/internal/csf";
|
|
@@ -5949,22 +5949,23 @@ function generateCode(ast, compact = !1) {
|
|
|
5949
5949
|
return (0, import_escodegen.generate)(ast, compact ? COMPACT_OPTIONS : PRETTY_OPTIONS);
|
|
5950
5950
|
}
|
|
5951
5951
|
function generateObjectCode(ast, compact = !1) {
|
|
5952
|
-
return compact ?
|
|
5953
|
-
}
|
|
5954
|
-
function generateCompactObjectCode(ast) {
|
|
5955
|
-
let result = generateCode(ast, !0);
|
|
5956
|
-
return result.endsWith(" }") || (result = `${result.slice(0, -1)} }`), result;
|
|
5952
|
+
return compact ? generateCompactCode(ast) : generateCode(ast);
|
|
5957
5953
|
}
|
|
5958
5954
|
function generateArrayCode(ast, compact = !1) {
|
|
5959
|
-
return compact ?
|
|
5955
|
+
return compact ? generateCompactCode(ast) : generateMultilineArrayCode(ast);
|
|
5960
5956
|
}
|
|
5961
5957
|
function generateMultilineArrayCode(ast) {
|
|
5962
5958
|
let result = generateCode(ast);
|
|
5963
5959
|
return result.endsWith(" }]") && (result = dedent(result)), result;
|
|
5964
5960
|
}
|
|
5965
|
-
function
|
|
5966
|
-
|
|
5967
|
-
|
|
5961
|
+
function generateCompactCode(ast) {
|
|
5962
|
+
return ast.type === "ArrayExpression" ? `[${ast.elements.map(generateCompactCode).join(", ")}]` : ast.type === "ObjectExpression" ? `{ ${ast.properties.map(generateCompactProperty).join(", ")} }` : generateCode(ast, !0);
|
|
5963
|
+
}
|
|
5964
|
+
function generateCompactProperty(property) {
|
|
5965
|
+
if (property.type !== "Property" || property.kind !== "init" || property.method || property.shorthand)
|
|
5966
|
+
return generateCode(property, !0);
|
|
5967
|
+
let key = generateCode(property.key, !0);
|
|
5968
|
+
return `${property.computed ? `[${key}]` : key}: ${generateCompactCode(property.value)}`;
|
|
5968
5969
|
}
|
|
5969
5970
|
|
|
5970
5971
|
// src/docs/lib/inspection/acornParser.ts
|