@v-c/select 1.0.9 → 1.0.10

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 (43) hide show
  1. package/dist/BaseSelect/index.js +9 -4
  2. package/dist/SelectInput/Content/SingleContent.js +32 -26
  3. package/dist/hooks/useBaseProps.d.ts +1 -0
  4. package/dist/hooks/useOpen.d.ts +1 -1
  5. package/dist/hooks/useOpen.js +3 -2
  6. package/package.json +4 -4
  7. package/dist/BaseSelect/Polite.cjs +0 -40
  8. package/dist/BaseSelect/index.cjs +0 -778
  9. package/dist/OptGroup.cjs +0 -8
  10. package/dist/Option.cjs +0 -8
  11. package/dist/OptionList.cjs +0 -258
  12. package/dist/Select.cjs +0 -838
  13. package/dist/SelectContext.cjs +0 -12
  14. package/dist/SelectInput/Affix.cjs +0 -19
  15. package/dist/SelectInput/Content/MultipleContent.cjs +0 -145
  16. package/dist/SelectInput/Content/Placeholder.cjs +0 -36
  17. package/dist/SelectInput/Content/SingleContent.cjs +0 -83
  18. package/dist/SelectInput/Content/index.cjs +0 -43
  19. package/dist/SelectInput/Input.cjs +0 -179
  20. package/dist/SelectInput/context.cjs +0 -12
  21. package/dist/SelectInput/index.cjs +0 -341
  22. package/dist/SelectTrigger.cjs +0 -198
  23. package/dist/TransBtn.cjs +0 -72
  24. package/dist/_virtual/rolldown_runtime.cjs +0 -21
  25. package/dist/hooks/index.cjs +0 -24
  26. package/dist/hooks/useAllowClear.cjs +0 -18
  27. package/dist/hooks/useBaseProps.cjs +0 -15
  28. package/dist/hooks/useCache.cjs +0 -39
  29. package/dist/hooks/useComponents.cjs +0 -18
  30. package/dist/hooks/useFilterOptions.cjs +0 -42
  31. package/dist/hooks/useLock.cjs +0 -29
  32. package/dist/hooks/useOpen.cjs +0 -63
  33. package/dist/hooks/useOptions.cjs +0 -41
  34. package/dist/hooks/useRefFunc.cjs +0 -15
  35. package/dist/hooks/useSearchConfig.cjs +0 -26
  36. package/dist/hooks/useSelectTriggerControl.cjs +0 -26
  37. package/dist/index.cjs +0 -22
  38. package/dist/interface.cjs +0 -1
  39. package/dist/utils/commonUtil.cjs +0 -38
  40. package/dist/utils/keyUtil.cjs +0 -37
  41. package/dist/utils/legacyUtil.cjs +0 -33
  42. package/dist/utils/platformUtil.cjs +0 -6
  43. package/dist/utils/valueUtil.cjs +0 -80
