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