@fangxinyan/lumina 0.9.3 → 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-UTNBARSQ.css → Select-M3HCB3PW.css} +66 -0
- 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-6MT3APJ3.js → chunk-3SUMCW2F.js} +1 -1
- package/dist/{chunk-7RYLV5CM.cjs → chunk-562P5YMO.cjs} +129 -57
- package/dist/{chunk-EBU3DTUN.cjs → chunk-A5MLLFKT.cjs} +2 -2
- package/dist/{chunk-P3ZIABMZ.cjs → chunk-G5ENSJBS.cjs} +2 -2
- package/dist/{chunk-AFYNTVSH.js → chunk-OKGODC5A.js} +128 -56
- package/dist/{chunk-X547KNTP.js → chunk-QITKDNCX.js} +1 -1
- package/dist/{chunk-EP7QREID.js → chunk-T422LYTL.js} +1 -1
- package/dist/{chunk-5Q2ZYR5Z.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 +65 -0
- 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
|
@@ -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;
|
|
@@ -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,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",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkA5MLLFKT_cjs = require('./chunk-A5MLLFKT.cjs');
|
|
4
4
|
var chunkKPBZKHCS_cjs = require('./chunk-KPBZKHCS.cjs');
|
|
5
5
|
var chunkFJB3243S_cjs = require('./chunk-FJB3243S.cjs');
|
|
6
6
|
var chunkHSDMJUB6_cjs = require('./chunk-HSDMJUB6.cjs');
|
|
@@ -503,7 +503,7 @@ var TableInner = ({
|
|
|
503
503
|
}
|
|
504
504
|
),
|
|
505
505
|
pagEnabled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "table-pagination", children: /* @__PURE__ */ jsxRuntime.jsx(chunkV6BLBIY6_cjs.InternalComponentThemePart, { components: "Pagination", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
506
|
-
|
|
506
|
+
chunkA5MLLFKT_cjs.Pagination,
|
|
507
507
|
{
|
|
508
508
|
total: totalCount,
|
|
509
509
|
pageSize: curPageSize,
|
|
@@ -6,11 +6,67 @@ import { withComponentTheme, useComponentPortalTheme, InternalComponentThemePart
|
|
|
6
6
|
import { usePortalContainer } from './chunk-CPVUDSIY.js';
|
|
7
7
|
import './tokens-223RYVVS.css';
|
|
8
8
|
import './shared-NJHRNLRH.css';
|
|
9
|
-
import './Select-
|
|
10
|
-
import * as
|
|
9
|
+
import './Select-M3HCB3PW.css';
|
|
10
|
+
import * as React2 from 'react';
|
|
11
11
|
import { createPortal } from 'react-dom';
|
|
12
12
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
13
13
|
|
|
14
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React2.useLayoutEffect : React2.useEffect;
|
|
15
|
+
function measureResponsiveTags(container) {
|
|
16
|
+
const availableWidth = container.getBoundingClientRect().width;
|
|
17
|
+
if (availableWidth <= 0) return void 0;
|
|
18
|
+
const tags = Array.from(container.querySelectorAll("[data-select-tag]"));
|
|
19
|
+
const overflows = Array.from(container.querySelectorAll("[data-select-overflow]"));
|
|
20
|
+
const search = container.querySelector(".select-search-measure");
|
|
21
|
+
const gap = parseFloat(getComputedStyle(container).columnGap) || 0;
|
|
22
|
+
const tagWidths = tags.map((tag) => tag.getBoundingClientRect().width);
|
|
23
|
+
const overflowWidths = [0, ...overflows.map((tag) => tag.getBoundingClientRect().width)];
|
|
24
|
+
const inputWidth = search ? Math.min(search.getBoundingClientRect().width, Math.max(
|
|
25
|
+
0,
|
|
26
|
+
availableWidth - (overflowWidths[tags.length] ?? 0) - (tags.length > 0 ? gap : 0)
|
|
27
|
+
)) : 0;
|
|
28
|
+
let count = 0;
|
|
29
|
+
let prefixWidth = 0;
|
|
30
|
+
for (let index = 0; index <= tags.length; index += 1) {
|
|
31
|
+
const remaining = tags.length - index;
|
|
32
|
+
const itemCount = index + (remaining > 0 ? 1 : 0) + (search ? 1 : 0);
|
|
33
|
+
const width = prefixWidth + (overflowWidths[remaining] ?? 0) + inputWidth + Math.max(0, itemCount - 1) * gap;
|
|
34
|
+
if (width <= availableWidth) count = index;
|
|
35
|
+
prefixWidth += tagWidths[index] ?? 0;
|
|
36
|
+
}
|
|
37
|
+
return { count, inputWidth };
|
|
38
|
+
}
|
|
39
|
+
function useResponsiveTags(enabled, items, searchable) {
|
|
40
|
+
const tagsRef = React2.useRef(null);
|
|
41
|
+
const [layout, setLayout] = React2.useState({ count: 0, inputWidth: 0 });
|
|
42
|
+
const measure = React2.useCallback(() => {
|
|
43
|
+
if (!tagsRef.current) return;
|
|
44
|
+
const next = measureResponsiveTags(tagsRef.current);
|
|
45
|
+
if (next) setLayout((previous) => previous.count === next.count && previous.inputWidth === next.inputWidth ? previous : next);
|
|
46
|
+
}, []);
|
|
47
|
+
useIsomorphicLayoutEffect(() => {
|
|
48
|
+
if (enabled) measure();
|
|
49
|
+
});
|
|
50
|
+
useIsomorphicLayoutEffect(() => {
|
|
51
|
+
const container = tagsRef.current;
|
|
52
|
+
if (!enabled || !container) return;
|
|
53
|
+
let frame = 0;
|
|
54
|
+
const scheduleMeasure = () => {
|
|
55
|
+
cancelAnimationFrame(frame);
|
|
56
|
+
frame = requestAnimationFrame(measure);
|
|
57
|
+
};
|
|
58
|
+
const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(scheduleMeasure) : void 0;
|
|
59
|
+
observer?.observe(container);
|
|
60
|
+
container.querySelectorAll("[data-select-tag], [data-select-overflow], .select-search-measure").forEach((element) => observer?.observe(element));
|
|
61
|
+
window.addEventListener("resize", scheduleMeasure);
|
|
62
|
+
return () => {
|
|
63
|
+
observer?.disconnect();
|
|
64
|
+
window.removeEventListener("resize", scheduleMeasure);
|
|
65
|
+
cancelAnimationFrame(frame);
|
|
66
|
+
};
|
|
67
|
+
}, [enabled, items, searchable, measure]);
|
|
68
|
+
return { tagsRef, count: Math.min(layout.count, items.length), inputWidth: layout.inputWidth };
|
|
69
|
+
}
|
|
14
70
|
var isGroup = (it) => Array.isArray(it.options);
|
|
15
71
|
var flatten = (items) => items.flatMap((it) => isGroup(it) ? it.options : [it]);
|
|
16
72
|
var prioritizePinnedGroups = (items) => {
|
|
@@ -89,21 +145,22 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
89
145
|
...rest
|
|
90
146
|
} = props;
|
|
91
147
|
const isMulti = multiple === true;
|
|
148
|
+
const responsiveTags = isMulti && maxTagCount === "responsive";
|
|
92
149
|
const mergedClearable = clearable ?? !!allowClear;
|
|
93
150
|
const mergedClearIcon = typeof allowClear === "object" ? allowClear.clearIcon : void 0;
|
|
94
151
|
const mergedSearchable = searchable ?? !!showSearch;
|
|
95
152
|
const mergedListHeight = Number.isFinite(listHeight) && listHeight > 0 ? listHeight : 260;
|
|
96
153
|
const mergedMenuClassName = [menuClassName, popupClassName, dropdownClassName].filter(Boolean).join(" ");
|
|
97
|
-
const [innerSingle, setInnerSingle] =
|
|
154
|
+
const [innerSingle, setInnerSingle] = React2.useState(
|
|
98
155
|
!isMulti ? props.defaultValue : void 0
|
|
99
156
|
);
|
|
100
|
-
const [innerMulti, setInnerMulti] =
|
|
157
|
+
const [innerMulti, setInnerMulti] = React2.useState(
|
|
101
158
|
isMulti && Array.isArray(props.defaultValue) ? props.defaultValue : []
|
|
102
159
|
);
|
|
103
|
-
const [innerOpen, setInnerOpen] =
|
|
104
|
-
const [innerSearchValue, setInnerSearchValue] =
|
|
105
|
-
const [activeIdx, setActiveIdx] =
|
|
106
|
-
const searchRef =
|
|
160
|
+
const [innerOpen, setInnerOpen] = React2.useState(defaultOpen ?? false);
|
|
161
|
+
const [innerSearchValue, setInnerSearchValue] = React2.useState(defaultSearchValue ?? "");
|
|
162
|
+
const [activeIdx, setActiveIdx] = React2.useState(-1);
|
|
163
|
+
const searchRef = React2.useRef(null);
|
|
107
164
|
const portalContainer = usePortalContainer();
|
|
108
165
|
const portalTheme = useComponentPortalTheme([
|
|
109
166
|
"Select",
|
|
@@ -116,26 +173,26 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
116
173
|
(styleValue) => styleValue?.width != null || styleValue?.minWidth != null || styleValue?.maxWidth != null
|
|
117
174
|
);
|
|
118
175
|
const resolvedPopupWidth = popupStyle?.width ?? themedPopupStyle?.width;
|
|
119
|
-
const listboxId =
|
|
176
|
+
const listboxId = React2.useId();
|
|
120
177
|
const openControlled = openProp !== void 0;
|
|
121
178
|
const requestedOpen = openControlled ? openProp : innerOpen;
|
|
122
179
|
const open = !disabled && requestedOpen;
|
|
123
|
-
const requestedOpenRef =
|
|
180
|
+
const requestedOpenRef = React2.useRef(requestedOpen);
|
|
124
181
|
requestedOpenRef.current = requestedOpen;
|
|
125
182
|
const searchControlled = searchValueProp !== void 0;
|
|
126
183
|
const searchValue = searchControlled ? searchValueProp : innerSearchValue;
|
|
127
184
|
const hasInlineSearch = mergedSearchable;
|
|
128
185
|
const showsInlineSearchInput = hasInlineSearch && (isMulti || open);
|
|
129
|
-
const updateSearchValue =
|
|
186
|
+
const updateSearchValue = React2.useCallback((nextValue) => {
|
|
130
187
|
if (!searchControlled) setInnerSearchValue(nextValue);
|
|
131
188
|
onSearch?.(nextValue);
|
|
132
189
|
}, [onSearch, searchControlled]);
|
|
133
|
-
const resetSearchValue =
|
|
190
|
+
const resetSearchValue = React2.useCallback(() => {
|
|
134
191
|
if (!searchValue) return;
|
|
135
192
|
if (!searchControlled) setInnerSearchValue("");
|
|
136
193
|
onSearch?.("");
|
|
137
194
|
}, [onSearch, searchControlled, searchValue]);
|
|
138
|
-
const setOpen =
|
|
195
|
+
const setOpen = React2.useCallback((nextOpen) => {
|
|
139
196
|
if (disabled && nextOpen) return;
|
|
140
197
|
if (nextOpen === requestedOpenRef.current) return;
|
|
141
198
|
requestedOpenRef.current = nextOpen;
|
|
@@ -143,7 +200,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
143
200
|
onOpenChange?.(nextOpen);
|
|
144
201
|
if (!nextOpen) resetSearchValue();
|
|
145
202
|
}, [disabled, onOpenChange, openControlled, resetSearchValue]);
|
|
146
|
-
|
|
203
|
+
React2.useEffect(() => {
|
|
147
204
|
if (!disabled || openControlled || !innerOpen) return;
|
|
148
205
|
setInnerOpen(false);
|
|
149
206
|
onOpenChange?.(false);
|
|
@@ -163,7 +220,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
163
220
|
onEscape: () => setOpen(false),
|
|
164
221
|
restoreFocus: true
|
|
165
222
|
});
|
|
166
|
-
const setTriggerRef =
|
|
223
|
+
const setTriggerRef = React2.useCallback(
|
|
167
224
|
(node) => {
|
|
168
225
|
triggerRef.current = node;
|
|
169
226
|
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
@@ -176,16 +233,16 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
176
233
|
const singleValue = singleControlled ? props.value : innerSingle;
|
|
177
234
|
const controlledMultiValue = props.value;
|
|
178
235
|
const multiValue = multiControlled ? Array.isArray(controlledMultiValue) ? controlledMultiValue : [] : innerMulti;
|
|
179
|
-
const selectedValues =
|
|
236
|
+
const selectedValues = React2.useMemo(
|
|
180
237
|
() => isMulti ? multiValue : singleValue !== void 0 ? [singleValue] : [],
|
|
181
238
|
[isMulti, multiValue, singleValue]
|
|
182
239
|
);
|
|
183
240
|
const selectionLimit = maxCount !== void 0 && Number.isFinite(maxCount) ? Math.max(0, Math.floor(maxCount)) : void 0;
|
|
184
|
-
const isOptionDisabled =
|
|
241
|
+
const isOptionDisabled = React2.useCallback((option) => {
|
|
185
242
|
const selected = selectedValues.includes(option.value);
|
|
186
243
|
return !!option.disabled || !!getOptionDisabled?.(option, selectedValues) || isMulti && !selected && selectionLimit !== void 0 && selectedValues.length >= selectionLimit;
|
|
187
244
|
}, [getOptionDisabled, isMulti, selectedValues, selectionLimit]);
|
|
188
|
-
|
|
245
|
+
React2.useEffect(() => {
|
|
189
246
|
if (!open) return;
|
|
190
247
|
const h = (e) => {
|
|
191
248
|
const t = e.target;
|
|
@@ -196,42 +253,43 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
196
253
|
document.addEventListener("mousedown", h);
|
|
197
254
|
return () => document.removeEventListener("mousedown", h);
|
|
198
255
|
}, [menuRef, open, setOpen, triggerRef]);
|
|
199
|
-
|
|
256
|
+
React2.useEffect(() => {
|
|
200
257
|
if (open && mergedSearchable) {
|
|
201
258
|
requestAnimationFrame(() => searchRef.current?.focus());
|
|
202
259
|
}
|
|
203
260
|
if (!open) setActiveIdx(-1);
|
|
204
261
|
}, [open, mergedSearchable]);
|
|
205
|
-
const orderedItems =
|
|
262
|
+
const orderedItems = React2.useMemo(
|
|
206
263
|
() => prioritizePinnedGroups(options),
|
|
207
264
|
[options]
|
|
208
265
|
);
|
|
209
|
-
const allFlat =
|
|
210
|
-
const optionByValue =
|
|
266
|
+
const allFlat = React2.useMemo(() => flatten(orderedItems), [orderedItems]);
|
|
267
|
+
const optionByValue = React2.useMemo(() => {
|
|
211
268
|
const index = /* @__PURE__ */ new Map();
|
|
212
269
|
allFlat.forEach((option) => index.set(option.value, option));
|
|
213
270
|
return index;
|
|
214
271
|
}, [allFlat]);
|
|
215
|
-
const selectedOptionCacheRef =
|
|
216
|
-
|
|
272
|
+
const selectedOptionCacheRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
273
|
+
React2.useEffect(() => {
|
|
217
274
|
selectedValues.forEach((selectedValue) => {
|
|
218
275
|
const option = optionByValue.get(selectedValue);
|
|
219
276
|
if (option) selectedOptionCacheRef.current.set(selectedValue, option);
|
|
220
277
|
});
|
|
221
278
|
}, [optionByValue, selectedValues]);
|
|
222
|
-
const selectedOptions =
|
|
279
|
+
const selectedOptions = React2.useMemo(
|
|
223
280
|
() => selectedValues.map(
|
|
224
281
|
(selectedValue) => optionByValue.get(selectedValue) ?? selectedOptionCacheRef.current.get(selectedValue)
|
|
225
282
|
).filter((option) => option !== void 0),
|
|
226
283
|
[optionByValue, selectedValues]
|
|
227
284
|
);
|
|
228
|
-
const
|
|
285
|
+
const responsiveLayout = useResponsiveTags(responsiveTags, selectedOptions, hasInlineSearch);
|
|
286
|
+
const filteredFlat = React2.useMemo(() => {
|
|
229
287
|
if (!searchValue.trim()) return allFlat;
|
|
230
288
|
if (filterOption === false) return allFlat;
|
|
231
289
|
const f = typeof filterOption === "function" ? filterOption : (input, option) => defaultFilter(input, option, optionFilterProp);
|
|
232
290
|
return allFlat.filter((o) => f(searchValue, o));
|
|
233
291
|
}, [allFlat, filterOption, optionFilterProp, searchValue]);
|
|
234
|
-
const filteredItems =
|
|
292
|
+
const filteredItems = React2.useMemo(() => {
|
|
235
293
|
if (!searchValue.trim()) {
|
|
236
294
|
return orderedItems.filter((item) => !isGroup(item) || item.options.length > 0);
|
|
237
295
|
}
|
|
@@ -243,7 +301,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
243
301
|
return kept.length ? { ...it, options: kept } : null;
|
|
244
302
|
}).filter((x) => x !== null);
|
|
245
303
|
}, [orderedItems, filteredFlat, searchValue]);
|
|
246
|
-
|
|
304
|
+
React2.useEffect(() => {
|
|
247
305
|
setActiveIdx((current) => {
|
|
248
306
|
if (current >= 0 && current < filteredFlat.length && !isOptionDisabled(filteredFlat[current])) {
|
|
249
307
|
return current;
|
|
@@ -357,7 +415,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
357
415
|
"data-inline-size": multiHasSelection ? "content" : "fill",
|
|
358
416
|
type: "search",
|
|
359
417
|
value: searchValue,
|
|
360
|
-
style: multiHasSelection ? { width: `${Math.min(Math.max(searchDisplayWidth + 1, 2), 32)}ch` } : void 0,
|
|
418
|
+
style: responsiveTags ? { width: responsiveLayout.inputWidth } : multiHasSelection ? { width: `${Math.min(Math.max(searchDisplayWidth + 1, 2), 32)}ch` } : void 0,
|
|
361
419
|
placeholder: isMulti ? multiValue.length === 0 ? placeholder : void 0 : "\u641C\u7D22...",
|
|
362
420
|
disabled,
|
|
363
421
|
autoComplete: "off",
|
|
@@ -382,16 +440,21 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
382
440
|
const renderTrigger = () => {
|
|
383
441
|
if (isMulti) {
|
|
384
442
|
const selected = selectedOptions;
|
|
385
|
-
const max = maxTagCount;
|
|
443
|
+
const max = typeof maxTagCount === "number" ? maxTagCount : void 0;
|
|
386
444
|
const shown = max != null ? selected.slice(0, max) : selected;
|
|
387
|
-
const overflow = selected.length - shown.length;
|
|
388
|
-
if (selected.length === 0 && !hasInlineSearch) {
|
|
445
|
+
const overflow = selected.length - (responsiveTags ? responsiveLayout.count : shown.length);
|
|
446
|
+
if (selected.length === 0 && !hasInlineSearch && !responsiveTags) {
|
|
389
447
|
return /* @__PURE__ */ jsx("span", { className: "placeholder", children: placeholder });
|
|
390
448
|
}
|
|
391
|
-
return /* @__PURE__ */ jsx(InternalComponentThemePart, { components: "Tag", children: /* @__PURE__ */ jsxs("span", { className: "select-tags", children: [
|
|
392
|
-
|
|
449
|
+
return /* @__PURE__ */ jsx(InternalComponentThemePart, { components: "Tag", children: /* @__PURE__ */ jsxs("span", { className: "select-tags", ref: responsiveLayout.tagsRef, children: [
|
|
450
|
+
selected.length === 0 && !hasInlineSearch && /* @__PURE__ */ jsx("span", { className: "placeholder", children: placeholder }),
|
|
451
|
+
shown.map((o, index) => /* @__PURE__ */ jsx(
|
|
393
452
|
Tag,
|
|
394
453
|
{
|
|
454
|
+
"data-select-tag": responsiveTags ? "" : void 0,
|
|
455
|
+
"data-collapsed": responsiveTags && index >= responsiveLayout.count ? "true" : void 0,
|
|
456
|
+
"aria-hidden": responsiveTags && index >= responsiveLayout.count ? true : void 0,
|
|
457
|
+
...responsiveTags && index >= responsiveLayout.count ? { inert: "" } : {},
|
|
395
458
|
tone: "accent",
|
|
396
459
|
removable: !disabled,
|
|
397
460
|
onRemove: () => removeMultiValue(o.value),
|
|
@@ -408,7 +471,14 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
408
471
|
"+",
|
|
409
472
|
overflow
|
|
410
473
|
] }),
|
|
411
|
-
renderInlineSearchInput()
|
|
474
|
+
renderInlineSearchInput(),
|
|
475
|
+
responsiveTags && /* @__PURE__ */ jsxs("span", { className: "select-tag-measurements", "aria-hidden": "true", ...{ inert: "" }, children: [
|
|
476
|
+
selected.map((option, index) => /* @__PURE__ */ jsxs(Tag, { tone: "neutral", "data-select-overflow": "", children: [
|
|
477
|
+
"+",
|
|
478
|
+
index + 1
|
|
479
|
+
] }, String(option.value))),
|
|
480
|
+
hasInlineSearch && /* @__PURE__ */ jsx("span", { className: "select-search-measure", children: searchValue || "\u200B" })
|
|
481
|
+
] })
|
|
412
482
|
] }) });
|
|
413
483
|
}
|
|
414
484
|
if (showsInlineSearchInput) return renderInlineSearchInput();
|
|
@@ -424,6 +494,24 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
424
494
|
};
|
|
425
495
|
const hasSelection = isMulti ? multiValue.length > 0 : singleValue != null;
|
|
426
496
|
const showClear = mergedClearable && hasSelection && !disabled;
|
|
497
|
+
const renderClearButton = () => showClear && /* @__PURE__ */ jsx(
|
|
498
|
+
"button",
|
|
499
|
+
{
|
|
500
|
+
type: "button",
|
|
501
|
+
className: "select-clear",
|
|
502
|
+
"aria-label": "Clear",
|
|
503
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
504
|
+
onMouseDown: (event) => {
|
|
505
|
+
if (hasInlineSearch) event.preventDefault();
|
|
506
|
+
event.stopPropagation();
|
|
507
|
+
},
|
|
508
|
+
onClick: (event) => {
|
|
509
|
+
event.stopPropagation();
|
|
510
|
+
clearAll();
|
|
511
|
+
},
|
|
512
|
+
children: mergedClearIcon ?? /* @__PURE__ */ jsx(Icon, { name: "x", size: 12 })
|
|
513
|
+
}
|
|
514
|
+
);
|
|
427
515
|
let renderIdx = -1;
|
|
428
516
|
const renderOption = (o, groupPinned = false) => {
|
|
429
517
|
renderIdx += 1;
|
|
@@ -483,7 +571,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
483
571
|
);
|
|
484
572
|
};
|
|
485
573
|
const renderMenuItems = (items) => items.map(
|
|
486
|
-
(item, groupIndex) => isGroup(item) ? /* @__PURE__ */ jsxs(
|
|
574
|
+
(item, groupIndex) => isGroup(item) ? /* @__PURE__ */ jsxs(React2.Fragment, { children: [
|
|
487
575
|
/* @__PURE__ */ jsx("div", { className: "menu-group-label", children: item.label }),
|
|
488
576
|
item.options.map((option) => renderOption(option, !!item.pinned))
|
|
489
577
|
] }, `g-${groupIndex}-${item.pinned ? "pinned" : "regular"}`) : renderOption(item)
|
|
@@ -507,7 +595,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
507
595
|
{
|
|
508
596
|
ref: setTriggerRef,
|
|
509
597
|
...rest,
|
|
510
|
-
className: `select ${size} ${isMulti ? "multi" : ""} ${hasInlineSearch ? "searchable" : ""} ${open ? "open" : ""} ${disabled ? "disabled" : ""} ${invalid ? "invalid" : ""} ${className}`,
|
|
598
|
+
className: `select ${size} ${isMulti ? "multi" : ""} ${responsiveTags ? "responsive" : ""} ${hasInlineSearch ? "searchable" : ""} ${open ? "open" : ""} ${disabled ? "disabled" : ""} ${invalid ? "invalid" : ""} ${className}`,
|
|
511
599
|
onKeyDown: (e) => {
|
|
512
600
|
onRootKeyDown?.(e);
|
|
513
601
|
const target = e.target;
|
|
@@ -554,28 +642,12 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
554
642
|
"aria-activedescendant": showsInlineSearchInput ? void 0 : open && activeIdx >= 0 ? `${listboxId}-option-${activeIdx}` : void 0,
|
|
555
643
|
children: [
|
|
556
644
|
renderTrigger(),
|
|
645
|
+
responsiveTags && renderClearButton(),
|
|
557
646
|
/* @__PURE__ */ jsx(Icon, { name: "chevDown", size: 14, className: "select-caret" })
|
|
558
647
|
]
|
|
559
648
|
}
|
|
560
649
|
),
|
|
561
|
-
|
|
562
|
-
"button",
|
|
563
|
-
{
|
|
564
|
-
type: "button",
|
|
565
|
-
className: "select-clear",
|
|
566
|
-
"aria-label": "Clear",
|
|
567
|
-
onPointerDown: (event) => event.stopPropagation(),
|
|
568
|
-
onMouseDown: (event) => {
|
|
569
|
-
if (hasInlineSearch) event.preventDefault();
|
|
570
|
-
event.stopPropagation();
|
|
571
|
-
},
|
|
572
|
-
onClick: (event) => {
|
|
573
|
-
event.stopPropagation();
|
|
574
|
-
clearAll();
|
|
575
|
-
},
|
|
576
|
-
children: mergedClearIcon ?? /* @__PURE__ */ jsx(Icon, { name: "x", size: 12 })
|
|
577
|
-
}
|
|
578
|
-
),
|
|
650
|
+
!responsiveTags && renderClearButton(),
|
|
579
651
|
open && portalContainer && createPortal(
|
|
580
652
|
/* @__PURE__ */ jsx(
|
|
581
653
|
"div",
|
|
@@ -614,7 +686,7 @@ var SelectInner = (props, forwardedRef) => {
|
|
|
614
686
|
}
|
|
615
687
|
);
|
|
616
688
|
};
|
|
617
|
-
var SelectBase =
|
|
689
|
+
var SelectBase = React2.forwardRef(SelectInner);
|
|
618
690
|
SelectBase.displayName = "Select";
|
|
619
691
|
var Select = withComponentTheme(
|
|
620
692
|
SelectBase,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkG5ENSJBS_cjs = require('./chunk-G5ENSJBS.cjs');
|
|
4
4
|
var chunkV6BLBIY6_cjs = require('./chunk-V6BLBIY6.cjs');
|
|
5
5
|
require('./tokens-223RYVVS.css');
|
|
6
6
|
require('./shared-NJHRNLRH.css');
|
|
@@ -77,7 +77,7 @@ var TableProInner = ({
|
|
|
77
77
|
actions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "table-toolbar-actions", children: actions })
|
|
78
78
|
] }),
|
|
79
79
|
/* @__PURE__ */ jsxRuntime.jsx(chunkV6BLBIY6_cjs.InternalComponentThemePart, { components: "Table", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
80
|
-
|
|
80
|
+
chunkG5ENSJBS_cjs.Table,
|
|
81
81
|
{
|
|
82
82
|
columns,
|
|
83
83
|
data,
|
package/dist/index.cjs
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var chunkRXITGNPX_cjs = require('./chunk-RXITGNPX.cjs');
|
|
4
4
|
var chunkXHKSUKKL_cjs = require('./chunk-XHKSUKKL.cjs');
|
|
5
5
|
var chunk3D5RJA7R_cjs = require('./chunk-3D5RJA7R.cjs');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var chunkV6DY7J2Z_cjs = require('./chunk-V6DY7J2Z.cjs');
|
|
7
|
+
var chunkG5ENSJBS_cjs = require('./chunk-G5ENSJBS.cjs');
|
|
8
8
|
var chunkAEY76EAH_cjs = require('./chunk-AEY76EAH.cjs');
|
|
9
9
|
require('./chunk-HYJSMFZA.cjs');
|
|
10
10
|
var chunkAQN3PD24_cjs = require('./chunk-AQN3PD24.cjs');
|
|
@@ -20,8 +20,8 @@ var chunk6WEXRX7K_cjs = require('./chunk-6WEXRX7K.cjs');
|
|
|
20
20
|
var chunkZ6AG7O4B_cjs = require('./chunk-Z6AG7O4B.cjs');
|
|
21
21
|
var chunkTPFY5SKB_cjs = require('./chunk-TPFY5SKB.cjs');
|
|
22
22
|
var chunkSOAGRYM3_cjs = require('./chunk-SOAGRYM3.cjs');
|
|
23
|
-
var
|
|
24
|
-
var
|
|
23
|
+
var chunkA5MLLFKT_cjs = require('./chunk-A5MLLFKT.cjs');
|
|
24
|
+
var chunk562P5YMO_cjs = require('./chunk-562P5YMO.cjs');
|
|
25
25
|
var chunkVNP5WB6M_cjs = require('./chunk-VNP5WB6M.cjs');
|
|
26
26
|
var chunk3J7HOTD6_cjs = require('./chunk-3J7HOTD6.cjs');
|
|
27
27
|
var chunkPYCAGTO7_cjs = require('./chunk-PYCAGTO7.cjs');
|
|
@@ -58,7 +58,7 @@ require('./chunk-V6BLBIY6.cjs');
|
|
|
58
58
|
var chunkI4GJZLJU_cjs = require('./chunk-I4GJZLJU.cjs');
|
|
59
59
|
|
|
60
60
|
// src/index.ts
|
|
61
|
-
var VERSION = "0.9.
|
|
61
|
+
var VERSION = "0.9.4";
|
|
62
62
|
|
|
63
63
|
Object.defineProperty(exports, "Timeline", {
|
|
64
64
|
enumerable: true,
|
|
@@ -90,11 +90,11 @@ Object.defineProperty(exports, "Typography", {
|
|
|
90
90
|
});
|
|
91
91
|
Object.defineProperty(exports, "TablePro", {
|
|
92
92
|
enumerable: true,
|
|
93
|
-
get: function () { return
|
|
93
|
+
get: function () { return chunkV6DY7J2Z_cjs.TablePro; }
|
|
94
94
|
});
|
|
95
95
|
Object.defineProperty(exports, "Table", {
|
|
96
96
|
enumerable: true,
|
|
97
|
-
get: function () { return
|
|
97
|
+
get: function () { return chunkG5ENSJBS_cjs.Table; }
|
|
98
98
|
});
|
|
99
99
|
Object.defineProperty(exports, "Tabs", {
|
|
100
100
|
enumerable: true,
|
|
@@ -190,11 +190,11 @@ Object.defineProperty(exports, "Modal", {
|
|
|
190
190
|
});
|
|
191
191
|
Object.defineProperty(exports, "Pagination", {
|
|
192
192
|
enumerable: true,
|
|
193
|
-
get: function () { return
|
|
193
|
+
get: function () { return chunkA5MLLFKT_cjs.Pagination; }
|
|
194
194
|
});
|
|
195
195
|
Object.defineProperty(exports, "Select", {
|
|
196
196
|
enumerable: true,
|
|
197
|
-
get: function () { return
|
|
197
|
+
get: function () { return chunk562P5YMO_cjs.Select; }
|
|
198
198
|
});
|
|
199
199
|
Object.defineProperty(exports, "Tag", {
|
|
200
200
|
enumerable: true,
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { Timeline } from './chunk-U7V2FOIM.js';
|
|
2
2
|
export { Tooltip } from './chunk-TALNKJQ2.js';
|
|
3
3
|
export { Link, Paragraph, Text, Title, Typography } from './chunk-2COQYOVG.js';
|
|
4
|
-
export { TablePro } from './chunk-
|
|
5
|
-
export { Table } from './chunk-
|
|
4
|
+
export { TablePro } from './chunk-T422LYTL.js';
|
|
5
|
+
export { Table } from './chunk-QITKDNCX.js';
|
|
6
6
|
export { Tabs } from './chunk-4JANYBXO.js';
|
|
7
7
|
import './chunk-EE7IJ3MB.js';
|
|
8
8
|
export { THEME_PANEL_DEFAULT_PRESET_OPTIONS, THEME_PANEL_DEFAULT_THEME_PRESETS, ThemePanel } from './chunk-IU6PLLEL.js';
|
|
@@ -18,8 +18,8 @@ export { InputNumber } from './chunk-RYF5ADJW.js';
|
|
|
18
18
|
export { List } from './chunk-LACXN5CI.js';
|
|
19
19
|
export { MessageContainer, ToastContainer, message, toast } from './chunk-2V6RQQRI.js';
|
|
20
20
|
export { Modal } from './chunk-RJCPXAZ3.js';
|
|
21
|
-
export { Pagination } from './chunk-
|
|
22
|
-
export { Select } from './chunk-
|
|
21
|
+
export { Pagination } from './chunk-3SUMCW2F.js';
|
|
22
|
+
export { Select } from './chunk-OKGODC5A.js';
|
|
23
23
|
export { Tag } from './chunk-OGMI3TO5.js';
|
|
24
24
|
export { Popover } from './chunk-A34P5CU7.js';
|
|
25
25
|
export { Progress } from './chunk-BOBT7JUB.js';
|
|
@@ -56,6 +56,6 @@ import './chunk-5HLNFDV4.js';
|
|
|
56
56
|
export { ACCENT_PRESETS, ACCENT_PRESETS_DARK, DEFAULT_THEME_COLORS, FONT_STACKS, ThemeProvider, applyTheme, componentTokensToStyle, deriveThemeColors, normalizeAccentInput, resolveThemeColorScheme, resolveThemeColors, resolveThemeMode, resolveVisualThemeSnapshot, themeColorsToStyle, themeTokenToKebabCase, useTheme, useThemeOptional, visualThemeToStyle } from './chunk-CPVUDSIY.js';
|
|
57
57
|
|
|
58
58
|
// src/index.ts
|
|
59
|
-
var VERSION = "0.9.
|
|
59
|
+
var VERSION = "0.9.4";
|
|
60
60
|
|
|
61
61
|
export { VERSION };
|
package/dist/styles.css
CHANGED
|
@@ -1777,6 +1777,71 @@ button.collapse-chev {
|
|
|
1777
1777
|
}
|
|
1778
1778
|
.select:hover .select-clear { opacity: 1; }
|
|
1779
1779
|
.select-clear:hover { color: var(--lmn-select-accent-ink, var(--accent-ink)); box-shadow: var(--lmn-select-neu-shadow-inset, var(--neu-shadow-inset)); }
|
|
1780
|
+
/* 自适应模式:控件按真实宽度参与布局,标签区只展示测量后能完整容纳的前缀。 */
|
|
1781
|
+
.select.multi.responsive .select-trigger {
|
|
1782
|
+
flex-wrap: nowrap;
|
|
1783
|
+
padding: var(--lmn-select-tag-gap, var(--gap-1)) var(--lmn-select-trigger-padding, var(--gap-2));
|
|
1784
|
+
gap: var(--lmn-select-control-gap, var(--gap-2));
|
|
1785
|
+
}
|
|
1786
|
+
.select.multi.responsive .select-tags {
|
|
1787
|
+
flex-wrap: nowrap;
|
|
1788
|
+
flex: 1 1 0%;
|
|
1789
|
+
gap: var(--lmn-select-tag-gap, var(--gap-1));
|
|
1790
|
+
position: relative;
|
|
1791
|
+
}
|
|
1792
|
+
.select.multi.responsive .select-tags > .tag,
|
|
1793
|
+
.select-tag-measurements > .tag {
|
|
1794
|
+
flex: none;
|
|
1795
|
+
width: max-content;
|
|
1796
|
+
max-width: var(--lmn-select-tag-max-width, 160px);
|
|
1797
|
+
}
|
|
1798
|
+
.select.multi.responsive .select-tags > .select-tag-overflow {
|
|
1799
|
+
max-width: none;
|
|
1800
|
+
}
|
|
1801
|
+
.select.multi.responsive [data-collapsed="true"],
|
|
1802
|
+
.select-tag-measurements {
|
|
1803
|
+
position: absolute;
|
|
1804
|
+
top: 0;
|
|
1805
|
+
left: 0;
|
|
1806
|
+
visibility: hidden;
|
|
1807
|
+
pointer-events: none;
|
|
1808
|
+
}
|
|
1809
|
+
.select-tag-measurements {
|
|
1810
|
+
width: 100%;
|
|
1811
|
+
height: 100%;
|
|
1812
|
+
overflow: hidden;
|
|
1813
|
+
}
|
|
1814
|
+
.select-tag-measurements > .tag {
|
|
1815
|
+
position: absolute;
|
|
1816
|
+
max-width: none;
|
|
1817
|
+
}
|
|
1818
|
+
.select-search-measure {
|
|
1819
|
+
display: block;
|
|
1820
|
+
width: max-content;
|
|
1821
|
+
min-width: 2ch;
|
|
1822
|
+
padding-inline: calc(var(--gap-1) / 2);
|
|
1823
|
+
padding-inline-end: calc(var(--gap-1) / 2 + 1ch);
|
|
1824
|
+
white-space: pre;
|
|
1825
|
+
font: inherit;
|
|
1826
|
+
}
|
|
1827
|
+
.select.multi.responsive .select-search-input {
|
|
1828
|
+
flex: 1 1 auto;
|
|
1829
|
+
min-width: 0;
|
|
1830
|
+
max-width: 100%;
|
|
1831
|
+
field-sizing: fixed;
|
|
1832
|
+
}
|
|
1833
|
+
.select.multi.responsive .select-caret,
|
|
1834
|
+
.select.multi.responsive .select-clear {
|
|
1835
|
+
position: static;
|
|
1836
|
+
transform: none;
|
|
1837
|
+
flex-shrink: 0;
|
|
1838
|
+
}
|
|
1839
|
+
.select.multi.responsive.open .select-caret { transform: rotate(180deg); }
|
|
1840
|
+
.select.multi.responsive .select-tags > .placeholder {
|
|
1841
|
+
overflow: hidden;
|
|
1842
|
+
text-overflow: ellipsis;
|
|
1843
|
+
white-space: nowrap;
|
|
1844
|
+
}
|
|
1780
1845
|
/* Multi-select menu: leading checkbox per item */
|
|
1781
1846
|
.menu-check {
|
|
1782
1847
|
width: 16px;
|
package/docs/llms/select.md
CHANGED
|
@@ -27,6 +27,20 @@ multiple + Tag 形式呈现已选项。
|
|
|
27
27
|
<Select multiple clearable value={tags} onChange={setTags} options={...} />
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
### 单行自适应标签折叠
|
|
31
|
+
|
|
32
|
+
maxTagCount="responsive" 按标签、+N、输入框和按钮的实际占位自动增减展示数量,始终单行。长搜索词在原输入框内横向编辑;折叠不改变完整选值。仅多选启用,数字值与未设置时仍保留原来的数量折叠和换行行为。
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
<Select
|
|
36
|
+
multiple searchable allowClear
|
|
37
|
+
maxTagCount="responsive"
|
|
38
|
+
style={{ width: 218 }}
|
|
39
|
+
value={values} onChange={setValues}
|
|
40
|
+
options={options}
|
|
41
|
+
/>
|
|
42
|
+
```
|
|
43
|
+
|
|
30
44
|
### 远程搜索多选
|
|
31
45
|
|
|
32
46
|
searchable 在单选和多选中都复用选择框本体作为输入;多选 Tag 后的空输入会收缩,不单独占行。选中后保持展开和关键词,业务层负责防抖与迟到结果保护。
|
|
@@ -181,7 +195,7 @@ loading 时显示 spinner,emptyContent 自定义空态。
|
|
|
181
195
|
| onChange | `(value) => void` | — | 变更 |
|
|
182
196
|
| placeholder | `string` | `"请选择…"` | 空选择时的提示文本 |
|
|
183
197
|
| multiple | `boolean` | `false` | 多选 |
|
|
184
|
-
| maxTagCount | `number` | — |
|
|
198
|
+
| maxTagCount | `number | "responsive"` | — | 多选标签展示上限;responsive 按可用宽度动态折叠为 +N 并保持单行,搜索词可横向编辑;不改变选值。数字和未设置时保留既有换行行为 |
|
|
185
199
|
| maxCount | `number` | — | 多选允许的最大选择数;达到上限后禁用未选项 |
|
|
186
200
|
| getOptionDisabled | `(option, selectedValues) => boolean` | — | 基于候选项和当前选择动态判断禁用状态 |
|
|
187
201
|
| searchable | `boolean` | `false` | 在选择框本体内启用搜索,单选和多选共用同一交互形态 |
|
package/docs/llms.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> 拟态风格的 React 18 组件库,目标是 Electron 桌面应用。**写给 AI 编程助手**的按需文档 —— 每个组件单独一个 `.md`,避免一次性读取全部。示例源自 playground 的 demo,可直接复制运行。
|
|
4
4
|
|
|
5
5
|
- **包名**: `@fangxinyan/lumina`
|
|
6
|
-
- **版本**: `0.9.
|
|
6
|
+
- **版本**: `0.9.4`
|
|
7
7
|
- **React 最低版本**: 18
|
|
8
8
|
- **环境**: 带打包器的 React 工程(Vite / Next.js / Webpack / Remix / Electron + Vite 等)
|
|
9
9
|
- **零运行时依赖**: 只依赖 `react` / `react-dom` (peer deps)
|