@histoire/app 0.13.1 → 0.14.0

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 (87) hide show
  1. package/dist/bundled/App.vue2.js +11 -2
  2. package/dist/bundled/api.js +8 -1
  3. package/dist/bundled/components/app/AppHeader.vue2.js +4 -3
  4. package/dist/bundled/components/base/BaseButton.vue.js +5 -0
  5. package/dist/bundled/components/base/BaseButton.vue2.js +39 -0
  6. package/dist/bundled/components/base/BaseIcon.vue.js +8 -0
  7. package/dist/bundled/components/base/BaseIcon.vue2.js +30 -0
  8. package/dist/bundled/components/base/BaseIcon.vue3.js +4 -0
  9. package/dist/bundled/components/base/BaseKeyboardShortcut.vue.js +5 -0
  10. package/dist/bundled/components/base/BaseKeyboardShortcut.vue2.js +20 -0
  11. package/dist/bundled/components/base/BaseListItem.vue.js +5 -0
  12. package/dist/bundled/components/base/BaseListItem.vue2.js +32 -0
  13. package/dist/bundled/components/command/CommandPrompts.vue.js +5 -0
  14. package/dist/bundled/components/command/CommandPrompts.vue2.js +95 -0
  15. package/dist/bundled/components/command/CommandPromptsModal.vue.js +5 -0
  16. package/dist/bundled/components/command/CommandPromptsModal.vue2.js +44 -0
  17. package/dist/bundled/components/command/PromptSelect.vue.js +5 -0
  18. package/dist/bundled/components/command/PromptSelect.vue2.js +142 -0
  19. package/dist/bundled/components/command/PromptText.vue.js +5 -0
  20. package/dist/bundled/components/command/PromptText.vue2.js +67 -0
  21. package/dist/bundled/components/panel/StoryDocs.vue2.js +25 -3
  22. package/dist/bundled/components/panel/StorySourceCode.vue.js +1 -1
  23. package/dist/bundled/components/panel/StorySourceCode.vue2.js +1 -1
  24. package/dist/bundled/components/panel/StorySourceCode.vue3.js +2 -2
  25. package/dist/bundled/components/search/SearchItem.vue.js +1 -1
  26. package/dist/bundled/components/search/SearchItem.vue2.js +42 -62
  27. package/dist/bundled/components/search/SearchItem.vue3.js +2 -2
  28. package/dist/bundled/components/search/SearchItemContent.vue.js +5 -0
  29. package/dist/bundled/components/search/SearchItemContent.vue2.js +72 -0
  30. package/dist/bundled/components/search/SearchModal.vue2.js +2 -2
  31. package/dist/bundled/components/search/SearchPane.vue2.js +46 -24
  32. package/dist/bundled/components/story/StoryVariantGrid.vue2.js +10 -2
  33. package/dist/bundled/components/story/StoryVariantSingleView.vue2.js +13 -6
  34. package/dist/bundled/components/story/StoryView.vue2.js +1 -0
  35. package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue.js +5 -0
  36. package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue2.js +31 -0
  37. package/dist/bundled/index.js +3 -1
  38. package/dist/bundled/plugin.js +50 -0
  39. package/dist/bundled/sandbox.js +4 -0
  40. package/dist/bundled/stores/command.js +26 -0
  41. package/dist/bundled/style.css +22 -18
  42. package/dist/bundled/util/commands.js +59 -0
  43. package/dist/bundled/util/dark.js +6 -1
  44. package/dist/bundled/util/keyboard.js +3 -0
  45. package/dist/bundled/util/open-in-editor.js +6 -0
  46. package/dist/bundled/util/select.js +28 -0
  47. package/dist/bundled/util/tooltip.js +1 -1
  48. package/dist/style.css +116 -63
  49. package/package.json +4 -4
  50. package/src/app/App.vue +10 -1
  51. package/src/app/api.ts +8 -0
  52. package/src/app/components/app/AppHeader.vue +1 -0
  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/StoryVariantSingleView.vue +7 -0
  73. package/src/app/components/story/StoryView.vue +1 -0
  74. package/src/app/components/toolbar/DevOnlyToolbarOpenInEditor.vue +23 -0
  75. package/src/app/index.ts +5 -1
  76. package/src/app/plugin.ts +58 -0
  77. package/src/app/sandbox.ts +6 -1
  78. package/src/app/stores/command.ts +25 -0
  79. package/src/app/types.ts +26 -4
  80. package/src/app/util/commands.ts +56 -0
  81. package/src/app/util/config.ts +0 -1
  82. package/src/app/util/dark.ts +6 -1
  83. package/src/app/util/keyboard.ts +3 -0
  84. package/src/app/util/open-in-editor.ts +3 -0
  85. package/src/app/util/select.ts +29 -0
  86. package/src/app/util/tooltip.ts +1 -1
  87. package/src/virtual.d.ts +6 -0
