@rockshin/tao-ui 0.0.2 → 0.0.3

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 (49) hide show
  1. package/dist/components/breadcrumb/breadcrumb.css +3 -0
  2. package/dist/components/button/button.css +3 -0
  3. package/dist/components/checkbox/checkbox.css +3 -0
  4. package/dist/components/collapsible/collapsible.css +3 -0
  5. package/dist/components/context-menu/context-menu.css +4 -1
  6. package/dist/components/context-menu/context-menu.js +10 -8
  7. package/dist/components/date-picker/calendar/month-grid.d.ts +1 -1
  8. package/dist/components/date-picker/calendar/time-panel.d.ts +1 -1
  9. package/dist/components/date-picker/calendar/year-grid.d.ts +1 -1
  10. package/dist/components/date-picker/date-picker.css +43 -1
  11. package/dist/components/date-picker/date-picker.js +9 -7
  12. package/dist/components/date-picker/range-picker.js +9 -7
  13. package/dist/components/drawer/drawer.css +5 -2
  14. package/dist/components/drawer/drawer.js +27 -18
  15. package/dist/components/dropdown/dropdown.css +3 -0
  16. package/dist/components/dropdown/dropdown.js +17 -15
  17. package/dist/components/form-field/form.css +3 -0
  18. package/dist/components/input/input.css +42 -0
  19. package/dist/components/menu/menu-render.js +11 -8
  20. package/dist/components/menu/menu.css +4 -1
  21. package/dist/components/modal/modal.css +5 -2
  22. package/dist/components/modal/modal.js +27 -18
  23. package/dist/components/pagination/pagination.css +3 -0
  24. package/dist/components/pagination/pagination.js +3 -1
  25. package/dist/components/radio/radio.css +3 -0
  26. package/dist/components/scroll-area/scroll-area.css +3 -0
  27. package/dist/components/select/mobile-select.css +10 -0
  28. package/dist/components/select/mobile-select.d.ts +4 -1
  29. package/dist/components/select/mobile-select.js +103 -121
  30. package/dist/components/select/select.css +65 -11
  31. package/dist/components/select/select.d.ts +58 -4
  32. package/dist/components/select/select.js +356 -410
  33. package/dist/components/spinner/spinner.css +1084 -0
  34. package/dist/components/spinner/spinner.d.ts +26 -0
  35. package/dist/components/spinner/spinner.js +229 -0
  36. package/dist/components/splitter/splitter.css +3 -0
  37. package/dist/components/switch/switch.css +3 -0
  38. package/dist/components/table/table.css +3 -0
  39. package/dist/components/tabs/tabs.css +3 -0
  40. package/dist/components/tag/tag.css +3 -0
  41. package/dist/components/textarea/textarea.css +42 -0
  42. package/dist/index.d.ts +4 -3
  43. package/dist/index.js +4 -3
  44. package/dist/layouts/stack/layout.css +3 -0
  45. package/dist/provider/tao-provider.d.ts +17 -1
  46. package/dist/provider/tao-provider.js +53 -15
  47. package/dist/theme/control.css +42 -0
  48. package/dist/theme/theme.css +3 -0
  49. package/package.json +13 -13
@@ -1,7 +1,8 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react/compiler-runtime";
3
- import { useState } from "react";
4
- import { useTaoConfig } from "../../provider/tao-provider.js";
3
+ import { useCallback, useMemo, useRef, useState } from "react";
4
+ import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
5
+ import { cx } from "../../utils/semantic.js";
5
6
  import { MobileSelectDrawer } from "./mobile-select.js";
6
7
  import "./select.css";
7
8
  import { useIsMobile } from "./use-is-mobile.js";
@@ -10,447 +11,370 @@ const defaultFilter = (input, option)=>{
10
11
  const label = 'string' == typeof option.label ? option.label : String(option.label);
11
12
  return label.toLowerCase().includes(input.toLowerCase());
12
13
  };
