@v-c/select 1.0.9 → 1.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/BaseSelect/index.js +9 -4
- package/dist/SelectInput/Content/SingleContent.js +32 -26
- package/dist/hooks/useBaseProps.d.ts +1 -0
- package/dist/hooks/useOpen.d.ts +1 -1
- package/dist/hooks/useOpen.js +3 -2
- package/package.json +5 -5
- package/dist/BaseSelect/Polite.cjs +0 -40
- package/dist/BaseSelect/index.cjs +0 -778
- package/dist/OptGroup.cjs +0 -8
- package/dist/Option.cjs +0 -8
- package/dist/OptionList.cjs +0 -258
- package/dist/Select.cjs +0 -838
- package/dist/SelectContext.cjs +0 -12
- package/dist/SelectInput/Affix.cjs +0 -19
- package/dist/SelectInput/Content/MultipleContent.cjs +0 -145
- package/dist/SelectInput/Content/Placeholder.cjs +0 -36
- package/dist/SelectInput/Content/SingleContent.cjs +0 -83
- package/dist/SelectInput/Content/index.cjs +0 -43
- package/dist/SelectInput/Input.cjs +0 -179
- package/dist/SelectInput/context.cjs +0 -12
- package/dist/SelectInput/index.cjs +0 -341
- package/dist/SelectTrigger.cjs +0 -198
- package/dist/TransBtn.cjs +0 -72
- package/dist/_virtual/rolldown_runtime.cjs +0 -21
- package/dist/hooks/index.cjs +0 -24
- package/dist/hooks/useAllowClear.cjs +0 -18
- package/dist/hooks/useBaseProps.cjs +0 -15
- package/dist/hooks/useCache.cjs +0 -39
- package/dist/hooks/useComponents.cjs +0 -18
- package/dist/hooks/useFilterOptions.cjs +0 -42
- package/dist/hooks/useLock.cjs +0 -29
- package/dist/hooks/useOpen.cjs +0 -63
- package/dist/hooks/useOptions.cjs +0 -41
- package/dist/hooks/useRefFunc.cjs +0 -15
- package/dist/hooks/useSearchConfig.cjs +0 -26
- package/dist/hooks/useSelectTriggerControl.cjs +0 -26
- package/dist/index.cjs +0 -22
- package/dist/interface.cjs +0 -1
- package/dist/utils/commonUtil.cjs +0 -38
- package/dist/utils/keyUtil.cjs +0 -37
- package/dist/utils/legacyUtil.cjs +0 -33
- package/dist/utils/platformUtil.cjs +0 -6
- package/dist/utils/valueUtil.cjs +0 -80
package/dist/SelectContext.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
3
|
-
let vue = require("vue");
|
|
4
|
-
var SelectContextKey = Symbol("SelectContext");
|
|
5
|
-
function useSelectProvider(value) {
|
|
6
|
-
(0, vue.provide)(SelectContextKey, value);
|
|
7
|
-
}
|
|
8
|
-
function useSelectContext() {
|
|
9
|
-
return (0, vue.inject)(SelectContextKey, (0, vue.ref)(null));
|
|
10
|
-
}
|
|
11
|
-
exports.useSelectContext = useSelectContext;
|
|
12
|
-
exports.useSelectProvider = useSelectProvider;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
let vue = require("vue");
|
|
7
|
-
let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
8
|
-
var Affix = /* @__PURE__ */ (0, vue.defineComponent)((_, { attrs, slots }) => {
|
|
9
|
-
return () => {
|
|
10
|
-
const children = (0, _v_c_util_dist_props_util.filterEmpty)(slots?.default?.() ?? []);
|
|
11
|
-
if (children.length < 1) return null;
|
|
12
|
-
return (0, vue.createVNode)("div", attrs, [children]);
|
|
13
|
-
};
|
|
14
|
-
}, {
|
|
15
|
-
name: "Affix",
|
|
16
|
-
inheritAttrs: false
|
|
17
|
-
});
|
|
18
|
-
var Affix_default = Affix;
|
|
19
|
-
exports.default = Affix_default;
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_useBaseProps = require("../../hooks/useBaseProps.cjs");
|
|
7
|
-
const require_TransBtn = require("../../TransBtn.cjs");
|
|
8
|
-
const require_commonUtil = require("../../utils/commonUtil.cjs");
|
|
9
|
-
const require_context = require("../context.cjs");
|
|
10
|
-
const require_Input = require("../Input.cjs");
|
|
11
|
-
const require_Placeholder = require("./Placeholder.cjs");
|
|
12
|
-
let vue = require("vue");
|
|
13
|
-
let _v_c_util = require("@v-c/util");
|
|
14
|
-
let _v_c_overflow = require("@v-c/overflow");
|
|
15
|
-
_v_c_overflow = require_rolldown_runtime.__toESM(_v_c_overflow);
|
|
16
|
-
function itemKey(value) {
|
|
17
|
-
return value.key ?? value.value ?? "";
|
|
18
|
-
}
|
|
19
|
-
function onPreventMouseDown(event) {
|
|
20
|
-
event.preventDefault();
|
|
21
|
-
event.stopPropagation();
|
|
22
|
-
}
|
|
23
|
-
var MultipleContent = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose }) => {
|
|
24
|
-
const selectInputContext = require_context.useSelectInputContext();
|
|
25
|
-
const baseProps = require_useBaseProps.default();
|
|
26
|
-
const inputRef = (0, vue.shallowRef)();
|
|
27
|
-
const prefixCls = (0, vue.computed)(() => selectInputContext.value?.prefixCls ?? "");
|
|
28
|
-
const displayValues = (0, vue.computed)(() => selectInputContext.value?.displayValues ?? []);
|
|
29
|
-
const searchValue = (0, vue.computed)(() => selectInputContext.value?.searchValue ?? "");
|
|
30
|
-
const mode = (0, vue.computed)(() => selectInputContext.value?.mode);
|
|
31
|
-
const removeIconFromContext = (0, vue.computed)(() => selectInputContext.value?.removeIcon);
|
|
32
|
-
const onSelectorRemove = (0, vue.computed)(() => selectInputContext.value?.onSelectorRemove);
|
|
33
|
-
const disabled = (0, vue.computed)(() => baseProps.value?.disabled ?? false);
|
|
34
|
-
const showSearch = (0, vue.computed)(() => baseProps.value?.showSearch ?? false);
|
|
35
|
-
const triggerOpen = (0, vue.computed)(() => baseProps.value?.triggerOpen ?? false);
|
|
36
|
-
const toggleOpen = (0, vue.computed)(() => baseProps.value?.toggleOpen);
|
|
37
|
-
const autoClearSearchValue = (0, vue.computed)(() => baseProps.value?.autoClearSearchValue);
|
|
38
|
-
const tagRenderFromContext = (0, vue.computed)(() => baseProps.value?.tagRender);
|
|
39
|
-
const maxTagPlaceholderFromContext = (0, vue.computed)(() => baseProps.value?.maxTagPlaceholder);
|
|
40
|
-
const maxTagTextLength = (0, vue.computed)(() => baseProps.value?.maxTagTextLength);
|
|
41
|
-
const maxTagCount = (0, vue.computed)(() => baseProps.value?.maxTagCount);
|
|
42
|
-
const classNamesConfig = (0, vue.computed)(() => baseProps.value?.classNames);
|
|
43
|
-
const stylesConfig = (0, vue.computed)(() => baseProps.value?.styles);
|
|
44
|
-
const selectionItemPrefixCls = (0, vue.computed)(() => `${prefixCls.value}-selection-item`);
|
|
45
|
-
const computedSearchValue = (0, vue.computed)(() => {
|
|
46
|
-
if (!triggerOpen.value && mode.value === "multiple" && autoClearSearchValue.value !== false) return "";
|
|
47
|
-
return searchValue.value;
|
|
48
|
-
});
|
|
49
|
-
const inputValue = (0, vue.computed)(() => showSearch.value ? computedSearchValue.value || "" : "");
|
|
50
|
-
const inputEditable = (0, vue.computed)(() => showSearch.value && !disabled.value);
|
|
51
|
-
const removeIcon = (0, vue.computed)(() => removeIconFromContext.value ?? "×");
|
|
52
|
-
const maxTagPlaceholder = (0, vue.computed)(() => maxTagPlaceholderFromContext.value ?? ((omittedValues) => `+ ${omittedValues.length} ...`));
|
|
53
|
-
const tagRender = (0, vue.computed)(() => tagRenderFromContext.value);
|
|
54
|
-
const onToggleOpen = (newOpen) => {
|
|
55
|
-
toggleOpen.value?.(newOpen);
|
|
56
|
-
};
|
|
57
|
-
const onRemove = (value) => {
|
|
58
|
-
onSelectorRemove.value?.(value);
|
|
59
|
-
};
|
|
60
|
-
expose({ input: (0, vue.computed)(() => inputRef.value?.input) });
|
|
61
|
-
const defaultRenderSelector = (item, content, itemDisabled, closable, onClose) => (0, vue.createVNode)("span", {
|
|
62
|
-
"title": require_commonUtil.getTitle(item),
|
|
63
|
-
"class": (0, _v_c_util.clsx)(selectionItemPrefixCls.value, { [`${selectionItemPrefixCls.value}-disabled`]: itemDisabled }, classNamesConfig.value?.item),
|
|
64
|
-
"style": stylesConfig.value?.item
|
|
65
|
-
}, [(0, vue.createVNode)("span", {
|
|
66
|
-
"class": (0, _v_c_util.clsx)(`${selectionItemPrefixCls.value}-content`, classNamesConfig.value?.itemContent),
|
|
67
|
-
"style": stylesConfig.value?.itemContent
|
|
68
|
-
}, [content]), closable && (0, vue.createVNode)(require_TransBtn.default, {
|
|
69
|
-
"className": (0, _v_c_util.clsx)(`${selectionItemPrefixCls.value}-remove`, classNamesConfig.value?.itemRemove),
|
|
70
|
-
"style": stylesConfig.value?.itemRemove,
|
|
71
|
-
"onMouseDown": onPreventMouseDown,
|
|
72
|
-
"onClick": onClose,
|
|
73
|
-
"customizeIcon": removeIcon.value
|
|
74
|
-
}, { default: () => [(0, vue.createTextVNode)("×")] })]);
|
|
75
|
-
const customizeRenderSelector = (value, content, itemDisabled, closable, onClose, isMaxTag, info) => {
|
|
76
|
-
const onMouseDown = (e) => {
|
|
77
|
-
onPreventMouseDown(e);
|
|
78
|
-
onToggleOpen(!triggerOpen.value);
|
|
79
|
-
};
|
|
80
|
-
return (0, vue.createVNode)("span", { "onMousedown": onMouseDown }, [tagRender.value?.({
|
|
81
|
-
label: content,
|
|
82
|
-
value,
|
|
83
|
-
index: info?.index ?? 0,
|
|
84
|
-
disabled: itemDisabled,
|
|
85
|
-
closable: !!closable,
|
|
86
|
-
onClose,
|
|
87
|
-
isMaxTag: !!isMaxTag
|
|
88
|
-
})]);
|
|
89
|
-
};
|
|
90
|
-
const renderItem = (valueItem, info) => {
|
|
91
|
-
const { disabled: itemDisabled, label, value } = valueItem;
|
|
92
|
-
const closable = !disabled.value && !itemDisabled;
|
|
93
|
-
let displayLabel = label;
|
|
94
|
-
if (typeof maxTagTextLength.value === "number") {
|
|
95
|
-
if (typeof label === "string" || typeof label === "number") {
|
|
96
|
-
const strLabel = String(displayLabel);
|
|
97
|
-
if (strLabel.length > maxTagTextLength.value) displayLabel = `${strLabel.slice(0, maxTagTextLength.value)}...`;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const onClose = (event) => {
|
|
101
|
-
if (event) event.stopPropagation();
|
|
102
|
-
onRemove(valueItem);
|
|
103
|
-
};
|
|
104
|
-
return typeof tagRender.value === "function" ? customizeRenderSelector(value, displayLabel, !!itemDisabled, closable, onClose, void 0, info) : defaultRenderSelector(valueItem, displayLabel, !!itemDisabled, closable, onClose);
|
|
105
|
-
};
|
|
106
|
-
const renderRest = (omittedValues) => {
|
|
107
|
-
if (!displayValues.value.length) return null;
|
|
108
|
-
const content = typeof maxTagPlaceholder.value === "function" ? maxTagPlaceholder.value(omittedValues) : maxTagPlaceholder.value;
|
|
109
|
-
return typeof tagRender.value === "function" ? customizeRenderSelector(void 0, content, false, false, void 0, true) : defaultRenderSelector({ title: content }, content, false);
|
|
110
|
-
};
|
|
111
|
-
return () => {
|
|
112
|
-
const { inputProps } = props;
|
|
113
|
-
const prefixNode = !displayValues.value.length && !inputValue.value ? () => (0, vue.createVNode)(require_Placeholder.default, null, null) : null;
|
|
114
|
-
const suffixNode = () => (0, vue.createVNode)(require_Input.default, (0, vue.mergeProps)({
|
|
115
|
-
"ref": inputRef,
|
|
116
|
-
"disabled": disabled.value,
|
|
117
|
-
"readOnly": !inputEditable.value
|
|
118
|
-
}, inputProps, {
|
|
119
|
-
"value": inputValue.value || "",
|
|
120
|
-
"syncWidth": true
|
|
121
|
-
}), null);
|
|
122
|
-
return (0, vue.createVNode)(_v_c_overflow.default, {
|
|
123
|
-
"prefixCls": `${prefixCls.value}-content`,
|
|
124
|
-
"class": classNamesConfig.value?.content,
|
|
125
|
-
"style": stylesConfig.value?.content,
|
|
126
|
-
"prefix": prefixNode,
|
|
127
|
-
"data": displayValues.value,
|
|
128
|
-
"renderItem": renderItem,
|
|
129
|
-
"renderRest": renderRest,
|
|
130
|
-
"suffix": suffixNode,
|
|
131
|
-
"itemKey": itemKey,
|
|
132
|
-
"maxCount": maxTagCount.value
|
|
133
|
-
}, null);
|
|
134
|
-
};
|
|
135
|
-
}, {
|
|
136
|
-
props: { inputProps: {
|
|
137
|
-
type: Object,
|
|
138
|
-
required: true,
|
|
139
|
-
default: void 0
|
|
140
|
-
} },
|
|
141
|
-
name: "MultipleContent",
|
|
142
|
-
inheritAttrs: false
|
|
143
|
-
});
|
|
144
|
-
var MultipleContent_default = MultipleContent;
|
|
145
|
-
exports.default = MultipleContent_default;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_useBaseProps = require("../../hooks/useBaseProps.cjs");
|
|
7
|
-
const require_context = require("../context.cjs");
|
|
8
|
-
let vue = require("vue");
|
|
9
|
-
let _v_c_util = require("@v-c/util");
|
|
10
|
-
var Placeholder = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
11
|
-
const selectInputContext = require_context.useSelectInputContext();
|
|
12
|
-
const baseProps = require_useBaseProps.default();
|
|
13
|
-
return () => {
|
|
14
|
-
const { prefixCls, placeholder, displayValues } = selectInputContext.value ?? {};
|
|
15
|
-
const { classNames, styles } = baseProps.value ?? {};
|
|
16
|
-
const { show = true } = props;
|
|
17
|
-
if (displayValues?.length) return null;
|
|
18
|
-
return (0, vue.createVNode)("div", {
|
|
19
|
-
"class": (0, _v_c_util.clsx)(`${prefixCls}-placeholder`, classNames?.placeholder),
|
|
20
|
-
"style": {
|
|
21
|
-
visibility: show ? "visible" : "hidden",
|
|
22
|
-
...styles?.placeholder
|
|
23
|
-
}
|
|
24
|
-
}, [placeholder]);
|
|
25
|
-
};
|
|
26
|
-
}, {
|
|
27
|
-
props: { show: {
|
|
28
|
-
type: Boolean,
|
|
29
|
-
required: false,
|
|
30
|
-
default: void 0
|
|
31
|
-
} },
|
|
32
|
-
name: "Placeholder",
|
|
33
|
-
inheritAttrs: false
|
|
34
|
-
});
|
|
35
|
-
var Placeholder_default = Placeholder;
|
|
36
|
-
exports.default = Placeholder_default;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_useBaseProps = require("../../hooks/useBaseProps.cjs");
|
|
7
|
-
const require_SelectContext = require("../../SelectContext.cjs");
|
|
8
|
-
const require_commonUtil = require("../../utils/commonUtil.cjs");
|
|
9
|
-
const require_context = require("../context.cjs");
|
|
10
|
-
const require_Input = require("../Input.cjs");
|
|
11
|
-
const require_Placeholder = require("./Placeholder.cjs");
|
|
12
|
-
let vue = require("vue");
|
|
13
|
-
let _v_c_util = require("@v-c/util");
|
|
14
|
-
var SingleContent = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose }) => {
|
|
15
|
-
const selectInputContext = require_context.useSelectInputContext();
|
|
16
|
-
const baseProps = require_useBaseProps.default();
|
|
17
|
-
const selectContext = require_SelectContext.useSelectContext();
|
|
18
|
-
const inputChanged = (0, vue.shallowRef)(false);
|
|
19
|
-
const combobox = (0, vue.computed)(() => selectInputContext.value?.mode === "combobox");
|
|
20
|
-
const displayValue = (0, vue.computed)(() => selectInputContext.value?.displayValues[0]);
|
|
21
|
-
const mergedSearchValue = (0, vue.computed)(() => {
|
|
22
|
-
if (combobox.value && selectInputContext.value?.activeValue && !inputChanged.value && baseProps.value?.triggerOpen) return selectInputContext.value.activeValue;
|
|
23
|
-
return baseProps.value?.showSearch ? selectInputContext.value?.searchValue : "";
|
|
24
|
-
});
|
|
25
|
-
const optionProps = (0, vue.computed)(() => {
|
|
26
|
-
let restProps = {
|
|
27
|
-
class: `${selectInputContext.value?.prefixCls}-content-value`,
|
|
28
|
-
style: mergedSearchValue.value ? { visibility: "hidden" } : {}
|
|
29
|
-
};
|
|
30
|
-
if (displayValue.value && selectContext.value?.flattenOptions) {
|
|
31
|
-
const option = selectContext.value.flattenOptions.find((opt) => opt.value === displayValue.value?.value);
|
|
32
|
-
if (option?.data) {
|
|
33
|
-
const { label, value, className, style, key, children, ...rest } = option.data;
|
|
34
|
-
restProps = {
|
|
35
|
-
...restProps,
|
|
36
|
-
...rest,
|
|
37
|
-
title: require_commonUtil.getTitle(option.data),
|
|
38
|
-
class: (0, _v_c_util.clsx)(restProps.class, className),
|
|
39
|
-
style: {
|
|
40
|
-
...restProps.style,
|
|
41
|
-
...style
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (displayValue.value && !restProps.title) restProps.title = require_commonUtil.getTitle(displayValue.value);
|
|
47
|
-
if (baseProps.value?.title !== void 0) restProps.title = baseProps.value.title;
|
|
48
|
-
return restProps;
|
|
49
|
-
});
|
|
50
|
-
(0, vue.watch)([combobox, () => selectInputContext.value?.displayValues], () => {
|
|
51
|
-
if (combobox.value) inputChanged.value = false;
|
|
52
|
-
}, { immediate: true });
|
|
53
|
-
const inputRef = (0, vue.shallowRef)();
|
|
54
|
-
expose({ input: (0, vue.computed)(() => inputRef.value?.input) });
|
|
55
|
-
return () => {
|
|
56
|
-
const { prefixCls, mode, maxLength } = selectInputContext.value ?? {};
|
|
57
|
-
const { classNames, styles } = baseProps.value ?? {};
|
|
58
|
-
const { inputProps } = props;
|
|
59
|
-
return (0, vue.createVNode)("div", {
|
|
60
|
-
"class": (0, _v_c_util.clsx)(`${prefixCls}-content`, classNames?.content),
|
|
61
|
-
"style": styles?.content
|
|
62
|
-
}, [displayValue.value ? (0, vue.createVNode)("div", optionProps.value, [displayValue.value.label]) : (0, vue.createVNode)(require_Placeholder.default, { "show": !mergedSearchValue.value }, null), (0, vue.createVNode)(require_Input.default, (0, vue.mergeProps)(inputProps, {
|
|
63
|
-
"value": mergedSearchValue.value,
|
|
64
|
-
"maxLength": mode === "combobox" ? maxLength : void 0,
|
|
65
|
-
"onChange": (e) => {
|
|
66
|
-
inputChanged.value = true;
|
|
67
|
-
inputProps.onChange?.(e);
|
|
68
|
-
inputProps.onInput?.(e);
|
|
69
|
-
},
|
|
70
|
-
"ref": inputRef
|
|
71
|
-
}), null)]);
|
|
72
|
-
};
|
|
73
|
-
}, {
|
|
74
|
-
props: { inputProps: {
|
|
75
|
-
type: Object,
|
|
76
|
-
required: true,
|
|
77
|
-
default: void 0
|
|
78
|
-
} },
|
|
79
|
-
name: "SingleContent",
|
|
80
|
-
inheritAttrs: false
|
|
81
|
-
});
|
|
82
|
-
var SingleContent_default = SingleContent;
|
|
83
|
-
exports.default = SingleContent_default;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_useBaseProps = require("../../hooks/useBaseProps.cjs");
|
|
7
|
-
const require_context = require("../context.cjs");
|
|
8
|
-
const require_MultipleContent = require("./MultipleContent.cjs");
|
|
9
|
-
const require_SingleContent = require("./SingleContent.cjs");
|
|
10
|
-
let vue = require("vue");
|
|
11
|
-
let _v_c_util_dist_pickAttrs = require("@v-c/util/dist/pickAttrs");
|
|
12
|
-
_v_c_util_dist_pickAttrs = require_rolldown_runtime.__toESM(_v_c_util_dist_pickAttrs);
|
|
13
|
-
var SelectContent = /* @__PURE__ */ (0, vue.defineComponent)((_, { expose }) => {
|
|
14
|
-
const selectInputContext = require_context.useSelectInputContext();
|
|
15
|
-
const baseProps = require_useBaseProps.default();
|
|
16
|
-
const inputRef = (0, vue.shallowRef)();
|
|
17
|
-
expose({ input: (0, vue.computed)(() => inputRef.value?.input) });
|
|
18
|
-
const multiple = (0, vue.computed)(() => selectInputContext.value?.multiple);
|
|
19
|
-
const onInputKeyDown = (0, vue.computed)(() => selectInputContext.value?.onInputKeyDown);
|
|
20
|
-
const showSearch = (0, vue.computed)(() => baseProps.value?.showSearch);
|
|
21
|
-
const ariaProps = (0, vue.computed)(() => (0, _v_c_util_dist_pickAttrs.default)(baseProps.value ?? {}, { aria: true }));
|
|
22
|
-
const sharedInputProps = (0, vue.computed)(() => ({
|
|
23
|
-
...ariaProps.value,
|
|
24
|
-
onKeyDown: onInputKeyDown.value,
|
|
25
|
-
readonly: !showSearch.value,
|
|
26
|
-
tabindex: baseProps.value?.tabIndex
|
|
27
|
-
}));
|
|
28
|
-
return () => {
|
|
29
|
-
if (multiple.value) return (0, vue.createVNode)(require_MultipleContent.default, {
|
|
30
|
-
"ref": inputRef,
|
|
31
|
-
"inputProps": sharedInputProps.value
|
|
32
|
-
}, null);
|
|
33
|
-
return (0, vue.createVNode)(require_SingleContent.default, {
|
|
34
|
-
"ref": inputRef,
|
|
35
|
-
"inputProps": sharedInputProps.value
|
|
36
|
-
}, null);
|
|
37
|
-
};
|
|
38
|
-
}, {
|
|
39
|
-
name: "SelectContent",
|
|
40
|
-
inheritAttrs: false
|
|
41
|
-
});
|
|
42
|
-
var Content_default = SelectContent;
|
|
43
|
-
exports.default = Content_default;
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_useBaseProps = require("../hooks/useBaseProps.cjs");
|
|
7
|
-
const require_context = require("./context.cjs");
|
|
8
|
-
let vue = require("vue");
|
|
9
|
-
let _v_c_util = require("@v-c/util");
|
|
10
|
-
let _v_c_util_dist_KeyCode = require("@v-c/util/dist/KeyCode");
|
|
11
|
-
var Input = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, attrs }) => {
|
|
12
|
-
const selectInputContext = require_context.useSelectInputContext();
|
|
13
|
-
const baseProps = require_useBaseProps.default();
|
|
14
|
-
const compositionStatusRef = (0, vue.shallowRef)(false);
|
|
15
|
-
const pastedTextRef = (0, vue.shallowRef)(null);
|
|
16
|
-
const inputRef = (0, vue.shallowRef)();
|
|
17
|
-
expose({ input: inputRef });
|
|
18
|
-
const handleChange = (event) => {
|
|
19
|
-
const { tokenWithEnter, onSearch } = selectInputContext.value ?? {};
|
|
20
|
-
let { value: nextVal } = event.target;
|
|
21
|
-
if (tokenWithEnter && pastedTextRef.value && /[\r\n]/.test(pastedTextRef.value)) {
|
|
22
|
-
const replacedText = pastedTextRef.value.replace(/[\r\n]+$/, "").replace(/\r\n/g, " ").replace(/[\r\n]/g, " ");
|
|
23
|
-
nextVal = nextVal.replace(replacedText, pastedTextRef.value);
|
|
24
|
-
}
|
|
25
|
-
pastedTextRef.value = null;
|
|
26
|
-
if (onSearch) onSearch(nextVal, true, compositionStatusRef.value);
|
|
27
|
-
props?.onChange?.(event);
|
|
28
|
-
};
|
|
29
|
-
const handleKeyDown = (event) => {
|
|
30
|
-
const { mode, onSearchSubmit } = selectInputContext.value ?? {};
|
|
31
|
-
const { key } = event;
|
|
32
|
-
const { value: nextVal } = event.currentTarget;
|
|
33
|
-
if (key === _v_c_util_dist_KeyCode.KeyCodeStr.Enter && mode === "tags" && !compositionStatusRef.value && onSearchSubmit) onSearchSubmit(nextVal);
|
|
34
|
-
props?.onKeyDown?.(event);
|
|
35
|
-
};
|
|
36
|
-
const handleBlur = (event) => {
|
|
37
|
-
const { onInputBlur } = selectInputContext.value ?? {};
|
|
38
|
-
onInputBlur?.();
|
|
39
|
-
props?.onBlur?.(event);
|
|
40
|
-
};
|
|
41
|
-
const handleCompositionStart = () => {
|
|
42
|
-
compositionStatusRef.value = true;
|
|
43
|
-
};
|
|
44
|
-
const handleCompositionEnd = (event) => {
|
|
45
|
-
const { mode, onSearch } = selectInputContext.value ?? {};
|
|
46
|
-
compositionStatusRef.value = false;
|
|
47
|
-
if (mode !== "combobox") {
|
|
48
|
-
const { value: nextVal } = event.currentTarget;
|
|
49
|
-
onSearch?.(nextVal, true, false);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const handlePaste = (event) => {
|
|
53
|
-
const { clipboardData } = event;
|
|
54
|
-
pastedTextRef.value = clipboardData?.getData?.("text") || "";
|
|
55
|
-
};
|
|
56
|
-
const widthCssVar = (0, vue.shallowRef)();
|
|
57
|
-
(0, vue.watch)([() => props.syncWidth, () => props.value], async () => {
|
|
58
|
-
await (0, vue.nextTick)();
|
|
59
|
-
const input = inputRef.value;
|
|
60
|
-
if (props.syncWidth && input) {
|
|
61
|
-
input.style.width = "0px";
|
|
62
|
-
widthCssVar.value = input.scrollWidth;
|
|
63
|
-
input.style.width = "";
|
|
64
|
-
}
|
|
65
|
-
}, { immediate: true });
|
|
66
|
-
return () => {
|
|
67
|
-
const { style, autoComplete, className, value } = props;
|
|
68
|
-
const { prefixCls, mode, autoFocus, placeholder } = selectInputContext.value ?? {};
|
|
69
|
-
const { input: InputComponent = "input" } = selectInputContext.value?.components ?? {};
|
|
70
|
-
const { styles, id, classNames, open, activeDescendantId, role, disabled } = baseProps.value ?? {};
|
|
71
|
-
const inputCls = (0, _v_c_util.clsx)(`${prefixCls}-input`, classNames?.input, className);
|
|
72
|
-
const sharedInputProps = {
|
|
73
|
-
id,
|
|
74
|
-
"type": mode === "combobox" ? "text" : "search",
|
|
75
|
-
...attrs,
|
|
76
|
-
"ref": inputRef,
|
|
77
|
-
"style": {
|
|
78
|
-
...styles?.input,
|
|
79
|
-
...style,
|
|
80
|
-
"--select-input-width": widthCssVar.value
|
|
81
|
-
},
|
|
82
|
-
autoFocus,
|
|
83
|
-
"autocomplete": autoComplete || "off",
|
|
84
|
-
"class": inputCls,
|
|
85
|
-
disabled,
|
|
86
|
-
"value": value || "",
|
|
87
|
-
"onInput": handleChange,
|
|
88
|
-
"onKeydown": handleKeyDown,
|
|
89
|
-
"onBlur": handleBlur,
|
|
90
|
-
"onPaste": handlePaste,
|
|
91
|
-
"onCompositionstart": handleCompositionStart,
|
|
92
|
-
"onCompositionend": handleCompositionEnd,
|
|
93
|
-
"role": role || "combobox",
|
|
94
|
-
"aria-expanded": open || false,
|
|
95
|
-
"aria-haspopup": "listbox",
|
|
96
|
-
"aria-owns": `${id}_list`,
|
|
97
|
-
"aria-autocomplete": "list",
|
|
98
|
-
"aria-controls": `${id}_list`,
|
|
99
|
-
"aria-activedescendant": open ? activeDescendantId : void 0
|
|
100
|
-
};
|
|
101
|
-
if ((0, vue.isVNode)(InputComponent)) return (0, vue.createVNode)(InputComponent, {
|
|
102
|
-
placeholder: props.placeholder || placeholder,
|
|
103
|
-
...sharedInputProps
|
|
104
|
-
});
|
|
105
|
-
return (0, vue.createVNode)(InputComponent, sharedInputProps, null);
|
|
106
|
-
};
|
|
107
|
-
}, {
|
|
108
|
-
props: {
|
|
109
|
-
id: {
|
|
110
|
-
type: String,
|
|
111
|
-
required: false,
|
|
112
|
-
default: void 0
|
|
113
|
-
},
|
|
114
|
-
readOnly: {
|
|
115
|
-
type: Boolean,
|
|
116
|
-
required: false,
|
|
117
|
-
default: void 0
|
|
118
|
-
},
|
|
119
|
-
value: {
|
|
120
|
-
type: String,
|
|
121
|
-
required: false,
|
|
122
|
-
default: void 0
|
|
123
|
-
},
|
|
124
|
-
onChange: {
|
|
125
|
-
type: Function,
|
|
126
|
-
required: false,
|
|
127
|
-
default: void 0
|
|
128
|
-
},
|
|
129
|
-
onKeyDown: {
|
|
130
|
-
type: Function,
|
|
131
|
-
required: false,
|
|
132
|
-
default: void 0
|
|
133
|
-
},
|
|
134
|
-
onFocus: {
|
|
135
|
-
type: Function,
|
|
136
|
-
required: false,
|
|
137
|
-
default: void 0
|
|
138
|
-
},
|
|
139
|
-
onBlur: {
|
|
140
|
-
type: Function,
|
|
141
|
-
required: false,
|
|
142
|
-
default: void 0
|
|
143
|
-
},
|
|
144
|
-
placeholder: {
|
|
145
|
-
type: String,
|
|
146
|
-
required: false,
|
|
147
|
-
default: void 0
|
|
148
|
-
},
|
|
149
|
-
className: {
|
|
150
|
-
type: String,
|
|
151
|
-
required: false,
|
|
152
|
-
default: void 0
|
|
153
|
-
},
|
|
154
|
-
style: {
|
|
155
|
-
type: Object,
|
|
156
|
-
required: false,
|
|
157
|
-
default: void 0
|
|
158
|
-
},
|
|
159
|
-
maxLength: {
|
|
160
|
-
type: Number,
|
|
161
|
-
required: false,
|
|
162
|
-
default: void 0
|
|
163
|
-
},
|
|
164
|
-
syncWidth: {
|
|
165
|
-
type: Boolean,
|
|
166
|
-
required: false,
|
|
167
|
-
default: void 0
|
|
168
|
-
},
|
|
169
|
-
autoComplete: {
|
|
170
|
-
type: String,
|
|
171
|
-
required: false,
|
|
172
|
-
default: void 0
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
name: "Input",
|
|
176
|
-
inheritAttrs: false
|
|
177
|
-
});
|
|
178
|
-
var Input_default = Input;
|
|
179
|
-
exports.default = Input_default;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
|
-
let vue = require("vue");
|
|
4
|
-
var SelectInputKey = Symbol("SelectInputContext");
|
|
5
|
-
function useSelectInputContext() {
|
|
6
|
-
return (0, vue.inject)(SelectInputKey, (0, vue.ref)(null));
|
|
7
|
-
}
|
|
8
|
-
function useSelectInputProvider(context) {
|
|
9
|
-
(0, vue.provide)(SelectInputKey, context);
|
|
10
|
-
}
|
|
11
|
-
exports.useSelectInputContext = useSelectInputContext;
|
|
12
|
-
exports.useSelectInputProvider = useSelectInputProvider;
|