@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,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { SelectPrompt, SelectPromptOption } from '@histoire/shared'
3
- import { computed, ref, watchEffect } from 'vue'
4
3
  import { Icon } from '@iconify/vue'
4
+ import { computed, ref, watchEffect } from 'vue'
5
5
  import { useSelection } from '../../util/select.js'
6
6
  import BaseKeyboardShortcut from '../base/BaseKeyboardShortcut.vue'
7
7
 
@@ -26,7 +26,7 @@ const model = computed({
26
26
 
27
27
  const input = ref<HTMLInputElement>()
28
28
 
29
- function focus () {
29
+ function focus() {
30
30
  input.value?.focus()
31
31
  input.value?.select()
32
32
  }
@@ -47,7 +47,8 @@ watchEffect(async () => {
47
47
  if (rId === requestId) {
48
48
  options.value = result
49
49
  }
50
- } else {
50
+ }
51
+ else {
51
52
  options.value = props.prompt.options
52
53
  }
53
54
  })
@@ -59,7 +60,8 @@ const formattedOptions = computed(() => {
59
60
  value: option,
60
61
  label: option,
61
62
  }
62
- } else {
63
+ }
64
+ else {
63
65
  return option
64
66
  }
65
67
  })
@@ -73,7 +75,7 @@ const {
73
75
  selectPrevious,
74
76
  } = useSelection(formattedOptions)
75
77
 
