@fangxinyan/lumina 0.9.2 → 0.9.4
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-Y3X3ZJTC.css → Select-M3HCB3PW.css} +68 -2
- package/dist/Select.cjs +2 -2
- package/dist/Select.d.cts +6 -2
- package/dist/Select.d.ts +6 -2
- package/dist/Select.js +1 -1
- 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-LZXJN3XA.js → chunk-3SUMCW2F.js} +1 -1
- package/dist/{chunk-CDT2QCBL.cjs → chunk-562P5YMO.cjs} +131 -58
- package/dist/{chunk-QZ2AAQBX.cjs → chunk-A5MLLFKT.cjs} +2 -2
- package/dist/{chunk-MJYMPK5K.cjs → chunk-G5ENSJBS.cjs} +2 -2
- package/dist/{chunk-MSWWABXP.js → chunk-OKGODC5A.js} +130 -57
- package/dist/{chunk-RM6JIM6O.js → chunk-QITKDNCX.js} +1 -1
- package/dist/{chunk-U3T6RC6U.js → chunk-T422LYTL.js} +1 -1
- package/dist/{chunk-IDEE7PP5.cjs → chunk-V6DY7J2Z.cjs} +2 -2
- 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 +67 -2
- package/docs/llms/select.md +15 -1
- package/docs/llms.md +1 -1
- package/package.json +1 -1
package/dist/Pagination.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkA5MLLFKT_cjs = require('./chunk-A5MLLFKT.cjs');
|
|
4
|
+
require('./chunk-562P5YMO.cjs');
|
|
5
5
|
require('./chunk-VNP5WB6M.cjs');
|
|
6
6
|
require('./chunk-FJB3243S.cjs');
|
|
7
7
|
require('./chunk-GFGMGJ5A.cjs');
|
|
@@ -15,5 +15,5 @@ require('./chunk-I4GJZLJU.cjs');
|
|
|
15
15
|
|
|
16
16
|
Object.defineProperty(exports, "Pagination", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkA5MLLFKT_cjs.Pagination; }
|
|
19
19
|
});
|
package/dist/Pagination.js
CHANGED
|
@@ -139,11 +139,11 @@
|
|
|
139
139
|
font: inherit;
|
|
140
140
|
line-height: 24px;
|
|
141
141
|
}
|
|
142
|
-
.select-search-input
|
|
142
|
+
.select-search-input[data-inline-size="fill"] {
|
|
143
143
|
flex: 1 1 auto;
|
|
144
144
|
width: 100%;
|
|
145
145
|
}
|
|
146
|
-
.select-search-input
|
|
146
|
+
.select-search-input[data-inline-size="content"] {
|
|
147
147
|
flex: 0 1 auto;
|
|
148
148
|
min-width: 2ch;
|
|
149
149
|
max-width: 100%;
|
|
@@ -188,6 +188,72 @@
|
|
|
188
188
|
.select:hover .select-clear { opacity: 1; }
|
|
189
189
|
.select-clear:hover { color: var(--lmn-select-accent-ink, var(--accent-ink)); box-shadow: var(--lmn-select-neu-shadow-inset, var(--neu-shadow-inset)); }
|
|
190
190
|
|
|
191
|
+
/* 自适应模式:控件按真实宽度参与布局,标签区只展示测量后能完整容纳的前缀。 */
|
|
192
|
+
.select.multi.responsive .select-trigger {
|
|
193
|
+
flex-wrap: nowrap;
|
|
194
|
+
padding: var(--lmn-select-tag-gap, var(--gap-1)) var(--lmn-select-trigger-padding, var(--gap-2));
|
|
195
|
+
gap: var(--lmn-select-control-gap, var(--gap-2));
|
|
196
|
+
}
|
|
197
|
+
.select.multi.responsive .select-tags {
|
|
198
|
+
flex-wrap: nowrap;
|
|
199
|
+
flex: 1 1 0%;
|
|
200
|
+
gap: var(--lmn-select-tag-gap, var(--gap-1));
|
|
201
|
+
position: relative;
|
|
202
|
+
}
|
|
203
|
+
.select.multi.responsive .select-tags > .tag,
|
|
204
|
+
.select-tag-measurements > .tag {
|
|
205
|
+
flex: none;
|
|
206
|
+
width: max-content;
|
|
207
|
+
max-width: var(--lmn-select-tag-max-width, 160px);
|
|
208
|
+
}
|
|
209
|
+
.select.multi.responsive .select-tags > .select-tag-overflow {
|
|
210
|
+
max-width: none;
|
|
211
|
+
}
|
|
212
|
+
.select.multi.responsive [data-collapsed="true"],
|
|
213
|
+
.select-tag-measurements {
|
|
214
|
+
position: absolute;
|
|
215
|
+
top: 0;
|
|
216
|
+
left: 0;
|
|
217
|
+
visibility: hidden;
|
|
218
|
+
pointer-events: none;
|
|
219
|
+
}
|
|
220
|
+
.select-tag-measurements {
|
|
221
|
+
width: 100%;
|
|
222
|
+
height: 100%;
|
|
223
|
+
overflow: hidden;
|
|
224
|
+
}
|
|
225
|
+
.select-tag-measurements > .tag {
|
|
226
|
+
position: absolute;
|
|
227
|
+
max-width: none;
|
|
228
|
+
}
|
|
229
|
+
.select-search-measure {
|
|
230
|
+
display: block;
|
|
231
|
+
width: max-content;
|
|
232
|
+
min-width: 2ch;
|
|
233
|
+
padding-inline: calc(var(--gap-1) / 2);
|
|
234
|
+
padding-inline-end: calc(var(--gap-1) / 2 + 1ch);
|
|
235
|
+
white-space: pre;
|
|
236
|
+
font: inherit;
|
|
237
|
+
}
|
|
238
|
+
.select.multi.responsive .select-search-input {
|
|
239
|
+
flex: 1 1 auto;
|
|
240
|
+
min-width: 0;
|
|
241
|
+
max-width: 100%;
|
|
242
|
+
field-sizing: fixed;
|
|
243
|
+
}
|
|
244
|
+
.select.multi.responsive .select-caret,
|
|
245
|
+
.select.multi.responsive .select-clear {
|
|
246
|
+
position: static;
|
|
247
|
+
transform: none;
|
|
248
|
+
flex-shrink: 0;
|
|
249
|
+
}
|
|
250
|
+
.select.multi.responsive.open .select-caret { transform: rotate(180deg); }
|
|
251
|
+
.select.multi.responsive .select-tags > .placeholder {
|
|
252
|
+
overflow: hidden;
|
|
253
|
+
text-overflow: ellipsis;
|
|
254
|
+
white-space: nowrap;
|
|
255
|
+
}
|
|
256
|
+
|
|
191
257
|
/* Multi-select menu: leading checkbox per item */
|
|
192
258
|
.menu-check {
|
|
193
259
|
width: 16px;
|
package/dist/Select.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk562P5YMO_cjs = require('./chunk-562P5YMO.cjs');
|
|
4
4
|
require('./chunk-VNP5WB6M.cjs');
|
|
5
5
|
require('./chunk-FJB3243S.cjs');
|
|
6
6
|
require('./chunk-HSDMJUB6.cjs');
|
|
@@ -12,5 +12,5 @@ require('./chunk-I4GJZLJU.cjs');
|
|
|
12
12
|
|
|
13
13
|
Object.defineProperty(exports, "Select", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunk562P5YMO_cjs.Select; }
|
|
16
16
|
});
|
package/dist/Select.d.cts
CHANGED
|
@@ -113,6 +113,7 @@ interface SingleSelectProps<T extends string | number = string> extends BaseSele
|
|
|
113
113
|
/** Fired when user clears the selection via the × button. */
|
|
114
114
|
onClear?: () => void;
|
|
115
115
|
}
|
|
116
|
+
/** 多选模式的选值、标签展示和数量限制配置。 */
|
|
116
117
|
interface MultiSelectProps<T extends string | number = string> extends BaseSelectProps<T> {
|
|
117
118
|
multiple: true;
|
|
118
119
|
value?: T[];
|
|
@@ -120,8 +121,11 @@ interface MultiSelectProps<T extends string | number = string> extends BaseSelec
|
|
|
120
121
|
onChange?: SelectMultiChangeHandler<T>;
|
|
121
122
|
/** Fired when user clears all selections via the × button. */
|
|
122
123
|
onClear?: () => void;
|
|
123
|
-
/**
|
|
124
|
-
|
|
124
|
+
/**
|
|
125
|
+
* 显示的标签数量;responsive 按实际可用宽度折叠为 +N,保持单行且不改变选值。
|
|
126
|
+
* @example <Select multiple maxTagCount="responsive" options={options} />
|
|
127
|
+
*/
|
|
128
|
+
maxTagCount?: number | "responsive";
|
|
125
129
|
/** 多选允许的最大选择数;达到上限后禁用尚未选中的候选项。 */
|
|
126
130
|
maxCount?: number;
|
|
127
131
|
}
|
package/dist/Select.d.ts
CHANGED
|
@@ -113,6 +113,7 @@ interface SingleSelectProps<T extends string | number = string> extends BaseSele
|
|
|
113
113
|
/** Fired when user clears the selection via the × button. */
|
|
114
114
|
onClear?: () => void;
|
|
115
115
|
}
|
|
116
|
+
/** 多选模式的选值、标签展示和数量限制配置。 */
|
|
116
117
|
interface MultiSelectProps<T extends string | number = string> extends BaseSelectProps<T> {
|
|
117
118
|
multiple: true;
|
|
118
119
|
value?: T[];
|
|
@@ -120,8 +121,11 @@ interface MultiSelectProps<T extends string | number = string> extends BaseSelec
|
|
|
120
121
|
onChange?: SelectMultiChangeHandler<T>;
|
|
121
122
|
/** Fired when user clears all selections via the × button. */
|
|
122
123
|
onClear?: () => void;
|
|
123
|
-
/**
|
|
124
|
-
|
|
124
|
+
/**
|
|
125
|
+
* 显示的标签数量;responsive 按实际可用宽度折叠为 +N,保持单行且不改变选值。
|
|
126
|
+
* @example <Select multiple maxTagCount="responsive" options={options} />
|
|
127
|
+
*/
|
|
128
|
+
maxTagCount?: number | "responsive";
|
|
125
129
|
/** 多选允许的最大选择数;达到上限后禁用尚未选中的候选项。 */
|
|
126
130
|
maxCount?: number;
|
|
127
131
|
}
|
package/dist/Select.js
CHANGED
package/dist/Table.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var chunkG5ENSJBS_cjs = require('./chunk-G5ENSJBS.cjs');
|
|
4
|
+
require('./chunk-A5MLLFKT.cjs');
|
|
5
|
+
require('./chunk-562P5YMO.cjs');
|
|
6
6
|
require('./chunk-VNP5WB6M.cjs');
|
|
7
7
|
require('./chunk-KPBZKHCS.cjs');
|
|
8
8
|
require('./chunk-FJB3243S.cjs');
|
|
@@ -18,5 +18,5 @@ require('./chunk-I4GJZLJU.cjs');
|
|
|
18
18
|
|
|
19
19
|
Object.defineProperty(exports, "Table", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkG5ENSJBS_cjs.Table; }
|
|
22
22
|
});
|
package/dist/Table.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { Table } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { Table } from './chunk-QITKDNCX.js';
|
|
2
|
+
import './chunk-3SUMCW2F.js';
|
|
3
|
+
import './chunk-OKGODC5A.js';
|
|
4
4
|
import './chunk-OGMI3TO5.js';
|
|
5
5
|
import './chunk-QSLXUNLM.js';
|
|
6
6
|
import './chunk-3QXP2ZNP.js';
|
package/dist/TablePro.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
3
|
+
var chunkV6DY7J2Z_cjs = require('./chunk-V6DY7J2Z.cjs');
|
|
4
|
+
require('./chunk-G5ENSJBS.cjs');
|
|
5
|
+
require('./chunk-A5MLLFKT.cjs');
|
|
6
|
+
require('./chunk-562P5YMO.cjs');
|
|
7
7
|
require('./chunk-VNP5WB6M.cjs');
|
|
8
8
|
require('./chunk-KPBZKHCS.cjs');
|
|
9
9
|
require('./chunk-FJB3243S.cjs');
|
|
@@ -19,5 +19,5 @@ require('./chunk-I4GJZLJU.cjs');
|
|
|
19
19
|
|
|
20
20
|
Object.defineProperty(exports, "TablePro", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkV6DY7J2Z_cjs.TablePro; }
|
|
23
23
|
});
|
package/dist/TablePro.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { TablePro } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
1
|
+
export { TablePro } from './chunk-T422LYTL.js';
|
|
2
|
+
import './chunk-QITKDNCX.js';
|
|
3
|
+
import './chunk-3SUMCW2F.js';
|
|
4
|
+
import './chunk-OKGODC5A.js';
|
|
5
5
|
import './chunk-OGMI3TO5.js';
|
|
6
6
|
import './chunk-QSLXUNLM.js';
|
|
7
7
|
import './chunk-3QXP2ZNP.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Select } from './chunk-
|
|
1
|
+
import { Select } from './chunk-OKGODC5A.js';
|
|
2
2
|
import { Input } from './chunk-TUXF2G2O.js';
|
|
3
3
|
import { Icon } from './chunk-2BM65ITV.js';
|
|
4
4
|
import { InternalComponentThemePart, withComponentTheme } from './chunk-5HLNFDV4.js';
|
|
@@ -8,8 +8,8 @@ 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,7 +222,7 @@ 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);
|
|
@@ -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;
|
|
@@ -375,10 +433,11 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
375
433
|
{
|
|
376
434
|
ref: searchRef,
|
|
377
435
|
id: fieldId,
|
|
378
|
-
className:
|
|
436
|
+
className: "select-search-input",
|
|
437
|
+
"data-inline-size": multiHasSelection ? "content" : "fill",
|
|
379
438
|
type: "search",
|
|
380
439
|
value: searchValue,
|
|
381
|
-
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,
|
|
382
441
|
placeholder: isMulti ? multiValue.length === 0 ? placeholder : void 0 : "\u641C\u7D22...",
|
|
383
442
|
disabled,
|
|
384
443
|
autoComplete: "off",
|
|
@@ -403,16 +462,21 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
403
462
|
const renderTrigger = () => {
|
|
404
463
|
if (isMulti) {
|
|
405
464
|
const selected = selectedOptions;
|
|
406
|
-
const max = maxTagCount;
|
|
465
|
+
const max = typeof maxTagCount === "number" ? maxTagCount : void 0;
|
|
407
466
|
const shown = max != null ? selected.slice(0, max) : selected;
|
|
408
|
-
const overflow = selected.length - shown.length;
|
|
409
|
-
if (selected.length === 0 && !hasInlineSearch) {
|
|
467
|
+
const overflow = selected.length - (responsiveTags ? responsiveLayout.count : shown.length);
|
|
468
|
+
if (selected.length === 0 && !hasInlineSearch && !responsiveTags) {
|
|
410
469
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "placeholder", children: placeholder });
|
|
411
470
|
}
|
|
412
|
-
return /* @__PURE__ */ jsxRuntime.jsx(chunkV6BLBIY6_cjs.InternalComponentThemePart, { components: "Tag", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "select-tags", children: [
|
|
413
|
-
|
|
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(
|
|
414
474
|
chunkVNP5WB6M_cjs.Tag,
|
|
415
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: "" } : {},
|
|
416
480
|
tone: "accent",
|
|
417
481
|
removable: !disabled,
|
|
418
482
|
onRemove: () => removeMultiValue(o.value),
|
|
@@ -429,7 +493,14 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
429
493
|
"+",
|
|
430
494
|
overflow
|
|
431
495
|
] }),
|
|
432
|
-
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
|
+
] })
|
|
433
504
|
] }) });
|
|
434
505
|
}
|
|
435
506
|
if (showsInlineSearchInput) return renderInlineSearchInput();
|
|
@@ -445,6 +516,24 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
445
516
|
};
|
|
446
517
|
const hasSelection = isMulti ? multiValue.length > 0 : singleValue != null;
|
|
447
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
|
+
);
|
|
448
537
|
let renderIdx = -1;
|
|
449
538
|
const renderOption = (o, groupPinned = false) => {
|
|
450
539
|
renderIdx += 1;
|
|
@@ -504,7 +593,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
504
593
|
);
|
|
505
594
|
};
|
|
506
595
|
const renderMenuItems = (items) => items.map(
|
|
507
|
-
(item, groupIndex) => isGroup(item) ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
596
|
+
(item, groupIndex) => isGroup(item) ? /* @__PURE__ */ jsxRuntime.jsxs(React2__namespace.Fragment, { children: [
|
|
508
597
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "menu-group-label", children: item.label }),
|
|
509
598
|
item.options.map((option) => renderOption(option, !!item.pinned))
|
|
510
599
|
] }, `g-${groupIndex}-${item.pinned ? "pinned" : "regular"}`) : renderOption(item)
|
|
@@ -528,7 +617,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
528
617
|
{
|
|
529
618
|
ref: setTriggerRef,
|
|
530
619
|
...rest,
|
|
531
|
-
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}`,
|
|
532
621
|
onKeyDown: (e) => {
|
|
533
622
|
onRootKeyDown?.(e);
|
|
534
623
|
const target = e.target;
|
|
@@ -575,28 +664,12 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
575
664
|
"aria-activedescendant": showsInlineSearchInput ? void 0 : open && activeIdx >= 0 ? `${listboxId}-option-${activeIdx}` : void 0,
|
|
576
665
|
children: [
|
|
577
666
|
renderTrigger(),
|
|
667
|
+
responsiveTags && renderClearButton(),
|
|
578
668
|
/* @__PURE__ */ jsxRuntime.jsx(chunkVDVKY2IX_cjs.Icon, { name: "chevDown", size: 14, className: "select-caret" })
|
|
579
669
|
]
|
|
580
670
|
}
|
|
581
671
|
),
|
|
582
|
-
|
|
583
|
-
"button",
|
|
584
|
-
{
|
|
585
|
-
type: "button",
|
|
586
|
-
className: "select-clear",
|
|
587
|
-
"aria-label": "Clear",
|
|
588
|
-
onPointerDown: (event) => event.stopPropagation(),
|
|
589
|
-
onMouseDown: (event) => {
|
|
590
|
-
if (hasInlineSearch) event.preventDefault();
|
|
591
|
-
event.stopPropagation();
|
|
592
|
-
},
|
|
593
|
-
onClick: (event) => {
|
|
594
|
-
event.stopPropagation();
|
|
595
|
-
clearAll();
|
|
596
|
-
},
|
|
597
|
-
children: mergedClearIcon ?? /* @__PURE__ */ jsxRuntime.jsx(chunkVDVKY2IX_cjs.Icon, { name: "x", size: 12 })
|
|
598
|
-
}
|
|
599
|
-
),
|
|
672
|
+
!responsiveTags && renderClearButton(),
|
|
600
673
|
open && portalContainer && reactDom.createPortal(
|
|
601
674
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
602
675
|
"div",
|
|
@@ -635,7 +708,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
635
708
|
}
|
|
636
709
|
);
|
|
637
710
|
};
|
|
638
|
-
var SelectBase =
|
|
711
|
+
var SelectBase = React2__namespace.forwardRef(SelectInner);
|
|
639
712
|
SelectBase.displayName = "Select";
|
|
640
713
|
var Select = chunkV6BLBIY6_cjs.withComponentTheme(
|
|
641
714
|
SelectBase,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk562P5YMO_cjs = require('./chunk-562P5YMO.cjs');
|
|
4
4
|
var chunkGFGMGJ5A_cjs = require('./chunk-GFGMGJ5A.cjs');
|
|
5
5
|
var chunkVDVKY2IX_cjs = require('./chunk-VDVKY2IX.cjs');
|
|
6
6
|
var chunkV6BLBIY6_cjs = require('./chunk-V6BLBIY6.cjs');
|
|
@@ -137,7 +137,7 @@ var PaginationBase = React__namespace.forwardRef(({
|
|
|
137
137
|
}
|
|
138
138
|
),
|
|
139
139
|
showSizeChanger && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pg-size-changer", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
140
|
-
|
|
140
|
+
chunk562P5YMO_cjs.Select,
|
|
141
141
|
{
|
|
142
142
|
value: normalizedPageSize,
|
|
143
143
|
size: "sm",
|