@fangxinyan/lumina 0.9.3 → 0.9.5
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/AutoComplete.cjs +4 -4
- package/dist/AutoComplete.js +3 -3
- package/dist/Cascader.cjs +4 -4
- package/dist/Cascader.js +3 -3
- package/dist/ColorPicker.cjs +4 -4
- package/dist/ColorPicker.js +3 -3
- package/dist/CommandPalette.cjs +3 -3
- package/dist/CommandPalette.js +2 -2
- package/dist/ContextMenu.cjs +3 -3
- package/dist/ContextMenu.js +2 -2
- package/dist/DatePicker.cjs +5 -5
- package/dist/DatePicker.js +4 -4
- package/dist/DateTimePicker.cjs +5 -5
- package/dist/DateTimePicker.js +4 -4
- package/dist/Drawer.cjs +3 -3
- package/dist/Drawer.js +2 -2
- package/dist/Form.cjs +5 -5
- package/dist/Form.js +2 -2
- package/dist/Image.cjs +6 -6
- package/dist/Image.js +2 -2
- package/dist/Message.cjs +6 -6
- package/dist/Message.js +2 -2
- package/dist/Modal.cjs +3 -3
- package/dist/Modal.js +2 -2
- package/dist/Pagination.cjs +5 -5
- package/dist/Pagination.js +4 -4
- package/dist/Popover.cjs +4 -4
- package/dist/Popover.js +3 -3
- package/dist/{Select-UTNBARSQ.css → Select-M3HCB3PW.css} +66 -0
- package/dist/Select.cjs +4 -4
- package/dist/Select.d.cts +6 -2
- package/dist/Select.d.ts +6 -2
- package/dist/Select.js +3 -3
- package/dist/Table.cjs +6 -6
- package/dist/Table.js +5 -5
- package/dist/TablePro.cjs +7 -7
- package/dist/TablePro.js +6 -6
- package/dist/ThemePanel.cjs +7 -7
- package/dist/ThemePanel.js +4 -4
- package/dist/TimePicker.cjs +5 -5
- package/dist/TimePicker.js +4 -4
- package/dist/Tooltip.cjs +4 -4
- package/dist/Tooltip.js +3 -3
- package/dist/Typography.cjs +8 -8
- package/dist/Typography.js +3 -3
- package/dist/{chunk-7PUYEPLK.js → chunk-4K6PQCWU.js} +1 -1
- package/dist/{chunk-ZT7ZWAF2.cjs → chunk-5OQB5UUT.cjs} +6 -6
- package/dist/{chunk-Z7GKR4LL.js → chunk-5PDEOGFV.js} +2 -2
- package/dist/{chunk-AE5XWZ24.cjs → chunk-5PGRAEGA.cjs} +4 -4
- package/dist/{chunk-FJB3243S.cjs → chunk-6A5KEWVU.cjs} +2 -2
- package/dist/{chunk-6MT3APJ3.js → chunk-6EHKQDMX.js} +1 -1
- package/dist/{chunk-GW77XQEF.cjs → chunk-73IEJLSD.cjs} +6 -6
- package/dist/{chunk-EBU3DTUN.cjs → chunk-757JNNLH.cjs} +2 -2
- package/dist/{chunk-TNQJA5JF.js → chunk-7QKSXVN3.js} +1 -1
- package/dist/{chunk-MEBAE7DB.js → chunk-AEMDX4S7.js} +2 -2
- package/dist/{chunk-3J7HOTD6.cjs → chunk-BCQIVYL6.cjs} +4 -4
- package/dist/{chunk-4ZSFMWLF.cjs → chunk-BM2J5QAE.cjs} +4 -4
- package/dist/{chunk-HSDMJUB6.cjs → chunk-BN44QG2B.cjs} +14 -1
- package/dist/{chunk-2A4GYSN4.js → chunk-BZB45GGK.js} +14 -2
- package/dist/{chunk-P3ZIABMZ.cjs → chunk-D5HLHN5N.cjs} +6 -6
- package/dist/{chunk-35RCCUGO.cjs → chunk-ELKGV3NA.cjs} +3 -3
- package/dist/{chunk-2V6RQQRI.js → chunk-G4E5QA2M.js} +1 -1
- package/dist/{chunk-MKVONDTB.js → chunk-G62HAXAL.js} +3 -3
- package/dist/{chunk-7IWUBBYX.cjs → chunk-HPNZDAXF.cjs} +6 -6
- package/dist/{chunk-AR3MT2ZT.cjs → chunk-IM47JR57.cjs} +4 -4
- package/dist/{chunk-5Q2ZYR5Z.cjs → chunk-JNDATLOY.cjs} +2 -2
- package/dist/{chunk-QK3E6FAQ.js → chunk-K4P45V67.js} +1 -1
- package/dist/{chunk-A34P5CU7.js → chunk-KJG44Z5J.js} +2 -2
- package/dist/{chunk-TPFY5SKB.cjs → chunk-L6ELDWUX.cjs} +2 -2
- package/dist/{chunk-AQN3PD24.cjs → chunk-LDZCDOMW.cjs} +2 -2
- package/dist/{chunk-XHKSUKKL.cjs → chunk-LQKP7MEA.cjs} +4 -4
- package/dist/{chunk-7ZMUCSCJ.cjs → chunk-M4GXFACD.cjs} +4 -4
- package/dist/{chunk-IU6PLLEL.js → chunk-MAXOCM5I.js} +1 -1
- package/dist/{chunk-HJGPUE67.cjs → chunk-NALBGFHY.cjs} +4 -4
- package/dist/{chunk-3QXP2ZNP.js → chunk-NKIXCDZC.js} +1 -1
- package/dist/{chunk-RWM44VCZ.cjs → chunk-OA3O5S7X.cjs} +4 -4
- package/dist/{chunk-EP7QREID.js → chunk-PK5ZMOW6.js} +1 -1
- package/dist/{chunk-BDPJ2BPN.js → chunk-QS4GORDY.js} +1 -1
- package/dist/{chunk-ZGZLEJKA.cjs → chunk-QV4SPR4Z.cjs} +3 -3
- package/dist/{chunk-2COQYOVG.js → chunk-QVDW32F2.js} +2 -2
- package/dist/{chunk-AFYNTVSH.js → chunk-ROCX6JDG.js} +130 -58
- package/dist/{chunk-X547KNTP.js → chunk-S6KPLYLT.js} +3 -3
- package/dist/{chunk-RC6ULCQP.js → chunk-SW3KEFIA.js} +3 -3
- package/dist/{chunk-QI6BJJXM.cjs → chunk-U5B2JLNE.cjs} +3 -3
- package/dist/{chunk-CFKAKB2B.js → chunk-UNUFUTFQ.js} +2 -2
- package/dist/{chunk-3D5RJA7R.cjs → chunk-UOXJH4AR.cjs} +4 -4
- package/dist/{chunk-DQMG4XPX.js → chunk-VSIBZ7VH.js} +3 -3
- package/dist/{chunk-TALNKJQ2.js → chunk-WOE73NDO.js} +2 -2
- package/dist/{chunk-7RYLV5CM.cjs → chunk-XPFAAATJ.cjs} +133 -61
- package/dist/{chunk-INCTDROH.js → chunk-XX7YYKIJ.js} +1 -1
- package/dist/{chunk-RJCPXAZ3.js → chunk-XXCKQSWD.js} +1 -1
- package/dist/{chunk-SOAGRYM3.cjs → chunk-ZNSTIRSE.cjs} +4 -4
- package/dist/{chunk-SXT672KF.js → chunk-ZP4ROQEZ.js} +3 -3
- package/dist/index.cjs +60 -60
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -25
- package/dist/styles.css +65 -0
- package/docs/llms/datepicker.md +26 -1
- package/docs/llms/datetimepicker.md +3 -1
- package/docs/llms/select.md +15 -1
- package/docs/llms/timepicker.md +3 -1
- package/docs/llms.md +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkVNP5WB6M_cjs = require('./chunk-VNP5WB6M.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunk6A5KEWVU_cjs = require('./chunk-6A5KEWVU.cjs');
|
|
5
|
+
var chunkBN44QG2B_cjs = require('./chunk-BN44QG2B.cjs');
|
|
6
6
|
var chunkVDVKY2IX_cjs = require('./chunk-VDVKY2IX.cjs');
|
|
7
7
|
var chunkV6BLBIY6_cjs = require('./chunk-V6BLBIY6.cjs');
|
|
8
8
|
var chunkI4GJZLJU_cjs = require('./chunk-I4GJZLJU.cjs');
|
|
9
9
|
require('./tokens-223RYVVS.css');
|
|
10
10
|
require('./shared-NJHRNLRH.css');
|
|
11
|
-
require('./Select-
|
|
12
|
-
var
|
|
11
|
+
require('./Select-M3HCB3PW.css');
|
|
12
|
+
var React2 = require('react');
|
|
13
13
|
var reactDom = require('react-dom');
|
|
14
14
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
15
|
|
|
@@ -31,8 +31,64 @@ function _interopNamespace(e) {
|
|
|
31
31
|
return Object.freeze(n);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
35
35
|
|
|
36
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React2__namespace.useLayoutEffect : React2__namespace.useEffect;
|
|
37
|
+
function measureResponsiveTags(container) {
|
|
38
|
+
const availableWidth = container.getBoundingClientRect().width;
|
|
39
|
+
if (availableWidth <= 0) return void 0;
|
|
40
|
+
const tags = Array.from(container.querySelectorAll("[data-select-tag]"));
|
|
41
|
+
const overflows = Array.from(container.querySelectorAll("[data-select-overflow]"));
|
|
42
|
+
const search = container.querySelector(".select-search-measure");
|
|
43
|
+
const gap = parseFloat(getComputedStyle(container).columnGap) || 0;
|
|
44
|
+
const tagWidths = tags.map((tag) => tag.getBoundingClientRect().width);
|
|
45
|
+
const overflowWidths = [0, ...overflows.map((tag) => tag.getBoundingClientRect().width)];
|
|
46
|
+
const inputWidth = search ? Math.min(search.getBoundingClientRect().width, Math.max(
|
|
47
|
+
0,
|
|
48
|
+
availableWidth - (overflowWidths[tags.length] ?? 0) - (tags.length > 0 ? gap : 0)
|
|
49
|
+
)) : 0;
|
|
50
|
+
let count = 0;
|
|
51
|
+
let prefixWidth = 0;
|
|
52
|
+
for (let index = 0; index <= tags.length; index += 1) {
|
|
53
|
+
const remaining = tags.length - index;
|
|
54
|
+
const itemCount = index + (remaining > 0 ? 1 : 0) + (search ? 1 : 0);
|
|
55
|
+
const width = prefixWidth + (overflowWidths[remaining] ?? 0) + inputWidth + Math.max(0, itemCount - 1) * gap;
|
|
56
|
+
if (width <= availableWidth) count = index;
|
|
57
|
+
prefixWidth += tagWidths[index] ?? 0;
|
|
58
|
+
}
|
|
59
|
+
return { count, inputWidth };
|
|
60
|
+
}
|
|
61
|
+
function useResponsiveTags(enabled, items, searchable) {
|
|
62
|
+
const tagsRef = React2__namespace.useRef(null);
|
|
63
|
+
const [layout, setLayout] = React2__namespace.useState({ count: 0, inputWidth: 0 });
|
|
64
|
+
const measure = React2__namespace.useCallback(() => {
|
|
65
|
+
if (!tagsRef.current) return;
|
|
66
|
+
const next = measureResponsiveTags(tagsRef.current);
|
|
67
|
+
if (next) setLayout((previous) => previous.count === next.count && previous.inputWidth === next.inputWidth ? previous : next);
|
|
68
|
+
}, []);
|
|
69
|
+
useIsomorphicLayoutEffect(() => {
|
|
70
|
+
if (enabled) measure();
|
|
71
|
+
});
|
|
72
|
+
useIsomorphicLayoutEffect(() => {
|
|
73
|
+
const container = tagsRef.current;
|
|
74
|
+
if (!enabled || !container) return;
|
|
75
|
+
let frame = 0;
|
|
76
|
+
const scheduleMeasure = () => {
|
|
77
|
+
cancelAnimationFrame(frame);
|
|
78
|
+
frame = requestAnimationFrame(measure);
|
|
79
|
+
};
|
|
80
|
+
const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(scheduleMeasure) : void 0;
|
|
81
|
+
observer?.observe(container);
|
|
82
|
+
container.querySelectorAll("[data-select-tag], [data-select-overflow], .select-search-measure").forEach((element) => observer?.observe(element));
|
|
83
|
+
window.addEventListener("resize", scheduleMeasure);
|
|
84
|
+
return () => {
|
|
85
|
+
observer?.disconnect();
|
|
86
|
+
window.removeEventListener("resize", scheduleMeasure);
|
|
87
|
+
cancelAnimationFrame(frame);
|
|
88
|
+
};
|
|
89
|
+
}, [enabled, items, searchable, measure]);
|
|
90
|
+
return { tagsRef, count: Math.min(layout.count, items.length), inputWidth: layout.inputWidth };
|
|
91
|
+
}
|
|
36
92
|
var isGroup = (it) => Array.isArray(it.options);
|
|
37
93
|
var flatten = (items) => items.flatMap((it) => isGroup(it) ? it.options : [it]);
|
|
38
94
|
var prioritizePinnedGroups = (items) => {
|
|
@@ -111,21 +167,22 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
111
167
|
...rest
|
|
112
168
|
} = props;
|
|
113
169
|
const isMulti = multiple === true;
|
|
170
|
+
const responsiveTags = isMulti && maxTagCount === "responsive";
|
|
114
171
|
const mergedClearable = clearable ?? !!allowClear;
|
|
115
172
|
const mergedClearIcon = typeof allowClear === "object" ? allowClear.clearIcon : void 0;
|
|
116
173
|
const mergedSearchable = searchable ?? !!showSearch;
|
|
117
174
|
const mergedListHeight = Number.isFinite(listHeight) && listHeight > 0 ? listHeight : 260;
|
|
118
175
|
const mergedMenuClassName = [menuClassName, popupClassName, dropdownClassName].filter(Boolean).join(" ");
|
|
119
|
-
const [innerSingle, setInnerSingle] =
|
|
176
|
+
const [innerSingle, setInnerSingle] = React2__namespace.useState(
|
|
120
177
|
!isMulti ? props.defaultValue : void 0
|
|
121
178
|
);
|
|
122
|
-
const [innerMulti, setInnerMulti] =
|
|
179
|
+
const [innerMulti, setInnerMulti] = React2__namespace.useState(
|
|
123
180
|
isMulti && Array.isArray(props.defaultValue) ? props.defaultValue : []
|
|
124
181
|
);
|
|
125
|
-
const [innerOpen, setInnerOpen] =
|
|
126
|
-
const [innerSearchValue, setInnerSearchValue] =
|
|
127
|
-
const [activeIdx, setActiveIdx] =
|
|
128
|
-
const searchRef =
|
|
182
|
+
const [innerOpen, setInnerOpen] = React2__namespace.useState(defaultOpen ?? false);
|
|
183
|
+
const [innerSearchValue, setInnerSearchValue] = React2__namespace.useState(defaultSearchValue ?? "");
|
|
184
|
+
const [activeIdx, setActiveIdx] = React2__namespace.useState(-1);
|
|
185
|
+
const searchRef = React2__namespace.useRef(null);
|
|
129
186
|
const portalContainer = chunkI4GJZLJU_cjs.usePortalContainer();
|
|
130
187
|
const portalTheme = chunkV6BLBIY6_cjs.useComponentPortalTheme([
|
|
131
188
|
"Select",
|
|
@@ -138,26 +195,26 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
138
195
|
(styleValue) => styleValue?.width != null || styleValue?.minWidth != null || styleValue?.maxWidth != null
|
|
139
196
|
);
|
|
140
197
|
const resolvedPopupWidth = popupStyle?.width ?? themedPopupStyle?.width;
|
|
141
|
-
const listboxId =
|
|
198
|
+
const listboxId = React2__namespace.useId();
|
|
142
199
|
const openControlled = openProp !== void 0;
|
|
143
200
|
const requestedOpen = openControlled ? openProp : innerOpen;
|
|
144
201
|
const open = !disabled && requestedOpen;
|
|
145
|
-
const requestedOpenRef =
|
|
202
|
+
const requestedOpenRef = React2__namespace.useRef(requestedOpen);
|
|
146
203
|
requestedOpenRef.current = requestedOpen;
|
|
147
204
|
const searchControlled = searchValueProp !== void 0;
|
|
148
205
|
const searchValue = searchControlled ? searchValueProp : innerSearchValue;
|
|
149
206
|
const hasInlineSearch = mergedSearchable;
|
|
150
207
|
const showsInlineSearchInput = hasInlineSearch && (isMulti || open);
|
|
151
|
-
const updateSearchValue =
|
|
208
|
+
const updateSearchValue = React2__namespace.useCallback((nextValue) => {
|
|
152
209
|
if (!searchControlled) setInnerSearchValue(nextValue);
|
|
153
210
|
onSearch?.(nextValue);
|
|
154
211
|
}, [onSearch, searchControlled]);
|
|
155
|
-
const resetSearchValue =
|
|
212
|
+
const resetSearchValue = React2__namespace.useCallback(() => {
|
|
156
213
|
if (!searchValue) return;
|
|
157
214
|
if (!searchControlled) setInnerSearchValue("");
|
|
158
215
|
onSearch?.("");
|
|
159
216
|
}, [onSearch, searchControlled, searchValue]);
|
|
160
|
-
const setOpen =
|
|
217
|
+
const setOpen = React2__namespace.useCallback((nextOpen) => {
|
|
161
218
|
if (disabled && nextOpen) return;
|
|
162
219
|
if (nextOpen === requestedOpenRef.current) return;
|
|
163
220
|
requestedOpenRef.current = nextOpen;
|
|
@@ -165,19 +222,19 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
165
222
|
onOpenChange?.(nextOpen);
|
|
166
223
|
if (!nextOpen) resetSearchValue();
|
|
167
224
|
}, [disabled, onOpenChange, openControlled, resetSearchValue]);
|
|
168
|
-
|
|
225
|
+
React2__namespace.useEffect(() => {
|
|
169
226
|
if (!disabled || openControlled || !innerOpen) return;
|
|
170
227
|
setInnerOpen(false);
|
|
171
228
|
onOpenChange?.(false);
|
|
172
229
|
}, [disabled, innerOpen, onOpenChange, openControlled]);
|
|
173
|
-
const { triggerRef, floatingRef: menuRef, floatingStyle, zIndex: menuZIndex } =
|
|
230
|
+
const { triggerRef, floatingRef: menuRef, floatingStyle, zIndex: menuZIndex } = chunk6A5KEWVU_cjs.useFloating({
|
|
174
231
|
open,
|
|
175
232
|
placement: "bottom",
|
|
176
233
|
matchTriggerWidth: !hasCustomPopupWidth,
|
|
177
234
|
panelWidth: typeof resolvedPopupWidth === "number" ? resolvedPopupWidth : 360,
|
|
178
235
|
panelHeight: mergedListHeight + 12
|
|
179
236
|
});
|
|
180
|
-
|
|
237
|
+
chunkBN44QG2B_cjs.useOverlayLayer({
|
|
181
238
|
open: open && portalContainer != null,
|
|
182
239
|
containerRef: menuRef,
|
|
183
240
|
ownerRef: triggerRef,
|
|
@@ -185,7 +242,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
185
242
|
onEscape: () => setOpen(false),
|
|
186
243
|
restoreFocus: true
|
|
187
244
|
});
|
|
188
|
-
const setTriggerRef =
|
|
245
|
+
const setTriggerRef = React2__namespace.useCallback(
|
|
189
246
|
(node) => {
|
|
190
247
|
triggerRef.current = node;
|
|
191
248
|
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
@@ -198,16 +255,16 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
198
255
|
const singleValue = singleControlled ? props.value : innerSingle;
|
|
199
256
|
const controlledMultiValue = props.value;
|
|
200
257
|
const multiValue = multiControlled ? Array.isArray(controlledMultiValue) ? controlledMultiValue : [] : innerMulti;
|
|
201
|
-
const selectedValues =
|
|
258
|
+
const selectedValues = React2__namespace.useMemo(
|
|
202
259
|
() => isMulti ? multiValue : singleValue !== void 0 ? [singleValue] : [],
|
|
203
260
|
[isMulti, multiValue, singleValue]
|
|
204
261
|
);
|
|
205
262
|
const selectionLimit = maxCount !== void 0 && Number.isFinite(maxCount) ? Math.max(0, Math.floor(maxCount)) : void 0;
|
|
206
|
-
const isOptionDisabled =
|
|
263
|
+
const isOptionDisabled = React2__namespace.useCallback((option) => {
|
|
207
264
|
const selected = selectedValues.includes(option.value);
|
|
208
265
|
return !!option.disabled || !!getOptionDisabled?.(option, selectedValues) || isMulti && !selected && selectionLimit !== void 0 && selectedValues.length >= selectionLimit;
|
|
209
266
|
}, [getOptionDisabled, isMulti, selectedValues, selectionLimit]);
|
|
210
|
-
|
|
267
|
+
React2__namespace.useEffect(() => {
|
|
211
268
|
if (!open) return;
|
|
212
269
|
const h = (e) => {
|
|
213
270
|
const t = e.target;
|
|
@@ -218,42 +275,43 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
218
275
|
document.addEventListener("mousedown", h);
|
|
219
276
|
return () => document.removeEventListener("mousedown", h);
|
|
220
277
|
}, [menuRef, open, setOpen, triggerRef]);
|
|
221
|
-
|
|
278
|
+
React2__namespace.useEffect(() => {
|
|
222
279
|
if (open && mergedSearchable) {
|
|
223
280
|
requestAnimationFrame(() => searchRef.current?.focus());
|
|
224
281
|
}
|
|
225
282
|
if (!open) setActiveIdx(-1);
|
|
226
283
|
}, [open, mergedSearchable]);
|
|
227
|
-
const orderedItems =
|
|
284
|
+
const orderedItems = React2__namespace.useMemo(
|
|
228
285
|
() => prioritizePinnedGroups(options),
|
|
229
286
|
[options]
|
|
230
287
|
);
|
|
231
|
-
const allFlat =
|
|
232
|
-
const optionByValue =
|
|
288
|
+
const allFlat = React2__namespace.useMemo(() => flatten(orderedItems), [orderedItems]);
|
|
289
|
+
const optionByValue = React2__namespace.useMemo(() => {
|
|
233
290
|
const index = /* @__PURE__ */ new Map();
|
|
234
291
|
allFlat.forEach((option) => index.set(option.value, option));
|
|
235
292
|
return index;
|
|
236
293
|
}, [allFlat]);
|
|
237
|
-
const selectedOptionCacheRef =
|
|
238
|
-
|
|
294
|
+
const selectedOptionCacheRef = React2__namespace.useRef(/* @__PURE__ */ new Map());
|
|
295
|
+
React2__namespace.useEffect(() => {
|
|
239
296
|
selectedValues.forEach((selectedValue) => {
|
|
240
297
|
const option = optionByValue.get(selectedValue);
|
|
241
298
|
if (option) selectedOptionCacheRef.current.set(selectedValue, option);
|
|
242
299
|
});
|
|
243
300
|
}, [optionByValue, selectedValues]);
|
|
244
|
-
const selectedOptions =
|
|
301
|
+
const selectedOptions = React2__namespace.useMemo(
|
|
245
302
|
() => selectedValues.map(
|
|
246
303
|
(selectedValue) => optionByValue.get(selectedValue) ?? selectedOptionCacheRef.current.get(selectedValue)
|
|
247
304
|
).filter((option) => option !== void 0),
|
|
248
305
|
[optionByValue, selectedValues]
|
|
249
306
|
);
|
|
250
|
-
const
|
|
307
|
+
const responsiveLayout = useResponsiveTags(responsiveTags, selectedOptions, hasInlineSearch);
|
|
308
|
+
const filteredFlat = React2__namespace.useMemo(() => {
|
|
251
309
|
if (!searchValue.trim()) return allFlat;
|
|
252
310
|
if (filterOption === false) return allFlat;
|
|
253
311
|
const f = typeof filterOption === "function" ? filterOption : (input, option) => defaultFilter(input, option, optionFilterProp);
|
|
254
312
|
return allFlat.filter((o) => f(searchValue, o));
|
|
255
313
|
}, [allFlat, filterOption, optionFilterProp, searchValue]);
|
|
256
|
-
const filteredItems =
|
|
314
|
+
const filteredItems = React2__namespace.useMemo(() => {
|
|
257
315
|
if (!searchValue.trim()) {
|
|
258
316
|
return orderedItems.filter((item) => !isGroup(item) || item.options.length > 0);
|
|
259
317
|
}
|
|
@@ -265,7 +323,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
265
323
|
return kept.length ? { ...it, options: kept } : null;
|
|
266
324
|
}).filter((x) => x !== null);
|
|
267
325
|
}, [orderedItems, filteredFlat, searchValue]);
|
|
268
|
-
|
|
326
|
+
React2__namespace.useEffect(() => {
|
|
269
327
|
setActiveIdx((current) => {
|
|
270
328
|
if (current >= 0 && current < filteredFlat.length && !isOptionDisabled(filteredFlat[current])) {
|
|
271
329
|
return current;
|
|
@@ -379,7 +437,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
379
437
|
"data-inline-size": multiHasSelection ? "content" : "fill",
|
|
380
438
|
type: "search",
|
|
381
439
|
value: searchValue,
|
|
382
|
-
style: multiHasSelection ? { width: `${Math.min(Math.max(searchDisplayWidth + 1, 2), 32)}ch` } : void 0,
|
|
440
|
+
style: responsiveTags ? { width: responsiveLayout.inputWidth } : multiHasSelection ? { width: `${Math.min(Math.max(searchDisplayWidth + 1, 2), 32)}ch` } : void 0,
|
|
383
441
|
placeholder: isMulti ? multiValue.length === 0 ? placeholder : void 0 : "\u641C\u7D22...",
|
|
384
442
|
disabled,
|
|
385
443
|
autoComplete: "off",
|
|
@@ -404,16 +462,21 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
404
462
|
const renderTrigger = () => {
|
|
405
463
|
if (isMulti) {
|
|
406
464
|
const selected = selectedOptions;
|
|
407
|
-
const max = maxTagCount;
|
|
465
|
+
const max = typeof maxTagCount === "number" ? maxTagCount : void 0;
|
|
408
466
|
const shown = max != null ? selected.slice(0, max) : selected;
|
|
409
|
-
const overflow = selected.length - shown.length;
|
|
410
|
-
if (selected.length === 0 && !hasInlineSearch) {
|
|
467
|
+
const overflow = selected.length - (responsiveTags ? responsiveLayout.count : shown.length);
|
|
468
|
+
if (selected.length === 0 && !hasInlineSearch && !responsiveTags) {
|
|
411
469
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "placeholder", children: placeholder });
|
|
412
470
|
}
|
|
413
|
-
return /* @__PURE__ */ jsxRuntime.jsx(chunkV6BLBIY6_cjs.InternalComponentThemePart, { components: "Tag", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "select-tags", children: [
|
|
414
|
-
|
|
471
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkV6BLBIY6_cjs.InternalComponentThemePart, { components: "Tag", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "select-tags", ref: responsiveLayout.tagsRef, children: [
|
|
472
|
+
selected.length === 0 && !hasInlineSearch && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "placeholder", children: placeholder }),
|
|
473
|
+
shown.map((o, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
415
474
|
chunkVNP5WB6M_cjs.Tag,
|
|
416
475
|
{
|
|
476
|
+
"data-select-tag": responsiveTags ? "" : void 0,
|
|
477
|
+
"data-collapsed": responsiveTags && index >= responsiveLayout.count ? "true" : void 0,
|
|
478
|
+
"aria-hidden": responsiveTags && index >= responsiveLayout.count ? true : void 0,
|
|
479
|
+
...responsiveTags && index >= responsiveLayout.count ? { inert: "" } : {},
|
|
417
480
|
tone: "accent",
|
|
418
481
|
removable: !disabled,
|
|
419
482
|
onRemove: () => removeMultiValue(o.value),
|
|
@@ -430,7 +493,14 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
430
493
|
"+",
|
|
431
494
|
overflow
|
|
432
495
|
] }),
|
|
433
|
-
renderInlineSearchInput()
|
|
496
|
+
renderInlineSearchInput(),
|
|
497
|
+
responsiveTags && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "select-tag-measurements", "aria-hidden": "true", ...{ inert: "" }, children: [
|
|
498
|
+
selected.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs(chunkVNP5WB6M_cjs.Tag, { tone: "neutral", "data-select-overflow": "", children: [
|
|
499
|
+
"+",
|
|
500
|
+
index + 1
|
|
501
|
+
] }, String(option.value))),
|
|
502
|
+
hasInlineSearch && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "select-search-measure", children: searchValue || "\u200B" })
|
|
503
|
+
] })
|
|
434
504
|
] }) });
|
|
435
505
|
}
|
|
436
506
|
if (showsInlineSearchInput) return renderInlineSearchInput();
|
|
@@ -446,6 +516,24 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
446
516
|
};
|
|
447
517
|
const hasSelection = isMulti ? multiValue.length > 0 : singleValue != null;
|
|
448
518
|
const showClear = mergedClearable && hasSelection && !disabled;
|
|
519
|
+
const renderClearButton = () => showClear && /* @__PURE__ */ jsxRuntime.jsx(
|
|
520
|
+
"button",
|
|
521
|
+
{
|
|
522
|
+
type: "button",
|
|
523
|
+
className: "select-clear",
|
|
524
|
+
"aria-label": "Clear",
|
|
525
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
526
|
+
onMouseDown: (event) => {
|
|
527
|
+
if (hasInlineSearch) event.preventDefault();
|
|
528
|
+
event.stopPropagation();
|
|
529
|
+
},
|
|
530
|
+
onClick: (event) => {
|
|
531
|
+
event.stopPropagation();
|
|
532
|
+
clearAll();
|
|
533
|
+
},
|
|
534
|
+
children: mergedClearIcon ?? /* @__PURE__ */ jsxRuntime.jsx(chunkVDVKY2IX_cjs.Icon, { name: "x", size: 12 })
|
|
535
|
+
}
|
|
536
|
+
);
|
|
449
537
|
let renderIdx = -1;
|
|
450
538
|
const renderOption = (o, groupPinned = false) => {
|
|
451
539
|
renderIdx += 1;
|
|
@@ -505,7 +593,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
505
593
|
);
|
|
506
594
|
};
|
|
507
595
|
const renderMenuItems = (items) => items.map(
|
|
508
|
-
(item, groupIndex) => isGroup(item) ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
596
|
+
(item, groupIndex) => isGroup(item) ? /* @__PURE__ */ jsxRuntime.jsxs(React2__namespace.Fragment, { children: [
|
|
509
597
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-group-label", children: item.label }),
|
|
510
598
|
item.options.map((option) => renderOption(option, !!item.pinned))
|
|
511
599
|
] }, `g-${groupIndex}-${item.pinned ? "pinned" : "regular"}`) : renderOption(item)
|
|
@@ -529,7 +617,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
529
617
|
{
|
|
530
618
|
ref: setTriggerRef,
|
|
531
619
|
...rest,
|
|
532
|
-
className: `select ${size} ${isMulti ? "multi" : ""} ${hasInlineSearch ? "searchable" : ""} ${open ? "open" : ""} ${disabled ? "disabled" : ""} ${invalid ? "invalid" : ""} ${className}`,
|
|
620
|
+
className: `select ${size} ${isMulti ? "multi" : ""} ${responsiveTags ? "responsive" : ""} ${hasInlineSearch ? "searchable" : ""} ${open ? "open" : ""} ${disabled ? "disabled" : ""} ${invalid ? "invalid" : ""} ${className}`,
|
|
533
621
|
onKeyDown: (e) => {
|
|
534
622
|
onRootKeyDown?.(e);
|
|
535
623
|
const target = e.target;
|
|
@@ -576,28 +664,12 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
576
664
|
"aria-activedescendant": showsInlineSearchInput ? void 0 : open && activeIdx >= 0 ? `${listboxId}-option-${activeIdx}` : void 0,
|
|
577
665
|
children: [
|
|
578
666
|
renderTrigger(),
|
|
667
|
+
responsiveTags && renderClearButton(),
|
|
579
668
|
/* @__PURE__ */ jsxRuntime.jsx(chunkVDVKY2IX_cjs.Icon, { name: "chevDown", size: 14, className: "select-caret" })
|
|
580
669
|
]
|
|
581
670
|
}
|
|
582
671
|
),
|
|
583
|
-
|
|
584
|
-
"button",
|
|
585
|
-
{
|
|
586
|
-
type: "button",
|
|
587
|
-
className: "select-clear",
|
|
588
|
-
"aria-label": "Clear",
|
|
589
|
-
onPointerDown: (event) => event.stopPropagation(),
|
|
590
|
-
onMouseDown: (event) => {
|
|
591
|
-
if (hasInlineSearch) event.preventDefault();
|
|
592
|
-
event.stopPropagation();
|
|
593
|
-
},
|
|
594
|
-
onClick: (event) => {
|
|
595
|
-
event.stopPropagation();
|
|
596
|
-
clearAll();
|
|
597
|
-
},
|
|
598
|
-
children: mergedClearIcon ?? /* @__PURE__ */ jsxRuntime.jsx(chunkVDVKY2IX_cjs.Icon, { name: "x", size: 12 })
|
|
599
|
-
}
|
|
600
|
-
),
|
|
672
|
+
!responsiveTags && renderClearButton(),
|
|
601
673
|
open && portalContainer && reactDom.createPortal(
|
|
602
674
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
603
675
|
"div",
|
|
@@ -636,7 +708,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
636
708
|
}
|
|
637
709
|
);
|
|
638
710
|
};
|
|
639
|
-
var SelectBase =
|
|
711
|
+
var SelectBase = React2__namespace.forwardRef(SelectInner);
|
|
640
712
|
SelectBase.displayName = "Select";
|
|
641
713
|
var Select = chunkV6BLBIY6_cjs.withComponentTheme(
|
|
642
714
|
SelectBase,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useOverlayZIndex, useOverlayLayer, OverlayZIndexProvider } from './chunk-
|
|
1
|
+
import { useOverlayZIndex, useOverlayLayer, OverlayZIndexProvider } from './chunk-BZB45GGK.js';
|
|
2
2
|
import { Button } from './chunk-563SQXH7.js';
|
|
3
3
|
import { Icon } from './chunk-2BM65ITV.js';
|
|
4
4
|
import { useComponentPortalTheme, InternalComponentThemePart, withComponentTheme } from './chunk-5HLNFDV4.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkBN44QG2B_cjs = require('./chunk-BN44QG2B.cjs');
|
|
4
4
|
var chunkM3JYP3V4_cjs = require('./chunk-M3JYP3V4.cjs');
|
|
5
5
|
var chunkVDVKY2IX_cjs = require('./chunk-VDVKY2IX.cjs');
|
|
6
6
|
var chunkV6BLBIY6_cjs = require('./chunk-V6BLBIY6.cjs');
|
|
@@ -78,7 +78,7 @@ var ModalBase = React__namespace.forwardRef((props, ref) => {
|
|
|
78
78
|
const panelRef = React__namespace.useRef(null);
|
|
79
79
|
const titleId = React__namespace.useId();
|
|
80
80
|
const descriptionId = React__namespace.useId();
|
|
81
|
-
const overlayZIndex =
|
|
81
|
+
const overlayZIndex = chunkBN44QG2B_cjs.useOverlayZIndex(open, zIndex);
|
|
82
82
|
const [hasOpenedOnce, setHasOpenedOnce] = React__namespace.useState(open);
|
|
83
83
|
React__namespace.useEffect(() => {
|
|
84
84
|
if (open) setHasOpenedOnce(true);
|
|
@@ -87,7 +87,7 @@ var ModalBase = React__namespace.forwardRef((props, ref) => {
|
|
|
87
87
|
if (onCancel) onCancel();
|
|
88
88
|
else onClose?.();
|
|
89
89
|
}, [onCancel, onClose]);
|
|
90
|
-
|
|
90
|
+
chunkBN44QG2B_cjs.useOverlayLayer({
|
|
91
91
|
open: open && portalContainer != null,
|
|
92
92
|
containerRef: panelRef,
|
|
93
93
|
zIndex: overlayZIndex,
|
|
@@ -145,7 +145,7 @@ var ModalBase = React__namespace.forwardRef((props, ref) => {
|
|
|
145
145
|
const modalBodyStyle = bodyOverflow == null ? { ...portalTheme.styles.body, ...bodyStyle } : { ...portalTheme.styles.body, overflow: bodyOverflow, ...bodyStyle };
|
|
146
146
|
const usesDefaultBodyOverflow = bodyOverflow == null && bodyStyle?.overflow == null && portalTheme.styles.body?.overflow == null;
|
|
147
147
|
return ReactDOM__default.default.createPortal(
|
|
148
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
148
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBN44QG2B_cjs.OverlayZIndexProvider, { zIndex: overlayZIndex, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
149
149
|
"div",
|
|
150
150
|
{
|
|
151
151
|
className: ["modal-overlay", open ? "" : "hidden", maskClassName].filter(Boolean).join(" "),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useInputTriggerToggle } from './chunk-
|
|
2
|
-
import { useFloating } from './chunk-
|
|
1
|
+
import { useInputTriggerToggle } from './chunk-SW3KEFIA.js';
|
|
2
|
+
import { useFloating } from './chunk-NKIXCDZC.js';
|
|
3
3
|
import { Input } from './chunk-TUXF2G2O.js';
|
|
4
|
-
import { useOverlayLayer } from './chunk-
|
|
4
|
+
import { useOverlayLayer } from './chunk-BZB45GGK.js';
|
|
5
5
|
import { Button } from './chunk-563SQXH7.js';
|
|
6
6
|
import { useComponentPortalTheme, InternalComponentThemePart, withComponentTheme } from './chunk-5HLNFDV4.js';
|
|
7
7
|
import { usePortalContainer } from './chunk-CPVUDSIY.js';
|