@storybook/vue3 11.0.0-alpha.7 → 11.0.0-alpha.8

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 CJS_COMPAT_NODE_URL_6gh9awpayy7 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6gh9awpayy7 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6gh9awpayy7 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6gh9awpayy7.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6gh9awpayy7.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6gh9awpayy7.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1,25 +1,29 @@
1
- import CJS_COMPAT_NODE_URL_6gh9awpayy7 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6gh9awpayy7 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6gh9awpayy7 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6gh9awpayy7.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6gh9awpayy7.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6gh9awpayy7.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.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
 
13
13
  // src/docgen/shared/render-primitives.ts
14
- import { types as t } from "storybook/internal/babel";
15
14
  import {
16
15
  buildImportStatements,
16
+ isStringLiteral as isStringLiteral2,
17
17
  unwrapExpression as unwrapExpression2
18
18
  } from "storybook/internal/csf-tools";
19
19
 
20
20
  // src/docgen/shared/classify-value.ts
21
- import { recast } from "storybook/internal/babel";
22
- import { unwrapExpression } from "storybook/internal/csf-tools";
21
+ import {
22
+ textOf,
23
+ isStringLiteral,
24
+ unwrapExpression,
25
+ walk
26
+ } from "storybook/internal/csf-tools";
23
27
  var RESOLVABLE_GLOBALS = /* @__PURE__ */ new Set([
24
28
  "Array",
25
29
  "BigInt",
@@ -59,7 +63,27 @@ function classifyValue(node) {
59
63
  return isUndefinedIdentifier(value) ? { kind: "unset" } : isFunctionExpression(value) || isEmptyString(value) ? { kind: "omit" } : isInlineLiteral(value) ? { kind: "inline" } : isResolvable(value) ? { kind: "hoist" } : { kind: "unrepresentable" };
60
64
  }
61
65
  function printValue(node) {
62
- return recast.print(node, { tabWidth: 2 }).code;
66
+ let source = textOf(node), lines = source.split(`
67
+ `);
68
+ if (lines.length === 1)
69
+ return source;
70
+ let { start } = node, quasis = [];
71
+ walk(node, (child) => {
72
+ if (child.type === "TemplateElement") {
73
+ let span = child;
74
+ quasis.push([span.start - start, span.end - start]);
75
+ }
76
+ });
77
+ let offset = 0, dedentable = lines.map((line, index) => {
78
+ let lineStart = offset;
79
+ return offset += line.length + 1, index > 0 && !quasis.some(([from, to]) => from < lineStart && lineStart <= to);
80
+ }), depth = Math.min(
81
+ ...lines.filter((line, index) => dedentable[index] && line.trim() !== "").map((line) => line.search(/\S/))
82
+ );
83
+ return Number.isFinite(depth) && depth > 0 ? lines.map(
84
+ (line, index) => dedentable[index] ? line.slice(Math.min(depth, line.search(/\S|$/))) : line
85
+ ).join(`
86
+ `) : source;
63
87
  }
64
88
  function isFunctionExpression(node) {
65
89
  let unwrapped = unwrapExpression(node);
@@ -74,7 +98,7 @@ function isSelfContainedFunction(node) {
74
98
  if (fn.type !== "ArrowFunctionExpression" && fn.type !== "FunctionExpression")
75
99
  return !1;
76
100
  let locals = /* @__PURE__ */ new Set();
77
- return fn.params.every((param) => collectPatternNames(param, locals)) ? fn.body.type !== "BlockStatement" ? isResolvable(fn.body, locals) : fn.body.body.every((statement) => statementIsResolvable(statement, locals)) : !1;
101
+ return !fn.params.every((param) => collectPatternNames(param, locals)) || !fn.body ? !1 : fn.body.type !== "BlockStatement" ? isResolvable(fn.body, locals) : fn.body.body.every((statement) => statementIsResolvable(statement, locals));
78
102
  }
79
103
  function statementIsResolvable(statement, locals) {
80
104
  switch (statement.type) {
@@ -110,17 +134,13 @@ function collectPatternNames(pattern, into) {
110
134
  }
111
135
  function isEmptyString(node) {
112
136
  let value = unwrapExpression(node);
113
- return value.type === "StringLiteral" && value.value === "";
137
+ return isStringLiteral(value) && value.value === "";
114
138
  }
115
139
  function isInlineLiteral(node) {
116
140
  let value = unwrapExpression(node);
117
141
  switch (value.type) {
118
- case "StringLiteral":
119
- case "NumericLiteral":
120
- case "BooleanLiteral":
121
- case "NullLiteral":
122
- case "BigIntLiteral":
123
- return !0;
142
+ case "Literal":
143
+ return !("regex" in value && value.regex);
124
144
  case "UnaryExpression":
125
145
  return value.operator === "-" && isInlineLiteral(value.argument);
126
146
  default:
@@ -130,12 +150,7 @@ function isInlineLiteral(node) {
130
150
  function isResolvable(node, locals = NO_LOCALS) {
131
151
  let value = unwrapExpression(node), resolves = (child) => isResolvable(child, locals);
132
152
  switch (value.type) {
133
- case "StringLiteral":
134
- case "NumericLiteral":
135
- case "BooleanLiteral":
136
- case "NullLiteral":
137
- case "BigIntLiteral":
138
- case "RegExpLiteral":
153
+ case "Literal":
139
154
  return !0;
140
155
  case "Identifier":
141
156
  return locals.has(value.name) || RESOLVABLE_GLOBALS.has(value.name);
@@ -144,7 +159,7 @@ function isResolvable(node, locals = NO_LOCALS) {
144
159
  case "ArrayExpression":
145
160
  return value.elements.every((element) => !element || resolves(element));
146
161
  case "ObjectExpression":
147
- return value.properties.every((property) => property.type !== "ObjectProperty" ? !1 : (!property.computed || resolves(property.key)) && resolves(property.value));
162
+ return value.properties.every((property) => property.type !== "Property" || property.method || property.kind !== "init" ? !1 : (!property.computed || resolves(property.key)) && resolves(property.value));
148
163
  case "CallExpression":
149
164
  case "NewExpression":
150
165
  return resolves(value.callee) && value.arguments.every(resolves);
@@ -198,7 +213,7 @@ function renderPropArg(arg, ctx) {
198
213
  }
199
214
  function renderPropValue(input, ctx) {
200
215
  let value = unwrapExpression2(input.value);
201
- return input.plan.kind === "hoist" ? hoistedProp(input, ctx, printValue(value)) : value.type === "BooleanLiteral" ? value.value ? { attrName: input.attributeName } : { attrName: `:${input.attributeName}`, value: "false" } : value.type === "StringLiteral" ? quoteAttributeValue(value.value) === void 0 ? hoistedProp(input, ctx, printValue(value)) : { attrName: input.attributeName, value: value.value } : { attrName: `:${input.attributeName}`, value: printValue(value) };
216
+ return input.plan.kind === "hoist" ? hoistedProp(input, ctx, printValue(value)) : value.type === "Literal" && typeof value.value == "boolean" ? value.value ? { attrName: input.attributeName } : { attrName: `:${input.attributeName}`, value: "false" } : isStringLiteral2(value) ? quoteAttributeValue(value.value) === void 0 ? hoistedProp(input, ctx, printValue(value)) : { attrName: input.attributeName, value: value.value } : { attrName: `:${input.attributeName}`, value: printValue(value) };
202
217
  }
203
218
  function hoistedProp(input, ctx, source) {
204
219
  let existing = ctx.hoistedArgs.get(input.variableName);
@@ -229,15 +244,8 @@ function renderSlotContent(arg, plan, ctx) {
229
244
  }
230
245
  function inlinePrimitiveSource(node) {
231
246
  let value = unwrapExpression2(node);
232
- switch (value.type) {
233
- case "StringLiteral":
234
- return value.value;
235
- case "NumericLiteral":
236
- case "BooleanLiteral":
237
- return String(value.value);
238
- default:
239
- return;
240
- }
247
+ if (value.type === "Literal")
248
+ return typeof value.value == "string" ? value.value : typeof value.value == "number" || typeof value.value == "boolean" ? String(value.value) : void 0;
241
249
  }
242
250
  function escapeTextContent(text) {
243
251
  return text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("{{", "&#123;&#123;");
@@ -256,11 +264,18 @@ ${sections.join(`
256
264
  </script>`;
257
265
  }
258
266
  function allocateBindingName(name, ctx) {
259
- let baseName = t.toIdentifier(name), bindingName = baseName, suffix = 2;
267
+ let baseName = toIdentifier(name), bindingName = baseName, suffix = 2;
260
268
  for (; ctx.bindings.has(bindingName); )
261
269
  bindingName = `${baseName}${suffix}`, suffix += 1;
262
270
  return ctx.bindings.add(bindingName), bindingName;
263
271
  }
272
+ var RESERVED_WORDS = new Set(
273
+ "break case catch class const continue debugger default delete do else enum export extends false finally for function if import in instanceof new null return super switch this throw true try typeof var void while with implements interface let package private protected public static yield await arguments eval".split(" ")
274
+ );
275
+ function toIdentifier(input) {
276
+ let name = [...input].map((char) => /[\p{ID_Continue}$\u200C\u200D]/u.test(char) ? char : "-").join("").replace(/^[-0-9]+/, "").replace(/[-\s]+(.)?/g, (_, next) => next ? next.toUpperCase() : "");
277
+ return name && !RESERVED_WORDS.has(name) ? name : `_${name}`;
278
+ }
264
279
  function quoteAttributeValue(value) {
265
280
  if (!value.includes("&")) {
266
281
  if (!value.includes('"'))
@@ -1,17 +1,17 @@
1
- import CJS_COMPAT_NODE_URL_6gh9awpayy7 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6gh9awpayy7 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6gh9awpayy7 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6gh9awpayy7.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6gh9awpayy7.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6gh9awpayy7.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.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 "./chunk-M5XXRPJZ.js";
14
+ } from "./chunk-KQTNCEDF.js";
15
15
 
16
16
  // src/docgen/component-docgen/arg-types/extractArgTypes.ts
17
17
  import { convert, extractComponentProps, hasDocgen } from "storybook/internal/docs-tools";