@histoire/app 0.17.16 → 1.0.0-alpha.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 (200) hide show
  1. package/dist/app/style/main.pcss +1 -1
  2. package/dist/app/style/sandbox.css +1 -1
  3. package/dist/bundle-main-dev.js +1 -1
  4. package/dist/bundle-main.js +2 -2
  5. package/dist/bundled/App.vue2.js +11 -11
  6. package/dist/bundled/app.css +101 -0
  7. package/dist/bundled/components/HomeView.vue2.js +1 -1
  8. package/dist/bundled/components/app/AppHeader.vue2.js +3 -3
  9. package/dist/bundled/components/app/AppLogo.vue2.js +4 -4
  10. package/dist/bundled/components/app/Breadcrumb.vue.js +2 -2
  11. package/dist/bundled/components/app/Breadcrumb.vue2.js +8 -10
  12. package/dist/bundled/components/app/HomeCounter.vue2.js +2 -7
  13. package/dist/bundled/components/app/InitialLoading.vue2.js +1 -1
  14. package/dist/bundled/components/base/BaseCheckbox.vue2.js +1 -2
  15. package/dist/bundled/components/base/BaseEmpty.vue.js +2 -3
  16. package/dist/bundled/components/base/BaseIcon.vue.js +2 -2
  17. package/dist/bundled/components/base/BaseIcon.vue2.js +1 -2
  18. package/dist/bundled/components/base/BaseListItemLink.vue.js +1 -1
  19. package/dist/bundled/components/base/BaseOverflowMenu.vue2.js +5 -5
  20. package/dist/bundled/components/base/BaseOverflowTab.vue.js +1 -1
  21. package/dist/bundled/components/base/BaseSelect.vue2.js +2 -2
  22. package/dist/bundled/components/base/BaseSplitPane.vue.js +2 -2
  23. package/dist/bundled/components/base/BaseSplitPane.vue2.js +3 -6
  24. package/dist/bundled/components/base/BaseTab.vue.js +1 -1
  25. package/dist/bundled/components/base/BaseTag.vue.js +1 -1
  26. package/dist/bundled/components/command/CommandPrompts.vue2.js +3 -7
  27. package/dist/bundled/components/command/CommandPromptsModal.vue2.js +1 -1
  28. package/dist/bundled/components/command/PromptSelect.vue2.js +3 -3
  29. package/dist/bundled/components/command/PromptText.vue2.js +1 -1
  30. package/dist/bundled/components/misc/CheckerboardPattern.vue.js +31 -34
  31. package/dist/bundled/components/misc/HatchedPattern.vue.js +2 -3
  32. package/dist/bundled/components/panel/ControlsComponentPropItem.vue2.js +1 -1
  33. package/dist/bundled/components/panel/ControlsComponentProps.vue2.js +2 -4
  34. package/dist/bundled/components/panel/ControlsComponentState.vue2.js +1 -2
  35. package/dist/bundled/components/panel/PaneTabs.vue2.js +12 -12
  36. package/dist/bundled/components/panel/StatePresets.vue2.js +3 -4
  37. package/dist/bundled/components/panel/StoryControls.vue2.js +5 -6
  38. package/dist/bundled/components/panel/StoryDocs.vue2.js +6 -6
  39. package/dist/bundled/components/panel/StoryEvents.vue2.js +2 -2
  40. package/dist/bundled/components/panel/StorySidePanel.vue2.js +10 -12
  41. package/dist/bundled/components/panel/StorySourceCode.vue.js +2 -2
  42. package/dist/bundled/components/panel/StorySourceCode.vue2.js +15 -20
  43. package/dist/bundled/components/search/SearchItem.vue.js +2 -2
  44. package/dist/bundled/components/search/SearchItem.vue2.js +4 -6
  45. package/dist/bundled/components/search/SearchLoading.vue2.js +2 -2
  46. package/dist/bundled/components/search/SearchModal.vue2.js +1 -1
  47. package/dist/bundled/components/search/SearchPane.vue2.js +42 -60
  48. package/dist/bundled/components/search/search-docs-data.js +1 -1
  49. package/dist/bundled/components/search/search-title-data.js +1 -1
  50. package/dist/bundled/components/story/GenericMountStory.vue2.js +1 -1
  51. package/dist/bundled/components/story/StoryResponsivePreview.vue.js +2 -2
  52. package/dist/bundled/components/story/StoryResponsivePreview.vue2.js +9 -12
  53. package/dist/bundled/components/story/StoryVariantGrid.vue2.js +8 -11
  54. package/dist/bundled/components/story/StoryVariantGridItem.vue.js +2 -2
  55. package/dist/bundled/components/story/StoryVariantGridItem.vue2.js +16 -19
  56. package/dist/bundled/components/story/StoryVariantListItem.vue.js +2 -2
  57. package/dist/bundled/components/story/StoryVariantListItem.vue2.js +4 -5
  58. package/dist/bundled/components/story/StoryVariantSingle.vue.js +2 -2
  59. package/dist/bundled/components/story/StoryVariantSingle.vue2.js +5 -6
  60. package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue2.js +3 -3
  61. package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue2.js +4 -4
  62. package/dist/bundled/components/story/StoryVariantSingleView.vue2.js +4 -4
  63. package/dist/bundled/components/story/StoryView.vue2.js +5 -5
  64. package/dist/bundled/components/story/StoryViewer.vue.js +2 -2
  65. package/dist/bundled/components/story/StoryViewer.vue2.js +3 -4
  66. package/dist/bundled/components/toolbar/ToolbarBackground.vue.js +1 -1
  67. package/dist/bundled/components/toolbar/ToolbarBackground.vue2.js +3 -4
  68. package/dist/bundled/components/toolbar/ToolbarResponsiveSize.vue2.js +16 -17
  69. package/dist/bundled/components/tree/StoryGroup.vue2.js +9 -11
  70. package/dist/bundled/components/tree/StoryList.vue2.js +3 -3
  71. package/dist/bundled/components/tree/StoryListFolder.vue.js +2 -2
  72. package/dist/bundled/components/tree/StoryListFolder.vue2.js +13 -15
  73. package/dist/bundled/components/tree/StoryListItem.vue.js +2 -2
  74. package/dist/bundled/components/tree/StoryListItem.vue2.js +5 -6
  75. package/dist/bundled/index.js +4 -4
  76. package/dist/bundled/plugin.js +1 -2
  77. package/dist/bundled/sandbox.js +15 -20
  78. package/dist/bundled/stores/folder.js +1 -1
  79. package/dist/bundled/stores/preview-settings.js +1 -1
  80. package/dist/bundled/util/commands.js +1 -1
  81. package/dist/bundled/util/dark.js +1 -1
  82. package/dist/bundled/util/events.js +2 -4
  83. package/dist/bundled/util/scroll.js +1 -1
  84. package/dist/bundled/util/state.js +2 -2
  85. package/dist/style.css +281 -293
  86. package/package.json +24 -25
  87. package/scripts/copy.mjs +1 -1
  88. package/scripts/watchAndCopy.mjs +4 -4
  89. package/src/app/App.vue +15 -15
  90. package/src/app/api.ts +3 -3
  91. package/src/app/components/HomeView.vue +4 -3
  92. package/src/app/components/app/AppHeader.vue +2 -2
  93. package/src/app/components/app/AppLogo.vue +4 -4
  94. package/src/app/components/app/Breadcrumb.vue +5 -5
  95. package/src/app/components/app/HomeCounter.vue +1 -10
  96. package/src/app/components/app/MobileOverlay.vue +1 -1
  97. package/src/app/components/base/BaseCheckbox.vue +2 -3
  98. package/src/app/components/base/BaseIcon.vue +2 -2
  99. package/src/app/components/base/BaseKeyboardShortcut.vue +1 -1
  100. package/src/app/components/base/BaseListItem.vue +2 -2
  101. package/src/app/components/base/BaseListItemLink.vue +3 -3
  102. package/src/app/components/base/BaseOverflowMenu.vue +5 -5
  103. package/src/app/components/base/BaseSelect.vue +6 -5
  104. package/src/app/components/base/BaseSplitPane.vue +19 -15
  105. package/src/app/components/command/CommandPrompts.vue +8 -10
  106. package/src/app/components/command/CommandPromptsModal.vue +2 -1
  107. package/src/app/components/command/PromptSelect.vue +7 -5
  108. package/src/app/components/command/PromptText.vue +4 -3
  109. package/src/app/components/panel/ControlsComponentPropItem.vue +4 -4
  110. package/src/app/components/panel/ControlsComponentState.vue +3 -3
  111. package/src/app/components/panel/ControlsComponentStateItem.vue +2 -2
  112. package/src/app/components/panel/PaneTabs.vue +3 -3
  113. package/src/app/components/panel/StatePresets.vue +16 -13
  114. package/src/app/components/panel/StoryControls.vue +5 -5
  115. package/src/app/components/panel/StoryDocs.vue +28 -24
  116. package/src/app/components/panel/StoryEvent.vue +2 -2
  117. package/src/app/components/panel/StoryEvents.vue +3 -3
  118. package/src/app/components/panel/StorySidePanel.vue +2 -2
  119. package/src/app/components/panel/StorySourceCode.vue +12 -8
  120. package/src/app/components/search/SearchItem.vue +5 -4
  121. package/src/app/components/search/SearchItemContent.vue +4 -4
  122. package/src/app/components/search/SearchModal.vue +2 -1
  123. package/src/app/components/search/SearchPane.vue +64 -76
  124. package/src/app/components/search/search-docs-data.ts +3 -3
  125. package/src/app/components/search/search-title-data.ts +3 -3
  126. package/src/app/components/search/types.ts +1 -1
  127. package/src/app/components/story/GenericMountStory.vue +2 -2
  128. package/src/app/components/story/GenericRenderStory.vue +4 -3
  129. package/src/app/components/story/StoryResponsivePreview.vue +17 -16
  130. package/src/app/components/story/StoryVariantGrid.vue +10 -9
  131. package/src/app/components/story/StoryVariantGridItem.vue +14 -14
  132. package/src/app/components/story/StoryVariantListItem.vue +4 -3
  133. package/src/app/components/story/StoryVariantSingle.vue +3 -3
  134. package/src/app/components/story/StoryVariantSinglePreviewNative.vue +5 -5
  135. package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +14 -14
  136. package/src/app/components/story/StoryVariantSingleView.vue +4 -4
  137. package/src/app/components/story/StoryView.vue +8 -8
  138. package/src/app/components/story/StoryViewer.vue +2 -3
  139. package/src/app/components/toolbar/ToolbarNewTab.vue +1 -1
  140. package/src/app/components/toolbar/ToolbarTitle.vue +1 -1
  141. package/src/app/components/tree/StoryGroup.vue +3 -3
  142. package/src/app/components/tree/StoryList.vue +3 -3
  143. package/src/app/components/tree/StoryListFolder.vue +3 -3
  144. package/src/app/components/tree/StoryListItem.vue +2 -2
  145. package/src/app/index.ts +6 -7
  146. package/src/app/plugin.ts +4 -3
  147. package/src/app/router.ts +2 -2
  148. package/src/app/sandbox.ts +24 -27
  149. package/src/app/stores/command.ts +4 -3
  150. package/src/app/stores/events.ts +4 -4
  151. package/src/app/stores/folder.ts +10 -8
  152. package/src/app/stores/preview-settings.ts +2 -2
  153. package/src/app/stores/story.ts +4 -4
  154. package/src/app/style/main.pcss +1 -1
  155. package/src/app/style/sandbox.css +1 -1
  156. package/src/app/types.ts +3 -3
  157. package/src/app/util/commands.ts +5 -4
  158. package/src/app/util/dark.ts +3 -3
  159. package/src/app/util/docs.ts +6 -4
  160. package/src/app/util/events.ts +4 -3
  161. package/src/app/util/keyboard.ts +9 -8
  162. package/src/app/util/mapping.ts +9 -6
  163. package/src/app/util/open-in-editor.ts +1 -1
  164. package/src/app/util/preview-settings.ts +3 -3
  165. package/src/app/util/sandbox.ts +2 -3
  166. package/src/app/util/scroll.ts +5 -4
  167. package/src/app/util/select.ts +5 -4
  168. package/src/app/util/state.ts +6 -5
  169. package/src/app/util/tooltip.ts +2 -2
  170. package/src/app/util/variant.ts +4 -3
  171. package/src/bundle-main-dev.js +1 -1
  172. package/src/bundle-main.js +2 -2
  173. package/src/shim.d.ts +0 -6
  174. package/src/virtual.d.ts +1 -0
  175. package/tailwind.config.cjs +20 -21
  176. package/tsconfig.json +26 -26
  177. package/vite.config.ts +8 -7
  178. package/dist/bundled/components/app/Breadcrumb.vue3.js +0 -1
  179. package/dist/bundled/components/base/BaseEmpty.vue2.js +0 -1
  180. package/dist/bundled/components/base/BaseIcon.vue3.js +0 -1
  181. package/dist/bundled/components/base/BaseSplitPane.vue3.js +0 -1
  182. package/dist/bundled/components/misc/HatchedPattern.vue2.js +0 -1
  183. package/dist/bundled/components/panel/StorySourceCode.vue3.js +0 -1
  184. package/dist/bundled/components/search/SearchItem.vue3.js +0 -1
  185. package/dist/bundled/components/story/StoryResponsivePreview.vue3.js +0 -1
  186. package/dist/bundled/components/story/StoryVariantGridItem.vue3.js +0 -1
  187. package/dist/bundled/components/story/StoryVariantListItem.vue3.js +0 -1
  188. package/dist/bundled/components/story/StoryVariantSingle.vue3.js +0 -1
  189. package/dist/bundled/components/story/StoryViewer.vue3.js +0 -1
  190. package/dist/bundled/components/toolbar/ToolbarBackground.vue3.js +0 -1
  191. package/dist/bundled/components/tree/StoryListFolder.vue3.js +0 -1
  192. package/dist/bundled/components/tree/StoryListItem.vue3.js +0 -1
  193. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/common.js +0 -52
  194. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/en.js +0 -10
  195. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/advanced.js +0 -16
  196. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/balance.js +0 -31
  197. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/simple.js +0 -15
  198. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang.js +0 -60
  199. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/type.js +0 -11
  200. package/dist/bundled/style.css +0 -101