@@ -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
  };
@@ -7,7 +7,7 @@ import { clientSupportPlugins } from "virtual:$histoire-support-plugins-client";
7
7
  import { isDark } from "../../util/dark.js";
8
8
  import BaseEmpty from "../base/BaseEmpty.vue.js";
9
9
  "use strict";
10
- const _withScopeId = (n) => (pushScopeId("data-v-f528bb1b"), n = n(), popScopeId(), n);
10
+ const _withScopeId = (n) => (pushScopeId("data-v-1bdf9905"), n = n(), popScopeId(), n);
11
11
  const _hoisted_1 = { class: "histoire-story-source-code htw-bg-gray-50 dark:htw-bg-gray-750 htw-h-full htw-overflow-hidden htw-flex htw-flex-col" };
12
12
  const _hoisted_2 = {
13
13
  key: 0,
@@ -1,4 +1,4 @@
1
- const StorySourceCode_vue_vue_type_style_index_0_scoped_f528bb1b_lang = "";
1
+ const StorySourceCode_vue_vue_type_style_index_0_scoped_1bdf9905_lang = "";
2
2
  export {
3
- StorySourceCode_vue_vue_type_style_index_0_scoped_f528bb1b_lang as default
3
+ StorySourceCode_vue_vue_type_style_index_0_scoped_1bdf9905_lang as default
4
4
  };
@@ -2,7 +2,7 @@ import _sfc_main from "./SearchItem.vue2.js";
2
2
  import "./SearchItem.vue3.js";
3
3
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
4
  "use strict";
5
- const SearchItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d95fcb03"]]);
5
+ const SearchItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-6c8e9661"]]);
6
6
  export {
7
7
  SearchItem as default
8
8
  };
@@ -1,19 +1,15 @@
1
- import { defineComponent, useCssVars, ref, toRefs, openBlock, createElementBlock, unref, createVNode, withCtx, normalizeClass, createElementVNode, createTextVNode, toDisplayString, Fragment, renderList, createBlock, createCommentVNode, pushScopeId, popScopeId } from "@histoire/vendors/vue";
1
+ import { defineComponent, useCssVars, ref, toRefs, openBlock, createElementBlock, unref, createBlock, withCtx, createVNode, createCommentVNode, pushScopeId, popScopeId } from "@histoire/vendors/vue";
2
2
  import { useRouter } from "@histoire/vendors/vue-router";
3
- import { Icon } from "@histoire/vendors/iconify";
4
3
  import { onKeyboardShortcut } from "../../util/keyboard.js";
5
- import BaseListItemLink from "../base/BaseListItemLink.vue.js";
6
4
  import { useScrollOnActive } from "../../util/scroll.js";
5
+ import BaseListItemLink from "../base/BaseListItemLink.vue.js";
6
+ import "../base/BaseListItem.vue.js";
7
+ import "./SearchItemContent.vue.js";
8
+ import _sfc_main$1 from "./SearchItemContent.vue2.js";
9
+ import _sfc_main$2 from "../base/BaseListItem.vue2.js";
7
10
  "use strict";
8
- const _withScopeId = (n) => (pushScopeId("data-v-d95fcb03"), n = n(), popScopeId(), n);
11
+ const _withScopeId = (n) => (pushScopeId("data-v-6c8e9661"), n = n(), popScopeId(), n);
9
12
  const _hoisted_1 = ["data-selected"];
10
- const _hoisted_2 = { class: "htw-flex-1" };
11
- const _hoisted_3 = { class: "htw-flex" };
12
- const _hoisted_4 = { class: "htw-ml-auto htw-opacity-40" };
13
- const _hoisted_5 = {
14
- key: 0,
15
- class: "htw-flex htw-items-center htw-gap-0.5 htw-opacity-60"
16
- };
17
13
  const _sfc_main = /* @__PURE__ */ defineComponent({
18
14
  __name: "SearchItem",
19
15
  props: {
@@ -32,7 +28,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
32
28
  setup(__props, { emit }) {
33
29
  const props = __props;
34
30
  useCssVars((_ctx) => ({
35
- "beebbd52": __props.result.iconColor
31
+ "a8c1277e": __props.result.iconColor
36
32
  }));
37
33
  const el = ref();
38
34
  const { selected } = toRefs(props);
@@ -41,17 +37,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
41
37
  onKeyboardShortcut(["enter"], () => {
42
38
  if (!props.selected)
43
39
  return;
44
- router.push(props.result.route);
45
- emit("close");
40
+ action();
46
41
  });
47
- const defaultIcons = {
48
- story: "carbon:cube",
49
- variant: "carbon:cube"
50
- };
51
- const kindLabels = {
52
- story: "Story",
53
- variant: "Variant"
54
- };
42
+ function action(fromClick = false) {
43
+ if ("route" in props.result && !fromClick) {
44
+ router.push(props.result.route);
45
+ }
46
+ if ("onActivate" in props.result) {
47
+ props.result.onActivate();
48
+ }
49
+ emit("close");
50
+ }
55
51
  return (_ctx, _cache) => {
56
52
  return openBlock(), createElementBlock("div", {
57
53
  ref_key: "el",
@@ -60,51 +56,35 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
60
56
  "data-test-id": "search-item",
61
57
  "data-selected": unref(selected) ? "" : void 0
62
58
  }, [
63
- createVNode(BaseListItemLink, {
59
+ "route" in __props.result ? (openBlock(), createBlock(BaseListItemLink, {
60
+ key: 0,
64
61
  to: __props.result.route,
65
62
  "is-active": unref(selected),
66
63
  class: "htw-px-6 htw-py-4 htw-gap-4",
67
- onNavigate: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close"))
64
+ onNavigate: _cache[0] || (_cache[0] = ($event) => action(true))
65
+ }, {
66
+ default: withCtx(() => [
67
+ createVNode(_sfc_main$1, {
68
+ result: __props.result,
69
+ selected: unref(selected)
70
+ }, null, 8, ["result", "selected"])
71
+ ]),
72
+ _: 1
73
+ }, 8, ["to", "is-active"])) : createCommentVNode("", true),
74
+ "onActivate" in __props.result ? (openBlock(), createBlock(_sfc_main$2, {
75
+ key: 1,
76
+ "is-active": unref(selected),
77
+ class: "htw-px-6 htw-py-4 htw-gap-4",
78
+ onNavigate: _cache[1] || (_cache[1] = ($event) => action(true))
68
79
  }, {
69
- default: withCtx(() => {
70
- var _a;
71
- return [
72
- createVNode(unref(Icon), {
73
- icon: __props.result.icon ?? defaultIcons[__props.result.kind],
74
- class: normalizeClass(["htw-w-4 htw-h-4", [
75
- !unref(selected) ? [
76
- __props.result.iconColor ? "bind-icon-color" : {
77
- "htw-text-primary-500": __props.result.kind === "story",
78
- "htw-text-gray-500": __props.result.kind === "variant"
79
- }
80
- ] : []
81
- ]])
82
- }, null, 8, ["icon", "class"]),
83
- createElementVNode("div", _hoisted_2, [
84
- createElementVNode("div", _hoisted_3, [
85
- createTextVNode(toDisplayString(__props.result.title) + " ", 1),
86
- createElementVNode("span", _hoisted_4, toDisplayString(kindLabels[__props.result.kind]), 1)
87
- ]),
88
- ((_a = __props.result.path) == null ? void 0 : _a.length) ? (openBlock(), createElementBlock("div", _hoisted_5, [
89
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.result.path, (p, index) => {
90
- return openBlock(), createElementBlock("div", {
91
- key: index,
92
- class: "htw-flex htw-items-center htw-gap-0.5"
93
- }, [
94
- index > 0 ? (openBlock(), createBlock(unref(Icon), {
95
- key: 0,
96
- icon: "carbon:chevron-right",
97
- class: "htw-w-4 htw-h-4 htw-mt-0.5 htw-opacity-50"
98
- })) : createCommentVNode("", true),
99
- createElementVNode("span", null, toDisplayString(p), 1)
100
- ]);
101
- }), 128))
102
- ])) : createCommentVNode("", true)
103
- ])
104
- ];
105
- }),
80
+ default: withCtx(() => [
81
+ createVNode(_sfc_main$1, {
82
+ result: __props.result,
83
+ selected: unref(selected)
84
+ }, null, 8, ["result", "selected"])
85
+ ]),
106
86
  _: 1
107
- }, 8, ["to", "is-active"])
87
+ }, 8, ["is-active"])) : createCommentVNode("", true)
108
88
  ], 8, _hoisted_1);
109
89
  };
110
90
  }
@@ -1,4 +1,4 @@
1
- const SearchItem_vue_vue_type_style_index_0_scoped_d95fcb03_lang = "";
1
+ const SearchItem_vue_vue_type_style_index_0_scoped_6c8e9661_lang = "";
2
2
  export {
3
- SearchItem_vue_vue_type_style_index_0_scoped_d95fcb03_lang as default
3
+ SearchItem_vue_vue_type_style_index_0_scoped_6c8e9661_lang as default
4
4
  };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./SearchItemContent.vue2.js";
2
+ "use strict";
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,72 @@
1
+ import { defineComponent, openBlock, createElementBlock, Fragment, createVNode, normalizeClass, createElementVNode, createTextVNode, toDisplayString, renderList, createBlock, unref, createCommentVNode } from "@histoire/vendors/vue";
2
+ import { Icon } from "@histoire/vendors/iconify";
3
+ import BaseIcon from "../base/BaseIcon.vue.js";
4
+ "use strict";
5
+ const _hoisted_1 = { class: "htw-flex-1" };
6
+ const _hoisted_2 = { class: "htw-flex" };
7
+ const _hoisted_3 = { class: "htw-ml-auto htw-opacity-40" };
8
+ const _hoisted_4 = {
9
+ key: 0,
10
+ class: "htw-flex htw-items-center htw-gap-0.5 htw-opacity-60"
11
+ };
12
+ const _sfc_main = /* @__PURE__ */ defineComponent({
13
+ __name: "SearchItemContent",
14
+ props: {
15
+ result: null,
16
+ selected: { type: Boolean }
17
+ },
18
+ setup(__props) {
19
+ const defaultIcons = {
20
+ story: "carbon:cube",
21
+ variant: "carbon:cube"
22
+ };
23
+ const kindLabels = {
24
+ story: "Story",
25
+ variant: "Variant",
26
+ command: "Command"
27
+ };
28
+ return (_ctx, _cache) => {
29
+ var _a;
30
+ return openBlock(), createElementBlock(Fragment, null, [
31
+ createVNode(BaseIcon, {
32
+ icon: __props.result.icon ?? defaultIcons[__props.result.kind],
33
+ class: normalizeClass(["htw-w-4 htw-h-4", [
34
+ !__props.selected ? [
35
+ __props.result.iconColor ? "bind-icon-color" : {
36
+ "htw-text-primary-500": __props.result.kind === "story",
37
+ "htw-text-gray-500": __props.result.kind === "variant"
38
+ }
39
+ ] : [],
40
+ {
41
+ "colorize-black": __props.selected
42
+ }
43
+ ]])
44
+ }, null, 8, ["icon", "class"]),
45
+ createElementVNode("div", _hoisted_1, [
46
+ createElementVNode("div", _hoisted_2, [
47
+ createTextVNode(toDisplayString(__props.result.title) + " ", 1),
48
+ createElementVNode("span", _hoisted_3, toDisplayString(kindLabels[__props.result.kind]), 1)
49
+ ]),
50
+ ((_a = __props.result.path) == null ? void 0 : _a.length) ? (openBlock(), createElementBlock("div", _hoisted_4, [
51
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.result.path, (p, index) => {
52
+ return openBlock(), createElementBlock("div", {
53
+ key: index,
54
+ class: "htw-flex htw-items-center htw-gap-0.5"
55
+ }, [
56
+ index > 0 ? (openBlock(), createBlock(unref(Icon), {
57
+ key: 0,
58
+ icon: "carbon:chevron-right",
59
+ class: "htw-w-4 htw-h-4 htw-mt-0.5 htw-opacity-50"
60
+ })) : createCommentVNode("", true),
61
+ createElementVNode("span", null, toDisplayString(p), 1)
62
+ ]);
63
+ }), 128))
64
+ ])) : createCommentVNode("", true)
65
+ ])
66
+ ], 64);
67
+ };
68
+ }
69
+ });
70
+ export {
71
+ _sfc_main as default
72
+ };
@@ -3,10 +3,10 @@ import "./SearchLoading.vue.js";
3
3
  import _sfc_main$1 from "./SearchLoading.vue2.js";
