@histoire/app 0.17.9 → 0.17.10

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.
@@ -47,11 +47,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
47
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
48
  });
49
49
  return (_ctx, _cache) => {
50
+ var _a;
50
51
  const _directive_tooltip = resolveDirective("tooltip");
51
52
  return comp.value ? (openBlock(), createBlock(resolveDynamicComponent(comp.value), {
52
53
  key: 0,
53
54
  modelValue: model.value,
54
55
  "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,
55
57
  class: "histoire-controls-component-prop-item",
56
58
  title: `${_ctx.definition.name}${canReset.value ? " *" : ""}`
57
59
  }, {
@@ -67,7 +69,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
67
69
  ])
68
70
  ]),
69
71
  _: 1
70
- }, 8, ["modelValue", "title"])) : createCommentVNode("", true);
72
+ }, 8, ["modelValue", "placeholder", "title"])) : createCommentVNode("", true);
71
73
  };
72
74
  }
73
75
  });
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./ControlsComponentState.vue2.js";
2
+ "use strict";
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,42 @@
1
+ import { defineComponent, computed, resolveDirective, openBlock, createElementBlock, createElementVNode, withDirectives, createVNode, unref, Fragment, renderList, createBlock } from "@histoire/vendors/vue";
2
+ import { Icon } from "@histoire/vendors/iconify";
3
+ import "./ControlsComponentStateItem.vue.js";
4
+ import _sfc_main$1 from "./ControlsComponentStateItem.vue2.js";
5
+ "use strict";
6
+ const _hoisted_1 = { class: "histoire-controls-component-init-state" };
7
+ const _hoisted_2 = { class: "htw-p-2 htw-flex htw-items-center htw-gap-1" };
8
+ const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", null, " State ", -1);
9
+ const _sfc_main = /* @__PURE__ */ defineComponent({
10
+ __name: "ControlsComponentState",
11
+ props: {
12
+ variant: {}
13
+ },
14
+ setup(__props) {
15
+ const props = __props;
16
+ const stateKeys = computed(() => Object.keys(props.variant.state || {}).filter((key) => !key.startsWith("_h")));
17
+ return (_ctx, _cache) => {
18
+ const _directive_tooltip = resolveDirective("tooltip");
19
+ return openBlock(), createElementBlock("div", _hoisted_1, [
20
+ createElementVNode("div", _hoisted_2, [
21
+ withDirectives(createVNode(unref(Icon), {
22
+ icon: "carbon:data-vis-1",
23
+ class: "htw-w-4 htw-h-4 htw-text-primary-500 htw-flex-none"
24
+ }, null, 512), [
25
+ [_directive_tooltip, "Auto-detected state"]
26
+ ]),
27
+ _hoisted_3
28
+ ]),
29
+ (openBlock(true), createElementBlock(Fragment, null, renderList(stateKeys.value, (key) => {
30
+ return openBlock(), createBlock(_sfc_main$1, {
31
+ key,
32
+ item: key,
33
+ variant: _ctx.variant
34
+ }, null, 8, ["item", "variant"]);
35
+ }), 128))
36
+ ]);
37
+ };
38
+ }
39
+ });
40
+ export {
41
+ _sfc_main as default
42
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./ControlsComponentStateItem.vue2.js";
2
+ "use strict";
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,46 @@
1
+ import { defineComponent, computed, openBlock, createBlock, resolveDynamicComponent, createCommentVNode } from "@histoire/vendors/vue";
2
+ import { HstJson, HstCheckbox, HstNumber, HstText } from "@histoire/controls";
3
+ "use strict";
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ __name: "ControlsComponentStateItem",
6
+ props: {
7
+ variant: {},
8
+ item: {}
9
+ },
10
+ setup(__props) {
11
+ const props = __props;
12
+ const comp = computed(() => {
13
+ switch (typeof props.variant.state[props.item]) {
14
+ case "string":
15
+ return HstText;
16
+ case "number":
17
+ return HstNumber;
18
+ case "boolean":
19
+ return HstCheckbox;
20
+ case "object":
21
+ default:
22
+ return HstJson;
23
+ }
24
+ });
25
+ const model = computed({
26
+ get: () => {
27
+ return props.variant.state[props.item];
28
+ },
29
+ set: (value) => {
30
+ props.variant.state[props.item] = value;
31
+ }
32
+ });
33
+ return (_ctx, _cache) => {
34
+ return comp.value ? (openBlock(), createBlock(resolveDynamicComponent(comp.value), {
35
+ key: 0,
36
+ modelValue: model.value,
37
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
38
+ class: "histoire-controls-component-prop-item",
39
+ title: props.item
40
+ }, null, 8, ["modelValue", "title"])) : createCommentVNode("", true);
41
+ };
42
+ }
43
+ });
44
+ export {
45
+ _sfc_main as default
46
+ };
@@ -1,20 +1,23 @@
1
- import { defineComponent, ref, watch, computed, openBlock, createElementBlock, createElementVNode, createBlock, createCommentVNode, withCtx, createVNode, unref, Fragment, renderList } from "@histoire/vendors/vue";
1
+ import { defineComponent, ref, watch, computed, openBlock, createElementBlock, createElementVNode, createBlock, createCommentVNode, createVNode, withCtx, unref, Fragment, renderList } from "@histoire/vendors/vue";
2
2
  import { Icon } from "@histoire/vendors/iconify";
