@sdata/web-vue 1.7.1 → 1.9.0
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/sd.css +182 -1
- package/dist/sd.min.css +1 -1
- package/es/_components/input-label/input-label.js +30 -24
- package/es/_components/select-view/interface.d.ts +1 -0
- package/es/_components/select-view/select-view.d.ts +12 -3
- package/es/_components/select-view/select-view.js +38 -28
- package/es/_components/select-view/style/index.css +45 -0
- package/es/_hooks/use-allow-clear.d.ts +4 -0
- package/es/_hooks/use-allow-clear.js +20 -0
- package/es/_hooks/use-trigger.d.ts +4 -6
- package/es/_hooks/use-trigger.js +7 -5
- package/es/_utils/color.js +1 -18
- package/es/auto-complete/auto-complete.d.ts +1 -1
- package/es/auto-complete/auto-complete.js +4 -2
- package/es/auto-complete/index.d.ts +3 -3
- package/es/badge/badge.d.ts +1 -1
- package/es/badge/index.d.ts +3 -3
- package/es/carousel/carousel-arrow.vue.d.ts +1 -1
- package/es/carousel/carousel.d.ts +2 -2
- package/es/carousel/index.d.ts +6 -6
- package/es/cascader/cascader-panel.vue.d.ts +2 -2
- package/es/cascader/cascader.js +1 -1
- package/es/cascader/cascader.vue.d.ts +21 -11
- package/es/cascader/cascader.vue_vue_type_script_lang.js +4 -1
- package/es/cascader/index.d.ts +47 -26
- package/es/color-picker/color-picker.d.ts +115 -40
- package/es/color-picker/color-picker.js +146 -102
- package/es/color-picker/index.d.ts +217 -69
- package/es/color-picker/interface.d.ts +41 -0
- package/es/color-picker/palette.js +1 -1
- package/es/color-picker/panel.d.ts +73 -34
- package/es/color-picker/panel.js +423 -89
- package/es/color-picker/style/index.css +92 -1
- package/es/color-picker/style/index.scss +107 -1
- package/es/color-picker/utils.d.ts +89 -0
- package/es/color-picker/utils.js +456 -0
- package/es/config-provider/config-provider.vue.d.ts +10 -1
- package/es/config-provider/config-provider.vue_vue_type_script_lang.js +6 -1
- package/es/config-provider/context.d.ts +1 -0
- package/es/config-provider/index.d.ts +18 -3
- package/es/date-picker/index.d.ts +7 -6
- package/es/date-picker/picker.js +1 -1
- package/es/date-picker/picker.vue.d.ts +7 -6
- package/es/date-picker/picker.vue_vue_type_script_lang.js +4 -1
- package/es/date-picker/range-picker.js +1 -1
- package/es/date-picker/range-picker.vue.d.ts +7 -6
- package/es/date-picker/range-picker.vue_vue_type_script_lang.js +4 -1
- package/es/descriptions/descriptions.d.ts +2 -2
- package/es/descriptions/index.d.ts +6 -6
- package/es/drawer/drawer.vue_vue_type_script_lang.js +1 -1
- package/es/dropdown/dropdown-button.vue.d.ts +8 -8
- package/es/dropdown/dropdown-panel.vue.d.ts +2 -2
- package/es/dropdown/dropdown-submenu.vue.d.ts +8 -8
- package/es/dropdown/dropdown.vue.d.ts +8 -8
- package/es/dropdown/index.d.ts +32 -32
- package/es/ellipsis/ellipsis.vue.d.ts +13 -13
- package/es/ellipsis/ellipsis.vue_vue_type_script_lang.js +1 -1
- package/es/ellipsis/index.d.ts +56 -56
- package/es/ellipsis/performant-ellipsis.vue.d.ts +14 -14
- package/es/form/form-item-label.vue.d.ts +12 -12
- package/es/form/form-item.vue.d.ts +12 -12
- package/es/form/index.d.ts +12 -12
- package/es/grid/grid.vue.d.ts +1 -1
- package/es/grid/index.d.ts +3 -3
- package/es/image/image.vue.d.ts +12 -12
- package/es/image/preview-action.d.ts +12 -12
- package/es/image/preview-group.vue.d.ts +12 -12
- package/es/image/preview-toolbar.vue.d.ts +12 -12
- package/es/image/preview.vue.d.ts +12 -12
- package/es/index.css +182 -1
- package/es/index.js +2 -2
- package/es/input/input.js +4 -2
- package/es/input-number/input-number.js +4 -2
- package/es/input-tag/index.d.ts +6 -6
- package/es/input-tag/input-tag.d.ts +3 -3
- package/es/input-tag/input-tag.js +183 -32
- package/es/input-tag/style/index.css +45 -0
- package/es/input-tag/style/input-tag.scss +53 -0
- package/es/list/index.d.ts +3 -3
- package/es/list/list.d.ts +1 -1
- package/es/mention/mention.js +4 -2
- package/es/menu/sub-menu-pop.vue.d.ts +6 -6
- package/es/modal/modal.vue_vue_type_script_lang.js +1 -1
- package/es/overflow-list/index.d.ts +3 -3
- package/es/overflow-list/overflow-list.d.ts +1 -1
- package/es/pagination/page-options.vue.d.ts +188 -98
- package/es/popconfirm/index.d.ts +12 -12
- package/es/popconfirm/popconfirm.vue.d.ts +6 -6
- package/es/popover/index.d.ts +12 -12
- package/es/popover/popover.vue.d.ts +6 -6
- package/es/progress/index.d.ts +5 -5
- package/es/progress/line.vue.d.ts +1 -1
- package/es/progress/progress.vue.d.ts +2 -2
- package/es/rate/rate.js +4 -2
- package/es/scrollbar/index.d.ts +2 -2
- package/es/scrollbar/scrollbar.vue.d.ts +1 -1
- package/es/scrollbar/thumb.vue.d.ts +1 -1
- package/es/sd-vue.js +2 -2
- package/es/select/hooks/use-options.d.ts +9 -4
- package/es/select/hooks/use-options.js +2 -2
- package/es/select/hooks/use-select.d.ts +9 -4
- package/es/select/index.d.ts +188 -98
- package/es/select/interface.d.ts +57 -46
- package/es/select/select-dropdown.vue.d.ts +2 -2
- package/es/select/select.d.ts +107 -59
- package/es/select/select.js +182 -126
- package/es/select/utils.d.ts +1 -1
- package/es/select/utils.js +28 -10
- package/es/skeleton/index.d.ts +1 -1
- package/es/skeleton/line.vue.d.ts +1 -1
- package/es/slider/index.d.ts +27 -27
- package/es/slider/slider-button.vue.d.ts +12 -12
- package/es/slider/slider.vue.d.ts +13 -13
- package/es/space/index.d.ts +3 -3
- package/es/space/space.d.ts +1 -1
- package/es/statistic/index.d.ts +6 -6
- package/es/statistic/statistic.vue.d.ts +2 -2
- package/es/table/index.d.ts +6 -6
- package/es/table/table.d.ts +2 -2
- package/es/tabs/index.d.ts +9 -9
- package/es/tabs/tabs.d.ts +3 -3
- package/es/tag/index.d.ts +3 -3
- package/es/tag/tag.vue.d.ts +1 -1
- package/es/textarea/index.d.ts +3 -3
- package/es/textarea/textarea.vue.d.ts +1 -1
- package/es/textarea/textarea.vue_vue_type_script_lang.js +6 -2
- package/es/time-picker/index.d.ts +15 -12
- package/es/time-picker/time-picker.js +1 -1
- package/es/time-picker/time-picker.vue.d.ts +7 -6
- package/es/time-picker/time-picker.vue_vue_type_script_lang.js +4 -1
- package/es/tooltip/index.d.ts +12 -12
- package/es/tooltip/tooltip.vue.d.ts +6 -6
- package/es/transfer/index.d.ts +10 -10
- package/es/transfer/transfer-view.vue.d.ts +5 -5
- package/es/transfer/transfer.vue.d.ts +5 -5
- package/es/tree/index.d.ts +6 -6
- package/es/tree/tree.vue.d.ts +2 -2
- package/es/tree-select/hooks/use-selected-state.d.ts +2 -0
- package/es/tree-select/hooks/use-selected-state.js +26 -8
- package/es/tree-select/index.d.ts +268 -61
- package/es/tree-select/interface.d.ts +16 -3
- package/es/tree-select/panel.d.ts +6 -6
- package/es/tree-select/tree-select.js +29 -16
- package/es/tree-select/tree-select.vue.d.ts +144 -30
- package/es/tree-select/tree-select.vue_vue_type_script_lang.js +102 -22
- package/es/trigger/index.d.ts +6 -6
- package/es/trigger/trigger.d.ts +2 -2
- package/es/typography/operations.vue.d.ts +12 -12
- package/json/vetur-attributes.json +82 -178
- package/json/vetur-tags.json +24 -52
- package/json/web-types.json +164 -387
- package/package.json +9 -7
- package/es/color-picker/input-alpha.js +0 -32
- package/es/color-picker/input-hex.js +0 -73
- package/es/color-picker/input-rgb.js +0 -55
package/es/select/select.js
CHANGED
|
@@ -3,6 +3,7 @@ import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.124.0/helper
|
|
|
3
3
|
import { getPrefixCls } from "../_utils/global-config.js";
|
|
4
4
|
import { isArray, isBoolean, isEmptyObject, isFunction, isNull, isNumber, isObject, isString, isUndefined } from "../_utils/is.js";
|
|
5
5
|
import virtual_list_v2_default from "../_components/virtual-list-v2/index.js";
|
|
6
|
+
import { useAllowClear } from "../_hooks/use-allow-clear.js";
|
|
6
7
|
import { getKeyFromValue, hasEmptyStringKey, isGroupOptionInfo, isValidOption } from "./utils.js";
|
|
7
8
|
import { useSelect } from "./hooks/use-select.js";
|
|
8
9
|
import option_default from "./option.js";
|
|
@@ -20,9 +21,9 @@ function _isSlot(s) {
|
|
|
20
21
|
var DEFAULT_FIELD_NAMES = {
|
|
21
22
|
value: "value",
|
|
22
23
|
label: "label",
|
|
24
|
+
children: "children",
|
|
23
25
|
disabled: "disabled",
|
|
24
|
-
tagProps: "tagProps"
|
|
25
|
-
render: "render"
|
|
26
|
+
tagProps: "tagProps"
|
|
26
27
|
};
|
|
27
28
|
var select_default = /* @__PURE__ */ defineComponent({
|
|
28
29
|
name: "Select",
|
|
@@ -36,6 +37,16 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
36
37
|
type: Boolean,
|
|
37
38
|
default: false
|
|
38
39
|
},
|
|
40
|
+
value: {
|
|
41
|
+
type: [
|
|
42
|
+
String,
|
|
43
|
+
Number,
|
|
44
|
+
Boolean,
|
|
45
|
+
Object,
|
|
46
|
+
Array
|
|
47
|
+
],
|
|
48
|
+
default: void 0
|
|
49
|
+
},
|
|
39
50
|
modelValue: {
|
|
40
51
|
type: [
|
|
41
52
|
String,
|
|
@@ -54,7 +65,7 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
54
65
|
Object,
|
|
55
66
|
Array
|
|
56
67
|
],
|
|
57
|
-
default: (props) =>
|
|
68
|
+
default: (props) => props.multiple ? [] : ""
|
|
58
69
|
},
|
|
59
70
|
inputValue: { type: String },
|
|
60
71
|
defaultInputValue: {
|
|
@@ -77,19 +88,23 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
77
88
|
},
|
|
78
89
|
allowClear: {
|
|
79
90
|
type: Boolean,
|
|
80
|
-
default:
|
|
91
|
+
default: true
|
|
81
92
|
},
|
|
82
93
|
allowSearch: {
|
|
83
94
|
type: [Boolean, Object],
|
|
84
|
-
default:
|
|
95
|
+
default: true
|
|
85
96
|
},
|
|
86
97
|
allowCreate: {
|
|
87
98
|
type: Boolean,
|
|
88
99
|
default: false
|
|
89
100
|
},
|
|
101
|
+
showArrow: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
default: true
|
|
104
|
+
},
|
|
90
105
|
maxTagCount: {
|
|
91
|
-
type: Number,
|
|
92
|
-
default:
|
|
106
|
+
type: [Number, String],
|
|
107
|
+
default: "responsive"
|
|
93
108
|
},
|
|
94
109
|
popupContainer: { type: [String, Object] },
|
|
95
110
|
bordered: {
|
|
@@ -104,10 +119,18 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
104
119
|
type: Boolean,
|
|
105
120
|
default: void 0
|
|
106
121
|
},
|
|
122
|
+
show: {
|
|
123
|
+
type: Boolean,
|
|
124
|
+
default: void 0
|
|
125
|
+
},
|
|
107
126
|
defaultPopupVisible: {
|
|
108
127
|
type: Boolean,
|
|
109
128
|
default: false
|
|
110
129
|
},
|
|
130
|
+
defaultShow: {
|
|
131
|
+
type: Boolean,
|
|
132
|
+
default: void 0
|
|
133
|
+
},
|
|
111
134
|
unmountOnClose: {
|
|
112
135
|
type: Boolean,
|
|
113
136
|
default: false
|
|
@@ -122,7 +145,6 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
122
145
|
},
|
|
123
146
|
virtualListProps: { type: Object },
|
|
124
147
|
triggerProps: { type: Object },
|
|
125
|
-
formatLabel: { type: Function },
|
|
126
148
|
fallbackOption: {
|
|
127
149
|
type: [Boolean, Function],
|
|
128
150
|
default: true
|
|
@@ -163,11 +185,14 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
163
185
|
},
|
|
164
186
|
emits: {
|
|
165
187
|
"update:modelValue": (_value) => true,
|
|
188
|
+
"update:value": (_value) => true,
|
|
166
189
|
"update:inputValue": (_inputValue) => true,
|
|
167
190
|
"update:popupVisible": (_visible) => true,
|
|
191
|
+
"update:show": (_visible) => true,
|
|
168
192
|
"change": (_value) => true,
|
|
169
193
|
"inputValueChange": (_inputValue) => true,
|
|
170
194
|
"popupVisibleChange": (_visible) => true,
|
|
195
|
+
"showChange": (_visible) => true,
|
|
171
196
|
"clear": (_ev) => true,
|
|
172
197
|
"remove": (_removed) => true,
|
|
173
198
|
"search": (_inputValue) => true,
|
|
@@ -175,14 +200,16 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
175
200
|
"dropdownReachBottom": (_ev) => true,
|
|
176
201
|
"exceedLimit": (_value, _ev) => true
|
|
177
202
|
},
|
|
178
|
-
setup(props, { slots, emit, attrs }) {
|
|
179
|
-
const { size, disabled, error, options, filterOption, valueKey, multiple, popupVisible, defaultPopupVisible, showExtraOptions, modelValue, fieldNames, loading, defaultActiveFirstOption } = toRefs(props);
|
|
203
|
+
setup(props, { slots, emit, attrs, expose }) {
|
|
204
|
+
const { size, disabled, error, options, filterOption, valueKey, multiple, value: valueProp, popupVisible, show, defaultPopupVisible, defaultShow, showExtraOptions, modelValue, fieldNames, loading, defaultActiveFirstOption, allowClear } = toRefs(props);
|
|
180
205
|
const prefixCls = getPrefixCls("select");
|
|
206
|
+
const selectViewRef = ref(null);
|
|
181
207
|
const { mergedSize, mergedDisabled, mergedError, eventHandlers } = useFormItem({
|
|
182
208
|
size,
|
|
183
209
|
disabled,
|
|
184
210
|
error
|
|
185
211
|
});
|
|
212
|
+
const { mergedAllowClear } = useAllowClear(allowClear);
|
|
186
213
|
const component = computed(() => props.virtualListProps ? "div" : "li");
|
|
187
214
|
const retainInputValue = computed(() => isObject(props.allowSearch) && Boolean(props.allowSearch.retainInputValue));
|
|
188
215
|
const dropdownRef = ref();
|
|
@@ -191,23 +218,29 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
191
218
|
const { computedPopupVisible, handlePopupVisibleChange } = useTrigger({
|
|
192
219
|
popupVisible,
|
|
193
220
|
defaultPopupVisible,
|
|
221
|
+
show,
|
|
222
|
+
defaultShow,
|
|
194
223
|
emit
|
|
195
224
|
});
|
|
196
225
|
const _value = ref(props.defaultValue);
|
|
197
226
|
const computedValueObjects = computed(() => {
|
|
198
|
-
var _props$modelValue;
|
|
199
|
-
const mergedValue = (_props$modelValue = props.modelValue) !== null && _props$modelValue !== void 0 ? _props$modelValue : _value.value;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
227
|
+
var _ref, _props$modelValue;
|
|
228
|
+
const mergedValue = (_ref = (_props$modelValue = props.modelValue) !== null && _props$modelValue !== void 0 ? _props$modelValue : props.value) !== null && _ref !== void 0 ? _ref : _value.value;
|
|
229
|
+
const valueArray = [];
|
|
230
|
+
if (isArray(mergedValue)) valueArray.push(...mergedValue);
|
|
231
|
+
else if (mergedValue || isNumber(mergedValue) || isString(mergedValue) || isBoolean(mergedValue)) valueArray.push(mergedValue);
|
|
232
|
+
return valueArray.map((item) => ({
|
|
233
|
+
value: item,
|
|
234
|
+
key: getKeyFromValue(item, props.valueKey)
|
|
203
235
|
}));
|
|
204
236
|
});
|
|
205
|
-
watch(modelValue, (
|
|
206
|
-
|
|
237
|
+
watch([modelValue, valueProp], ([nextModelValue, nextValue]) => {
|
|
238
|
+
const mergedValue = nextModelValue !== null && nextModelValue !== void 0 ? nextModelValue : nextValue;
|
|
239
|
+
if (isUndefined(mergedValue) || isNull(mergedValue)) _value.value = multiple.value ? [] : mergedValue;
|
|
207
240
|
});
|
|
208
|
-
const computedValueKeys = computed(() => computedValueObjects.value.map((
|
|
209
|
-
const mergedFieldNames = computed(() => _objectSpread2(_objectSpread2({}, DEFAULT_FIELD_NAMES), fieldNames
|
|
210
|
-
const
|
|
241
|
+
const computedValueKeys = computed(() => computedValueObjects.value.map((item) => item.key));
|
|
242
|
+
const mergedFieldNames = computed(() => _objectSpread2(_objectSpread2({}, DEFAULT_FIELD_NAMES), fieldNames.value));
|
|
243
|
+
const selectedOptionMap = ref({});
|
|
211
244
|
const getRawOptionFromValueKeys = (valueKeys) => {
|
|
212
245
|
const optionMap = {};
|
|
213
246
|
valueKeys.forEach((key) => {
|
|
@@ -216,61 +249,63 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
216
249
|
return optionMap;
|
|
217
250
|
};
|
|
218
251
|
const updateSelectedOption = (valueKeys) => {
|
|
219
|
-
|
|
252
|
+
selectedOptionMap.value = getRawOptionFromValueKeys(valueKeys);
|
|
220
253
|
};
|
|
221
254
|
const getFallBackOption = (value) => {
|
|
222
255
|
if (isFunction(props.fallbackOption)) return props.fallbackOption(value);
|
|
223
256
|
return {
|
|
224
257
|
[mergedFieldNames.value.value]: value,
|
|
225
|
-
[mergedFieldNames.value.label]: String(isObject(value) ? value[valueKey
|
|
258
|
+
[mergedFieldNames.value.label]: String(isObject(value) ? value[valueKey.value] : value)
|
|
226
259
|
};
|
|
227
260
|
};
|
|
261
|
+
const shouldAppendExtraValue = (keyArray, optionKey, optionValue) => {
|
|
262
|
+
if (keyArray.includes(optionKey) || optionValue === "") return false;
|
|
263
|
+
const optionInfo = optionInfoMap.get(optionKey);
|
|
264
|
+
return !optionInfo || optionInfo.origin === "extraOptions";
|
|
265
|
+
};
|
|
266
|
+
const appendExtraValue = (valueArray, keyArray, option) => {
|
|
267
|
+
valueArray.push(option);
|
|
268
|
+
keyArray.push(option.key);
|
|
269
|
+
};
|
|
228
270
|
const getExtraValueData = () => {
|
|
229
271
|
const valueArray = [];
|
|
230
272
|
const keyArray = [];
|
|
231
273
|
if (props.allowCreate || props.fallbackOption) {
|
|
232
|
-
for (const item of computedValueObjects.value) if (
|
|
233
|
-
const optionInfo = optionInfoMap.get(item.key);
|
|
234
|
-
if (!optionInfo || optionInfo.origin === "extraOptions") {
|
|
235
|
-
valueArray.push(item);
|
|
236
|
-
keyArray.push(item.key);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
274
|
+
for (const item of computedValueObjects.value) if (shouldAppendExtraValue(keyArray, item.key, item.value)) appendExtraValue(valueArray, keyArray, item);
|
|
239
275
|
}
|
|
240
276
|
if (props.allowCreate && computedInputValue.value) {
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
key
|
|
247
|
-
});
|
|
248
|
-
}
|
|
277
|
+
const createdOption = {
|
|
278
|
+
value: computedInputValue.value,
|
|
279
|
+
key: getKeyFromValue(computedInputValue.value)
|
|
280
|
+
};
|
|
281
|
+
if (shouldAppendExtraValue(keyArray, createdOption.key, createdOption.value)) appendExtraValue(valueArray, keyArray, createdOption);
|
|
249
282
|
}
|
|
250
283
|
return valueArray;
|
|
251
284
|
};
|
|
252
285
|
const extraValueObjects = ref([]);
|
|
253
|
-
const extraOptions = computed(() => extraValueObjects.value.map((
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const extraOptionRawInfo = (_selectedOption$value = _selectedOption.value) === null || _selectedOption$value === void 0 ? void 0 : _selectedOption$value[obj.key];
|
|
286
|
+
const extraOptions = computed(() => extraValueObjects.value.map((item) => {
|
|
287
|
+
let optionInfo = getFallBackOption(item.value);
|
|
288
|
+
const extraOptionRawInfo = selectedOptionMap.value[item.key];
|
|
257
289
|
if (!isUndefined(extraOptionRawInfo) && !isEmptyObject(extraOptionRawInfo)) optionInfo = _objectSpread2(_objectSpread2({}, optionInfo), extraOptionRawInfo);
|
|
258
290
|
return optionInfo;
|
|
259
291
|
}));
|
|
260
292
|
nextTick(() => {
|
|
261
293
|
watchEffect(() => {
|
|
262
294
|
const valueData = getExtraValueData();
|
|
263
|
-
if (valueData.length !== extraValueObjects.value.length)
|
|
264
|
-
|
|
295
|
+
if (valueData.length !== extraValueObjects.value.length) {
|
|
296
|
+
extraValueObjects.value = valueData;
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
for (let index = 0; index < valueData.length; index += 1) {
|
|
265
300
|
var _extraValueObjects$va;
|
|
266
|
-
if (valueData[
|
|
301
|
+
if (valueData[index].key !== ((_extraValueObjects$va = extraValueObjects.value[index]) === null || _extraValueObjects$va === void 0 ? void 0 : _extraValueObjects$va.key)) {
|
|
267
302
|
extraValueObjects.value = valueData;
|
|
268
303
|
break;
|
|
269
304
|
}
|
|
270
305
|
}
|
|
271
306
|
});
|
|
272
307
|
});
|
|
273
|
-
const _inputValue = ref(
|
|
308
|
+
const _inputValue = ref(props.defaultInputValue);
|
|
274
309
|
const computedInputValue = computed(() => {
|
|
275
310
|
var _props$inputValue;
|
|
276
311
|
return (_props$inputValue = props.inputValue) !== null && _props$inputValue !== void 0 ? _props$inputValue : _inputValue.value;
|
|
@@ -290,10 +325,11 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
290
325
|
};
|
|
291
326
|
const updateValue = (valueKeys) => {
|
|
292
327
|
var _eventHandlers$value, _eventHandlers$value$;
|
|
293
|
-
const
|
|
294
|
-
_value.value =
|
|
295
|
-
emit("update:modelValue",
|
|
296
|
-
emit("
|
|
328
|
+
const nextValue = getValueFromValueKeys(valueKeys);
|
|
329
|
+
_value.value = nextValue;
|
|
330
|
+
emit("update:modelValue", nextValue);
|
|
331
|
+
emit("update:value", nextValue);
|
|
332
|
+
emit("change", nextValue);
|
|
297
333
|
(_eventHandlers$value = eventHandlers.value) === null || _eventHandlers$value === void 0 || (_eventHandlers$value$ = _eventHandlers$value.onChange) === null || _eventHandlers$value$ === void 0 || _eventHandlers$value$.call(_eventHandlers$value);
|
|
298
334
|
updateSelectedOption(valueKeys);
|
|
299
335
|
};
|
|
@@ -302,53 +338,58 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
302
338
|
emit("update:inputValue", inputValue);
|
|
303
339
|
emit("inputValueChange", inputValue);
|
|
304
340
|
};
|
|
341
|
+
const handleMultipleSelect = (key, ev) => {
|
|
342
|
+
if (!computedValueKeys.value.includes(key)) {
|
|
343
|
+
if (enabledOptionKeys.value.includes(key)) if (props.limit > 0 && computedValueKeys.value.length >= props.limit) {
|
|
344
|
+
const info = optionInfoMap.get(key);
|
|
345
|
+
emit("exceedLimit", info === null || info === void 0 ? void 0 : info.value, ev);
|
|
346
|
+
} else updateValue(computedValueKeys.value.concat(key));
|
|
347
|
+
} else updateValue(computedValueKeys.value.filter((valueKeyItem) => valueKeyItem !== key));
|
|
348
|
+
if (!retainInputValue.value) updateInputValue("");
|
|
349
|
+
};
|
|
350
|
+
const handleSingleSelect = (key) => {
|
|
351
|
+
if (key !== computedValueKeys.value[0]) updateValue([key]);
|
|
352
|
+
if (retainInputValue.value) {
|
|
353
|
+
const optionInfo = optionInfoMap.get(key);
|
|
354
|
+
if (optionInfo) updateInputValue(optionInfo.label);
|
|
355
|
+
}
|
|
356
|
+
handlePopupVisibleChange(false);
|
|
357
|
+
};
|
|
305
358
|
const handleSelect = (key, ev) => {
|
|
306
359
|
if (props.multiple) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const info = optionInfoMap.get(key);
|
|
310
|
-
emit("exceedLimit", info === null || info === void 0 ? void 0 : info.value, ev);
|
|
311
|
-
} else updateValue(computedValueKeys.value.concat(key));
|
|
312
|
-
} else updateValue(computedValueKeys.value.filter((_key) => _key !== key));
|
|
313
|
-
if (!retainInputValue.value) updateInputValue("");
|
|
314
|
-
} else {
|
|
315
|
-
if (key !== computedValueKeys.value[0]) updateValue([key]);
|
|
316
|
-
if (retainInputValue.value) {
|
|
317
|
-
const optionInfo = optionInfoMap.get(key);
|
|
318
|
-
if (optionInfo) updateInputValue(optionInfo.label);
|
|
319
|
-
}
|
|
320
|
-
handlePopupVisibleChange(false);
|
|
360
|
+
handleMultipleSelect(key, ev);
|
|
361
|
+
return;
|
|
321
362
|
}
|
|
363
|
+
handleSingleSelect(key);
|
|
322
364
|
};
|
|
323
365
|
const handleSearch = debounce((value) => {
|
|
324
366
|
emit("search", value);
|
|
325
367
|
}, props.searchDelay);
|
|
326
368
|
const handleInputValueChange = (inputValue) => {
|
|
327
|
-
if (inputValue
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
369
|
+
if (inputValue === computedInputValue.value) return;
|
|
370
|
+
if (!computedPopupVisible.value) handlePopupVisibleChange(true);
|
|
371
|
+
updateInputValue(inputValue);
|
|
372
|
+
if (props.allowSearch) handleSearch(inputValue);
|
|
332
373
|
};
|
|
333
374
|
const handleRemove = (key) => {
|
|
334
375
|
const optionInfo = optionInfoMap.get(key);
|
|
335
|
-
updateValue(computedValueKeys.value.filter((
|
|
376
|
+
updateValue(computedValueKeys.value.filter((currentKey) => currentKey !== key));
|
|
336
377
|
emit("remove", optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.value);
|
|
337
378
|
};
|
|
338
|
-
const handleClear = (
|
|
339
|
-
|
|
379
|
+
const handleClear = (event) => {
|
|
380
|
+
event.stopPropagation();
|
|
340
381
|
updateValue(computedValueKeys.value.filter((key) => {
|
|
341
382
|
var _optionInfoMap$get3;
|
|
342
383
|
return (_optionInfoMap$get3 = optionInfoMap.get(key)) === null || _optionInfoMap$get3 === void 0 ? void 0 : _optionInfoMap$get3.disabled;
|
|
343
384
|
}));
|
|
344
385
|
updateInputValue("");
|
|
345
|
-
emit("clear",
|
|
386
|
+
emit("clear", event);
|
|
346
387
|
};
|
|
347
|
-
const handleDropdownScroll = (
|
|
348
|
-
emit("dropdownScroll",
|
|
388
|
+
const handleDropdownScroll = (event) => {
|
|
389
|
+
emit("dropdownScroll", event);
|
|
349
390
|
};
|
|
350
|
-
const handleDropdownReachBottom = (
|
|
351
|
-
emit("dropdownReachBottom",
|
|
391
|
+
const handleDropdownReachBottom = (event) => {
|
|
392
|
+
emit("dropdownReachBottom", event);
|
|
352
393
|
};
|
|
353
394
|
const { validOptions, optionInfoMap, validOptionInfos, enabledOptionKeys, handleKeyDown } = useSelect({
|
|
354
395
|
multiple,
|
|
@@ -373,25 +414,24 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
373
414
|
const selectViewValue = computed(() => {
|
|
374
415
|
const result = [];
|
|
375
416
|
for (const item of computedValueObjects.value) {
|
|
417
|
+
var _optionInfo$label;
|
|
376
418
|
const optionInfo = optionInfoMap.get(item.key);
|
|
377
|
-
if (optionInfo)
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
419
|
+
if (!optionInfo) continue;
|
|
420
|
+
result.push(_objectSpread2(_objectSpread2({}, optionInfo), {}, {
|
|
421
|
+
value: item.key,
|
|
422
|
+
label: (_optionInfo$label = optionInfo.label) !== null && _optionInfo$label !== void 0 ? _optionInfo$label : String(isObject(item.value) ? item.value[valueKey.value] : item.value),
|
|
423
|
+
closable: !optionInfo.disabled,
|
|
424
|
+
tagProps: optionInfo.tagProps,
|
|
425
|
+
option: optionInfo.raw
|
|
426
|
+
}));
|
|
386
427
|
}
|
|
387
428
|
return result;
|
|
388
429
|
});
|
|
389
430
|
const getOptionContentFunc = (optionInfo) => {
|
|
390
|
-
if (isFunction(slots.option)) {
|
|
391
|
-
|
|
392
|
-
return ()
|
|
393
|
-
}
|
|
394
|
-
if (isFunction(optionInfo.render)) return optionInfo.render;
|
|
431
|
+
if (isFunction(slots.option)) return () => {
|
|
432
|
+
var _slots$option;
|
|
433
|
+
return (_slots$option = slots.option) === null || _slots$option === void 0 ? void 0 : _slots$option.call(slots, { data: optionInfo.raw });
|
|
434
|
+
};
|
|
395
435
|
return () => optionInfo.label;
|
|
396
436
|
};
|
|
397
437
|
const renderOption = (optionInfo) => {
|
|
@@ -404,11 +444,12 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
404
444
|
}
|
|
405
445
|
if (!isValidOption(optionInfo, {
|
|
406
446
|
inputValue: computedInputValue.value,
|
|
407
|
-
filterOption: filterOption
|
|
447
|
+
filterOption: filterOption.value
|
|
408
448
|
})) return null;
|
|
409
449
|
return createVNode(option_default, {
|
|
410
|
-
"ref": (
|
|
411
|
-
|
|
450
|
+
"ref": (refInstance) => {
|
|
451
|
+
const element = refInstance === null || refInstance === void 0 ? void 0 : refInstance.$el;
|
|
452
|
+
if (element instanceof HTMLElement) optionRefs.value[optionInfo.key] = element;
|
|
412
453
|
},
|
|
413
454
|
"key": optionInfo.key,
|
|
414
455
|
"value": optionInfo.value,
|
|
@@ -417,42 +458,54 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
417
458
|
"internal": true
|
|
418
459
|
}, { default: getOptionContentFunc(optionInfo) });
|
|
419
460
|
};
|
|
420
|
-
const renderDropDown = () => {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
"
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
});
|
|
444
|
-
};
|
|
461
|
+
const renderDropDown = () => createVNode(select_dropdown_default, {
|
|
462
|
+
"ref": dropdownRef,
|
|
463
|
+
"loading": props.loading,
|
|
464
|
+
"empty": validOptionInfos.value.length === 0,
|
|
465
|
+
"virtualList": Boolean(props.virtualListProps),
|
|
466
|
+
"scrollbar": props.scrollbar,
|
|
467
|
+
"showHeaderOnEmpty": props.showHeaderOnEmpty,
|
|
468
|
+
"showFooterOnEmpty": props.showFooterOnEmpty,
|
|
469
|
+
"onScroll": handleDropdownScroll,
|
|
470
|
+
"onReachBottom": handleDropdownReachBottom
|
|
471
|
+
}, {
|
|
472
|
+
"default": () => {
|
|
473
|
+
var _slots$default, _slots$default2;
|
|
474
|
+
return [...(_slots$default = (_slots$default2 = slots.default) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots)) !== null && _slots$default !== void 0 ? _slots$default : [], ...validOptions.value.map(renderOption)];
|
|
475
|
+
},
|
|
476
|
+
"virtual-list": () => createVNode(virtual_list_v2_default, mergeProps(props.virtualListProps, {
|
|
477
|
+
"ref": virtualListRef,
|
|
478
|
+
"data": validOptions.value
|
|
479
|
+
}), { item: ({ item }) => renderOption(item) }),
|
|
480
|
+
"empty": slots.empty,
|
|
481
|
+
"header": slots.header,
|
|
482
|
+
"footer": slots.footer
|
|
483
|
+
});
|
|
445
484
|
const renderLabel = ({ data }) => {
|
|
446
485
|
var _data$label;
|
|
447
|
-
if (
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
return (_slots$label = (_slots$label2 = slots.label) === null || _slots$label2 === void 0 ? void 0 : _slots$label2.call(slots, { data: optionInfo.raw })) !== null && _slots$label !== void 0 ? _slots$label : (_props$formatLabel = props.formatLabel) === null || _props$formatLabel === void 0 ? void 0 : _props$formatLabel.call(props, optionInfo.raw);
|
|
452
|
-
}
|
|
486
|
+
if (slots.label && data) {
|
|
487
|
+
var _data$option, _optionInfoMap$get4;
|
|
488
|
+
const optionData = (_data$option = data.option) !== null && _data$option !== void 0 ? _data$option : (_optionInfoMap$get4 = optionInfoMap.get(data.value)) === null || _optionInfoMap$get4 === void 0 ? void 0 : _optionInfoMap$get4.raw;
|
|
489
|
+
if (optionData) return slots.label({ data: optionData });
|
|
453
490
|
}
|
|
454
|
-
return (_data$label = data
|
|
491
|
+
return (_data$label = data.label) !== null && _data$label !== void 0 ? _data$label : "";
|
|
492
|
+
};
|
|
493
|
+
const renderTag = ({ data }) => {
|
|
494
|
+
var _data$option2, _optionInfoMap$get5, _slots$tag, _slots$tag2;
|
|
495
|
+
const optionData = (_data$option2 = data.option) !== null && _data$option2 !== void 0 ? _data$option2 : (_optionInfoMap$get5 = optionInfoMap.get(data.value)) === null || _optionInfoMap$get5 === void 0 ? void 0 : _optionInfoMap$get5.raw;
|
|
496
|
+
if (!optionData) return renderLabel({ data });
|
|
497
|
+
return (_slots$tag = (_slots$tag2 = slots.tag) === null || _slots$tag2 === void 0 ? void 0 : _slots$tag2.call(slots, { data: optionData })) !== null && _slots$tag !== void 0 ? _slots$tag : renderLabel({ data });
|
|
455
498
|
};
|
|
499
|
+
expose({
|
|
500
|
+
focus: () => {
|
|
501
|
+
var _selectViewRef$value, _selectViewRef$value$;
|
|
502
|
+
return (_selectViewRef$value = selectViewRef.value) === null || _selectViewRef$value === void 0 || (_selectViewRef$value$ = _selectViewRef$value.focus) === null || _selectViewRef$value$ === void 0 ? void 0 : _selectViewRef$value$.call(_selectViewRef$value);
|
|
503
|
+
},
|
|
504
|
+
blur: () => {
|
|
505
|
+
var _selectViewRef$value2, _selectViewRef$value3;
|
|
506
|
+
return (_selectViewRef$value2 = selectViewRef.value) === null || _selectViewRef$value2 === void 0 || (_selectViewRef$value3 = _selectViewRef$value2.blur) === null || _selectViewRef$value3 === void 0 ? void 0 : _selectViewRef$value3.call(_selectViewRef$value2);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
456
509
|
return () => createVNode(Trigger, mergeProps({
|
|
457
510
|
"trigger": "click",
|
|
458
511
|
"position": "bl",
|
|
@@ -472,6 +525,7 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
472
525
|
default: () => {
|
|
473
526
|
var _slots$trigger, _slots$trigger2;
|
|
474
527
|
return [(_slots$trigger = (_slots$trigger2 = slots.trigger) === null || _slots$trigger2 === void 0 ? void 0 : _slots$trigger2.call(slots)) !== null && _slots$trigger !== void 0 ? _slots$trigger : createVNode(select_view_default, mergeProps({
|
|
528
|
+
"ref": selectViewRef,
|
|
475
529
|
"class": prefixCls,
|
|
476
530
|
"modelValue": selectViewValue.value,
|
|
477
531
|
"inputValue": computedInputValue.value,
|
|
@@ -479,9 +533,10 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
479
533
|
"disabled": mergedDisabled.value,
|
|
480
534
|
"error": mergedError.value,
|
|
481
535
|
"loading": props.loading,
|
|
482
|
-
"allowClear":
|
|
536
|
+
"allowClear": mergedAllowClear.value,
|
|
483
537
|
"allowCreate": props.allowCreate,
|
|
484
538
|
"allowSearch": Boolean(props.allowSearch),
|
|
539
|
+
"showArrow": props.showArrow,
|
|
485
540
|
"opened": computedPopupVisible.value,
|
|
486
541
|
"maxTagCount": props.maxTagCount,
|
|
487
542
|
"placeholder": props.placeholder,
|
|
@@ -494,6 +549,7 @@ var select_default = /* @__PURE__ */ defineComponent({
|
|
|
494
549
|
"onKeydown": handleKeyDown
|
|
495
550
|
}, attrs), {
|
|
496
551
|
"label": renderLabel,
|
|
552
|
+
"tag": renderTag,
|
|
497
553
|
"prefix": slots.prefix,
|
|
498
554
|
"arrow-icon": slots["arrow-icon"],
|
|
499
555
|
"loading-icon": slots["loading-icon"],
|
package/es/select/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FilterOption, SelectOptionGroup, SelectOptionGroupInfo, SelectOption, SelectOptionData, SelectOptionInfo, SelectOptionValue, SelectFieldNames } from './interface';
|
|
2
|
-
export declare const isGroupOption: (option: SelectOption) => option is SelectOptionGroup;
|
|
2
|
+
export declare const isGroupOption: (option: SelectOption, fieldNames?: Required<SelectFieldNames>) => option is SelectOptionGroup;
|
|
3
3
|
export declare const isGroupOptionInfo: (option: SelectOptionInfo | SelectOptionGroupInfo) => option is SelectOptionGroupInfo;
|
|
4
4
|
export declare const getValueString: (value: SelectOptionValue, valueKey?: string) => string;
|
|
5
5
|
export declare const getKeyFromValue: (value?: SelectOptionValue, valueKey?: string) => string;
|
package/es/select/utils.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.124.0/helpers/objectSpread2.js";
|
|
2
2
|
import { isBoolean, isFunction, isNumber, isObject, isString } from "../_utils/is.js";
|
|
3
3
|
//#region components/select/utils.ts
|
|
4
|
-
var isGroupOption = (option) => {
|
|
5
|
-
|
|
4
|
+
var isGroupOption = (option, fieldNames) => {
|
|
5
|
+
if (!isObject(option)) return false;
|
|
6
|
+
if ("isGroup" in option) return true;
|
|
7
|
+
if (!fieldNames) return false;
|
|
8
|
+
const children = option[fieldNames.children];
|
|
9
|
+
return Array.isArray(children);
|
|
6
10
|
};
|
|
7
11
|
var isGroupOptionInfo = (option) => {
|
|
8
12
|
return isObject(option) && "isGroup" in option;
|
|
@@ -27,7 +31,6 @@ var createOptionInfo = (option, { valueKey, fieldNames, origin, index = -1 }) =>
|
|
|
27
31
|
origin,
|
|
28
32
|
value,
|
|
29
33
|
label: (_option$fieldNames$la = option[fieldNames.label]) !== null && _option$fieldNames$la !== void 0 ? _option$fieldNames$la : getValueString(value, valueKey),
|
|
30
|
-
render: option[fieldNames.render],
|
|
31
34
|
disabled: Boolean(option[fieldNames.disabled]),
|
|
32
35
|
tagProps: option[fieldNames.tagProps]
|
|
33
36
|
};
|
|
@@ -44,20 +47,35 @@ var createOptionInfo = (option, { valueKey, fieldNames, origin, index = -1 }) =>
|
|
|
44
47
|
origin
|
|
45
48
|
}, raw);
|
|
46
49
|
};
|
|
50
|
+
var createGroupInfo = (item, { valueKey, fieldNames, origin, optionInfoMap }) => {
|
|
51
|
+
var _ref, _item$options, _item$fieldNames$labe;
|
|
52
|
+
const groupOptions = (_ref = (_item$options = item.options) !== null && _item$options !== void 0 ? _item$options : item[fieldNames.children]) !== null && _ref !== void 0 ? _ref : [];
|
|
53
|
+
const groupLabel = (_item$fieldNames$labe = item[fieldNames.label]) !== null && _item$fieldNames$labe !== void 0 ? _item$fieldNames$labe : item.label;
|
|
54
|
+
const options = getOptionInfos(groupOptions, {
|
|
55
|
+
valueKey,
|
|
56
|
+
fieldNames,
|
|
57
|
+
origin,
|
|
58
|
+
optionInfoMap
|
|
59
|
+
});
|
|
60
|
+
if (options.length === 0) return null;
|
|
61
|
+
const label = typeof groupLabel === "string" ? groupLabel : "";
|
|
62
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
63
|
+
isGroup: true,
|
|
64
|
+
label,
|
|
65
|
+
options,
|
|
66
|
+
key: `__arco__group__${label}`
|
|
67
|
+
});
|
|
68
|
+
};
|
|
47
69
|
var getOptionInfos = (options, { valueKey, fieldNames, origin, optionInfoMap }) => {
|
|
48
70
|
const infos = [];
|
|
49
|
-
for (const item of options) if (isGroupOption(item)) {
|
|
50
|
-
|
|
51
|
-
const options = getOptionInfos((_item$options = item.options) !== null && _item$options !== void 0 ? _item$options : [], {
|
|
71
|
+
for (const item of options) if (isGroupOption(item, fieldNames)) {
|
|
72
|
+
const groupInfo = createGroupInfo(item, {
|
|
52
73
|
valueKey,
|
|
53
74
|
fieldNames,
|
|
54
75
|
origin,
|
|
55
76
|
optionInfoMap
|
|
56
77
|
});
|
|
57
|
-
if (
|
|
58
|
-
key: `__arco__group__${item.label}`,
|
|
59
|
-
options
|
|
60
|
-
}));
|
|
78
|
+
if (groupInfo) infos.push(groupInfo);
|
|
61
79
|
} else {
|
|
62
80
|
const optionInfo = createOptionInfo(item, {
|
|
63
81
|
valueKey,
|
package/es/skeleton/index.d.ts
CHANGED
|
@@ -105,8 +105,8 @@ declare const Skeleton: {
|
|
|
105
105
|
default: number;
|
|
106
106
|
};
|
|
107
107
|
}>> & Readonly<{}>, {
|
|
108
|
-
rows: number;
|
|
109
108
|
lineHeight: number;
|
|
109
|
+
rows: number;
|
|
110
110
|
widths: (string | number)[];
|
|
111
111
|
lineSpacing: number;
|
|
112
112
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -39,8 +39,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
39
39
|
default: number;
|
|
40
40
|
};
|
|
41
41
|
}>> & Readonly<{}>, {
|
|
42
|
-
rows: number;
|
|
43
42
|
lineHeight: number;
|
|
43
|
+
rows: number;
|
|
44
44
|
widths: (string | number)[];
|
|
45
45
|
lineSpacing: number;
|
|
46
46
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|