@histoire/app 0.17.17 → 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 (170) 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/{style.css → app.css} +41 -41
  7. package/dist/bundled/components/HomeView.vue2.js +1 -1
  8. package/dist/bundled/components/app/AppHeader.vue2.js +2 -2
  9. package/dist/bundled/components/app/AppLogo.vue2.js +3 -3
  10. package/dist/bundled/components/app/Breadcrumb.vue.js +2 -2
  11. package/dist/bundled/components/app/Breadcrumb.vue2.js +7 -9
  12. package/dist/bundled/components/app/InitialLoading.vue2.js +1 -1
  13. package/dist/bundled/components/base/BaseEmpty.vue.js +2 -3
  14. package/dist/bundled/components/base/BaseIcon.vue.js +1 -1
  15. package/dist/bundled/components/base/BaseIcon.vue2.js +1 -2
  16. package/dist/bundled/components/base/BaseListItemLink.vue.js +1 -1
  17. package/dist/bundled/components/base/BaseOverflowMenu.vue2.js +1 -1
  18. package/dist/bundled/components/base/BaseOverflowTab.vue.js +1 -1
  19. package/dist/bundled/components/base/BaseSelect.vue2.js +2 -2
  20. package/dist/bundled/components/base/BaseSplitPane.vue.js +1 -1
  21. package/dist/bundled/components/base/BaseSplitPane.vue2.js +2 -4
  22. package/dist/bundled/components/base/BaseTab.vue.js +1 -1
  23. package/dist/bundled/components/base/BaseTag.vue.js +1 -1
  24. package/dist/bundled/components/command/CommandPrompts.vue2.js +3 -7
  25. package/dist/bundled/components/command/CommandPromptsModal.vue2.js +1 -1
  26. package/dist/bundled/components/command/PromptSelect.vue2.js +3 -3
  27. package/dist/bundled/components/command/PromptText.vue2.js +1 -1
  28. package/dist/bundled/components/misc/CheckerboardPattern.vue.js +31 -34
  29. package/dist/bundled/components/misc/HatchedPattern.vue.js +2 -3
  30. package/dist/bundled/components/panel/ControlsComponentPropItem.vue2.js +1 -1
  31. package/dist/bundled/components/panel/ControlsComponentProps.vue2.js +2 -4
  32. package/dist/bundled/components/panel/ControlsComponentState.vue2.js +1 -2
  33. package/dist/bundled/components/panel/PaneTabs.vue2.js +11 -11
  34. package/dist/bundled/components/panel/StatePresets.vue2.js +3 -4
  35. package/dist/bundled/components/panel/StoryControls.vue2.js +5 -6
  36. package/dist/bundled/components/panel/StoryDocs.vue2.js +4 -4
  37. package/dist/bundled/components/panel/StoryEvents.vue2.js +2 -2
  38. package/dist/bundled/components/panel/StorySidePanel.vue2.js +10 -12
  39. package/dist/bundled/components/panel/StorySourceCode.vue.js +2 -2
  40. package/dist/bundled/components/panel/StorySourceCode.vue2.js +15 -20
  41. package/dist/bundled/components/search/SearchItem.vue.js +2 -2
  42. package/dist/bundled/components/search/SearchItem.vue2.js +4 -6
  43. package/dist/bundled/components/search/SearchLoading.vue2.js +2 -2
  44. package/dist/bundled/components/search/SearchModal.vue2.js +1 -1
  45. package/dist/bundled/components/search/SearchPane.vue2.js +41 -59
  46. package/dist/bundled/components/search/search-docs-data.js +1 -1
  47. package/dist/bundled/components/search/search-title-data.js +1 -1
  48. package/dist/bundled/components/story/GenericMountStory.vue2.js +1 -1
  49. package/dist/bundled/components/story/StoryResponsivePreview.vue.js +2 -2
  50. package/dist/bundled/components/story/StoryResponsivePreview.vue2.js +7 -10
  51. package/dist/bundled/components/story/StoryVariantGrid.vue2.js +4 -7
  52. package/dist/bundled/components/story/StoryVariantGridItem.vue.js +2 -2
  53. package/dist/bundled/components/story/StoryVariantGridItem.vue2.js +13 -15
  54. package/dist/bundled/components/story/StoryVariantListItem.vue.js +2 -2
  55. package/dist/bundled/components/story/StoryVariantListItem.vue2.js +3 -4
  56. package/dist/bundled/components/story/StoryVariantSingle.vue.js +2 -2
  57. package/dist/bundled/components/story/StoryVariantSingle.vue2.js +2 -3
  58. package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue2.js +2 -2
  59. package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue2.js +3 -3
  60. package/dist/bundled/components/story/StoryVariantSingleView.vue2.js +4 -4
  61. package/dist/bundled/components/story/StoryView.vue2.js +4 -4
  62. package/dist/bundled/components/story/StoryViewer.vue.js +2 -2
  63. package/dist/bundled/components/story/StoryViewer.vue2.js +3 -4
  64. package/dist/bundled/components/toolbar/ToolbarBackground.vue.js +1 -1
  65. package/dist/bundled/components/toolbar/ToolbarBackground.vue2.js +3 -4
  66. package/dist/bundled/components/toolbar/ToolbarResponsiveSize.vue2.js +16 -17
  67. package/dist/bundled/components/tree/StoryGroup.vue2.js +8 -10
  68. package/dist/bundled/components/tree/StoryList.vue2.js +3 -3
  69. package/dist/bundled/components/tree/StoryListFolder.vue.js +2 -2
  70. package/dist/bundled/components/tree/StoryListFolder.vue2.js +11 -13
  71. package/dist/bundled/components/tree/StoryListItem.vue.js +2 -2
  72. package/dist/bundled/components/tree/StoryListItem.vue2.js +4 -5
  73. package/dist/bundled/index.js +4 -4
  74. package/dist/bundled/plugin.js +1 -2
  75. package/dist/bundled/sandbox.js +14 -19
  76. package/dist/bundled/stores/folder.js +1 -1
  77. package/dist/bundled/stores/preview-settings.js +1 -1
  78. package/dist/bundled/util/dark.js +1 -1
  79. package/dist/bundled/util/events.js +2 -4
  80. package/dist/bundled/util/scroll.js +1 -1
  81. package/dist/style.css +281 -293
  82. package/package.json +22 -23
  83. package/src/app/App.vue +11 -11
  84. package/src/app/api.ts +2 -2
  85. package/src/app/components/HomeView.vue +1 -1
  86. package/src/app/components/app/AppHeader.vue +1 -1
  87. package/src/app/components/app/AppLogo.vue +3 -3
  88. package/src/app/components/app/Breadcrumb.vue +2 -2
  89. package/src/app/components/base/BaseOverflowMenu.vue +2 -2
  90. package/src/app/components/base/BaseSelect.vue +2 -2
  91. package/src/app/components/command/CommandPrompts.vue +3 -6
  92. package/src/app/components/command/PromptSelect.vue +1 -1
  93. package/src/app/components/panel/ControlsComponentPropItem.vue +3 -3
  94. package/src/app/components/panel/ControlsComponentProps.vue +1 -1
  95. package/src/app/components/panel/ControlsComponentState.vue +2 -2
  96. package/src/app/components/panel/ControlsComponentStateItem.vue +2 -2
  97. package/src/app/components/panel/PaneTabs.vue +2 -2
  98. package/src/app/components/panel/StatePresets.vue +4 -4
  99. package/src/app/components/panel/StoryControls.vue +4 -4
  100. package/src/app/components/panel/StoryDocs.vue +5 -5
  101. package/src/app/components/panel/StoryEvent.vue +1 -1
  102. package/src/app/components/panel/StoryEvents.vue +2 -2
  103. package/src/app/components/panel/StorySidePanel.vue +2 -2
  104. package/src/app/components/panel/StorySourceCode.vue +4 -4
  105. package/src/app/components/search/SearchItem.vue +2 -2
  106. package/src/app/components/search/SearchItemContent.vue +1 -1
  107. package/src/app/components/search/SearchPane.vue +49 -61
  108. package/src/app/components/search/search-docs-data.ts +2 -2
  109. package/src/app/components/search/search-title-data.ts +2 -2
  110. package/src/app/components/search/types.ts +1 -1
  111. package/src/app/components/story/GenericMountStory.vue +1 -1
  112. package/src/app/components/story/GenericRenderStory.vue +1 -1
  113. package/src/app/components/story/StoryResponsivePreview.vue +5 -5
  114. package/src/app/components/story/StoryVariantGrid.vue +1 -1
  115. package/src/app/components/story/StoryVariantGridItem.vue +8 -8
  116. package/src/app/components/story/StoryVariantListItem.vue +3 -3
  117. package/src/app/components/story/StoryVariantSingle.vue +1 -1
  118. package/src/app/components/story/StoryVariantSinglePreviewNative.vue +3 -3
  119. package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +6 -6
  120. package/src/app/components/story/StoryVariantSingleView.vue +4 -4
  121. package/src/app/components/story/StoryView.vue +4 -4
  122. package/src/app/components/story/StoryViewer.vue +1 -1
  123. package/src/app/components/toolbar/ToolbarNewTab.vue +1 -1
  124. package/src/app/components/toolbar/ToolbarTitle.vue +1 -1
  125. package/src/app/components/tree/StoryGroup.vue +2 -2
  126. package/src/app/components/tree/StoryList.vue +2 -2
  127. package/src/app/components/tree/StoryListFolder.vue +1 -1
  128. package/src/app/components/tree/StoryListItem.vue +2 -2
  129. package/src/app/index.ts +4 -4
  130. package/src/app/sandbox.ts +13 -17
  131. package/src/app/stores/folder.ts +1 -1
  132. package/src/app/stores/preview-settings.ts +2 -2
  133. package/src/app/stores/story.ts +1 -1
  134. package/src/app/style/main.pcss +1 -1
  135. package/src/app/style/sandbox.css +1 -1
  136. package/src/app/types.ts +1 -1
  137. package/src/app/util/dark.ts +1 -1
  138. package/src/app/util/docs.ts +1 -1
  139. package/src/app/util/keyboard.ts +1 -1
  140. package/src/app/util/mapping.ts +1 -1
  141. package/src/app/util/preview-settings.ts +1 -1
  142. package/src/app/util/sandbox.ts +1 -1
  143. package/src/app/util/scroll.ts +1 -1
  144. package/src/app/util/variant.ts +1 -1
  145. package/src/bundle-main-dev.js +1 -1
  146. package/src/bundle-main.js +2 -2
  147. package/tailwind.config.cjs +1 -1
  148. package/vite.config.ts +2 -2
  149. package/dist/bundled/components/app/Breadcrumb.vue3.js +0 -1
  150. package/dist/bundled/components/base/BaseEmpty.vue2.js +0 -1
  151. package/dist/bundled/components/base/BaseIcon.vue3.js +0 -1
  152. package/dist/bundled/components/base/BaseSplitPane.vue3.js +0 -1
  153. package/dist/bundled/components/misc/HatchedPattern.vue2.js +0 -1
  154. package/dist/bundled/components/panel/StorySourceCode.vue3.js +0 -1
  155. package/dist/bundled/components/search/SearchItem.vue3.js +0 -1
  156. package/dist/bundled/components/story/StoryResponsivePreview.vue3.js +0 -1
  157. package/dist/bundled/components/story/StoryVariantGridItem.vue3.js +0 -1
  158. package/dist/bundled/components/story/StoryVariantListItem.vue3.js +0 -1
  159. package/dist/bundled/components/story/StoryVariantSingle.vue3.js +0 -1
  160. package/dist/bundled/components/story/StoryViewer.vue3.js +0 -1
  161. package/dist/bundled/components/toolbar/ToolbarBackground.vue3.js +0 -1
  162. package/dist/bundled/components/tree/StoryListFolder.vue3.js +0 -1
  163. package/dist/bundled/components/tree/StoryListItem.vue3.js +0 -1
  164. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/common.js +0 -52
  165. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/en.js +0 -10
  166. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/advanced.js +0 -16
  167. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/balance.js +0 -31
  168. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/simple.js +0 -15
  169. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang.js +0 -60
  170. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/type.js +0 -11
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@histoire/app",
3
3
  "type": "module",
