@histoire/app 0.9.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-vue.pcss +34 -0
- package/dist/app/style/main.pcss +86 -0
- package/dist/app/style/sandbox.css +19 -0
- package/dist/app/style/transitions.pcss +51 -0
- package/dist/bundle-index.js +1 -0
- package/dist/bundle-main.js +5 -0
- package/dist/bundle-sandbox.js +2 -0
- package/dist/bundled/App.js +148 -0
- package/dist/bundled/_virtual/plugin-vue_export-helper.js +8 -0
- package/dist/bundled/api.js +1 -0
- package/dist/bundled/assets/histoire-text-dark.js +2 -0
- package/dist/bundled/assets/histoire-text.js +2 -0
- package/dist/bundled/assets/histoire.js +2 -0
- 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/components/base/BaseEmpty.js +13 -0
- 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 +69 -0
- package/dist/bundled/components/base/BaseSplitPane.js +184 -0
- 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 +112 -0
- package/dist/bundled/components/panel/StatePresets.js +190 -0
- package/dist/bundled/components/panel/StoryControls.js +66 -0
- package/dist/bundled/components/panel/StoryDocs.js +57 -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 +72 -0
- package/dist/bundled/components/panel/StorySourceCode.js +119 -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/components/search/search-docs-data.js +7 -0
- package/dist/bundled/components/search/search-title-data.js +7 -0
- package/dist/bundled/components/story/GenericMountStory.js +27 -0
- package/dist/bundled/components/story/GenericRenderStory.js +27 -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 +90 -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 +29 -0
- 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 +88 -0
- package/dist/bundled/stores/events.js +29 -0
- package/dist/bundled/stores/folder.js +49 -0
- package/dist/bundled/stores/preview-settings.js +15 -0
- package/dist/bundled/stores/story.js +43 -0
- package/dist/bundled/style.css +102 -0
- package/dist/bundled/util/config.js +4 -0
- package/dist/bundled/util/const.js +5 -0
- 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/util/mapping.js +65 -0
- 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/util/state.js +31 -0
- package/dist/bundled/util/tooltip.js +12 -0
- package/dist/bundled/util/variant.js +18 -0
- package/dist/style.css +2697 -0
- package/package.json +57 -0
- package/postcss.config.cjs +8 -0
- package/scripts/copy.mjs +12 -0
- package/scripts/watchAndCopy.mjs +15 -0
- package/src/app/App.vue +162 -0
- package/src/app/api.ts +1 -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 +17 -0
- package/src/app/components/app/AppHeader.vue +64 -0
- package/src/app/components/app/AppLogo.vue +24 -0
- package/src/app/components/app/Breadcrumb.vue +98 -0
- package/src/app/components/app/InitialLoading.vue +44 -0
- package/src/app/components/app/MobileOverlay.vue +33 -0
- package/src/app/components/base/BaseCheckbox.vue +77 -0
- package/src/app/components/base/BaseCopyIcon.vue +34 -0
- package/src/app/components/base/BaseEmpty.vue +21 -0
- package/src/app/components/base/BaseListItemLink.vue +55 -0
- package/src/app/components/base/BaseOverflowMenu.vue +119 -0
- package/src/app/components/base/BaseOverflowTab.vue +46 -0
- package/src/app/components/base/BaseSelect.vue +72 -0
- package/src/app/components/base/BaseSplitPane.vue +240 -0
- package/src/app/components/base/BaseTab.vue +46 -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 +103 -0
- package/src/app/components/panel/ControlsComponentProps.vue +34 -0
- package/src/app/components/panel/PaneTabs.vue +89 -0
- package/src/app/components/panel/StatePresets.vue +196 -0
- package/src/app/components/panel/StoryControls.vue +68 -0
- package/src/app/components/panel/StoryDocs.vue +60 -0
- package/src/app/components/panel/StoryEvent.vue +54 -0
- package/src/app/components/panel/StoryEvents.vue +45 -0
- package/src/app/components/panel/StorySidePanel.vue +70 -0
- package/src/app/components/panel/StorySourceCode.vue +126 -0
- package/src/app/components/search/SearchItem.vue +110 -0
- package/src/app/components/search/SearchLoading.vue +16 -0
- package/src/app/components/search/SearchModal.vue +43 -0
- package/src/app/components/search/SearchPane.vue +293 -0
- package/src/app/components/search/search-docs-data.ts +10 -0
- package/src/app/components/search/search-title-data.ts +10 -0
- package/src/app/components/search/types.ts +4 -0
- package/src/app/components/story/GenericMountStory.vue +28 -0
- package/src/app/components/story/GenericRenderStory.vue +29 -0
- package/src/app/components/story/StoryResponsivePreview.vue +204 -0
- package/src/app/components/story/StoryVariantGrid.vue +112 -0
- package/src/app/components/story/StoryVariantGridItem.vue +110 -0
- package/src/app/components/story/StoryVariantListItem.vue +50 -0
- package/src/app/components/story/StoryVariantSingle.vue +105 -0
- package/src/app/components/story/StoryVariantSinglePreviewNative.vue +42 -0
- package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +139 -0
- package/src/app/components/story/StoryVariantSingleView.vue +52 -0
- package/src/app/components/story/StoryView.vue +96 -0
- package/src/app/components/story/StoryViewer.vue +53 -0
- package/src/app/components/toolbar/StoryVariantBackground.vue +67 -0
- package/src/app/components/toolbar/StoryVariantNewTab.vue +29 -0
- package/src/app/components/toolbar/StoryVariantResponsiveSize.vue +82 -0
- package/src/app/components/toolbar/StoryVariantTitle.vue +21 -0
- package/src/app/components/tree/StoryGroup.vue +75 -0
- package/src/app/components/tree/StoryList.vue +35 -0
- package/src/app/components/tree/StoryListFolder.vue +89 -0
- package/src/app/components/tree/StoryListItem.vue +71 -0
- package/src/app/index.ts +30 -0
- package/src/app/router.ts +29 -0
- package/src/app/sandbox.ts +96 -0
- package/src/app/stores/events.ts +36 -0
- package/src/app/stores/folder.ts +59 -0
- package/src/app/stores/preview-settings.ts +17 -0
- package/src/app/stores/story.ts +47 -0
- package/src/app/style/floating-vue.pcss +34 -0
- package/src/app/style/main.pcss +86 -0
- package/src/app/style/sandbox.css +19 -0
- package/src/app/style/transitions.pcss +51 -0
- package/src/app/types.ts +46 -0
- package/src/app/util/config.ts +6 -0
- package/src/app/util/const.ts +4 -0
- package/src/app/util/dark.ts +4 -0
- package/src/app/util/env.ts +1 -0
- package/src/app/util/events.ts +30 -0
- package/src/app/util/keyboard.ts +99 -0
- package/src/app/util/mapping.ts +76 -0
- package/src/app/util/preview-settings.ts +8 -0
- package/src/app/util/responsive.ts +3 -0
- package/src/app/util/sandbox.ts +10 -0
- package/src/app/util/scroll.ts +31 -0
- package/src/app/util/state.ts +37 -0
- package/src/app/util/tooltip.ts +13 -0
- package/src/app/util/variant.ts +20 -0
- package/src/bundle-index.js +1 -0
- package/src/bundle-main.js +5 -0
- package/src/bundle-sandbox.js +2 -0
- package/src/index.ts +1 -0
- package/src/shim.d.ts +7 -0
- package/tailwind.config.cjs +126 -0
- package/tsconfig.json +54 -0
- package/vite.config.ts +87 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
|
|
2
|
+
.landscape > div > .dragger[data-v-328ea07c] {
|
|
3
|
+
width: .625rem;
|
|
4
|
+
}
|
|
5
|
+
.portrait > div > .dragger[data-v-328ea07c] {
|
|
6
|
+
height: .625rem;
|
|
7
|
+
}
|
|
8
|
+
.landscape > div > .dragger.dragger-offset-before[data-v-328ea07c] {
|
|
9
|
+
right: 0;
|
|
10
|
+
}
|
|
11
|
+
.portrait > div > .dragger.dragger-offset-before[data-v-328ea07c] {
|
|
12
|
+
bottom: 0;
|
|
13
|
+
}
|
|
14
|
+
.landscape > div > .dragger.dragger-offset-center[data-v-328ea07c] {
|
|
15
|
+
right: -.3125rem;
|
|
16
|
+
}
|
|
17
|
+
.portrait > div > .dragger.dragger-offset-center[data-v-328ea07c] {
|
|
18
|
+
bottom: -.3125rem;
|
|
19
|
+
}
|
|
20
|
+
.landscape > div > .dragger.dragger-offset-after[data-v-328ea07c] {
|
|
21
|
+
right: -.625rem;
|
|
22
|
+
}
|
|
23
|
+
.portrait > div > .dragger.dragger-offset-after[data-v-328ea07c] {
|
|
24
|
+
bottom: -.625rem;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.bind-icon-color[data-v-25f7510c] {
|
|
28
|
+
color: var(--353b213f);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.htw-base-empty[data-v-c242ab26]:not(.no-animation) {
|
|
32
|
+
-webkit-animation: htw-base-empty-c242ab26 .15s .2s both;
|
|
33
|
+
animation: htw-base-empty-c242ab26 .15s .2s both;
|
|
34
|
+
}
|
|
35
|
+
@-webkit-keyframes htw-base-empty-c242ab26 {
|
|
36
|
+
0% {
|
|
37
|
+
opacity: 0;
|
|
38
|
+
}
|
|
39
|
+
100% {
|
|
40
|
+
opacity: 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
@keyframes htw-base-empty-c242ab26 {
|
|
44
|
+
0% {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
}
|
|
47
|
+
100% {
|
|
48
|
+
opacity: 1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.bind-tree-margin[data-v-d0757d50] {
|
|
53
|
+
margin-left: var(--9d1e9326);
|
|
54
|
+
}
|
|
55
|
+
.bind-icon-color[data-v-d0757d50] {
|
|
56
|
+
color: var(--411af7ae);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.bind-tree-padding[data-v-8eb31f6a] {
|
|
60
|
+
padding-left: var(--7b519d4f);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.bind-icon-color[data-v-b9d4a640] {
|
|
64
|
+
color: var(--10f93ca4);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.bind-icon-color[data-v-3fb261e4] {
|
|
68
|
+
color: var(--7333f29c);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.bind-icon-color[data-v-7f8cccbc] {
|
|
72
|
+
color: var(--cebc8760);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.bind-icon-color[data-v-2ca2325e] {
|
|
76
|
+
color: var(--0589c2c6);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.__histoire-code-placeholder[data-v-5ab4829f] {
|
|
80
|
+
color: inherit;
|
|
81
|
+
font-size: inherit;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.bind-icon-color[data-v-b8b384dc] {
|
|
85
|
+
color: var(--6e7451a9);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.bind-preview-bg[data-v-bc4883a4] {
|
|
89
|
+
background-color: var(--6bcdf233);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.bind-preview-bg[data-v-04999d80] {
|
|
93
|
+
background-color: var(--95cca8b2);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.__histoire-hatched-pattern[data-v-0bb8c4e8] {
|
|
97
|
+
background: repeating-linear-gradient(135deg,
|
|
98
|
+
transparent 0px,
|
|
99
|
+
transparent 32px,
|
|
100
|
+
currentColor 32px,
|
|
101
|
+
currentColor 64px);
|
|
102
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
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 { 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/vue-use";
|
|
2
|
+
import { isRef } from "@histoire/vendors/vue";
|
|
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 };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { markRaw, reactive } from "@histoire/vendors/vue";
|
|
2
|
+
const copiedFromExistingVariant = [
|
|
3
|
+
"state",
|
|
4
|
+
"slots",
|
|
5
|
+
"source",
|
|
6
|
+
"responsiveDisabled",
|
|
7
|
+
"autoPropsDisabled",
|
|
8
|
+
"setupApp",
|
|
9
|
+
"configReady",
|
|
10
|
+
"previewReady"
|
|
11
|
+
];
|
|
12
|
+
function mapFile(file, existingFile) {
|
|
13
|
+
let result;
|
|
14
|
+
if (existingFile) {
|
|
15
|
+
result = existingFile;
|
|
16
|
+
for (const key in file) {
|
|
17
|
+
if (key === "story") {
|
|
18
|
+
Object.assign(result.story, {
|
|
19
|
+
...file.story,
|
|
20
|
+
file: markRaw(result),
|
|
21
|
+
variants: file.story.variants.map((v) => mapVariant(v, existingFile.story.variants.find((item) => item.id === v.id)))
|
|
22
|
+
});
|
|
23
|
+
} else if (key !== "component") {
|
|
24
|
+
result[key] = file[key];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
result = {
|
|
29
|
+
...file,
|
|
30
|
+
component: markRaw(file.component),
|
|
31
|
+
story: {
|
|
32
|
+
...file.story,
|
|
33
|
+
title: file.story.title,
|
|
34
|
+
file: markRaw(file),
|
|
35
|
+
variants: file.story.variants.map((v) => mapVariant(v)),
|
|
36
|
+
slots: () => ({})
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
function mapVariant(variant, existingVariant) {
|
|
43
|
+
let result;
|
|
44
|
+
if (existingVariant) {
|
|
45
|
+
result = existingVariant;
|
|
46
|
+
for (const key in variant) {
|
|
47
|
+
if (!copiedFromExistingVariant.includes(key)) {
|
|
48
|
+
result[key] = variant[key];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
result = {
|
|
53
|
+
...variant,
|
|
54
|
+
state: reactive({
|
|
55
|
+
_hPropState: {},
|
|
56
|
+
_hPropDefs: {}
|
|
57
|
+
}),
|
|
58
|
+
setupApp: null,
|
|
59
|
+
slots: () => ({}),
|
|
60
|
+
previewReady: false
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
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/vue";
|
|
2
|
+
import scrollIntoView from "@histoire/vendors/scroll";
|
|
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 };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { isRef, unref } from "@histoire/vendors/vue";
|
|
2
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
3
|
+
function toRawDeep(val, seen = /* @__PURE__ */ new WeakMap()) {
|
|
4
|
+
const unwrappedValue = isRef(val) ? unref(val) : val;
|
|
5
|
+
if (typeof unwrappedValue === "symbol") {
|
|
6
|
+
return unwrappedValue.toString();
|
|
7
|
+
}
|
|
8
|
+
if (!isObject(unwrappedValue)) {
|
|
9
|
+
return unwrappedValue;
|
|
10
|
+
}
|
|
11
|
+
if (seen.has(unwrappedValue)) {
|
|
12
|
+
return seen.get(unwrappedValue);
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(unwrappedValue)) {
|
|
15
|
+
const result = [];
|
|
16
|
+
seen.set(unwrappedValue, result);
|
|
17
|
+
result.push(...unwrappedValue.map((value) => toRawDeep(value, seen)));
|
|
18
|
+
return result;
|
|
19
|
+
} else {
|
|
20
|
+
const result = {};
|
|
21
|
+
seen.set(unwrappedValue, result);
|
|
22
|
+
toRawObject(unwrappedValue, result, seen);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const toRawObject = (obj, target, seen = /* @__PURE__ */ new WeakMap()) => {
|
|
27
|
+
Object.keys(obj).forEach((key) => {
|
|
28
|
+
target[key] = toRawDeep(obj[key], seen);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
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,18 @@
|
|
|
1
|
+
import { computed } from "@histoire/vendors/vue";
|
|
2
|
+
import { useRoute } from "@histoire/vendors/vue-router";
|
|
3
|
+
function useCurrentVariantRoute(variant) {
|
|
4
|
+
const route = useRoute();
|
|
5
|
+
const isActive = computed(() => route.query.variantId === variant.value.id);
|
|
6
|
+
const targetRoute = computed(() => ({
|
|
7
|
+
...route,
|
|
8
|
+
query: {
|
|
9
|
+
...route.query,
|
|
10
|
+
variantId: variant.value.id
|
|
11
|
+
}
|
|
12
|
+
}));
|
|
13
|
+
return {
|
|
14
|
+
isActive,
|
|
15
|
+
targetRoute
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export { useCurrentVariantRoute };
|