@histoire/controls 1.0.0-alpha.1 → 1.0.0-alpha.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.
Files changed (45) hide show
  1. package/dist/components/HstWrapper.vue.d.ts +4 -4
  2. package/dist/components/button/HstButton.vue.d.ts +3 -3
  3. package/dist/components/button/HstButtonGroup.vue.d.ts +3 -3
  4. package/dist/components/checkbox/HstCheckbox.vue.d.ts +3 -3
  5. package/dist/components/checkbox/HstCheckboxList.vue.d.ts +3 -3
  6. package/dist/components/checkbox/HstSimpleCheckbox.vue.d.ts +3 -1
  7. package/dist/components/colorselect/HstColorSelect.vue.d.ts +3 -3
  8. package/dist/components/design-tokens/HstColorShades.vue.d.ts +4 -4
  9. package/dist/components/design-tokens/HstTokenGrid.vue.d.ts +4 -4
  10. package/dist/components/design-tokens/HstTokenList.vue.d.ts +4 -4
  11. package/dist/components/json/HstJson.vue.d.ts +6 -4
  12. package/dist/components/number/HstNumber.vue.d.ts +6 -4
  13. package/dist/components/radio/HstRadio.vue.d.ts +3 -3
  14. package/dist/components/select/CustomSelect.vue.d.ts +4 -4
  15. package/dist/components/select/HstSelect.vue.d.ts +3 -3
  16. package/dist/components/slider/HstSlider.vue.d.ts +3 -1
  17. package/dist/components/text/HstText.vue.d.ts +6 -4
  18. package/dist/components/textarea/HstTextarea.vue.d.ts +6 -4
  19. package/dist/index.d.ts +64 -44
  20. package/dist/index.es.js +1876 -1815
  21. package/package.json +3 -3
  22. package/.histoire/dist/__sandbox.html +0 -16
  23. package/.histoire/dist/assets/BaseEmpty.d30f3079.js +0 -11
  24. package/.histoire/dist/assets/HomeView.8e044be6.js +0 -24
  25. package/.histoire/dist/assets/HstCheckbox.story.3d04d85b.js +0 -144
  26. package/.histoire/dist/assets/HstColorShades.story.68cf74d1.js +0 -532
  27. package/.histoire/dist/assets/HstCopyIcon.e40e725e.js +0 -51
  28. package/.histoire/dist/assets/HstNumber.story.1e1964ff.js +0 -160
  29. package/.histoire/dist/assets/HstSelect.story.04860383.js +0 -277
  30. package/.histoire/dist/assets/HstText.story.c915d831.js +0 -137
  31. package/.histoire/dist/assets/HstTextarea.story.802b9c26.js +0 -105
  32. package/.histoire/dist/assets/HstTokenGrid.story.025819d6.js +0 -148
  33. package/.histoire/dist/assets/HstTokenList.story.d3aa6575.js +0 -176
  34. package/.histoire/dist/assets/HstWrapper.246b6982.js +0 -56
  35. package/.histoire/dist/assets/SearchPane.daa2675c.js +0 -426
  36. package/.histoire/dist/assets/StoryView.2f64dad1.js +0 -2260
  37. package/.histoire/dist/assets/bundle-main.784e5bf7.js +0 -1156
  38. package/.histoire/dist/assets/bundle-sandbox.5e153933.js +0 -84
  39. package/.histoire/dist/assets/const.268165fd.js +0 -658
  40. package/.histoire/dist/assets/global-components.6736b2a9.js +0 -5722
  41. package/.histoire/dist/assets/search-docs-data.b9a75539.js +0 -6
  42. package/.histoire/dist/assets/style.04507241.css +0 -2504
  43. package/.histoire/dist/assets/vendor.2833ae3d.js +0 -28970
  44. package/.histoire/dist/histoire.svg +0 -51
  45. package/.histoire/dist/index.html +0 -16
