@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,87 @@
|
|
|
1
|
+
import { applyState } from "@histoire/shared";
|
|
2
|
+
import { createPinia } from "@histoire/vendors/pinia";
|
|
3
|
+
import { files } from "./_virtual/histoire-stories.js";
|
|
4
|
+
import { ref, createApp, h, computed, watch, onMounted } from "@histoire/vendors/vue";
|
|
5
|
+
import { parseQuery } from "@histoire/vendors/vue-router";
|
|
6
|
+
import "./components/story/GenericMountStory.vue.js";
|
|
7
|
+
import "./components/story/GenericRenderStory.vue.js";
|
|
8
|
+
import { setupPluginApi } from "./plugin.js";
|
|
9
|
+
import { histoireConfig } from "./util/config.js";
|
|
10
|
+
import { SANDBOX_READY, STATE_SYNC, PREVIEW_SETTINGS_SYNC } from "./util/const.js";
|
|
11
|
+
import { isDark } from "./util/dark.js";
|
|
12
|
+
import { mapFile } from "./util/mapping.js";
|
|
13
|
+
import { applyPreviewSettings } from "./util/preview-settings.js";
|
|
14
|
+
import { toRawDeep } from "./util/state.js";
|
|
15
|
+
import _sfc_main from "./components/story/GenericMountStory.vue2.js";
|
|
16
|
+
import _sfc_main$1 from "./components/story/GenericRenderStory.vue2.js";
|
|
17
|
+
"use strict";
|
|
18
|
+
const query = parseQuery(window.location.search);
|
|
19
|
+
const file = ref(mapFile(files.find((f) => f.id === query.storyId)));
|
|
20
|
+
const app = createApp({
|
|
21
|
+
name: "SandboxApp",
|
|
22
|
+
setup() {
|
|
23
|
+
const story = computed(() => file.value.story);
|
|
24
|
+
const variant = computed(() => story.value?.variants.find((v) => v.id === query.variantId));
|
|
25
|
+
let synced = false;
|
|
26
|
+
let mounted = false;
|
|
27
|
+
window.addEventListener("message", (event) => {
|
|
28
|
+
if (event.data?.type === STATE_SYNC) {
|
|
29
|
+
if (!mounted) return;
|
|
30
|
+
synced = true;
|
|
31
|
+
applyState(variant.value.state, event.data.state);
|
|
32
|
+
} else if (event.data?.type === PREVIEW_SETTINGS_SYNC) {
|
|
33
|
+
applyPreviewSettings(event.data.settings);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
watch(() => variant.value.state, (value) => {
|
|
37
|
+
if (synced && mounted) {
|
|
38
|
+
synced = false;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
window.parent?.postMessage({
|
|
42
|
+
type: STATE_SYNC,
|
|
43
|
+
state: toRawDeep(value, true)
|
|
44
|
+
});
|
|
45
|
+
}, {
|
|
46
|
+
deep: true
|
|
47
|
+
});
|
|
48
|
+
onMounted(() => {
|
|
49
|
+
mounted = true;
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
story,
|
|
53
|
+
variant
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
render() {
|
|
57
|
+
return [
|
|
58
|
+
h("div", { class: "htw-sandbox-hidden" }, [
|
|
59
|
+
h(_sfc_main, {
|
|
60
|
+
key: file.value.story.id,
|
|
61
|
+
story: file.value.story
|
|
62
|
+
})
|
|
63
|
+
]),
|
|
64
|
+
this.story && this.variant ? h(_sfc_main$1, { story: this.story, variant: this.variant, onReady: () => {
|
|
65
|
+
window.parent?.postMessage({
|
|
66
|
+
type: SANDBOX_READY
|
|
67
|
+
});
|
|
68
|
+
} }) : null
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
app.use(createPinia());
|
|
73
|
+
app.mount("#app");
|
|
74
|
+
watch(isDark, (value) => {
|
|
75
|
+
if (value) {
|
|
76
|
+
document.documentElement.classList.add(histoireConfig.sandboxDarkClass);
|
|
77
|
+
document.documentElement.classList.add(histoireConfig.theme.darkClass);
|
|
78
|
+
} else {
|
|
79
|
+
document.documentElement.classList.remove(histoireConfig.sandboxDarkClass);
|
|
80
|
+
document.documentElement.classList.remove(histoireConfig.theme.darkClass);
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
immediate: true
|
|
84
|
+
});
|
|
85
|
+
if (import.meta.hot) {
|
|
86
|
+
/* @__PURE__ */ setupPluginApi();
|
|
87
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineStore } from "@histoire/vendors/pinia";
|
|
2
|
+
import { ref } from "@histoire/vendors/vue";
|
|
3
|
+
import { getCommandContext, executeCommand } from "../util/commands.js";
|
|
4
|
+
"use strict";
|
|
5
|
+
const useCommandStore = defineStore("command", () => {
|
|
6
|
+
const selectedCommand = ref(null);
|
|
7
|
+
const showPromptsModal = ref(false);
|
|
8
|
+
function activateCommand(command) {
|
|
9
|
+
selectedCommand.value = command;
|
|
10
|
+
if (command.prompts?.length) {
|
|
11
|
+
showPromptsModal.value = true;
|
|
12
|
+
} else {
|
|
13
|
+
const params = command.getParams?.(getCommandContext()) ?? {};
|
|
14
|
+
executeCommand(command, params);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
selectedCommand,
|
|
19
|
+
showPromptsModal,
|
|
20
|
+
activateCommand
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
export {
|
|
24
|
+
useCommandStore
|
|
25
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineStore } from "@histoire/vendors/pinia";
|
|
2
|
+
import { reactive, ref, watch } from "@histoire/vendors/vue";
|
|
3
|
+
import { useStoryStore } from "./story.js";
|
|
4
|
+
"use strict";
|
|
5
|
+
const useEventsStore = defineStore("events", () => {
|
|
6
|
+
const storyStore = useStoryStore();
|
|
7
|
+
const events = reactive([]);
|
|
8
|
+
const unseen = ref(0);
|
|
9
|
+
function addEvent(event) {
|
|
10
|
+
events.push(event);
|
|
11
|
+
unseen.value++;
|
|
12
|
+
}
|
|
13
|
+
function reset() {
|
|
14
|
+
events.length = 0;
|
|
15
|
+
unseen.value = 0;
|
|
16
|
+
}
|
|
17
|
+
watch(() => storyStore.currentVariant?.id, () => {
|
|
18
|
+
reset();
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
addEvent,
|
|
22
|
+
reset,
|
|
23
|
+
events,
|
|
24
|
+
unseen
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
export {
|
|
28
|
+
useEventsStore
|
|
29
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useStorage } from "@histoire/vendors/vue-use";
|
|
2
|
+
import { defineStore } from "@histoire/vendors/pinia";
|
|
3
|
+
import { watch } from "@histoire/vendors/vue";
|
|
4
|
+
import { useStoryStore } from "./story.js";
|
|
5
|
+
"use strict";
|
|
6
|
+
const useFolderStore = defineStore("folder", () => {
|
|
7
|
+
const openedFolders = useStorage(
|
|
8
|
+
"_histoire-tree-state",
|
|
9
|
+
/* @__PURE__ */ new Map()
|
|
10
|
+
);
|
|
11
|
+
function getStringPath(path) {
|
|
12
|
+
return path.join("␜");
|
|
13
|
+
}
|
|
14
|
+
function toggleFolder(path, defaultToggleValue = true) {
|
|
15
|
+
const stringPath = getStringPath(path);
|
|
16
|
+
const currentValue = openedFolders.value.get(stringPath);
|
|
17
|
+
if (currentValue == null) {
|
|
18
|
+
setFolderOpen(stringPath, defaultToggleValue);
|
|
19
|
+
} else if (currentValue) {
|
|
20
|
+
setFolderOpen(stringPath, false);
|
|
21
|
+
} else {
|
|
22
|
+
setFolderOpen(stringPath, true);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function setFolderOpen(path, value) {
|
|
26
|
+
const stringPath = typeof path === "string" ? path : getStringPath(path);
|
|
27
|
+
openedFolders.value.set(stringPath, value);
|
|
28
|
+
}
|
|
29
|
+
function isFolderOpened(path, defaultValue = false) {
|
|
30
|
+
const value = openedFolders.value.get(getStringPath(path));
|
|
31
|
+
if (value == null) {
|
|
32
|
+
return defaultValue;
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
function openFileFolders(path) {
|
|
37
|
+
for (let pathLength = 1; pathLength < path.length; pathLength++) {
|
|
38
|
+
setFolderOpen(path.slice(0, pathLength), true);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const storyStore = useStoryStore();
|
|
42
|
+
watch(() => storyStore.currentStory, (story) => {
|
|
43
|
+
if (story) {
|
|
44
|
+
openFileFolders(story.file.path);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
isFolderOpened,
|
|
49
|
+
toggleFolder
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
export {
|
|
53
|
+
useFolderStore
|
|
54
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useStorage } from "@histoire/vendors/vue-use";
|
|
2
|
+
import { defineStore } from "@histoire/vendors/pinia";
|
|
3
|
+
"use strict";
|
|
4
|
+
const usePreviewSettingsStore = defineStore("preview-settings", () => {
|
|
5
|
+
const currentSettings = useStorage("_histoire-sandbox-settings-v3", {
|
|
6
|
+
responsiveWidth: 720,
|
|
7
|
+
responsiveHeight: null,
|
|
8
|
+
rotate: false,
|
|
9
|
+
backgroundColor: "transparent",
|
|
10
|
+
checkerboard: false,
|
|
11
|
+
textDirection: "ltr"
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
currentSettings
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
usePreviewSettingsStore
|
|
19
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineStore } from "@histoire/vendors/pinia";
|
|
2
|
+
import { ref, computed } from "@histoire/vendors/vue";
|
|
3
|
+
import { router } from "../router.js";
|
|
4
|
+
"use strict";
|
|
5
|
+
const useStoryStore = defineStore("story", () => {
|
|
6
|
+
const stories = ref([]);
|
|
7
|
+
function setStories(value) {
|
|
8
|
+
stories.value = value;
|
|
9
|
+
}
|
|
10
|
+
const currentStory = computed(() => stories.value.find((s) => s.id === router.currentRoute.value.params.storyId));
|
|
11
|
+
const currentVariant = computed(() => currentStory.value?.variants.find((v) => v.id === router.currentRoute.value.query.variantId));
|
|
12
|
+
const maps = computed(() => {
|
|
13
|
+
const storyMap = /* @__PURE__ */ new Map();
|
|
14
|
+
const variantMap = /* @__PURE__ */ new Map();
|
|
15
|
+
for (const story of stories.value) {
|
|
16
|
+
storyMap.set(story.id, story);
|
|
17
|
+
for (const variant of story.variants) {
|
|
18
|
+
variantMap.set(`${story.id}:${variant.id}`, variant);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
stories: storyMap,
|
|
23
|
+
variants: variantMap
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
function getStoryById(id) {
|
|
27
|
+
return maps.value.stories.get(id);
|
|
28
|
+
}
|
|
29
|
+
function getVariantById(idWithStoryId) {
|
|
30
|
+
return maps.value.variants.get(idWithStoryId);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
stories,
|
|
34
|
+
setStories,
|
|
35
|
+
currentStory,
|
|
36
|
+
currentVariant,
|
|
37
|
+
getStoryById,
|
|
38
|
+
getVariantById
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
export {
|
|
42
|
+
useStoryStore
|
|
43
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { router } from "../router.js";
|
|
2
|
+
import { useStoryStore } from "../stores/story.js";
|
|
3
|
+
import { openInEditor } from "./open-in-editor.js";
|
|
4
|
+
"use strict";
|
|
5
|
+
const builtinCommands = [
|
|
6
|
+
{
|
|
7
|
+
id: "builtin:open-in-editor",
|
|
8
|
+
label: "Open file in editor",
|
|
9
|
+
icon: "carbon:script-reference",
|
|
10
|
+
showIf: ({ route }) => route.name === "story" && !!useStoryStore().currentStory,
|
|
11
|
+
getParams: () => {
|
|
12
|
+
const story = useStoryStore().currentStory;
|
|
13
|
+
let file;
|
|
14
|
+
if (story.docsOnly) {
|
|
15
|
+
file = story.file?.docsFilePath ?? story.file?.filePath;
|
|
16
|
+
} else {
|
|
17
|
+
file = story.file?.filePath;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
file
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
clientAction: ({ file }) => {
|
|
24
|
+
openInEditor(file);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "builtin:histoire-docs",
|
|
29
|
+
label: "Open Histoire Documentation",
|
|
30
|
+
icon: "carbon:help",
|
|
31
|
+
clientAction: () => {
|
|
32
|
+
window.open("https://histoire.dev/guide/getting-started.html", "_blank");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
function executeCommand(command, params) {
|
|
37
|
+
if (import.meta.hot) {
|
|
38
|
+
import.meta.hot.send("histoire:dev-command", {
|
|
39
|
+
id: command.id,
|
|
40
|
+
params
|
|
41
|
+
});
|
|
42
|
+
command.clientAction?.(params, getCommandContext());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function getCommandContext() {
|
|
46
|
+
const storyStore = useStoryStore();
|
|
47
|
+
return {
|
|
48
|
+
route: router.currentRoute.value,
|
|
49
|
+
currentStory: storyStore.currentStory,
|
|
50
|
+
currentVariant: storyStore.currentVariant
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
builtinCommands,
|
|
55
|
+
executeCommand,
|
|
56
|
+
getCommandContext
|
|
57
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const STATE_SYNC = "__histoire:state-sync";
|
|
2
|
+
const SANDBOX_READY = "__histoire:sandbox-ready";
|
|
3
|
+
const EVENT_SEND = "__histoire:event";
|
|
4
|
+
const PREVIEW_SETTINGS_SYNC = "__histoire:preview-settings-sync";
|
|
5
|
+
export {
|
|
6
|
+
EVENT_SEND,
|
|
7
|
+
PREVIEW_SETTINGS_SYNC,
|
|
8
|
+
SANDBOX_READY,
|
|
9
|
+
STATE_SYNC
|
|
10
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useDark, useToggle } from "@histoire/vendors/vue-use";
|
|
2
|
+
import { watch } from "@histoire/vendors/vue";
|
|
3
|
+
import { histoireConfig } from "./config.js";
|
|
4
|
+
"use strict";
|
|
5
|
+
const isDark = useDark({
|
|
6
|
+
valueDark: "htw-dark",
|
|
7
|
+
initialValue: histoireConfig.theme.defaultColorScheme,
|
|
8
|
+
storageKey: "histoire-color-scheme",
|
|
9
|
+
storage: histoireConfig.theme.storeColorScheme ? localStorage : sessionStorage
|
|
10
|
+
});
|
|
11
|
+
const toggleDark = useToggle(isDark);
|
|
12
|
+
function applyDarkToControls() {
|
|
13
|
+
window.__hst_controls_dark?.forEach((ref) => {
|
|
14
|
+
ref.value = isDark.value;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
watch(isDark, () => {
|
|
18
|
+
applyDarkToControls();
|
|
19
|
+
}, {
|
|
20
|
+
immediate: true
|
|
21
|
+
});
|
|
22
|
+
window.__hst_controls_dark_ready = () => {
|
|
23
|
+
applyDarkToControls();
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
isDark,
|
|
27
|
+
toggleDark
|
|
28
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { unindent } from "@histoire/shared";
|
|
2
|
+
import { clientSupportPlugins } from "../_virtual/histoire-support-plugins-client.js";
|
|
3
|
+
"use strict";
|
|
4
|
+
async function getSourceCode(story, variant) {
|
|
5
|
+
if (variant.source) {
|
|
6
|
+
return variant.source;
|
|
7
|
+
} else if (variant.slots?.().source) {
|
|
8
|
+
const source = variant.slots?.().source()[0].children;
|
|
9
|
+
if (source) {
|
|
10
|
+
return unindent(source);
|
|
11
|
+
}
|
|
12
|
+
} else {
|
|
13
|
+
const clientPlugin = clientSupportPlugins[story.file?.supportPluginId];
|
|
14
|
+
if (clientPlugin) {
|
|
15
|
+
const pluginModule = await clientPlugin();
|
|
16
|
+
return pluginModule.generateSourceCode(variant);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const sourceLoader = story.file?.source;
|
|
20
|
+
if (sourceLoader) {
|
|
21
|
+
return (await sourceLoader()).default;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
getSourceCode
|
|
26
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EVENT_SEND } from "./const.js";
|
|
2
|
+
"use strict";
|
|
3
|
+
async function logEvent(name, argument) {
|
|
4
|
+
console.log("[histoire] Event fired", { name, argument });
|
|
5
|
+
const event = {
|
|
6
|
+
name,
|
|
7
|
+
argument: JSON.parse(stringifyEvent(argument))
|
|
8
|
+
// Needed for HTMLEvent that can't be cloned
|
|
9
|
+
};
|
|
10
|
+
if (location.href.includes("__sandbox")) {
|
|
11
|
+
window.parent?.postMessage({
|
|
12
|
+
type: EVENT_SEND,
|
|
13
|
+
event
|
|
14
|
+
});
|
|
15
|
+
} else {
|
|
16
|
+
const { useEventsStore } = await import("../stores/events.js");
|
|
17
|
+
useEventsStore().addEvent(event);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function stringifyEvent(e) {
|
|
21
|
+
const obj = {};
|
|
22
|
+
for (const k in e) {
|
|
23
|
+
obj[k] = e[k];
|
|
24
|
+
}
|
|
25
|
+
return JSON.stringify(obj, (k, v) => {
|
|
26
|
+
if (v instanceof Node) return "Node";
|
|
27
|
+
if (v instanceof Window) return "Window";
|
|
28
|
+
return v;
|
|
29
|
+
}, " ");
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
logEvent
|
|
33
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { useEventListener } from "@histoire/vendors/vue-use";
|
|
2
|
+
import { isRef } from "@histoire/vendors/vue";
|
|
3
|
+
import { isMac } from "./env.js";
|
|
4
|
+
"use strict";
|
|
5
|
+
function onKeyboardShortcut(shortcut, handler, options = {}) {
|
|
6
|
+
useEventListener(options.event ?? "keydown", (event) => {
|
|
7
|
+
if (isMatchingShortcut(isRef(shortcut) ? shortcut.value : shortcut)) {
|
|
8
|
+
handler(event);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const modifiers = {
|
|
13
|
+
ctrl: { key: "Control", pressed: false },
|
|
14
|
+
alt: { key: "Alt", pressed: false },
|
|
15
|
+
shift: { key: "Shift", pressed: false },
|
|
16
|
+
meta: { key: "Meta", pressed: false }
|
|
17
|
+
};
|
|
18
|
+
const pressedKeys = /* @__PURE__ */ new Set();
|
|
19
|
+
window.addEventListener("keydown", (event) => {
|
|
20
|
+
for (const i in modifiers) {
|
|
21
|
+
const mod = modifiers[i];
|
|
22
|
+
if (mod.key === event.key) {
|
|
23
|
+
mod.pressed = true;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
pressedKeys.add(event.key.toLocaleLowerCase());
|
|
28
|
+
});
|
|
29
|
+
window.addEventListener("keyup", (event) => {
|
|
30
|
+
requestAnimationFrame(() => {
|
|
31
|
+
pressedKeys.clear();
|
|
32
|
+
for (const i in modifiers) {
|
|
33
|
+
const mod = modifiers[i];
|
|
34
|
+
if (mod.key === event.key) {
|
|
35
|
+
mod.pressed = false;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
window.addEventListener("blur", () => {
|
|
42
|
+
pressedKeys.clear();
|
|
43
|
+
for (const i in modifiers) {
|
|
44
|
+
const mod = modifiers[i];
|
|
45
|
+
mod.pressed = false;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
function isMatchingShortcut(shortcut) {
|
|
49
|
+
for (const combination of shortcut) {
|
|
50
|
+
if (isMatchingCombination(combination.toLowerCase())) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
function isMatchingCombination(combination) {
|
|
57
|
+
const splitted = combination.split("+").map((key) => key.trim());
|
|
58
|
+
const targetKey = splitted.pop();
|
|
59
|
+
for (const mod in modifiers) {
|
|
60
|
+
const containsMod = splitted.includes(mod);
|
|
61
|
+
const isPressed = modifiers[mod].pressed;
|
|
62
|
+
if (containsMod !== isPressed) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return pressedKeys.has(targetKey);
|
|
67
|
+
}
|
|
68
|
+
function formatKey(key) {
|
|
69
|
+
key = key.toLowerCase();
|
|
70
|
+
if (key === "ctrl") {
|
|
71
|
+
return isMac ? "^" : "Ctrl";
|
|
72
|
+
}
|
|
73
|
+
if (key === "alt") {
|
|
74
|
+
return isMac ? "⎇" : "Alt";
|
|
75
|
+
}
|
|
76
|
+
if (key === "shift") {
|
|
77
|
+
return "⇧";
|
|
78
|
+
}
|
|
79
|
+
if (key === "meta") {
|
|
80
|
+
return "⌘";
|
|
81
|
+
}
|
|
82
|
+
if (key === "enter") {
|
|
83
|
+
return "⏎";
|
|
84
|
+
}
|
|
85
|
+
return key.charAt(0).toUpperCase() + key.substring(1).toLowerCase();
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
formatKey,
|
|
89
|
+
onKeyboardShortcut
|
|
90
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { markRaw, reactive } from "@histoire/vendors/vue";
|
|
2
|
+
"use strict";
|
|
3
|
+
const copiedFromExistingVariant = [
|
|
4
|
+
"state",
|
|
5
|
+
"slots",
|
|
6
|
+
"source",
|
|
7
|
+
"responsiveDisabled",
|
|
8
|
+
"autoPropsDisabled",
|
|
9
|
+
"setupApp",
|
|
10
|
+
"configReady",
|
|
11
|
+
"previewReady"
|
|
12
|
+
];
|
|
13
|
+
function mapFile(file, existingFile) {
|
|
14
|
+
let result;
|
|
15
|
+
if (existingFile) {
|
|
16
|
+
result = existingFile;
|
|
17
|
+
for (const key in file) {
|
|
18
|
+
if (key === "story") {
|
|
19
|
+
result.story = {
|
|
20
|
+
...result.story,
|
|
21
|
+
...file.story,
|
|
22
|
+
file: markRaw(result),
|
|
23
|
+
variants: file.story.variants.map((v) => mapVariant(v, existingFile.story.variants.find((item) => item.id === v.id)))
|
|
24
|
+
};
|
|
25
|
+
} else if (key !== "component") {
|
|
26
|
+
result[key] = file[key];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
result = {
|
|
31
|
+
...file,
|
|
32
|
+
component: markRaw(file.component),
|
|
33
|
+
story: {
|
|
34
|
+
...file.story,
|
|
35
|
+
title: file.story.title,
|
|
36
|
+
file: markRaw(file),
|
|
37
|
+
variants: file.story.variants.map((v) => mapVariant(v)),
|
|
38
|
+
slots: () => ({})
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
function mapVariant(variant, existingVariant) {
|
|
45
|
+
let result;
|
|
46
|
+
if (existingVariant) {
|
|
47
|
+
result = existingVariant;
|
|
48
|
+
for (const key in variant) {
|
|
49
|
+
if (!copiedFromExistingVariant.includes(key)) {
|
|
50
|
+
result[key] = variant[key];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
result = {
|
|
55
|
+
...variant,
|
|
56
|
+
state: reactive({
|
|
57
|
+
_hPropState: {},
|
|
58
|
+
_hPropDefs: {}
|
|
59
|
+
}),
|
|
60
|
+
setupApp: null,
|
|
61
|
+
slots: () => ({}),
|
|
62
|
+
previewReady: false
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
mapFile,
|
|
69
|
+
mapVariant
|
|
70
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const openInEditorBase = (typeof import.meta !== "undefined" && import.meta.env && import.meta.env.BASE_URL !== undefined) ? import.meta.env.BASE_URL : "/";
|
|
2
|
+
function openInEditor(file) {
|
|
3
|
+
return fetch(`${openInEditorBase}__open-in-editor?file=${encodeURIComponent(file)}`);
|
|
4
|
+
}
|
|
5
|
+
export {
|
|
6
|
+
openInEditor
|
|
7
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { reactive } from "@histoire/vendors/vue";
|
|
2
|
+
import { histoireConfig } from "./config.js";
|
|
3
|
+
"use strict";
|
|
4
|
+
const receivedSettings = reactive({});
|
|
5
|
+
function applyPreviewSettings(settings) {
|
|
6
|
+
Object.assign(receivedSettings, settings);
|
|
7
|
+
document.documentElement.setAttribute("dir", settings.textDirection);
|
|
8
|
+
const contrastColor = getContrastColor(settings);
|
|
9
|
+
document.documentElement.style.setProperty("--histoire-contrast-color", contrastColor);
|
|
10
|
+
if (histoireConfig.autoApplyContrastColor) {
|
|
11
|
+
document.documentElement.style.color = contrastColor;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function getContrastColor(setting) {
|
|
15
|
+
return histoireConfig.backgroundPresets.find((preset) => preset.color === setting.backgroundColor)?.contrastColor ?? "unset";
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
applyPreviewSettings,
|
|
19
|
+
getContrastColor,
|
|
20
|
+
receivedSettings
|
|
21
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { base } from "../router.js";
|
|
2
|
+
"use strict";
|
|
3
|
+
function getSandboxUrl(story, variant) {
|
|
4
|
+
const url = new URLSearchParams();
|
|
5
|
+
url.append("storyId", story.id);
|
|
6
|
+
url.append("variantId", variant.id);
|
|
7
|
+
return `${base}__sandbox.html?${url.toString()}`;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
getSandboxUrl
|
|
11
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import scrollIntoView from "@histoire/vendors/scroll";
|
|
2
|
+
import { watch, onMounted } from "@histoire/vendors/vue";
|
|
3
|
+
"use strict";
|
|
4
|
+
function useScrollOnActive(active, el) {
|
|
5
|
+
watch(active, (value) => {
|
|
6
|
+
if (value) {
|
|
7
|
+
autoScroll();
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
function autoScroll() {
|
|
11
|
+
if (el.value) {
|
|
12
|
+
scrollIntoView(el.value, {
|
|
13
|
+
scrollMode: "if-needed",
|
|
14
|
+
block: "center",
|
|
15
|
+
inline: "nearest",
|
|
16
|
+
behavior: "smooth"
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
onMounted(() => {
|
|
21
|
+
if (active.value) {
|
|
22
|
+
autoScroll();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
autoScroll
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
useScrollOnActive
|
|
31
|
+
};
|