14
+ function flattenOptions(options) {
15
+ const out = [];
16
+ for (const o of options)if (o.options) out.push(...flattenOptions(o.options));
17
+ else out.push(o);
18
+ return out;
19
+ }
20
+ function filterTree(options, fn, input) {
21
+ const result = [];
22
+ for (const o of options)if (o.options) {
23
+ const kids = filterTree(o.options, fn, input);
24
+ if (kids.length) result.push({
25
+ ...o,
26
+ options: kids
27
+ });
28
+ } else if (fn(input, o)) result.push(o);
29
+ return result;
30
+ }
31
+ const PLACEMENT_MAP = {
32
+ bottomLeft: {
33
+ side: 'bottom',
34
+ align: 'start'
35
+ },
36
+ bottomRight: {
37
+ side: 'bottom',
38
+ align: 'end'
39
+ },
40
+ topLeft: {
41
+ side: 'top',
42
+ align: 'start'
43
+ },
44
+ topRight: {
45
+ side: 'top',
46
+ align: 'end'
47
+ }
48
+ };
13
49
  function Select(props) {
14
- const $ = c(101);
15
- const { options, value, onChange, placeholder, size, variant, disabled, showSearch, filterOption, allowClear, loading, notFoundContent: t0, prefix, mobile } = props;
16
- const notFoundContent = void 0 === t0 ? "No results" : t0;
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;
17
51
  const ctx = useTaoConfig();
18
52
  const resolvedSize = size ?? ctx.size;
19
53
  const resolvedVariant = variant ?? ctx.variant;
20
54
  const resolvedDisabled = disabled ?? ctx.disabled;
21
55
  const autoMobile = useIsMobile();
22
56
  const isMobile = mobile ?? autoMobile;
23
- const [open, setOpen] = useState(false);
24
- const [search, setSearch] = useState("");
57
+ const triggerRef = useRef(null);
58
+ const isValueControlled = void 0 !== valueProp;
59
+ const [valueInternal, setValueInternal] = useState(defaultValue);
60
+ const value = isValueControlled ? valueProp : valueInternal;
61
+ const isOpenControlled = void 0 !== openProp;
62
+ const [openInternal, setOpenInternal] = useState(defaultOpen ?? false);
63
+ const open = isOpenControlled ? openProp : openInternal;
64
+ const isSearchControlled = void 0 !== searchValueProp;
65
+ const [searchInternal, setSearchInternal] = useState('');
66
+ const search = isSearchControlled ? searchValueProp : searchInternal;
25
67
  const [hovering, setHovering] = useState(false);
26
- let t1;
27
- bb0: {
28
- if (!showSearch || !search) {
29
- t1 = options;
30
- break bb0;
31
- }
68
+ const allOptions = useMemo(()=>flattenOptions(options), [
69
+ options
70
+ ]);
71
+ const handleValueChange = useCallback((next)=>{
72
+ const opt = allOptions.find((o)=>o.value === next);
73
+ if (!isValueControlled) setValueInternal(next);
74
+ onChange?.(next, opt);
75
+ if (opt) onSelect?.(next, opt);
76
+ }, [
77
+ allOptions,
78
+ isValueControlled,
79
+ onChange,
80
+ onSelect
81
+ ]);
82
+ const handleOpenChange = useCallback((next_0)=>{
83
+ if (!isOpenControlled) setOpenInternal(next_0);
84
+ if (!next_0 && !isSearchControlled) setSearchInternal('');
85
+ onOpenChange?.(next_0);
86
+ }, [
87
+ isOpenControlled,
88
+ isSearchControlled,
89
+ onOpenChange
90
+ ]);
91
+ const handleSearchChange = useCallback((v)=>{
92
+ if (!isSearchControlled) setSearchInternal(v);
93
+ onSearch?.(v);
94
+ }, [
95
+ isSearchControlled,
96
+ onSearch
97
+ ]);
98
+ const handleClear = useCallback((e)=>{
99
+ e.stopPropagation();
100
+ if (!isValueControlled) setValueInternal(void 0);
101
+ onChange?.('', void 0);
102
+ onClear?.();
103
+ }, [
104
+ isValueControlled,
105
+ onChange,
106
+ onClear
107
+ ]);
108
+ const filteredOptions = useMemo(()=>{
109
+ if (!showSearch || !search) return options;
32
110
  const fn = filterOption ?? defaultFilter;
33
- let t2;
34
- if ($[0] !== fn || $[1] !== options || $[2] !== search) {
35
- let t3;
36
- if ($[4] !== fn || $[5] !== search) {
37
- t3 = (o)=>fn(search, o);
38
- $[4] = fn;
39
- $[5] = search;
40
- $[6] = t3;
41
- } else t3 = $[6];
42
- t2 = options.filter(t3);
43
- $[0] = fn;
44
- $[1] = options;
45
- $[2] = search;
46
- $[3] = t2;
47
- } else t2 = $[3];
48
- t1 = t2;
49
- }
50
- const filteredOptions = t1;
51
- let t2;
52
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
53
- t2 = (nextOpen)=>{
54
- setOpen(nextOpen);
55
- if (!nextOpen) setSearch("");
56
- };
57
- $[7] = t2;
58
- } else t2 = $[7];
59
- const handleOpenChange = t2;
60
- let t3;
61
- if ($[8] !== onChange) {
62
- t3 = (e)=>{
63
- e.stopPropagation();
64
- onChange?.("");
65
- };
66
- $[8] = onChange;
67
- $[9] = t3;
68
- } else t3 = $[9];
69
- const handleClear = t3;
70
- const showClearBtn = allowClear && value && !resolvedDisabled;
71
- let t4;
72
- if ($[10] !== options || $[11] !== value) {
73
- let t5;
74
- if ($[13] !== value) {
75
- t5 = (o_0)=>o_0.value === value;
76
- $[13] = value;
77
- $[14] = t5;
78
- } else t5 = $[14];
79
- t4 = options.find(t5);
80
- $[10] = options;
81
- $[11] = value;
82
- $[12] = t4;
83
- } else t4 = $[12];
84
- const selectedOption = t4;
85
- if (isMobile) {
86
- const t5 = resolvedDisabled || void 0;
87
- let t6;
88
- let t7;
89
- let t8;
90
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
91
- t6 = ()=>setOpen(true);
92
- t7 = ()=>setHovering(true);
93
- t8 = ()=>setHovering(false);
94
- $[15] = t6;
95
- $[16] = t7;
96
- $[17] = t8;
97
- } else {
98
- t6 = $[15];
99
- t7 = $[16];
100
- t8 = $[17];
101
- }
102
- let t9;
103
- if ($[18] !== prefix) {
104
- t9 = null != prefix && /*#__PURE__*/ jsx("span", {
105
- "data-tao-select-prefix": "",
106
- children: prefix
107
- });
108
- $[18] = prefix;
109
- $[19] = t9;
110
- } else t9 = $[19];
111
- let t10;
112
- if ($[20] !== selectedOption) {
113
- t10 = selectedOption?.icon != null && /*#__PURE__*/ jsx("span", {
114
- "data-tao-select-value-icon": "",
115
- children: selectedOption.icon
116
- });
117
- $[20] = selectedOption;
118
- $[21] = t10;
119
- } else t10 = $[21];
120
- let t11;
121
- if ($[22] !== placeholder || $[23] !== selectedOption) {
122
- t11 = selectedOption ? selectedOption.label : /*#__PURE__*/ jsx("span", {
123
- "data-tao-select-placeholder": "",
124
- children: placeholder
125
- });
126
- $[22] = placeholder;
127
- $[23] = selectedOption;
128
- $[24] = t11;
129
- } else t11 = $[24];
130
- let t12;
131
- if ($[25] !== t11) {
132
- t12 = /*#__PURE__*/ jsx("span", {
133
- "data-tao-select-value": "",
134
- children: t11
135
- });
136
- $[25] = t11;
137
- $[26] = t12;
138
- } else t12 = $[26];
139
- let t13;
140
- if ($[27] !== loading) {
141
- t13 = loading && /*#__PURE__*/ jsx(LoadingIcon, {});
142
- $[27] = loading;
143
- $[28] = t13;
144
- } else t13 = $[28];
145
- let t14;
146
- if ($[29] !== handleClear || $[30] !== hovering || $[31] !== showClearBtn) {
147
- t14 = showClearBtn && hovering ? /*#__PURE__*/ jsx("span", {
148
- "data-tao-select-clear": "",
149
- onClick: handleClear,
150
- role: "button",
151
- "aria-label": "Clear",
152
- children: /*#__PURE__*/ jsx(CloseIcon, {})
153
- }) : /*#__PURE__*/ jsx("span", {
154
- "data-tao-select-icon": "",
155
- children: /*#__PURE__*/ jsx(ChevronDownIcon, {})
156
- });
157
- $[29] = handleClear;
158
- $[30] = hovering;
159
- $[31] = showClearBtn;
160
- $[32] = t14;
161
- } else t14 = $[32];
162
- let t15;
163
- if ($[33] !== t13 || $[34] !== t14) {
164
- t15 = /*#__PURE__*/ jsxs("span", {
165
- "data-tao-select-icons": "",
166
- children: [
167
- t13,
168
- t14
169
- ]
170
- });
171
- $[33] = t13;
172
- $[34] = t14;
173
- $[35] = t15;
174
- } else t15 = $[35];
175
- let t16;
176
- if ($[36] !== resolvedDisabled || $[37] !== resolvedSize || $[38] !== resolvedVariant || $[39] !== t10 || $[40] !== t12 || $[41] !== t15 || $[42] !== t5 || $[43] !== t9) {
177
- t16 = /*#__PURE__*/ jsxs("button", {
111
+ return filterTree(options, fn, search);
112
+ }, [
113
+ options,
114
+ search,
115
+ showSearch,
116
+ filterOption
117
+ ]);
118
+ const allowClearEnabled = !!allowClear;
119
+ const clearIcon = 'object' == typeof allowClear && allowClear.clearIcon || /*#__PURE__*/ jsx(CloseIcon, {});
120
+ const showClearBtn = allowClearEnabled && !!value && !resolvedDisabled;
121
+ const selectedOption = allOptions.find((o_0)=>o_0.value === value);
122
+ const statusProps = {
123
+ 'data-tao-error': 'error' === status || void 0,
124
+ 'data-tao-warning': 'warning' === status || void 0
125
+ };
126
+ const triggerLabel = selectedOption ? labelRender ? labelRender(selectedOption) : selectedOption.label : /*#__PURE__*/ jsx("span", {
127
+ "data-tao-select-placeholder": "",
128
+ className: cx(classNames?.placeholder),
129
+ style: styles?.placeholder,
130
+ children: placeholder
131
+ });
132
+ const trailingIcons = /*#__PURE__*/ jsx("span", {
133
+ "data-tao-select-icons": "",
134
+ children: loading ? /*#__PURE__*/ jsx("span", {
135
+ "data-tao-select-icon": "",
136
+ "data-tao-select-loading-slot": "",
137
+ children: loadingIcon ?? /*#__PURE__*/ jsx(LoadingIcon, {})
138
+ }) : showClearBtn && hovering ? /*#__PURE__*/ jsx("span", {
139
+ "data-tao-select-clear": "",
140
+ className: cx(classNames?.clear),
141
+ style: styles?.clear,
142
+ onPointerDown: (e_0)=>e_0.stopPropagation(),
143
+ onClick: handleClear,
144
+ role: "button",
145
+ "aria-label": "Clear",
146
+ children: clearIcon
147
+ }) : /*#__PURE__*/ jsx("span", {
148
+ "data-tao-select-icon": "",
149
+ "data-tao-custom-suffix": null != suffixIcon || void 0,
150
+ className: cx(classNames?.suffix),
151
+ style: styles?.suffix,
152
+ children: suffixIcon ?? /*#__PURE__*/ jsx(ChevronDownIcon, {})
153
+ })
154
+ });
155
+ if (isMobile) return /*#__PURE__*/ jsxs(Fragment, {
156
+ children: [
157
+ /*#__PURE__*/ jsxs("button", {
178
158
  type: "button",
159
+ id: id,
179
160
  "data-tao-control": "",
180
161
  "data-tao-select": "",
181
162
  "data-tao-size": resolvedSize,
182
163
  "data-tao-variant": resolvedVariant,
183
- "data-tao-disabled": t5,
164
+ "data-tao-disabled": resolvedDisabled || void 0,
165
+ ...statusProps,
184
166
  disabled: resolvedDisabled,
185
- onClick: t6,
186
- onMouseEnter: t7,
187
- onMouseLeave: t8,
167
+ autoFocus: autoFocus,
168
+ className: cx(classNames?.root, className),
169
+ style: {
170
+ ...styles?.root,
171
+ ...style
172
+ },
173
+ onClick: ()=>handleOpenChange(true),
174
+ onMouseEnter: ()=>setHovering(true),
175
+ onMouseLeave: ()=>setHovering(false),
188
176
  children: [
189
- t9,
190
- t10,
191
- t12,
192
- t15
177
+ null != prefix && /*#__PURE__*/ jsx("span", {
178
+ "data-tao-select-prefix": "",
179
+ className: cx(classNames?.prefix),
180
+ style: styles?.prefix,
181
+ children: prefix
182
+ }),
183
+ selectedOption?.icon != null && /*#__PURE__*/ jsx("span", {
184
+ "data-tao-select-value-icon": "",
185
+ children: selectedOption.icon
186
+ }),
187
+ /*#__PURE__*/ jsx("span", {
188
+ "data-tao-select-value": "",
189
+ children: triggerLabel
190
+ }),
191
+ trailingIcons
193
192
  ]
194
- });
195
- $[36] = resolvedDisabled;
196
- $[37] = resolvedSize;
197
- $[38] = resolvedVariant;
198
- $[39] = t10;
199
- $[40] = t12;
200
- $[41] = t15;
201
- $[42] = t5;
202
- $[43] = t9;
203
- $[44] = t16;
204
- } else t16 = $[44];
205
- let t17;
206
- if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
207
- t17 = ()=>handleOpenChange(false);
208
- $[45] = t17;
209
- } else t17 = $[45];
210
- let t18;
211
- if ($[46] !== filterOption || $[47] !== notFoundContent || $[48] !== onChange || $[49] !== open || $[50] !== options || $[51] !== placeholder || $[52] !== showSearch || $[53] !== value) {
212
- t18 = /*#__PURE__*/ jsx(MobileSelectDrawer, {
193
+ }),
194
+ /*#__PURE__*/ jsx(MobileSelectDrawer, {
213
195
  open: open,
214
- onClose: t17,
196
+ onClose: ()=>handleOpenChange(false),
215
197
  options: options,
216
198
  value: value,
217
- onChange: onChange,
199
+ onChange: handleValueChange,
218
200
  placeholder: placeholder,
219
201
  showSearch: showSearch,
220
202
  filterOption: filterOption,
221
- notFoundContent: notFoundContent
222
- });
223
- $[46] = filterOption;
224
- $[47] = notFoundContent;
225
- $[48] = onChange;
226
- $[49] = open;
227
- $[50] = options;
228
- $[51] = placeholder;
229
- $[52] = showSearch;
230
- $[53] = value;
231
- $[54] = t18;
232
- } else t18 = $[54];
233
- let t19;
234
- if ($[55] !== t16 || $[56] !== t18) {
235
- t19 = /*#__PURE__*/ jsxs(Fragment, {
236
- children: [
237
- t16,
238
- t18
239
- ]
240
- });
241
- $[55] = t16;
242
- $[56] = t18;
243
- $[57] = t19;
244
- } else t19 = $[57];
245
- return t19;
246
- }
247
- const t5 = resolvedDisabled || void 0;
248
- let t6;
249
- let t7;
250
- if ($[58] === Symbol.for("react.memo_cache_sentinel")) {
251
- t6 = ()=>setHovering(true);
252
- t7 = ()=>setHovering(false);
253
- $[58] = t6;
254
- $[59] = t7;
255
- } else {
256
- t6 = $[58];
257
- t7 = $[59];
258
- }
259
- let t8;
260
- if ($[60] !== prefix) {
261
- t8 = null != prefix && /*#__PURE__*/ jsx("span", {
262
- "data-tao-select-prefix": "",
263
- children: prefix
264
- });
265
- $[60] = prefix;
266
- $[61] = t8;
267
- } else t8 = $[61];
268
- let t9;
269
- if ($[62] !== selectedOption) {
270
- t9 = selectedOption?.icon != null && /*#__PURE__*/ jsx("span", {
271
- "data-tao-select-value-icon": "",
272
- children: selectedOption.icon
273
- });
274
- $[62] = selectedOption;
275
- $[63] = t9;
276
- } else t9 = $[63];
277
- let t10;
278
- if ($[64] !== placeholder) {
279
- t10 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Value, {
280
- placeholder: placeholder
281
- });
282
- $[64] = placeholder;
283
- $[65] = t10;
284
- } else t10 = $[65];
285
- let t11;
286
- if ($[66] !== loading) {
287
- t11 = loading && /*#__PURE__*/ jsx(LoadingIcon, {});
288
- $[66] = loading;
289
- $[67] = t11;
290
- } else t11 = $[67];
291
- let t12;
292
- if ($[68] !== handleClear || $[69] !== hovering || $[70] !== showClearBtn) {
293
- t12 = showClearBtn && hovering ? /*#__PURE__*/ jsx("span", {
294
- "data-tao-select-clear": "",
295
- onClick: handleClear,
296
- role: "button",
297
- "aria-label": "Clear",
298
- children: /*#__PURE__*/ jsx(CloseIcon, {})
299
- }) : /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Icon, {
300
- "data-tao-select-icon": "",
301
- children: /*#__PURE__*/ jsx(ChevronDownIcon, {})
302
- });
303
- $[68] = handleClear;
304
- $[69] = hovering;
305
- $[70] = showClearBtn;
306
- $[71] = t12;
307
- } else t12 = $[71];
308
- let t13;
309
- if ($[72] !== t11 || $[73] !== t12) {
310
- t13 = /*#__PURE__*/ jsxs("span", {
311
- "data-tao-select-icons": "",
312
- children: [
313
- t11,
314
- t12
315
- ]
316
- });
317
- $[72] = t11;
318
- $[73] = t12;
319
- $[74] = t13;
320
- } else t13 = $[74];
321
- let t14;
322
- if ($[75] !== resolvedSize || $[76] !== resolvedVariant || $[77] !== t10 || $[78] !== t13 || $[79] !== t5 || $[80] !== t8 || $[81] !== t9) {
323
- t14 = /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Trigger, {
324
- "data-tao-control": "",
325
- "data-tao-select": "",
326
- "data-tao-size": resolvedSize,
327
- "data-tao-variant": resolvedVariant,
328
- "data-tao-disabled": t5,
329
- onMouseEnter: t6,
330
- onMouseLeave: t7,
331
- children: [
332
- t8,
333
- t9,
334
- t10,
335
- t13
336
- ]
337
- });
338
- $[75] = resolvedSize;
339
- $[76] = resolvedVariant;
340
- $[77] = t10;
341
- $[78] = t13;
342
- $[79] = t5;
343
- $[80] = t8;
344
- $[81] = t9;
345
- $[82] = t14;
346
- } else t14 = $[82];
347
- let t15;
348
- if ($[83] !== search || $[84] !== showSearch) {
349
- t15 = showSearch && /*#__PURE__*/ jsxs("div", {
350
- "data-tao-select-search": "",
203
+ notFoundContent: notFoundContent,
204
+ optionRender: optionRender
205
+ })
206
+ ]
207
+ });
208
+ const { side, align } = PLACEMENT_MAP[placement];
209
+ const contentStyle = {
210
+ ...styles?.popup
211
+ };
212
+ if ('number' == typeof popupMatchSelectWidth) contentStyle.width = popupMatchSelectWidth;
213
+ const resultCount = flattenOptions(filteredOptions).length;
214
+ let optIndex = 0;
215
+ const renderItem = (opt_0)=>{
216
+ const index = optIndex++;
217
+ const textLabel = 'string' == typeof opt_0.label ? opt_0.label : String(opt_0.label);
218
+ return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Item, {
219
+ value: opt_0.value,
220
+ disabled: opt_0.disabled,
221
+ "data-tao-select-item": "",
222
+ "data-tao-has-desc": null != opt_0.description || void 0,
223
+ className: cx(classNames?.item),
224
+ style: styles?.item,
351
225
  children: [
352
- /*#__PURE__*/ jsx(SearchIcon, {}),
353
- /*#__PURE__*/ jsx("input", {
354
- "data-tao-select-search-input": "",
355
- value: search,
356
- onChange: (e_0)=>setSearch(e_0.target.value),
357
- placeholder: "Search...",
358
- autoFocus: true
226
+ optionRender ? /*#__PURE__*/ jsxs(Fragment, {
227
+ children: [
228
+ optionRender(opt_0, {
229
+ index
230
+ }),
231
+ /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.ItemText, {
232
+ style: {
233
+ display: 'none'
234
+ },
235
+ children: textLabel
236
+ })
237
+ ]
238
+ }) : /*#__PURE__*/ jsxs(Fragment, {
239
+ children: [
240
+ null != opt_0.icon && /*#__PURE__*/ jsx("span", {
241
+ "data-tao-select-item-icon": "",
242
+ className: cx(classNames?.itemIcon),
243
+ style: styles?.itemIcon,
244
+ children: opt_0.icon
245
+ }),
246
+ /*#__PURE__*/ jsxs("span", {
247
+ "data-tao-select-item-main": "",
248
+ className: cx(classNames?.itemLabel),
249
+ style: styles?.itemLabel,
250
+ children: [
251
+ /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.ItemText, {
252
+ children: opt_0.label
253
+ }),
254
+ null != opt_0.description && /*#__PURE__*/ jsx("span", {
255
+ "data-tao-select-item-desc": "",
256
+ className: cx(classNames?.itemDesc),
257
+ style: styles?.itemDesc,
258
+ children: opt_0.description
259
+ })
260
+ ]
261
+ })
262
+ ]
263
+ }),
264
+ /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.ItemIndicator, {
265
+ "data-tao-select-check": "",
266
+ children: /*#__PURE__*/ jsx(CheckIcon, {})
359
267
  })
360
268
  ]
361
- });
362
- $[83] = search;
363
- $[84] = showSearch;
364
- $[85] = t15;
365
- } else t15 = $[85];
366
- let t16;
367
- if ($[86] !== filteredOptions || $[87] !== notFoundContent) {
368
- t16 = filteredOptions.length > 0 ? filteredOptions.map(_temp) : /*#__PURE__*/ jsx("div", {
369
- "data-tao-select-empty": "",
370
- children: notFoundContent
371
- });
372
- $[86] = filteredOptions;
373
- $[87] = notFoundContent;
374
- $[88] = t16;
375
- } else t16 = $[88];
376
- let t17;
377
- if ($[89] !== t16) {
378
- t17 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Viewport, {
379
- "data-tao-select-viewport": "",
380
- children: t16
381
- });
382
- $[89] = t16;
383
- $[90] = t17;
384
- } else t17 = $[90];
385
- let t18;
386
- if ($[91] !== t15 || $[92] !== t17) {
387
- t18 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Portal, {
388
- children: /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Content, {
389
- "data-tao-select-content": "",
390
- position: "popper",
391
- sideOffset: 4,
269
+ }, opt_0.value);
270
+ };
271
+ const renderTree = (opts)=>opts.map((o_1)=>o_1.options ? /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Group, {
272
+ "data-tao-select-group": "",
273
+ className: cx(classNames?.group),
274
+ style: styles?.group,
275
+ children: [
276
+ /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Label, {
277
+ "data-tao-select-group-label": "",
278
+ className: cx(classNames?.groupLabel),
279
+ style: styles?.groupLabel,
280
+ children: o_1.label
281
+ }),
282
+ o_1.options.map(renderItem)
283
+ ]
284
+ }, o_1.value) : renderItem(o_1));
285
+ const menuNode = /*#__PURE__*/ jsxs(Fragment, {
286
+ children: [
287
+ showSearch && /*#__PURE__*/ jsxs("div", {
288
+ "data-tao-select-search": "",
289
+ className: cx(classNames?.search),
290
+ style: styles?.search,
392
291
  children: [
393
- t15,
394
- t17
292
+ /*#__PURE__*/ jsx(SearchIcon, {}),
293
+ /*#__PURE__*/ jsx("input", {
294
+ "data-tao-select-search-input": "",
295
+ value: search,
296
+ onChange: (e_1)=>handleSearchChange(e_1.target.value),
297
+ placeholder: "Search...",
298
+ autoFocus: true
299
+ })
395
300
  ]
301
+ }),
302
+ /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Viewport, {
303
+ "data-tao-select-viewport": "",
304
+ style: {
305
+ maxHeight: listHeight
306
+ },
307
+ children: resultCount > 0 ? renderTree(filteredOptions) : /*#__PURE__*/ jsx("div", {
308
+ "data-tao-select-empty": "",
309
+ className: cx(classNames?.empty),
310
+ style: styles?.empty,
311
+ children: notFoundContent
312
+ })
396
313
  })
397
- });
398
- $[91] = t15;
399
- $[92] = t17;
400
- $[93] = t18;
401
- } else t18 = $[93];
402
- let t19;
403
- if ($[94] !== onChange || $[95] !== open || $[96] !== resolvedDisabled || $[97] !== t14 || $[98] !== t18 || $[99] !== value) {
404
- t19 = /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Root, {
405
- value: value,
406
- onValueChange: onChange,
407
- disabled: resolvedDisabled,
408
- open: open,
409
- onOpenChange: handleOpenChange,
410
- children: [
411
- t14,
412
- t18
413
- ]
414
- });
415
- $[94] = onChange;
416
- $[95] = open;
417
- $[96] = resolvedDisabled;
418
- $[97] = t14;
419
- $[98] = t18;
420
- $[99] = value;
421
- $[100] = t19;
422
- } else t19 = $[100];
423
- return t19;
424
- }
425
- function _temp(opt) {
426
- return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Item, {
427
- value: opt.value,
428
- disabled: opt.disabled,
429
- "data-tao-select-item": "",
430
- "data-tao-has-desc": null != opt.description || void 0,
314
+ ]
315
+ });
316
+ const container = getPopupContainer && triggerRef.current ? getPopupContainer(triggerRef.current) : void 0;
317
+ return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Root, {
318
+ value: value || void 0,
319
+ onValueChange: handleValueChange,
320
+ disabled: resolvedDisabled,
321
+ open: open,
322
+ onOpenChange: handleOpenChange,
323
+ name: name,
431
324
  children: [
432
- null != opt.icon && /*#__PURE__*/ jsx("span", {
433
- "data-tao-select-item-icon": "",
434
- children: opt.icon
435
- }),
436
- /*#__PURE__*/ jsxs("span", {
437
- "data-tao-select-item-main": "",
325
+ /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_36a82244.Trigger, {
326
+ ref: triggerRef,
327
+ id: id,
328
+ "data-tao-control": "",
329
+ "data-tao-select": "",
330
+ "data-tao-size": resolvedSize,
331
+ "data-tao-variant": resolvedVariant,
332
+ "data-tao-disabled": resolvedDisabled || void 0,
333
+ ...statusProps,
334
+ autoFocus: autoFocus,
335
+ className: cx(classNames?.root, className),
336
+ style: {
337
+ ...styles?.root,
338
+ ...style
339
+ },
340
+ onMouseEnter: ()=>setHovering(true),
341
+ onMouseLeave: ()=>setHovering(false),
438
342
  children: [
439
- /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.ItemText, {
440
- children: opt.label
343
+ null != prefix && /*#__PURE__*/ jsx("span", {
344
+ "data-tao-select-prefix": "",
345
+ className: cx(classNames?.prefix),
346
+ style: styles?.prefix,
347
+ children: prefix
441
348
  }),
442
- null != opt.description && /*#__PURE__*/ jsx("span", {
443
- "data-tao-select-item-desc": "",
444
- children: opt.description
445
- })
349
+ selectedOption?.icon != null && /*#__PURE__*/ jsx("span", {
350
+ "data-tao-select-value-icon": "",
351
+ children: selectedOption.icon
352
+ }),
353
+ /*#__PURE__*/ jsx("span", {
354
+ "data-tao-select-value": "",
355
+ children: triggerLabel
356
+ }),
357
+ trailingIcons
446
358
  ]
447
359
  }),
448
- /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.ItemIndicator, {
449
- "data-tao-select-check": "",
450
- children: /*#__PURE__*/ jsx(CheckIcon, {})
360
+ /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Portal, {
361
+ container: container,
362
+ children: /*#__PURE__*/ jsx(TaoPortalScope, {
363
+ children: /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_36a82244.Content, {
364
+ "data-tao-select-content": "",
365
+ "data-tao-popup-width": false === popupMatchSelectWidth ? 'content' : void 0,
366
+ className: cx(classNames?.popup),
367
+ style: contentStyle,
368
+ position: "popper",
369
+ side: side,
370
+ align: align,
371
+ sideOffset: 4,
372
+ children: popupRender ? popupRender(menuNode) : menuNode
373
+ })
374
+ })
451
375
  })
452
376
  ]
453
- }, opt.value);
377
+ });
454
378
  }
