@storybook/vue3 11.0.0-rc.0 → 11.0.0-rc.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.
@@ -5,119 +5,14 @@ import {
5
5
  // src/entry-preview-docs.ts
6
6
  var entry_preview_docs_exports = {};
7
7
  __export(entry_preview_docs_exports, {
8
- decorators: () => decorators,
9
- parameters: () => parameters
8
+ decorators: () => decorators
10
9
  });
11
10
  import { getSourceSnippetRuntime } from "storybook/internal/docs-tools";
12
11
 
13
- // src/docs/print-hole.ts
14
- import { printValue, unknownHoleKind } from "storybook/internal/docs-tools";
15
- import { isVNode } from "vue";
16
-
17
- // src/snippet-values.ts
18
- var attributeOrder = (a, b) => a.localeCompare(b), slotOrder = (a, b) => a === "default" ? -1 : b === "default" ? 1 : a.localeCompare(b);
19
- function quoteAttributeValue(value) {
20
- if (!value.includes("&")) {
21
- if (!value.includes('"'))
22
- return `"${value}"`;
23
- if (!value.includes("'"))
24
- return `'${value}'`;
25
- }
26
- }
27
- function printAttribute(name, value) {
28
- switch (value.kind) {
29
- case "boolean":
30
- return value.value ? name : `:${name}="false"`;
31
- case "string": {
32
- let quoted = quoteAttributeValue(value.value);
33
- return quoted === void 0 ? void 0 : `${name}=${quoted}`;
34
- }
35
- default:
36
- return `:${name}="${value.code}"`;
37
- }
38
- }
39
- function escapeTextContent(text2) {
40
- return text2.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("{{", "&#123;&#123;");
41
- }
42
- function interpolatedText(value) {
43
- return value.kind === "code" ? void 0 : escapeTextContent(String(value.value));
44
- }
45
- function slotContent(value) {
46
- if (value.kind === "code") {
47
- let code2 = expressionCode(value.code, void 0);
48
- return code2 === void 0 ? void 0 : `{{ ${code2} }}`;
49
- }
50
- let text2 = String(value.value);
51
- return /^\s|\s$/.test(text2) ? void 0 : escapeTextContent(text2);
52
- }
53
- function expressionCode(code2, quote) {
54
- return quote && code2.includes(quote) || code2.includes("}}") || code2.includes("&") ? void 0 : code2;
55
- }
56
- function operand(code2, readsOn) {
57
- return code2.startsWith("-") || code2.startsWith("{") || readsOn && /^\d/.test(code2) ? `(${code2})` : code2;
58
- }
59
- function wrapSlotContent(name, content) {
60
- return name === "default" ? content : `<template #${name}>
61
- ${indent(content)}
62
- </template>`;
63
- }
64
- function indent(source, by = " ") {
65
- return source.split(`
66
- `).map((line) => line && `${by}${line}`).join(`
67
- `);
68
- }
69
-
70
- // src/docs/print-hole.ts
71
- var printHole = (hole, value) => {
72
- let arg = hole.arg ?? "";
73
- switch (hole.kind) {
74
- case "attr":
75
- return value === void 0 ? "" : attribute(hole.name ?? arg, arg, value);
76
- case "props":
77
- return Object.entries(value).filter(([name]) => !hole.except.includes(name)).sort(([a], [b]) => attributeOrder(a, b)).map(([name, item]) => attribute(name, name, item)).join(" ");
78
- case "slots": {
79
- let set = hole.slots.filter((name) => Object.hasOwn(value, name)).sort(slotOrder);
80
- if (set.length === 0)
81
- return hole.tag ? " />" : "";
82
- let children = set.map((name) => wrapSlotContent(name, slot(name, value[name]))).map((child) => indent(child, hole.indent)).join(`
83
- `);
84
- return hole.tag ? `>
85
- ${children}
86
- ${hole.indent.slice(2)}</${hole.tag}>` : `
87
- ${children}`;
88
- }
89
- case "text":
90
- return value === void 0 ? "" : hole.slot ? slot(arg, value) : text(arg, value);
91
- case "value": {
92
- let readsOn = hole.readsOn === !0;
93
- if (hole.in === "attribute") {
94
- let quote = hole.quote;
95
- return operand(inAttribute(code(arg, value, quote === "'" ? '"' : "'"), quote), readsOn);
96
- }
97
- let printed = code(arg, value, "'");
98
- return hole.in === "script" ? printed : operand(hole.in === "interpolation" ? inInterpolation(printed) : printed, readsOn);
99
- }
100
- default:
101
- return unknownHoleKind(hole);
102
- }
103
- }, code = (name, value, quote) => printValue(value, name, { quote, opaque: isVNode });
104
- function snippetValue(name, value) {
105
- return typeof value == "boolean" ? { kind: "boolean", value } : typeof value == "string" ? { kind: "string", value } : typeof value == "number" && Number.isFinite(value) && value >= 0 && !Object.is(value, -0) ? { kind: "number", value, code: String(value) } : { kind: "code", code: code(name, value, "'") };
106
- }
107
- var inAttribute = (text2, quote) => text2.replaceAll("&", "&amp;").replaceAll(quote, quote === '"' ? "&quot;" : "&#39;"), inInterpolation = (text2) => text2.replaceAll("&", "&amp;").replace(/}(?=})/g, "}\\");
108
- function attribute(name, arg, value) {
109
- let snippet = snippetValue(arg, value);
110
- return snippet.kind === "code" ? `:${name}="${inAttribute(snippet.code, '"')}"` : printAttribute(name, snippet) ?? `${name}="${inAttribute(String(snippet.value), '"')}"`;
111
- }
112
- function text(name, value) {
113
- return interpolatedText(snippetValue(name, value))?.replace(/\{$/, "&#123;") ?? interpolation(name, value);
114
- }
115
- var slot = (name, value) => slotContent(snippetValue(name, value)) ?? interpolation(name, value), interpolation = (name, value) => `{{ ${inInterpolation(code(name, value, "'"))} }}`;
116
-
117
12
  // src/docgen/story-docs/source-decorator/sourceDecorator.ts
118
13
  import { SourceType } from "storybook/internal/docs-tools";
119
14
  import { emitTransformCode, useEffect } from "storybook/preview-api";
120
- import { isVNode as isVNode2 } from "vue";
15
+ import { isVNode } from "vue";
121
16
  var TRACKING_SYMBOL = /* @__PURE__ */ Symbol("DEEP_ACCESS_SYMBOL"), isProxy = (obj) => !!(obj && typeof obj == "object" && TRACKING_SYMBOL in obj), sourceDecorator = (storyFn, ctx) => {
122
17
  let story = storyFn();
123
18
  return useEffect(() => {
@@ -243,18 +138,18 @@ ${template}`;
243
138
  let arg = args[slotName];
244
139
  if (!arg)
245
140
  return;
246
- let slotContent2 = generateSlotChildrenSourceCode([arg], ctx);
247
- if (!slotContent2)
141
+ let slotContent = generateSlotChildrenSourceCode([arg], ctx);
142
+ if (!slotContent)
248
143
  return;
249
144
  let slotBindings = typeof arg == "function" ? getFunctionParamNames(arg) : [];
250
- slotName === "default" && !slotBindings.length ? slotSourceCodes.push(slotContent2) : slotSourceCodes.push(
251
- `<template ${slotBindingsToString(slotName, slotBindings)}>${slotContent2}</template>`
145
+ slotName === "default" && !slotBindings.length ? slotSourceCodes.push(slotContent) : slotSourceCodes.push(
146
+ `<template ${slotBindingsToString(slotName, slotBindings)}>${slotContent}</template>`
252
147
  );
253
148
  }), slotSourceCodes.join(`
254
149
  `);
255
150
  }, generateSlotChildrenSourceCode = (children, ctx) => {
256
151
  let slotChildrenSourceCodes = [], generateSingleChildSourceCode = (child) => {
257
- if (isVNode2(child))
152
+ if (isVNode(child))
258
153
  return generateVNodeSourceCode(child, ctx);
259
154
  switch (typeof child) {
260
155
  case "string":
@@ -262,14 +157,14 @@ ${template}`;
262
157
  case "boolean":
263
158
  return child.toString();
264
159
  case "object":
265
- return child === null ? "" : Array.isArray(child) ? child.map(generateSingleChildSourceCode).filter((code2) => code2 !== "").join(`
160
+ return child === null ? "" : Array.isArray(child) ? child.map(generateSingleChildSourceCode).filter((code) => code !== "").join(`
266
161
  `) : JSON.stringify(child);
267
162
  case "function": {
268
163
  let paramNames = getFunctionParamNames(child).filter(
269
164
  (param) => !["{", "}"].includes(param)
270
- ), parameters2 = {}, proxied = {};
165
+ ), parameters = {}, proxied = {};
271
166
  paramNames.forEach((param) => {
272
- parameters2[param] = `{{ ${param} }}`, proxied[param] = new Proxy(
167
+ parameters[param] = `{{ ${param} }}`, proxied[param] = new Proxy(
273
168
  {
274
169
  // we use the symbol to identify the proxy
275
170
  [TRACKING_SYMBOL]: !0
@@ -341,10 +236,9 @@ ${template}`;
341
236
  ) ? JSON.stringify(obj) : JSON.stringify(obj, null, 2);
342
237
 
343
238
  // src/entry-preview-docs.ts
344
- var snippetRuntime = getSourceSnippetRuntime(), decorators = snippetRuntime === "preview" ? [sourceDecorator] : [], parameters = snippetRuntime === "server" ? { docs: { source: { printHole } } } : {};
239
+ var snippetRuntime = getSourceSnippetRuntime(), decorators = snippetRuntime === "preview" ? [sourceDecorator] : [];
345
240
 
346
241
  export {
347
242
  decorators,
348
- parameters,
349
243
  entry_preview_docs_exports
350
244
  };
@@ -0,0 +1,111 @@
1
+ // src/docs/register-print-hole.ts
2
+ import { registerPrintHole } from "storybook/internal/docs-tools/snippets";
3
+
4
+ // src/docs/print-hole.ts
5
+ import {
6
+ printValue,
7
+ unknownHoleKind
8
+ } from "storybook/internal/docs-tools/snippets";
9
+
10
+ // src/snippet-values.ts
11
+ var attributeOrder = (a, b) => a.localeCompare(b), slotOrder = (a, b) => a === "default" ? -1 : b === "default" ? 1 : a.localeCompare(b);
12
+ function quoteAttributeValue(value) {
13
+ if (!value.includes("&")) {
14
+ if (!value.includes('"'))
15
+ return `"${value}"`;
16
+ if (!value.includes("'"))
17
+ return `'${value}'`;
18
+ }
19
+ }
20
+ function printAttribute(name, value) {
21
+ switch (value.kind) {
22
+ case "boolean":
23
+ return value.value ? name : `:${name}="false"`;
24
+ case "string": {
25
+ let quoted = quoteAttributeValue(value.value);
26
+ return quoted === void 0 ? void 0 : `${name}=${quoted}`;
27
+ }
28
+ default:
29
+ return `:${name}="${value.code}"`;
30
+ }
31
+ }
32
+ function escapeTextContent(text2) {
33
+ return text2.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("{{", "&#123;&#123;");
34
+ }
35
+ function interpolatedText(value) {
36
+ return value.kind === "code" ? void 0 : escapeTextContent(String(value.value));
37
+ }
38
+ function slotContent(value) {
39
+ if (value.kind === "code") {
40
+ let code2 = expressionCode(value.code, void 0);
41
+ return code2 === void 0 ? void 0 : `{{ ${code2} }}`;
42
+ }
43
+ let text2 = String(value.value);
44
+ return /^\s|\s$/.test(text2) ? void 0 : escapeTextContent(text2);
45
+ }
46
+ function expressionCode(code2, quote) {
47
+ return quote && code2.includes(quote) || code2.includes("}}") || code2.includes("&") ? void 0 : code2;
48
+ }
49
+ function operand(code2, readsOn) {
50
+ return code2.startsWith("-") || code2.startsWith("{") || readsOn && /^\d/.test(code2) ? `(${code2})` : code2;
51
+ }
52
+ function wrapSlotContent(name, content) {
53
+ return name === "default" ? content : `<template #${name}>
54
+ ${indent(content)}
55
+ </template>`;
56
+ }
57
+ function indent(source, by = " ") {
58
+ return source.split(`
59
+ `).map((line) => line && `${by}${line}`).join(`
60
+ `);
61
+ }
62
+
63
+ // src/docs/print-hole.ts
64
+ var printHole = (hole, value) => {
65
+ let arg = hole.arg ?? "";
66
+ switch (hole.kind) {
67
+ case "attr":
68
+ return value === void 0 ? "" : attribute(hole.name ?? arg, arg, value);
69
+ case "props":
70
+ return Object.entries(value).filter(([name]) => !hole.except.includes(name)).sort(([a], [b]) => attributeOrder(a, b)).map(([name, item]) => attribute(name, name, item)).join(" ");
71
+ case "slots": {
72
+ let set = hole.slots.filter((name) => Object.hasOwn(value, name)).sort(slotOrder);
73
+ if (set.length === 0)
74
+ return hole.tag ? " />" : "";
75
+ let children = set.map((name) => wrapSlotContent(name, slot(name, value[name]))).map((child) => indent(child, hole.indent)).join(`
76
+ `);
77
+ return hole.tag ? `>
78
+ ${children}
79
+ ${hole.indent.slice(2)}</${hole.tag}>` : `
80
+ ${children}`;
81
+ }
82
+ case "text":
83
+ return value === void 0 ? "" : hole.slot ? slot(arg, value) : text(arg, value);
84
+ case "value": {
85
+ let readsOn = hole.readsOn === !0;
86
+ if (hole.in === "attribute") {
87
+ let quote = hole.quote;
88
+ return operand(inAttribute(code(arg, value, quote === "'" ? '"' : "'"), quote), readsOn);
89
+ }
90
+ let printed = code(arg, value, "'");
91
+ return hole.in === "script" ? printed : operand(hole.in === "interpolation" ? inInterpolation(printed) : printed, readsOn);
92
+ }
93
+ default:
94
+ return unknownHoleKind(hole);
95
+ }
96
+ }, isVNode = (value) => typeof value == "object" && value !== null && "__v_isVNode" in value && value.__v_isVNode === !0, code = (name, value, quote) => printValue(value, name, { quote, opaque: isVNode });
97
+ function snippetValue(name, value) {
98
+ return typeof value == "boolean" ? { kind: "boolean", value } : typeof value == "string" ? { kind: "string", value } : typeof value == "number" && Number.isFinite(value) && value >= 0 && !Object.is(value, -0) ? { kind: "number", value, code: String(value) } : { kind: "code", code: code(name, value, "'") };
99
+ }
100
+ var inAttribute = (text2, quote) => text2.replaceAll("&", "&amp;").replaceAll(quote, quote === '"' ? "&quot;" : "&#39;"), inInterpolation = (text2) => text2.replaceAll("&", "&amp;").replace(/}(?=})/g, "}\\");
101
+ function attribute(name, arg, value) {
102
+ let snippet = snippetValue(arg, value);
103
+ return snippet.kind === "code" ? `:${name}="${inAttribute(snippet.code, '"')}"` : printAttribute(name, snippet) ?? `${name}="${inAttribute(String(snippet.value), '"')}"`;
104
+ }
105
+ function text(name, value) {
106
+ return interpolatedText(snippetValue(name, value))?.replace(/\{$/, "&#123;") ?? interpolation(name, value);
107
+ }
108
+ var slot = (name, value) => slotContent(snippetValue(name, value)) ?? interpolation(name, value), interpolation = (name, value) => `{{ ${inInterpolation(code(name, value, "'"))} }}`;
109
+
110
+ // src/docs/register-print-hole.ts
111
+ registerPrintHole(printHole);
@@ -0,0 +1,2 @@
1
+ import "../_browser-chunks/chunk-ZXXNCHU7.js";
2
+ import "../_browser-chunks/chunk-4BE7D4DS.js";
@@ -1,9 +1,8 @@
1
1
  import {
2
- decorators,
3
- parameters
4
- } from "./_browser-chunks/chunk-S434HE7Q.js";
2
+ decorators
3
+ } from "./_browser-chunks/chunk-SERTEPAZ.js";
4
+ import "./_browser-chunks/chunk-ZXXNCHU7.js";
5
5
  import "./_browser-chunks/chunk-4BE7D4DS.js";
6
6
  export {
7
- decorators,
8
- parameters
7
+ decorators
9
8
  };
package/dist/index.js CHANGED
@@ -5,14 +5,13 @@ import {
5
5
  } from "./_browser-chunks/chunk-CQAJYHIB.js";
6
6
  import {
7
7
  entry_preview_docs_exports
8
- } from "./_browser-chunks/chunk-S434HE7Q.js";
8
+ } from "./_browser-chunks/chunk-SERTEPAZ.js";
9
+ import "./_browser-chunks/chunk-ZXXNCHU7.js";
9
10
  import "./_browser-chunks/chunk-4BE7D4DS.js";
10
11
 
11
12
  // src/globals.ts
12
- import { global } from "@storybook/global";
13
- var { window: globalWindow } = global;
14
- globalWindow.STORYBOOK_ENV = "vue3";
15
- globalWindow.PLUGINS_SETUP_FUNCTIONS ||= /* @__PURE__ */ new Set();
13
+ globalThis.STORYBOOK_ENV = "vue3";
14
+ globalThis.PLUGINS_SETUP_FUNCTIONS ||= /* @__PURE__ */ new Set();
16
15
 
17
16
  // src/portable-stories.ts
18
17
  import {
package/dist/preset.js CHANGED
@@ -32,7 +32,8 @@ import { createWorkerGatedStoryDocsProvider } from "storybook/internal/core-serv
32
32
  var experimental_storyDocsProvider = createWorkerGatedStoryDocsProvider({
33
33
  label: "Vue",
34
34
  docgenWorker: fileURLToPath2(import.meta.resolve(DOCGEN_WORKER_SPECIFIER)),
35
- build: (input) => buildStoryDocsPayload(input)
35
+ build: (input) => buildStoryDocsPayload(input),
36
+ printHole: fileURLToPath2(import.meta.resolve("@storybook/vue3/internal/register-print-hole"))
36
37
  });
37
38
 
38
39
  // src/docgen/engine.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/vue3",
3
- "version": "11.0.0-rc.0",
3
+ "version": "11.0.0-rc.2",
4
4
  "description": "Storybook Vue 3 renderer: Develop, document, and test UI components in isolation",
5
5
  "keywords": [
6
6
  "storybook",
@@ -38,6 +38,7 @@
38
38
  "default": "./dist/docgen/index.js"
39
39
  },
40
40
  "./internal/docgen-worker": "./dist/docgen/docgen-worker.js",
41
+ "./internal/register-print-hole": "./dist/docs/register-print-hole.js",
41
42
  "./package.json": "./package.json",
42
43
  "./preset": {
43
44
  "types": "./dist/preset.d.ts",
@@ -54,7 +55,6 @@
54
55
  "!src/**/*"
55
56
  ],
56
57
  "dependencies": {
57
- "@storybook/global": "^5.0.0",
58
58
  "@types/pug": "2.0.10",
59
59
  "@vue/compiler-dom": "^3.2.47",
60
60
  "@vue/language-core": "^3.2.7",
@@ -71,7 +71,7 @@
71
71
  "vue-tsc": "latest"
72
72
  },
73
73
  "peerDependencies": {
74
- "storybook": "^11.0.0-rc.0",
74
+ "storybook": "^11.0.0-rc.2",
75
75
  "typescript": "^5.9.0 || ^6.0.0 || ^7.0.0",
76
76
  "vue": "^3.0.0"
77
77
  },
@@ -1,5 +1,3 @@
1
- import { global as globalThis } from '@storybook/global';
2
-
3
1
  import Button from './Button.vue';
4
2
  import Form from './Form.vue';
5
3
  import Html from './Html.vue';
@@ -1,4 +1,3 @@
1
- import { global as globalThis } from '@storybook/global';
2
1
  import { setup } from '@storybook/vue3';
3
2
 
4
3
  const somePlugin = {