@ohos-ports/histoire-app 1.0.0-beta.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/LICENSE +21 -0
- package/dist/app/assets/histoire-text-dark.svg +89 -0
- package/dist/app/assets/histoire-text.svg +89 -0
- package/dist/app/assets/histoire.svg +51 -0
- package/dist/app/style/floating.pcss +34 -0
- package/dist/app/style/main.pcss +100 -0
- package/dist/app/style/sandbox.css +24 -0
- package/dist/app/style/transitions.pcss +51 -0
- package/dist/bundle-index.js +3 -0
- package/dist/bundle-main-dev.js +4 -0
- package/dist/bundle-main.js +5 -0
- package/dist/bundle-sandbox-dev.js +2 -0
- package/dist/bundle-sandbox.js +2 -0
- package/dist/bundled/App.vue.js +5 -0
- package/dist/bundled/App.vue2.js +167 -0
- package/dist/bundled/_virtual/_node-dom-env.js +188 -0
- package/dist/bundled/_virtual/_node-dom-polyfill.js +152 -0
- package/dist/bundled/_virtual/_plugin-vue_export-helper.js +10 -0
- package/dist/bundled/_virtual/histoire-commands.js +8 -0
- package/dist/bundled/_virtual/histoire-config.js +42 -0
- package/dist/bundled/_virtual/histoire-markdown-files.js +8 -0
- package/dist/bundled/_virtual/histoire-search-docs-data.js +11 -0
- package/dist/bundled/_virtual/histoire-search-title-data.js +11 -0
- package/dist/bundled/_virtual/histoire-stories.js +17 -0
- package/dist/bundled/_virtual/histoire-support-plugins-client.js +8 -0
- package/dist/bundled/_virtual/histoire-theme.js +8 -0
- package/dist/bundled/api.js +12 -0
- package/dist/bundled/app.css +116 -0
- package/dist/bundled/assets/histoire-text-dark.svg.js +4 -0
- package/dist/bundled/assets/histoire-text.svg.js +4 -0
- package/dist/bundled/assets/histoire.svg.js +4 -0
- package/dist/bundled/components/HomeView.vue.js +5 -0
- package/dist/bundled/components/HomeView.vue2.js +66 -0
- package/dist/bundled/components/app/AppHeader.vue.js +5 -0
- package/dist/bundled/components/app/AppHeader.vue2.js +71 -0
- package/dist/bundled/components/app/AppLogo.vue.js +5 -0
- package/dist/bundled/components/app/AppLogo.vue2.js +29 -0
- package/dist/bundled/components/app/Breadcrumb.vue.js +8 -0
- package/dist/bundled/components/app/Breadcrumb.vue2.js +91 -0
- package/dist/bundled/components/app/HomeCounter.vue.js +5 -0
- package/dist/bundled/components/app/HomeCounter.vue2.js +42 -0
- package/dist/bundled/components/app/InitialLoading.vue.js +5 -0
- package/dist/bundled/components/app/InitialLoading.vue2.js +51 -0
- package/dist/bundled/components/app/MobileOverlay.vue.js +5 -0
- package/dist/bundled/components/app/MobileOverlay.vue2.js +45 -0
- package/dist/bundled/components/base/BaseButton.vue.js +5 -0
- package/dist/bundled/components/base/BaseButton.vue2.js +39 -0
- package/dist/bundled/components/base/BaseCheckbox.vue.js +5 -0
- package/dist/bundled/components/base/BaseCheckbox.vue2.js +78 -0
- package/dist/bundled/components/base/BaseEmpty.vue.js +14 -0
- package/dist/bundled/components/base/BaseIcon.vue.js +8 -0
- package/dist/bundled/components/base/BaseIcon.vue2.js +29 -0
- package/dist/bundled/components/base/BaseKeyboardShortcut.vue.js +5 -0
- package/dist/bundled/components/base/BaseKeyboardShortcut.vue2.js +20 -0
- package/dist/bundled/components/base/BaseListItem.vue.js +5 -0
- package/dist/bundled/components/base/BaseListItem.vue2.js +33 -0
- package/dist/bundled/components/base/BaseListItemLink.vue.js +33 -0
- package/dist/bundled/components/base/BaseListItemLink.vue2.js +26 -0
- package/dist/bundled/components/base/BaseOverflowMenu.vue.js +5 -0
- package/dist/bundled/components/base/BaseOverflowMenu.vue2.js +100 -0
- package/dist/bundled/components/base/BaseOverflowTab.vue.js +36 -0
- package/dist/bundled/components/base/BaseOverflowTab.vue2.js +18 -0
- package/dist/bundled/components/base/BaseSelect.vue.js +5 -0
- package/dist/bundled/components/base/BaseSelect.vue2.js +77 -0
- package/dist/bundled/components/base/BaseSplitPane.vue.js +8 -0
- package/dist/bundled/components/base/BaseSplitPane.vue2.js +183 -0
- package/dist/bundled/components/base/BaseTab.vue.js +36 -0
- package/dist/bundled/components/base/BaseTab.vue2.js +18 -0
- package/dist/bundled/components/base/BaseTag.vue.js +13 -0
- package/dist/bundled/components/command/CommandPrompts.vue.js +5 -0
- package/dist/bundled/components/command/CommandPrompts.vue2.js +91 -0
- package/dist/bundled/components/command/CommandPromptsModal.vue.js +5 -0
- package/dist/bundled/components/command/CommandPromptsModal.vue2.js +45 -0
- package/dist/bundled/components/command/PromptSelect.vue.js +5 -0
- package/dist/bundled/components/command/PromptSelect.vue2.js +142 -0
- package/dist/bundled/components/command/PromptText.vue.js +5 -0
- package/dist/bundled/components/command/PromptText.vue2.js +67 -0
- package/dist/bundled/components/misc/CheckerboardPattern.vue.js +40 -0
- package/dist/bundled/components/misc/HatchedPattern.vue.js +12 -0
- package/dist/bundled/components/panel/ControlsComponentPropItem.vue.js +5 -0
- package/dist/bundled/components/panel/ControlsComponentPropItem.vue2.js +72 -0
- package/dist/bundled/components/panel/ControlsComponentProps.vue.js +5 -0
- package/dist/bundled/components/panel/ControlsComponentProps.vue2.js +45 -0
- package/dist/bundled/components/panel/ControlsComponentState.vue.js +5 -0
- package/dist/bundled/components/panel/ControlsComponentState.vue2.js +41 -0
- package/dist/bundled/components/panel/ControlsComponentStateItem.vue.js +5 -0
- package/dist/bundled/components/panel/ControlsComponentStateItem.vue2.js +46 -0
- package/dist/bundled/components/panel/PaneTabs.vue.js +5 -0
- package/dist/bundled/components/panel/PaneTabs.vue2.js +114 -0
- package/dist/bundled/components/panel/StatePresets.vue.js +5 -0
- package/dist/bundled/components/panel/StatePresets.vue2.js +193 -0
- package/dist/bundled/components/panel/StoryControls.vue.js +5 -0
- package/dist/bundled/components/panel/StoryControls.vue2.js +87 -0
- package/dist/bundled/components/panel/StoryDocs.vue.js +7 -0
- package/dist/bundled/components/panel/StoryDocs.vue2.js +161 -0
- package/dist/bundled/components/panel/StoryEvent.vue.js +5 -0
- package/dist/bundled/components/panel/StoryEvent.vue2.js +59 -0
- package/dist/bundled/components/panel/StoryEvents.vue.js +5 -0
- package/dist/bundled/components/panel/StoryEvents.vue2.js +53 -0
- package/dist/bundled/components/panel/StorySidePanel.vue.js +5 -0
- package/dist/bundled/components/panel/StorySidePanel.vue2.js +83 -0
- package/dist/bundled/components/panel/StorySourceCode.vue.js +8 -0
- package/dist/bundled/components/panel/StorySourceCode.vue2.js +204 -0
- package/dist/bundled/components/search/SearchItem.vue.js +8 -0
- package/dist/bundled/components/search/SearchItem.vue2.js +93 -0
- package/dist/bundled/components/search/SearchItemContent.vue.js +5 -0
- package/dist/bundled/components/search/SearchItemContent.vue2.js +71 -0
- package/dist/bundled/components/search/SearchLoading.vue.js +5 -0
- package/dist/bundled/components/search/SearchLoading.vue2.js +21 -0
- package/dist/bundled/components/search/SearchModal.vue.js +5 -0
- package/dist/bundled/components/search/SearchModal.vue2.js +51 -0
- package/dist/bundled/components/search/SearchPane.vue.js +5 -0
- package/dist/bundled/components/search/SearchPane.vue2.js +272 -0
- package/dist/bundled/components/search/search-docs-data.js +11 -0
- package/dist/bundled/components/search/search-title-data.js +11 -0
- package/dist/bundled/components/story/GenericMountStory.vue.js +5 -0
- package/dist/bundled/components/story/GenericMountStory.vue2.js +34 -0
- package/dist/bundled/components/story/GenericRenderStory.vue.js +5 -0
- package/dist/bundled/components/story/GenericRenderStory.vue2.js +39 -0
- package/dist/bundled/components/story/StoryResponsivePreview.vue.js +8 -0
- package/dist/bundled/components/story/StoryResponsivePreview.vue2.js +207 -0
- package/dist/bundled/components/story/StoryVariantGrid.vue.js +5 -0
- package/dist/bundled/components/story/StoryVariantGrid.vue2.js +146 -0
- package/dist/bundled/components/story/StoryVariantGridItem.vue.js +8 -0
- package/dist/bundled/components/story/StoryVariantGridItem.vue2.js +153 -0
- package/dist/bundled/components/story/StoryVariantListItem.vue.js +8 -0
- package/dist/bundled/components/story/StoryVariantListItem.vue2.js +55 -0
- package/dist/bundled/components/story/StoryVariantSingle.vue.js +8 -0
- package/dist/bundled/components/story/StoryVariantSingle.vue2.js +107 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue.js +5 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue2.js +70 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue.js +5 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue2.js +128 -0
- package/dist/bundled/components/story/StoryVariantSingleView.vue.js +5 -0
- package/dist/bundled/components/story/StoryVariantSingleView.vue2.js +66 -0
- package/dist/bundled/components/story/StoryView.vue.js +5 -0
- package/dist/bundled/components/story/StoryView.vue2.js +104 -0
- package/dist/bundled/components/story/StoryViewer.vue.js +8 -0
- package/dist/bundled/components/story/StoryViewer.vue2.js +55 -0
- package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue.js +5 -0
- package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue2.js +31 -0
- package/dist/bundled/components/toolbar/ToolbarBackground.vue.js +8 -0
- package/dist/bundled/components/toolbar/ToolbarBackground.vue2.js +98 -0
- package/dist/bundled/components/toolbar/ToolbarNewTab.vue.js +5 -0
- package/dist/bundled/components/toolbar/ToolbarNewTab.vue2.js +36 -0
- package/dist/bundled/components/toolbar/ToolbarResponsiveSize.vue.js +5 -0
- package/dist/bundled/components/toolbar/ToolbarResponsiveSize.vue2.js +127 -0
- package/dist/bundled/components/toolbar/ToolbarTextDirection.vue.js +5 -0
- package/dist/bundled/components/toolbar/ToolbarTextDirection.vue2.js +27 -0
- package/dist/bundled/components/toolbar/ToolbarTitle.vue.js +5 -0
- package/dist/bundled/components/toolbar/ToolbarTitle.vue2.js +26 -0
- package/dist/bundled/components/tree/StoryGroup.vue.js +5 -0
- package/dist/bundled/components/tree/StoryGroup.vue2.js +74 -0
- package/dist/bundled/components/tree/StoryList.vue.js +5 -0
- package/dist/bundled/components/tree/StoryList.vue2.js +41 -0
- package/dist/bundled/components/tree/StoryListFolder.vue.js +8 -0
- package/dist/bundled/components/tree/StoryListFolder.vue2.js +86 -0
- package/dist/bundled/components/tree/StoryListItem.vue.js +8 -0
- package/dist/bundled/components/tree/StoryListItem.vue2.js +69 -0
- package/dist/bundled/index.js +36 -0
- package/dist/bundled/plugin.js +49 -0
- package/dist/bundled/router.js +32 -0
- package/dist/bundled/sandbox.js +87 -0
- package/dist/bundled/stores/command.js +25 -0
- package/dist/bundled/stores/events.js +29 -0
- package/dist/bundled/stores/folder.js +54 -0
- package/dist/bundled/stores/preview-settings.js +19 -0
- package/dist/bundled/stores/story.js +43 -0
- package/dist/bundled/util/commands.js +57 -0
- package/dist/bundled/util/config.js +8 -0
- package/dist/bundled/util/const.js +10 -0
- package/dist/bundled/util/dark.js +28 -0
- package/dist/bundled/util/docs.js +26 -0
- package/dist/bundled/util/env.js +4 -0
- package/dist/bundled/util/events.js +33 -0
- package/dist/bundled/util/keyboard.js +90 -0
- package/dist/bundled/util/mapping.js +70 -0
- package/dist/bundled/util/open-in-editor.js +7 -0
- package/dist/bundled/util/preview-settings.js +21 -0
- package/dist/bundled/util/responsive.js +6 -0
- package/dist/bundled/util/sandbox.js +11 -0
- package/dist/bundled/util/scroll.js +31 -0
- package/dist/bundled/util/select.js +28 -0
- package/dist/bundled/util/state.js +41 -0
- package/dist/bundled/util/tooltip.js +15 -0
- package/dist/bundled/util/variant.js +21 -0
- package/dist/style.css +2853 -0
- package/package.json +62 -0
- package/postcss-scope-wrapper.cjs +35 -0
- package/postcss.config.cjs +9 -0
- package/scripts/copy.mjs +12 -0
- package/scripts/watchAndCopy.mjs +15 -0
- package/src/app/App.vue +172 -0
- package/src/app/api.ts +9 -0
- package/src/app/assets/histoire-text-dark.svg +89 -0
- package/src/app/assets/histoire-text.svg +89 -0
- package/src/app/assets/histoire.svg +51 -0
- package/src/app/components/HomeView.vue +61 -0
- package/src/app/components/app/AppHeader.vue +65 -0
- package/src/app/components/app/AppLogo.vue +25 -0
- package/src/app/components/app/Breadcrumb.vue +98 -0
- package/src/app/components/app/HomeCounter.vue +39 -0
- package/src/app/components/app/InitialLoading.vue +44 -0
- package/src/app/components/app/MobileOverlay.vue +33 -0
- package/src/app/components/base/BaseButton.vue +33 -0
- package/src/app/components/base/BaseCheckbox.vue +76 -0
- package/src/app/components/base/BaseCopyIcon.vue +34 -0
- package/src/app/components/base/BaseEmpty.vue +21 -0
- package/src/app/components/base/BaseIcon.vue +31 -0
- package/src/app/components/base/BaseKeyboardShortcut.vue +16 -0
- package/src/app/components/base/BaseListItem.vue +30 -0
- package/src/app/components/base/BaseListItemLink.vue +56 -0
- package/src/app/components/base/BaseOverflowMenu.vue +119 -0
- package/src/app/components/base/BaseOverflowTab.vue +47 -0
- package/src/app/components/base/BaseSelect.vue +75 -0
- package/src/app/components/base/BaseSplitPane.vue +244 -0
- package/src/app/components/base/BaseTab.vue +47 -0
- package/src/app/components/base/BaseTag.vue +5 -0
- package/src/app/components/command/CommandPrompts.vue +95 -0
- package/src/app/components/command/CommandPromptsModal.vue +41 -0
- package/src/app/components/command/PromptSelect.vue +142 -0
- package/src/app/components/command/PromptText.vue +65 -0
- package/src/app/components/misc/CheckerboardPattern.vue +32 -0
- package/src/app/components/misc/HatchedPattern.vue +13 -0
- package/src/app/components/panel/ControlsComponentPropItem.vue +73 -0
- package/src/app/components/panel/ControlsComponentProps.vue +34 -0
- package/src/app/components/panel/ControlsComponentState.vue +38 -0
- package/src/app/components/panel/ControlsComponentStateItem.vue +44 -0
- package/src/app/components/panel/PaneTabs.vue +84 -0
- package/src/app/components/panel/StatePresets.vue +199 -0
- package/src/app/components/panel/StoryControls.vue +97 -0
- package/src/app/components/panel/StoryDocs.vue +202 -0
- package/src/app/components/panel/StoryEvent.vue +54 -0
- package/src/app/components/panel/StoryEvents.vue +48 -0
- package/src/app/components/panel/StorySidePanel.vue +76 -0
- package/src/app/components/panel/StorySourceCode.vue +248 -0
- package/src/app/components/search/SearchItem.vue +89 -0
- package/src/app/components/search/SearchItemContent.vue +67 -0
- package/src/app/components/search/SearchLoading.vue +16 -0
- package/src/app/components/search/SearchModal.vue +44 -0
- package/src/app/components/search/SearchPane.vue +319 -0
- package/src/app/components/search/search-docs-data.ts +9 -0
- package/src/app/components/search/search-title-data.ts +9 -0
- package/src/app/components/search/types.ts +4 -0
- package/src/app/components/story/GenericMountStory.vue +35 -0
- package/src/app/components/story/GenericRenderStory.vue +41 -0
- package/src/app/components/story/StoryResponsivePreview.vue +216 -0
- package/src/app/components/story/StoryVariantGrid.vue +169 -0
- package/src/app/components/story/StoryVariantGridItem.vue +163 -0
- package/src/app/components/story/StoryVariantListItem.vue +52 -0
- package/src/app/components/story/StoryVariantSingle.vue +105 -0
- package/src/app/components/story/StoryVariantSinglePreviewNative.vue +66 -0
- package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +143 -0
- package/src/app/components/story/StoryVariantSingleView.vue +61 -0
- package/src/app/components/story/StoryView.vue +110 -0
- package/src/app/components/story/StoryViewer.vue +52 -0
- package/src/app/components/toolbar/DevOnlyToolbarOpenInEditor.vue +23 -0
- package/src/app/components/toolbar/ToolbarBackground.vue +81 -0
- package/src/app/components/toolbar/ToolbarNewTab.vue +29 -0
- package/src/app/components/toolbar/ToolbarResponsiveSize.vue +82 -0
- package/src/app/components/toolbar/ToolbarTextDirection.vue +19 -0
- package/src/app/components/toolbar/ToolbarTitle.vue +21 -0
- package/src/app/components/tree/StoryGroup.vue +73 -0
- package/src/app/components/tree/StoryList.vue +35 -0
- package/src/app/components/tree/StoryListFolder.vue +88 -0
- package/src/app/components/tree/StoryListItem.vue +72 -0
- package/src/app/index.ts +33 -0
- package/src/app/plugin.ts +59 -0
- package/src/app/router.ts +29 -0
- package/src/app/sandbox.ts +101 -0
- package/src/app/stores/command.ts +26 -0
- package/src/app/stores/events.ts +36 -0
- package/src/app/stores/folder.ts +63 -0
- package/src/app/stores/preview-settings.ts +18 -0
- package/src/app/stores/story.ts +47 -0
- package/src/app/style/floating.pcss +34 -0
- package/src/app/style/main.pcss +100 -0
- package/src/app/style/sandbox.css +24 -0
- package/src/app/style/transitions.pcss +51 -0
- package/src/app/types.ts +72 -0
- package/src/app/util/commands.ts +57 -0
- package/src/app/util/config.ts +5 -0
- package/src/app/util/const.ts +4 -0
- package/src/app/util/dark.ts +27 -0
- package/src/app/util/docs.ts +27 -0
- package/src/app/util/env.ts +1 -0
- package/src/app/util/events.ts +31 -0
- package/src/app/util/keyboard.ts +103 -0
- package/src/app/util/mapping.ts +80 -0
- package/src/app/util/open-in-editor.ts +3 -0
- package/src/app/util/preview-settings.ts +23 -0
- package/src/app/util/responsive.ts +3 -0
- package/src/app/util/sandbox.ts +9 -0
- package/src/app/util/scroll.ts +32 -0
- package/src/app/util/select.ts +30 -0
- package/src/app/util/state.ts +45 -0
- package/src/app/util/tooltip.ts +13 -0
- package/src/app/util/variant.ts +21 -0
- package/src/bundle-index.js +1 -0
- package/src/bundle-main-dev.js +4 -0
- package/src/bundle-main.js +5 -0
- package/src/bundle-sandbox-dev.js +2 -0
- package/src/bundle-sandbox.js +2 -0
- package/src/index.ts +1 -0
- package/src/shim.d.ts +10 -0
- package/src/virtual.d.ts +7 -0
- package/tailwind.config.cjs +137 -0
- package/tsconfig.json +53 -0
- package/vite.config.ts +88 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { SelectPrompt, SelectPromptOption } from '@histoire/shared'
|
|
3
|
+
import { Icon } from '@iconify/vue'
|
|
4
|
+
import { computed, ref, watchEffect } from 'vue'
|
|
5
|
+
import { useSelection } from '../../util/select.js'
|
|
6
|
+
import BaseKeyboardShortcut from '../base/BaseKeyboardShortcut.vue'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
modelValue?: string
|
|
10
|
+
prompt: SelectPrompt
|
|
11
|
+
answers: Record<string, any>
|
|
12
|
+
}>()
|
|
13
|
+
|
|
14
|
+
const emit = defineEmits<{
|
|
15
|
+
(e: 'update:modelValue', value: string): void
|
|
16
|
+
(e: 'next'): void
|
|
17
|
+
}>()
|
|
18
|
+
|
|
19
|
+
const model = computed({
|
|
20
|
+
get: () => props.modelValue,
|
|
21
|
+
set: (value) => {
|
|
22
|
+
emit('update:modelValue', value)
|
|
23
|
+
emit('next')
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const input = ref<HTMLInputElement>()
|
|
28
|
+
|
|
29
|
+
function focus() {
|
|
30
|
+
input.value?.focus()
|
|
31
|
+
input.value?.select()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
defineExpose({
|
|
35
|
+
focus,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const search = ref('')
|
|
39
|
+
|
|
40
|
+
const options = ref<SelectPromptOption[]>([])
|
|
41
|
+
|
|
42
|
+
let requestId = 0
|
|
43
|
+
watchEffect(async () => {
|
|
44
|
+
if (typeof props.prompt.options === 'function') {
|
|
45
|
+
const rId = ++requestId
|
|
46
|
+
const result = await props.prompt.options(search.value, props.answers)
|
|
47
|
+
if (rId === requestId) {
|
|
48
|
+
options.value = result
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
options.value = props.prompt.options
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const formattedOptions = computed(() => {
|
|
57
|
+
return options.value.map((option) => {
|
|
58
|
+
if (typeof option === 'string') {
|
|
59
|
+
return {
|
|
60
|
+
value: option,
|
|
61
|
+
label: option,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return option
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
// Keyboard navigation
|
|
71
|
+
|
|
72
|
+
const {
|
|
73
|
+
selectedIndex,
|
|
74
|
+
selectNext,
|
|
75
|
+
selectPrevious,
|
|
76
|
+
} = useSelection(formattedOptions)
|
|
77
|
+
|
|
78
|
+
function selectIndex(index: number) {
|
|
79
|
+
const result = formattedOptions.value[index].value
|
|
80
|
+
if (result) {
|
|
81
|
+
model.value = result
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<template>
|
|
87
|
+
<div class="histoire-prompt-select htw-relative htw-group">
|
|
88
|
+
<input
|
|
89
|
+
v-model="model"
|
|
90
|
+
:required="prompt.required"
|
|
91
|
+
tabindex="-1"
|
|
92
|
+
class="htw-absolute htw-inset-0 htw-opacity-0 htw-pointer-events-none"
|
|
93
|
+
>
|
|
94
|
+
<label class="htw-flex htw-flex-col htw-gap-2 htw-p-2">
|
|
95
|
+
<span class="htw-px-2 htw-flex">
|
|
96
|
+
<span>{{ prompt.label }}</span>
|
|
97
|
+
<span
|
|
98
|
+
v-if="prompt.required"
|
|
99
|
+
class="htw-opacity-70"
|
|
100
|
+
>*</span>
|
|
101
|
+
|
|
102
|
+
<span class="htw-opacity-40 htw-text-sm htw-ml-auto htw-invisible group-focus-within:htw-visible">
|
|
103
|
+
Press <BaseKeyboardShortcut shortcut="Space" /> to select
|
|
104
|
+
</span>
|
|
105
|
+
</span>
|
|
106
|
+
<input
|
|
107
|
+
ref="input"
|
|
108
|
+
v-model="search"
|
|
109
|
+
class="htw-bg-transparent htw-w-full htw-p-2 htw-border htw-border-gray-500/50 focus:htw-border-primary-500/50 htw-rounded htw-outline-none"
|
|
110
|
+
@keydown.down.prevent="selectNext()"
|
|
111
|
+
@keydown.up.prevent="selectPrevious()"
|
|
112
|
+
@keydown.space.prevent="selectIndex(selectedIndex)"
|
|
113
|
+
>
|
|
114
|
+
</label>
|
|
115
|
+
|
|
116
|
+
<div class="htw-overflow-auto max-h-[300px] htw-mb-2">
|
|
117
|
+
<button
|
|
118
|
+
v-for="(option, index) of formattedOptions"
|
|
119
|
+
:key="option.value"
|
|
120
|
+
type="button"
|
|
121
|
+
tabindex="-1"
|
|
122
|
+
:class="[
|
|
123
|
+
model === option.value
|
|
124
|
+
? 'htw-bg-primary-500/20'
|
|
125
|
+
: index === selectedIndex
|
|
126
|
+
? 'htw-bg-primary-500/10'
|
|
127
|
+
: 'htw-bg-transparent',
|
|
128
|
+
]"
|
|
129
|
+
class="htw-w-full htw-text-left htw-px-4 htw-py-2 hover:htw-bg-primary-500/10 htw-flex htw-items-center"
|
|
130
|
+
@click="model = option.value"
|
|
131
|
+
>
|
|
132
|
+
<span class="htw-flex-1">{{ option.label }}</span>
|
|
133
|
+
|
|
134
|
+
<Icon
|
|
135
|
+
v-if="model === option.value"
|
|
136
|
+
icon="carbon:checkmark"
|
|
137
|
+
class="htw-w-4 htw-h-4 htw-text-primary-500"
|
|
138
|
+
/>
|
|
139
|
+
</button>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</template>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { TextPrompt } from '@histoire/shared'
|
|
3
|
+
import { computed, ref, watch } from 'vue'
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
modelValue?: string
|
|
7
|
+
prompt: TextPrompt
|
|
8
|
+
answers: Record<string, any>
|
|
9
|
+
}>()
|
|
10
|
+
|
|
11
|
+
const emit = defineEmits<{
|
|
12
|
+
(e: 'update:modelValue', value: string): void
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const model = computed({
|
|
16
|
+
get: () => props.modelValue,
|
|
17
|
+
set: value => emit('update:modelValue', value),
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const input = ref<HTMLInputElement>()
|
|
21
|
+
|
|
22
|
+
function focus() {
|
|
23
|
+
input.value?.focus()
|
|
24
|
+
input.value?.select()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
defineExpose({
|
|
28
|
+
focus,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// Default value
|
|
32
|
+
|
|
33
|
+
const defaultValue = computed(() => {
|
|
34
|
+
if (typeof props.prompt.defaultValue === 'function') {
|
|
35
|
+
return props.prompt.defaultValue(props.answers)
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return props.prompt.defaultValue
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
watch(defaultValue, (value) => {
|
|
43
|
+
model.value = value
|
|
44
|
+
})
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<div class="histoire-prompt-text">
|
|
49
|
+
<label class="htw-flex htw-flex-col htw-gap-2 htw-p-2">
|
|
50
|
+
<span class="htw-px-2">
|
|
51
|
+
<span>{{ prompt.label }}</span>
|
|
52
|
+
<span
|
|
53
|
+
v-if="prompt.required"
|
|
54
|
+
class="htw-opacity-70"
|
|
55
|
+
>*</span>
|
|
56
|
+
</span>
|
|
57
|
+
<input
|
|
58
|
+
ref="input"
|
|
59
|
+
v-model="model"
|
|
60
|
+
class="htw-bg-transparent htw-w-full htw-p-2 htw-border htw-border-gray-500/50 focus:htw-border-primary-500/50 htw-rounded htw-outline-none"
|
|
61
|
+
:required="prompt.required"
|
|
62
|
+
>
|
|
63
|
+
</label>
|
|
64
|
+
</div>
|
|
65
|
+
</template>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg fill="none">
|
|
3
|
+
<pattern
|
|
4
|
+
id="checkerboard"
|
|
5
|
+
width="64"
|
|
6
|
+
height="64"
|
|
7
|
+
patternUnits="userSpaceOnUse"
|
|
8
|
+
>
|
|
9
|
+
<rect
|
|
10
|
+
x="0"
|
|
11
|
+
y="0"
|
|
12
|
+
width="32"
|
|
13
|
+
height="32"
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
/>
|
|
16
|
+
<rect
|
|
17
|
+
x="32"
|
|
18
|
+
y="32"
|
|
19
|
+
width="32"
|
|
20
|
+
height="32"
|
|
21
|
+
fill="currentColor"
|
|
22
|
+
/>
|
|
23
|
+
</pattern>
|
|
24
|
+
<rect
|
|
25
|
+
x="0"
|
|
26
|
+
y="0"
|
|
27
|
+
width="100%"
|
|
28
|
+
height="100%"
|
|
29
|
+
fill="url(#checkerboard)"
|
|
30
|
+
/>
|
|
31
|
+
</svg>
|
|
32
|
+
</template>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="__histoire-hatched-pattern" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<style scoped>
|
|
6
|
+
.__histoire-hatched-pattern {
|
|
7
|
+
background: repeating-linear-gradient(135deg,
|
|
8
|
+
transparent 0px,
|
|
9
|
+
transparent 32px,
|
|
10
|
+
currentColor 32px,
|
|
11
|
+
currentColor 64px);
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { AutoPropComponentDefinition, PropDefinition } from '@histoire/shared'
|
|
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
|
+
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
variant: Variant
|
|
10
|
+
component: AutoPropComponentDefinition
|
|
11
|
+
definition: PropDefinition
|
|
12
|
+
}>()
|
|
13
|
+
|
|
14
|
+
const comp = computed(() => {
|
|
15
|
+
switch (props.definition.types?.[0]) {
|
|
16
|
+
case 'string':
|
|
17
|
+
return HstText
|
|
18
|
+
case 'number':
|
|
19
|
+
return HstNumber
|
|
20
|
+
case 'boolean':
|
|
21
|
+
return HstCheckbox
|
|
22
|
+
case 'object':
|
|
23
|
+
default:
|
|
24
|
+
return HstJson
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const model = computed({
|
|
29
|
+
get: () => {
|
|
30
|
+
return props.variant.state._hPropState[props.component.index]?.[props.definition.name]
|
|
31
|
+
},
|
|
32
|
+
set: (value) => {
|
|
33
|
+
if (!props.variant.state._hPropState[props.component.index]) {
|
|
34
|
+
// eslint-disable-next-line vue/no-mutating-props
|
|
35
|
+
props.variant.state._hPropState[props.component.index] = {}
|
|
36
|
+
}
|
|
37
|
+
// eslint-disable-next-line vue/no-mutating-props
|
|
38
|
+
props.variant.state._hPropState[props.component.index][props.definition.name] = value
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
function reset() {
|
|
43
|
+
if (props.variant.state._hPropState[props.component.index]) {
|
|
44
|
+
// eslint-disable-next-line vue/no-mutating-props
|
|
45
|
+
delete props.variant.state._hPropState[props.component.index][props.definition.name]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const canReset = computed(() => props.variant.state?._hPropState?.[props.component.index] && props.definition.name in props.variant.state._hPropState[props.component.index])
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<template>
|
|
53
|
+
<component
|
|
54
|
+
:is="comp"
|
|
55
|
+
v-if="comp"
|
|
56
|
+
v-model="model"
|
|
57
|
+
:placeholder="model === undefined ? definition?.default : null"
|
|
58
|
+
class="histoire-controls-component-prop-item"
|
|
59
|
+
:title="`${definition.name}${canReset ? ' *' : ''}`"
|
|
60
|
+
>
|
|
61
|
+
<template #actions>
|
|
62
|
+
<Icon
|
|
63
|
+
v-tooltip="'Remove override'"
|
|
64
|
+
icon="carbon:erase"
|
|
65
|
+
class="htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100"
|
|
66
|
+
:class="[
|
|
67
|
+
canReset ? 'htw-opacity-50 hover:htw-opacity-100' : 'htw-opacity-25 htw-pointer-events-none',
|
|
68
|
+
]"
|
|
69
|
+
@click.stop="reset()"
|
|
70
|
+
/>
|
|
71
|
+
</template>
|
|
72
|
+
</component>
|
|
73
|
+
</template>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { AutoPropComponentDefinition } from '@histoire/shared'
|
|
3
|
+
import type { Variant } from '../../types'
|
|
4
|
+
import { Icon } from '@iconify/vue'
|
|
5
|
+
import ControlsComponentPropItem from './ControlsComponentPropItem.vue'
|
|
6
|
+
|
|
7
|
+
defineProps<{
|
|
8
|
+
variant: Variant
|
|
9
|
+
definition: AutoPropComponentDefinition
|
|
10
|
+
}>()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<div class="histoire-controls-component-props">
|
|
15
|
+
<div class="htw-font-mono htw-p-2 htw-flex htw-items-center htw-gap-1">
|
|
16
|
+
<Icon
|
|
17
|
+
v-tooltip="'Auto-detected props'"
|
|
18
|
+
icon="carbon:flash"
|
|
19
|
+
class="htw-w-4 htw-h-4 htw-text-primary-500 htw-flex-none"
|
|
20
|
+
/>
|
|
21
|
+
<div>
|
|
22
|
+
<span class="htw-opacity-30"><</span>{{ definition.name }}<span class="htw-opacity-30">></span>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<ControlsComponentPropItem
|
|
27
|
+
v-for="prop of definition.props"
|
|
28
|
+
:key="prop.name"
|
|
29
|
+
:variant="variant"
|
|
30
|
+
:component="definition"
|
|
31
|
+
:definition="prop"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Variant } from '@histoire/shared'
|
|
3
|
+
import { Icon } from '@iconify/vue'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import ControlsComponentStateItem from './ControlsComponentStateItem.vue'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
variant: Variant
|
|
9
|
+
}>()
|
|
10
|
+
|
|
11
|
+
const stateKeys = computed(() => Object.keys(props.variant.state || {})
|
|
12
|
+
.filter(key => !key.startsWith('_h')))
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<div class="histoire-controls-component-init-state">
|
|
17
|
+
<div class="htw-p-2 htw-flex htw-items-center htw-gap-1">
|
|
18
|
+
<Icon
|
|
19
|
+
v-tooltip="'Auto-detected state'"
|
|
20
|
+
icon="carbon:data-vis-1"
|
|
21
|
+
class="htw-w-4 htw-h-4 htw-text-primary-500 htw-flex-none"
|
|
22
|
+
/>
|
|
23
|
+
<div>
|
|
24
|
+
State
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
<ControlsComponentStateItem
|
|
28
|
+
v-for="key of stateKeys"
|
|
29
|
+
:key="key"
|
|
30
|
+
:item="key"
|
|
31
|
+
:variant="variant"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<style scoped>
|
|
37
|
+
|
|
38
|
+
</style>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { Variant } from '../../types'
|
|
3
|
+
import { HstCheckbox, HstJson, HstNumber, HstText } from '@histoire/controls'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
variant: Variant
|
|
8
|
+
item: string
|
|
9
|
+
}>()
|
|
10
|
+
|
|
11
|
+
const comp = computed(() => {
|
|
12
|
+
switch (typeof props.variant.state[props.item]) {
|
|
13
|
+
case 'string':
|
|
14
|
+
return HstText
|
|
15
|
+
case 'number':
|
|
16
|
+
return HstNumber
|
|
17
|
+
case 'boolean':
|
|
18
|
+
return HstCheckbox
|
|
19
|
+
case 'object':
|
|
20
|
+
default:
|
|
21
|
+
return HstJson
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const model = computed({
|
|
26
|
+
get: () => {
|
|
27
|
+
return props.variant.state[props.item]
|
|
28
|
+
},
|
|
29
|
+
set: (value) => {
|
|
30
|
+
// eslint-disable-next-line vue/no-mutating-props
|
|
31
|
+
props.variant.state[props.item] = value
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<component
|
|
38
|
+
:is="comp"
|
|
39
|
+
v-if="comp"
|
|
40
|
+
v-model="model"
|
|
41
|
+
class="histoire-controls-component-prop-item"
|
|
42
|
+
:title="props.item"
|
|
43
|
+
/>
|
|
44
|
+
</template>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { Story, Variant } from '../../types'
|
|
3
|
+
import { computed, toRefs } from 'vue'
|
|
4
|
+
import { useEventsStore } from '../../stores/events'
|
|
5
|
+
import BaseOverflowMenu from '../base/BaseOverflowMenu.vue'
|
|
6
|
+
import BaseOverflowTab from '../base/BaseOverflowTab.vue'
|
|
7
|
+
import BaseTab from '../base/BaseTab.vue'
|
|
8
|
+
import BaseTag from '../base/BaseTag.vue'
|
|
9
|
+
import { useStoryDoc } from './StoryDocs.vue'
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
story: Story
|
|
13
|
+
variant: Variant
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const { story } = toRefs(props)
|
|
17
|
+
|
|
18
|
+
const { renderedDoc } = useStoryDoc(story)
|
|
19
|
+
|
|
20
|
+
const eventsStore = useEventsStore()
|
|
21
|
+
const hasEvents = computed(() => eventsStore.events.length)
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<BaseOverflowMenu class="histoire-pane-tabs htw-h-10 htw-flex-none htw-border-b htw-border-gray-100 dark:htw-border-gray-750">
|
|
26
|
+
<BaseTab
|
|
27
|
+
:to="{ ...$route, query: { ...$route.query, tab: '' } }"
|
|
28
|
+
:matched="!$route.query.tab"
|
|
29
|
+
>
|
|
30
|
+
Controls
|
|
31
|
+
</BaseTab>
|
|
32
|
+
<BaseTab
|
|
33
|
+
:to="{ ...$route, query: { ...$route.query, tab: 'docs' } }"
|
|
34
|
+
:matched="$route.query.tab === 'docs'"
|
|
35
|
+
:class="{
|
|
36
|
+
'htw-opacity-50': !renderedDoc,
|
|
37
|
+
}"
|
|
38
|
+
>
|
|
39
|
+
Docs
|
|
40
|
+
</BaseTab>
|
|
41
|
+
<BaseTab
|
|
42
|
+
:to="{ ...$route, query: { ...$route.query, tab: 'events' } }"
|
|
43
|
+
:matched="$route.query.tab === 'events'"
|
|
44
|
+
:class="{
|
|
45
|
+
'htw-opacity-50': !hasEvents,
|
|
46
|
+
}"
|
|
47
|
+
>
|
|
48
|
+
Events
|
|
49
|
+
<BaseTag v-if="eventsStore.unseen">
|
|
50
|
+
{{ eventsStore.unseen <= 99 ? eventsStore.unseen : "99+" }}
|
|
51
|
+
</BaseTag>
|
|
52
|
+
</BaseTab>
|
|
53
|
+
|
|
54
|
+
<template #overflow>
|
|
55
|
+
<BaseOverflowTab
|
|
56
|
+
:to="{ ...$route, query: { ...$route.query, tab: '' } }"
|
|
57
|
+
:matched="!$route.query.tab"
|
|
58
|
+
>
|
|
59
|
+
Controls
|
|
60
|
+
</BaseOverflowTab>
|
|
61
|
+
<BaseOverflowTab
|
|
62
|
+
:to="{ ...$route, query: { ...$route.query, tab: 'docs' } }"
|
|
63
|
+
:matched="$route.query.tab === 'docs'"
|
|
64
|
+
:class="{
|
|
65
|
+
'opacity-50': !renderedDoc,
|
|
66
|
+
}"
|
|
67
|
+
>
|
|
68
|
+
Docs
|
|
69
|
+
</BaseOverflowTab>
|
|
70
|
+
<BaseOverflowTab
|
|
71
|
+
:to="{ ...$route, query: { ...$route.query, tab: 'events' } }"
|
|
72
|
+
:matched="$route.query.tab === 'events'"
|
|
73
|
+
:class="{
|
|
74
|
+
'htw-opacity-50': !hasEvents,
|
|
75
|
+
}"
|
|
76
|
+
>
|
|
77
|
+
Events
|
|
78
|
+
<BaseTag v-if="eventsStore.unseen">
|
|
79
|
+
{{ eventsStore.unseen <= 99 ? eventsStore.unseen : "99+" }}
|
|
80
|
+
</BaseTag>
|
|
81
|
+
</BaseOverflowTab>
|
|
82
|
+
</template>
|
|
83
|
+
</BaseOverflowMenu>
|
|
84
|
+
</template>
|