histoire 0.2.3 → 0.3.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/client/app/App.vue +9 -4
- 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 +82 -21
- package/dist/client/app/components/app/AppHeader.vue +2 -2
- package/dist/client/app/components/app/Breadcrumb.vue +1 -1
- package/dist/client/app/components/base/BaseEmpty.vue +17 -1
- package/dist/client/app/components/base/BaseListItemLink.vue +1 -1
- package/dist/client/app/components/base/BaseTab.vue +1 -1
- package/dist/client/app/components/exposed/Story.vue +22 -1
- package/dist/client/app/components/exposed/Variant.vue +13 -1
- package/dist/client/app/components/sandbox/SandboxVue3.vue +6 -4
- package/dist/client/app/components/sandbox/lib.js +2 -1
- package/dist/client/app/components/search/SearchItem.vue +1 -0
- package/dist/client/app/components/search/SearchLoading.vue +16 -0
- package/dist/client/app/components/search/SearchModal.vue +12 -148
- 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 +7 -0
- package/dist/client/app/components/story/StoryControls.vue +5 -0
- package/dist/client/app/components/story/StoryDocs.vue +18 -11
- package/dist/client/app/components/story/StoryEvent.vue +53 -0
- package/dist/client/app/components/story/StoryEvents.vue +45 -0
- package/dist/client/app/components/story/StoryResponsivePreview.vue +41 -8
- package/dist/client/app/components/story/StorySidePanel.vue +28 -3
- package/dist/client/app/components/story/StorySourceCode.vue +24 -14
- package/dist/client/app/components/story/StoryView.vue +16 -2
- package/dist/client/app/components/story/toolbar/StoryVariantNewTab.vue +1 -1
- package/dist/client/app/components/tree/StoryGroup.vue +75 -0
- package/dist/client/app/components/{story → tree}/StoryList.vue +8 -2
- package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListFolder.vue +10 -8
- package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListItem.vue +7 -4
- package/dist/client/app/router.d.ts +1 -0
- package/dist/client/app/router.js +3 -1
- package/dist/client/app/sandbox.js +11 -1
- package/dist/client/app/stores/events.d.ts +29 -0
- package/dist/client/app/stores/events.js +25 -0
- package/dist/client/app/stores/folder.d.ts +10 -0
- package/dist/client/app/stores/folder.js +47 -0
- package/dist/client/app/stores/story.d.ts +20 -8
- package/dist/client/app/stores/story.js +20 -28
- package/dist/client/app/style/floating-vue.pcss +3 -1
- package/dist/client/app/style/main.pcss +5 -0
- package/dist/client/app/style/sandbox.css +2 -0
- package/dist/client/app/types.d.ts +9 -1
- 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 +31 -0
- package/dist/client/app/util/mapping.js +2 -2
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.js +2 -1
- package/dist/client/server/Story.server.vue +21 -4
- 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 +5 -3
- package/dist/node/commands/preview.js +4 -25
- package/dist/node/config.d.ts +111 -5
- 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 +9 -4
- package/dist/node/tree.d.ts +16 -12
- package/dist/node/tree.js +45 -5
- package/dist/node/types.d.ts +11 -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 +179 -36
- package/package.json +5 -3
- package/scripts/copy.mjs +2 -1
- package/src/client/app/App.vue +9 -4
- package/src/client/app/codegen/const.ts +3 -0
- package/src/client/app/codegen/vue3.ts +80 -22
- package/src/client/app/components/app/AppHeader.vue +2 -2
- package/src/client/app/components/app/Breadcrumb.vue +1 -1
- package/src/client/app/components/base/BaseEmpty.vue +17 -1
- package/src/client/app/components/base/BaseListItemLink.vue +1 -1
- package/src/client/app/components/base/BaseTab.vue +1 -1
- package/src/client/app/components/exposed/Story.vue +22 -1
- package/src/client/app/components/exposed/Variant.vue +13 -1
- package/src/client/app/components/sandbox/SandboxVue3.vue +6 -4
- package/src/client/app/components/sandbox/lib.ts +3 -1
- package/src/client/app/components/search/SearchItem.vue +1 -0
- package/src/client/app/components/search/SearchLoading.vue +16 -0
- package/src/client/app/components/search/SearchModal.vue +12 -148
- 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/StoryControls.vue +5 -0
- package/src/client/app/components/story/StoryDocs.vue +18 -11
- package/src/client/app/components/story/StoryEvent.vue +53 -0
- package/src/client/app/components/story/StoryEvents.vue +45 -0
- package/src/client/app/components/story/StoryResponsivePreview.vue +41 -8
- package/src/client/app/components/story/StorySidePanel.vue +28 -3
- package/src/client/app/components/story/StorySourceCode.vue +24 -14
- package/src/client/app/components/story/StoryView.vue +16 -2
- package/src/client/app/components/story/toolbar/StoryVariantNewTab.vue +1 -1
- package/src/client/app/components/tree/StoryGroup.vue +75 -0
- package/src/client/app/components/{story → tree}/StoryList.vue +8 -2
- package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListFolder.vue +10 -8
- package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListItem.vue +7 -4
- package/src/client/app/router.ts +4 -1
- package/src/client/app/sandbox.ts +12 -2
- package/src/client/app/stores/events.ts +36 -0
- package/src/client/app/stores/folder.ts +59 -0
- package/src/client/app/stores/story.ts +20 -35
- package/src/client/app/style/floating-vue.pcss +3 -1
- package/src/client/app/style/main.pcss +5 -0
- package/src/client/app/style/sandbox.css +2 -0
- package/src/client/app/types.ts +10 -1
- 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 +2 -2
- package/src/client/index.ts +2 -1
- package/src/client/server/Story.server.vue +21 -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 +6 -4
- package/src/node/commands/preview.ts +4 -33
- package/src/node/config.ts +62 -29
- 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 +9 -4
- package/src/node/tree.spec.ts +35 -17
- package/src/node/tree.ts +64 -10
- package/src/node/types.ts +12 -0
- package/src/node/util/find-up.ts +24 -0
- package/src/node/vite.ts +296 -0
- package/tailwind.config.cjs +1 -0
- package/tsconfig.json +2 -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/stores/story.ts +0 -62
- package/dist/client/app/types.ts +0 -70
- 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/server/index.ts +0 -32
- package/dist/client/shim.d.ts +0 -5
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { Story, TreeGroup, TreeFolder, TreeLeaf } from '../../types'
|
|
3
|
+
import StoryListItem from './StoryListItem.vue'
|
|
4
|
+
import StoryListFolder from './StoryListFolder.vue'
|
|
5
|
+
import { Icon } from '@iconify/vue'
|
|
6
|
+
import { computed, withDefaults } from 'vue'
|
|
7
|
+
import { useFolderStore } from '../../stores/folder'
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<{
|
|
10
|
+
path?: Array<string>
|
|
11
|
+
group: TreeGroup
|
|
12
|
+
stories: Story[]
|
|
13
|
+
}>(), {
|
|
14
|
+
path: () => [],
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const folderStore = useFolderStore()
|
|
18
|
+
|
|
19
|
+
const folderPath = computed(() => [...props.path, props.group.title])
|
|
20
|
+
const isFolderOpen = computed(() => folderStore.isFolderOpened(folderPath.value, true))
|
|
21
|
+
|
|
22
|
+
function toggleOpen () {
|
|
23
|
+
folderStore.toggleFolder(folderPath.value, false)
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<div
|
|
29
|
+
data-test-id="story-group"
|
|
30
|
+
class="htw-my-2 first:htw-mt-0 last:htw-mb-0"
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
v-if="group.title"
|
|
34
|
+
role="button"
|
|
35
|
+
tabindex="0"
|
|
36
|
+
class="htw-px-0.5 htw-py-2 md:htw-py-1.5 htw-mx-1 htw-rounded-sm hover:htw-bg-primary-100 dark:hover:htw-bg-primary-900 htw-cursor-pointer htw-select-none htw-flex htw-items-center htw-gap-1 htw-min-w-0"
|
|
37
|
+
@click="toggleOpen"
|
|
38
|
+
@keyup.enter="toggleOpen"
|
|
39
|
+
@keyup.space="toggleOpen"
|
|
40
|
+
>
|
|
41
|
+
<Icon
|
|
42
|
+
icon="carbon:caret-right"
|
|
43
|
+
class="htw-w-4 htw-h-4 htw-transition-transform htw-duration-150 htw-opacity-30 htw-flex-none"
|
|
44
|
+
:class="{
|
|
45
|
+
'htw-rotate-90': isFolderOpen,
|
|
46
|
+
}"
|
|
47
|
+
/>
|
|
48
|
+
<span class="htw-truncate htw-opacity-50">{{ group.title }}</span>
|
|
49
|
+
<span class="htw-h-[1px] htw-flex-1 htw-bg-gray-500/10 htw-mx-2" />
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<!-- Children -->
|
|
53
|
+
<div
|
|
54
|
+
v-if="isFolderOpen"
|
|
55
|
+
>
|
|
56
|
+
<template
|
|
57
|
+
v-for="element of group.children"
|
|
58
|
+
:key="element.title"
|
|
59
|
+
>
|
|
60
|
+
<StoryListFolder
|
|
61
|
+
v-if="(element as TreeFolder).children"
|
|
62
|
+
:path="folderPath"
|
|
63
|
+
:folder="(element as TreeFolder)"
|
|
64
|
+
:stories="stories"
|
|
65
|
+
:depth="0"
|
|
66
|
+
/>
|
|
67
|
+
<StoryListItem
|
|
68
|
+
v-else
|
|
69
|
+
:story="stories[(element as TreeLeaf).index]"
|
|
70
|
+
:depth="0"
|
|
71
|
+
/>
|
|
72
|
+
</template>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</template>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type { Story, Tree, TreeFolder, TreeLeaf } from '../../types'
|
|
2
|
+
import type { Story, Tree, TreeGroup, TreeFolder, TreeLeaf } from '../../types'
|
|
3
3
|
import StoryListItem from './StoryListItem.vue'
|
|
4
4
|
import StoryListFolder from './StoryListFolder.vue'
|
|
5
|
+
import StoryGroup from './StoryGroup.vue'
|
|
5
6
|
|
|
6
7
|
const props = defineProps<{
|
|
7
8
|
tree: Tree
|
|
@@ -15,8 +16,13 @@ const props = defineProps<{
|
|
|
15
16
|
v-for="element of tree"
|
|
16
17
|
:key="element.title"
|
|
17
18
|
>
|
|
19
|
+
<StoryGroup
|
|
20
|
+
v-if="(element as TreeGroup).group"
|
|
21
|
+
:group="(element as TreeGroup)"
|
|
22
|
+
:stories="stories"
|
|
23
|
+
/>
|
|
18
24
|
<StoryListFolder
|
|
19
|
-
v-if="(element as TreeFolder).children"
|
|
25
|
+
v-else-if="(element as TreeFolder).children"
|
|
20
26
|
:folder="(element as TreeFolder)"
|
|
21
27
|
:stories="stories"
|
|
22
28
|
/>
|
package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListFolder.vue
RENAMED
|
@@ -3,7 +3,7 @@ import type { Story, TreeFolder, TreeLeaf } from '../../types'
|
|
|
3
3
|
import StoryListItem from './StoryListItem.vue'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
5
|
import { computed, withDefaults } from 'vue'
|
|
6
|
-
import {
|
|
6
|
+
import { useFolderStore } from '../../stores/folder'
|
|
7
7
|
|
|
8
8
|
const props = withDefaults(defineProps<{
|
|
9
9
|
path?: Array<string>
|
|
@@ -15,17 +15,17 @@ const props = withDefaults(defineProps<{
|
|
|
15
15
|
path: () => [],
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const folderStore = useFolderStore()
|
|
19
19
|
|
|
20
20
|
const folderPath = computed(() => [...props.path, props.folder.title])
|
|
21
|
-
const isFolderOpen = computed(() =>
|
|
21
|
+
const isFolderOpen = computed(() => folderStore.isFolderOpened(folderPath.value))
|
|
22
22
|
|
|
23
23
|
function toggleOpen () {
|
|
24
|
-
|
|
24
|
+
folderStore.toggleFolder(folderPath.value)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const folderPadding = computed(() => {
|
|
28
|
-
return (props.depth *
|
|
28
|
+
return (props.depth * 12) + 'px'
|
|
29
29
|
})
|
|
30
30
|
</script>
|
|
31
31
|
|
|
@@ -34,13 +34,13 @@ const folderPadding = computed(() => {
|
|
|
34
34
|
<div
|
|
35
35
|
role="button"
|
|
36
36
|
tabindex="0"
|
|
37
|
-
class="htw-px-0.5 htw-py-2 md:htw-py-1.5 htw-
|
|
37
|
+
class="htw-px-0.5 htw-py-2 md:htw-py-1.5 htw-mx-1 htw-rounded-sm hover:htw-bg-primary-100 dark:hover:htw-bg-primary-900 htw-cursor-pointer htw-select-none htw-flex"
|
|
38
38
|
@click="toggleOpen"
|
|
39
39
|
@keyup.enter="toggleOpen"
|
|
40
40
|
@keyup.space="toggleOpen"
|
|
41
41
|
>
|
|
42
42
|
<span class="bind-tree-padding htw-flex htw-items-center htw-gap-2 htw-min-w-0">
|
|
43
|
-
<span class="htw-flex htw-
|
|
43
|
+
<span class="htw-flex htw-flex-none htw-items-center">
|
|
44
44
|
<Icon
|
|
45
45
|
icon="carbon:caret-right"
|
|
46
46
|
class="htw-w-4 htw-h-4 htw-transition-transform htw-duration-150 htw-opacity-30"
|
|
@@ -56,6 +56,8 @@ const folderPadding = computed(() => {
|
|
|
56
56
|
<span class="htw-truncate">{{ folder.title }}</span>
|
|
57
57
|
</span>
|
|
58
58
|
</div>
|
|
59
|
+
|
|
60
|
+
<!-- Children -->
|
|
59
61
|
<div
|
|
60
62
|
v-if="isFolderOpen"
|
|
61
63
|
>
|
|
@@ -66,7 +68,7 @@ const folderPadding = computed(() => {
|
|
|
66
68
|
<StoryListFolder
|
|
67
69
|
v-if="(element as TreeFolder).children"
|
|
68
70
|
:path="folderPath"
|
|
69
|
-
:folder="element"
|
|
71
|
+
:folder="(element as TreeFolder)"
|
|
70
72
|
:stories="stories"
|
|
71
73
|
:depth="depth + 1"
|
|
72
74
|
/>
|
package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListItem.vue
RENAMED
|
@@ -14,7 +14,7 @@ const props = withDefaults(defineProps<{
|
|
|
14
14
|
})
|
|
15
15
|
|
|
16
16
|
const filePadding = computed(() => {
|
|
17
|
-
return (props.depth *
|
|
17
|
+
return (props.depth * 12) + 'px'
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
const route = useRoute()
|
|
@@ -36,9 +36,9 @@ useScrollOnActive(active, el)
|
|
|
36
36
|
storyId: story.id,
|
|
37
37
|
},
|
|
38
38
|
}"
|
|
39
|
-
class="htw-pl-0.5 htw-pr-2 htw-py-2 md:htw-py-1.5 htw-
|
|
39
|
+
class="htw-pl-0.5 htw-pr-2 htw-py-2 md:htw-py-1.5 htw-mx-1 htw-rounded-sm"
|
|
40
40
|
>
|
|
41
|
-
<span class="bind-tree-margin htw-flex htw-items-center htw-gap-2 htw-pl-
|
|
41
|
+
<span class="bind-tree-margin htw-flex htw-items-center htw-gap-2 htw-pl-4 htw-min-w-0">
|
|
42
42
|
<Icon
|
|
43
43
|
:icon="story.icon ?? 'carbon:cube'"
|
|
44
44
|
class="base-list-item-link-icon htw-w-5 htw-h-5 sm:htw-w-4 sm:htw-h-4 htw-flex-none"
|
|
@@ -50,7 +50,10 @@ useScrollOnActive(active, el)
|
|
|
50
50
|
<span class="htw-truncate">{{ story.title }}</span>
|
|
51
51
|
</span>
|
|
52
52
|
|
|
53
|
-
<span
|
|
53
|
+
<span
|
|
54
|
+
v-if="!story.docsOnly"
|
|
55
|
+
class="htw-opacity-40 htw-text-sm"
|
|
56
|
+
>
|
|
54
57
|
{{ story.variants.length }}
|
|
55
58
|
</span>
|
|
56
59
|
</BaseListItemLink>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createRouter, createWebHistory } from 'vue-router';
|
|
2
|
+
// @ts-expect-error env not defined
|
|
3
|
+
export const base = import.meta.env.BASE_URL;
|
|
2
4
|
export const router = createRouter({
|
|
3
|
-
history: createWebHistory(),
|
|
5
|
+
history: createWebHistory(base),
|
|
4
6
|
routes: [
|
|
5
7
|
{
|
|
6
8
|
path: '/',
|
|
@@ -15,6 +15,7 @@ import { toRawDeep } from './util/reactivity';
|
|
|
15
15
|
const query = parseQuery(window.location.search);
|
|
16
16
|
const file = ref(mapFile(files.find(f => f.id === query.storyId)));
|
|
17
17
|
const app = createApp({
|
|
18
|
+
name: 'SandboxApp',
|
|
18
19
|
setup() {
|
|
19
20
|
const story = computed(() => file.value.story);
|
|
20
21
|
const variant = computed(() => story.value?.variants.find(v => v.id === query.variantId));
|
|
@@ -25,7 +26,16 @@ const app = createApp({
|
|
|
25
26
|
if (!mounted)
|
|
26
27
|
return;
|
|
27
28
|
synced = true;
|
|
28
|
-
|
|
29
|
+
if (variant.value.state) {
|
|
30
|
+
for (const key in event.data.state) {
|
|
31
|
+
if (typeof variant.value.state[key] === 'object') {
|
|
32
|
+
Object.assign(variant.value.state[key], event.data.state[key]);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
variant.value.state[key] = event.data.state[key];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
29
39
|
}
|
|
30
40
|
else if (event.data?.type === PREVIEW_SETTINGS_SYNC) {
|
|
31
41
|
applyPreviewSettings(event.data.settings);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare type HstEvent = {
|
|
2
|
+
name: string;
|
|
3
|
+
argument: unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare const useEventsStore: import("pinia").StoreDefinition<"events", import("pinia")._UnwrapAll<Pick<{
|
|
6
|
+
addEvent: (event: HstEvent) => void;
|
|
7
|
+
reset: () => void;
|
|
8
|
+
events: {
|
|
9
|
+
name: string;
|
|
10
|
+
argument: unknown;
|
|
11
|
+
}[];
|
|
12
|
+
unseen: import("vue").Ref<number>;
|
|
13
|
+
}, "events" | "unseen">>, import("pinia")._UnwrapAll<Pick<{
|
|
14
|
+
addEvent: (event: HstEvent) => void;
|
|
15
|
+
reset: () => void;
|
|
16
|
+
events: {
|
|
17
|
+
name: string;
|
|
18
|
+
argument: unknown;
|
|
19
|
+
}[];
|
|
20
|
+
unseen: import("vue").Ref<number>;
|
|
21
|
+
}, never>>, Pick<{
|
|
22
|
+
addEvent: (event: HstEvent) => void;
|
|
23
|
+
reset: () => void;
|
|
24
|
+
events: {
|
|
25
|
+
name: string;
|
|
26
|
+
argument: unknown;
|
|
27
|
+
}[];
|
|
28
|
+
unseen: import("vue").Ref<number>;
|
|
29
|
+
}, "addEvent" | "reset">>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { ref, reactive, watch } from 'vue';
|
|
3
|
+
import { useStoryStore } from './story.js';
|
|
4
|
+
export const useEventsStore = defineStore('events', () => {
|
|
5
|
+
const storyStore = useStoryStore();
|
|
6
|
+
const events = reactive([]);
|
|
7
|
+
const unseen = ref(0);
|
|
8
|
+
function addEvent(event) {
|
|
9
|
+
events.push(event);
|
|
10
|
+
unseen.value++;
|
|
11
|
+
}
|
|
12
|
+
function reset() {
|
|
13
|
+
events.length = 0;
|
|
14
|
+
unseen.value = 0;
|
|
15
|
+
}
|
|
16
|
+
watch(() => storyStore.currentVariant, () => {
|
|
17
|
+
reset();
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
addEvent,
|
|
21
|
+
reset,
|
|
22
|
+
events,
|
|
23
|
+
unseen,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const useFolderStore: import("pinia").StoreDefinition<"folder", import("pinia")._UnwrapAll<Pick<{
|
|
2
|
+
isFolderOpened: (path: Array<string>, defaultValue?: boolean) => boolean;
|
|
3
|
+
toggleFolder: (path: Array<string>, defaultToggleValue?: boolean) => void;
|
|
4
|
+
}, never>>, import("pinia")._UnwrapAll<Pick<{
|
|
5
|
+
isFolderOpened: (path: Array<string>, defaultValue?: boolean) => boolean;
|
|
6
|
+
toggleFolder: (path: Array<string>, defaultToggleValue?: boolean) => void;
|
|
7
|
+
}, never>>, Pick<{
|
|
8
|
+
isFolderOpened: (path: Array<string>, defaultValue?: boolean) => boolean;
|
|
9
|
+
toggleFolder: (path: Array<string>, defaultToggleValue?: boolean) => void;
|
|
10
|
+
}, "isFolderOpened" | "toggleFolder">>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { watch } from 'vue';
|
|
3
|
+
import { useStorage } from '@vueuse/core';
|
|
4
|
+
import { useStoryStore } from './story';
|
|
5
|
+
export const useFolderStore = defineStore('folder', () => {
|
|
6
|
+
const openedFolders = useStorage('_histoire-tree-state', new Map());
|
|
7
|
+
function getStringPath(path) {
|
|
8
|
+
return path.join('␜');
|
|
9
|
+
}
|
|
10
|
+
function toggleFolder(path, defaultToggleValue = true) {
|
|
11
|
+
const stringPath = getStringPath(path);
|
|
12
|
+
const currentValue = openedFolders.value.get(stringPath);
|
|
13
|
+
if (currentValue == null) {
|
|
14
|
+
setFolderOpen(stringPath, defaultToggleValue);
|
|
15
|
+
}
|
|
16
|
+
else if (currentValue) {
|
|
17
|
+
setFolderOpen(stringPath, false);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
setFolderOpen(stringPath, true);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function setFolderOpen(path, value) {
|
|
24
|
+
const stringPath = typeof path === 'string' ? path : getStringPath(path);
|
|
25
|
+
openedFolders.value.set(stringPath, value);
|
|
26
|
+
}
|
|
27
|
+
function isFolderOpened(path, defaultValue = false) {
|
|
28
|
+
const value = openedFolders.value.get(getStringPath(path));
|
|
29
|
+
if (value == null) {
|
|
30
|
+
return defaultValue;
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
function openFileFolders(path) {
|
|
35
|
+
for (let pathLength = 1; pathLength < path.length; pathLength++) {
|
|
36
|
+
setFolderOpen(path.slice(0, pathLength), true);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const storyStore = useStoryStore();
|
|
40
|
+
watch(() => storyStore.currentStory, (story) => {
|
|
41
|
+
openFileFolders(story.file.path);
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
isFolderOpened,
|
|
45
|
+
toggleFolder,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Story } from '../types';
|
|
1
|
+
import { Story, Variant } from '../types';
|
|
2
2
|
export declare const useStoryStore: import("pinia").StoreDefinition<"story", import("pinia")._UnwrapAll<Pick<{
|
|
3
3
|
stories: import("vue").Ref<{
|
|
4
4
|
id: string;
|
|
5
5
|
title: string;
|
|
6
|
+
group?: string;
|
|
6
7
|
variants: {
|
|
7
8
|
id: string;
|
|
8
9
|
title: string;
|
|
@@ -24,6 +25,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
24
25
|
};
|
|
25
26
|
icon?: string;
|
|
26
27
|
iconColor?: string;
|
|
28
|
+
docsOnly?: boolean;
|
|
27
29
|
file?: {
|
|
28
30
|
id: string;
|
|
29
31
|
framework: string;
|
|
@@ -49,6 +51,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
49
51
|
currentStory: import("vue").ComputedRef<{
|
|
50
52
|
id: string;
|
|
51
53
|
title: string;
|
|
54
|
+
group?: string;
|
|
52
55
|
variants: {
|
|
53
56
|
id: string;
|
|
54
57
|
title: string;
|
|
@@ -70,6 +73,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
70
73
|
};
|
|
71
74
|
icon?: string;
|
|
72
75
|
iconColor?: string;
|
|
76
|
+
docsOnly?: boolean;
|
|
73
77
|
file?: {
|
|
74
78
|
id: string;
|
|
75
79
|
framework: string;
|
|
@@ -104,12 +108,13 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
104
108
|
configReady?: boolean;
|
|
105
109
|
previewReady?: boolean;
|
|
106
110
|
}>;
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
getStoryById: (id: string) => Story;
|
|
112
|
+
getVariantById: (idWithStoryId: string) => Variant;
|
|
109
113
|
}, "stories">>, import("pinia")._UnwrapAll<Pick<{
|
|
110
114
|
stories: import("vue").Ref<{
|
|
111
115
|
id: string;
|
|
112
116
|
title: string;
|
|
117
|
+
group?: string;
|
|
113
118
|
variants: {
|
|
114
119
|
id: string;
|
|
115
120
|
title: string;
|
|
@@ -131,6 +136,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
131
136
|
};
|
|
132
137
|
icon?: string;
|
|
133
138
|
iconColor?: string;
|
|
139
|
+
docsOnly?: boolean;
|
|
134
140
|
file?: {
|
|
135
141
|
id: string;
|
|
136
142
|
framework: string;
|
|
@@ -156,6 +162,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
156
162
|
currentStory: import("vue").ComputedRef<{
|
|
157
163
|
id: string;
|
|
158
164
|
title: string;
|
|
165
|
+
group?: string;
|
|
159
166
|
variants: {
|
|
160
167
|
id: string;
|
|
161
168
|
title: string;
|
|
@@ -177,6 +184,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
177
184
|
};
|
|
178
185
|
icon?: string;
|
|
179
186
|
iconColor?: string;
|
|
187
|
+
docsOnly?: boolean;
|
|
180
188
|
file?: {
|
|
181
189
|
id: string;
|
|
182
190
|
framework: string;
|
|
@@ -211,12 +219,13 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
211
219
|
configReady?: boolean;
|
|
212
220
|
previewReady?: boolean;
|
|
213
221
|
}>;
|
|
214
|
-
|
|
215
|
-
|
|
222
|
+
getStoryById: (id: string) => Story;
|
|
223
|
+
getVariantById: (idWithStoryId: string) => Variant;
|
|
216
224
|
}, "currentStory" | "currentVariant">>, Pick<{
|
|
217
225
|
stories: import("vue").Ref<{
|
|
218
226
|
id: string;
|
|
219
227
|
title: string;
|
|
228
|
+
group?: string;
|
|
220
229
|
variants: {
|
|
221
230
|
id: string;
|
|
222
231
|
title: string;
|
|
@@ -238,6 +247,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
238
247
|
};
|
|
239
248
|
icon?: string;
|
|
240
249
|
iconColor?: string;
|
|
250
|
+
docsOnly?: boolean;
|
|
241
251
|
file?: {
|
|
242
252
|
id: string;
|
|
243
253
|
framework: string;
|
|
@@ -263,6 +273,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
263
273
|
currentStory: import("vue").ComputedRef<{
|
|
264
274
|
id: string;
|
|
265
275
|
title: string;
|
|
276
|
+
group?: string;
|
|
266
277
|
variants: {
|
|
267
278
|
id: string;
|
|
268
279
|
title: string;
|
|
@@ -284,6 +295,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
284
295
|
};
|
|
285
296
|
icon?: string;
|
|
286
297
|
iconColor?: string;
|
|
298
|
+
docsOnly?: boolean;
|
|
287
299
|
file?: {
|
|
288
300
|
id: string;
|
|
289
301
|
framework: string;
|
|
@@ -318,6 +330,6 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
318
330
|
configReady?: boolean;
|
|
319
331
|
previewReady?: boolean;
|
|
320
332
|
}>;
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}, "setStories" | "
|
|
333
|
+
getStoryById: (id: string) => Story;
|
|
334
|
+
getVariantById: (idWithStoryId: string) => Variant;
|
|
335
|
+
}, "setStories" | "getStoryById" | "getVariantById">>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { defineStore } from 'pinia';
|
|
2
|
-
import { computed, ref
|
|
2
|
+
import { computed, ref } from 'vue';
|
|
3
3
|
import { router } from '../router';
|
|
4
|
-
import { useStorage } from '@vueuse/core';
|
|
5
4
|
export const useStoryStore = defineStore('story', () => {
|
|
6
5
|
const stories = ref([]);
|
|
7
6
|
function setStories(value) {
|
|
@@ -9,39 +8,32 @@ export const useStoryStore = defineStore('story', () => {
|
|
|
9
8
|
}
|
|
10
9
|
const currentStory = computed(() => stories.value.find(s => s.id === router.currentRoute.value.params.storyId));
|
|
11
10
|
const currentVariant = computed(() => currentStory.value?.variants.find(v => v.id === router.currentRoute.value.query.variantId));
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
if (force) {
|
|
22
|
-
openedFolders.value.set(stringPath, true);
|
|
11
|
+
const maps = computed(() => {
|
|
12
|
+
const storyMap = new Map();
|
|
13
|
+
const variantMap = new Map();
|
|
14
|
+
for (const story of stories.value) {
|
|
15
|
+
storyMap.set(story.id, story);
|
|
16
|
+
for (const variant of story.variants) {
|
|
17
|
+
variantMap.set(`${story.id}:${variant.id}`, variant);
|
|
18
|
+
}
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
return {
|
|
21
|
+
stories: storyMap,
|
|
22
|
+
variants: variantMap,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
function getStoryById(id) {
|
|
26
|
+
return maps.value.stories.get(id);
|
|
30
27
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
toggleFolder(path.slice(0, pathLength), true);
|
|
34
|
-
}
|
|
28
|
+
function getVariantById(idWithStoryId) {
|
|
29
|
+
return maps.value.variants.get(idWithStoryId);
|
|
35
30
|
}
|
|
36
|
-
watch(currentStory, () => {
|
|
37
|
-
openFileFolders(currentStory.value.file.path);
|
|
38
|
-
});
|
|
39
31
|
return {
|
|
40
32
|
stories,
|
|
41
33
|
setStories,
|
|
42
34
|
currentStory,
|
|
43
35
|
currentVariant,
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
getStoryById,
|
|
37
|
+
getVariantById,
|
|
46
38
|
};
|
|
47
39
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@import url('https://fonts.googleapis.com/css2?family=Lato&display=swap');
|
|
2
2
|
@import 'floating-vue/dist/style.css';
|
|
3
|
+
@import '@histoire/controls/dist/style.css';
|
|
3
4
|
|
|
4
5
|
@import 'floating-vue.pcss';
|
|
5
6
|
@import 'transitions.pcss';
|
|
@@ -78,4 +79,8 @@ body {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
}
|
|
82
|
+
|
|
83
|
+
hr {
|
|
84
|
+
margin: 1rem 0;
|
|
85
|
+
}
|
|
81
86
|
}
|
|
@@ -9,6 +9,7 @@ export interface StoryFile {
|
|
|
9
9
|
export interface Story {
|
|
10
10
|
id: string;
|
|
11
11
|
title: string;
|
|
12
|
+
group?: string;
|
|
12
13
|
variants: Variant[];
|
|
13
14
|
layout?: {
|
|
14
15
|
type: 'single';
|
|
@@ -18,6 +19,7 @@ export interface Story {
|
|
|
18
19
|
};
|
|
19
20
|
icon?: string;
|
|
20
21
|
iconColor?: string;
|
|
22
|
+
docsOnly?: boolean;
|
|
21
23
|
file?: StoryFile;
|
|
22
24
|
lastSelectedVariant?: Variant;
|
|
23
25
|
}
|
|
@@ -42,7 +44,13 @@ export declare type TreeFolder = {
|
|
|
42
44
|
title: string;
|
|
43
45
|
children: (TreeFolder | TreeLeaf)[];
|
|
44
46
|
};
|
|
45
|
-
export
|
|
47
|
+
export interface TreeGroup {
|
|
48
|
+
group: true;
|
|
49
|
+
id: string;
|
|
50
|
+
title: string;
|
|
51
|
+
children: (TreeFolder | TreeLeaf)[];
|
|
52
|
+
}
|
|
53
|
+
export declare type Tree = (TreeGroup | TreeFolder | TreeLeaf)[];
|
|
46
54
|
export interface SearchResult {
|
|
47
55
|
kind: 'story' | 'variant';
|
|
48
56
|
rank: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hstEvent(name: string, argument: any): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useEventsStore } from '../stores/events.js';
|
|
2
|
+
import { EVENT_SEND } from './const';
|
|
3
|
+
export function hstEvent(name, argument) {
|
|
4
|
+
console.log('[histoire] Event fired', { name, argument });
|
|
5
|
+
const event = {
|
|
6
|
+
name,
|
|
7
|
+
argument: JSON.parse(stringifyEvent(argument)), // Needed for HTMLEvent that can't be cloned
|
|
8
|
+
};
|
|
9
|
+
if (location.href.includes('__sandbox')) {
|
|
10
|
+
window.parent?.postMessage({
|
|
11
|
+
type: EVENT_SEND,
|
|
12
|
+
event,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
useEventsStore().addEvent(event);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function stringifyEvent(e) {
|
|
20
|
+
const obj = {};
|
|
21
|
+
for (const k in e) {
|
|
22
|
+
obj[k] = e[k];
|
|
23
|
+
}
|
|
24
|
+
return JSON.stringify(obj, (k, v) => {
|
|
25
|
+
if (v instanceof Node)
|
|
26
|
+
return 'Node';
|
|
27
|
+
if (v instanceof Window)
|
|
28
|
+
return 'Window';
|
|
29
|
+
return v;
|
|
30
|
+
}, ' ');
|
|
31
|
+
}
|