hzzt-plus 2.0.9 → 2.0.11
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/index.full.js +45 -25
- package/dist/index.full.min.js +6 -6
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +5 -5
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +45 -25
- package/dist/locale/en.js +1 -1
- package/dist/locale/en.min.js +1 -1
- package/dist/locale/en.min.mjs +1 -1
- package/dist/locale/en.mjs +1 -1
- package/dist/locale/zh-cn.js +1 -1
- package/dist/locale/zh-cn.min.js +1 -1
- package/dist/locale/zh-cn.min.mjs +1 -1
- package/dist/locale/zh-cn.mjs +1 -1
- package/es/components/cascader/index.mjs +2 -2
- package/es/components/cascader/src/cascader.mjs +156 -40
- package/es/components/cascader/src/cascader.mjs.map +1 -1
- package/es/components/cascader/src/cascader2.mjs +40 -156
- package/es/components/cascader/src/cascader2.mjs.map +1 -1
- package/es/components/index.mjs +3 -3
- package/es/components/lazy-list/index.mjs +2 -2
- package/es/components/lazy-list/src/lazy-list.mjs +22 -80
- package/es/components/lazy-list/src/lazy-list.mjs.map +1 -1
- package/es/components/lazy-list/src/lazy-list2.mjs +80 -22
- package/es/components/lazy-list/src/lazy-list2.mjs.map +1 -1
- package/es/components/select/index.mjs +2 -2
- package/es/components/select/src/select.mjs +213 -42
- package/es/components/select/src/select.mjs.map +1 -1
- package/es/components/select/src/select2.mjs +42 -193
- package/es/components/select/src/select2.mjs.map +1 -1
- package/es/index.mjs +3 -3
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/version.mjs.map +1 -1
- package/lib/components/cascader/index.js +2 -2
- package/lib/components/cascader/src/cascader.js +155 -40
- package/lib/components/cascader/src/cascader.js.map +1 -1
- package/lib/components/cascader/src/cascader2.js +40 -155
- package/lib/components/cascader/src/cascader2.js.map +1 -1
- package/lib/components/index.js +3 -3
- package/lib/components/lazy-list/index.js +2 -2
- package/lib/components/lazy-list/src/lazy-list.js +23 -80
- package/lib/components/lazy-list/src/lazy-list.js.map +1 -1
- package/lib/components/lazy-list/src/lazy-list2.js +80 -23
- package/lib/components/lazy-list/src/lazy-list2.js.map +1 -1
- package/lib/components/select/index.js +2 -2
- package/lib/components/select/src/select.js +213 -43
- package/lib/components/select/src/select.js.map +1 -1
- package/lib/components/select/src/select2.js +43 -193
- package/lib/components/select/src/select2.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +1 -1
- package/web-types.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cascader2.mjs","sources":["../../../../../../packages/components/cascader/src/cascader.
|
|
1
|
+
{"version":3,"file":"cascader2.mjs","sources":["../../../../../../packages/components/cascader/src/cascader.ts"],"sourcesContent":["import {buildProps, definePropType, isString} from '@hzzt-plus/utils'\nimport {useSizeProp} from \"@hzzt-plus/hooks\";\nimport type {ExtractPropTypes} from 'vue'\nimport type Cascader from './cascader.vue'\nimport {UPDATE_MODEL_EVENT} from \"@hzzt-plus/constants\";\n\nexport type CascaderNodeValue = string | number\n\nexport interface CascaderOption extends Record<string, unknown> {\n label?: string\n value?: CascaderNodeValue\n children?: CascaderOption[]\n disabled?: boolean\n leaf?: boolean\n}\n\nexport const cascaderProps = buildProps({\n cascaderProps: {\n type: Object,\n default: () => ({\n showAllLevels: true,\n }),\n },\n disabled: Boolean,\n readonly: Boolean,\n clearable: Boolean,\n size: useSizeProp,\n options: {\n type: definePropType<CascaderOption[]>(Array),\n default: () => [] as CascaderOption[],\n },\n placeholder: {\n type: String,\n default: '',\n },\n joinSeparator: {\n type: String,\n default: ',',\n },\n modelValue: {\n type: definePropType<string | undefined>([\n String,\n ]),\n default: '',\n },\n})\n\nexport type CascaderProps = ExtractPropTypes<typeof cascaderProps>\n\nexport const cascaderEmits = {\n [UPDATE_MODEL_EVENT]: (value: string | undefined) => isString(value),\n input: (value: string | undefined) => isString(value),\n change: (value: string | undefined) => isString(value),\n}\nexport type CascaderEmits = typeof cascaderEmits\n\n\nexport type CascaderInstance = InstanceType<typeof Cascader>\n"],"names":[],"mappings":";;;;;;;;AAGY,MAAC,aAAa,GAAG,UAAU,CAAC;AACxC,EAAE,aAAa,EAAE;AACjB,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,OAAO;AACpB,MAAM,aAAa,EAAE,IAAI;AACzB,KAAK,CAAC;AACN,GAAG;AACH,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,SAAS,EAAE,OAAO;AACpB,EAAE,IAAI,EAAE,WAAW;AACnB,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,OAAO,EAAE,MAAM,EAAE;AACrB,GAAG;AACH,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,aAAa,EAAE;AACjB,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,GAAG;AAChB,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,cAAc,CAAC;AACzB,MAAM,MAAM;AACZ,KAAK,CAAC;AACN,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,CAAC,EAAE;AACS,MAAC,aAAa,GAAG;AAC7B,EAAE,CAAC,kBAAkB,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AAClD,EAAE,KAAK,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AACnC,EAAE,MAAM,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AACpC;;;;"}
|
package/es/components/index.mjs
CHANGED
|
@@ -27,8 +27,8 @@ export { scanEmits, scanProps } from './scan/src/scan.mjs';
|
|
|
27
27
|
export { selectInputEmits, selectInputProps } from './select-input/src/select-input.mjs';
|
|
28
28
|
export { selectTextareaEmits, selectTextareaProps } from './select-textarea/src/select-textarea.mjs';
|
|
29
29
|
export { inputRangeEmits, inputRangeProps } from './input-range/src/input-range.mjs';
|
|
30
|
-
export { cascaderEmits, cascaderProps } from './cascader/src/
|
|
31
|
-
export { selectEmits, selectProps } from './select/src/
|
|
30
|
+
export { cascaderEmits, cascaderProps } from './cascader/src/cascader2.mjs';
|
|
31
|
+
export { selectEmits, selectProps } from './select/src/select2.mjs';
|
|
32
32
|
export { clickInputEmits, clickInputProps } from './click-input/src/click-input.mjs';
|
|
33
|
-
export { lazyListEmits, lazyListProps } from './lazy-list/src/lazy-
|
|
33
|
+
export { lazyListEmits, lazyListProps } from './lazy-list/src/lazy-list.mjs';
|
|
34
34
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../../utils/index.mjs';
|
|
2
|
-
import LazyList from './src/lazy-
|
|
3
|
-
export { lazyListEmits, lazyListProps } from './src/lazy-
|
|
2
|
+
import LazyList from './src/lazy-list2.mjs';
|
|
3
|
+
export { lazyListEmits, lazyListProps } from './src/lazy-list.mjs';
|
|
4
4
|
import { withInstall } from '../../utils/vue/install.mjs';
|
|
5
5
|
|
|
6
6
|
const HzztLazyList = withInstall(LazyList);
|
|
@@ -1,85 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '../../../hooks/index.mjs';
|
|
4
|
-
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
5
|
-
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
1
|
+
import '../../../utils/index.mjs';
|
|
2
|
+
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
|
|
6
3
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"overflow-y-auto",
|
|
24
|
-
nsLazy.b()
|
|
25
|
-
]);
|
|
26
|
-
watch(() => props.data, () => {
|
|
27
|
-
totalHeight.value = props.data.length * props.height + "px";
|
|
28
|
-
}, {
|
|
29
|
-
immediate: true
|
|
30
|
-
});
|
|
31
|
-
const calcList = computed(() => props.data.slice(currentIndex.value === 1 ? 0 : (currentIndex.value - 1) * props.size - props.size / 2, (currentIndex.value + 1) * props.size + props.size / 2));
|
|
32
|
-
function scrollList(e) {
|
|
33
|
-
const target = e.target;
|
|
34
|
-
const scrollTop = target.scrollTop;
|
|
35
|
-
if (scrollTop < props.size / 2 * props.height) {
|
|
36
|
-
currentIndex.value = 1;
|
|
37
|
-
} else {
|
|
38
|
-
currentIndex.value = Math.ceil((scrollTop - props.size / 2 * props.height) / props.size / props.height);
|
|
39
|
-
}
|
|
40
|
-
if (currentIndex.value === 1) {
|
|
41
|
-
marginTop.value = "0px";
|
|
42
|
-
} else {
|
|
43
|
-
marginTop.value = ((currentIndex.value - 1) * props.size - props.size / 2) * props.height + "px";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function rowClick(row) {
|
|
47
|
-
current.value = row;
|
|
48
|
-
emit("row-click", row);
|
|
49
|
-
}
|
|
50
|
-
return (_ctx, _cache) => {
|
|
51
|
-
return openBlock(), createElementBlock("div", {
|
|
52
|
-
class: normalizeClass(unref(containerCls)),
|
|
53
|
-
onScroll: scrollList
|
|
54
|
-
}, [
|
|
55
|
-
createElementVNode("div", {
|
|
56
|
-
style: normalizeStyle({
|
|
57
|
-
height: totalHeight.value,
|
|
58
|
-
width: 0,
|
|
59
|
-
float: "left"
|
|
60
|
-
})
|
|
61
|
-
}, null, 4),
|
|
62
|
-
createElementVNode("div", {
|
|
63
|
-
style: normalizeStyle({ marginTop: marginTop.value })
|
|
64
|
-
}, [
|
|
65
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(calcList), (item) => {
|
|
66
|
-
return openBlock(), createElementBlock("div", {
|
|
67
|
-
key: item[_ctx.rowKey],
|
|
68
|
-
style: normalizeStyle({
|
|
69
|
-
height: _ctx.height + "px"
|
|
70
|
-
}),
|
|
71
|
-
class: normalizeClass(["hzzt-lazy-list__item", current.value === item ? "is-active" : ""]),
|
|
72
|
-
onClick: ($event) => rowClick(item)
|
|
73
|
-
}, [
|
|
74
|
-
renderSlot(_ctx.$slots, "default", { data: item })
|
|
75
|
-
], 14, _hoisted_1);
|
|
76
|
-
}), 128))
|
|
77
|
-
], 4)
|
|
78
|
-
], 34);
|
|
79
|
-
};
|
|
4
|
+
const lazyListProps = buildProps({
|
|
5
|
+
size: {
|
|
6
|
+
type: Number,
|
|
7
|
+
default: 20
|
|
8
|
+
},
|
|
9
|
+
height: {
|
|
10
|
+
type: Number,
|
|
11
|
+
default: 30
|
|
12
|
+
},
|
|
13
|
+
data: {
|
|
14
|
+
type: definePropType(Array),
|
|
15
|
+
default: () => []
|
|
16
|
+
},
|
|
17
|
+
rowKey: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: "id"
|
|
80
20
|
}
|
|
81
21
|
});
|
|
82
|
-
|
|
22
|
+
const lazyListEmits = {
|
|
23
|
+
"row-click": (row) => row
|
|
24
|
+
};
|
|
83
25
|
|
|
84
|
-
export {
|
|
26
|
+
export { lazyListEmits, lazyListProps };
|
|
85
27
|
//# sourceMappingURL=lazy-list.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-list.mjs","sources":["../../../../../../packages/components/lazy-list/src/lazy-list.
|
|
1
|
+
{"version":3,"file":"lazy-list.mjs","sources":["../../../../../../packages/components/lazy-list/src/lazy-list.ts"],"sourcesContent":["import {buildProps, definePropType} from '@hzzt-plus/utils'\nimport type {ExtractPropTypes} from 'vue'\nimport type LazyList from './lazy-list.vue'\n\nexport const lazyListProps = buildProps({\n size: {\n type: Number,\n default: 20,\n },\n height: {\n type: Number,\n default: 30,\n },\n data: {\n type: definePropType<Record<string, any>[]>(Array),\n default: () => [],\n },\n rowKey: {\n type: String,\n default: 'id',\n },\n})\n\nexport type LazyListProps = ExtractPropTypes<typeof lazyListProps>\n\nexport const lazyListEmits = {\n 'row-click': (row: any) => row\n}\n\nexport type LazyListEmits = typeof lazyListEmits\n\n\nexport type LazyListInstance = InstanceType<typeof LazyList>\n"],"names":[],"mappings":";;;AACY,MAAC,aAAa,GAAG,UAAU,CAAC;AACxC,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,OAAO,EAAE,MAAM,EAAE;AACrB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,aAAa,GAAG;AAC7B,EAAE,WAAW,EAAE,CAAC,GAAG,KAAK,GAAG;AAC3B;;;;"}
|
|
@@ -1,27 +1,85 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import {
|
|
1
|
+
import { defineComponent, ref, computed, watch, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, normalizeStyle, Fragment, renderList, renderSlot } from 'vue';
|
|
2
|
+
import { lazyListProps, lazyListEmits } from './lazy-list.mjs';
|
|
3
|
+
import '../../../hooks/index.mjs';
|
|
4
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
5
|
+
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
3
6
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const _hoisted_1 = ["onClick"];
|
|
8
|
+
const __default__ = defineComponent({
|
|
9
|
+
name: "HzztLazyList"
|
|
10
|
+
});
|
|
11
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
12
|
+
...__default__,
|
|
13
|
+
props: lazyListProps,
|
|
14
|
+
emits: lazyListEmits,
|
|
15
|
+
setup(__props, { emit }) {
|
|
16
|
+
const props = __props;
|
|
17
|
+
const totalHeight = ref("100%");
|
|
18
|
+
const marginTop = ref("0px");
|
|
19
|
+
const currentIndex = ref(1);
|
|
20
|
+
const current = ref(null);
|
|
21
|
+
const nsLazy = useNamespace("lazy-list");
|
|
22
|
+
const containerCls = computed(() => [
|
|
23
|
+
"overflow-y-auto",
|
|
24
|
+
nsLazy.b()
|
|
25
|
+
]);
|
|
26
|
+
watch(() => props.data, () => {
|
|
27
|
+
totalHeight.value = props.data.length * props.height + "px";
|
|
28
|
+
}, {
|
|
29
|
+
immediate: true
|
|
30
|
+
});
|
|
31
|
+
const calcList = computed(() => props.data.slice(currentIndex.value === 1 ? 0 : (currentIndex.value - 1) * props.size - props.size / 2, (currentIndex.value + 1) * props.size + props.size / 2));
|
|
32
|
+
function scrollList(e) {
|
|
33
|
+
const target = e.target;
|
|
34
|
+
const scrollTop = target.scrollTop;
|
|
35
|
+
if (scrollTop < props.size / 2 * props.height) {
|
|
36
|
+
currentIndex.value = 1;
|
|
37
|
+
} else {
|
|
38
|
+
currentIndex.value = Math.ceil((scrollTop - props.size / 2 * props.height) / props.size / props.height);
|
|
39
|
+
}
|
|
40
|
+
if (currentIndex.value === 1) {
|
|
41
|
+
marginTop.value = "0px";
|
|
42
|
+
} else {
|
|
43
|
+
marginTop.value = ((currentIndex.value - 1) * props.size - props.size / 2) * props.height + "px";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function rowClick(row) {
|
|
47
|
+
current.value = row;
|
|
48
|
+
emit("row-click", row);
|
|
49
|
+
}
|
|
50
|
+
return (_ctx, _cache) => {
|
|
51
|
+
return openBlock(), createElementBlock("div", {
|
|
52
|
+
class: normalizeClass(unref(containerCls)),
|
|
53
|
+
onScroll: scrollList
|
|
54
|
+
}, [
|
|
55
|
+
createElementVNode("div", {
|
|
56
|
+
style: normalizeStyle({
|
|
57
|
+
height: totalHeight.value,
|
|
58
|
+
width: 0,
|
|
59
|
+
float: "left"
|
|
60
|
+
})
|
|
61
|
+
}, null, 4),
|
|
62
|
+
createElementVNode("div", {
|
|
63
|
+
style: normalizeStyle({ marginTop: marginTop.value })
|
|
64
|
+
}, [
|
|
65
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(calcList), (item) => {
|
|
66
|
+
return openBlock(), createElementBlock("div", {
|
|
67
|
+
key: item[_ctx.rowKey],
|
|
68
|
+
style: normalizeStyle({
|
|
69
|
+
height: _ctx.height + "px"
|
|
70
|
+
}),
|
|
71
|
+
class: normalizeClass(["hzzt-lazy-list__item", current.value === item ? "is-active" : ""]),
|
|
72
|
+
onClick: ($event) => rowClick(item)
|
|
73
|
+
}, [
|
|
74
|
+
renderSlot(_ctx.$slots, "default", { data: item })
|
|
75
|
+
], 14, _hoisted_1);
|
|
76
|
+
}), 128))
|
|
77
|
+
], 4)
|
|
78
|
+
], 34);
|
|
79
|
+
};
|
|
20
80
|
}
|
|
21
81
|
});
|
|
22
|
-
|
|
23
|
-
"row-click": (row) => row
|
|
24
|
-
};
|
|
82
|
+
var LazyList = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "lazy-list.vue"]]);
|
|
25
83
|
|
|
26
|
-
export {
|
|
84
|
+
export { LazyList as default };
|
|
27
85
|
//# sourceMappingURL=lazy-list2.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-list2.mjs","sources":["../../../../../../packages/components/lazy-list/src/lazy-list.
|
|
1
|
+
{"version":3,"file":"lazy-list2.mjs","sources":["../../../../../../packages/components/lazy-list/src/lazy-list.vue"],"sourcesContent":["<template>\n <div :class=\"containerCls\" @scroll=\"scrollList\">\n <div\n :style=\"{\n height: totalHeight,\n width: 0,\n float: 'left',\n }\"\n />\n <div :style=\"{marginTop: marginTop}\">\n <div\n v-for=\"item in calcList\"\n :key=\"item[rowKey]\"\n :style=\"{\n height: height+'px'\n }\"\n :class=\"['hzzt-lazy-list__item', current === item?'is-active':'']\"\n @click=\"rowClick(item)\"\n >\n <slot :data=\"item\" />\n </div>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import {lazyListEmits, lazyListProps} from './lazy-list'\n import {computed, ref, watch} from \"vue\";\n import {useNamespace} from \"@hzzt-plus/hooks\";\n\n defineOptions({\n name: 'HzztLazyList',\n })\n\n const props = defineProps(lazyListProps)\n const emit = defineEmits(lazyListEmits)\n\n const totalHeight = ref('100%');\n const marginTop = ref('0px');\n const currentIndex = ref(1);\n const current = ref(null);\n\n const nsLazy = useNamespace('lazy-list');\n\n const containerCls = computed(() => [\n 'overflow-y-auto',\n nsLazy.b(),\n ])\n\n watch(() => props.data, () => {\n totalHeight.value = props.data.length * props.height + 'px';\n }, {\n immediate: true,\n });\n\n const calcList = computed(\n () => props.data.slice(currentIndex.value === 1 ? 0 : ((currentIndex.value - 1) * props.size -\n props.size / 2), (currentIndex.value + 1) * props.size + props.size / 2));\n\n function scrollList(e: Event) {\n const target = e.target as HTMLElement;\n const scrollTop = target.scrollTop;\n if (scrollTop < props.size / 2 * props.height) {\n currentIndex.value = 1;\n } else {\n currentIndex.value = Math.ceil((scrollTop - props.size / 2 * props.height) / props.size / props.height);\n }\n if (currentIndex.value === 1) {\n marginTop.value = '0px';\n } else {\n marginTop.value = ((currentIndex.value - 1) * props.size - props.size / 2) * props.height + 'px';\n }\n }\n\n function rowClick(row: any) {\n current.value = row;\n emit('row-click', row);\n }\n\n\n</script>\n"],"names":["_openBlock","_createElementBlock"],"mappings":";;;;;;;mCA8BgB,CAAA;AAAA,EACZ,IAAM,EAAA,cAAA;AACR,CAAA,CAAA,CAAA;;;;;;;AAKA,IAAM,MAAA,WAAA,GAAc,IAAI,MAAM,CAAA,CAAA;AAC9B,IAAM,MAAA,SAAA,GAAY,IAAI,KAAK,CAAA,CAAA;AAC3B,IAAM,MAAA,YAAA,GAAe,IAAI,CAAC,CAAA,CAAA;AAC1B,IAAM,MAAA,OAAA,GAAU,IAAI,IAAI,CAAA,CAAA;AAExB,IAAM,MAAA,MAAA,GAAS,aAAa,WAAW,CAAA,CAAA;AAEvC,IAAM,MAAA,YAAA,GAAe,SAAS,MAAM;AAAA,MAClC,iBAAA;AAAA,MACA,OAAO,CAAE,EAAA;AAAA,KACV,CAAA,CAAA;AAED,IAAM,KAAA,CAAA,MAAM,KAAM,CAAA,IAAA,EAAM,MAAM;AAC5B,MAAA,WAAA,CAAY,KAAQ,GAAA,KAAA,CAAM,IAAK,CAAA,MAAA,GAAS,MAAM,MAAS,GAAA,IAAA,CAAA;AAAA,KACtD,EAAA;AAAA,MACD,SAAW,EAAA,IAAA;AAAA,KACZ,CAAA,CAAA;AAED,IAAA,MAAM,QAAW,GAAA,QAAA,CAAA,MAAA,KAAA,CAAA,IAAA,CAAA,KAAA,CAAA,YAAA,CAAA,KAAA,KAAA,CAAA,GAAA,CAAA,GAAA,CAAA,YAAA,CAAA,KAAA,GAAA,CAAA,IAAA,KAAA,CAAA,IAAA,GAAA,KAAA,CAAA,IAAA,GAAA,CAAA,EAAA,CAAA,YAAA,CAAA,KAAA,GAAA,CAAA,IAAA,KAAA,CAAA,IAAA,GAAA,KAAA,CAAA,IAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,IACf,mBAAiB,CAAA,CAAA,EAAA;AACwD,MAAC,MAAA,MAAA,GAAA,CAAA,CAAA,MAAA,CAAA;AAE5E,MAAA,MAAA,YAAoB,MAAU,CAAA,SAAA,CAAA;AAC5B,MAAA,IAAA,YAAiB,KAAA,CAAA,IAAA,GAAA,CAAA,GAAA,KAAA,CAAA,MAAA,EAAA;AACjB,QAAA,kBAAyB,GAAA,CAAA,CAAA;AACzB,OAAA,MAAgB;AACd,QAAA,YAAA,CAAa,KAAQ,GAAA,IAAA,CAAA,IAAA,CAAA,CAAA,SAAA,GAAA,KAAA,CAAA,IAAA,GAAA,CAAA,GAAA,KAAA,CAAA,MAAA,IAAA,KAAA,CAAA,IAAA,GAAA,KAAA,CAAA,MAAA,CAAA,CAAA;AAAA,OAChB;AACL,MAAA,IAAA,YAAqB,CAAA,KAAA,KAAA,CAAK,EAAM;AAAsE,QACxG,SAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AACA,OAAI,MAAA;AACF,QAAA,SAAA,CAAU,KAAQ,GAAA,CAAA,CAAA,YAAA,CAAA,KAAA,GAAA,CAAA,IAAA,KAAA,CAAA,IAAA,GAAA,KAAA,CAAA,IAAA,GAAA,CAAA,IAAA,KAAA,CAAA,MAAA,GAAA,IAAA,CAAA;AAAA,OACb;AACL,KAAU;AAAkF,IAC9F,SAAA,QAAA,CAAA,GAAA,EAAA;AAAA,MACF,OAAA,CAAA,KAAA,GAAA,GAAA,CAAA;AAEA,MAAA,IAAA,CAAA,WAAkB,EAAU,GAAA,CAAA,CAAA;AAC1B,KAAA;AACA,IAAA,OAAK,aAAa,KAAG;AAAA,MACvB,OAAAA,SAAA,EAAA,EAAAC,kBAAA,CAAA,KAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../../utils/index.mjs';
|
|
2
|
-
import Select from './src/
|
|
3
|
-
export { selectEmits, selectProps } from './src/
|
|
2
|
+
import Select from './src/select.mjs';
|
|
3
|
+
export { selectEmits, selectProps } from './src/select2.mjs';
|
|
4
4
|
import { withInstall } from '../../utils/vue/install.mjs';
|
|
5
5
|
|
|
6
6
|
const HzztSelect = withInstall(Select);
|
|
@@ -1,47 +1,218 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '
|
|
1
|
+
import { defineComponent, useAttrs, ref, computed, watch, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createVNode, mergeProps, withCtx, createBlock, createCommentVNode, renderSlot } from 'vue';
|
|
2
|
+
import { selectProps, selectEmits } from './select2.mjs';
|
|
3
|
+
import { useFormSize, useFormDisabled, ElInput, ElSelectV2 } from 'element-plus';
|
|
3
4
|
import '../../../hooks/index.mjs';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import HzztIcon from '../../icon/src/index.mjs';
|
|
6
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
7
|
+
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
8
|
+
import { useGlobalSize } from '../../../hooks/use-size/index.mjs';
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type: definePropType(Array),
|
|
13
|
-
default: () => []
|
|
14
|
-
},
|
|
15
|
-
modelValue: {
|
|
16
|
-
type: definePropType([
|
|
17
|
-
String
|
|
18
|
-
]),
|
|
19
|
-
default: ""
|
|
20
|
-
},
|
|
21
|
-
disabled: Boolean,
|
|
22
|
-
readonly: Boolean,
|
|
23
|
-
clearable: Boolean,
|
|
24
|
-
replace: {
|
|
25
|
-
type: Boolean,
|
|
26
|
-
default: true
|
|
27
|
-
},
|
|
28
|
-
autoPullDown: {
|
|
29
|
-
type: Boolean,
|
|
30
|
-
default: true
|
|
31
|
-
},
|
|
32
|
-
placeholder: String,
|
|
33
|
-
size: useSizeProp
|
|
10
|
+
const __default__ = defineComponent({
|
|
11
|
+
name: "HzztSelect",
|
|
12
|
+
inheritAttrs: false
|
|
34
13
|
});
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
14
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
15
|
+
...__default__,
|
|
16
|
+
props: selectProps,
|
|
17
|
+
emits: selectEmits,
|
|
18
|
+
setup(__props, { emit }) {
|
|
19
|
+
const props = __props;
|
|
20
|
+
const attrs = useAttrs();
|
|
21
|
+
const inputVal = ref(props.modelValue);
|
|
22
|
+
const selectVal = ref();
|
|
23
|
+
const inputRef = ref();
|
|
24
|
+
const selectRef = ref();
|
|
25
|
+
const arrowName = ref("arrow-down");
|
|
26
|
+
const nsSelect = useNamespace("select");
|
|
27
|
+
const formSize = useFormSize();
|
|
28
|
+
const formDisabled = useFormDisabled();
|
|
29
|
+
const trueSize = computed(() => props.size || formSize.value || useGlobalSize().value);
|
|
30
|
+
const trueDisabled = computed(() => props.disabled || formDisabled.value);
|
|
31
|
+
const trueReadonly = computed(() => props.readonly || trueDisabled.value);
|
|
32
|
+
const containerCls = computed(() => [
|
|
33
|
+
"relative",
|
|
34
|
+
"line-height-1",
|
|
35
|
+
attrs.class,
|
|
36
|
+
nsSelect.b(),
|
|
37
|
+
nsSelect.m(trueSize.value)
|
|
38
|
+
]);
|
|
39
|
+
const containerStyle = computed(() => attrs.style);
|
|
40
|
+
const inputCls = computed(() => [nsSelect.e("input"), "width-100%"]);
|
|
41
|
+
const selectCls = computed(() => [nsSelect.e("select"), "width-100%"]);
|
|
42
|
+
const _inputProps = computed(() => ({
|
|
43
|
+
disabled: trueDisabled.value,
|
|
44
|
+
size: trueSize.value,
|
|
45
|
+
clearable: props.clearable,
|
|
46
|
+
placeholder: props.placeholder,
|
|
47
|
+
readonly: props.readonly,
|
|
48
|
+
...attrs,
|
|
49
|
+
class: "",
|
|
50
|
+
style: {
|
|
51
|
+
position: trueReadonly.value ? "static" : "absolute",
|
|
52
|
+
left: 0,
|
|
53
|
+
top: 0,
|
|
54
|
+
right: 0,
|
|
55
|
+
zIndex: 2
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
const _selectProps = computed(() => ({
|
|
59
|
+
options: props.options,
|
|
60
|
+
size: trueSize.value,
|
|
61
|
+
filterable: true,
|
|
62
|
+
popperClass: "select-v2-popper-min-width-100",
|
|
63
|
+
...props.selectProps
|
|
64
|
+
}));
|
|
65
|
+
watch(() => props.modelValue, (v) => {
|
|
66
|
+
inputVal.value = v;
|
|
67
|
+
});
|
|
68
|
+
watch(() => inputVal.value, (v) => {
|
|
69
|
+
selectVal.value = v;
|
|
70
|
+
});
|
|
71
|
+
function input(str) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
if ((_a = selectRef.value) == null ? void 0 : _a.dropdownMenuVisible) {
|
|
74
|
+
selectRef.value.states.inputValue = (_b = inputVal.value) != null ? _b : "";
|
|
75
|
+
selectRef.value.debouncedOnInputChange();
|
|
76
|
+
} else if (selectRef.value) {
|
|
77
|
+
selectRef.value.dropdownMenuVisible = true;
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
var _a2;
|
|
80
|
+
if (selectRef.value) {
|
|
81
|
+
selectRef.value.states.inputValue = (_a2 = inputVal.value) != null ? _a2 : "";
|
|
82
|
+
selectRef.value.debouncedOnInputChange();
|
|
83
|
+
}
|
|
84
|
+
}, 200);
|
|
85
|
+
}
|
|
86
|
+
emit("update:modelValue", str);
|
|
87
|
+
emit("input", str);
|
|
88
|
+
}
|
|
89
|
+
function change(str) {
|
|
90
|
+
emit("change", str);
|
|
91
|
+
}
|
|
92
|
+
function focus() {
|
|
93
|
+
if (selectRef.value && props.autoPullDown) {
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
if (selectRef.value) {
|
|
96
|
+
selectRef.value.dropdownMenuVisible = true;
|
|
97
|
+
}
|
|
98
|
+
}, 200);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function keydown(e) {
|
|
102
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
103
|
+
const key = "key" in e && e.key;
|
|
104
|
+
const dropdownVisible = (_a = selectRef.value) == null ? void 0 : _a.dropdownMenuVisible;
|
|
105
|
+
if (dropdownVisible && (key === "ArrowDown" || key === "ArrowUp" || key === "Enter")) {
|
|
106
|
+
(_b = e.preventDefault) == null ? void 0 : _b.call(e);
|
|
107
|
+
if (key === "ArrowDown") {
|
|
108
|
+
(_c = selectRef.value) == null ? void 0 : _c.onKeyboardNavigate("forward");
|
|
109
|
+
} else if (key === "ArrowUp") {
|
|
110
|
+
(_d = selectRef.value) == null ? void 0 : _d.onKeyboardNavigate("backward");
|
|
111
|
+
} else if (key === "Enter") {
|
|
112
|
+
(_e = selectRef.value) == null ? void 0 : _e.onKeyboardSelect();
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!dropdownVisible) {
|
|
117
|
+
if (key === "ArrowDown") {
|
|
118
|
+
emit("arrow-down", e);
|
|
119
|
+
} else if (key === "ArrowUp") {
|
|
120
|
+
emit("arrow-up", e);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (key === "ArrowLeft") {
|
|
124
|
+
const index = inputRef.value.input.selectionStart;
|
|
125
|
+
if (index === 0 && selectRef.value) {
|
|
126
|
+
emit("arrow-left", e);
|
|
127
|
+
selectRef.value.dropdownMenuVisible = false;
|
|
128
|
+
}
|
|
129
|
+
} else if (key === "ArrowRight") {
|
|
130
|
+
const index = inputRef.value.input.selectionStart;
|
|
131
|
+
if (((_g = (_f = inputVal.value) == null ? void 0 : _f.length) != null ? _g : 0) === index && selectRef.value) {
|
|
132
|
+
emit("arrow-right", e);
|
|
133
|
+
selectRef.value.dropdownMenuVisible = false;
|
|
134
|
+
}
|
|
135
|
+
} else if (key === "Enter") {
|
|
136
|
+
emit("enter", e);
|
|
137
|
+
selectRef.value && (selectRef.value.dropdownMenuVisible = false);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function showSelect() {
|
|
141
|
+
if (selectRef.value) {
|
|
142
|
+
selectRef.value.dropdownMenuVisible = !selectRef.value.dropdownMenuVisible;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function selectChange(v) {
|
|
146
|
+
let str = inputVal.value || "";
|
|
147
|
+
if (props.replace) {
|
|
148
|
+
str = v;
|
|
149
|
+
} else {
|
|
150
|
+
str += v;
|
|
151
|
+
}
|
|
152
|
+
emit("update:modelValue", str);
|
|
153
|
+
emit("input", str);
|
|
154
|
+
inputVal.value = str;
|
|
155
|
+
setTimeout(() => {
|
|
156
|
+
inputRef.value.focus();
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
if (selectRef.value) {
|
|
159
|
+
selectRef.value.dropdownMenuVisible = false;
|
|
160
|
+
}
|
|
161
|
+
}, 250);
|
|
162
|
+
emit("change", str);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function selectVisibleChange(v) {
|
|
166
|
+
arrowName.value = v ? "arrow-up" : "arrow-down";
|
|
167
|
+
}
|
|
168
|
+
return (_ctx, _cache) => {
|
|
169
|
+
return openBlock(), createElementBlock("div", {
|
|
170
|
+
class: normalizeClass(unref(containerCls)),
|
|
171
|
+
style: normalizeStyle(unref(containerStyle))
|
|
172
|
+
}, [
|
|
173
|
+
createVNode(unref(ElInput), mergeProps({
|
|
174
|
+
class: unref(inputCls),
|
|
175
|
+
modelValue: inputVal.value,
|
|
176
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputVal.value = $event),
|
|
177
|
+
ref_key: "inputRef",
|
|
178
|
+
ref: inputRef
|
|
179
|
+
}, unref(_inputProps), {
|
|
180
|
+
onInput: input,
|
|
181
|
+
onChange: change,
|
|
182
|
+
onFocus: focus,
|
|
183
|
+
onKeydown: keydown
|
|
184
|
+
}), {
|
|
185
|
+
suffix: withCtx(() => [
|
|
186
|
+
!unref(trueReadonly) ? (openBlock(), createBlock(HzztIcon, {
|
|
187
|
+
key: 0,
|
|
188
|
+
class: "pointer",
|
|
189
|
+
name: arrowName.value,
|
|
190
|
+
onClick: showSelect
|
|
191
|
+
}, null, 8, ["name"])) : createCommentVNode("v-if", true)
|
|
192
|
+
]),
|
|
193
|
+
_: 1
|
|
194
|
+
}, 16, ["class", "modelValue"]),
|
|
195
|
+
!unref(trueReadonly) ? (openBlock(), createBlock(unref(ElSelectV2), mergeProps({
|
|
196
|
+
key: 0,
|
|
197
|
+
class: unref(selectCls),
|
|
198
|
+
modelValue: selectVal.value,
|
|
199
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => selectVal.value = $event),
|
|
200
|
+
ref_key: "selectRef",
|
|
201
|
+
ref: selectRef
|
|
202
|
+
}, unref(_selectProps), {
|
|
203
|
+
onChange: selectChange,
|
|
204
|
+
onVisibleChange: selectVisibleChange
|
|
205
|
+
}), {
|
|
206
|
+
default: withCtx(({ item }) => [
|
|
207
|
+
renderSlot(_ctx.$slots, "default", { item })
|
|
208
|
+
]),
|
|
209
|
+
_: 3
|
|
210
|
+
}, 16, ["class", "modelValue"])) : createCommentVNode("v-if", true)
|
|
211
|
+
], 6);
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
var Select = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "select.vue"]]);
|
|
45
216
|
|
|
46
|
-
export {
|
|
217
|
+
export { Select as default };
|
|
47
218
|
//# sourceMappingURL=select.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.mjs","sources":["../../../../../../packages/components/select/src/select.ts"],"sourcesContent":["import {buildProps, definePropType, isString} from '@hzzt-plus/utils'\nimport type {ExtractPropTypes} from 'vue'\nimport type Select from './select.vue'\nimport {UPDATE_MODEL_EVENT} from \"@hzzt-plus/constants\";\nimport {useSizeProp} from \"@hzzt-plus/hooks\";\n\n\ntype OptionCommon = Record<string, any>\n\nexport type Option = OptionCommon & {\n created?: boolean\n}\n\nexport type OptionGroup = OptionCommon\n\nexport type OptionType = Option | OptionGroup\n\nexport const selectProps = buildProps({\n selectProps: Object,\n options: {\n type: definePropType<OptionType[]>(Array),\n default: () => [],\n },\n modelValue: {\n type: definePropType<string | null | undefined>([\n String,\n ]),\n default: '',\n },\n disabled: Boolean,\n readonly: Boolean,\n clearable: Boolean,\n replace: {\n type: Boolean,\n default: true,\n },\n autoPullDown: {\n type: Boolean,\n default: true,\n },\n placeholder: String,\n size: useSizeProp,\n})\n\nexport type SelectProps = ExtractPropTypes<typeof selectProps>\n\nexport const selectEmits = {\n [UPDATE_MODEL_EVENT]: (value: string | undefined) => isString(value),\n 'input': (value: string | undefined) => isString(value),\n 'change': (value: string | undefined) => isString(value),\n 'arrow-down': (e: KeyboardEvent | Event) => e,\n 'arrow-up': (e: KeyboardEvent | Event) => e,\n 'arrow-left': (e: KeyboardEvent | Event) => e,\n 'arrow-right': (e: KeyboardEvent | Event) => e,\n 'enter': (e: KeyboardEvent | Event) => e,\n}\nexport type SelectEmits = typeof selectEmits\n\n\nexport type SelectInstance = InstanceType<typeof Select>\n"],"names":[],"mappings":";;;;;;;;AAGY,MAAC,WAAW,GAAG,UAAU,CAAC;AACtC,EAAE,WAAW,EAAE,MAAM;AACrB,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,OAAO,EAAE,MAAM,EAAE;AACrB,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,cAAc,CAAC;AACzB,MAAM,MAAM;AACZ,KAAK,CAAC;AACN,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,SAAS,EAAE,OAAO;AACpB,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,YAAY,EAAE;AAChB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,WAAW,EAAE,MAAM;AACrB,EAAE,IAAI,EAAE,WAAW;AACnB,CAAC,EAAE;AACS,MAAC,WAAW,GAAG;AAC3B,EAAE,CAAC,kBAAkB,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AAClD,EAAE,OAAO,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AACrC,EAAE,QAAQ,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AACtC,EAAE,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC;AACxB,EAAE,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC;AACtB,EAAE,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC;AACxB,EAAE,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC;AACzB,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC;AACnB;;;;"}
|
|
1
|
+
{"version":3,"file":"select.mjs","sources":["../../../../../../packages/components/select/src/select.vue"],"sourcesContent":["<template>\n <div :class=\"containerCls\" :style=\"containerStyle\">\n <el-input\n :class=\"inputCls\"\n v-model=\"inputVal\"\n ref=\"inputRef\"\n v-bind=\"_inputProps\"\n @input=\"input\"\n @change=\"change\"\n @focus=\"focus\"\n @keydown=\"keydown\"\n >\n <template #suffix>\n <hzzt-icon\n v-if=\"!trueReadonly\"\n class=\"pointer\"\n :name=\"arrowName\"\n @click=\"showSelect\"\n ></hzzt-icon>\n </template>\n </el-input>\n <el-select-v2\n v-if=\"!trueReadonly\"\n :class=\"selectCls\"\n v-model=\"selectVal\"\n ref=\"selectRef\"\n v-bind=\"_selectProps\"\n @change=\"selectChange\"\n @visible-change=\"selectVisibleChange\"\n >\n <template #default=\"{ item }\">\n <slot :item=\"item\" />\n </template>\n </el-select-v2>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { selectEmits, selectProps } from './select'\nimport { computed, ref, useAttrs, watch } from 'vue'\nimport { useFormDisabled, useFormSize } from 'element-plus'\nimport { useGlobalSize, useNamespace } from '@hzzt-plus/hooks'\nimport { ElInput, ElSelectV2 } from 'element-plus'\nimport type { CSSProperties } from 'vue'\nimport HzztIcon from '@hzzt-plus/components/icon/src/index.vue'\n\ndefineOptions({\n name: 'HzztSelect',\n inheritAttrs: false,\n})\n\nconst props = defineProps(selectProps)\nconst emit = defineEmits(selectEmits)\n\nconst attrs = useAttrs()\n\nconst inputVal = ref(props.modelValue)\nconst selectVal = ref()\nconst inputRef = ref()\nconst selectRef = ref()\nconst arrowName = ref('arrow-down')\n\nconst nsSelect = useNamespace('select')\n\nconst formSize = useFormSize()\nconst formDisabled = useFormDisabled()\n\nconst trueSize = computed(\n () => props.size || formSize.value || useGlobalSize().value\n)\n\nconst trueDisabled = computed(() => props.disabled || formDisabled.value)\n\nconst trueReadonly = computed(() => props.readonly || trueDisabled.value)\n\nconst containerCls = computed(() => [\n 'relative',\n 'line-height-1',\n attrs.class,\n nsSelect.b(),\n nsSelect.m(trueSize.value),\n])\n\nconst containerStyle = computed(() => attrs.style as CSSProperties)\n\nconst inputCls = computed(() => [nsSelect.e('input'), 'width-100%'])\n\nconst selectCls = computed(() => [nsSelect.e('select'), 'width-100%'])\n\nconst _inputProps = computed(() => ({\n disabled: trueDisabled.value,\n size: trueSize.value,\n clearable: props.clearable,\n placeholder: props.placeholder,\n readonly: props.readonly,\n ...attrs,\n class: '',\n style: {\n position: trueReadonly.value ? 'static' : 'absolute',\n left: 0,\n top: 0,\n right: 0,\n zIndex: 2,\n },\n}))\n\nconst _selectProps = computed(() => ({\n options: props.options,\n size: trueSize.value,\n filterable: true,\n popperClass: 'select-v2-popper-min-width-100',\n ...props.selectProps,\n}))\n\nwatch(\n () => props.modelValue,\n (v) => {\n inputVal.value = v\n }\n)\n\nwatch(\n () => inputVal.value,\n (v) => {\n selectVal.value = v\n }\n)\n\nfunction input(str: string) {\n if (selectRef.value?.dropdownMenuVisible) {\n selectRef.value.states.inputValue = inputVal.value ?? ''\n selectRef.value.debouncedOnInputChange()\n } else if (selectRef.value) {\n selectRef.value.dropdownMenuVisible = true\n setTimeout(() => {\n if (selectRef.value) {\n selectRef.value.states.inputValue = inputVal.value ?? ''\n selectRef.value.debouncedOnInputChange()\n }\n }, 200)\n }\n emit('update:modelValue', str)\n emit('input', str)\n}\n\nfunction change(str: string) {\n emit('change', str)\n}\n\nfunction focus() {\n if (selectRef.value && props.autoPullDown) {\n setTimeout(() => {\n if (selectRef.value) {\n selectRef.value.dropdownMenuVisible = true\n }\n }, 200)\n }\n}\n\nfunction keydown(e: KeyboardEvent | Event) {\n const key = 'key' in e && e.key\n const dropdownVisible = selectRef.value?.dropdownMenuVisible\n\n // 下拉面板展开时,上下箭头切换选项,回车选中当前高亮项\n if (\n dropdownVisible &&\n (key === 'ArrowDown' || key === 'ArrowUp' || key === 'Enter')\n ) {\n e.preventDefault?.()\n if (key === 'ArrowDown') {\n selectRef.value?.onKeyboardNavigate('forward')\n } else if (key === 'ArrowUp') {\n selectRef.value?.onKeyboardNavigate('backward')\n } else if (key === 'Enter') {\n selectRef.value?.onKeyboardSelect()\n }\n return\n }\n\n if (!dropdownVisible) {\n if (key === 'ArrowDown') {\n emit('arrow-down', e)\n } else if (key === 'ArrowUp') {\n emit('arrow-up', e)\n }\n }\n if (key === 'ArrowLeft') {\n const index = inputRef.value.input.selectionStart\n if (index === 0 && selectRef.value) {\n emit('arrow-left', e)\n selectRef.value.dropdownMenuVisible = false\n }\n } else if (key === 'ArrowRight') {\n const index = inputRef.value.input.selectionStart\n if ((inputVal.value?.length ?? 0) === index && selectRef.value) {\n emit('arrow-right', e)\n selectRef.value.dropdownMenuVisible = false\n }\n } else if (key === 'Enter') {\n emit('enter', e)\n selectRef.value && (selectRef.value.dropdownMenuVisible = false)\n }\n}\n\nfunction showSelect() {\n if (selectRef.value) {\n selectRef.value.dropdownMenuVisible = !selectRef.value.dropdownMenuVisible\n }\n}\n\nfunction selectChange(v: string) {\n let str = inputVal.value || ''\n if (props.replace) {\n str = v\n } else {\n str += v\n }\n emit('update:modelValue', str)\n emit('input', str)\n inputVal.value = str\n setTimeout(() => {\n inputRef.value.focus()\n setTimeout(() => {\n if (selectRef.value) {\n selectRef.value.dropdownMenuVisible = false\n }\n }, 250)\n emit('change', str)\n })\n}\n\nfunction selectVisibleChange(v: boolean) {\n arrowName.value = v ? 'arrow-up' : 'arrow-down'\n}\n</script>\n"],"names":["_openBlock","_createElementBlock","_normalizeStyle","_unref"],"mappings":";;;;;;;;;mCA8Cc,CAAA;AAAA,EACZ,IAAM,EAAA,YAAA;AAAA,EACN,YAAc,EAAA,KAAA;AAChB,CAAA,CAAA,CAAA;;;;;;;AAKA,IAAA,MAAM,QAAQ,QAAS,EAAA,CAAA;AAEvB,IAAM,MAAA,QAAA,GAAW,GAAI,CAAA,KAAA,CAAM,UAAU,CAAA,CAAA;AACrC,IAAA,MAAM,YAAY,GAAI,EAAA,CAAA;AACtB,IAAA,MAAM,WAAW,GAAI,EAAA,CAAA;AACrB,IAAA,MAAM,YAAY,GAAI,EAAA,CAAA;AACtB,IAAM,MAAA,SAAA,GAAY,IAAI,YAAY,CAAA,CAAA;AAElC,IAAM,MAAA,QAAA,GAAW,aAAa,QAAQ,CAAA,CAAA;AAEtC,IAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,IAAA,MAAM,eAAe,eAAgB,EAAA,CAAA;AAErC,IAAA,MAAM,QAAW,GAAA,QAAA,CAAA,MAAA,KAAA,CAAA,IAAA,IAAA,QAAA,CAAA,KAAA,IAAA,aAAA,EAAA,CAAA,KAAA,CAAA,CAAA;AAAA,IAAA,kBACH,GAAA,QAAiB,CAAA,MAAA,kBAAuB,YAAE,CAAA,KAAA,CAAA,CAAA;AAAA,IACxD,MAAA,YAAA,GAAA,QAAA,CAAA,MAAA,KAAA,CAAA,QAAA,IAAA,YAAA,CAAA,KAAA,CAAA,CAAA;AAEA,IAAA,MAAM,eAAe,QAAS,CA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