@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,190 @@
|
|
|
1
|
+
import { defineComponent, computed, onMounted, ref, nextTick, resolveDirective, openBlock, createElementBlock, createElementVNode, createVNode, unref, isRef, withKeys, withCtx, withDirectives, withModifiers, vModelText, toDisplayString, createBlock, createCommentVNode, normalizeClass } from "@histoire/vendors/vue";
|
|
2
|
+
import { Icon } from "@histoire/vendors/iconify";
|
|
3
|
+
import { useStorage, useTimeoutFn, onClickOutside } from "@histoire/vendors/vue-use";
|
|
4
|
+
import { clone, omit, applyState } from "@histoire/shared";
|
|
5
|
+
import _sfc_main$1 from "../base/BaseSelect.js";
|
|
6
|
+
import { toRawDeep } from "../../util/state.js";
|
|
7
|
+
const _hoisted_1 = { class: "htw-flex htw-gap-2 htw-w-full htw-items-center" };
|
|
8
|
+
const _hoisted_2 = ["onUpdate:modelValue"];
|
|
9
|
+
const _hoisted_3 = {
|
|
10
|
+
key: 1,
|
|
11
|
+
class: "htw-flex htw-items-center htw-gap-2"
|
|
12
|
+
};
|
|
13
|
+
const _hoisted_4 = { class: "htw-flex-1 htw-truncate" };
|
|
14
|
+
const _hoisted_5 = { class: "htw-flex htw-gap-2 htw-items-center" };
|
|
15
|
+
const _hoisted_6 = { class: "htw-flex-1 htw-truncate" };
|
|
16
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
17
|
+
__name: "StatePresets",
|
|
18
|
+
props: {
|
|
19
|
+
story: null,
|
|
20
|
+
variant: null
|
|
21
|
+
},
|
|
22
|
+
setup(__props) {
|
|
23
|
+
const props = __props;
|
|
24
|
+
const DEFAULT_ID = "default";
|
|
25
|
+
const saveId = computed(() => `${props.story.id}:${props.variant.id}`);
|
|
26
|
+
const omitKeys = ["_hPropDefs"];
|
|
27
|
+
const defaultState = clone(omit(toRawDeep(props.variant.state), omitKeys));
|
|
28
|
+
const selectedOption = useStorage(
|
|
29
|
+
`_histoire-presets/${saveId.value}/selected`,
|
|
30
|
+
DEFAULT_ID
|
|
31
|
+
);
|
|
32
|
+
const presetStates = useStorage(
|
|
33
|
+
`_histoire-presets/${saveId.value}/states`,
|
|
34
|
+
/* @__PURE__ */ new Map()
|
|
35
|
+
);
|
|
36
|
+
const presetsOptions = computed(() => {
|
|
37
|
+
const options = { [DEFAULT_ID]: "Initial state" };
|
|
38
|
+
presetStates.value.forEach((value, key) => {
|
|
39
|
+
options[key] = value.label;
|
|
40
|
+
});
|
|
41
|
+
return options;
|
|
42
|
+
});
|
|
43
|
+
function resetState() {
|
|
44
|
+
selectedOption.value = DEFAULT_ID;
|
|
45
|
+
applyState(props.variant.state, clone(defaultState));
|
|
46
|
+
}
|
|
47
|
+
function applyPreset(id) {
|
|
48
|
+
if (id === DEFAULT_ID) {
|
|
49
|
+
resetState();
|
|
50
|
+
} else if (presetStates.value.has(id)) {
|
|
51
|
+
applyState(props.variant.state, clone(presetStates.value.get(id).state));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
onMounted(() => {
|
|
55
|
+
if (selectedOption.value !== DEFAULT_ID) {
|
|
56
|
+
applyPreset(selectedOption.value);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const input = ref();
|
|
60
|
+
const select = ref();
|
|
61
|
+
const canEdit = computed(() => selectedOption.value !== DEFAULT_ID);
|
|
62
|
+
const isEditing = ref(false);
|
|
63
|
+
async function createPreset() {
|
|
64
|
+
const id = new Date().getTime().toString();
|
|
65
|
+
presetStates.value.set(id, { state: clone(omit(toRawDeep(props.variant.state), omitKeys)), label: "New preset" });
|
|
66
|
+
selectedOption.value = id;
|
|
67
|
+
isEditing.value = true;
|
|
68
|
+
await nextTick();
|
|
69
|
+
input.value.select();
|
|
70
|
+
}
|
|
71
|
+
const savedNotif = ref(false);
|
|
72
|
+
const savedTimeout = useTimeoutFn(() => {
|
|
73
|
+
savedNotif.value = false;
|
|
74
|
+
}, 1e3);
|
|
75
|
+
async function savePreset() {
|
|
76
|
+
if (!canEdit.value)
|
|
77
|
+
return;
|
|
78
|
+
const preset = presetStates.value.get(selectedOption.value);
|
|
79
|
+
preset.state = clone(omit(toRawDeep(props.variant.state), omitKeys));
|
|
80
|
+
savedNotif.value = true;
|
|
81
|
+
savedTimeout.start();
|
|
82
|
+
}
|
|
83
|
+
function deletePreset(id) {
|
|
84
|
+
if (!confirm("Are you sure you want to delete this preset?")) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (selectedOption.value === id) {
|
|
88
|
+
resetState();
|
|
89
|
+
}
|
|
90
|
+
presetStates.value.delete(id);
|
|
91
|
+
}
|
|
92
|
+
async function startEditing() {
|
|
93
|
+
if (!canEdit.value) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
isEditing.value = true;
|
|
97
|
+
await nextTick();
|
|
98
|
+
input.value.select();
|
|
99
|
+
}
|
|
100
|
+
function stopEditing() {
|
|
101
|
+
isEditing.value = false;
|
|
102
|
+
}
|
|
103
|
+
onClickOutside(select, stopEditing);
|
|
104
|
+
return (_ctx, _cache) => {
|
|
105
|
+
const _directive_tooltip = resolveDirective("tooltip");
|
|
106
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
107
|
+
createElementVNode("div", {
|
|
108
|
+
ref_key: "select",
|
|
109
|
+
ref: select,
|
|
110
|
+
class: "htw-flex-1 htw-min-w-0"
|
|
111
|
+
}, [
|
|
112
|
+
createVNode(_sfc_main$1, {
|
|
113
|
+
modelValue: unref(selectedOption),
|
|
114
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(selectedOption) ? selectedOption.value = $event : null),
|
|
115
|
+
options: unref(presetsOptions),
|
|
116
|
+
onDblclick: _cache[3] || (_cache[3] = ($event) => startEditing()),
|
|
117
|
+
onKeydown: [
|
|
118
|
+
_cache[4] || (_cache[4] = withKeys(($event) => stopEditing(), ["enter"])),
|
|
119
|
+
_cache[5] || (_cache[5] = withKeys(($event) => stopEditing(), ["escape"]))
|
|
120
|
+
],
|
|
121
|
+
onSelect: _cache[6] || (_cache[6] = (id) => applyPreset(id))
|
|
122
|
+
}, {
|
|
123
|
+
default: withCtx(({ label }) => [
|
|
124
|
+
isEditing.value ? withDirectives((openBlock(), createElementBlock("input", {
|
|
125
|
+
key: 0,
|
|
126
|
+
ref_key: "input",
|
|
127
|
+
ref: input,
|
|
128
|
+
"onUpdate:modelValue": ($event) => unref(presetStates).get(unref(selectedOption)).label = $event,
|
|
129
|
+
type: "text",
|
|
130
|
+
class: "htw-text-inherit htw-bg-transparent htw-w-full htw-h-full htw-outline-none",
|
|
131
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
132
|
+
}, ["stop", "prevent"]))
|
|
133
|
+
}, null, 8, _hoisted_2)), [
|
|
134
|
+
[vModelText, unref(presetStates).get(unref(selectedOption)).label]
|
|
135
|
+
]) : (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
136
|
+
createElementVNode("span", _hoisted_4, toDisplayString(label), 1),
|
|
137
|
+
unref(canEdit) ? withDirectives((openBlock(), createBlock(unref(Icon), {
|
|
138
|
+
key: 0,
|
|
139
|
+
icon: "carbon:edit",
|
|
140
|
+
class: "htw-flex-none htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
|
|
141
|
+
onClick: _cache[1] || (_cache[1] = withModifiers(($event) => startEditing(), ["stop"]))
|
|
142
|
+
}, null, 512)), [
|
|
143
|
+
[_directive_tooltip, "Rename this preset"]
|
|
144
|
+
]) : createCommentVNode("", true)
|
|
145
|
+
]))
|
|
146
|
+
]),
|
|
147
|
+
option: withCtx(({ label, value }) => [
|
|
148
|
+
createElementVNode("div", _hoisted_5, [
|
|
149
|
+
createElementVNode("span", _hoisted_6, toDisplayString(label), 1),
|
|
150
|
+
value !== DEFAULT_ID ? withDirectives((openBlock(), createBlock(unref(Icon), {
|
|
151
|
+
key: 0,
|
|
152
|
+
icon: "carbon:trash-can",
|
|
153
|
+
class: "htw-flex-none htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
|
|
154
|
+
onClick: withModifiers(($event) => deletePreset(value), ["stop"])
|
|
155
|
+
}, null, 8, ["onClick"])), [
|
|
156
|
+
[_directive_tooltip, "Delete this preset"]
|
|
157
|
+
]) : createCommentVNode("", true)
|
|
158
|
+
])
|
|
159
|
+
]),
|
|
160
|
+
_: 1
|
|
161
|
+
}, 8, ["modelValue", "options"])
|
|
162
|
+
], 512),
|
|
163
|
+
withDirectives(createVNode(unref(Icon), {
|
|
164
|
+
icon: savedNotif.value ? "carbon:checkmark" : "carbon:save",
|
|
165
|
+
class: normalizeClass(["htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100", [
|
|
166
|
+
unref(canEdit) ? "htw-opacity-50 hover:htw-opacity-100" : "htw-opacity-25 htw-pointer-events-none"
|
|
167
|
+
]]),
|
|
168
|
+
onClick: _cache[7] || (_cache[7] = ($event) => savePreset())
|
|
169
|
+
}, null, 8, ["icon", "class"]), [
|
|
170
|
+
[_directive_tooltip, savedNotif.value ? "Saved!" : unref(canEdit) ? "Save to preset" : null]
|
|
171
|
+
]),
|
|
172
|
+
withDirectives(createVNode(unref(Icon), {
|
|
173
|
+
icon: "carbon:add-alt",
|
|
174
|
+
class: "htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
|
|
175
|
+
onClick: _cache[8] || (_cache[8] = ($event) => createPreset())
|
|
176
|
+
}, null, 512), [
|
|
177
|
+
[_directive_tooltip, "Create new preset"]
|
|
178
|
+
]),
|
|
179
|
+
withDirectives(createVNode(unref(Icon), {
|
|
180
|
+
icon: "carbon:reset",
|
|
181
|
+
class: "htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
|
|
182
|
+
onClick: _cache[9] || (_cache[9] = ($event) => resetState())
|
|
183
|
+
}, null, 512), [
|
|
184
|
+
[_directive_tooltip, "Reset to initial state"]
|
|
185
|
+
])
|
|
186
|
+
]);
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createElementVNode, defineComponent, openBlock, createElementBlock, createVNode, createBlock, withCtx, unref, createCommentVNode, Fragment, renderList } from "@histoire/vendors/vue";
|
|
2
|
+
import { Icon } from "@histoire/vendors/iconify";
|
|
3
|
+
import _sfc_main$2 from "../story/GenericRenderStory.js";
|
|
4
|
+
import BaseEmpty from "../base/BaseEmpty.js";
|
|
5
|
+
import _sfc_main$1 from "./StatePresets.js";
|
|
6
|
+
import _sfc_main$3 from "./ControlsComponentProps.js";
|
|
7
|
+
const _hoisted_1 = {
|
|
8
|
+
"data-test-id": "story-controls",
|
|
9
|
+
class: "htw-flex htw-flex-col htw-divide-y htw-divide-gray-100 dark:htw-divide-gray-750"
|
|
10
|
+
};
|
|
11
|
+
const _hoisted_2 = { class: "htw-h-9 htw-flex-none htw-px-2 htw-flex htw-items-center" };
|
|
12
|
+
const _hoisted_3 = /* @__PURE__ */ createElementVNode("span", null, "No controls available for this story", -1);
|
|
13
|
+
const _hoisted_4 = { key: 2 };
|
|
14
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
15
|
+
__name: "StoryControls",
|
|
16
|
+
props: {
|
|
17
|
+
variant: {
|
|
18
|
+
type: Object,
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
story: {
|
|
22
|
+
type: Object,
|
|
23
|
+
required: true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
setup(__props) {
|
|
27
|
+
return (_ctx, _cache) => {
|
|
28
|
+
var _a, _b, _c, _d;
|
|
29
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
30
|
+
createElementVNode("div", _hoisted_2, [
|
|
31
|
+
createVNode(_sfc_main$1, {
|
|
32
|
+
story: __props.story,
|
|
33
|
+
variant: __props.variant
|
|
34
|
+
}, null, 8, ["story", "variant"])
|
|
35
|
+
]),
|
|
36
|
+
__props.variant.slots().controls || __props.story.slots().controls ? (openBlock(), createBlock(_sfc_main$2, {
|
|
37
|
+
key: 0,
|
|
38
|
+
"slot-name": "controls",
|
|
39
|
+
variant: __props.variant,
|
|
40
|
+
story: __props.story,
|
|
41
|
+
class: "htw-flex-none"
|
|
42
|
+
}, null, 8, ["variant", "story"])) : !((_b = (_a = __props.variant.state) == null ? void 0 : _a._hPropDefs) == null ? void 0 : _b.length) ? (openBlock(), createBlock(BaseEmpty, { key: 1 }, {
|
|
43
|
+
default: withCtx(() => [
|
|
44
|
+
createVNode(unref(Icon), {
|
|
45
|
+
icon: "carbon:audio-console",
|
|
46
|
+
class: "htw-w-8 htw-h-8 htw-opacity-50 htw-mb-6"
|
|
47
|
+
}),
|
|
48
|
+
_hoisted_3
|
|
49
|
+
]),
|
|
50
|
+
_: 1
|
|
51
|
+
})) : createCommentVNode("", true),
|
|
52
|
+
((_d = (_c = __props.variant.state) == null ? void 0 : _c._hPropDefs) == null ? void 0 : _d.length) ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
53
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.variant.state._hPropDefs, (def, index) => {
|
|
54
|
+
return openBlock(), createBlock(_sfc_main$3, {
|
|
55
|
+
key: index,
|
|
56
|
+
variant: __props.variant,
|
|
57
|
+
definition: def,
|
|
58
|
+
class: "htw-flex-none htw-my-2"
|
|
59
|
+
}, null, 8, ["variant", "definition"]);
|
|
60
|
+
}), 128))
|
|
61
|
+
])) : createCommentVNode("", true)
|
|
62
|
+
]);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createTextVNode, ref, watchEffect, defineComponent, toRefs, openBlock, createElementBlock, unref, createBlock, withCtx, createVNode } from "@histoire/vendors/vue";
|
|
2
|
+
import { Icon } from "@histoire/vendors/iconify";
|
|
3
|
+
import BaseEmpty from "../base/BaseEmpty.js";
|
|
4
|
+
const _hoisted_1 = /* @__PURE__ */ createTextVNode(" No documentation available ");
|
|
5
|
+
const _hoisted_2 = ["innerHTML"];
|
|
6
|
+
function useStoryDoc(story) {
|
|
7
|
+
const renderedDoc = ref("");
|
|
8
|
+
watchEffect(async () => {
|
|
9
|
+
var _a;
|
|
10
|
+
let comp = (_a = story.value.file) == null ? void 0 : _a.component;
|
|
11
|
+
if (comp) {
|
|
12
|
+
if (comp.__asyncResolved) {
|
|
13
|
+
comp = comp.__asyncResolved;
|
|
14
|
+
} else if (comp.__asyncLoader) {
|
|
15
|
+
comp = await comp.__asyncLoader();
|
|
16
|
+
}
|
|
17
|
+
renderedDoc.value = comp.doc;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
renderedDoc
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const _sfc_main = defineComponent({
|
|
25
|
+
__name: "StoryDocs",
|
|
26
|
+
props: {
|
|
27
|
+
story: {
|
|
28
|
+
type: Object,
|
|
29
|
+
required: true
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
setup(__props) {
|
|
33
|
+
const props = __props;
|
|
34
|
+
const { story } = toRefs(props);
|
|
35
|
+
const { renderedDoc } = useStoryDoc(story);
|
|
36
|
+
return (_ctx, _cache) => {
|
|
37
|
+
return openBlock(), createElementBlock("div", null, [
|
|
38
|
+
!unref(renderedDoc) ? (openBlock(), createBlock(BaseEmpty, { key: 0 }, {
|
|
39
|
+
default: withCtx(() => [
|
|
40
|
+
createVNode(unref(Icon), {
|
|
41
|
+
icon: "carbon:document-unknown",
|
|
42
|
+
class: "htw-w-8 htw-h-8 htw-opacity-50 htw-mb-6"
|
|
43
|
+
}),
|
|
44
|
+
_hoisted_1
|
|
45
|
+
]),
|
|
46
|
+
_: 1
|
|
47
|
+
})) : (openBlock(), createElementBlock("div", {
|
|
48
|
+
key: 1,
|
|
49
|
+
class: "htw-prose dark:htw-prose-invert htw-p-4 htw-max-w-none",
|
|
50
|
+
"data-test-id": "story-docs",
|
|
51
|
+
innerHTML: unref(renderedDoc)
|
|
52
|
+
}, null, 8, _hoisted_2))
|
|
53
|
+
]);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
export { _sfc_main as default, useStoryDoc };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, withCtx, createElementVNode, normalizeClass, toDisplayString, createElementBlock, unref, createCommentVNode } from "@histoire/vendors/vue";
|
|
2
|
+
const _hoisted_1 = {
|
|
3
|
+
key: 0,
|
|
4
|
+
class: "htw-text-xs htw-opacity-50 htw-truncate"
|
|
5
|
+
};
|
|
6
|
+
const _hoisted_2 = { class: "htw-overflow-auto htw-max-w-[400px] htw-max-h-[400px]" };
|
|
7
|
+
const _hoisted_3 = { class: "htw-p-4" };
|
|
8
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
9
|
+
__name: "StoryEvent",
|
|
10
|
+
props: {
|
|
11
|
+
event: null
|
|
12
|
+
},
|
|
13
|
+
setup(__props) {
|
|
14
|
+
const props = __props;
|
|
15
|
+
const formattedArgument = computed(() => {
|
|
16
|
+
switch (typeof props.event.argument) {
|
|
17
|
+
case "string":
|
|
18
|
+
return `"${props.event.argument}"`;
|
|
19
|
+
case "object":
|
|
20
|
+
return `{ ${Object.keys(props.event.argument).map((key) => `${key}: ${props.event.argument[key]}`).join(", ")} }`;
|
|
21
|
+
default:
|
|
22
|
+
return props.event.argument;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return (_ctx, _cache) => {
|
|
26
|
+
const _component_VDropdown = resolveComponent("VDropdown");
|
|
27
|
+
return openBlock(), createBlock(_component_VDropdown, {
|
|
28
|
+
class: "htw-group",
|
|
29
|
+
placement: "right",
|
|
30
|
+
"data-test-id": "event-item"
|
|
31
|
+
}, {
|
|
32
|
+
default: withCtx(({ shown }) => [
|
|
33
|
+
createElementVNode("div", {
|
|
34
|
+
class: normalizeClass(["group-hover:htw-bg-primary-100 dark:group-hover:htw-bg-primary-700 htw-cursor-pointer htw-py-2 htw-px-4 htw-flex htw-items-baseline htw-gap-1 htw-leading-normal", [
|
|
35
|
+
shown ? "htw-bg-primary-50 dark:htw-bg-primary-600" : "group-odd:htw-bg-gray-100/50 dark:group-odd:htw-bg-gray-750/40"
|
|
36
|
+
]])
|
|
37
|
+
}, [
|
|
38
|
+
createElementVNode("span", {
|
|
39
|
+
class: normalizeClass({
|
|
40
|
+
"htw-text-primary-500": shown
|
|
41
|
+
})
|
|
42
|
+
}, toDisplayString(__props.event.name), 3),
|
|
43
|
+
__props.event.argument ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(unref(formattedArgument)), 1)) : createCommentVNode("", true)
|
|
44
|
+
], 2)
|
|
45
|
+
]),
|
|
46
|
+
popper: withCtx(() => [
|
|
47
|
+
createElementVNode("div", _hoisted_2, [
|
|
48
|
+
createElementVNode("pre", _hoisted_3, toDisplayString(__props.event.argument), 1)
|
|
49
|
+
])
|
|
50
|
+
]),
|
|
51
|
+
_: 1
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createTextVNode, defineComponent, computed, onMounted, watch, nextTick, ref, openBlock, createElementBlock, unref, createBlock, withCtx, createVNode, Fragment, renderList } from "@histoire/vendors/vue";
|
|
2
|
+
import { Icon } from "@histoire/vendors/iconify";
|
|
3
|
+
import BaseEmpty from "../base/BaseEmpty.js";
|
|
4
|
+
import { useEventsStore } from "../../stores/events.js";
|
|
5
|
+
import _sfc_main$1 from "./StoryEvent.js";
|
|
6
|
+
const _hoisted_1 = /* @__PURE__ */ createTextVNode(" No event fired ");
|
|
7
|
+
const _hoisted_2 = { key: 1 };
|
|
8
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
9
|
+
__name: "StoryEvents",
|
|
10
|
+
setup(__props) {
|
|
11
|
+
const eventsStore = useEventsStore();
|
|
12
|
+
const hasEvents = computed(() => eventsStore.events.length);
|
|
13
|
+
onMounted(resetUnseen);
|
|
14
|
+
watch(() => eventsStore.unseen, resetUnseen);
|
|
15
|
+
async function resetUnseen() {
|
|
16
|
+
if (eventsStore.unseen > 0) {
|
|
17
|
+
eventsStore.unseen = 0;
|
|
18
|
+
}
|
|
19
|
+
await nextTick();
|
|
20
|
+
eventsElement.value.scrollTo({ top: eventsElement.value.scrollHeight });
|
|
21
|
+
}
|
|
22
|
+
const eventsElement = ref();
|
|
23
|
+
return (_ctx, _cache) => {
|
|
24
|
+
return openBlock(), createElementBlock("div", {
|
|
25
|
+
ref_key: "eventsElement",
|
|
26
|
+
ref: eventsElement
|
|
27
|
+
}, [
|
|
28
|
+
!unref(hasEvents) ? (openBlock(), createBlock(BaseEmpty, { key: 0 }, {
|
|
29
|
+
default: withCtx(() => [
|
|
30
|
+
createVNode(unref(Icon), {
|
|
31
|
+
icon: "carbon:event-schedule",
|
|
32
|
+
class: "htw-w-8 htw-h-8 htw-opacity-50 htw-mb-6"
|
|
33
|
+
}),
|
|
34
|
+
_hoisted_1
|
|
35
|
+
]),
|
|
36
|
+
_: 1
|
|
37
|
+
})) : (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
38
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(eventsStore).events, (event, key) => {
|
|
39
|
+
return openBlock(), createBlock(_sfc_main$1, {
|
|
40
|
+
key,
|
|
41
|
+
event
|
|
42
|
+
}, null, 8, ["event"]);
|
|
43
|
+
}), 128))
|
|
44
|
+
]))
|
|
45
|
+
], 512);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createElementVNode, defineComponent, computed, unref, openBlock, createBlock, withCtx, createVNode, resolveDynamicComponent } from "@histoire/vendors/vue";
|
|
2
|
+
import { useRoute } from "@histoire/vendors/vue-router";
|
|
3
|
+
import { useStoryStore } from "../../stores/story.js";
|
|
4
|
+
import BaseSplitPane from "../base/BaseSplitPane.js";
|
|
5
|
+
import BaseEmpty from "../base/BaseEmpty.js";
|
|
6
|
+
import _sfc_main$1 from "./StoryControls.js";
|
|
7
|
+
import _sfc_main$3 from "./StoryDocs.js";
|
|
8
|
+
import _sfc_main$2 from "./StoryEvents.js";
|
|
9
|
+
import StorySourceCode from "./StorySourceCode.js";
|
|
10
|
+
import _sfc_main$4 from "./PaneTabs.js";
|
|
11
|
+
const _hoisted_1 = /* @__PURE__ */ createElementVNode("span", null, "Select a variant", -1);
|
|
12
|
+
const _hoisted_2 = /* @__PURE__ */ createElementVNode("span", null, "Loading...", -1);
|
|
13
|
+
const _hoisted_3 = { class: "htw-flex htw-flex-col htw-h-full" };
|
|
14
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
15
|
+
__name: "StorySidePanel",
|
|
16
|
+
setup(__props) {
|
|
17
|
+
const storyStore = useStoryStore();
|
|
18
|
+
const route = useRoute();
|
|
19
|
+
const panelContentComponent = computed(() => {
|
|
20
|
+
switch (route.query.tab) {
|
|
21
|
+
case "docs":
|
|
22
|
+
return _sfc_main$3;
|
|
23
|
+
case "events":
|
|
24
|
+
return _sfc_main$2;
|
|
25
|
+
default:
|
|
26
|
+
return _sfc_main$1;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return (_ctx, _cache) => {
|
|
30
|
+
return !unref(storyStore).currentVariant ? (openBlock(), createBlock(BaseEmpty, { key: 0 }, {
|
|
31
|
+
default: withCtx(() => [
|
|
32
|
+
_hoisted_1
|
|
33
|
+
]),
|
|
34
|
+
_: 1
|
|
35
|
+
})) : !unref(storyStore).currentVariant.configReady || !unref(storyStore).currentVariant.previewReady ? (openBlock(), createBlock(BaseEmpty, { key: 1 }, {
|
|
36
|
+
default: withCtx(() => [
|
|
37
|
+
_hoisted_2
|
|
38
|
+
]),
|
|
39
|
+
_: 1
|
|
40
|
+
})) : (openBlock(), createBlock(BaseSplitPane, {
|
|
41
|
+
key: 2,
|
|
42
|
+
"save-id": "story-sidepane",
|
|
43
|
+
orientation: "portrait",
|
|
44
|
+
class: "htw-h-full",
|
|
45
|
+
"data-test-id": "story-side-panel"
|
|
46
|
+
}, {
|
|
47
|
+
first: withCtx(() => [
|
|
48
|
+
createElementVNode("div", _hoisted_3, [
|
|
49
|
+
createVNode(_sfc_main$4, {
|
|
50
|
+
story: unref(storyStore).currentStory,
|
|
51
|
+
variant: unref(storyStore).currentVariant
|
|
52
|
+
}, null, 8, ["story", "variant"]),
|
|
53
|
+
(openBlock(), createBlock(resolveDynamicComponent(unref(panelContentComponent)), {
|
|
54
|
+
story: unref(storyStore).currentStory,
|
|
55
|
+
variant: unref(storyStore).currentVariant,
|
|
56
|
+
class: "htw-h-full htw-overflow-auto"
|
|
57
|
+
}, null, 8, ["story", "variant"]))
|
|
58
|
+
])
|
|
59
|
+
]),
|
|
60
|
+
last: withCtx(() => [
|
|
61
|
+
createVNode(StorySourceCode, {
|
|
62
|
+
story: unref(storyStore).currentStory,
|
|
63
|
+
variant: unref(storyStore).currentVariant,
|
|
64
|
+
class: "htw-h-full"
|
|
65
|
+
}, null, 8, ["story", "variant"])
|
|
66
|
+
]),
|
|
67
|
+
_: 1
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { pushScopeId, popScopeId, createElementVNode, defineComponent, ref, watchEffect, markRaw, shallowRef, onMounted, watch, computed, openBlock, createElementBlock, createVNode, unref, createCommentVNode, toDisplayString } from "@histoire/vendors/vue";
|
|
2
|
+
import { setCDN, getHighlighter } from "shiki";
|
|
3
|
+
import { HstCopyIcon } from "@histoire/controls";
|
|
4
|
+
import { unindent } from "@histoire/shared";
|
|
5
|
+
import { clientSupportPlugins } from "virtual:$histoire-support-plugins-client";
|
|
6
|
+
import { isDark } from "../../util/dark.js";
|
|
7
|
+
import "./StorySourceCode.vue_vue_type_style_index_0_scoped_true_lang.js";
|
|
8
|
+
import _export_sfc from "../../_virtual/plugin-vue_export-helper.js";
|
|
9
|
+
const _withScopeId = (n) => (pushScopeId("data-v-5ab4829f"), n = n(), popScopeId(), n);
|
|
10
|
+
const _hoisted_1 = { class: "htw-bg-gray-100 dark:htw-bg-gray-800 htw-h-full htw-overflow-hidden htw-flex htw-flex-col" };
|
|
11
|
+
const _hoisted_2 = {
|
|
12
|
+
key: 0,
|
|
13
|
+
class: "htw-h-10 htw-flex-none htw-border-b htw-border-solid htw-border-gray-150 dark:htw-border-gray-850 htw-px-4 htw-flex htw-items-center"
|
|
14
|
+
};
|
|
15
|
+
const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "htw-text-gray-900 dark:htw-text-gray-100" }, " Source ", -1));
|
|
16
|
+
const _hoisted_4 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "htw-flex-1" }, null, -1));
|
|
17
|
+
const _hoisted_5 = {
|
|
18
|
+
key: 1,
|
|
19
|
+
class: "htw-text-red-500 htw-h-full htw-p-2 htw-overflow-auto htw-font-mono htw-text-sm"
|
|
20
|
+
};
|
|
21
|
+
const _hoisted_6 = ["value"];
|
|
22
|
+
const _hoisted_7 = {
|
|
23
|
+
key: 3,
|
|
24
|
+
class: "htw-w-full htw-h-full htw-overflow-auto",
|
|
25
|
+
"data-test-id": "story-source-code"
|
|
26
|
+
};
|
|
27
|
+
const _hoisted_8 = ["innerHTML"];
|
|
28
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
29
|
+
__name: "StorySourceCode",
|
|
30
|
+
props: {
|
|
31
|
+
story: null,
|
|
32
|
+
variant: null
|
|
33
|
+
},
|
|
34
|
+
setup(__props) {
|
|
35
|
+
const props = __props;
|
|
36
|
+
const generateSourceCodeFn = ref(null);
|
|
37
|
+
watchEffect(async () => {
|
|
38
|
+
var _a;
|
|
39
|
+
const clientPlugin = clientSupportPlugins[(_a = props.story.file) == null ? void 0 : _a.supportPluginId];
|
|
40
|
+
if (clientPlugin) {
|
|
41
|
+
const pluginModule = await clientPlugin();
|
|
42
|
+
generateSourceCodeFn.value = markRaw(pluginModule.generateSourceCode);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const sourceCode = ref("");
|
|
46
|
+
const highlighter = shallowRef();
|
|
47
|
+
const error = ref(null);
|
|
48
|
+
onMounted(async () => {
|
|
49
|
+
setCDN("https://unpkg.com/shiki@0.10.1/");
|
|
50
|
+
highlighter.value = await getHighlighter({
|
|
51
|
+
langs: [
|
|
52
|
+
"html",
|
|
53
|
+
"jsx"
|
|
54
|
+
],
|
|
55
|
+
themes: [
|
|
56
|
+
"github-light",
|
|
57
|
+
"github-dark"
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
watch(() => [props.variant, generateSourceCodeFn.value], async () => {
|
|
62
|
+
var _a, _b, _c, _d;
|
|
63
|
+
if (!generateSourceCodeFn.value)
|
|
64
|
+
return;
|
|
65
|
+
error.value = null;
|
|
66
|
+
try {
|
|
67
|
+
if (props.variant.source) {
|
|
68
|
+
sourceCode.value = props.variant.source;
|
|
69
|
+
} else if ((_b = (_a = props.variant).slots) == null ? void 0 : _b.call(_a).source) {
|
|
70
|
+
const source = (_d = (_c = props.variant).slots) == null ? void 0 : _d.call(_c).source()[0].children;
|
|
71
|
+
if (source) {
|
|
72
|
+
sourceCode.value = await unindent(source);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
sourceCode.value = await generateSourceCodeFn.value(props.variant);
|
|
76
|
+
}
|
|
77
|
+
} catch (e) {
|
|
78
|
+
console.error(e);
|
|
79
|
+
error.value = e.message;
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
deep: true,
|
|
83
|
+
immediate: true
|
|
84
|
+
});
|
|
85
|
+
const sourceHtml = computed(() => {
|
|
86
|
+
var _a;
|
|
87
|
+
return (_a = highlighter.value) == null ? void 0 : _a.codeToHtml(sourceCode.value, {
|
|
88
|
+
lang: "html",
|
|
89
|
+
theme: isDark.value ? "github-dark" : "github-light"
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
return (_ctx, _cache) => {
|
|
93
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
94
|
+
!error.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
95
|
+
_hoisted_3,
|
|
96
|
+
_hoisted_4,
|
|
97
|
+
createVNode(unref(HstCopyIcon), {
|
|
98
|
+
content: sourceCode.value,
|
|
99
|
+
class: "htw-flex-none"
|
|
100
|
+
}, null, 8, ["content"])
|
|
101
|
+
])) : createCommentVNode("", true),
|
|
102
|
+
error.value ? (openBlock(), createElementBlock("div", _hoisted_5, " Error: " + toDisplayString(error.value), 1)) : !unref(sourceHtml) ? (openBlock(), createElementBlock("textarea", {
|
|
103
|
+
key: 2,
|
|
104
|
+
class: "__histoire-code-placeholder htw-w-full htw-h-full htw-p-4 htw-outline-none htw-bg-transparent htw-resize-none htw-m-0",
|
|
105
|
+
value: sourceCode.value,
|
|
106
|
+
readonly: "",
|
|
107
|
+
"data-test-id": "story-source-code"
|
|
108
|
+
}, null, 8, _hoisted_6)) : (openBlock(), createElementBlock("div", _hoisted_7, [
|
|
109
|
+
createElementVNode("div", {
|
|
110
|
+
class: "__histoire-code htw-p-4 htw-w-fit",
|
|
111
|
+
innerHTML: unref(sourceHtml)
|
|
112
|
+
}, null, 8, _hoisted_8)
|
|
113
|
+
]))
|
|
114
|
+
]);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
var StorySourceCode = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5ab4829f"]]);
|
|
119
|
+
export { StorySourceCode as default };
|