@@ -1,658 +0,0 @@
1
- import { d as defineComponent, r as ref, p as onMounted, w as watch, o as onUnmounted, a as openBlock, b as createElementBlock, D as createApp, ab as Case, ac as Text, Z as vModelText, ad as vModelSelect, ae as vModelRadio, af as vModelCheckbox, ag as vModelDynamic } from "./vendor.2833ae3d.js";
2
- import { d as applyStateToVariant } from "./global-components.6736b2a9.js";
3
- var main = "";
4
- var histoireSetup = () => {
5
- };
6
- var setup = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7
- __proto__: null,
8
- "default": histoireSetup
9
- }, Symbol.toStringTag, { value: "Module" }));
10
- var __defProp = Object.defineProperty;
11
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
12
- var __hasOwnProp = Object.prototype.hasOwnProperty;
13
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
- var __spreadValues = (a, b) => {
16
- for (var prop in b || (b = {}))
17
- if (__hasOwnProp.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- if (__getOwnPropSymbols)
20
- for (var prop of __getOwnPropSymbols(b)) {
21
- if (__propIsEnum.call(b, prop))
22
- __defNormalProp(a, prop, b[prop]);
23
- }
24
- return a;
25
- };
26
- function indent(lines, count = 1) {
27
- return lines.map((line) => `${" ".repeat(count)}${line}`);
28
- }
29
- function unindent(code) {
30
- const lines = code.split("\n");
31
- let indentLevel = -1;
32
- let indentText;
33
- const linesToAnalyze = lines.filter((line) => line.trim().length > 0);
34
- for (const line of linesToAnalyze) {
35
- const match = /^\s*/.exec(line);
36
- if (match && (indentLevel === -1 || indentLevel > match[0].length)) {
37
- indentLevel = match[0].length;
38
- indentText = match[0];
39
- }
40
- }
41
- const result = [];
42
- for (const line of lines) {
43
- result.push(line.replace(indentText, ""));
44
- }
45
- return result.join("\n").trim();
46
- }
47
- function createAutoBuildingObject(format, specialKeysHandler, key = "", depth = 0) {
48
- const cache = {};
49
- if (depth > 32)
50
- return { key, cache, target: {}, proxy: () => key };
51
- const target = () => {
52
- const k = key + "()";
53
- return format ? format(k) : k;
54
- };
55
- const proxy = new Proxy(target, {
56
- get(_, p) {
57
- if (p === "__autoBuildingObject") {
58
- return true;
59
- }
60
- if (p === "__autoBuildingObjectGetKey") {
61
- return key;
62
- }
63
- if (specialKeysHandler) {
64
- const fn = specialKeysHandler(target, p);
65
- if (fn) {
66
- return fn();
67
- }
68
- }
69
- if (p === "toString") {
70
- const k = key + ".toString()";
71
- return () => format ? format(k) : k;
72
- }
73
- if (p === Symbol.toPrimitive) {
74
- return () => format ? format(key) : key;
75
- }
76
- if (!cache[p]) {
77
- const childKey = key ? `${key}.${p.toString()}` : p.toString();
78
- const child = createAutoBuildingObject(format, specialKeysHandler, childKey, depth + 1);
79
- cache[p] = __spreadValues({ key: childKey }, child);
80
- }
81
- return cache[p].proxy;
82
- },
83
- apply(_, thisArg, args) {
84
- const k = `${key}(${args.join(", ")})`;
85
- return format ? format(k) : k;
86
- }
87
- });
88
- return {
89
- key,
90
- cache,
91
- target,
92
- proxy
93
- };
94
- }
95
- const KEY_ESCAPE_REG = /[\s-.:|#@$£*%]/;
96
- const MAX_SINGLE_LINE_ARRAY_LENGTH = 3;
97
- function serializeJs(value) {
98
- if (value === void 0) {
99
- return "undefined";
100
- }
101
- if (value === null) {
102
- return "null";
103
- }
104
- if (typeof value === "string") {
105
- return `'${value}'`;
106
- }
107
- if (typeof value === "boolean") {
108
- return value ? "true" : "false";
109
- }
110
- if (Array.isArray(value)) {
111
- return printLines(arrayToSourceLines(value));
112
- }
113
- if (typeof value === "object") {
114
- return printLines(objectToSourceLines(value));
115
- }
116
- if (value == null ? void 0 : value.__autoBuildingObject) {
117
- return value;
118
- }
119
- if (typeof value === "function" && value.name) {
120
- return value.name;
121
- }
122
- return value.toString();
123
- }
124
- function printLines(lines) {
125
- return lines.map((line) => " ".repeat(line.spaces) + line.line).join("\n");
126
- }
127
- function objectToSourceLines(object, indentCount = 0) {
128
- return createLines(indentCount, (lines) => {
129
- lines.push("{");
130
- lines.push(...createLines(1, (lines2) => {
131
- for (const key in object) {
132
- const value = object[key];
133
- let printedKey = key;
134
- if (KEY_ESCAPE_REG.test(key)) {
135
- printedKey = `'${printedKey}'`;
136
- }
137
- addLinesFromValue(lines2, value, `${printedKey}: `, ",");
138
- }
139
- }));
140
- lines.push("}");
141
- });
142
- }
143
- function arrayToSourceLines(array, indentCount = 0) {
144
- return createLines(indentCount, (lines) => {
145
- const contentLines = createLines(1, (lines2) => {
146
- for (const value of array) {
147
- addLinesFromValue(lines2, value, "", ",");
148
- }
149
- });
150
- if (contentLines.length === 0) {
151
- lines.push("[]");
152
- } else if (contentLines.length <= MAX_SINGLE_LINE_ARRAY_LENGTH && !contentLines.some((line) => line.spaces > 1)) {
153
- const [first] = contentLines;
154
- first.line = contentLines.map(({ line }) => line.substring(0, line.length - 1)).join(", ");
155
- first.line = `[${first.line}]`;
156
- first.spaces--;
157
- lines.push(first);
158
- } else {
159
- lines.push("[", ...contentLines, "]");
160
- }
161
- });
162
- }
163
- function createLines(indentCount, handler) {
164
- const lines = [];
165
- handler(lines);
166
- return lines.map((line) => {
167
- if (line.spaces != null) {
168
- line.spaces += indentCount;
169
- return line;
170
- }
171
- return { spaces: indentCount, line };
172
- });
173
- }
174
- function addLinesFromValue(lines, value, before, after) {
175
- let result;
176
- if (Array.isArray(value)) {
177
- lines.push(...wrap(arrayToSourceLines(value), before, after));
178
- return;
179
- } else if (value && typeof value === "object") {
180
- lines.push(...wrap(objectToSourceLines(value), before, after));
181
- return;
182
- } else if (typeof value === "string") {
183
- result = value.includes("'") ? `\`${value}\`` : `'${value}'`;
184
- } else if (typeof value === "undefined") {
185
- result = "undefined";
186
- } else if (value === null) {
187
- result = "null";
188
- } else if (typeof value === "boolean") {
189
- result = value ? "true" : "false";
190
- } else {
191
- result = value;
192
- }
193
- lines.push(before + result + after);
194
- }
195
- function wrap(lines, before, after) {
196
- lines[0].line = before + lines[0].line;
197
- lines[lines.length - 1].line += after;
198
- return lines;
199
- }
200
- const voidElements = [
201
- "area",
202
- "base",
203
- "br",
204
- "col",
205
- "embed",
206
- "hr",
207
- "img",
208
- "input",
209
- "keygen",
210
- "link",
211
- "meta",
212
- "param",
213
- "source",
214
- "track",
215
- "wbr"
216
- ];
217
- async function generateSourceCode(variant) {
218
- var _a, _b, _c, _d, _e, _f;
219
- const vnode = (_d = (_c = (_b = variant.slots()).default) == null ? void 0 : _c.call(_b, { state: (_a = variant.state) != null ? _a : {} })) != null ? _d : [];
220
- const list = Array.isArray(vnode) ? vnode : [vnode];
221
- const lines = [];
222
- for (const n in list) {
223
- const vnode2 = list[n];
224
- lines.push(...(await printVNode(vnode2, (_f = (_e = variant.state) == null ? void 0 : _e._hPropState) == null ? void 0 : _f[n])).lines);
225
- }
226
- return lines.join("\n");
227
- }
228
- async function printVNode(vnode, propsOverrides = null) {
229
- var _a, _b, _c;
230
- if (vnode.type === Text) {
231
- return {
232
- lines: [vnode.children],
233
- isText: true
234
- };
235
- }
236
- const lines = [];
237
- if (typeof vnode.type === "object" || typeof vnode.type === "string") {
238
- let genDirective = function(dirName, dir, valueCode = null) {
239
- var _a2;
240
- let modifiers = "";
241
- for (const key in dir.modifiers) {
242
- if (dir.modifiers[key]) {
243
- modifiers += `.${key}`;
244
- }
245
- }
246
- let arg = "";
247
- if (dir.arg) {
248
- arg = `:${dir.arg}`;
249
- }
250
- if (valueCode) {
251
- valueCode = valueCode.replace(/^\$(setup|props|data)\./g, "");
252
- }
253
- const valueLines = valueCode ? [valueCode] : serializeAndCleanJs(dir.value);
254
- const attr = [];
255
- const dirAttr = `v-${dirName}${arg}${modifiers}="`;
256
- if (valueLines.length > 1) {
257
- attr.push(`${dirAttr}${valueLines[0]}`);
258
- attr.push(...valueLines.slice(1, valueLines.length - 1));
259
- attr.push(`${valueLines[valueLines.length - 1]}"`);
260
- multilineAttrs = true;
261
- } else {
262
- attr.push(`${dirAttr}${(_a2 = valueLines[0]) != null ? _a2 : ""}"`);
263
- }
264
- attrs.push(attr);
265
- }, addAttr = function(prop, value) {
266
- var _a2, _b2, _c2;
267
- if (typeof value !== "string" || ((_a2 = vnode.dynamicProps) == null ? void 0 : _a2.includes(prop))) {
268
- let directive = ":";
269
- if (prop.startsWith("on")) {
270
- directive = "@";
271
- }
272
- const arg = directive === "@" ? `${prop[2].toLowerCase()}${prop.slice(3)}` : prop;
273
- const vmodelListener = `onUpdate:${prop}`;
274
- if (directive === ":" && ((_b2 = vnode.dynamicProps) == null ? void 0 : _b2.includes(vmodelListener))) {
275
- skipProps.push(vmodelListener);
276
- const listener = vnode.props[vmodelListener];
277
- const listenerSource = listener.toString();
278
- let valueCode;
279
- const result = /\(\$event\) => (.*?) = \$event/.exec(listenerSource);
280
- if (result) {
281
- valueCode = result[1];
282
- }
283
- const modifiersKey = `${prop === "modelValue" ? "model" : prop}Modifiers`;
284
- const modifiers = (_c2 = vnode.props[modifiersKey]) != null ? _c2 : {};
285
- skipProps.push(modifiersKey);
286
- genDirective("model", {
287
- arg: prop === "modelValue" ? null : prop,
288
- modifiers,
289
- value
290
- }, valueCode);
291
- return;
292
- }
293
- let serialized;
294
- if (typeof value === "string" && value.startsWith("{{") && value.endsWith("}}")) {
295
- serialized = cleanupExpression(value.substring(2, value.length - 2).trim()).split("\n");
296
- } else if (typeof value === "function") {
297
- let code = cleanupExpression(value.toString().replace(/'/g, "\\'").replace(/"/g, "'"));
298
- const testResult = /function ([^\s]+)\(/.exec(code);
299
- if (testResult) {
300
- serialized = [testResult[1]];
301
- } else {
302
- if (code.startsWith("($event) => ")) {
303
- code = code.substring("($event) => ".length);
304
- }
305
- serialized = code.split("\n");
306
- }
307
- } else {
308
- serialized = serializeAndCleanJs(value);
309
- }
310
- if (serialized.length > 1) {
311
- multilineAttrs = true;
312
- const indented = [`${directive}${arg}="${serialized[0]}`];
313
- indented.push(...serialized.slice(1, serialized.length - 1));
314
- indented.push(`${serialized[serialized.length - 1]}"`);
315
- attrs.push(indented);
316
- } else {
317
- attrs.push([`${directive}${arg}="${serialized[0]}"`]);
318
- }
319
- } else {
320
- attrs.push([`${prop}="${value}"`]);
321
- }
322
- };
323
- if (((_a = vnode.type) == null ? void 0 : _a.__asyncLoader) && !vnode.type.__asyncResolved) {
324
- await vnode.type.__asyncLoader();
325
- }
326
- const attrs = [];
327
- let multilineAttrs = false;
328
- const skipProps = [
329
- "key"
330
- ];
331
- if (vnode.dirs) {
332
- for (const dir of vnode.dirs) {
333
- if (dir.dir === vModelText || dir.dir === vModelSelect || dir.dir === vModelRadio || dir.dir === vModelCheckbox || dir.dir === vModelDynamic) {
334
- const listenerKey = `onUpdate:${(_b = dir.arg) != null ? _b : "modelValue"}`;
335
- const listener = vnode.props[listenerKey];
336
- let valueCode = null;
337
- if (listener) {
338
- skipProps.push(listenerKey);
339
- const listenerSource = listener.toString();
340
- const result = /\(\$event\) => (.*?) = \$event/.exec(listenerSource);
341
- if (result) {
342
- valueCode = result[1];
343
- }
344
- }
345
- genDirective("model", dir, valueCode);
346
- } else if (dir.instance._ || dir.instance.$) {
347
- const target = (_c = dir.instance.$) != null ? _c : dir.instance._;
348
- let dirName;
349
- for (const directives of [target.directives, target.appContext.directives]) {
350
- for (const key in directives) {
351
- if (target.directives[key] === dir.dir) {
352
- dirName = key;
353
- break;
354
- }
355
- }
356
- if (dirName)
357
- break;
358
- }
359
- if (dirName) {
360
- genDirective(dirName, dir);
361
- }
362
- }
363
- }
364
- }
365
- for (const prop in vnode.props) {
366
- if (skipProps.includes(prop) || propsOverrides && prop in propsOverrides) {
367
- continue;
368
- }
369
- const value = vnode.props[prop];
370
- addAttr(prop, value);
371
- }
372
- if (propsOverrides) {
373
- for (const prop in propsOverrides) {
374
- addAttr(prop, propsOverrides[prop]);
375
- }
376
- }
377
- if (attrs.length > 1) {
378
- multilineAttrs = true;
379
- }
380
- const tagName = getTagName(vnode);
381
- let isChildText = false;
382
- const childLines = [];
383
- if (typeof vnode.children === "string") {
384
- if (tagName === "pre") {
385
- childLines.push(vnode.children);
386
- } else {
387
- childLines.push(...vnode.children.split("\n"));
388
- }
389
- isChildText = true;
390
- } else if (Array.isArray(vnode.children)) {
391
- let isAllChildText;
392
- for (const child of vnode.children) {
393
- const result = await printVNode(child);
394
- if (result.isText) {
395
- if (isAllChildText === void 0) {
396
- isAllChildText = true;
397
- }
398
- const text = result.lines[0];
399
- if (!childLines.length || /^\s/.test(text)) {
400
- childLines.push(text.trim());
401
- } else {
402
- childLines[childLines.length - 1] += text;
403
- }
404
- } else {
405
- if (isAllChildText === void 0) {
406
- isAllChildText = false;
407
- }
408
- childLines.push(...result.lines);
409
- }
410
- }
411
- if (isAllChildText !== void 0) {
412
- isChildText = isAllChildText;
413
- }
414
- }
415
- if (vnode.children && typeof vnode.children === "object" && !Array.isArray(vnode.children)) {
416
- for (const key in vnode.children) {
417
- if (typeof vnode.children[key] === "function") {
418
- const autoObject = createAutoBuildingObject((key2) => `{{ ${key2} }}`, (target, p) => {
419
- if (p === "__v_isRef") {
420
- return () => false;
421
- }
422
- });
423
- const children = vnode.children[key](autoObject.proxy);
424
- const slotLines = [];
425
- for (const child of children) {
426
- slotLines.push(...(await printVNode(child)).lines);
427
- }
428
- const slotProps = Object.keys(autoObject.cache);
429
- if (slotProps.length) {
430
- childLines.push(`<template #${key}="{ ${slotProps.join(", ")} }">`);
431
- childLines.push(...indent(slotLines));
432
- childLines.push("</template>");
433
- } else if (key === "default") {
434
- childLines.push(...slotLines);
435
- } else {
436
- childLines.push(`<template #${key}>`);
437
- childLines.push(...indent(slotLines));
438
- childLines.push(`</template>`);
439
- }
440
- }
441
- }
442
- }
443
- const tag = [`<${tagName}`];
444
- if (multilineAttrs) {
445
- for (const attrLines of attrs) {
446
- tag.push(...indent(attrLines));
447
- }
448
- if (childLines.length > 0) {
449
- tag.push(">");
450
- }
451
- } else {
452
- if (attrs.length === 1) {
453
- tag[0] += ` ${attrs[0]}`;
454
- }
455
- if (childLines.length > 0) {
456
- tag[0] += ">";
457
- }
458
- }
459
- const isVoid = voidElements.includes(tagName.toLowerCase());
460
- if (childLines.length > 0) {
461
- if (childLines.length === 1 && tag.length === 1 && !attrs.length && isChildText) {
462
- lines.push(`${tag[0]}${childLines[0]}</${tagName}>`);
463
- } else {
464
- lines.push(...tag);
465
- lines.push(...indent(childLines));
466
- lines.push(`</${tagName}>`);
467
- }
468
- } else if (tag.length > 1) {
469
- lines.push(...tag);
470
- lines.push(isVoid ? ">" : "/>");
471
- } else {
472
- lines.push(`${tag[0]}${isVoid ? "" : " /"}>`);
473
- }
474
- } else if ((vnode == null ? void 0 : vnode.shapeFlag) & 1 << 4) {
475
- for (const child of vnode.children) {
476
- lines.push(...(await printVNode(child)).lines);
477
- }
478
- }
479
- return {
480
- lines
481
- };
482
- }
483
- function getTagName(vnode) {
484
- var _a, _b, _c, _d, _e;
485
- if (typeof vnode.type === "string") {
486
- return vnode.type;
487
- } else if ((_a = vnode.type) == null ? void 0 : _a.__asyncResolved) {
488
- const asyncComp = (_b = vnode.type) == null ? void 0 : _b.__asyncResolved;
489
- return (_c = asyncComp.name) != null ? _c : getNameFromFile(asyncComp.__file);
490
- } else if ((_d = vnode.type) == null ? void 0 : _d.name) {
491
- return vnode.type.name;
492
- } else if ((_e = vnode.type) == null ? void 0 : _e.__file) {
493
- return getNameFromFile(vnode.type.__file);
494
- }
495
- return "Anonymous";
496
- }
497
- function getNameFromFile(file) {
498
- const parts = /([^/]+)\.vue$/.exec(file);
499
- if (parts) {
500
- return Case.exports.pascal(parts[1]);
501
- }
502
- return "Anonymous";
503
- }
504
- function serializeAndCleanJs(value) {
505
- const isAutoBuildingObject = !!(value == null ? void 0 : value.__autoBuildingObject);
506
- const result = serializeJs(value);
507
- if (isAutoBuildingObject) {
508
- return [cleanupExpression(result.__autoBuildingObjectGetKey)];
509
- } else {
510
- return cleanupExpression(result).split("\n");
511
- }
512
- }
513
- function cleanupExpression(expr) {
514
- return expr.replace(/\$setup\./g, "");
515
- }
516
- const _sfc_main = /* @__PURE__ */ defineComponent({
517
- name: "SandboxVue3",
518
- props: {
519
- variant: {
520
- type: Object,
521
- required: true
522
- },
523
- story: {
524
- type: Object,
525
- required: true
526
- },
527
- slotName: {
528
- type: String,
529
- default: "default"
530
- }
531
- },
532
- emits: {
533
- ready: () => true
534
- },
535
- setup(__props, { emit }) {
536
- const props = __props;
537
- const sandbox = ref();
538
- let app;
539
- let mounting = false;
540
- async function mountVariant() {
541
- mounting = true;
542
- await props.variant.initState();
543
- let lastPropsTypesSnapshot;
544
- app = createApp({
545
- name: "SandboxVue3",
546
- render: () => {
547
- var _a, _b, _c, _d, _e, _f, _g;
548
- const vnodes = (_g = (_c = (_a = props.variant.slots()) == null ? void 0 : _a[props.slotName]) == null ? void 0 : _c.call(_a, {
549
- state: (_b = props.variant.state) != null ? _b : {}
550
- })) != null ? _g : (_f = (_d = props.story.slots()) == null ? void 0 : _d[props.slotName]) == null ? void 0 : _f.call(_d, {
551
- state: (_e = props.variant.state) != null ? _e : {}
552
- });
553
- if (props.slotName === "default") {
554
- const propsTypes = vnodes.filter((vnode) => typeof vnode.type === "object").map((vnode, index) => {
555
- var _a2, _b2, _c2;
556
- const propDefs = [];
557
- for (const key in vnode.type.props) {
558
- const prop = vnode.type.props[key];
559
- let types;
560
- let defaultValue;
561
- if (prop) {
562
- const rawTypes = Array.isArray(prop.type) ? prop.type : [prop.type];
563
- types = rawTypes.map((t) => {
564
- switch (t) {
565
- case String:
566
- return "string";
567
- case Number:
568
- return "number";
569
- case Boolean:
570
- return "boolean";
571
- case Object:
572
- return "object";
573
- case Array:
574
- return "array";
575
- default:
576
- return "unknown";
577
- }
578
- });
579
- defaultValue = typeof prop.default === "function" ? prop.default.toString() : prop.default;
580
- }
581
- propDefs.push({
582
- name: key,
583
- types,
584
- required: prop == null ? void 0 : prop.required,
585
- default: defaultValue
586
- });
587
- if ((_c2 = (_b2 = (_a2 = props.variant.state) == null ? void 0 : _a2._hPropState) == null ? void 0 : _b2[index]) == null ? void 0 : _c2[key]) {
588
- vnode.props[key] = props.variant.state._hPropState[index][key];
589
- }
590
- }
591
- return {
592
- name: getTagName(vnode),
593
- index,
594
- props: propDefs
595
- };
596
- }).filter((def) => def.props.length);
597
- const snapshot = JSON.stringify(propsTypes);
598
- if (!lastPropsTypesSnapshot || lastPropsTypesSnapshot !== snapshot) {
599
- applyStateToVariant(props.variant, {
600
- _hPropDefs: propsTypes
601
- });
602
- if (!props.variant.state._hPropState) {
603
- applyStateToVariant(props.variant, {
604
- _hPropState: {}
605
- });
606
- }
607
- lastPropsTypesSnapshot = snapshot;
608
- }
609
- }
610
- return vnodes;
611
- }
612
- });
613
- if (typeof (setup == null ? void 0 : void 0) === "function") {
614
- await (void 0)({
615
- app,
616
- story: props.story,
617
- variant: props.variant
618
- });
619
- }
620
- if (typeof props.variant.setupApp === "function") {
621
- await props.variant.setupApp({
622
- app,
623
- story: props.story,
624
- variant: props.variant
625
- });
626
- }
627
- const target = document.createElement("div");
628
- sandbox.value.appendChild(target);
629
- app.mount(target);
630
- emit("ready");
631
- }
632
- onMounted(async () => {
633
- if (props.variant.initState) {
634
- await mountVariant();
635
- }
636
- });
637
- watch(() => props.variant.initState, (value) => {
638
- if (value && !mounting) {
639
- mountVariant();
640
- }
641
- });
642
- onUnmounted(() => {
643
- app == null ? void 0 : app.unmount();
644
- });
645
- return (_ctx, _cache) => {
646
- return openBlock(), createElementBlock("div", {
647
- ref_key: "sandbox",
648
- ref: sandbox,
649
- class: "__histoire-sandbox htw-overflow-auto"
650
- }, null, 512);
651
- };
652
- }
653
- });
654
- const STATE_SYNC = "__histoire:state-sync";
655
- const SANDBOX_READY = "__histoire:sandbox-ready";
656
- const EVENT_SEND = "__histoire:event";
657
- const PREVIEW_SETTINGS_SYNC = "__histoire:preview-settings-sync";
658
- export { EVENT_SEND as E, PREVIEW_SETTINGS_SYNC as P, STATE_SYNC as S, _sfc_main as _, SANDBOX_READY as a, generateSourceCode as g, unindent as u };