@fangxinyan/lumina 0.9.1 → 0.9.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.
- package/dist/Pagination.cjs +3 -3
- package/dist/Pagination.js +2 -2
- package/dist/{Select-QPBB73KA.css → Select-UTNBARSQ.css} +54 -11
- package/dist/Select.cjs +2 -4
- package/dist/Select.d.cts +7 -1
- package/dist/Select.d.ts +7 -1
- package/dist/Select.js +1 -3
- package/dist/Table.cjs +4 -4
- package/dist/Table.js +3 -3
- package/dist/TablePro.cjs +5 -5
- package/dist/TablePro.js +4 -4
- package/dist/{chunk-HMN65CDW.cjs → chunk-5Q2ZYR5Z.cjs} +2 -2
- package/dist/{chunk-UCE53RYR.js → chunk-6MT3APJ3.js} +1 -1
- package/dist/{chunk-K3KHQ77L.cjs → chunk-7RYLV5CM.cjs} +178 -85
- package/dist/{chunk-AL2PYVVP.js → chunk-AFYNTVSH.js} +178 -85
- package/dist/{chunk-VTN6YLRJ.cjs → chunk-EBU3DTUN.cjs} +2 -2
- package/dist/{chunk-2NECDEAJ.js → chunk-EP7QREID.js} +1 -1
- package/dist/{chunk-7KA5D37Z.cjs → chunk-P3ZIABMZ.cjs} +2 -2
- package/dist/{chunk-JMYUO7V7.js → chunk-X547KNTP.js} +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/styles.css +54 -10
- package/docs/llms/select.md +40 -1
- package/docs/llms.md +1 -1
- package/package.json +1 -1
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkVNP5WB6M_cjs = require('./chunk-VNP5WB6M.cjs');
|
|
4
4
|
var chunkFJB3243S_cjs = require('./chunk-FJB3243S.cjs');
|
|
5
|
-
var chunkGFGMGJ5A_cjs = require('./chunk-GFGMGJ5A.cjs');
|
|
6
5
|
var chunkHSDMJUB6_cjs = require('./chunk-HSDMJUB6.cjs');
|
|
7
6
|
var chunkVDVKY2IX_cjs = require('./chunk-VDVKY2IX.cjs');
|
|
8
7
|
var chunkV6BLBIY6_cjs = require('./chunk-V6BLBIY6.cjs');
|
|
9
8
|
var chunkI4GJZLJU_cjs = require('./chunk-I4GJZLJU.cjs');
|
|
10
9
|
require('./tokens-223RYVVS.css');
|
|
11
10
|
require('./shared-NJHRNLRH.css');
|
|
12
|
-
require('./Select-
|
|
11
|
+
require('./Select-UTNBARSQ.css');
|
|
13
12
|
var React = require('react');
|
|
14
13
|
var reactDom = require('react-dom');
|
|
15
14
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -51,6 +50,10 @@ var defaultFilter = (input, opt, optionFilterProp) => {
|
|
|
51
50
|
const txt = propValue != null ? String(propValue) : opt.text ?? (typeof opt.label === "string" ? opt.label : String(opt.value));
|
|
52
51
|
return txt.toLowerCase().includes(q);
|
|
53
52
|
};
|
|
53
|
+
var getSearchInputDisplayWidth = (value) => Array.from(value).reduce(
|
|
54
|
+
(width, character) => width + ((character.codePointAt(0) ?? 0) > 255 ? 2 : 1),
|
|
55
|
+
0
|
|
56
|
+
);
|
|
54
57
|
var getOptionAriaLabel = (option) => {
|
|
55
58
|
if (option.ariaLabel) return option.ariaLabel;
|
|
56
59
|
if (typeof option.label === "string" || typeof option.label === "number") {
|
|
@@ -69,6 +72,9 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
69
72
|
allowClear,
|
|
70
73
|
searchable,
|
|
71
74
|
showSearch,
|
|
75
|
+
searchValue: searchValueProp,
|
|
76
|
+
defaultSearchValue,
|
|
77
|
+
onSearch,
|
|
72
78
|
filterOption,
|
|
73
79
|
optionFilterProp,
|
|
74
80
|
loading,
|
|
@@ -117,7 +123,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
117
123
|
isMulti && Array.isArray(props.defaultValue) ? props.defaultValue : []
|
|
118
124
|
);
|
|
119
125
|
const [innerOpen, setInnerOpen] = React__namespace.useState(defaultOpen ?? false);
|
|
120
|
-
const [
|
|
126
|
+
const [innerSearchValue, setInnerSearchValue] = React__namespace.useState(defaultSearchValue ?? "");
|
|
121
127
|
const [activeIdx, setActiveIdx] = React__namespace.useState(-1);
|
|
122
128
|
const searchRef = React__namespace.useRef(null);
|
|
123
129
|
const portalContainer = chunkI4GJZLJU_cjs.usePortalContainer();
|
|
@@ -136,12 +142,29 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
136
142
|
const openControlled = openProp !== void 0;
|
|
137
143
|
const requestedOpen = openControlled ? openProp : innerOpen;
|
|
138
144
|
const open = !disabled && requestedOpen;
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
const requestedOpenRef = React__namespace.useRef(requestedOpen);
|
|
146
|
+
requestedOpenRef.current = requestedOpen;
|
|
147
|
+
const searchControlled = searchValueProp !== void 0;
|
|
148
|
+
const searchValue = searchControlled ? searchValueProp : innerSearchValue;
|
|
149
|
+
const hasInlineSearch = mergedSearchable;
|
|
150
|
+
const showsInlineSearchInput = hasInlineSearch && (isMulti || open);
|
|
151
|
+
const updateSearchValue = React__namespace.useCallback((nextValue) => {
|
|
152
|
+
if (!searchControlled) setInnerSearchValue(nextValue);
|
|
153
|
+
onSearch?.(nextValue);
|
|
154
|
+
}, [onSearch, searchControlled]);
|
|
155
|
+
const resetSearchValue = React__namespace.useCallback(() => {
|
|
156
|
+
if (!searchValue) return;
|
|
157
|
+
if (!searchControlled) setInnerSearchValue("");
|
|
158
|
+
onSearch?.("");
|
|
159
|
+
}, [onSearch, searchControlled, searchValue]);
|
|
160
|
+
const setOpen = React__namespace.useCallback((nextOpen) => {
|
|
161
|
+
if (disabled && nextOpen) return;
|
|
162
|
+
if (nextOpen === requestedOpenRef.current) return;
|
|
163
|
+
requestedOpenRef.current = nextOpen;
|
|
164
|
+
if (!openControlled) setInnerOpen(nextOpen);
|
|
165
|
+
onOpenChange?.(nextOpen);
|
|
166
|
+
if (!nextOpen) resetSearchValue();
|
|
167
|
+
}, [disabled, onOpenChange, openControlled, resetSearchValue]);
|
|
145
168
|
React__namespace.useEffect(() => {
|
|
146
169
|
if (!disabled || openControlled || !innerOpen) return;
|
|
147
170
|
setInnerOpen(false);
|
|
@@ -152,7 +175,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
152
175
|
placement: "bottom",
|
|
153
176
|
matchTriggerWidth: !hasCustomPopupWidth,
|
|
154
177
|
panelWidth: typeof resolvedPopupWidth === "number" ? resolvedPopupWidth : 360,
|
|
155
|
-
panelHeight: mergedListHeight +
|
|
178
|
+
panelHeight: mergedListHeight + 12
|
|
156
179
|
});
|
|
157
180
|
chunkHSDMJUB6_cjs.useOverlayLayer({
|
|
158
181
|
open: open && portalContainer != null,
|
|
@@ -194,7 +217,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
194
217
|
};
|
|
195
218
|
document.addEventListener("mousedown", h);
|
|
196
219
|
return () => document.removeEventListener("mousedown", h);
|
|
197
|
-
}, [open]);
|
|
220
|
+
}, [menuRef, open, setOpen, triggerRef]);
|
|
198
221
|
React__namespace.useEffect(() => {
|
|
199
222
|
if (open && mergedSearchable) {
|
|
200
223
|
requestAnimationFrame(() => searchRef.current?.focus());
|
|
@@ -206,14 +229,32 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
206
229
|
[options]
|
|
207
230
|
);
|
|
208
231
|
const allFlat = React__namespace.useMemo(() => flatten(orderedItems), [orderedItems]);
|
|
232
|
+
const optionByValue = React__namespace.useMemo(() => {
|
|
233
|
+
const index = /* @__PURE__ */ new Map();
|
|
234
|
+
allFlat.forEach((option) => index.set(option.value, option));
|
|
235
|
+
return index;
|
|
236
|
+
}, [allFlat]);
|
|
237
|
+
const selectedOptionCacheRef = React__namespace.useRef(/* @__PURE__ */ new Map());
|
|
238
|
+
React__namespace.useEffect(() => {
|
|
239
|
+
selectedValues.forEach((selectedValue) => {
|
|
240
|
+
const option = optionByValue.get(selectedValue);
|
|
241
|
+
if (option) selectedOptionCacheRef.current.set(selectedValue, option);
|
|
242
|
+
});
|
|
243
|
+
}, [optionByValue, selectedValues]);
|
|
244
|
+
const selectedOptions = React__namespace.useMemo(
|
|
245
|
+
() => selectedValues.map(
|
|
246
|
+
(selectedValue) => optionByValue.get(selectedValue) ?? selectedOptionCacheRef.current.get(selectedValue)
|
|
247
|
+
).filter((option) => option !== void 0),
|
|
248
|
+
[optionByValue, selectedValues]
|
|
249
|
+
);
|
|
209
250
|
const filteredFlat = React__namespace.useMemo(() => {
|
|
210
|
-
if (!
|
|
251
|
+
if (!searchValue.trim()) return allFlat;
|
|
211
252
|
if (filterOption === false) return allFlat;
|
|
212
253
|
const f = typeof filterOption === "function" ? filterOption : (input, option) => defaultFilter(input, option, optionFilterProp);
|
|
213
|
-
return allFlat.filter((o) => f(
|
|
214
|
-
}, [allFlat,
|
|
254
|
+
return allFlat.filter((o) => f(searchValue, o));
|
|
255
|
+
}, [allFlat, filterOption, optionFilterProp, searchValue]);
|
|
215
256
|
const filteredItems = React__namespace.useMemo(() => {
|
|
216
|
-
if (!
|
|
257
|
+
if (!searchValue.trim()) {
|
|
217
258
|
return orderedItems.filter((item) => !isGroup(item) || item.options.length > 0);
|
|
218
259
|
}
|
|
219
260
|
return orderedItems.map((it) => {
|
|
@@ -223,7 +264,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
223
264
|
const kept = it.options.filter((o) => filteredFlat.includes(o));
|
|
224
265
|
return kept.length ? { ...it, options: kept } : null;
|
|
225
266
|
}).filter((x) => x !== null);
|
|
226
|
-
}, [orderedItems, filteredFlat,
|
|
267
|
+
}, [orderedItems, filteredFlat, searchValue]);
|
|
227
268
|
React__namespace.useEffect(() => {
|
|
228
269
|
setActiveIdx((current) => {
|
|
229
270
|
if (current >= 0 && current < filteredFlat.length && !isOptionDisabled(filteredFlat[current])) {
|
|
@@ -234,6 +275,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
234
275
|
}, [filteredFlat, isOptionDisabled]);
|
|
235
276
|
const pickSingle = (opt) => {
|
|
236
277
|
if (disabled || isOptionDisabled(opt)) return;
|
|
278
|
+
selectedOptionCacheRef.current.set(opt.value, opt);
|
|
237
279
|
if (!singleControlled) setInnerSingle(opt.value);
|
|
238
280
|
props.onChange?.(opt.value);
|
|
239
281
|
setOpen(false);
|
|
@@ -242,8 +284,17 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
242
284
|
if (disabled || isOptionDisabled(opt)) return;
|
|
243
285
|
const cur = multiValue ?? [];
|
|
244
286
|
const next = cur.includes(opt.value) ? cur.filter((v) => v !== opt.value) : [...cur, opt.value];
|
|
287
|
+
selectedOptionCacheRef.current.set(opt.value, opt);
|
|
288
|
+
if (!multiControlled) setInnerMulti(next);
|
|
289
|
+
props.onChange?.(next);
|
|
290
|
+
if (hasInlineSearch) requestAnimationFrame(() => searchRef.current?.focus());
|
|
291
|
+
};
|
|
292
|
+
const removeMultiValue = (removedValue) => {
|
|
293
|
+
if (disabled) return;
|
|
294
|
+
const next = (multiValue ?? []).filter((value) => value !== removedValue);
|
|
245
295
|
if (!multiControlled) setInnerMulti(next);
|
|
246
296
|
props.onChange?.(next);
|
|
297
|
+
if (hasInlineSearch) requestAnimationFrame(() => searchRef.current?.focus());
|
|
247
298
|
};
|
|
248
299
|
const clearAll = () => {
|
|
249
300
|
if (disabled) return;
|
|
@@ -259,13 +310,20 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
259
310
|
};
|
|
260
311
|
const isSelected = (val) => isMulti ? (multiValue ?? []).includes(val) : singleValue === val;
|
|
261
312
|
const onKeyDown = (e) => {
|
|
262
|
-
|
|
313
|
+
const fromSearchInput = e.target === searchRef.current;
|
|
314
|
+
if (e.nativeEvent.isComposing || e.keyCode === 229) return;
|
|
315
|
+
if (fromSearchInput && e.key === "Backspace" && !searchValue && isMulti && multiValue.length > 0) {
|
|
316
|
+
e.preventDefault();
|
|
317
|
+
removeMultiValue(multiValue[multiValue.length - 1]);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (!fromSearchInput && (e.key === "Backspace" || e.key === "Delete") && showClear) {
|
|
263
321
|
e.preventDefault();
|
|
264
322
|
clearAll();
|
|
265
323
|
return;
|
|
266
324
|
}
|
|
267
325
|
if (!open) {
|
|
268
|
-
if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") {
|
|
326
|
+
if (e.key === "Enter" || !fromSearchInput && e.key === " " || e.key === "ArrowDown") {
|
|
269
327
|
e.preventDefault();
|
|
270
328
|
setOpen(true);
|
|
271
329
|
}
|
|
@@ -308,13 +366,48 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
308
366
|
return;
|
|
309
367
|
}
|
|
310
368
|
};
|
|
369
|
+
const renderInlineSearchInput = () => {
|
|
370
|
+
if (!showsInlineSearchInput) return null;
|
|
371
|
+
const multiHasSelection = isMulti && multiValue.length > 0;
|
|
372
|
+
const searchDisplayWidth = getSearchInputDisplayWidth(searchValue);
|
|
373
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
374
|
+
"input",
|
|
375
|
+
{
|
|
376
|
+
ref: searchRef,
|
|
377
|
+
id: fieldId,
|
|
378
|
+
className: "select-search-input",
|
|
379
|
+
"data-inline-size": multiHasSelection ? "content" : "fill",
|
|
380
|
+
type: "search",
|
|
381
|
+
value: searchValue,
|
|
382
|
+
style: multiHasSelection ? { width: `${Math.min(Math.max(searchDisplayWidth + 1, 2), 32)}ch` } : void 0,
|
|
383
|
+
placeholder: isMulti ? multiValue.length === 0 ? placeholder : void 0 : "\u641C\u7D22...",
|
|
384
|
+
disabled,
|
|
385
|
+
autoComplete: "off",
|
|
386
|
+
role: "combobox",
|
|
387
|
+
"aria-autocomplete": "list",
|
|
388
|
+
"aria-label": ariaLabel,
|
|
389
|
+
"aria-labelledby": ariaLabelledBy,
|
|
390
|
+
"aria-invalid": ariaInvalid,
|
|
391
|
+
"aria-required": ariaRequired,
|
|
392
|
+
"aria-describedby": ariaDescribedBy,
|
|
393
|
+
"aria-haspopup": "listbox",
|
|
394
|
+
"aria-expanded": open,
|
|
395
|
+
"aria-controls": open ? listboxId : void 0,
|
|
396
|
+
"aria-activedescendant": open && activeIdx >= 0 ? `${listboxId}-option-${activeIdx}` : void 0,
|
|
397
|
+
onChange: (event) => {
|
|
398
|
+
updateSearchValue(event.target.value);
|
|
399
|
+
if (!open) setOpen(true);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
};
|
|
311
404
|
const renderTrigger = () => {
|
|
312
405
|
if (isMulti) {
|
|
313
|
-
const selected =
|
|
406
|
+
const selected = selectedOptions;
|
|
314
407
|
const max = maxTagCount;
|
|
315
408
|
const shown = max != null ? selected.slice(0, max) : selected;
|
|
316
409
|
const overflow = selected.length - shown.length;
|
|
317
|
-
if (selected.length === 0) {
|
|
410
|
+
if (selected.length === 0 && !hasInlineSearch) {
|
|
318
411
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "placeholder", children: placeholder });
|
|
319
412
|
}
|
|
320
413
|
return /* @__PURE__ */ jsxRuntime.jsx(chunkV6BLBIY6_cjs.InternalComponentThemePart, { components: "Tag", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "select-tags", children: [
|
|
@@ -323,24 +416,25 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
323
416
|
{
|
|
324
417
|
tone: "accent",
|
|
325
418
|
removable: !disabled,
|
|
326
|
-
onRemove: () =>
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
props.onChange?.(next);
|
|
419
|
+
onRemove: () => removeMultiValue(o.value),
|
|
420
|
+
onMouseDown: (event) => {
|
|
421
|
+
event.preventDefault();
|
|
422
|
+
event.stopPropagation();
|
|
331
423
|
},
|
|
332
424
|
onClick: (e) => e.stopPropagation(),
|
|
333
|
-
children: selectedRender?.(o, { value: o.value, multiple: true }) ?? o.label
|
|
425
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "select-tag-label", children: selectedRender?.(o, { value: o.value, multiple: true }) ?? o.label })
|
|
334
426
|
},
|
|
335
427
|
String(o.value)
|
|
336
428
|
)),
|
|
337
|
-
overflow > 0 && /* @__PURE__ */ jsxRuntime.jsxs(chunkVNP5WB6M_cjs.Tag, { tone: "neutral", children: [
|
|
429
|
+
overflow > 0 && /* @__PURE__ */ jsxRuntime.jsxs(chunkVNP5WB6M_cjs.Tag, { className: "select-tag-overflow", tone: "neutral", children: [
|
|
338
430
|
"+",
|
|
339
431
|
overflow
|
|
340
|
-
] })
|
|
432
|
+
] }),
|
|
433
|
+
renderInlineSearchInput()
|
|
341
434
|
] }) });
|
|
342
435
|
}
|
|
343
|
-
|
|
436
|
+
if (showsInlineSearchInput) return renderInlineSearchInput();
|
|
437
|
+
const current = selectedOptions[0];
|
|
344
438
|
if (!current) return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "placeholder", children: placeholder });
|
|
345
439
|
if (selectedRender) {
|
|
346
440
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "select-value select-value-custom", children: selectedRender(current, { value: current.value, multiple: false }) });
|
|
@@ -387,6 +481,9 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
387
481
|
"aria-label": getOptionAriaLabel(o),
|
|
388
482
|
disabled: optionDisabled,
|
|
389
483
|
className: `menu-item ${sel ? "active" : ""} ${active ? "highlight" : ""}`,
|
|
484
|
+
onMouseDown: (event) => {
|
|
485
|
+
if (hasInlineSearch) event.preventDefault();
|
|
486
|
+
},
|
|
390
487
|
onClick: () => isMulti ? toggleMulti(o) : pickSingle(o),
|
|
391
488
|
children: [
|
|
392
489
|
isMulti && /* @__PURE__ */ jsxRuntime.jsx("span", { className: `menu-check ${sel ? "on" : ""}`, "aria-hidden": true, children: sel && /* @__PURE__ */ jsxRuntime.jsx(chunkVDVKY2IX_cjs.Icon, { name: "check", size: 11, stroke: 3 }) }),
|
|
@@ -413,15 +510,32 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
413
510
|
item.options.map((option) => renderOption(option, !!item.pinned))
|
|
414
511
|
] }, `g-${groupIndex}-${item.pinned ? "pinned" : "regular"}`) : renderOption(item)
|
|
415
512
|
);
|
|
513
|
+
const handleTriggerClick = (event) => {
|
|
514
|
+
if (disabled) return;
|
|
515
|
+
if (!hasInlineSearch) {
|
|
516
|
+
setOpen(!open);
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
const target = event.target;
|
|
520
|
+
if (target.closest(".select-caret")) {
|
|
521
|
+
setOpen(!open);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
setOpen(true);
|
|
525
|
+
searchRef.current?.focus();
|
|
526
|
+
};
|
|
416
527
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
417
528
|
"div",
|
|
418
529
|
{
|
|
419
530
|
ref: setTriggerRef,
|
|
420
531
|
...rest,
|
|
421
|
-
className: `select ${size} ${isMulti ? "multi" : ""} ${open ? "open" : ""} ${disabled ? "disabled" : ""} ${invalid ? "invalid" : ""} ${className}`,
|
|
532
|
+
className: `select ${size} ${isMulti ? "multi" : ""} ${hasInlineSearch ? "searchable" : ""} ${open ? "open" : ""} ${disabled ? "disabled" : ""} ${invalid ? "invalid" : ""} ${className}`,
|
|
422
533
|
onKeyDown: (e) => {
|
|
423
534
|
onRootKeyDown?.(e);
|
|
424
|
-
|
|
535
|
+
const target = e.target;
|
|
536
|
+
if (!e.defaultPrevented && (target.classList.contains("select-trigger") || target === searchRef.current)) {
|
|
537
|
+
onKeyDown(e);
|
|
538
|
+
}
|
|
425
539
|
},
|
|
426
540
|
onBlur: (event) => {
|
|
427
541
|
onRootBlur?.(event);
|
|
@@ -446,20 +560,20 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
446
560
|
"div",
|
|
447
561
|
{
|
|
448
562
|
className: "select-trigger",
|
|
449
|
-
onClick:
|
|
450
|
-
tabIndex: disabled ? -1 : triggerTabIndex ?? 0,
|
|
451
|
-
id: fieldId,
|
|
452
|
-
role: "combobox",
|
|
453
|
-
"aria-disabled": disabled || void 0,
|
|
454
|
-
"aria-label": ariaLabel,
|
|
455
|
-
"aria-labelledby": ariaLabelledBy,
|
|
456
|
-
"aria-invalid": ariaInvalid,
|
|
457
|
-
"aria-required": ariaRequired,
|
|
458
|
-
"aria-describedby": ariaDescribedBy,
|
|
459
|
-
"aria-haspopup": "listbox",
|
|
460
|
-
"aria-expanded": open,
|
|
461
|
-
"aria-controls": open ? listboxId : void 0,
|
|
462
|
-
"aria-activedescendant": open && activeIdx >= 0 ? `${listboxId}-option-${activeIdx}` : void 0,
|
|
563
|
+
onClick: handleTriggerClick,
|
|
564
|
+
tabIndex: showsInlineSearchInput || disabled ? -1 : triggerTabIndex ?? 0,
|
|
565
|
+
id: showsInlineSearchInput ? void 0 : fieldId,
|
|
566
|
+
role: showsInlineSearchInput ? void 0 : "combobox",
|
|
567
|
+
"aria-disabled": showsInlineSearchInput ? void 0 : disabled || void 0,
|
|
568
|
+
"aria-label": showsInlineSearchInput ? void 0 : ariaLabel,
|
|
569
|
+
"aria-labelledby": showsInlineSearchInput ? void 0 : ariaLabelledBy,
|
|
570
|
+
"aria-invalid": showsInlineSearchInput ? void 0 : ariaInvalid,
|
|
571
|
+
"aria-required": showsInlineSearchInput ? void 0 : ariaRequired,
|
|
572
|
+
"aria-describedby": showsInlineSearchInput ? void 0 : ariaDescribedBy,
|
|
573
|
+
"aria-haspopup": showsInlineSearchInput ? void 0 : "listbox",
|
|
574
|
+
"aria-expanded": showsInlineSearchInput ? void 0 : open,
|
|
575
|
+
"aria-controls": showsInlineSearchInput ? void 0 : open ? listboxId : void 0,
|
|
576
|
+
"aria-activedescendant": showsInlineSearchInput ? void 0 : open && activeIdx >= 0 ? `${listboxId}-option-${activeIdx}` : void 0,
|
|
463
577
|
children: [
|
|
464
578
|
renderTrigger(),
|
|
465
579
|
/* @__PURE__ */ jsxRuntime.jsx(chunkVDVKY2IX_cjs.Icon, { name: "chevDown", size: 14, className: "select-caret" })
|
|
@@ -473,7 +587,10 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
473
587
|
className: "select-clear",
|
|
474
588
|
"aria-label": "Clear",
|
|
475
589
|
onPointerDown: (event) => event.stopPropagation(),
|
|
476
|
-
onMouseDown: (event) =>
|
|
590
|
+
onMouseDown: (event) => {
|
|
591
|
+
if (hasInlineSearch) event.preventDefault();
|
|
592
|
+
event.stopPropagation();
|
|
593
|
+
},
|
|
477
594
|
onClick: (event) => {
|
|
478
595
|
event.stopPropagation();
|
|
479
596
|
clearAll();
|
|
@@ -482,7 +599,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
482
599
|
}
|
|
483
600
|
),
|
|
484
601
|
open && portalContainer && reactDom.createPortal(
|
|
485
|
-
/* @__PURE__ */ jsxRuntime.
|
|
602
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
486
603
|
"div",
|
|
487
604
|
{
|
|
488
605
|
ref: menuRef,
|
|
@@ -497,44 +614,20 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
497
614
|
...portalTheme.styles.popup,
|
|
498
615
|
...popupStyle
|
|
499
616
|
},
|
|
500
|
-
children:
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
"
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
onValueChange: setQuery,
|
|
515
|
-
onKeyDown: (e) => {
|
|
516
|
-
if (e.key === "Escape" || e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Enter") {
|
|
517
|
-
e.preventDefault();
|
|
518
|
-
onKeyDown(e);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
) }) }),
|
|
523
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
524
|
-
"div",
|
|
525
|
-
{
|
|
526
|
-
className: "menu-options",
|
|
527
|
-
style: { maxHeight: mergedListHeight },
|
|
528
|
-
children: loading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "menu-state", children: [
|
|
529
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "menu-state-ico", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "spinner" }) }),
|
|
530
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u52A0\u8F7D\u4E2D..." })
|
|
531
|
-
] }) : filteredFlat.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "menu-state", children: [
|
|
532
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "menu-state-ico", children: /* @__PURE__ */ jsxRuntime.jsx(chunkVDVKY2IX_cjs.Icon, { name: "search", size: 16 }) }),
|
|
533
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: emptyContent ?? "\u6682\u65E0\u5339\u914D\u9879" })
|
|
534
|
-
] }) : renderMenuItems(filteredItems)
|
|
535
|
-
}
|
|
536
|
-
)
|
|
537
|
-
]
|
|
617
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
618
|
+
"div",
|
|
619
|
+
{
|
|
620
|
+
className: "menu-options",
|
|
621
|
+
style: { maxHeight: mergedListHeight },
|
|
622
|
+
children: loading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "menu-state", children: [
|
|
623
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "menu-state-ico", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "spinner" }) }),
|
|
624
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u52A0\u8F7D\u4E2D..." })
|
|
625
|
+
] }) : filteredFlat.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "menu-state", children: [
|
|
626
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "menu-state-ico", children: /* @__PURE__ */ jsxRuntime.jsx(chunkVDVKY2IX_cjs.Icon, { name: "search", size: 16 }) }),
|
|
627
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: emptyContent ?? "\u6682\u65E0\u5339\u914D\u9879" })
|
|
628
|
+
] }) : renderMenuItems(filteredItems)
|
|
629
|
+
}
|
|
630
|
+
)
|
|
538
631
|
}
|
|
539
632
|
),
|
|
540
633
|
portalContainer
|