@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
@@ -0,0 +1,50 @@
1
+ import { router } from "./router.js";
2
+ "use strict";
3
+ function setupPluginApi() {
4
+ if (!import.meta.hot)
5
+ return;
6
+ const listeners = {};
7
+ import.meta.hot.on("histoire:dev-event-result", ({ event, result }) => {
8
+ const set = listeners[event];
9
+ if (set) {
10
+ for (const listener of set) {
11
+ listener(result);
12
+ }
13
+ }
14
+ });
15
+ function addDevEventListener(event, listener) {
16
+ let set = listeners[event];
17
+ if (!set) {
18
+ set = /* @__PURE__ */ new Set();
19
+ listeners[event] = set;
20
+ }
21
+ set.add(listener);
22
+ return () => {
23
+ set.delete(listener);
24
+ };
25
+ }
26
+ window.__HST_PLUGIN_API__ = {
27
+ sendEvent: (event, payload) => {
28
+ return new Promise((resolve) => {
29
+ import.meta.hot.send(`histoire:dev-event`, {
30
+ event,
31
+ payload
32
+ });
33
+ if (event.startsWith("on")) {
34
+ resolve(void 0);
35
+ } else {
36
+ const off = addDevEventListener(event, (result) => {
37
+ off();
38
+ resolve(result);
39
+ });
40
+ }
41
+ });
42
+ },
43
+ openStory: (storyId) => {
44
+ router.push({ name: "story", params: { storyId } });
45
+ }
46
+ };
47
+ }
48
+ export {
49
+ setupPluginApi
50
+ };
@@ -11,6 +11,7 @@ import { applyPreviewSettings } from "./util/preview-settings.js";
11
11
  import { isDark } from "./util/dark.js";
12
12
  import { histoireConfig } from "./util/config.js";
13
13
  import { toRawDeep } from "./util/state.js";
14
+ import { setupPluginApi } from "./plugin.js";
14
15
  import _sfc_main from "./components/story/GenericMountStory.vue2.js";
15
16
  import _sfc_main$1 from "./components/story/GenericRenderStory.vue2.js";
16
17
  "use strict";
@@ -84,9 +85,14 @@ app.mount("#app");
84
85
  watch(isDark, (value) => {
85
86
  if (value) {
86
87
  document.documentElement.classList.add(histoireConfig.sandboxDarkClass);
88
+ document.documentElement.classList.add(histoireConfig.theme.darkClass);
87
89
  } else {
88
90
  document.documentElement.classList.remove(histoireConfig.sandboxDarkClass);
91
+ document.documentElement.classList.remove(histoireConfig.theme.darkClass);
89
92
  }
90
93
  }, {
91
94
  immediate: true
92
95
  });
96
+ if (import.meta.hot) {
97
+ /* @__PURE__ */ setupPluginApi();
98
+ }
@@ -0,0 +1,26 @@
1
+ import { defineStore } from "@histoire/vendors/pinia";
2
+ import { ref } from "@histoire/vendors/vue";
3
+ import { getCommandContext, executeCommand } from "../util/commands.js";
4
+ "use strict";
5
+ const useCommandStore = defineStore("command", () => {
6
+ const selectedCommand = ref(null);
7
+ const showPromptsModal = ref(false);
8
+ function activateCommand(command) {
9
+ var _a, _b;
10
+ selectedCommand.value = command;
11
+ if ((_a = command.prompts) == null ? void 0 : _a.length) {
12
+ showPromptsModal.value = true;
13
+ } else {
14
+ const params = ((_b = command.getParams) == null ? void 0 : _b.call(command, getCommandContext())) ?? {};
15
+ executeCommand(command, params);
16
+ }
17
+ }
18
+ return {
19
+ selectedCommand,
20
+ showPromptsModal,
21
+ activateCommand
22
+ };
23
+ });
24
+ export {
25
+ useCommandStore
26
+ };
@@ -11,10 +11,6 @@
11
11
  }
