@v-c/select 1.0.17 → 1.0.19-beta.1
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);
|
|
@@ -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, {
|
|
@@ -25,7 +25,8 @@ var Input_default = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =
|
|
|
25
25
|
const { mode, onSearchSubmit } = selectInputContext.value ?? {};
|
|
26
26
|
const { key } = event;
|
|
27
27
|
const { value: nextVal } = event.currentTarget;
|
|
28
|
-
|
|
28
|
+
const isOpen = !!baseProps.value?.open;
|
|
29
|
+
if (key === KeyCodeStr.Enter && mode === "tags" && !isOpen && !compositionStatusRef.value && onSearchSubmit) onSearchSubmit(nextVal);
|
|
29
30
|
props?.onKeyDown?.(event);
|
|
30
31
|
};
|
|
31
32
|
const handleBlur = (event) => {
|
|
@@ -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.19-beta.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@v-c/overflow": "^1.0.3",
|
|
33
|
-
"@v-c/trigger": "^1.0.
|
|
33
|
+
"@v-c/trigger": "^1.0.12-beta.1",
|
|
34
34
|
"@v-c/util": "^1.0.17",
|
|
35
35
|
"@v-c/virtual-list": "^1.0.6"
|
|
36
36
|
},
|