455
379
  function ChevronDownIcon() {
456
380
  const $ = c(1);
@@ -473,6 +397,28 @@ function ChevronDownIcon() {
473
397
  } else t0 = $[0];
474
398
  return t0;
475
399
  }
400
+ function ChevronsUpDownIcon() {
401
+ const $ = c(1);
402
+ let t0;
403
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
404
+ t0 = /*#__PURE__*/ jsx("svg", {
405
+ width: "16",
406
+ height: "16",
407
+ viewBox: "0 0 24 24",
408
+ fill: "none",
409
+ stroke: "currentColor",
410
+ strokeWidth: "2",
411
+ strokeLinecap: "round",
412
+ strokeLinejoin: "round",
413
+ "aria-hidden": "true",
414
+ children: /*#__PURE__*/ jsx("path", {
415
+ d: "m7 15 5 5 5-5M7 9l5-5 5 5"
416
+ })
417
+ });
418
+ $[0] = t0;
419
+ } else t0 = $[0];
420
+ return t0;
421
+ }
476
422
  function CheckIcon() {
477
423
  const $ = c(1);
478
424
  let t0;
@@ -549,8 +495,8 @@ function LoadingIcon() {
549
495
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
550
496
  t0 = /*#__PURE__*/ jsx("svg", {
551
497
  "data-tao-select-loading": "",
552
- width: "14",
553
- height: "14",
498
+ width: "16",
499
+ height: "16",
554
500
  viewBox: "0 0 24 24",
555
501
  fill: "none",
556
502
  stroke: "currentColor",
@@ -565,4 +511,4 @@ function LoadingIcon() {
565
511
  } else t0 = $[0];
566
512
  return t0;
567
513
  }
568
- export { Select };
514
+ export { ChevronsUpDownIcon, Select };