@histoire/app 1.0.0-alpha.2 → 1.0.0-alpha.3

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.
Files changed (41) hide show
  1. package/dist/bundled/app.css +6 -6
  2. package/dist/bundled/components/HomeView.vue2.js +1 -4
  3. package/dist/bundled/components/app/AppHeader.vue2.js +1 -2
  4. package/dist/bundled/components/app/AppLogo.vue2.js +2 -3
  5. package/dist/bundled/components/app/Breadcrumb.vue2.js +3 -6
  6. package/dist/bundled/components/base/BaseCheckbox.vue2.js +1 -2
  7. package/dist/bundled/components/command/CommandPrompts.vue2.js +1 -2
  8. package/dist/bundled/components/command/PromptSelect.vue2.js +2 -3
  9. package/dist/bundled/components/command/PromptText.vue2.js +2 -3
  10. package/dist/bundled/components/panel/ControlsComponentPropItem.vue2.js +4 -10
  11. package/dist/bundled/components/panel/StoryControls.vue2.js +2 -3
  12. package/dist/bundled/components/panel/StoryDocs.vue2.js +3 -7
  13. package/dist/bundled/components/panel/StorySourceCode.vue2.js +9 -18
  14. package/dist/bundled/components/search/SearchItemContent.vue2.js +1 -2
  15. package/dist/bundled/components/search/SearchPane.vue2.js +1 -4
  16. package/dist/bundled/components/story/GenericMountStory.vue2.js +1 -2
  17. package/dist/bundled/components/story/GenericRenderStory.vue2.js +1 -2
  18. package/dist/bundled/components/story/StoryVariantGrid.vue2.js +1 -2
  19. package/dist/bundled/components/story/StoryVariantSingle.vue2.js +4 -10
  20. package/dist/bundled/components/story/StoryVariantSingleView.vue2.js +2 -3
  21. package/dist/bundled/components/story/StoryView.vue2.js +3 -5
  22. package/dist/bundled/components/story/StoryViewer.vue2.js +3 -6
  23. package/dist/bundled/components/toolbar/ToolbarResponsiveSize.vue2.js +19 -23
  24. package/dist/bundled/components/tree/StoryListFolder.vue.js +1 -1
  25. package/dist/bundled/components/tree/StoryListFolder.vue2.js +1 -1
  26. package/dist/bundled/components/tree/StoryListItem.vue.js +1 -1
  27. package/dist/bundled/components/tree/StoryListItem.vue2.js +2 -2
  28. package/dist/bundled/sandbox.js +5 -11
  29. package/dist/bundled/stores/command.js +2 -3
  30. package/dist/bundled/stores/events.js +1 -4
  31. package/dist/bundled/stores/story.js +1 -4
  32. package/dist/bundled/util/commands.js +3 -5
  33. package/dist/bundled/util/dark.js +1 -2
  34. package/dist/bundled/util/docs.js +4 -5
  35. package/dist/bundled/util/events.js +1 -2
  36. package/dist/bundled/util/preview-settings.js +1 -2
  37. package/dist/style.css +0 -2
  38. package/package.json +5 -5
  39. package/src/app/components/tree/StoryGroup.vue +1 -1
  40. package/src/app/components/tree/StoryListFolder.vue +1 -1
  41. package/src/app/components/tree/StoryListItem.vue +1 -1
@@ -1,13 +1,13 @@
1
1
 