4
4
  "use strict";
5
5
  const _hoisted_1 = {
6
- class: "histoire-search-modal htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-700/80 htw-z-20",
6
+ class: "histoire-search-modal htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-900/80 htw-z-20",
7
7
  "data-test-id": "search-modal"
8
8
  };
9
- const _hoisted_2 = { class: "htw-bg-white dark:htw-bg-gray-700 md:htw-mt-16 md:htw-mx-auto htw-w-screen htw-max-w-[512px] htw-shadow-xl htw-border htw-border-gray-200 dark:htw-border-gray-850 htw-rounded-lg htw-relative htw-divide-y htw-divide-gray-200 dark:htw-divide-gray-850" };
9
+ 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-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" };
10
10
  const _sfc_main = /* @__PURE__ */ defineComponent({
11
11
  __name: "SearchModal",
12
12
  props: {
@@ -4,10 +4,14 @@ import { Icon } from "@histoire/vendors/iconify";
4
4
  import * as flexsearch from "flexsearch";
5
5
  import charset from "../../node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/advanced.js";
6
6
  import language from "../../node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/en.js";
7
+ import { registeredCommands } from "virtual:$histoire-commands";
7
8
  import { useStoryStore } from "../../stores/story.js";
8
9
  import BaseEmpty from "../base/BaseEmpty.vue.js";
9
10
  import SearchItem from "./SearchItem.vue.js";
10
11
  import { searchData, onUpdate } from "./search-title-data.js";
12
+ import { getCommandContext, builtinCommands } from "../../util/commands.js";
13
+ import { useCommandStore } from "../../stores/command.js";
14
+ import { useSelection } from "../../util/select.js";
11
15
  "use strict";
12
16
  const _hoisted_1 = {
13
17
  key: 1,
@@ -163,8 +167,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
163
167
  },
164
168
  path: story.file.path.slice(0, -1),
165
169
  icon: story.icon,
166
- iconColor: story.iconColor,
167
- type
170
+ iconColor: story.iconColor
168
171
  };
169
172
  }
170
173
  function variantResultFactory(story, variant, rank, type = "title") {
@@ -185,12 +188,42 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
185
188
  },
186
189
  path: [...story.file.path ?? [], story.title],
187
190
  icon: variant.icon,
188
- iconColor: variant.iconColor,
189
- type
191
+ iconColor: variant.iconColor
192
+ };
193
+ }
194
+ const allCommands = [
195
+ ...builtinCommands,
196
+ ...registeredCommands
197
+ ];
198
+ const commandResults = computed(() => {
199
+ if (__HISTOIRE_DEV__) {
200
+ const commandCtx = getCommandContext();
201
+ const searchText = searchInputText.value.toLowerCase();
202
+ return allCommands.filter((command) => !command.showIf || command.showIf(commandCtx)).filter((command) => {
203
+ var _a;
204
+ return command.label.toLowerCase().includes(searchText) || ((_a = command.searchText) == null ? void 0 : _a.toLowerCase().includes(searchText));
205
+ }).map((command) => commandResultFactory(command, 0));
206
+ }
207
+ return [];
208
+ });
209
+ const commandStore = useCommandStore();
210
+ function commandResultFactory(command, rank) {
211
+ return {
212
+ kind: "command",
213
+ rank,
214
+ id: `_command:${command.id}`,
215
+ title: command.label,
216
+ icon: command.icon ?? "carbon:chevron-right",
217
+ onActivate: () => {
218
+ commandStore.activateCommand(command);
219
+ }
190
220
  };
191
221
  }
