@storybook/vue3 10.1.0-alpha.8 → 10.1.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.
- package/dist/_browser-chunks/chunk-4BE7D4DS.js +9 -0
- package/dist/_browser-chunks/chunk-YJYABENR.js +263 -0
- package/dist/entry-preview-docs.js +147 -289
- package/dist/entry-preview.js +2 -2
- package/dist/index.js +12 -23
- package/dist/playwright.js +1 -1
- package/dist/preset.js +10 -13
- package/package.json +3 -3
- package/template/cli/ts/Button.stories.ts +1 -5
- package/dist/_browser-chunks/chunk-GZHEVVQL.js +0 -427
- package/dist/_browser-chunks/chunk-JFJ5UJ7Q.js +0 -11
|
@@ -1,160 +1,107 @@
|
|
|
1
|
-
import
|
|
2
|
-
__name
|
|
3
|
-
} from "./_browser-chunks/chunk-JFJ5UJ7Q.js";
|
|
1
|
+
import "./_browser-chunks/chunk-4BE7D4DS.js";
|
|
4
2
|
|
|
5
3
|
// src/docs/sourceDecorator.ts
|
|
6
4
|
import { SourceType } from "storybook/internal/docs-tools";
|
|
7
5
|
import { emitTransformCode, useEffect } from "storybook/preview-api";
|
|
8
6
|
import { isVNode } from "vue";
|
|
9
|
-
var TRACKING_SYMBOL = Symbol("DEEP_ACCESS_SYMBOL")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
emitTransformCode(sourceCode, ctx);
|
|
19
|
-
});
|
|
20
|
-
return story;
|
|
21
|
-
}, "sourceDecorator");
|
|
22
|
-
var generateSourceCode = /* @__PURE__ */ __name((ctx) => {
|
|
23
|
-
const sourceCodeContext = {
|
|
7
|
+
var TRACKING_SYMBOL = Symbol("DEEP_ACCESS_SYMBOL"), isProxy = (obj) => !!(obj && typeof obj == "object" && TRACKING_SYMBOL in obj), sourceDecorator = (storyFn, ctx) => {
|
|
8
|
+
let story = storyFn();
|
|
9
|
+
return useEffect(() => {
|
|
10
|
+
let sourceCode = generateSourceCode(ctx);
|
|
11
|
+
shouldSkipSourceCodeGeneration(ctx) || emitTransformCode(sourceCode, ctx);
|
|
12
|
+
}), story;
|
|
13
|
+
}, generateSourceCode = (ctx) => {
|
|
14
|
+
let sourceCodeContext = {
|
|
24
15
|
imports: {},
|
|
25
16
|
scriptVariables: {}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const componentName = displayName || ctx.title.split("/").at(-1);
|
|
31
|
-
const templateCode = slotSourceCode ? `<${componentName} ${props}> ${slotSourceCode} </${componentName}>` : `<${componentName} ${props} />`;
|
|
32
|
-
const variablesCode = Object.entries(sourceCodeContext.scriptVariables).map(([name, value]) => `const ${name} = ${value};`).join("\n\n");
|
|
33
|
-
const importsCode = Object.entries(sourceCodeContext.imports).map(([packageName, imports]) => {
|
|
34
|
-
return `import { ${Array.from(imports.values()).sort().join(", ")} } from "${packageName}";`;
|
|
35
|
-
}).join("\n");
|
|
36
|
-
const template = `<template>
|
|
17
|
+
}, { displayName, slotNames, eventNames } = parseDocgenInfo(ctx.component), props = generatePropsSourceCode(ctx.args, slotNames, eventNames, sourceCodeContext), slotSourceCode = generateSlotSourceCode(ctx.args, slotNames, sourceCodeContext), componentName = displayName || ctx.title.split("/").at(-1), templateCode = slotSourceCode ? `<${componentName} ${props}> ${slotSourceCode} </${componentName}>` : `<${componentName} ${props} />`, variablesCode = Object.entries(sourceCodeContext.scriptVariables).map(([name, value]) => `const ${name} = ${value};`).join(`
|
|
18
|
+
|
|
19
|
+
`), importsCode = Object.entries(sourceCodeContext.imports).map(([packageName, imports]) => `import { ${Array.from(imports.values()).sort().join(", ")} } from "${packageName}";`).join(`
|
|
20
|
+
`), template = `<template>
|
|
37
21
|
${templateCode}
|
|
38
22
|
</template>`;
|
|
39
|
-
|
|
40
|
-
return template;
|
|
41
|
-
}
|
|
42
|
-
return `<script lang="ts" setup>
|
|
23
|
+
return !importsCode && !variablesCode ? template : `<script lang="ts" setup>
|
|
43
24
|
${importsCode ? `${importsCode}
|
|
44
25
|
|
|
45
26
|
${variablesCode}` : variablesCode}
|
|
46
27
|
<\/script>
|
|
47
28
|
|
|
48
29
|
${template}`;
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
const isArgsStory = context?.parameters.__isArgsStory;
|
|
56
|
-
return !isArgsStory || sourceParams?.code || sourceParams?.type === SourceType.CODE;
|
|
57
|
-
}, "shouldSkipSourceCodeGeneration");
|
|
58
|
-
var parseDocgenInfo = /* @__PURE__ */ __name((component) => {
|
|
59
|
-
if (!component || !("__docgenInfo" in component) || !component.__docgenInfo || typeof component.__docgenInfo !== "object") {
|
|
30
|
+
}, shouldSkipSourceCodeGeneration = (context) => {
|
|
31
|
+
let sourceParams = context?.parameters.docs?.source;
|
|
32
|
+
return sourceParams?.type === SourceType.DYNAMIC ? !1 : !context?.parameters.__isArgsStory || sourceParams?.code || sourceParams?.type === SourceType.CODE;
|
|
33
|
+
}, parseDocgenInfo = (component) => {
|
|
34
|
+
if (!component || !("__docgenInfo" in component) || !component.__docgenInfo || typeof component.__docgenInfo != "object")
|
|
60
35
|
return {
|
|
61
36
|
displayName: component?.__name,
|
|
62
37
|
eventNames: [],
|
|
63
38
|
slotNames: []
|
|
64
39
|
};
|
|
65
|
-
|
|
66
|
-
const docgenInfo = component.__docgenInfo;
|
|
67
|
-
const displayName = "displayName" in docgenInfo && typeof docgenInfo.displayName === "string" ? docgenInfo.displayName : void 0;
|
|
68
|
-
const parseNames = /* @__PURE__ */ __name((key) => {
|
|
69
|
-
if (!(key in docgenInfo) || !Array.isArray(docgenInfo[key])) {
|
|
70
|
-
return [];
|
|
71
|
-
}
|
|
72
|
-
const values = docgenInfo[key];
|
|
73
|
-
return values.map((i) => i && typeof i === "object" && "name" in i ? i.name : void 0).filter((i) => typeof i === "string");
|
|
74
|
-
}, "parseNames");
|
|
40
|
+
let docgenInfo = component.__docgenInfo, displayName = "displayName" in docgenInfo && typeof docgenInfo.displayName == "string" ? docgenInfo.displayName : void 0, parseNames = (key) => !(key in docgenInfo) || !Array.isArray(docgenInfo[key]) ? [] : docgenInfo[key].map((i) => i && typeof i == "object" && "name" in i ? i.name : void 0).filter((i) => typeof i == "string");
|
|
75
41
|
return {
|
|
76
42
|
displayName: displayName || component.__name,
|
|
77
|
-
slotNames: parseNames("slots").sort((a, b) =>
|
|
78
|
-
if (a === "default") {
|
|
79
|
-
return -1;
|
|
80
|
-
}
|
|
81
|
-
if (b === "default") {
|
|
82
|
-
return 1;
|
|
83
|
-
}
|
|
84
|
-
return a.localeCompare(b);
|
|
85
|
-
}),
|
|
43
|
+
slotNames: parseNames("slots").sort((a, b) => a === "default" ? -1 : b === "default" ? 1 : a.localeCompare(b)),
|
|
86
44
|
eventNames: parseNames("events")
|
|
87
45
|
};
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
const properties = [];
|
|
46
|
+
}, generatePropsSourceCode = (args, slotNames, eventNames, ctx) => {
|
|
47
|
+
let properties = [];
|
|
91
48
|
Object.entries(args).forEach(([propName, value]) => {
|
|
92
|
-
if (slotNames.includes(propName))
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
49
|
+
if (!slotNames.includes(propName) && value != null)
|
|
50
|
+
switch (isProxy(value) && (value = value.toString()), typeof value) {
|
|
51
|
+
case "string":
|
|
52
|
+
if (value === "")
|
|
53
|
+
return;
|
|
54
|
+
properties.push({
|
|
55
|
+
name: propName,
|
|
56
|
+
value: value.includes('"') ? `'${value}'` : `"${value}"`,
|
|
57
|
+
templateFn: (name, propValue) => `${name}=${propValue}`
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
60
|
+
case "number":
|
|
61
|
+
properties.push({
|
|
62
|
+
name: propName,
|
|
63
|
+
value: value.toString(),
|
|
64
|
+
templateFn: (name, propValue) => `:${name}="${propValue}"`
|
|
65
|
+
});
|
|
66
|
+
break;
|
|
67
|
+
case "bigint":
|
|
68
|
+
properties.push({
|
|
69
|
+
name: propName,
|
|
70
|
+
value: `BigInt(${value.toString()})`,
|
|
71
|
+
templateFn: (name, propValue) => `:${name}="${propValue}"`
|
|
72
|
+
});
|
|
73
|
+
break;
|
|
74
|
+
case "boolean":
|
|
75
|
+
properties.push({
|
|
76
|
+
name: propName,
|
|
77
|
+
value: value ? "true" : "false",
|
|
78
|
+
templateFn: (name, propValue) => propValue === "true" ? name : `:${name}="false"`
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
81
|
+
case "symbol":
|
|
82
|
+
properties.push({
|
|
83
|
+
name: propName,
|
|
84
|
+
value: `Symbol(${value.description ? `'${value.description}'` : ""})`,
|
|
85
|
+
templateFn: (name, propValue) => `:${name}="${propValue}"`
|
|
86
|
+
});
|
|
87
|
+
break;
|
|
88
|
+
case "object": {
|
|
89
|
+
properties.push({
|
|
90
|
+
name: propName,
|
|
91
|
+
value: formatObject(value ?? {}),
|
|
92
|
+
// to follow Vue best practices, complex values like object and arrays are
|
|
93
|
+
// usually placed inside the <script setup> block instead of inlining them in the <template>
|
|
94
|
+
templateFn: void 0
|
|
95
|
+
});
|
|
96
|
+
break;
|
|
105
97
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
value: value.includes('"') ? `'${value}'` : `"${value}"`,
|
|
109
|
-
templateFn: /* @__PURE__ */ __name((name, propValue) => `${name}=${propValue}`, "templateFn")
|
|
110
|
-
});
|
|
111
|
-
break;
|
|
112
|
-
case "number":
|
|
113
|
-
properties.push({
|
|
114
|
-
name: propName,
|
|
115
|
-
value: value.toString(),
|
|
116
|
-
templateFn: /* @__PURE__ */ __name((name, propValue) => `:${name}="${propValue}"`, "templateFn")
|
|
117
|
-
});
|
|
118
|
-
break;
|
|
119
|
-
case "bigint":
|
|
120
|
-
properties.push({
|
|
121
|
-
name: propName,
|
|
122
|
-
value: `BigInt(${value.toString()})`,
|
|
123
|
-
templateFn: /* @__PURE__ */ __name((name, propValue) => `:${name}="${propValue}"`, "templateFn")
|
|
124
|
-
});
|
|
125
|
-
break;
|
|
126
|
-
case "boolean":
|
|
127
|
-
properties.push({
|
|
128
|
-
name: propName,
|
|
129
|
-
value: value ? "true" : "false",
|
|
130
|
-
templateFn: /* @__PURE__ */ __name((name, propValue) => propValue === "true" ? name : `:${name}="false"`, "templateFn")
|
|
131
|
-
});
|
|
132
|
-
break;
|
|
133
|
-
case "symbol":
|
|
134
|
-
properties.push({
|
|
135
|
-
name: propName,
|
|
136
|
-
value: `Symbol(${value.description ? `'${value.description}'` : ""})`,
|
|
137
|
-
templateFn: /* @__PURE__ */ __name((name, propValue) => `:${name}="${propValue}"`, "templateFn")
|
|
138
|
-
});
|
|
139
|
-
break;
|
|
140
|
-
case "object": {
|
|
141
|
-
properties.push({
|
|
142
|
-
name: propName,
|
|
143
|
-
value: formatObject(value ?? {}),
|
|
144
|
-
// to follow Vue best practices, complex values like object and arrays are
|
|
145
|
-
// usually placed inside the <script setup> block instead of inlining them in the <template>
|
|
146
|
-
templateFn: void 0
|
|
147
|
-
});
|
|
148
|
-
break;
|
|
98
|
+
case "function":
|
|
99
|
+
break;
|
|
149
100
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
properties.sort((a, b) => a.name.localeCompare(b.name));
|
|
155
|
-
const props = [];
|
|
156
|
-
properties.forEach((prop) => {
|
|
157
|
-
const isVModel = eventNames.includes(`update:${prop.name}`);
|
|
101
|
+
}), properties.sort((a, b) => a.name.localeCompare(b.name));
|
|
102
|
+
let props = [];
|
|
103
|
+
return properties.forEach((prop) => {
|
|
104
|
+
let isVModel = eventNames.includes(`update:${prop.name}`);
|
|
158
105
|
if (!isVModel && prop.templateFn) {
|
|
159
106
|
props.push(prop.templateFn(prop.name, prop.value));
|
|
160
107
|
return;
|
|
@@ -162,116 +109,73 @@ var generatePropsSourceCode = /* @__PURE__ */ __name((args, slotNames, eventName
|
|
|
162
109
|
let variableName = prop.name;
|
|
163
110
|
if (variableName in ctx.scriptVariables) {
|
|
164
111
|
let index = 1;
|
|
165
|
-
do
|
|
166
|
-
variableName = `${prop.name}${index}
|
|
167
|
-
|
|
168
|
-
} while (variableName in ctx.scriptVariables);
|
|
112
|
+
do
|
|
113
|
+
variableName = `${prop.name}${index}`, index++;
|
|
114
|
+
while (variableName in ctx.scriptVariables);
|
|
169
115
|
}
|
|
170
116
|
if (!isVModel) {
|
|
171
|
-
ctx.scriptVariables[variableName] = prop.value;
|
|
172
|
-
props.push(`:${prop.name}="${variableName}"`);
|
|
117
|
+
ctx.scriptVariables[variableName] = prop.value, props.push(`:${prop.name}="${variableName}"`);
|
|
173
118
|
return;
|
|
174
119
|
}
|
|
175
|
-
ctx.scriptVariables[variableName] = `ref(${prop.value})
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
} else {
|
|
183
|
-
props.push(`v-model:${prop.name}="${variableName}"`);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
return props.join(" ");
|
|
187
|
-
}, "generatePropsSourceCode");
|
|
188
|
-
var generateSlotSourceCode = /* @__PURE__ */ __name((args, slotNames, ctx) => {
|
|
189
|
-
const slotSourceCodes = [];
|
|
190
|
-
slotNames.forEach((slotName) => {
|
|
191
|
-
const arg = args[slotName];
|
|
192
|
-
if (!arg) {
|
|
120
|
+
ctx.scriptVariables[variableName] = `ref(${prop.value})`, ctx.imports.vue || (ctx.imports.vue = /* @__PURE__ */ new Set()), ctx.imports.vue.add("ref"), prop.name === "modelValue" ? props.push(`v-model="${variableName}"`) : props.push(`v-model:${prop.name}="${variableName}"`);
|
|
121
|
+
}), props.join(" ");
|
|
122
|
+
}, generateSlotSourceCode = (args, slotNames, ctx) => {
|
|
123
|
+
let slotSourceCodes = [];
|
|
124
|
+
return slotNames.forEach((slotName) => {
|
|
125
|
+
let arg = args[slotName];
|
|
126
|
+
if (!arg)
|
|
193
127
|
return;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (!slotContent) {
|
|
128
|
+
let slotContent = generateSlotChildrenSourceCode([arg], ctx);
|
|
129
|
+
if (!slotContent)
|
|
197
130
|
return;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return slotSourceCodes.join("\n\n");
|
|
209
|
-
}, "generateSlotSourceCode");
|
|
210
|
-
var generateSlotChildrenSourceCode = /* @__PURE__ */ __name((children, ctx) => {
|
|
211
|
-
const slotChildrenSourceCodes = [];
|
|
212
|
-
const generateSingleChildSourceCode = /* @__PURE__ */ __name((child) => {
|
|
213
|
-
if (isVNode(child)) {
|
|
131
|
+
let slotBindings = typeof arg == "function" ? getFunctionParamNames(arg) : [];
|
|
132
|
+
slotName === "default" && !slotBindings.length ? slotSourceCodes.push(slotContent) : slotSourceCodes.push(
|
|
133
|
+
`<template ${slotBindingsToString(slotName, slotBindings)}>${slotContent}</template>`
|
|
134
|
+
);
|
|
135
|
+
}), slotSourceCodes.join(`
|
|
136
|
+
|
|
137
|
+
`);
|
|
138
|
+
}, generateSlotChildrenSourceCode = (children, ctx) => {
|
|
139
|
+
let slotChildrenSourceCodes = [], generateSingleChildSourceCode = (child) => {
|
|
140
|
+
if (isVNode(child))
|
|
214
141
|
return generateVNodeSourceCode(child, ctx);
|
|
215
|
-
}
|
|
216
142
|
switch (typeof child) {
|
|
217
143
|
case "string":
|
|
218
144
|
case "number":
|
|
219
145
|
case "boolean":
|
|
220
146
|
return child.toString();
|
|
221
147
|
case "object":
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
if (Array.isArray(child)) {
|
|
226
|
-
return child.map(generateSingleChildSourceCode).filter((code) => code !== "").join("\n");
|
|
227
|
-
}
|
|
228
|
-
return JSON.stringify(child);
|
|
148
|
+
return child === null ? "" : Array.isArray(child) ? child.map(generateSingleChildSourceCode).filter((code) => code !== "").join(`
|
|
149
|
+
`) : JSON.stringify(child);
|
|
229
150
|
case "function": {
|
|
230
|
-
|
|
151
|
+
let paramNames = getFunctionParamNames(child).filter(
|
|
231
152
|
(param) => !["{", "}"].includes(param)
|
|
232
|
-
);
|
|
233
|
-
const parameters = {};
|
|
234
|
-
const proxied = {};
|
|
153
|
+
), parameters = {}, proxied = {};
|
|
235
154
|
paramNames.forEach((param) => {
|
|
236
|
-
parameters[param] = `{{ ${param} }}
|
|
237
|
-
proxied[param] = new Proxy(
|
|
155
|
+
parameters[param] = `{{ ${param} }}`, proxied[param] = new Proxy(
|
|
238
156
|
{
|
|
239
157
|
// we use the symbol to identify the proxy
|
|
240
|
-
[TRACKING_SYMBOL]:
|
|
158
|
+
[TRACKING_SYMBOL]: !0
|
|
241
159
|
},
|
|
242
160
|
{
|
|
243
161
|
// getter is called when any prop of the parameter is read
|
|
244
|
-
get:
|
|
245
|
-
if (key === TRACKING_SYMBOL) {
|
|
246
|
-
return t[TRACKING_SYMBOL];
|
|
247
|
-
}
|
|
248
|
-
if ([Symbol.toPrimitive, Symbol.toStringTag, "toString"].includes(key)) {
|
|
249
|
-
return () => `{{ ${param} }}`;
|
|
250
|
-
}
|
|
251
|
-
if (key === "v-bind") {
|
|
252
|
-
return `${param}`;
|
|
253
|
-
}
|
|
254
|
-
return `{{ ${param}.${key.toString()} }}`;
|
|
255
|
-
}, "get"),
|
|
162
|
+
get: (t, key) => key === TRACKING_SYMBOL ? t[TRACKING_SYMBOL] : [Symbol.toPrimitive, Symbol.toStringTag, "toString"].includes(key) ? () => `{{ ${param} }}` : key === "v-bind" ? `${param}` : `{{ ${param}.${key.toString()} }}`,
|
|
256
163
|
// ownKeys is called, among other uses, when an object is destructured
|
|
257
164
|
// in this case we assume the parameter is supposed to be bound using "v-bind"
|
|
258
165
|
// Therefore we only return one special key "v-bind" and the getter will be called afterwards with it
|
|
259
|
-
ownKeys:
|
|
260
|
-
return [`v-bind`];
|
|
261
|
-
}, "ownKeys"),
|
|
166
|
+
ownKeys: () => ["v-bind"],
|
|
262
167
|
/** Called when destructured */
|
|
263
|
-
getOwnPropertyDescriptor:
|
|
264
|
-
configurable:
|
|
265
|
-
enumerable:
|
|
168
|
+
getOwnPropertyDescriptor: () => ({
|
|
169
|
+
configurable: !0,
|
|
170
|
+
enumerable: !0,
|
|
266
171
|
value: param,
|
|
267
|
-
writable:
|
|
268
|
-
})
|
|
172
|
+
writable: !0
|
|
173
|
+
})
|
|
269
174
|
}
|
|
270
175
|
);
|
|
271
176
|
});
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
return slotSourceCode.replaceAll(/ (\S+)="{{ (\S+) }}"/g, ` :$1="$2"`);
|
|
177
|
+
let returnValue = child(proxied);
|
|
178
|
+
return generateSlotChildrenSourceCode([returnValue], ctx).replaceAll(/ (\S+)="{{ (\S+) }}"/g, ' :$1="$2"');
|
|
275
179
|
}
|
|
276
180
|
case "bigint":
|
|
277
181
|
return `{{ BigInt(${child.toString()}) }}`;
|
|
@@ -280,90 +184,44 @@ var generateSlotChildrenSourceCode = /* @__PURE__ */ __name((children, ctx) => {
|
|
|
280
184
|
default:
|
|
281
185
|
return "";
|
|
282
186
|
}
|
|
283
|
-
}
|
|
284
|
-
children.forEach((child) => {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
// $stable is a default property in vnode.children so we need to filter it out
|
|
303
|
-
// to not generate source code for it
|
|
304
|
-
Object.keys(vnode.children).filter((i) => i !== "$stable"),
|
|
305
|
-
ctx
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
const props = vnode.props ? generatePropsSourceCode(vnode.props, [], [], ctx) : "";
|
|
309
|
-
if (childrenCode) {
|
|
310
|
-
return `<${componentName}${props ? ` ${props}` : ""}>${childrenCode}</${componentName}>`;
|
|
311
|
-
}
|
|
312
|
-
return `<${componentName}${props ? ` ${props}` : ""} />`;
|
|
313
|
-
}, "generateVNodeSourceCode");
|
|
314
|
-
var getVNodeName = /* @__PURE__ */ __name((vnode) => {
|
|
315
|
-
if (typeof vnode.type === "string") {
|
|
187
|
+
};
|
|
188
|
+
return children.forEach((child) => {
|
|
189
|
+
let sourceCode = generateSingleChildSourceCode(child);
|
|
190
|
+
sourceCode !== "" && slotChildrenSourceCodes.push(sourceCode);
|
|
191
|
+
}), slotChildrenSourceCodes.join(`
|
|
192
|
+
`);
|
|
193
|
+
}, generateVNodeSourceCode = (vnode, ctx) => {
|
|
194
|
+
let componentName = getVNodeName(vnode), childrenCode = "";
|
|
195
|
+
typeof vnode.children == "string" ? childrenCode = vnode.children : Array.isArray(vnode.children) ? childrenCode = generateSlotChildrenSourceCode(vnode.children, ctx) : vnode.children && (childrenCode = generateSlotSourceCode(
|
|
196
|
+
vnode.children,
|
|
197
|
+
// $stable is a default property in vnode.children so we need to filter it out
|
|
198
|
+
// to not generate source code for it
|
|
199
|
+
Object.keys(vnode.children).filter((i) => i !== "$stable"),
|
|
200
|
+
ctx
|
|
201
|
+
));
|
|
202
|
+
let props = vnode.props ? generatePropsSourceCode(vnode.props, [], [], ctx) : "";
|
|
203
|
+
return childrenCode ? `<${componentName}${props ? ` ${props}` : ""}>${childrenCode}</${componentName}>` : `<${componentName}${props ? ` ${props}` : ""} />`;
|
|
204
|
+
}, getVNodeName = (vnode) => {
|
|
205
|
+
if (typeof vnode.type == "string")
|
|
316
206
|
return vnode.type;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if ("name" in vnode.type && vnode.type.name) {
|
|
207
|
+
if (typeof vnode.type == "object") {
|
|
208
|
+
if ("name" in vnode.type && vnode.type.name)
|
|
320
209
|
return vnode.type.name;
|
|
321
|
-
|
|
210
|
+
if ("__name" in vnode.type && vnode.type.__name)
|
|
322
211
|
return vnode.type.__name;
|
|
323
|
-
}
|
|
324
212
|
}
|
|
325
213
|
return "component";
|
|
326
|
-
},
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const fnStr = func.toString().replace(STRIP_COMMENTS, "");
|
|
331
|
-
const result = fnStr.slice(fnStr.indexOf("(") + 1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
|
|
332
|
-
if (!result) {
|
|
333
|
-
return [];
|
|
334
|
-
}
|
|
335
|
-
return result.flatMap((param) => {
|
|
336
|
-
if (["{", "}"].includes(param)) {
|
|
214
|
+
}, getFunctionParamNames = (func) => {
|
|
215
|
+
let STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm, ARGUMENT_NAMES = /([^\s,]+)/g, fnStr = func.toString().replace(STRIP_COMMENTS, ""), result = fnStr.slice(fnStr.indexOf("(") + 1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
|
|
216
|
+
return result ? result.flatMap((param) => {
|
|
217
|
+
if (["{", "}"].includes(param))
|
|
337
218
|
return param;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
return [nonMinifiedName, "}"];
|
|
345
|
-
}
|
|
346
|
-
return nonMinifiedName;
|
|
347
|
-
});
|
|
348
|
-
}, "getFunctionParamNames");
|
|
349
|
-
var slotBindingsToString = /* @__PURE__ */ __name((slotName, params) => {
|
|
350
|
-
if (!params.length) {
|
|
351
|
-
return `#${slotName}`;
|
|
352
|
-
}
|
|
353
|
-
if (params.length === 1) {
|
|
354
|
-
return `#${slotName}="${params[0]}"`;
|
|
355
|
-
}
|
|
356
|
-
return `#${slotName}="{ ${params.filter((i) => !["{", "}"].includes(i)).join(", ")} }"`;
|
|
357
|
-
}, "slotBindingsToString");
|
|
358
|
-
var formatObject = /* @__PURE__ */ __name((obj) => {
|
|
359
|
-
const isPrimitive = Object.values(obj).every(
|
|
360
|
-
(value) => value == null || typeof value !== "object"
|
|
361
|
-
);
|
|
362
|
-
if (isPrimitive) {
|
|
363
|
-
return JSON.stringify(obj);
|
|
364
|
-
}
|
|
365
|
-
return JSON.stringify(obj, null, 2);
|
|
366
|
-
}, "formatObject");
|
|
219
|
+
let nonMinifiedName = param.split(":")[0].trim();
|
|
220
|
+
return nonMinifiedName.startsWith("{") ? ["{", nonMinifiedName.substring(1)] : param.endsWith("}") && !nonMinifiedName.endsWith("}") ? [nonMinifiedName, "}"] : nonMinifiedName;
|
|
221
|
+
}) : [];
|
|
222
|
+
}, slotBindingsToString = (slotName, params) => params.length ? params.length === 1 ? `#${slotName}="${params[0]}"` : `#${slotName}="{ ${params.filter((i) => !["{", "}"].includes(i)).join(", ")} }"` : `#${slotName}`, formatObject = (obj) => Object.values(obj).every(
|
|
223
|
+
(value) => value == null || typeof value != "object"
|
|
224
|
+
) ? JSON.stringify(obj) : JSON.stringify(obj, null, 2);
|
|
367
225
|
|
|
368
226
|
// src/entry-preview-docs.ts
|
|
369
227
|
var decorators = [sourceDecorator];
|
package/dist/entry-preview.js
CHANGED
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
parameters,
|
|
6
6
|
render,
|
|
7
7
|
renderToCanvas
|
|
8
|
-
} from "./_browser-chunks/chunk-
|
|
9
|
-
import "./_browser-chunks/chunk-
|
|
8
|
+
} from "./_browser-chunks/chunk-YJYABENR.js";
|
|
9
|
+
import "./_browser-chunks/chunk-4BE7D4DS.js";
|
|
10
10
|
export {
|
|
11
11
|
decorateStory as applyDecorators,
|
|
12
12
|
argTypesEnhancers,
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,8 @@ import {
|
|
|
2
2
|
entry_preview_exports,
|
|
3
3
|
renderToCanvas,
|
|
4
4
|
setup
|
|
5
|
-
} from "./_browser-chunks/chunk-
|
|
6
|
-
import
|
|
7
|
-
__name
|
|
8
|
-
} from "./_browser-chunks/chunk-JFJ5UJ7Q.js";
|
|
5
|
+
} from "./_browser-chunks/chunk-YJYABENR.js";
|
|
6
|
+
import "./_browser-chunks/chunk-4BE7D4DS.js";
|
|
9
7
|
|
|
10
8
|
// src/globals.ts
|
|
11
9
|
import { global } from "@storybook/global";
|
|
@@ -22,45 +20,36 @@ import {
|
|
|
22
20
|
} from "storybook/preview-api";
|
|
23
21
|
import { h } from "vue";
|
|
24
22
|
function setProjectAnnotations(projectAnnotations) {
|
|
25
|
-
setDefaultProjectAnnotations(vueProjectAnnotations)
|
|
26
|
-
return originalSetProjectAnnotations(
|
|
23
|
+
return setDefaultProjectAnnotations(vueProjectAnnotations), originalSetProjectAnnotations(
|
|
27
24
|
projectAnnotations
|
|
28
25
|
);
|
|
29
26
|
}
|
|
30
|
-
__name(setProjectAnnotations, "setProjectAnnotations");
|
|
31
27
|
var vueProjectAnnotations = {
|
|
32
28
|
...entry_preview_exports,
|
|
33
29
|
/** @deprecated */
|
|
34
|
-
renderToCanvas:
|
|
35
|
-
if (renderContext.storyContext.testingLibraryRender == null)
|
|
30
|
+
renderToCanvas: (renderContext, canvasElement) => {
|
|
31
|
+
if (renderContext.storyContext.testingLibraryRender == null)
|
|
36
32
|
return renderToCanvas(renderContext, canvasElement);
|
|
37
|
-
|
|
38
|
-
const {
|
|
33
|
+
let {
|
|
39
34
|
storyFn,
|
|
40
35
|
storyContext: { testingLibraryRender: render }
|
|
41
|
-
} = renderContext;
|
|
42
|
-
const { unmount } = render(storyFn(), { container: canvasElement });
|
|
36
|
+
} = renderContext, { unmount } = render(storyFn(), { container: canvasElement });
|
|
43
37
|
return unmount;
|
|
44
|
-
}
|
|
38
|
+
}
|
|
45
39
|
};
|
|
46
40
|
function composeStory(story, componentAnnotations, projectAnnotations, exportsName) {
|
|
47
|
-
|
|
41
|
+
let composedStory = originalComposeStory(
|
|
48
42
|
story,
|
|
49
43
|
componentAnnotations,
|
|
50
44
|
projectAnnotations,
|
|
51
45
|
globalThis.globalProjectAnnotations ?? vueProjectAnnotations,
|
|
52
46
|
exportsName
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
Object.assign(renderable, composedStory);
|
|
56
|
-
return renderable;
|
|
47
|
+
), renderable = (...args) => h(composedStory(...args));
|
|
48
|
+
return Object.assign(renderable, composedStory), renderable;
|
|
57
49
|
}
|
|
58
|
-
__name(composeStory, "composeStory");
|
|
59
50
|
function composeStories(csfExports, projectAnnotations) {
|
|
60
|
-
|
|
61
|
-
return composedStories;
|
|
51
|
+
return originalComposeStories(csfExports, projectAnnotations, composeStory);
|
|
62
52
|
}
|
|
63
|
-
__name(composeStories, "composeStories");
|
|
64
53
|
export {
|
|
65
54
|
composeStories,
|
|
66
55
|
composeStory,
|
package/dist/playwright.js
CHANGED
package/dist/preset.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_oagrjas449k from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_oagrjas449k from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_oagrjas449k from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_oagrjas449k.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_oagrjas449k.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_oagrjas449k.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
-
var __defProp = Object.defineProperty;
|
|
13
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
14
12
|
|
|
15
13
|
// src/preset.ts
|
|
16
14
|
import { fileURLToPath } from "node:url";
|
|
17
|
-
var previewAnnotations =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return result.concat(input).concat([fileURLToPath(import.meta.resolve("@storybook/vue3/entry-preview"))]).concat(
|
|
15
|
+
var previewAnnotations = async (input = [], options) => {
|
|
16
|
+
let docsEnabled = Object.keys(await options.presets.apply("docs", {}, options)).length > 0;
|
|
17
|
+
return [].concat(input).concat([fileURLToPath(import.meta.resolve("@storybook/vue3/entry-preview"))]).concat(
|
|
21
18
|
docsEnabled ? [fileURLToPath(import.meta.resolve("@storybook/vue3/entry-preview-docs"))] : []
|
|
22
19
|
);
|
|
23
|
-
}
|
|
20
|
+
};
|
|
24
21
|
export {
|
|
25
22
|
previewAnnotations
|
|
26
23
|
};
|