@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,21 +1,19 @@
1
1
  <script lang="ts" setup>
2
- import { useFocus, useDebounce } from '@vueuse/core'
3
- import { computed, ref, watch } from 'vue'
4
- import { Icon } from '@iconify/vue'
5
- import * as flexsearch from 'flexsearch'
6
- import charset from 'flexsearch/dist/module/lang/latin/advanced.js'
7
- import language from 'flexsearch/dist/module/lang/en.js'
8
2
  import type { ClientCommand } from '@histoire/shared'
9
- import { registeredCommands } from 'virtual:$histoire-commands'
10
- import { useStoryStore } from '../../stores/story'
11
- import BaseEmpty from '../base/BaseEmpty.vue'
12
3
  import type { SearchResult, SearchResultType, Story, Variant } from '../../types'
13
- import SearchItem from './SearchItem.vue'
14
- import { searchData, onUpdate } from './search-title-data'
15
4
  import type { SearchData } from './types'
16
- import { builtinCommands, getCommandContext } from '../../util/commands.js'
5
+ import { Icon } from '@iconify/vue'
6
+ import { useDebounce, useFocus } from '@vueuse/core'
7
+ import Fuse from 'fuse.js'
8
+ import { registeredCommands } from 'virtual:$histoire-commands'
9
+ import { computed, ref, watch } from 'vue'
17
10
  import { useCommandStore } from '../../stores/command.js'
11
+ import { useStoryStore } from '../../stores/story'
12
+ import { builtinCommands, getCommandContext } from '../../util/commands.js'
18
13
  import { useSelection } from '../../util/select.js'
14
+ import BaseEmpty from '../base/BaseEmpty.vue'
15
+ import { onUpdate, searchData } from './search-title-data'
16
+ import SearchItem from './SearchItem.vue'
19
17
 
20
18
  const DocSearchData = () => import('./search-docs-data')
21
19
 
@@ -30,7 +28,7 @@ const emit = defineEmits({
30
28
  close: () => true,
31
29
  })
32
30
 
