histoire 0.3.1 → 0.4.0
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/BaseEmpty.js +13 -0
- package/dist/bundled/HomeView.js +23 -0
- package/dist/bundled/MobileOverlay.js +303 -0
- package/dist/bundled/SearchPane.js +504 -0
- package/dist/bundled/StoryView.js +2330 -0
- package/dist/bundled/api.js +32 -0
- package/dist/bundled/config.js +4 -0
- package/dist/bundled/const.js +5 -0
- package/dist/bundled/dark.js +4 -0
- package/dist/bundled/events.js +29 -0
- package/dist/bundled/global-components.js +203 -0
- package/dist/bundled/index.js +7 -0
- package/dist/bundled/index2.js +762 -0
- package/dist/bundled/reactivity.js +96 -0
- package/dist/bundled/sandbox.js +97 -0
- package/dist/bundled/search-docs-data.js +7 -0
- package/dist/bundled/story.js +59 -0
- package/dist/bundled/style.css +102 -0
- package/dist/client/app/App.vue +2 -2
- package/dist/client/app/api.d.ts +1 -0
- package/dist/client/app/api.js +1 -0
- package/dist/client/app/codegen/vue3.js +1 -2
- package/dist/client/app/components/HomeView.vue +1 -1
- package/dist/client/app/components/app/AppLogo.vue +1 -1
- package/dist/client/app/components/app/MobileOverlay.vue +0 -1
- package/dist/client/app/components/base/BaseEmpty.vue +1 -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 +13 -2
- package/dist/client/app/components/exposed/Variant.vue +6 -0
- package/dist/client/app/components/panel/PaneTabs.vue +64 -0
- package/{src/client/app/components/story → dist/client/app/components/panel}/StoryControls.vue +1 -1
- package/dist/client/app/components/{story → panel}/StoryDocs.vue +0 -0
- package/dist/client/app/components/{story → panel}/StoryEvent.vue +1 -0
- package/dist/client/app/components/{story → panel}/StoryEvents.vue +0 -0
- package/dist/client/app/components/{story → panel}/StorySidePanel.vue +3 -31
- package/dist/client/app/components/{story → panel}/StorySourceCode.vue +0 -0
- package/dist/client/app/components/sandbox/SandboxVue3.vue +10 -0
- package/dist/client/app/components/search/SearchItem.vue +1 -1
- package/dist/client/app/components/search/SearchPane.vue +108 -25
- package/dist/client/app/components/search/search-docs-data.d.ts +3 -0
- package/dist/client/app/components/search/{search-data.js → search-docs-data.js} +1 -1
- package/dist/client/app/components/search/search-title-data.d.ts +3 -0
- package/dist/client/app/components/search/search-title-data.js +7 -0
- package/dist/client/app/components/search/types.d.ts +7 -0
- package/dist/client/app/components/search/types.js +1 -0
- package/dist/client/app/components/story/StoryResponsivePreview.vue +9 -131
- package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantListItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +42 -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 +2 -2
- package/dist/client/app/components/story/StoryViewer.vue +2 -92
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantBackground.vue +3 -3
- package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantNewTab.vue +2 -2
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantResponsiveSize.vue +3 -3
- package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantTitle.vue +1 -1
- package/dist/client/app/components/tree/StoryListItem.vue +1 -1
- package/dist/client/app/index.d.ts +1 -1
- package/dist/client/app/index.js +21 -18
- package/dist/client/app/sandbox.d.ts +1 -1
- package/dist/client/app/sandbox.js +0 -1
- package/dist/client/app/stores/events.js +1 -1
- package/dist/client/app/stores/story.d.ts +27 -0
- package/dist/client/app/style/transitions.pcss +13 -0
- package/dist/client/app/types.d.ts +3 -0
- package/dist/client/app/util/events.d.ts +1 -1
- package/dist/client/app/util/events.js +2 -2
- package/dist/client/app/util/mapping.js +2 -0
- package/dist/client/bundle-index.js +5 -0
- package/dist/client/bundle-main.js +5 -0
- package/dist/client/bundle-sandbox.js +3 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/server/vue3/Story.vue +1 -1
- package/dist/client/server/vue3/run.js +8 -0
- package/dist/node/alias.js +1 -1
- package/dist/node/build.js +4 -4
- package/dist/node/builtin-plugins/tailwind-tokens.js +1 -1
- package/dist/node/search.d.ts +15 -1
- package/dist/node/search.js +78 -32
- package/dist/node/server.js +2 -2
- package/dist/node/types.d.ts +1 -0
- package/dist/node/vite.d.ts +4 -2
- package/dist/node/vite.js +24 -28
- package/dist/style.css +93 -69
- package/package.json +10 -10
- package/src/client/app/App.vue +2 -2
- package/src/client/app/api.ts +1 -0
- package/src/client/app/codegen/vue3.ts +1 -2
- package/src/client/app/components/HomeView.vue +1 -1
- package/src/client/app/components/app/AppLogo.vue +1 -1
- package/src/client/app/components/app/MobileOverlay.vue +0 -1
- package/src/client/app/components/base/BaseEmpty.vue +1 -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 +13 -2
- package/src/client/app/components/exposed/Variant.vue +6 -0
- package/src/client/app/components/panel/PaneTabs.vue +64 -0
- package/{dist/client/app/components/story → src/client/app/components/panel}/StoryControls.vue +1 -1
- package/src/client/app/components/{story → panel}/StoryDocs.vue +0 -0
- package/src/client/app/components/{story → panel}/StoryEvent.vue +1 -0
- package/src/client/app/components/{story → panel}/StoryEvents.vue +0 -0
- package/src/client/app/components/{story → panel}/StorySidePanel.vue +3 -31
- package/src/client/app/components/{story → panel}/StorySourceCode.vue +0 -0
- package/src/client/app/components/sandbox/SandboxVue3.vue +10 -0
- package/src/client/app/components/search/SearchItem.vue +1 -1
- package/src/client/app/components/search/SearchPane.vue +108 -25
- package/src/client/app/components/search/search-docs-data.ts +10 -0
- package/src/client/app/components/search/search-title-data.ts +10 -0
- package/src/client/app/components/search/types.ts +4 -0
- package/src/client/app/components/story/StoryResponsivePreview.vue +9 -131
- package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantListItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +42 -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 +2 -2
- package/src/client/app/components/story/StoryViewer.vue +2 -92
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantBackground.vue +3 -3
- package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantNewTab.vue +2 -2
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantResponsiveSize.vue +3 -3
- package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantTitle.vue +1 -1
- package/src/client/app/components/tree/StoryListItem.vue +1 -1
- package/src/client/app/index.ts +23 -19
- package/src/client/app/sandbox.ts +1 -2
- package/src/client/app/stores/events.ts +1 -1
- package/src/client/app/style/transitions.pcss +13 -0
- package/src/client/app/types.ts +4 -0
- package/src/client/app/util/events.ts +2 -2
- package/src/client/app/util/mapping.ts +2 -0
- package/src/client/bundle-index.js +5 -0
- package/src/client/bundle-main.js +5 -0
- package/src/client/bundle-sandbox.js +3 -0
- package/src/client/index.ts +1 -1
- package/src/client/server/vue3/Story.vue +1 -1
- package/src/client/server/vue3/run.ts +11 -0
- package/src/node/alias.ts +1 -1
- package/src/node/build.ts +4 -4
- package/src/node/builtin-plugins/tailwind-tokens.ts +1 -1
- package/src/node/search.ts +87 -32
- package/src/node/server.ts +2 -2
- package/src/node/types.ts +1 -0
- package/src/node/vite.ts +24 -29
- package/vite.config.ts +46 -0
- package/dist/client/app/components/search/search-data.d.ts +0 -2
- package/src/client/app/components/search/search-data.ts +0 -9
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import BaseTab from '../base/BaseTab.vue'
|
|
3
|
+
import { useEventsStore } from '../../stores/events'
|
|
4
|
+
import BaseOverflowMenu from '../base/BaseOverflowMenu.vue'
|
|
5
|
+
import BaseOverflowTab from '../base/BaseOverflowTab.vue'
|
|
6
|
+
|
|
7
|
+
const eventsStore = useEventsStore()
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<BaseOverflowMenu class="htw-h-10 htw-flex-none htw-border-b htw-border-gray-100 dark:htw-border-gray-750">
|
|
12
|
+
<BaseTab
|
|
13
|
+
:to="{ ...$route, query: { ...$route.query, tab: '' } }"
|
|
14
|
+
:matched="!$route.query.tab"
|
|
15
|
+
>
|
|
16
|
+
Controls
|
|
17
|
+
</BaseTab>
|
|
18
|
+
<BaseTab
|
|
19
|
+
:to="{ ...$route, query: { ...$route.query, tab: 'docs' } }"
|
|
20
|
+
:matched="$route.query.tab === 'docs'"
|
|
21
|
+
>
|
|
22
|
+
Docs
|
|
23
|
+
</BaseTab>
|
|
24
|
+
<BaseTab
|
|
25
|
+
:to="{ ...$route, query: { ...$route.query, tab: 'events' } }"
|
|
26
|
+
:matched="$route.query.tab === 'events'"
|
|
27
|
+
>
|
|
28
|
+
Events
|
|
29
|
+
<span
|
|
30
|
+
v-if="eventsStore.unseen"
|
|
31
|
+
class="htw-text-center htw-text-xs htw-mx-1 htw-px-0.5 htw-h-4 htw-min-w-4 htw-rounded-full active htw-bg-primary-500 htw-text-white dark:htw-text-black"
|
|
32
|
+
>
|
|
33
|
+
{{ eventsStore.unseen <=99 ? eventsStore.unseen : "99+" }}
|
|
34
|
+
</span>
|
|
35
|
+
</BaseTab>
|
|
36
|
+
|
|
37
|
+
<template #overflow>
|
|
38
|
+
<BaseOverflowTab
|
|
39
|
+
:to="{ ...$route, query: { ...$route.query, tab: '' } }"
|
|
40
|
+
:matched="!$route.query.tab"
|
|
41
|
+
>
|
|
42
|
+
Controls
|
|
43
|
+
</BaseOverflowTab>
|
|
44
|
+
<BaseOverflowTab
|
|
45
|
+
:to="{ ...$route, query: { ...$route.query, tab: 'docs' } }"
|
|
46
|
+
:matched="$route.query.tab === 'docs'"
|
|
47
|
+
>
|
|
48
|
+
Docs
|
|
49
|
+
</BaseOverflowTab>
|
|
50
|
+
<BaseOverflowTab
|
|
51
|
+
:to="{ ...$route, query: { ...$route.query, tab: 'events' } }"
|
|
52
|
+
:matched="$route.query.tab === 'events'"
|
|
53
|
+
>
|
|
54
|
+
Events
|
|
55
|
+
<span
|
|
56
|
+
v-if="eventsStore.unseen"
|
|
57
|
+
class="htw-text-center htw-text-xs htw-mx-1 htw-px-0.5 htw-h-4 htw-min-w-4 htw-rounded-full active htw-bg-primary-500 htw-text-white dark:htw-text-black"
|
|
58
|
+
>
|
|
59
|
+
{{ eventsStore.unseen <=99 ? eventsStore.unseen : "99+" }}
|
|
60
|
+
</span>
|
|
61
|
+
</BaseOverflowTab>
|
|
62
|
+
</template>
|
|
63
|
+
</BaseOverflowMenu>
|
|
64
|
+
</template>
|
|
File without changes
|
|
File without changes
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
-
import { useRoute
|
|
3
|
+
import { useRoute } from 'vue-router'
|
|
4
4
|
import { useStoryStore } from '../../stores/story'
|
|
5
|
-
import { useEventsStore } from '../../stores/events'
|
|
6
5
|
|
|
7
6
|
import BaseSplitPane from '../base/BaseSplitPane.vue'
|
|
8
7
|
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
9
|
-
import BaseTab from '../base/BaseTab.vue'
|
|
10
8
|
import StoryControls from './StoryControls.vue'
|
|
11
9
|
import StoryDocs from './StoryDocs.vue'
|
|
12
10
|
import StoryEvents from './StoryEvents.vue'
|
|
13
11
|
import StorySourceCode from './StorySourceCode.vue'
|
|
12
|
+
import PaneTabs from './PaneTabs.vue'
|
|
14
13
|
|
|
15
14
|
const storyStore = useStoryStore()
|
|
16
|
-
const eventsStore = useEventsStore()
|
|
17
15
|
|
|
18
|
-
const router = useRouter()
|
|
19
16
|
const route = useRoute()
|
|
20
17
|
|
|
21
18
|
const panelContentComponent = computed(() => {
|
|
@@ -48,32 +45,7 @@ const panelContentComponent = computed(() => {
|
|
|
48
45
|
>
|
|
49
46
|
<template #first>
|
|
50
47
|
<div class="htw-flex htw-flex-col htw-h-full">
|
|
51
|
-
<
|
|
52
|
-
<BaseTab
|
|
53
|
-
:to="{ ...$route, query: { ...$route.query, tab: '' } }"
|
|
54
|
-
:matched="!$route.query.tab"
|
|
55
|
-
>
|
|
56
|
-
Controls
|
|
57
|
-
</BaseTab>
|
|
58
|
-
<BaseTab
|
|
59
|
-
:to="{ ...$route, query: { ...$route.query, tab: 'docs' } }"
|
|
60
|
-
:matched="$route.query.tab === 'docs'"
|
|
61
|
-
>
|
|
62
|
-
Docs
|
|
63
|
-
</BaseTab>
|
|
64
|
-
<BaseTab
|
|
65
|
-
:to="{ ...$route, query: { ...$route.query, tab: 'events' } }"
|
|
66
|
-
:matched="$route.query.tab === 'events'"
|
|
67
|
-
>
|
|
68
|
-
Events
|
|
69
|
-
<span
|
|
70
|
-
v-if="eventsStore.unseen"
|
|
71
|
-
class="htw-text-center htw-text-gray-900 dark:htw-text-gray-100 htw-text-xs htw-mx-1 htw-px-0.5 htw-h-4 htw-min-w-4 htw-rounded-full active htw-bg-primary-500 htw-text-white dark:htw-text-black"
|
|
72
|
-
>
|
|
73
|
-
{{ eventsStore.unseen <=99 ? eventsStore.unseen : "99+" }}
|
|
74
|
-
</span>
|
|
75
|
-
</BaseTab>
|
|
76
|
-
</nav>
|
|
48
|
+
<PaneTabs />
|
|
77
49
|
|
|
78
50
|
<component
|
|
79
51
|
:is="panelContentComponent"
|
|
File without changes
|
|
@@ -40,6 +40,8 @@ async function mountVariant () {
|
|
|
40
40
|
render: () => {
|
|
41
41
|
return props.variant.slots()?.[props.slotName]?.({
|
|
42
42
|
state: props.variant.state ?? {},
|
|
43
|
+
}) ?? props.story.slots()?.[props.slotName]?.({
|
|
44
|
+
state: props.variant.state ?? {},
|
|
43
45
|
})
|
|
44
46
|
},
|
|
45
47
|
})
|
|
@@ -52,6 +54,14 @@ async function mountVariant () {
|
|
|
52
54
|
})
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
if (typeof props.variant.setupApp === 'function') {
|
|
58
|
+
await props.variant.setupApp({
|
|
59
|
+
app,
|
|
60
|
+
story: props.story,
|
|
61
|
+
variant: props.variant,
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
55
65
|
const target = document.createElement('div')
|
|
56
66
|
sandbox.value.appendChild(target)
|
|
57
67
|
app.mount(target)
|
|
@@ -3,7 +3,7 @@ import { PropType, ref, toRefs } from 'vue'
|
|
|
3
3
|
import { useRouter } from 'vue-router'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
5
|
import { SearchResult } from '../../types'
|
|
6
|
-
import { onKeyboardShortcut } from '../../util/keyboard
|
|
6
|
+
import { onKeyboardShortcut } from '../../util/keyboard'
|
|
7
7
|
import BaseListItemLink from '../base/BaseListItemLink.vue'
|
|
8
8
|
import { useScrollOnActive } from '../../util/scroll'
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { useFocus, useDebounce } from '@vueuse/core'
|
|
3
|
-
import { ref, watch } from 'vue'
|
|
3
|
+
import { computed, ref, watch } from 'vue'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
5
|
import flexsearch from 'flexsearch'
|
|
6
6
|
import charset from 'flexsearch/dist/module/lang/latin/advanced.js'
|
|
@@ -9,7 +9,10 @@ import { useStoryStore } from '../../stores/story'
|
|
|
9
9
|
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
10
10
|
import type { SearchResult, Story, Variant } from '../../types'
|
|
11
11
|
import SearchItem from './SearchItem.vue'
|
|
12
|
-
import { searchData, onUpdate } from './search-data
|
|
12
|
+
import { searchData, onUpdate } from './search-title-data'
|
|
13
|
+
import type { SearchData } from './types'
|
|
14
|
+
|
|
15
|
+
const DocSearchData = () => import('./search-docs-data')
|
|
13
16
|
|
|
14
17
|
const props = defineProps({
|
|
15
18
|
shown: {
|
|
@@ -42,34 +45,40 @@ watch(() => props.shown, value => {
|
|
|
42
45
|
}
|
|
43
46
|
})
|
|
44
47
|
|
|
45
|
-
//
|
|
48
|
+
// Index
|
|
46
49
|
|
|
47
50
|
const searchInputText = ref('')
|
|
48
51
|
const rateLimitedSearch = useDebounce(searchInputText, 50)
|
|
49
52
|
|
|
50
53
|
const storyStore = useStoryStore()
|
|
51
54
|
|
|
52
|
-
let
|
|
55
|
+
let titleSearchIndex: flexsearch.Document<any, any>
|
|
56
|
+
let titleIdMap: SearchData['idMap']
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
function createIndex () {
|
|
59
|
+
return new flexsearch.Document({
|
|
56
60
|
preset: 'match',
|
|
57
61
|
document: {
|
|
58
62
|
id: 'id',
|
|
59
63
|
index: [
|
|
60
|
-
'
|
|
61
|
-
'docs',
|
|
64
|
+
'text',
|
|
62
65
|
],
|
|
63
66
|
},
|
|
64
67
|
worker: true,
|
|
65
68
|
charset,
|
|
66
69
|
language,
|
|
67
|
-
tokenize: '
|
|
70
|
+
tokenize: 'forward',
|
|
68
71
|
})
|
|
72
|
+
}
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
async function loadSearchIndex (data: SearchData) {
|
|
75
|
+
titleSearchIndex = createIndex()
|
|
76
|
+
|
|
77
|
+
for (const key of Object.keys(data.index)) {
|
|
78
|
+
await titleSearchIndex.import(key, data.index[key])
|
|
72
79
|
}
|
|
80
|
+
|
|
81
|
+
titleIdMap = data.idMap
|
|
73
82
|
}
|
|
74
83
|
|
|
75
84
|
loadSearchIndex(searchData)
|
|
@@ -78,26 +87,57 @@ onUpdate(searchData => {
|
|
|
78
87
|
loadSearchIndex(searchData)
|
|
79
88
|
})
|
|
80
89
|
|
|
81
|
-
|
|
90
|
+
let docSearchIndex: flexsearch.Document<any, any>
|
|
91
|
+
let docIdMap: SearchData['idMap']
|
|
92
|
+
|
|
93
|
+
async function loadDocSearchIndex () {
|
|
94
|
+
async function load (data: SearchData) {
|
|
95
|
+
docSearchIndex = createIndex()
|
|
96
|
+
|
|
97
|
+
for (const key of Object.keys(data.index)) {
|
|
98
|
+
await docSearchIndex.import(key, data.index[key])
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
docIdMap = data.idMap
|
|
102
|
+
|
|
103
|
+
if (rateLimitedSearch.value) {
|
|
104
|
+
searchOnDocField(rateLimitedSearch.value)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const searchDataModule = await DocSearchData()
|
|
109
|
+
|
|
110
|
+
load(searchDataModule.searchData)
|
|
111
|
+
// Handle HMR
|
|
112
|
+
searchDataModule.onUpdate(searchData => {
|
|
113
|
+
load(searchData)
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
loadDocSearchIndex()
|
|
118
|
+
|
|
119
|
+
// Search
|
|
120
|
+
|
|
121
|
+
const titleResults = ref<SearchResult[]>([])
|
|
82
122
|
|
|
83
123
|
watch(rateLimitedSearch, async value => {
|
|
84
124
|
const list: SearchResult[] = []
|
|
85
|
-
const raw = await
|
|
86
|
-
enrich: true,
|
|
87
|
-
})
|
|
125
|
+
const raw = await titleSearchIndex.search(value)
|
|
88
126
|
let rank = 0
|
|
89
127
|
for (const field of raw) {
|
|
90
|
-
for (const
|
|
91
|
-
|
|
128
|
+
for (const id of field.result) {
|
|
129
|
+
const idMapData = titleIdMap[id]
|
|
130
|
+
if (!idMapData) continue
|
|
131
|
+
switch (idMapData.kind) {
|
|
92
132
|
case 'story': {
|
|
93
|
-
list.push(storyResultFactory(storyStore.getStoryById(
|
|
133
|
+
list.push(storyResultFactory(storyStore.getStoryById(idMapData.id), rank))
|
|
94
134
|
rank++
|
|
95
135
|
break
|
|
96
136
|
}
|
|
97
137
|
case 'variant': {
|
|
98
|
-
const [storyId] =
|
|
138
|
+
const [storyId] = idMapData.id.split(':')
|
|
99
139
|
const story = storyStore.getStoryById(storyId)
|
|
100
|
-
const variant = storyStore.getVariantById(
|
|
140
|
+
const variant = storyStore.getVariantById(idMapData.id)
|
|
101
141
|
list.push(variantResultFactory(story, variant, rank))
|
|
102
142
|
rank++
|
|
103
143
|
break
|
|
@@ -105,14 +145,40 @@ watch(rateLimitedSearch, async value => {
|
|
|
105
145
|
}
|
|
106
146
|
}
|
|
107
147
|
}
|
|
108
|
-
|
|
148
|
+
titleResults.value = list
|
|
109
149
|
})
|
|
110
150
|
|
|
151
|
+
const docsResults = ref<SearchResult[]>([])
|
|
152
|
+
|
|
153
|
+
async function searchOnDocField (query: string) {
|
|
154
|
+
if (docSearchIndex) {
|
|
155
|
+
const list: SearchResult[] = []
|
|
156
|
+
const raw = await docSearchIndex.search(query)
|
|
157
|
+
let rank = 0
|
|
158
|
+
for (const field of raw) {
|
|
159
|
+
for (const id of field.result) {
|
|
160
|
+
const idMapData = docIdMap[id]
|
|
161
|
+
if (!idMapData) continue
|
|
162
|
+
switch (idMapData.kind) {
|
|
163
|
+
case 'story': {
|
|
164
|
+
list.push(storyResultFactory(storyStore.getStoryById(idMapData.id), rank))
|
|
165
|
+
rank++
|
|
166
|
+
break
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
docsResults.value = list
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
watch(rateLimitedSearch, searchOnDocField)
|
|
176
|
+
|
|
111
177
|
function storyResultFactory (story: Story, rank: number): SearchResult {
|
|
112
178
|
return {
|
|
113
179
|
kind: 'story',
|
|
114
180
|
rank,
|
|
115
|
-
id: story.id
|
|
181
|
+
id: `story:${story.id}`,
|
|
116
182
|
title: story.title,
|
|
117
183
|
route: {
|
|
118
184
|
name: 'story',
|
|
@@ -130,7 +196,7 @@ function variantResultFactory (story: Story, variant: Variant, rank: number): Se
|
|
|
130
196
|
return {
|
|
131
197
|
kind: 'variant',
|
|
132
198
|
rank,
|
|
133
|
-
id: variant.id
|
|
199
|
+
id: `variant:${story.id}:${variant.id}`,
|
|
134
200
|
title: variant.title,
|
|
135
201
|
route: {
|
|
136
202
|
name: 'story',
|
|
@@ -147,6 +213,20 @@ function variantResultFactory (story: Story, variant: Variant, rank: number): Se
|
|
|
147
213
|
}
|
|
148
214
|
}
|
|
149
215
|
|
|
216
|
+
const results = computed(() => {
|
|
217
|
+
const list = [...titleResults.value]
|
|
218
|
+
const seen = {}
|
|
219
|
+
for (const r of titleResults.value) {
|
|
220
|
+
seen[r.id] = true
|
|
221
|
+
}
|
|
222
|
+
for (const r of docsResults.value) {
|
|
223
|
+
if (!seen[r.id]) {
|
|
224
|
+
list.push(r)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return list
|
|
228
|
+
})
|
|
229
|
+
|
|
150
230
|
// Selection
|
|
151
231
|
|
|
152
232
|
const selectedIndex = ref(0)
|
|
@@ -191,7 +271,10 @@ function selectPrevious () {
|
|
|
191
271
|
>
|
|
192
272
|
</div>
|
|
193
273
|
|
|
194
|
-
<BaseEmpty
|
|
274
|
+
<BaseEmpty
|
|
275
|
+
v-if="rateLimitedSearch && !results.length"
|
|
276
|
+
class="no-animation"
|
|
277
|
+
>
|
|
195
278
|
No results
|
|
196
279
|
</BaseEmpty>
|
|
197
280
|
|
|
@@ -201,7 +284,7 @@ function selectPrevious () {
|
|
|
201
284
|
>
|
|
202
285
|
<SearchItem
|
|
203
286
|
v-for="(result, index) of results"
|
|
204
|
-
:key="
|
|
287
|
+
:key="result.id"
|
|
205
288
|
:result="result"
|
|
206
289
|
:selected="index === selectedIndex"
|
|
207
290
|
@close="close()"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { markRaw } from 'vue';
|
|
2
2
|
// @ts-expect-error virtual module
|
|
3
|
-
import { searchData as _searchData, onUpdate as _onUpdate } from '$histoire-search-data';
|
|
3
|
+
import { searchData as _searchData, onUpdate as _onUpdate } from '$histoire-search-docs-data';
|
|
4
4
|
export const searchData = markRaw(_searchData);
|
|
5
5
|
export function onUpdate(cb) {
|
|
6
6
|
_onUpdate(cb);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { markRaw } from 'vue';
|
|
2
|
+
// @ts-expect-error virtual module
|
|
3
|
+
import { searchData as _searchData, onUpdate as _onUpdate } from '$histoire-search-title-data';
|
|
4
|
+
export const searchData = markRaw(_searchData);
|
|
5
|
+
export function onUpdate(cb) {
|
|
6
|
+
_onUpdate(cb);
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,131 +1,18 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, onUnmounted, Ref, ref
|
|
2
|
+
import { computed, onUnmounted, Ref, ref } from 'vue'
|
|
3
3
|
import { useEventListener } from '@vueuse/core'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
|
-
import { STATE_SYNC, PREVIEW_SETTINGS_SYNC, SANDBOX_READY, EVENT_SEND } from '../../util/const'
|
|
6
|
-
import type { Story, Variant } from '../../types'
|
|
7
5
|
import HatchedPattern from '../misc/HatchedPattern.vue'
|
|
8
6
|
import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
|
|
9
|
-
import { toRawDeep } from '../../util/reactivity'
|
|
10
|
-
import { getSandboxUrl } from '../sandbox/lib'
|
|
11
7
|
import { usePreviewSettingsStore } from '../../stores/preview-settings'
|
|
12
|
-
import {
|
|
8
|
+
import { Variant } from '../../types'
|
|
13
9
|
|
|
14
10
|
const props = defineProps<{
|
|
15
|
-
story: Story
|
|
16
11
|
variant: Variant
|
|
17
12
|
}>()
|
|
18
13
|
|
|
19
14
|
const settings = usePreviewSettingsStore().currentSettings
|
|
20
15
|
|
|
21
|
-
// Iframe
|
|
22
|
-
|
|
23
|
-
const iframe = ref<HTMLIFrameElement>()
|
|
24
|
-
|
|
25
|
-
function syncState () {
|
|
26
|
-
if (iframe.value && props.variant.previewReady) {
|
|
27
|
-
iframe.value.contentWindow.postMessage({
|
|
28
|
-
type: STATE_SYNC,
|
|
29
|
-
state: toRawDeep(props.variant.state),
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let synced = false
|
|
35
|
-
|
|
36
|
-
watch(() => props.variant.state, () => {
|
|
37
|
-
if (synced) {
|
|
38
|
-
synced = false
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
syncState()
|
|
42
|
-
}, {
|
|
43
|
-
deep: true,
|
|
44
|
-
immediate: true,
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
Object.assign(props.variant, {
|
|
48
|
-
previewReady: false,
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
useEventListener(window, 'message', (event) => {
|
|
52
|
-
switch (event.data.type) {
|
|
53
|
-
case STATE_SYNC:
|
|
54
|
-
updateVariantState(event.data.state)
|
|
55
|
-
break
|
|
56
|
-
case EVENT_SEND:
|
|
57
|
-
logEvent(event.data.event)
|
|
58
|
-
break
|
|
59
|
-
case SANDBOX_READY:
|
|
60
|
-
setPreviewReady()
|
|
61
|
-
break
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
function updateVariantState (state: any) {
|
|
66
|
-
synced = true
|
|
67
|
-
if (props.variant.state) {
|
|
68
|
-
for (const key in state) {
|
|
69
|
-
if (typeof props.variant.state[key] === 'object') {
|
|
70
|
-
Object.assign(props.variant.state[key], state[key])
|
|
71
|
-
} else {
|
|
72
|
-
// eslint-disable-next-line vue/no-mutating-props
|
|
73
|
-
props.variant.state[key] = state[key]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
// eslint-disable-next-line vue/no-mutating-props
|
|
78
|
-
props.variant.state = state
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function logEvent (event: HstEvent) {
|
|
83
|
-
const eventsStore = useEventsStore()
|
|
84
|
-
eventsStore.addEvent(event)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function setPreviewReady () {
|
|
88
|
-
Object.assign(props.variant, {
|
|
89
|
-
previewReady: true,
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const sandboxUrl = computed(() => {
|
|
94
|
-
return getSandboxUrl(props.story, props.variant)
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
const isIframeLoaded = ref(false)
|
|
98
|
-
|
|
99
|
-
watch(sandboxUrl, () => {
|
|
100
|
-
isIframeLoaded.value = false
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
// Settings
|
|
104
|
-
|
|
105
|
-
function syncSettings () {
|
|
106
|
-
if (iframe.value) {
|
|
107
|
-
iframe.value.contentWindow.postMessage({
|
|
108
|
-
type: PREVIEW_SETTINGS_SYNC,
|
|
109
|
-
settings: toRaw(settings),
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
watch(() => settings, () => {
|
|
115
|
-
syncSettings()
|
|
116
|
-
}, {
|
|
117
|
-
deep: true,
|
|
118
|
-
immediate: true,
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
// Iframe load
|
|
122
|
-
|
|
123
|
-
function onIframeLoad () {
|
|
124
|
-
isIframeLoaded.value = true
|
|
125
|
-
syncState()
|
|
126
|
-
syncSettings()
|
|
127
|
-
}
|
|
128
|
-
|
|
129
16
|
// Resize
|
|
130
17
|
|
|
131
18
|
const resizing = ref(false)
|
|
@@ -150,7 +37,7 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
|
|
|
150
37
|
event.preventDefault()
|
|
151
38
|
event.stopPropagation()
|
|
152
39
|
const start = axis === 'x' ? event.clientX : event.clientY
|
|
153
|
-
const startValue = value.value
|
|
40
|
+
const startValue = value.value
|
|
154
41
|
resizing.value = true
|
|
155
42
|
|
|
156
43
|
const removeListeners = [
|
|
@@ -179,7 +66,7 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
|
|
|
179
66
|
event.preventDefault()
|
|
180
67
|
event.stopPropagation()
|
|
181
68
|
const start = axis === 'x' ? event.touches[0].clientX : event.touches[0].clientY
|
|
182
|
-
const startValue = value.value
|
|
69
|
+
const startValue = value.value
|
|
183
70
|
resizing.value = true
|
|
184
71
|
|
|
185
72
|
const removeListeners = [
|
|
@@ -261,20 +148,11 @@ const isResponsiveEnabled = computed(() => !props.variant.responsiveDisabled)
|
|
|
261
148
|
class="htw-absolute htw-inset-0 htw-w-full htw-h-full htw-text-gray-500/20"
|
|
262
149
|
/>
|
|
263
150
|
|
|
264
|
-
<
|
|
265
|
-
|
|
266
|
-
:
|
|
267
|
-
|
|
268
|
-
:
|
|
269
|
-
'htw-invisible': !isIframeLoaded,
|
|
270
|
-
'htw-pointer-events-none': resizing,
|
|
271
|
-
}"
|
|
272
|
-
:style="isResponsiveEnabled ? {
|
|
273
|
-
width: finalWidth ? `${finalWidth}px` : null,
|
|
274
|
-
height: finalHeight ? `${finalHeight}px` : null,
|
|
275
|
-
} : undefined"
|
|
276
|
-
data-test-id="preview-iframe"
|
|
277
|
-
@load="onIframeLoad()"
|
|
151
|
+
<slot
|
|
152
|
+
:is-responsive-enabled="isResponsiveEnabled"
|
|
153
|
+
:final-width="finalWidth"
|
|
154
|
+
:final-height="finalHeight"
|
|
155
|
+
:resizing="resizing"
|
|
278
156
|
/>
|
|
279
157
|
</div>
|
|
280
158
|
|
|
@@ -6,7 +6,7 @@ import { useResizeObserver } from '@vueuse/core'
|
|
|
6
6
|
import { useCurrentVariantRoute } from '../../util/variant'
|
|
7
7
|
import type { Story, Variant } from '../../types'
|
|
8
8
|
import SandboxVue3 from '../sandbox/SandboxVue3.vue'
|
|
9
|
-
import { useScrollOnActive } from '../../util/scroll
|
|
9
|
+
import { useScrollOnActive } from '../../util/scroll'
|
|
10
10
|
|
|
11
11
|
const props = defineProps({
|
|
12
12
|
variant: {
|
|
@@ -4,7 +4,7 @@ import { useCurrentVariantRoute } from '../../util/variant'
|
|
|
4
4
|
import type { Variant } from '../../types'
|
|
5
5
|
import BaseListItemLink from '../base/BaseListItemLink.vue'
|
|
6
6
|
import { Icon } from '@iconify/vue'
|
|
7
|
-
import { useScrollOnActive } from '../../util/scroll
|
|
7
|
+
import { useScrollOnActive } from '../../util/scroll'
|
|
8
8
|
|
|
9
9
|
const props = defineProps({
|
|
10
10
|
variant: {
|