4
- "version": "0.17.17",
4
+ "version": "1.0.0-alpha.1",
5
5
  "description": "Pre-bundled UI for Histoire",
6
6
  "author": {
7
7
  "name": "Guillaume Chau"
@@ -24,30 +24,29 @@
24
24
  },
25
25
  "types": "./src/index.ts",
26
26
  "dependencies": {
27
- "@types/flexsearch": "^0.7.6",
28
- "flexsearch": "0.7.21",
29
- "shiki-es": "^0.2.0",
30
- "@histoire/controls": "^0.17.17",
31
- "@histoire/shared": "^0.17.17",
32
- "@histoire/vendors": "^0.17.17"
27
+ "fuse.js": "^7.0.0",
28
+ "shiki-es": "^0.14.0",
29
+ "@histoire/controls": "^1.0.0-alpha.1",
30
+ "@histoire/shared": "^1.0.0-alpha.1",
31
+ "@histoire/vendors": "^1.0.0-alpha.1"
33
32
  },
34
33
  "devDependencies": {
35
- "@tailwindcss/typography": "^0.5.10",
36
- "@types/fs-extra": "^9.0.13",
37
- "@types/node": "^18.11.9",
38
- "@vitejs/plugin-vue": "^4.5.0",
39
- "autoprefixer": "^10.4.16",
40
- "chokidar": "^3.5.3",
41
- "concurrently": "^7.6.0",
42
- "fs-extra": "^10.1.0",
43
- "globby": "^13.2.2",
44
- "pathe": "^1.1.1",
45
- "postcss": "^8.4.31",
46
- "postcss-import": "^14.1.0",
47
- "tailwindcss": "^3.3.5",
48
- "typescript": "^5.4.4",
49
- "vite": "^5.0.11",
50
- "vue": "^3.3.8"
34
+ "@tailwindcss/typography": "^0.5.15",
35
+ "@types/fs-extra": "^11.0.4",
36
+ "@types/node": "^22.10.1",
37
+ "@vitejs/plugin-vue": "^5.2.1",
38
+ "autoprefixer": "^10.4.20",
39
+ "chokidar": "^4.0.1",
40
+ "concurrently": "^9.1.0",
41
+ "fs-extra": "^11.2.0",
42
+ "globby": "^14.0.2",
43
+ "pathe": "^1.1.2",
44
+ "postcss": "^8.4.49",
45
+ "postcss-import": "^16.1.0",
46
+ "tailwindcss": "^3.4.16",
47
+ "typescript": "5.6.3",
48
+ "vite": "^6.0.5",
49
+ "vue": "^3.5.13"
51
50
  },