2
- .bind-tree-margin[data-v-048885b7] {
3
- margin-left: var(--10fa28ae);
2
+ .bind-tree-margin[data-v-64c2458f] {
3
+ margin-left: var(--2562213a);
4
4
  }
5
- .bind-icon-color[data-v-048885b7] {
6
- color: var(--8aa08936);
5
+ .bind-icon-color[data-v-64c2458f] {
6
+ color: var(--1eff521f);
7
7
  }
8
8
 
9
- .bind-tree-padding[data-v-10840b73] {
10
- padding-left: var(--224f37c4);
9
+ .bind-tree-padding[data-v-ee932a0c] {
10
+ padding-left: var(--5352bb71);
11
11
  }
12
12
 
13
13
  .bind-icon-color[data-v-d15ecb89] {
@@ -11,10 +11,7 @@ const _hoisted_3 = { class: "htw-flex !md:htw-flex-col htw-flex-wrap htw-justify
11
11
  const _sfc_main = /* @__PURE__ */ defineComponent({
12
12
  __name: "HomeView",
13
13
  setup(__props) {
14
- const logoUrl = computed(() => {
15
- var _a, _b;
16
- return ((_b = (_a = histoireConfig.theme) == null ? void 0 : _a.logo) == null ? void 0 : _b.square) ? customLogos.square : HistoireLogo;
17
- });
14
+ const logoUrl = computed(() => histoireConfig.theme?.logo?.square ? customLogos.square : HistoireLogo);
18
15
  const storyStore = useStoryStore();
19
16
  const stats = computed(() => {
20
17
  let storyCount = 0;
@@ -25,12 +25,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
25
25
  toggleDark();
26
26
  });
27
27
  return (_ctx, _cache) => {
28
- var _a;
29
28
  const _directive_tooltip = resolveDirective("tooltip");
30
29
  return openBlock(), createElementBlock("div", _hoisted_1, [
31
30
  createElementVNode("div", _hoisted_2, [
32
31
  createElementVNode("a", {
33
- href: (_a = unref(histoireConfig).theme) == null ? void 0 : _a.logoHref,
32
+ href: unref(histoireConfig).theme?.logoHref,
34
33
  target: "_blank",
35
34
  class: "htw-w-full htw-h-full htw-flex htw-items-center"
36
35
  }, [
@@ -9,11 +9,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
9
9
  __name: "AppLogo",
10
10
  setup(__props) {
11
11
  const logoUrl = computed(() => {
12
- var _a, _b;
13
12
  if (isDark.value) {
14
- return ((_a = histoireConfig.theme.logo) == null ? void 0 : _a.dark) ? customLogos.dark : HistoireLogoDark;
13
+ return histoireConfig.theme.logo?.dark ? customLogos.dark : HistoireLogoDark;
15
14
  }
16
- return ((_b = histoireConfig.theme.logo) == null ? void 0 : _b.light) ? customLogos.light : HistoireLogoLight;
15
+ return histoireConfig.theme.logo?.light ? customLogos.light : HistoireLogoLight;
17
16
  });
18
17
  const altText = computed(() => `${histoireConfig.theme.title} logo`);
19
18
  return (_ctx, _cache) => {
@@ -16,12 +16,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16
16
  stories: {}
17
17
  },
18
18
  setup(__props) {
19
- useCssVars((_ctx) => {
20
- var _a;
21
- return {
22
- "a3f02f4e": (_a = story.value) == null ? void 0 : _a.iconColor
23
- };
24
- });
19
+ useCssVars((_ctx) => ({
20
+ "a3f02f4e": story.value?.iconColor
21
+ }));
25
22
  const storyStore = useStoryStore();
26
23
  const story = computed(() => storyStore.currentStory);
27
24
  const folders = computed(() => {
@@ -32,8 +32,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
32
32
  const dashoffset = computed(() => (1 - progress.value) * dasharray.value);
33
33
  const animationEnabled = ref(false);
34
34
  watch(path, () => {
35
- var _a, _b;
36
- dasharray.value = ((_b = (_a = path.value).getTotalLength) == null ? void 0 : _b.call(_a)) ?? 21.21;
35
+ dasharray.value = path.value.getTotalLength?.() ?? 21.21;
37
36
  });
38
37
  return (_ctx, _cache) => {
39
38
  return openBlock(), createElementBlock("div", {
@@ -42,8 +42,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
42
42
  const promptComps = ref([]);
43
43
  function focusPrompt(index) {
44
44
  nextTick(() => {
45
- var _a, _b;
46
- (_b = (_a = promptComps.value[index]) == null ? void 0 : _a.focus) == null ? void 0 : _b.call(_a);
45
+ promptComps.value[index]?.focus?.();
47
46
  });
48
47
  }
49
48
  onMounted(() => {
@@ -36,9 +36,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
36
36
  });
37
37
  const input = ref();
38
38
  function focus() {
39
- var _a, _b;
40
- (_a = input.value) == null ? void 0 : _a.focus();
41
- (_b = input.value) == null ? void 0 : _b.select();
39
+ input.value?.focus();
40
+ input.value?.select();
42
41
  }
43
42
  __expose({
44
43
  focus
@@ -25,9 +25,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
25
25
  });
26
26
  const input = ref();
27
27
  function focus() {
28
- var _a, _b;
29
- (_a = input.value) == null ? void 0 : _a.focus();
30
- (_b = input.value) == null ? void 0 : _b.select();
28
+ input.value?.focus();
29
+ input.value?.select();
31
30
  }
32
31
  __expose({
33
32
  focus
@@ -12,8 +12,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
12
12
  setup(__props) {
13
13
  const props = __props;
14
14
  const comp = computed(() => {
15
- var _a;
16
- switch ((_a = props.definition.types) == null ? void 0 : _a[0]) {
15
+ switch (props.definition.types?.[0]) {
17
16
  case "string":
18
17
  return HstText;
19
18
  case "number":
@@ -27,8 +26,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
27
26
  });
28
27
  const model = computed({
29
28
  get: () => {
30
- var _a;
31
- return (_a = props.variant.state._hPropState[props.component.index]) == null ? void 0 : _a[props.definition.name];
29
+ return props.variant.state._hPropState[props.component.index]?.[props.definition.name];
32
30
  },
33
31
  set: (value) => {
34
32
  if (!props.variant.state._hPropState[props.component.index]) {
@@ -42,18 +40,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
42
40
  delete props.variant.state._hPropState[props.component.index][props.definition.name];
43
41
  }
44
42
  }
45
- const canReset = computed(() => {
46
- var _a, _b;
47
- return ((_b = (_a = props.variant.state) == null ? void 0 : _a._hPropState) == null ? void 0 : _b[props.component.index]) && props.definition.name in props.variant.state._hPropState[props.component.index];
48
- });
43
+ const canReset = computed(() => props.variant.state?._hPropState?.[props.component.index] && props.definition.name in props.variant.state._hPropState[props.component.index]);
49
44
  return (_ctx, _cache) => {
50
- var _a;
51
45
  const _directive_tooltip = resolveDirective("tooltip");
52
46
  return comp.value ? (openBlock(), createBlock(resolveDynamicComponent(comp.value), {
53
47
  key: 0,
54
48
  modelValue: model.value,
55
49
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => model.value = $event),
56
- placeholder: model.value === void 0 ? (_a = _ctx.definition) == null ? void 0 : _a.default : null,
50
+ placeholder: model.value === void 0 ? _ctx.definition?.default : null,
57
51
  class: "histoire-controls-component-prop-item",
58
52
  title: `${_ctx.definition.name}${canReset.value ? " *" : ""}`
59
53
  }, {
@@ -38,7 +38,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
38
38
  const hasCustomControls = computed(() => props.variant.slots().controls || props.story.slots().controls);
39
39
  const hasInitState = computed(() => Object.entries(props.variant.state || {}).filter(([key]) => !key.startsWith("_h")).length > 0);
40
40
  return (_ctx, _cache) => {
41
- var _a, _b, _c, _d;
42
41
  return openBlock(), createElementBlock("div", _hoisted_1, [
43
42
  createElementVNode("div", _hoisted_2, [
44
43
  ready.value || !hasCustomControls.value ? (openBlock(), createBlock(_sfc_main$1, {
@@ -59,7 +58,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
59
58
  class: "htw-flex-none htw-my-2",
60
59
  variant: __props.variant
61
60
  }, null, 8, ["variant"])
62
- ])) : !((_b = (_a = __props.variant.state) == null ? void 0 : _a._hPropDefs) == null ? void 0 : _b.length) ? (openBlock(), createBlock(BaseEmpty, { key: 2 }, {
61
+ ])) : !__props.variant.state?._hPropDefs?.length ? (openBlock(), createBlock(BaseEmpty, { key: 2 }, {
63
62
  default: withCtx(() => [
64
63
  createVNode(unref(Icon), {
65
64
  icon: "carbon:audio-console",
@@ -69,7 +68,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
69
68
  ]),
70
69
  _: 1
71
70
  })) : createCommentVNode("", true),
72
- ((_d = (_c = __props.variant.state) == null ? void 0 : _c._hPropDefs) == null ? void 0 : _d.length) ? (openBlock(), createElementBlock("div", _hoisted_4, [
71
+ __props.variant.state?._hPropDefs?.length ? (openBlock(), createElementBlock("div", _hoisted_4, [
73
72
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.variant.state._hPropDefs, (def, index) => {
74
73
  return openBlock(), createBlock(_sfc_main$4, {
75
74
  key: index,
@@ -11,14 +11,13 @@ const _hoisted_1 = ["innerHTML"];
11
11
  function useStoryDoc(story) {
12
12
  const renderedDoc = ref("");
13
13
  watchEffect(async () => {
14
- var _a;
15
14
  const mdKey = story.value.file.filePath.replace(/\.(\w*)$/, ".md");
16
15
  if (markdownFiles[mdKey]) {
17
16
  const md = await markdownFiles[mdKey]();
18
17
  renderedDoc.value = md.html;
19
18
  return;
20
19
  }
21
- let comp = (_a = story.value.file) == null ? void 0 : _a.component;
20
+ let comp = story.value.file?.component;
22
21
  if (comp) {
23
22
  if (comp.__asyncResolved) {
24
23
  comp = comp.__asyncResolved;
@@ -30,7 +29,7 @@ function useStoryDoc(story) {
30
29
  } catch (e) {
31
30
  }
32
31
  }
33
- if (comp == null ? void 0 : comp.default) {
32
+ if (comp?.default) {
34
33
  comp = comp.default;
35
34
  }
36
35
  renderedDoc.value = comp.doc;
@@ -117,10 +116,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
117
116
  }, {
118
117
  immediate: true
119
118
  });
120
- const filePath = computed(() => {
121
- var _a, _b;
122
- return ((_a = story.value.file) == null ? void 0 : _a.docsFilePath) ?? (props.standalone && ((_b = story.value.file) == null ? void 0 : _b.filePath));
123
- });
119
+ const filePath = computed(() => story.value.file?.docsFilePath ?? (props.standalone && story.value.file?.filePath));
124
120
  return (_ctx, _cache) => {
125
121
  return openBlock(), createElementBlock("div", {
126
122
  class: "histoire-story-docs",
@@ -29,8 +29,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
29
29
  const props = __props;
30
30
  const generateSourceCodeFn = ref(null);
31
31
  watchEffect(async () => {
32
- var _a;
33
- const clientPlugin = clientSupportPlugins[(_a = props.story.file) == null ? void 0 : _a.supportPluginId];
32
+ const clientPlugin = clientSupportPlugins[props.story.file?.supportPluginId];
34
33
  if (clientPlugin) {
35
34
  const pluginModule = await clientPlugin();
36
35
  generateSourceCodeFn.value = markRaw(pluginModule.generateSourceCode);
@@ -40,15 +39,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
40
39
  const dynamicSourceCode = ref("");
41
40
  const error = ref(null);
42
41
  watch(() => [props.variant, generateSourceCodeFn.value], async () => {
43
- var _a, _b, _c, _d;
44
42
  if (!generateSourceCodeFn.value) return;
45
43
  error.value = null;
46
44
  dynamicSourceCode.value = "";
47
45
  try {
48
46
  if (props.variant.source) {
49
47
  dynamicSourceCode.value = props.variant.source;
50
- } else if ((_b = (_a = props.variant).slots) == null ? void 0 : _b.call(_a).source) {
51
- const source = (_d = (_c = props.variant).slots) == null ? void 0 : _d.call(_c).source()[0].children;
48
+ } else if (props.variant.slots?.().source) {
49
+ const source = props.variant.slots?.().source()[0].children;
52
50
  if (source) {
53
51
  dynamicSourceCode.value = await unindent(source);
54
52
  }
@@ -67,13 +65,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
67
65
  immediate: true
68
66
  });
69
67
  const staticSourceCode = ref("");
70
- watch(() => {
71
- var _a, _b;
72
- return [props.story, (_b = (_a = props.story) == null ? void 0 : _a.file) == null ? void 0 : _b.source];
73
- }, async () => {
74
- var _a;
68
+ watch(() => [props.story, props.story?.file?.source], async () => {
75
69
  staticSourceCode.value = "";
76
- const sourceLoader = (_a = props.story.file) == null ? void 0 : _a.source;
70
+ const sourceLoader = props.story.file?.source;
77
71
  if (sourceLoader) {
78
72
  staticSourceCode.value = (await sourceLoader()).default;
79
73
  }
@@ -99,13 +93,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
99
93
  ]
100
94
  });
101
95
  });
102
- const sourceHtml = computed(() => {
103
- var _a;
104
- return displayedSourceCode.value ? (_a = highlighter.value) == null ? void 0 : _a.codeToHtml(displayedSourceCode.value, {
105
- lang: "html",
106
- theme: isDark.value ? "github-dark" : "github-light"
107
- }) : "";
108
- });
96
+ const sourceHtml = computed(() => displayedSourceCode.value ? highlighter.value?.codeToHtml(displayedSourceCode.value, {
97
+ lang: "html",
98
+ theme: isDark.value ? "github-dark" : "github-light"
99
+ }) : "");
109
100
  let lastScroll = 0;
110
101
  watch(() => props.variant, () => {
111
102
  lastScroll = 0;
@@ -26,7 +26,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
26
26
  command: "Command"
27
27
  };
28
28
  return (_ctx, _cache) => {
29
- var _a;
30
29
  return openBlock(), createElementBlock(Fragment, null, [
31
30
  createVNode(BaseIcon, {
32
31
  icon: _ctx.result.icon ?? defaultIcons[_ctx.result.kind],
@@ -47,7 +46,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
47
46
  createTextVNode(toDisplayString(_ctx.result.title) + " ", 1),
48
47
  createElementVNode("span", _hoisted_3, toDisplayString(kindLabels[_ctx.result.kind]), 1)
49
48
  ]),
50
- ((_a = _ctx.result.path) == null ? void 0 : _a.length) ? (openBlock(), createElementBlock("div", _hoisted_4, [
49
+ _ctx.result.path?.length ? (openBlock(), createElementBlock("div", _hoisted_4, [
51
50
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.result.path, (p, index) => {
52
51
  return openBlock(), createElementBlock("div", {
53
52
  key: index,
@@ -182,10 +182,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
182
182
  if (__HISTOIRE_DEV__) {
183
183
  const commandCtx = getCommandContext();
184
184
  const searchText = searchInputText.value.toLowerCase();
185
- return allCommands.filter((command) => !command.showIf || command.showIf(commandCtx)).filter((command) => {
186
- var _a;
187
- return command.label.toLowerCase().includes(searchText) || ((_a = command.searchText) == null ? void 0 : _a.toLowerCase().includes(searchText));
188
- }).map((command) => commandResultFactory(command, 0));
185
+ return allCommands.filter((command) => !command.showIf || command.showIf(commandCtx)).filter((command) => command.label.toLowerCase().includes(searchText) || command.searchText?.toLowerCase().includes(searchText)).map((command) => commandResultFactory(command, 0));
189
186
  }
190
187
  return [];
191
188
  });
@@ -14,8 +14,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14
14
  const props = __props;
15
15
  const mountComponent = ref(null);
16
16
  watchEffect(async () => {
17
- var _a;
18
- const clientPlugin = clientSupportPlugins[(_a = props.story.file) == null ? void 0 : _a.supportPluginId];
17
+ const clientPlugin = clientSupportPlugins[props.story.file?.supportPluginId];
19
18
  if (clientPlugin) {
20
19
  const pluginModule = await clientPlugin();
21
20
  mountComponent.value = markRaw(pluginModule.MountStory);
@@ -14,8 +14,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14
14
  const props = __props;
15
15
  const mountComponent = ref(null);
16
16
  watchEffect(async () => {
17
- var _a;
18
- const clientPlugin = clientSupportPlugins[(_a = props.story.file) == null ? void 0 : _a.supportPluginId];
17
+ const clientPlugin = clientSupportPlugins[props.story.file?.supportPluginId];
19
18
  if (clientPlugin) {
20
19
  try {
21
20
  const pluginModule = await clientPlugin();
@@ -94,14 +94,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
94
94
  });
95
95
  const columnCount = computed(() => Math.min(storyStore.currentStory.variants.length, Math.floor((viewWidth.value + gap) / (gridColumnWidth.value + gap))));
96
96
  return (_ctx, _cache) => {
97
- var _a;
98
97
  return openBlock(), createElementBlock("div", _hoisted_1, [
99
98
  !unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2, [
100
99
  createVNode(ToolbarBackground),
101
100
  createVNode(_sfc_main$1),
102
101
  _ctx.__HISTOIRE_DEV__ ? (openBlock(), createBlock(_sfc_main$2, {
103
102
  key: 0,
104
- file: (_a = unref(storyStore).currentStory.file) == null ? void 0 : _a.filePath,
103
+ file: unref(storyStore).currentStory.file?.filePath,
105
104
  tooltip: "Edit story in editor"
106
105
  }, null, 8, ["file"])) : createCommentVNode("", true)
107
106
  ])) : createCommentVNode("", true),
@@ -30,17 +30,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
30
30
  openVariantMenu: () => true
31
31
  },
32
32
  setup(__props) {
33
- useCssVars((_ctx) => {
34
- var _a;
35
- return {
36
- "41c4d268": (_a = variant.value) == null ? void 0 : _a.iconColor
37
- };
38
- });
33
+ useCssVars((_ctx) => ({
34
+ "41c4d268": variant.value?.iconColor
35
+ }));
39
36
  const storyStore = useStoryStore();
40
- const hasSingleVariant = computed(() => {
41
- var _a;
42
- return ((_a = storyStore.currentStory) == null ? void 0 : _a.variants.length) === 1;
43
- });
37
+ const hasSingleVariant = computed(() => storyStore.currentStory?.variants.length === 1);
44
38
  const variant = computed(() => storyStore.currentVariant);
45
39
  return (_ctx, _cache) => {
46
40
  return hasSingleVariant.value && variant.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
@@ -32,7 +32,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
32
32
  },
33
33
  setup(__props) {
34
34
  return (_ctx, _cache) => {
35
- var _a, _b;
36
35
  return openBlock(), createElementBlock("div", _hoisted_1, [
37
36
  !unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2, [
38
37
  createVNode(_sfc_main$1, { variant: _ctx.variant }, null, 8, ["variant"]),
@@ -45,11 +44,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
45
44
  }, null, 8, ["variant", "story"]),
46
45
  _ctx.__HISTOIRE_DEV__ ? (openBlock(), createBlock(_sfc_main$5, {
47
46
  key: 1,
48
- file: (_a = _ctx.story.file) == null ? void 0 : _a.filePath,
47
+ file: _ctx.story.file?.filePath,
49
48
  tooltip: "Edit story in editor"
50
49
  }, null, 8, ["file"])) : createCommentVNode("", true)
51
50
  ])) : createCommentVNode("", true),
52
- ((_b = _ctx.story.layout) == null ? void 0 : _b.iframe) === false ? (openBlock(), createBlock(_sfc_main$6, {
51
+ _ctx.story.layout?.iframe === false ? (openBlock(), createBlock(_sfc_main$6, {
53
52
  key: 1,
54
53
  story: _ctx.story,
55
54
  variant: _ctx.variant
@@ -29,13 +29,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
29
29
  immediate: true
30
30
  });
31
31
  watch(() => [storyStore.currentStory, storyStore.currentVariant], () => {
32
- var _a, _b;
33
32
  if (!storyStore.currentVariant) {
34
- if ((_a = storyStore.currentStory) == null ? void 0 : _a.lastSelectedVariant) {
33
+ if (storyStore.currentStory?.lastSelectedVariant) {
35
34
  setVariant(storyStore.currentStory.lastSelectedVariant.id);
36
35
  return;
37
36
  }
38
- if (((_b = storyStore.currentStory) == null ? void 0 : _b.variants.length) === 1) {
37
+ if (storyStore.currentStory?.variants.length === 1) {
39
38
  setVariant(storyStore.currentStory.variants[0].id);
40
39
  }
41
40
  }
@@ -53,8 +52,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
53
52
  }
54
53
  const docsOnlyScroller = ref(null);
55
54
  function scrollDocsToTop() {
56
- var _a;
57
- (_a = docsOnlyScroller.value) == null ? void 0 : _a.scrollTo(0, 0);
55
+ docsOnlyScroller.value?.scrollTo(0, 0);
58
56
  }
59
57
  return (_ctx, _cache) => {
60
58
  return !unref(storyStore).currentStory ? (openBlock(), createBlock(BaseEmpty, {
@@ -11,12 +11,9 @@ const _hoisted_1 = { class: "histoire-story-viewer htw-bg-gray-50 htw-h-full dar
11
11
  const _sfc_main = /* @__PURE__ */ defineComponent({
12
12
  __name: "StoryViewer",
13
13
  setup(__props) {
14
- useCssVars((_ctx) => {
15
- var _a;
16
- return {
17
- "0f021d3c": (_a = variant.value) == null ? void 0 : _a.iconColor
18
- };
19
- });
14
+ useCssVars((_ctx) => ({
15
+ "0f021d3c": variant.value?.iconColor
16
+ }));
20
17
  const storyStore = useStoryStore();
21
18
  const variant = computed(() => storyStore.currentVariant);
22
19
  const isMenuOpened = ref(false);
@@ -19,13 +19,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
19
19
  setup(__props) {
20
20
  const settings = usePreviewSettingsStore().currentSettings;
21
21
  return (_ctx, _cache) => {
22
- var _a;
23
22
  const _component_VDropdown = resolveComponent("VDropdown");
24
23
  const _directive_tooltip = resolveDirective("tooltip");
25
24
  return openBlock(), createBlock(_component_VDropdown, {
26
25
  placement: "bottom-end",
27
26
  skidding: 6,
28
- disabled: !((_a = unref(histoireConfig).responsivePresets) == null ? void 0 : _a.length),
27
+ disabled: !unref(histoireConfig).responsivePresets?.length,
29
28
  class: "histoire-toolbar-responsive-size htw-h-full htw-flex-none"
30
29
  }, {
31
30
  popper: withCtx(({ hide }) => [
@@ -100,27 +99,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
100
99
  }), 128))
101
100
  ])
102
101
  ]),
103
- default: withCtx(() => {
104
- var _a2;
105
- return [
106
- withDirectives((openBlock(), createElementBlock("div", {
107
- class: normalizeClass(["htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 htw-group", {
108
- "htw-cursor-pointer hover:htw-text-primary-500": (_a2 = unref(histoireConfig).responsivePresets) == null ? void 0 : _a2.length
109
- }])
110
- }, [
111
- createVNode(unref(Icon), {
112
- icon: "carbon:devices",
113
- class: "htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
114
- }),
115
- createVNode(unref(Icon), {
116
- icon: "carbon:caret-down",
117
- class: "htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
118
- })
119
- ], 2)), [
120
- [_directive_tooltip, "Responsive sizes"]
121
- ])
122
- ];
123
- }),
102
+ default: withCtx(() => [
103
+ withDirectives((openBlock(), createElementBlock("div", {
104
+ class: normalizeClass(["htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 htw-group", {
105
+ "htw-cursor-pointer hover:htw-text-primary-500": unref(histoireConfig).responsivePresets?.length
106
+ }])
107
+ }, [
108
+ createVNode(unref(Icon), {
109
+ icon: "carbon:devices",
110
+ class: "htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
111
+ }),
112
+ createVNode(unref(Icon), {
113
+ icon: "carbon:caret-down",
114
+ class: "htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
115
+ })
116
+ ], 2)), [
117
+ [_directive_tooltip, "Responsive sizes"]
118
+ ])
119
+ ]),
124
120
  _: 1
125
121
  }, 8, ["disabled"]);
126
122
  };
@@ -2,7 +2,7 @@ import _sfc_main from "./StoryListFolder.vue2.js";
2
2
  /* empty css */
3
3
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
4
  "use strict";
5
- const StoryListFolder = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-10840b73"]]);
5
+ const StoryListFolder = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ee932a0c"]]);
6
6
  export {
7
7
  StoryListFolder as default
8
8
  };
@@ -21,7 +21,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
21
21
  },
22
22
  setup(__props) {
23
23
  useCssVars((_ctx) => ({
24
- "224f37c4": folderPadding.value
24
+ "5352bb71": folderPadding.value
25
25
  }));
26
26
  const props = __props;
27
27
  const folderStore = useFolderStore();
@@ -2,7 +2,7 @@ import _sfc_main from "./StoryListItem.vue2.js";
2
2
  /* empty css */
3
3
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
4
  "use strict";
5
- const StoryListItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-048885b7"]]);
5
+ const StoryListItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-64c2458f"]]);
6
6
  export {
7
7
  StoryListItem as default
8
8
  };
@@ -18,8 +18,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
18
18
  },
19
19
  setup(__props) {
20
20
  useCssVars((_ctx) => ({
21
- "10fa28ae": filePadding.value,
22
- "8aa08936": _ctx.story.iconColor
21
+ "2562213a": filePadding.value,
22
+ "1eff521f": _ctx.story.iconColor
23
23
  }));
24
24
  const props = __props;
25
25
  const filePadding = computed(() => {
@@ -21,29 +21,24 @@ const app = createApp({
21
21
  name: "SandboxApp",
22
22
  setup() {
23
23
  const story = computed(() => file.value.story);
24
- const variant = computed(() => {
25
- var _a;
26
- return (_a = story.value) == null ? void 0 : _a.variants.find((v) => v.id === query.variantId);
27
- });
24
+ const variant = computed(() => story.value?.variants.find((v) => v.id === query.variantId));
28
25
  let synced = false;
29
26
  let mounted = false;
30
27
  window.addEventListener("message", (event) => {
31
- var _a, _b;
32
- if (((_a = event.data) == null ? void 0 : _a.type) === STATE_SYNC) {
28
+ if (event.data?.type === STATE_SYNC) {
33
29
  if (!mounted) return;
34
30
  synced = true;
35
31
  applyState(variant.value.state, event.data.state);
36
- } else if (((_b = event.data) == null ? void 0 : _b.type) === PREVIEW_SETTINGS_SYNC) {
32
+ } else if (event.data?.type === PREVIEW_SETTINGS_SYNC) {
37
33
  applyPreviewSettings(event.data.settings);
38
34
  }
39
35
  });
40
36
  watch(() => variant.value.state, (value) => {
41
- var _a;
42
37
  if (synced && mounted) {
43
38
  synced = false;
44
39
  return;
45
40
  }
46
- (_a = window.parent) == null ? void 0 : _a.postMessage({
41
+ window.parent?.postMessage({
47
42
  type: STATE_SYNC,
48
43
  state: toRawDeep(value, true)
49
44
  });
@@ -67,8 +62,7 @@ const app = createApp({
67
62
  })
68
63
  ]),
69
64
  this.story && this.variant ? h(_sfc_main$1, { story: this.story, variant: this.variant, onReady: () => {
70
- var _a;
71
- (_a = window.parent) == null ? void 0 : _a.postMessage({
65
+ window.parent?.postMessage({
72
66
  type: SANDBOX_READY
73
67
  });
74
68
  } }) : null
@@ -6,12 +6,11 @@ const useCommandStore = defineStore("command", () => {
6
6
  const selectedCommand = ref(null);
7
7
  const showPromptsModal = ref(false);
8
8
  function activateCommand(command) {
9
- var _a, _b;
10
9
  selectedCommand.value = command;
11
- if ((_a = command.prompts) == null ? void 0 : _a.length) {
10
+ if (command.prompts?.length) {
12
11
  showPromptsModal.value = true;
13
12
  } else {
14
- const params = ((_b = command.getParams) == null ? void 0 : _b.call(command, getCommandContext())) ?? {};
13
+ const params = command.getParams?.(getCommandContext()) ?? {};
15
14
  executeCommand(command, params);
16
15
  }
17
16
  }
@@ -14,10 +14,7 @@ const useEventsStore = defineStore("events", () => {
14
14
  events.length = 0;
15
15
  unseen.value = 0;
16
16
  }
17
- watch(() => {
18
- var _a;
19
- return (_a = storyStore.currentVariant) == null ? void 0 : _a.id;
20
- }, () => {
17
+ watch(() => storyStore.currentVariant?.id, () => {
21
18
  reset();
22
19
  });
23
20
  return {
@@ -8,10 +8,7 @@ const useStoryStore = defineStore("story", () => {
8
8
  stories.value = value;
9
9
  }
10
10
  const currentStory = computed(() => stories.value.find((s) => s.id === router.currentRoute.value.params.storyId));
11
- const currentVariant = computed(() => {
12
- var _a;
13
- return (_a = currentStory.value) == null ? void 0 : _a.variants.find((v) => v.id === router.currentRoute.value.query.variantId);
14
- });
11
+ const currentVariant = computed(() => currentStory.value?.variants.find((v) => v.id === router.currentRoute.value.query.variantId));
15
12
  const maps = computed(() => {
16
13
  const storyMap = /* @__PURE__ */ new Map();
17
14
  const variantMap = /* @__PURE__ */ new Map();
@@ -9,13 +9,12 @@ const builtinCommands = [
9
9
  icon: "carbon:script-reference",
10
10
  showIf: ({ route }) => route.name === "story" && !!useStoryStore().currentStory,
11
11
  getParams: () => {
12
- var _a, _b, _c;
13
12
  const story = useStoryStore().currentStory;
14
13
  let file;
15
14
  if (story.docsOnly) {
16
- file = ((_a = story.file) == null ? void 0 : _a.docsFilePath) ?? ((_b = story.file) == null ? void 0 : _b.filePath);
15
+ file = story.file?.docsFilePath ?? story.file?.filePath;
17
16
  } else {
18
- file = (_c = story.file) == null ? void 0 : _c.filePath;
17
+ file = story.file?.filePath;
19
18
  }
20
19
  return {
21
20
  file
@@ -35,13 +34,12 @@ const builtinCommands = [
35
34
  }
36
35
  ];
37
36
  function executeCommand(command, params) {
38
- var _a;
39
37
  if (import.meta.hot) {
40
38
  import.meta.hot.send("histoire:dev-command", {
41
39
  id: command.id,
42
40
  params
43
41
  });
44
- (_a = command.clientAction) == null ? void 0 : _a.call(command, params, getCommandContext());
42
+ command.clientAction?.(params, getCommandContext());
45
43
  }
46
44
  }
47
45
  function getCommandContext() {
@@ -10,8 +10,7 @@ const isDark = useDark({
10
10
  });
11
11
  const toggleDark = useToggle(isDark);
12
12
  function applyDarkToControls() {
13
- var _a;
14
- (_a = window.__hst_controls_dark) == null ? void 0 : _a.forEach((ref) => {
13
+ window.__hst_controls_dark?.forEach((ref) => {
15
14
  ref.value = isDark.value;
16
15
  });
17
16
  }
@@ -2,22 +2,21 @@ import { unindent } from "@histoire/shared";
2
2
  import { clientSupportPlugins } from "virtual:$histoire-support-plugins-client";
3
3
  "use strict";
4
4
  async function getSourceCode(story, variant) {
5
- var _a, _b, _c, _d;
6
5
  if (variant.source) {
7
6
  return variant.source;
8
- } else if ((_a = variant.slots) == null ? void 0 : _a.call(variant).source) {
9
- const source = (_b = variant.slots) == null ? void 0 : _b.call(variant).source()[0].children;
7
+ } else if (variant.slots?.().source) {
8
+ const source = variant.slots?.().source()[0].children;
10
9
  if (source) {
11
10
  return unindent(source);
12
11
  }
13
12
  } else {
14
- const clientPlugin = clientSupportPlugins[(_c = story.file) == null ? void 0 : _c.supportPluginId];
13
+ const clientPlugin = clientSupportPlugins[story.file?.supportPluginId];
15
14
  if (clientPlugin) {
16
15
  const pluginModule = await clientPlugin();
17
16
  return pluginModule.generateSourceCode(variant);
18
17
  }
19
18
  }
20
- const sourceLoader = (_d = story.file) == null ? void 0 : _d.source;
19
+ const sourceLoader = story.file?.source;
21
20
  if (sourceLoader) {
22
21
  return (await sourceLoader()).default;
23
22
  }
@@ -1,7 +1,6 @@
1
1
  import { EVENT_SEND } from "./const.js";
2
2
  "use strict";
3
3
  async function logEvent(name, argument) {
4
- var _a;
5
4
  console.log("[histoire] Event fired", { name, argument });
6
5
  const event = {
7
6
  name,
@@ -9,7 +8,7 @@ async function logEvent(name, argument) {
9
8
  // Needed for HTMLEvent that can't be cloned
10
9
  };
11
10
  if (location.href.includes("__sandbox")) {
12
- (_a = window.parent) == null ? void 0 : _a.postMessage({
11
+ window.parent?.postMessage({
13
12
  type: EVENT_SEND,
14
13
  event
15
14
  });
@@ -12,8 +12,7 @@ function applyPreviewSettings(settings) {
12
12
  }
13
13
  }
14
14
  function getContrastColor(setting) {
15
- var _a;
16
- return ((_a = histoireConfig.backgroundPresets.find((preset) => preset.color === setting.backgroundColor)) == null ? void 0 : _a.contrastColor) ?? "unset";
15
+ return histoireConfig.backgroundPresets.find((preset) => preset.color === setting.backgroundColor)?.contrastColor ?? "unset";
17
16
  }
18
17
  export {
19
18
  applyPreviewSettings,
package/dist/style.css CHANGED
@@ -254,7 +254,6 @@
254
254
  height:.75rem;
255
255
  width:.75rem;
256
256
  -webkit-appearance:none;
257
- -moz-appearance:none;
258
257
  appearance:none;
259
258
  border-radius:9999px;
260
259
  border-width:1px;
@@ -281,7 +280,6 @@
281
280
  height:.75rem;
282
281
  width:.75rem;
283
282
  -moz-appearance:none;
284
- -webkit-appearance:none;
285
283
  appearance:none;
286
284
  border-radius:9999px;
287
285
  border-width:1px;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@histoire/app",
3
3
  "type": "module",
4
- "version": "1.0.0-alpha.2",
4
+ "version": "1.0.0-alpha.3",
5
5
  "description": "Pre-bundled UI for Histoire",
6
6
  "author": {
7
7
  "name": "Guillaume Chau"
@@ -26,9 +26,9 @@
26
26
  "dependencies": {
27
27
  "fuse.js": "^7.0.0",
28
28
  "shiki": "^3.0.0",
29
- "@histoire/shared": "^1.0.0-alpha.2",
30
- "@histoire/vendors": "^1.0.0-alpha.2",
31
- "@histoire/controls": "^1.0.0-alpha.2"
29
+ "@histoire/controls": "^1.0.0-alpha.3",
30
+ "@histoire/vendors": "^1.0.0-alpha.3",
31
+ "@histoire/shared": "^1.0.0-alpha.3"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@tailwindcss/typography": "^0.5.15",
@@ -45,7 +45,7 @@
45
45
  "postcss-import": "^16.1.0",
46
46
  "tailwindcss": "^3.4.16",
47
47
  "typescript": "5.6.3",
48
- "vite": "^6.0.5",
48
+ "vite": "^7.0.0",
49
49
  "vue": "^3.5.13"
50
50
  },
51
51
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Story, TreeGroup } from '../../types'
3
3
  import { Icon } from '@iconify/vue'
4
- import { computed, withDefaults } from 'vue'
4
+ import { computed } from 'vue'
5
5
  import { useFolderStore } from '../../stores/folder'
6
6
  import StoryListFolder from './StoryListFolder.vue'
7
7
  import StoryListItem from './StoryListItem.vue'
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Story, TreeFolder, TreeLeaf } from '../../types'
3
3
  import { Icon } from '@iconify/vue'
4
- import { computed, withDefaults } from 'vue'
4
+ import { computed } from 'vue'
5
5
  import { useFolderStore } from '../../stores/folder'
6
6
  import StoryListItem from './StoryListItem.vue'
7
7
 
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Story } from '../../types'
3
3
  import { Icon } from '@iconify/vue'
4
- import { computed, ref, withDefaults } from 'vue'
4
+ import { computed, ref } from 'vue'
5
5
  import { useRoute } from 'vue-router'
6
6
  import { useScrollOnActive } from '../../util/scroll'
7
7
  import BaseListItemLink from '../base/BaseListItemLink.vue'