@rockshin/tao-ui 0.0.13 → 0.0.14

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.
@@ -1,6 +1,6 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react/compiler-runtime";
3
- import { useCallback, useMemo, useRef, useState } from "react";
3
+ import { Fragment as external_react_Fragment, useCallback, useMemo, useRef, useState } from "react";
4
4
  import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
5
5
  import { cx } from "../../utils/semantic.js";
6
6
  import { MobileSelectDrawer } from "./mobile-select.js";
@@ -47,7 +47,7 @@ const PLACEMENT_MAP = {
47
47
  }
48
48
  };
49
49
  function Select(props) {
50
- const { options, value: valueProp, defaultValue, onChange, onSelect, onClear, placeholder, size, variant, disabled, status, showSearch, filterOption, searchValue: searchValueProp, onSearch, allowClear, loading, loadingIcon, notFoundContent = 'No results', prefix, suffixIcon, autoFocus, id, name, open: openProp, defaultOpen, onOpenChange, placement = 'bottomLeft', popupMatchSelectWidth = true, listHeight = 256, getPopupContainer, optionRender, labelRender, popupRender, mobile, className, style, classNames, styles } = props;
50
+ const { options, value: valueProp, defaultValue, onChange, onSelect, onDeselect, onClear, mode, placeholder, size, variant, disabled, status, showSearch, filterOption, searchValue: searchValueProp, onSearch, allowClear, loading, loadingIcon, notFoundContent = 'No results', prefix, suffixIcon, removeIcon, autoFocus, id, name, open: openProp, defaultOpen, onOpenChange, placement = 'bottomLeft', popupMatchSelectWidth = true, listHeight = 256, getPopupContainer, optionRender, labelRender, popupRender, tagRender, maxTagCount, maxTagPlaceholder, maxTagTextLength, maxCount, autoClearSearchValue = true, tokenSeparators, hideSelected, mobile, className, style, classNames, styles } = props;
51
51
  const ctx = useTaoConfig();
52
52
  const resolvedSize = size ?? ctx.size;
53
53
  const resolvedVariant = variant ?? ctx.variant;
@@ -55,9 +55,20 @@ function Select(props) {
55
55
  const autoMobile = useIsMobile();
56
56
  const isMobile = mobile ?? autoMobile;
57
57
  const triggerRef = useRef(null);
58
+ const inputRef = useRef(null);
59
+ const isMultiple = 'multiple' === mode || 'tags' === mode;
58
60
  const isValueControlled = void 0 !== valueProp;
59
- const [valueInternal, setValueInternal] = useState(defaultValue);
61
+ const [valueInternal, setValueInternal] = useState(isMultiple ? defaultValue ?? [] : defaultValue);
60
62
  const value = isValueControlled ? valueProp : valueInternal;
63
+ const valueArray = useMemo(()=>{
64
+ if (isMultiple) return value ?? [];
65
+ return value ? [
66
+ value
67
+ ] : [];
68
+ }, [
69
+ isMultiple,
70
+ value
71
+ ]);
61
72
  const isOpenControlled = void 0 !== openProp;
62
73
  const [openInternal, setOpenInternal] = useState(defaultOpen ?? false);
63
74
  const open = isOpenControlled ? openProp : openInternal;
@@ -65,75 +76,276 @@ function Select(props) {
65
76
  const [searchInternal, setSearchInternal] = useState('');
66
77
  const search = isSearchControlled ? searchValueProp : searchInternal;
67
78
  const [hovering, setHovering] = useState(false);
79
+ const suppressCloseRef = useRef(false);
68
80
  const allOptions = useMemo(()=>flattenOptions(options), [
69
81
  options
70
82
  ]);
71
83
  const handleValueChange = useCallback((next)=>{
72
- const opt = allOptions.find((o)=>o.value === next);
84
+ if (isMultiple) {
85
+ if (tokenSeparators && tokenSeparators.length > 0) {
86
+ const sep = tokenSeparators.find((s)=>next.includes(s));
87
+ if (sep) {
88
+ const tokens = next.split(sep).map((t)=>t.trim()).filter(Boolean);
89
+ const toAdd = tokens.filter((t_0)=>{
90
+ const opt = allOptions.find((o)=>o.value === t_0 || o.label === t_0);
91
+ return opt && !valueArray.includes(opt.value);
92
+ });
93
+ if (toAdd.length > 0) {
94
+ const nextArray = [
95
+ ...valueArray,
96
+ ...toAdd
97
+ ];
98
+ if (null != maxCount && nextArray.length > maxCount) return;
99
+ if (!isValueControlled) setValueInternal(nextArray);
100
+ const selectedOpts = nextArray.map((v)=>allOptions.find((o_0)=>o_0.value === v)).filter(Boolean);
101
+ onChange?.(nextArray, selectedOpts);
102
+ for (const v_0 of toAdd){
103
+ const opt_0 = allOptions.find((o_1)=>o_1.value === v_0);
104
+ if (opt_0) onSelect?.(v_0, opt_0);
105
+ }
106
+ }
107
+ return;
108
+ }
109
+ }
110
+ suppressCloseRef.current = true;
111
+ const current = valueArray;
112
+ const existed = current.includes(next);
113
+ const nextArray_0 = existed ? current.filter((v_1)=>v_1 !== next) : [
114
+ ...current,
115
+ next
116
+ ];
117
+ if (!existed && null != maxCount && nextArray_0.length > maxCount) return;
118
+ if (!isValueControlled) setValueInternal(nextArray_0);
119
+ const selectedOpts_0 = nextArray_0.map((v_2)=>allOptions.find((o_2)=>o_2.value === v_2)).filter(Boolean);
120
+ onChange?.(nextArray_0, selectedOpts_0);
121
+ const opt_1 = allOptions.find((o_3)=>o_3.value === next);
122
+ if (opt_1) if (existed) onDeselect?.(next, opt_1);
123
+ else onSelect?.(next, opt_1);
124
+ if (autoClearSearchValue && !isSearchControlled) setSearchInternal('');
125
+ return;
126
+ }
127
+ const opt_2 = allOptions.find((o_4)=>o_4.value === next);
73
128
  if (!isValueControlled) setValueInternal(next);
74
- onChange?.(next, opt);
75
- if (opt) onSelect?.(next, opt);
129
+ onChange?.(next, opt_2);
130
+ if (opt_2) onSelect?.(next, opt_2);
76
131
  }, [
77
- allOptions,
132
+ isMultiple,
133
+ valueArray,
134
+ maxCount,
135
+ tokenSeparators,
78
136
  isValueControlled,
137
+ allOptions,
79
138
  onChange,
80
- onSelect
139
+ onSelect,
140
+ onDeselect,
141
+ autoClearSearchValue,
142
+ isSearchControlled
81
143
  ]);
82
144
  const handleOpenChange = useCallback((next_0)=>{
145
+ if (isMultiple && !next_0 && suppressCloseRef.current) {
146
+ suppressCloseRef.current = false;
147
+ return;
148
+ }
149
+ suppressCloseRef.current = false;
83
150
  if (!isOpenControlled) setOpenInternal(next_0);
84
151
  if (!next_0 && !isSearchControlled) setSearchInternal('');
152
+ if (next_0 && showSearch && !isMobile) setTimeout(()=>inputRef.current?.focus(), 0);
85
153
  onOpenChange?.(next_0);
86
154
  }, [
155
+ isMultiple,
87
156
  isOpenControlled,
88
157
  isSearchControlled,
89
- onOpenChange
158
+ onOpenChange,
159
+ showSearch,
160
+ isMobile
90
161
  ]);
91
- const handleSearchChange = useCallback((v)=>{
92
- if (!isSearchControlled) setSearchInternal(v);
93
- onSearch?.(v);
162
+ const handleSearchChange = useCallback((v_3)=>{
163
+ if (!isSearchControlled) setSearchInternal(v_3);
164
+ onSearch?.(v_3);
94
165
  }, [
95
166
  isSearchControlled,
96
167
  onSearch
97
168
  ]);
169
+ const handleSearchKeyDown = useCallback((e)=>{
170
+ if (!isMultiple || !tokenSeparators || 0 === tokenSeparators.length) return;
171
+ const value_0 = e.target.value;
172
+ const sep_0 = tokenSeparators.find((s_0)=>value_0.includes(s_0));
173
+ if (!sep_0) return;
174
+ e.preventDefault();
175
+ handleValueChange(value_0);
176
+ if (!isSearchControlled) setSearchInternal('');
177
+ }, [
178
+ isMultiple,
179
+ tokenSeparators,
180
+ handleValueChange,
181
+ isSearchControlled
182
+ ]);
98
183
  const clearValue = useCallback(()=>{
99
- if (!isValueControlled) setValueInternal(void 0);
100
- onChange?.('', void 0);
184
+ if (isMultiple) {
185
+ if (!isValueControlled) setValueInternal([]);
186
+ onChange?.([], void 0);
187
+ } else {
188
+ if (!isValueControlled) setValueInternal(void 0);
189
+ onChange?.('', void 0);
190
+ }
101
191
  onClear?.();
102
192
  }, [
193
+ isMultiple,
103
194
  isValueControlled,
104
195
  onChange,
105
196
  onClear
106
197
  ]);
107
- const handleClear = useCallback((e)=>{
108
- e.stopPropagation();
198
+ const handleClear = useCallback((e_0)=>{
199
+ e_0.stopPropagation();
109
200
  clearValue();
110
201
  }, [
111
202
  clearValue
112
203
  ]);
204
+ const handleRemoveTag = useCallback((removedValue, e_1)=>{
205
+ e_1.stopPropagation();
206
+ e_1.preventDefault();
207
+ if (!isMultiple) return;
208
+ const nextArray_1 = valueArray.filter((v_4)=>v_4 !== removedValue);
209
+ if (!isValueControlled) setValueInternal(nextArray_1);
210
+ const selectedOpts_1 = nextArray_1.map((v_5)=>allOptions.find((o_5)=>o_5.value === v_5)).filter(Boolean);
211
+ onChange?.(nextArray_1, selectedOpts_1);
212
+ const opt_3 = allOptions.find((o_6)=>o_6.value === removedValue);
213
+ if (opt_3) onDeselect?.(removedValue, opt_3);
214
+ }, [
215
+ isMultiple,
216
+ valueArray,
217
+ isValueControlled,
218
+ allOptions,
219
+ onChange,
220
+ onDeselect
221
+ ]);
222
+ const handleMultiChange = useCallback((nextArray_2)=>{
223
+ if (!isValueControlled) setValueInternal(nextArray_2);
224
+ const selectedOpts_2 = nextArray_2.map((v_6)=>allOptions.find((o_7)=>o_7.value === v_6)).filter(Boolean);
225
+ onChange?.(nextArray_2, selectedOpts_2);
226
+ const prev = valueArray;
227
+ for (const v_7 of nextArray_2)if (!prev.includes(v_7)) {
228
+ const opt_4 = allOptions.find((o_8)=>o_8.value === v_7);
229
+ if (opt_4) onSelect?.(v_7, opt_4);
230
+ }
231
+ for (const v_8 of prev)if (!nextArray_2.includes(v_8)) {
232
+ const opt_5 = allOptions.find((o_9)=>o_9.value === v_8);
233
+ if (opt_5) onDeselect?.(v_8, opt_5);
234
+ }
235
+ }, [
236
+ valueArray,
237
+ isValueControlled,
238
+ allOptions,
239
+ onChange,
240
+ onSelect,
241
+ onDeselect
242
+ ]);
113
243
  const filteredOptions = useMemo(()=>{
114
- if (!showSearch || !search) return options;
244
+ let opts = options;
245
+ if (hideSelected && isMultiple && valueArray.length > 0) {
246
+ const filterSelected = (list)=>{
247
+ const result = [];
248
+ for (const o_10 of list)if (o_10.options) {
249
+ const kids = filterSelected(o_10.options);
250
+ if (kids.length) result.push({
251
+ ...o_10,
252
+ options: kids
253
+ });
254
+ } else if (!valueArray.includes(o_10.value)) result.push(o_10);
255
+ return result;
256
+ };
257
+ opts = filterSelected(opts);
258
+ }
259
+ if (!showSearch || !search) return opts;
115
260
  const fn = filterOption ?? defaultFilter;
116
- return filterTree(options, fn, search);
261
+ return filterTree(opts, fn, search);
117
262
  }, [
118
263
  options,
119
264
  search,
120
265
  showSearch,
121
- filterOption
266
+ filterOption,
267
+ hideSelected,
268
+ isMultiple,
269
+ valueArray
122
270
  ]);
123
271
  const allowClearEnabled = !!allowClear;
124
272
  const clearIcon = 'object' == typeof allowClear && allowClear.clearIcon || /*#__PURE__*/ jsx(CloseIcon, {});
125
- const showClearBtn = allowClearEnabled && !!value && !resolvedDisabled;
126
- const selectedOption = allOptions.find((o_0)=>o_0.value === value);
273
+ const showClearBtn = allowClearEnabled && (isMultiple ? valueArray.length > 0 : !!value) && !resolvedDisabled;
274
+ const selectedOption = useMemo(()=>!isMultiple && value ? allOptions.find((o_11)=>o_11.value === value) : void 0, [
275
+ isMultiple,
276
+ value,
277
+ allOptions
278
+ ]);
279
+ const selectedOptions = useMemo(()=>isMultiple ? valueArray.map((v_9)=>allOptions.find((o_12)=>o_12.value === v_9)).filter(Boolean) : [], [
280
+ isMultiple,
281
+ valueArray,
282
+ allOptions
283
+ ]);
127
284
  const statusProps = {
128
285
  'data-tao-error': 'error' === status || void 0,
129
286
  'data-tao-warning': 'warning' === status || void 0
130
287
  };
131
- const triggerLabel = selectedOption ? labelRender ? labelRender(selectedOption) : selectedOption.label : /*#__PURE__*/ jsx("span", {
132
- "data-tao-select-placeholder": "",
133
- className: cx(classNames?.placeholder),
134
- style: styles?.placeholder,
135
- children: placeholder
136
- });
288
+ const renderTags = ()=>{
289
+ if (!isMultiple || 0 === selectedOptions.length) return null;
290
+ let visible = selectedOptions;
291
+ let omitted = [];
292
+ if ('number' == typeof maxTagCount && maxTagCount < selectedOptions.length) {
293
+ visible = selectedOptions.slice(0, maxTagCount);
294
+ omitted = selectedOptions.slice(maxTagCount);
295
+ }
296
+ const truncateLabel = (opt_6)=>{
297
+ const raw = 'string' == typeof opt_6.label ? opt_6.label : String(opt_6.label);
298
+ if (null != maxTagTextLength && 'string' == typeof raw && raw.length > maxTagTextLength) return `${raw.slice(0, maxTagTextLength)}…`;
299
+ return opt_6.label;
300
+ };
301
+ return /*#__PURE__*/ jsxs(Fragment, {
302
+ children: [
303
+ visible.map((opt_7)=>{
304
+ const closable = !resolvedDisabled && !opt_7.disabled;
305
+ const tagNode = tagRender ? tagRender({
306
+ label: truncateLabel(opt_7),
307
+ value: opt_7.value,
308
+ closable,
309
+ disabled: !!opt_7.disabled,
310
+ onClose: (e_2)=>handleRemoveTag(opt_7.value, e_2)
311
+ }) : /*#__PURE__*/ jsxs("span", {
312
+ "data-tao-select-tag": "",
313
+ "data-tao-disabled": opt_7.disabled || void 0,
314
+ className: cx(classNames?.tag),
315
+ style: styles?.tag,
316
+ children: [
317
+ /*#__PURE__*/ jsx("span", {
318
+ "data-tao-select-tag-label": "",
319
+ className: cx(classNames?.tagLabel),
320
+ style: styles?.tagLabel,
321
+ children: truncateLabel(opt_7)
322
+ }),
323
+ closable && /*#__PURE__*/ jsx("span", {
324
+ "data-tao-select-tag-close": "",
325
+ className: cx(classNames?.tagClose),
326
+ style: styles?.tagClose,
327
+ role: "button",
328
+ "aria-label": `Remove ${'string' == typeof opt_7.label ? opt_7.label : opt_7.value}`,
329
+ onPointerDown: (e_3)=>e_3.stopPropagation(),
330
+ onClick: (e_4)=>handleRemoveTag(opt_7.value, e_4),
331
+ children: removeIcon ?? /*#__PURE__*/ jsx(CloseSmallIcon, {})
332
+ })
333
+ ]
334
+ }, opt_7.value);
335
+ return /*#__PURE__*/ jsx(external_react_Fragment, {
336
+ children: tagNode
337
+ }, opt_7.value);
338
+ }),
339
+ omitted.length > 0 && /*#__PURE__*/ jsx("span", {
340
+ "data-tao-select-tag": "",
341
+ "data-tao-select-tag-rest": "",
342
+ className: cx(classNames?.tagRest),
343
+ style: styles?.tagRest,
344
+ children: 'function' == typeof maxTagPlaceholder ? maxTagPlaceholder(omitted) : maxTagPlaceholder ?? `+${omitted.length}…`
345
+ })
346
+ ]
347
+ });
348
+ };
137
349
  const trailingIcons = /*#__PURE__*/ jsx("span", {
138
350
  "data-tao-select-icons": "",
139
351
  children: loading ? /*#__PURE__*/ jsx("span", {
@@ -144,12 +356,12 @@ function Select(props) {
144
356
  "data-tao-select-clear": "",
145
357
  className: cx(classNames?.clear),
146
358
  style: styles?.clear,
147
- onPointerDown: (e_0)=>e_0.stopPropagation(),
359
+ onPointerDown: (e_5)=>e_5.stopPropagation(),
148
360
  onClick: handleClear,
149
- onKeyDown: (e_1)=>{
150
- if ('Enter' === e_1.key || ' ' === e_1.key) {
151
- e_1.preventDefault();
152
- e_1.stopPropagation();
361
+ onKeyDown: (e_6)=>{
362
+ if ('Enter' === e_6.key || ' ' === e_6.key) {
363
+ e_6.preventDefault();
364
+ e_6.stopPropagation();
153
365
  clearValue();
154
366
  }
155
367
  },
@@ -167,8 +379,7 @@ function Select(props) {
167
379
  });
168
380
  if (isMobile) return /*#__PURE__*/ jsxs(Fragment, {
169
381
  children: [
170
- /*#__PURE__*/ jsxs("button", {
171
- type: "button",
382
+ /*#__PURE__*/ jsxs("div", {
172
383
  id: id,
173
384
  "data-tao-control": "",
174
385
  "data-tao-select": "",
@@ -176,14 +387,22 @@ function Select(props) {
176
387
  "data-tao-variant": resolvedVariant,
177
388
  "data-tao-disabled": resolvedDisabled || void 0,
178
389
  ...statusProps,
179
- disabled: resolvedDisabled,
180
390
  autoFocus: autoFocus,
391
+ role: "button",
392
+ tabIndex: resolvedDisabled ? void 0 : 0,
393
+ "aria-disabled": resolvedDisabled || void 0,
181
394
  className: cx(classNames?.root, className),
182
395
  style: {
183
396
  ...styles?.root,
184
397
  ...style
185
398
  },
186
399
  onClick: ()=>handleOpenChange(true),
400
+ onKeyDown: (e_7)=>{
401
+ if ('Enter' === e_7.key || ' ' === e_7.key) {
402
+ e_7.preventDefault();
403
+ handleOpenChange(true);
404
+ }
405
+ },
187
406
  onMouseEnter: ()=>setHovering(true),
188
407
  onMouseLeave: ()=>setHovering(false),
189
408
  children: [
@@ -193,13 +412,35 @@ function Select(props) {
193
412
  style: styles?.prefix,
194
413
  children: prefix
195
414
  }),
196
- selectedOption?.icon != null && /*#__PURE__*/ jsx("span", {
197
- "data-tao-select-value-icon": "",
198
- children: selectedOption.icon
199
- }),
200
- /*#__PURE__*/ jsx("span", {
201
- "data-tao-select-value": "",
202
- children: triggerLabel
415
+ isMultiple ? /*#__PURE__*/ jsx("span", {
416
+ "data-tao-select-values": "",
417
+ className: cx(classNames?.values),
418
+ style: styles?.values,
419
+ children: selectedOptions.length > 0 ? renderTags() : /*#__PURE__*/ jsx("span", {
420
+ "data-tao-select-placeholder": "",
421
+ className: cx(classNames?.placeholder),
422
+ style: styles?.placeholder,
423
+ children: placeholder
424
+ })
425
+ }) : /*#__PURE__*/ jsxs(Fragment, {
426
+ children: [
427
+ selectedOption?.icon != null && /*#__PURE__*/ jsx("span", {
428
+ "data-tao-select-value-icon": "",
429
+ children: selectedOption.icon
430
+ }),
431
+ selectedOption && labelRender ? /*#__PURE__*/ jsx("span", {
432
+ "data-tao-select-value": "",
433
+ children: labelRender(selectedOption)
434
+ }) : selectedOption ? /*#__PURE__*/ jsx("span", {
435
+ "data-tao-select-value": "",
436
+ children: 'string' == typeof selectedOption.label ? selectedOption.label : String(selectedOption.label)
437
+ }) : /*#__PURE__*/ jsx("span", {
438
+ "data-tao-select-placeholder": "",
439
+ className: cx(classNames?.placeholder),
440
+ style: styles?.placeholder,
441
+ children: placeholder
442
+ })
443
+ ]
203
444
  }),
204
445
  trailingIcons
205
446
  ]
@@ -210,11 +451,13 @@ function Select(props) {
210
451
  options: options,
211
452
  value: value,
212
453
  onChange: handleValueChange,
454
+ onMultiChange: handleMultiChange,
213
455
  placeholder: placeholder,
214
456
  showSearch: showSearch,
215
457
  filterOption: filterOption,
216
458
  notFoundContent: notFoundContent,
217
- optionRender: optionRender
459
+ optionRender: optionRender,
460
+ multiple: isMultiple
218
461
  })
219
462
  ]
220
463
  });
@@ -223,22 +466,27 @@ function Select(props) {
223
466
  ...styles?.popup
224
467
  };
225
468
  if ('number' == typeof popupMatchSelectWidth) contentStyle.width = popupMatchSelectWidth;
469
+ const radixValue = isMultiple ? '' : value || void 0;
226
470
  const resultCount = flattenOptions(filteredOptions).length;
471
+ const overMaxCount = isMultiple && null != maxCount && valueArray.length >= maxCount;
227
472
  let optIndex = 0;
228
- const renderItem = (opt_0)=>{
473
+ const renderItem = (opt_8)=>{
229
474
  const index = optIndex++;
230
- const textLabel = 'string' == typeof opt_0.label ? opt_0.label : String(opt_0.label);
475
+ const textLabel = 'string' == typeof opt_8.label ? opt_8.label : String(opt_8.label);
476
+ const isSelected = valueArray.includes(opt_8.value);
477
+ const itemDisabled = opt_8.disabled || !isSelected && overMaxCount;
231
478
  return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Item, {
232
- value: opt_0.value,
233
- disabled: opt_0.disabled,
479
+ value: opt_8.value,
480
+ disabled: itemDisabled,
234
481
  "data-tao-select-item": "",
235
- "data-tao-has-desc": null != opt_0.description || void 0,
482
+ "data-tao-has-desc": null != opt_8.description || void 0,
483
+ "data-tao-selected": isMultiple && isSelected ? '' : void 0,
236
484
  className: cx(classNames?.item),
237
485
  style: styles?.item,
238
486
  children: [
239
487
  optionRender ? /*#__PURE__*/ jsxs(Fragment, {
240
488
  children: [
241
- optionRender(opt_0, {
489
+ optionRender(opt_8, {
242
490
  index
243
491
  }),
244
492
  /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.ItemText, {
@@ -250,11 +498,11 @@ function Select(props) {
250
498
  ]
251
499
  }) : /*#__PURE__*/ jsxs(Fragment, {
252
500
  children: [
253
- null != opt_0.icon && /*#__PURE__*/ jsx("span", {
501
+ null != opt_8.icon && /*#__PURE__*/ jsx("span", {
254
502
  "data-tao-select-item-icon": "",
255
503
  className: cx(classNames?.itemIcon),
256
504
  style: styles?.itemIcon,
257
- children: opt_0.icon
505
+ children: opt_8.icon
258
506
  }),
259
507
  /*#__PURE__*/ jsxs("span", {
260
508
  "data-tao-select-item-main": "",
@@ -262,26 +510,29 @@ function Select(props) {
262
510
  style: styles?.itemLabel,
263
511
  children: [
264
512
  /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.ItemText, {
265
- children: opt_0.label
513
+ children: opt_8.label
266
514
  }),
267
- null != opt_0.description && /*#__PURE__*/ jsx("span", {
515
+ null != opt_8.description && /*#__PURE__*/ jsx("span", {
268
516
  "data-tao-select-item-desc": "",
269
517
  className: cx(classNames?.itemDesc),
270
518
  style: styles?.itemDesc,
271
- children: opt_0.description
519
+ children: opt_8.description
272
520
  })
273
521
  ]
274
522
  })
275
523
  ]
276
524
  }),
277
- /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.ItemIndicator, {
525
+ isMultiple ? isSelected && /*#__PURE__*/ jsx("span", {
526
+ "data-tao-select-check": "",
527
+ children: /*#__PURE__*/ jsx(CheckIcon, {})
528
+ }) : /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.ItemIndicator, {
278
529
  "data-tao-select-check": "",
279
530
  children: /*#__PURE__*/ jsx(CheckIcon, {})
280
531
  })
281
532
  ]
282
- }, opt_0.value);
533
+ }, opt_8.value);
283
534
  };
284
- const renderTree = (opts)=>opts.map((o_1)=>o_1.options ? /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Group, {
535
+ const renderTree = (opts_0)=>opts_0.map((o_13)=>o_13.options ? /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Group, {
285
536
  "data-tao-select-group": "",
286
537
  className: cx(classNames?.group),
287
538
  style: styles?.group,
@@ -290,91 +541,97 @@ function Select(props) {
290
541
  "data-tao-select-group-label": "",
291
542
  className: cx(classNames?.groupLabel),
292
543
  style: styles?.groupLabel,
293
- children: o_1.label
544
+ children: o_13.label
294
545
  }),
295
- o_1.options.map(renderItem)
546
+ o_13.options.map(renderItem)
296
547
  ]
297
- }, o_1.value) : renderItem(o_1));
298
- const menuNode = /*#__PURE__*/ jsxs(Fragment, {
299
- children: [
300
- showSearch && /*#__PURE__*/ jsxs("div", {
301
- "data-tao-select-search": "",
302
- className: cx(classNames?.search),
303
- style: styles?.search,
304
- children: [
305
- /*#__PURE__*/ jsx(SearchIcon, {}),
306
- /*#__PURE__*/ jsx("input", {
307
- "data-tao-select-search-input": "",
308
- value: search,
309
- onChange: (e_2)=>handleSearchChange(e_2.target.value),
310
- placeholder: "Search...",
311
- autoFocus: true
312
- })
313
- ]
314
- }),
315
- /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Viewport, {
316
- "data-tao-select-viewport": "",
317
- style: {
318
- maxHeight: listHeight
319
- },
320
- children: resultCount > 0 ? renderTree(filteredOptions) : /*#__PURE__*/ jsx("div", {
321
- "data-tao-select-empty": "",
322
- className: cx(classNames?.empty),
323
- style: styles?.empty,
324
- children: notFoundContent
325
- })
326
- })
327
- ]
548
+ }, o_13.value) : renderItem(o_13));
549
+ const menuNode = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Viewport, {
550
+ "data-tao-select-viewport": "",
551
+ style: {
552
+ maxHeight: listHeight
553
+ },
554
+ children: resultCount > 0 ? renderTree(filteredOptions) : /*#__PURE__*/ jsx("div", {
555
+ "data-tao-select-empty": "",
556
+ className: cx(classNames?.empty),
557
+ style: styles?.empty,
558
+ children: notFoundContent
559
+ })
328
560
  });
329
561
  const container = getPopupContainer && triggerRef.current ? getPopupContainer(triggerRef.current) : void 0;
330
562
  return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Root, {
331
- value: value || void 0,
563
+ value: radixValue,
332
564
  onValueChange: handleValueChange,
333
565
  disabled: resolvedDisabled,
334
566
  open: open,
335
567
  onOpenChange: handleOpenChange,
336
- name: name,
568
+ name: isMultiple ? void 0 : name,
337
569
  children: [
338
- /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Trigger, {
339
- ref: triggerRef,
340
- id: id,
341
- "data-tao-control": "",
342
- "data-tao-select": "",
343
- "data-tao-size": resolvedSize,
344
- "data-tao-variant": resolvedVariant,
345
- "data-tao-disabled": resolvedDisabled || void 0,
346
- ...statusProps,
347
- autoFocus: autoFocus,
348
- className: cx(classNames?.root, className),
349
- style: {
350
- ...styles?.root,
351
- ...style
352
- },
353
- onMouseEnter: ()=>setHovering(true),
354
- onMouseLeave: ()=>setHovering(false),
355
- children: [
356
- null != prefix && /*#__PURE__*/ jsx("span", {
357
- "data-tao-select-prefix": "",
358
- className: cx(classNames?.prefix),
359
- style: styles?.prefix,
360
- children: prefix
361
- }),
362
- selectedOption?.icon != null && /*#__PURE__*/ jsx("span", {
363
- "data-tao-select-value-icon": "",
364
- children: selectedOption.icon
365
- }),
366
- /*#__PURE__*/ jsx("span", {
367
- "data-tao-select-value": "",
368
- children: triggerLabel
369
- }),
370
- trailingIcons
371
- ]
570
+ /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Trigger, {
571
+ asChild: true,
572
+ children: /*#__PURE__*/ jsxs("div", {
573
+ ref: triggerRef,
574
+ id: id,
575
+ "data-tao-control": "",
576
+ "data-tao-select": "",
577
+ "data-tao-size": resolvedSize,
578
+ "data-tao-variant": resolvedVariant,
579
+ "data-tao-disabled": resolvedDisabled || void 0,
580
+ "data-tao-multiple": isMultiple || void 0,
581
+ ...statusProps,
582
+ className: cx(classNames?.root, className),
583
+ style: {
584
+ ...styles?.root,
585
+ ...style
586
+ },
587
+ onMouseEnter: ()=>setHovering(true),
588
+ onMouseLeave: ()=>setHovering(false),
589
+ children: [
590
+ null != prefix && /*#__PURE__*/ jsx("span", {
591
+ "data-tao-select-prefix": "",
592
+ className: cx(classNames?.prefix),
593
+ style: styles?.prefix,
594
+ children: prefix
595
+ }),
596
+ isMultiple ? /*#__PURE__*/ jsx("span", {
597
+ "data-tao-select-values": "",
598
+ className: cx(classNames?.values),
599
+ style: styles?.values,
600
+ children: selectedOptions.length > 0 ? renderTags() : /*#__PURE__*/ jsx("span", {
601
+ "data-tao-select-placeholder": "",
602
+ className: cx(classNames?.placeholder),
603
+ style: styles?.placeholder,
604
+ children: placeholder
605
+ })
606
+ }) : /*#__PURE__*/ jsxs(Fragment, {
607
+ children: [
608
+ selectedOption?.icon != null && /*#__PURE__*/ jsx("span", {
609
+ "data-tao-select-value-icon": "",
610
+ children: selectedOption.icon
611
+ }),
612
+ selectedOption && labelRender ? /*#__PURE__*/ jsx("span", {
613
+ "data-tao-select-value": "",
614
+ children: labelRender(selectedOption)
615
+ }) : selectedOption ? /*#__PURE__*/ jsx("span", {
616
+ "data-tao-select-value": "",
617
+ children: 'string' == typeof selectedOption.label ? selectedOption.label : String(selectedOption.label)
618
+ }) : /*#__PURE__*/ jsx("span", {
619
+ "data-tao-select-placeholder": "",
620
+ className: cx(classNames?.placeholder),
621
+ style: styles?.placeholder,
622
+ children: placeholder
623
+ })
624
+ ]
625
+ }),
626
+ trailingIcons
627
+ ]
628
+ })
372
629
  }),
373
630
  /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Portal, {
374
631
  container: container,
375
632
  children: /*#__PURE__*/ jsx(TaoPortalScope, {
376
633
  asChild: true,
377
- children: /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Content, {
634
+ children: /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Content, {
378
635
  "data-tao-select-content": "",
379
636
  "data-tao-popup-width": false === popupMatchSelectWidth ? 'content' : void 0,
380
637
  className: cx(classNames?.popup),
@@ -383,7 +640,34 @@ function Select(props) {
383
640
  side: side,
384
641
  align: align,
385
642
  sideOffset: 4,
386
- children: popupRender ? popupRender(menuNode) : menuNode
643
+ children: [
644
+ showSearch && !isMobile && /*#__PURE__*/ jsxs("div", {
645
+ "data-tao-select-search": "",
646
+ className: cx(classNames?.search),
647
+ style: styles?.search,
648
+ children: [
649
+ /*#__PURE__*/ jsx("span", {
650
+ "data-tao-select-search-icon": "",
651
+ children: /*#__PURE__*/ jsx(SearchIcon, {})
652
+ }),
653
+ /*#__PURE__*/ jsx("input", {
654
+ ref: inputRef,
655
+ "data-tao-select-search-input": "",
656
+ className: cx(classNames?.searchInput),
657
+ style: styles?.searchInput,
658
+ value: search,
659
+ onChange: (e_8)=>handleSearchChange(e_8.target.value),
660
+ onKeyDown: (e_9)=>{
661
+ e_9.stopPropagation();
662
+ handleSearchKeyDown(e_9);
663
+ },
664
+ placeholder: "Search...",
665
+ autoComplete: "off"
666
+ })
667
+ ]
668
+ }),
669
+ popupRender ? popupRender(menuNode) : menuNode
670
+ ]
387
671
  })
388
672
  })
389
673
  })
@@ -485,6 +769,30 @@ function CloseIcon() {
485
769
  } else t0 = $[0];
486
770
  return t0;
487
771
  }
772
+ function CloseSmallIcon() {
773
+ const $ = c(1);
774
+ let t0;
775
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
776
+ t0 = /*#__PURE__*/ jsx("svg", {
777
+ width: "10",
778
+ height: "10",
779
+ viewBox: "0 0 24 24",
780
+ fill: "none",
781
+ stroke: "currentColor",
782
+ strokeWidth: "2.5",
783
+ strokeLinecap: "round",
784
+ strokeLinejoin: "round",
785
+ "aria-hidden": "true",
786
+ focusable: "false",
787
+ role: "presentation",
788
+ children: /*#__PURE__*/ jsx("path", {
789
+ d: "M18 6 6 18M6 6l12 12"
790
+ })
791
+ });
792
+ $[0] = t0;
793
+ } else t0 = $[0];
794
+ return t0;
795
+ }
488
796
  function SearchIcon() {
489
797
  const $ = c(1);
490
798
  let t0;
@@ -541,4 +849,4 @@ function LoadingIcon() {
541
849
  } else t0 = $[0];
542
850
  return t0;
543
851
  }
544
- export { ChevronsUpDownIcon, Select };
852
+ export { ChevronsUpDownIcon, SearchIcon, Select };