@histoire/app 0.13.2 → 0.14.1

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 (89) hide show
  1. package/dist/bundled/App.vue2.js +11 -2
  2. package/dist/bundled/components/base/BaseButton.vue.js +5 -0
  3. package/dist/bundled/components/base/BaseButton.vue2.js +39 -0
  4. package/dist/bundled/components/base/BaseIcon.vue.js +8 -0
  5. package/dist/bundled/components/base/BaseIcon.vue2.js +30 -0
  6. package/dist/bundled/components/base/BaseIcon.vue3.js +4 -0
  7. package/dist/bundled/components/base/BaseKeyboardShortcut.vue.js +5 -0
  8. package/dist/bundled/components/base/BaseKeyboardShortcut.vue2.js +20 -0
  9. package/dist/bundled/components/base/BaseListItem.vue.js +5 -0
  10. package/dist/bundled/components/base/BaseListItem.vue2.js +32 -0
  11. package/dist/bundled/components/command/CommandPrompts.vue.js +5 -0
  12. package/dist/bundled/components/command/CommandPrompts.vue2.js +95 -0
  13. package/dist/bundled/components/command/CommandPromptsModal.vue.js +5 -0
  14. package/dist/bundled/components/command/CommandPromptsModal.vue2.js +44 -0
  15. package/dist/bundled/components/command/PromptSelect.vue.js +5 -0
  16. package/dist/bundled/components/command/PromptSelect.vue2.js +142 -0
  17. package/dist/bundled/components/command/PromptText.vue.js +5 -0
  18. package/dist/bundled/components/command/PromptText.vue2.js +67 -0
  19. package/dist/bundled/components/panel/StoryDocs.vue2.js +25 -3
  20. package/dist/bundled/components/panel/StorySourceCode.vue.js +1 -1
  21. package/dist/bundled/components/panel/StorySourceCode.vue2.js +1 -1
  22. package/dist/bundled/components/panel/StorySourceCode.vue3.js +2 -2
  23. package/dist/bundled/components/search/SearchItem.vue.js +1 -1
  24. package/dist/bundled/components/search/SearchItem.vue2.js +42 -62
  25. package/dist/bundled/components/search/SearchItem.vue3.js +2 -2
  26. package/dist/bundled/components/search/SearchItemContent.vue.js +5 -0
  27. package/dist/bundled/components/search/SearchItemContent.vue2.js +72 -0
  28. package/dist/bundled/components/search/SearchModal.vue2.js +2 -2
  29. package/dist/bundled/components/search/SearchPane.vue2.js +46 -24
  30. package/dist/bundled/components/story/StoryVariantGrid.vue2.js +10 -2
  31. package/dist/bundled/components/story/StoryVariantGridItem.vue.js +1 -1
  32. package/dist/bundled/components/story/StoryVariantGridItem.vue2.js +8 -4
  33. package/dist/bundled/components/story/StoryVariantGridItem.vue3.js +2 -2
  34. package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue2.js +5 -1
  35. package/dist/bundled/components/story/StoryVariantSingleView.vue2.js +13 -6
  36. package/dist/bundled/components/story/StoryView.vue2.js +1 -0
  37. package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue.js +5 -0
  38. package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue2.js +31 -0
  39. package/dist/bundled/index.js +3 -1
  40. package/dist/bundled/plugin.js +50 -0
  41. package/dist/bundled/sandbox.js +6 -0
  42. package/dist/bundled/stores/command.js +26 -0
  43. package/dist/bundled/style.css +22 -18
  44. package/dist/bundled/util/commands.js +59 -0
  45. package/dist/bundled/util/dark.js +2 -1
  46. package/dist/bundled/util/keyboard.js +3 -0
  47. package/dist/bundled/util/open-in-editor.js +6 -0
  48. package/dist/bundled/util/select.js +28 -0
  49. package/dist/bundled/util/tooltip.js +1 -1
  50. package/dist/style.css +116 -63
  51. package/package.json +4 -4
  52. package/src/app/App.vue +10 -1
  53. package/src/app/components/base/BaseButton.vue +33 -0
  54. package/src/app/components/base/BaseIcon.vue +31 -0
  55. package/src/app/components/base/BaseKeyboardShortcut.vue +16 -0
  56. package/src/app/components/base/BaseListItem.vue +30 -0
  57. package/src/app/components/command/CommandPrompts.vue +97 -0
  58. package/src/app/components/command/CommandPromptsModal.vue +40 -0
  59. package/src/app/components/command/PromptSelect.vue +140 -0
  60. package/src/app/components/command/PromptText.vue +64 -0
  61. package/src/app/components/panel/StoryDocs.vue +25 -2
  62. package/src/app/components/panel/StorySourceCode.vue +0 -1
  63. package/src/app/components/search/SearchItem.vue +29 -52
  64. package/src/app/components/search/SearchItemContent.vue +67 -0
  65. package/src/app/components/search/SearchModal.vue +2 -2
  66. package/src/app/components/search/SearchPane.vue +50 -22
  67. package/src/app/components/search/search-docs-data.ts +0 -1
  68. package/src/app/components/search/search-title-data.ts +0 -1
  69. package/src/app/components/story/GenericMountStory.vue +0 -1
  70. package/src/app/components/story/GenericRenderStory.vue +0 -1
  71. package/src/app/components/story/StoryVariantGrid.vue +7 -0
  72. package/src/app/components/story/StoryVariantGridItem.vue +4 -0
  73. package/src/app/components/story/StoryVariantSinglePreviewNative.vue +4 -1
  74. package/src/app/components/story/StoryVariantSingleView.vue +7 -0
  75. package/src/app/components/story/StoryView.vue +1 -0
  76. package/src/app/components/toolbar/DevOnlyToolbarOpenInEditor.vue +23 -0
  77. package/src/app/index.ts +5 -1
  78. package/src/app/plugin.ts +58 -0
  79. package/src/app/sandbox.ts +10 -3
  80. package/src/app/stores/command.ts +25 -0
  81. package/src/app/types.ts +26 -4
  82. package/src/app/util/commands.ts +56 -0
  83. package/src/app/util/config.ts +0 -1
  84. package/src/app/util/dark.ts +2 -1
  85. package/src/app/util/keyboard.ts +3 -0
  86. package/src/app/util/open-in-editor.ts +3 -0
  87. package/src/app/util/select.ts +29 -0
  88. package/src/app/util/tooltip.ts +1 -1
  89. package/src/virtual.d.ts +6 -0
