@sia.soul/sia-react-ui 0.1.141 → 0.1.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/{Button-BiL3Wjsd.d.ts → Button-C8W8ZHWV.d.ts} +1 -1
  2. package/dist/{Button-O_pNB3SQ.d.cts → Button-CxKBjLda.d.cts} +1 -1
  3. package/dist/{Select-DeD4O8FL.d.ts → Select-CTSd8zum.d.ts} +14 -10
  4. package/dist/{Select-Y0e9kaxE.d.cts → Select-bKLket9n.d.cts} +14 -10
  5. package/dist/chart.cjs +1051 -335
  6. package/dist/chart.js +5 -5
  7. package/dist/chunk-4OHS7RXE.js +1004 -0
  8. package/dist/{chunk-WIRIEIRO.js → chunk-4TYHSAR3.js} +5 -5
  9. package/dist/{chunk-L2S7IPSM.js → chunk-566S64IP.js} +5 -5
  10. package/dist/{chunk-CZ2ITBRW.js → chunk-7SEGBB6V.js} +34 -5
  11. package/dist/{chunk-KY6A5IJH.js → chunk-ETQJ2DQ2.js} +1 -1
  12. package/dist/{chunk-WD56MJO2.js → chunk-F52O2MOV.js} +7 -3
  13. package/dist/{chunk-PQBCD54U.js → chunk-JRXYM5YH.js} +167 -64
  14. package/dist/{chunk-SCEHVGKV.js → chunk-LKLPCYEP.js} +2 -2
  15. package/dist/{chunk-DIRPOUVX.js → chunk-MD4CGSOR.js} +105 -61
  16. package/dist/{chunk-436QH6XH.js → chunk-ORSQAJ22.js} +160 -497
  17. package/dist/{chunk-SO7IJZIR.js → chunk-PD3K5U5Y.js} +2 -2
  18. package/dist/{chunk-UVHC6OEX.js → chunk-WCYVBO2N.js} +342 -123
  19. package/dist/{core-DYo5C4Si.d.cts → core-COaZfusa.d.cts} +51 -24
  20. package/dist/{core-sWwvVAmP.d.ts → core-CvfsQGuT.d.ts} +51 -24
  21. package/dist/core.cjs +2000 -1251
  22. package/dist/core.css +416 -344
  23. package/dist/core.d.cts +3 -3
  24. package/dist/core.d.ts +3 -3
  25. package/dist/core.js +18 -9
  26. package/dist/game.cjs +1984 -1169
  27. package/dist/game.css +182 -177
  28. package/dist/game.d.cts +1 -1
  29. package/dist/game.d.ts +1 -1
  30. package/dist/game.js +8 -3
  31. package/dist/index.cjs +4658 -3542
  32. package/dist/index.css +416 -344
  33. package/dist/index.d.cts +84 -81
  34. package/dist/index.d.ts +84 -81
  35. package/dist/index.js +1075 -713
  36. package/dist/markdown-editor.cjs +727 -40
  37. package/dist/markdown-editor.js +8 -3
  38. package/dist/rich-text-editor.cjs +1265 -308
  39. package/dist/rich-text-editor.js +12 -7
  40. package/dist/{select-date-range-X6a9Y-Te.d.ts → select-date-range-C8cacfmb.d.ts} +1 -1
  41. package/dist/{select-date-range-DiBQQ0Rn.d.cts → select-date-range-Dad0IdD4.d.cts} +1 -1
  42. package/dist/select-date-range.cjs +1281 -807
  43. package/dist/select-date-range.d.cts +3 -3
  44. package/dist/select-date-range.d.ts +3 -3
  45. package/dist/select-date-range.js +13 -8
  46. package/package.json +9 -2
  47. package/dist/chunk-NZMUW5XI.js +0 -292
@@ -1,41 +1,80 @@
1
1
  import {
2
2
  Dropdown,
3
- Input,
4
- registerFloatingScrollbar,
5
- setFloatingScrollbarDragging
6
- } from "./chunk-UVHC6OEX.js";
3
+ Input
4
+ } from "./chunk-WCYVBO2N.js";
7
5
  import {
8
6
  Icon,
9
7
  Modal,
10
8
  isAnchorBehindOverlay,
11
9
  subscribeOverlayLayers
12
- } from "./chunk-PQBCD54U.js";
10
+ } from "./chunk-JRXYM5YH.js";
13
11
  import {
14
12
  Button
15
- } from "./chunk-CZ2ITBRW.js";
13
+ } from "./chunk-7SEGBB6V.js";
16
14
  import {
17
15
  useFloatingPlaceholder
18
- } from "./chunk-KY6A5IJH.js";
16
+ } from "./chunk-ETQJ2DQ2.js";
19
17
  import {
20
18
  ControlSizeContext,
19
+ FloatingScrollbarProvider,
21
20
  PopupPortal,
22
21
  useControlSize,
23
22
  useControllableState,
23
+ useOverlayMotion,
24
24
  withTitleTooltip
25
- } from "./chunk-NZMUW5XI.js";
25
+ } from "./chunk-4OHS7RXE.js";
26
+
27
+ // src/components/usePressFeedback.ts
28
+ import { useEffect, useRef } from "react";
29
+ function usePressFeedback() {
30
+ const running = useRef();
31
+ const cleanup = useRef();
32
+ useEffect(() => () => cleanup.current?.(), []);
33
+ return (node, compact = true) => {
34
+ if (!node?.animate) return;
35
+ const media = window.matchMedia("(prefers-reduced-motion: reduce)");
36
+ if (media.matches) return;
37
+ const from = getComputedStyle(node).scale;
38
+ cleanup.current?.();
39
+ const animation = node.animate([
40
+ { scale: from === "none" ? "1" : from, offset: 0 },
41
+ // 小控件放大过冲和二次回收,避免十几像素的图形回弹难以察觉。
42
+ { scale: compact ? ".68" : ".92", offset: 0.18 },
43
+ { scale: compact ? "1.34" : "1.08", offset: 0.46 },
44
+ { scale: compact ? ".88" : ".96", offset: 0.7 },
45
+ { scale: compact ? "1.08" : "1.025", offset: 0.86 },
46
+ { scale: "1", offset: 1 }
47
+ ], { duration: compact ? 360 : 320, easing: "cubic-bezier(.3,0,.25,1)" });
48
+ running.current = animation;
49
+ const stop = () => {
50
+ animation.cancel();
51
+ media.removeEventListener("change", stop);
52
+ if (running.current === animation) {
53
+ running.current = void 0;
54
+ cleanup.current = void 0;
55
+ }
56
+ };
57
+ cleanup.current = stop;
58
+ media.addEventListener("change", stop, { once: true });
59
+ animation.onfinish = stop;
60
+ };
61
+ }
26
62
 
27
63
  // src/components/Checkbox.tsx