192
222
  const results = computed(() => {
193
- const list = [...titleResults.value];
223
+ const list = [
224
+ ...commandResults.value,
225
+ ...titleResults.value
226
+ ];
194
227
  const seen = {};
195
228
  for (const r of titleResults.value) {
196
229
  seen[r.id] = true;
@@ -202,22 +235,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
202
235
  }
203
236
  return list;
204
237
  });
205
- const selectedIndex = ref(0);
206
- watch(results, () => {
207
- selectedIndex.value = 0;
208
- });
209
- function selectNext() {
210
- selectedIndex.value++;
211
- if (selectedIndex.value > results.value.length - 1) {
212
- selectedIndex.value = 0;
213
- }
214
- }
215
- function selectPrevious() {
216
- selectedIndex.value--;
217
- if (selectedIndex.value < 0) {
218
- selectedIndex.value = results.value.length - 1;
219
- }
220
- }
238
+ const {
239
+ selectedIndex,
240
+ selectNext,
241
+ selectPrevious
242
+ } = useSelection(results);
221
243
  return (_ctx, _cache) => {
222
244
  return openBlock(), createElementBlock(Fragment, null, [
223
245
  createElementVNode("div", {
@@ -235,8 +257,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
235
257
  placeholder: "Search for stories, variants...",
236
258
  class: "htw-bg-transparent htw-w-full htw-flex-1 htw-pl-0 htw-pr-6 htw-py-4 htw-outline-none",
237
259
  onKeydown: [
238
- _cache[1] || (_cache[1] = withKeys(withModifiers(($event) => selectNext(), ["prevent"]), ["down"])),
239
- _cache[2] || (_cache[2] = withKeys(withModifiers(($event) => selectPrevious(), ["prevent"]), ["up"])),
260
+ _cache[1] || (_cache[1] = withKeys(withModifiers(($event) => unref(selectNext)(), ["prevent"]), ["down"])),
261
+ _cache[2] || (_cache[2] = withKeys(withModifiers(($event) => unref(selectPrevious)(), ["prevent"]), ["up"])),
240
262
  _cache[3] || (_cache[3] = withKeys(($event) => close(), ["escape"]))
241
263
  ]
242
264
  }, null, 544), [
@@ -256,7 +278,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
256
278
  return openBlock(), createBlock(SearchItem, {
257
279
  key: result.id,
258
280
  result,
259
- selected: index === selectedIndex.value,
281
+ selected: index === unref(selectedIndex),
260
282
  onClose: _cache[5] || (_cache[5] = ($event) => close())
261
283
  }, null, 8, ["result", "selected"]);
262
284
  }), 128))
