@histoire/controls 0.3.1 → 0.4.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.
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
2
+ export default _default;
@@ -0,0 +1,43 @@
1
+ import { PropType } from 'vue';
2
+ export interface HstSelectOptions {
3
+ label: string;
4
+ value: string;
5
+ }
6
+ declare const _default: import("vue").DefineComponent<{
7
+ title: {
8
+ type: StringConstructor;
9
+ default: string;
10
+ };
11
+ modelValue: {
12
+ type: StringConstructor;
13
+ default: any;
14
+ };
15
+ options: {
16
+ type: PropType<string[] | HstSelectOptions[]>;
17
+ required: true;
18
+ default: () => any[];
19
+ };
20
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
21
+ 'update:modelValue': (newValue: string) => true;
22
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
23
+ title: {
24
+ type: StringConstructor;
25
+ default: string;
26
+ };
27
+ modelValue: {
28
+ type: StringConstructor;
29
+ default: any;
30
+ };
31
+ options: {
32
+ type: PropType<string[] | HstSelectOptions[]>;
33
+ required: true;
34
+ default: () => any[];
35
+ };
36
+ }>> & {
37
+ "onUpdate:modelValue"?: (newValue: string) => any;
38
+ }, {
39
+ title: string;
40
+ modelValue: string;
41
+ options: string[] | HstSelectOptions[];
42
+ }>;
43
+ export default _default;
package/dist/index.es.js CHANGED
@@ -29,7 +29,7 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { pushScopeId, popScopeId, defineComponent, nextTick, openBlock, createBlock, withScopeId, resolveComponent, createElementBlock, normalizeClass, normalizeStyle, withKeys, createElementVNode, Fragment, renderSlot, createCommentVNode, mergeProps, withCtx, createVNode, ref, createApp, h, toDisplayString, withDirectives, createTextVNode, unref, computed, watch, withModifiers, onUnmounted, isRef, vModelText, getCurrentScope, onScopeDispose, renderList } from "vue";
32
+ import { pushScopeId, popScopeId, defineComponent, nextTick, openBlock, createBlock, withScopeId, resolveComponent, createElementBlock, normalizeClass, normalizeStyle, withKeys, createElementVNode, Fragment, renderSlot, createCommentVNode, mergeProps, withCtx, createVNode, ref, createApp, h, toDisplayString, withDirectives, createTextVNode, unref, computed, watch, withModifiers, onUnmounted, isRef, vModelText, renderList, getCurrentScope, onScopeDispose } from "vue";
33
33
  function getBasePlacement(placement) {
34
34
  return placement.split("-")[0];
35
35
  }
@@ -1486,7 +1486,8 @@ var PrivatePopper = () => defineComponent({
1486
1486
  classes: __spreadProps2(__spreadValues2({}, this.classes), {
1487
1487
  popperClass: this.popperClass
1488
1488
  }),
1489
- result: this.positioningDisabled ? null : this.result
1489
+ result: this.positioningDisabled ? null : this.result,
1490
+ attrs: this.$attrs
1490
1491
  };
1491
1492
  },
1492
1493
  parentPopper() {
@@ -2465,19 +2466,22 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
2465
2466
  handleResize,
2466
2467
  onResize,
2467
2468
  classes,
2468
- result
2469
+ result,
2470
+ attrs
2469
2471
  }) => [
2470
- createElementVNode("div", {
2472
+ createElementVNode("div", mergeProps({
2471
2473
  ref: "reference",
2472
- class: normalizeClass(["v-popper", [
2474
+ class: "v-popper"
2475
+ }, attrs, {
2476
+ class: [
2473
2477
  _ctx.$attrs.class,
2474
2478
  _ctx.themeClass,
2475
2479
  {
2476
2480
  "v-popper--shown": isShown
2477
2481
  }
2478
- ]]),
2479
- style: normalizeStyle(_ctx.$attrs.style)
2480
- }, [
2482
+ ],
2483
+ style: _ctx.$attrs.style
2484
+ }), [
2481
2485
  renderSlot(_ctx.$slots, "default", {
2482
2486
  shown: isShown,
2483
2487
  show,
@@ -2505,7 +2509,7 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
2505
2509
  ]),
2506
2510
  _: 2
2507
2511
  }, 1032, ["popper-id", "theme", "shown", "mounted", "skip-transition", "auto-hide", "handle-resize", "classes", "result", "onHide", "onResize"])
2508
- ], 6)
2512
+ ], 16)
2509
2513
  ]),