package/dist/Select.cjs DELETED
@@ -1,838 +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_SelectContext = require("./SelectContext.cjs");
7
- const require_valueUtil = require("./utils/valueUtil.cjs");
8
- const require_OptionList = require("./OptionList.cjs");
9
- const require_useCache = require("./hooks/useCache.cjs");
10
- const require_commonUtil = require("./utils/commonUtil.cjs");
11
- const require_useFilterOptions = require("./hooks/useFilterOptions.cjs");
12
- const require_useOptions = require("./hooks/useOptions.cjs");
13
- const require_useRefFunc = require("./hooks/useRefFunc.cjs");
14
- const require_useSearchConfig = require("./hooks/useSearchConfig.cjs");
15
- const require_index = require("./BaseSelect/index.cjs");
16
- const require_legacyUtil = require("./utils/legacyUtil.cjs");
17
- let vue = require("vue");
18
- let _v_c_util_dist_hooks_useId = require("@v-c/util/dist/hooks/useId");
19
- _v_c_util_dist_hooks_useId = require_rolldown_runtime.__toESM(_v_c_util_dist_hooks_useId);
20
- let _v_c_util_dist_omit = require("@v-c/util/dist/omit");
21
- _v_c_util_dist_omit = require_rolldown_runtime.__toESM(_v_c_util_dist_omit);
22
- let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
23
- var OMIT_DOM_PROPS = ["inputValue"];
24
- var omitKeyList = [
25
- "id",
26
- "mode",
27
- "prefixCls",
28
- "backfill",
29
- "fieldNames",
30
- "showSearch",
31
- "searchValue",
32
- "onSearch",
33
- "autoClearSearchValue",
34
- "filterOption",
35
- "optionFilterProp",
36
- "filterSort",
37
- "onSelect",
38
- "onDeselect",
39
- "onActive",
40
- "popupMatchSelectWidth",
41
- "optionLabelProp",
42
- "options",
43
- "optionRender",
44
- "children",
45
- "defaultActiveFirstOption",
46
- "menuItemSelectedIcon",
47
- "virtual",
48
- "direction",
49
- "listHeight",
50
- "listItemHeight",
51
- "labelRender",
52
- "value",
53
- "defaultValue",
54
- "labelInValue",
55
- "onChange",
56
- "maxCount",
57
- "classNames",
58
- "styles"
59
- ];
60
- function isRawValue(value) {
61
- return !value || typeof value !== "object";
62
- }
63
- var Select = /* @__PURE__ */ (0, vue.defineComponent)({
64
- props: /* @__PURE__ */ (0, vue.mergeDefaults)({
65
- prefixCls: {
66
- type: String,
67
- required: false,
68
- default: void 0
69
- },
70
- id: {
71
- type: String,
72
- required: false,
73
- default: void 0
74
- },
75
- backfill: {
76
- type: Boolean,
77
- required: false,
78
- default: void 0
79
- },
80
- fieldNames: {
81
- type: Object,
82
- required: false,
83
- default: void 0
84
- },
85
- onSearch: {
86
- type: Function,
87
- required: false,
88
- default: void 0
89
- },
90
- showSearch: {
91
- type: [Boolean, Object],
92
- required: false,
93
- default: void 0
94
- },
95
- searchValue: {
96
- type: String,
97
- required: false,
98
- default: void 0
99
- },
100
- autoClearSearchValue: {
101
- type: Boolean,
102
- required: false,
103
- default: void 0
104
- },
105
- onSelect: {
106
- type: Function,
107
- required: false,
108
- default: void 0
109
- },
110
- onDeselect: {
111
- type: Function,
112
- required: false,
113
- default: void 0
114
- },
115
- onActive: {
116
- type: Function,
117
- required: false,
118
- default: void 0
119
- },
120
- filterOption: {
121
- type: [Boolean, Function],
122
- required: false,
123
- default: void 0
124
- },
125
- filterSort: {
126
- type: Function,
127
- required: false,
128
- default: void 0
129
- },
130
- optionFilterProp: {
131
- type: String,
132
- required: false,
133
- default: void 0
134
- },
135
- optionLabelProp: {
136
- type: String,
137
- required: false,
138
- default: void 0
139
- },
140
- options: {
141
- type: Array,
142
- required: false,
143
- default: void 0
144
- },
145
- optionRender: {
146
- type: Function,
147
- required: false,
148
- default: void 0
149
- },
150
- defaultActiveFirstOption: {
151
- type: Boolean,
152
- required: false,
153
- default: void 0
154
- },
155
- virtual: {
156
- type: Boolean,
157
- required: false,
158
- default: void 0
159
- },
160
- direction: {
161
- type: String,
162
- required: false,
163
- default: void 0
164
- },
165
- listHeight: {
166
- type: Number,
167
- required: false,
168
- default: void 0
169
- },
170
- listItemHeight: {
171
- type: Number,
172
- required: false,
173
- default: void 0
174
- },
175
- labelRender: {
176
- type: Function,
177
- required: false,
178
- default: void 0
179
- },
180
- menuItemSelectedIcon: {
181
- type: [
182
- Object,
183
- Function,
184
- String,
185
- Number,
186
- null,
187
- Boolean,
188
- Array
189
- ],
190
- required: false,
191
- default: void 0
192
- },
193
- mode: {
194
- type: String,
195
- required: false,
196
- default: void 0
197
- },
198
- labelInValue: {
199
- type: Boolean,
200
- required: false,
201
- default: void 0
202
- },
203
- value: {
204
- required: false,
205
- default: void 0
206
- },
207
- defaultValue: {
208
- required: false,
209
- default: void 0
210
- },
211
- maxCount: {
212
- type: Number,
213
- required: false,
214
- default: void 0
215
- },
216
- onChange: {
217
- type: Function,
218
- required: false,
219
- default: void 0
220
- },
221
- classNames: {
222
- type: Object,
223
- required: false,
224
- default: void 0
225
- },
226
- styles: {
227
- type: Object,
228
- required: false,
229
- default: void 0
230
- },
231
- className: {
232
- type: String,
233
- required: false,
234
- default: void 0
235
- },
236
- style: {
237
- type: Object,
238
- required: false,
239
- default: void 0
240
- },
241
- tagRender: {
242
- type: Function,
243
- required: false,
244
- default: void 0
245
- },
246
- autoFocus: {
247
- type: Boolean,
248
- required: false,
249
- default: void 0
250
- },
251
- placeholder: {
252
- type: [
253
- Object,
254
- Function,
255
- String,
256
- Number,
257
- null,
258
- Boolean,
259
- Array
260
- ],
261
- required: false,
262
- default: void 0
263
- },
264
- title: {
265
- type: String,
266
- required: false,
267
- default: void 0
268
- },
269
- tabIndex: {
270
- type: Number,
271
- required: false,
272
- default: void 0
273
- },
274
- notFoundContent: {
275
- type: [
276
- Object,
277
- Function,
278
- String,
279
- Number,
280
- null,
281
- Boolean,
282
- Array
283
- ],
284
- required: false,
285
- default: void 0
286
- },
287
- onClear: {
288
- type: Function,
289
- required: false,
290
- default: void 0
291
- },
292
- maxLength: {
293
- type: Number,
294
- required: false,
295
- default: void 0
296
- },
297
- showScrollBar: {
298
- type: [Boolean, String],
299
- required: false,
300
- default: void 0
301
- },
302
- choiceTransitionName: {
303
- type: String,
304
- required: false,
305
- default: void 0
306
- },
307
- disabled: {
308
- type: Boolean,
309
- required: false,
310
- default: void 0
311
- },
312
- loading: {
313
- type: Boolean,
314
- required: false,
315
- default: void 0
316
- },
317
- open: {
318
- type: Boolean,
319
- required: false,
320
- default: void 0
321
- },
322
- defaultOpen: {
323
- type: Boolean,
324
- required: false,
325
- default: void 0
326
- },
327
- onPopupVisibleChange: {
328
- type: Function,
329
- required: false,
330
- default: void 0
331
- },
332
- getInputElement: {
333
- type: Function,
334
- required: false,
335
- default: void 0
336
- },
337
- getRawInputElement: {
338
- type: Function,
339
- required: false,
340
- default: void 0
341
- },
342
- maxTagTextLength: {
343
- type: Number,
344
- required: false,
345
- default: void 0
346
- },
347
- maxTagCount: {
348
- type: [Number, String],
349
- required: false,
350
- default: void 0
351
- },
352
- maxTagPlaceholder: {
353
- type: [
354
- Object,
355
- Function,
356
- String,
357
- Number,
358
- null,
359
- Boolean,
360
- Array
361
- ],
362
- required: false,
363
- default: void 0
364
- },
365
- tokenSeparators: {
366
- type: Array,
367
- required: false,
368
- default: void 0
369
- },
370
- allowClear: {
371
- type: [Boolean, Object],
372
- required: false,
373
- default: void 0
374
- },
375
- prefix: {
376
- type: [
377
- Object,
378
- Function,
379
- String,
380
- Number,
381
- null,
382
- Boolean,
383
- Array
384
- ],
385
- required: false,
386
- default: void 0
387
- },
388
- suffixIcon: {
389
- type: [
390
- Object,
391
- Function,
392
- String,
393
- Number,
394
- null,
395
- Boolean,
396
- Array
397
- ],
398
- required: false,
399
- default: void 0
400
- },
401
- suffix: {
402
- type: [
403
- Object,
404
- Function,
405
- String,
406
- Number,
407
- null,
408
- Boolean,
409
- Array
410
- ],
411
- required: false,
412
- default: void 0
413
- },
414
- clearIcon: {
415
- type: [
416
- Object,
417
- Function,
418
- String,
419
- Number,
420
- null,
421
- Boolean,
422
- Array
423
- ],
424
- required: false,
425
- default: void 0
426
- },
427
- removeIcon: {
428
- type: [
429
- Object,
430
- Function,
431
- String,
432
- Number,
433
- null,
434
- Boolean,
435
- Array
436
- ],
437
- required: false,
438
- default: void 0
439
- },
440
- animation: {
441
- type: String,
442
- required: false,
443
- default: void 0
444
- },
445
- transitionName: {
446
- type: String,
447
- required: false,
448
- default: void 0
449
- },
450
- popupStyle: {
451
- type: Object,
452
- required: false,
453
- default: void 0
454
- },
455
- popupClassName: {
456
- type: String,
457
- required: false,
458
- default: void 0
459
- },
460
- popupMatchSelectWidth: {
461
- type: [Boolean, Number],
462
- required: false,
463
- default: void 0
464
- },
465
- popupRender: {
466
- type: Function,
467
- required: false,
468
- default: void 0
469
- },
470
- popupAlign: {
471
- type: Object,
472
- required: false,
473
- default: void 0
474
- },
475
- placement: {
476
- type: String,
477
- required: false,
478
- default: void 0
479
- },
480
- builtinPlacements: {
481
- type: Object,
482
- required: false,
483
- default: void 0
484
- },
485
- getPopupContainer: {
486
- type: Function,
487
- required: false,
488
- default: void 0
489
- },
490
- showAction: {
491
- type: Array,
492
- required: false,
493
- default: void 0
494
- },
495
- onBlur: {
496
- type: Function,
497
- required: false,
498
- default: void 0
499
- },
500
- onFocus: {
501
- type: Function,
502
- required: false,
503
- default: void 0
504
- },
505
- onKeyUp: {
506
- type: Function,
507
- required: false,
508
- default: void 0
509
- },
510
- onKeyDown: {
511
- type: Function,
512
- required: false,
513
- default: void 0
514
- },
515
- onMouseDown: {
516
- type: Function,
517
- required: false,
518
- default: void 0
519
- },
520
- onPopupScroll: {
521
- type: Function,
522
- required: false,
523
- default: void 0
524
- },
525
- onInputKeyDown: {
526
- type: Function,
527
- required: false,
528
- default: void 0
529
- },
530
- onMouseEnter: {
531
- type: Function,
532
- required: false,
533
- default: void 0
534
- },
535
- onMouseLeave: {
536
- type: Function,
537
- required: false,
538
- default: void 0
539
- },
540
- onClick: {
541
- type: Function,
542
- required: false,
543
- default: void 0
544
- },
545
- components: {
546
- type: Object,
547
- required: false,
548
- default: void 0
549
- }
550
- }, {
551
- prefixCls: "vc-select",
552
- popupMatchSelectWidth: true,
553
- listHeight: 200,
554
- listItemHeight: 20
555
- }),
556
- name: "VcSelect",
557
- inheritAttrs: false,
558
- setup(props, { attrs, expose, slots }) {
559
- const baseSelectRef = (0, vue.shallowRef)(null);
560
- expose({
561
- focus: () => baseSelectRef.value?.focus(),
562
- blur: () => baseSelectRef.value?.blur(),
563
- scrollTo: (arg) => baseSelectRef.value?.scrollTo?.(arg)
564
- });
565
- const mergedId = (0, _v_c_util_dist_hooks_useId.default)(props.id);
566
- const multiple = (0, vue.computed)(() => require_index.isMultiple(props.mode));
567
- const [mergedShowSearch, searchConfig] = require_useSearchConfig.default((0, vue.toRef)(props, "showSearch"), {
568
- filterOption: (0, vue.toRef)(props, "filterOption"),
569
- searchValue: (0, vue.toRef)(props, "searchValue"),
570
- optionFilterProp: (0, vue.toRef)(props, "optionFilterProp"),
571
- filterSort: (0, vue.toRef)(props, "filterSort"),
572
- onSearch: (0, vue.toRef)(props, "onSearch"),
573
- autoClearSearchValue: (0, vue.toRef)(props, "autoClearSearchValue")
574
- }, (0, vue.toRef)(props, "mode"));
575
- const mergedFilterOption = (0, vue.computed)(() => {
576
- if (searchConfig.value.filterOption === void 0 && props.mode === "combobox") return false;
577
- return searchConfig.value.filterOption;
578
- });
579
- const mergedFieldNames = (0, vue.computed)(() => require_valueUtil.fillFieldNames(props.fieldNames, false));
580
- const internalSearchValue = (0, vue.shallowRef)(props.searchValue || "");
581
- (0, vue.watch)(() => props.searchValue, (val) => {
582
- if (val !== void 0) internalSearchValue.value = val;
583
- });
584
- const setSearchValue = (val) => {
585
- internalSearchValue.value = val;
586
- };
587
- const mergedSearchValue = (0, vue.computed)(() => internalSearchValue.value || "");
588
- const childrenOptionsRef = (0, vue.shallowRef)([]);
589
- const parsedOptions = require_useOptions.default((0, vue.toRef)(props, "options"), childrenOptionsRef, mergedFieldNames, (0, vue.toRef)(props, "optionFilterProp"), (0, vue.toRef)(props, "optionLabelProp"));
590
- const valueOptions = (0, vue.computed)(() => parsedOptions.value.valueOptions);
591
- const labelOptions = (0, vue.computed)(() => parsedOptions.value.labelOptions);
592
- const mergedOptions = (0, vue.computed)(() => parsedOptions.value.options);
593
- const convert2LabelValues = (draftValues) => {
594
- return require_commonUtil.toArray(draftValues).map((val) => {
595
- let rawValue;
596
- let rawLabel;
597
- let rawDisabled;
598
- let rawTitle;
599
- if (isRawValue(val)) rawValue = val;
600
- else {
601
- rawLabel = val.label;
602
- rawValue = val.value;
603
- }
604
- const option = valueOptions.value.get(rawValue);
605
- if (option) {
606
- if (rawLabel === void 0) rawLabel = option?.[props.optionLabelProp || mergedFieldNames.value.label];
607
- rawDisabled = option?.disabled;
608
- rawTitle = option?.title;
609
- }
610
- return {
611
- label: rawLabel,
612
- value: rawValue,
613
- key: rawValue,
614
- disabled: rawDisabled,
615
- title: rawTitle
616
- };
617
- });
618
- };
619
- const internalValue = (0, vue.shallowRef)(props?.value ?? props.defaultValue);
620
- (0, vue.watch)(() => props.value, (val) => {
621
- if (val !== internalValue.value) internalValue.value = val;
622
- });
623
- const setInternalValue = (val) => {
624
- internalValue.value = val;
625
- };
626
- const [mergedValues, getMixedOption] = require_useCache.default((0, vue.computed)(() => {
627
- const values = convert2LabelValues(multiple.value && internalValue.value === null ? [] : internalValue.value);
628
- if (props.mode === "combobox" && require_commonUtil.isComboNoValue(values[0]?.value)) return [];
629
- return values;
630
- }), valueOptions);
631
- const displayValues = (0, vue.computed)(() => {
632
- if (!props.mode && mergedValues.value.length === 1) {
633
- const firstValue = mergedValues.value[0];
634
- if (firstValue.value === null && (firstValue.label === null || firstValue.label === void 0)) return [];
635
- }
636
- return mergedValues.value.map((item) => ({
637
- ...item,
638
- label: (typeof props.labelRender === "function" ? props.labelRender(item) : item.label) ?? item.value
639
- }));
640
- });
641
- const rawValues = (0, vue.computed)(() => new Set(mergedValues.value.map((val) => val.value)));
642
- (0, vue.watch)(mergedValues, () => {
643
- if (props.mode === "combobox") {
644
- const strValue = mergedValues.value[0]?.value;
645
- setSearchValue(require_commonUtil.hasValue(strValue) ? String(strValue) : "");
646
- }
647
- });
648
- const createTagOption = require_useRefFunc.default((val, label) => {
649
- const mergedLabel = label ?? val;
650
- return {
651
- [mergedFieldNames.value.value]: val,
652
- [mergedFieldNames.value.label]: mergedLabel
653
- };
654
- });
655
- const filteredOptions = require_useFilterOptions.default((0, vue.computed)(() => {
656
- if (props.mode !== "tags") return mergedOptions.value;
657
- const cloneOptions = [...mergedOptions.value];
658
- const existOptions = (val) => valueOptions.value.has(val);
659
- [...mergedValues.value].sort((a, b) => a.value < b.value ? -1 : 1).forEach((item) => {
660
- const val = item.value;
661
- if (!existOptions(val)) cloneOptions.push(createTagOption(val, item.label));
662
- });
663
- return cloneOptions;
664
- }), mergedFieldNames, mergedSearchValue, mergedFilterOption, (0, vue.toRef)(props, "optionFilterProp"));
665
- const filledSearchOptions = (0, vue.computed)(() => {
666
- if (props.mode !== "tags" || !mergedSearchValue.value || filteredOptions.value.some((item) => item[props.optionFilterProp || "value"] === mergedSearchValue.value)) return filteredOptions.value;
667
- if (filteredOptions.value.some((item) => item[mergedFieldNames.value.value] === mergedSearchValue.value)) return filteredOptions.value;
668
- return [createTagOption(mergedSearchValue.value), ...filteredOptions.value];
669
- });
670
- const sorter = (inputOptions) => {
671
- return [...inputOptions].sort((a, b) => searchConfig.value.filterSort(a, b, { searchValue: mergedSearchValue.value })).map((item) => {
672
- if (Array.isArray(item.options)) return {
673
- ...item,
674
- options: item.options.length > 0 ? sorter(item.options) : item.options
675
- };
676
- return item;
677
- });
678
- };
679
- const orderedFilteredOptions = (0, vue.computed)(() => {
680
- if (!searchConfig.value.filterSort) return filledSearchOptions.value;
681
- return sorter(filledSearchOptions.value);
682
- });
683
- const displayOptions = (0, vue.computed)(() => require_valueUtil.flattenOptions(orderedFilteredOptions.value, {
684
- fieldNames: mergedFieldNames.value,
685
- childrenAsData: false
686
- }));
687
- const triggerChange = (values) => {
688
- const labeledValues = convert2LabelValues(values);
689
- const prevValues = mergedValues.value;
690
- setInternalValue(labeledValues);
691
- const onChange = props.onChange;
692
- if (onChange && (labeledValues.length !== prevValues.length || labeledValues.some((newVal, index) => prevValues[index]?.value !== newVal?.value))) {
693
- const returnValues = props.labelInValue ? labeledValues.map(({ label: l, value: v }) => ({
694
- label: l,
695
- value: v
696
- })) : labeledValues.map((v) => v.value);
697
- const returnOptions = labeledValues.map((v) => require_valueUtil.injectPropsWithOption(getMixedOption(v.value)));
698
- onChange(multiple.value ? returnValues : returnValues[0], multiple.value ? returnOptions : returnOptions[0]);
699
- }
700
- };
701
- const activeValue = (0, vue.shallowRef)(null);
702
- const accessibilityIndex = (0, vue.shallowRef)(0);
703
- const mergedDefaultActiveFirstOption = (0, vue.computed)(() => props.defaultActiveFirstOption !== void 0 ? props.defaultActiveFirstOption : props.mode !== "combobox");
704
- const onActiveValue = (active, index, { source = "keyboard" } = {}) => {
705
- accessibilityIndex.value = index;
706
- if (props.backfill && props.mode === "combobox" && active !== null && source === "keyboard") activeValue.value = String(active);
707
- props.onActive?.(active);
708
- };
709
- const triggerSelect = (val, selected, type) => {
710
- const getSelectEnt = () => {
711
- const option = getMixedOption(val);
712
- return [props.labelInValue ? {
713
- label: option?.[mergedFieldNames.value.label],
714
- value: val
715
- } : val, require_valueUtil.injectPropsWithOption(option)];
716
- };
717
- if (selected && props.onSelect) {
718
- const [wrappedValue, option] = getSelectEnt();
719
- props.onSelect(wrappedValue, option);
720
- } else if (!selected && props.onDeselect && type !== "clear") {
721
- const [wrappedValue, option] = getSelectEnt();
722
- props.onDeselect(wrappedValue, option);
723
- }
724
- };
725
- const onInternalSelect = require_useRefFunc.default((val, info) => {
726
- let cloneValues;
727
- const mergedSelect = multiple.value ? info.selected : true;
728
- if (mergedSelect) cloneValues = multiple.value ? [...mergedValues.value, val] : [val];
729
- else cloneValues = mergedValues.value.filter((v) => v.value !== val);
730
- triggerChange(cloneValues);
731
- triggerSelect(val, mergedSelect);
732
- if (props.mode === "combobox") activeValue.value = "";
733
- else if (!multiple.value || searchConfig.value.autoClearSearchValue) {
734
- setSearchValue("");
735
- activeValue.value = "";
736
- }
737
- });
738
- const onDisplayValuesChange = (nextValues, info) => {
739
- triggerChange(nextValues);
740
- const { type, values } = info;
741
- if (type === "remove" || type === "clear") values.forEach((item) => {
742
- triggerSelect(item.value, false, type);
743
- });
744
- };
745
- const onInternalSearch = (searchText, info) => {
746
- setSearchValue(searchText);
747
- activeValue.value = null;
748
- if (info.source === "submit") {
749
- const formatted = (searchText || "").trim();
750
- if (formatted) {
751
- triggerChange(Array.from(new Set([...rawValues.value, formatted])));
752
- triggerSelect(formatted, true);
753
- setSearchValue("");
754
- }
755
- return;
756
- }
757
- if (info.source !== "blur") {
758
- if (props.mode === "combobox") triggerChange(searchText);
759
- searchConfig.value.onSearch?.(searchText);
760
- }
761
- };
762
- const onInternalSearchSplit = (words) => {
763
- let patchValues = words;
764
- if (props.mode !== "tags") patchValues = words.map((word) => {
765
- return labelOptions.value.get(word)?.[mergedFieldNames.value.value];
766
- }).filter((val) => val !== void 0);
767
- const newRawValues = Array.from(new Set([...rawValues.value, ...patchValues]));
768
- triggerChange(newRawValues);
769
- newRawValues.forEach((newRawValue) => {
770
- triggerSelect(newRawValue, true);
771
- });
772
- };
773
- require_SelectContext.useSelectProvider((0, vue.computed)(() => {
774
- const realVirtual = props.virtual !== false && props.popupMatchSelectWidth !== false;
775
- return {
776
- ...parsedOptions.value,
777
- flattenOptions: displayOptions.value,
778
- onActiveValue,
779
- defaultActiveFirstOption: mergedDefaultActiveFirstOption.value,
780
- onSelect: onInternalSelect,
781
- menuItemSelectedIcon: props.menuItemSelectedIcon,
782
- rawValues: rawValues.value,
783
- fieldNames: mergedFieldNames.value,
784
- virtual: realVirtual,
785
- direction: props.direction,
786
- listHeight: props.listHeight,
787
- listItemHeight: props.listItemHeight,
788
- childrenAsData: false,
789
- maxCount: props.maxCount,
790
- optionRender: props.optionRender,
791
- classNames: props.classNames,
792
- styles: props.styles
793
- };
794
- }));
795
- let lastChildrenKey = "";
796
- return () => {
797
- if (!props.options || props.options.length === 0) {
798
- const newChildrenOptions = require_legacyUtil.convertChildrenToData((0, _v_c_util_dist_props_util.filterEmpty)(slots?.default?.() ?? []));
799
- const newKey = newChildrenOptions.map((o) => `${o.value}`).join(",");
800
- if (lastChildrenKey !== newKey) {
801
- lastChildrenKey = newKey;
802
- childrenOptionsRef.value = newChildrenOptions;
803
- }
804
- }
805
- const restAttrs = { ...attrs };
806
- const restProps = (0, _v_c_util_dist_omit.default)(props, omitKeyList);
807
- const { prefixCls, mode, classNames, styles, maxCount, placeholder, direction, popupMatchSelectWidth } = props;
808
- return (0, vue.createVNode)(require_index.BaseSelect, (0, vue.mergeProps)(restAttrs, restProps, {
809
- "placeholder": placeholder,
810
- "id": mergedId,
811
- "prefixCls": prefixCls,
812
- "ref": (el) => {
813
- baseSelectRef.value = el;
814
- },
815
- "omitDomProps": OMIT_DOM_PROPS,
816
- "mode": mode,
817
- "classNames": classNames,
818
- "styles": styles,
819
- "displayValues": displayValues.value,
820
- "onDisplayValuesChange": onDisplayValuesChange,
821
- "maxCount": maxCount,
822
- "direction": direction,
823
- "showSearch": mergedShowSearch.value,
824
- "searchValue": mergedSearchValue.value,
825
- "onSearch": onInternalSearch,
826
- "autoClearSearchValue": searchConfig.value.autoClearSearchValue,
827
- "onSearchSplit": onInternalSearchSplit,
828
- "popupMatchSelectWidth": popupMatchSelectWidth,
829
- "OptionList": require_OptionList.default,
830
- "emptyOptions": !displayOptions.value.length,
831
- "activeValue": activeValue.value || void 0,
832
- "activeDescendantId": `${mergedId}_list_${accessibilityIndex.value}`
833
- }), null);
834
- };
835
- }
836
- });
837
- var Select_default = Select;
838
- exports.default = Select_default;