@@ -9,15 +9,18 @@ import { useTitle } from "@histoire/vendors/vue-use";
9
9
  import { histoireConfig } from "./util/config.js";
10
10
  import { onKeyboardShortcut } from "./util/keyboard.js";
11
11
  import { isMobile } from "./util/responsive.js";
12
+ import { useCommandStore } from "./stores/command.js";
12
13
  import Breadcrumb from "./components/app/Breadcrumb.vue.js";
13
14
  import "./components/search/SearchModal.vue.js";
15
+ import "./components/command/CommandPromptsModal.vue.js";
14
16
  import "./components/app/InitialLoading.vue.js";
15
17
  import "./components/story/GenericMountStory.vue.js";
16
18
  import _sfc_main$1 from "./components/story/GenericMountStory.vue2.js";
17
19
  import _sfc_main$2 from "./components/app/AppHeader.vue2.js";
18
20
  import _sfc_main$3 from "./components/tree/StoryList.vue2.js";
19
21
  import _sfc_main$4 from "./components/search/SearchModal.vue2.js";
20
- import _sfc_main$5 from "./components/app/InitialLoading.vue2.js";
22
+ import _sfc_main$5 from "./components/command/CommandPromptsModal.vue2.js";
23
+ import _sfc_main$6 from "./components/app/InitialLoading.vue2.js";
21
24
  "use strict";
22
25
  const _hoisted_1 = {
23
26
  key: 0,
@@ -86,6 +89,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
86
89
  onMounted(() => {
87
90
  mounted.value = true;
88
91
  });
92
+ const commandStore = useCommandStore();
89
93
  return (_ctx, _cache) => {
90
94
  const _component_RouterView = resolveComponent("RouterView");
91
95
  return openBlock(), createElementBlock(Fragment, null, [
@@ -141,11 +145,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
141
145
  key: 2,
142
146
  shown: isSearchOpen.value,
143
147
  onClose: _cache[2] || (_cache[2] = ($event) => isSearchOpen.value = false)
148
+ }, null, 8, ["shown"])) : createCommentVNode("", true),
149
+ _ctx.__HISTOIRE_DEV__ ? (openBlock(), createBlock(_sfc_main$5, {
150
+ key: 3,
151
+ shown: unref(commandStore).showPromptsModal,
152
+ onClose: _cache[3] || (_cache[3] = ($event) => unref(commandStore).showPromptsModal = false)
144
153
  }, null, 8, ["shown"])) : createCommentVNode("", true)
145
154
  ], 4),