@@ -1,14 +1,15 @@
1
1
  <script lang="ts" setup>
2
- import { computed, ref, toRaw, watch } from 'vue'
3
- import { useEventListener } from '@vueuse/core'
4
- import { applyState } from '@histoire/shared'
5
- import { STATE_SYNC, PREVIEW_SETTINGS_SYNC, SANDBOX_READY, EVENT_SEND } from '../../util/const'
2
+ import type { HstEvent } from '../../stores/events'
6
3
  import type { Story, Variant } from '../../types'
7
- import { getSandboxUrl } from '../../util/sandbox'
4
+ import { applyState } from '@histoire/shared'
5
+ import { useEventListener } from '@vueuse/core'
6
+ import { computed, ref, toRaw, watch } from 'vue'
7
+ import { useEventsStore } from '../../stores/events'
8
8
  import { usePreviewSettingsStore } from '../../stores/preview-settings'
9
- import { HstEvent, useEventsStore } from '../../stores/events'
10
- import StoryResponsivePreview from './StoryResponsivePreview.vue'
9
+ import { EVENT_SEND, PREVIEW_SETTINGS_SYNC, SANDBOX_READY, STATE_SYNC } from '../../util/const'
10
+ import { getSandboxUrl } from '../../util/sandbox'
11
11
  import { toRawDeep } from '../../util/state'