52
51
  "scripts": {
53
52
  "build": "rimraf dist && vite build && pnpm run build:css && node ./scripts/copy.mjs",
package/src/app/App.vue CHANGED
@@ -5,24 +5,24 @@ export default {
5
5
  </script>
6
6
 
7
7
  <script lang="ts" setup>
8
+ import type { StoryFile, Tree } from './types'
9
+ import { useTitle } from '@vueuse/core'
8
10
  import { onUpdate, files as rawFiles, tree as rawTree } from 'virtual:$histoire-stories'
9
11
  import { computed, onMounted, ref, watch } from 'vue'
10
- import { useTitle } from '@vueuse/core'
11
- import StoryList from './components/tree/StoryList.vue'
12
- import BaseSplitPane from './components/base/BaseSplitPane.vue'
13
12
  import AppHeader from './components/app/AppHeader.vue'
14
- import type { StoryFile, Tree } from './types'
13
+ import Breadcrumb from './components/app/Breadcrumb.vue'
14
+ import InitialLoading from './components/app/InitialLoading.vue'
15
+ import BaseSplitPane from './components/base/BaseSplitPane.vue'
16
+ import CommandPromptsModal from './components/command/CommandPromptsModal.vue'
17
+ import SearchModal from './components/search/SearchModal.vue'
18
+ import GenericMountStory from './components/story/GenericMountStory.vue'
19
+ import StoryList from './components/tree/StoryList.vue'
20
+ import { useCommandStore } from './stores/command'
15
21
  import { useStoryStore } from './stores/story'
16
- import { mapFile } from './util/mapping'
17
22
  import { histoireConfig } from './util/config'
18
23
  import { onKeyboardShortcut } from './util/keyboard'
24
+ import { mapFile } from './util/mapping'
19
25
  import { isMobile } from './util/responsive'
20
- import { useCommandStore } from './stores/command'
21
- import Breadcrumb from './components/app/Breadcrumb.vue'
22
- import SearchModal from './components/search/SearchModal.vue'
23
- import CommandPromptsModal from './components/command/CommandPromptsModal.vue'
24
- import InitialLoading from './components/app/InitialLoading.vue'
25
- import GenericMountStory from './components/story/GenericMountStory.vue'
26
26
 
27
27
  const files = ref<StoryFile[]>(rawFiles.map(file => mapFile(file)))
28
28
  const tree = ref<Tree>(rawTree)
package/src/app/api.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { isDark as _isDark } from './util/dark.js'
2
2
 
3
- export { logEvent } from './util/events.js'
4
-
5
3
  export { toggleDark } from './util/dark.js'
6
4
 
5
+ export { logEvent } from './util/events.js'
6
+
7
7
  export function isDark() {
8
8
  return _isDark.value
9
9
  }
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed } from 'vue'
3
- import { customLogos, histoireConfig } from '../util/config'
4
3
  import HistoireLogo from '../assets/histoire.svg'
5
4
  import { useStoryStore } from '../stores/story'
5
+ import { customLogos, histoireConfig } from '../util/config'
6
6
  import HomeCounter from './app/HomeCounter.vue'
7
7
 
8
8
  const logoUrl = computed(() => histoireConfig.theme?.logo?.square ? customLogos.square : HistoireLogo)
@@ -1,10 +1,10 @@
1
1
  <script setup lang="ts">
2
2
  import { Icon } from '@iconify/vue'
3
3
  import { computed } from 'vue'
4
+ import { histoireConfig } from '../../util/config'
4
5
  import { isDark, toggleDark } from '../../util/dark'
5
6
  import { onKeyboardShortcut } from '../../util/keyboard'
6
7
  import { makeTooltip } from '../../util/tooltip'
7
- import { histoireConfig } from '../../util/config'
8
8
  import AppLogo from './AppLogo.vue'
9
9
 
10
10
  defineEmits({
@@ -1,11 +1,11 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed } from 'vue'
3
- import { isDark } from '../../util/dark'
4
- import { customLogos, histoireConfig } from '../../util/config'
5
-
6
3
  import HistoireLogoDark from '../../assets/histoire-text-dark.svg'
7
4
  import HistoireLogoLight from '../../assets/histoire-text.svg'
8
5
 
6
+ import { customLogos, histoireConfig } from '../../util/config'
7
+ import { isDark } from '../../util/dark'
8
+
9
9
  const logoUrl = computed(() => {
10
10
  if (isDark.value) {
11
11
  return histoireConfig.theme.logo?.dark ? customLogos.dark : HistoireLogoDark
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" setup>
2
- import { computed, ref, watch } from 'vue'
2
+ import type { Story, Tree } from '../../types'
3
3
  import { Icon } from '@iconify/vue'
4
+ import { computed, ref, watch } from 'vue'
4
5
  import { useStoryStore } from '../../stores/story'
5
- import type { Story, Tree } from '../../types'
6
6
  import StoryList from '../tree/StoryList.vue'
7
7
  import MobileOverlay from './MobileOverlay.vue'
8
8
 
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
- import { computed, h, onBeforeUnmount, reactive, ref } from 'vue'
3
- import { useResizeObserver } from '@vueuse/core'
4
2
  import { Icon } from '@iconify/vue'
3
+ import { useResizeObserver } from '@vueuse/core'
4
+ import { computed, h, onBeforeUnmount, reactive, ref } from 'vue'
5
5
 
6
6
  // Container
7
7
 
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" setup>
2
- import { Dropdown as VDropdown } from 'floating-vue'
3
2
  import type { ComputedRef } from 'vue'
4
- import { computed } from 'vue'
5
3
  import { Icon } from '@iconify/vue'
4
+ import { Dropdown as VDropdown } from 'floating-vue'
5
+ import { computed } from 'vue'
6
6
 
7
7
  const props = defineProps<{
8
8
  modelValue: string
@@ -1,11 +1,11 @@
1
1
  <script lang="ts" setup>
2
- import { nextTick, onMounted, reactive, ref } from 'vue'
3
2
  import type { ClientCommand } from '@histoire/shared'
3
+ import { nextTick, onMounted, reactive, ref } from 'vue'
4
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
- import PromptText from './PromptText.vue'
8
7
  import PromptSelect from './PromptSelect.vue'
8
+ import PromptText from './PromptText.vue'
9
9
 
10
10
  const props = defineProps<{
11
11
  command: ClientCommand
@@ -36,10 +36,7 @@ for (const prompt of props.command.prompts) {
36
36
 
37
37
  function submit() {
38
38
  const params = props.command.getParams
39
- ? props.command.getParams({
40
- ...getCommandContext(),
41
- answers,
42
- })
39
+ ? props.command.getParams({ ...getCommandContext(), answers })
43
40
  : answers
44
41
  executeCommand(props.command, params)
45
42
  emit('close')
@@ -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
 
@@ -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
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { AutoPropComponentDefinition } from '@histoire/shared'
3
- import { Icon } from '@iconify/vue'
4
3
  import type { Variant } from '../../types'
4
+ import { Icon } from '@iconify/vue'
5
5
  import ControlsComponentPropItem from './ControlsComponentPropItem.vue'
6
6
 
7
7
  defineProps<{
@@ -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<{
@@ -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,10 +1,10 @@
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'
7
+ import BaseTab from '../base/BaseTab.vue'
8
8
  import BaseTag from '../base/BaseTag.vue'
9
9
  import { useStoryDoc } from './StoryDocs.vue'
10
10
 
@@ -1,11 +1,11 @@
1
1
  <script lang="ts" setup>
2
- import { computed, nextTick, onMounted, ref } from 'vue'
2
+ import type { Story, Variant } from '../../types'
3
+ import { applyState, clone, omit } from '@histoire/shared'
3
4
  import { Icon } from '@iconify/vue'
4
5
  import { onClickOutside, useStorage, useTimeoutFn } from '@vueuse/core'
5
- import { applyState, clone, omit } from '@histoire/shared'
6
- import BaseSelect from '../base/BaseSelect.vue'
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
 
@@ -1,13 +1,13 @@
1
1
  <script lang="ts" setup>
2
2
  import type { PropType } from 'vue'
3
- import { computed, ref, watch } from 'vue'
4
- import { Icon } from '@iconify/vue'
5
- import GenericRenderStory from '../story/GenericRenderStory.vue'
6
3
  import type { Story, Variant } from '../../types'
4
+ import { Icon } from '@iconify/vue'
5
+ import { computed, ref, watch } from 'vue'
7
6
  import BaseEmpty from '../base/BaseEmpty.vue'
8
- import StatePresets from './StatePresets.vue'
7
+ import GenericRenderStory from '../story/GenericRenderStory.vue'
9
8
  import ControlsComponentProps from './ControlsComponentProps.vue'
10
9
  import ControlsComponentState from './ControlsComponentState.vue'
10
+ import StatePresets from './StatePresets.vue'
11
11
 
12
12
  const props = defineProps({
13
13
  variant: {
@@ -1,20 +1,20 @@
1
1
  <script lang="ts">
2
2
  import type { PropType, Ref } from 'vue'
3
- import { computed, nextTick, ref, toRefs, watch, watchEffect } from 'vue'
4
- import { markdownFiles } from 'virtual:$histoire-markdown-files'
3
+ import type { Story } from '../../types'
5
4
  import { Icon } from '@iconify/vue'
5
+ import { markdownFiles } from 'virtual:$histoire-markdown-files'
6
+ import { computed, nextTick, ref, toRefs, watch, watchEffect } from 'vue'
6
7
  import { useRoute, useRouter } from 'vue-router'
7
- import type { Story } from '../../types'
8
8
  import { histoireConfig } from '../../util/config.js'
9
- import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
10
9
  import BaseEmpty from '../base/BaseEmpty.vue'
10
+ import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
11
11
 
12
12
  export function useStoryDoc(story: Ref<Story>) {
13
13
  const renderedDoc = ref('')
14
14
 
15
15
  watchEffect(async () => {
16
16
  // Markdown file
17
- const mdKey = story.value.file.filePath.replace(/\.(\w*?)$/, '.md')
17
+ const mdKey = story.value.file.filePath.replace(/\.(\w*)$/, '.md')
18
18
  if (markdownFiles[mdKey]) {
19
19
  const md = await markdownFiles[mdKey]()
20
20
  renderedDoc.value = md.html
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
- import { computed } from 'vue'
3
2
  import type { HstEvent } from '../../stores/events'
3
+ import { computed } from 'vue'
4
4
 
5
5
  const props = defineProps<{
6
6
  event: HstEvent
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" setup>
2
- import { computed, nextTick, onMounted, ref, watch } 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()
@@ -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,12 +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
2
  import type { Highlighter } from 'shiki-es'
5
- import { getHighlighter } from 'shiki-es'
3
+ import type { Story, Variant } from '../../types'
6
4
  import { HstCopyIcon } from '@histoire/controls'
7
5
  import { unindent } from '@histoire/shared'
6
+ import { Icon } from '@iconify/vue'
7
+ import { getHighlighter } from 'shiki-es'
8
8
  import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
9
- import type { Story, Variant } from '../../types'
9
+ import { computed, markRaw, nextTick, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'
10
10
  import { isDark } from '../../util/dark'
11
11
  import BaseEmpty from '../base/BaseEmpty.vue'
12
12
 
@@ -1,12 +1,12 @@
1
1
  <script lang="ts" setup>
2
2
  import type { PropType } from 'vue'
3
+ import type { SearchResult } from '../../types'
3
4
  import { ref, toRefs } from 'vue'
4
5
  import { useRouter } from 'vue-router'
5
- import type { SearchResult } from '../../types'
6
6
  import { onKeyboardShortcut } from '../../util/keyboard'
7
7
  import { useScrollOnActive } from '../../util/scroll'
8
- import BaseListItemLink from '../base/BaseListItemLink.vue'
9
8
  import BaseListItem from '../base/BaseListItem.vue'
9
+ import BaseListItemLink from '../base/BaseListItemLink.vue'
10
10
  import SearchItemContent from './SearchItemContent.vue'
11
11
 
12
12
  const props = defineProps({
@@ -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
@@ -1,21 +1,19 @@
1
1
  <script lang="ts" setup>
2
- import { useDebounce, useFocus } 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'
3
+ import type { SearchResult, SearchResultType, Story, Variant } from '../../types'
4
+ import type { SearchData } from './types'
5
+ import { Icon } from '@iconify/vue'
6
+ import { useDebounce, useFocus } from '@vueuse/core'
7
+ import Fuse from 'fuse.js'
9
8
  import { registeredCommands } from 'virtual:$histoire-commands'
9
+ import { computed, ref, watch } from 'vue'
10
+ import { useCommandStore } from '../../stores/command.js'
10
11
  import { useStoryStore } from '../../stores/story'
11
- import BaseEmpty from '../base/BaseEmpty.vue'
12
- import type { SearchResult, SearchResultType, Story, Variant } from '../../types'
13
12
  import { builtinCommands, getCommandContext } from '../../util/commands.js'
14
- import { useCommandStore } from '../../stores/command.js'
15
13
  import { useSelection } from '../../util/select.js'
16
- import SearchItem from './SearchItem.vue'
14
+ import BaseEmpty from '../base/BaseEmpty.vue'
17
15
  import { onUpdate, searchData } from './search-title-data'
18
- import type { SearchData } from './types'
16
+ import SearchItem from './SearchItem.vue'
19
17
 
20
18
  const DocSearchData = () => import('./search-docs-data')
21
19
 
@@ -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
61
  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',
62
+ return new Fuse<{ id: number, text: string }>([], {
63
+ keys: ['text'],
76
64
  })
77
65
  }
78
66
 
79
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
@@ -92,27 +80,27 @@ 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
86
  async function loadDocSearchIndex() {
99
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
105
  searchDataModule.onUpdate((searchData) => {
118
106
  load(searchData)
@@ -127,29 +115,29 @@ const titleResults = ref<SearchResult[]>([])
127
115
 
128
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
 
@@ -158,21 +146,21 @@ const docsResults = ref<SearchResult[]>([])
158
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
  }
@@ -1,6 +1,6 @@
1
- import { markRaw } from 'vue'
2
- import { onUpdate as _onUpdate, searchData as _searchData } 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
 
@@ -1,6 +1,6 @@
1
- import { markRaw } from 'vue'
2
- import { onUpdate as _onUpdate, searchData as _searchData } 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
 
@@ -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
  }