histoire 0.4.5 → 0.4.6

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.
@@ -17,18 +17,19 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { computed, pushScopeId, popScopeId, defineComponent, useCssVars, unref, toRefs, ref, openBlock, createElementBlock, createVNode, withCtx, normalizeClass, createElementVNode, toDisplayString, resolveComponent, withModifiers, watch, normalizeStyle, Fragment, renderList, createBlock, withKeys, renderSlot, createTextVNode, resolveDirective, withDirectives, vModelText, createCommentVNode, createStaticVNode, onUnmounted, toRaw, watchEffect, onMounted, nextTick, Text, vModelSelect, vModelRadio, vModelCheckbox, vModelDynamic, shallowRef, mergeProps, Transition, reactive, onBeforeUnmount, h, resolveDynamicComponent } from "vue";
20
+ import { computed, pushScopeId, popScopeId, defineComponent, useCssVars, unref, toRefs, ref, openBlock, createElementBlock, createVNode, withCtx, normalizeClass, createElementVNode, toDisplayString, resolveComponent, withModifiers, watch, normalizeStyle, Fragment, renderList, createBlock, withKeys, renderSlot, createTextVNode, resolveDirective, withDirectives, vModelText, createCommentVNode, createStaticVNode, onUnmounted, toRaw, mergeProps, onMounted, nextTick, isRef, watchEffect, Text, vModelSelect, vModelRadio, vModelCheckbox, vModelDynamic, shallowRef, Transition, reactive, onBeforeUnmount, h, resolveDynamicComponent } from "vue";
21
21
  import { useRoute, useRouter } from "vue-router";
22
22
  import { Icon } from "@iconify/vue";
23
23
  import { u as useStoryStore, b as base } from "./story.js";
24
- import { u as useScrollOnActive, B as BaseListItemLink, _ as _export_sfc, i as isMobile, b as BaseSplitPane, a as _sfc_main$s } from "./MobileOverlay.js";
24
+ import { u as useScrollOnActive, B as BaseListItemLink, _ as _export_sfc, i as isMobile, b as BaseSplitPane, a as _sfc_main$u } from "./MobileOverlay.js";
25
25
  import { B as BaseEmpty } from "./BaseEmpty.js";
26
- import { useResizeObserver, useStorage, useEventListener } from "@vueuse/core";
27
- import { _ as _sfc_main$r, t as toRawDeep } from "./reactivity.js";
26
+ import { useResizeObserver, useStorage, useEventListener, useTimeoutFn, onClickOutside } from "@vueuse/core";
27
+ import { _ as _sfc_main$t, t as toRawDeep, a as applyStateToVariant, c as clone } from "./state.js";
28
28
  import { defineStore } from "pinia";
29
29
  import { h as histoireConfig } from "./config.js";
30
30
  import { S as STATE_SYNC, a as SANDBOX_READY, E as EVENT_SEND, P as PREVIEW_SETTINGS_SYNC } from "./const.js";
31
31
  import { useEventsStore } from "./events.js";
32
+ import { Dropdown } from "floating-vue";
32
33
  import { setCDN, getHighlighter } from "shiki";
33
34
  import { HstCopyIcon } from "@histoire/controls";
34
35
  import { pascal } from "case";
@@ -48,8 +49,8 @@ function useCurrentVariantRoute(variant) {
48
49
  }
49
50
  var StoryVariantListItem_vue_vue_type_style_index_0_scoped_true_lang = "";
50
51
  const _withScopeId$7 = (n) => (pushScopeId("data-v-2cdc2ac0"), n = n(), popScopeId(), n);
51
- const _hoisted_1$o = { class: "htw-truncate" };
52
- const _sfc_main$q = /* @__PURE__ */ defineComponent({
52
+ const _hoisted_1$q = { class: "htw-truncate" };
53
+ const _sfc_main$s = /* @__PURE__ */ defineComponent({
53
54
  props: {
54
55
  variant: {
55
56
  type: Object,
@@ -86,7 +87,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
86
87
  "bind-icon-color": !active && unref(variant).iconColor
87
88
  }])
88
89
  }, null, 8, ["icon", "class"]),
89
- createElementVNode("span", _hoisted_1$o, toDisplayString(unref(variant).title), 1)
90
+ createElementVNode("span", _hoisted_1$q, toDisplayString(unref(variant).title), 1)
90
91
  ];
91
92
  }),
92
93
  _: 1
@@ -95,11 +96,11 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
95
96
  };
96
97
  }
97
98
  });
98
- var StoryVariantListItem = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-2cdc2ac0"]]);
99
+ var StoryVariantListItem = /* @__PURE__ */ _export_sfc(_sfc_main$s, [["__scopeId", "data-v-2cdc2ac0"]]);
99
100
  var StoryVariantGridItem_vue_vue_type_style_index_0_scoped_true_lang = "";
100
101
  const _withScopeId$6 = (n) => (pushScopeId("data-v-5c057bcc"), n = n(), popScopeId(), n);
