histoire 0.7.7 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundled/App.js +166 -0
- package/dist/bundled/_virtual/plugin-vue_export-helper.js +8 -0
- package/dist/bundled/api.js +1 -32
- package/dist/bundled/assets/histoire-text-dark.js +2 -0
- package/dist/bundled/assets/histoire-text.js +2 -0
- package/dist/bundled/{HomeView.js → assets/histoire.js} +1 -23
- package/dist/bundled/components/HomeView.js +24 -0
- package/dist/bundled/components/app/AppHeader.js +67 -0
- package/dist/bundled/components/app/AppLogo.js +26 -0
- package/dist/bundled/components/app/Breadcrumb.js +95 -0
- package/dist/bundled/components/app/Breadcrumb.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/app/InitialLoading.js +48 -0
- package/dist/bundled/components/app/MobileOverlay.js +41 -0
- package/dist/bundled/components/base/BaseCheckbox.js +75 -0
- package/dist/bundled/{BaseEmpty.js → components/base/BaseEmpty.js} +4 -4
- package/dist/bundled/components/base/BaseEmpty.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/base/BaseListItemLink.js +50 -0
- package/dist/bundled/components/base/BaseOverflowMenu.js +97 -0
- package/dist/bundled/components/base/BaseOverflowTab.js +45 -0
- package/dist/bundled/components/base/BaseSelect.js +88 -0
- package/dist/bundled/{MobileOverlay.js → components/base/BaseSplitPane.js} +9 -130
- package/dist/bundled/components/base/BaseSplitPane.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/base/BaseTab.js +45 -0
- package/dist/bundled/components/misc/CheckerboardPattern.js +41 -0
- package/dist/bundled/components/misc/HatchedPattern.js +11 -0
- package/dist/bundled/components/misc/HatchedPattern.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/panel/ControlsComponentPropItem.js +98 -0
- package/dist/bundled/components/panel/ControlsComponentProps.js +42 -0
- package/dist/bundled/components/panel/PaneTabs.js +110 -0
- package/dist/bundled/components/panel/StatePresets.js +184 -0
- package/dist/bundled/components/panel/StoryControls.js +66 -0
- package/dist/bundled/components/panel/StoryDocs.js +48 -0
- package/dist/bundled/components/panel/StoryEvent.js +56 -0
- package/dist/bundled/components/panel/StoryEvents.js +49 -0
- package/dist/bundled/components/panel/StorySidePanel.js +68 -0
- package/dist/bundled/components/panel/StorySourceCode.js +110 -0
- package/dist/bundled/components/panel/StorySourceCode.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/search/SearchItem.js +113 -0
- package/dist/bundled/components/search/SearchItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/search/SearchLoading.js +19 -0
- package/dist/bundled/components/search/SearchModal.js +46 -0
- package/dist/bundled/components/search/SearchPane.js +263 -0
- package/dist/bundled/{search-docs-data.js → components/search/search-docs-data.js} +1 -1
- package/dist/bundled/components/search/search-title-data.js +7 -0
- package/dist/bundled/components/story/StoryResponsivePreview.js +180 -0
- package/dist/bundled/components/story/StoryResponsivePreview.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantGrid.js +94 -0
- package/dist/bundled/components/story/StoryVariantGridItem.js +106 -0
- package/dist/bundled/components/story/StoryVariantGridItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantListItem.js +58 -0
- package/dist/bundled/components/story/StoryVariantListItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantSingle.js +115 -0
- package/dist/bundled/components/story/StoryVariantSingle.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewNative.js +43 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.js +119 -0
- package/dist/bundled/components/story/StoryVariantSingleView.js +49 -0
- package/dist/bundled/components/story/StoryView.js +107 -0
- package/dist/bundled/components/story/StoryViewer.js +57 -0
- package/dist/bundled/components/story/StoryViewer.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/toolbar/StoryVariantBackground.js +85 -0
- package/dist/bundled/components/toolbar/StoryVariantBackground.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/toolbar/StoryVariantNewTab.js +33 -0
- package/dist/bundled/components/toolbar/StoryVariantResponsiveSize.js +129 -0
- package/dist/bundled/components/toolbar/StoryVariantTitle.js +24 -0
- package/dist/bundled/components/tree/StoryGroup.js +74 -0
- package/dist/bundled/components/tree/StoryList.js +37 -0
- package/dist/bundled/components/tree/StoryListFolder.js +89 -0
- package/dist/bundled/components/tree/StoryListFolder.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/tree/StoryListItem.js +72 -0
- package/dist/bundled/components/tree/StoryListItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/index.js +28 -5
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/common.js +40 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/en.js +5 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/advanced.js +11 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/balance.js +26 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/simple.js +10 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang.js +50 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/type.js +8 -0
- package/dist/bundled/router.js +28 -0
- package/dist/bundled/sandbox.js +11 -14
- package/dist/bundled/{events.js → stores/events.js} +3 -3
- package/dist/bundled/stores/folder.js +46 -0
- package/dist/bundled/stores/preview-settings.js +15 -0
- package/dist/bundled/{story.js → stores/story.js} +4 -30
- package/dist/bundled/style.css +56 -56
- package/dist/bundled/{config.js → util/config.js} +1 -1
- package/dist/bundled/{const.js → util/const.js} +1 -1
- package/dist/bundled/util/dark.js +4 -0
- package/dist/bundled/util/env.js +2 -0
- package/dist/bundled/util/events.js +32 -0
- package/dist/bundled/util/keyboard.js +84 -0
- package/dist/bundled/{mapping.js → util/mapping.js} +5 -5
- package/dist/bundled/util/preview-settings.js +6 -0
- package/dist/bundled/util/responsive.js +3 -0
- package/dist/bundled/util/sandbox.js +8 -0
- package/dist/bundled/util/scroll.js +28 -0
- package/dist/bundled/{state.js → util/state.js} +4 -3
- package/dist/bundled/util/tooltip.js +12 -0
- package/dist/bundled/util/variant.js +35 -0
- package/dist/client/app/App.vue +0 -1
- package/dist/client/app/components/app/Breadcrumb.vue +1 -1
- package/dist/client/app/components/app/MobileOverlay.vue +1 -1
- package/dist/client/app/components/base/BaseCheckbox.vue +2 -1
- package/dist/client/app/components/base/BaseCopyIcon.vue +34 -0
- package/dist/client/app/components/base/BaseOverflowMenu.vue +1 -0
- package/dist/client/app/components/base/BaseSplitPane.vue +1 -0
- package/dist/client/app/components/panel/StatePresets.vue +3 -3
- package/dist/client/app/components/panel/StorySidePanel.vue +1 -1
- package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -0
- package/dist/client/app/components/story/StoryVariantSingle.vue +5 -7
- package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -6
- package/dist/client/app/components/story/StoryViewer.vue +2 -2
- package/dist/client/app/components/tree/StoryList.vue +1 -1
- package/dist/client/app/components/tree/StoryListItem.vue +2 -2
- package/dist/client/app/index.js +1 -3
- package/dist/client/app/sandbox.js +3 -2
- package/dist/client/app/stores/story.d.ts +30 -30
- package/dist/client/app/util/dark.d.ts +1 -1
- package/dist/client/app/util/mapping.js +3 -3
- package/dist/client/app/util/responsive.d.ts +1 -1
- package/dist/client/app/util/scroll.js +1 -1
- package/dist/client/app/util/state.js +2 -1
- package/dist/node/build.js +8 -1
- package/dist/node/commands/dev.js +1 -1
- package/dist/node/server.js +5 -4
- package/dist/node/util/log.d.ts +1 -0
- package/dist/node/util/log.js +9 -0
- package/dist/node/vite.d.ts +1 -1
- package/dist/node/vite.js +5 -3
- package/dist/style.css +21 -0
- package/index.d.ts +0 -2
- package/package.json +8 -15
- package/src/client/app/App.vue +0 -1
- package/src/client/app/components/app/Breadcrumb.vue +1 -1
- package/src/client/app/components/app/MobileOverlay.vue +1 -1
- package/src/client/app/components/base/BaseCheckbox.vue +2 -1
- package/src/client/app/components/base/BaseCopyIcon.vue +34 -0
- package/src/client/app/components/base/BaseOverflowMenu.vue +1 -0
- package/src/client/app/components/base/BaseSplitPane.vue +1 -0
- package/src/client/app/components/panel/StatePresets.vue +3 -3
- package/src/client/app/components/panel/StorySidePanel.vue +1 -1
- package/src/client/app/components/story/StoryVariantGridItem.vue +1 -0
- package/src/client/app/components/story/StoryVariantSingle.vue +5 -7
- package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -6
- package/src/client/app/components/story/StoryViewer.vue +2 -2
- package/src/client/app/components/tree/StoryList.vue +1 -1
- package/src/client/app/components/tree/StoryListItem.vue +2 -2
- package/src/client/app/index.ts +1 -5
- package/src/client/app/sandbox.ts +3 -2
- package/src/client/app/util/mapping.ts +3 -3
- package/src/client/app/util/scroll.ts +1 -1
- package/src/client/app/util/state.ts +2 -1
- package/src/node/build.ts +13 -3
- package/src/node/commands/dev.ts +1 -1
- package/src/node/server.ts +5 -4
- package/src/node/util/log.ts +9 -0
- package/src/node/vite.ts +5 -3
- package/tsconfig.json +12 -0
- package/vite.config.ts +21 -10
- package/vue.d.ts +1 -0
- package/dist/bundled/SearchPane.js +0 -506
- package/dist/bundled/StoryView.js +0 -2264
- package/dist/bundled/dark.js +0 -4
- package/dist/bundled/index2.js +0 -843
|
@@ -1,32 +1,6 @@
|
|
|
1
|
-
import { defineStore } from "pinia";
|
|
2
|
-
import { ref, computed } from "vue";
|
|
3
|
-
import {
|
|
4
|
-
import { h as histoireConfig } from "./config.js";
|
|
5
|
-
const base = import.meta.env.BASE_URL;
|
|
6
|
-
function createRouterHistory() {
|
|
7
|
-
switch (histoireConfig.routerMode) {
|
|
8
|
-
case "hash":
|
|
9
|
-
return createWebHashHistory(base);
|
|
10
|
-
case "history":
|
|
11
|
-
default:
|
|
12
|
-
return createWebHistory(base);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
const router = createRouter({
|
|
16
|
-
history: createRouterHistory(),
|
|
17
|
-
routes: [
|
|
18
|
-
{
|
|
19
|
-
path: "/",
|
|
20
|
-
name: "home",
|
|
21
|
-
component: () => import("./HomeView.js")
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
path: "/story/:storyId",
|
|
25
|
-
name: "story",
|
|
26
|
-
component: () => import("./StoryView.js")
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
});
|
|
1
|
+
import { defineStore } from "@histoire/vendors/dist/client/pinia.js";
|
|
2
|
+
import { ref, computed } from "@histoire/vendors/dist/client/vue.js";
|
|
3
|
+
import { router } from "../router.js";
|
|
30
4
|
const useStoryStore = defineStore("story", () => {
|
|
31
5
|
const stories = ref([]);
|
|
32
6
|
function setStories(value) {
|
|
@@ -66,4 +40,4 @@ const useStoryStore = defineStore("story", () => {
|
|
|
66
40
|
getVariantById
|
|
67
41
|
};
|
|
68
42
|
});
|
|
69
|
-
export {
|
|
43
|
+
export { useStoryStore };
|
package/dist/bundled/style.css
CHANGED
|
@@ -1,74 +1,71 @@
|
|
|
1
1
|
|
|
2
|
-
.
|
|
3
|
-
|
|
2
|
+
.htw-base-empty[data-v-552cc113]:not(.no-animation) {
|
|
3
|
+
-webkit-animation: htw-base-empty-552cc113 .3s 1s both;
|
|
4
|
+
animation: htw-base-empty-552cc113 .3s 1s both;
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
@-webkit-keyframes htw-base-empty-552cc113 {
|
|
7
|
+
0% {
|
|
8
|
+
opacity: 0;
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
100% {
|
|
11
|
+
opacity: 1;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
@keyframes htw-base-empty-552cc113 {
|
|
15
|
+
0% {
|
|
16
|
+
opacity: 0;
|
|
17
|
+
}
|
|
18
|
+
100% {
|
|
19
|
+
opacity: 1;
|
|
11
20
|
}
|
|
12
|
-
|
|
13
|
-
.bind-icon-color[data-v-5fe505b0] {
|
|
14
|
-
color: var(--7fa476a0);
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
.landscape > div > .dragger[data-v-
|
|
23
|
+
.landscape > div > .dragger[data-v-7c5763cc] {
|
|
18
24
|
width: .625rem;
|
|
19
25
|
}
|
|
20
|
-
.portrait > div > .dragger[data-v-
|
|
26
|
+
.portrait > div > .dragger[data-v-7c5763cc] {
|
|
21
27
|
height: .625rem;
|
|
22
28
|
}
|
|
23
|
-
.landscape > div > .dragger.dragger-offset-before[data-v-
|
|
29
|
+
.landscape > div > .dragger.dragger-offset-before[data-v-7c5763cc] {
|
|
24
30
|
right: 0;
|
|
25
31
|
}
|
|
26
|
-
.portrait > div > .dragger.dragger-offset-before[data-v-
|
|
32
|
+
.portrait > div > .dragger.dragger-offset-before[data-v-7c5763cc] {
|
|
27
33
|
bottom: 0;
|
|
28
34
|
}
|
|
29
|
-
.landscape > div > .dragger.dragger-offset-center[data-v-
|
|
35
|
+
.landscape > div > .dragger.dragger-offset-center[data-v-7c5763cc] {
|
|
30
36
|
right: -.3125rem;
|
|
31
37
|
}
|
|
32
|
-
.portrait > div > .dragger.dragger-offset-center[data-v-
|
|
38
|
+
.portrait > div > .dragger.dragger-offset-center[data-v-7c5763cc] {
|
|
33
39
|
bottom: -.3125rem;
|
|
34
40
|
}
|
|
35
|
-
.landscape > div > .dragger.dragger-offset-after[data-v-
|
|
41
|
+
.landscape > div > .dragger.dragger-offset-after[data-v-7c5763cc] {
|
|
36
42
|
right: -.625rem;
|
|
37
43
|
}
|
|
38
|
-
.portrait > div > .dragger.dragger-offset-after[data-v-
|
|
44
|
+
.portrait > div > .dragger.dragger-offset-after[data-v-7c5763cc] {
|
|
39
45
|
bottom: -.625rem;
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
.bind-icon-color[data-v-
|
|
43
|
-
color: var(--
|
|
48
|
+
.bind-icon-color[data-v-356879fc] {
|
|
49
|
+
color: var(--578fcd62);
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
.bind-icon-color[data-v-
|
|
47
|
-
color: var(--
|
|
52
|
+
.bind-icon-color[data-v-67187ed0] {
|
|
53
|
+
color: var(--5e381dde);
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
.bind-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.__histoire-hatched-pattern[data-v-250960ac] {
|
|
55
|
-
background: repeating-linear-gradient(135deg,
|
|
56
|
-
transparent 0px,
|
|
57
|
-
transparent 32px,
|
|
58
|
-
currentColor 32px,
|
|
59
|
-
currentColor 64px);
|
|
56
|
+
.bind-tree-margin[data-v-1b0b957a] {
|
|
57
|
+
margin-left: var(--2101d9b6);
|
|
60
58
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
background-color: var(--700caecc);
|
|
59
|
+
.bind-icon-color[data-v-1b0b957a] {
|
|
60
|
+
color: var(--0fbedaf2);
|
|
64
61
|
}
|
|
65
62
|
|
|
66
|
-
.bind-
|
|
67
|
-
|
|
63
|
+
.bind-tree-padding[data-v-1a78012e] {
|
|
64
|
+
padding-left: var(--27f98670);
|
|
68
65
|
}
|
|
69
66
|
|
|
70
|
-
.bind-icon-color[data-v-
|
|
71
|
-
color: var(--
|
|
67
|
+
.bind-icon-color[data-v-2cdc2ac0] {
|
|
68
|
+
color: var(--3c4190ff);
|
|
72
69
|
}
|
|
73
70
|
|
|
74
71
|
.__histoire-code-placeholder[data-v-8b318638] {
|
|
@@ -76,27 +73,30 @@
|
|
|
76
73
|
font-size: inherit;
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
.
|
|
80
|
-
|
|
81
|
-
animation: htw-base-empty-552cc113 .3s 1s both;
|
|
82
|
-
}
|
|
83
|
-
@-webkit-keyframes htw-base-empty-552cc113 {
|
|
84
|
-
0% {
|
|
85
|
-
opacity: 0;
|
|
86
|
-
}
|
|
87
|
-
100% {
|
|
88
|
-
opacity: 1;
|
|
76
|
+
.bind-icon-color[data-v-30bcb922] {
|
|
77
|
+
color: var(--33d9fc01);
|
|
89
78
|
}
|
|
79
|
+
|
|
80
|
+
.bind-icon-color[data-v-307653da] {
|
|
81
|
+
color: var(--5f94a358);
|
|
90
82
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
83
|
+
|
|
84
|
+
.bind-icon-color[data-v-7856c5b0] {
|
|
85
|
+
color: var(--0e1c785e);
|
|
94
86
|
}
|
|
95
|
-
|
|
96
|
-
|
|
87
|
+
|
|
88
|
+
.bind-preview-bg[data-v-bde73868] {
|
|
89
|
+
background-color: var(--b797c7ca);
|
|
97
90
|
}
|
|
91
|
+
|
|
92
|
+
.bind-preview-bg[data-v-769a585e] {
|
|
93
|
+
background-color: var(--700caecc);
|
|
98
94
|
}
|
|
99
95
|
|
|
100
|
-
.
|
|
101
|
-
|
|
96
|
+
.__histoire-hatched-pattern[data-v-250960ac] {
|
|
97
|
+
background: repeating-linear-gradient(135deg,
|
|
98
|
+
transparent 0px,
|
|
99
|
+
transparent 32px,
|
|
100
|
+
currentColor 32px,
|
|
101
|
+
currentColor 64px);
|
|
102
102
|
}
|
|
@@ -2,4 +2,4 @@ const STATE_SYNC = "__histoire:state-sync";
|
|
|
2
2
|
const SANDBOX_READY = "__histoire:sandbox-ready";
|
|
3
3
|
const EVENT_SEND = "__histoire:event";
|
|
4
4
|
const PREVIEW_SETTINGS_SYNC = "__histoire:preview-settings-sync";
|
|
5
|
-
export { EVENT_SEND
|
|
5
|
+
export { EVENT_SEND, PREVIEW_SETTINGS_SYNC, SANDBOX_READY, STATE_SYNC };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EVENT_SEND } from "./const.js";
|
|
2
|
+
async function hstEvent(name, argument) {
|
|
3
|
+
var _a;
|
|
4
|
+
console.log("[histoire] Event fired", { name, argument });
|
|
5
|
+
const event = {
|
|
6
|
+
name,
|
|
7
|
+
argument: JSON.parse(stringifyEvent(argument))
|
|
8
|
+
};
|
|
9
|
+
if (location.href.includes("__sandbox")) {
|
|
10
|
+
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
11
|
+
type: EVENT_SEND,
|
|
12
|
+
event
|
|
13
|
+
});
|
|
14
|
+
} else {
|
|
15
|
+
const { useEventsStore } = await import("../stores/events.js");
|
|
16
|
+
useEventsStore().addEvent(event);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function stringifyEvent(e) {
|
|
20
|
+
const obj = {};
|
|
21
|
+
for (const k in e) {
|
|
22
|
+
obj[k] = e[k];
|
|
23
|
+
}
|
|
24
|
+
return JSON.stringify(obj, (k, v) => {
|
|
25
|
+
if (v instanceof Node)
|
|
26
|
+
return "Node";
|
|
27
|
+
if (v instanceof Window)
|
|
28
|
+
return "Window";
|
|
29
|
+
return v;
|
|
30
|
+
}, " ");
|
|
31
|
+
}
|
|
32
|
+
export { hstEvent };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { useEventListener } from "@histoire/vendors/dist/client/vue-use.js";
|
|
2
|
+
import { isRef } from "@histoire/vendors/dist/client/vue.js";
|
|
3
|
+
import { isMac } from "./env.js";
|
|
4
|
+
function onKeyboardShortcut(shortcut, handler, options = {}) {
|
|
5
|
+
var _a;
|
|
6
|
+
useEventListener((_a = options.event) != null ? _a : "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 ? "\u2387" : "Alt";
|
|
75
|
+
}
|
|
76
|
+
if (key === "shift") {
|
|
77
|
+
return "\u21E7";
|
|
78
|
+
}
|
|
79
|
+
if (key === "meta") {
|
|
80
|
+
return "\u2318";
|
|
81
|
+
}
|
|
82
|
+
return key.charAt(0).toUpperCase() + key.substring(1).toLowerCase();
|
|
83
|
+
}
|
|
84
|
+
export { formatKey, onKeyboardShortcut };
|
|
@@ -17,13 +17,14 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { markRaw } from "vue";
|
|
20
|
+
import { markRaw } from "@histoire/vendors/dist/client/vue.js";
|
|
21
|
+
import { reactive } from "@histoire/vendors/dist/client/vue";
|
|
21
22
|
const copiedFromExistingVariant = [
|
|
22
23
|
"state",
|
|
23
24
|
"slots",
|
|
24
|
-
"initState",
|
|
25
25
|
"source",
|
|
26
26
|
"responsiveDisabled",
|
|
27
|
+
"autoPropsDisabled",
|
|
27
28
|
"setupApp",
|
|
28
29
|
"configReady",
|
|
29
30
|
"previewReady"
|
|
@@ -66,8 +67,7 @@ function mapVariant(variant, existingVariant) {
|
|
|
66
67
|
}
|
|
67
68
|
} else {
|
|
68
69
|
result = __spreadProps(__spreadValues({}, variant), {
|
|
69
|
-
state:
|
|
70
|
-
initState: null,
|
|
70
|
+
state: reactive({}),
|
|
71
71
|
setupApp: null,
|
|
72
72
|
slots: () => ({}),
|
|
73
73
|
previewReady: false
|
|
@@ -75,4 +75,4 @@ function mapVariant(variant, existingVariant) {
|
|
|
75
75
|
}
|
|
76
76
|
return result;
|
|
77
77
|
}
|
|
78
|
-
export { mapFile
|
|
78
|
+
export { mapFile, mapVariant };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { base } from "../router.js";
|
|
2
|
+
function getSandboxUrl(story, variant) {
|
|
3
|
+
const url = new URLSearchParams();
|
|
4
|
+
url.append("storyId", story.id);
|
|
5
|
+
url.append("variantId", variant.id);
|
|
6
|
+
return `${base}__sandbox.html?${url.toString()}`;
|
|
7
|
+
}
|
|
8
|
+
export { getSandboxUrl };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { watch, onMounted } from "@histoire/vendors/dist/client/vue.js";
|
|
2
|
+
import { scrollIntoView } from "@histoire/vendors/dist/client/scroll.js";
|
|
3
|
+
function useScrollOnActive(active, el) {
|
|
4
|
+
watch(active, (value) => {
|
|
5
|
+
if (value) {
|
|
6
|
+
autoScroll();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
function autoScroll() {
|
|
10
|
+
if (el.value) {
|
|
11
|
+
scrollIntoView(el.value, {
|
|
12
|
+
scrollMode: "if-needed",
|
|
13
|
+
block: "center",
|
|
14
|
+
inline: "nearest",
|
|
15
|
+
behavior: "smooth"
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
onMounted(() => {
|
|
20
|
+
if (active.value) {
|
|
21
|
+
autoScroll();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
autoScroll
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export { useScrollOnActive };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { isRef, unref } from "vue";
|
|
1
|
+
import { isRef, unref } from "@histoire/vendors/dist/client/vue.js";
|
|
2
2
|
const isObject = (val) => val !== null && typeof val === "object";
|
|
3
3
|
function toRawDeep(val, seen = /* @__PURE__ */ new Set()) {
|
|
4
4
|
const unwrappedValue = isRef(val) ? unref(val) : val;
|
|
5
|
-
|
|
5
|
+
const valueType = typeof unwrappedValue;
|
|
6
|
+
if (valueType === "symbol" || valueType === "function") {
|
|
6
7
|
return unwrappedValue.toString();
|
|
7
8
|
}
|
|
8
9
|
if (!isObject(unwrappedValue)) {
|
|
@@ -21,4 +22,4 @@ const toRawObject = (obj, seen = /* @__PURE__ */ new Set()) => Object.keys(obj).
|
|
|
21
22
|
raw[key] = toRawDeep(obj[key], seen);
|
|
22
23
|
return raw;
|
|
23
24
|
}, {});
|
|
24
|
-
export { toRawDeep
|
|
25
|
+
export { toRawDeep };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isMac } from "./env.js";
|
|
2
|
+
import { formatKey } from "./keyboard.js";
|
|
3
|
+
function makeTooltip(descriptionHtml, keyboardShortcut) {
|
|
4
|
+
return {
|
|
5
|
+
content: `<div>${descriptionHtml}</div><div class="htw-flex htw-items-center htw-gap-1 htw-mt-2 htw-text-sm">${genKeyboardShortcutHtml(keyboardShortcut({ isMac }))}</div>`,
|
|
6
|
+
html: true
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function genKeyboardShortcutHtml(shortcut) {
|
|
10
|
+
return shortcut.split("+").map((k) => k.trim()).map((key) => `<span class="htw-bg-gray-500 htw-border-b-2 htw-border-gray-600 htw-px-1 htw-rounded-sm">${formatKey(key)}</span>`).join("");
|
|
11
|
+
}
|
|
12
|
+
export { makeTooltip };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { computed } from "@histoire/vendors/dist/client/vue.js";
|
|
21
|
+
import { useRoute } from "@histoire/vendors/dist/client/vue-router.js";
|
|
22
|
+
function useCurrentVariantRoute(variant) {
|
|
23
|
+
const route = useRoute();
|
|
24
|
+
const isActive = computed(() => route.query.variantId === variant.value.id);
|
|
25
|
+
const targetRoute = computed(() => __spreadProps(__spreadValues({}, route), {
|
|
26
|
+
query: __spreadProps(__spreadValues({}, route.query), {
|
|
27
|
+
variantId: variant.value.id
|
|
28
|
+
})
|
|
29
|
+
}));
|
|
30
|
+
return {
|
|
31
|
+
isActive,
|
|
32
|
+
targetRoute
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export { useCurrentVariantRoute };
|
package/dist/client/app/App.vue
CHANGED
|
@@ -9,6 +9,7 @@ const props = defineProps({
|
|
|
9
9
|
})
|
|
10
10
|
|
|
11
11
|
const emit = defineEmits({
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
13
|
'update:modelValue': (newValue: boolean) => true,
|
|
13
14
|
})
|
|
14
15
|
|
|
@@ -25,7 +26,7 @@ const progress = computed(() => props.modelValue ? 1 : 0)
|
|
|
25
26
|
const dashoffset = computed(() => (1 - progress.value) * dasharray.value)
|
|
26
27
|
const animationEnabled = ref(false)
|
|
27
28
|
|
|
28
|
-
watch(path,
|
|
29
|
+
watch(path, () => {
|
|
29
30
|
dasharray.value = path.value.getTotalLength?.() ?? 21.21
|
|
30
31
|
})
|
|
31
32
|
</script>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export default {
|
|
3
|
+
name: 'HstCopyIcon',
|
|
4
|
+
}
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { Icon } from '@iconify/vue'
|
|
9
|
+
import { useClipboard } from '@vueuse/core'
|
|
10
|
+
import { VTooltip as vTooltip } from 'floating-vue'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
content: string
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const { copy, copied } = useClipboard()
|
|
17
|
+
|
|
18
|
+
const action = () => copy(props.content)
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<Icon
|
|
23
|
+
v-tooltip="{
|
|
24
|
+
content: 'Copied!',
|
|
25
|
+
triggers: [],
|
|
26
|
+
shown: copied,
|
|
27
|
+
distance: 12,
|
|
28
|
+
delay: 0,
|
|
29
|
+
}"
|
|
30
|
+
icon="carbon:copy-file"
|
|
31
|
+
class="htw-w-4 htw-h-4 htw-opacity-50 hover:htw-opacity-100 hover:htw-text-primary-500 htw-cursor-pointer"
|
|
32
|
+
@click="action()"
|
|
33
|
+
/>
|
|
34
|
+
</template>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ref, computed, nextTick, onMounted } from 'vue'
|
|
3
3
|
import { Icon } from '@iconify/vue'
|
|
4
4
|
import { useStorage, onClickOutside, useTimeoutFn } from '@vueuse/core'
|
|
5
|
-
import {
|
|
5
|
+
import { applyState, clone, omit } from '@histoire/shared'
|
|
6
6
|
import BaseSelect from '../base/BaseSelect.vue'
|
|
7
7
|
import { toRawDeep } from '../../util/state'
|
|
8
8
|
import type { Story, Variant } from '../../types'
|
|
@@ -40,14 +40,14 @@ const presetsOptions = computed(() => {
|
|
|
40
40
|
|
|
41
41
|
function resetState () {
|
|
42
42
|
selectedOption.value = DEFAULT_ID
|
|
43
|
-
|
|
43
|
+
applyState(props.variant.state, clone(defaultState))
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
function applyPreset (id) {
|
|
47
47
|
if (id === DEFAULT_ID) {
|
|
48
48
|
resetState()
|
|
49
49
|
} else if (presetStates.value.has(id)) {
|
|
50
|
-
|
|
50
|
+
applyState(props.variant.state, clone(presetStates.value.get(id).state))
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -32,7 +32,7 @@ const panelContentComponent = computed(() => {
|
|
|
32
32
|
<span>Select a variant</span>
|
|
33
33
|
</BaseEmpty>
|
|
34
34
|
|
|
35
|
-
<BaseEmpty v-else-if="!storyStore.currentVariant.previewReady">
|
|
35
|
+
<BaseEmpty v-else-if="!storyStore.currentVariant.configReady || !storyStore.currentVariant.previewReady">
|
|
36
36
|
<span>Loading...</span>
|
|
37
37
|
</BaseEmpty>
|
|
38
38
|
|