histoire 0.2.5 → 0.3.2
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.
- package/dist/client/app/App.vue +8 -3
- package/dist/client/app/codegen/const.d.ts +1 -0
- package/dist/client/app/codegen/const.js +3 -0
- package/dist/client/app/codegen/vue3.js +83 -21
- package/dist/client/app/codegen/vue3.js.map +1 -0
- package/dist/client/app/components/base/BaseEmpty.vue +17 -1
- package/dist/client/app/components/base/BaseOverflowMenu.vue +118 -0
- package/dist/client/app/components/base/BaseOverflowTab.vue +46 -0
- package/dist/client/app/components/exposed/Story.vue +33 -1
- package/dist/client/app/components/exposed/Variant.vue +19 -1
- package/dist/client/app/components/panel/PaneTabs.vue +64 -0
- package/dist/client/app/components/{story → panel}/StoryControls.vue +6 -1
- package/dist/client/app/components/{story → panel}/StoryDocs.vue +18 -11
- package/dist/client/app/components/panel/StoryEvent.vue +53 -0
- package/dist/client/app/components/panel/StoryEvents.vue +45 -0
- package/{src/client/app/components/story → dist/client/app/components/panel}/StorySidePanel.vue +17 -20
- package/{src/client/app/components/story → dist/client/app/components/panel}/StorySourceCode.vue +24 -14
- package/dist/client/app/components/sandbox/SandboxVue3.vue +16 -4
- package/dist/client/app/components/sandbox/lib.js +2 -1
- package/dist/client/app/components/search/SearchLoading.vue +16 -0
- package/dist/client/app/components/search/SearchModal.vue +12 -149
- package/dist/client/app/components/search/SearchPane.vue +210 -0
- package/dist/client/app/components/search/search-data.d.ts +2 -0
- package/dist/client/app/components/search/search-data.js +8 -0
- package/dist/client/app/components/search/search-data.js.map +1 -0
- package/dist/client/app/components/story/StoryResponsivePreview.vue +9 -98
- package/dist/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +39 -0
- package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
- package/dist/client/app/components/story/StoryVariantSingleView.vue +13 -6
- package/dist/client/app/components/story/StoryView.vue +17 -3
- package/dist/client/app/components/story/StoryViewer.vue +2 -92
- package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantBackground.vue +3 -3
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantNewTab.vue +2 -2
- package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantResponsiveSize.vue +3 -3
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantTitle.vue +1 -1
- package/dist/client/app/components/tree/StoryGroup.vue +4 -4
- package/dist/client/app/components/tree/StoryListFolder.vue +4 -4
- package/dist/client/app/components/tree/StoryListItem.vue +4 -1
- package/dist/client/app/global-components.js +1 -0
- package/dist/client/app/global-components.js.map +1 -0
- package/dist/client/app/index.js +1 -0
- package/dist/client/app/index.js.map +1 -0
- package/dist/client/app/router.d.ts +1 -0
- package/dist/client/app/router.js +3 -1
- package/dist/client/app/sandbox.js +12 -1
- package/dist/client/app/sandbox.js.map +1 -0
- package/dist/client/app/stores/events.d.ts +29 -0
- package/dist/client/app/stores/events.js +26 -0
- package/dist/client/app/stores/events.js.map +1 -0
- package/dist/client/app/stores/folder.d.ts +10 -0
- package/dist/client/app/stores/folder.js +48 -0
- package/dist/client/app/stores/folder.js.map +1 -0
- package/dist/client/app/stores/story.d.ts +41 -8
- package/dist/client/app/stores/story.js +21 -33
- package/dist/client/app/stores/story.js.map +1 -0
- package/dist/client/app/style/main.pcss +5 -0
- package/dist/client/app/style/sandbox.css +2 -0
- package/dist/client/app/style/transitions.pcss +13 -0
- package/dist/client/app/types.d.ts +4 -0
- package/dist/client/app/types.js +1 -0
- package/dist/client/app/types.js.map +1 -0
- package/dist/client/app/util/const.d.ts +1 -0
- package/dist/client/app/util/const.js +1 -0
- package/dist/client/app/util/events.d.ts +1 -0
- package/dist/client/app/util/events.js +32 -0
- package/dist/client/app/util/events.js.map +1 -0
- package/dist/client/app/util/keyboard.js +1 -0
- package/dist/client/app/util/keyboard.js.map +1 -0
- package/dist/client/app/util/mapping.js +5 -2
- package/dist/client/app/util/mapping.js.map +1 -0
- package/dist/client/app/util/preview-settings.js +1 -0
- package/dist/client/app/util/preview-settings.js.map +1 -0
- package/dist/client/app/util/reactivity.js +1 -0
- package/dist/client/app/util/reactivity.js.map +1 -0
- package/dist/client/app/util/scroll.js +1 -0
- package/dist/client/app/util/scroll.js.map +1 -0
- package/dist/client/app/util/variant.js +1 -0
- package/dist/client/app/util/variant.js.map +1 -0
- package/dist/client/index.d.ts +4 -3
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -0
- package/dist/client/server/index.d.ts +7 -2
- package/dist/client/server/index.js +8 -26
- package/{src/client/server/Story.server.vue → dist/client/server/vue3/Story.vue} +14 -3
- package/dist/client/server/{Variant.server.vue → vue3/Variant.vue} +0 -0
- package/dist/client/server/vue3/run.d.ts +2 -0
- package/dist/client/server/vue3/run.js +33 -0
- package/dist/client/server/vue3/run.js.map +1 -0
- package/dist/controls.js +1 -0
- package/dist/controls.js.map +1 -0
- package/dist/node/alias.d.ts +2 -1
- package/dist/node/alias.js +3 -2
- package/dist/node/build.js +74 -21
- package/dist/node/builtin-plugins/tailwind-tokens.d.ts +5 -0
- package/dist/node/builtin-plugins/tailwind-tokens.js +510 -0
- package/dist/node/collect/index.js +3 -1
- package/dist/node/collect/worker.js +6 -2
- package/dist/node/commands/preview.js +4 -25
- package/dist/node/config.d.ts +103 -3
- package/dist/node/config.js +40 -23
- package/dist/node/context.d.ts +3 -3
- package/dist/node/context.js +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/load.d.ts +12 -0
- package/dist/node/load.js +42 -0
- package/dist/node/plugin.d.ts +67 -11
- package/dist/node/plugin.js +42 -245
- package/dist/node/preview.d.ts +8 -0
- package/dist/node/preview.js +41 -0
- package/dist/node/search.d.ts +2 -0
- package/dist/node/search.js +68 -0
- package/dist/node/server.js +43 -21
- package/dist/node/stories.d.ts +2 -0
- package/dist/node/stories.js +4 -4
- package/dist/node/types.d.ts +1 -0
- package/dist/node/util/find-up.d.ts +1 -0
- package/dist/node/util/find-up.js +20 -0
- package/dist/node/vite.d.ts +13 -0
- package/dist/node/vite.js +278 -0
- package/dist/style.css +174 -86
- package/package.json +7 -6
- package/scripts/copy.mjs +2 -1
- package/src/client/app/App.vue +8 -3
- package/src/client/app/codegen/const.ts +3 -0
- package/src/client/app/codegen/vue3.ts +80 -22
- package/src/client/app/components/base/BaseEmpty.vue +17 -1
- package/src/client/app/components/base/BaseOverflowMenu.vue +118 -0
- package/src/client/app/components/base/BaseOverflowTab.vue +46 -0
- package/src/client/app/components/exposed/Story.vue +33 -1
- package/src/client/app/components/exposed/Variant.vue +19 -1
- package/src/client/app/components/panel/PaneTabs.vue +64 -0
- package/src/client/app/components/{story → panel}/StoryControls.vue +6 -1
- package/src/client/app/components/{story → panel}/StoryDocs.vue +18 -11
- package/src/client/app/components/panel/StoryEvent.vue +53 -0
- package/src/client/app/components/panel/StoryEvents.vue +45 -0
- package/{dist/client/app/components/story → src/client/app/components/panel}/StorySidePanel.vue +17 -20
- package/{dist/client/app/components/story → src/client/app/components/panel}/StorySourceCode.vue +24 -14
- package/src/client/app/components/sandbox/SandboxVue3.vue +16 -4
- package/src/client/app/components/sandbox/lib.ts +3 -1
- package/src/client/app/components/search/SearchLoading.vue +16 -0
- package/src/client/app/components/search/SearchModal.vue +12 -149
- package/src/client/app/components/search/SearchPane.vue +210 -0
- package/src/client/app/components/search/search-data.ts +9 -0
- package/src/client/app/components/story/StoryResponsivePreview.vue +9 -98
- package/src/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +39 -0
- package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
- package/src/client/app/components/story/StoryVariantSingleView.vue +13 -6
- package/src/client/app/components/story/StoryView.vue +17 -3
- package/src/client/app/components/story/StoryViewer.vue +2 -92
- package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantBackground.vue +3 -3
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantNewTab.vue +2 -2
- package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantResponsiveSize.vue +3 -3
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantTitle.vue +1 -1
- package/src/client/app/components/tree/StoryGroup.vue +4 -4
- package/src/client/app/components/tree/StoryListFolder.vue +4 -4
- package/src/client/app/components/tree/StoryListItem.vue +4 -1
- package/src/client/app/router.ts +4 -1
- package/src/client/app/sandbox.ts +11 -1
- package/src/client/app/stores/events.ts +36 -0
- package/{dist/client/app/stores/story.ts → src/client/app/stores/folder.ts} +16 -23
- package/src/client/app/stores/story.ts +21 -40
- package/src/client/app/style/main.pcss +5 -0
- package/src/client/app/style/sandbox.css +2 -0
- package/src/client/app/style/transitions.pcss +13 -0
- package/src/client/app/types.ts +5 -0
- package/src/client/app/util/const.ts +1 -0
- package/src/client/app/util/events.ts +30 -0
- package/src/client/app/util/mapping.ts +4 -2
- package/src/client/index.ts +4 -3
- package/src/client/server/index.ts +14 -27
- package/{dist/client/server/Story.server.vue → src/client/server/vue3/Story.vue} +14 -3
- package/src/client/server/{Variant.server.vue → vue3/Variant.vue} +0 -0
- package/{dist/client/server/index.ts → src/client/server/vue3/run.ts} +10 -4
- package/src/node/alias.ts +4 -2
- package/src/node/build.ts +86 -21
- package/src/node/builtin-plugins/tailwind-tokens.ts +521 -0
- package/src/node/collect/index.ts +3 -1
- package/src/node/collect/worker.ts +7 -2
- package/src/node/commands/preview.ts +4 -33
- package/src/node/config.ts +53 -27
- package/src/node/context.ts +3 -3
- package/src/node/index.ts +1 -0
- package/src/node/load.ts +63 -0
- package/src/node/plugin.ts +75 -252
- package/src/node/preview.ts +56 -0
- package/src/node/search.ts +75 -0
- package/src/node/server.ts +49 -23
- package/src/node/stories.ts +4 -4
- package/src/node/types.ts +1 -0
- package/src/node/util/find-up.ts +24 -0
- package/src/node/vite.ts +296 -0
- package/tailwind.config.cjs +1 -0
- package/dist/client/app/codegen/serialize-js.ts +0 -119
- package/dist/client/app/codegen/util.ts +0 -79
- package/dist/client/app/codegen/vue3.ts +0 -276
- package/dist/client/app/components/sandbox/lib.ts +0 -8
- package/dist/client/app/global-components.ts +0 -13
- package/dist/client/app/index.ts +0 -28
- package/dist/client/app/router.ts +0 -17
- package/dist/client/app/sandbox.ts +0 -94
- package/dist/client/app/stores/preview-settings.ts +0 -17
- package/dist/client/app/types.ts +0 -78
- package/dist/client/app/util/config.ts +0 -6
- package/dist/client/app/util/const.ts +0 -3
- package/dist/client/app/util/dark.ts +0 -4
- package/dist/client/app/util/env.ts +0 -1
- package/dist/client/app/util/keyboard.ts +0 -99
- package/dist/client/app/util/mapping.ts +0 -48
- package/dist/client/app/util/preview-settings.ts +0 -8
- package/dist/client/app/util/reactivity.ts +0 -22
- package/dist/client/app/util/responsive.ts +0 -3
- package/dist/client/app/util/scroll.ts +0 -31
- package/dist/client/app/util/tooltip.ts +0 -13
- package/dist/client/app/util/variant.ts +0 -20
- package/dist/client/index.ts +0 -12
- package/dist/client/shim.d.ts +0 -5
package/dist/client/app/types.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { RouteLocationRaw } from 'vue-router'
|
|
2
|
-
|
|
3
|
-
export interface StoryFile {
|
|
4
|
-
id: string
|
|
5
|
-
framework: string
|
|
6
|
-
component: any
|
|
7
|
-
story: Story
|
|
8
|
-
path: string[]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface Story {
|
|
12
|
-
id: string
|
|
13
|
-
title: string
|
|
14
|
-
group?: string
|
|
15
|
-
variants: Variant[]
|
|
16
|
-
layout?: {
|
|
17
|
-
type: 'single'
|
|
18
|
-
} | {
|
|
19
|
-
type: 'grid'
|
|
20
|
-
width?: number | string
|
|
21
|
-
}
|
|
22
|
-
icon?: string
|
|
23
|
-
iconColor?: string
|
|
24
|
-
file?: StoryFile
|
|
25
|
-
lastSelectedVariant?: Variant
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface Variant {
|
|
29
|
-
id: string
|
|
30
|
-
title: string
|
|
31
|
-
icon?: string
|
|
32
|
-
iconColor?: string
|
|
33
|
-
initState?: () => any
|
|
34
|
-
slots?: () => Readonly<any>
|
|
35
|
-
state?: any
|
|
36
|
-
source?: string
|
|
37
|
-
responsiveDisabled?: boolean
|
|
38
|
-
configReady?: boolean
|
|
39
|
-
previewReady?: boolean
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type TreeLeaf = {
|
|
43
|
-
title: string
|
|
44
|
-
index: number
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export type TreeFolder = {
|
|
48
|
-
title: string
|
|
49
|
-
children: (TreeFolder | TreeLeaf)[]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface TreeGroup {
|
|
53
|
-
group: true
|
|
54
|
-
id: string
|
|
55
|
-
title: string
|
|
56
|
-
children: (TreeFolder | TreeLeaf)[]
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export type Tree = (TreeGroup | TreeFolder | TreeLeaf)[]
|
|
60
|
-
|
|
61
|
-
export interface SearchResult {
|
|
62
|
-
kind: 'story' | 'variant'
|
|
63
|
-
rank: number
|
|
64
|
-
id: string
|
|
65
|
-
title: string
|
|
66
|
-
route: RouteLocationRaw
|
|
67
|
-
path?: string[]
|
|
68
|
-
icon?: string
|
|
69
|
-
iconColor?: string
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface PreviewSettings {
|
|
73
|
-
responsiveWidth: number
|
|
74
|
-
responsiveHeight: number
|
|
75
|
-
rotate: boolean
|
|
76
|
-
backgroundColor: string
|
|
77
|
-
checkerboard: boolean
|
|
78
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { HistoireConfig } from '../../../node/config'
|
|
2
|
-
// @ts-expect-error virtual module
|
|
3
|
-
import { config as configRaw, logos as logosRaw } from '$histoire-config'
|
|
4
|
-
|
|
5
|
-
export const histoireConfig: HistoireConfig = configRaw
|
|
6
|
-
export const customLogos: HistoireConfig['theme']['logo'] = logosRaw
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const isMac = navigator.platform.toLowerCase().includes('mac')
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { useEventListener } from '@vueuse/core'
|
|
2
|
-
import { isRef, Ref } from 'vue'
|
|
3
|
-
import { isMac } from './env.js'
|
|
4
|
-
|
|
5
|
-
export type KeyboardShortcut = string[]
|
|
6
|
-
|
|
7
|
-
export type KeyboardHandler = (event: KeyboardEvent) => unknown
|
|
8
|
-
|
|
9
|
-
export interface KeyboardShortcutOptions {
|
|
10
|
-
event?: 'keyup' | 'keydown' | 'keypress'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function onKeyboardShortcut (shortcut: KeyboardShortcut | Ref<KeyboardShortcut>, handler: KeyboardHandler, options: KeyboardShortcutOptions = {}) {
|
|
14
|
-
useEventListener(options.event ?? 'keydown', event => {
|
|
15
|
-
if (isMatchingShortcut(isRef(shortcut) ? shortcut.value : shortcut)) {
|
|
16
|
-
handler(event)
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const modifiers: { [i: string]: { key: string, pressed: boolean } } = {
|
|
22
|
-
ctrl: { key: 'Control', pressed: false },
|
|
23
|
-
alt: { key: 'Alt', pressed: false },
|
|
24
|
-
shift: { key: 'Shift', pressed: false },
|
|
25
|
-
meta: { key: 'Meta', pressed: false },
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const pressedKeys = new Set<string>()
|
|
29
|
-
|
|
30
|
-
window.addEventListener('keydown', event => {
|
|
31
|
-
for (const i in modifiers) {
|
|
32
|
-
const mod = modifiers[i]
|
|
33
|
-
if (mod.key === event.key) {
|
|
34
|
-
mod.pressed = true
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
pressedKeys.add(event.key.toLocaleLowerCase())
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
window.addEventListener('keyup', event => {
|
|
42
|
-
requestAnimationFrame(() => {
|
|
43
|
-
pressedKeys.clear()
|
|
44
|
-
for (const i in modifiers) {
|
|
45
|
-
const mod = modifiers[i]
|
|
46
|
-
if (mod.key === event.key) {
|
|
47
|
-
mod.pressed = false
|
|
48
|
-
break
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
window.addEventListener('blur', () => {
|
|
55
|
-
pressedKeys.clear()
|
|
56
|
-
for (const i in modifiers) {
|
|
57
|
-
const mod = modifiers[i]
|
|
58
|
-
mod.pressed = false
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
function isMatchingShortcut (shortcut: KeyboardShortcut): boolean {
|
|
63
|
-
for (const combination of shortcut) {
|
|
64
|
-
if (isMatchingCombination(combination.toLowerCase())) {
|
|
65
|
-
return true
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return false
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function isMatchingCombination (combination: string): boolean {
|
|
72
|
-
const splitted = combination.split('+').map(key => key.trim())
|
|
73
|
-
const targetKey = splitted.pop()
|
|
74
|
-
for (const mod in modifiers) {
|
|
75
|
-
const containsMod = splitted.includes(mod)
|
|
76
|
-
const isPressed = modifiers[mod].pressed
|
|
77
|
-
if (containsMod !== isPressed) {
|
|
78
|
-
return false
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return pressedKeys.has(targetKey)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function formatKey (key: string) {
|
|
85
|
-
key = key.toLowerCase()
|
|
86
|
-
if (key === 'ctrl') {
|
|
87
|
-
return isMac ? '^' : 'Ctrl'
|
|
88
|
-
}
|
|
89
|
-
if (key === 'alt') {
|
|
90
|
-
return isMac ? '⎇' : 'Alt'
|
|
91
|
-
}
|
|
92
|
-
if (key === 'shift') {
|
|
93
|
-
return '⇧'
|
|
94
|
-
}
|
|
95
|
-
if (key === 'meta') {
|
|
96
|
-
return '⌘'
|
|
97
|
-
}
|
|
98
|
-
return key.charAt(0).toUpperCase() + key.substring(1).toLowerCase()
|
|
99
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { markRaw } from 'vue'
|
|
2
|
-
import type { StoryFile, Variant } from '../types'
|
|
3
|
-
|
|
4
|
-
export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
|
|
5
|
-
const result: StoryFile = {
|
|
6
|
-
...file,
|
|
7
|
-
component: markRaw(file.component),
|
|
8
|
-
story: {
|
|
9
|
-
...file.story,
|
|
10
|
-
title: file.story.title,
|
|
11
|
-
file: markRaw(file),
|
|
12
|
-
variants: file.story.variants.map(v => mapVariant(v)),
|
|
13
|
-
},
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (existingFile) {
|
|
17
|
-
for (const index in result.story.variants) {
|
|
18
|
-
const variant = result.story.variants[index]
|
|
19
|
-
const existingVariant = existingFile.story.variants[index]
|
|
20
|
-
if (existingVariant) {
|
|
21
|
-
for (const key in existingVariant) {
|
|
22
|
-
if (typeof existingVariant[key] !== 'undefined') {
|
|
23
|
-
if (key === 'state') {
|
|
24
|
-
Object.assign(variant.state, existingVariant.state)
|
|
25
|
-
continue
|
|
26
|
-
}
|
|
27
|
-
variant[key] = existingVariant[key]
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (existingFile.story.lastSelectedVariant) {
|
|
33
|
-
result.story.lastSelectedVariant = result.story.variants.find(v => v.id === existingFile.story.lastSelectedVariant.id)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return result
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function mapVariant (variant: Variant): Variant {
|
|
41
|
-
return {
|
|
42
|
-
...variant,
|
|
43
|
-
state: {},
|
|
44
|
-
initState: null,
|
|
45
|
-
slots: () => ({}),
|
|
46
|
-
previewReady: false,
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { reactive } from 'vue'
|
|
2
|
-
import type { PreviewSettings } from '../types'
|
|
3
|
-
|
|
4
|
-
export const receivedSettings = reactive<PreviewSettings>({} as PreviewSettings)
|
|
5
|
-
|
|
6
|
-
export function applyPreviewSettings (settings: PreviewSettings) {
|
|
7
|
-
Object.assign(receivedSettings, settings)
|
|
8
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { unref, isRef } from 'vue'
|
|
2
|
-
|
|
3
|
-
const isObject = (val) => val !== null && typeof val === 'object'
|
|
4
|
-
|
|
5
|
-
export function toRawDeep (val) {
|
|
6
|
-
const unwrappedValue = isRef(val) ? unref(val) : val
|
|
7
|
-
|
|
8
|
-
if (!isObject(unwrappedValue)) {
|
|
9
|
-
return unwrappedValue
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (Array.isArray(unwrappedValue)) {
|
|
13
|
-
return unwrappedValue.map(toRawDeep)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return toRawObject(unwrappedValue)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const toRawObject = (obj: Record<any, any>) => Object.keys(obj).reduce((raw, key) => {
|
|
20
|
-
raw[key] = toRawDeep(obj[key])
|
|
21
|
-
return raw
|
|
22
|
-
}, {})
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { watch, onMounted, Ref } from 'vue'
|
|
2
|
-
import scrollIntoView from 'scroll-into-view-if-needed'
|
|
3
|
-
|
|
4
|
-
export function useScrollOnActive (active: Ref<boolean>, el: Ref<HTMLElement>) {
|
|
5
|
-
watch(active, value => {
|
|
6
|
-
if (value) {
|
|
7
|
-
autoScroll()
|
|
8
|
-
}
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
function autoScroll () {
|
|
12
|
-
if (el.value) {
|
|
13
|
-
scrollIntoView(el.value, {
|
|
14
|
-
scrollMode: 'if-needed',
|
|
15
|
-
block: 'center',
|
|
16
|
-
inline: 'nearest',
|
|
17
|
-
behavior: 'smooth',
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
onMounted(() => {
|
|
23
|
-
if (active.value) {
|
|
24
|
-
autoScroll()
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
autoScroll,
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isMac } from './env.js'
|
|
2
|
-
import { formatKey } from './keyboard.js'
|
|
3
|
-
|
|
4
|
-
export function makeTooltip (descriptionHtml: string, keyboardShortcut: ({ isMac: boolean }) => string) {
|
|
5
|
-
return {
|
|
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
|
-
html: true,
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function genKeyboardShortcutHtml (shortcut: string) {
|
|
12
|
-
return shortcut.split('+').map(k => k.trim()).map(key => `<span class="htw-bg-gray-500 htw-border-b-2 htw-border-gray-600 htw-px-1 htw-rounded-sm">${formatKey(key)}</span>`).join('')
|
|
13
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { computed, Ref } from 'vue'
|
|
2
|
-
import { useRoute } from 'vue-router'
|
|
3
|
-
import { Variant } from '../types'
|
|
4
|
-
|
|
5
|
-
export function useCurrentVariantRoute (variant: Ref<Variant>) {
|
|
6
|
-
const route = useRoute()
|
|
7
|
-
const isActive = computed(() => route.query.variantId === variant.value.id)
|
|
8
|
-
const targetRoute = computed(() => ({
|
|
9
|
-
...route,
|
|
10
|
-
query: {
|
|
11
|
-
...route.query,
|
|
12
|
-
variantId: variant.value.id,
|
|
13
|
-
},
|
|
14
|
-
}))
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
isActive,
|
|
18
|
-
targetRoute,
|
|
19
|
-
}
|
|
20
|
-
}
|
package/dist/client/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { App } from 'vue'
|
|
2
|
-
import type { Story, Variant } from './app/types.js'
|
|
3
|
-
|
|
4
|
-
export type Vue3StorySetupHandler = (payload: {
|
|
5
|
-
app: App
|
|
6
|
-
story: Story
|
|
7
|
-
variant: Variant
|
|
8
|
-
}) => Promise<void> | void
|
|
9
|
-
|
|
10
|
-
export function defineVue3StorySetup (handler: Vue3StorySetupHandler): Vue3StorySetupHandler {
|
|
11
|
-
return handler
|
|
12
|
-
}
|