@histoire/controls 0.4.3 → 0.4.6
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/dist/components/select/CustomSelect.vue.d.ts +25 -0
- package/dist/components/select/HstSelect.vue.d.ts +23 -41
- package/dist/index.es.js +130 -90
- package/dist/style-standalone.css +56 -0
- package/dist/style.css +1 -1
- package/package.json +3 -3
- package/src/components/select/CustomSelect.vue +119 -0
- package/src/components/select/HstSelect.story.vue +33 -7
- package/src/components/select/HstSelect.vue +17 -44
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface SelectOption {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
6
|
+
modelValue: string;
|
|
7
|
+
options: Record<string, string> | string[] | SelectOption[];
|
|
8
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
"update:modelValue": (value: string) => void;
|
|
10
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
11
|
+
modelValue: string;
|
|
12
|
+
options: Record<string, string> | string[] | SelectOption[];
|
|
13
|
+
}>>> & {
|
|
14
|
+
"onUpdate:modelValue"?: (value: string) => any;
|
|
15
|
+
}, {}>;
|
|
16
|
+
export default _default;
|
|
17
|
+
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
18
|
+
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
19
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
20
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
21
|
+
} : {
|
|
22
|
+
type: import('vue').PropType<T[K]>;
|
|
23
|
+
required: true;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -1,43 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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;
|
|
1
|
+
export type { SelectOption as HstSelectOption } from './CustomSelect.vue';
|
|
2
|
+
import { SelectOption } from './CustomSelect.vue';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
+
title?: string;
|
|
5
|
+
modelValue: string;
|
|
6
|
+
options: Record<string, string> | string[] | SelectOption[];
|
|
7
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
8
|
+
"update:modelValue": (value: string) => void;
|
|
9
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
10
|
+
title?: string;
|
|
40
11
|
modelValue: string;
|
|
41
|
-
options: string[] |
|
|
42
|
-
}
|
|
12
|
+
options: Record<string, string> | string[] | SelectOption[];
|
|
13
|
+
}>>> & {
|
|
14
|
+
"onUpdate:modelValue"?: (value: string) => any;
|
|
15
|
+
}, {}>;
|
|
43
16
|
export default _default;
|
|
17
|
+
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
18
|
+
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
19
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
20
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
21
|
+
} : {
|
|
22
|
+
type: import('vue').PropType<T[K]>;
|
|
23
|
+
required: true;
|
|
24
|
+
};
|
|
25
|
+
};
|
package/dist/index.es.js
CHANGED
|
@@ -2327,11 +2327,11 @@ const _hoisted_2$1$1 = {
|
|
|
2327
2327
|
ref: "inner",
|
|
2328
2328
|
class: "v-popper__inner"
|
|
2329
2329
|
};
|
|
2330
|
-
const _hoisted_3$
|
|
2331
|
-
const _hoisted_4$
|
|
2330
|
+
const _hoisted_3$6 = /* @__PURE__ */ createElementVNode("div", { class: "v-popper__arrow-outer" }, null, -1);
|
|
2331
|
+
const _hoisted_4$4 = /* @__PURE__ */ createElementVNode("div", { class: "v-popper__arrow-inner" }, null, -1);
|
|
2332
2332
|
const _hoisted_5$3 = [
|
|
2333
|
-
_hoisted_3$
|
|
2334
|
-
_hoisted_4$
|
|
2333
|
+
_hoisted_3$6,
|
|
2334
|
+
_hoisted_4$4
|
|
2335
2335
|
];
|
|
2336
2336
|
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2337
2337
|
const _component_ResizeObserver = resolveComponent("ResizeObserver");
|
|
@@ -2515,7 +2515,7 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2515
2515
|
}, 16, ["theme", "target-nodes", "reference-node", "popper-node"]);
|
|
2516
2516
|
}
|
|
2517
2517
|
var PrivatePopperWrapper = /* @__PURE__ */ _export_sfc(_sfc_main$4$1, [["render", _sfc_render$1]]);
|
|
2518
|
-
defineComponent(__spreadProps2(__spreadValues2({}, PrivatePopperWrapper), {
|
|
2518
|
+
const _sfc_main$3$1 = defineComponent(__spreadProps2(__spreadValues2({}, PrivatePopperWrapper), {
|
|
2519
2519
|
name: "VDropdown",
|
|
2520
2520
|
vPopperTheme: "dropdown"
|
|
2521
2521
|
}));
|
|
@@ -2527,7 +2527,7 @@ defineComponent(__spreadProps2(__spreadValues2({}, PrivatePopperWrapper), {
|
|
|
2527
2527
|
name: "VTooltip",
|
|
2528
2528
|
vPopperTheme: "tooltip"
|
|
2529
2529
|
}));
|
|
2530
|
-
const _sfc_main$
|
|
2530
|
+
const _sfc_main$b = defineComponent({
|
|
2531
2531
|
name: "VTooltipDirective",
|
|
2532
2532
|
components: {
|
|
2533
2533
|
Popper: PrivatePopper(),
|
|
@@ -2673,7 +2673,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2673
2673
|
_: 1
|
|
2674
2674
|
}, 16, ["theme", "popper-node", "onApplyShow", "onApplyHide"]);
|
|
2675
2675
|
}
|
|
2676
|
-
var PrivateTooltipDirective = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2676
|
+
var PrivateTooltipDirective = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render]]);
|
|
2677
2677
|
const TARGET_CLASS = "v-popper--has-tooltip";
|
|
2678
2678
|
function getPlacement(options2, modifiers) {
|
|
2679
2679
|
let result = options2.placement;
|
|
@@ -2798,13 +2798,14 @@ var PrivateVTooltip = {
|
|
|
2798
2798
|
}
|
|
2799
2799
|
};
|
|
2800
2800
|
const VTooltip = PrivateVTooltip;
|
|
2801
|
+
const Dropdown = _sfc_main$3$1;
|
|
2801
2802
|
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
2803
|
const _hoisted_2$5 = { class: "htw-w-28 htw-whitespace-nowrap htw-text-ellipsis htw-overflow-hidden htw-shrink-0" };
|
|
2803
|
-
const _hoisted_3$
|
|
2804
|
-
const __default__$
|
|
2804
|
+
const _hoisted_3$5 = { class: "htw-block htw-grow" };
|
|
2805
|
+
const __default__$a = {
|
|
2805
2806
|
name: "HstWrapper"
|
|
2806
2807
|
};
|
|
2807
|
-
const _sfc_main$
|
|
2808
|
+
const _sfc_main$a = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$a), {
|
|
2808
2809
|
props: {
|
|
2809
2810
|
title: null
|
|
2810
2811
|
},
|
|
@@ -2820,7 +2821,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
2820
2821
|
distance: 12
|
|
2821
2822
|
}]
|
|
2822
2823
|
]),
|
|
2823
|
-
createElementVNode("span", _hoisted_3$
|
|
2824
|
+
createElementVNode("span", _hoisted_3$5, [
|
|
2824
2825
|
renderSlot(_ctx.$slots, "default")
|
|
2825
2826
|
])
|
|
2826
2827
|
]);
|
|
@@ -2834,11 +2835,11 @@ const _hoisted_2$4 = {
|
|
|
2834
2835
|
viewBox: "0 0 24 24",
|
|
2835
2836
|
class: "htw-relative htw-z-10"
|
|
2836
2837
|
};
|
|
2837
|
-
const _hoisted_3$
|
|
2838
|
-
const __default__$
|
|
2838
|
+
const _hoisted_3$4 = ["stroke-dasharray", "stroke-dashoffset"];
|
|
2839
|
+
const __default__$9 = {
|
|
2839
2840
|
name: "HstCheckbox"
|
|
2840
2841
|
};
|
|
2841
|
-
const _sfc_main$
|
|
2842
|
+
const _sfc_main$9 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$9), {
|
|
2842
2843
|
props: {
|
|
2843
2844
|
modelValue: { type: Boolean },
|
|
2844
2845
|
title: null
|
|
@@ -2862,7 +2863,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
2862
2863
|
dasharray.value = (_c = (_b2 = (_a2 = path.value).getTotalLength) == null ? void 0 : _b2.call(_a2)) != null ? _c : 21.21;
|
|
2863
2864
|
});
|
|
2864
2865
|
return (_ctx, _cache) => {
|
|
2865
|
-
return openBlock(), createBlock(_sfc_main$
|
|
2866
|
+
return openBlock(), createBlock(_sfc_main$a, {
|
|
2866
2867
|
role: "checkbox",
|
|
2867
2868
|
tabindex: "0",
|
|
2868
2869
|
class: "htw-cursor-pointer htw-items-center",
|
|
@@ -2894,7 +2895,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
2894
2895
|
]]),
|
|
2895
2896
|
"stroke-dasharray": dasharray.value,
|
|
2896
2897
|
"stroke-dashoffset": unref(dashoffset)
|
|
2897
|
-
}, null, 10, _hoisted_3$
|
|
2898
|
+
}, null, 10, _hoisted_3$4)
|
|
2898
2899
|
]))
|
|
2899
2900
|
])
|
|
2900
2901
|
]),
|
|
@@ -2904,10 +2905,10 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
2904
2905
|
}
|
|
2905
2906
|
}));
|
|
2906
2907
|
const _hoisted_1$5 = ["value"];
|
|
2907
|
-
const __default__$
|
|
2908
|
+
const __default__$8 = {
|
|
2908
2909
|
name: "HstText"
|
|
2909
2910
|
};
|
|
2910
|
-
const _sfc_main$
|
|
2911
|
+
const _sfc_main$8 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$8), {
|
|
2911
2912
|
props: {
|
|
2912
2913
|
title: null,
|
|
2913
2914
|
modelValue: null
|
|
@@ -2918,7 +2919,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
2918
2919
|
setup(__props, { emit }) {
|
|
2919
2920
|
const input = ref();
|
|
2920
2921
|
return (_ctx, _cache) => {
|
|
2921
|
-
return openBlock(), createBlock(_sfc_main$
|
|
2922
|
+
return openBlock(), createBlock(_sfc_main$a, {
|
|
2922
2923
|
title: __props.title,
|
|
2923
2924
|
class: normalizeClass(["htw-cursor-text htw-items-center", _ctx.$attrs.class]),
|
|
2924
2925
|
style: normalizeStyle(_ctx.$attrs.style),
|
|
@@ -2940,11 +2941,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
2940
2941
|
};
|
|
2941
2942
|
}
|
|
2942
2943
|
}));
|
|
2943
|
-
const __default__$
|
|
2944
|
+
const __default__$7 = {
|
|
2944
2945
|
name: "HstNumber",
|
|
2945
2946
|
inheritAttrs: false
|
|
2946
2947
|
};
|
|
2947
|
-
const _sfc_main$
|
|
2948
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$7), {
|
|
2948
2949
|
props: {
|
|
2949
2950
|
title: null,
|
|
2950
2951
|
modelValue: null
|
|
@@ -2991,7 +2992,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
2991
2992
|
stopDragging();
|
|
2992
2993
|
});
|
|
2993
2994
|
return (_ctx, _cache) => {
|
|
2994
|
-
return openBlock(), createBlock(_sfc_main$
|
|
2995
|
+
return openBlock(), createBlock(_sfc_main$a, {
|
|
2995
2996
|
class: normalizeClass(["htw-cursor-ew-resize htw-items-center", [
|
|
2996
2997
|
_ctx.$attrs.class,
|
|
2997
2998
|
{ "htw-select-none": isDragging.value }
|
|
@@ -3026,11 +3027,11 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
3026
3027
|
}
|
|
3027
3028
|
}));
|
|
3028
3029
|
const _hoisted_1$4 = ["value"];
|
|
3029
|
-
const __default__$
|
|
3030
|
+
const __default__$6 = {
|
|
3030
3031
|
name: "HstTextarea",
|
|
3031
3032
|
inheritAttrs: false
|
|
3032
3033
|
};
|
|
3033
|
-
const _sfc_main$
|
|
3034
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$6), {
|
|
3034
3035
|
props: {
|
|
3035
3036
|
title: null,
|
|
3036
3037
|
modelValue: null
|
|
@@ -3041,7 +3042,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
3041
3042
|
setup(__props, { emit }) {
|
|
3042
3043
|
const input = ref();
|
|
3043
3044
|
return (_ctx, _cache) => {
|
|
3044
|
-
return openBlock(), createBlock(_sfc_main$
|
|
3045
|
+
return openBlock(), createBlock(_sfc_main$a, {
|
|
3045
3046
|
title: __props.title,
|
|
3046
3047
|
class: normalizeClass(["htw-cursor-text", _ctx.$attrs.class]),
|
|
3047
3048
|
style: normalizeStyle(_ctx.$attrs.style),
|
|
@@ -3062,63 +3063,6 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
3062
3063
|
};
|
|
3063
3064
|
}
|
|
3064
3065
|
}));
|
|
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)
|
|
3116
|
-
]),
|
|
3117
|
-
_: 1
|
|
3118
|
-
}, 8, ["title", "class", "style"]);
|
|
3119
|
-
};
|
|
3120
|
-
}
|
|
3121
|
-
}));
|
|
3122
3066
|
const matchName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
3123
3067
|
const iconDefaults = Object.freeze({
|
|
3124
3068
|
left: 0,
|
|
@@ -4937,6 +4881,102 @@ const Icon = defineComponent({
|
|
|
4937
4881
|
return render(icon.data, newProps);
|
|
4938
4882
|
}
|
|
4939
4883
|
});
|
|
4884
|
+
var CustomSelect_vue_vue_type_style_index_0_lang = "";
|
|
4885
|
+
const _hoisted_1$3 = { class: "htw-cursor-pointer htw-w-full htw-outline-none htw-px-2 htw-h-[27px] -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 hover:htw-border-primary-500 dark:hover:htw-border-primary-500 htw-rounded-sm htw-flex htw-gap-2 htw-items-center htw-leading-normal" };
|
|
4886
|
+
const _hoisted_2$3 = { class: "htw-flex-1 htw-truncate" };
|
|
4887
|
+
const _hoisted_3$3 = { class: "htw-flex htw-flex-col htw-bg-gray-50 dark:htw-bg-gray-700" };
|
|
4888
|
+
const _hoisted_4$3 = ["onClick"];
|
|
4889
|
+
const __default__$5 = {
|
|
4890
|
+
name: "CustomSelect"
|
|
4891
|
+
};
|
|
4892
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$5), {
|
|
4893
|
+
props: {
|
|
4894
|
+
modelValue: null,
|
|
4895
|
+
options: null
|
|
4896
|
+
},
|
|
4897
|
+
emits: ["update:modelValue"],
|
|
4898
|
+
setup(__props, { emit: emits }) {
|
|
4899
|
+
const props = __props;
|
|
4900
|
+
const formattedOptions = computed(() => {
|
|
4901
|
+
if (Array.isArray(props.options)) {
|
|
4902
|
+
return Object.fromEntries(props.options.map((value) => {
|
|
4903
|
+
if (typeof value === "string") {
|
|
4904
|
+
return [value, value];
|
|
4905
|
+
} else {
|
|
4906
|
+
return [value.value, value.label];
|
|
4907
|
+
}
|
|
4908
|
+
}));
|
|
4909
|
+
}
|
|
4910
|
+
return props.options;
|
|
4911
|
+
});
|
|
4912
|
+
const selectedLabel = computed(() => formattedOptions.value[props.modelValue]);
|
|
4913
|
+
function selectValue(value, hide) {
|
|
4914
|
+
emits("update:modelValue", value);
|
|
4915
|
+
hide();
|
|
4916
|
+
}
|
|
4917
|
+
return (_ctx, _cache) => {
|
|
4918
|
+
return openBlock(), createBlock(unref(Dropdown), { "auto-size": "" }, {
|
|
4919
|
+
popper: withCtx(({ hide }) => [
|
|
4920
|
+
createElementVNode("div", _hoisted_3$3, [
|
|
4921
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(formattedOptions), (label, value) => {
|
|
4922
|
+
return openBlock(), createElementBlock("div", mergeProps(__spreadProps(__spreadValues({}, _ctx.$attrs), { class: null, style: null }), {
|
|
4923
|
+
key: label,
|
|
4924
|
+
class: ["htw-px-2 htw-py-1 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700", {
|
|
4925
|
+
"htw-bg-primary-200 dark:htw-bg-primary-800": props.modelValue === value
|
|
4926
|
+
}],
|
|
4927
|
+
onClick: ($event) => selectValue(value, hide)
|
|
4928
|
+
}), toDisplayString(label), 17, _hoisted_4$3);
|
|
4929
|
+
}), 128))
|
|
4930
|
+
])
|
|
4931
|
+
]),
|
|
4932
|
+
default: withCtx(() => [
|
|
4933
|
+
createElementVNode("div", _hoisted_1$3, [
|
|
4934
|
+
createElementVNode("div", _hoisted_2$3, [
|
|
4935
|
+
renderSlot(_ctx.$slots, "default", { label: unref(selectedLabel) }, () => [
|
|
4936
|
+
createTextVNode(toDisplayString(unref(selectedLabel)), 1)
|
|
4937
|
+
])
|
|
4938
|
+
]),
|
|
4939
|
+
createVNode(unref(Icon), {
|
|
4940
|
+
icon: "carbon:chevron-sort",
|
|
4941
|
+
class: "htw-w-4 htw-h-4 htw-flex-none htw-ml-auto"
|
|
4942
|
+
})
|
|
4943
|
+
])
|
|
4944
|
+
]),
|
|
4945
|
+
_: 3
|
|
4946
|
+
});
|
|
4947
|
+
};
|
|
4948
|
+
}
|
|
4949
|
+
}));
|
|
4950
|
+
const __default__$4 = {
|
|
4951
|
+
name: "HstSelect"
|
|
4952
|
+
};
|
|
4953
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$4), {
|
|
4954
|
+
props: {
|
|
4955
|
+
title: null,
|
|
4956
|
+
modelValue: null,
|
|
4957
|
+
options: null
|
|
4958
|
+
},
|
|
4959
|
+
emits: ["update:modelValue"],
|
|
4960
|
+
setup(__props, { emit: emits }) {
|
|
4961
|
+
ref();
|
|
4962
|
+
return (_ctx, _cache) => {
|
|
4963
|
+
return openBlock(), createBlock(_sfc_main$a, {
|
|
4964
|
+
title: __props.title,
|
|
4965
|
+
class: normalizeClass(["htw-cursor-text htw-items-center", _ctx.$attrs.class]),
|
|
4966
|
+
style: normalizeStyle(_ctx.$attrs.style)
|
|
4967
|
+
}, {
|
|
4968
|
+
default: withCtx(() => [
|
|
4969
|
+
createVNode(_sfc_main$5, {
|
|
4970
|
+
options: __props.options,
|
|
4971
|
+
"model-value": __props.modelValue,
|
|
4972
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => emits("update:modelValue", $event))
|
|
4973
|
+
}, null, 8, ["options", "model-value"])
|
|
4974
|
+
]),
|
|
4975
|
+
_: 1
|
|
4976
|
+
}, 8, ["title", "class", "style"]);
|
|
4977
|
+
};
|
|
4978
|
+
}
|
|
4979
|
+
}));
|
|
4940
4980
|
function tryOnScopeDispose(fn) {
|
|
4941
4981
|
if (getCurrentScope()) {
|
|
4942
4982
|
onScopeDispose(fn);
|
|
@@ -5326,20 +5366,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
5326
5366
|
};
|
|
5327
5367
|
}
|
|
5328
5368
|
}));
|
|
5329
|
-
const HstCheckbox = _sfc_main$
|
|
5330
|
-
const HstText = _sfc_main$
|
|
5331
|
-
const HstNumber = _sfc_main$
|
|
5332
|
-
const HstTextarea = _sfc_main$
|
|
5369
|
+
const HstCheckbox = _sfc_main$9;
|
|
5370
|
+
const HstText = _sfc_main$8;
|
|
5371
|
+
const HstNumber = _sfc_main$7;
|
|
5372
|
+
const HstTextarea = _sfc_main$6;
|
|
5333
5373
|
const HstColorShades = _sfc_main$2;
|
|
5334
5374
|
const HstTokenList = _sfc_main$1;
|
|
5335
5375
|
const HstTokenGrid = _sfc_main;
|
|
5336
5376
|
const HstCopyIcon = _sfc_main$3;
|
|
5337
5377
|
function registerVueComponents(app) {
|
|
5338
|
-
app.component("HstCheckbox", _sfc_main$
|
|
5339
|
-
app.component("HstText", _sfc_main$
|
|
5340
|
-
app.component("HstNumber", _sfc_main$
|
|
5378
|
+
app.component("HstCheckbox", _sfc_main$9);
|
|
5379
|
+
app.component("HstText", _sfc_main$8);
|
|
5380
|
+
app.component("HstNumber", _sfc_main$7);
|
|
5341
5381
|
app.component("HstSelect", _sfc_main$4);
|
|
5342
|
-
app.component("HstTextarea", _sfc_main$
|
|
5382
|
+
app.component("HstTextarea", _sfc_main$6);
|
|
5343
5383
|
app.component("HstColorShades", _sfc_main$2);
|
|
5344
5384
|
app.component("HstTokenList", _sfc_main$1);
|
|
5345
5385
|
app.component("HstTokenGrid", _sfc_main);
|
|
@@ -294,6 +294,10 @@
|
|
|
294
294
|
margin-bottom:0.5rem
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
.htw-ml-auto{
|
|
298
|
+
margin-left:auto
|
|
299
|
+
}
|
|
300
|
+
|
|
297
301
|
.htw-box-border{
|
|
298
302
|
box-sizing:border-box
|
|
299
303
|
}
|
|
@@ -334,6 +338,10 @@
|
|
|
334
338
|
height:5rem
|
|
335
339
|
}
|
|
336
340
|
|
|
341
|
+
.htw-h-\[27px\]{
|
|
342
|
+
height:27px
|
|
343
|
+
}
|
|
344
|
+
|
|
337
345
|
.htw-min-h-\[26px\]{
|
|
338
346
|
min-height:26px
|
|
339
347
|
}
|
|
@@ -366,6 +374,10 @@
|
|
|
366
374
|
flex:none
|
|
367
375
|
}
|
|
368
376
|
|
|
377
|
+
.htw-flex-1{
|
|
378
|
+
flex:1 1 0%
|
|
379
|
+
}
|
|
380
|
+
|
|
369
381
|
.htw-shrink-0{
|
|
370
382
|
flex-shrink:0
|
|
371
383
|
}
|
|
@@ -488,6 +500,11 @@
|
|
|
488
500
|
border-color:rgb(0 0 0 / 0.25)
|
|
489
501
|
}
|
|
490
502
|
|
|
503
|
+
.htw-border-gray-850{
|
|
504
|
+
--tw-border-opacity:1;
|
|
505
|
+
border-color:rgb(31 31 33 / var(--tw-border-opacity))
|
|
506
|
+
}
|
|
507
|
+
|
|
491
508
|
.htw-bg-white{
|
|
492
509
|
--tw-bg-opacity:1;
|
|
493
510
|
background-color:rgb(255 255 255 / var(--tw-bg-opacity))
|
|
@@ -510,6 +527,16 @@
|
|
|
510
527
|
background-color:rgb(250 250 250 / var(--tw-bg-opacity))
|
|
511
528
|
}
|
|
512
529
|
|
|
530
|
+
.htw-bg-primary-200{
|
|
531
|
+
--tw-bg-opacity:1;
|
|
532
|
+
background-color:rgb(167 243 208 / var(--tw-bg-opacity))
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.htw-bg-gray-700{
|
|
536
|
+
--tw-bg-opacity:1;
|
|
537
|
+
background-color:rgb(63 63 70 / var(--tw-bg-opacity))
|
|
538
|
+
}
|
|
539
|
+
|
|
513
540
|
.htw-stroke-white{
|
|
514
541
|
stroke:#fff
|
|
515
542
|
}
|
|
@@ -550,6 +577,10 @@
|
|
|
550
577
|
line-height:1rem
|
|
551
578
|
}
|
|
552
579
|
|
|
580
|
+
.htw-leading-normal{
|
|
581
|
+
line-height:1.5
|
|
582
|
+
}
|
|
583
|
+
|
|
553
584
|
.htw-text-white{
|
|
554
585
|
--tw-text-opacity:1;
|
|
555
586
|
color:rgb(255 255 255 / var(--tw-text-opacity))
|
|
@@ -619,6 +650,11 @@ body {
|
|
|
619
650
|
}
|
|
620
651
|
}
|
|
621
652
|
|
|
653
|
+
.hover\:htw-border-primary-500:hover{
|
|
654
|
+
--tw-border-opacity:1;
|
|
655
|
+
border-color:rgb(16 185 129 / var(--tw-border-opacity))
|
|
656
|
+
}
|
|
657
|
+
|
|
622
658
|
.hover\:htw-bg-primary-100:hover{
|
|
623
659
|
--tw-bg-opacity:1;
|
|
624
660
|
background-color:rgb(209 250 229 / var(--tw-bg-opacity))
|
|
@@ -651,16 +687,36 @@ body {
|
|
|
651
687
|
background-color:rgb(0 0 0 / var(--tw-bg-opacity))
|
|
652
688
|
}
|
|
653
689
|
|
|
690
|
+
.htw-dark .dark\:htw-bg-gray-700{
|
|
691
|
+
--tw-bg-opacity:1;
|
|
692
|
+
background-color:rgb(63 63 70 / var(--tw-bg-opacity))
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
.htw-dark .dark\:htw-bg-primary-800{
|
|
696
|
+
--tw-bg-opacity:1;
|
|
697
|
+
background-color:rgb(6 95 70 / var(--tw-bg-opacity))
|
|
698
|
+
}
|
|
699
|
+
|
|
654
700
|
.htw-dark .dark\:htw-bg-gray-600{
|
|
655
701
|
--tw-bg-opacity:1;
|
|
656
702
|
background-color:rgb(82 82 91 / var(--tw-bg-opacity))
|
|
657
703
|
}
|
|
658
704
|
|
|
705
|
+
.htw-dark .dark\:hover\:htw-border-primary-500:hover{
|
|
706
|
+
--tw-border-opacity:1;
|
|
707
|
+
border-color:rgb(16 185 129 / var(--tw-border-opacity))
|
|
708
|
+
}
|
|
709
|
+
|
|
659
710
|
.htw-dark .dark\:hover\:htw-bg-primary-800:hover{
|
|
660
711
|
--tw-bg-opacity:1;
|
|
661
712
|
background-color:rgb(6 95 70 / var(--tw-bg-opacity))
|
|
662
713
|
}
|
|
663
714
|
|
|
715
|
+
.htw-dark .dark\:hover\:htw-bg-primary-700:hover{
|
|
716
|
+
--tw-bg-opacity:1;
|
|
717
|
+
background-color:rgb(4 120 87 / var(--tw-bg-opacity))
|
|
718
|
+
}
|
|
719
|
+
|
|
664
720
|
.htw-dark .dark\:focus\:htw-border-primary-500:focus{
|
|
665
721
|
--tw-border-opacity:1;
|
|
666
722
|
border-color:rgb(16 185 129 / var(--tw-border-opacity))
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.htw-bind-col-size{grid-template-columns:repeat(auto-fill,minmax(var(--histoire-col-size),1fr))}
|
|
1
|
+
.v-popper{line-height:0}.htw-dark .v-popper--theme-dropdown .v-popper__inner{--tw-border-opacity: 1;border-color:rgb(31 31 33 / var(--tw-border-opacity));--tw-bg-opacity: 1;background-color:rgb(63 63 70 / var(--tw-bg-opacity));--tw-text-opacity: 1;color:rgb(244 244 245 / var(--tw-text-opacity))}.htw-dark .v-popper--theme-dropdown .v-popper__arrow-inner{--tw-border-opacity: 1;border-color:rgb(63 63 70 / var(--tw-border-opacity))}.htw-dark .v-popper--theme-dropdown .v-popper__arrow-outer{--tw-border-opacity: 1;border-color:rgb(31 31 33 / var(--tw-border-opacity))}.v-popper--theme-dropdown.v-popper__popper--show-from .v-popper__wrapper{transform:scale(.75)}.v-popper--theme-dropdown.v-popper__popper--show-to .v-popper__wrapper{transform:none;transition:transform .15s cubic-bezier(0,1,.5,1)}.v-popper__popper:focus-visible{outline:none}.htw-bind-col-size{grid-template-columns:repeat(auto-fill,minmax(var(--histoire-col-size),1fr))}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@histoire/controls",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "Prebuilt controls components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@peeky/test": "^0.13.5",
|
|
40
|
-
"@types/node": "^17.0.
|
|
40
|
+
"@types/node": "^17.0.32",
|
|
41
41
|
"@vitejs/plugin-vue": "^2.3.1",
|
|
42
42
|
"@vue/test-utils": "^2.0.0-rc.19",
|
|
43
43
|
"@vueuse/core": "^8.2.5",
|
|
44
44
|
"autoprefixer": "^10.4.4",
|
|
45
45
|
"concurrently": "^7.1.0",
|
|
46
46
|
"floating-vue": "^2.0.0-beta.16",
|
|
47
|
-
"histoire": "0.4.
|
|
47
|
+
"histoire": "0.4.6",
|
|
48
48
|
"postcss": "^8.4.12",
|
|
49
49
|
"postcss-import": "^14.1.0",
|
|
50
50
|
"tailwindcss": "^3.0.23",
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export default {
|
|
3
|
+
name: 'CustomSelect',
|
|
4
|
+
}
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { Dropdown as VDropdown } from 'floating-vue'
|
|
9
|
+
import { computed, ComputedRef } from 'vue'
|
|
10
|
+
import { Icon } from '@iconify/vue'
|
|
11
|
+
|
|
12
|
+
export interface SelectOption {
|
|
13
|
+
label: string
|
|
14
|
+
value: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const props = defineProps<{
|
|
18
|
+
modelValue: string
|
|
19
|
+
options: Record<string, string> | string[] | SelectOption[]
|
|
20
|
+
}>()
|
|
21
|
+
|
|
22
|
+
const emits = defineEmits<{
|
|
23
|
+
(e: 'update:modelValue', value: string): void
|
|
24
|
+
}>()
|
|
25
|
+
|
|
26
|
+
const formattedOptions: ComputedRef<Record<string, string>> = computed(() => {
|
|
27
|
+
if (Array.isArray(props.options)) {
|
|
28
|
+
return Object.fromEntries(props.options.map((value: string | SelectOption) => {
|
|
29
|
+
if (typeof value === 'string') {
|
|
30
|
+
return [value, value]
|
|
31
|
+
} else {
|
|
32
|
+
return [value.value, value.label]
|
|
33
|
+
}
|
|
34
|
+
}))
|
|
35
|
+
}
|
|
36
|
+
return props.options
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const selectedLabel = computed(() => formattedOptions.value[props.modelValue])
|
|
40
|
+
|
|
41
|
+
function selectValue (value: string, hide: () => void) {
|
|
42
|
+
emits('update:modelValue', value)
|
|
43
|
+
hide()
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<VDropdown
|
|
49
|
+
auto-size
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
class="htw-cursor-pointer htw-w-full htw-outline-none htw-px-2 htw-h-[27px] -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 hover:htw-border-primary-500 dark:hover:htw-border-primary-500 htw-rounded-sm htw-flex htw-gap-2 htw-items-center htw-leading-normal"
|
|
53
|
+
>
|
|
54
|
+
<div class="htw-flex-1 htw-truncate">
|
|
55
|
+
<slot :label="selectedLabel">
|
|
56
|
+
{{ selectedLabel }}
|
|
57
|
+
</slot>
|
|
58
|
+
</div>
|
|
59
|
+
<Icon
|
|
60
|
+
icon="carbon:chevron-sort"
|
|
61
|
+
class="htw-w-4 htw-h-4 htw-flex-none htw-ml-auto"
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
<template #popper="{ hide }">
|
|
65
|
+
<div class="htw-flex htw-flex-col htw-bg-gray-50 dark:htw-bg-gray-700">
|
|
66
|
+
<div
|
|
67
|
+
v-for="( label, value ) in formattedOptions"
|
|
68
|
+
v-bind="{ ...$attrs, class: null, style: null }"
|
|
69
|
+
:key="label"
|
|
70
|
+
class="htw-px-2 htw-py-1 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700"
|
|
71
|
+
:class="{
|
|
72
|
+
'htw-bg-primary-200 dark:htw-bg-primary-800': props.modelValue === value,
|
|
73
|
+
}"
|
|
74
|
+
@click="selectValue(value, hide)"
|
|
75
|
+
>
|
|
76
|
+
{{ label }}
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</template>
|
|
80
|
+
</VDropdown>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<style lang="postcss">
|
|
84
|
+
/* @TODO custom themes */
|
|
85
|
+
|
|
86
|
+
.v-popper {
|
|
87
|
+
line-height: 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.v-popper--theme-dropdown {
|
|
91
|
+
.htw-dark & {
|
|
92
|
+
.v-popper__inner {
|
|
93
|
+
@apply htw-bg-gray-700 htw-border-gray-850 htw-text-gray-100;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.v-popper__arrow-inner {
|
|
97
|
+
@apply htw-border-gray-700;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.v-popper__arrow-outer {
|
|
101
|
+
@apply htw-border-gray-850;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&.v-popper__popper--show-from .v-popper__wrapper {
|
|
106
|
+
transform: scale(.75);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&.v-popper__popper--show-to .v-popper__wrapper {
|
|
110
|
+
transform: none;
|
|
111
|
+
transition: transform .15s cubic-bezier(0, 1, .5, 1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.v-popper__popper:focus-visible {
|
|
116
|
+
outline: none;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
</style>
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import HstSelect from './HstSelect.vue'
|
|
3
3
|
|
|
4
|
-
const options =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const options = {
|
|
5
|
+
'crash-bandicoot': 'Crash Bandicoot',
|
|
6
|
+
'the-last-of-us': 'The Last of Us',
|
|
7
|
+
'ghost-of-tsushima': 'Ghost of Tsushima',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const flatOptions = Object.keys(options)
|
|
9
11
|
|
|
10
|
-
const
|
|
12
|
+
const objectOptions = Object.keys(options).map(key => ({
|
|
13
|
+
label: options[key],
|
|
14
|
+
value: key,
|
|
15
|
+
}))
|
|
11
16
|
|
|
12
17
|
function initState () {
|
|
13
18
|
return {
|
|
@@ -66,7 +71,7 @@ function initState () {
|
|
|
66
71
|
</Variant>
|
|
67
72
|
|
|
68
73
|
<Variant
|
|
69
|
-
title="options-as-
|
|
74
|
+
title="options-as-object"
|
|
70
75
|
:init-state="initState"
|
|
71
76
|
>
|
|
72
77
|
<template #default="{ state }">
|
|
@@ -86,6 +91,27 @@ function initState () {
|
|
|
86
91
|
</template>
|
|
87
92
|
</Variant>
|
|
88
93
|
|
|
94
|
+
<Variant
|
|
95
|
+
title="options-as-array-of-objects"
|
|
96
|
+
:init-state="initState"
|
|
97
|
+
>
|
|
98
|
+
<template #default="{ state }">
|
|
99
|
+
<pre class="htw-text-xs htw-bg-gray-50 dark:htw-bg-gray-600 htw-rounded htw-p-4">{{ objectOptions }}</pre>
|
|
100
|
+
<HstSelect
|
|
101
|
+
v-model="state.select"
|
|
102
|
+
title="Games"
|
|
103
|
+
:options="objectOptions"
|
|
104
|
+
/>
|
|
105
|
+
</template>
|
|
106
|
+
<template #controls="{ state }">
|
|
107
|
+
<HstSelect
|
|
108
|
+
v-model="state.select"
|
|
109
|
+
title="Games"
|
|
110
|
+
:options="objectOptions"
|
|
111
|
+
/>
|
|
112
|
+
</template>
|
|
113
|
+
</Variant>
|
|
114
|
+
|
|
89
115
|
<Variant
|
|
90
116
|
title="options-as-array-of-strings"
|
|
91
117
|
:init-state="initState"
|
|
@@ -2,39 +2,24 @@
|
|
|
2
2
|
export default {
|
|
3
3
|
name: 'HstSelect',
|
|
4
4
|
}
|
|
5
|
+
|
|
6
|
+
export type { SelectOption as HstSelectOption } from './CustomSelect.vue'
|
|
5
7
|
</script>
|
|
6
8
|
|
|
7
9
|
<script lang="ts" setup>
|
|
8
|
-
import { ref
|
|
10
|
+
import { ref } from 'vue'
|
|
9
11
|
import HstWrapper from '../HstWrapper.vue'
|
|
12
|
+
import CustomSelect, { SelectOption } from './CustomSelect.vue'
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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))
|
|
14
|
+
const props = defineProps<{
|
|
15
|
+
title?: string
|
|
16
|
+
modelValue: string
|
|
17
|
+
options: Record<string, string> | string[] | SelectOption[]
|
|
18
|
+
}>()
|
|
34
19
|
|
|
35
|
-
const
|
|
36
|
-
'update:modelValue'
|
|
37
|
-
})
|
|
20
|
+
const emits = defineEmits<{
|
|
21
|
+
(e: 'update:modelValue', value: string): void
|
|
22
|
+
}>()
|
|
38
23
|
|
|
39
24
|
const select = ref<HTMLInputElement>()
|
|
40
25
|
</script>
|
|
@@ -45,23 +30,11 @@ const select = ref<HTMLInputElement>()
|
|
|
45
30
|
class="htw-cursor-text htw-items-center"
|
|
46
31
|
:class="$attrs.class"
|
|
47
32
|
:style="$attrs.style"
|
|
48
|
-
@click="select.focus()"
|
|
49
33
|
>
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
:value="modelValue"
|
|
54
|
-
|
|
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>
|
|
34
|
+
<CustomSelect
|
|
35
|
+
:options="options"
|
|
36
|
+
:model-value="modelValue"
|
|
37
|
+
@update:model-value="emits('update:modelValue', $event)"
|
|
38
|
+
/>
|
|
66
39
|
</HstWrapper>
|
|
67
40
|
</template>
|