12
+ import StoryResponsivePreview from './StoryResponsivePreview.vue'
12
13
 
13
14
  const props = defineProps<{
14
15
  story: Story
@@ -21,7 +22,7 @@ const settings = usePreviewSettingsStore().currentSettings
21
22
 
22
23
  const iframe = ref<HTMLIFrameElement>()
23
24
 
24
- function syncState () {
25
+ function syncState() {
25
26
  if (iframe.value && props.variant.previewReady) {
26
27
  iframe.value.contentWindow.postMessage({
27
28
  type: STATE_SYNC,
@@ -61,17 +62,17 @@ useEventListener(window, 'message', (event) => {
61
62
  }
62
63
  })
63
64
 
64
- function updateVariantState (state: any) {
65
+ function updateVariantState(state: any) {
65
66
  synced = true
66
67
  applyState(props.variant.state, state)
67
68
  }
68
69
 
69
- function logEvent (event: HstEvent) {
70
+ function logEvent(event: HstEvent) {
70
71
  const eventsStore = useEventsStore()
71
72
  eventsStore.addEvent(event)
72
73
  }
73
74
 
74
- function setPreviewReady () {
75
+ function setPreviewReady() {
75
76
  Object.assign(props.variant, {
76
77
  previewReady: true,
77
78
  })
@@ -92,7 +93,7 @@ watch(sandboxUrl, () => {
92
93
 
93
94
  // Settings
94
95
 
95
- function syncSettings () {
96
+ function syncSettings() {
96
97
  if (iframe.value) {
97
98
  iframe.value.contentWindow.postMessage({
98
99
  type: PREVIEW_SETTINGS_SYNC,
@@ -110,12 +111,11 @@ watch(() => settings, () => {
110
111
 
111
112
  // Iframe load
112
113
 
113
- function onIframeLoad () {
114
+ function onIframeLoad() {
114
115
  isIframeLoaded.value = true
115
116
  syncState()
116
117
  syncSettings()
117
118
  }
118
-
119
119
  </script>
120
120
 
121
121
  <template>
@@ -1,12 +1,12 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Story, Variant } from '../../types'
3
3
  import { isMobile } from '../../util/responsive'
4
- import ToolbarTitle from '../toolbar/ToolbarTitle.vue'
5
- import ToolbarResponsiveSize from '../toolbar/ToolbarResponsiveSize.vue'
4
+ import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
6
5
  import ToolbarBackground from '../toolbar/ToolbarBackground.vue'
7
- import ToolbarTextDirection from '../toolbar/ToolbarTextDirection.vue'
8
6
  import ToolbarNewTab from '../toolbar/ToolbarNewTab.vue'
9
- import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
7
+ import ToolbarResponsiveSize from '../toolbar/ToolbarResponsiveSize.vue'
8
+ import ToolbarTextDirection from '../toolbar/ToolbarTextDirection.vue'
9
+ import ToolbarTitle from '../toolbar/ToolbarTitle.vue'
10
10
  import StoryVariantSinglePreviewNative from './StoryVariantSinglePreviewNative.vue'
11
11
  import StoryVariantSinglePreviewRemote from './StoryVariantSinglePreviewRemote.vue'
12
12
 
@@ -1,15 +1,15 @@
1
1
  <script lang="ts" setup>
2
+ import { Icon } from '@iconify/vue'
2
3
  import { ref, watch } from 'vue'
3
4
  import { useRoute, useRouter } from 'vue-router'
4
- import { Icon } from '@iconify/vue'
5
5
  import { useStoryStore } from '../../stores/story'
6
6
 
7
- import BaseSplitPane from '../base/BaseSplitPane.vue'
8
- import BaseEmpty from '../base/BaseEmpty.vue'
9
7
  import { isMobile } from '../../util/responsive'
10
- import StoryViewer from './StoryViewer.vue'
11
- import StorySidePanel from '../panel/StorySidePanel.vue'
8
+ import BaseEmpty from '../base/BaseEmpty.vue'
9
+ import BaseSplitPane from '../base/BaseSplitPane.vue'
12
10
  import StoryDocs from '../panel/StoryDocs.vue'
11
+ import StorySidePanel from '../panel/StorySidePanel.vue'
12
+ import StoryViewer from './StoryViewer.vue'
13
13
 
14
14
  const storyStore = useStoryStore()
15
15
 
@@ -18,7 +18,7 @@ const route = useRoute()
18
18
 
19
19
  // Restore variant selection
20
20
 
21
- watch(() => storyStore.currentVariant, value => {
21
+ watch(() => storyStore.currentVariant, (value) => {
22
22
  if (value) {
23
23
  storyStore.currentStory.lastSelectedVariant = value
24
24
  }
@@ -41,7 +41,7 @@ watch(() => [storyStore.currentStory, storyStore.currentVariant], () => {
41
41
  immediate: true,
42
42
  })
43
43
 
44
- function setVariant (variantId: string) {
44
+ function setVariant(variantId: string) {
45
45
  router.replace({
46
46
  ...route,
47
47
  query: {
@@ -55,7 +55,7 @@ function setVariant (variantId: string) {
55
55
 
56
56
  const docsOnlyScroller = ref<HTMLElement>(null)
57
57
 
58
- function scrollDocsToTop () {
58
+ function scrollDocsToTop() {
59
59
  docsOnlyScroller.value?.scrollTo(0, 0)
60
60
  }
61
61
  </script>
@@ -1,9 +1,9 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed, ref, watch } from 'vue'
3
3
  import { useStoryStore } from '../../stores/story'
4
- import StoryVariantListItem from './StoryVariantListItem.vue'
5
4
  import MobileOverlay from '../app/MobileOverlay.vue'
6
5
  import StoryVariantGrid from './StoryVariantGrid.vue'
6
+ import StoryVariantListItem from './StoryVariantListItem.vue'
7
7
  import StoryVariantSingle from './StoryVariantSingle.vue'
8
8
 
9
9
  const storyStore = useStoryStore()
@@ -12,14 +12,13 @@ const variant = computed(() => storyStore.currentVariant)
12
12
 
13
13
  const isMenuOpened = ref(false)
14
14
 
15
- function closeMenu () {
15
+ function closeMenu() {
16
16
  isMenuOpened.value = false
17
17
  }
18
18
 
19
19
  watch(variant, () => {
20
20
  isMenuOpened.value = false
21
21
  })
22
-
23
22
  </script>
24
23
 
25
24
  <template>
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
- import { Icon } from '@iconify/vue'
3
2
  import type { Story, Variant } from '../../types'
3
+ import { Icon } from '@iconify/vue'
4
4
  import { computed } from 'vue'
5
5
  import { getSandboxUrl } from '../../util/sandbox'
6
6
 
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
- import { Icon } from '@iconify/vue'
3
2
  import type { Variant } from '../../types'
3
+ import { Icon } from '@iconify/vue'
4
4
 
5
5
  defineProps<{
6
6
  variant: Variant
@@ -1,10 +1,10 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Story, TreeGroup } from '../../types'
3
- import StoryListItem from './StoryListItem.vue'
4
- import StoryListFolder from './StoryListFolder.vue'
5
3
  import { Icon } from '@iconify/vue'
6
4
  import { computed, withDefaults } from 'vue'
7
5
  import { useFolderStore } from '../../stores/folder'
6
+ import StoryListFolder from './StoryListFolder.vue'
7
+ import StoryListItem from './StoryListItem.vue'
8
8
 
9
9
  const props = withDefaults(defineProps<{
10
10
  path?: Array<string>
@@ -19,7 +19,7 @@ const folderStore = useFolderStore()
19
19
  const folderPath = computed(() => [...props.path, props.group.title])
20
20
  const isFolderOpen = computed(() => folderStore.isFolderOpened(folderPath.value, true))
21
21
 
22
- function toggleOpen () {
22
+ function toggleOpen() {
23
23
  folderStore.toggleFolder(folderPath.value, false)
24
24
  }
25
25
  </script>
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" setup>
2
- import type { Story, Tree, TreeGroup, TreeFolder, TreeLeaf } from '../../types'
3
- import StoryListItem from './StoryListItem.vue'
4
- import StoryListFolder from './StoryListFolder.vue'
2
+ import type { Story, Tree, TreeFolder, TreeGroup, TreeLeaf } from '../../types'
5
3
  import StoryGroup from './StoryGroup.vue'
4
+ import StoryListFolder from './StoryListFolder.vue'
5
+ import StoryListItem from './StoryListItem.vue'
6
6
 
7
7
  defineProps<{
8
8
  tree: Tree
@@ -1,9 +1,9 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Story, TreeFolder, TreeLeaf } from '../../types'
3
- import StoryListItem from './StoryListItem.vue'
4
3
  import { Icon } from '@iconify/vue'
5
4
  import { computed, withDefaults } from 'vue'
6
5
  import { useFolderStore } from '../../stores/folder'
6
+ import StoryListItem from './StoryListItem.vue'
7
7
 
8
8
  const props = withDefaults(defineProps<{
9
9
  path?: Array<string>
@@ -20,12 +20,12 @@ const folderStore = useFolderStore()
20
20
  const folderPath = computed(() => [...props.path, props.folder.title])
21
21
  const isFolderOpen = computed(() => folderStore.isFolderOpened(folderPath.value))
22
22
 
23
- function toggleOpen () {
23
+ function toggleOpen() {
24
24
  folderStore.toggleFolder(folderPath.value)
25
25
  }
26
26
 
27
27
  const folderPadding = computed(() => {
28
- return (props.depth * 12) + 'px'
28
+ return `${props.depth * 12}px`
29
29
  })
30
30
  </script>
31
31
 
@@ -1,10 +1,10 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Story } from '../../types'
3
- import BaseListItemLink from '../base/BaseListItemLink.vue'
4
3
  import { Icon } from '@iconify/vue'
5
4
  import { computed, ref, withDefaults } from 'vue'
6
5
  import { useRoute } from 'vue-router'
7
6
  import { useScrollOnActive } from '../../util/scroll'
7
+ import BaseListItemLink from '../base/BaseListItemLink.vue'
8
8
 
9
9
  const props = withDefaults(defineProps<{
10
10
  story: Story
@@ -14,7 +14,7 @@ const props = withDefaults(defineProps<{
14
14
  })
15
15
 
16
16
  const filePadding = computed(() => {
17
- return (props.depth * 12) + 'px'
17
+ return `${props.depth * 12}px`
18
18
  })
19
19
 
20
20
  const route = useRoute()
package/src/app/index.ts CHANGED
@@ -1,12 +1,12 @@
1
- import 'virtual:$histoire-theme'
2
- import { createApp } from 'vue'
3
- import { createPinia } from 'pinia'
4
1
  import FloatingVue from 'floating-vue'
2
+ import { createPinia } from 'pinia'
3
+ import { createApp } from 'vue'
5
4
  import App from './App.vue'
6
- import { router } from './router'
7
5
  import { setupPluginApi } from './plugin.js'
6
+ import { router } from './router'
7
+ import 'virtual:$histoire-theme'
8
8
 
9
- export async function mountMainApp () {
9
+ export async function mountMainApp() {
10
10
  const app = createApp(App)
11
11
  app.use(createPinia())
12
12
  app.use(FloatingVue, {
@@ -28,7 +28,6 @@ export async function mountMainApp () {
28
28
  if (import.meta.hot) {
29
29
  import.meta.hot.send('histoire:mount', {})
30
30
 
31
- // eslint-disable-next-line spaced-comment
32
- /*#__PURE__*/ setupPluginApi()
31
+ /* #__PURE__ */ setupPluginApi()
33
32
  }
34
33
  }
package/src/app/plugin.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { router } from './router.js'
2
2
 
3
- export function setupPluginApi () {
3
+ export function setupPluginApi() {
4
4
  if (!import.meta.hot) return
5
5
 
6
6
  const listeners: Record<string, Set<(result: any) => unknown>> = {}
@@ -14,7 +14,7 @@ export function setupPluginApi () {
14
14
  }
15
15
  })
16
16
 
17
- function addDevEventListener (event: string, listener: (result: any) => unknown) {
17
+ function addDevEventListener(event: string, listener: (result: any) => unknown) {
18
18
  let set = listeners[event]
19
19
  if (!set) {
20
20
  set = new Set()
@@ -42,7 +42,8 @@ export function setupPluginApi () {
42
42
  })
43
43
  if (event.startsWith('on')) {
44
44
  resolve(undefined)
45
- } else {
45
+ }
46
+ else {
46
47
  const off = addDevEventListener(event, (result: any) => {
47
48
  off()
48
49
  resolve(result)
package/src/app/router.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
1
+ import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
2
2
  import { histoireConfig } from './util/config'
3
3
 
4
4
  export const base = import.meta.env.BASE_URL as string
5
5
 
6
- function createRouterHistory () {
6
+ function createRouterHistory() {
7
7
  switch (histoireConfig.routerMode) {
8
8
  case 'hash': return createWebHashHistory(base)
9
9
  case 'history':
@@ -1,18 +1,18 @@
1
- import { parseQuery } from 'vue-router'
2
- import { computed, createApp, h, onMounted, ref, watch } from 'vue'
3
- import { createPinia } from 'pinia'
1
+ import type { StoryFile } from './types'
4
2
  import { applyState } from '@histoire/shared'
3
+ import { createPinia } from 'pinia'
4
+ import { files } from 'virtual:$histoire-stories'
5
+ import { computed, createApp, h, onMounted, ref, watch } from 'vue'
6
+ import { parseQuery } from 'vue-router'
5
7
  import GenericMountStory from './components/story/GenericMountStory.vue'
6
8
  import GenericRenderStory from './components/story/GenericRenderStory.vue'
7
- import type { StoryFile } from './types'
9
+ import { setupPluginApi } from './plugin.js'
10
+ import { histoireConfig } from './util/config.js'
11
+ import { PREVIEW_SETTINGS_SYNC, SANDBOX_READY, STATE_SYNC } from './util/const.js'
12
+ import { isDark } from './util/dark.js'
8
13
  import { mapFile } from './util/mapping'
9
- import { files } from 'virtual:$histoire-stories'
10
- import { PREVIEW_SETTINGS_SYNC, STATE_SYNC, SANDBOX_READY } from './util/const.js'
11
14
  import { applyPreviewSettings } from './util/preview-settings.js'
12
- import { isDark } from './util/dark.js'
13
- import { histoireConfig } from './util/config.js'
14
15
  import { toRawDeep } from './util/state.js'
15
- import { setupPluginApi } from './plugin.js'
16
16
 
17
17
  const query = parseQuery(window.location.search)
18
18
  const file = ref<StoryFile>(mapFile(files.find(f => f.id === query.storyId)))
@@ -20,25 +20,26 @@ const file = ref<StoryFile>(mapFile(files.find(f => f.id === query.storyId)))
20
20
  const app = createApp({
21
21
  name: 'SandboxApp',
22
22
 
23
- setup () {
23
+ setup() {
24
24
  const story = computed(() => file.value.story)
25
25
  const variant = computed(() => story.value?.variants.find(v => v.id === query.variantId))
26
26
 
27
27
  let synced = false
28
28
  let mounted = false
29
29
 
30
- window.addEventListener('message', event => {
30
+ window.addEventListener('message', (event) => {
31
31
  // console.log('[sandbox] received message', event.data)
32
32
  if (event.data?.type === STATE_SYNC) {
33
33
  if (!mounted) return
34
34
  synced = true
35
35
  applyState(variant.value.state, event.data.state)
36
- } else if (event.data?.type === PREVIEW_SETTINGS_SYNC) {
36
+ }
37
+ else if (event.data?.type === PREVIEW_SETTINGS_SYNC) {
37
38
  applyPreviewSettings(event.data.settings)
38
39
  }
39
40
  })
40
41
 
41
- watch(() => variant.value.state, value => {
42
+ watch(() => variant.value.state, (value) => {
42
43
  if (synced && mounted) {
43
44
  synced = false
44
45
  return
@@ -61,7 +62,7 @@ const app = createApp({
61
62
  }
62
63
  },
63
64
 
64
- render () {
65
+ render() {
65
66
  return [
66
67
  h('div', { class: 'htw-sandbox-hidden' }, [
67
68
  h(GenericMountStory, {
@@ -70,15 +71,11 @@ const app = createApp({
70
71
  }),
71
72
  ]),
72
73
  this.story && this.variant
73
- ? h(GenericRenderStory, {
74
- story: this.story,
75
- variant: this.variant,
76
- onReady: () => {
77
- window.parent?.postMessage({
78
- type: SANDBOX_READY,
79
- })
80
- },
81
- })
74
+ ? h(GenericRenderStory, { story: this.story, variant: this.variant, onReady: () => {
75
+ window.parent?.postMessage({
76
+ type: SANDBOX_READY,
77
+ })
78
+ } })
82
79
  : null,
83
80
  ]
84
81
  },
@@ -86,11 +83,12 @@ const app = createApp({
86
83
  app.use(createPinia())
87
84
  app.mount('#app')
88
85
 
89
- watch(isDark, value => {
86
+ watch(isDark, (value) => {
90
87
  if (value) {
91
88
  document.documentElement.classList.add(histoireConfig.sandboxDarkClass) // @TODO remove
92
89
  document.documentElement.classList.add(histoireConfig.theme.darkClass)
93
- } else {
90
+ }
91
+ else {
94
92
  document.documentElement.classList.remove(histoireConfig.sandboxDarkClass) // @TODO remove
95
93
  document.documentElement.classList.remove(histoireConfig.theme.darkClass)
96
94
  }
@@ -99,6 +97,5 @@ watch(isDark, value => {
99
97
  })
100
98
 
101
99
  if (import.meta.hot) {
102
- // eslint-disable-next-line spaced-comment
103
- /*#__PURE__*/ setupPluginApi()
100
+ /* #__PURE__ */ setupPluginApi()
104
101
  }
@@ -1,4 +1,4 @@
1
- import { ClientCommand } from '@histoire/shared'
1
+ import type { ClientCommand } from '@histoire/shared'
2
2
  import { defineStore } from 'pinia'
3
3
  import { ref } from 'vue'
4
4
  import { executeCommand, getCommandContext } from '../util/commands.js'
@@ -7,11 +7,12 @@ export const useCommandStore = defineStore('command', () => {
7
7
  const selectedCommand = ref<ClientCommand | null>(null)
8
8
  const showPromptsModal = ref(false)
9
9
 
10
- function activateCommand (command: ClientCommand) {
10
+ function activateCommand(command: ClientCommand) {
11
11
  selectedCommand.value = command
12
12
  if (command.prompts?.length) {
13
13
  showPromptsModal.value = true
14
- } else {
14
+ }
15
+ else {
15
16
  const params = command.getParams?.(getCommandContext()) ?? {}
16
17
  executeCommand(command, params)
17
18
  }
@@ -1,8 +1,8 @@
1
1
  import { defineStore } from 'pinia'
2
- import { ref, reactive, watch } from 'vue'
2
+ import { reactive, ref, watch } from 'vue'
3
3
  import { useStoryStore } from './story.js'
4
4
 
5
- export type HstEvent = {
5
+ export interface HstEvent {
6
6
  name: string
7
7
  argument: unknown
8
8
  }
@@ -13,12 +13,12 @@ export const useEventsStore = defineStore('events', () => {
13
13
  const events = reactive<Array<HstEvent>>([])
14
14
  const unseen = ref(0)
15
15
 
16
- function addEvent (event: HstEvent) {
16
+ function addEvent(event: HstEvent) {
17
17
  events.push(event)
18
18
  unseen.value++
19
19
  }
20
20
 
21
- function reset () {
21
+ function reset() {
22
22
  events.length = 0
23
23
  unseen.value = 0
24
24
  }
@@ -1,6 +1,6 @@
1
+ import { useStorage } from '@vueuse/core'
1
2
  import { defineStore } from 'pinia'
2
3
  import { watch } from 'vue'
3
- import { useStorage } from '@vueuse/core'
4
4
  import { useStoryStore } from './story'
5
5
 
6
6
  export const useFolderStore = defineStore('folder', () => {
@@ -9,30 +9,32 @@ export const useFolderStore = defineStore('folder', () => {
9
9
  new Map(),
10
10
  )
11
11
 
12
- function getStringPath (path: Array<string>) {
12
+ function getStringPath(path: Array<string>) {
13
13
  return path.join('␜')
14
14
  }
15
15
 
16
- function toggleFolder (path: Array<string>, defaultToggleValue = true) {
16
+ function toggleFolder(path: Array<string>, defaultToggleValue = true) {
17
17
  const stringPath = getStringPath(path)
18
18
 
19
19
  const currentValue = openedFolders.value.get(stringPath)
20
20
 
21
21
  if (currentValue == null) {
22
22
  setFolderOpen(stringPath, defaultToggleValue)
23
- } else if (currentValue) {
23
+ }
24
+ else if (currentValue) {
24
25
  setFolderOpen(stringPath, false)
25
- } else {
26
+ }
27
+ else {
26
28
  setFolderOpen(stringPath, true)
27
29
  }
28
30
  }
29
31
 
30
- function setFolderOpen (path: Array<string> | string, value: boolean) {
32
+ function setFolderOpen(path: Array<string> | string, value: boolean) {
31
33
  const stringPath = typeof path === 'string' ? path : getStringPath(path)
32
34
  openedFolders.value.set(stringPath, value)
33
35
  }
34
36
 
35
- function isFolderOpened (path: Array<string>, defaultValue = false) {
37
+ function isFolderOpened(path: Array<string>, defaultValue = false) {
36
38
  const value = openedFolders.value.get(getStringPath(path))
37
39
  if (value == null) {
38
40
  return defaultValue
@@ -40,7 +42,7 @@ export const useFolderStore = defineStore('folder', () => {
40
42
  return value
41
43
  }
42
44
 
43
- function openFileFolders (path: Array<string>) {
45
+ function openFileFolders(path: Array<string>) {
44
46
  for (let pathLength = 1; pathLength < path.length; pathLength++) {
45
47
  setFolderOpen(path.slice(0, pathLength), true)
46
48
  }
@@ -1,6 +1,6 @@
1
- import { defineStore } from 'pinia'
2
- import { useStorage } from '@vueuse/core'
3
1
  import type { PreviewSettings } from '../types'
2
+ import { useStorage } from '@vueuse/core'
3
+ import { defineStore } from 'pinia'
4
4
 
5
5
  export const usePreviewSettingsStore = defineStore('preview-settings', () => {
6
6
  const currentSettings = useStorage<PreviewSettings>('_histoire-sandbox-settings-v3', {
@@ -1,11 +1,11 @@
1
+ import type { Story, Variant } from '../types'
1
2
  import { defineStore } from 'pinia'
2
3
  import { computed, ref } from 'vue'
3
4
  import { router } from '../router'
4
- import { Story, Variant } from '../types'
5
5
 
6
6
  export const useStoryStore = defineStore('story', () => {
7
7
  const stories = ref<Story[]>([])
8
- function setStories (value: Story[]) {
8
+ function setStories(value: Story[]) {
9
9
  stories.value = value
10
10
  }
11
11
 
@@ -28,11 +28,11 @@ export const useStoryStore = defineStore('story', () => {
28
28
  }
29
29
  })
30
30
 
31
- function getStoryById (id: string) {
31
+ function getStoryById(id: string) {
32
32
  return maps.value.stories.get(id)
33
33
  }
34
34
 
35
- function getVariantById (idWithStoryId: string) {
35
+ function getVariantById(idWithStoryId: string) {
36
36
  return maps.value.variants.get(idWithStoryId)
37
37
  }
38
38
 
@@ -1,6 +1,6 @@
1
1
  @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Display&display=swap');
2
2
  @import 'floating-vue/dist/style.css';
3
- @import '@histoire/controls/dist/style.css';
3
+ @import '@histoire/controls/dist/index.es.css';
4
4
 
5
5
  @import 'floating.pcss';
6
6
  @import 'transitions.pcss';
@@ -1,4 +1,4 @@
1
- @import '@histoire/controls/dist/style.css';
1
+ @import '@histoire/controls/dist/index.es.css';
2
2
 
3
3
  html,
4
4
  body {
package/src/app/types.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import type { RouteLocationRaw } from 'vue-router'
2
2
 
3
3
  export type {
4
+ Story,
4
5
  StoryFile,
5
6
  StoryLayout,
6
- Story,
7
7
  Variant,
8
8
  } from '@histoire/shared'
9
9
 
10
- export type TreeLeaf = {
10
+ export interface TreeLeaf {
11
11
  title: string
12
12
  index: number
13
13
  }
14
14
 
15
- export type TreeFolder = {
15
+ export interface TreeFolder {
16
16
  title: string
17
17
  children: (TreeFolder | TreeLeaf)[]
18
18
  }
@@ -1,7 +1,7 @@
1
1
  import type { ClientCommand, ClientCommandContext } from '@histoire/shared'
2
2
  import { router } from '../router.js'
3
- import { openInEditor } from './open-in-editor.js'
4
3
  import { useStoryStore } from '../stores/story.js'
4
+ import { openInEditor } from './open-in-editor.js'
5
5
 
6
6
  export const builtinCommands: ClientCommand[] = [
7
7
  {
@@ -14,7 +14,8 @@ export const builtinCommands: ClientCommand[] = [
14
14
  let file: string
15
15
  if (story.docsOnly) {
16
16
  file = story.file?.docsFilePath ?? story.file?.filePath
17
- } else {
17
+ }
18
+ else {
18
19
  file = story.file?.filePath
19
20
  }
20
21
  return {
@@ -35,7 +36,7 @@ export const builtinCommands: ClientCommand[] = [
35
36
  },
36
37
  ]
37
38
 
38
- export function executeCommand (command: ClientCommand, params: Record<string, any>) {
39
+ export function executeCommand(command: ClientCommand, params: Record<string, any>) {
39
40
  if (import.meta.hot) {
40
41
  import.meta.hot.send('histoire:dev-command', {
41
42
  id: command.id,
@@ -46,7 +47,7 @@ export function executeCommand (command: ClientCommand, params: Record<string, a
46
47
  }
47
48
  }
48
49
 
49
- export function getCommandContext (): ClientCommandContext {
50
+ export function getCommandContext(): ClientCommandContext {
50
51
  const storyStore = useStoryStore()
51
52
  return {
52
53
  route: router.currentRoute.value,