@storybook/vue3 10.6.0-alpha.8 → 10.6.0-beta.0

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_zol2z3jfkwh from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_zol2z3jfkwh from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_zol2z3jfkwh from "node:module";
1
+ import CJS_COMPAT_NODE_URL_rhcqxor3cl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_rhcqxor3cl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_rhcqxor3cl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_zol2z3jfkwh.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_zol2z3jfkwh.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_zol2z3jfkwh.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_rhcqxor3cl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_rhcqxor3cl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_rhcqxor3cl.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 isFunctionExpression(value) || isUndefinedIdentifier(value) || isEmptyString(value) ? { kind: "omit" } : isInlineLiteral(value) ? { kind: "inline" } : isResolvable(value) ? { kind: "hoist" } : { kind: "unrepresentable" };
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;
@@ -175,7 +175,8 @@ function createRenderContext() {
175
175
  bindings: /* @__PURE__ */ new Set(["ref"]),
176
176
  variables: /* @__PURE__ */ new Map(),
177
177
  hoistedArgs: /* @__PURE__ */ new Map(),
178
- componentImports: /* @__PURE__ */ new Set()
178
+ componentImports: /* @__PURE__ */ new Set(),
179
+ statements: []
179
180
  };
180
181
  }
181
182
  function renderPreparedSfcSnippet(input) {
@@ -200,8 +201,11 @@ function renderPropValue(input, ctx) {
200
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) };
201
202
  }
202
203
  function hoistedProp(input, ctx, source) {
204
+ let existing = ctx.hoistedArgs.get(input.variableName);
205
+ if (existing?.source === source)
206
+ return { attrName: `:${input.attributeName}`, value: existing.binding };
203
207
  let bindingName = allocateBindingName(input.variableName, ctx);
204
- return ctx.variables.set(bindingName, source), { attrName: `:${input.attributeName}`, value: bindingName };
208
+ return ctx.variables.set(bindingName, source), ctx.hoistedArgs.set(input.variableName, { binding: bindingName, source }), { attrName: `:${input.attributeName}`, value: bindingName };
205
209
  }