33
- function close () {
31
+ function close() {
34
32
  emit('close')
35
33
  }
36
34
 
@@ -41,7 +39,7 @@ const { focused } = useFocus(input, {
41
39
  initialValue: true,
42
40
  })
43
41
 
44
- watch(() => props.shown, value => {
42
+ watch(() => props.shown, (value) => {
45
43
  if (value) {
46
44
  requestAnimationFrame(() => {
47
45
  focused.value = true
@@ -57,30 +55,20 @@ const rateLimitedSearch = useDebounce(searchInputText, 50)
57
55
 
58
56
  const storyStore = useStoryStore()
59
57
 
60
- let titleSearchIndex: flexsearch.Document<any, any>
58
+ let titleSearchIndex: Fuse<{ id: number, text: string }>
61
59
  let titleIdMap: SearchData['idMap']
62
60
 
63
- function createIndex () {
64
- return new flexsearch.Document({
65
- preset: 'match',
66
- document: {
67
- id: 'id',
68
- index: [
69
- 'text',
70
- ],
71
- },
72
- worker: true,
73
- charset,
74
- language,
75
- tokenize: 'forward',
61
+ function createIndex() {
62
+ return new Fuse<{ id: number, text: string }>([], {
63
+ keys: ['text'],
76
64
  })
77
65
  }
78
66
 
79
- async function loadSearchIndex (data: SearchData) {
67
+ async function loadSearchIndex(data: SearchData) {
80
68
  titleSearchIndex = createIndex()
81
69
 
82
- for (const key of Object.keys(data.index)) {
83
- await titleSearchIndex.import(key, data.index[key])
70
+ for (const document of data.index) {
71
+ titleSearchIndex.add(document)
84
72
  }
85
73
 
86
74
  titleIdMap = data.idMap
@@ -88,33 +76,33 @@ async function loadSearchIndex (data: SearchData) {
88
76
 
89
77
  loadSearchIndex(searchData)
90
78
  // Handle HMR
91
- onUpdate(searchData => {
79
+ onUpdate((searchData) => {
92
80
  loadSearchIndex(searchData)
93
81
  })
94
82
 
95
- let docSearchIndex: flexsearch.Document<any, any>
83
+ let docSearchIndex: Fuse<{ id: number, text: string }>
96
84
  let docIdMap: SearchData['idMap']
97
85
 
98
- async function loadDocSearchIndex () {
99
- async function load (data: SearchData) {
86
+ async function loadDocSearchIndex() {
87
+ async function load(data: SearchData) {
100
88
  docSearchIndex = createIndex()
101
89
 
102
- for (const key of Object.keys(data.index)) {
103
- await docSearchIndex.import(key, data.index[key])
90
+ for (const document of data.index) {
91
+ docSearchIndex.add(document)
104
92
  }
105
93
 
106
94
  docIdMap = data.idMap
107
95
 
108
96
  if (rateLimitedSearch.value) {
109
- searchOnDocField(rateLimitedSearch.value)
97
+ await searchOnDocField(rateLimitedSearch.value)
110
98
  }
111
99
  }
112
100
 
113
101
  const searchDataModule = await DocSearchData()
114
102
 
115
- load(searchDataModule.searchData)
103
+ await load(searchDataModule.searchData)
116
104
  // Handle HMR
117
- searchDataModule.onUpdate(searchData => {
105
+ searchDataModule.onUpdate((searchData) => {
118
106
  load(searchData)
119
107
  })
120
108
  }
@@ -125,61 +113,61 @@ loadDocSearchIndex()
125
113
 
126
114
  const titleResults = ref<SearchResult[]>([])
127
115
 
128
- watch(rateLimitedSearch, async value => {
116
+ watch(rateLimitedSearch, async (value) => {
129
117
  const list: SearchResult[] = []
130
- const raw = await titleSearchIndex.search(value)
118
+ const result = titleSearchIndex.search(value)
131
119
  let rank = 0
132
- for (const field of raw) {
133
- for (const id of field.result) {
134
- const idMapData = titleIdMap[id]
135
- if (!idMapData) continue
136
- switch (idMapData.kind) {
137
- case 'story': {
138
- list.push(storyResultFactory(storyStore.getStoryById(idMapData.id), rank))
139
- rank++
140
- break
141
- }
142
- case 'variant': {
143
- const [storyId] = idMapData.id.split(':')
144
- const story = storyStore.getStoryById(storyId)
145
- const variant = storyStore.getVariantById(idMapData.id)
146
- list.push(variantResultFactory(story, variant, rank))
147
- rank++
148
- break
149
- }
120
+
121
+ for (const document of result) {
122
+ const idMapData = titleIdMap[document.item.id]
123
+ if (!idMapData) continue
124
+ switch (idMapData.kind) {
125
+ case 'story': {
126
+ list.push(storyResultFactory(storyStore.getStoryById(idMapData.id), rank))
127
+ rank++
128
+ break
129
+ }
130
+ case 'variant': {
131
+ const [storyId] = idMapData.id.split(':')
132
+ const story = storyStore.getStoryById(storyId)
133
+ const variant = storyStore.getVariantById(idMapData.id)
134
+ list.push(variantResultFactory(story, variant, rank))
135
+ rank++
136
+ break
150
137
  }
151
138
  }
152
139
  }
140
+
153
141
  titleResults.value = list
154
142
  })
155
143
 
156
144
  const docsResults = ref<SearchResult[]>([])
157
145
 
158
- async function searchOnDocField (query: string) {
146
+ async function searchOnDocField(query: string) {
159
147
  if (docSearchIndex) {
160
148
  const list: SearchResult[] = []
161
- const raw = await docSearchIndex.search(query)
149
+ const result = docSearchIndex.search(query)
162
150
  let rank = 0
163
- for (const field of raw) {
164
- for (const id of field.result) {
165
- const idMapData = docIdMap[id]
166
- if (!idMapData) continue
167
- switch (idMapData.kind) {
168
- case 'story': {
169
- list.push(storyResultFactory(storyStore.getStoryById(idMapData.id), rank, 'docs'))
170
- rank++
171
- break
172
- }
151
+
152
+ for (const document of result) {
153
+ const idMapData = docIdMap[document.item.id]
154
+ if (!idMapData) continue
155
+ switch (idMapData.kind) {
156
+ case 'story': {
157
+ list.push(storyResultFactory(storyStore.getStoryById(idMapData.id), rank, 'docs'))
158
+ rank++
159
+ break
173
160
  }
174
161
  }
175
162
  }
163
+
176
164
  docsResults.value = list
177
165
  }
178
166
  }
179
167
 
180
168
  watch(rateLimitedSearch, searchOnDocField)
181
169
 
182
- function storyResultFactory (story: Story, rank: number, type: SearchResultType = 'title'): SearchResult {
170
+ function storyResultFactory(story: Story, rank: number, type: SearchResultType = 'title'): SearchResult {
183
171
  return {
184
172
  kind: 'story',
185
173
  rank,
@@ -202,7 +190,7 @@ function storyResultFactory (story: Story, rank: number, type: SearchResultType
202
190
  }
203
191
  }
204
192
 
205
- function variantResultFactory (story: Story, variant: Variant, rank: number, type: SearchResultType = 'title'): SearchResult {
193
+ function variantResultFactory(story: Story, variant: Variant, rank: number, type: SearchResultType = 'title'): SearchResult {
206
194
  return {
207
195
  kind: 'variant',
208
196
  rank,
@@ -240,14 +228,14 @@ const commandResults = computed(() => {
240
228
  return allCommands
241
229
  .filter(command => !command.showIf || command.showIf(commandCtx))
242
230
  .filter(command => command.label.toLowerCase().includes(searchText) || command.searchText?.toLowerCase().includes(searchText))
243
- .map((command) => commandResultFactory(command, 0))
231
+ .map(command => commandResultFactory(command, 0))
244
232
  }
245
233
  return []
246
234
  })
247
235
 
248
236
  const commandStore = useCommandStore()
249
237
 
250
- function commandResultFactory (command: ClientCommand, rank: number): SearchResult {
238
+ function commandResultFactory(command: ClientCommand, rank: number): SearchResult {
251
239
  return {
252
240
  kind: 'command',
253
241
  rank,
@@ -1,9 +1,9 @@
1
- import { markRaw } from 'vue'
2
- import { searchData as _searchData, onUpdate as _onUpdate } from 'virtual:$histoire-search-docs-data'
3
1
  import type { SearchData } from './types.js'
2
+ import { onUpdate as _onUpdate, searchData as _searchData } from 'virtual:$histoire-search-docs-data'
3
+ import { markRaw } from 'vue'
4
4
 
5
5
  export const searchData: SearchData = markRaw(_searchData)
6
6
 
7
- export function onUpdate (cb: (data: SearchData) => unknown) {
7
+ export function onUpdate(cb: (data: SearchData) => unknown) {
8
8
  _onUpdate(cb)
9
9
  }
@@ -1,9 +1,9 @@
1
- import { markRaw } from 'vue'
2
- import { searchData as _searchData, onUpdate as _onUpdate } from 'virtual:$histoire-search-title-data'
3
1
  import type { SearchData } from './types.js'
2
+ import { onUpdate as _onUpdate, searchData as _searchData } from 'virtual:$histoire-search-title-data'
3
+ import { markRaw } from 'vue'
4
4
 
5
5
  export const searchData: SearchData = markRaw(_searchData)
6
6
 
7
- export function onUpdate (cb: (data: SearchData) => unknown) {
7
+ export function onUpdate(cb: (data: SearchData) => unknown) {
8
8
  _onUpdate(cb)
9
9
  }
@@ -1,4 +1,4 @@
1
1
  export interface SearchData {
2
- index: Record<string, any>
2
+ index: Array<{ id: number, text: string }>
3
3
  idMap: Record<number, { id: string, kind: string }>
4
4
  }
@@ -5,9 +5,9 @@ export default {
5
5
  </script>
6
6
 
7
7
  <script lang="ts" setup>
8
- import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
9
- import { ref, watchEffect, markRaw } from 'vue'
10
8
  import type { Story } from '../../types'
9
+ import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
10
+ import { markRaw, ref, watchEffect } from 'vue'
11
11
 
12
12
  const props = defineProps<{
13
13
  story: Story
@@ -5,9 +5,9 @@ export default {
5
5
  </script>
6
6
 
7
7
  <script lang="ts" setup>
8
- import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
9
- import { ref, watchEffect, markRaw } from 'vue'
10
8
  import type { Story } from '../../types'
9
+ import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
10
+ import { markRaw, ref, watchEffect } from 'vue'
11
11
 
12
12
  const props = defineProps<{
13
13
  story: Story
@@ -21,7 +21,8 @@ watchEffect(async () => {
21
21
  try {
22
22
  const pluginModule = await clientPlugin()
23
23
  mountComponent.value = markRaw(pluginModule.RenderStory)
24
- } catch (e) {
24
+ }
25
+ catch (e) {
25
26
  console.error(e)
26
27
  throw e
27
28
  }
@@ -1,12 +1,13 @@
1
1
  <script lang="ts" setup>
2
- import { computed, onUnmounted, Ref, ref } from 'vue'
3
- import { useEventListener } from '@vueuse/core'
2
+ import type { Ref } from 'vue'
3
+ import type { Variant } from '../../types'
4
4
  import { Icon } from '@iconify/vue'
5
- import HatchedPattern from '../misc/HatchedPattern.vue'
6
- import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
7
- import { usePreviewSettingsStore } from '../../stores/preview-settings'
8
- import { Variant } from '../../types'
5
+ import { useEventListener } from '@vueuse/core'
9
6
  import { VTooltip as vTooltip } from 'floating-vue'
7
+ import { computed, onUnmounted, ref } from 'vue'
8
+ import { usePreviewSettingsStore } from '../../stores/preview-settings'
9
+ import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
10
+ import HatchedPattern from '../misc/HatchedPattern.vue'
10
11
 
11
12
  const props = defineProps<{
12
13
  variant: Variant
@@ -23,7 +24,7 @@ onUnmounted(() => {
23
24
  onUnmountedCleanupFns.forEach(fn => fn())
24
25
  })
25
26
 
26
- function addWindowListener (event: string, listener: (event: any) => unknown) {
27
+ function addWindowListener(event: string, listener: (event: any) => unknown) {
27
28
  window.addEventListener(event, listener)
28
29
  const removeListener = () => window.removeEventListener(event, listener)
29
30
  onUnmountedCleanupFns.push(removeListener)
@@ -33,8 +34,8 @@ function addWindowListener (event: string, listener: (event: any) => unknown) {
33
34
  }
34
35
  }
35
36
 
36
- function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, max: number, axis: 'x' | 'y') {
37
- function onMouseDown (event: MouseEvent) {
37
+ function useDragger(el: Ref<HTMLDivElement>, value: Ref<number>, min: number, max: number, axis: 'x' | 'y') {
38
+ function onMouseDown(event: MouseEvent) {
38
39
  event.preventDefault()
39
40
  event.stopPropagation()
40
41
  const start = axis === 'x' ? event.clientX : event.clientY
@@ -46,7 +47,7 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
46
47
  addWindowListener('mouseup', onMouseUp),
47
48
  ]
48
49
 
49
- function onMouseMove (event: MouseEvent) {
50
+ function onMouseMove(event: MouseEvent) {
50
51
  const snapTarget = (axis === 'x' ? previewWrapper.value.clientWidth : previewWrapper.value.clientHeight)
51
52
  const delta = (axis === 'x' ? event.clientX : event.clientY) - start
52
53
  value.value = Math.max(min, Math.min(max, startValue + delta))
@@ -56,14 +57,14 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
56
57
  }
57
58
  }
58
59
 
59
- function onMouseUp () {
60
+ function onMouseUp() {
60
61
  removeListeners.forEach(fn => fn())
61
62
  resizing.value = false
62
63
  }
63
64
  }
64
65
  useEventListener(el, 'mousedown', onMouseDown)
65
66
 
66
- function onTouchStart (event: TouchEvent) {
67
+ function onTouchStart(event: TouchEvent) {
67
68
  event.preventDefault()
68
69
  event.stopPropagation()
69
70
  const start = axis === 'x' ? event.touches[0].clientX : event.touches[0].clientY
@@ -76,12 +77,12 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
76
77
  addWindowListener('touchcancel', onTouchEnd),
77
78
  ]
78
79
 
79
- function onTouchMove (event: TouchEvent) {
80
+ function onTouchMove(event: TouchEvent) {
80
81
  const delta = (axis === 'x' ? event.touches[0].clientX : event.touches[0].clientY) - start
81
82
  value.value = Math.max(min, Math.min(max, startValue + delta))
82
83
  }
83
84
 
84
- function onTouchEnd () {
85
+ function onTouchEnd() {
85
86
  removeListeners.forEach(fn => fn())
86
87
  resizing.value = false
87
88
  }
@@ -117,7 +118,7 @@ const finalHeight = computed(() => settings.rotate ? settings.responsiveWidth :
117
118
 
118
119
  const isResponsiveEnabled = computed(() => !props.variant.responsiveDisabled)
119
120
 
120
- const sizeTooltip = computed(() => (responsiveWidth.value ?? 'Auto') + ' × ' + (responsiveHeight.value ?? 'Auto'))
121
+ const sizeTooltip = computed(() => `${responsiveWidth.value ?? 'Auto'} × ${responsiveHeight.value ?? 'Auto'}`)
121
122
  </script>
122
123
 
123
124
  <template>
@@ -140,7 +141,7 @@ const sizeTooltip = computed(() => (responsiveWidth.value ?? 'Auto') + ' × ' +
140
141
  :class="isResponsiveEnabled ? {
141
142
  'htw-w-fit': !!finalWidth,
142
143
  'htw-h-fit': !!finalHeight,
143
- 'htw-h-full': !finalHeight
144
+ 'htw-h-full': !finalHeight,
144
145
  } : 'htw-h-full'"
145
146
  >
146
147
  <div
@@ -3,10 +3,10 @@ import { useResizeObserver } from '@vueuse/core'
3
3
  import { computed, onMounted, ref, watch } from 'vue'
4
4
  import { useStoryStore } from '../../stores/story'
5
5
  import { isMobile } from '../../util/responsive'
6
- import StoryVariantGridItem from './StoryVariantGridItem.vue'
6
+ import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
7
7
  import ToolbarBackground from '../toolbar/ToolbarBackground.vue'
8
8
  import ToolbarTextDirection from '../toolbar/ToolbarTextDirection.vue'
9
- import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
9
+ import StoryVariantGridItem from './StoryVariantGridItem.vue'
10
10
 
11
11
  const storyStore = useStoryStore()
12
12
 
@@ -22,7 +22,7 @@ const gridTemplateWidth = computed(() => {
22
22
  }
23
23
 
24
24
  if (typeof layoutWidth === 'number') {
25
- return layoutWidth + 'px'
25
+ return `${layoutWidth}px`
26
26
  }
27
27
 
28
28
  return layoutWidth
@@ -44,7 +44,7 @@ useResizeObserver(el, () => {
44
44
  updateSize()
45
45
  })
46
46
 
47
- function updateMaxCount () {
47
+ function updateMaxCount() {
48
48
  if (!maxItemHeight.value) return
49
49
 
50
50
  const width = el.value!.clientWidth - margin * 2
@@ -74,7 +74,7 @@ function updateMaxCount () {
74
74
  }
75
75
  }
76
76
 
77
- function onItemResize (w: number, h: number) {
77
+ function onItemResize(w: number, h: number) {
78
78
  itemWidth.value = w
79
79
  if (maxItemHeight.value < h) {
80
80
  maxItemHeight.value = h
@@ -93,16 +93,17 @@ const gridEl = ref<HTMLDivElement>(null)
93
93
  const gridColumnWidth = ref(1)
94
94
  const viewWidth = ref(1)
95
95
 
96
- function updateSize () {
96
+ function updateSize() {
97
97
  if (!el.value) return
98
98
  viewWidth.value = el.value.clientWidth
99
99
 
100
100
  if (!gridEl.value) return
101
101
 
102
102
  if (gridTemplateWidth.value.endsWith('%')) {
103
- gridColumnWidth.value = viewWidth.value * parseInt(gridTemplateWidth.value) / 100 - gap
104
- } else {
105
- gridColumnWidth.value = parseInt(gridTemplateWidth.value)
103
+ gridColumnWidth.value = viewWidth.value * Number.parseInt(gridTemplateWidth.value) / 100 - gap
104
+ }
105
+ else {
106
+ gridColumnWidth.value = Number.parseInt(gridTemplateWidth.value)
106
107
  }
107
108
  }
108
109
 
@@ -1,20 +1,21 @@
1
1
  <script lang="ts" setup>
2
- import { computed, PropType, ref, toRefs } from 'vue'
2
+ import type { PropType } from 'vue'
3
+ import type { Story, Variant } from '../../types'
4
+ import { HstCopyIcon } from '@histoire/controls'
3
5
  import { Icon } from '@iconify/vue'
4
- import { useRouter } from 'vue-router'
5
6
  import { useResizeObserver } from '@vueuse/core'
6
- import { HstCopyIcon } from '@histoire/controls'
7
- import { useCurrentVariantRoute } from '../../util/variant'
8
- import type { Story, Variant } from '../../types'
9
- import { useScrollOnActive } from '../../util/scroll'
7
+ import { computed, ref, toRefs } from 'vue'
8
+ import { useRouter } from 'vue-router'
10
9
  import { usePreviewSettingsStore } from '../../stores/preview-settings'
11
- import { getContrastColor } from '../../util/preview-settings'
12
10
  import { histoireConfig } from '../../util/config'
13
11
  import { isDark } from '../../util/dark'
14
12
  import { getSourceCode } from '../../util/docs'
15
- import GenericRenderStory from './GenericRenderStory.vue'
16
- import ToolbarNewTab from '../toolbar/ToolbarNewTab.vue'
13
+ import { getContrastColor } from '../../util/preview-settings'
14
+ import { useScrollOnActive } from '../../util/scroll'
15
+ import { useCurrentVariantRoute } from '../../util/variant'
17
16
  import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
17
+ import ToolbarNewTab from '../toolbar/ToolbarNewTab.vue'
18
+ import GenericRenderStory from './GenericRenderStory.vue'
18
19
 
19
20
  const props = defineProps({
20
21
  variant: {
@@ -29,8 +30,7 @@ const props = defineProps({
29
30
  })
30
31
 
31
32
  const emit = defineEmits({
32
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
- resize: (width: number, height: number) => true,
33
+ resize: (_width: number, _height: number) => true,
34
34
  })
35
35
 
36
36
  const { variant } = toRefs(props)
@@ -39,7 +39,7 @@ const { isActive, targetRoute } = useCurrentVariantRoute(variant)
39
39
  Object.assign(props.variant, {
40
40
  previewReady: false,
41
41
  })
42
- function onReady () {
42
+ function onReady() {
43
43
  Object.assign(props.variant, {
44
44
  previewReady: true,
45
45
  })
@@ -47,7 +47,7 @@ function onReady () {
47
47
 
48
48
  const router = useRouter()
49
49
 
50
- function selectVariant () {
50
+ function selectVariant() {
51
51
  router.push(targetRoute.value)
52
52
  }
53
53
 
@@ -134,7 +134,7 @@ const autoApplyContrastColor = computed(() => !!histoireConfig.autoApplyContrast
134
134
  class="htw-relative htw-h-full"
135
135
  :style="{
136
136
  '--histoire-contrast-color': contrastColor,
137
- color: autoApplyContrastColor ? contrastColor : undefined,
137
+ 'color': autoApplyContrastColor ? contrastColor : undefined,
138
138
  }"
139
139
  >
140
140
  <GenericRenderStory
@@ -1,10 +1,11 @@
1
1
  <script lang="ts" setup>
2
- import { PropType, ref, toRefs } from 'vue'
3
- import { useCurrentVariantRoute } from '../../util/variant'
2
+ import type { PropType } from 'vue'
4
3
  import type { Variant } from '../../types'
5
- import BaseListItemLink from '../base/BaseListItemLink.vue'
6
4
  import { Icon } from '@iconify/vue'
5
+ import { ref, toRefs } from 'vue'
7
6
  import { useScrollOnActive } from '../../util/scroll'
7
+ import { useCurrentVariantRoute } from '../../util/variant'
8
+ import BaseListItemLink from '../base/BaseListItemLink.vue'
8
9
 
9
10
  const props = defineProps({
10
11
  variant: {
@@ -1,14 +1,14 @@
1
1
  <script lang="ts" setup>
2
+ import { Icon } from '@iconify/vue'
2
3
  import { computed } from 'vue'
3
4
  import { useStoryStore } from '../../stores/story'
4
- import { Icon } from '@iconify/vue'
5
5
  import { isMobile } from '../../util/responsive'
6
6
  import BaseSplitPane from '../base/BaseSplitPane.vue'
7
7
  import StoryVariantListItem from './StoryVariantListItem.vue'
8
8
  import StoryVariantSingleView from './StoryVariantSingleView.vue'
9
9
 
10
10
  defineEmits({
11
- 'open-variant-menu': () => true,
11
+ openVariantMenu: () => true,
12
12
  })
13
13
 
14
14
  const storyStore = useStoryStore()
@@ -35,7 +35,7 @@ const variant = computed(() => storyStore.currentVariant)
35
35
  >
36
36
  <a
37
37
  class="htw-px-6 htw-h-12 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer htw-flex htw-gap-2 htw-flex-wrap htw-w-full htw-items-center htw-flex-none"
38
- @click="$emit('open-variant-menu')"
38
+ @click="$emit('openVariantMenu')"
39
39
  >
40
40
  <template v-if="variant">
41
41
  <Icon
@@ -1,9 +1,9 @@
1
1
  <script lang="ts" setup>
2
- import { computed } from 'vue'
3
2
  import type { Story, Variant } from '../../types'
4
- import { isDark } from '../../util/dark'
5
- import { histoireConfig } from '../../util/config'
3
+ import { computed } from 'vue'
6
4
  import { usePreviewSettingsStore } from '../../stores/preview-settings'
5
+ import { histoireConfig } from '../../util/config'
6
+ import { isDark } from '../../util/dark'
7
7
  import { getContrastColor } from '../../util/preview-settings'
8
8
  import GenericRenderStory from './GenericRenderStory.vue'
9
9
  import StoryResponsivePreview from './StoryResponsivePreview.vue'
@@ -17,7 +17,7 @@ Object.assign(props.variant, {
17
17
  previewReady: false,
18
18
  })
19
19
 
20
- function onReady () {
20
+ function onReady() {
21
21
  Object.assign(props.variant, {
22
22
  previewReady: true,
23
23
  })
@@ -43,7 +43,7 @@ const autoApplyContrastColor = computed(() => !!histoireConfig.autoApplyContrast
43
43
  } : { width: '100%', height: '100%' },
44
44
  {
45
45
  '--histoire-contrast-color': contrastColor,
46
- color: autoApplyContrastColor ? contrastColor : undefined,
46
+ 'color': autoApplyContrastColor ? contrastColor : undefined,
47
47
  },
48
48
  ]"
49
49
  class="htw-relative"