2510
2514
  _: 3
2511
2515
  }, 16, ["theme", "target-nodes", "reference-node", "popper-node"]);
@@ -2523,7 +2527,7 @@ defineComponent(__spreadProps2(__spreadValues2({}, PrivatePopperWrapper), {
2523
2527
  name: "VTooltip",
2524
2528
  vPopperTheme: "tooltip"
2525
2529
  }));
2526
- const _sfc_main$9 = defineComponent({
2530
+ const _sfc_main$a = defineComponent({
2527
2531
  name: "VTooltipDirective",
2528
2532
  components: {
2529
2533
  Popper: PrivatePopper(),
@@ -2614,8 +2618,8 @@ const _sfc_main$9 = defineComponent({
2614
2618
  }
2615
2619
  }
2616
2620
  });
2617
- const _hoisted_1$7 = ["innerHTML"];
2618
- const _hoisted_2$5 = ["textContent"];
2621
+ const _hoisted_1$8 = ["innerHTML"];
2622
+ const _hoisted_2$6 = ["textContent"];
2619
2623
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
2620
2624
  const _component_PopperContent = resolveComponent("PopperContent");
2621
2625
  const _component_Popper = resolveComponent("Popper");
@@ -2658,10 +2662,10 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
2658
2662
  _ctx.html ? (openBlock(), createElementBlock("div", {
2659
2663
  key: 0,
2660
2664
  innerHTML: _ctx.finalContent
2661
- }, null, 8, _hoisted_1$7)) : (openBlock(), createElementBlock("div", {
2665
+ }, null, 8, _hoisted_1$8)) : (openBlock(), createElementBlock("div", {
2662
2666
  key: 1,
2663
2667
  textContent: toDisplayString(_ctx.finalContent)
2664
- }, null, 8, _hoisted_2$5))
2668
+ }, null, 8, _hoisted_2$6))
2665
2669
  ]),
2666
2670
  _: 2
2667
2671
  }, 1032, ["class", "popper-id", "theme", "shown", "mounted", "skip-transition", "auto-hide", "handle-resize", "classes", "result", "onHide", "onResize"])
@@ -2669,7 +2673,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
2669
2673
  _: 1
2670
2674
  }, 16, ["theme", "popper-node", "onApplyShow", "onApplyHide"]);
2671
2675
  }
2672
- var PrivateTooltipDirective = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render]]);
2676
+ var PrivateTooltipDirective = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render]]);
2673
2677
  const TARGET_CLASS = "v-popper--has-tooltip";
2674
2678
  function getPlacement(options2, modifiers) {
2675
2679
  let result = options2.placement;
@@ -2794,20 +2798,20 @@ var PrivateVTooltip = {
2794
2798
  }
2795
2799
  };
2796
2800
  const VTooltip = PrivateVTooltip;
2797
- const _hoisted_1$6 = { class: "htw-p-2 hover:htw-bg-primary-100 dark:hover:htw-bg-primary-800 htw-flex htw-gap-2 htw-flex-wrap" };
2798
- const _hoisted_2$4 = { class: "htw-w-28 htw-whitespace-nowrap htw-text-ellipsis htw-overflow-hidden htw-shrink-0" };
2801
+ const _hoisted_1$7 = { class: "htw-p-2 hover:htw-bg-primary-100 dark:hover:htw-bg-primary-800 htw-flex htw-gap-2 htw-flex-wrap" };
2802
+ const _hoisted_2$5 = { class: "htw-w-28 htw-whitespace-nowrap htw-text-ellipsis htw-overflow-hidden htw-shrink-0" };
2799
2803
  const _hoisted_3$4 = { class: "htw-block htw-grow" };