146
155
  createVNode(Transition, { name: "__histoire-fade" }, {
147
156
  default: withCtx(() => [
148
- loading.value ? (openBlock(), createBlock(_sfc_main$5, { key: 0 })) : createCommentVNode("", true)
157
+ loading.value ? (openBlock(), createBlock(_sfc_main$6, { key: 0 })) : createCommentVNode("", true)
149
158
  ]),
150
159
  _: 1
151
160
  })
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./BaseButton.vue2.js";
2
+ "use strict";
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,39 @@
1
+ import { defineComponent, computed, openBlock, createBlock, resolveDynamicComponent, unref, normalizeClass, withCtx, renderSlot } from "@histoire/vendors/vue";
2
+ import { RouterLink } from "@histoire/vendors/vue-router";
3
+ "use strict";
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ __name: "BaseButton",
6
+ props: {
7
+ to: null,
8
+ href: null,
9
+ color: null
10
+ },
11
+ setup(__props) {
12
+ const props = __props;
13
+ const comp = computed(() => {
14
+ if (props.to) {
15
+ return RouterLink;
16
+ }
17
+ if (props.href) {
18
+ return "a";
19
+ }
20
+ return "button";
21
+ });
22
+ return (_ctx, _cache) => {
23
+ return openBlock(), createBlock(resolveDynamicComponent(unref(comp)), {
24
+ class: normalizeClass(["histoire-base-button htw-rounded htw-cursor-pointer", {
25
+ "htw-bg-primary-200 dark:htw-bg-primary-800 hover:htw-bg-primary-300 dark:hover:htw-bg-primary-700": __props.color === "primary" || !__props.color,
26
+ "htw-bg-grey-100 dark:htw-bg-grey-900 hover:htw-bg-grey-200 dark:hover:htw-bg-grey-800": __props.color === "grey"
27
+ }])
28
+ }, {
29
+ default: withCtx(() => [
30
+ renderSlot(_ctx.$slots, "default")
31
+ ]),
32
+ _: 3
33
+ }, 8, ["class"]);
34
+ };
35
+ }
36
+ });
37
+ export {
38
+ _sfc_main as default
39
+ };
@@ -0,0 +1,8 @@
1
+ import _sfc_main from "./BaseIcon.vue2.js";
2
+ import "./BaseIcon.vue3.js";
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
+ "use strict";
5
+ const BaseIcon = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-74182813"]]);
6
+ export {
7
+ BaseIcon as default
8
+ };
@@ -0,0 +1,30 @@
1
+ import { defineComponent, computed, unref, openBlock, createElementBlock, createBlock, pushScopeId, popScopeId } from "@histoire/vendors/vue";
2
+ import { Icon } from "@histoire/vendors/iconify";
3
+ "use strict";
4
+ const _withScopeId = (n) => (pushScopeId("data-v-74182813"), n = n(), popScopeId(), n);
5
+ const _hoisted_1 = ["src", "alt"];
6
+ const _sfc_main = /* @__PURE__ */ defineComponent({
7
+ __name: "BaseIcon",
8
+ props: {
9
+ icon: null
10
+ },
11
+ setup(__props) {
12
+ const props = __props;
13
+ const isUrl = computed(() => props.icon.startsWith("http") || props.icon.startsWith("data:image") || props.icon.startsWith(".") || props.icon.startsWith("/"));
14
+ return (_ctx, _cache) => {
15
+ return unref(isUrl) ? (openBlock(), createElementBlock("img", {
16
+ key: 0,
17
+ src: __props.icon,
18
+ alt: __props.icon,
19
+ class: "histoire-base-icon"
20
+ }, null, 8, _hoisted_1)) : (openBlock(), createBlock(unref(Icon), {
21
+ key: 1,
22
+ icon: __props.icon,
23
+ class: "histoire-base-icon"
24
+ }, null, 8, ["icon"]));
25
+ };
26
+ }
27
+ });
28
+ export {
29
+ _sfc_main as default
30
+ };
@@ -0,0 +1,4 @@
1
+ const BaseIcon_vue_vue_type_style_index_0_scoped_74182813_lang = "";
2
+ export {
3
+ BaseIcon_vue_vue_type_style_index_0_scoped_74182813_lang as default
4
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./BaseKeyboardShortcut.vue2.js";
2
+ "use strict";
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,20 @@
1
+ import { defineComponent, computed, openBlock, createElementBlock, toDisplayString, unref } from "@histoire/vendors/vue";
2
+ import { formatKey } from "../../util/keyboard.js";
3
+ "use strict";
4
+ const _hoisted_1 = { class: "histoire-base-keyboard-shortcut htw-border htw-border-current htw-opacity-50 htw-px-1 htw-rounded-sm" };
5
+ const _sfc_main = /* @__PURE__ */ defineComponent({
6
+ __name: "BaseKeyboardShortcut",
7
+ props: {
8
+ shortcut: null
9
+ },
10
+ setup(__props) {
11
+ const props = __props;
12
+ const formatted = computed(() => props.shortcut.split("+").map((k) => formatKey(k.trim())).join(" "));
13
+ return (_ctx, _cache) => {
14
+ return openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(unref(formatted)), 1);
15
+ };
16
+ }
17
+ });
18
+ export {
19
+ _sfc_main as default
20
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./BaseListItem.vue2.js";
2
+ "use strict";
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,32 @@
1
+ import { defineComponent, openBlock, createElementBlock, normalizeClass, withKeys, renderSlot } from "@histoire/vendors/vue";
2
+ "use strict";
3
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4
+ __name: "BaseListItem",
5
+ props: {
6
+ isActive: { type: Boolean }
7
+ },
8
+ emits: ["navigate"],
9
+ setup(__props, { emit }) {
10
+ function handleNavigate() {
11
+ emit("navigate");
12
+ }
13
+ return (_ctx, _cache) => {
14
+ return openBlock(), createElementBlock("a", {
15
+ class: normalizeClass(["istoire-base-list-ite htw-flex htw-items-center htw-gap-2 htw-text-gray-900 dark:htw-text-gray-100", [
16
+ _ctx.$attrs.class,
17
+ __props.isActive ? "active htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black" : "hover:htw-bg-primary-100 dark:hover:htw-bg-primary-900"
18
+ ]]),
19
+ onClick: _cache[0] || (_cache[0] = ($event) => handleNavigate()),
20
+ onKeyup: [
21
+ _cache[1] || (_cache[1] = withKeys(($event) => handleNavigate(), ["enter"])),
22
+ _cache[2] || (_cache[2] = withKeys(($event) => handleNavigate(), ["space"]))
23
+ ]
24
+ }, [
25
+ renderSlot(_ctx.$slots, "default")
26
+ ], 34);
27
+ };
28
+ }
29
+ });
30
+ export {
31
+ _sfc_main as default
32
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./CommandPrompts.vue2.js";
2
+ "use strict";
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,95 @@
1
+ import { defineComponent, reactive, ref, onMounted, openBlock, createElementBlock, withModifiers, withKeys, createElementVNode, toDisplayString, Fragment, renderList, createBlock, resolveDynamicComponent, createVNode, withCtx, nextTick } from "@histoire/vendors/vue";
2
+ import { getCommandContext, executeCommand } from "../../util/commands.js";
3
+ import "../base/BaseButton.vue.js";
4
+ import "../base/BaseKeyboardShortcut.vue.js";
5
+ import "./PromptText.vue.js";
6
+ import "./PromptSelect.vue.js";
7
+ import _sfc_main$1 from "../base/BaseButton.vue2.js";
8
+ import _sfc_main$2 from "../base/BaseKeyboardShortcut.vue2.js";
9
+ import _sfc_main$3 from "./PromptText.vue2.js";
10
+ import _sfc_main$4 from "./PromptSelect.vue2.js";
11
+ "use strict";
12
+ const _hoisted_1 = { class: "htw-p-4 htw-opacity-70" };
13
+ const _hoisted_2 = { class: "htw-flex htw-justify-end htw-gap-2 htw-p-2" };
14
+ const _hoisted_3 = /* @__PURE__ */ createElementVNode("span", null, "Submit", -1);
15
+ const _sfc_main = /* @__PURE__ */ defineComponent({
16
+ __name: "CommandPrompts",
17
+ props: {
18
+ command: null
19
+ },
20
+ emits: ["close"],
21
+ setup(__props, { emit }) {
22
+ const props = __props;
23
+ const promptTypes = {
24
+ text: _sfc_main$3,
25
+ select: _sfc_main$4
26
+ };
27
+ const answers = reactive({});
28
+ for (const prompt of props.command.prompts) {
29
+ let defaultValue;
30
+ if (typeof prompt.defaultValue === "function") {
31
+ defaultValue = prompt.defaultValue(answers);
32
+ } else {
33
+ defaultValue = prompt.defaultValue;
34
+ }
35
+ answers[prompt.field] = defaultValue;
36
+ }
37
+ function submit() {
38
+ const params = props.command.getParams ? props.command.getParams({
39
+ ...getCommandContext(),
40
+ answers
41
+ }) : answers;
42
+ executeCommand(props.command, params);
43
+ emit("close");
44
+ }
45
+ const promptComps = ref([]);
46
+ function focusPrompt(index) {
47
+ nextTick(() => {
48
+ var _a, _b;
49
+ (_b = (_a = promptComps.value[index]) == null ? void 0 : _a.focus) == null ? void 0 : _b.call(_a);
50
+ });
51
+ }
52
+ onMounted(() => {
53
+ focusPrompt(0);
54
+ });
55
+ return (_ctx, _cache) => {
56
+ return openBlock(), createElementBlock("form", {
57
+ class: "histoire-command-prompts htw-flex htw-flex-col",
58
+ onSubmit: _cache[0] || (_cache[0] = withModifiers(($event) => submit(), ["prevent"])),
59
+ onKeyup: _cache[1] || (_cache[1] = withKeys(($event) => _ctx.$emit("close"), ["escape"]))
60
+ }, [
61
+ createElementVNode("div", _hoisted_1, toDisplayString(__props.command.label), 1),
62
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.command.prompts, (prompt, index) => {
63
+ return openBlock(), createBlock(resolveDynamicComponent(promptTypes[prompt.type]), {
64
+ key: prompt.field,
65
+ ref_for: true,
66
+ ref_key: "promptComps",
67
+ ref: promptComps,
68
+ modelValue: answers[prompt.field],
69
+ "onUpdate:modelValue": ($event) => answers[prompt.field] = $event,
70
+ prompt,
71
+ answers,
72
+ index,
73
+ class: "hover:htw-bg-gray-500/10 focus-within:htw-bg-gray-500/5",
74
+ onNext: ($event) => focusPrompt(index + 1)
75
+ }, null, 40, ["modelValue", "onUpdate:modelValue", "prompt", "answers", "index", "onNext"]);
76
+ }), 128)),
77
+ createElementVNode("div", _hoisted_2, [
78
+ createVNode(_sfc_main$1, {
79
+ type: "submit",
80
+ class: "htw-px-4 htw-py-2 htw-flex htw-items-start htw-gap-2"
81
+ }, {
82
+ default: withCtx(() => [
83
+ createVNode(_sfc_main$2, { shortcut: "Enter" }),
84
+ _hoisted_3
85
+ ]),
86
+ _: 1
87
+ })
88
+ ])
89
+ ], 32);
90
+ };
91
+ }
92
+ });
93
+ export {
94
+ _sfc_main as default
95
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./CommandPromptsModal.vue2.js";
2
+ "use strict";
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,44 @@
1
+ import { defineComponent, defineAsyncComponent, openBlock, createElementBlock, createElementVNode, createVNode, unref, createCommentVNode } from "@histoire/vendors/vue";
2
+ import { useCommandStore } from "../../stores/command.js";
3
+ "use strict";
4
+ const _hoisted_1 = {
5
+ key: 0,
6
+ class: "histoire-command-prompts-modal htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-900/80 htw-z-20"
7
+ };
8
+ const _hoisted_2 = { class: "htw-bg-white dark:htw-bg-gray-900 md:htw-mt-16 md:htw-mx-auto htw-w-screen htw-max-w-[512px] htw-max-h-[80vh] htw-overflow-y-auto htw-scroll-smooth htw-shadow-xl htw-border htw-border-gray-200 dark:htw-border-gray-750 htw-rounded-lg htw-relative htw-divide-y htw-divide-gray-200 dark:htw-divide-gray-850" };
9
+ const _sfc_main = /* @__PURE__ */ defineComponent({
10
+ __name: "CommandPromptsModal",
11
+ props: {
12
+ shown: {
13
+ type: Boolean,
14
+ default: false
15
+ }
16
+ },
17
+ emits: {
18
+ close: () => true
19
+ },
20
+ setup(__props, { emit }) {
21
+ const CommandPrompts = defineAsyncComponent(() => import("./CommandPrompts.vue.js"));
22
+ function close() {
23
+ emit("close");
24
+ }
25
+ const commandStore = useCommandStore();
26
+ return (_ctx, _cache) => {
27
+ return __props.shown ? (openBlock(), createElementBlock("div", _hoisted_1, [
28
+ createElementVNode("div", {
29
+ class: "htw-absolute htw-inset-0",
30
+ onClick: _cache[0] || (_cache[0] = ($event) => close())
31
+ }),
32
+ createElementVNode("div", _hoisted_2, [
33
+ createVNode(unref(CommandPrompts), {
34
+ command: unref(commandStore).selectedCommand,
35
+ onClose: _cache[1] || (_cache[1] = ($event) => close())
36
+ }, null, 8, ["command"])
37
+ ])
38
+ ])) : createCommentVNode("", true);
39
+ };
40
+ }
41
+ });
42
+ export {
43
+ _sfc_main as default
44
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./PromptSelect.vue2.js";
2
+ "use strict";
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,142 @@
1
+ import { defineComponent, computed, ref, watchEffect, openBlock, createElementBlock, withDirectives, createElementVNode, isRef, vModelText, unref, toDisplayString, createCommentVNode, createTextVNode, createVNode, withKeys, withModifiers, Fragment, renderList, normalizeClass, createBlock } from "@histoire/vendors/vue";
2
+ import { Icon } from "@histoire/vendors/iconify";
3
+ import { useSelection } from "../../util/select.js";
4
+ import "../base/BaseKeyboardShortcut.vue.js";
5
+ import _sfc_main$1 from "../base/BaseKeyboardShortcut.vue2.js";
6
+ "use strict";
7
+ const _hoisted_1 = { class: "histoire-prompt-select htw-relative htw-group" };
8
+ const _hoisted_2 = ["required"];
9
+ const _hoisted_3 = { class: "htw-flex htw-flex-col htw-gap-2 htw-p-2" };
10
+ const _hoisted_4 = { class: "htw-px-2 htw-flex" };
11
+ const _hoisted_5 = {
12
+ key: 0,
13
+ class: "htw-opacity-70"
14
+ };
15
+ const _hoisted_6 = { class: "htw-opacity-40 htw-text-sm htw-ml-auto htw-invisible group-focus-within:htw-visible" };
16
+ const _hoisted_7 = { class: "htw-overflow-auto max-h-[300px] htw-mb-2" };
17
+ const _hoisted_8 = ["onClick"];
18
+ const _hoisted_9 = { class: "htw-flex-1" };
19
+ const _sfc_main = /* @__PURE__ */ defineComponent({
20
+ __name: "PromptSelect",
21
+ props: {
22
+ modelValue: null,
23
+ prompt: null,
24
+ answers: null
25
+ },
26
+ emits: ["update:modelValue", "next"],
27
+ setup(__props, { expose, emit }) {
28
+ const props = __props;
29
+ const model = computed({
30
+ get: () => props.modelValue,
31
+ set: (value) => {
32
+ emit("update:modelValue", value);
33
+ emit("next");
34
+ }
35
+ });
36
+ const input = ref();
37
+ function focus() {
38
+ var _a, _b;
39
+ (_a = input.value) == null ? void 0 : _a.focus();
40
+ (_b = input.value) == null ? void 0 : _b.select();
41
+ }
42
+ expose({
43
+ focus
44
+ });
45
+ const search = ref("");
46
+ const options = ref([]);
47
+ let requestId = 0;
48
+ watchEffect(async () => {
49
+ if (typeof props.prompt.options === "function") {
50
+ const rId = ++requestId;
51
+ const result = await props.prompt.options(search.value, props.answers);
52
+ if (rId === requestId) {
53
+ options.value = result;
54
+ }
55
+ } else {
56
+ options.value = props.prompt.options;
57
+ }
58
+ });
59
+ const formattedOptions = computed(() => {
60
+ return options.value.map((option) => {
61
+ if (typeof option === "string") {
62
+ return {
63
+ value: option,
64
+ label: option
65
+ };
66
+ } else {
67
+ return option;
68
+ }
69
+ });
70
+ });
71
+ const {
72
+ selectedIndex,
73
+ selectNext,
74
+ selectPrevious
75
+ } = useSelection(formattedOptions);
76
+ function selectIndex(index) {
77
+ const result = formattedOptions.value[index].value;
78
+ if (result) {
79
+ model.value = result;
80
+ }
81
+ }
82
+ return (_ctx, _cache) => {
83
+ return openBlock(), createElementBlock("div", _hoisted_1, [
84
+ withDirectives(createElementVNode("input", {
85
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
86
+ required: __props.prompt.required,
87
+ tabindex: "-1",
88
+ class: "htw-absolute htw-inset-0 htw-opacity-0 htw-pointer-events-none"
89
+ }, null, 8, _hoisted_2), [
90
+ [vModelText, unref(model)]
91
+ ]),
92
+ createElementVNode("label", _hoisted_3, [
93
+ createElementVNode("span", _hoisted_4, [
94
+ createElementVNode("span", null, toDisplayString(__props.prompt.label), 1),
95
+ __props.prompt.required ? (openBlock(), createElementBlock("span", _hoisted_5, "*")) : createCommentVNode("", true),
96
+ createElementVNode("span", _hoisted_6, [
97
+ createTextVNode(" Press "),
98
+ createVNode(_sfc_main$1, { shortcut: "Space" }),
99
+ createTextVNode(" to select ")
100
+ ])
101
+ ]),
102
+ withDirectives(createElementVNode("input", {
103
+ ref_key: "input",
104
+ ref: input,
105
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => search.value = $event),
106
+ class: "htw-bg-transparent htw-w-full htw-p-2 htw-border htw-border-gray-500/50 focus:htw-border-primary-500/50 htw-rounded htw-outline-none",
107
+ onKeydown: [
108
+ _cache[2] || (_cache[2] = withKeys(withModifiers(($event) => unref(selectNext)(), ["prevent"]), ["down"])),
109
+ _cache[3] || (_cache[3] = withKeys(withModifiers(($event) => unref(selectPrevious)(), ["prevent"]), ["up"])),
110
+ _cache[4] || (_cache[4] = withKeys(withModifiers(($event) => selectIndex(unref(selectedIndex)), ["prevent"]), ["space"]))
111
+ ]
112
+ }, null, 544), [
113
+ [vModelText, search.value]
114
+ ])
115
+ ]),
116
+ createElementVNode("div", _hoisted_7, [
117
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(formattedOptions), (option, index) => {
118
+ return openBlock(), createElementBlock("button", {
119
+ key: option.value,
120
+ type: "button",
121
+ tabindex: "-1",
122
+ class: normalizeClass([[
123
+ unref(model) === option.value ? "htw-bg-primary-500/20" : index === unref(selectedIndex) ? "htw-bg-primary-500/10" : "htw-bg-transparent"
124
+ ], "htw-w-full htw-text-left htw-px-4 htw-py-2 hover:htw-bg-primary-500/10 htw-flex htw-items-center"]),
125
+ onClick: ($event) => model.value = option.value
126
+ }, [
127
+ createElementVNode("span", _hoisted_9, toDisplayString(option.label), 1),
128
+ unref(model) === option.value ? (openBlock(), createBlock(unref(Icon), {
129
+ key: 0,
130
+ icon: "carbon:checkmark",
131
+ class: "htw-w-4 htw-h-4 htw-text-primary-500"
132
+ })) : createCommentVNode("", true)
133
+ ], 10, _hoisted_8);
134
+ }), 128))
135
+ ])
136
+ ]);
137
+ };
138
+ }
139
+ });
140
+ export {
141
+ _sfc_main as default
142
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./PromptText.vue2.js";
2
+ "use strict";
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,67 @@
1
+ import { defineComponent, computed, ref, watch, openBlock, createElementBlock, createElementVNode, toDisplayString, createCommentVNode, withDirectives, isRef, vModelText, unref } from "@histoire/vendors/vue";
2
+ "use strict";
3
+ const _hoisted_1 = { class: "histoire-prompt-text" };
4
+ const _hoisted_2 = { class: "htw-flex htw-flex-col htw-gap-2 htw-p-2" };
5
+ const _hoisted_3 = { class: "htw-px-2" };
6
+ const _hoisted_4 = {
7
+ key: 0,
8
+ class: "htw-opacity-70"
9
+ };
10
+ const _hoisted_5 = ["required"];
11
+ const _sfc_main = /* @__PURE__ */ defineComponent({
12
+ __name: "PromptText",
13
+ props: {
14
+ modelValue: null,
15
+ prompt: null,
16
+ answers: null
17
+ },
18
+ emits: ["update:modelValue"],
19
+ setup(__props, { expose, emit }) {
20
+ const props = __props;
21
+ const model = computed({
22
+ get: () => props.modelValue,
23
+ set: (value) => emit("update:modelValue", value)
24
+ });
25
+ const input = ref();
26
+ function focus() {
27
+ var _a, _b;
28
+ (_a = input.value) == null ? void 0 : _a.focus();
29
+ (_b = input.value) == null ? void 0 : _b.select();
30
+ }
31
+ expose({
32
+ focus
33
+ });
34
+ const defaultValue = computed(() => {
35
+ if (typeof props.prompt.defaultValue === "function") {
36
+ return props.prompt.defaultValue(props.answers);
37
+ } else {
38
+ return props.prompt.defaultValue;
39
+ }
40
+ });
41
+ watch(defaultValue, (value) => {
42
+ model.value = value;
43
+ });
44
+ return (_ctx, _cache) => {
45
+ return openBlock(), createElementBlock("div", _hoisted_1, [
46
+ createElementVNode("label", _hoisted_2, [
47
+ createElementVNode("span", _hoisted_3, [
48
+ createElementVNode("span", null, toDisplayString(__props.prompt.label), 1),
49
+ __props.prompt.required ? (openBlock(), createElementBlock("span", _hoisted_4, "*")) : createCommentVNode("", true)
50
+ ]),
51
+ withDirectives(createElementVNode("input", {
52
+ ref_key: "input",
53
+ ref: input,
54
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
55
+ class: "htw-bg-transparent htw-w-full htw-p-2 htw-border htw-border-gray-500/50 focus:htw-border-primary-500/50 htw-rounded htw-outline-none",
56
+ required: __props.prompt.required
57
+ }, null, 8, _hoisted_5), [
58
+ [vModelText, unref(model)]
59
+ ])
60
+ ])
61
+ ]);
62
+ };
63
+ }
64
+ });
65
+ export {
66
+ _sfc_main as default
67
+ };
@@ -1,9 +1,11 @@
1
- import { defineComponent, toRefs, watch, ref, openBlock, createElementBlock, unref, createBlock, withCtx, createVNode, createTextVNode, watchEffect, nextTick } from "@histoire/vendors/vue";
1
+ import { defineComponent, toRefs, watch, ref, computed, openBlock, createElementBlock, unref, normalizeClass, createBlock, createCommentVNode, withCtx, createVNode, createTextVNode, watchEffect, nextTick } from "@histoire/vendors/vue";
2
2
  import { Icon } from "@histoire/vendors/iconify";
3
3
  import { useRouter, useRoute } from "@histoire/vendors/vue-router";
4
4
  import BaseEmpty from "../base/BaseEmpty.vue.js";
5
5
  import { markdownFiles } from "virtual:$histoire-markdown-files";
6
6
  import { histoireConfig } from "../../util/config.js";
7
+ import "../toolbar/DevOnlyToolbarOpenInEditor.vue.js";
8
+ import _sfc_main$1 from "../toolbar/DevOnlyToolbarOpenInEditor.vue2.js";
7
9
  "use strict";
8
10
  const _hoisted_1 = ["innerHTML"];
9
11
  function useStoryDoc(story) {
@@ -44,6 +46,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
44
46
  story: {
45
47
  type: Object,
46
48
  required: true
49
+ },
50
+ standalone: {
51
+ type: Boolean,
52
+ default: false
47
53
  }
48
54
  },
49
55
  emits: ["scroll-top"],
@@ -110,12 +116,28 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
110
116
  }, {
111
117
  immediate: true
112
118
  });
