@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
@@ -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";
@@ -90,3 +91,6 @@ watch(isDark, (value) => {
90
91
  }, {
91
92
  immediate: true
92
93
  });
94
+ if (import.meta.hot) {
95
+ /* @__PURE__ */ setupPluginApi();
96
+ }
@@ -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,6 +11,10 @@
11
11
  }
12
12
  }
13
13
 
14
+ .bind-icon-color[data-v-36846ccf] {
15
+ color: var(--5792748b);
16
+ }
17
+
14
18
  .landscape > div > .dragger[data-v-ed925107] {
15
19
  width: .625rem;
16
20
  }
@@ -36,14 +40,14 @@
36
40
  bottom: -.625rem;
37
41
  }
38
42
 
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
+ .bind-tree-padding[data-v-2d2e4786] {
48
+ padding-left: var(--6851b0a7);
49
+ }
50
+
47
51
  .bind-tree-margin[data-v-19810958] {
48
52
  margin-left: var(--444efc12);
49
53
  }
@@ -51,30 +55,21 @@
51
55
  color: var(--ae892164);
52
56
  }
53
57
 
54
- .bind-tree-padding[data-v-2d2e4786] {
55
- padding-left: var(--6851b0a7);
56
- }
57
-
58
58
  .bind-icon-color[data-v-ab890d9c] {
59
59
  color: var(--89126aaa);
60
60
  }
61
61
 
62
- .__histoire-code-placeholder[data-v-f528bb1b] {
63
- color: inherit;
64
- font-size: inherit;
65
- }
66
-
67
62
  .bind-icon-color[data-v-ddfc5b4f] {
68
63
  color: var(--4d25d048);
69
64
  }
70
65
 
71
- .bind-icon-color[data-v-d95fcb03] {
72
- color: var(--beebbd52);
66
+ .__histoire-code-placeholder[data-v-1bdf9905] {
67
+ color: inherit;
68
+ font-size: inherit;
73
69
  }
74
70
 
75
- .bind-preview-bg[data-v-c48fb2b2] {
76
- background-color: var(--627bec82);
77
- color: var(--35068428);
71
+ .bind-icon-color[data-v-6c8e9661] {
72
+ color: var(--a8c1277e);
78
73
  }
79
74
 
80
75
  .bind-icon-color[data-v-f7c98176] {
@@ -84,6 +79,15 @@
84
79
  background-color: var(--f4b27ac2);
85
80
  }
86
81
 
82
+ .bind-preview-bg[data-v-c48fb2b2] {
83
+ background-color: var(--627bec82);
84
+ color: var(--35068428);
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
+ };
@@ -1,7 +1,12 @@
1
1
  import { watch } from "@histoire/vendors/vue";
2
2
  import { useDark, useToggle } from "@histoire/vendors/vue-use";
3
+ import { histoireConfig } from "./config.js";
3
4
  "use strict";
4
- const isDark = useDark({ valueDark: "htw-dark" });
5
+ const isDark = useDark({
6
+ valueDark: "htw-dark",
7
+ initialValue: histoireConfig.theme.defaultColorScheme,
8
+ storageKey: histoireConfig.theme.storeColorScheme ? "histoire-color-scheme" : null
9
+ });
5
10
  const toggleDark = useToggle(isDark);
6
11
  function applyDarkToControls() {
7
12
  var _a;
@@ -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