@v-c/select 1.0.16 → 1.0.18
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/BaseSelect/index.js
CHANGED
|
@@ -154,7 +154,9 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
|
|
|
154
154
|
const isEnterKey = key === KeyCodeStr.Enter;
|
|
155
155
|
const isSpaceKey = key === KeyCodeStr.Space;
|
|
156
156
|
if (isEnterKey || isSpaceKey) {
|
|
157
|
-
|
|
157
|
+
const isCombobox = mode.value === "combobox";
|
|
158
|
+
const isEditable = isCombobox || !!props.showSearch;
|
|
159
|
+
if (isSpaceKey && !isEditable || isEnterKey && !isCombobox) event.preventDefault();
|
|
158
160
|
if (!mergedOpen.value) triggerOpen(true);
|
|
159
161
|
}
|
|
160
162
|
setClearLock(!!mergedSearchValue.value);
|
package/dist/Select.js
CHANGED
|
@@ -627,7 +627,7 @@ var Select_default = /* @__PURE__ */ defineComponent({
|
|
|
627
627
|
const displayValues = computed(() => {
|
|
628
628
|
if (!props.mode && mergedValues.value.length === 1) {
|
|
629
629
|
const firstValue = mergedValues.value[0];
|
|
630
|
-
if (firstValue.value === null && (firstValue.label === null || firstValue.label === void 0)) return [];
|
|
630
|
+
if ((firstValue.value === null || firstValue.value === "") && (firstValue.label === null || firstValue.label === void 0)) return [];
|
|
631
631
|
}
|
|
632
632
|
return mergedValues.value.map((item) => ({
|
|
633
633
|
...item,
|
|
@@ -49,6 +49,7 @@ var SingleContent_default = /* @__PURE__ */ defineComponent((props, { expose })
|
|
|
49
49
|
const { prefixCls, mode, maxLength, components } = selectInputContext.value ?? {};
|
|
50
50
|
const { classNames, styles } = baseProps.value ?? {};
|
|
51
51
|
const { inputProps } = props;
|
|
52
|
+
const showHasValueCls = displayValue.value && displayValue.value.label !== null && displayValue.value.label !== void 0 && String(displayValue.value.label).trim() !== "";
|
|
52
53
|
const renderValue = !(combobox && components?.input) ? displayValue.value ? hasOptionStyle.value ? createVNode("div", {
|
|
53
54
|
"class": clsx(`${prefixCls}-content-value`, optionClassName.value),
|
|
54
55
|
"style": {
|
|
@@ -58,7 +59,7 @@ var SingleContent_default = /* @__PURE__ */ defineComponent((props, { expose })
|
|
|
58
59
|
"title": optionTitle.value
|
|
59
60
|
}, [displayValue.value?.label]) : displayValue.value?.label : createVNode(Placeholder_default, { "show": !mergedSearchValue.value }, null) : null;
|
|
60
61
|
return createVNode("div", {
|
|
61
|
-
"class": clsx(`${prefixCls}-content`,
|
|
62
|
+
"class": clsx(`${prefixCls}-content`, showHasValueCls && `${prefixCls}-content-has-value`, mergedSearchValue.value && `${prefixCls}-content-has-search-value`, hasOptionStyle.value && `${prefixCls}-content-has-option-style`, classNames?.content),
|
|
62
63
|
"style": styles?.content,
|
|
63
64
|
"title": hasOptionStyle.value ? void 0 : optionTitle.value
|
|
64
65
|
}, [renderValue, createVNode(Input_default, mergeProps(inputProps, {
|
|
@@ -3,7 +3,7 @@ import { isValidateOpenKey } from "../utils/keyUtil.js";
|
|
|
3
3
|
import Affix_default from "./Affix.js";
|
|
4
4
|
import { useSelectInputProvider } from "./context.js";
|
|
5
5
|
import Content_default from "./Content/index.js";
|
|
6
|
-
import { computed, createVNode, defineComponent, isVNode, mergeProps, shallowRef } from "vue";
|
|
6
|
+
import { cloneVNode, computed, createVNode, defineComponent, isVNode, mergeProps, shallowRef } from "vue";
|
|
7
7
|
import { clsx } from "@v-c/util";
|
|
8
8
|
import KeyCode from "@v-c/util/dist/KeyCode";
|
|
9
9
|
import omit from "@v-c/util/dist/omit";
|
|
@@ -24,6 +24,21 @@ var DEFAULT_OMIT_PROPS = [
|
|
|
24
24
|
"onSelectorRemove",
|
|
25
25
|
"focused"
|
|
26
26
|
];
|
|
27
|
+
function mergeVNodeProps(originProps, nextProps) {
|
|
28
|
+
const mergedProps = {
|
|
29
|
+
...originProps,
|
|
30
|
+
...nextProps
|
|
31
|
+
};
|
|
32
|
+
Object.keys(originProps).forEach((key) => {
|
|
33
|
+
const originVal = originProps[key];
|
|
34
|
+
const nextVal = nextProps[key];
|
|
35
|
+
if (typeof originVal === "function" && typeof nextVal === "function") mergedProps[key] = (...args) => {
|
|
36
|
+
nextVal(...args);
|
|
37
|
+
originVal(...args);
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
return mergedProps;
|
|
41
|
+
}
|
|
27
42
|
var SelectInput_default = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots }) => {
|
|
28
43
|
const baseProps = useBaseProps();
|
|
29
44
|
const rootRef = shallowRef();
|
|
@@ -66,14 +81,17 @@ var SelectInput_default = /* @__PURE__ */ defineComponent((props, { attrs, expos
|
|
|
66
81
|
blur: () => {
|
|
67
82
|
(inputRef.value?.input || rootRef.value)?.blur?.();
|
|
68
83
|
},
|
|
69
|
-
nativeElement: rootRef
|
|
84
|
+
nativeElement: computed(() => getDOM(rootRef.value))
|
|
70
85
|
});
|
|
71
86
|
const onInternalMouseDown = (event) => {
|
|
72
87
|
if (!disabled.value) {
|
|
73
88
|
const inputDOM = getDOM(inputRef.value?.input);
|
|
74
89
|
event._ori_target = inputDOM;
|
|
75
|
-
|
|
76
|
-
|
|
90
|
+
const isClickOnInput = inputDOM === event.target || inputDOM?.contains(event.target);
|
|
91
|
+
if (inputDOM && !isClickOnInput) event.preventDefault();
|
|
92
|
+
const shouldPreventCloseOnSingle = triggerOpen.value && !multiple.value && (mode.value === "combobox" || showSearch.value);
|
|
93
|
+
const shouldPreventCloseOnMultipleInput = triggerOpen.value && multiple.value && isClickOnInput;
|
|
94
|
+
const shouldPreventClose = shouldPreventCloseOnSingle || shouldPreventCloseOnMultipleInput;
|
|
77
95
|
if (!event._select_lazy) {
|
|
78
96
|
inputRef.value?.input?.focus();
|
|
79
97
|
if (!shouldPreventClose) toggleOpen.value?.();
|
|
@@ -98,11 +116,12 @@ var SelectInput_default = /* @__PURE__ */ defineComponent((props, { attrs, expos
|
|
|
98
116
|
onMousedown: props.onMouseDown
|
|
99
117
|
}, DEFAULT_OMIT_PROPS);
|
|
100
118
|
if (RootComponent) {
|
|
101
|
-
|
|
102
|
-
|
|
119
|
+
const mergedProps = mergeVNodeProps(RootComponent.props || {}, domProps);
|
|
120
|
+
if (isVNode(RootComponent)) return cloneVNode(RootComponent, {
|
|
121
|
+
...mergedProps,
|
|
103
122
|
ref: rootRef
|
|
104
123
|
});
|
|
105
|
-
return createVNode(RootComponent, mergeProps(
|
|
124
|
+
return createVNode(RootComponent, mergeProps(mergedProps, { "ref": rootRef }), null);
|
|
106
125
|
}
|
|
107
126
|
return createVNode("div", mergeProps(domProps, {
|
|
108
127
|
"ref": rootRef,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/select",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.18",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@v-c/overflow": "^1.0.3",
|
|
33
33
|
"@v-c/trigger": "^1.0.11",
|
|
34
|
-
"@v-c/
|
|
35
|
-
"@v-c/
|
|
34
|
+
"@v-c/virtual-list": "^1.0.6",
|
|
35
|
+
"@v-c/util": "^1.0.17"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "vite build",
|