@rockshin/tao-ui 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -5
- package/dist/components/collapsible/collapsible.js +4 -4
- package/dist/components/context-menu/context-menu.js +17 -17
- package/dist/components/date-picker/date-picker.css +40 -11
- package/dist/components/date-picker/date-picker.js +517 -380
- package/dist/components/date-picker/range-picker.d.ts +1 -1
- package/dist/components/date-picker/range-picker.js +166 -46
- package/dist/components/drawer/drawer.css +5 -5
- package/dist/components/drawer/drawer.js +7 -7
- package/dist/components/dropdown/dropdown.js +18 -18
- package/dist/components/input/input.css +4 -0
- package/dist/components/modal/modal.css +5 -3
- package/dist/components/modal/modal.js +7 -7
- package/dist/components/scroll-area/scroll-area.css +4 -4
- package/dist/components/select/mobile-select.css +1 -1
- package/dist/components/select/select.css +72 -0
- package/dist/components/select/select.js +326 -30
- package/dist/components/table/table.css +8 -6
- package/dist/components/tag/tag.css +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/provider/tao-provider.d.ts +13 -0
- package/dist/provider/tao-provider.js +79 -58
- package/dist/theme/theme.css +48 -8
- package/dist/theme/tokens.d.ts +2 -2
- package/dist/theme/tokens.js +5 -0
- package/package.json +10 -8
|
@@ -35,6 +35,42 @@
|
|
|
35
35
|
overflow: hidden;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
[data-tao-select-search-trigger] {
|
|
39
|
+
flex: 1;
|
|
40
|
+
align-items: center;
|
|
41
|
+
min-width: 0;
|
|
42
|
+
display: grid;
|
|
43
|
+
position: relative;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[data-tao-select-trigger-input], [data-tao-select-trigger-value] {
|
|
47
|
+
grid-area: 1 / 1;
|
|
48
|
+
min-width: 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[data-tao-select-trigger-input] {
|
|
52
|
+
width: 100%;
|
|
53
|
+
font: inherit;
|
|
54
|
+
line-height: inherit;
|
|
55
|
+
color: var(--tao-color-text);
|
|
56
|
+
cursor: text;
|
|
57
|
+
background: none;
|
|
58
|
+
border: 0;
|
|
59
|
+
outline: 0;
|
|
60
|
+
padding: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[data-tao-select-trigger-input]::placeholder {
|
|
64
|
+
color: var(--tao-color-text-placeholder);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[data-tao-select-trigger-value] {
|
|
68
|
+
text-overflow: ellipsis;
|
|
69
|
+
white-space: nowrap;
|
|
70
|
+
pointer-events: none;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
}
|
|
73
|
+
|
|
38
74
|
[data-tao-select-placeholder] {
|
|
39
75
|
color: var(--tao-color-text-placeholder);
|
|
40
76
|
line-height: var(--tao-select-line-height);
|
|
@@ -113,6 +149,21 @@
|
|
|
113
149
|
display: flex;
|
|
114
150
|
}
|
|
115
151
|
|
|
152
|
+
button[data-tao-select-clear] {
|
|
153
|
+
font: inherit;
|
|
154
|
+
background: none;
|
|
155
|
+
border: 0;
|
|
156
|
+
padding: 0;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
[data-tao-select][data-tao-inline-search] [data-tao-select-icons][data-tao-clearable] [data-tao-select-clear], [data-tao-select][data-tao-inline-search]:hover [data-tao-select-icons][data-tao-clearable] [data-tao-select-icon] {
|
|
160
|
+
display: none;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
[data-tao-select][data-tao-inline-search]:hover [data-tao-select-icons][data-tao-clearable] [data-tao-select-clear] {
|
|
164
|
+
display: flex;
|
|
165
|
+
}
|
|
166
|
+
|
|
116
167
|
[data-tao-select-icon] {
|
|
117
168
|
color: var(--tao-color-text-tertiary);
|
|
118
169
|
transition: transform var(--tao-motion-duration-fast)
|
|
@@ -154,6 +205,7 @@
|
|
|
154
205
|
|
|
155
206
|
[data-tao-select][data-disabled] {
|
|
156
207
|
cursor: not-allowed;
|
|
208
|
+
pointer-events: none;
|
|
157
209
|
}
|
|
158
210
|
|
|
159
211
|
[data-tao-select-content] {
|
|
@@ -226,6 +278,17 @@
|
|
|
226
278
|
margin-block-start: var(--tao-padding-xxs);
|
|
227
279
|
}
|
|
228
280
|
|
|
281
|
+
fieldset[data-tao-select-group] {
|
|
282
|
+
border: 0;
|
|
283
|
+
min-inline-size: 0;
|
|
284
|
+
margin-inline: 0;
|
|
285
|
+
padding: 0;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
legend[data-tao-select-group-label] {
|
|
289
|
+
width: 100%;
|
|
290
|
+
}
|
|
291
|
+
|
|
229
292
|
[data-tao-select-group-label] {
|
|
230
293
|
padding: var(--tao-padding-xs) var(--tao-padding-sm) var(--tao-padding-xxs);
|
|
231
294
|
font-size: var(--tao-font-size-xs);
|
|
@@ -236,17 +299,21 @@
|
|
|
236
299
|
}
|
|
237
300
|
|
|
238
301
|
[data-tao-select-item] {
|
|
302
|
+
width: 100%;
|
|
239
303
|
min-height: var(--tao-control-height);
|
|
240
304
|
padding-inline: var(--tao-padding-sm);
|
|
241
305
|
font-size: var(--tao-font-size-base);
|
|
242
306
|
font-family: var(--tao-font-family);
|
|
243
307
|
color: var(--tao-color-text);
|
|
308
|
+
text-align: start;
|
|
244
309
|
border-radius: var(--tao-radius-sm);
|
|
245
310
|
cursor: pointer;
|
|
246
311
|
-webkit-user-select: none;
|
|
247
312
|
user-select: none;
|
|
248
313
|
transition: background-color var(--tao-motion-duration-fast)
|
|
249
314
|
var(--tao-motion-ease-out);
|
|
315
|
+
background: none;
|
|
316
|
+
border: 0;
|
|
250
317
|
outline: none;
|
|
251
318
|
align-items: center;
|
|
252
319
|
line-height: 1;
|
|
@@ -344,6 +411,11 @@
|
|
|
344
411
|
display: flex;
|
|
345
412
|
}
|
|
346
413
|
|
|
414
|
+
[data-tao-select][data-tao-inline-search][data-tao-multiple] [data-tao-select-trigger-input] {
|
|
415
|
+
flex: 1 0 4ch;
|
|
416
|
+
width: 4ch;
|
|
417
|
+
}
|
|
418
|
+
|
|
347
419
|
[data-tao-select-tag] {
|
|
348
420
|
max-width: 160px;
|
|
349
421
|
font-size: var(--tao-font-size-sm);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react/compiler-runtime";
|
|
3
|
-
import { Fragment as external_react_Fragment, useCallback, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Fragment as external_react_Fragment, useCallback, useId, 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";
|
|
7
7
|
import "./select.css";
|
|
8
8
|
import { useIsMobile } from "./use-is-mobile.js";
|
|
9
|
-
import * as
|
|
9
|
+
import * as __rspack_external__radix_ui_react_popover_c8444160 from "@radix-ui/react-popover";
|
|
10
|
+
import * as __rspack_external__radix_ui_react_select_4606f4d3 from "@radix-ui/react-select";
|
|
10
11
|
const defaultFilter = (input, option)=>{
|
|
11
12
|
const label = 'string' == typeof option.label ? option.label : String(option.label);
|
|
12
13
|
return label.toLowerCase().includes(input.toLowerCase());
|
|
@@ -56,7 +57,9 @@ function Select(props) {
|
|
|
56
57
|
const isMobile = mobile ?? autoMobile;
|
|
57
58
|
const triggerRef = useRef(null);
|
|
58
59
|
const inputRef = useRef(null);
|
|
60
|
+
const searchListboxId = useId();
|
|
59
61
|
const isMultiple = 'multiple' === mode || 'tags' === mode;
|
|
62
|
+
const hasInlineSearch = !!showSearch && !isMobile;
|
|
60
63
|
const isValueControlled = void 0 !== valueProp;
|
|
61
64
|
const [valueInternal, setValueInternal] = useState(isMultiple ? defaultValue ?? [] : defaultValue);
|
|
62
65
|
const value = isValueControlled ? valueProp : valueInternal;
|
|
@@ -75,6 +78,7 @@ function Select(props) {
|
|
|
75
78
|
const isSearchControlled = void 0 !== searchValueProp;
|
|
76
79
|
const [searchInternal, setSearchInternal] = useState('');
|
|
77
80
|
const search = isSearchControlled ? searchValueProp : searchInternal;
|
|
81
|
+
const [activeSearchIndex, setActiveSearchIndex] = useState(0);
|
|
78
82
|
const [hovering, setHovering] = useState(false);
|
|
79
83
|
const suppressCloseRef = useRef(false);
|
|
80
84
|
const allOptions = useMemo(()=>flattenOptions(options), [
|
|
@@ -107,7 +111,7 @@ function Select(props) {
|
|
|
107
111
|
return;
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
|
-
suppressCloseRef.current = true;
|
|
114
|
+
if (!hasInlineSearch) suppressCloseRef.current = true;
|
|
111
115
|
const current = valueArray;
|
|
112
116
|
const existed = current.includes(next);
|
|
113
117
|
const nextArray_0 = existed ? current.filter((v_1)=>v_1 !== next) : [
|
|
@@ -130,6 +134,7 @@ function Select(props) {
|
|
|
130
134
|
if (opt_2) onSelect?.(next, opt_2);
|
|
131
135
|
}, [
|
|
132
136
|
isMultiple,
|
|
137
|
+
hasInlineSearch,
|
|
133
138
|
valueArray,
|
|
134
139
|
maxCount,
|
|
135
140
|
tokenSeparators,
|
|
@@ -142,7 +147,7 @@ function Select(props) {
|
|
|
142
147
|
isSearchControlled
|
|
143
148
|
]);
|
|
144
149
|
const handleOpenChange = useCallback((next_0)=>{
|
|
145
|
-
if (isMultiple && !next_0 && suppressCloseRef.current) {
|
|
150
|
+
if (isMultiple && !hasInlineSearch && !next_0 && suppressCloseRef.current) {
|
|
146
151
|
suppressCloseRef.current = false;
|
|
147
152
|
return;
|
|
148
153
|
}
|
|
@@ -153,6 +158,7 @@ function Select(props) {
|
|
|
153
158
|
onOpenChange?.(next_0);
|
|
154
159
|
}, [
|
|
155
160
|
isMultiple,
|
|
161
|
+
hasInlineSearch,
|
|
156
162
|
isOpenControlled,
|
|
157
163
|
isSearchControlled,
|
|
158
164
|
onOpenChange,
|
|
@@ -276,10 +282,14 @@ function Select(props) {
|
|
|
276
282
|
value,
|
|
277
283
|
allOptions
|
|
278
284
|
]);
|
|
279
|
-
const selectedOptions = useMemo(()=>isMultiple ? valueArray.map((v_9)=>allOptions.find((o_12)=>o_12.value === v_9)
|
|
285
|
+
const selectedOptions = useMemo(()=>isMultiple ? valueArray.map((v_9)=>allOptions.find((o_12)=>o_12.value === v_9) ?? ('tags' === mode ? {
|
|
286
|
+
label: v_9,
|
|
287
|
+
value: v_9
|
|
288
|
+
} : void 0)).filter(Boolean) : [], [
|
|
280
289
|
isMultiple,
|
|
281
290
|
valueArray,
|
|
282
|
-
allOptions
|
|
291
|
+
allOptions,
|
|
292
|
+
mode
|
|
283
293
|
]);
|
|
284
294
|
const statusProps = {
|
|
285
295
|
'data-tao-error': 'error' === status || void 0,
|
|
@@ -325,9 +335,13 @@ function Select(props) {
|
|
|
325
335
|
className: cx(classNames?.tagClose),
|
|
326
336
|
style: styles?.tagClose,
|
|
327
337
|
role: "button",
|
|
338
|
+
tabIndex: 0,
|
|
328
339
|
"aria-label": `Remove ${'string' == typeof opt_7.label ? opt_7.label : opt_7.value}`,
|
|
329
340
|
onPointerDown: (e_3)=>e_3.stopPropagation(),
|
|
330
341
|
onClick: (e_4)=>handleRemoveTag(opt_7.value, e_4),
|
|
342
|
+
onKeyDown: (e_5)=>{
|
|
343
|
+
if ('Enter' === e_5.key || ' ' === e_5.key) handleRemoveTag(opt_7.value, e_5);
|
|
344
|
+
},
|
|
331
345
|
children: removeIcon ?? /*#__PURE__*/ jsx(CloseSmallIcon, {})
|
|
332
346
|
})
|
|
333
347
|
]
|
|
@@ -356,12 +370,12 @@ function Select(props) {
|
|
|
356
370
|
"data-tao-select-clear": "",
|
|
357
371
|
className: cx(classNames?.clear),
|
|
358
372
|
style: styles?.clear,
|
|
359
|
-
onPointerDown: (
|
|
373
|
+
onPointerDown: (e_6)=>e_6.stopPropagation(),
|
|
360
374
|
onClick: handleClear,
|
|
361
|
-
onKeyDown: (
|
|
362
|
-
if ('Enter' ===
|
|
363
|
-
|
|
364
|
-
|
|
375
|
+
onKeyDown: (e_7)=>{
|
|
376
|
+
if ('Enter' === e_7.key || ' ' === e_7.key) {
|
|
377
|
+
e_7.preventDefault();
|
|
378
|
+
e_7.stopPropagation();
|
|
365
379
|
clearValue();
|
|
366
380
|
}
|
|
367
381
|
},
|
|
@@ -377,6 +391,35 @@ function Select(props) {
|
|
|
377
391
|
children: suffixIcon ?? /*#__PURE__*/ jsx(ChevronDownIcon, {})
|
|
378
392
|
})
|
|
379
393
|
});
|
|
394
|
+
const searchableTrailingIcons = /*#__PURE__*/ jsx("span", {
|
|
395
|
+
"data-tao-select-icons": "",
|
|
396
|
+
"data-tao-clearable": showClearBtn || void 0,
|
|
397
|
+
children: loading ? /*#__PURE__*/ jsx("span", {
|
|
398
|
+
"data-tao-select-icon": "",
|
|
399
|
+
"data-tao-select-loading-slot": "",
|
|
400
|
+
children: loadingIcon ?? /*#__PURE__*/ jsx(LoadingIcon, {})
|
|
401
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
402
|
+
children: [
|
|
403
|
+
showClearBtn && /*#__PURE__*/ jsx("button", {
|
|
404
|
+
type: "button",
|
|
405
|
+
"data-tao-select-clear": "",
|
|
406
|
+
className: cx(classNames?.clear),
|
|
407
|
+
style: styles?.clear,
|
|
408
|
+
onPointerDown: (event)=>event.stopPropagation(),
|
|
409
|
+
onClick: handleClear,
|
|
410
|
+
"aria-label": "Clear",
|
|
411
|
+
children: clearIcon
|
|
412
|
+
}),
|
|
413
|
+
/*#__PURE__*/ jsx("span", {
|
|
414
|
+
"data-tao-select-icon": "",
|
|
415
|
+
"data-tao-custom-suffix": null != suffixIcon || void 0,
|
|
416
|
+
className: cx(classNames?.suffix),
|
|
417
|
+
style: styles?.suffix,
|
|
418
|
+
children: suffixIcon ?? /*#__PURE__*/ jsx(ChevronDownIcon, {})
|
|
419
|
+
})
|
|
420
|
+
]
|
|
421
|
+
})
|
|
422
|
+
});
|
|
380
423
|
if (isMobile) return /*#__PURE__*/ jsxs(Fragment, {
|
|
381
424
|
children: [
|
|
382
425
|
/*#__PURE__*/ jsxs("div", {
|
|
@@ -397,9 +440,9 @@ function Select(props) {
|
|
|
397
440
|
...style
|
|
398
441
|
},
|
|
399
442
|
onClick: ()=>handleOpenChange(true),
|
|
400
|
-
onKeyDown: (
|
|
401
|
-
if ('Enter' ===
|
|
402
|
-
|
|
443
|
+
onKeyDown: (e_8)=>{
|
|
444
|
+
if ('Enter' === e_8.key || ' ' === e_8.key) {
|
|
445
|
+
e_8.preventDefault();
|
|
403
446
|
handleOpenChange(true);
|
|
404
447
|
}
|
|
405
448
|
},
|
|
@@ -475,7 +518,7 @@ function Select(props) {
|
|
|
475
518
|
const textLabel = 'string' == typeof opt_8.label ? opt_8.label : String(opt_8.label);
|
|
476
519
|
const isSelected = valueArray.includes(opt_8.value);
|
|
477
520
|
const itemDisabled = opt_8.disabled || !isSelected && overMaxCount;
|
|
478
|
-
return /*#__PURE__*/ jsxs(
|
|
521
|
+
return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_4606f4d3.Item, {
|
|
479
522
|
value: opt_8.value,
|
|
480
523
|
disabled: itemDisabled,
|
|
481
524
|
"data-tao-select-item": "",
|
|
@@ -489,7 +532,7 @@ function Select(props) {
|
|
|
489
532
|
optionRender(opt_8, {
|
|
490
533
|
index
|
|
491
534
|
}),
|
|
492
|
-
/*#__PURE__*/ jsx(
|
|
535
|
+
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.ItemText, {
|
|
493
536
|
style: {
|
|
494
537
|
display: 'none'
|
|
495
538
|
},
|
|
@@ -509,7 +552,7 @@ function Select(props) {
|
|
|
509
552
|
className: cx(classNames?.itemLabel),
|
|
510
553
|
style: styles?.itemLabel,
|
|
511
554
|
children: [
|
|
512
|
-
/*#__PURE__*/ jsx(
|
|
555
|
+
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.ItemText, {
|
|
513
556
|
children: opt_8.label
|
|
514
557
|
}),
|
|
515
558
|
null != opt_8.description && /*#__PURE__*/ jsx("span", {
|
|
@@ -525,19 +568,19 @@ function Select(props) {
|
|
|
525
568
|
isMultiple ? isSelected && /*#__PURE__*/ jsx("span", {
|
|
526
569
|
"data-tao-select-check": "",
|
|
527
570
|
children: /*#__PURE__*/ jsx(CheckIcon, {})
|
|
528
|
-
}) : /*#__PURE__*/ jsx(
|
|
571
|
+
}) : /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.ItemIndicator, {
|
|
529
572
|
"data-tao-select-check": "",
|
|
530
573
|
children: /*#__PURE__*/ jsx(CheckIcon, {})
|
|
531
574
|
})
|
|
532
575
|
]
|
|
533
576
|
}, opt_8.value);
|
|
534
577
|
};
|
|
535
|
-
const renderTree = (opts_0)=>opts_0.map((o_13)=>o_13.options ? /*#__PURE__*/ jsxs(
|
|
578
|
+
const renderTree = (opts_0)=>opts_0.map((o_13)=>o_13.options ? /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_4606f4d3.Group, {
|
|
536
579
|
"data-tao-select-group": "",
|
|
537
580
|
className: cx(classNames?.group),
|
|
538
581
|
style: styles?.group,
|
|
539
582
|
children: [
|
|
540
|
-
/*#__PURE__*/ jsx(
|
|
583
|
+
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.Label, {
|
|
541
584
|
"data-tao-select-group-label": "",
|
|
542
585
|
className: cx(classNames?.groupLabel),
|
|
543
586
|
style: styles?.groupLabel,
|
|
@@ -546,7 +589,7 @@ function Select(props) {
|
|
|
546
589
|
o_13.options.map(renderItem)
|
|
547
590
|
]
|
|
548
591
|
}, o_13.value) : renderItem(o_13));
|
|
549
|
-
const menuNode = /*#__PURE__*/ jsx(
|
|
592
|
+
const menuNode = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.Viewport, {
|
|
550
593
|
"data-tao-select-viewport": "",
|
|
551
594
|
style: {
|
|
552
595
|
maxHeight: listHeight
|
|
@@ -558,8 +601,261 @@ function Select(props) {
|
|
|
558
601
|
children: notFoundContent
|
|
559
602
|
})
|
|
560
603
|
});
|
|
604
|
+
const isSearchableOptionDisabled = (option)=>!!option.disabled || overMaxCount && !valueArray.includes(option.value);
|
|
605
|
+
const searchableOptions = flattenOptions(filteredOptions).filter((option_0)=>!isSearchableOptionDisabled(option_0));
|
|
606
|
+
const activeSearchOption = searchableOptions[Math.min(activeSearchIndex, Math.max(searchableOptions.length - 1, 0))];
|
|
607
|
+
let searchableItemIndex = 0;
|
|
608
|
+
const renderSearchableItem = (option_1)=>{
|
|
609
|
+
const renderIndex = searchableItemIndex++;
|
|
610
|
+
const optionIndex = searchableOptions.findIndex((candidate)=>candidate.value === option_1.value);
|
|
611
|
+
const isSelected_0 = valueArray.includes(option_1.value);
|
|
612
|
+
const itemDisabled_0 = isSearchableOptionDisabled(option_1);
|
|
613
|
+
return /*#__PURE__*/ jsxs("button", {
|
|
614
|
+
id: `${searchListboxId}-option-${encodeURIComponent(option_1.value)}`,
|
|
615
|
+
type: "button",
|
|
616
|
+
role: "option",
|
|
617
|
+
"aria-selected": isSelected_0,
|
|
618
|
+
disabled: itemDisabled_0,
|
|
619
|
+
"data-disabled": itemDisabled_0 || void 0,
|
|
620
|
+
"data-tao-select-item": "",
|
|
621
|
+
"data-tao-selected": isMultiple && isSelected_0 ? '' : void 0,
|
|
622
|
+
"data-tao-has-desc": null != option_1.description || void 0,
|
|
623
|
+
"data-state": isSelected_0 ? 'checked' : 'unchecked',
|
|
624
|
+
"data-highlighted": activeSearchOption?.value === option_1.value ? '' : void 0,
|
|
625
|
+
className: cx(classNames?.item),
|
|
626
|
+
style: styles?.item,
|
|
627
|
+
onPointerDown: (event_0)=>event_0.preventDefault(),
|
|
628
|
+
onMouseMove: ()=>{
|
|
629
|
+
if (optionIndex >= 0) setActiveSearchIndex(optionIndex);
|
|
630
|
+
},
|
|
631
|
+
onClick: ()=>{
|
|
632
|
+
if (itemDisabled_0) return;
|
|
633
|
+
handleValueChange(option_1.value);
|
|
634
|
+
if (!isMultiple) handleOpenChange(false);
|
|
635
|
+
},
|
|
636
|
+
children: [
|
|
637
|
+
optionRender ? optionRender(option_1, {
|
|
638
|
+
index: renderIndex
|
|
639
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
640
|
+
children: [
|
|
641
|
+
null != option_1.icon && /*#__PURE__*/ jsx("span", {
|
|
642
|
+
"data-tao-select-item-icon": "",
|
|
643
|
+
className: cx(classNames?.itemIcon),
|
|
644
|
+
style: styles?.itemIcon,
|
|
645
|
+
children: option_1.icon
|
|
646
|
+
}),
|
|
647
|
+
/*#__PURE__*/ jsxs("span", {
|
|
648
|
+
"data-tao-select-item-main": "",
|
|
649
|
+
className: cx(classNames?.itemLabel),
|
|
650
|
+
style: styles?.itemLabel,
|
|
651
|
+
children: [
|
|
652
|
+
/*#__PURE__*/ jsx("span", {
|
|
653
|
+
children: option_1.label
|
|
654
|
+
}),
|
|
655
|
+
null != option_1.description && /*#__PURE__*/ jsx("span", {
|
|
656
|
+
"data-tao-select-item-desc": "",
|
|
657
|
+
className: cx(classNames?.itemDesc),
|
|
658
|
+
style: styles?.itemDesc,
|
|
659
|
+
children: option_1.description
|
|
660
|
+
})
|
|
661
|
+
]
|
|
662
|
+
})
|
|
663
|
+
]
|
|
664
|
+
}),
|
|
665
|
+
isSelected_0 && /*#__PURE__*/ jsx("span", {
|
|
666
|
+
"data-tao-select-check": "",
|
|
667
|
+
children: /*#__PURE__*/ jsx(CheckIcon, {})
|
|
668
|
+
})
|
|
669
|
+
]
|
|
670
|
+
}, option_1.value);
|
|
671
|
+
};
|
|
672
|
+
const renderSearchableTree = (items)=>items.map((option_2)=>option_2.options ? /*#__PURE__*/ jsxs("fieldset", {
|
|
673
|
+
"aria-label": String(option_2.label),
|
|
674
|
+
"data-tao-select-group": "",
|
|
675
|
+
className: cx(classNames?.group),
|
|
676
|
+
style: styles?.group,
|
|
677
|
+
children: [
|
|
678
|
+
/*#__PURE__*/ jsx("legend", {
|
|
679
|
+
"data-tao-select-group-label": "",
|
|
680
|
+
className: cx(classNames?.groupLabel),
|
|
681
|
+
style: styles?.groupLabel,
|
|
682
|
+
children: option_2.label
|
|
683
|
+
}),
|
|
684
|
+
renderSearchableTree(option_2.options)
|
|
685
|
+
]
|
|
686
|
+
}, option_2.value) : renderSearchableItem(option_2));
|
|
687
|
+
const searchableMenuNode = /*#__PURE__*/ jsx("div", {
|
|
688
|
+
id: searchListboxId,
|
|
689
|
+
role: "listbox",
|
|
690
|
+
"aria-multiselectable": isMultiple || void 0,
|
|
691
|
+
"data-tao-select-viewport": "",
|
|
692
|
+
style: {
|
|
693
|
+
maxHeight: listHeight
|
|
694
|
+
},
|
|
695
|
+
children: resultCount > 0 ? renderSearchableTree(filteredOptions) : /*#__PURE__*/ jsx("div", {
|
|
696
|
+
"data-tao-select-empty": "",
|
|
697
|
+
className: cx(classNames?.empty),
|
|
698
|
+
style: styles?.empty,
|
|
699
|
+
children: notFoundContent
|
|
700
|
+
})
|
|
701
|
+
});
|
|
561
702
|
const container = getPopupContainer && triggerRef.current ? getPopupContainer(triggerRef.current) : void 0;
|
|
562
|
-
|
|
703
|
+
const inlineSearchInput = /*#__PURE__*/ jsx("input", {
|
|
704
|
+
ref: inputRef,
|
|
705
|
+
id: id,
|
|
706
|
+
role: "combobox",
|
|
707
|
+
"data-tao-select-trigger-input": "",
|
|
708
|
+
className: cx(classNames?.searchInput),
|
|
709
|
+
style: styles?.searchInput,
|
|
710
|
+
value: search,
|
|
711
|
+
placeholder: isMultiple && 0 === selectedOptions.length ? placeholder : void 0,
|
|
712
|
+
disabled: resolvedDisabled,
|
|
713
|
+
"aria-expanded": open,
|
|
714
|
+
"aria-autocomplete": "list",
|
|
715
|
+
"aria-controls": open ? searchListboxId : void 0,
|
|
716
|
+
"aria-invalid": 'error' === status || void 0,
|
|
717
|
+
"aria-activedescendant": open && activeSearchOption ? `${searchListboxId}-option-${encodeURIComponent(activeSearchOption.value)}` : void 0,
|
|
718
|
+
"aria-label": selectedOption ? String(selectedOption.label) : placeholder,
|
|
719
|
+
autoFocus: autoFocus,
|
|
720
|
+
autoComplete: "off",
|
|
721
|
+
onClick: (event_1)=>{
|
|
722
|
+
if (open) event_1.stopPropagation();
|
|
723
|
+
},
|
|
724
|
+
onChange: (event_2)=>{
|
|
725
|
+
handleSearchChange(event_2.target.value);
|
|
726
|
+
setActiveSearchIndex(0);
|
|
727
|
+
if (!open) handleOpenChange(true);
|
|
728
|
+
},
|
|
729
|
+
onKeyDown: (event_3)=>{
|
|
730
|
+
event_3.stopPropagation();
|
|
731
|
+
handleSearchKeyDown(event_3);
|
|
732
|
+
if (event_3.defaultPrevented) return;
|
|
733
|
+
if ('Escape' === event_3.key) {
|
|
734
|
+
handleSearchChange('');
|
|
735
|
+
handleOpenChange(false);
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
if ('ArrowDown' === event_3.key) {
|
|
739
|
+
event_3.preventDefault();
|
|
740
|
+
setActiveSearchIndex((index_0)=>Math.min(index_0 + 1, searchableOptions.length - 1));
|
|
741
|
+
if (!open) handleOpenChange(true);
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
if ('ArrowUp' === event_3.key) {
|
|
745
|
+
event_3.preventDefault();
|
|
746
|
+
setActiveSearchIndex((index_1)=>Math.max(index_1 - 1, 0));
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
const nextValue = activeSearchOption?.value ?? ('tags' === mode ? search.trim() : void 0);
|
|
750
|
+
if ('Enter' === event_3.key && nextValue) {
|
|
751
|
+
event_3.preventDefault();
|
|
752
|
+
handleValueChange(nextValue);
|
|
753
|
+
if (!isMultiple) handleOpenChange(false);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
if (hasInlineSearch) {
|
|
758
|
+
const searchableContentStyle = {
|
|
759
|
+
...contentStyle
|
|
760
|
+
};
|
|
761
|
+
if (true === popupMatchSelectWidth) searchableContentStyle.minWidth = 'var(--radix-popover-trigger-width)';
|
|
762
|
+
else if (false === popupMatchSelectWidth) searchableContentStyle.minWidth = 'max-content';
|
|
763
|
+
return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_popover_c8444160.Root, {
|
|
764
|
+
open: open,
|
|
765
|
+
onOpenChange: handleOpenChange,
|
|
766
|
+
children: [
|
|
767
|
+
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_c8444160.Trigger, {
|
|
768
|
+
asChild: true,
|
|
769
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
770
|
+
ref: triggerRef,
|
|
771
|
+
role: "presentation",
|
|
772
|
+
"data-tao-control": "",
|
|
773
|
+
"data-tao-select": "",
|
|
774
|
+
"data-tao-inline-search": "",
|
|
775
|
+
"data-tao-multiple": isMultiple || void 0,
|
|
776
|
+
"data-tao-size": resolvedSize,
|
|
777
|
+
"data-tao-variant": resolvedVariant,
|
|
778
|
+
"data-disabled": resolvedDisabled || void 0,
|
|
779
|
+
"data-tao-disabled": resolvedDisabled || void 0,
|
|
780
|
+
...statusProps,
|
|
781
|
+
className: cx(classNames?.root, className),
|
|
782
|
+
style: {
|
|
783
|
+
...styles?.root,
|
|
784
|
+
...style
|
|
785
|
+
},
|
|
786
|
+
children: [
|
|
787
|
+
null != prefix && /*#__PURE__*/ jsx("span", {
|
|
788
|
+
"data-tao-select-prefix": "",
|
|
789
|
+
className: cx(classNames?.prefix),
|
|
790
|
+
style: styles?.prefix,
|
|
791
|
+
children: prefix
|
|
792
|
+
}),
|
|
793
|
+
isMultiple ? /*#__PURE__*/ jsxs("span", {
|
|
794
|
+
"data-tao-select-values": "",
|
|
795
|
+
className: cx(classNames?.values),
|
|
796
|
+
style: styles?.values,
|
|
797
|
+
children: [
|
|
798
|
+
renderTags(),
|
|
799
|
+
inlineSearchInput
|
|
800
|
+
]
|
|
801
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
802
|
+
children: [
|
|
803
|
+
selectedOption?.icon != null && /*#__PURE__*/ jsx("span", {
|
|
804
|
+
"data-tao-select-value-icon": "",
|
|
805
|
+
children: selectedOption.icon
|
|
806
|
+
}),
|
|
807
|
+
/*#__PURE__*/ jsxs("span", {
|
|
808
|
+
"data-tao-select-search-trigger": "",
|
|
809
|
+
className: cx(classNames?.search),
|
|
810
|
+
style: styles?.search,
|
|
811
|
+
children: [
|
|
812
|
+
inlineSearchInput,
|
|
813
|
+
!search && /*#__PURE__*/ jsx("span", {
|
|
814
|
+
"data-tao-select-trigger-value": "",
|
|
815
|
+
"data-tao-select-placeholder": selectedOption ? void 0 : '',
|
|
816
|
+
className: cx(selectedOption ? void 0 : classNames?.placeholder),
|
|
817
|
+
style: selectedOption ? void 0 : styles?.placeholder,
|
|
818
|
+
children: selectedOption && labelRender ? labelRender(selectedOption) : selectedOption ? String(selectedOption.label) : placeholder
|
|
819
|
+
})
|
|
820
|
+
]
|
|
821
|
+
})
|
|
822
|
+
]
|
|
823
|
+
}),
|
|
824
|
+
searchableTrailingIcons
|
|
825
|
+
]
|
|
826
|
+
})
|
|
827
|
+
}),
|
|
828
|
+
name && !isMultiple && /*#__PURE__*/ jsx("input", {
|
|
829
|
+
type: "hidden",
|
|
830
|
+
name: name,
|
|
831
|
+
value: value ?? '',
|
|
832
|
+
disabled: resolvedDisabled
|
|
833
|
+
}),
|
|
834
|
+
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_c8444160.Portal, {
|
|
835
|
+
container: container,
|
|
836
|
+
children: /*#__PURE__*/ jsx(TaoPortalScope, {
|
|
837
|
+
asChild: true,
|
|
838
|
+
children: /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_c8444160.Content, {
|
|
839
|
+
"data-tao-select-content": "",
|
|
840
|
+
"data-tao-popup-width": false === popupMatchSelectWidth ? 'content' : void 0,
|
|
841
|
+
className: cx(classNames?.popup),
|
|
842
|
+
style: searchableContentStyle,
|
|
843
|
+
side: side,
|
|
844
|
+
align: align,
|
|
845
|
+
sideOffset: 4,
|
|
846
|
+
onOpenAutoFocus: (event_4)=>event_4.preventDefault(),
|
|
847
|
+
onCloseAutoFocus: (event_5)=>{
|
|
848
|
+
event_5.preventDefault();
|
|
849
|
+
inputRef.current?.focus();
|
|
850
|
+
},
|
|
851
|
+
children: popupRender ? popupRender(searchableMenuNode) : searchableMenuNode
|
|
852
|
+
})
|
|
853
|
+
})
|
|
854
|
+
})
|
|
855
|
+
]
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_4606f4d3.Root, {
|
|
563
859
|
value: radixValue,
|
|
564
860
|
onValueChange: handleValueChange,
|
|
565
861
|
disabled: resolvedDisabled,
|
|
@@ -567,7 +863,7 @@ function Select(props) {
|
|
|
567
863
|
onOpenChange: handleOpenChange,
|
|
568
864
|
name: isMultiple ? void 0 : name,
|
|
569
865
|
children: [
|
|
570
|
-
/*#__PURE__*/ jsx(
|
|
866
|
+
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.Trigger, {
|
|
571
867
|
asChild: true,
|
|
572
868
|
children: /*#__PURE__*/ jsxs("div", {
|
|
573
869
|
ref: triggerRef,
|
|
@@ -627,11 +923,11 @@ function Select(props) {
|
|
|
627
923
|
]
|
|
628
924
|
})
|
|
629
925
|
}),
|
|
630
|
-
/*#__PURE__*/ jsx(
|
|
926
|
+
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.Portal, {
|
|
631
927
|
container: container,
|
|
632
928
|
children: /*#__PURE__*/ jsx(TaoPortalScope, {
|
|
633
929
|
asChild: true,
|
|
634
|
-
children: /*#__PURE__*/ jsxs(
|
|
930
|
+
children: /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_4606f4d3.Content, {
|
|
635
931
|
"data-tao-select-content": "",
|
|
636
932
|
"data-tao-popup-width": false === popupMatchSelectWidth ? 'content' : void 0,
|
|
637
933
|
className: cx(classNames?.popup),
|
|
@@ -641,7 +937,7 @@ function Select(props) {
|
|
|
641
937
|
align: align,
|
|
642
938
|
sideOffset: 4,
|
|
643
939
|
children: [
|
|
644
|
-
showSearch && !
|
|
940
|
+
showSearch && !hasInlineSearch && /*#__PURE__*/ jsxs("div", {
|
|
645
941
|
"data-tao-select-search": "",
|
|
646
942
|
className: cx(classNames?.search),
|
|
647
943
|
style: styles?.search,
|
|
@@ -656,10 +952,10 @@ function Select(props) {
|
|
|
656
952
|
className: cx(classNames?.searchInput),
|
|
657
953
|
style: styles?.searchInput,
|
|
658
954
|
value: search,
|
|
659
|
-
onChange: (
|
|
660
|
-
onKeyDown: (
|
|
661
|
-
|
|
662
|
-
handleSearchKeyDown(
|
|
955
|
+
onChange: (e_9)=>handleSearchChange(e_9.target.value),
|
|
956
|
+
onKeyDown: (e_10)=>{
|
|
957
|
+
e_10.stopPropagation();
|
|
958
|
+
handleSearchKeyDown(e_10);
|
|
663
959
|
},
|
|
664
960
|
placeholder: "Search...",
|
|
665
961
|
autoComplete: "off"
|