12
12
  }
13
13
 
14
- .bind-icon-color[data-v-36846ccf] {
15
- color: var(--5792748b);
16
- }
17
-
18
14
  .landscape > div > .dragger[data-v-ed925107] {
19
15
  width: .625rem;
20
16
  }
@@ -40,10 +36,19 @@
40
36
  bottom: -.625rem;
41
37
  }
42
38
 
39
+ .bind-icon-color[data-v-36846ccf] {
40
+ color: var(--5792748b);
41
+ }
42
+
43
43
  .bind-icon-color[data-v-6046525f] {
44
44
  color: var(--663732b6);
45
45
  }
46
46
 
47
+ .__histoire-code-placeholder[data-v-1bdf9905] {
48
+ color: inherit;
49
+ font-size: inherit;
50
+ }
51
+
47
52
  .bind-tree-margin[data-v-19810958] {
48
53
  margin-left: var(--444efc12);
49
54
  }
@@ -55,11 +60,6 @@
55
60
  padding-left: var(--6851b0a7);
56
61
  }
57
62
 
58
- .__histoire-code-placeholder[data-v-f528bb1b] {
59
- color: inherit;
60
- font-size: inherit;
61
- }
62
-
63
63
  .bind-icon-color[data-v-ddfc5b4f] {
64
64
  color: var(--4d25d048);
65
65
  }
@@ -68,15 +68,8 @@
68
68
  color: var(--89126aaa);
69
69
  }
70
70
 
