histoire 0.7.1 → 0.7.4
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/client.d.ts +1 -1
- package/dist/bundled/MobileOverlay.js +2 -2
- package/dist/bundled/StoryView.js +22 -19
- package/dist/bundled/dark.js +4 -0
- package/dist/bundled/index.js +0 -1
- package/dist/bundled/index2.js +6 -6
- package/dist/bundled/mapping.js +78 -0
- package/dist/bundled/sandbox.js +7 -6
- package/dist/bundled/state.js +13 -44
- package/dist/bundled/style.css +17 -17
- package/dist/client/app/App.vue +2 -2
- package/dist/client/app/components/base/BaseSplitPane.vue +6 -6
- package/dist/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
- package/dist/client/app/components/panel/ControlsComponentProps.vue +2 -1
- package/dist/client/app/components/panel/StatePresets.vue +2 -1
- package/dist/client/app/components/panel/StoryControls.vue +1 -1
- package/dist/client/app/components/panel/StorySourceCode.vue +2 -2
- package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
- package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
- package/dist/client/app/components/story/StoryVariantSingleView.vue +1 -1
- package/dist/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
- package/dist/client/app/components/tree/StoryGroup.vue +1 -1
- package/dist/client/app/index.js +0 -2
- package/dist/client/app/sandbox.js +4 -5
- package/dist/client/app/style/main.pcss +3 -3
- package/dist/client/app/style/sandbox.css +1 -1
- package/dist/client/app/types.d.ts +1 -52
- package/dist/client/app/util/mapping.d.ts +1 -1
- package/dist/client/app/util/mapping.js +50 -36
- package/dist/client/app/{components/sandbox/lib.d.ts → util/sandbox.d.ts} +1 -1
- package/dist/client/app/{components/sandbox/lib.js → util/sandbox.js} +1 -1
- package/dist/client/app/util/state.d.ts +1 -5
- package/dist/client/app/util/state.js +12 -44
- package/dist/node/collect/index.d.ts +2 -2
- package/dist/node/collect/index.js +3 -0
- package/dist/node/collect/run.d.ts +2 -0
- package/dist/{client/server/index.js → node/collect/run.js} +1 -1
- package/dist/node/collect/worker.d.ts +3 -3
- package/dist/node/collect/worker.js +4 -1
- package/dist/node/config.d.ts +3 -3
- package/dist/node/context.d.ts +2 -2
- package/dist/node/plugin.d.ts +3 -3
- package/dist/node/stories.d.ts +4 -4
- package/dist/node/tree.d.ts +3 -22
- package/dist/style.css +80 -4
- package/package.json +4 -2
- package/src/client/app/App.vue +2 -2
- package/src/client/app/components/base/BaseSplitPane.vue +6 -6
- package/src/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
- package/src/client/app/components/panel/ControlsComponentProps.vue +2 -1
- package/src/client/app/components/panel/StatePresets.vue +2 -1
- package/src/client/app/components/panel/StoryControls.vue +1 -1
- package/src/client/app/components/panel/StorySourceCode.vue +2 -2
- package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
- package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
- package/src/client/app/components/story/StoryVariantSingleView.vue +1 -1
- package/src/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
- package/src/client/app/components/tree/StoryGroup.vue +1 -1
- package/src/client/app/index.ts +0 -2
- package/src/client/app/sandbox.ts +4 -5
- package/src/client/app/style/main.pcss +3 -3
- package/src/client/app/style/sandbox.css +1 -1
- package/src/client/app/types.ts +6 -57
- package/src/client/app/util/mapping.ts +47 -34
- package/src/client/app/{components/sandbox/lib.ts → util/sandbox.ts} +2 -2
- package/src/client/app/util/state.ts +15 -44
- package/src/node/collect/index.ts +5 -2
- package/src/node/collect/run.ts +13 -0
- package/src/node/collect/worker.ts +8 -6
- package/src/node/config.ts +3 -3
- package/src/node/context.ts +2 -2
- package/src/node/plugin.ts +2 -2
- package/src/node/server.ts +2 -2
- package/src/node/stories.ts +4 -4
- package/src/node/tree.ts +7 -31
- package/tailwind.config.cjs +1 -1
- package/vite.config.ts +12 -7
- package/dist/bundled/SandboxVue3.js +0 -706
- package/dist/bundled/global-components.js +0 -213
- package/dist/client/app/codegen/const.d.ts +0 -1
- package/dist/client/app/codegen/const.js +0 -3
- package/dist/client/app/codegen/serialize-js.d.ts +0 -1
- package/dist/client/app/codegen/serialize-js.js +0 -113
- package/dist/client/app/codegen/util.d.ts +0 -10
- package/dist/client/app/codegen/util.js +0 -70
- package/dist/client/app/codegen/vue3.d.ts +0 -4
- package/dist/client/app/codegen/vue3.js +0 -357
- package/dist/client/app/components/exposed/Story.vue +0 -106
- package/dist/client/app/components/exposed/Variant.vue +0 -78
- package/dist/client/app/components/sandbox/RouterLinkStub.d.ts +0 -21
- package/dist/client/app/components/sandbox/RouterLinkStub.js +0 -43
- package/dist/client/app/components/sandbox/SandboxVue3.vue +0 -185
- package/dist/client/app/global-components.d.ts +0 -2
- package/dist/client/app/global-components.js +0 -10
- package/dist/client/server/index.d.ts +0 -7
- package/dist/client/server/vue3/Story.vue +0 -120
- package/dist/client/server/vue3/Variant.vue +0 -52
- package/dist/client/server/vue3/run.d.ts +0 -2
- package/dist/client/server/vue3/run.js +0 -45
- package/dist/node/types.d.ts +0 -50
- package/dist/node/types.js +0 -1
- package/src/client/app/codegen/const.ts +0 -3
- package/src/client/app/codegen/serialize-js.ts +0 -119
- package/src/client/app/codegen/util.ts +0 -79
- package/src/client/app/codegen/vue3.ts +0 -361
- package/src/client/app/components/exposed/Story.vue +0 -106
- package/src/client/app/components/exposed/Variant.vue +0 -78
- package/src/client/app/components/sandbox/RouterLinkStub.ts +0 -49
- package/src/client/app/components/sandbox/SandboxVue3.vue +0 -185
- package/src/client/app/global-components.ts +0 -13
- package/src/client/server/index.ts +0 -19
- package/src/client/server/vue3/Story.vue +0 -120
- package/src/client/server/vue3/Variant.vue +0 -52
- package/src/client/server/vue3/run.ts +0 -55
- package/src/components.d.ts +0 -143
- package/src/node/types.ts +0 -53
package/client.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ function useScrollOnActive(active, el) {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
var BaseSplitPane_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
85
|
-
const _withScopeId = (n) => (pushScopeId("data-v-
|
|
85
|
+
const _withScopeId = (n) => (pushScopeId("data-v-4cd3cd6c"), n = n(), popScopeId(), n);
|
|
86
86
|
const _hoisted_1$1 = ["onMousedown"];
|
|
87
87
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
88
88
|
name: "BaseSplitPane",
|
|
@@ -261,7 +261,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
261
261
|
};
|
|
262
262
|
}
|
|
263
263
|
});
|
|
264
|
-
var BaseSplitPane = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
264
|
+
var BaseSplitPane = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4cd3cd6c"]]);
|
|
265
265
|
const isMobile = useMediaQuery("(max-width: 640px)");
|
|
266
266
|
const _hoisted_1 = {
|
|
267
267
|
key: 0,
|
|
@@ -21,18 +21,20 @@ import { computed, pushScopeId, popScopeId, defineComponent, useCssVars, unref,
|
|
|
21
21
|
import { useRoute, useRouter } from "vue-router";
|
|
22
22
|
import { Icon } from "@iconify/vue";
|
|
23
23
|
import { u as useStoryStore, b as base } from "./story.js";
|
|
24
|
-
import { u as useScrollOnActive, B as BaseListItemLink, _ as _export_sfc, i as isMobile, b as BaseSplitPane, a as _sfc_main$
|
|
24
|
+
import { u as useScrollOnActive, B as BaseListItemLink, _ as _export_sfc, i as isMobile, b as BaseSplitPane, a as _sfc_main$v } from "./MobileOverlay.js";
|
|
25
25
|
import { B as BaseEmpty } from "./BaseEmpty.js";
|
|
26
26
|
import { useResizeObserver, useStorage, useEventListener, useTimeoutFn, onClickOutside } from "@vueuse/core";
|
|
27
|
-
import {
|
|
27
|
+
import { SandboxVue3, generateSourceCode } from "@histoire/plugin-vue/client";
|
|
28
28
|
import { defineStore } from "pinia";
|
|
29
29
|
import { h as histoireConfig } from "./config.js";
|
|
30
|
+
import { applyStateToVariant, clone, omit, unindent } from "@histoire/shared";
|
|
30
31
|
import { S as STATE_SYNC, a as SANDBOX_READY, E as EVENT_SEND, P as PREVIEW_SETTINGS_SYNC } from "./const.js";
|
|
31
32
|
import { useEventsStore } from "./events.js";
|
|
32
|
-
import {
|
|
33
|
+
import { t as toRawDeep } from "./state.js";
|
|
33
34
|
import { Dropdown } from "floating-vue";
|
|
35
|
+
import { HstTextarea, HstCheckbox, HstNumber, HstText, HstCopyIcon } from "@histoire/controls";
|
|
34
36
|
import { setCDN, getHighlighter } from "shiki";
|
|
35
|
-
import {
|
|
37
|
+
import { i as isDark } from "./dark.js";
|
|
36
38
|
function useCurrentVariantRoute(variant) {
|
|
37
39
|
const route = useRoute();
|
|
38
40
|
const isActive = computed(() => route.query.variantId === variant.value.id);
|
|
@@ -98,7 +100,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
98
100
|
});
|
|
99
101
|
var StoryVariantListItem = /* @__PURE__ */ _export_sfc(_sfc_main$u, [["__scopeId", "data-v-2cdc2ac0"]]);
|
|
100
102
|
var StoryVariantGridItem_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
101
|
-
const _withScopeId$6 = (n) => (pushScopeId("data-v-
|
|
103
|
+
const _withScopeId$6 = (n) => (pushScopeId("data-v-265ac8e3"), n = n(), popScopeId(), n);
|
|
102
104
|
const _hoisted_1$q = { class: "htw-flex-none htw-flex htw-items-center" };
|
|
103
105
|
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
104
106
|
name: "StoryVariantGridItem",
|
|
@@ -118,7 +120,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
118
120
|
setup(__props, { emit }) {
|
|
119
121
|
const props = __props;
|
|
120
122
|
useCssVars((_ctx) => ({
|
|
121
|
-
"
|
|
123
|
+
"7d3aedf8": unref(variant).iconColor
|
|
122
124
|
}));
|
|
123
125
|
const { variant } = toRefs(props);
|
|
124
126
|
const { isActive, targetRoute } = useCurrentVariantRoute(variant);
|
|
@@ -183,7 +185,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
183
185
|
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => selectVariant(), ["stop", "prevent"])),
|
|
184
186
|
onKeyup: _cache[1] || (_cache[1] = ($event) => selectVariant())
|
|
185
187
|
}, [
|
|
186
|
-
createVNode(
|
|
188
|
+
createVNode(unref(SandboxVue3), {
|
|
187
189
|
variant: unref(variant),
|
|
188
190
|
story: __props.story,
|
|
189
191
|
onReady
|
|
@@ -193,7 +195,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
193
195
|
};
|
|
194
196
|
}
|
|
195
197
|
});
|
|
196
|
-
var StoryVariantGridItem = /* @__PURE__ */ _export_sfc(_sfc_main$t, [["__scopeId", "data-v-
|
|
198
|
+
var StoryVariantGridItem = /* @__PURE__ */ _export_sfc(_sfc_main$t, [["__scopeId", "data-v-265ac8e3"]]);
|
|
197
199
|
const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
198
200
|
name: "StoryVariantGrid",
|
|
199
201
|
setup(__props) {
|
|
@@ -868,7 +870,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
868
870
|
height: finalHeight ? `${finalHeight}px` : "100%"
|
|
869
871
|
} : { width: "100%", height: "100%" })
|
|
870
872
|
}, [
|
|
871
|
-
(openBlock(), createBlock(
|
|
873
|
+
(openBlock(), createBlock(unref(SandboxVue3), {
|
|
872
874
|
key: `${__props.story.id}-${__props.variant.id}`,
|
|
873
875
|
variant: __props.variant,
|
|
874
876
|
story: __props.story,
|
|
@@ -1007,6 +1009,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
1007
1009
|
},
|
|
1008
1010
|
setup(__props) {
|
|
1009
1011
|
return (_ctx, _cache) => {
|
|
1012
|
+
var _a;
|
|
1010
1013
|
return openBlock(), createElementBlock("div", _hoisted_1$g, [
|
|
1011
1014
|
!unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2$f, [
|
|
1012
1015
|
createVNode(_sfc_main$r, { variant: __props.variant }, null, 8, ["variant"]),
|
|
@@ -1017,7 +1020,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
1017
1020
|
story: __props.story
|
|
1018
1021
|
}, null, 8, ["variant", "story"])
|
|
1019
1022
|
])) : createCommentVNode("", true),
|
|
1020
|
-
__props.story.layout.iframe === false ? (openBlock(), createBlock(_sfc_main$j, {
|
|
1023
|
+
((_a = __props.story.layout) == null ? void 0 : _a.iframe) === false ? (openBlock(), createBlock(_sfc_main$j, {
|
|
1021
1024
|
key: 1,
|
|
1022
1025
|
story: __props.story,
|
|
1023
1026
|
variant: __props.variant
|
|
@@ -1167,7 +1170,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
1167
1170
|
onOpenVariantMenu: _cache[0] || (_cache[0] = ($event) => isMenuOpened.value = true)
|
|
1168
1171
|
})) : createCommentVNode("", true)
|
|
1169
1172
|
]),
|
|
1170
|
-
createVNode(_sfc_main$
|
|
1173
|
+
createVNode(_sfc_main$v, {
|
|
1171
1174
|
title: "Select a variant",
|
|
1172
1175
|
opened: isMenuOpened.value,
|
|
1173
1176
|
onClose: closeMenu
|
|
@@ -1442,17 +1445,17 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
1442
1445
|
var _a;
|
|
1443
1446
|
switch ((_a = props.definition.types) == null ? void 0 : _a[0]) {
|
|
1444
1447
|
case "string":
|
|
1445
|
-
return
|
|
1448
|
+
return HstText;
|
|
1446
1449
|
case "number":
|
|
1447
|
-
return
|
|
1450
|
+
return HstNumber;
|
|
1448
1451
|
case "boolean":
|
|
1449
|
-
return
|
|
1452
|
+
return HstCheckbox;
|
|
1450
1453
|
case "object":
|
|
1451
1454
|
default:
|
|
1452
|
-
return
|
|
1455
|
+
return HstTextarea;
|
|
1453
1456
|
}
|
|
1454
1457
|
});
|
|
1455
|
-
const isJSON = computed(() => comp.value ===
|
|
1458
|
+
const isJSON = computed(() => comp.value === HstTextarea);
|
|
1456
1459
|
const invalidValue = ref("");
|
|
1457
1460
|
const model = computed({
|
|
1458
1461
|
get: () => {
|
|
@@ -1590,7 +1593,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
1590
1593
|
variant: __props.variant
|
|
1591
1594
|
}, null, 8, ["story", "variant"])
|
|
1592
1595
|
]),
|
|
1593
|
-
__props.variant.slots().controls || __props.story.slots().controls ? (openBlock(), createBlock(
|
|
1596
|
+
__props.variant.slots().controls || __props.story.slots().controls ? (openBlock(), createBlock(unref(SandboxVue3), {
|
|
1594
1597
|
key: 0,
|
|
1595
1598
|
"slot-name": "controls",
|
|
1596
1599
|
variant: __props.variant,
|
|
@@ -1762,7 +1765,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
1762
1765
|
}
|
|
1763
1766
|
});
|
|
1764
1767
|
var StorySourceCode_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
1765
|
-
const _withScopeId = (n) => (pushScopeId("data-v-
|
|
1768
|
+
const _withScopeId = (n) => (pushScopeId("data-v-8b318638"), n = n(), popScopeId(), n);
|
|
1766
1769
|
const _hoisted_1$6 = { class: "htw-bg-gray-100 dark:htw-bg-gray-800 htw-h-full htw-overflow-hidden htw-flex htw-flex-col" };
|
|
1767
1770
|
const _hoisted_2$6 = {
|
|
1768
1771
|
key: 0,
|
|
@@ -1862,7 +1865,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
1862
1865
|
};
|
|
1863
1866
|
}
|
|
1864
1867
|
});
|
|
1865
|
-
var StorySourceCode = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-
|
|
1868
|
+
var StorySourceCode = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-8b318638"]]);
|
|
1866
1869
|
const _sfc_main$5 = defineComponent({
|
|
1867
1870
|
inheritAttrs: false,
|
|
1868
1871
|
props: {
|
package/dist/bundled/index.js
CHANGED
package/dist/bundled/index2.js
CHANGED
|
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import "$histoire-theme";
|
|
21
|
-
import { pushScopeId, popScopeId, defineComponent, useCssVars, unref, computed, ref, openBlock, createElementBlock, createVNode, withCtx, createElementVNode, normalizeClass, toDisplayString, createCommentVNode, watch, resolveComponent, withKeys, Fragment, renderList, createBlock, isRef, resolveDirective, withDirectives, createTextVNode, defineAsyncComponent, vShow, reactive, Transition, normalizeStyle, onMounted,
|
|
21
|
+
import { pushScopeId, popScopeId, defineComponent, useCssVars, unref, computed, ref, openBlock, createElementBlock, createVNode, withCtx, createElementVNode, normalizeClass, toDisplayString, createCommentVNode, watch, resolveComponent, withKeys, Fragment, renderList, createBlock, isRef, resolveDirective, withDirectives, createTextVNode, defineAsyncComponent, vShow, reactive, Transition, normalizeStyle, onMounted, createApp } from "vue";
|
|
22
22
|
import { defineStore, createPinia } from "pinia";
|
|
23
23
|
import FloatingVue from "floating-vue";
|
|
24
24
|
import { files, tree, onUpdate } from "$histoire-stories";
|
|
@@ -27,9 +27,10 @@ import { Icon } from "@iconify/vue";
|
|
|
27
27
|
import { useRoute } from "vue-router";
|
|
28
28
|
import { useStorage, useEventListener, useTitle } from "@vueuse/core";
|
|
29
29
|
import { u as useStoryStore, r as router } from "./story.js";
|
|
30
|
-
import { i as isDark, t as toggleDark } from "./
|
|
30
|
+
import { i as isDark, t as toggleDark } from "./dark.js";
|
|
31
31
|
import { h as histoireConfig, c as customLogos } from "./config.js";
|
|
32
|
-
import { m as mapFile
|
|
32
|
+
import { m as mapFile } from "./mapping.js";
|
|
33
|
+
import { MountStoryVue3 } from "@histoire/plugin-vue/client";
|
|
33
34
|
var StoryListItem_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
34
35
|
const _withScopeId$2 = (n) => (pushScopeId("data-v-3bb05a26"), n = n(), popScopeId(), n);
|
|
35
36
|
const _hoisted_1$a = { class: "bind-tree-margin htw-flex htw-items-center htw-gap-2 htw-pl-4 htw-min-w-0" };
|
|
@@ -756,9 +757,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
756
757
|
const _component_RouterView = resolveComponent("RouterView");
|
|
757
758
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
758
759
|
unref(storyStore).currentStory ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
759
|
-
(
|
|
760
|
+
createVNode(unref(MountStoryVue3), {
|
|
760
761
|
story: unref(storyStore).currentStory
|
|
761
|
-
}, null, 8, ["story"])
|
|
762
|
+
}, null, 8, ["story"])
|
|
762
763
|
])) : createCommentVNode("", true),
|
|
763
764
|
createElementVNode("div", {
|
|
764
765
|
class: "htw-h-screen htw-bg-white dark:htw-bg-gray-700 dark:htw-text-gray-100",
|
|
@@ -834,7 +835,6 @@ function mountMainApp() {
|
|
|
834
835
|
}
|
|
835
836
|
});
|
|
836
837
|
app.use(router);
|
|
837
|
-
registerGlobalComponents(app);
|
|
838
838
|
app.mount("#app");
|
|
839
839
|
if (import.meta.hot) {
|
|
840
840
|
import.meta.hot.send("histoire:mount", {});
|
|
@@ -0,0 +1,78 @@
|
|
|
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 { markRaw } from "vue";
|
|
21
|
+
const copiedFromExistingVariant = [
|
|
22
|
+
"state",
|
|
23
|
+
"slots",
|
|
24
|
+
"initState",
|
|
25
|
+
"source",
|
|
26
|
+
"responsiveDisabled",
|
|
27
|
+
"setupApp",
|
|
28
|
+
"configReady",
|
|
29
|
+
"previewReady"
|
|
30
|
+
];
|
|
31
|
+
function mapFile(file, existingFile) {
|
|
32
|
+
let result;
|
|
33
|
+
if (existingFile) {
|
|
34
|
+
result = existingFile;
|
|
35
|
+
for (const key in file) {
|
|
36
|
+
if (key === "story") {
|
|
37
|
+
Object.assign(result.story, __spreadProps(__spreadValues({}, file.story), {
|
|
38
|
+
file: markRaw(result),
|
|
39
|
+
variants: file.story.variants.map((v) => mapVariant(v, existingFile.story.variants.find((item) => item.id === v.id)))
|
|
40
|
+
}));
|
|
41
|
+
} else if (key !== "component") {
|
|
42
|
+
result[key] = file[key];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
result = __spreadProps(__spreadValues({}, file), {
|
|
47
|
+
component: markRaw(file.component),
|
|
48
|
+
story: __spreadProps(__spreadValues({}, file.story), {
|
|
49
|
+
title: file.story.title,
|
|
50
|
+
file: markRaw(file),
|
|
51
|
+
variants: file.story.variants.map((v) => mapVariant(v)),
|
|
52
|
+
slots: () => ({})
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
function mapVariant(variant, existingVariant) {
|
|
59
|
+
let result;
|
|
60
|
+
if (existingVariant) {
|
|
61
|
+
result = existingVariant;
|
|
62
|
+
for (const key in variant) {
|
|
63
|
+
if (!copiedFromExistingVariant.includes(key)) {
|
|
64
|
+
result[key] = variant[key];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
result = __spreadProps(__spreadValues({}, variant), {
|
|
69
|
+
state: null,
|
|
70
|
+
initState: null,
|
|
71
|
+
setupApp: null,
|
|
72
|
+
slots: () => ({}),
|
|
73
|
+
previewReady: false
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
export { mapFile as m };
|
package/dist/bundled/sandbox.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { parseQuery } from "vue-router";
|
|
2
2
|
import { reactive, ref, createApp, computed, watch, onMounted, h } from "vue";
|
|
3
3
|
import { createPinia } from "pinia";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { applyStateToVariant } from "@histoire/shared";
|
|
5
|
+
import { MountStoryVue3, SandboxVue3 } from "@histoire/plugin-vue/client";
|
|
6
|
+
import { m as mapFile } from "./mapping.js";
|
|
6
7
|
import { files } from "$histoire-stories";
|
|
7
8
|
import { S as STATE_SYNC, P as PREVIEW_SETTINGS_SYNC, a as SANDBOX_READY } from "./const.js";
|
|
8
|
-
import {
|
|
9
|
+
import { i as isDark } from "./dark.js";
|
|
9
10
|
import { h as histoireConfig } from "./config.js";
|
|
11
|
+
import { t as toRawDeep } from "./state.js";
|
|
10
12
|
const receivedSettings = reactive({});
|
|
11
13
|
function applyPreviewSettings(settings) {
|
|
12
14
|
Object.assign(receivedSettings, settings);
|
|
@@ -58,11 +60,11 @@ const app = createApp({
|
|
|
58
60
|
render() {
|
|
59
61
|
return [
|
|
60
62
|
h("div", { class: "htw-sandbox-hidden" }, [
|
|
61
|
-
h(
|
|
63
|
+
h(MountStoryVue3, {
|
|
62
64
|
story: file.value.story
|
|
63
65
|
})
|
|
64
66
|
]),
|
|
65
|
-
this.story && this.variant ? h(
|
|
67
|
+
this.story && this.variant ? h(SandboxVue3, {
|
|
66
68
|
story: this.story,
|
|
67
69
|
variant: this.variant,
|
|
68
70
|
onReady: () => {
|
|
@@ -76,7 +78,6 @@ const app = createApp({
|
|
|
76
78
|
}
|
|
77
79
|
});
|
|
78
80
|
app.use(createPinia());
|
|
79
|
-
registerGlobalComponents(app);
|
|
80
81
|
app.mount("#app");
|
|
81
82
|
watch(isDark, (value) => {
|
|
82
83
|
if (value) {
|
package/dist/bundled/state.js
CHANGED
|
@@ -1,55 +1,24 @@
|
|
|
1
|
-
import { useDark, useToggle } from "@vueuse/core";
|
|
2
1
|
import { isRef, unref } from "vue";
|
|
3
|
-
const isDark = useDark({ valueDark: "htw-dark" });
|
|
4
|
-
const toggleDark = useToggle(isDark);
|
|
5
2
|
const isObject = (val) => val !== null && typeof val === "object";
|
|
6
|
-
function toRawDeep(val) {
|
|
3
|
+
function toRawDeep(val, seen = /* @__PURE__ */ new Set()) {
|
|
7
4
|
const unwrappedValue = isRef(val) ? unref(val) : val;
|
|
5
|
+
if (typeof unwrappedValue === "symbol") {
|
|
6
|
+
return unwrappedValue.toString();
|
|
7
|
+
}
|
|
8
|
+
if (seen.has(unwrappedValue)) {
|
|
9
|
+
return Array.isArray(unwrappedValue) ? [] : {};
|
|
10
|
+
}
|
|
11
|
+
seen.add(unwrappedValue);
|
|
8
12
|
if (!isObject(unwrappedValue)) {
|
|
9
13
|
return unwrappedValue;
|
|
10
14
|
}
|
|
11
15
|
if (Array.isArray(unwrappedValue)) {
|
|
12
|
-
return unwrappedValue.map(toRawDeep);
|
|
16
|
+
return unwrappedValue.map((value) => toRawDeep(value, seen));
|
|
13
17
|
}
|
|
14
|
-
return toRawObject(unwrappedValue);
|
|
18
|
+
return toRawObject(unwrappedValue, seen);
|
|
15
19
|
}
|
|
16
|
-
const toRawObject = (obj) => Object.keys(obj).reduce((raw, key) => {
|
|
17
|
-
raw[key] = toRawDeep(obj[key]);
|
|
20
|
+
const toRawObject = (obj, seen = /* @__PURE__ */ new Set()) => Object.keys(obj).reduce((raw, key) => {
|
|
21
|
+
raw[key] = toRawDeep(obj[key], seen);
|
|
18
22
|
return raw;
|
|
19
23
|
}, {});
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
return structuredClone(data);
|
|
23
|
-
} catch (e) {
|
|
24
|
-
console.warn(e, `Fallback to JSON cloning`);
|
|
25
|
-
try {
|
|
26
|
-
return JSON.parse(JSON.stringify(data));
|
|
27
|
-
} catch (e2) {
|
|
28
|
-
console.error(e2);
|
|
29
|
-
}
|
|
30
|
-
return data;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function omit(data, keys) {
|
|
34
|
-
const copy = {};
|
|
35
|
-
for (const key in data) {
|
|
36
|
-
if (!keys.includes(key)) {
|
|
37
|
-
copy[key] = data[key];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return copy;
|
|
41
|
-
}
|
|
42
|
-
function applyStateToVariant(variant, state) {
|
|
43
|
-
if (variant.state) {
|
|
44
|
-
for (const key in state) {
|
|
45
|
-
if (variant.state[key] && !key.startsWith("_h") && typeof variant.state[key] === "object" && !Array.isArray(variant.state[key])) {
|
|
46
|
-
Object.assign(variant.state[key], state[key]);
|
|
47
|
-
} else {
|
|
48
|
-
variant.state[key] = state[key];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
variant.state = state;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
export { applyStateToVariant as a, toRawDeep as b, clone as c, isDark as i, omit as o, toggleDark as t };
|
|
24
|
+
export { toRawDeep as t };
|
package/dist/bundled/style.css
CHANGED
|
@@ -14,37 +14,37 @@
|
|
|
14
14
|
color: var(--7fa476a0);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.landscape > div > .dragger[data-v-
|
|
18
|
-
width:
|
|
17
|
+
.landscape > div > .dragger[data-v-4cd3cd6c] {
|
|
18
|
+
width: .625rem;
|
|
19
19
|
}
|
|
20
|
-
.portrait > div > .dragger[data-v-
|
|
21
|
-
height:
|
|
20
|
+
.portrait > div > .dragger[data-v-4cd3cd6c] {
|
|
21
|
+
height: .625rem;
|
|
22
22
|
}
|
|
23
|
-
.landscape > div > .dragger.dragger-offset-before[data-v-
|
|
23
|
+
.landscape > div > .dragger.dragger-offset-before[data-v-4cd3cd6c] {
|
|
24
24
|
right: 0;
|
|
25
25
|
}
|
|
26
|
-
.portrait > div > .dragger.dragger-offset-before[data-v-
|
|
26
|
+
.portrait > div > .dragger.dragger-offset-before[data-v-4cd3cd6c] {
|
|
27
27
|
bottom: 0;
|
|
28
28
|
}
|
|
29
|
-
.landscape > div > .dragger.dragger-offset-center[data-v-
|
|
30
|
-
right:
|
|
29
|
+
.landscape > div > .dragger.dragger-offset-center[data-v-4cd3cd6c] {
|
|
30
|
+
right: -.3125rem;
|
|
31
31
|
}
|
|
32
|
-
.portrait > div > .dragger.dragger-offset-center[data-v-
|
|
33
|
-
bottom:
|
|
32
|
+
.portrait > div > .dragger.dragger-offset-center[data-v-4cd3cd6c] {
|
|
33
|
+
bottom: -.3125rem;
|
|
34
34
|
}
|
|
35
|
-
.landscape > div > .dragger.dragger-offset-after[data-v-
|
|
36
|
-
right:
|
|
35
|
+
.landscape > div > .dragger.dragger-offset-after[data-v-4cd3cd6c] {
|
|
36
|
+
right: -.625rem;
|
|
37
37
|
}
|
|
38
|
-
.portrait > div > .dragger.dragger-offset-after[data-v-
|
|
39
|
-
bottom:
|
|
38
|
+
.portrait > div > .dragger.dragger-offset-after[data-v-4cd3cd6c] {
|
|
39
|
+
bottom: -.625rem;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
.bind-icon-color[data-v-2cdc2ac0] {
|
|
43
43
|
color: var(--3c4190ff);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.bind-icon-color[data-v-
|
|
47
|
-
color: var(--
|
|
46
|
+
.bind-icon-color[data-v-265ac8e3] {
|
|
47
|
+
color: var(--7d3aedf8);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
.bind-preview-bg[data-v-bde73868] {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
color: var(--d1b61db4);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
.__histoire-code-placeholder[data-v-
|
|
74
|
+
.__histoire-code-placeholder[data-v-8b318638] {
|
|
75
75
|
color: inherit;
|
|
76
76
|
font-size: inherit;
|
|
77
77
|
}
|
package/dist/client/app/App.vue
CHANGED
|
@@ -21,6 +21,7 @@ import { isMobile } from './util/responsive'
|
|
|
21
21
|
import Breadcrumb from './components/app/Breadcrumb.vue'
|
|
22
22
|
import SearchModal from './components/search/SearchModal.vue'
|
|
23
23
|
import InitialLoading from './components/app/InitialLoading.vue'
|
|
24
|
+
import { MountStoryVue3 } from '@histoire/plugin-vue/client'
|
|
24
25
|
|
|
25
26
|
const files = ref<StoryFile[]>(rawFiles.map(file => mapFile(file)))
|
|
26
27
|
const tree = ref<Tree>(rawTree)
|
|
@@ -96,8 +97,7 @@ onMounted(() => {
|
|
|
96
97
|
v-if="storyStore.currentStory"
|
|
97
98
|
class="htw-hidden"
|
|
98
99
|
>
|
|
99
|
-
<
|
|
100
|
-
:is="storyStore.currentStory.file.component"
|
|
100
|
+
<MountStoryVue3
|
|
101
101
|
:story="storyStore.currentStory"
|
|
102
102
|
/>
|
|
103
103
|
</div>
|
|
@@ -206,11 +206,11 @@ onUnmounted(() => {
|
|
|
206
206
|
|
|
207
207
|
<style lang="postcss" scoped>
|
|
208
208
|
.landscape > div > .dragger {
|
|
209
|
-
width:
|
|
209
|
+
width: .625rem;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
.portrait > div > .dragger {
|
|
213
|
-
height:
|
|
213
|
+
height: .625rem;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
.landscape > div > .dragger.dragger-offset-before {
|
|
@@ -222,18 +222,18 @@ onUnmounted(() => {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
.landscape > div > .dragger.dragger-offset-center {
|
|
225
|
-
right:
|
|
225
|
+
right: -.3125rem;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
.portrait > div > .dragger.dragger-offset-center {
|
|
229
|
-
bottom:
|
|
229
|
+
bottom: -.3125rem;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
.landscape > div > .dragger.dragger-offset-after {
|
|
233
|
-
right:
|
|
233
|
+
right: -.625rem;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
.portrait > div > .dragger.dragger-offset-after {
|
|
237
|
-
bottom:
|
|
237
|
+
bottom: -.625rem;
|
|
238
238
|
}
|
|
239
239
|
</style>
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed, ref } from 'vue'
|
|
3
3
|
import { Icon } from '@iconify/vue'
|
|
4
|
-
import type {
|
|
4
|
+
import type { PropDefinition, AutoPropComponentDefinition } from '@histoire/shared'
|
|
5
|
+
import {
|
|
6
|
+
HstText,
|
|
7
|
+
HstNumber,
|
|
8
|
+
HstCheckbox,
|
|
9
|
+
HstTextarea,
|
|
10
|
+
} from '@histoire/controls'
|
|
11
|
+
import type { Variant } from '../../types'
|
|
5
12
|
|
|
6
13
|
const props = defineProps<{
|
|
7
14
|
variant: Variant
|
|
@@ -12,18 +19,18 @@ const props = defineProps<{
|
|
|
12
19
|
const comp = computed(() => {
|
|
13
20
|
switch (props.definition.types?.[0]) {
|
|
14
21
|
case 'string':
|
|
15
|
-
return
|
|
22
|
+
return HstText
|
|
16
23
|
case 'number':
|
|
17
|
-
return
|
|
24
|
+
return HstNumber
|
|
18
25
|
case 'boolean':
|
|
19
|
-
return
|
|
26
|
+
return HstCheckbox
|
|
20
27
|
case 'object':
|
|
21
28
|
default:
|
|
22
|
-
return
|
|
29
|
+
return HstTextarea
|
|
23
30
|
}
|
|
24
31
|
})
|
|
25
32
|
|
|
26
|
-
const isJSON = computed(() => comp.value ===
|
|
33
|
+
const isJSON = computed(() => comp.value === HstTextarea)
|
|
27
34
|
|
|
28
35
|
const invalidValue = ref('')
|
|
29
36
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type { AutoPropComponentDefinition
|
|
2
|
+
import type { AutoPropComponentDefinition } from '@histoire/shared'
|
|
3
|
+
import type { Variant } from '../../types'
|
|
3
4
|
import { Icon } from '@iconify/vue'
|
|
4
5
|
import ControlsComponentPropItem from './ControlsComponentPropItem.vue'
|
|
5
6
|
|
|
@@ -2,8 +2,9 @@
|
|
|
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 { applyStateToVariant, clone, omit } from '@histoire/shared'
|
|
5
6
|
import BaseSelect from '../base/BaseSelect.vue'
|
|
6
|
-
import {
|
|
7
|
+
import { toRawDeep } from '../../util/state'
|
|
7
8
|
import type { Story, Variant } from '../../types'
|
|
8
9
|
|
|
9
10
|
const DEFAULT_ID = 'default'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { PropType } from 'vue'
|
|
3
3
|
import { Icon } from '@iconify/vue'
|
|
4
|
+
import { SandboxVue3 } from '@histoire/plugin-vue/client'
|
|
4
5
|
import type { Story, Variant } from '../../types'
|
|
5
|
-
import SandboxVue3 from '../sandbox/SandboxVue3.vue'
|
|
6
6
|
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
7
7
|
import StatePresets from './StatePresets.vue'
|
|
8
8
|
import ControlsComponentProps from './ControlsComponentProps.vue'
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { computed, onMounted, PropType, ref, shallowRef, watch } from 'vue'
|
|
3
3
|
import { getHighlighter, Highlighter, setCDN } from 'shiki'
|
|
4
4
|
import { HstCopyIcon } from '@histoire/controls'
|
|
5
|
-
import {
|
|
5
|
+
import { unindent } from '@histoire/shared'
|
|
6
|
+
import { generateSourceCode } from '@histoire/plugin-vue/client'
|
|
6
7
|
import type { Variant } from '../../types'
|
|
7
8
|
import { isDark } from '../../util/dark'
|
|
8
|
-
import { unindent } from '../../codegen/util'
|
|
9
9
|
|
|
10
10
|
const props = defineProps({
|
|
11
11
|
variant: {
|
|
@@ -3,9 +3,9 @@ import { PropType, ref, toRefs } from 'vue'
|
|
|
3
3
|
import { Icon } from '@iconify/vue'
|
|
4
4
|
import { useRouter } from 'vue-router'
|
|
5
5
|
import { useResizeObserver } from '@vueuse/core'
|
|
6
|
+
import { SandboxVue3 } from '@histoire/plugin-vue/client'
|
|
6
7
|
import { useCurrentVariantRoute } from '../../util/variant'
|
|
7
8
|
import type { Story, Variant } from '../../types'
|
|
8
|
-
import SandboxVue3 from '../sandbox/SandboxVue3.vue'
|
|
9
9
|
import { useScrollOnActive } from '../../util/scroll'
|
|
10
10
|
|
|
11
11
|
const props = defineProps({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
+
import { SandboxVue3 } from '@histoire/plugin-vue/client'
|
|
2
3
|
import type { Story, Variant } from '../../types'
|
|
3
|
-
import SandboxVue3 from '../sandbox/SandboxVue3.vue'
|
|
4
4
|
import StoryResponsivePreview from './StoryResponsivePreview.vue'
|
|
5
5
|
|
|
6
6
|
const props = defineProps<{
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
import { computed, onUnmounted, Ref, ref, toRaw, watch } from 'vue'
|
|
3
3
|
import { useEventListener } from '@vueuse/core'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
|
+
import { applyStateToVariant } from '@histoire/shared'
|
|
5
6
|
import { STATE_SYNC, PREVIEW_SETTINGS_SYNC, SANDBOX_READY, EVENT_SEND } from '../../util/const'
|
|
6
7
|
import type { Story, Variant } from '../../types'
|
|
7
8
|
import HatchedPattern from '../misc/HatchedPattern.vue'
|
|
8
9
|
import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
|
|
9
|
-
import { getSandboxUrl } from '
|
|
10
|
+
import { getSandboxUrl } from '../../util/sandbox'
|
|
10
11
|
import { usePreviewSettingsStore } from '../../stores/preview-settings'
|
|
11
12
|
import { HstEvent, useEventsStore } from '../../stores/events'
|
|
12
13
|
import StoryResponsivePreview from './StoryResponsivePreview.vue'
|
|
13
|
-
import {
|
|
14
|
+
import { toRawDeep } from '../../util/state'
|
|
14
15
|
|
|
15
16
|
const props = defineProps<{
|
|
16
17
|
story: Story
|