@vueless/storybook 0.0.75-beta.12 → 0.0.75-beta.13
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.
|
@@ -64,12 +64,14 @@ export const vue3SourceDecorator = makeDecorator({
|
|
|
64
64
|
htmlWhitespaceSensitivity: "ignore",
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
// emits an event when the transformation is completed
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
// emits an event when the transformation is completed and content rendered
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
channel.emit("storybook/docs/snippet-rendered", {
|
|
70
|
+
id: context.id,
|
|
71
|
+
args: context.args,
|
|
72
|
+
source: postFormat(formattedCode),
|
|
73
|
+
});
|
|
74
|
+
}, 500);
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
await emitFormattedTemplate();
|
|
@@ -124,7 +126,9 @@ function preFormat(templateSource, args, argTypes) {
|
|
|
124
126
|
// eslint-disable-next-line vue/max-len
|
|
125
127
|
`</template><template v-else-if="slot === 'default' && args['defaultSlot']">{{ args['defaultSlot'] }}</template><template v-else-if="args[slot + 'Slot']">{{ args[slot + 'Slot'] }}</template></template>`;
|
|
126
128
|
|
|
127
|
-
const modelValue =
|
|
129
|
+
const modelValue = isPrimitive(args["modelValue"])
|
|
130
|
+
? JSON.stringify(args["modelValue"])?.replaceAll('"', "")
|
|
131
|
+
: JSON.stringify(args["modelValue"])?.replaceAll('"', "'");
|
|
128
132
|
|
|
129
133
|
templateSource = templateSource
|
|
130
134
|
.replace(/>[\s]+</g, "><")
|
|
@@ -259,16 +263,17 @@ function generateEnumAttributes(args, option) {
|
|
|
259
263
|
|
|
260
264
|
return enumKeys
|
|
261
265
|
.map((key) => {
|
|
262
|
-
|
|
263
|
-
Object.keys(args[key] || {}).length || (Array.isArray(args[key]) && args[key].length);
|
|
264
|
-
|
|
265
|
-
return key in args && isNotPrimitive
|
|
266
|
+
return key in args && !isPrimitive(args[key])
|
|
266
267
|
? `${key}="${JSON.stringify(args[key]).replaceAll('"', "'").replaceAll("{enumValue}", option)}"`
|
|
267
268
|
: `${key}="${option}"`;
|
|
268
269
|
})
|
|
269
270
|
.join(" ");
|
|
270
271
|
}
|
|
271
272
|
|
|
273
|
+
function isPrimitive(value) {
|
|
274
|
+
return !(value && (typeof value === "object" || Array.isArray(value)));
|
|
275
|
+
}
|
|
276
|
+
|
|
272
277
|
function propToSource(key, val, argType) {
|
|
273
278
|
const defaultValue = argType.table?.defaultValue?.summary;
|
|
274
279
|
const type = typeof val;
|