2800
- const __default__$8 = {
2804
+ const __default__$9 = {
2801
2805
  name: "HstWrapper"
2802
2806
  };
2803
- const _sfc_main$8 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$8), {
2807
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$9), {
2804
2808
  props: {
2805
2809
  title: null
2806
2810
  },
2807
2811
  setup(__props) {
2808
2812
  return (_ctx, _cache) => {
2809
- return openBlock(), createElementBlock("label", _hoisted_1$6, [
2810
- withDirectives((openBlock(), createElementBlock("span", _hoisted_2$4, [
2813
+ return openBlock(), createElementBlock("label", _hoisted_1$7, [
2814
+ withDirectives((openBlock(), createElementBlock("span", _hoisted_2$5, [
2811
2815
  createTextVNode(toDisplayString(__props.title), 1)
2812
2816
  ])), [
2813
2817
  [unref(VTooltip), {
@@ -2823,18 +2827,18 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
2823
2827
  };
2824
2828
  }
2825
2829
  }));
2826
- const _hoisted_1$5 = { class: "htw-text-white htw-w-[16px] htw-h-[16px] htw-relative" };
2827
- const _hoisted_2$3 = {
2830
+ const _hoisted_1$6 = { class: "htw-text-white htw-w-[16px] htw-h-[16px] htw-relative" };
2831
+ const _hoisted_2$4 = {
2828
2832
  width: "16",
2829
2833
  height: "16",
2830
2834
  viewBox: "0 0 24 24",
2831
2835
  class: "htw-relative htw-z-10"
2832
2836
  };
2833
2837
  const _hoisted_3$3 = ["stroke-dasharray", "stroke-dashoffset"];
2834
- const __default__$7 = {
2838
+ const __default__$8 = {
2835
2839
  name: "HstCheckbox"
2836
2840
  };
2837
- const _sfc_main$7 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$7), {
2841
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$8), {
2838
2842
  props: {
2839
2843
  modelValue: { type: Boolean },
2840
2844
  title: null
@@ -2858,7 +2862,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
2858
2862
  dasharray.value = (_c = (_b2 = (_a2 = path.value).getTotalLength) == null ? void 0 : _b2.call(_a2)) != null ? _c : 21.21;
2859
2863
  });
2860
2864
  return (_ctx, _cache) => {
2861
- return openBlock(), createBlock(_sfc_main$8, {
2865
+ return openBlock(), createBlock(_sfc_main$9, {
2862
2866
  role: "checkbox",
2863
2867
  tabindex: "0",
2864
2868
  class: "htw-cursor-pointer htw-items-center",
@@ -2870,13 +2874,13 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
2870
2874
  ]
2871
2875
  }, {
2872
2876
  default: withCtx(() => [
2873
- createElementVNode("div", _hoisted_1$5, [
2877
+ createElementVNode("div", _hoisted_1$6, [
2874
2878
  createElementVNode("div", {
2875
2879
  class: normalizeClass(["htw-border htw-border-solid group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out", [
2876
2880
  __props.modelValue ? "htw-border-primary-500 htw-border-8" : "htw-border-black/25 dark:htw-border-white/25 htw-delay-150"
2877
2881
  ]])
2878
2882
  }, null, 2),
2879
- (openBlock(), createElementBlock("svg", _hoisted_2$3, [
2883
+ (openBlock(), createElementBlock("svg", _hoisted_2$4, [
2880
2884
  createElementVNode("path", {
2881
2885
  ref_key: "path",
2882
2886
  ref: path,
@@ -2899,11 +2903,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
2899
2903
  };
2900
2904
  }
2901
2905
  }));
2902
- const _hoisted_1$4 = ["value"];
2903
- const __default__$6 = {
2906
+ const _hoisted_1$5 = ["value"];
2907
+ const __default__$7 = {
2904
2908
  name: "HstText"
2905
2909
  };
2906
- const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$6), {
2910
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$7), {
2907
2911
  props: {
2908
2912
  title: null,
2909
2913
  modelValue: null
@@ -2914,7 +2918,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
2914
2918
  setup(__props, { emit }) {
2915
2919
  const input = ref();
2916
2920
  return (_ctx, _cache) => {
2917
- return openBlock(), createBlock(_sfc_main$8, {
2921
+ return openBlock(), createBlock(_sfc_main$9, {
2918
2922
  title: __props.title,
2919
2923
  class: normalizeClass(["htw-cursor-text htw-items-center", _ctx.$attrs.class]),
2920
2924
  style: normalizeStyle(_ctx.$attrs.style),
@@ -2929,18 +2933,18 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
2929
2933
  value: __props.modelValue,
2930
2934
  class: "htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-px-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm",
2931
2935
  onInput: _cache[0] || (_cache[0] = ($event) => emit("update:modelValue", $event.target.value))
2932
- }), null, 16, _hoisted_1$4)
2936
+ }), null, 16, _hoisted_1$5)
2933
2937
  ]),
2934
2938
  _: 1
2935
2939
  }, 8, ["title", "class", "style"]);
2936
2940
  };
2937
2941
  }
2938
2942
  }));
2939
- const __default__$5 = {
2943
+ const __default__$6 = {
2940
2944
  name: "HstNumber",
2941
2945
  inheritAttrs: false
2942
2946
  };
2943
- const _sfc_main$5 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$5), {
2947
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$6), {
2944
2948
  props: {
2945
2949
  title: null,
2946
2950
  modelValue: null
@@ -2987,7 +2991,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
2987
2991
  stopDragging();
2988
2992
  });
2989
2993
  return (_ctx, _cache) => {
2990
- return openBlock(), createBlock(_sfc_main$8, {
2994
+ return openBlock(), createBlock(_sfc_main$9, {
2991
2995
  class: normalizeClass(["htw-cursor-ew-resize htw-items-center", [
2992
2996
  _ctx.$attrs.class,
2993
2997
  { "htw-select-none": isDragging.value }
@@ -3021,12 +3025,12 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
3021
3025
  };
3022
3026
  }
3023
3027
  }));
3024
- const _hoisted_1$3 = ["value"];
3025
- const __default__$4 = {
3028
+ const _hoisted_1$4 = ["value"];
3029
+ const __default__$5 = {
3026
3030
  name: "HstTextarea",
3027
3031
  inheritAttrs: false
3028
3032
  };
3029
- const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$4), {
3033
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$5), {
3030
3034
  props: {
3031
3035
  title: null,
3032
3036
  modelValue: null
@@ -3037,7 +3041,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
3037
3041
  setup(__props, { emit }) {
3038
3042
  const input = ref();
3039
3043
  return (_ctx, _cache) => {
3040
- return openBlock(), createBlock(_sfc_main$8, {
3044
+ return openBlock(), createBlock(_sfc_main$9, {
3041
3045
  title: __props.title,
3042
3046
  class: normalizeClass(["htw-cursor-text", _ctx.$attrs.class]),
3043
3047
  style: normalizeStyle(_ctx.$attrs.style),
@@ -3051,7 +3055,64 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
3051
3055
  value: __props.modelValue,
3052
3056
  class: "htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-px-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm htw-box-border htw-resize-y htw-min-h-[26px]",
3053
3057
  onInput: _cache[0] || (_cache[0] = ($event) => emit("update:modelValue", $event.target.value))
3054
- }), null, 16, _hoisted_1$3)
3058
+ }), null, 16, _hoisted_1$4)
3059
+ ]),
3060
+ _: 1
3061
+ }, 8, ["title", "class", "style"]);
3062
+ };
3063
+ }
3064
+ }));
3065
+ const _hoisted_1$3 = ["value"];
3066
+ const _hoisted_2$3 = ["value"];
3067
+ const __default__$4 = {
3068
+ name: "HstSelect"
3069
+ };
3070
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$4), {
3071
+ props: {
3072
+ title: {
3073
+ type: String,
3074
+ default: ""
3075
+ },
3076
+ modelValue: {
3077
+ type: String,
3078
+ default: null
3079
+ },
3080
+ options: {
3081
+ type: Array,
3082
+ required: true,
3083
+ default: () => []
3084
+ }
3085
+ },
3086
+ emits: {
3087
+ "update:modelValue": (newValue) => true
3088
+ },
3089
+ setup(__props, { emit }) {
3090
+ const props = __props;
3091
+ const formattedOtions = computed(() => props.options.map((option) => typeof option === "string" ? { label: option, value: option } : option));
3092
+ const select = ref();
3093
+ return (_ctx, _cache) => {
3094
+ return openBlock(), createBlock(_sfc_main$9, {
3095
+ title: __props.title,
3096
+ class: normalizeClass(["htw-cursor-text htw-items-center", _ctx.$attrs.class]),
3097
+ style: normalizeStyle(_ctx.$attrs.style),
3098
+ onClick: _cache[1] || (_cache[1] = ($event) => select.value.focus())
3099
+ }, {
3100
+ default: withCtx(() => [
3101
+ createElementVNode("select", {
3102
+ ref_key: "select",
3103
+ ref: select,
3104
+ class: "htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-px-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm",
3105
+ value: __props.modelValue,
3106
+ onInput: _cache[0] || (_cache[0] = ($event) => emit("update:modelValue", $event.target.value))
3107
+ }, [
3108
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(formattedOtions), ({ label, value }) => {
3109
+ return openBlock(), createElementBlock("option", mergeProps(__spreadProps(__spreadValues({}, _ctx.$attrs), { class: null, style: null }), {
3110
+ key: label,
3111
+ class: "dark:htw-bg-gray-600",
3112
+ value
3113
+ }), toDisplayString(label), 17, _hoisted_2$3);
3114
+ }), 128))
3115
+ ], 40, _hoisted_1$3)
3055
3116
  ]),
3056
3117
  _: 1
3057
3118
  }, 8, ["title", "class", "style"]);
@@ -5265,19 +5326,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
5265
5326
  };
5266
5327
  }
5267
5328
  }));
5268
- const HstCheckbox = _sfc_main$7;
5269
- const HstText = _sfc_main$6;
5270
- const HstNumber = _sfc_main$5;
5271
- const HstTextarea = _sfc_main$4;
5329
+ const HstCheckbox = _sfc_main$8;
5330
+ const HstText = _sfc_main$7;
5331
+ const HstNumber = _sfc_main$6;
5332
+ const HstTextarea = _sfc_main$5;
5272
5333
  const HstColorShades = _sfc_main$2;
5273
5334
  const HstTokenList = _sfc_main$1;
5274
5335
  const HstTokenGrid = _sfc_main;
5275
5336
  const HstCopyIcon = _sfc_main$3;
5276
5337
  function registerVueComponents(app) {
5277
- app.component("HstCheckbox", _sfc_main$7);
5278
- app.component("HstText", _sfc_main$6);
5279
- app.component("HstNumber", _sfc_main$5);
5280
- app.component("HstTextarea", _sfc_main$4);
5338
+ app.component("HstCheckbox", _sfc_main$8);
5339
+ app.component("HstText", _sfc_main$7);
5340
+ app.component("HstNumber", _sfc_main$6);
5341
+ app.component("HstSelect", _sfc_main$4);
5342
+ app.component("HstTextarea", _sfc_main$5);
5281
5343
  app.component("HstColorShades", _sfc_main$2);
5282
5344
  app.component("HstTokenList", _sfc_main$1);
5283
5345
  app.component("HstTokenGrid", _sfc_main);
@@ -505,6 +505,11 @@
505
505
  background-color:transparent
506
506
  }
507
507
 
508
+ .htw-bg-gray-50{
509
+ --tw-bg-opacity:1;
510
+ background-color:rgb(250 250 250 / var(--tw-bg-opacity))
511
+ }
512
+
508
513
  .htw-stroke-white{
509
514
  stroke:#fff
510
515
  }
@@ -517,6 +522,10 @@
517
522
  padding:0.5rem
518
523
  }
519
524
 
525
+ .htw-p-4{
526
+ padding:1rem
527
+ }
528
+
520
529
  .htw-py-1{
521
530
  padding-top:0.25rem;
522
531
  padding-bottom:0.25rem
@@ -536,6 +545,11 @@
536
545
  line-height:1
537
546
  }
538
547
 
548
+ .htw-text-xs{
549
+ font-size:0.75rem;
550
+ line-height:1rem
551
+ }
552
+
539
553
  .htw-text-white{
540
554
  --tw-text-opacity:1;
541
555
  color:rgb(255 255 255 / var(--tw-text-opacity))
@@ -637,6 +651,11 @@ body {
637
651
  background-color:rgb(0 0 0 / var(--tw-bg-opacity))
638
652
  }
639
653
 
654
+ .htw-dark .dark\:htw-bg-gray-600{
655
+ --tw-bg-opacity:1;
656
+ background-color:rgb(82 82 91 / var(--tw-bg-opacity))
657
+ }
658
+
640
659
  .htw-dark .dark\:hover\:htw-bg-primary-800:hover{
641
660
  --tw-bg-opacity:1;
642
661
  background-color:rgb(6 95 70 / var(--tw-bg-opacity))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@histoire/controls",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Prebuilt controls components",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@iconify/vue": "^3.2.1",
35
35
  "@vueuse/core": "^8.2.5",
36
- "floating-vue": "^2.0.0-beta.14"
36
+ "floating-vue": "^2.0.0-beta.16"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@peeky/test": "^0.13.5",
@@ -43,8 +43,8 @@
43
43
  "@vueuse/core": "^8.2.5",
44
44
  "autoprefixer": "^10.4.4",
45
45
  "concurrently": "^7.1.0",
46
- "floating-vue": "^2.0.0-beta.14",
47
- "histoire": "0.3.1",
46
+ "floating-vue": "^2.0.0-beta.16",
47
+ "histoire": "0.4.0",
48
48
  "postcss": "^8.4.12",
49
49
  "postcss-import": "^14.1.0",
50
50
  "tailwindcss": "^3.0.23",
@@ -0,0 +1,110 @@
1
+ <script lang="ts" setup>
2
+ import HstSelect from './HstSelect.vue'
3
+
4
+ const options = [
5
+ { label: 'Crash Bandicoot', value: 'crash-bandicoot' },
6
+ { label: 'The Last of Us', value: 'the-last-of-us' },
7
+ { label: 'Ghost of Tsushima', value: 'ghost-of-tsushima' },
8
+ ]
9
+
10
+ const flatOptions = options.map(option => option.label)
11
+
12
+ function initState () {
13
+ return {
14
+ label: 'My really long label',
15
+ select: 'crash-bandicoot',
16
+ }
17
+ }
18
+ </script>
19
+
20
+ <template>
21
+ <Story
22
+ title="HstSelect"
23
+ :layout="{
24
+ type: 'grid',
25
+ width: '100%',
26
+ }"
27
+ >
28
+ <Variant
29
+ title="default"
30
+ :init-state="initState"
31
+ >
32
+ <template #default="{ state }">
33
+ <HstSelect
34
+ v-model="state.select"
35
+ :title="state.label"
36
+ :options="options"
37
+ />
38
+ </template>
39
+
40
+ <template #controls="{ state }">
41
+ <HstSelect
42
+ v-model="state.select"
43
+ title="Select"
44
+ :options="options"
45
+ />
46
+ </template>
47
+ </Variant>
48
+
49
+ <Variant
50
+ title="no-label"
51
+ :init-state="initState"
52
+ >
53
+ <template #default="{ state }">
54
+ <HstSelect
55
+ v-model="state.select"
56
+ :options="options"
57
+ />
58
+ </template>
59
+ <template #controls="{ state }">
60
+ <HstSelect
61
+ v-model="state.select"
62
+ title="Select"
63
+ :options="options"
64
+ />
65
+ </template>
66
+ </Variant>
67
+
68
+ <Variant
69
+ title="options-as-array-of-objects"
70
+ :init-state="initState"
71
+ >
72
+ <template #default="{ state }">
73
+ <pre class="htw-text-xs htw-bg-gray-50 dark:htw-bg-gray-600 htw-rounded htw-p-4">{{ options }}</pre>
74
+ <HstSelect
75
+ v-model="state.select"
76
+ title="Games"
77
+ :options="options"
78
+ />
79
+ </template>
80
+ <template #controls="{ state }">
81
+ <HstSelect
82
+ v-model="state.select"
83
+ title="Games"
84
+ :options="options"
85
+ />
86
+ </template>
87
+ </Variant>
88
+
89
+ <Variant
90
+ title="options-as-array-of-strings"
91
+ :init-state="initState"
92
+ >
93
+ <template #default="{ state }">
94
+ <pre class="htw-text-xs htw-bg-gray-50 dark:htw-bg-gray-600 htw-rounded htw-p-4">{{ flatOptions }}</pre>
95
+ <HstSelect
96
+ v-model="state.select"
97
+ title="Select"
98
+ :options="flatOptions"
99
+ />
100
+ </template>
101
+ <template #controls="{ state }">
102
+ <HstSelect
103
+ v-model="state.select"
104
+ title="Select"
105
+ :options="flatOptions"
106
+ />
107
+ </template>
108
+ </Variant>
109
+ </Story>
110
+ </template>
@@ -0,0 +1,67 @@
1
+ <script lang="ts">
2
+ export default {
3
+ name: 'HstSelect',
4
+ }
5
+ </script>
6
+
7
+ <script lang="ts" setup>
8
+ import { ref, computed, ComputedRef, PropType } from 'vue'
9
+ import HstWrapper from '../HstWrapper.vue'
10
+
11
+ export interface HstSelectOptions {
12
+ label: string
13
+ value: string
14
+ }
15
+
16
+ const props = defineProps({
17
+ title: {
18
+ type: String,
19
+ default: '',
20
+ },
21
+ modelValue: {
22
+ type: String,
23
+ default: null,
24
+ },
25
+ options: {
26
+ type: Array as PropType<HstSelectOptions[] | string[]>,
27
+ required: true,
28
+ default: () => [],
29
+ },
30
+ })
31
+
32
+ const formattedOtions: ComputedRef<HstSelectOptions[]> =
33
+ computed(() => props.options.map(option => typeof option === 'string' ? { label: option, value: option } as HstSelectOptions : option as HstSelectOptions))
34
+
35
+ const emit = defineEmits({
36
+ 'update:modelValue': (newValue: string) => true,
37
+ })
38
+
39
+ const select = ref<HTMLInputElement>()
40
+ </script>
41
+
42
+ <template>
43
+ <HstWrapper
44
+ :title="title"
45
+ class="htw-cursor-text htw-items-center"
46
+ :class="$attrs.class"
47
+ :style="$attrs.style"
48
+ @click="select.focus()"
49
+ >
50
+ <select
51
+ ref="select"
52
+ class="htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-px-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm"
53
+ :value="modelValue"
54
+ @input="emit('update:modelValue', ($event.target as HTMLInputElement).value)"
55
+ >
56
+ <option
57
+ v-for="{ label, value } in formattedOtions"
58
+ v-bind="{ ...$attrs, class: null, style: null }"
59
+ :key="label"
60
+ class="dark:htw-bg-gray-600"
61
+ :value="value"
62
+ >
63
+ {{ label }}
64
+ </option>
65
+ </select>
66
+ </HstWrapper>
67
+ </template>
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ import HstCheckboxVue from './components/checkbox/HstCheckbox.vue'
3
3
  import HstTextVue from './components/text/HstText.vue'
4
4
  import HstNumberVue from './components/number/HstNumber.vue'
5
5
  import HstTextareaVue from './components/textarea/HstTextarea.vue'
6
+ import HstSelectVue from './components/select/HstSelect.vue'
6
7
  import HstColorShadesVue from './components/design-tokens/HstColorShades.vue'
7
8
  import HstTokenListVue from './components/design-tokens/HstTokenList.vue'
8
9
  import HstTokenGridVue from './components/design-tokens/HstTokenGrid.vue'
@@ -21,6 +22,7 @@ export function registerVueComponents (app: App) {
21
22
  app.component('HstCheckbox', HstCheckboxVue)
22
23
  app.component('HstText', HstTextVue)
23
24
  app.component('HstNumber', HstNumberVue)
25
+ app.component('HstSelect', HstSelectVue)
24
26
  app.component('HstTextarea', HstTextareaVue)
25
27
  app.component('HstColorShades', HstColorShadesVue)
26
28
  app.component('HstTokenList', HstTokenListVue)