101
- const _hoisted_1$n = { class: "htw-flex-none htw-flex htw-items-center" };
102
- const _sfc_main$p = /* @__PURE__ */ defineComponent({
102
+ const _hoisted_1$p = { class: "htw-flex-none htw-flex htw-items-center" };
103
+ const _sfc_main$r = /* @__PURE__ */ defineComponent({
103
104
  props: {
104
105
  variant: {
105
106
  type: Object,
@@ -149,7 +150,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
149
150
  ref: el,
150
151
  class: "htw-cursor-default htw-flex htw-flex-col htw-gap-y-1"
151
152
  }, [
152
- createElementVNode("div", _hoisted_1$n, [
153
+ createElementVNode("div", _hoisted_1$p, [
153
154
  createVNode(_component_RouterLink, {
154
155
  to: unref(targetRoute),
155
156
  class: normalizeClass(["htw-rounded htw-w-max htw-px-2 htw-py-0.5 htw-min-w-16 htw-cursor-pointer htw-flex htw-items-center htw-gap-1", {
@@ -181,7 +182,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
181
182
  onClick: _cache[0] || (_cache[0] = withModifiers(($event) => selectVariant(), ["stop", "prevent"])),
182
183
  onKeyup: _cache[1] || (_cache[1] = ($event) => selectVariant())
183
184
  }, [
184
- createVNode(_sfc_main$r, {
185
+ createVNode(_sfc_main$t, {
185
186
  variant: unref(variant),
186
187
  story: __props.story,
187
188
  onReady
@@ -191,8 +192,8 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
191
192
  };
192
193
  }
193
194
  });
194
- var StoryVariantGridItem = /* @__PURE__ */ _export_sfc(_sfc_main$p, [["__scopeId", "data-v-5c057bcc"]]);
195
- const _sfc_main$o = /* @__PURE__ */ defineComponent({
195
+ var StoryVariantGridItem = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["__scopeId", "data-v-5c057bcc"]]);
196
+ const _sfc_main$q = /* @__PURE__ */ defineComponent({
196
197
  setup(__props) {
197
198
  const storyStore = useStoryStore();
198
199
  const gridTemplateWidth = computed(() => {
@@ -280,15 +281,15 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
280
281
  };
281
282
  }
282
283
  });
283
- const _hoisted_1$m = { class: "htw-flex htw-items-center htw-gap-1 htw-text-gray-500 htw-flex-1 htw-truncate htw-min-w-0" };
284
- const _sfc_main$n = /* @__PURE__ */ defineComponent({
284
+ const _hoisted_1$o = { class: "htw-flex htw-items-center htw-gap-1 htw-text-gray-500 htw-flex-1 htw-truncate htw-min-w-0" };
285
+ const _sfc_main$p = /* @__PURE__ */ defineComponent({
285
286
  props: {
286
287
  variant: null
287
288
  },
288
289
  setup(__props) {
289
290
  return (_ctx, _cache) => {
290
291
  var _a;
291
- return openBlock(), createElementBlock("div", _hoisted_1$m, [
292
+ return openBlock(), createElementBlock("div", _hoisted_1$o, [
292
293
  createVNode(unref(Icon), {
293
294
  icon: (_a = __props.variant.icon) != null ? _a : "carbon:cube",
294
295
  class: normalizeClass(["base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50", [
@@ -312,15 +313,15 @@ const usePreviewSettingsStore = defineStore("preview-settings", () => {
312
313
  currentSettings
313
314
  };
314
315
  });
315
- const _hoisted_1$l = { class: "htw-text-white htw-w-[16px] htw-h-[16px] htw-relative" };
316
- const _hoisted_2$h = {
316
+ const _hoisted_1$n = { class: "htw-text-white htw-w-[16px] htw-h-[16px] htw-relative" };
317
+ const _hoisted_2$j = {
317
318
  width: "16",
318
319
  height: "16",
319
320
  viewBox: "0 0 24 24",
320
321
  class: "htw-relative htw-z-10"
321
322
  };
322
- const _hoisted_3$9 = ["stroke-dasharray", "stroke-dashoffset"];
323
- const _sfc_main$m = /* @__PURE__ */ defineComponent({
323
+ const _hoisted_3$c = ["stroke-dasharray", "stroke-dashoffset"];
324
+ const _sfc_main$o = /* @__PURE__ */ defineComponent({
324
325
  props: {
325
326
  modelValue: {
326
327
  type: Boolean,
@@ -356,13 +357,13 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
356
357
  _cache[2] || (_cache[2] = withKeys(withModifiers(($event) => toggle(), ["prevent"]), ["space"]))
357
358
  ]
358
359
  }, [
359
- createElementVNode("div", _hoisted_1$l, [
360
+ createElementVNode("div", _hoisted_1$n, [
360
361
  createElementVNode("div", {
361
362
  class: normalizeClass(["htw-border group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out", [
362
363
  __props.modelValue ? "htw-border-primary-500 htw-border-8" : "htw-border-black/25 dark:htw-border-white/25 htw-delay-150"
363
364
  ]])
364
365
  }, null, 2),
365
- (openBlock(), createElementBlock("svg", _hoisted_2$h, [
366
+ (openBlock(), createElementBlock("svg", _hoisted_2$j, [
366
367
  createElementVNode("path", {
367
368
  ref_key: "path",
368
369
  ref: path,
@@ -376,7 +377,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
376
377
  ]]),
377
378
  "stroke-dasharray": dasharray.value,
378
379
  "stroke-dashoffset": unref(dashoffset)
379
- }, null, 10, _hoisted_3$9)
380
+ }, null, 10, _hoisted_3$c)
380
381
  ]))
381
382
  ]),
382
383
  renderSlot(_ctx.$slots, "default")
@@ -384,18 +385,18 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
384
385
  };
385
386
  }
386
387
  });
387
- const _hoisted_1$k = { class: "htw-flex htw-flex-col htw-items-stretch" };
388
- const _hoisted_2$g = /* @__PURE__ */ createTextVNode(" Rotate ");
389
- const _hoisted_3$8 = { class: "htw-flex htw-gap-2 htw-px-4 htw-py-3" };
390
- const _hoisted_4$6 = /* @__PURE__ */ createElementVNode("span", { class: "htw-opacity-50" }, "x", -1);
391
- const _hoisted_5$5 = ["onClick"];
392
- const _hoisted_6$5 = { class: "htw-ml-auto htw-opacity-70 htw-flex htw-gap-1" };
388
+ const _hoisted_1$m = { class: "htw-flex htw-flex-col htw-items-stretch" };
389
+ const _hoisted_2$i = /* @__PURE__ */ createTextVNode(" Rotate ");
390
+ const _hoisted_3$b = { class: "htw-flex htw-gap-2 htw-px-4 htw-py-3" };
391
+ const _hoisted_4$8 = /* @__PURE__ */ createElementVNode("span", { class: "htw-opacity-50" }, "x", -1);
392
+ const _hoisted_5$6 = ["onClick"];
393
+ const _hoisted_6$6 = { class: "htw-ml-auto htw-opacity-70 htw-flex htw-gap-1" };
393
394
  const _hoisted_7$3 = { key: 0 };
394
395
  const _hoisted_8$2 = { key: 0 };
395
396
  const _hoisted_9 = { key: 1 };
396
397
  const _hoisted_10 = { key: 2 };
397
398
  const _hoisted_11 = { key: 0 };
398
- const _sfc_main$l = /* @__PURE__ */ defineComponent({
399
+ const _sfc_main$n = /* @__PURE__ */ defineComponent({
399
400
  setup(__props) {
400
401
  const settings = usePreviewSettingsStore().currentSettings;
401
402
  return (_ctx, _cache) => {
@@ -409,17 +410,17 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
409
410
  class: "htw-h-full htw-flex-none"
410
411
  }, {
411
412
  popper: withCtx(({ hide }) => [
412
- createElementVNode("div", _hoisted_1$k, [
413
- createVNode(_sfc_main$m, {
413
+ createElementVNode("div", _hoisted_1$m, [
414
+ createVNode(_sfc_main$o, {
414
415
  modelValue: unref(settings).rotate,
415
416
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(settings).rotate = $event)
416
417
  }, {
417
418
  default: withCtx(() => [
418
- _hoisted_2$g
419
+ _hoisted_2$i
419
420
  ]),
420
421
  _: 1
421
422
  }, 8, ["modelValue"]),
422
- createElementVNode("div", _hoisted_3$8, [
423
+ createElementVNode("div", _hoisted_3$b, [
423
424
  withDirectives(createElementVNode("input", {
424
425
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(settings).responsiveWidth = $event),
425
426
  type: "number",
@@ -435,7 +436,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
435
436
  ],
436
437
  [_directive_tooltip, "Responsive width (px)"]
437
438
  ]),
438
- _hoisted_4$6,
439
+ _hoisted_4$8,
439
440
  withDirectives(createElementVNode("input", {
440
441
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => unref(settings).responsiveHeight = $event),
441
442
  type: "number",
@@ -465,7 +466,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
465
466
  }
466
467
  }, [
467
468
  createTextVNode(toDisplayString(preset.label) + " ", 1),
468
- createElementVNode("span", _hoisted_6$5, [
469
+ createElementVNode("span", _hoisted_6$6, [
469
470
  preset.width ? (openBlock(), createElementBlock("span", _hoisted_7$3, [
470
471
  createTextVNode(toDisplayString(preset.width), 1),
471
472
  !preset.height ? (openBlock(), createElementBlock("span", _hoisted_8$2, "px")) : createCommentVNode("", true)
@@ -476,7 +477,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
476
477
  !preset.width ? (openBlock(), createElementBlock("span", _hoisted_11, "px")) : createCommentVNode("", true)
477
478
  ])) : createCommentVNode("", true)
478
479
  ])
479
- ], 10, _hoisted_5$5);
480
+ ], 10, _hoisted_5$6);
480
481
  }), 128))
481
482
  ])
482
483
  ]),
@@ -508,14 +509,14 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
508
509
  });
509
510
  var StoryVariantBackground_vue_vue_type_style_index_0_scoped_true_lang = "";
510
511
  const _withScopeId$5 = (n) => (pushScopeId("data-v-bde73868"), n = n(), popScopeId(), n);
511
- const _hoisted_1$j = { class: "htw-cursor-pointer hover:htw-text-primary-500 htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 htw-group" };
512
- const _hoisted_2$f = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ createElementVNode("div", { class: "bind-preview-bg htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/50 dark:htw-border-white/50" }, null, -1));
513
- const _hoisted_3$7 = { class: "htw-flex htw-flex-col htw-items-stretch" };
514
- const _hoisted_4$5 = /* @__PURE__ */ createTextVNode(" Checkerboard ");
515
- const _hoisted_5$4 = ["onClick"];
516
- const _hoisted_6$4 = { class: "htw-mr-auto" };
512
+ const _hoisted_1$l = { class: "htw-cursor-pointer hover:htw-text-primary-500 htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 htw-group" };
513
+ const _hoisted_2$h = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ createElementVNode("div", { class: "bind-preview-bg htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/50 dark:htw-border-white/50" }, null, -1));
514
+ const _hoisted_3$a = { class: "htw-flex htw-flex-col htw-items-stretch" };
515
+ const _hoisted_4$7 = /* @__PURE__ */ createTextVNode(" Checkerboard ");
516
+ const _hoisted_5$5 = ["onClick"];
517
+ const _hoisted_6$5 = { class: "htw-mr-auto" };
517
518
  const _hoisted_7$2 = { class: "htw-ml-auto htw-opacity-70" };
518
- const _sfc_main$k = /* @__PURE__ */ defineComponent({
519
+ const _sfc_main$m = /* @__PURE__ */ defineComponent({
519
520
  setup(__props) {
520
521
  useCssVars((_ctx) => ({
521
522
  "b797c7ca": unref(settings).backgroundColor
@@ -531,13 +532,13 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
531
532
  class: "htw-h-full htw-flex-none"
532
533
  }, {
533
534
  popper: withCtx(({ hide }) => [
534
- createElementVNode("div", _hoisted_3$7, [
535
- createVNode(_sfc_main$m, {
535
+ createElementVNode("div", _hoisted_3$a, [
536
+ createVNode(_sfc_main$o, {
536
537
  modelValue: unref(settings).checkerboard,
537
538
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(settings).checkerboard = $event)
538
539
  }, {
539
540
  default: withCtx(() => [
540
- _hoisted_4$5
541
+ _hoisted_4$7
541
542
  ]),
542
543
  _: 1
543
544
  }, 8, ["modelValue"]),
@@ -552,7 +553,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
552
553
  hide();
553
554
  }
554
555
  }, [
555
- createElementVNode("span", _hoisted_6$4, toDisplayString(option.label), 1),
556
+ createElementVNode("span", _hoisted_6$5, toDisplayString(option.label), 1),
556
557
  option.color !== "$checkerboard" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
557
558
  createElementVNode("span", _hoisted_7$2, toDisplayString(option.color), 1),
558
559
  createElementVNode("div", {
@@ -562,13 +563,13 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
562
563
  })
563
564
  }, null, 4)
564
565
  ], 64)) : createCommentVNode("", true)
565
- ], 10, _hoisted_5$4);
566
+ ], 10, _hoisted_5$5);
566
567
  }), 128))
567
568
  ])
568
569
  ]),
569
570
  default: withCtx(() => [
570
- withDirectives((openBlock(), createElementBlock("div", _hoisted_1$j, [
571
- _hoisted_2$f,
571
+ withDirectives((openBlock(), createElementBlock("div", _hoisted_1$l, [
572
+ _hoisted_2$h,
572
573
  createVNode(unref(Icon), {
573
574
  icon: "carbon:caret-down",
574
575
  class: "htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
@@ -582,15 +583,15 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
582
583
  };
583
584
  }
584
585
  });
585
- var StoryVariantBackground = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-bde73868"]]);
586
+ var StoryVariantBackground = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-bde73868"]]);
586
587
  function getSandboxUrl(story, variant) {
587
588
  const url = new URLSearchParams();
588
589
  url.append("storyId", story.id);
589
590
  url.append("variantId", variant.id);
590
591
  return `${base}__sandbox?${url.toString()}`;
591
592
  }
592
- const _hoisted_1$i = ["href"];
593
- const _sfc_main$j = /* @__PURE__ */ defineComponent({
593
+ const _hoisted_1$k = ["href"];
594
+ const _sfc_main$l = /* @__PURE__ */ defineComponent({
594
595
  props: {
595
596
  variant: null,
596
597
  story: null
@@ -611,23 +612,23 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
611
612
  icon: "carbon:launch",
612
613
  class: "base-list-item-link-icon htw-w-4 htw-h-4"
613
614
  })
614
- ], 8, _hoisted_1$i)), [
615
+ ], 8, _hoisted_1$k)), [
615
616
  [_directive_tooltip, "Open variant in new tab"]
616
617
  ]);
617
618
  };
618
619
  }
619
620
  });
620
621
  var HatchedPattern_vue_vue_type_style_index_0_scoped_true_lang = "";
621
- const _sfc_main$i = {};
622
+ const _sfc_main$k = {};
622
623
  const _withScopeId$4 = (n) => (pushScopeId("data-v-250960ac"), n = n(), popScopeId(), n);
623
- const _hoisted_1$h = { class: "__histoire-hatched-pattern" };
624
+ const _hoisted_1$j = { class: "__histoire-hatched-pattern" };
624
625
  function _sfc_render$3(_ctx, _cache) {
625
- return openBlock(), createElementBlock("div", _hoisted_1$h);
626
+ return openBlock(), createElementBlock("div", _hoisted_1$j);
626
627
  }
627
- var HatchedPattern = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$3], ["__scopeId", "data-v-250960ac"]]);
628
- const _sfc_main$h = {};
629
- const _hoisted_1$g = { fill: "none" };
630
- const _hoisted_2$e = /* @__PURE__ */ createElementVNode("pattern", {
628
+ var HatchedPattern = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$3], ["__scopeId", "data-v-250960ac"]]);
629
+ const _sfc_main$j = {};
630
+ const _hoisted_1$i = { fill: "none" };
631
+ const _hoisted_2$g = /* @__PURE__ */ createElementVNode("pattern", {
631
632
  id: "checkerboard",
632
633
  width: "64",
633
634
  height: "64",
@@ -648,33 +649,33 @@ const _hoisted_2$e = /* @__PURE__ */ createElementVNode("pattern", {
648
649
  fill: "currentColor"
649
650
  })
650
651
  ], -1);
651
- const _hoisted_3$6 = /* @__PURE__ */ createElementVNode("rect", {
652
+ const _hoisted_3$9 = /* @__PURE__ */ createElementVNode("rect", {
652
653
  x: "0",
653
654
  y: "0",
654
655
  width: "100%",
655
656
  height: "100%",
656
657
  fill: "url(#checkerboard)"
657
658
  }, null, -1);
658
- const _hoisted_4$4 = [
659
- _hoisted_2$e,
660
- _hoisted_3$6
659
+ const _hoisted_4$6 = [
660
+ _hoisted_2$g,
661
+ _hoisted_3$9
661
662
  ];
662
663
  function _sfc_render$2(_ctx, _cache) {
663
- return openBlock(), createElementBlock("svg", _hoisted_1$g, _hoisted_4$4);
664
+ return openBlock(), createElementBlock("svg", _hoisted_1$i, _hoisted_4$6);
664
665
  }
665
- var CheckerboardPattern = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$2]]);
666
+ var CheckerboardPattern = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$2]]);
666
667
  var StoryResponsivePreview_vue_vue_type_style_index_0_scoped_true_lang = "";
667
668
  const _withScopeId$3 = (n) => (pushScopeId("data-v-769a585e"), n = n(), popScopeId(), n);
668
- const _hoisted_1$f = { class: "htw-w-full htw-h-full htw-flex-1 htw-border htw-border-gray-100 dark:htw-border-gray-800 htw-rounded-lg htw-relative htw-overflow-hidden" };
669
- const _hoisted_2$d = {
669
+ const _hoisted_1$h = { class: "htw-w-full htw-h-full htw-flex-1 htw-border htw-border-gray-100 dark:htw-border-gray-800 htw-rounded-lg htw-relative htw-overflow-hidden" };
670
+ const _hoisted_2$f = {
670
671
  key: 0,
671
672
  class: "htw-absolute htw-inset-0 htw-w-full htw-h-full htw-bg-gray-200 dark:htw-bg-gray-850 htw-rounded-r-lg htw-border-l-2 htw-border-gray-500/10 dark:htw-border-gray-700/30 htw-overflow-hidden"
672
673
  };
673
- const _hoisted_3$5 = { class: "htw-p-4 htw-h-full htw-relative" };
674
- const _hoisted_4$3 = { class: "htw-w-full htw-h-full htw-border htw-border-gray-100 dark:htw-border-gray-800 htw-rounded-sm htw-relative" };
675
- const _hoisted_5$3 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ createElementVNode("div", { class: "bind-preview-bg htw-absolute htw-inset-0" }, null, -1));
676
- const _hoisted_6$3 = /* @__PURE__ */ createStaticVNode('<div class="htw-absolute htw-top-1 htw-left-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-top-1 htw-right-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-bottom-1 htw-left-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-bottom-1 htw-right-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-left-1 htw-top-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-left-1 htw-bottom-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-right-1 htw-top-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-right-1 htw-bottom-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div>', 8);
677
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
674
+ const _hoisted_3$8 = { class: "htw-p-4 htw-h-full htw-relative" };
675
+ const _hoisted_4$5 = { class: "htw-w-full htw-h-full htw-border htw-border-gray-100 dark:htw-border-gray-800 htw-rounded-sm htw-relative" };
676
+ const _hoisted_5$4 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ createElementVNode("div", { class: "bind-preview-bg htw-absolute htw-inset-0" }, null, -1));
677
+ const _hoisted_6$4 = /* @__PURE__ */ createStaticVNode('<div class="htw-absolute htw-top-1 htw-left-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-top-1 htw-right-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-bottom-1 htw-left-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-bottom-1 htw-right-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-left-1 htw-top-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-left-1 htw-bottom-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-right-1 htw-top-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-right-1 htw-bottom-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div>', 8);
678
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
678
679
  props: {
679
680
  variant: null
680
681
  },
@@ -769,8 +770,8 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
769
770
  const finalHeight = computed(() => settings.rotate ? settings.responsiveWidth : settings.responsiveHeight);
770
771
  const isResponsiveEnabled = computed(() => !props.variant.responsiveDisabled);
771
772
  return (_ctx, _cache) => {
772
- return openBlock(), createElementBlock("div", _hoisted_1$f, [
773
- unref(isResponsiveEnabled) ? (openBlock(), createElementBlock("div", _hoisted_2$d, [
773
+ return openBlock(), createElementBlock("div", _hoisted_1$h, [
774
+ unref(isResponsiveEnabled) ? (openBlock(), createElementBlock("div", _hoisted_2$f, [
774
775
  createVNode(HatchedPattern, { class: "htw-w-full htw-h-full htw-text-black/[2%] dark:htw-text-white/[2%]" })
775
776
  ])) : createCommentVNode("", true),
776
777
  createElementVNode("div", {
@@ -784,9 +785,9 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
784
785
  "htw-h-fit": !!unref(finalHeight)
785
786
  } : void 0])
786
787
  }, [
787
- createElementVNode("div", _hoisted_3$5, [
788
- createElementVNode("div", _hoisted_4$3, [
789
- _hoisted_5$3,
788
+ createElementVNode("div", _hoisted_3$8, [
789
+ createElementVNode("div", _hoisted_4$5, [
790
+ _hoisted_5$4,
790
791
  unref(settings).checkerboard ? (openBlock(), createBlock(CheckerboardPattern, {
791
792
  key: 0,
792
793
  class: "htw-absolute htw-inset-0 htw-w-full htw-h-full htw-text-gray-500/20"
@@ -798,7 +799,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
798
799
  resizing: resizing.value
799
800
  }, void 0, true)
800
801
  ]),
801
- _hoisted_6$3
802
+ _hoisted_6$4
802
803
  ]),
803
804
  unref(isResponsiveEnabled) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
804
805
  createElementVNode("div", {
@@ -833,8 +834,8 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
833
834
  };
834
835
  }
835
836
  });
836
- var StoryResponsivePreview = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId", "data-v-769a585e"]]);
837
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
837
+ var StoryResponsivePreview = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-769a585e"]]);
838
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
838
839
  props: {
839
840
  story: null,
840
841
  variant: null
@@ -858,7 +859,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
858
859
  height: finalHeight ? `${finalHeight}px` : "100%"
859
860
  } : { width: "100%", height: "100%" })
860
861
  }, [
861
- (openBlock(), createBlock(_sfc_main$r, {
862
+ (openBlock(), createBlock(_sfc_main$t, {
862
863
  key: `${__props.story.id}-${__props.variant.id}`,
863
864
  variant: __props.variant,
864
865
  story: __props.story,
@@ -872,8 +873,8 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
872
873
  };
873
874
  }
874
875
  });
875
- const _hoisted_1$e = ["src"];
876
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
876
+ const _hoisted_1$g = ["src"];
877
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
877
878
  props: {
878
879
  story: null,
879
880
  variant: null
@@ -919,17 +920,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
919
920
  });
920
921
  function updateVariantState(state) {
921
922
  synced = true;
922
- if (props.variant.state) {
923
- for (const key in state) {
924
- if (typeof props.variant.state[key] === "object") {
925
- Object.assign(props.variant.state[key], state[key]);
926
- } else {
927
- props.variant.state[key] = state[key];
928
- }
929
- }
930
- } else {
931
- props.variant.state = state;
932
- }
923
+ applyStateToVariant(props.variant, state);
933
924
  }
934
925
  function logEvent(event) {
935
926
  const eventsStore = useEventsStore();
@@ -983,43 +974,43 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
983
974
  } : void 0),
984
975
  "data-test-id": "preview-iframe",
985
976
  onLoad: _cache[0] || (_cache[0] = ($event) => onIframeLoad())
986
- }, null, 46, _hoisted_1$e)
977
+ }, null, 46, _hoisted_1$g)
987
978
  ]),
988
979
  _: 1
989
980
  }, 8, ["variant"]);
990
981
  };
991
982
  }
992
983
  });
993
- const _hoisted_1$d = {
984
+ const _hoisted_1$f = {
994
985
  class: "htw-h-full htw-flex htw-flex-col",
995
986
  "data-test-id": "story-variant-single-view"
996
987
  };
997
- const _hoisted_2$c = {
988
+ const _hoisted_2$e = {
998
989
  key: 0,
999
990
  class: "htw-flex-none htw-flex htw-items-center htw-h-8 -htw-mt-1"
1000
991
  };
1001
- const _sfc_main$d = /* @__PURE__ */ defineComponent({
992
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
1002
993
  props: {
1003
994
  variant: null,
1004
995
  story: null
1005
996
  },
1006
997
  setup(__props) {
1007
998
  return (_ctx, _cache) => {
1008
- return openBlock(), createElementBlock("div", _hoisted_1$d, [
1009
- !unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2$c, [
1010
- createVNode(_sfc_main$n, { variant: __props.variant }, null, 8, ["variant"]),
1011
- !__props.variant.responsiveDisabled ? (openBlock(), createBlock(_sfc_main$l, { key: 0 })) : createCommentVNode("", true),
999
+ return openBlock(), createElementBlock("div", _hoisted_1$f, [
1000
+ !unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2$e, [
1001
+ createVNode(_sfc_main$p, { variant: __props.variant }, null, 8, ["variant"]),
1002
+ !__props.variant.responsiveDisabled ? (openBlock(), createBlock(_sfc_main$n, { key: 0 })) : createCommentVNode("", true),
1012
1003
  createVNode(StoryVariantBackground),
1013
- createVNode(_sfc_main$j, {
1004
+ createVNode(_sfc_main$l, {
1014
1005
  variant: __props.variant,
1015
1006
  story: __props.story
1016
1007
  }, null, 8, ["variant", "story"])
1017
1008
  ])) : createCommentVNode("", true),
1018
- __props.story.layout.iframe === false ? (openBlock(), createBlock(_sfc_main$f, {
1009
+ __props.story.layout.iframe === false ? (openBlock(), createBlock(_sfc_main$h, {
1019
1010
  key: 1,
1020
1011
  story: __props.story,
1021
1012
  variant: __props.variant
1022
- }, null, 8, ["story", "variant"])) : (openBlock(), createBlock(_sfc_main$e, {
1013
+ }, null, 8, ["story", "variant"])) : (openBlock(), createBlock(_sfc_main$g, {
1023
1014
  key: 2,
1024
1015
  story: __props.story,
1025
1016
  variant: __props.variant
@@ -1030,25 +1021,25 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
1030
1021
  });
1031
1022
  var StoryVariantSingle_vue_vue_type_style_index_0_scoped_true_lang = "";
1032
1023
  const _withScopeId$2 = (n) => (pushScopeId("data-v-a52efa6c"), n = n(), popScopeId(), n);
1033
- const _hoisted_1$c = {
1024
+ const _hoisted_1$e = {
1034
1025
  key: 0,
1035
1026
  class: "htw-p-2 htw-h-full"
1036
1027
  };
1037
- const _hoisted_2$b = {
1028
+ const _hoisted_2$d = {
1038
1029
  key: 0,
1039
1030
  class: "htw-divide-y htw-divide-gray-100 dark:htw-divide-gray-800 htw-h-full htw-flex htw-flex-col"
1040
1031
  };
1041
- const _hoisted_3$4 = /* @__PURE__ */ createTextVNode(" Select a variant... ");
1042
- const _hoisted_4$2 = {
1032
+ const _hoisted_3$7 = /* @__PURE__ */ createTextVNode(" Select a variant... ");
1033
+ const _hoisted_4$4 = {
1043
1034
  key: 0,
1044
1035
  class: "htw-p-2 htw-h-full"
1045
1036
  };
1046
- const _hoisted_5$2 = { class: "htw-h-full htw-overflow-y-auto" };
1047
- const _hoisted_6$2 = {
1037
+ const _hoisted_5$3 = { class: "htw-h-full htw-overflow-y-auto" };
1038
+ const _hoisted_6$3 = {
1048
1039
  key: 0,
1049
1040
  class: "htw-p-2 htw-h-full"
1050
1041
  };
1051
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
1042
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
1052
1043
  setup(__props) {
1053
1044
  useCssVars((_ctx) => {
1054
1045
  var _a;
@@ -1068,14 +1059,14 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
1068
1059
  }
1069
1060
  return (_ctx, _cache) => {
1070
1061
  var _a;
1071
- return unref(hasSingleVariant) && unref(storyStore).currentVariant ? (openBlock(), createElementBlock("div", _hoisted_1$c, [
1072
- unref(storyStore).currentVariant.configReady ? (openBlock(), createBlock(_sfc_main$d, {
1062
+ return unref(hasSingleVariant) && unref(storyStore).currentVariant ? (openBlock(), createElementBlock("div", _hoisted_1$e, [
1063
+ unref(storyStore).currentVariant.configReady ? (openBlock(), createBlock(_sfc_main$f, {
1073
1064
  key: 0,
1074
1065
  variant: unref(storyStore).currentVariant,
1075
1066
  story: unref(storyStore).currentStory
1076
1067
  }, null, 8, ["variant", "story"])) : createCommentVNode("", true)
1077
1068
  ])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1078
- unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2$b, [
1069
+ unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2$d, [
1079
1070
  createElementVNode("a", {
1080
1071
  class: "htw-px-6 htw-h-12 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer htw-flex htw-gap-2 htw-flex-wrap htw-w-full htw-items-center",
1081
1072
  onClick: openMenu
@@ -1090,15 +1081,15 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
1090
1081
  }, null, 8, ["icon", "class"]),
1091
1082
  createTextVNode(" " + toDisplayString(unref(variant).title), 1)
1092
1083
  ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1093
- _hoisted_3$4
1084
+ _hoisted_3$7
1094
1085
  ], 64)),
1095
1086
  createVNode(unref(Icon), {
1096
1087
  icon: "carbon:chevron-sort",
1097
1088
  class: "htw-w-5 htw-h-5 htw-shrink-0 htw-ml-auto"
1098
1089
  })
1099
1090
  ]),
1100
- unref(storyStore).currentVariant ? (openBlock(), createElementBlock("div", _hoisted_4$2, [
1101
- unref(storyStore).currentVariant.configReady ? (openBlock(), createBlock(_sfc_main$d, {
1091
+ unref(storyStore).currentVariant ? (openBlock(), createElementBlock("div", _hoisted_4$4, [
1092
+ unref(storyStore).currentVariant.configReady ? (openBlock(), createBlock(_sfc_main$f, {
1102
1093
  key: 0,
1103
1094
  variant: unref(storyStore).currentVariant,
1104
1095
  story: unref(storyStore).currentStory
@@ -1112,7 +1103,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
1112
1103
  "default-split": 17
1113
1104
  }, {
1114
1105
  first: withCtx(() => [
1115
- createElementVNode("div", _hoisted_5$2, [
1106
+ createElementVNode("div", _hoisted_5$3, [
1116
1107
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(storyStore).currentStory.variants, (variant2, index) => {
1117
1108
  return openBlock(), createBlock(StoryVariantListItem, {
1118
1109
  key: index,
@@ -1122,8 +1113,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
1122
1113
  ])
1123
1114
  ]),
1124
1115
  last: withCtx(() => [
1125
- unref(storyStore).currentVariant ? (openBlock(), createElementBlock("div", _hoisted_6$2, [
1126
- createVNode(_sfc_main$d, {
1116
+ unref(storyStore).currentVariant ? (openBlock(), createElementBlock("div", _hoisted_6$3, [
1117
+ createVNode(_sfc_main$f, {
1127
1118
  variant: unref(storyStore).currentVariant,
1128
1119
  story: unref(storyStore).currentStory
1129
1120
  }, null, 8, ["variant", "story"])
@@ -1135,11 +1126,11 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
1135
1126
  };
1136
1127
  }
1137
1128
  });
1138
- var StoryVariantSingle = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-a52efa6c"]]);
1129
+ var StoryVariantSingle = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-a52efa6c"]]);
1139
1130
  var StoryViewer_vue_vue_type_style_index_0_scoped_true_lang = "";
1140
1131
  const _withScopeId$1 = (n) => (pushScopeId("data-v-141c6b20"), n = n(), popScopeId(), n);
1141
- const _hoisted_1$b = { class: "htw-bg-gray-50 htw-h-full dark:htw-bg-gray-750" };
1142
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
1132
+ const _hoisted_1$d = { class: "htw-bg-gray-50 htw-h-full dark:htw-bg-gray-750" };
1133
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
1143
1134
  setup(__props) {
1144
1135
  useCssVars((_ctx) => {
1145
1136
  var _a;
@@ -1158,10 +1149,10 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
1158
1149
  });
1159
1150
  return (_ctx, _cache) => {
1160
1151
  return openBlock(), createElementBlock(Fragment, null, [
1161
- createElementVNode("div", _hoisted_1$b, [
1162
- unref(storyStore).currentStory.layout.type === "grid" ? (openBlock(), createBlock(_sfc_main$o, { key: 0 })) : unref(storyStore).currentStory.layout.type === "single" ? (openBlock(), createBlock(StoryVariantSingle, { key: 1 })) : createCommentVNode("", true)
1152
+ createElementVNode("div", _hoisted_1$d, [
1153
+ unref(storyStore).currentStory.layout.type === "grid" ? (openBlock(), createBlock(_sfc_main$q, { key: 0 })) : unref(storyStore).currentStory.layout.type === "single" ? (openBlock(), createBlock(StoryVariantSingle, { key: 1 })) : createCommentVNode("", true)
1163
1154
  ]),
1164
- createVNode(_sfc_main$s, {
1155
+ createVNode(_sfc_main$u, {
1165
1156
  title: "Select a variant",
1166
1157
  opened: isMenuOpened.value,
1167
1158
  onClose: closeMenu
@@ -1180,9 +1171,252 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
1180
1171
  };
1181
1172
  }
1182
1173
  });
1183
- var StoryViewer = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-141c6b20"]]);
1184
- const _hoisted_1$a = { "data-test-id": "story-controls" };
1185
- const _hoisted_2$a = /* @__PURE__ */ createElementVNode("span", null, "No controls available for this story", -1);
1174
+ var StoryViewer = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-141c6b20"]]);
1175
+ const _hoisted_1$c = { class: "htw-cursor-pointer htw-w-full htw-outline-none htw-px-2 htw-h-[27px] -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 hover:htw-border-primary-500 dark:hover:htw-border-primary-500 htw-rounded-sm htw-flex htw-gap-2 htw-items-center htw-leading-normal" };
1176
+ const _hoisted_2$c = { class: "htw-flex-1 htw-truncate" };
1177
+ const _hoisted_3$6 = { class: "htw-flex htw-flex-col htw-bg-gray-50 dark:htw-bg-gray-700" };
1178
+ const _hoisted_4$3 = ["onClick"];
1179
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
1180
+ props: {
1181
+ modelValue: null,
1182
+ options: null
1183
+ },
1184
+ emits: ["update:modelValue", "select"],
1185
+ setup(__props, { emit: emits }) {
1186
+ const props = __props;
1187
+ const formattedOptions = computed(() => {
1188
+ if (Array.isArray(props.options)) {
1189
+ return Object.fromEntries(props.options.map((value) => [value, value]));
1190
+ }
1191
+ return props.options;
1192
+ });
1193
+ const selectedLabel = computed(() => formattedOptions.value[props.modelValue]);
1194
+ function selectValue(value, hide) {
1195
+ emits("update:modelValue", value);
1196
+ emits("select", value);
1197
+ hide();
1198
+ }
1199
+ return (_ctx, _cache) => {
1200
+ return openBlock(), createBlock(unref(Dropdown), { "auto-size": "" }, {
1201
+ popper: withCtx(({ hide }) => [
1202
+ createElementVNode("div", _hoisted_3$6, [
1203
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(formattedOptions), (label, value) => {
1204
+ return openBlock(), createElementBlock("div", mergeProps(__spreadProps(__spreadValues({}, _ctx.$attrs), { class: null, style: null }), {
1205
+ key: label,
1206
+ class: ["htw-px-2 htw-py-1 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700", {
1207
+ "htw-bg-primary-200 dark:htw-bg-primary-800": props.modelValue === value
1208
+ }],
1209
+ onClick: ($event) => selectValue(value, hide)
1210
+ }), [
1211
+ renderSlot(_ctx.$slots, "option", {
1212
+ label,
1213
+ value
1214
+ }, () => [
1215
+ createTextVNode(toDisplayString(label), 1)
1216
+ ])
1217
+ ], 16, _hoisted_4$3);
1218
+ }), 128))
1219
+ ])
1220
+ ]),
1221
+ default: withCtx(() => [
1222
+ createElementVNode("div", _hoisted_1$c, [
1223
+ createElementVNode("div", _hoisted_2$c, [
1224
+ renderSlot(_ctx.$slots, "default", { label: unref(selectedLabel) }, () => [
1225
+ createTextVNode(toDisplayString(unref(selectedLabel)), 1)
1226
+ ])
1227
+ ]),
1228
+ createVNode(unref(Icon), {
1229
+ icon: "carbon:chevron-sort",
1230
+ class: "htw-w-4 htw-h-4 htw-flex-none htw-ml-auto"
1231
+ })
1232
+ ])
1233
+ ]),
1234
+ _: 3
1235
+ });
1236
+ };
1237
+ }
1238
+ });
1239
+ const _hoisted_1$b = { class: "htw-flex htw-gap-2 htw-w-full htw-items-center" };
1240
+ const _hoisted_2$b = ["onUpdate:modelValue"];
1241
+ const _hoisted_3$5 = {
1242
+ key: 1,
1243
+ class: "htw-flex htw-items-center htw-gap-2"
1244
+ };
1245
+ const _hoisted_4$2 = { class: "htw-flex-1 htw-truncate" };
1246
+ const _hoisted_5$2 = { class: "htw-flex htw-gap-2 htw-items-center" };
1247
+ const _hoisted_6$2 = { class: "htw-flex-1 htw-truncate" };
1248
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
1249
+ props: {
1250
+ story: null,
1251
+ variant: null
1252
+ },
1253
+ setup(__props) {
1254
+ const props = __props;
1255
+ const DEFAULT_ID = "default";
1256
+ const saveId = computed(() => `${props.story.id}:${props.variant.id}`);
1257
+ const defaultState = clone(toRawDeep(props.variant.state));
1258
+ const selectedOption = useStorage(`_histoire-presets/${saveId.value}/selected`, DEFAULT_ID);
1259
+ const presetStates = useStorage(`_histoire-presets/${saveId.value}/states`, /* @__PURE__ */ new Map());
1260
+ const presetsOptions = computed(() => {
1261
+ const options = { [DEFAULT_ID]: "Initial state" };
1262
+ presetStates.value.forEach((value, key) => {
1263
+ options[key] = value.label;
1264
+ });
1265
+ return options;
1266
+ });
1267
+ function resetState() {
1268
+ selectedOption.value = DEFAULT_ID;
1269
+ applyStateToVariant(props.variant, defaultState);
1270
+ }
1271
+ function applyPreset(id) {
1272
+ if (id === DEFAULT_ID) {
1273
+ resetState();
1274
+ } else if (presetStates.value.has(id)) {
1275
+ applyStateToVariant(props.variant, presetStates.value.get(id).state);
1276
+ }
1277
+ }
1278
+ onMounted(() => {
1279
+ if (selectedOption.value !== DEFAULT_ID) {
1280
+ applyPreset(selectedOption.value);
1281
+ }
1282
+ });
1283
+ const input = ref();
1284
+ const select = ref();
1285
+ const canEdit = computed(() => selectedOption.value !== DEFAULT_ID);
1286
+ const isEditing = ref(false);
1287
+ async function createPreset() {
1288
+ const id = new Date().getTime().toString();
1289
+ presetStates.value.set(id, { state: clone(toRawDeep(props.variant.state)), label: "New preset" });
1290
+ selectedOption.value = id;
1291
+ isEditing.value = true;
1292
+ await nextTick();
1293
+ input.value.select();
1294
+ }
1295
+ const savedNotif = ref(false);
1296
+ const savedTimeout = useTimeoutFn(() => {
1297
+ savedNotif.value = false;
1298
+ }, 1e3);
1299
+ async function savePreset() {
1300
+ if (!canEdit.value)
1301
+ return;
1302
+ const preset = presetStates.value.get(selectedOption.value);
1303
+ preset.state = clone(toRawDeep(props.variant.state));
1304
+ savedNotif.value = true;
1305
+ savedTimeout.start();
1306
+ }
1307
+ function deletePreset(id) {
1308
+ if (!confirm("Are you sure you want to delete this preset?")) {
1309
+ return;
1310
+ }
1311
+ if (selectedOption.value === id) {
1312
+ resetState();
1313
+ }
1314
+ presetStates.value.delete(id);
1315
+ }
1316
+ async function startEditing() {
1317
+ if (!canEdit.value) {
1318
+ return;
1319
+ }
1320
+ isEditing.value = true;
1321
+ await nextTick();
1322
+ input.value.select();
1323
+ }
1324
+ function stopEditing() {
1325
+ isEditing.value = false;
1326
+ }
1327
+ onClickOutside(select, stopEditing);
1328
+ return (_ctx, _cache) => {
1329
+ const _directive_tooltip = resolveDirective("tooltip");
1330
+ return openBlock(), createElementBlock("div", _hoisted_1$b, [
1331
+ createElementVNode("div", {
1332
+ ref_key: "select",
1333
+ ref: select,
1334
+ class: "htw-flex-1 htw-min-w-0"
1335
+ }, [
1336
+ createVNode(_sfc_main$c, {
1337
+ modelValue: unref(selectedOption),
1338
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(selectedOption) ? selectedOption.value = $event : null),
1339
+ options: unref(presetsOptions),
1340
+ onDblclick: _cache[3] || (_cache[3] = ($event) => startEditing()),
1341
+ onKeydown: [
1342
+ _cache[4] || (_cache[4] = withKeys(($event) => stopEditing(), ["enter"])),
1343
+ _cache[5] || (_cache[5] = withKeys(($event) => stopEditing(), ["escape"]))
1344
+ ],
1345
+ onSelect: _cache[6] || (_cache[6] = (id) => applyPreset(id))
1346
+ }, {
1347
+ default: withCtx(({ label }) => [
1348
+ isEditing.value ? withDirectives((openBlock(), createElementBlock("input", {
1349
+ key: 0,
1350
+ ref_key: "input",
1351
+ ref: input,
1352
+ "onUpdate:modelValue": ($event) => unref(presetStates).get(unref(selectedOption)).label = $event,
1353
+ type: "text",
1354
+ class: "htw-text-inherit htw-bg-transparent htw-w-full htw-h-full htw-outline-none",
1355
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {
1356
+ }, ["stop", "prevent"]))
1357
+ }, null, 8, _hoisted_2$b)), [
1358
+ [vModelText, unref(presetStates).get(unref(selectedOption)).label]
1359
+ ]) : (openBlock(), createElementBlock("div", _hoisted_3$5, [
1360
+ createElementVNode("span", _hoisted_4$2, toDisplayString(label), 1),
1361
+ unref(canEdit) ? withDirectives((openBlock(), createBlock(unref(Icon), {
1362
+ key: 0,
1363
+ icon: "carbon:edit",
1364
+ class: "htw-flex-none htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
1365
+ onClick: _cache[1] || (_cache[1] = withModifiers(($event) => startEditing(), ["stop"]))
1366
+ }, null, 512)), [
1367
+ [_directive_tooltip, "Rename this preset"]
1368
+ ]) : createCommentVNode("", true)
1369
+ ]))
1370
+ ]),
1371
+ option: withCtx(({ label, value }) => [
1372
+ createElementVNode("div", _hoisted_5$2, [
1373
+ createElementVNode("span", _hoisted_6$2, toDisplayString(label), 1),
1374
+ value !== DEFAULT_ID ? withDirectives((openBlock(), createBlock(unref(Icon), {
1375
+ key: 0,
1376
+ icon: "carbon:trash-can",
1377
+ class: "htw-flex-none htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
1378
+ onClick: withModifiers(($event) => deletePreset(value), ["stop"])
1379
+ }, null, 8, ["onClick"])), [
1380
+ [_directive_tooltip, "Delete this preset"]
1381
+ ]) : createCommentVNode("", true)
1382
+ ])
1383
+ ]),
1384
+ _: 1
1385
+ }, 8, ["modelValue", "options"])
1386
+ ], 512),
1387
+ withDirectives(createVNode(unref(Icon), {
1388
+ icon: savedNotif.value ? "carbon:checkmark" : "carbon:save",
1389
+ class: normalizeClass(["htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100", [
1390
+ unref(canEdit) ? "htw-opacity-50 hover:htw-opacity-100" : "htw-opacity-25 htw-pointer-events-none"
1391
+ ]]),
1392
+ onClick: _cache[7] || (_cache[7] = ($event) => savePreset())
1393
+ }, null, 8, ["icon", "class"]), [
1394
+ [_directive_tooltip, savedNotif.value ? "Saved!" : unref(canEdit) ? "Save to preset" : null]
1395
+ ]),
1396
+ withDirectives(createVNode(unref(Icon), {
1397
+ icon: "carbon:add-alt",
1398
+ class: "htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
1399
+ onClick: _cache[8] || (_cache[8] = ($event) => createPreset())
1400
+ }, null, 512), [
1401
+ [_directive_tooltip, "Create new preset"]
1402
+ ]),
1403
+ withDirectives(createVNode(unref(Icon), {
1404
+ icon: "carbon:reset",
1405
+ class: "htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
1406
+ onClick: _cache[9] || (_cache[9] = ($event) => resetState())
1407
+ }, null, 512), [
1408
+ [_directive_tooltip, "Reset to initial state"]
1409
+ ])
1410
+ ]);
1411
+ };
1412
+ }
1413
+ });
1414
+ const _hoisted_1$a = {
1415
+ "data-test-id": "story-controls",
1416
+ class: "htw-flex htw-flex-col"
1417
+ };
1418
+ const _hoisted_2$a = { class: "htw-h-9 htw-flex-none htw-border-b htw-border-solid htw-border-gray-100 dark:htw-border-gray-750 htw-px-2 htw-flex htw-items-center" };
1419
+ const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("span", null, "No controls available for this story", -1);
1186
1420
  const _sfc_main$a = /* @__PURE__ */ defineComponent({
1187
1421
  props: {
1188
1422
  variant: {
@@ -1197,7 +1431,13 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
1197
1431
  setup(__props) {
1198
1432
  return (_ctx, _cache) => {
1199
1433
  return openBlock(), createElementBlock("div", _hoisted_1$a, [
1200
- __props.variant.slots().controls || __props.story.slots().controls ? (openBlock(), createBlock(_sfc_main$r, {
1434
+ createElementVNode("div", _hoisted_2$a, [
1435
+ createVNode(_sfc_main$b, {
1436
+ story: __props.story,
1437
+ variant: __props.variant
1438
+ }, null, 8, ["story", "variant"])
1439
+ ]),
1440
+ __props.variant.slots().controls || __props.story.slots().controls ? (openBlock(), createBlock(_sfc_main$t, {
1201
1441
  key: 0,
1202
1442
  "slot-name": "controls",
1203
1443
  variant: __props.variant,
@@ -1208,7 +1448,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
1208
1448
  icon: "carbon:audio-console",
1209
1449
  class: "htw-w-8 htw-h-8 htw-opacity-50 htw-mb-6"
1210
1450
  }),
1211
- _hoisted_2$a
1451
+ _hoisted_3$4
1212
1452
  ]),
1213
1453
  _: 1
1214
1454
  }))