@histoire/app 0.17.16 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/style/main.pcss +1 -1
- package/dist/app/style/sandbox.css +1 -1
- package/dist/bundle-main-dev.js +1 -1
- package/dist/bundle-main.js +2 -2
- package/dist/bundled/App.vue2.js +11 -11
- package/dist/bundled/app.css +101 -0
- package/dist/bundled/components/HomeView.vue2.js +1 -1
- package/dist/bundled/components/app/AppHeader.vue2.js +3 -3
- package/dist/bundled/components/app/AppLogo.vue2.js +4 -4
- package/dist/bundled/components/app/Breadcrumb.vue.js +2 -2
- package/dist/bundled/components/app/Breadcrumb.vue2.js +8 -10
- package/dist/bundled/components/app/HomeCounter.vue2.js +2 -7
- package/dist/bundled/components/app/InitialLoading.vue2.js +1 -1
- package/dist/bundled/components/base/BaseCheckbox.vue2.js +1 -2
- package/dist/bundled/components/base/BaseEmpty.vue.js +2 -3
- package/dist/bundled/components/base/BaseIcon.vue.js +2 -2
- package/dist/bundled/components/base/BaseIcon.vue2.js +1 -2
- package/dist/bundled/components/base/BaseListItemLink.vue.js +1 -1
- package/dist/bundled/components/base/BaseOverflowMenu.vue2.js +5 -5
- package/dist/bundled/components/base/BaseOverflowTab.vue.js +1 -1
- package/dist/bundled/components/base/BaseSelect.vue2.js +2 -2
- package/dist/bundled/components/base/BaseSplitPane.vue.js +2 -2
- package/dist/bundled/components/base/BaseSplitPane.vue2.js +3 -6
- package/dist/bundled/components/base/BaseTab.vue.js +1 -1
- package/dist/bundled/components/base/BaseTag.vue.js +1 -1
- package/dist/bundled/components/command/CommandPrompts.vue2.js +3 -7
- package/dist/bundled/components/command/CommandPromptsModal.vue2.js +1 -1
- package/dist/bundled/components/command/PromptSelect.vue2.js +3 -3
- package/dist/bundled/components/command/PromptText.vue2.js +1 -1
- package/dist/bundled/components/misc/CheckerboardPattern.vue.js +31 -34
- package/dist/bundled/components/misc/HatchedPattern.vue.js +2 -3
- package/dist/bundled/components/panel/ControlsComponentPropItem.vue2.js +1 -1
- package/dist/bundled/components/panel/ControlsComponentProps.vue2.js +2 -4
- package/dist/bundled/components/panel/ControlsComponentState.vue2.js +1 -2
- package/dist/bundled/components/panel/PaneTabs.vue2.js +12 -12
- package/dist/bundled/components/panel/StatePresets.vue2.js +3 -4
- package/dist/bundled/components/panel/StoryControls.vue2.js +5 -6
- package/dist/bundled/components/panel/StoryDocs.vue2.js +6 -6
- package/dist/bundled/components/panel/StoryEvents.vue2.js +2 -2
- package/dist/bundled/components/panel/StorySidePanel.vue2.js +10 -12
- package/dist/bundled/components/panel/StorySourceCode.vue.js +2 -2
- package/dist/bundled/components/panel/StorySourceCode.vue2.js +15 -20
- package/dist/bundled/components/search/SearchItem.vue.js +2 -2
- package/dist/bundled/components/search/SearchItem.vue2.js +4 -6
- package/dist/bundled/components/search/SearchLoading.vue2.js +2 -2
- package/dist/bundled/components/search/SearchModal.vue2.js +1 -1
- package/dist/bundled/components/search/SearchPane.vue2.js +42 -60
- package/dist/bundled/components/search/search-docs-data.js +1 -1
- package/dist/bundled/components/search/search-title-data.js +1 -1
- package/dist/bundled/components/story/GenericMountStory.vue2.js +1 -1
- package/dist/bundled/components/story/StoryResponsivePreview.vue.js +2 -2
- package/dist/bundled/components/story/StoryResponsivePreview.vue2.js +9 -12
- package/dist/bundled/components/story/StoryVariantGrid.vue2.js +8 -11
- package/dist/bundled/components/story/StoryVariantGridItem.vue.js +2 -2
- package/dist/bundled/components/story/StoryVariantGridItem.vue2.js +16 -19
- package/dist/bundled/components/story/StoryVariantListItem.vue.js +2 -2
- package/dist/bundled/components/story/StoryVariantListItem.vue2.js +4 -5
- package/dist/bundled/components/story/StoryVariantSingle.vue.js +2 -2
- package/dist/bundled/components/story/StoryVariantSingle.vue2.js +5 -6
- package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue2.js +3 -3
- package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue2.js +4 -4
- package/dist/bundled/components/story/StoryVariantSingleView.vue2.js +4 -4
- package/dist/bundled/components/story/StoryView.vue2.js +5 -5
- package/dist/bundled/components/story/StoryViewer.vue.js +2 -2
- package/dist/bundled/components/story/StoryViewer.vue2.js +3 -4
- package/dist/bundled/components/toolbar/ToolbarBackground.vue.js +1 -1
- package/dist/bundled/components/toolbar/ToolbarBackground.vue2.js +3 -4
- package/dist/bundled/components/toolbar/ToolbarResponsiveSize.vue2.js +16 -17
- package/dist/bundled/components/tree/StoryGroup.vue2.js +9 -11
- package/dist/bundled/components/tree/StoryList.vue2.js +3 -3
- package/dist/bundled/components/tree/StoryListFolder.vue.js +2 -2
- package/dist/bundled/components/tree/StoryListFolder.vue2.js +13 -15
- package/dist/bundled/components/tree/StoryListItem.vue.js +2 -2
- package/dist/bundled/components/tree/StoryListItem.vue2.js +5 -6
- package/dist/bundled/index.js +4 -4
- package/dist/bundled/plugin.js +1 -2
- package/dist/bundled/sandbox.js +15 -20
- package/dist/bundled/stores/folder.js +1 -1
- package/dist/bundled/stores/preview-settings.js +1 -1
- package/dist/bundled/util/commands.js +1 -1
- package/dist/bundled/util/dark.js +1 -1
- package/dist/bundled/util/events.js +2 -4
- package/dist/bundled/util/scroll.js +1 -1
- package/dist/bundled/util/state.js +2 -2
- package/dist/style.css +281 -293
- package/package.json +24 -25
- package/scripts/copy.mjs +1 -1
- package/scripts/watchAndCopy.mjs +4 -4
- package/src/app/App.vue +15 -15
- package/src/app/api.ts +3 -3
- package/src/app/components/HomeView.vue +4 -3
- package/src/app/components/app/AppHeader.vue +2 -2
- package/src/app/components/app/AppLogo.vue +4 -4
- package/src/app/components/app/Breadcrumb.vue +5 -5
- 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 +5 -5
- package/src/app/components/base/BaseSelect.vue +6 -5
- package/src/app/components/base/BaseSplitPane.vue +19 -15
- package/src/app/components/command/CommandPrompts.vue +8 -10
- package/src/app/components/command/CommandPromptsModal.vue +2 -1
- package/src/app/components/command/PromptSelect.vue +7 -5
- package/src/app/components/command/PromptText.vue +4 -3
- package/src/app/components/panel/ControlsComponentPropItem.vue +4 -4
- package/src/app/components/panel/ControlsComponentState.vue +3 -3
- package/src/app/components/panel/ControlsComponentStateItem.vue +2 -2
- package/src/app/components/panel/PaneTabs.vue +3 -3
- package/src/app/components/panel/StatePresets.vue +16 -13
- package/src/app/components/panel/StoryControls.vue +5 -5
- 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 +3 -3
- package/src/app/components/panel/StorySidePanel.vue +2 -2
- package/src/app/components/panel/StorySourceCode.vue +12 -8
- package/src/app/components/search/SearchItem.vue +5 -4
- package/src/app/components/search/SearchItemContent.vue +4 -4
- package/src/app/components/search/SearchModal.vue +2 -1
- package/src/app/components/search/SearchPane.vue +64 -76
- package/src/app/components/search/search-docs-data.ts +3 -3
- package/src/app/components/search/search-title-data.ts +3 -3
- package/src/app/components/search/types.ts +1 -1
- package/src/app/components/story/GenericMountStory.vue +2 -2
- package/src/app/components/story/GenericRenderStory.vue +4 -3
- package/src/app/components/story/StoryResponsivePreview.vue +17 -16
- package/src/app/components/story/StoryVariantGrid.vue +10 -9
- package/src/app/components/story/StoryVariantGridItem.vue +14 -14
- package/src/app/components/story/StoryVariantListItem.vue +4 -3
- package/src/app/components/story/StoryVariantSingle.vue +3 -3
- package/src/app/components/story/StoryVariantSinglePreviewNative.vue +5 -5
- package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +14 -14
- package/src/app/components/story/StoryVariantSingleView.vue +4 -4
- package/src/app/components/story/StoryView.vue +8 -8
- package/src/app/components/story/StoryViewer.vue +2 -3
- package/src/app/components/toolbar/ToolbarNewTab.vue +1 -1
- package/src/app/components/toolbar/ToolbarTitle.vue +1 -1
- package/src/app/components/tree/StoryGroup.vue +3 -3
- package/src/app/components/tree/StoryList.vue +3 -3
- package/src/app/components/tree/StoryListFolder.vue +3 -3
- package/src/app/components/tree/StoryListItem.vue +2 -2
- package/src/app/index.ts +6 -7
- package/src/app/plugin.ts +4 -3
- package/src/app/router.ts +2 -2
- package/src/app/sandbox.ts +24 -27
- package/src/app/stores/command.ts +4 -3
- package/src/app/stores/events.ts +4 -4
- package/src/app/stores/folder.ts +10 -8
- package/src/app/stores/preview-settings.ts +2 -2
- package/src/app/stores/story.ts +4 -4
- package/src/app/style/main.pcss +1 -1
- package/src/app/style/sandbox.css +1 -1
- package/src/app/types.ts +3 -3
- package/src/app/util/commands.ts +5 -4
- package/src/app/util/dark.ts +3 -3
- 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 +9 -6
- 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 +4 -3
- package/src/bundle-main-dev.js +1 -1
- package/src/bundle-main.js +2 -2
- package/src/shim.d.ts +0 -6
- package/src/virtual.d.ts +1 -0
- package/tailwind.config.cjs +20 -21
- package/tsconfig.json +26 -26
- package/vite.config.ts +8 -7
- package/dist/bundled/components/app/Breadcrumb.vue3.js +0 -1
- package/dist/bundled/components/base/BaseEmpty.vue2.js +0 -1
- package/dist/bundled/components/base/BaseIcon.vue3.js +0 -1
- package/dist/bundled/components/base/BaseSplitPane.vue3.js +0 -1
- package/dist/bundled/components/misc/HatchedPattern.vue2.js +0 -1
- package/dist/bundled/components/panel/StorySourceCode.vue3.js +0 -1
- package/dist/bundled/components/search/SearchItem.vue3.js +0 -1
- package/dist/bundled/components/story/StoryResponsivePreview.vue3.js +0 -1
- package/dist/bundled/components/story/StoryVariantGridItem.vue3.js +0 -1
- package/dist/bundled/components/story/StoryVariantListItem.vue3.js +0 -1
- package/dist/bundled/components/story/StoryVariantSingle.vue3.js +0 -1
- package/dist/bundled/components/story/StoryViewer.vue3.js +0 -1
- package/dist/bundled/components/toolbar/ToolbarBackground.vue3.js +0 -1
- package/dist/bundled/components/tree/StoryListFolder.vue3.js +0 -1
- package/dist/bundled/components/tree/StoryListItem.vue3.js +0 -1
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/common.js +0 -52
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/en.js +0 -10
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/advanced.js +0 -16
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/balance.js +0 -31
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/simple.js +0 -15
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang.js +0 -60
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/type.js +0 -11
- package/dist/bundled/style.css +0 -101
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { SelectPrompt, SelectPromptOption } from '@histoire/shared'
|
|
3
|
-
import { computed, ref, watchEffect } from 'vue'
|
|
4
3
|
import { Icon } from '@iconify/vue'
|
|
4
|
+
import { computed, ref, watchEffect } from 'vue'
|
|
5
5
|
import { useSelection } from '../../util/select.js'
|
|
6
6
|
import BaseKeyboardShortcut from '../base/BaseKeyboardShortcut.vue'
|
|
7
7
|
|
|
@@ -26,7 +26,7 @@ const model = computed({
|
|
|
26
26
|
|
|
27
27
|
const input = ref<HTMLInputElement>()
|
|
28
28
|
|
|
29
|
-
function focus
|
|
29
|
+
function focus() {
|
|
30
30
|
input.value?.focus()
|
|
31
31
|
input.value?.select()
|
|
32
32
|
}
|
|
@@ -47,7 +47,8 @@ watchEffect(async () => {
|
|
|
47
47
|
if (rId === requestId) {
|
|
48
48
|
options.value = result
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
51
52
|
options.value = props.prompt.options
|
|
52
53
|
}
|
|
53
54
|
})
|
|
@@ -59,7 +60,8 @@ const formattedOptions = computed(() => {
|
|
|
59
60
|
value: option,
|
|
60
61
|
label: option,
|
|
61
62
|
}
|
|
62
|
-
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
63
65
|
return option
|
|
64
66
|
}
|
|
65
67
|
})
|
|
@@ -73,7 +75,7 @@ const {
|
|
|
73
75
|
selectPrevious,
|
|
74
76
|
} = useSelection(formattedOptions)
|
|
75
77
|
|
|
76
|
-
function selectIndex
|
|
78
|
+
function selectIndex(index: number) {
|
|
77
79
|
const result = formattedOptions.value[index].value
|
|
78
80
|
if (result) {
|
|
79
81
|
model.value = result
|
|
@@ -14,12 +14,12 @@ const emit = defineEmits<{
|
|
|
14
14
|
|
|
15
15
|
const model = computed({
|
|
16
16
|
get: () => props.modelValue,
|
|
17
|
-
set:
|
|
17
|
+
set: value => emit('update:modelValue', value),
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
const input = ref<HTMLInputElement>()
|
|
21
21
|
|
|
22
|
-
function focus
|
|
22
|
+
function focus() {
|
|
23
23
|
input.value?.focus()
|
|
24
24
|
input.value?.select()
|
|
25
25
|
}
|
|
@@ -33,7 +33,8 @@ defineExpose({
|
|
|
33
33
|
const defaultValue = computed(() => {
|
|
34
34
|
if (typeof props.prompt.defaultValue === 'function') {
|
|
35
35
|
return props.prompt.defaultValue(props.answers)
|
|
36
|
-
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
37
38
|
return props.prompt.defaultValue
|
|
38
39
|
}
|
|
39
40
|
})
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed } from 'vue'
|
|
3
|
-
import { Icon } from '@iconify/vue'
|
|
4
2
|
import type { AutoPropComponentDefinition, PropDefinition } from '@histoire/shared'
|
|
5
|
-
import { HstCheckbox, HstJson, HstNumber, HstText } from '@histoire/controls'
|
|
6
3
|
import type { Variant } from '../../types'
|
|
4
|
+
import { HstCheckbox, HstJson, HstNumber, HstText } from '@histoire/controls'
|
|
5
|
+
import { Icon } from '@iconify/vue'
|
|
6
|
+
import { computed } from 'vue'
|
|
7
7
|
|
|
8
8
|
const props = defineProps<{
|
|
9
9
|
variant: Variant
|
|
@@ -39,7 +39,7 @@ const model = computed({
|
|
|
39
39
|
},
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
-
function reset
|
|
42
|
+
function reset() {
|
|
43
43
|
if (props.variant.state._hPropState[props.component.index]) {
|
|
44
44
|
// eslint-disable-next-line vue/no-mutating-props
|
|
45
45
|
delete props.variant.state._hPropState[props.component.index][props.definition.name]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed } from 'vue'
|
|
3
|
-
import { Icon } from '@iconify/vue'
|
|
4
2
|
import type { Variant } from '@histoire/shared'
|
|
3
|
+
import { Icon } from '@iconify/vue'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
5
|
import ControlsComponentStateItem from './ControlsComponentStateItem.vue'
|
|
6
6
|
|
|
7
7
|
const props = defineProps<{
|
|
@@ -9,7 +9,7 @@ const props = defineProps<{
|
|
|
9
9
|
}>()
|
|
10
10
|
|
|
11
11
|
const stateKeys = computed(() => Object.keys(props.variant.state || {})
|
|
12
|
-
.filter(
|
|
12
|
+
.filter(key => !key.startsWith('_h')))
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed } from 'vue'
|
|
3
|
-
import { HstCheckbox, HstJson, HstNumber, HstText } from '@histoire/controls'
|
|
4
2
|
import type { Variant } from '../../types'
|
|
3
|
+
import { HstCheckbox, HstJson, HstNumber, HstText } from '@histoire/controls'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
5
|
|
|
6
6
|
const props = defineProps<{
|
|
7
7
|
variant: Variant
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
+
import type { Story, Variant } from '../../types'
|
|
2
3
|
import { computed, toRefs } from 'vue'
|
|
3
|
-
import BaseTab from '../base/BaseTab.vue'
|
|
4
4
|
import { useEventsStore } from '../../stores/events'
|
|
5
|
-
import type { Story, Variant } from '../../types'
|
|
6
5
|
import BaseOverflowMenu from '../base/BaseOverflowMenu.vue'
|
|
7
6
|
import BaseOverflowTab from '../base/BaseOverflowTab.vue'
|
|
8
|
-
import
|
|
7
|
+
import BaseTab from '../base/BaseTab.vue'
|
|
9
8
|
import BaseTag from '../base/BaseTag.vue'
|
|
9
|
+
import { useStoryDoc } from './StoryDocs.vue'
|
|
10
10
|
|
|
11
11
|
const props = defineProps<{
|
|
12
12
|
story: Story
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
import { Icon } from '@iconify/vue'
|
|
4
|
-
import { useStorage, onClickOutside, useTimeoutFn } from '@vueuse/core'
|
|
2
|
+
import type { Story, Variant } from '../../types'
|
|
5
3
|
import { applyState, clone, omit } from '@histoire/shared'
|
|
6
|
-
import
|
|
4
|
+
import { Icon } from '@iconify/vue'
|
|
5
|
+
import { onClickOutside, useStorage, useTimeoutFn } from '@vueuse/core'
|
|
6
|
+
import { computed, nextTick, onMounted, ref } from 'vue'
|
|
7
7
|
import { toRawDeep } from '../../util/state'
|
|
8
|
-
import
|
|
8
|
+
import BaseSelect from '../base/BaseSelect.vue'
|
|
9
9
|
|
|
10
10
|
const DEFAULT_ID = 'default'
|
|
11
11
|
|
|
@@ -38,15 +38,16 @@ const presetsOptions = computed(() => {
|
|
|
38
38
|
return options
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
function resetState
|
|
41
|
+
function resetState() {
|
|
42
42
|
selectedOption.value = DEFAULT_ID
|
|
43
43
|
applyState(props.variant.state, clone(defaultState))
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function applyPreset
|
|
46
|
+
function applyPreset(id) {
|
|
47
47
|
if (id === DEFAULT_ID) {
|
|
48
48
|
resetState()
|
|
49
|
-
}
|
|
49
|
+
}
|
|
50
|
+
else if (presetStates.value.has(id)) {
|
|
50
51
|
applyState(props.variant.state, clone(toRawDeep(presetStates.value.get(id).state)))
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -62,7 +63,7 @@ const select = ref<HTMLInputElement>()
|
|
|
62
63
|
const canEdit = computed(() => selectedOption.value !== DEFAULT_ID)
|
|
63
64
|
const isEditing = ref(false)
|
|
64
65
|
|
|
65
|
-
async function createPreset
|
|
66
|
+
async function createPreset() {
|
|
66
67
|
const id = (new Date()).getTime().toString()
|
|
67
68
|
|
|
68
69
|
presetStates.value.set(id, { state: clone(omit(toRawDeep(props.variant.state), omitKeys)), label: 'New preset' })
|
|
@@ -77,7 +78,7 @@ const savedTimeout = useTimeoutFn(() => {
|
|
|
77
78
|
savedNotif.value = false
|
|
78
79
|
}, 1000)
|
|
79
80
|
|
|
80
|
-
async function savePreset
|
|
81
|
+
async function savePreset() {
|
|
81
82
|
if (!canEdit.value) return
|
|
82
83
|
|
|
83
84
|
const preset = presetStates.value.get(selectedOption.value)
|
|
@@ -86,7 +87,9 @@ async function savePreset () {
|
|
|
86
87
|
savedTimeout.start()
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
function deletePreset
|
|
90
|
+
function deletePreset(id) {
|
|
91
|
+
// @TODO custom confirm modal UI
|
|
92
|
+
// eslint-disable-next-line no-alert
|
|
90
93
|
if (!confirm('Are you sure you want to delete this preset?')) {
|
|
91
94
|
return
|
|
92
95
|
}
|
|
@@ -97,7 +100,7 @@ function deletePreset (id) {
|
|
|
97
100
|
presetStates.value.delete(id)
|
|
98
101
|
}
|
|
99
102
|
|
|
100
|
-
async function startEditing
|
|
103
|
+
async function startEditing() {
|
|
101
104
|
if (!canEdit.value) {
|
|
102
105
|
return
|
|
103
106
|
}
|
|
@@ -107,7 +110,7 @@ async function startEditing () {
|
|
|
107
110
|
input.value.select()
|
|
108
111
|
}
|
|
109
112
|
|
|
110
|
-
function stopEditing
|
|
113
|
+
function stopEditing() {
|
|
111
114
|
isEditing.value = false
|
|
112
115
|
}
|
|
113
116
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
import { Icon } from '@iconify/vue'
|
|
4
|
-
import GenericRenderStory from '../story/GenericRenderStory.vue'
|
|
2
|
+
import type { PropType } from 'vue'
|
|
5
3
|
import type { Story, Variant } from '../../types'
|
|
4
|
+
import { Icon } from '@iconify/vue'
|
|
5
|
+
import { computed, ref, watch } from 'vue'
|
|
6
6
|
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
7
|
-
import
|
|
7
|
+
import GenericRenderStory from '../story/GenericRenderStory.vue'
|
|
8
8
|
import ControlsComponentProps from './ControlsComponentProps.vue'
|
|
9
9
|
import ControlsComponentState from './ControlsComponentState.vue'
|
|
10
|
+
import StatePresets from './StatePresets.vue'
|
|
10
11
|
|
|
11
12
|
const props = defineProps({
|
|
12
13
|
variant: {
|
|
@@ -33,7 +34,6 @@ const hasInitState = computed(() => Object
|
|
|
33
34
|
.entries(props.variant.state || {})
|
|
34
35
|
.filter(([key]) => !key.startsWith('_h'))
|
|
35
36
|
.length > 0)
|
|
36
|
-
|
|
37
37
|
</script>
|
|
38
38
|
|
|
39
39
|
<template>
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import type { PropType, Ref } from 'vue'
|
|
3
3
|
import type { Story } from '../../types'
|
|
4
|
+
import { Icon } from '@iconify/vue'
|
|
4
5
|
import { markdownFiles } from 'virtual:$histoire-markdown-files'
|
|
6
|
+
import { computed, nextTick, ref, toRefs, watch, watchEffect } from 'vue'
|
|
7
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
5
8
|
import { histoireConfig } from '../../util/config.js'
|
|
9
|
+
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
6
10
|
import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
|
|
7
11
|
|
|
8
|
-
export function useStoryDoc
|
|
12
|
+
export function useStoryDoc(story: Ref<Story>) {
|
|
9
13
|
const renderedDoc = ref('')
|
|
10
14
|
|
|
11
15
|
watchEffect(async () => {
|
|
12
16
|
// Markdown file
|
|
13
|
-
const mdKey = story.value.file.filePath.replace(/\.(\w
|
|
17
|
+
const mdKey = story.value.file.filePath.replace(/\.(\w*)$/, '.md')
|
|
14
18
|
if (markdownFiles[mdKey]) {
|
|
15
19
|
const md = await markdownFiles[mdKey]()
|
|
16
20
|
renderedDoc.value = md.html
|
|
@@ -23,12 +27,15 @@ export function useStoryDoc (story: Ref<Story>) {
|
|
|
23
27
|
if (comp) {
|
|
24
28
|
if (comp.__asyncResolved) {
|
|
25
29
|
comp = comp.__asyncResolved
|
|
26
|
-
}
|
|
30
|
+
}
|
|
31
|
+
else if (comp.__asyncLoader) {
|
|
27
32
|
comp = await comp.__asyncLoader()
|
|
28
|
-
}
|
|
33
|
+
}
|
|
34
|
+
else if (typeof comp === 'function') {
|
|
29
35
|
try {
|
|
30
36
|
comp = await comp()
|
|
31
|
-
}
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
32
39
|
// Noop
|
|
33
40
|
// Could be a class that requires `new com()`
|
|
34
41
|
}
|
|
@@ -47,10 +54,6 @@ export function useStoryDoc (story: Ref<Story>) {
|
|
|
47
54
|
</script>
|
|
48
55
|
|
|
49
56
|
<script lang="ts" setup>
|
|
50
|
-
import { Icon } from '@iconify/vue'
|
|
51
|
-
import { useRoute, useRouter } from 'vue-router'
|
|
52
|
-
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
53
|
-
|
|
54
57
|
const props = defineProps({
|
|
55
58
|
story: {
|
|
56
59
|
type: Object as PropType<Story>,
|
|
@@ -64,7 +67,7 @@ const props = defineProps({
|
|
|
64
67
|
})
|
|
65
68
|
|
|
66
69
|
const emit = defineEmits<{
|
|
67
|
-
(e: '
|
|
70
|
+
(e: 'scrollTop'): void
|
|
68
71
|
}>()
|
|
69
72
|
|
|
70
73
|
const { story } = toRefs(props)
|
|
@@ -78,16 +81,16 @@ const router = useRouter()
|
|
|
78
81
|
// matter and is only passed to support same-host hrefs.
|
|
79
82
|
const fakeHost = `http://a.com`
|
|
80
83
|
|
|
81
|
-
function onClick
|
|
84
|
+
function onClick(e: MouseEvent) {
|
|
82
85
|
const link = (e.target as Element).closest('a')
|
|
83
86
|
if (
|
|
84
|
-
link
|
|
85
|
-
link.getAttribute('data-route')
|
|
86
|
-
!e.ctrlKey
|
|
87
|
-
!e.shiftKey
|
|
88
|
-
!e.altKey
|
|
89
|
-
!e.metaKey
|
|
90
|
-
link.target !== `_blank`
|
|
87
|
+
link
|
|
88
|
+
&& link.getAttribute('data-route')
|
|
89
|
+
&& !e.ctrlKey
|
|
90
|
+
&& !e.shiftKey
|
|
91
|
+
&& !e.altKey
|
|
92
|
+
&& !e.metaKey
|
|
93
|
+
&& link.target !== `_blank`
|
|
91
94
|
) {
|
|
92
95
|
e.preventDefault()
|
|
93
96
|
const url = new URL(link.href, fakeHost)
|
|
@@ -98,20 +101,21 @@ function onClick (e: MouseEvent) {
|
|
|
98
101
|
|
|
99
102
|
// Handle URL anchor
|
|
100
103
|
|
|
101
|
-
function getHash
|
|
104
|
+
function getHash() {
|
|
102
105
|
const hash = location.hash
|
|
103
106
|
if (histoireConfig.routerMode === 'hash') {
|
|
104
107
|
const index = hash.indexOf('#', 1)
|
|
105
108
|
if (index !== -1) {
|
|
106
109
|
return hash.slice(index)
|
|
107
|
-
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
108
112
|
return undefined
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
return hash
|
|
112
116
|
}
|
|
113
117
|
|
|
114
|
-
async function scrollToAnchor
|
|
118
|
+
async function scrollToAnchor() {
|
|
115
119
|
await nextTick()
|
|
116
120
|
const hash = getHash()
|
|
117
121
|
if (hash) {
|
|
@@ -121,7 +125,7 @@ async function scrollToAnchor () {
|
|
|
121
125
|
return
|
|
122
126
|
}
|
|
123
127
|
}
|
|
124
|
-
emit('
|
|
128
|
+
emit('scrollTop')
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
watch(renderedDoc, () => {
|
|
@@ -135,7 +139,7 @@ watch(renderedDoc, () => {
|
|
|
135
139
|
const renderedEl = ref<HTMLElement>()
|
|
136
140
|
const route = useRoute()
|
|
137
141
|
|
|
138
|
-
async function patchAnchorLinks
|
|
142
|
+
async function patchAnchorLinks() {
|
|
139
143
|
await nextTick()
|
|
140
144
|
if (histoireConfig.routerMode === 'hash' && renderedEl.value) {
|
|
141
145
|
const links = renderedEl.value.querySelectorAll('a.header-anchor')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
+
import type { HstEvent } from '../../stores/events'
|
|
2
3
|
import { computed } from 'vue'
|
|
3
|
-
import { HstEvent } from '../../stores/events'
|
|
4
4
|
|
|
5
5
|
const props = defineProps<{
|
|
6
6
|
event: HstEvent
|
|
@@ -11,7 +11,7 @@ const formattedArgument = computed(() => {
|
|
|
11
11
|
case 'string':
|
|
12
12
|
return `"${props.event.argument}"`
|
|
13
13
|
case 'object':
|
|
14
|
-
return `{ ${Object.keys(props.event.argument).map(
|
|
14
|
+
return `{ ${Object.keys(props.event.argument).map(key => `${key}: ${props.event.argument[key]}`).join(', ')} }`
|
|
15
15
|
default:
|
|
16
16
|
return props.event.argument
|
|
17
17
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { ref, computed, watch, onMounted, nextTick } from 'vue'
|
|
3
2
|
import { Icon } from '@iconify/vue'
|
|
4
|
-
import
|
|
3
|
+
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
|
5
4
|
import { useEventsStore } from '../../stores/events'
|
|
5
|
+
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
6
6
|
import StoryEvent from './StoryEvent.vue'
|
|
7
7
|
|
|
8
8
|
const eventsStore = useEventsStore()
|
|
@@ -12,7 +12,7 @@ const hasEvents = computed(() => eventsStore.events.length)
|
|
|
12
12
|
onMounted(resetUnseen)
|
|
13
13
|
watch(() => eventsStore.unseen, resetUnseen)
|
|
14
14
|
|
|
15
|
-
async function resetUnseen
|
|
15
|
+
async function resetUnseen() {
|
|
16
16
|
if (eventsStore.unseen > 0) {
|
|
17
17
|
eventsStore.unseen = 0
|
|
18
18
|
}
|
|
@@ -3,13 +3,13 @@ import { computed } from 'vue'
|
|
|
3
3
|
import { useRoute } from 'vue-router'
|
|
4
4
|
import { useStoryStore } from '../../stores/story'
|
|
5
5
|
|
|
6
|
-
import BaseSplitPane from '../base/BaseSplitPane.vue'
|
|
7
6
|
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
7
|
+
import BaseSplitPane from '../base/BaseSplitPane.vue'
|
|
8
|
+
import PaneTabs from './PaneTabs.vue'
|
|
8
9
|
import StoryControls from './StoryControls.vue'
|
|
9
10
|
import StoryDocs from './StoryDocs.vue'
|
|
10
11
|
import StoryEvents from './StoryEvents.vue'
|
|
11
12
|
import StorySourceCode from './StorySourceCode.vue'
|
|
12
|
-
import PaneTabs from './PaneTabs.vue'
|
|
13
13
|
|
|
14
14
|
const storyStore = useStoryStore()
|
|
15
15
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { getHighlighter, Highlighter } from 'shiki-es'
|
|
2
|
+
import type { Highlighter } from 'shiki-es'
|
|
3
|
+
import type { Story, Variant } from '../../types'
|
|
5
4
|
import { HstCopyIcon } from '@histoire/controls'
|
|
6
5
|
import { unindent } from '@histoire/shared'
|
|
6
|
+
import { Icon } from '@iconify/vue'
|
|
7
|
+
import { getHighlighter } from 'shiki-es'
|
|
7
8
|
import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
|
|
8
|
-
import
|
|
9
|
+
import { computed, markRaw, nextTick, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'
|
|
9
10
|
import { isDark } from '../../util/dark'
|
|
10
11
|
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
11
12
|
|
|
@@ -36,15 +37,18 @@ watch(() => [props.variant, generateSourceCodeFn.value], async () => {
|
|
|
36
37
|
try {
|
|
37
38
|
if (props.variant.source) {
|
|
38
39
|
dynamicSourceCode.value = props.variant.source
|
|
39
|
-
}
|
|
40
|
+
}
|
|
41
|
+
else if (props.variant.slots?.().source) {
|
|
40
42
|
const source = props.variant.slots?.().source()[0].children
|
|
41
43
|
if (source) {
|
|
42
44
|
dynamicSourceCode.value = await unindent(source)
|
|
43
45
|
}
|
|
44
|
-
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
45
48
|
dynamicSourceCode.value = await generateSourceCodeFn.value(props.variant)
|
|
46
49
|
}
|
|
47
|
-
}
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
48
52
|
console.error(e)
|
|
49
53
|
error.value = e.message
|
|
50
54
|
}
|
|
@@ -113,7 +117,7 @@ watch(() => props.variant, () => {
|
|
|
113
117
|
|
|
114
118
|
const scroller = ref<HTMLElement>()
|
|
115
119
|
|
|
116
|
-
function onScroll
|
|
120
|
+
function onScroll(event) {
|
|
117
121
|
if (sourceHtml.value) {
|
|
118
122
|
lastScroll = event.target.scrollTop
|
|
119
123
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { PropType
|
|
2
|
+
import type { PropType } from 'vue'
|
|
3
|
+
import type { SearchResult } from '../../types'
|
|
4
|
+
import { ref, toRefs } from 'vue'
|
|
3
5
|
import { useRouter } from 'vue-router'
|
|
4
|
-
import { SearchResult } from '../../types'
|
|
5
6
|
import { onKeyboardShortcut } from '../../util/keyboard'
|
|
6
7
|
import { useScrollOnActive } from '../../util/scroll'
|
|
7
|
-
import BaseListItemLink from '../base/BaseListItemLink.vue'
|
|
8
8
|
import BaseListItem from '../base/BaseListItem.vue'
|
|
9
|
+
import BaseListItemLink from '../base/BaseListItemLink.vue'
|
|
9
10
|
import SearchItemContent from './SearchItemContent.vue'
|
|
10
11
|
|
|
11
12
|
const props = defineProps({
|
|
@@ -36,7 +37,7 @@ onKeyboardShortcut(['enter'], () => {
|
|
|
36
37
|
action()
|
|
37
38
|
})
|
|
38
39
|
|
|
39
|
-
function action
|
|
40
|
+
function action(fromClick = false) {
|
|
40
41
|
if ('route' in props.result && !fromClick) {
|
|
41
42
|
router.push(props.result.route)
|
|
42
43
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
+
import type { SearchResult } from '../../types.js'
|
|
2
3
|
import { Icon } from '@iconify/vue'
|
|
3
4
|
import BaseIcon from '../base/BaseIcon.vue'
|
|
4
|
-
import type { SearchResult } from '../../types.js'
|
|
5
5
|
|
|
6
6
|
defineProps<{
|
|
7
7
|
result: SearchResult
|
|
@@ -27,15 +27,15 @@ const kindLabels = {
|
|
|
27
27
|
:class="[
|
|
28
28
|
!selected ? [
|
|
29
29
|
result.iconColor
|
|
30
|
-
?'bind-icon-color'
|
|
30
|
+
? 'bind-icon-color'
|
|
31
31
|
: {
|
|
32
32
|
'htw-text-primary-500': result.kind === 'story',
|
|
33
33
|
'htw-text-gray-500': result.kind === 'variant',
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
35
|
] : [],
|
|
36
36
|
{
|
|
37
37
|
'colorize-black': selected,
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
39
|
]"
|
|
40
40
|
/>
|
|
41
41
|
<div class="htw-flex-1">
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { defineAsyncComponent } from 'vue'
|
|
3
3
|
import SearchLoading from './SearchLoading.vue'
|
|
4
|
+
|
|
4
5
|
const SearchPane = defineAsyncComponent({
|
|
5
6
|
loader: () => import('./SearchPane.vue'),
|
|
6
7
|
loadingComponent: SearchLoading,
|
|
@@ -18,7 +19,7 @@ const emit = defineEmits({
|
|
|
18
19
|
close: () => true,
|
|
19
20
|
})
|
|
20
21
|
|
|
21
|
-
function close
|
|
22
|
+
function close() {
|
|
22
23
|
emit('close')
|
|
23
24
|
}
|
|
24
25
|
</script>
|