206
210
  function renderModelArg(arg, ctx) {
207
211
  let bindingName = hoistModelRef(arg.name, arg.value, ctx);
@@ -242,11 +246,13 @@ function renderScript(ctx) {
242
246
  let importsCode = Object.entries(ctx.imports).sort(([a], [b]) => a.localeCompare(b)).map(([packageName, imports]) => `import { ${Array.from(imports.values()).sort().join(", ")} } from "${packageName}";`).concat(Array.from(ctx.componentImports).sort()).join(`
243
247
  `), variablesCode = Array.from(ctx.variables.entries()).map(([name, value]) => `const ${name} = ${value};`).join(`
244
248
 
245
- `);
246
- return !importsCode && !variablesCode ? void 0 : `<script lang="ts" setup>
247
- ${importsCode && variablesCode ? `${importsCode}
249
+ `), statementsCode = ctx.statements.join(`
250
+ `), sections = [importsCode, variablesCode, statementsCode].filter(Boolean);
251
+ if (sections.length !== 0)
252
+ return `<script lang="ts" setup>
253
+ ${sections.join(`
248
254
 
249
- ${variablesCode}` : importsCode || variablesCode}
255
+ `)}
250
256
  </script>`;
251
257
  }
252
258
  function allocateBindingName(name, ctx) {
@@ -266,20 +272,23 @@ function quoteAttributeValue(value) {
266
272
  function formatRenderedProp(prop) {
267
273
  return prop.value === void 0 ? prop.attrName : isVueExpressionAttribute(prop.attrName) ? `${prop.attrName}="${prop.value}"` : `${prop.attrName}=${quoteAttributeValue(prop.value)}`;
268
274
  }
269
- function renderArgsBindingAttributes(args, existingAttributeNames, ctx) {
275
+ function renderArgsBindingExpansion(args, ctx, options) {
270
276
  let partitioned = partitionArgsByRole(args);
271
- if (partitioned.slots.length > 0 || [
272
- ...partitioned.props.map((arg) => arg.name),
273
- ...partitioned.events.map((arg) => arg.eventName ?? arg.name)
274
- ].some((name) => existingAttributeNames.has(name)))
277
+ if (partitioned.slots.length > 0 && !options.roleAware)
275
278
  return;
276
279
  let props = partitioned.props.map(
277
- (arg) => renderPropValue(
280
+ (arg) => options.roleAware ? renderPropLikeArg(arg, ctx) : renderPropValue(
278
281
  { attributeName: arg.name, variableName: arg.name, value: arg.value, plan: arg.plan },
279
282
  ctx
280
283
  )
281
- ), events = partitioned.events.map((arg) => renderEventArg(arg, ctx));
282
- return [...props, ...events].map(formatRenderedProp).join(" ");
284
+ ), events = partitioned.events.map((arg) => renderEventArg(arg, ctx)), slotChildren = [];
285
+ for (let slot of partitioned.slots) {
286
+ let content = options.renderSlotArg?.(slot);
287
+ if (content === void 0)
288
+ return;
289
+ slotChildren.push(wrapSlotContent(slot.name, content));
290
+ }
291
+ return { attributes: [...props, ...events].map(formatRenderedProp), slotChildren };
283
292
  }
284
293
  function renderBoundArgAttribute(attributeName, arg, ctx) {
285
294
  return formatRenderedProp(
@@ -299,7 +308,7 @@ function hoistArgValue(name, value, ctx) {
299
308
  function hoistModelRef(name, value, ctx) {
300
309
  (ctx.imports[VUE_PACKAGE] ??= /* @__PURE__ */ new Set()).add("ref");
301
310
  let bindingName = allocateBindingName(name, ctx);
302
- return ctx.variables.set(bindingName, `ref(${printValue(unwrapExpression2(value))})`), bindingName;
311
+ return ctx.variables.set(bindingName, value ? `ref(${printValue(unwrapExpression2(value))})` : "ref()"), bindingName;
303
312
  }
304
313
  function importStatementForBinding(localName, binding) {
305
314
  if (!(!binding || binding.importName === "*"))
@@ -332,11 +341,12 @@ function isVueExpressionAttribute(name) {
332
341
  }
333
342
 
334
343
  export {
344
+ RESOLVABLE_GLOBALS,
335
345
  classifyValue,
336
346
  printValue,
337
347
  isFunctionExpression,
338
348
  isSelfContainedFunction,
339
- partitionArgsByRole,
349
+ collectPatternNames,
340
350
  createRenderContext,
341
351
  renderPreparedSfcSnippet,
342
352
  renderPropLikeArg,
@@ -345,7 +355,7 @@ export {
345
355
  inlinePrimitiveSource,
346
356
  escapeTextContent,
347
357
  formatRenderedProp,
348
- renderArgsBindingAttributes,
358
+ renderArgsBindingExpansion,
349
359
  renderBoundArgAttribute,
350
360
  hoistArgValue,
351
361
  hoistModelRef,
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_zol2z3jfkwh from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_zol2z3jfkwh from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_zol2z3jfkwh from "node:module";
1
+ import CJS_COMPAT_NODE_URL_rhcqxor3cl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_rhcqxor3cl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_rhcqxor3cl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_zol2z3jfkwh.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_zol2z3jfkwh.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_zol2z3jfkwh.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_rhcqxor3cl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_rhcqxor3cl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_rhcqxor3cl.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 CJS_COMPAT_NODE_URL_zol2z3jfkwh from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_zol2z3jfkwh from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_zol2z3jfkwh from "node:module";
1
+ import CJS_COMPAT_NODE_URL_rhcqxor3cl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_rhcqxor3cl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_rhcqxor3cl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_zol2z3jfkwh.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_zol2z3jfkwh.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_zol2z3jfkwh.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_rhcqxor3cl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_rhcqxor3cl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_rhcqxor3cl.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-WN6FRBUG.js";
17
+ } from "./chunk-XAP4PSCV.js";
18
18
  export {
19
19
  CHECKER_OPTIONS,
20
20
  applyVueDocgenApiTempFixes,
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_zol2z3jfkwh from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_zol2z3jfkwh from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_zol2z3jfkwh from "node:module";
1
+ import CJS_COMPAT_NODE_URL_rhcqxor3cl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_rhcqxor3cl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_rhcqxor3cl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_zol2z3jfkwh.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_zol2z3jfkwh.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_zol2z3jfkwh.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_rhcqxor3cl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_rhcqxor3cl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_rhcqxor3cl.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_rhcqxor3cl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_rhcqxor3cl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_rhcqxor3cl from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_rhcqxor3cl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_rhcqxor3cl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_rhcqxor3cl.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 CJS_COMPAT_NODE_URL_zol2z3jfkwh from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_zol2z3jfkwh from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_zol2z3jfkwh from "node:module";
1
+ import CJS_COMPAT_NODE_URL_rhcqxor3cl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_rhcqxor3cl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_rhcqxor3cl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_zol2z3jfkwh.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_zol2z3jfkwh.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_zol2z3jfkwh.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_rhcqxor3cl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_rhcqxor3cl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_rhcqxor3cl.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-REUZ4KRS.js";
14
+ } from "../_node-chunks/chunk-N23VPSRC.js";
15
15
  import {
16
16
  CHECKER_OPTIONS,
17
17
  collectComponentMetaSources
18
- } from "../_node-chunks/chunk-WN6FRBUG.js";
18
+ } from "../_node-chunks/chunk-XAP4PSCV.js";
19
19
 
20
20
  // src/docgen/docgen-worker.ts
21
21
  import { createLazyDocgenMiddleware } from "storybook/internal/common";