@histoire/app 0.17.15 → 0.17.17

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 (126) hide show
  1. package/dist/bundled/App.vue2.js +1 -1
  2. package/dist/bundled/components/app/AppHeader.vue2.js +1 -1
  3. package/dist/bundled/components/app/AppLogo.vue2.js +1 -1
  4. package/dist/bundled/components/app/Breadcrumb.vue.js +1 -1
  5. package/dist/bundled/components/app/Breadcrumb.vue2.js +3 -3
  6. package/dist/bundled/components/app/HomeCounter.vue2.js +2 -7
  7. package/dist/bundled/components/base/BaseCheckbox.vue2.js +1 -2
  8. package/dist/bundled/components/base/BaseIcon.vue.js +1 -1
  9. package/dist/bundled/components/base/BaseIcon.vue2.js +1 -1
  10. package/dist/bundled/components/base/BaseOverflowMenu.vue2.js +4 -4
  11. package/dist/bundled/components/base/BaseSplitPane.vue.js +1 -1
  12. package/dist/bundled/components/base/BaseSplitPane.vue2.js +2 -3
  13. package/dist/bundled/components/panel/PaneTabs.vue2.js +1 -1
  14. package/dist/bundled/components/panel/StoryDocs.vue2.js +4 -4
  15. package/dist/bundled/components/panel/StorySourceCode.vue.js +1 -1
  16. package/dist/bundled/components/panel/StorySourceCode.vue2.js +1 -1
  17. package/dist/bundled/components/search/SearchItem.vue.js +1 -1
  18. package/dist/bundled/components/search/SearchItem.vue2.js +2 -2
  19. package/dist/bundled/components/search/SearchPane.vue2.js +2 -2
  20. package/dist/bundled/components/story/StoryResponsivePreview.vue.js +1 -1
  21. package/dist/bundled/components/story/StoryResponsivePreview.vue2.js +8 -7
  22. package/dist/bundled/components/story/StoryVariantGrid.vue2.js +4 -4
  23. package/dist/bundled/components/story/StoryVariantGridItem.vue.js +1 -1
  24. package/dist/bundled/components/story/StoryVariantGridItem.vue2.js +6 -7
  25. package/dist/bundled/components/story/StoryVariantListItem.vue.js +1 -1
  26. package/dist/bundled/components/story/StoryVariantListItem.vue2.js +3 -3
  27. package/dist/bundled/components/story/StoryVariantSingle.vue.js +1 -1
  28. package/dist/bundled/components/story/StoryVariantSingle.vue2.js +5 -5
  29. package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue2.js +1 -1
  30. package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue2.js +1 -1
  31. package/dist/bundled/components/story/StoryView.vue2.js +1 -1
  32. package/dist/bundled/components/story/StoryViewer.vue.js +1 -1
  33. package/dist/bundled/components/story/StoryViewer.vue2.js +3 -3
  34. package/dist/bundled/components/tree/StoryGroup.vue2.js +2 -2
  35. package/dist/bundled/components/tree/StoryListFolder.vue.js +1 -1
  36. package/dist/bundled/components/tree/StoryListFolder.vue2.js +4 -4
  37. package/dist/bundled/components/tree/StoryListItem.vue.js +1 -1
  38. package/dist/bundled/components/tree/StoryListItem.vue2.js +5 -5
  39. package/dist/bundled/sandbox.js +1 -1
  40. package/dist/bundled/style.css +36 -36
  41. package/dist/bundled/util/commands.js +1 -1
  42. package/dist/bundled/util/state.js +2 -2
  43. package/dist/style.css +1 -1
  44. package/package.json +7 -7
  45. package/scripts/copy.mjs +1 -1
  46. package/scripts/watchAndCopy.mjs +4 -4
  47. package/src/app/App.vue +6 -6
  48. package/src/app/api.ts +1 -1
  49. package/src/app/components/HomeView.vue +4 -3
  50. package/src/app/components/app/AppHeader.vue +1 -1
  51. package/src/app/components/app/AppLogo.vue +3 -3
  52. package/src/app/components/app/Breadcrumb.vue +4 -4
  53. package/src/app/components/app/HomeCounter.vue +1 -10
  54. package/src/app/components/app/MobileOverlay.vue +1 -1
  55. package/src/app/components/base/BaseCheckbox.vue +2 -3
  56. package/src/app/components/base/BaseIcon.vue +2 -2
  57. package/src/app/components/base/BaseKeyboardShortcut.vue +1 -1
  58. package/src/app/components/base/BaseListItem.vue +2 -2
  59. package/src/app/components/base/BaseListItemLink.vue +3 -3
  60. package/src/app/components/base/BaseOverflowMenu.vue +4 -4
  61. package/src/app/components/base/BaseSelect.vue +5 -4
  62. package/src/app/components/base/BaseSplitPane.vue +19 -15
  63. package/src/app/components/command/CommandPrompts.vue +6 -5
  64. package/src/app/components/command/CommandPromptsModal.vue +2 -1
  65. package/src/app/components/command/PromptSelect.vue +6 -4
  66. package/src/app/components/command/PromptText.vue +4 -3
  67. package/src/app/components/panel/ControlsComponentPropItem.vue +1 -1
  68. package/src/app/components/panel/ControlsComponentProps.vue +1 -1
  69. package/src/app/components/panel/ControlsComponentState.vue +1 -1
  70. package/src/app/components/panel/PaneTabs.vue +1 -1
  71. package/src/app/components/panel/StatePresets.vue +13 -10
  72. package/src/app/components/panel/StoryControls.vue +2 -2
  73. package/src/app/components/panel/StoryDocs.vue +28 -24
  74. package/src/app/components/panel/StoryEvent.vue +2 -2
  75. package/src/app/components/panel/StoryEvents.vue +2 -2
  76. package/src/app/components/panel/StorySourceCode.vue +10 -6
  77. package/src/app/components/search/SearchItem.vue +4 -3
  78. package/src/app/components/search/SearchItemContent.vue +3 -3
  79. package/src/app/components/search/SearchModal.vue +2 -1
  80. package/src/app/components/search/SearchPane.vue +18 -18
  81. package/src/app/components/search/search-docs-data.ts +2 -2
  82. package/src/app/components/search/search-title-data.ts +2 -2
  83. package/src/app/components/story/GenericMountStory.vue +1 -1
  84. package/src/app/components/story/GenericRenderStory.vue +3 -2
  85. package/src/app/components/story/StoryResponsivePreview.vue +16 -14
  86. package/src/app/components/story/StoryVariantGrid.vue +9 -8
  87. package/src/app/components/story/StoryVariantGridItem.vue +7 -7
  88. package/src/app/components/story/StoryVariantListItem.vue +3 -2
  89. package/src/app/components/story/StoryVariantSingle.vue +3 -3
  90. package/src/app/components/story/StoryVariantSinglePreviewNative.vue +2 -2
  91. package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +10 -10
  92. package/src/app/components/story/StoryView.vue +4 -4
  93. package/src/app/components/story/StoryViewer.vue +2 -3
  94. package/src/app/components/toolbar/ToolbarNewTab.vue +1 -1
  95. package/src/app/components/tree/StoryGroup.vue +4 -4
  96. package/src/app/components/tree/StoryList.vue +1 -1
  97. package/src/app/components/tree/StoryListFolder.vue +4 -4
  98. package/src/app/components/tree/StoryListItem.vue +3 -3
  99. package/src/app/index.ts +2 -3
  100. package/src/app/plugin.ts +4 -3
  101. package/src/app/router.ts +2 -2
  102. package/src/app/sandbox.ts +12 -11
  103. package/src/app/stores/command.ts +4 -3
  104. package/src/app/stores/events.ts +4 -4
  105. package/src/app/stores/folder.ts +9 -7
  106. package/src/app/stores/story.ts +4 -4
  107. package/src/app/types.ts +2 -2
  108. package/src/app/util/commands.ts +5 -4
  109. package/src/app/util/dark.ts +2 -2
  110. package/src/app/util/docs.ts +6 -4
  111. package/src/app/util/events.ts +4 -3
  112. package/src/app/util/keyboard.ts +9 -8
  113. package/src/app/util/mapping.ts +8 -5
  114. package/src/app/util/open-in-editor.ts +1 -1
  115. package/src/app/util/preview-settings.ts +3 -3
  116. package/src/app/util/sandbox.ts +2 -3
  117. package/src/app/util/scroll.ts +5 -4
  118. package/src/app/util/select.ts +5 -4
  119. package/src/app/util/state.ts +6 -5
  120. package/src/app/util/tooltip.ts +2 -2
  121. package/src/app/util/variant.ts +3 -2
  122. package/src/shim.d.ts +0 -6
  123. package/src/virtual.d.ts +1 -0
  124. package/tailwind.config.cjs +19 -20
  125. package/tsconfig.json +26 -26
  126. package/vite.config.ts +7 -6
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { ref, computed, watch, onUnmounted } from 'vue'
2
+ import { computed, onUnmounted, ref, watch } from 'vue'
3
3
 