3
3
  import "../story/GenericRenderStory.vue.js";
4
4
  import BaseEmpty from "../base/BaseEmpty.vue.js";
5
5
  import "./StatePresets.vue.js";
6
6
  import "./ControlsComponentProps.vue.js";
7
+ import "./ControlsComponentState.vue.js";
7
8
  import _sfc_main$1 from "./StatePresets.vue2.js";
8
9
  import _sfc_main$2 from "../story/GenericRenderStory.vue2.js";
9
- import _sfc_main$3 from "./ControlsComponentProps.vue2.js";
10
+ import _sfc_main$3 from "./ControlsComponentState.vue2.js";
11
+ import _sfc_main$4 from "./ControlsComponentProps.vue2.js";
10
12
  "use strict";
11
13
  const _hoisted_1 = {
12
14
  "data-test-id": "story-controls",
13
15
  class: "histoire-story-controls htw-flex htw-flex-col htw-divide-y htw-divide-gray-100 dark:htw-divide-gray-750"
14
16
  };
15
17
  const _hoisted_2 = { class: "htw-h-9 htw-flex-none htw-px-2 htw-flex htw-items-center" };
16
- const _hoisted_3 = /* @__PURE__ */ createElementVNode("span", null, "No controls available for this story", -1);
17
- const _hoisted_4 = { key: 2 };
18
+ const _hoisted_3 = { key: 1 };
19
+ const _hoisted_4 = /* @__PURE__ */ createElementVNode("span", null, "No controls available for this story", -1);
20
+ const _hoisted_5 = { key: 3 };
18
21
  const _sfc_main = /* @__PURE__ */ defineComponent({
19
22
  __name: "StoryControls",
20
23
  props: {
@@ -34,6 +37,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
34
37
  ready.value = false;
35
38
  });
36
39
  const hasCustomControls = computed(() => props.variant.slots().controls || props.story.slots().controls);
40
+ const hasInitState = computed(() => Object.entries(props.variant.state || {}).filter(([key]) => !key.startsWith("_h")).length > 0);
37
41
  return (_ctx, _cache) => {
38
42
  var _a, _b, _c, _d;
39
43
  return openBlock(), createElementBlock("div", _hoisted_1, [
@@ -51,19 +55,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
51
55
  story: __props.story,
52
56
  class: "__histoire-render-custom-controls htw-flex-none",
53
57
  onReady: _cache[0] || (_cache[0] = ($event) => ready.value = true)
54
- }, null, 8, ["variant", "story"])) : !((_b = (_a = __props.variant.state) == null ? void 0 : _a._hPropDefs) == null ? void 0 : _b.length) ? (openBlock(), createBlock(BaseEmpty, { key: 1 }, {
58
+ }, null, 8, ["variant", "story"])) : hasInitState.value ? (openBlock(), createElementBlock("div", _hoisted_3, [
59
+ createVNode(_sfc_main$3, {
60
+ class: "htw-flex-none htw-my-2",
61
+ variant: __props.variant
62
+ }, null, 8, ["variant"])
63
+ ])) : !((_b = (_a = __props.variant.state) == null ? void 0 : _a._hPropDefs) == null ? void 0 : _b.length) ? (openBlock(), createBlock(BaseEmpty, { key: 2 }, {
55
64
  default: withCtx(() => [
56
65
  createVNode(unref(Icon), {
57
66
  icon: "carbon:audio-console",
58
67
  class: "htw-w-8 htw-h-8 htw-opacity-50 htw-mb-6"
59
68
  }),
60
- _hoisted_3
69
+ _hoisted_4
61
70
  ]),
62
71
  _: 1
63
72
  })) : createCommentVNode("", true),
64
- ((_d = (_c = __props.variant.state) == null ? void 0 : _c._hPropDefs) == null ? void 0 : _d.length) ? (openBlock(), createElementBlock("div", _hoisted_4, [
73
+ ((_d = (_c = __props.variant.state) == null ? void 0 : _c._hPropDefs) == null ? void 0 : _d.length) ? (openBlock(), createElementBlock("div", _hoisted_5, [
65
74
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.variant.state._hPropDefs, (def, index) => {
66
- return openBlock(), createBlock(_sfc_main$3, {
75
+ return openBlock(), createBlock(_sfc_main$4, {
67
76
  key: index,
68
77
  variant: __props.variant,
69
78
  definition: def,
@@ -1,4 +1,24 @@
1
1
 
2
+ .htw-base-empty[data-v-c5ecfead]:not(.no-animation) {
3
+ animation: htw-base-empty-c5ecfead .15s .2s both;
4
+ }
5
+ @keyframes htw-base-empty-c5ecfead {
6
+ 0% {
7
+ opacity: 0;
8
+ }
9
+ 100% {
10
+ opacity: 1;
11
+ }
12
+ }
13
+
14
+ .bind-icon-color[data-v-6046525f] {
15
+ color: var(--663732b6);
16
+ }
17
+
18
+ .bind-icon-color[data-v-36846ccf] {
19
+ color: var(--5792748b);
20
+ }
21
+
2
22
  .landscape > div > .dragger[data-v-ed925107] {
3
23
  width: .625rem;
4
24
  }
@@ -24,28 +44,12 @@
24
44
  bottom: -.625rem;
25
45
  }
26
46
 
27
- .bind-icon-color[data-v-36846ccf] {
28
- color: var(--5792748b);
29
- }
30
-
31
- .htw-base-empty[data-v-c5ecfead]:not(.no-animation) {
32
- animation: htw-base-empty-c5ecfead .15s .2s both;
33
- }
34
- @keyframes htw-base-empty-c5ecfead {
35
- 0% {
36
- opacity: 0;
37
- }
38
- 100% {
39
- opacity: 1;
40
- }
41
- }
42
-
43
- .bind-icon-color[data-v-6046525f] {
44
- color: var(--663732b6);
47
+ .bind-icon-color[data-v-ab890d9c] {
48
+ color: var(--89126aaa);
45
49
  }
46
50
 
47
- .bind-tree-padding[data-v-2d2e4786] {
48
- padding-left: var(--6851b0a7);
51
+ .bind-icon-color[data-v-ddfc5b4f] {
52
+ color: var(--4d25d048);
49
53
  }
50
54
 
51
55
  .bind-tree-margin[data-v-19810958] {
@@ -55,12 +59,8 @@
55
59
  color: var(--ae892164);
56
60
  }
57
61
 
58
- .bind-icon-color[data-v-ab890d9c] {
59
- color: var(--89126aaa);
60
- }
61
-
62
- .bind-icon-color[data-v-ddfc5b4f] {
63
- color: var(--4d25d048);
62
+ .bind-tree-padding[data-v-2d2e4786] {
63
+ padding-left: var(--6851b0a7);
64
64
  }
65
65
 
66
66
  .__histoire-code-placeholder[data-v-1bdf9905] {
@@ -68,10 +68,6 @@
68
68
  font-size: inherit;
69
69
  }
70
70
 
71
- .bind-icon-color[data-v-6c8e9661] {
72
- color: var(--a8c1277e);
73
- }
74
-
75
71
  .bind-icon-color[data-v-cf76cd68] {
76
72
  color: var(--29d8c174);
77
73
  }
@@ -84,14 +80,18 @@
84
80
  color: var(--35068428);
85
81
  }
86
82
 
87
- img.colorize-black[data-v-74182813] {
88
- filter: grayscale(100) brightness(0);
83
+ .bind-icon-color[data-v-6c8e9661] {
84
+ color: var(--a8c1277e);
89
85
  }
90
86
 
91
87
  .bind-preview-bg[data-v-a83b1911] {
92
88
  background-color: var(--03d1950e);
93
89
  }
94
90
 
91
+ img.colorize-black[data-v-74182813] {
92
+ filter: grayscale(100) brightness(0);
93
+ }
94
+
95
95
  .__histoire-hatched-pattern[data-v-91561117] {
96
96
  background: repeating-linear-gradient(135deg,
97
97
  transparent 0px,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@histoire/app",
3
- "version": "0.17.9",
3
+ "version": "0.17.10",
4
4
  "description": "Pre-bundled UI for Histoire",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -28,7 +28,7 @@
28
28
  "flexsearch": "0.7.21",
29
29
  "shiki-es": "^0.2.0",
30
30
  "@histoire/controls": "^0.17.9",
31
- "@histoire/shared": "^0.17.9",
31
+ "@histoire/shared": "^0.17.10",
32
32
  "@histoire/vendors": "^0.17.8"
33
33
  },
34
34
  "devDependencies": {
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { computed, ref } from 'vue'
2
+ import { computed } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
4
  import type { AutoPropComponentDefinition, PropDefinition } from '@histoire/shared'
5
5
  import { HstCheckbox, HstJson, HstNumber, HstText } from '@histoire/controls'
@@ -54,6 +54,7 @@ const canReset = computed(() => props.variant.state?._hPropState?.[props.compone
54
54
  :is="comp"
55
55
  v-if="comp"
56
56
  v-model="model"
57
+ :placeholder="model === undefined ? definition?.default : null"
57
58
  class="histoire-controls-component-prop-item"
58
59
  :title="`${definition.name}${canReset ? ' *' : ''}`"
59
60
  >
@@ -0,0 +1,38 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import { Icon } from '@iconify/vue'
4
+ import type { Variant } from '@histoire/shared'
5
+ import ControlsComponentStateItem from './ControlsComponentStateItem.vue'
6
+
7
+ const props = defineProps<{
8
+ variant: Variant
9
+ }>()
10
+
11
+ const stateKeys = computed(() => Object.keys(props.variant.state || {})
12
+ .filter((key) => !key.startsWith('_h')))
13
+ </script>
14
+
15
+ <template>
16
+ <div class="histoire-controls-component-init-state">
17
+ <div class="htw-p-2 htw-flex htw-items-center htw-gap-1">
18
+ <Icon
19
+ v-tooltip="'Auto-detected state'"
20
+ icon="carbon:data-vis-1"
21
+ class="htw-w-4 htw-h-4 htw-text-primary-500 htw-flex-none"
22
+ />
23
+ <div>
24
+ State
25
+ </div>
26
+ </div>
27
+ <ControlsComponentStateItem
28
+ v-for="key of stateKeys"
29
+ :key="key"
30
+ :item="key"
31
+ :variant="variant"
32
+ />
33
+ </div>
34
+ </template>
35
+
36
+ <style scoped>
37
+
38
+ </style>
@@ -0,0 +1,44 @@
1
+ <script lang="ts" setup>
2
+ import { computed } from 'vue'
3
+ import { HstCheckbox, HstJson, HstNumber, HstText } from '@histoire/controls'
4
+ import type { Variant } from '../../types'
5
+
6
+ const props = defineProps<{
7
+ variant: Variant
8
+ item: string
9
+ }>()
10
+
11
+ const comp = computed(() => {
12
+ switch (typeof props.variant.state[props.item]) {
13
+ case 'string':
14
+ return HstText
15
+ case 'number':
16
+ return HstNumber
17
+ case 'boolean':
18
+ return HstCheckbox
19
+ case 'object':
20
+ default:
21
+ return HstJson
22
+ }
23
+ })
24
+
25
+ const model = computed({
26
+ get: () => {
27
+ return props.variant.state[props.item]
28
+ },
29
+ set: (value) => {
30
+ // eslint-disable-next-line vue/no-mutating-props
31
+ props.variant.state[props.item] = value
32
+ },
33
+ })
34
+ </script>
35
+
36
+ <template>
37
+ <component
38
+ :is="comp"
39
+ v-if="comp"
40
+ v-model="model"
41
+ class="histoire-controls-component-prop-item"
42
+ :title="props.item"
43
+ />
44
+ </template>
@@ -6,6 +6,7 @@ import type { Story, Variant } from '../../types'
6
6
  import BaseEmpty from '../base/BaseEmpty.vue'
7
7
  import StatePresets from './StatePresets.vue'
8
8
  import ControlsComponentProps from './ControlsComponentProps.vue'
9
+ import ControlsComponentState from './ControlsComponentState.vue'
9
10
 
10
11
  const props = defineProps({
11
12
  variant: {
@@ -27,6 +28,12 @@ watch(() => props.variant, () => {
27
28
  })
28
29
 
29
30
  const hasCustomControls = computed(() => props.variant.slots().controls || props.story.slots().controls)
31
+
32
+ const hasInitState = computed(() => Object
33
+ .entries(props.variant.state || {})
34
+ .filter(([key]) => !key.startsWith('_h'))
35
+ .length > 0)
36
+
30
37
  </script>
31
38
 
32
39
  <template>
@@ -56,6 +63,16 @@ const hasCustomControls = computed(() => props.variant.slots().controls || props
56
63
  @ready="ready = true"
57
64
  />
58
65
 
66
+ <!-- Init state -->
67
+ <div
68
+ v-else-if="hasInitState"
69
+ >
70
+ <ControlsComponentState
71
+ class="htw-flex-none htw-my-2"
72
+ :variant="variant"
73
+ />
74
+ </div>
75
+
59
76
  <BaseEmpty v-else-if="!variant.state?._hPropDefs?.length">
60
77
  <Icon
61
78
  icon="carbon:audio-console"