119
+ const filePath = computed(() => {
120
+ var _a, _b;
121
+ return ((_a = story.value.file) == null ? void 0 : _a.docsFilePath) ?? (props.standalone && ((_b = story.value.file) == null ? void 0 : _b.filePath));
122
+ });
113
123
  return (_ctx, _cache) => {
114
124
  return openBlock(), createElementBlock("div", {
115
125
  class: "histoire-story-docs",
116
126
  onClickCapture: onClick
117
127
  }, [
118
- !unref(renderedDoc) ? (openBlock(), createBlock(BaseEmpty, { key: 0 }, {
128
+ _ctx.__HISTOIRE_DEV__ && unref(renderedDoc) && unref(filePath) ? (openBlock(), createElementBlock("div", {
129
+ key: 0,
130
+ class: normalizeClass(["htw-flex htw-items-center htw-gap-2 htw-p-2", {
131
+ "htw-pt-4": !__props.standalone
132
+ }])
133
+ }, [
134
+ unref(filePath) ? (openBlock(), createBlock(_sfc_main$1, {
135
+ key: 0,
136
+ file: unref(filePath),
137
+ tooltip: "Edit docs in editor"
138
+ }, null, 8, ["file"])) : createCommentVNode("", true)
139
+ ], 2)) : createCommentVNode("", true),
140
+ !unref(renderedDoc) ? (openBlock(), createBlock(BaseEmpty, { key: 1 }, {
119
141
  default: withCtx(() => [
120
142
  createVNode(unref(Icon), {
121
143
  icon: "carbon:document-unknown",
@@ -125,7 +147,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
125
147
  ]),
126
148
  _: 1
127
149
  })) : (openBlock(), createElementBlock("div", {
128
- key: 1,
150
+ key: 2,
129
151
  ref_key: "renderedEl",
130
152
  ref: renderedEl,
131
153
  class: "htw-prose dark:htw-prose-invert htw-p-4 htw-max-w-none",
@@ -2,7 +2,7 @@ import _sfc_main from "./StorySourceCode.vue2.js";
2
2
  import "./StorySourceCode.vue3.js";
3
3
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
4
  "use strict";
5
- const StorySourceCode = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f528bb1b"]]);
5
+ const StorySourceCode = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1bdf9905"]]);
6
6
  export {
7
7
  StorySourceCode as default
8
8
  };