@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,5 +1,5 @@
1
- import { watch } from 'vue'
2
1
  import { useDark, useToggle } from '@vueuse/core'
2
+ import { watch } from 'vue'
3
3
  import { histoireConfig } from './config.js'
4
4
 
5
5
  export const isDark = useDark({
@@ -10,8 +10,8 @@ export const isDark = useDark({
10
10
  })
11
11
  export const toggleDark = useToggle(isDark)
12
12
 
13
- function applyDarkToControls () {
14
- window.__hst_controls_dark?.forEach(ref => {
13
+ function applyDarkToControls() {
14
+ window.__hst_controls_dark?.forEach((ref) => {
15
15
  ref.value = isDark.value
16
16
  })
17
17
  }
@@ -1,16 +1,18 @@
1
+ import type { Story, Variant } from '../types'
1
2
  import { unindent } from '@histoire/shared'
2
3
  import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
3
- import type { Variant, Story } from '../types'
4
4
 
5
- export async function getSourceCode (story: Story, variant: Variant) {
5
+ export async function getSourceCode(story: Story, variant: Variant) {
6
6
  if (variant.source) {
7
7
  return variant.source
8
- } else if (variant.slots?.().source) {
8
+ }
9
+ else if (variant.slots?.().source) {
9
10
  const source = variant.slots?.().source()[0].children
10
11
  if (source) {
11
12
  return unindent(source)
12
13
  }
13
- } else {
14
+ }
15
+ else {
14
16
  const clientPlugin = clientSupportPlugins[story.file?.supportPluginId]
15
17
  if (clientPlugin) {
16
18
  const pluginModule = await clientPlugin()
@@ -1,6 +1,6 @@
1
1
  import { EVENT_SEND } from './const'
2
2
 
3
- export async function logEvent (name: string, argument) {
3
+ export async function logEvent(name: string, argument) {
4
4
  console.log('[histoire] Event fired', { name, argument })
5
5
  const event = {
6
6
  name,
@@ -11,13 +11,14 @@ export async function logEvent (name: string, argument) {
11
11
  type: EVENT_SEND,
12
12
  event,
13
13
  })
14
- } else {
14
+ }
15
+ else {
15
16
  const { useEventsStore } = await import('../stores/events.js')
16
17
  useEventsStore().addEvent(event)
17
18
  }
18
19
  }
19
20
 
20
- function stringifyEvent (e) {
21
+ function stringifyEvent(e) {
21
22
  const obj = {}
22
23
  for (const k in e) {
23
24
  obj[k] = e[k]
@@ -1,5 +1,6 @@
1
+ import type { Ref } from 'vue'
1
2
  import { useEventListener } from '@vueuse/core'
2
- import { isRef, Ref } from 'vue'
3
+ import { isRef } from 'vue'
3
4
  import { isMac } from './env.js'
4
5
 
5
6
  export type KeyboardShortcut = string[]
@@ -10,8 +11,8 @@ export interface KeyboardShortcutOptions {
10
11
  event?: 'keyup' | 'keydown' | 'keypress'
11
12
  }
12
13
 
13
- export function onKeyboardShortcut (shortcut: KeyboardShortcut | Ref<KeyboardShortcut>, handler: KeyboardHandler, options: KeyboardShortcutOptions = {}) {
14
- useEventListener(options.event ?? 'keydown', event => {
14
+ export function onKeyboardShortcut(shortcut: KeyboardShortcut | Ref<KeyboardShortcut>, handler: KeyboardHandler, options: KeyboardShortcutOptions = {}) {
15
+ useEventListener(options.event ?? 'keydown', (event) => {
15
16
  if (isMatchingShortcut(isRef(shortcut) ? shortcut.value : shortcut)) {
16
17
  handler(event)
17
18
  }
@@ -27,7 +28,7 @@ const modifiers: { [i: string]: { key: string, pressed: boolean } } = {
27
28
 
28
29
  const pressedKeys = new Set<string>()
29
30
 
30
- window.addEventListener('keydown', event => {
31
+ window.addEventListener('keydown', (event) => {
31
32
  for (const i in modifiers) {
32
33
  const mod = modifiers[i]
33
34
  if (mod.key === event.key) {
@@ -38,7 +39,7 @@ window.addEventListener('keydown', event => {
38
39
  pressedKeys.add(event.key.toLocaleLowerCase())
39
40
  })
40
41
 
41
- window.addEventListener('keyup', event => {
42
+ window.addEventListener('keyup', (event) => {
42
43
  requestAnimationFrame(() => {
43
44
  pressedKeys.clear()
44
45
  for (const i in modifiers) {
@@ -59,7 +60,7 @@ window.addEventListener('blur', () => {
59
60
  }
60
61
  })
61
62
 
62
- function isMatchingShortcut (shortcut: KeyboardShortcut): boolean {
63
+ function isMatchingShortcut(shortcut: KeyboardShortcut): boolean {
63
64
  for (const combination of shortcut) {
64
65
  if (isMatchingCombination(combination.toLowerCase())) {
65
66
  return true
@@ -68,7 +69,7 @@ function isMatchingShortcut (shortcut: KeyboardShortcut): boolean {
68
69
  return false
69
70
  }
70
71
 
71
- function isMatchingCombination (combination: string): boolean {
72
+ function isMatchingCombination(combination: string): boolean {
72
73
  const splitted = combination.split('+').map(key => key.trim())
73
74
  const targetKey = splitted.pop()
74
75
  for (const mod in modifiers) {
@@ -81,7 +82,7 @@ function isMatchingCombination (combination: string): boolean {
81
82
  return pressedKeys.has(targetKey)
82
83
  }
83
84
 
84
- export function formatKey (key: string) {
85
+ export function formatKey(key: string) {
85
86
  key = key.toLowerCase()
86
87
  if (key === 'ctrl') {
87
88
  return isMac ? '^' : 'Ctrl'
@@ -1,5 +1,5 @@
1
- import { markRaw, reactive } from 'vue'
2
1
  import type { StoryFile, Variant } from '../types'
2
+ import { markRaw, reactive } from 'vue'
3
3
 
4
4
  const copiedFromExistingVariant = [
5
5
  'state',
@@ -12,7 +12,7 @@ const copiedFromExistingVariant = [
12
12
  'previewReady',
13
13
  ]
14
14
 
15
- export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
15
+ export function mapFile(file: StoryFile, existingFile?: StoryFile): StoryFile {
16
16
  let result: StoryFile
17
17
 
18
18
  if (existingFile) {
@@ -26,11 +26,13 @@ export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
26
26
  file: markRaw(result),
27
27
  variants: file.story.variants.map(v => mapVariant(v, existingFile.story.variants.find(item => item.id === v.id))),
28
28
  }
29
- } else if (key !== 'component') {
29
+ }
30
+ else if (key !== 'component') {
30
31
  result[key] = file[key]
31
32
  }
32
33
  }
33
- } else {
34
+ }
35
+ else {
34
36
  // Create
35
37
  result = {
36
38
  ...file,
@@ -48,7 +50,7 @@ export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
48
50
  return result
49
51
  }
50
52
 
51
- export function mapVariant (variant: Variant, existingVariant?: Variant): Variant {
53
+ export function mapVariant(variant: Variant, existingVariant?: Variant): Variant {
52
54
  let result: Variant
53
55
 
54
56
  if (existingVariant) {
@@ -59,7 +61,8 @@ export function mapVariant (variant: Variant, existingVariant?: Variant): Varian
59
61
  result[key] = variant[key]
60
62
  }
61
63
  }
62
- } else {
64
+ }
65
+ else {
63
66
  // Create
64
67
  result = {
65
68
  ...variant,
@@ -1,3 +1,3 @@
1
- export function openInEditor (file: string) {
1
+ export function openInEditor(file: string) {
2
2
  return fetch(`${import.meta.env.BASE_URL}__open-in-editor?file=${encodeURIComponent(file)}`)
3
3
  }
@@ -1,10 +1,10 @@
1
+ import type { PreviewSettings } from '../types'
1
2
  import { reactive } from 'vue'
2
3
  import { histoireConfig } from './config'
3
- import type { PreviewSettings } from '../types'
4
4
 
5
5
  export const receivedSettings = reactive<PreviewSettings>({} as PreviewSettings)
6
6
 
7
- export function applyPreviewSettings (settings: PreviewSettings) {
7
+ export function applyPreviewSettings(settings: PreviewSettings) {
8
8
  Object.assign(receivedSettings, settings)
9
9
 
10
10
  // Text direction
@@ -18,6 +18,6 @@ export function applyPreviewSettings (settings: PreviewSettings) {
18
18
  }
19
19
  }
20
20
 
21
- export function getContrastColor (setting: PreviewSettings) {
21
+ export function getContrastColor(setting: PreviewSettings) {
22
22
  return histoireConfig.backgroundPresets.find(preset => preset.color === setting.backgroundColor)?.contrastColor ?? 'unset'
23
23
  }
@@ -1,8 +1,7 @@
1
-
1
+ import type { Story, Variant } from '../types'
2
2
  import { base } from '../router'
3
- import { Story, Variant } from '../types'
4
3
 
5
- export function getSandboxUrl (story: Story, variant: Variant) {
4
+ export function getSandboxUrl(story: Story, variant: Variant) {
6
5
  const url = new URLSearchParams()
7
6
  url.append('storyId', story.id)
8
7
  url.append('variantId', variant.id)
@@ -1,14 +1,15 @@
1
- import { watch, onMounted, Ref } from 'vue'
1
+ import type { Ref } from 'vue'
2
2
  import scrollIntoView from 'scroll-into-view-if-needed'
3
+ import { onMounted, watch } from 'vue'
3
4
 
4
- export function useScrollOnActive (active: Ref<boolean>, el: Ref<HTMLElement>) {
5
- watch(active, value => {
5
+ export function useScrollOnActive(active: Ref<boolean>, el: Ref<HTMLElement>) {
6
+ watch(active, (value) => {
6
7
  if (value) {
7
8
  autoScroll()
8
9
  }
9
10
  })
10
11
 
11
- function autoScroll () {
12
+ function autoScroll() {
12
13
  if (el.value) {
13
14
  scrollIntoView(el.value, {
14
15
  scrollMode: 'if-needed',
@@ -1,20 +1,21 @@
1
- import { Ref, ref, watch, computed } from 'vue'
1
+ import type { Ref } from 'vue'
2
+ import { computed, ref, watch } from 'vue'
2
3
 
3
- export function useSelection (list: Ref<any[]>) {
4
+ export function useSelection(list: Ref<any[]>) {
4
5
  const selectedIndex = ref(0)
5
6
 
6
7
  watch(list, () => {
7
8
  selectedIndex.value = 0
8
9
  })
9
10
 
10
- function selectNext () {
11
+ function selectNext() {
11
12
  selectedIndex.value++
12
13
  if (selectedIndex.value > list.value.length - 1) {
13
14
  selectedIndex.value = 0
14
15
  }
15
16
  }
16
17
 
17
- function selectPrevious () {
18
+ function selectPrevious() {
18
19
  selectedIndex.value--
19
20
  if (selectedIndex.value < 0) {
20
21
  selectedIndex.value = list.value.length - 1
@@ -1,8 +1,8 @@
1
- import { unref, isRef } from 'vue'
1
+ import { isRef, unref } from 'vue'
2
2
 
3
- const isObject = (val) => val !== null && typeof val === 'object'
3
+ const isObject = val => val !== null && typeof val === 'object'
4
4
 
5
- export function toRawDeep (val, clean = false, seen = new WeakMap()) {
5
+ export function toRawDeep(val, clean = false, seen = new WeakMap()) {
6
6
  const unwrappedValue = isRef(val) ? unref(val) : val
7
7
 
8
8
  if (typeof unwrappedValue === 'symbol') {
@@ -26,7 +26,8 @@ export function toRawDeep (val, clean = false, seen = new WeakMap()) {
26
26
  }
27
27
  result.push(...list)
28
28
  return result
29
- } else {
29
+ }
30
+ else {
30
31
  const result = {}
31
32
  seen.set(unwrappedValue, result)
32
33
  toRawObject(unwrappedValue, result, clean, seen)
@@ -34,7 +35,7 @@ export function toRawDeep (val, clean = false, seen = new WeakMap()) {
34
35
  }
35
36
  }
36
37
 
37
- const toRawObject = (obj: Record<any, any>, target: Record<any, any>, clean = false, seen = new WeakMap()) => {
38
+ function toRawObject(obj: Record<any, any>, target: Record<any, any>, clean = false, seen = new WeakMap()) {
38
39
  Object.keys(obj).forEach((key) => {
39
40
  if (clean && typeof obj[key] === 'function') {
40
41
  return
@@ -1,13 +1,13 @@
1
1
  import { isMac } from './env.js'
2
2
  import { formatKey } from './keyboard.js'
3
3
 
4
- export function makeTooltip (descriptionHtml: string, keyboardShortcut: (options: { isMac: boolean }) => string) {
4
+ export function makeTooltip(descriptionHtml: string, keyboardShortcut: (options: { isMac: boolean }) => string) {
5
5
  return {
6
6
  content: `<div>${descriptionHtml}</div><div class="htw-flex htw-items-center htw-gap-1 htw-mt-2 htw-text-sm">${genKeyboardShortcutHtml(keyboardShortcut({ isMac }))}</div>`,
7
7
  html: true,
8
8
  }
9
9
  }
10
10
 
11
- function genKeyboardShortcutHtml (shortcut: string) {
11
+ function genKeyboardShortcutHtml(shortcut: string) {
12
12
  return `<span class="htw-border htw-border-gray-600 htw-px-1 htw-rounded-sm htw-text-gray-400">${shortcut.split('+').map(k => formatKey(k.trim())).join(' ')}</span>`
13
13
  }
@@ -1,8 +1,9 @@
1
- import { computed, Ref } from 'vue'
2
- import { useRoute } from 'vue-router'
1
+ import type { Ref } from 'vue'
3
2
  import type { Variant } from '../types'
3
+ import { computed } from 'vue'
4
+ import { useRoute } from 'vue-router'
4
5
 
5
- export function useCurrentVariantRoute (variant: Ref<Variant>) {
6
+ export function useCurrentVariantRoute(variant: Ref<Variant>) {
6
7
  const route = useRoute()
7
8
  const isActive = computed(() => route.query.variantId === variant.value.id)
8
9
  const targetRoute = computed(() => ({
@@ -1,4 +1,4 @@
1
- import './app/style/main.pcss'
2
1
  import { mountMainApp } from './app/index'
2
+ import './app/style/main.pcss'
3
3
 
4
4
  mountMainApp()
@@ -1,5 +1,5 @@
1
- import './style.css'
2
- import './bundled/style.css'
3
1
  import { mountMainApp } from './bundled/index.js'
2
+ import './style.css'
3
+ import './bundled/app.css'
4
4
 
5
5
  mountMainApp()
package/src/shim.d.ts CHANGED
@@ -2,12 +2,6 @@
2
2
 
3
3
  import type { Ref } from '@histoire/vendors/vue'
4
4
 
5
- declare module '*.vue' {
6
- import { ComponentOptions } from 'vue'
7
- const comp: ComponentOptions
8
- export default comp
9
- }
10
-
11
5
  global {
12
6
  interface Window {
13
7
  __hst_controls_dark: Ref<boolean>[]
package/src/virtual.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  declare module 'virtual:$histoire-commands' {
2
2
  import type { ClientCommand } from '@histoire/shared'
3
+
3
4
  export const registeredCommands: ClientCommand[]
4
5
  }
5
6
 
@@ -1,11 +1,10 @@
1
-
2
- const inheritedConfig = require('../../tailwind.config.cjs')
3
- const defaultColors = require('tailwindcss/colors')
4
1
  const path = require('pathe')
2
+ const defaultColors = require('tailwindcss/colors')
3
+ const inheritedConfig = require('../../tailwind.config.cjs')
5
4
 
6
5
  // Colors
7
6
 
8
- function withOpacityValue (variable) {
7
+ function withOpacityValue(variable) {
9
8
  return ({ opacityValue }) => {
10
9
  if (opacityValue === undefined) {
11
10
  return `rgb(var(${variable}))`
@@ -73,12 +72,12 @@ module.exports.theme.colors = colors
73
72
 
74
73
  module.exports.plugins.push(require('@tailwindcss/typography'))
75
74
  // prose-a:htw-text-primary-500 prose-headings:htw-mb-2 prose-headings:htw-mt-4 first:prose-headings:htw-mt-0 prose-blockquote:htw-ml-0
76
- module.exports.theme.extend.typography = (theme) => ({
75
+ module.exports.theme.extend.typography = theme => ({
77
76
  DEFAULT: {
78
77
  css: {
79
- a: {
80
- color: theme('colors.primary-500'),
81
- textDecoration: 'none',
78
+ 'a': {
79
+ 'color': theme('colors.primary-500'),
80
+ 'textDecoration': 'none',
82
81
 
83
82
  '&:hover': {
84
83
  textDecoration: 'underline',
@@ -86,7 +85,7 @@ module.exports.theme.extend.typography = (theme) => ({
86
85
  },
87
86
 
88
87
  'h1, h2, h3, h4, th': {
89
- marginBottom: '0.75rem',
88
+ 'marginBottom': '0.75rem',
90
89
 
91
90
  '&:not(:first-child)': {
92
91
  marginTop: '1.25rem',
@@ -96,11 +95,11 @@ module.exports.theme.extend.typography = (theme) => ({
96
95
  '--tw-prose-invert-quote-borders': theme('colors.gray-800'),
97
96
  '--tw-prose-invert-hr': theme('colors.gray-800'),
98
97
 
99
- blockquote: {
100
- marginLeft: 0,
101
- marginRight: 0,
102
- backgroundColor: theme('colors.gray-100'),
103
- padding: '.25rem .375rem',
98
+ 'blockquote': {
99
+ 'marginLeft': 0,
100
+ 'marginRight': 0,
101
+ 'backgroundColor': theme('colors.gray-100'),
102
+ 'padding': '.25rem .375rem',
104
103
 
105
104
  '& p:first-child': {
106
105
  marginTop: 0,
@@ -117,17 +116,17 @@ module.exports.theme.extend.typography = (theme) => ({
117
116
 
118
117
  '--tw-prose-invert-bullets': theme('colors.gray-500'),
119
118
 
120
- li: {
119
+ 'li': {
121
120
  marginTop: '0.1rem',
122
121
  marginBottom: '0.1rem',
123
122
  },
124
123
 
125
- code: {
126
- backgroundColor: theme('colors.gray-500 / 20%'),
127
- fontWeight: 'normal',
128
- padding: '0.05rem 0.5rem',
129
- borderRadius: '0.25rem',
130
- fontSize: '0.8rem',
124
+ 'code': {
125
+ 'backgroundColor': theme('colors.gray-500 / 20%'),
126
+ 'fontWeight': 'normal',
127
+ 'padding': '0.05rem 0.5rem',
128
+ 'borderRadius': '0.25rem',
129
+ 'fontSize': '0.8rem',
131
130
 
132
131
  '&::before, &::after': {
133
132
  display: 'none',
package/tsconfig.json CHANGED
@@ -1,35 +1,17 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "node",
6
- "outDir": "dist",
7
- "rootDir": "src",
8
- "baseUrl": ".",
9
- "allowSyntheticDefaultImports": true,
10
- "esModuleInterop": true,
11
- "removeComments": false,
12
- "resolveJsonModule": true,
13
- "skipLibCheck": true,
14
- "types": [
15
- "node"
16
- ],
4
+ // Volar
5
+ "jsx": "preserve",
17
6
  "lib": [
18
7
  "ESNext",
19
8
  "DOM",
20
- "DOM.Iterable",
9
+ "DOM.Iterable"
21
10
  ],
22
- "sourceMap": false,
23
- "preserveWatchOutput": true,
24
- "declaration": false,
25
- // Strict
26
- "noImplicitAny": false,
27
- "noImplicitThis": true,
28
- "alwaysStrict": true,
29
- "strictBindCallApply": true,
30
- "strictFunctionTypes": true,
31
- // Volar
32
- "jsx": "preserve",
11
+ "baseUrl": ".",
12
+ "rootDir": "src",
13
+ "module": "ESNext",
14
+ "moduleResolution": "node",
33
15
  // Alias
34
16
  "paths": {
35
17
  "floating-vue": ["node_modules/@histoire/vendors/floating-vue"],
@@ -39,7 +21,25 @@
39
21
  "vue-router": ["node_modules/@histoire/vendors/vue-router"],
40
22
  "@vueuse/core": ["node_modules/@histoire/vendors/vue-use"],
41
23
  "vue": ["node_modules/@histoire/vendors/vue"]
42
- }
24
+ },
25
+ "resolveJsonModule": true,
26
+ "types": [
27
+ "node"
28
+ ],
29
+ "strictBindCallApply": true,
30
+ "strictFunctionTypes": true,
31
+ "alwaysStrict": true,
32
+ // Strict
33
+ "noImplicitAny": false,
34
+ "noImplicitThis": true,
35
+ "declaration": false,
36
+ "outDir": "dist",
37
+ "removeComments": false,
38
+ "sourceMap": false,
39
+ "allowSyntheticDefaultImports": true,
40
+ "esModuleInterop": true,
41
+ "skipLibCheck": true,
42
+ "preserveWatchOutput": true
43
43
  },
44
44
  "include": [
45
45
  "src"
package/vite.config.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { defineConfig } from 'vite'
2
1
  import vue from '@vitejs/plugin-vue'
3
2
  import fs from 'fs-extra'
4
3
  import { globbySync } from 'globby'
4
+ import { defineConfig } from 'vite'
5
5
 
6
6
  export default defineConfig({
7
7
  plugins: [
@@ -9,14 +9,14 @@ export default defineConfig({
9
9
  {
10
10
  name: 'histoire:preserve:import.meta',
11
11
  enforce: 'pre',
12
- transform (code) {
12
+ transform(code) {
13
13
  if (code.includes('import.meta')) {
14
14
  return {
15
15
  code: code.replace(/import\.meta/g, 'import__meta'),
16
16
  }
17
17
  }
18
18
  },
19
- closeBundle () {
19
+ closeBundle() {
20
20
  try {
21
21
  const files = globbySync('./dist/bundled/**/*.js')
22
22
  for (const file of files) {
@@ -25,7 +25,8 @@ export default defineConfig({
25
25
  fs.writeFileSync(file, content.replace(/import__meta/g, 'import.meta'), 'utf-8')
26
26
  }
27
27
  }
28
- } catch (e) {
28
+ }
29
+ catch (e) {
29
30
  console.error(e)
30
31
  }
31
32
  },
@@ -36,11 +37,11 @@ export default defineConfig({
36
37
  alias: {
37
38
  'floating-vue': '@histoire/vendors/floating-vue',
38
39
  '@iconify/vue': '@histoire/vendors/iconify',
39
- pinia: '@histoire/vendors/pinia',
40
+ 'pinia': '@histoire/vendors/pinia',
40
41
  'scroll-into-view-if-needed': '@histoire/vendors/scroll',
41
42
  'vue-router': '@histoire/vendors/vue-router',
42
43
  '@vueuse/core': '@histoire/vendors/vue-use',
43
- vue: '@histoire/vendors/vue',
44
+ 'vue': '@histoire/vendors/vue',
44
45
  },
45
46
  },
46
47
 
@@ -55,7 +56,7 @@ export default defineConfig({
55
56
  external: [
56
57
  /\$histoire/,
57
58
  /@histoire/,
58
- // eslint-disable-next-line @typescript-eslint/no-var-requires
59
+ // eslint-disable-next-line ts/no-require-imports
59
60
  ...Object.keys(require('./package.json').dependencies),
60
61
  ],
61
62