28
- import { createContext, forwardRef, useContext, useEffect, useId, useMemo, useRef } from "react";
64
+ import { createContext, forwardRef, useContext, useEffect as useEffect2, useId, useMemo, useRef as useRef2 } from "react";
29
65
  import { jsx, jsxs } from "react/jsx-runtime";
30
66
  var CheckboxGroupContext = createContext(null);
31
- var CheckboxRoot = forwardRef(function Checkbox({ value, size: sizeProp, indeterminate = false, children, disabled, checked, defaultChecked, className = "", onChange, ...props }, forwardedRef) {
67
+ var CheckboxRoot = forwardRef(function Checkbox({ value, size: sizeProp, shape: shapeProp, indeterminate = false, children, disabled, checked, defaultChecked, className = "", onChange, ...props }, forwardedRef) {
32
68
  const size = useControlSize(sizeProp);
33
69
  const group = useContext(CheckboxGroupContext);
34
- const localRef = useRef(null);
70
+ const shape = shapeProp ?? group?.shape ?? "square";
71
+ const localRef = useRef2(null);
72
+ const controlRef = useRef2(null);
73
+ const press = usePressFeedback();
35
74
  const fallbackId = useId();
36
75
  const grouped = group !== null && value !== void 0;
37
76
  const currentChecked = grouped ? group.values.includes(value) : checked;
38
- useEffect(() => {
77
+ useEffect2(() => {
39
78
  if (localRef.current) localRef.current.indeterminate = indeterminate;
40
79
  }, [indeterminate]);
41
80
  function setRef(node) {
@@ -43,7 +82,7 @@ var CheckboxRoot = forwardRef(function Checkbox({ value, size: sizeProp, indeter
43
82
  if (typeof forwardedRef === "function") forwardedRef(node);
44
83
  else if (forwardedRef) forwardedRef.current = node;
45
84
  }
46
- return /* @__PURE__ */ jsxs("label", { className: `sia-checkbox sia-checkbox--${size}${disabled || group?.disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
85
+ return /* @__PURE__ */ jsxs("label", { className: `sia-checkbox sia-checkbox--${size} sia-checkbox--${shape}${disabled || group?.disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
47
86
  /* @__PURE__ */ jsx(
48
87
  "input",
49
88
  {
@@ -56,6 +95,10 @@ var CheckboxRoot = forwardRef(function Checkbox({ value, size: sizeProp, indeter
56
95
  disabled: disabled || group?.disabled,
57
96
  checked: currentChecked,
58
97
  defaultChecked: grouped ? void 0 : defaultChecked,
98
+ onClick: (event) => {
99
+ props.onClick?.(event);
100
+ if (!event.defaultPrevented && !event.currentTarget.disabled) press(controlRef.current);
101
+ },
59
102
  "aria-checked": indeterminate ? "mixed" : currentChecked,
60
103
  onChange: (event) => {
61
104
  if (grouped) group.toggle(value, event.currentTarget.checked);
@@ -63,12 +106,13 @@ var CheckboxRoot = forwardRef(function Checkbox({ value, size: sizeProp, indeter
63
106
  }
64
107
  }
65
108
  ),
66
- /* @__PURE__ */ jsx("span", { className: "sia-checkbox__control", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", {}) }),
109
+ /* @__PURE__ */ jsx("span", { ref: controlRef, className: "sia-checkbox__control", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", {}) }),
67
110
  children !== void 0 ? /* @__PURE__ */ jsx("span", { className: "sia-checkbox__label", children }) : null
68
111
  ] });
69
112
  });
70
113
  function CheckboxGroup({
71
114
  size: sizeProp,
115
+ shape = "square",
72
116
  columns,
73
117
  direction = "horizontal",
74
118
  gap,
@@ -89,6 +133,7 @@ function CheckboxGroup({
89
133
  };
90
134
  const [values, setValues] = useControllableState({ value, defaultValue, onChange });
91
135
  const context = useMemo(() => ({
136
+ shape,
92
137
  values,
93
138
  disabled,
94
139
  name,
@@ -96,7 +141,7 @@ function CheckboxGroup({
96
141
  const next = checked ? values.includes(optionValue) ? values : [...values, optionValue] : values.filter((item) => item !== optionValue);
97
142
  setValues(next);
98
143
  }
99
- }), [disabled, name, setValues, values]);
144
+ }), [disabled, name, setValues, values, shape]);
100
145
  return /* @__PURE__ */ jsx(ControlSizeContext.Provider, { value: size, children: /* @__PURE__ */ jsx(CheckboxGroupContext.Provider, { value: context, children: /* @__PURE__ */ jsxs("div", { className: `sia-checkbox-group${gridColumns ? " sia-checkbox-group--grid" : direction === "vertical" ? " sia-checkbox-group--vertical" : ""} ${className}`.trim(), style: layoutStyle, role: "group", children: [
101
146
  options?.map((option) => {
102
147
  const normalized = typeof option === "object" ? option : { label: String(option), value: option };
@@ -110,426 +155,6 @@ var Checkbox2 = Object.assign(CheckboxRoot, {
110
155
  Group: CheckboxGroup
111
156
  });
112
157
 
113
- // src/components/FloatingScrollbarProvider.tsx
114
- import { useEffect as useEffect3 } from "react";
115
-
116
- // src/components/useScrollbarProximity.ts
117
- import { useEffect as useEffect2 } from "react";
118
- var users = 0;
119
- var cleanup;
120
- function useScrollbarProximity() {
121
- useEffect2(() => {
122
- if (users++ === 0) {
123
- let frame = 0;
124
- let x = -Infinity;
125
- let y = -Infinity;
126
- const nearby = /* @__PURE__ */ new Set();
127
- const clear = () => {
128
- nearby.forEach((track) => track.removeAttribute("data-scrollbar-near"));
129
- nearby.clear();
130
- };
131
- const update = () => {
132
- frame = 0;
133
- const next = /* @__PURE__ */ new Set();
134
- document.querySelectorAll(".sia-scrollbar-track").forEach((track) => {
135
- const rect = track.getBoundingClientRect();
136
- const proximity = Number.parseFloat(getComputedStyle(track).getPropertyValue("--sia-scrollbar-proximity")) || 16;
137
- if (rect.width && rect.height && x >= rect.left - proximity && x <= rect.right + proximity && y >= rect.top - proximity && y <= rect.bottom + proximity) {
138
- next.add(track);
139
- if (!nearby.has(track)) track.setAttribute("data-scrollbar-near", "true");
140
- }
141
- });
142
- nearby.forEach((track) => {
143
- if (!next.has(track)) track.removeAttribute("data-scrollbar-near");
144
- });
145
- nearby.clear();
146
- next.forEach((track) => nearby.add(track));
147
- };
148
- const move = (event) => {
149
- if (event.pointerType === "touch") return;
150
- x = event.clientX;
151
- y = event.clientY;
152
- if (!frame) frame = requestAnimationFrame(update);
153
- };
154
- const leave = () => {
155
- x = y = -Infinity;
156
- clear();
157
- };
158
- document.addEventListener("pointermove", move, { passive: true });
159
- document.documentElement.addEventListener("pointerleave", leave);
160
- window.addEventListener("blur", leave);
161
- cleanup = () => {
162
- if (frame) cancelAnimationFrame(frame);
163
- document.removeEventListener("pointermove", move);
164
- document.documentElement.removeEventListener("pointerleave", leave);
165
- window.removeEventListener("blur", leave);
166
- clear();
167
- };
168
- }
169
- return () => {
170
- if (--users === 0) {
171
- cleanup?.();
172
- cleanup = void 0;
173
- }
174
- };
175
- }, []);
176
- }
177
-
178
- // src/components/FloatingScrollbarProvider.tsx
179
- var scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
180
- var clippingOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay", "hidden", "clip"]);
181
- function isRootScroller(target) {
182
- return target === document.scrollingElement || target === document.documentElement;
183
- }
184
- function canScroll(target, axis) {
185
- if (target.matches(".sia-table__viewport, [data-sia-native-scrollbar]")) return false;
186
- if (isRootScroller(target)) {
187
- return axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
188
- }
189
- const style = getComputedStyle(target);
190
- const overflow = axis === "horizontal" ? style.overflowX : style.overflowY;
191
- const hasOverflow = axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
192
- return hasOverflow && scrollableOverflow.has(overflow);
193
- }
194
- function visibleRect(target) {
195
- if (isRootScroller(target)) {
196
- return { top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0, width: window.innerWidth, height: window.innerHeight };
197
- }
198
- const ownRect = target.getBoundingClientRect();
199
- let top = Math.max(0, ownRect.top);
200
- let right = Math.min(window.innerWidth, ownRect.right);
201
- let bottom = Math.min(window.innerHeight, ownRect.bottom);
202
- let left = Math.max(0, ownRect.left);
203
- let parent = target.parentElement;
204
- while (parent && parent !== document.body && parent !== document.documentElement) {
205
- const style = getComputedStyle(parent);
206
- const clipX = clippingOverflow.has(style.overflowX);
207
- const clipY = clippingOverflow.has(style.overflowY);
208
- if (clipX || clipY) {
209
- const rect = parent.getBoundingClientRect();
210
- if (clipX) {
211
- left = Math.max(left, rect.left);
212
- right = Math.min(right, rect.right);
213
- }
214
- if (clipY) {
215
- top = Math.max(top, rect.top);
216
- bottom = Math.min(bottom, rect.bottom);
217
- }
218
- }
219
- parent = parent.parentElement;
220
- }
221
- return {
222
- top,
223
- right,
224
- bottom,
225
- left,
226
- width: Math.max(0, right - left),
227
- height: Math.max(0, bottom - top)
228
- };
229
- }
230
- function createTrack(axis) {
231
- const track = document.createElement("div");
232
- const thumb = document.createElement("div");
233
- track.className = `sia-scrollbar-track sia-floating-scrollbar sia-floating-scrollbar--${axis}`;
234
- thumb.className = "sia-floating-scrollbar__thumb";
235
- track.dataset.axis = axis;
236
- track.setAttribute("aria-hidden", "true");
237
- track.append(thumb);
238
- return { track, thumb };
239
- }
240
- function FloatingScrollbarProvider({ disabled = false, targetRef }) {
241
- useScrollbarProximity();
242
- useEffect3(() => {
243
- if (disabled) return;
244
- const layer = document.createElement("div");
245
- layer.className = "sia-floating-scrollbar-layer";
246
- layer.setAttribute("aria-hidden", "true");
247
- document.body.append(layer);
248
- const entries = /* @__PURE__ */ new Map();
249
- let scanFrame = 0;
250
- let updateFrame = 0;
251
- const dirtyStyles = /* @__PURE__ */ new Set();
252
- let fullScan = true;
253
- const setEntryVisible = (entry, visible) => {
254
- entry.horizontalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
255
- entry.verticalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
256
- };
257
- const showEntry = (entry) => {
258
- if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
259
- entry.hideTimer = null;
260
- setEntryVisible(entry, true);
261
- };
262
- const scheduleHide = (entry, delay = 500) => {
263
- if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
264
- entry.hideTimer = window.setTimeout(() => {
265
- entry.hideTimer = null;
266
- if (!entry.hoveringTarget && !entry.hoveringTrack && !entry.dragging) setEntryVisible(entry, false);
267
- }, delay);
268
- };
269
- const updateEntry = (entry) => {
270
- const { target, horizontalTrack, horizontalThumb, verticalTrack, verticalThumb } = entry;
271
- const hasHorizontal = canScroll(target, "horizontal");
272
- const hasVertical = canScroll(target, "vertical");
273
- const rect = visibleRect(target);
274
- const thickness = 10;
275
- horizontalTrack.hidden = !hasHorizontal || rect.width <= thickness || rect.height <= 0;
276
- verticalTrack.hidden = !hasVertical || rect.height <= thickness || rect.width <= 0;
277
- if (!horizontalTrack.hidden) {
278
- const trackWidth = Math.max(0, rect.width - (hasVertical ? thickness : 0));
279
- const thumbWidth = Math.max(24, Math.min(trackWidth, trackWidth * target.clientWidth / target.scrollWidth));
280
- const travel = Math.max(0, trackWidth - thumbWidth);
281
- const maxScroll = Math.max(1, target.scrollWidth - target.clientWidth);
282
- horizontalTrack.style.left = `${rect.left}px`;
283
- horizontalTrack.style.top = `${rect.bottom - thickness}px`;
284
- horizontalTrack.style.width = `${trackWidth}px`;
285
- horizontalTrack.style.height = `${thickness}px`;
286
- horizontalThumb.style.width = `${thumbWidth}px`;
287
- horizontalThumb.style.transform = `translate3d(${travel * target.scrollLeft / maxScroll}px, 0, 0)`;
288
- }
289
- if (!verticalTrack.hidden) {
290
- const trackHeight = Math.max(0, rect.height - (hasHorizontal ? thickness : 0));
291
- const thumbHeight = Math.max(24, Math.min(trackHeight, trackHeight * target.clientHeight / target.scrollHeight));
292
- const travel = Math.max(0, trackHeight - thumbHeight);
293
- const maxScroll = Math.max(1, target.scrollHeight - target.clientHeight);
294
- verticalTrack.style.left = `${rect.right - thickness}px`;
295
- verticalTrack.style.top = `${rect.top}px`;
296
- verticalTrack.style.width = `${thickness}px`;
297
- verticalTrack.style.height = `${trackHeight}px`;
298
- verticalThumb.style.height = `${thumbHeight}px`;
299
- verticalThumb.style.transform = `translate3d(0, ${travel * target.scrollTop / maxScroll}px, 0)`;
300
- }
301
- };
302
- const scheduleUpdateAll = () => {
303
- if (updateFrame) return;
304
- updateFrame = window.requestAnimationFrame(() => {
305
- updateFrame = 0;
306
- entries.forEach(updateEntry);
307
- });
308
- };
309
- const bindTrackDrag = (entry, axis, track, thumb) => {
310
- const target = entry.target;
311
- const onTrackPointerEnter = () => {
312
- entry.hoveringTrack = true;
313
- showEntry(entry);
314
- };
315
- const onTrackPointerLeave = () => {
316
- entry.hoveringTrack = false;
317
- scheduleHide(entry);
318
- };
319
- const onTrackPointerDown = (event) => {
320
- if (event.target === thumb || event.button !== 0) return;
321
- event.preventDefault();
322
- event.stopPropagation();
323
- const trackRect = track.getBoundingClientRect();
324
- const thumbRect = thumb.getBoundingClientRect();
325
- const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
326
- const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
327
- const pointer = axis === "vertical" ? event.clientY - trackRect.top : event.clientX - trackRect.left;
328
- const ratio = Math.max(0, Math.min(1, (pointer - thumbLength / 2) / Math.max(1, trackLength - thumbLength)));
329
- if (axis === "vertical") target.scrollTop = ratio * (target.scrollHeight - target.clientHeight);
330
- else target.scrollLeft = ratio * (target.scrollWidth - target.clientWidth);
331
- };
332
- const onThumbPointerDown = (event) => {
333
- if (event.button !== 0) return;
334
- event.preventDefault();
335
- event.stopPropagation();
336
- entry.dragging = true;
337
- setFloatingScrollbarDragging(track, true);
338
- showEntry(entry);
339
- thumb.setPointerCapture(event.pointerId);
340
- const startPointer = axis === "vertical" ? event.clientY : event.clientX;
341
- const startScroll = axis === "vertical" ? target.scrollTop : target.scrollLeft;
342
- const trackRect = track.getBoundingClientRect();
343
- const thumbRect = thumb.getBoundingClientRect();
344
- const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
345
- const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
346
- const maxScroll = axis === "vertical" ? target.scrollHeight - target.clientHeight : target.scrollWidth - target.clientWidth;
347
- const travel = Math.max(1, trackLength - thumbLength);
348
- const onPointerMove = (moveEvent) => {
349
- if (moveEvent.pointerId !== event.pointerId) return;
350
- const pointer = axis === "vertical" ? moveEvent.clientY : moveEvent.clientX;
351
- const nextScroll = startScroll + (pointer - startPointer) * maxScroll / travel;
352
- if (axis === "vertical") target.scrollTop = nextScroll;
353
- else target.scrollLeft = nextScroll;
354
- };
355
- const onPointerUp = (upEvent) => {
356
- if (upEvent.pointerId !== event.pointerId) return;
357
- entry.dragging = false;
358
- setFloatingScrollbarDragging(track, false);
359
- thumb.releasePointerCapture(event.pointerId);
360
- window.removeEventListener("pointermove", onPointerMove);
361
- window.removeEventListener("pointerup", onPointerUp);
362
- window.removeEventListener("pointercancel", onPointerUp);
363
- scheduleHide(entry);
364
- };
365
- window.addEventListener("pointermove", onPointerMove);
366
- window.addEventListener("pointerup", onPointerUp);
367
- window.addEventListener("pointercancel", onPointerUp);
368
- };
369
- track.addEventListener("pointerenter", onTrackPointerEnter);
370
- track.addEventListener("pointerleave", onTrackPointerLeave);
371
- track.addEventListener("pointerdown", onTrackPointerDown);
372
- thumb.addEventListener("pointerdown", onThumbPointerDown);
373
- return () => {
374
- track.removeEventListener("pointerenter", onTrackPointerEnter);
375
- track.removeEventListener("pointerleave", onTrackPointerLeave);
376
- track.removeEventListener("pointerdown", onTrackPointerDown);
377
- thumb.removeEventListener("pointerdown", onThumbPointerDown);
378
- };
379
- };
380
- const resizeObserver = new ResizeObserver((observedEntries) => {
381
- observedEntries.forEach(({ target }) => {
382
- const entry = entries.get(target);
383
- if (entry) updateEntry(entry);
384
- });
385
- });
386
- const addTarget = (target) => {
387
- if (entries.has(target)) return;
388
- const horizontal = createTrack("horizontal");
389
- const vertical = createTrack("vertical");
390
- const releaseHorizontalOwner = registerFloatingScrollbar(horizontal.track, target);
391
- const releaseVerticalOwner = registerFloatingScrollbar(vertical.track, target);
392
- layer.append(horizontal.track, vertical.track);
393
- const onPointerEnter = () => {
394
- const entry2 = entries.get(target);
395
- if (!entry2) return;
396
- entry2.hoveringTarget = true;
397
- showEntry(entry2);
398
- };
399
- const onPointerLeave = () => {
400
- const entry2 = entries.get(target);
401
- if (!entry2) return;
402
- entry2.hoveringTarget = false;
403
- scheduleHide(entry2);
404
- };
405
- const onScroll = () => {
406
- const entry2 = entries.get(target);
407
- if (!entry2) return;
408
- updateEntry(entry2);
409
- showEntry(entry2);
410
- scheduleHide(entry2, 700);
411
- };
412
- target.addEventListener("pointerenter", onPointerEnter);
413
- target.addEventListener("pointerleave", onPointerLeave);
414
- target.addEventListener("scroll", onScroll, { passive: true });
415
- const entry = {
416
- target,
417
- horizontalTrack: horizontal.track,
418
- horizontalThumb: horizontal.thumb,
419
- verticalTrack: vertical.track,
420
- verticalThumb: vertical.thumb,
421
- hideTimer: null,
422
- hoveringTarget: target.matches(":hover"),
423
- hoveringTrack: false,
424
- dragging: false,
425
- cleanup: () => void 0
426
- };
427
- const cleanupHorizontal = bindTrackDrag(entry, "horizontal", horizontal.track, horizontal.thumb);
428
- const cleanupVertical = bindTrackDrag(entry, "vertical", vertical.track, vertical.thumb);
429
- entry.cleanup = () => {
430
- if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
431
- cleanupHorizontal();
432
- cleanupVertical();
433
- releaseHorizontalOwner();
434
- releaseVerticalOwner();
435
- target.removeEventListener("pointerenter", onPointerEnter);
436
- target.removeEventListener("pointerleave", onPointerLeave);
437
- target.removeEventListener("scroll", onScroll);
438
- resizeObserver.unobserve(target);
439
- target.removeAttribute("data-sia-floating-scrollbar");
440
- horizontal.track.remove();
441
- vertical.track.remove();
442
- };
443
- entries.set(target, entry);
444
- target.setAttribute("data-sia-floating-scrollbar", "");
445
- resizeObserver.observe(target);
446
- updateEntry(entry);
447
- if (entry.hoveringTarget) showEntry(entry);
448
- };
449
- const removeTarget = (target) => {
450
- const entry = entries.get(target);
451
- if (!entry) return;
452
- entry.cleanup();
453
- entries.delete(target);
454
- };
455
- const scanTargets = () => {
456
- scanFrame = 0;
457
- const managedSelector = ".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track, .sia-floating-scrollbar-layer";
458
- const discovered = /* @__PURE__ */ new Set();
459
- if (!targetRef) {
460
- const roots = fullScan ? [document.body] : [...dirtyStyles].filter((node) => node.isConnected);
461
- for (const root of roots) {
462
- const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
463
- acceptNode: (node) => node.matches(managedSelector) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
464
- });
465
- for (let node = walker.nextNode(); node; node = walker.nextNode()) {
466
- if (node instanceof HTMLElement) discovered.add(node);
467
- }
468
- for (let node = root; node; node = node.parentElement) discovered.add(node);
469
- }
470
- }
471
- const candidates = (targetRef ? [targetRef.current] : [document.scrollingElement, ...discovered]).filter((target) => target instanceof HTMLElement);
472
- const nextTargets = /* @__PURE__ */ new Set();
473
- candidates.forEach((target) => {
474
- if (canScroll(target, "horizontal") || canScroll(target, "vertical")) {
475
- nextTargets.add(target);
476
- if (entries.has(target) || !target.hasAttribute("data-sia-floating-scrollbar")) addTarget(target);
477
- }
478
- });
479
- entries.forEach((_entry, target) => {
480
- if (!target.isConnected || (fullScan || candidates.includes(target)) && !nextTargets.has(target)) removeTarget(target);
481
- else updateEntry(_entry);
482
- });
483
- dirtyStyles.clear();
484
- fullScan = false;
485
- };
486
- const scheduleScan = (complete = true) => {
487
- fullScan ||= complete;
488
- if (scanFrame) return;
489
- scanFrame = window.requestAnimationFrame(scanTargets);
490
- };
491
- const previousStyle = document.createElement("div").style;
492
- const positionProperties = /* @__PURE__ */ new Set(["left", "top", "transform"]);
493
- const mutationObserver = new MutationObserver((mutations) => {
494
- let relevant = false;
495
- for (const mutation of mutations) {
496
- const target = mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
497
- if (!target || layer.contains(target) || target.closest(".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track")) continue;
498
- relevant = true;
499
- let positionOnly = false;
500
- if (mutation.type === "attributes" && mutation.attributeName === "style" && target instanceof HTMLElement) {
501
- previousStyle.cssText = mutation.oldValue ?? "";
502
- const keys = /* @__PURE__ */ new Set([...Array.from(previousStyle), ...Array.from(target.style)]);
503
- const changed = [...keys].filter((key) => previousStyle.getPropertyValue(key) !== target.style.getPropertyValue(key) || previousStyle.getPropertyPriority(key) !== target.style.getPropertyPriority(key));
504
- if (!changed.length) continue;
505
- const fixedSize = target.style.width.endsWith("px") && target.style.height.endsWith("px");
506
- positionOnly = fixedSize && changed.every((key) => positionProperties.has(key)) && ["absolute", "fixed"].includes(getComputedStyle(target).position);
507
- }
508
- if (positionOnly && target instanceof HTMLElement) dirtyStyles.add(target);
509
- else fullScan = true;
510
- }
511
- if (relevant) scheduleScan(false);
512
- });
513
- mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ["class", "style", "hidden"] });
514
- const onResize = () => scheduleScan();
515
- window.addEventListener("resize", onResize);
516
- window.addEventListener("scroll", scheduleUpdateAll, true);
517
- scheduleScan();
518
- return () => {
519
- mutationObserver.disconnect();
520
- resizeObserver.disconnect();
521
- window.removeEventListener("resize", onResize);
522
- window.removeEventListener("scroll", scheduleUpdateAll, true);
523
- if (scanFrame) window.cancelAnimationFrame(scanFrame);
524
- if (updateFrame) window.cancelAnimationFrame(updateFrame);
525
- entries.forEach((entry) => entry.cleanup());
526
- entries.clear();
527
- layer.remove();
528
- };
529
- }, [disabled, targetRef]);
530
- return null;
531
- }
532
-
533
158
  // src/components/treeCheckState.ts
534
159
  function affectedKeys(node) {
535
160
  if (node.disabled || node.disableCheckbox) return [];
@@ -586,7 +211,7 @@ function toggleTreeCheck(nodes, keys, node, strictly = false) {
586
211
  }
587
212
 
588
213
  // src/components/FloatingDisplay.tsx
589
- import { cloneElement, useEffect as useEffect4, useId as useId2, useLayoutEffect, useMemo as useMemo2, useRef as useRef2, useState } from "react";
214
+ import { cloneElement, useEffect as useEffect3, useId as useId2, useLayoutEffect, useMemo as useMemo2, useRef as useRef3, useState } from "react";
590
215
  import { createPortal } from "react-dom";
591
216
  import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
592
217
  var FLOATING_GAP = 9;
@@ -673,23 +298,24 @@ function Floating({
673
298
  role = "tooltip",
674
299
  onOpenChange
675
300
  }) {
676
- const rootRef = useRef2(null);
677
- const triggerElementRef = useRef2(null);
678
- const overlayRef = useRef2(null);
679
- const enterTimer = useRef2();
680
- const leaveTimer = useRef2();
301
+ const rootRef = useRef3(null);
302
+ const triggerElementRef = useRef3(null);
303
+ const overlayRef = useRef3(null);
304
+ const enterTimer = useRef3();
305
+ const leaveTimer = useRef3();
681
306
  const contentId = useId2();
682
307
  const triggers = Array.isArray(trigger) ? trigger : [trigger];
683
308
  const [visible, setVisible] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
684
309
  const [position, setPosition] = useState();
310
+ const motion = useOverlayMotion(!!visible, overlayRef, "tooltip", "bottom", !!position, void 0, !overlayClassName.includes("sia-form-item__error-popover"));
685
311
  const [portalContainer, setPortalContainer] = useState(null);
686
312
  useLayoutEffect(() => {
687
- if (!visible) return;
313
+ if (!motion.present) return;
688
314
  setPortalContainer(rootRef.current?.closest(".sia-modal-root, .sia-drawer-root") ?? document.body);
689
315
  });
690
- const setVisibleRef = useRef2(setVisible);
316
+ const setVisibleRef = useRef3(setVisible);
691
317
  setVisibleRef.current = setVisible;
692
- const closeSelfRef = useRef2();
318
+ const closeSelfRef = useRef3();
693
319
  if (!closeSelfRef.current) closeSelfRef.current = () => setVisibleRef.current(false);
694
320
  const exclusiveTooltip = role === "tooltip" && triggers.includes("hover");
695
321
  function openNow() {
@@ -717,7 +343,7 @@ function Floating({
717
343
  if (delay <= 0) closeNow();
718
344
  else leaveTimer.current = window.setTimeout(closeNow, delay * 1e3);
719
345
  }
720
- useEffect4(() => {
346
+ useEffect3(() => {
721
347
  if (!visible || !triggers.includes("click")) return;
722
348
  const close = (event) => {
723
349
  const target = event.target;
@@ -727,7 +353,7 @@ function Floating({
727
353
  return () => document.removeEventListener("pointerdown", close);
728
354
  }, [triggers.join("|"), visible]);
729
355
  useLayoutEffect(() => {
730
- if (!visible) {
356
+ if (!motion.present) {
731
357
  setPosition(void 0);
732
358
  return;
733
359
  }
@@ -741,32 +367,42 @@ function Floating({
741
367
  const anchor2 = getAnchor();
742
368
  if (anchor2) {
743
369
  const rect = anchor2.getBoundingClientRect();
744
- const next = resolveFloatingPosition(rect, overlayRef.current.getBoundingClientRect(), placement, typeof arrow === "object" && !!arrow.pointAtCenter, autoAdjustOverflow);
370
+ const next = resolveFloatingPosition(rect, { width: overlayRef.current.offsetWidth, height: overlayRef.current.offsetHeight }, placement, typeof arrow === "object" && !!arrow.pointAtCenter, autoAdjustOverflow);
745
371
  next.hidden = isFloatingAnchorHidden(anchor2, rect) || isAnchorBehindOverlay(anchor2);
746
- setPosition(next);
372
+ setPosition((current) => current && current.top === next.top && current.left === next.left && current.placement === next.placement && current.hidden === next.hidden && current.arrowX === next.arrowX && current.arrowY === next.arrowY ? current : next);
747
373
  }
748
374
  };
749
375
  update();
750
- const unsubscribeLayers = subscribeOverlayLayers(update);
751
- window.addEventListener("resize", update);
752
- window.addEventListener("scroll", update, true);
753
- window.addEventListener("animationend", update, true);
754
- window.addEventListener("transitionend", update, true);
755
- const observer = new ResizeObserver(update);
376
+ let frame = 0;
377
+ const schedule = () => {
378
+ if (!frame) frame = requestAnimationFrame(() => {
379
+ frame = 0;
380
+ update();
381
+ });
382
+ };
383
+ const unsubscribeLayers = subscribeOverlayLayers(schedule);
384
+ window.addEventListener("resize", schedule);
385
+ window.addEventListener("scroll", schedule, true);
386
+ window.addEventListener("animationend", schedule, true);
387
+ window.addEventListener("transitionend", schedule, true);
388
+ window.addEventListener("sia-overlay-motion-end", schedule);
389
+ const observer = new ResizeObserver(schedule);
756
390
  if (rootRef.current) observer.observe(rootRef.current);
757
391
  const anchor = getAnchor();
758
392
  if (anchor) observer.observe(anchor);
759
393
  if (overlayRef.current) observer.observe(overlayRef.current);
760
394
  return () => {
761
- window.removeEventListener("resize", update);
762
- window.removeEventListener("scroll", update, true);
763
- window.removeEventListener("animationend", update, true);
764
- window.removeEventListener("transitionend", update, true);
395
+ window.removeEventListener("resize", schedule);
396
+ window.removeEventListener("scroll", schedule, true);
397
+ window.removeEventListener("animationend", schedule, true);
398
+ window.removeEventListener("transitionend", schedule, true);
399
+ window.removeEventListener("sia-overlay-motion-end", schedule);
400
+ cancelAnimationFrame(frame);
765
401
  observer.disconnect();
766
402
  unsubscribeLayers();
767
403
  };
768
- }, [children, content, placement, visible, portalContainer, autoAdjustOverflow, typeof arrow === "object" && arrow.pointAtCenter]);
769
- useEffect4(() => () => {
404
+ }, [children, content, placement, motion.present, portalContainer, autoAdjustOverflow, typeof arrow === "object" && arrow.pointAtCenter]);
405
+ useEffect3(() => () => {
770
406
  clearTimers();
771
407
  if (activeTooltipClose === closeSelfRef.current) activeTooltipClose = void 0;
772
408
  }, []);
@@ -795,13 +431,15 @@ function Floating({
795
431
  } } : {},
796
432
  "aria-describedby": visible ? contentId : void 0
797
433
  });
798
- const overlay = visible && content !== null && content !== void 0 && typeof document !== "undefined" ? createPortal(
434
+ const overlay = motion.present && content !== null && content !== void 0 && typeof document !== "undefined" ? createPortal(
799
435
  /* @__PURE__ */ jsxs2(
800
436
  "span",
801
437
  {
802
438
  ref: overlayRef,
803
439
  id: contentId,
804
440
  role,
441
+ "data-state": motion.closing ? "closing" : "open",
442
+ "aria-hidden": motion.closing || void 0,
805
443
  "data-custom-color": color ? "" : void 0,
806
444
  className: `sia-floating__overlay sia-floating__overlay--${position?.placement ?? normalizeFloatingPlacement(placement)} ${overlayClassName}`.trim(),
807
445
  style: {
@@ -810,7 +448,9 @@ function Floating({
810
448
  "--sia-floating-arrow-y": position?.arrowY == null ? void 0 : `${position.arrowY}px`,
811
449
  top: position?.top ?? 0,
812
450
  left: position?.left ?? 0,
813
- visibility: position && !position.hidden ? "visible" : "hidden"
451
+ visibility: position && !position.hidden ? "visible" : "hidden",
452
+ animation: "none",
453
+ pointerEvents: motion.closing ? "none" : void 0
814
454
  },
815
455
  onMouseEnter: triggers.includes("hover") ? () => show() : void 0,
816
456
  onMouseLeave: triggers.includes("hover") ? () => hide(mouseLeaveDelay) : void 0,
@@ -898,7 +538,7 @@ function Tree({
898
538
  className = "",
899
539
  ...props
900
540
  }) {
901
- const scrollRef = useRef2(null);
541
+ const scrollRef = useRef3(null);
902
542
  const [selected, setSelected] = useControllableState({ value: selectedKeys, defaultValue: defaultSelectedKeys });
903
543
  const [expanded, setExpanded] = useControllableState({ value: expandedKeys, defaultValue: defaultExpandAll ? collectKeys(treeData, true) : defaultExpandedKeys });
904
544
  const [checked, setChecked] = useControllableState({ value: checkedKeys, defaultValue: defaultCheckedKeys });
@@ -963,9 +603,9 @@ function Tree({
963
603
  visit(treeData, []);
964
604
  return ancestors;
965
605
  }, [selectedKeySet, treeData]);
966
- const dragNodeRef = useRef2();
967
- const pointerDragRef = useRef2();
968
- const suppressClickRef = useRef2(false);
606
+ const dragNodeRef = useRef3();
607
+ const pointerDragRef = useRef3();
608
+ const suppressClickRef = useRef3(false);
969
609
  const [dragOver, setDragOver] = useState();
970
610
  const normalizedSwitcherWidth = Math.max(0, switcherWidth);
971
611
  async function toggleExpand(node) {
@@ -1192,11 +832,19 @@ function Tree({
1192
832
  }
1193
833
 
1194
834
  // src/components/SelectionPanel.tsx
1195
- import { useEffect as useEffect5, useId as useId3, useMemo as useMemo3, useRef as useRef3, useState as useState2 } from "react";
835
+ import { useEffect as useEffect4, useId as useId3, useMemo as useMemo3, useRef as useRef4, useState as useState2 } from "react";
836
+
837
+ // src/components/selectionValues.ts
838
+ function normalizeSelectionValues(values, options) {
839
+ const known = new Set(options.filter((option) => option.optionType !== "divider").map((option) => option.value));
840
+ return values.filter((value) => typeof value === "number" || value.trim().length > 0 || known.has(value));
841
+ }
842
+
843
+ // src/components/SelectionPanel.tsx
1196
844
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1197
845
  function SelectionPanel({
1198
846
  options,
1199
- value,
847
+ value: rawValue,
1200
848
  onChange,
1201
849
  multiple = false,
1202
850
  allowDeselect = false,
@@ -1215,13 +863,14 @@ function SelectionPanel({
1215
863
  autoFocusSearch = false,
1216
864
  groupCheckable = false
1217
865
  }) {
866
+ const value = useMemo3(() => normalizeSelectionValues(rawValue, options), [rawValue, options]);
1218
867
  const [localSearch, setLocalSearch] = useState2("");
1219
868
  const search = searchValue ?? localSearch;
1220
869
  const [scrollTop, setScrollTop] = useState2(0);
1221
870
  const [active, setActive] = useState2();
1222
871
  const [keyboardActive, setKeyboardActive] = useState2(false);
1223
872
  const [deselectedHover, setDeselectedHover] = useState2();
1224
- const listRef = useRef3(null);
873
+ const listRef = useRef4(null);
1225
874
  const id = useId3();
1226
875
  const selected = useMemo3(() => new Set(value), [value]);
1227
876
  const count = Math.max(1, Math.floor(columns));
@@ -1260,7 +909,7 @@ function SelectionPanel({
1260
909
  const virtual = filtered.length > 100;
1261
910
  const renderedRows = virtual ? rows.filter((row) => row.top + row.height >= scrollTop - 100 && row.top <= scrollTop + maxHeight + 100) : rows;
1262
911
  const enabled = filtered.filter((option) => !option.disabled && option.optionType !== "divider");
1263
- useEffect5(() => {
912
+ useEffect4(() => {
1264
913
  setScrollTop(0);
1265
914
  if (listRef.current) listRef.current.scrollTop = 0;
1266
915
  setActive(void 0);
@@ -1427,16 +1076,16 @@ function SelectionPanel({
1427
1076
  }
1428
1077
 
1429
1078
  // src/components/Select.tsx
1430
- import { forwardRef as forwardRef2, useDeferredValue, useEffect as useEffect6, useId as useId4, useLayoutEffect as useLayoutEffect3, useMemo as useMemo4, useRef as useRef5, useState as useState4 } from "react";
1079
+ import { forwardRef as forwardRef2, useDeferredValue, useEffect as useEffect5, useId as useId4, useLayoutEffect as useLayoutEffect3, useMemo as useMemo4, useRef as useRef6, useState as useState4 } from "react";
1431
1080
 
1432
1081
  // src/components/OverflowTags.tsx
1433
- import { useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState3 } from "react";
1082
+ import { useLayoutEffect as useLayoutEffect2, useRef as useRef5, useState as useState3 } from "react";
1434
1083
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1435
- function OverflowTags({ items, maxCount, className = "", tagClassName, restClassName = "" }) {
1436
- const rootRef = useRef4(null);
1437
- const measureRef = useRef4(null);
1084
+ function OverflowTags({ items, maxCount, expandToFit = false, className = "", tagClassName, restClassName = "" }) {
1085
+ const rootRef = useRef5(null);
1086
+ const measureRef = useRef5(null);
1438
1087
  const limit = Math.min(items.length, Math.max(0, Math.floor(maxCount) || 0));
1439
- const [visibleCount, setVisibleCount] = useState3(0);
1088
+ const [layout, setLayout] = useState3({ count: 0, minimumWidths: [] });
1440
1089
  useLayoutEffect2(() => {
1441
1090
  const root = rootRef.current;
1442
1091
  const measure = measureRef.current;
@@ -1451,17 +1100,29 @@ function OverflowTags({ items, maxCount, className = "", tagClassName, restClass
1451
1100
  const rest = count2 < items.length ? gap + widths[limit + count2] : 0;
1452
1101
  if (used + rest <= root.clientWidth) fitting = count2;
1453
1102
  }
1454
- setVisibleCount((previous) => previous === fitting ? previous : fitting);
1103
+ const minimumWidths = Array.from({ length: fitting }, (_, index) => {
1104
+ const tag = measure.children[index];
1105
+ return expandToFit && tag.scrollWidth > tag.clientWidth ? widths[index] : 0;
1106
+ });
1107
+ setLayout((previous) => previous.count === fitting && minimumWidths.every((width, index) => previous.minimumWidths[index] === width) ? previous : { count: fitting, minimumWidths });
1455
1108
  };
1456
1109
  update();
1457
1110
  const observer = new ResizeObserver(update);
1458
1111
  observer.observe(root);
1459
1112
  for (const child of measure.children) observer.observe(child);
1460
1113
  return () => observer.disconnect();
1461
- }, [items, limit]);
1462
- const count = Math.min(visibleCount, limit);
1114
+ }, [items, limit, expandToFit]);
1115
+ const count = Math.min(layout.count, limit);
1463
1116
  return /* @__PURE__ */ jsxs4("span", { ref: rootRef, className: `sia-overflow-tags ${className}`.trim(), children: [
1464
- items.slice(0, count).map((item) => /* @__PURE__ */ jsx4("span", { className: tagClassName, children: item.label }, item.key)),
1117
+ items.slice(0, count).map((item, index) => /* @__PURE__ */ jsx4(
1118
+ "span",
1119
+ {
1120
+ className: tagClassName,
1121
+ style: expandToFit && layout.minimumWidths[index] ? { flex: "0 1 auto", minWidth: layout.minimumWidths[index], maxWidth: "none" } : void 0,
1122
+ children: item.label
1123
+ },
1124
+ item.key
1125
+ )),
1465
1126
  items.length > count ? /* @__PURE__ */ jsxs4("span", { className: `${tagClassName} sia-overflow-tags__rest ${restClassName}`.trim(), children: [
1466
1127
  "+",
1467
1128
  items.length - count
@@ -1501,12 +1162,12 @@ var Select = forwardRef2(function Select2({
1501
1162
  showValue = false,
1502
1163
  allowInput = false,
1503
1164
  inputMaxLength,
1504
- searchPlaceholder = "\u641C\u7D22\u9009\u9879",
1165
+ searchPlaceholder = allowInput ? "\u8F93\u5165\u6216\u641C\u7D22" : "\u641C\u7D22\u9009\u9879",
1505
1166
  onSearch,
1506
1167
  filterOption = defaultFilterOption,
1507
1168
  showSelectAll = true,
1508
1169
  showActions = mode === "multiple",
1509
- maxTagCount = 2,
1170
+ maxTagCount,
1510
1171
  virtual = true,
1511
1172
  virtualThreshold = 100,
1512
1173
  listHeight = 256,
@@ -1524,23 +1185,23 @@ var Select = forwardRef2(function Select2({
1524
1185
  const fallbackId = useId4();
1525
1186
  const selectId = id ?? fallbackId;
1526
1187
  const listboxId = `${selectId}-listbox`;
1527
- const rootRef = useRef5(null);
1528
- const popupRef = useRef5(null);
1529
- const searchRef = useRef5(null);
1530
- const listRef = useRef5(null);
1188
+ const rootRef = useRef6(null);
1189
+ const popupRef = useRef6(null);
1190
+ const searchRef = useRef6(null);
1191
+ const listRef = useRef6(null);
1531
1192
  const [open, setOpen] = useState4(false);
1532
1193
  const automaticMode = popupModeProp ?? (options.length > modalThreshold ? "modal" : "dropdown");
1533
1194
  const [openedMode, setOpenedMode] = useState4(automaticMode);
1534
1195
  const popupMode = open ? openedMode : automaticMode;
1535
1196
  const [modalValues, setModalValues] = useState4([]);
1536
1197
  const [modalSubmitting, setModalSubmitting] = useState4(false);
1537
- const modalSubmitLock = useRef5(false);
1198
+ const modalSubmitLock = useRef6(false);
1538
1199
  const [selectedOnly, setSelectedOnly] = useState4(false);
1539
1200
  const [query, setQuery] = useState4("");
1540
1201
  const [activeIndex, setActiveIndex] = useState4(-1);
1541
1202
  const [scrollTop, setScrollTop] = useState4(0);
1542
1203
  const [dropdownFontSize, setDropdownFontSize] = useState4();
1543
- const pendingSelectedScroll = useRef5(false);
1204
+ const pendingSelectedScroll = useRef6(false);
1544
1205
  const deferredQuery = useDeferredValue(query.trim());
1545
1206
  const initialValue = defaultValue === void 0 ? mode === "multiple" ? [] : null : defaultValue;
1546
1207
  const [currentValue, setCurrentValue] = useControllableState({
@@ -1583,7 +1244,7 @@ var Select = forwardRef2(function Select2({
1583
1244
  const renderedOptions = virtualEnabled ? filteredOptions.slice(virtualStart, virtualEnd) : filteredOptions;
1584
1245
  const enabledFilteredOptions = filteredOptions.filter((option) => !option.disabled);
1585
1246
  const allFilteredSelected = enabledFilteredOptions.length > 0 && enabledFilteredOptions.every((option) => selectedValueSet.has(option.value));
1586
- useEffect6(() => {
1247
+ useEffect5(() => {
1587
1248
  if (!open || popupMode === "modal") return void 0;
1588
1249
  function closeFromOutside(event) {
1589
1250
  const target = event.target;
@@ -1592,13 +1253,15 @@ var Select = forwardRef2(function Select2({
1592
1253
  document.addEventListener("mousedown", closeFromOutside);
1593
1254
  return () => document.removeEventListener("mousedown", closeFromOutside);
1594
1255
  }, [open, popupMode]);
1595
- useEffect6(() => {
1596
- if (open && (showSearch || allowInput)) searchRef.current?.focus();
1597
- }, [allowInput, open, showSearch]);
1598
- useEffect6(() => {
1256
+ useEffect5(() => {
1257
+ if (!open || popupMode !== "dropdown" || !(showSearch || allowInput)) return;
1258
+ const frame = requestAnimationFrame(() => searchRef.current?.focus({ preventScroll: true }));
1259
+ return () => cancelAnimationFrame(frame);
1260
+ }, [allowInput, open, popupMode, showSearch]);
1261
+ useEffect5(() => {
1599
1262
  if (disabled || loading) closeDropdown();
1600
1263
  }, [disabled, loading]);
1601
- useEffect6(() => {
1264
+ useEffect5(() => {
1602
1265
  if (!open || popupMode !== "dropdown" || !pendingSelectedScroll.current || query) return;
1603
1266
  const index = filteredOptions.findIndex((option) => selectedValueSet.has(option.value));
1604
1267
  if (index < 0) return;
@@ -1821,7 +1484,7 @@ var Select = forwardRef2(function Select2({
1821
1484
  onClick: () => open ? closeDropdown() : openDropdown(),
1822
1485
  onKeyDown: handleTriggerKeyDown,
1823
1486
  children: [
1824
- multiple && hasValue ? /* @__PURE__ */ jsx5(OverflowTags, { className: "sia-select__tags", tagClassName: "sia-select__tag", restClassName: "sia-select__tag--rest", maxCount: maxTagCount, items: selectedOptions.map((option) => ({ key: `${typeof option.value}-${option.value}`, label: option.label })) }) : /* @__PURE__ */ jsx5("span", { className: `sia-select__value${hasValue ? "" : " is-placeholder"}`, children: selectedOptions[0]?.label ?? placeholder }),
1487
+ multiple && hasValue ? /* @__PURE__ */ jsx5(OverflowTags, { expandToFit: true, className: "sia-select__tags", tagClassName: "sia-select__tag", restClassName: "sia-select__tag--rest", maxCount: maxTagCount ?? selectedOptions.length, items: selectedOptions.map((option) => ({ key: `${typeof option.value}-${option.value}`, label: option.label })) }) : /* @__PURE__ */ jsx5("span", { className: `sia-select__value${hasValue ? "" : " is-placeholder"}`, children: selectedOptions[0]?.label ?? placeholder }),
1825
1488
  loading ? /* @__PURE__ */ jsx5("span", { className: "sia-select__spinner", "aria-hidden": "true" }) : null,
1826
1489
  floating.label,
1827
1490
  /* @__PURE__ */ jsx5(Icon, { className: "sia-select__arrow", name: "chevron-down", size: 15 })
@@ -1962,13 +1625,13 @@ var Select = forwardRef2(function Select2({
1962
1625
  });
1963
1626
 
1964
1627
  export {
1628
+ usePressFeedback,
1965
1629
  Checkbox2 as Checkbox,
1966
- useScrollbarProximity,
1967
- FloatingScrollbarProvider,
1968
1630
  Tooltip,
1969
1631
  Popover,
1970
1632
  Timeline,
1971
1633
  Tree,
1634
+ normalizeSelectionValues,
1972
1635
  SelectionPanel,
1973
1636
  OverflowTags,
1974
1637
  Select