@histoire/app 0.17.16 → 0.17.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundled/App.vue2.js +1 -1
- package/dist/bundled/components/app/AppHeader.vue2.js +1 -1
- package/dist/bundled/components/app/AppLogo.vue2.js +1 -1
- package/dist/bundled/components/app/Breadcrumb.vue.js +1 -1
- package/dist/bundled/components/app/Breadcrumb.vue2.js +3 -3
- package/dist/bundled/components/app/HomeCounter.vue2.js +2 -7
- package/dist/bundled/components/base/BaseCheckbox.vue2.js +1 -2
- package/dist/bundled/components/base/BaseIcon.vue.js +1 -1
- package/dist/bundled/components/base/BaseIcon.vue2.js +1 -1
- package/dist/bundled/components/base/BaseOverflowMenu.vue2.js +4 -4
- package/dist/bundled/components/base/BaseSplitPane.vue.js +1 -1
- package/dist/bundled/components/base/BaseSplitPane.vue2.js +2 -3
- package/dist/bundled/components/panel/PaneTabs.vue2.js +1 -1
- package/dist/bundled/components/panel/StoryDocs.vue2.js +4 -4
- package/dist/bundled/components/panel/StorySourceCode.vue.js +1 -1
- package/dist/bundled/components/panel/StorySourceCode.vue2.js +1 -1
- package/dist/bundled/components/search/SearchItem.vue.js +1 -1
- package/dist/bundled/components/search/SearchItem.vue2.js +2 -2
- package/dist/bundled/components/search/SearchPane.vue2.js +2 -2
- package/dist/bundled/components/story/StoryResponsivePreview.vue.js +1 -1
- package/dist/bundled/components/story/StoryResponsivePreview.vue2.js +5 -5
- package/dist/bundled/components/story/StoryVariantGrid.vue2.js +4 -4
- package/dist/bundled/components/story/StoryVariantGridItem.vue.js +1 -1
- package/dist/bundled/components/story/StoryVariantGridItem.vue2.js +6 -7
- package/dist/bundled/components/story/StoryVariantListItem.vue.js +1 -1
- package/dist/bundled/components/story/StoryVariantListItem.vue2.js +3 -3
- package/dist/bundled/components/story/StoryVariantSingle.vue.js +1 -1
- package/dist/bundled/components/story/StoryVariantSingle.vue2.js +5 -5
- package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue2.js +1 -1
- package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue2.js +1 -1
- package/dist/bundled/components/story/StoryView.vue2.js +1 -1
- package/dist/bundled/components/story/StoryViewer.vue.js +1 -1
- package/dist/bundled/components/story/StoryViewer.vue2.js +3 -3
- package/dist/bundled/components/tree/StoryGroup.vue2.js +2 -2
- package/dist/bundled/components/tree/StoryListFolder.vue.js +1 -1
- package/dist/bundled/components/tree/StoryListFolder.vue2.js +4 -4
- package/dist/bundled/components/tree/StoryListItem.vue.js +1 -1
- package/dist/bundled/components/tree/StoryListItem.vue2.js +5 -5
- package/dist/bundled/sandbox.js +1 -1
- package/dist/bundled/style.css +50 -50
- package/dist/bundled/util/commands.js +1 -1
- package/dist/bundled/util/state.js +2 -2
- package/dist/style.css +1 -1
- package/package.json +7 -7
- package/scripts/copy.mjs +1 -1
- package/scripts/watchAndCopy.mjs +4 -4
- package/src/app/App.vue +6 -6
- package/src/app/api.ts +1 -1
- package/src/app/components/HomeView.vue +4 -3
- package/src/app/components/app/AppHeader.vue +1 -1
- package/src/app/components/app/AppLogo.vue +3 -3
- package/src/app/components/app/Breadcrumb.vue +4 -4
- package/src/app/components/app/HomeCounter.vue +1 -10
- package/src/app/components/app/MobileOverlay.vue +1 -1
- package/src/app/components/base/BaseCheckbox.vue +2 -3
- package/src/app/components/base/BaseIcon.vue +2 -2
- package/src/app/components/base/BaseKeyboardShortcut.vue +1 -1
- package/src/app/components/base/BaseListItem.vue +2 -2
- package/src/app/components/base/BaseListItemLink.vue +3 -3
- package/src/app/components/base/BaseOverflowMenu.vue +4 -4
- package/src/app/components/base/BaseSelect.vue +5 -4
- package/src/app/components/base/BaseSplitPane.vue +19 -15
- package/src/app/components/command/CommandPrompts.vue +6 -5
- package/src/app/components/command/CommandPromptsModal.vue +2 -1
- package/src/app/components/command/PromptSelect.vue +6 -4
- package/src/app/components/command/PromptText.vue +4 -3
- package/src/app/components/panel/ControlsComponentPropItem.vue +1 -1
- package/src/app/components/panel/ControlsComponentProps.vue +1 -1
- package/src/app/components/panel/ControlsComponentState.vue +1 -1
- package/src/app/components/panel/PaneTabs.vue +1 -1
- package/src/app/components/panel/StatePresets.vue +13 -10
- package/src/app/components/panel/StoryControls.vue +2 -2
- package/src/app/components/panel/StoryDocs.vue +28 -24
- package/src/app/components/panel/StoryEvent.vue +2 -2
- package/src/app/components/panel/StoryEvents.vue +2 -2
- package/src/app/components/panel/StorySourceCode.vue +10 -6
- package/src/app/components/search/SearchItem.vue +4 -3
- package/src/app/components/search/SearchItemContent.vue +3 -3
- package/src/app/components/search/SearchModal.vue +2 -1
- package/src/app/components/search/SearchPane.vue +18 -18
- package/src/app/components/search/search-docs-data.ts +2 -2
- package/src/app/components/search/search-title-data.ts +2 -2
- package/src/app/components/story/GenericMountStory.vue +1 -1
- package/src/app/components/story/GenericRenderStory.vue +3 -2
- package/src/app/components/story/StoryResponsivePreview.vue +14 -13
- package/src/app/components/story/StoryVariantGrid.vue +9 -8
- package/src/app/components/story/StoryVariantGridItem.vue +7 -7
- package/src/app/components/story/StoryVariantListItem.vue +3 -2
- package/src/app/components/story/StoryVariantSingle.vue +3 -3
- package/src/app/components/story/StoryVariantSinglePreviewNative.vue +2 -2
- package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +10 -10
- package/src/app/components/story/StoryView.vue +4 -4
- package/src/app/components/story/StoryViewer.vue +2 -3
- package/src/app/components/toolbar/ToolbarNewTab.vue +1 -1
- package/src/app/components/tree/StoryGroup.vue +4 -4
- package/src/app/components/tree/StoryList.vue +1 -1
- package/src/app/components/tree/StoryListFolder.vue +4 -4
- package/src/app/components/tree/StoryListItem.vue +3 -3
- package/src/app/index.ts +2 -3
- package/src/app/plugin.ts +4 -3
- package/src/app/router.ts +2 -2
- package/src/app/sandbox.ts +12 -11
- package/src/app/stores/command.ts +4 -3
- package/src/app/stores/events.ts +4 -4
- package/src/app/stores/folder.ts +9 -7
- package/src/app/stores/story.ts +4 -4
- package/src/app/types.ts +2 -2
- package/src/app/util/commands.ts +5 -4
- package/src/app/util/dark.ts +2 -2
- package/src/app/util/docs.ts +6 -4
- package/src/app/util/events.ts +4 -3
- package/src/app/util/keyboard.ts +9 -8
- package/src/app/util/mapping.ts +8 -5
- package/src/app/util/open-in-editor.ts +1 -1
- package/src/app/util/preview-settings.ts +3 -3
- package/src/app/util/sandbox.ts +2 -3
- package/src/app/util/scroll.ts +5 -4
- package/src/app/util/select.ts +5 -4
- package/src/app/util/state.ts +6 -5
- package/src/app/util/tooltip.ts +2 -2
- package/src/app/util/variant.ts +3 -2
- package/src/shim.d.ts +0 -6
- package/src/virtual.d.ts +1 -0
- package/tailwind.config.cjs +19 -20
- package/tsconfig.json +26 -26
- package/vite.config.ts +7 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import { useDebounce, useFocus } from '@vueuse/core'
|
|
3
3
|
import { computed, ref, watch } from 'vue'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
5
|
import * as flexsearch from 'flexsearch'
|
|
@@ -10,12 +10,12 @@ import { registeredCommands } from 'virtual:$histoire-commands'
|
|
|
10
10
|
import { useStoryStore } from '../../stores/story'
|
|
11
11
|
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
12
12
|
import type { SearchResult, SearchResultType, Story, Variant } from '../../types'
|
|
13
|
-
import SearchItem from './SearchItem.vue'
|
|
14
|
-
import { searchData, onUpdate } from './search-title-data'
|
|
15
|
-
import type { SearchData } from './types'
|
|
16
13
|
import { builtinCommands, getCommandContext } from '../../util/commands.js'
|
|
17
14
|
import { useCommandStore } from '../../stores/command.js'
|
|
18
15
|
import { useSelection } from '../../util/select.js'
|
|
16
|
+
import SearchItem from './SearchItem.vue'
|
|
17
|
+
import { onUpdate, searchData } from './search-title-data'
|
|
18
|
+
import type { SearchData } from './types'
|
|
19
19
|
|
|
20
20
|
const DocSearchData = () => import('./search-docs-data')
|
|
21
21
|
|
|
@@ -30,7 +30,7 @@ const emit = defineEmits({
|
|
|
30
30
|
close: () => true,
|
|
31
31
|
})
|
|
32
32
|
|
|
33
|
-
function close
|
|
33
|
+
function close() {
|
|
34
34
|
emit('close')
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -41,7 +41,7 @@ const { focused } = useFocus(input, {
|
|
|
41
41
|
initialValue: true,
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
-
watch(() => props.shown, value => {
|
|
44
|
+
watch(() => props.shown, (value) => {
|
|
45
45
|
if (value) {
|
|
46
46
|
requestAnimationFrame(() => {
|
|
47
47
|
focused.value = true
|
|
@@ -60,7 +60,7 @@ const storyStore = useStoryStore()
|
|
|
60
60
|
let titleSearchIndex: flexsearch.Document<any, any>
|
|
61
61
|
let titleIdMap: SearchData['idMap']
|
|
62
62
|
|
|
63
|
-
function createIndex
|
|
63
|
+
function createIndex() {
|
|
64
64
|
return new flexsearch.Document({
|
|
65
65
|
preset: 'match',
|
|
66
66
|
document: {
|
|
@@ -76,7 +76,7 @@ function createIndex () {
|
|
|
76
76
|
})
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
async function loadSearchIndex
|
|
79
|
+
async function loadSearchIndex(data: SearchData) {
|
|
80
80
|
titleSearchIndex = createIndex()
|
|
81
81
|
|
|
82
82
|
for (const key of Object.keys(data.index)) {
|
|
@@ -88,15 +88,15 @@ async function loadSearchIndex (data: SearchData) {
|
|
|
88
88
|
|
|
89
89
|
loadSearchIndex(searchData)
|
|
90
90
|
// Handle HMR
|
|
91
|
-
onUpdate(searchData => {
|
|
91
|
+
onUpdate((searchData) => {
|
|
92
92
|
loadSearchIndex(searchData)
|
|
93
93
|
})
|
|
94
94
|
|
|
95
95
|
let docSearchIndex: flexsearch.Document<any, any>
|
|
96
96
|
let docIdMap: SearchData['idMap']
|
|
97
97
|
|
|
98
|
-
async function loadDocSearchIndex
|
|
99
|
-
async function load
|
|
98
|
+
async function loadDocSearchIndex() {
|
|
99
|
+
async function load(data: SearchData) {
|
|
100
100
|
docSearchIndex = createIndex()
|
|
101
101
|
|
|
102
102
|
for (const key of Object.keys(data.index)) {
|
|
@@ -114,7 +114,7 @@ async function loadDocSearchIndex () {
|
|
|
114
114
|
|
|
115
115
|
load(searchDataModule.searchData)
|
|
116
116
|
// Handle HMR
|
|
117
|
-
searchDataModule.onUpdate(searchData => {
|
|
117
|
+
searchDataModule.onUpdate((searchData) => {
|
|
118
118
|
load(searchData)
|
|
119
119
|
})
|
|
120
120
|
}
|
|
@@ -125,7 +125,7 @@ loadDocSearchIndex()
|
|
|
125
125
|
|
|
126
126
|
const titleResults = ref<SearchResult[]>([])
|
|
127
127
|
|
|
128
|
-
watch(rateLimitedSearch, async value => {
|
|
128
|
+
watch(rateLimitedSearch, async (value) => {
|
|
129
129
|
const list: SearchResult[] = []
|
|
130
130
|
const raw = await titleSearchIndex.search(value)
|
|
131
131
|
let rank = 0
|
|
@@ -155,7 +155,7 @@ watch(rateLimitedSearch, async value => {
|
|
|
155
155
|
|
|
156
156
|
const docsResults = ref<SearchResult[]>([])
|
|
157
157
|
|
|
158
|
-
async function searchOnDocField
|
|
158
|
+
async function searchOnDocField(query: string) {
|
|
159
159
|
if (docSearchIndex) {
|
|
160
160
|
const list: SearchResult[] = []
|
|
161
161
|
const raw = await docSearchIndex.search(query)
|
|
@@ -179,7 +179,7 @@ async function searchOnDocField (query: string) {
|
|
|
179
179
|
|
|
180
180
|
watch(rateLimitedSearch, searchOnDocField)
|
|
181
181
|
|
|
182
|
-
function storyResultFactory
|
|
182
|
+
function storyResultFactory(story: Story, rank: number, type: SearchResultType = 'title'): SearchResult {
|
|
183
183
|
return {
|
|
184
184
|
kind: 'story',
|
|
185
185
|
rank,
|
|
@@ -202,7 +202,7 @@ function storyResultFactory (story: Story, rank: number, type: SearchResultType
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
function variantResultFactory
|
|
205
|
+
function variantResultFactory(story: Story, variant: Variant, rank: number, type: SearchResultType = 'title'): SearchResult {
|
|
206
206
|
return {
|
|
207
207
|
kind: 'variant',
|
|
208
208
|
rank,
|
|
@@ -240,14 +240,14 @@ const commandResults = computed(() => {
|
|
|
240
240
|
return allCommands
|
|
241
241
|
.filter(command => !command.showIf || command.showIf(commandCtx))
|
|
242
242
|
.filter(command => command.label.toLowerCase().includes(searchText) || command.searchText?.toLowerCase().includes(searchText))
|
|
243
|
-
.map(
|
|
243
|
+
.map(command => commandResultFactory(command, 0))
|
|
244
244
|
}
|
|
245
245
|
return []
|
|
246
246
|
})
|
|
247
247
|
|
|
248
248
|
const commandStore = useCommandStore()
|
|
249
249
|
|
|
250
|
-
function commandResultFactory
|
|
250
|
+
function commandResultFactory(command: ClientCommand, rank: number): SearchResult {
|
|
251
251
|
return {
|
|
252
252
|
kind: 'command',
|
|
253
253
|
rank,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { markRaw } from 'vue'
|
|
2
|
-
import {
|
|
2
|
+
import { onUpdate as _onUpdate, searchData as _searchData } from 'virtual:$histoire-search-docs-data'
|
|
3
3
|
import type { SearchData } from './types.js'
|
|
4
4
|
|
|
5
5
|
export const searchData: SearchData = markRaw(_searchData)
|
|
6
6
|
|
|
7
|
-
export function onUpdate
|
|
7
|
+
export function onUpdate(cb: (data: SearchData) => unknown) {
|
|
8
8
|
_onUpdate(cb)
|
|
9
9
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { markRaw } from 'vue'
|
|
2
|
-
import {
|
|
2
|
+
import { onUpdate as _onUpdate, searchData as _searchData } from 'virtual:$histoire-search-title-data'
|
|
3
3
|
import type { SearchData } from './types.js'
|
|
4
4
|
|
|
5
5
|
export const searchData: SearchData = markRaw(_searchData)
|
|
6
6
|
|
|
7
|
-
export function onUpdate
|
|
7
|
+
export function onUpdate(cb: (data: SearchData) => unknown) {
|
|
8
8
|
_onUpdate(cb)
|
|
9
9
|
}
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
|
|
7
7
|
<script lang="ts" setup>
|
|
8
8
|
import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
|
|
9
|
-
import { ref, watchEffect
|
|
9
|
+
import { markRaw, ref, watchEffect } from 'vue'
|
|
10
10
|
import type { Story } from '../../types'
|
|
11
11
|
|
|
12
12
|
const props = defineProps<{
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
|
|
7
7
|
<script lang="ts" setup>
|
|
8
8
|
import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
|
|
9
|
-
import { ref, watchEffect
|
|
9
|
+
import { markRaw, ref, watchEffect } from 'vue'
|
|
10
10
|
import type { Story } from '../../types'
|
|
11
11
|
|
|
12
12
|
const props = defineProps<{
|
|
@@ -21,7 +21,8 @@ watchEffect(async () => {
|
|
|
21
21
|
try {
|
|
22
22
|
const pluginModule = await clientPlugin()
|
|
23
23
|
mountComponent.value = markRaw(pluginModule.RenderStory)
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
25
26
|
console.error(e)
|
|
26
27
|
throw e
|
|
27
28
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import type { Ref } from 'vue'
|
|
3
|
+
import { computed, onUnmounted, ref } from 'vue'
|
|
3
4
|
import { useEventListener } from '@vueuse/core'
|
|
4
5
|
import { Icon } from '@iconify/vue'
|
|
6
|
+
import { VTooltip as vTooltip } from 'floating-vue'
|
|
5
7
|
import HatchedPattern from '../misc/HatchedPattern.vue'
|
|
6
8
|
import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
|
|
7
9
|
import { usePreviewSettingsStore } from '../../stores/preview-settings'
|
|
8
|
-
import { Variant } from '../../types'
|
|
9
|
-
import { VTooltip as vTooltip } from 'floating-vue'
|
|
10
|
+
import type { Variant } from '../../types'
|
|
10
11
|
|
|
11
12
|
const props = defineProps<{
|
|
12
13
|
variant: Variant
|
|
@@ -23,7 +24,7 @@ onUnmounted(() => {
|
|
|
23
24
|
onUnmountedCleanupFns.forEach(fn => fn())
|
|
24
25
|
})
|
|
25
26
|
|
|
26
|
-
function addWindowListener
|
|
27
|
+
function addWindowListener(event: string, listener: (event: any) => unknown) {
|
|
27
28
|
window.addEventListener(event, listener)
|
|
28
29
|
const removeListener = () => window.removeEventListener(event, listener)
|
|
29
30
|
onUnmountedCleanupFns.push(removeListener)
|
|
@@ -33,8 +34,8 @@ function addWindowListener (event: string, listener: (event: any) => unknown) {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
function useDragger
|
|
37
|
-
function onMouseDown
|
|
37
|
+
function useDragger(el: Ref<HTMLDivElement>, value: Ref<number>, min: number, max: number, axis: 'x' | 'y') {
|
|
38
|
+
function onMouseDown(event: MouseEvent) {
|
|
38
39
|
event.preventDefault()
|
|
39
40
|
event.stopPropagation()
|
|
40
41
|
const start = axis === 'x' ? event.clientX : event.clientY
|
|
@@ -46,7 +47,7 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
|
|
|
46
47
|
addWindowListener('mouseup', onMouseUp),
|
|
47
48
|
]
|
|
48
49
|
|
|
49
|
-
function onMouseMove
|
|
50
|
+
function onMouseMove(event: MouseEvent) {
|
|
50
51
|
const snapTarget = (axis === 'x' ? previewWrapper.value.clientWidth : previewWrapper.value.clientHeight)
|
|
51
52
|
const delta = (axis === 'x' ? event.clientX : event.clientY) - start
|
|
52
53
|
value.value = Math.max(min, Math.min(max, startValue + delta))
|
|
@@ -56,14 +57,14 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
function onMouseUp
|
|
60
|
+
function onMouseUp() {
|
|
60
61
|
removeListeners.forEach(fn => fn())
|
|
61
62
|
resizing.value = false
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
useEventListener(el, 'mousedown', onMouseDown)
|
|
65
66
|
|
|
66
|
-
function onTouchStart
|
|
67
|
+
function onTouchStart(event: TouchEvent) {
|
|
67
68
|
event.preventDefault()
|
|
68
69
|
event.stopPropagation()
|
|
69
70
|
const start = axis === 'x' ? event.touches[0].clientX : event.touches[0].clientY
|
|
@@ -76,12 +77,12 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
|
|
|
76
77
|
addWindowListener('touchcancel', onTouchEnd),
|
|
77
78
|
]
|
|
78
79
|
|
|
79
|
-
function onTouchMove
|
|
80
|
+
function onTouchMove(event: TouchEvent) {
|
|
80
81
|
const delta = (axis === 'x' ? event.touches[0].clientX : event.touches[0].clientY) - start
|
|
81
82
|
value.value = Math.max(min, Math.min(max, startValue + delta))
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
function onTouchEnd
|
|
85
|
+
function onTouchEnd() {
|
|
85
86
|
removeListeners.forEach(fn => fn())
|
|
86
87
|
resizing.value = false
|
|
87
88
|
}
|
|
@@ -117,7 +118,7 @@ const finalHeight = computed(() => settings.rotate ? settings.responsiveWidth :
|
|
|
117
118
|
|
|
118
119
|
const isResponsiveEnabled = computed(() => !props.variant.responsiveDisabled)
|
|
119
120
|
|
|
120
|
-
const sizeTooltip = computed(() =>
|
|
121
|
+
const sizeTooltip = computed(() => `${responsiveWidth.value ?? 'Auto'} × ${responsiveHeight.value ?? 'Auto'}`)
|
|
121
122
|
</script>
|
|
122
123
|
|
|
123
124
|
<template>
|
|
@@ -140,7 +141,7 @@ const sizeTooltip = computed(() => (responsiveWidth.value ?? 'Auto') + ' × ' +
|
|
|
140
141
|
:class="isResponsiveEnabled ? {
|
|
141
142
|
'htw-w-fit': !!finalWidth,
|
|
142
143
|
'htw-h-fit': !!finalHeight,
|
|
143
|
-
'htw-h-full': !finalHeight
|
|
144
|
+
'htw-h-full': !finalHeight,
|
|
144
145
|
} : 'htw-h-full'"
|
|
145
146
|
>
|
|
146
147
|
<div
|
|
@@ -3,10 +3,10 @@ import { useResizeObserver } from '@vueuse/core'
|
|
|
3
3
|
import { computed, onMounted, ref, watch } from 'vue'
|
|
4
4
|
import { useStoryStore } from '../../stores/story'
|
|
5
5
|
import { isMobile } from '../../util/responsive'
|
|
6
|
-
import StoryVariantGridItem from './StoryVariantGridItem.vue'
|
|
7
6
|
import ToolbarBackground from '../toolbar/ToolbarBackground.vue'
|
|
8
7
|
import ToolbarTextDirection from '../toolbar/ToolbarTextDirection.vue'
|
|
9
8
|
import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
|
|
9
|
+
import StoryVariantGridItem from './StoryVariantGridItem.vue'
|
|
10
10
|
|
|
11
11
|
const storyStore = useStoryStore()
|
|
12
12
|
|
|
@@ -22,7 +22,7 @@ const gridTemplateWidth = computed(() => {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
if (typeof layoutWidth === 'number') {
|
|
25
|
-
return layoutWidth
|
|
25
|
+
return `${layoutWidth}px`
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return layoutWidth
|
|
@@ -44,7 +44,7 @@ useResizeObserver(el, () => {
|
|
|
44
44
|
updateSize()
|
|
45
45
|
})
|
|
46
46
|
|
|
47
|
-
function updateMaxCount
|
|
47
|
+
function updateMaxCount() {
|
|
48
48
|
if (!maxItemHeight.value) return
|
|
49
49
|
|
|
50
50
|
const width = el.value!.clientWidth - margin * 2
|
|
@@ -74,7 +74,7 @@ function updateMaxCount () {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function onItemResize
|
|
77
|
+
function onItemResize(w: number, h: number) {
|
|
78
78
|
itemWidth.value = w
|
|
79
79
|
if (maxItemHeight.value < h) {
|
|
80
80
|
maxItemHeight.value = h
|
|
@@ -93,16 +93,17 @@ const gridEl = ref<HTMLDivElement>(null)
|
|
|
93
93
|
const gridColumnWidth = ref(1)
|
|
94
94
|
const viewWidth = ref(1)
|
|
95
95
|
|
|
96
|
-
function updateSize
|
|
96
|
+
function updateSize() {
|
|
97
97
|
if (!el.value) return
|
|
98
98
|
viewWidth.value = el.value.clientWidth
|
|
99
99
|
|
|
100
100
|
if (!gridEl.value) return
|
|
101
101
|
|
|
102
102
|
if (gridTemplateWidth.value.endsWith('%')) {
|
|
103
|
-
gridColumnWidth.value = viewWidth.value * parseInt(gridTemplateWidth.value) / 100 - gap
|
|
104
|
-
}
|
|
105
|
-
|
|
103
|
+
gridColumnWidth.value = viewWidth.value * Number.parseInt(gridTemplateWidth.value) / 100 - gap
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
gridColumnWidth.value = Number.parseInt(gridTemplateWidth.value)
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import type { PropType } from 'vue'
|
|
3
|
+
import { computed, ref, toRefs } from 'vue'
|
|
3
4
|
import { Icon } from '@iconify/vue'
|
|
4
5
|
import { useRouter } from 'vue-router'
|
|
5
6
|
import { useResizeObserver } from '@vueuse/core'
|
|
@@ -12,9 +13,9 @@ import { getContrastColor } from '../../util/preview-settings'
|
|
|
12
13
|
import { histoireConfig } from '../../util/config'
|
|
13
14
|
import { isDark } from '../../util/dark'
|
|
14
15
|
import { getSourceCode } from '../../util/docs'
|
|
15
|
-
import GenericRenderStory from './GenericRenderStory.vue'
|
|
16
16
|
import ToolbarNewTab from '../toolbar/ToolbarNewTab.vue'
|
|
17
17
|
import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
|
|
18
|
+
import GenericRenderStory from './GenericRenderStory.vue'
|
|
18
19
|
|
|
19
20
|
const props = defineProps({
|
|
20
21
|
variant: {
|
|
@@ -29,8 +30,7 @@ const props = defineProps({
|
|
|
29
30
|
})
|
|
30
31
|
|
|
31
32
|
const emit = defineEmits({
|
|
32
|
-
|
|
33
|
-
resize: (width: number, height: number) => true,
|
|
33
|
+
resize: (_width: number, _height: number) => true,
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
const { variant } = toRefs(props)
|
|
@@ -39,7 +39,7 @@ const { isActive, targetRoute } = useCurrentVariantRoute(variant)
|
|
|
39
39
|
Object.assign(props.variant, {
|
|
40
40
|
previewReady: false,
|
|
41
41
|
})
|
|
42
|
-
function onReady
|
|
42
|
+
function onReady() {
|
|
43
43
|
Object.assign(props.variant, {
|
|
44
44
|
previewReady: true,
|
|
45
45
|
})
|
|
@@ -47,7 +47,7 @@ function onReady () {
|
|
|
47
47
|
|
|
48
48
|
const router = useRouter()
|
|
49
49
|
|
|
50
|
-
function selectVariant
|
|
50
|
+
function selectVariant() {
|
|
51
51
|
router.push(targetRoute.value)
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -134,7 +134,7 @@ const autoApplyContrastColor = computed(() => !!histoireConfig.autoApplyContrast
|
|
|
134
134
|
class="htw-relative htw-h-full"
|
|
135
135
|
:style="{
|
|
136
136
|
'--histoire-contrast-color': contrastColor,
|
|
137
|
-
color: autoApplyContrastColor ? contrastColor : undefined,
|
|
137
|
+
'color': autoApplyContrastColor ? contrastColor : undefined,
|
|
138
138
|
}"
|
|
139
139
|
>
|
|
140
140
|
<GenericRenderStory
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { PropType
|
|
2
|
+
import type { PropType } from 'vue'
|
|
3
|
+
import { ref, toRefs } from 'vue'
|
|
4
|
+
import { Icon } from '@iconify/vue'
|
|
3
5
|
import { useCurrentVariantRoute } from '../../util/variant'
|
|
4
6
|
import type { Variant } from '../../types'
|
|
5
7
|
import BaseListItemLink from '../base/BaseListItemLink.vue'
|
|
6
|
-
import { Icon } from '@iconify/vue'
|
|
7
8
|
import { useScrollOnActive } from '../../util/scroll'
|
|
8
9
|
|
|
9
10
|
const props = defineProps({
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
-
import { useStoryStore } from '../../stores/story'
|
|
4
3
|
import { Icon } from '@iconify/vue'
|
|
4
|
+
import { useStoryStore } from '../../stores/story'
|
|
5
5
|
import { isMobile } from '../../util/responsive'
|
|
6
6
|
import BaseSplitPane from '../base/BaseSplitPane.vue'
|
|
7
7
|
import StoryVariantListItem from './StoryVariantListItem.vue'
|
|
8
8
|
import StoryVariantSingleView from './StoryVariantSingleView.vue'
|
|
9
9
|
|
|
10
10
|
defineEmits({
|
|
11
|
-
|
|
11
|
+
openVariantMenu: () => true,
|
|
12
12
|
})
|
|
13
13
|
|
|
14
14
|
const storyStore = useStoryStore()
|
|
@@ -35,7 +35,7 @@ const variant = computed(() => storyStore.currentVariant)
|
|
|
35
35
|
>
|
|
36
36
|
<a
|
|
37
37
|
class="htw-px-6 htw-h-12 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer htw-flex htw-gap-2 htw-flex-wrap htw-w-full htw-items-center htw-flex-none"
|
|
38
|
-
@click="$emit('
|
|
38
|
+
@click="$emit('openVariantMenu')"
|
|
39
39
|
>
|
|
40
40
|
<template v-if="variant">
|
|
41
41
|
<Icon
|
|
@@ -17,7 +17,7 @@ Object.assign(props.variant, {
|
|
|
17
17
|
previewReady: false,
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
function onReady
|
|
20
|
+
function onReady() {
|
|
21
21
|
Object.assign(props.variant, {
|
|
22
22
|
previewReady: true,
|
|
23
23
|
})
|
|
@@ -43,7 +43,7 @@ const autoApplyContrastColor = computed(() => !!histoireConfig.autoApplyContrast
|
|
|
43
43
|
} : { width: '100%', height: '100%' },
|
|
44
44
|
{
|
|
45
45
|
'--histoire-contrast-color': contrastColor,
|
|
46
|
-
color: autoApplyContrastColor ? contrastColor : undefined,
|
|
46
|
+
'color': autoApplyContrastColor ? contrastColor : undefined,
|
|
47
47
|
},
|
|
48
48
|
]"
|
|
49
49
|
class="htw-relative"
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
import { computed, ref, toRaw, watch } from 'vue'
|
|
3
3
|
import { useEventListener } from '@vueuse/core'
|
|
4
4
|
import { applyState } from '@histoire/shared'
|
|
5
|
-
import {
|
|
5
|
+
import { EVENT_SEND, PREVIEW_SETTINGS_SYNC, SANDBOX_READY, STATE_SYNC } from '../../util/const'
|
|
6
6
|
import type { Story, Variant } from '../../types'
|
|
7
7
|
import { getSandboxUrl } from '../../util/sandbox'
|
|
8
8
|
import { usePreviewSettingsStore } from '../../stores/preview-settings'
|
|
9
|
-
import { HstEvent
|
|
10
|
-
import
|
|
9
|
+
import type { HstEvent } from '../../stores/events'
|
|
10
|
+
import { useEventsStore } from '../../stores/events'
|
|
11
11
|
import { toRawDeep } from '../../util/state'
|
|
12
|
+
import StoryResponsivePreview from './StoryResponsivePreview.vue'
|
|
12
13
|
|
|
13
14
|
const props = defineProps<{
|
|
14
15
|
story: Story
|
|
@@ -21,7 +22,7 @@ const settings = usePreviewSettingsStore().currentSettings
|
|
|
21
22
|
|
|
22
23
|
const iframe = ref<HTMLIFrameElement>()
|
|
23
24
|
|
|
24
|
-
function syncState
|
|
25
|
+
function syncState() {
|
|
25
26
|
if (iframe.value && props.variant.previewReady) {
|
|
26
27
|
iframe.value.contentWindow.postMessage({
|
|
27
28
|
type: STATE_SYNC,
|
|
@@ -61,17 +62,17 @@ useEventListener(window, 'message', (event) => {
|
|
|
61
62
|
}
|
|
62
63
|
})
|
|
63
64
|
|
|
64
|
-
function updateVariantState
|
|
65
|
+
function updateVariantState(state: any) {
|
|
65
66
|
synced = true
|
|
66
67
|
applyState(props.variant.state, state)
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
function logEvent
|
|
70
|
+
function logEvent(event: HstEvent) {
|
|
70
71
|
const eventsStore = useEventsStore()
|
|
71
72
|
eventsStore.addEvent(event)
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
function setPreviewReady
|
|
75
|
+
function setPreviewReady() {
|
|
75
76
|
Object.assign(props.variant, {
|
|
76
77
|
previewReady: true,
|
|
77
78
|
})
|
|
@@ -92,7 +93,7 @@ watch(sandboxUrl, () => {
|
|
|
92
93
|
|
|
93
94
|
// Settings
|
|
94
95
|
|
|
95
|
-
function syncSettings
|
|
96
|
+
function syncSettings() {
|
|
96
97
|
if (iframe.value) {
|
|
97
98
|
iframe.value.contentWindow.postMessage({
|
|
98
99
|
type: PREVIEW_SETTINGS_SYNC,
|
|
@@ -110,12 +111,11 @@ watch(() => settings, () => {
|
|
|
110
111
|
|
|
111
112
|
// Iframe load
|
|
112
113
|
|
|
113
|
-
function onIframeLoad
|
|
114
|
+
function onIframeLoad() {
|
|
114
115
|
isIframeLoaded.value = true
|
|
115
116
|
syncState()
|
|
116
117
|
syncSettings()
|
|
117
118
|
}
|
|
118
|
-
|
|
119
119
|
</script>
|
|
120
120
|
|
|
121
121
|
<template>
|
|
@@ -7,9 +7,9 @@ import { useStoryStore } from '../../stores/story'
|
|
|
7
7
|
import BaseSplitPane from '../base/BaseSplitPane.vue'
|
|
8
8
|
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
9
9
|
import { isMobile } from '../../util/responsive'
|
|
10
|
-
import StoryViewer from './StoryViewer.vue'
|
|
11
10
|
import StorySidePanel from '../panel/StorySidePanel.vue'
|
|
12
11
|
import StoryDocs from '../panel/StoryDocs.vue'
|
|
12
|
+
import StoryViewer from './StoryViewer.vue'
|
|
13
13
|
|
|
14
14
|
const storyStore = useStoryStore()
|
|
15
15
|
|
|
@@ -18,7 +18,7 @@ const route = useRoute()
|
|
|
18
18
|
|
|
19
19
|
// Restore variant selection
|
|
20
20
|
|
|
21
|
-
watch(() => storyStore.currentVariant, value => {
|
|
21
|
+
watch(() => storyStore.currentVariant, (value) => {
|
|
22
22
|
if (value) {
|
|
23
23
|
storyStore.currentStory.lastSelectedVariant = value
|
|
24
24
|
}
|
|
@@ -41,7 +41,7 @@ watch(() => [storyStore.currentStory, storyStore.currentVariant], () => {
|
|
|
41
41
|
immediate: true,
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
-
function setVariant
|
|
44
|
+
function setVariant(variantId: string) {
|
|
45
45
|
router.replace({
|
|
46
46
|
...route,
|
|
47
47
|
query: {
|
|
@@ -55,7 +55,7 @@ function setVariant (variantId: string) {
|
|
|
55
55
|
|
|
56
56
|
const docsOnlyScroller = ref<HTMLElement>(null)
|
|
57
57
|
|
|
58
|
-
function scrollDocsToTop
|
|
58
|
+
function scrollDocsToTop() {
|
|
59
59
|
docsOnlyScroller.value?.scrollTo(0, 0)
|
|
60
60
|
}
|
|
61
61
|
</script>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed, ref, watch } from 'vue'
|
|
3
3
|
import { useStoryStore } from '../../stores/story'
|
|
4
|
-
import StoryVariantListItem from './StoryVariantListItem.vue'
|
|
5
4
|
import MobileOverlay from '../app/MobileOverlay.vue'
|
|
5
|
+
import StoryVariantListItem from './StoryVariantListItem.vue'
|
|
6
6
|
import StoryVariantGrid from './StoryVariantGrid.vue'
|
|
7
7
|
import StoryVariantSingle from './StoryVariantSingle.vue'
|
|
8
8
|
|
|
@@ -12,14 +12,13 @@ const variant = computed(() => storyStore.currentVariant)
|
|
|
12
12
|
|
|
13
13
|
const isMenuOpened = ref(false)
|
|
14
14
|
|
|
15
|
-
function closeMenu
|
|
15
|
+
function closeMenu() {
|
|
16
16
|
isMenuOpened.value = false
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
watch(variant, () => {
|
|
20
20
|
isMenuOpened.value = false
|
|
21
21
|
})
|
|
22
|
-
|
|
23
22
|
</script>
|
|
24
23
|
|
|
25
24
|
<template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { Icon } from '@iconify/vue'
|
|
3
|
-
import type { Story, Variant } from '../../types'
|
|
4
3
|
import { computed } from 'vue'
|
|
4
|
+
import type { Story, Variant } from '../../types'
|
|
5
5
|
import { getSandboxUrl } from '../../util/sandbox'
|
|
6
6
|
|
|
7
7
|
const props = defineProps<{
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type { Story, TreeGroup } from '../../types'
|
|
3
|
-
import StoryListItem from './StoryListItem.vue'
|
|
4
|
-
import StoryListFolder from './StoryListFolder.vue'
|
|
5
2
|
import { Icon } from '@iconify/vue'
|
|
6
3
|
import { computed, withDefaults } from 'vue'
|
|
4
|
+
import type { Story, TreeGroup } from '../../types'
|
|
7
5
|
import { useFolderStore } from '../../stores/folder'
|
|
6
|
+
import StoryListItem from './StoryListItem.vue'
|
|
7
|
+
import StoryListFolder from './StoryListFolder.vue'
|
|
8
8
|
|
|
9
9
|
const props = withDefaults(defineProps<{
|
|
10
10
|
path?: Array<string>
|
|
@@ -19,7 +19,7 @@ const folderStore = useFolderStore()
|
|
|
19
19
|
const folderPath = computed(() => [...props.path, props.group.title])
|
|
20
20
|
const isFolderOpen = computed(() => folderStore.isFolderOpened(folderPath.value, true))
|
|
21
21
|
|
|
22
|
-
function toggleOpen
|
|
22
|
+
function toggleOpen() {
|
|
23
23
|
folderStore.toggleFolder(folderPath.value, false)
|
|
24
24
|
}
|
|
25
25
|
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type { Story, Tree,
|
|
2
|
+
import type { Story, Tree, TreeFolder, TreeGroup, TreeLeaf } from '../../types'
|
|
3
3
|
import StoryListItem from './StoryListItem.vue'
|
|
4
4
|
import StoryListFolder from './StoryListFolder.vue'
|
|
5
5
|
import StoryGroup from './StoryGroup.vue'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type { Story, TreeFolder, TreeLeaf } from '../../types'
|
|
3
|
-
import StoryListItem from './StoryListItem.vue'
|
|
4
2
|
import { Icon } from '@iconify/vue'
|
|
5
3
|
import { computed, withDefaults } from 'vue'
|
|
4
|
+
import type { Story, TreeFolder, TreeLeaf } from '../../types'
|
|
6
5
|
import { useFolderStore } from '../../stores/folder'
|
|
6
|
+
import StoryListItem from './StoryListItem.vue'
|
|
7
7
|
|
|
8
8
|
const props = withDefaults(defineProps<{
|
|
9
9
|
path?: Array<string>
|
|
@@ -20,12 +20,12 @@ const folderStore = useFolderStore()
|
|
|
20
20
|
const folderPath = computed(() => [...props.path, props.folder.title])
|
|
21
21
|
const isFolderOpen = computed(() => folderStore.isFolderOpened(folderPath.value))
|
|
22
22
|
|
|
23
|
-
function toggleOpen
|
|
23
|
+
function toggleOpen() {
|
|
24
24
|
folderStore.toggleFolder(folderPath.value)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const folderPadding = computed(() => {
|
|
28
|
-
return
|
|
28
|
+
return `${props.depth * 12}px`
|
|
29
29
|
})
|
|
30
30
|
</script>
|
|
31
31
|
|