76
- function selectIndex (index: number) {
78
+ function selectIndex(index: number) {
77
79
  const result = formattedOptions.value[index].value
78
80
  if (result) {
79
81
  model.value = result
@@ -14,12 +14,12 @@ const emit = defineEmits<{
14
14
 
15
15
  const model = computed({
16
16
  get: () => props.modelValue,
17
- set: (value) => emit('update:modelValue', value),
17
+ set: value => emit('update:modelValue', value),
18
18
  })
19
19
 
20
20
  const input = ref<HTMLInputElement>()
21
21
 
22
- function focus () {
22
+ function focus() {
23
23
  input.value?.focus()
24
24
  input.value?.select()
25
25
  }
@@ -33,7 +33,8 @@ defineExpose({
33
33
  const defaultValue = computed(() => {
34
34
  if (typeof props.prompt.defaultValue === 'function') {
35
35
  return props.prompt.defaultValue(props.answers)
36
- } else {
36
+ }
37
+ else {
37
38
  return props.prompt.defaultValue
38
39
  }
39
40
  })
@@ -1,9 +1,9 @@
1
1
  <script lang="ts" setup>
2
- import { computed } from 'vue'
3
- import { Icon } from '@iconify/vue'
4
2
  import type { AutoPropComponentDefinition, PropDefinition } from '@histoire/shared'
5
- import { HstCheckbox, HstJson, HstNumber, HstText } from '@histoire/controls'
6
3
  import type { Variant } from '../../types'
4
+ import { HstCheckbox, HstJson, HstNumber, HstText } from '@histoire/controls'
5
+ import { Icon } from '@iconify/vue'
6
+ import { computed } from 'vue'
7
7
 
8
8
  const props = defineProps<{
9
9
  variant: Variant
@@ -39,7 +39,7 @@ const model = computed({
39
39
  },
40
40
  })
41
41
 
42
- function reset () {
42
+ function reset() {
43
43
  if (props.variant.state._hPropState[props.component.index]) {
44
44
  // eslint-disable-next-line vue/no-mutating-props
45
45
  delete props.variant.state._hPropState[props.component.index][props.definition.name]
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
- import { computed } from 'vue'
3
- import { Icon } from '@iconify/vue'
4
2
  import type { Variant } from '@histoire/shared'
3
+ import { Icon } from '@iconify/vue'
4
+ import { computed } from 'vue'
5
5
  import ControlsComponentStateItem from './ControlsComponentStateItem.vue'
6
6
 
7
7
  const props = defineProps<{
@@ -9,7 +9,7 @@ const props = defineProps<{
9
9
  }>()
10
10
 
11
11
  const stateKeys = computed(() => Object.keys(props.variant.state || {})
12
- .filter((key) => !key.startsWith('_h')))
12
+ .filter(key => !key.startsWith('_h')))
13
13
  </script>
14
14
 
15
15
  <template>
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
- import { computed } from 'vue'
3
- import { HstCheckbox, HstJson, HstNumber, HstText } from '@histoire/controls'
4
2
  import type { Variant } from '../../types'
3
+ import { HstCheckbox, HstJson, HstNumber, HstText } from '@histoire/controls'
4
+ import { computed } from 'vue'
5
5
 
6
6
  const props = defineProps<{
7
7
  variant: Variant
@@ -1,12 +1,12 @@
1
1
  <script lang="ts" setup>
2
+ import type { Story, Variant } from '../../types'
2
3
  import { computed, toRefs } from 'vue'
3
- import BaseTab from '../base/BaseTab.vue'
4
4
  import { useEventsStore } from '../../stores/events'
5
- import type { Story, Variant } from '../../types'
6
5
  import BaseOverflowMenu from '../base/BaseOverflowMenu.vue'
7
6
  import BaseOverflowTab from '../base/BaseOverflowTab.vue'
8
- import { useStoryDoc } from './StoryDocs.vue'
7
+ import BaseTab from '../base/BaseTab.vue'
9
8
  import BaseTag from '../base/BaseTag.vue'
9
+ import { useStoryDoc } from './StoryDocs.vue'
10
10
 
11
11
  const props = defineProps<{
12
12
  story: Story
@@ -1,11 +1,11 @@
1
1
  <script lang="ts" setup>
2
- import { ref, computed, nextTick, onMounted } from 'vue'
3
- import { Icon } from '@iconify/vue'
4
- import { useStorage, onClickOutside, useTimeoutFn } from '@vueuse/core'
2
+ import type { Story, Variant } from '../../types'
5
3
  import { applyState, clone, omit } from '@histoire/shared'
6
- import BaseSelect from '../base/BaseSelect.vue'
4
+ import { Icon } from '@iconify/vue'
5
+ import { onClickOutside, useStorage, useTimeoutFn } from '@vueuse/core'
6
+ import { computed, nextTick, onMounted, ref } from 'vue'
7
7
  import { toRawDeep } from '../../util/state'
8
- import type { Story, Variant } from '../../types'
8
+ import BaseSelect from '../base/BaseSelect.vue'
9
9
 
10
10
  const DEFAULT_ID = 'default'
11
11
 
@@ -38,15 +38,16 @@ const presetsOptions = computed(() => {
38
38
  return options
39
39
  })
40
40
 
41
- function resetState () {
41
+ function resetState() {
42
42
  selectedOption.value = DEFAULT_ID
43
43
  applyState(props.variant.state, clone(defaultState))
44
44
  }
45
45
 
46
- function applyPreset (id) {
46
+ function applyPreset(id) {
47
47
  if (id === DEFAULT_ID) {
48
48
  resetState()
49
- } else if (presetStates.value.has(id)) {
49
+ }
50
+ else if (presetStates.value.has(id)) {
50
51
  applyState(props.variant.state, clone(toRawDeep(presetStates.value.get(id).state)))
51
52
  }
52
53
  }
@@ -62,7 +63,7 @@ const select = ref<HTMLInputElement>()
62
63
  const canEdit = computed(() => selectedOption.value !== DEFAULT_ID)
63
64
  const isEditing = ref(false)
64
65
 
65
- async function createPreset () {
66
+ async function createPreset() {
66
67
  const id = (new Date()).getTime().toString()
67
68
 
68
69
  presetStates.value.set(id, { state: clone(omit(toRawDeep(props.variant.state), omitKeys)), label: 'New preset' })
@@ -77,7 +78,7 @@ const savedTimeout = useTimeoutFn(() => {
77
78
  savedNotif.value = false
78
79
  }, 1000)
79
80
 
80
- async function savePreset () {
81
+ async function savePreset() {
81
82
  if (!canEdit.value) return
82
83
 
83
84
  const preset = presetStates.value.get(selectedOption.value)
@@ -86,7 +87,9 @@ async function savePreset () {
86
87
  savedTimeout.start()
87
88
  }
88
89
 
89
- function deletePreset (id) {
90
+ function deletePreset(id) {
91
+ // @TODO custom confirm modal UI
92
+ // eslint-disable-next-line no-alert
90
93
  if (!confirm('Are you sure you want to delete this preset?')) {
91
94
  return
92
95
  }
@@ -97,7 +100,7 @@ function deletePreset (id) {
97
100
  presetStates.value.delete(id)
98
101
  }
99
102
 
100
- async function startEditing () {
103
+ async function startEditing() {
101
104
  if (!canEdit.value) {
102
105
  return
103
106
  }
@@ -107,7 +110,7 @@ async function startEditing () {
107
110
  input.value.select()
108
111
  }
109
112
 
110
- function stopEditing () {
113
+ function stopEditing() {
111
114
  isEditing.value = false
112
115
  }
113
116
 
@@ -1,12 +1,13 @@
1
1
  <script lang="ts" setup>
2
- import { computed, PropType, ref, watch } from 'vue'
3
- import { Icon } from '@iconify/vue'
4
- import GenericRenderStory from '../story/GenericRenderStory.vue'
2
+ import type { PropType } from 'vue'
5
3
  import type { Story, Variant } from '../../types'
4
+ import { Icon } from '@iconify/vue'
5
+ import { computed, ref, watch } from 'vue'
6
6
  import BaseEmpty from '../base/BaseEmpty.vue'
7
- import StatePresets from './StatePresets.vue'
7
+ import GenericRenderStory from '../story/GenericRenderStory.vue'
8
8
  import ControlsComponentProps from './ControlsComponentProps.vue'
9
9
  import ControlsComponentState from './ControlsComponentState.vue'
10
+ import StatePresets from './StatePresets.vue'
10
11
 
11
12
  const props = defineProps({
12
13
  variant: {
@@ -33,7 +34,6 @@ const hasInitState = computed(() => Object
33
34
  .entries(props.variant.state || {})
34
35
  .filter(([key]) => !key.startsWith('_h'))
35
36
  .length > 0)
36
-
37
37
  </script>
38
38
 
39
39
  <template>
@@ -1,16 +1,20 @@
1
1
  <script lang="ts">
2
- import { nextTick, PropType, Ref, ref, toRefs, watch, watchEffect, computed } from 'vue'
2
+ import type { PropType, Ref } from 'vue'
3
3
  import type { Story } from '../../types'
4
+ import { Icon } from '@iconify/vue'
4
5
  import { markdownFiles } from 'virtual:$histoire-markdown-files'
6
+ import { computed, nextTick, ref, toRefs, watch, watchEffect } from 'vue'
7
+ import { useRoute, useRouter } from 'vue-router'
5
8
  import { histoireConfig } from '../../util/config.js'
9
+ import BaseEmpty from '../base/BaseEmpty.vue'
6
10
  import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
7
11
 
8
- export function useStoryDoc (story: Ref<Story>) {
12
+ export function useStoryDoc(story: Ref<Story>) {
9
13
  const renderedDoc = ref('')
10
14
 
11
15
  watchEffect(async () => {
12
16
  // Markdown file
13
- const mdKey = story.value.file.filePath.replace(/\.(\w*?)$/, '.md')
17
+ const mdKey = story.value.file.filePath.replace(/\.(\w*)$/, '.md')
14
18
  if (markdownFiles[mdKey]) {
15
19
  const md = await markdownFiles[mdKey]()
16
20
  renderedDoc.value = md.html
@@ -23,12 +27,15 @@ export function useStoryDoc (story: Ref<Story>) {
23
27
  if (comp) {
24
28
  if (comp.__asyncResolved) {
25
29
  comp = comp.__asyncResolved
26
- } else if (comp.__asyncLoader) {
30
+ }
31
+ else if (comp.__asyncLoader) {
27
32
  comp = await comp.__asyncLoader()
28
- } else if (typeof comp === 'function') {
33
+ }
34
+ else if (typeof comp === 'function') {
29
35
  try {
30
36
  comp = await comp()
31
- } catch (e) {
37
+ }
38
+ catch (e) {
32
39
  // Noop
33
40
  // Could be a class that requires `new com()`
34
41
  }
@@ -47,10 +54,6 @@ export function useStoryDoc (story: Ref<Story>) {
47
54
  </script>
48
55
 
49
56
  <script lang="ts" setup>
50
- import { Icon } from '@iconify/vue'
51
- import { useRoute, useRouter } from 'vue-router'
52
- import BaseEmpty from '../base/BaseEmpty.vue'
53
-
54
57
  const props = defineProps({
55
58
  story: {
56
59
  type: Object as PropType<Story>,
@@ -64,7 +67,7 @@ const props = defineProps({
64
67
  })
65
68
 
66
69
  const emit = defineEmits<{
67
- (e: 'scroll-top'): void
70
+ (e: 'scrollTop'): void
68
71
  }>()
69
72
 
70
73
  const { story } = toRefs(props)
@@ -78,16 +81,16 @@ const router = useRouter()
78
81
  // matter and is only passed to support same-host hrefs.
79
82
  const fakeHost = `http://a.com`
80
83
 
81
- function onClick (e: MouseEvent) {
84
+ function onClick(e: MouseEvent) {
82
85
  const link = (e.target as Element).closest('a')
83
86
  if (
84
- link &&
85
- link.getAttribute('data-route') &&
86
- !e.ctrlKey &&
87
- !e.shiftKey &&
88
- !e.altKey &&
89
- !e.metaKey &&
90
- link.target !== `_blank`
87
+ link
88
+ && link.getAttribute('data-route')
89
+ && !e.ctrlKey
90
+ && !e.shiftKey
91
+ && !e.altKey
92
+ && !e.metaKey
93
+ && link.target !== `_blank`
91
94
  ) {
92
95
  e.preventDefault()
93
96
  const url = new URL(link.href, fakeHost)
@@ -98,20 +101,21 @@ function onClick (e: MouseEvent) {
98
101
 
99
102
  // Handle URL anchor
100
103
 
101
- function getHash () {
104
+ function getHash() {
102
105
  const hash = location.hash
103
106
  if (histoireConfig.routerMode === 'hash') {
104
107
  const index = hash.indexOf('#', 1)
105
108
  if (index !== -1) {
106
109
  return hash.slice(index)
107
- } else {
110
+ }
111
+ else {
108
112
  return undefined
109
113
  }
110
114
  }
111
115
  return hash
112
116
  }
113
117
 
114
- async function scrollToAnchor () {
118
+ async function scrollToAnchor() {
115
119
  await nextTick()
116
120
  const hash = getHash()
117
121
  if (hash) {
@@ -121,7 +125,7 @@ async function scrollToAnchor () {
121
125
  return
122
126
  }
123
127
  }
124
- emit('scroll-top')
128
+ emit('scrollTop')
125
129
  }
126
130
 
127
131
  watch(renderedDoc, () => {
@@ -135,7 +139,7 @@ watch(renderedDoc, () => {
135
139
  const renderedEl = ref<HTMLElement>()
136
140
  const route = useRoute()
137
141
 
138
- async function patchAnchorLinks () {
142
+ async function patchAnchorLinks() {
139
143
  await nextTick()
140
144
  if (histoireConfig.routerMode === 'hash' && renderedEl.value) {
141
145
  const links = renderedEl.value.querySelectorAll('a.header-anchor')
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
+ import type { HstEvent } from '../../stores/events'
2
3
  import { computed } from 'vue'
3
- import { HstEvent } from '../../stores/events'
4
4
 
5
5
  const props = defineProps<{
6
6
  event: HstEvent
@@ -11,7 +11,7 @@ const formattedArgument = computed(() => {
11
11
  case 'string':
12
12
  return `"${props.event.argument}"`
13
13
  case 'object':
14
- return `{ ${Object.keys(props.event.argument).map((key) => `${key}: ${props.event.argument[key]}`).join(', ')} }`
14
+ return `{ ${Object.keys(props.event.argument).map(key => `${key}: ${props.event.argument[key]}`).join(', ')} }`
15
15
  default:
16
16
  return props.event.argument
17
17
  }
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" setup>
2
- import { ref, computed, watch, onMounted, nextTick } from 'vue'
3
2
  import { Icon } from '@iconify/vue'
4
- import BaseEmpty from '../base/BaseEmpty.vue'
3
+ import { computed, nextTick, onMounted, ref, watch } from 'vue'
5
4
  import { useEventsStore } from '../../stores/events'
5
+ import BaseEmpty from '../base/BaseEmpty.vue'
6
6
  import StoryEvent from './StoryEvent.vue'
7
7
 
8
8
  const eventsStore = useEventsStore()
@@ -12,7 +12,7 @@ const hasEvents = computed(() => eventsStore.events.length)
12
12
  onMounted(resetUnseen)
13
13
  watch(() => eventsStore.unseen, resetUnseen)
14
14
 
15
- async function resetUnseen () {
15
+ async function resetUnseen() {
16
16
  if (eventsStore.unseen > 0) {
17
17
  eventsStore.unseen = 0
18
18
  }
@@ -3,13 +3,13 @@ import { computed } from 'vue'
3
3
  import { useRoute } from 'vue-router'
4
4
  import { useStoryStore } from '../../stores/story'
5
5
 
6
- import BaseSplitPane from '../base/BaseSplitPane.vue'
7
6
  import BaseEmpty from '../base/BaseEmpty.vue'
7
+ import BaseSplitPane from '../base/BaseSplitPane.vue'
8
+ import PaneTabs from './PaneTabs.vue'
8
9
  import StoryControls from './StoryControls.vue'
9
10
  import StoryDocs from './StoryDocs.vue'
10
11
  import StoryEvents from './StoryEvents.vue'
11
12
  import StorySourceCode from './StorySourceCode.vue'
12
- import PaneTabs from './PaneTabs.vue'
13
13
 
14
14
  const storyStore = useStoryStore()
15
15
 
@@ -1,11 +1,12 @@
1
1
  <script lang="ts" setup>
2
- import { computed, markRaw, nextTick, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'
3
- import { Icon } from '@iconify/vue'
4
- import { getHighlighter, Highlighter } from 'shiki-es'
2
+ import type { Highlighter } from 'shiki-es'
3
+ import type { Story, Variant } from '../../types'
5
4
  import { HstCopyIcon } from '@histoire/controls'
6
5
  import { unindent } from '@histoire/shared'
6
+ import { Icon } from '@iconify/vue'
7
+ import { getHighlighter } from 'shiki-es'
7
8
  import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
8
- import type { Variant, Story } from '../../types'
9
+ import { computed, markRaw, nextTick, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'
9
10
  import { isDark } from '../../util/dark'
10
11
  import BaseEmpty from '../base/BaseEmpty.vue'
11
12
 
@@ -36,15 +37,18 @@ watch(() => [props.variant, generateSourceCodeFn.value], async () => {
36
37
  try {
37
38
  if (props.variant.source) {
38
39
  dynamicSourceCode.value = props.variant.source
39
- } else if (props.variant.slots?.().source) {
40
+ }
41
+ else if (props.variant.slots?.().source) {
40
42
  const source = props.variant.slots?.().source()[0].children
41
43
  if (source) {
42
44
  dynamicSourceCode.value = await unindent(source)
43
45
  }
44
- } else {
46
+ }
47
+ else {
45
48
  dynamicSourceCode.value = await generateSourceCodeFn.value(props.variant)
46
49
  }
47
- } catch (e) {
50
+ }
51
+ catch (e) {
48
52
  console.error(e)
49
53
  error.value = e.message
50
54
  }
@@ -113,7 +117,7 @@ watch(() => props.variant, () => {
113
117
 
114
118
  const scroller = ref<HTMLElement>()
115
119
 
116
- function onScroll (event) {
120
+ function onScroll(event) {
117
121
  if (sourceHtml.value) {
118
122
  lastScroll = event.target.scrollTop
119
123
  }
@@ -1,11 +1,12 @@
1
1
  <script lang="ts" setup>
2
- import { PropType, ref, toRefs } from 'vue'
2
+ import type { PropType } from 'vue'
3
+ import type { SearchResult } from '../../types'
4
+ import { ref, toRefs } from 'vue'
3
5
  import { useRouter } from 'vue-router'
4
- import { SearchResult } from '../../types'
5
6
  import { onKeyboardShortcut } from '../../util/keyboard'
6
7
  import { useScrollOnActive } from '../../util/scroll'
7
- import BaseListItemLink from '../base/BaseListItemLink.vue'
8
8
  import BaseListItem from '../base/BaseListItem.vue'
9
+ import BaseListItemLink from '../base/BaseListItemLink.vue'
9
10
  import SearchItemContent from './SearchItemContent.vue'
10
11
 
11
12
  const props = defineProps({
@@ -36,7 +37,7 @@ onKeyboardShortcut(['enter'], () => {
36
37
  action()
37
38
  })
38
39
 
39
- function action (fromClick = false) {
40
+ function action(fromClick = false) {
40
41
  if ('route' in props.result && !fromClick) {
41
42
  router.push(props.result.route)
42
43
  }
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
+ import type { SearchResult } from '../../types.js'
2
3
  import { Icon } from '@iconify/vue'
3
4
  import BaseIcon from '../base/BaseIcon.vue'
4
- import type { SearchResult } from '../../types.js'
5
5
 
6
6
  defineProps<{
7
7
  result: SearchResult
@@ -27,15 +27,15 @@ const kindLabels = {
27
27
  :class="[
28
28
  !selected ? [
29
29
  result.iconColor
30
- ?'bind-icon-color'
30
+ ? 'bind-icon-color'
31
31
  : {
32
32
  'htw-text-primary-500': result.kind === 'story',
33
33
  'htw-text-gray-500': result.kind === 'variant',
34
- }
34
+ },
35
35
  ] : [],
36
36
  {
37
37
  'colorize-black': selected,
38
- }
38
+ },
39
39
  ]"
40
40
  />
41
41
  <div class="htw-flex-1">
@@ -1,6 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import { defineAsyncComponent } from 'vue'
3
3
  import SearchLoading from './SearchLoading.vue'
4
+
4
5
  const SearchPane = defineAsyncComponent({
5
6
  loader: () => import('./SearchPane.vue'),
6
7
  loadingComponent: SearchLoading,
@@ -18,7 +19,7 @@ const emit = defineEmits({
18
19
  close: () => true,
19
20
  })
20
21
 
21
- function close () {
22
+ function close() {
22
23
  emit('close')
23
24
  }
24
25
  </script>