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