71
- .bind-icon-color[data-v-d95fcb03] {
72
- color: var(--beebbd52);
73
- }
74
-
75
- .bind-icon-color[data-v-f7c98176] {
76
- color: var(--edeb0368);
77
- }
78
- .bind-preview-bg[data-v-f7c98176] {
79
- background-color: var(--f4b27ac2);
71
+ .bind-icon-color[data-v-6c8e9661] {
72
+ color: var(--a8c1277e);
80
73
  }
81
74
 
82
75
  .bind-preview-bg[data-v-c48fb2b2] {
@@ -84,6 +77,17 @@
84
77
  color: var(--35068428);
85
78
  }
86
79
 
80
+ .bind-icon-color[data-v-c1d28b37] {
81
+ color: var(--d647bf7e);
82
+ }
83
+ .bind-preview-bg[data-v-c1d28b37] {
84
+ background-color: var(--772419ec);
85
+ }
86
+
87
+ img.colorize-black[data-v-74182813] {
88
+ filter: grayscale(100) brightness(0);
89
+ }
90
+
87
91
  .bind-preview-bg[data-v-a83b1911] {
88
92
  background-color: var(--03d1950e);
89
93
  }
@@ -0,0 +1,59 @@
1
+ import { router } from "../router.js";
2
+ import { openInEditor } from "./open-in-editor.js";
3
+ import { useStoryStore } from "../stores/story.js";
4
+ "use strict";
5
+ const builtinCommands = [
6
+ {
7
+ id: "builtin:open-in-editor",
8
+ label: "Open file in editor",
9
+ icon: "carbon:script-reference",
10
+ showIf: ({ route }) => route.name === "story" && !!useStoryStore().currentStory,
11
+ getParams: () => {
12
+ var _a, _b, _c;
13
+ const story = useStoryStore().currentStory;
14
+ let file;
15
+ if (story.docsOnly) {
16
+ file = ((_a = story.file) == null ? void 0 : _a.docsFilePath) ?? ((_b = story.file) == null ? void 0 : _b.filePath);
17
+ } else {
18
+ file = (_c = story.file) == null ? void 0 : _c.filePath;
19
+ }
20
+ return {
21
+ file
22
+ };
23
+ },
24
+ clientAction: ({ file }) => {
25
+ openInEditor(file);
26
+ }
27
+ },
28
+ {
29
+ id: "builtin:histoire-docs",
30
+ label: "Open Histoire Documentation",
31
+ icon: "carbon:help",
32
+ clientAction: () => {
33
+ window.open("https://histoire.dev/guide/getting-started.html", "_blank");
34
+ }
35
+ }
36
+ ];
37
+ function executeCommand(command, params) {
38
+ var _a;
39
+ if (import.meta.hot) {
40
+ import.meta.hot.send("histoire:dev-command", {
41
+ id: command.id,
42
+ params
43
+ });
44
+ (_a = command.clientAction) == null ? void 0 : _a.call(command, params, getCommandContext());
45
+ }
46
+ }
47
+ function getCommandContext() {
48
+ const storyStore = useStoryStore();
49
+ return {
50
+ route: router.currentRoute.value,
51
+ currentStory: storyStore.currentStory,
52
+ currentVariant: storyStore.currentVariant
53
+ };
54
+ }
55
+ export {
56
+ builtinCommands,
57
+ executeCommand,
58
+ getCommandContext
59
+ };
@@ -5,7 +5,8 @@ import { histoireConfig } from "./config.js";
5
5
  const isDark = useDark({
6
6
  valueDark: "htw-dark",
7
7
  initialValue: histoireConfig.theme.defaultColorScheme,
8
- storageKey: histoireConfig.theme.storeColorScheme ? "histoire-color-scheme" : null
8
+ storageKey: "histoire-color-scheme",
9
+ storage: histoireConfig.theme.storeColorScheme ? localStorage : sessionStorage
9
10
  });
10
11
  const toggleDark = useToggle(isDark);
11
12
  function applyDarkToControls() {
@@ -79,6 +79,9 @@ function formatKey(key) {
79
79
  if (key === "meta") {
80
80
  return "⌘";
81
81
  }
82
+ if (key === "enter") {
83
+ return "⏎";
84
+ }
82
85
  return key.charAt(0).toUpperCase() + key.substring(1).toLowerCase();
83
86
  }
84
87
  export {
@@ -0,0 +1,6 @@
1
+ function openInEditor(file) {
2
+ return fetch(`${import.meta.env.BASE_URL}__open-in-editor?file=${encodeURIComponent(file)}`);
3
+ }
4
+ export {
5
+ openInEditor
6
+ };
@@ -0,0 +1,28 @@
1
+ import { ref, watch, computed } from "@histoire/vendors/vue";
2
+ "use strict";
3
+ function useSelection(list) {
4
+ const selectedIndex = ref(0);
5
+ watch(list, () => {
6
+ selectedIndex.value = 0;
7
+ });
8
+ function selectNext() {
9
+ selectedIndex.value++;
10
+ if (selectedIndex.value > list.value.length - 1) {
11
+ selectedIndex.value = 0;
12
+ }
13
+ }
14
+ function selectPrevious() {
15
+ selectedIndex.value--;
16
+ if (selectedIndex.value < 0) {
17
+ selectedIndex.value = list.value.length - 1;
18
+ }
19
+ }
20
+ return {
21
+ selectedIndex: computed(() => selectedIndex.value),
22
+ selectNext,
23
+ selectPrevious
24
+ };
25
+ }
26
+ export {
27
+ useSelection
28
+ };
@@ -8,7 +8,7 @@ function makeTooltip(descriptionHtml, keyboardShortcut) {
8
8
  };
9
9
  }
10
10
  function genKeyboardShortcutHtml(shortcut) {
11
- return shortcut.split("+").map((k) => k.trim()).map((key) => `<span class="htw-bg-gray-500 htw-border-b-2 htw-border-gray-600 htw-px-1 htw-rounded-sm">${formatKey(key)}</span>`).join("");
11
+ return `<span class="htw-border htw-border-gray-600 htw-px-1 htw-rounded-sm htw-text-gray-400">${shortcut.split("+").map((k) => formatKey(k.trim())).join(" ")}</span>`;
12
12
  }
13
13
  export {
14
14
  makeTooltip