@@ -1,11 +1,13 @@
1
- import { defineComponent, computed, ref, watch, onMounted, openBlock, createElementBlock, unref, createVNode, createCommentVNode, createElementVNode, normalizeStyle, Fragment, renderList, createBlock } from "@histoire/vendors/vue";
1
+ import { defineComponent, computed, ref, watch, onMounted, openBlock, createElementBlock, unref, createVNode, createBlock, createCommentVNode, createElementVNode, normalizeStyle, Fragment, renderList } from "@histoire/vendors/vue";
2
2
  import { useResizeObserver } from "@histoire/vendors/vue-use";
3
3
  import { useStoryStore } from "../../stores/story.js";
4
4
  import { isMobile } from "../../util/responsive.js";
5
5
  import StoryVariantGridItem from "./StoryVariantGridItem.vue.js";
6
6
  import ToolbarBackground from "../toolbar/ToolbarBackground.vue.js";
7
7
  import "../toolbar/ToolbarTextDirection.vue.js";
8
+ import "../toolbar/DevOnlyToolbarOpenInEditor.vue.js";
8
9
  import _sfc_main$1 from "../toolbar/ToolbarTextDirection.vue2.js";
10
+ import _sfc_main$2 from "../toolbar/DevOnlyToolbarOpenInEditor.vue2.js";
9
11
  "use strict";