4
4
  const SAVE_PREFIX = '__histoire'
5
5
 
@@ -48,8 +48,7 @@ const props = defineProps({
48
48
  })
49
49
 
50
50
  const emit = defineEmits({
51
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
52
- 'update:split': (value: number) => true,
51
+ 'update:split': (_value: number) => true,
53
52
  })
54
53
 
55
54
  const currentSplit = ref(props.defaultSplit)
@@ -70,7 +69,8 @@ if (props.saveId) {
70
69
  let parsedValue
71
70
  try {
72
71
  parsedValue = JSON.parse(savedValue)
73
- } catch (e) {
72
+ }
73
+ catch (e) {
74
74
  console.error(e)
75
75
  }
76
76
 
@@ -79,11 +79,11 @@ if (props.saveId) {
79
79
  }
80
80
  }
81
81
 
82
- watch(currentSplit, value => {
82
+ watch(currentSplit, (value) => {
83
83
  localStorage.setItem(storageKey, JSON.stringify(value))
84
84
  })
85
85
 
86
- watch(currentSplit, value => {
86
+ watch(currentSplit, (value) => {
87
87
  if (value !== props.split) {
88
88
  emit('update:split', value)
89
89
  }
@@ -95,9 +95,11 @@ if (props.saveId) {
95
95
  const boundSplit = computed(() => {
96
96
  if (currentSplit.value < props.min) {
97
97
  return props.min
98
- } else if (currentSplit.value > props.max) {
98
+ }
99
+ else if (currentSplit.value > props.max) {
99
100
  return props.max
100
- } else {
101
+ }
102
+ else {
101
103
  return currentSplit.value
102
104
  }
103
105
  })
@@ -115,7 +117,7 @@ let startPosition = 0
115
117
  let startSplit = 0
116
118
  const el = ref(null)
117
119
 
118
- function dragStart (e) {
120
+ function dragStart(e) {
119
121
  dragging.value = true
120
122
  startPosition = props.orientation === 'landscape' ? e.pageX : e.pageY
121
123
  startSplit = boundSplit.value
@@ -123,32 +125,34 @@ function dragStart (e) {
123
125
  window.addEventListener('mouseup', dragEnd)
124
126
  }
125
127
 
126
- function dragMove (e) {
128
+ function dragMove(e) {
127
129
  if (dragging.value) {
128
130
  let position
129
131
  let totalSize
130
132
  if (props.orientation === 'landscape') {
131
133
  position = e.pageX
132
134
  totalSize = el.value.offsetWidth
133
- } else {
135
+ }
136
+ else {
134
137
  position = e.pageY
135
138
  totalSize = el.value.offsetHeight
136
139
  }
137
140
  const dPosition = position - startPosition
138
141
  if (props.fixed) {
139
142
  currentSplit.value = startSplit + dPosition
140
- } else {
143
+ }
144
+ else {
141
145
  currentSplit.value = startSplit + ~~(dPosition / totalSize * 200) / 2
142
146
  }
143
147
  }
144
148
  }
145
149
 
146
- function dragEnd () {
150
+ function dragEnd() {
147
151
  dragging.value = false
148
152
  removeDragListeners()
149
153
  }
150
154
 
151
- function removeDragListeners () {
155
+ function removeDragListeners() {
152
156
  window.removeEventListener('mousemove', dragMove)
153
157
  window.removeEventListener('mouseup', dragEnd)
154
158
  }
@@ -166,7 +170,7 @@ onUnmounted(() => {
166
170
  'htw-flex-col': orientation === 'portrait',
167
171
  'htw-cursor-ew-resize': dragging && orientation === 'landscape',
168
172
  'htw-cursor-ns-resize': dragging && orientation === 'portrait',
169
- [orientation]: true
173
+ [orientation]: true,
170
174
  }"
171
175
  >
172
176
  <div
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
- import { reactive, ref, nextTick, onMounted } from 'vue'
2
+ import { nextTick, onMounted, reactive, ref } from 'vue'
3
3
  import type { ClientCommand } from '@histoire/shared'
4
- import { getCommandContext, executeCommand } from '../../util/commands.js'
4
+ import { executeCommand, getCommandContext } from '../../util/commands.js'
5
5
  import BaseButton from '../base/BaseButton.vue'
6
6
  import BaseKeyboardShortcut from '../base/BaseKeyboardShortcut.vue'
7
7
  import PromptText from './PromptText.vue'
@@ -27,13 +27,14 @@ for (const prompt of props.command.prompts) {
27
27
  let defaultValue
28
28
  if (typeof prompt.defaultValue === 'function') {
29
29
  defaultValue = prompt.defaultValue(answers)
30
- } else {
30
+ }
31
+ else {
31
32
  defaultValue = prompt.defaultValue
32
33
  }
33
34
  answers[prompt.field] = defaultValue
34
35
  }
35
36
 
36
- function submit () {
37
+ function submit() {
37
38
  const params = props.command.getParams
38
39
  ? props.command.getParams({
39
40
  ...getCommandContext(),
@@ -48,7 +49,7 @@ function submit () {
48
49
 
49
50
  const promptComps = ref<any[]>([])
50
51
 
51
- function focusPrompt (index: number) {
52
+ function focusPrompt(index: number) {
52
53
  nextTick(() => {
53
54
  promptComps.value[index]?.focus?.()
54
55
  })
@@ -1,6 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import { defineAsyncComponent } from 'vue'
3
3
  import { useCommandStore } from '../../stores/command.js'
4
+
4
5
  const CommandPrompts = defineAsyncComponent(() => import('./CommandPrompts.vue'))
5
6
 
6
7
  defineProps({
@@ -14,7 +15,7 @@ const emit = defineEmits({
14
15
  close: () => true,
15
16
  })
16
17
 
17
- function close () {
18
+ function close() {
18
19
  emit('close')
19
20
  }
20
21
 
@@ -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
  })
@@ -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 lang="ts" setup>
2
2
  import type { AutoPropComponentDefinition } from '@histoire/shared'
3
- import type { Variant } from '../../types'
4
3
  import { Icon } from '@iconify/vue'
4
+ import type { Variant } from '../../types'
5
5
  import ControlsComponentPropItem from './ControlsComponentPropItem.vue'
6
6
 
7
7
  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>
@@ -5,8 +5,8 @@ import { useEventsStore } from '../../stores/events'
5
5
  import type { Story, Variant } from '../../types'
6
6
  import BaseOverflowMenu from '../base/BaseOverflowMenu.vue'
7
7
  import BaseOverflowTab from '../base/BaseOverflowTab.vue'
8
- import { useStoryDoc } from './StoryDocs.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,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
- import { ref, computed, nextTick, onMounted } from 'vue'
2
+ import { computed, nextTick, onMounted, ref } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
- import { useStorage, onClickOutside, useTimeoutFn } from '@vueuse/core'
4
+ import { onClickOutside, useStorage, useTimeoutFn } from '@vueuse/core'
5
5
  import { applyState, clone, omit } from '@histoire/shared'
6
6
  import BaseSelect from '../base/BaseSelect.vue'
7
7
  import { toRawDeep } from '../../util/state'
@@ -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,5 +1,6 @@
1
1
  <script lang="ts" setup>
2
- import { computed, PropType, ref, watch } from 'vue'
2
+ import type { PropType } from 'vue'
3
+ import { computed, ref, watch } from 'vue'
3
4
  import { Icon } from '@iconify/vue'
4
5
  import GenericRenderStory from '../story/GenericRenderStory.vue'
5
6
  import type { Story, Variant } from '../../types'
@@ -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,11 +1,15 @@
1
1
  <script lang="ts">
2
- import { nextTick, PropType, Ref, ref, toRefs, watch, watchEffect, computed } from 'vue'
3
- import type { Story } from '../../types'
2
+ import type { PropType, Ref } from 'vue'
3
+ import { computed, nextTick, ref, toRefs, watch, watchEffect } from 'vue'
4
4
  import { markdownFiles } from 'virtual:$histoire-markdown-files'
5
+ import { Icon } from '@iconify/vue'
6
+ import { useRoute, useRouter } from 'vue-router'
7
+ import type { Story } from '../../types'
5
8
  import { histoireConfig } from '../../util/config.js'
6
9
  import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
10
+ import BaseEmpty from '../base/BaseEmpty.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 () => {
@@ -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
2
  import { computed } from 'vue'
3
- import { HstEvent } from '../../stores/events'
3
+ import type { 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,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { ref, computed, watch, onMounted, nextTick } from 'vue'
2
+ import { computed, nextTick, onMounted, ref, watch } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
4
  import BaseEmpty from '../base/BaseEmpty.vue'
5
5
  import { useEventsStore } from '../../stores/events'
@@ -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
  }
@@ -1,11 +1,12 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed, markRaw, nextTick, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
- import { getHighlighter, Highlighter } from 'shiki-es'
4
+ import type { Highlighter } from 'shiki-es'
5
+ import { getHighlighter } from 'shiki-es'
5
6
  import { HstCopyIcon } from '@histoire/controls'
6
7
  import { unindent } from '@histoire/shared'
7
8
  import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
8
- import type { Variant, Story } from '../../types'
9
+ import type { Story, Variant } from '../../types'
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,7 +1,8 @@
1
1
  <script lang="ts" setup>
2
- import { PropType, ref, toRefs } from 'vue'
2
+ import type { PropType } from 'vue'
3
+ import { ref, toRefs } from 'vue'
3
4
  import { useRouter } from 'vue-router'
4
- import { SearchResult } from '../../types'
5
+ import type { SearchResult } from '../../types'
5
6
  import { onKeyboardShortcut } from '../../util/keyboard'
6
7
  import { useScrollOnActive } from '../../util/scroll'
7
8
  import BaseListItemLink from '../base/BaseListItemLink.vue'
@@ -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
  }
@@ -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>