@storybook/vue3 10.6.0-alpha.9 → 10.6.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.
- package/dist/_node-chunks/{chunk-TIYYAC6Z.js → chunk-NEU4ERNK.js} +36 -10
- package/dist/_node-chunks/{chunk-ZVNSPIKY.js → chunk-YSO6Z4KW.js} +6 -6
- package/dist/_node-chunks/{component-meta-QE4NY6QK.js → component-meta-G6I5IDW4.js} +7 -7
- package/dist/_node-chunks/{parsers-SBPFRAP5.js → parsers-G26HQI5M.js} +6 -6
- package/dist/_node-chunks/vue-docgen-api-MCLL7MVI.js +17 -0
- package/dist/docgen/docgen-worker.js +8 -8
- package/dist/preset.js +89 -41
- package/package.json +2 -2
- package/dist/_node-chunks/vue-docgen-api-G5RUC7NT.js +0 -17
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_buse9zdwx0t from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_buse9zdwx0t from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_buse9zdwx0t from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_buse9zdwx0t.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_buse9zdwx0t.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_buse9zdwx0t.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -56,7 +56,7 @@ var RESOLVABLE_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
56
56
|
]), UNDEFINED_IDENTIFIER = "undefined", NO_LOCALS = /* @__PURE__ */ new Set();
|
|
57
57
|
function classifyValue(node) {
|
|
58
58
|
let value = unwrapExpression(node);
|
|
59
|
-
return
|
|
59
|
+
return isUndefinedIdentifier(value) ? { kind: "unset" } : isFunctionExpression(value) || isEmptyString(value) ? { kind: "omit" } : isInlineLiteral(value) ? { kind: "inline" } : isResolvable(value) ? { kind: "hoist" } : { kind: "unrepresentable" };
|
|
60
60
|
}
|
|
61
61
|
function printValue(node) {
|
|
62
62
|
return recast.print(node, { tabWidth: 2 }).code;
|
|
@@ -181,7 +181,7 @@ function createRenderContext() {
|
|
|
181
181
|
}
|
|
182
182
|
function renderPreparedSfcSnippet(input) {
|
|
183
183
|
let template = `<template>
|
|
184
|
-
${indent(input.templateCode)}
|
|
184
|
+
${indent(normalizeTemplateBlock(input.templateCode))}
|
|
185
185
|
</template>`, script = renderScript(input.ctx);
|
|
186
186
|
return script ? `${script}
|
|
187
187
|
|
|
@@ -308,7 +308,7 @@ function hoistArgValue(name, value, ctx) {
|
|
|
308
308
|
function hoistModelRef(name, value, ctx) {
|
|
309
309
|
(ctx.imports[VUE_PACKAGE] ??= /* @__PURE__ */ new Set()).add("ref");
|
|
310
310
|
let bindingName = allocateBindingName(name, ctx);
|
|
311
|
-
return ctx.variables.set(bindingName, `ref(${printValue(unwrapExpression2(value))})`), bindingName;
|
|
311
|
+
return ctx.variables.set(bindingName, value ? `ref(${printValue(unwrapExpression2(value))})` : "ref()"), bindingName;
|
|
312
312
|
}
|
|
313
313
|
function importStatementForBinding(localName, binding) {
|
|
314
314
|
if (!(!binding || binding.importName === "*"))
|
|
@@ -330,7 +330,33 @@ ${indent(content)}
|
|
|
330
330
|
}
|
|
331
331
|
function indent(source) {
|
|
332
332
|
return source.split(`
|
|
333
|
-
`).map((line) => ` ${line}`).join(`
|
|
333
|
+
`).map((line) => line && ` ${line}`).join(`
|
|
334
|
+
`);
|
|
335
|
+
}
|
|
336
|
+
function normalizeTemplateBlock(source) {
|
|
337
|
+
let lines = source.split(`
|
|
338
|
+
`), start, end = 0, commonPrefix;
|
|
339
|
+
for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
|
|
340
|
+
let line = lines[lineIndex], contentIndex = line.search(/\S/);
|
|
341
|
+
if (contentIndex === -1) {
|
|
342
|
+
lines[lineIndex] = "";
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
if (start ??= lineIndex, end = lineIndex + 1, commonPrefix === void 0) {
|
|
346
|
+
commonPrefix = line.slice(0, contentIndex);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
let index = 0;
|
|
350
|
+
for (; index < commonPrefix.length && index < contentIndex && commonPrefix[index] === line[index]; )
|
|
351
|
+
index += 1;
|
|
352
|
+
commonPrefix = commonPrefix.slice(0, index);
|
|
353
|
+
}
|
|
354
|
+
if (start === void 0)
|
|
355
|
+
return "";
|
|
356
|
+
if (commonPrefix)
|
|
357
|
+
for (let lineIndex = start; lineIndex < end; lineIndex += 1)
|
|
358
|
+
lines[lineIndex] = lines[lineIndex].slice(commonPrefix.length);
|
|
359
|
+
return lines.slice(start, end).join(`
|
|
334
360
|
`);
|
|
335
361
|
}
|
|
336
362
|
function slotSortKey(name) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_buse9zdwx0t from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_buse9zdwx0t from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_buse9zdwx0t from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_buse9zdwx0t.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_buse9zdwx0t.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_buse9zdwx0t.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_buse9zdwx0t from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_buse9zdwx0t from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_buse9zdwx0t from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_buse9zdwx0t.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_buse9zdwx0t.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_buse9zdwx0t.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
applyVueDocgenApiTempFixes,
|
|
15
15
|
collectComponentMetaSources,
|
|
16
16
|
createVueComponentMetaChecker
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-YSO6Z4KW.js";
|
|
18
18
|
export {
|
|
19
19
|
CHECKER_OPTIONS,
|
|
20
20
|
applyVueDocgenApiTempFixes,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_buse9zdwx0t from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_buse9zdwx0t from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_buse9zdwx0t from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_buse9zdwx0t.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_buse9zdwx0t.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_buse9zdwx0t.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_buse9zdwx0t from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_buse9zdwx0t from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_buse9zdwx0t from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_buse9zdwx0t.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_buse9zdwx0t.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_buse9zdwx0t.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
// src/docgen/vue-docgen-api.ts
|
|
14
|
+
import { parse } from "vue-docgen-api";
|
|
15
|
+
export {
|
|
16
|
+
parse
|
|
17
|
+
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_buse9zdwx0t from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_buse9zdwx0t from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_buse9zdwx0t from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_buse9zdwx0t.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_buse9zdwx0t.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_buse9zdwx0t.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
13
|
indent
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
14
|
+
} from "../_node-chunks/chunk-NEU4ERNK.js";
|
|
15
15
|
import {
|
|
16
16
|
CHECKER_OPTIONS,
|
|
17
17
|
collectComponentMetaSources
|
|
18
|
-
} from "../_node-chunks/chunk-
|
|
18
|
+
} from "../_node-chunks/chunk-YSO6Z4KW.js";
|
|
19
19
|
|
|
20
20
|
// src/docgen/docgen-worker.ts
|
|
21
21
|
import { createLazyDocgenMiddleware } from "storybook/internal/common";
|
package/dist/preset.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_buse9zdwx0t from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_buse9zdwx0t from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_buse9zdwx0t from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_buse9zdwx0t.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_buse9zdwx0t.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_buse9zdwx0t.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
renderPropLikeArg,
|
|
32
32
|
renderSlotContent,
|
|
33
33
|
wrapSlotContent
|
|
34
|
-
} from "./_node-chunks/chunk-
|
|
34
|
+
} from "./_node-chunks/chunk-NEU4ERNK.js";
|
|
35
35
|
|
|
36
36
|
// src/preset.ts
|
|
37
37
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -79,12 +79,12 @@ import {
|
|
|
79
79
|
// src/story-docs/classify-args.ts
|
|
80
80
|
import { returnedExpression, unwrapExpression } from "storybook/internal/csf-tools";
|
|
81
81
|
function classifyArgs(args, docgen) {
|
|
82
|
-
let classified = [], unresolved = [];
|
|
82
|
+
let classified = [], unset = /* @__PURE__ */ new Set(), unresolved = [];
|
|
83
83
|
for (let [name, value] of Object.entries(args)) {
|
|
84
84
|
let result = classifyArg(name, value, docgen);
|
|
85
|
-
result.kind === "classified" ? classified.push(result.arg) : result.kind === "unrepresentable" && unresolved.push(`${name}: ${printValue(value)}`);
|
|
85
|
+
result.kind === "classified" ? classified.push(result.arg) : result.kind === "unset" ? unset.add(name) : result.kind === "unrepresentable" && unresolved.push(`${name}: ${printValue(value)}`);
|
|
86
86
|
}
|
|
87
|
-
return { args: classified, unresolved };
|
|
87
|
+
return { args: classified, unset, unresolved };
|
|
88
88
|
}
|
|
89
89
|
function classifyArg(name, value, docgen) {
|
|
90
90
|
let isSlot = docgen.slots.has(name);
|
|
@@ -97,7 +97,7 @@ function classifyArg(name, value, docgen) {
|
|
|
97
97
|
kind: "classified",
|
|
98
98
|
arg: { name, value: returned, role: "slot", plan: plan2 }
|
|
99
99
|
};
|
|
100
|
-
if (plan2.kind === "omit")
|
|
100
|
+
if (plan2.kind === "omit" || plan2.kind === "unset")
|
|
101
101
|
return { kind: "omit" };
|
|
102
102
|
}
|
|
103
103
|
return {
|
|
@@ -114,7 +114,7 @@ function classifyArg(name, value, docgen) {
|
|
|
114
114
|
if (isFunctionExpression(value))
|
|
115
115
|
return docgen.props.has(name) ? isSelfContainedFunction(value) ? { kind: "classified", arg: { name, value, role: "prop", plan: { kind: "hoist" } } } : { kind: "unrepresentable" } : { kind: "omit" };
|
|
116
116
|
let plan = classifyValue(value);
|
|
117
|
-
return plan.kind === "omit" || plan.kind === "unrepresentable" ? { kind: plan.kind } : {
|
|
117
|
+
return plan.kind === "omit" || plan.kind === "unrepresentable" ? { kind: plan.kind } : plan.kind === "unset" ? { kind: "unset" } : {
|
|
118
118
|
kind: "classified",
|
|
119
119
|
arg: isSlot ? { name, value, role: "slot", plan } : {
|
|
120
120
|
name,
|
|
@@ -264,7 +264,7 @@ function printProps(node, tag, options) {
|
|
|
264
264
|
let classification = classifyArg(name, propValue, docgen);
|
|
265
265
|
if (classification.kind === "unrepresentable" || classification.kind === "omit" && isFunctionExpression(propValue))
|
|
266
266
|
return;
|
|
267
|
-
if (classification.kind === "omit")
|
|
267
|
+
if (classification.kind === "omit" || classification.kind === "unset")
|
|
268
268
|
continue;
|
|
269
269
|
let arg = classification.arg;
|
|
270
270
|
if (arg.role === "slot") {
|
|
@@ -699,7 +699,7 @@ function renderSlotArgContent(arg, ctx, importBindings, componentImportStatement
|
|
|
699
699
|
}
|
|
700
700
|
|
|
701
701
|
// src/story-docs/transform-template.ts
|
|
702
|
-
var ARGS_NAME3 = "args", ARGS_IDENTIFIER_REGEXP = /(^|[^\w$])args([^\w$]|$)/, ARGS_MEMBER_REGEXP = /^args\.([A-Za-z_$][\w$]*)$/, SETUP_PROPERTY = "setup", TEMPLATE_UNREADABLE_WARNING = "No static snippet: the `template` could not be read statically.", COMPONENTS_UNREADABLE_WARNING = "No static snippet: the `components` map could not be read statically.";
|
|
702
|
+
var ARGS_NAME3 = "args", ARGS_IDENTIFIER_REGEXP = /(^|[^\w$])args([^\w$]|$)/, ARGS_MEMBER_REGEXP = /^args\.([A-Za-z_$][\w$]*)$/, BLANK_REGEXP = /[ \t]/, SETUP_PROPERTY = "setup", TEMPLATE_UNREADABLE_WARNING = "No static snippet: the `template` could not be read statically.", COMPONENTS_UNREADABLE_WARNING = "No static snippet: the `components` map could not be read statically.";
|
|
703
703
|
function readTemplateRenderConfig(renderObject, importBindings, options = {}) {
|
|
704
704
|
if (!hasOnlySupportedRenderProperties(renderObject))
|
|
705
705
|
return { kind: "skip" };
|
|
@@ -735,6 +735,7 @@ function transformTemplate(input) {
|
|
|
735
735
|
return;
|
|
736
736
|
let state = {
|
|
737
737
|
argsByName: new Map(input.args.map((arg) => [arg.name, arg])),
|
|
738
|
+
unsetArgs: input.unsetArgs,
|
|
738
739
|
ctx: input.ctx ?? createRenderContext(),
|
|
739
740
|
edits: [],
|
|
740
741
|
componentImports: input.componentImports,
|
|
@@ -768,10 +769,10 @@ function appendSetupStatements(setup, state) {
|
|
|
768
769
|
for (let statement of setup.statements) {
|
|
769
770
|
let text = statement.source;
|
|
770
771
|
for (let read of [...statement.argsReads].sort((a, b) => b.start - a.start)) {
|
|
771
|
-
let arg = state.argsByName.get(read.name);
|
|
772
|
-
if (
|
|
772
|
+
let arg = state.argsByName.get(read.name), rendered = arg ? arg.role === "prop" ? arg.plan.kind === "inline" ? printValue(unwrapExpression5(arg.value)) : hoistArgValue(arg.name, arg.value, state.ctx) : void 0 : state.unsetArgs.has(read.name) ? "undefined" : void 0;
|
|
773
|
+
if (rendered === void 0)
|
|
773
774
|
return !1;
|
|
774
|
-
let
|
|
775
|
+
let wrapped = wrapSubstitution(rendered, text.slice(read.end));
|
|
775
776
|
text = text.slice(0, read.start) + wrapped + text.slice(read.end);
|
|
776
777
|
}
|
|
777
778
|
text = text.replace(/\r\n?/g, `
|
|
@@ -801,7 +802,12 @@ function transformInterpolation(node, state) {
|
|
|
801
802
|
let edit = substituteArgsExpression(expressionNode, state, "interpolation");
|
|
802
803
|
return edit ? (state.edits.push(edit), !0) : !1;
|
|
803
804
|
}
|
|
804
|
-
let arg = state.argsByName.get(argName)
|
|
805
|
+
let arg = state.argsByName.get(argName);
|
|
806
|
+
if (!arg && state.unsetArgs.has(argName))
|
|
807
|
+
return state.edits.push({ start: node.loc.start.offset, end: node.loc.end.offset, text: "" }), !0;
|
|
808
|
+
if (!arg)
|
|
809
|
+
return !1;
|
|
810
|
+
let rendered = inlinePrimitiveSource(arg.value);
|
|
805
811
|
if (rendered === void 0)
|
|
806
812
|
return !1;
|
|
807
813
|
let text = escapeTextContent(rendered), start = node.loc.start.offset, end = node.loc.end.offset;
|
|
@@ -879,7 +885,11 @@ function transformDirective(directive, attributesByName, element, state) {
|
|
|
879
885
|
let expressionNode = directive.exp?.type === NodeTypes.SIMPLE_EXPRESSION ? directive.exp : void 0, expression = expressionNode?.content.trim(), boundProp = staticDirectiveArg(directive), argName = expression === void 0 ? void 0 : exactArgsMemberName(expression);
|
|
880
886
|
if (directive.name === "bind" && boundProp && directive.modifiers.length === 0 && argName) {
|
|
881
887
|
let arg = state.argsByName.get(argName);
|
|
882
|
-
if (
|
|
888
|
+
if ((attributesByName.get(boundProp)?.length ?? 0) > 1)
|
|
889
|
+
return !1;
|
|
890
|
+
if (!arg && state.unsetArgs.has(argName))
|
|
891
|
+
return state.edits.push(replacementFor(directive, "", state.template)), !0;
|
|
892
|
+
if (!arg)
|
|
883
893
|
return !1;
|
|
884
894
|
if (arg.role === "slot") {
|
|
885
895
|
if (!element.storyTag)
|
|
@@ -900,7 +910,7 @@ function transformDirective(directive, attributesByName, element, state) {
|
|
|
900
910
|
}
|
|
901
911
|
if (directive.name === "on" && boundProp && argName && expressionNode) {
|
|
902
912
|
let arg = state.argsByName.get(argName);
|
|
903
|
-
return !arg || !isFunctionExpression(arg.value) ? !1 : (state.edits.push({
|
|
913
|
+
return !arg && state.unsetArgs.has(argName) ? (state.edits.push(replacementFor(directive, "", state.template)), !0) : !arg || !isFunctionExpression(arg.value) ? !1 : (state.edits.push({
|
|
904
914
|
start: expressionNode.loc.start.offset,
|
|
905
915
|
end: expressionNode.loc.end.offset,
|
|
906
916
|
text: hoistArgValue(argName, arg.value, state.ctx)
|
|
@@ -908,10 +918,10 @@ function transformDirective(directive, attributesByName, element, state) {
|
|
|
908
918
|
}
|
|
909
919
|
if (directive.name === "model" && argName && expressionNode) {
|
|
910
920
|
let arg = state.argsByName.get(argName);
|
|
911
|
-
return !arg || arg.role === "slot" || arg.role === "event" ? !1 : (state.edits.push({
|
|
921
|
+
return !arg && !state.unsetArgs.has(argName) || arg && (arg.role === "slot" || arg.role === "event") ? !1 : (state.edits.push({
|
|
912
922
|
start: expressionNode.loc.start.offset,
|
|
913
923
|
end: expressionNode.loc.end.offset,
|
|
914
|
-
text: hoistModelRef(argName, arg
|
|
924
|
+
text: hoistModelRef(argName, arg?.value, state.ctx)
|
|
915
925
|
}), !0);
|
|
916
926
|
}
|
|
917
927
|
if (!expressionNode || !expression || !valueReferencesArgs(expression))
|
|
@@ -1031,6 +1041,8 @@ function isAllowedArgsObject(node, parent) {
|
|
|
1031
1041
|
}
|
|
1032
1042
|
function replacementForArgsReference(reference, quote, state) {
|
|
1033
1043
|
let arg = state.argsByName.get(reference.name);
|
|
1044
|
+
if (!arg && state.unsetArgs.has(reference.name))
|
|
1045
|
+
return "undefined";
|
|
1034
1046
|
if (!arg || arg.role === "slot")
|
|
1035
1047
|
return;
|
|
1036
1048
|
let text = arg.plan.kind === "inline" ? printValue(unwrapExpression5(arg.value)) : hoistArgValue(arg.name, arg.value, state.ctx);
|
|
@@ -1038,11 +1050,36 @@ function replacementForArgsReference(reference, quote, state) {
|
|
|
1038
1050
|
return text;
|
|
1039
1051
|
}
|
|
1040
1052
|
function replacementFor(prop, text, template) {
|
|
1041
|
-
let start = prop.loc.start.offset;
|
|
1042
|
-
if (text
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
return
|
|
1053
|
+
let start = prop.loc.start.offset, end = prop.loc.end.offset;
|
|
1054
|
+
if (text !== "")
|
|
1055
|
+
return { start, end, text };
|
|
1056
|
+
let lineStart = blankRunStart(template, start), lineEnd = blankRunEnd(template, end), lineTerminator = lineTerminatorAt(template, lineEnd);
|
|
1057
|
+
return template[lineStart - 1] === `
|
|
1058
|
+
` && lineTerminator ? {
|
|
1059
|
+
start: previousLineTerminatorStart(template, lineStart),
|
|
1060
|
+
end: lineTerminator.start,
|
|
1061
|
+
text
|
|
1062
|
+
} : { start: lineStart, end, text };
|
|
1063
|
+
}
|
|
1064
|
+
function blankRunStart(template, index) {
|
|
1065
|
+
let cursor = index;
|
|
1066
|
+
for (; cursor > 0 && BLANK_REGEXP.test(template[cursor - 1]); )
|
|
1067
|
+
cursor -= 1;
|
|
1068
|
+
return cursor;
|
|
1069
|
+
}
|
|
1070
|
+
function blankRunEnd(template, index) {
|
|
1071
|
+
let cursor = index;
|
|
1072
|
+
for (; cursor < template.length && BLANK_REGEXP.test(template[cursor]); )
|
|
1073
|
+
cursor += 1;
|
|
1074
|
+
return cursor;
|
|
1075
|
+
}
|
|
1076
|
+
function lineTerminatorAt(template, index) {
|
|
1077
|
+
return template[index] === "\r" && template[index + 1] === `
|
|
1078
|
+
` ? { start: index } : template[index] === `
|
|
1079
|
+
` ? { start: index } : void 0;
|
|
1080
|
+
}
|
|
1081
|
+
function previousLineTerminatorStart(template, index) {
|
|
1082
|
+
return template[index - 2] === "\r" ? index - 2 : index - 1;
|
|
1046
1083
|
}
|
|
1047
1084
|
function slotChildrenEdit(node, children, template) {
|
|
1048
1085
|
let baseIndent = " ".repeat(Math.max(node.loc.start.column - 1, 0)), joined = `
|
|
@@ -1149,7 +1186,11 @@ function setupProperty(renderObject) {
|
|
|
1149
1186
|
}
|
|
1150
1187
|
|
|
1151
1188
|
// src/story-docs/build-story-docs.ts
|
|
1152
|
-
var openStoryReferences = createStoryReferenceResolver({ extensions: [".vue"] }), RENDER_UNRESOLVED_WARNING = "No static snippet: the `render` function could not be resolved statically.", SLOT_UNRESOLVED_WARNING = "No static snippet: a slot function could not be resolved statically.", IMPORT_UNRESOLVED_WARNING = "No static snippet: the component's import could not be resolved statically."
|
|
1189
|
+
var openStoryReferences = createStoryReferenceResolver({ extensions: [".vue"] }), RENDER_UNRESOLVED_WARNING = "No static snippet: the `render` function could not be resolved statically.", SLOT_UNRESOLVED_WARNING = "No static snippet: a slot function could not be resolved statically.", IMPORT_UNRESOLVED_WARNING = "No static snippet: the component's import could not be resolved statically.", TEMPLATE_UNRESOLVED_WARNING = "No static snippet: the story template could not be resolved statically.", UNRENDERED_WARNINGS = {
|
|
1190
|
+
h: RENDER_UNRESOLVED_WARNING,
|
|
1191
|
+
sfc: SLOT_UNRESOLVED_WARNING,
|
|
1192
|
+
template: TEMPLATE_UNRESOLVED_WARNING
|
|
1193
|
+
};
|
|
1153
1194
|
async function buildStoryDocsPayload(input, context = {}) {
|
|
1154
1195
|
let storyFilePath = getStoryImportPathFromEntry(input.entry);
|
|
1155
1196
|
if (!storyFilePath || !STORY_FILE_TEST_REGEXP.test(storyFilePath))
|
|
@@ -1256,17 +1297,21 @@ function enrichStoryDoc(csf, storyExport, storyDoc, options) {
|
|
|
1256
1297
|
return withWarning(renderer.warning);
|
|
1257
1298
|
if (renderer.kind === "sfc" && !componentImportStatement)
|
|
1258
1299
|
return withWarning(IMPORT_UNRESOLVED_WARNING);
|
|
1259
|
-
let resolved = resolveStaticStoryArgs(storyExport, docgenArgInfo, options), { args, unresolved: classifyUnresolved } =
|
|
1300
|
+
let resolved = resolveStaticStoryArgs(storyExport, docgenArgInfo, options), { classified } = resolved, { args, unresolved: classifyUnresolved } = classified, unresolved = [...classifyUnresolved, ...resolved.unresolved];
|
|
1260
1301
|
if (args.length === 0 && unresolved.length > 0)
|
|
1261
1302
|
return withWarning(noSnippetWarning(unresolved));
|
|
1262
|
-
let rendered = renderStaticStorySnippet(
|
|
1303
|
+
let rendered = renderStaticStorySnippet(
|
|
1304
|
+
renderer,
|
|
1305
|
+
classified,
|
|
1306
|
+
componentName,
|
|
1307
|
+
docgenArgInfo,
|
|
1308
|
+
options
|
|
1309
|
+
);
|
|
1263
1310
|
return rendered ? {
|
|
1264
1311
|
...storyDoc,
|
|
1265
1312
|
snippet: rendered.snippet,
|
|
1266
1313
|
...unresolved.length > 0 ? { warning: unresolvedWarning(unresolved) } : {}
|
|
1267
|
-
} : withWarning(
|
|
1268
|
-
renderer.kind === "sfc" ? SLOT_UNRESOLVED_WARNING : RENDER_UNRESOLVED_WARNING
|
|
1269
|
-
);
|
|
1314
|
+
} : withWarning(UNRENDERED_WARNINGS[renderer.kind]);
|
|
1270
1315
|
}
|
|
1271
1316
|
function staticRendererForRenderFunction(renderFunction, options) {
|
|
1272
1317
|
let renderObject = resolveReturnedObjectExpression(renderFunction);
|
|
@@ -1303,15 +1348,16 @@ function resolveStaticStoryArgs(storyExport, docgenArgInfo, options) {
|
|
|
1303
1348
|
unresolved: resolved.unresolved
|
|
1304
1349
|
};
|
|
1305
1350
|
}
|
|
1306
|
-
function renderStaticStorySnippet(renderer,
|
|
1307
|
-
let componentImportStatement = options.snippet?.componentImportStatement;
|
|
1351
|
+
function renderStaticStorySnippet(renderer, classified, componentName, docgenArgInfo, options) {
|
|
1352
|
+
let componentImportStatement = options.snippet?.componentImportStatement, { args } = classified;
|
|
1308
1353
|
if (renderer.kind === "sfc")
|
|
1309
1354
|
return componentImportStatement ? transformTemplate({
|
|
1310
1355
|
args,
|
|
1311
1356
|
componentImports: /* @__PURE__ */ new Map([[componentName, componentImportStatement]]),
|
|
1312
1357
|
componentName,
|
|
1313
1358
|
importBindings: options.importBindings,
|
|
1314
|
-
template: `<${componentName} v-bind="args"
|
|
1359
|
+
template: `<${componentName} v-bind="args" />`,
|
|
1360
|
+
unsetArgs: classified.unset
|
|
1315
1361
|
}) : void 0;
|
|
1316
1362
|
if (renderer.kind === "template")
|
|
1317
1363
|
return transformTemplate({
|
|
@@ -1320,7 +1366,8 @@ function renderStaticStorySnippet(renderer, args, componentName, docgenArgInfo,
|
|
|
1320
1366
|
componentName,
|
|
1321
1367
|
importBindings: options.importBindings,
|
|
1322
1368
|
setup: renderer.setup,
|
|
1323
|
-
template: renderer.template
|
|
1369
|
+
template: renderer.template,
|
|
1370
|
+
unsetArgs: classified.unset
|
|
1324
1371
|
});
|
|
1325
1372
|
let ctx = createRenderContext(), printed = printH({
|
|
1326
1373
|
argsParam: renderer.argsParam,
|
|
@@ -1338,7 +1385,8 @@ function renderStaticStorySnippet(renderer, args, componentName, docgenArgInfo,
|
|
|
1338
1385
|
componentName,
|
|
1339
1386
|
ctx,
|
|
1340
1387
|
importBindings: options.importBindings,
|
|
1341
|
-
template: printed.template
|
|
1388
|
+
template: printed.template,
|
|
1389
|
+
unsetArgs: classified.unset
|
|
1342
1390
|
});
|
|
1343
1391
|
}
|
|
1344
1392
|
function setupReturnedRenderExpression(renderObject) {
|
|
@@ -1401,11 +1449,11 @@ var previewAnnotations = async (input = [], options) => {
|
|
|
1401
1449
|
docsEnabled ? [fileURLToPath2(import.meta.resolve("@storybook/vue3/entry-preview-docs"))] : []
|
|
1402
1450
|
);
|
|
1403
1451
|
}, experimental_importParsers = async (input = []) => {
|
|
1404
|
-
let { vueImportParser } = await import("./_node-chunks/parsers-
|
|
1452
|
+
let { vueImportParser } = await import("./_node-chunks/parsers-G26HQI5M.js");
|
|
1405
1453
|
return [...input, vueImportParser];
|
|
1406
1454
|
}, experimental_vueDocgenEngine = async () => ({
|
|
1407
|
-
componentMeta: () => import("./_node-chunks/component-meta-
|
|
1408
|
-
vueDocgenApi: () => import("./_node-chunks/vue-docgen-api-
|
|
1455
|
+
componentMeta: () => import("./_node-chunks/component-meta-G6I5IDW4.js"),
|
|
1456
|
+
vueDocgenApi: () => import("./_node-chunks/vue-docgen-api-MCLL7MVI.js")
|
|
1409
1457
|
});
|
|
1410
1458
|
export {
|
|
1411
1459
|
DOCGEN_WORKER_SPECIFIER,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/vue3",
|
|
3
|
-
"version": "10.6.0-
|
|
3
|
+
"version": "10.6.0-beta.1",
|
|
4
4
|
"description": "Storybook Vue 3 renderer: Develop, document, and test UI components in isolation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"vue-tsc": "latest"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"storybook": "^10.6.0-
|
|
68
|
+
"storybook": "^10.6.0-beta.1",
|
|
69
69
|
"typescript": ">= 4.9.x",
|
|
70
70
|
"vue": "^3.0.0"
|
|
71
71
|
},
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_wgawtq5ff0t from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_wgawtq5ff0t from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_wgawtq5ff0t from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_wgawtq5ff0t.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_wgawtq5ff0t.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_wgawtq5ff0t.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
|
|
13
|
-
// src/docgen/vue-docgen-api.ts
|
|
14
|
-
import { parse } from "vue-docgen-api";
|
|
15
|
-
export {
|
|
16
|
-
parse
|
|
17
|
-
};
|