10
12
  const _hoisted_1 = { class: "histoire-story-variant-grid htw-flex htw-flex-col htw-items-stretch htw-h-full __histoire-pane-shadow-from-right" };
11
13
  const _hoisted_2 = {
@@ -95,10 +97,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
95
97
  });
96
98
  const columnCount = computed(() => Math.min(storyStore.currentStory.variants.length, Math.floor((viewWidth.value + gap) / (gridColumnWidth.value + gap))));
97
99
  return (_ctx, _cache) => {
100
+ var _a;
98
101
  return openBlock(), createElementBlock("div", _hoisted_1, [
99
102
  !unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2, [
100
103
  createVNode(ToolbarBackground),
101
- createVNode(_sfc_main$1)
104
+ createVNode(_sfc_main$1),
105
+ _ctx.__HISTOIRE_DEV__ ? (openBlock(), createBlock(_sfc_main$2, {
106
+ key: 0,
107
+ file: (_a = unref(storyStore).currentStory.file) == null ? void 0 : _a.filePath,
108
+ tooltip: "Edit story in editor"
109
+ }, null, 8, ["file"])) : createCommentVNode("", true)
102
110
  ])) : createCommentVNode("", true),
103
111
  createElementVNode("div", {
104
112
  ref_key: "el",
@@ -5,14 +5,16 @@ import "../toolbar/ToolbarResponsiveSize.vue.js";
5
5
  import ToolbarBackground from "../toolbar/ToolbarBackground.vue.js";
6
6
  import "../toolbar/ToolbarTextDirection.vue.js";
7
7
  import "../toolbar/ToolbarNewTab.vue.js";
8
+ import "../toolbar/DevOnlyToolbarOpenInEditor.vue.js";
8
9
  import "./StoryVariantSinglePreviewNative.vue.js";
9
10
  import "./StoryVariantSinglePreviewRemote.vue.js";
10
11
  import _sfc_main$1 from "../toolbar/ToolbarTitle.vue2.js";
11
12
  import _sfc_main$2 from "../toolbar/ToolbarResponsiveSize.vue2.js";
12
13
  import _sfc_main$3 from "../toolbar/ToolbarTextDirection.vue2.js";
13
14
  import _sfc_main$4 from "../toolbar/ToolbarNewTab.vue2.js";
14
- import _sfc_main$5 from "./StoryVariantSinglePreviewNative.vue2.js";
15
- import _sfc_main$6 from "./StoryVariantSinglePreviewRemote.vue2.js";
15
+ import _sfc_main$5 from "../toolbar/DevOnlyToolbarOpenInEditor.vue2.js";
16
+ import _sfc_main$6 from "./StoryVariantSinglePreviewNative.vue2.js";
17
+ import _sfc_main$7 from "./StoryVariantSinglePreviewRemote.vue2.js";
16
18
  "use strict";
17
19
  const _hoisted_1 = {
18
20
  class: "histoire-story-variant-single-view htw-h-full htw-flex htw-flex-col",
@@ -30,7 +32,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
30
32
  },
31
33
  setup(__props) {
32
34
  return (_ctx, _cache) => {
33
- var _a;
35
+ var _a, _b;
34
36
  return openBlock(), createElementBlock("div", _hoisted_1, [
35
37
  !unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2, [
36
38
  createVNode(_sfc_main$1, { variant: __props.variant }, null, 8, ["variant"]),
@@ -40,13 +42,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
40
42
  createVNode(_sfc_main$4, {
41
43
  variant: __props.variant,
42
44
  story: __props.story
43
- }, null, 8, ["variant", "story"])
45
+ }, null, 8, ["variant", "story"]),
46
+ _ctx.__HISTOIRE_DEV__ ? (openBlock(), createBlock(_sfc_main$5, {
47
+ key: 1,
48
+ file: (_a = __props.story.file) == null ? void 0 : _a.filePath,
49
+ tooltip: "Edit story in editor"
50
+ }, null, 8, ["file"])) : createCommentVNode("", true)
44
51
  ])) : createCommentVNode("", true),
45
- ((_a = __props.story.layout) == null ? void 0 : _a.iframe) === false ? (openBlock(), createBlock(_sfc_main$5, {
52
+ ((_b = __props.story.layout) == null ? void 0 : _b.iframe) === false ? (openBlock(), createBlock(_sfc_main$6, {
46
53
  key: 1,
47
54
  story: __props.story,
48
55
  variant: __props.variant
49
- }, null, 8, ["story", "variant"])) : (openBlock(), createBlock(_sfc_main$6, {
56
+ }, null, 8, ["story", "variant"])) : (openBlock(), createBlock(_sfc_main$7, {
50
57
  key: 2,
51
58
  story: __props.story,
52
59
  variant: __props.variant
@@ -77,6 +77,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
77
77
  }, [
78
78
  createVNode(_sfc_main$1, {
79
79
  story: unref(storyStore).currentStory,
80
+ standalone: "",
80
81
  class: "md:htw-p-12 htw-w-full md:htw-max-w-[600px] lg:htw-max-w-[800px] xl:htw-max-w-[900px]",
81
82
  onScrollTop: _cache[0] || (_cache[0] = ($event) => scrollDocsToTop())
82
83
  }, null, 8, ["story"])
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./DevOnlyToolbarOpenInEditor.vue2.js";
2
+ "use strict";
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,31 @@
1
+ import { defineComponent, resolveDirective, withDirectives, openBlock, createElementBlock, unref, createVNode } from "@histoire/vendors/vue";
2
+ import { Icon } from "@histoire/vendors/iconify";
3
+ import { openInEditor } from "../../util/open-in-editor.js";
4
+ "use strict";
5
+ const _sfc_main = /* @__PURE__ */ defineComponent({
6
+ __name: "DevOnlyToolbarOpenInEditor",
7
+ props: {
8
+ file: null,
9
+ tooltip: null
10
+ },
11
+ setup(__props) {
12
+ return (_ctx, _cache) => {
13
+ const _directive_tooltip = resolveDirective("tooltip");
14
+ return withDirectives((openBlock(), createElementBlock("a", {
15
+ target: "_blank",
16
+ class: "histoire-toolbar-open-in-editor htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 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",
17
+ onClick: _cache[0] || (_cache[0] = ($event) => unref(openInEditor)(__props.file))
18
+ }, [
19
+ createVNode(unref(Icon), {
20
+ icon: "carbon:script-reference",
21
+ class: "htw-w-4 htw-h-4"
22
+ })
23
+ ])), [
24
+ [_directive_tooltip, __props.tooltip]
25
+ ]);
26
+ };
27
+ }
28
+ });
29
+ export {
30
+ _sfc_main as default
31
+ };
@@ -4,9 +4,10 @@ import { createPinia } from "@histoire/vendors/pinia";
4
4
  import FloatingVue from "@histoire/vendors/floating-vue";
5
5
  import "./App.vue.js";
6
6
  import { router } from "./router.js";
7
+ import { setupPluginApi } from "./plugin.js";
7
8
  import _sfc_main from "./App.vue2.js";
8
9
  "use strict";
9
- function mountMainApp() {
10
+ async function mountMainApp() {
10
11
  const app = createApp(_sfc_main);
11
12
  app.use(createPinia());
12
13
  app.use(FloatingVue, {
@@ -26,6 +27,7 @@ function mountMainApp() {
26
27
  app.mount("#app");
27
28
  if (import.meta.hot) {
28
29
  import.meta.hot.send("histoire:mount", {});
30
+ /* @__PURE__ */ setupPluginApi();
29
31
  }
30
32
  }
31
33
  export {