@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.
- package/dist/{Button-BiL3Wjsd.d.ts → Button-C8W8ZHWV.d.ts} +1 -1
- package/dist/{Button-O_pNB3SQ.d.cts → Button-CxKBjLda.d.cts} +1 -1
- package/dist/{Select-DeD4O8FL.d.ts → Select-CTSd8zum.d.ts} +14 -10
- package/dist/{Select-Y0e9kaxE.d.cts → Select-bKLket9n.d.cts} +14 -10
- package/dist/chart.cjs +1051 -335
- package/dist/chart.js +5 -5
- package/dist/chunk-4OHS7RXE.js +1004 -0
- package/dist/{chunk-WIRIEIRO.js → chunk-4TYHSAR3.js} +5 -5
- package/dist/{chunk-L2S7IPSM.js → chunk-566S64IP.js} +5 -5
- package/dist/{chunk-CZ2ITBRW.js → chunk-7SEGBB6V.js} +34 -5
- package/dist/{chunk-KY6A5IJH.js → chunk-ETQJ2DQ2.js} +1 -1
- package/dist/{chunk-WD56MJO2.js → chunk-F52O2MOV.js} +7 -3
- package/dist/{chunk-PQBCD54U.js → chunk-JRXYM5YH.js} +167 -64
- package/dist/{chunk-SCEHVGKV.js → chunk-LKLPCYEP.js} +2 -2
- package/dist/{chunk-DIRPOUVX.js → chunk-MD4CGSOR.js} +105 -61
- package/dist/{chunk-436QH6XH.js → chunk-ORSQAJ22.js} +160 -497
- package/dist/{chunk-SO7IJZIR.js → chunk-PD3K5U5Y.js} +2 -2
- package/dist/{chunk-UVHC6OEX.js → chunk-WCYVBO2N.js} +342 -123
- package/dist/{core-DYo5C4Si.d.cts → core-COaZfusa.d.cts} +51 -24
- package/dist/{core-sWwvVAmP.d.ts → core-CvfsQGuT.d.ts} +51 -24
- package/dist/core.cjs +2000 -1251
- package/dist/core.css +416 -344
- package/dist/core.d.cts +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js +18 -9
- package/dist/game.cjs +1984 -1169
- package/dist/game.css +182 -177
- package/dist/game.d.cts +1 -1
- package/dist/game.d.ts +1 -1
- package/dist/game.js +8 -3
- package/dist/index.cjs +4658 -3542
- package/dist/index.css +416 -344
- package/dist/index.d.cts +84 -81
- package/dist/index.d.ts +84 -81
- package/dist/index.js +1075 -713
- package/dist/markdown-editor.cjs +727 -40
- package/dist/markdown-editor.js +8 -3
- package/dist/rich-text-editor.cjs +1265 -308
- package/dist/rich-text-editor.js +12 -7
- package/dist/{select-date-range-X6a9Y-Te.d.ts → select-date-range-C8cacfmb.d.ts} +1 -1
- package/dist/{select-date-range-DiBQQ0Rn.d.cts → select-date-range-Dad0IdD4.d.cts} +1 -1
- package/dist/select-date-range.cjs +1281 -807
- package/dist/select-date-range.d.cts +3 -3
- package/dist/select-date-range.d.ts +3 -3
- package/dist/select-date-range.js +13 -8
- package/package.json +9 -2
- package/dist/chunk-NZMUW5XI.js +0 -292
|
@@ -24,12 +24,675 @@ __export(select_date_range_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(select_date_range_exports);
|
|
26
26
|
|
|
27
|
+
// src/components/FloatingScrollbarProvider.tsx
|
|
28
|
+
var import_react2 = require("react");
|
|
29
|
+
|
|
30
|
+
// src/components/useScrollbarProximity.ts
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var users = 0;
|
|
33
|
+
var cleanup;
|
|
34
|
+
function acquireScrollbarProximity() {
|
|
35
|
+
if (users++ === 0) {
|
|
36
|
+
let frame = 0;
|
|
37
|
+
let x = -Infinity;
|
|
38
|
+
let y = -Infinity;
|
|
39
|
+
const nearby = /* @__PURE__ */ new Set();
|
|
40
|
+
const clear = () => {
|
|
41
|
+
nearby.forEach((track) => track.removeAttribute("data-scrollbar-near"));
|
|
42
|
+
nearby.clear();
|
|
43
|
+
};
|
|
44
|
+
const update = () => {
|
|
45
|
+
frame = 0;
|
|
46
|
+
const next = /* @__PURE__ */ new Set();
|
|
47
|
+
document.querySelectorAll(".sia-scrollbar-track").forEach((track) => {
|
|
48
|
+
const rect = track.getBoundingClientRect();
|
|
49
|
+
const proximity = Number.parseFloat(getComputedStyle(track).getPropertyValue("--sia-scrollbar-proximity")) || 16;
|
|
50
|
+
if (rect.width && rect.height && x >= rect.left - proximity && x <= rect.right + proximity && y >= rect.top - proximity && y <= rect.bottom + proximity) {
|
|
51
|
+
next.add(track);
|
|
52
|
+
if (!nearby.has(track)) track.setAttribute("data-scrollbar-near", "true");
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
nearby.forEach((track) => {
|
|
56
|
+
if (!next.has(track)) track.removeAttribute("data-scrollbar-near");
|
|
57
|
+
});
|
|
58
|
+
nearby.clear();
|
|
59
|
+
next.forEach((track) => nearby.add(track));
|
|
60
|
+
};
|
|
61
|
+
const move = (event) => {
|
|
62
|
+
if (event.pointerType === "touch") return;
|
|
63
|
+
x = event.clientX;
|
|
64
|
+
y = event.clientY;
|
|
65
|
+
if (!frame) frame = requestAnimationFrame(update);
|
|
66
|
+
};
|
|
67
|
+
const leave = () => {
|
|
68
|
+
x = y = -Infinity;
|
|
69
|
+
clear();
|
|
70
|
+
};
|
|
71
|
+
document.addEventListener("pointermove", move, { passive: true });
|
|
72
|
+
document.documentElement.addEventListener("pointerleave", leave);
|
|
73
|
+
window.addEventListener("blur", leave);
|
|
74
|
+
cleanup = () => {
|
|
75
|
+
if (frame) cancelAnimationFrame(frame);
|
|
76
|
+
document.removeEventListener("pointermove", move);
|
|
77
|
+
document.documentElement.removeEventListener("pointerleave", leave);
|
|
78
|
+
window.removeEventListener("blur", leave);
|
|
79
|
+
clear();
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return () => {
|
|
83
|
+
if (--users === 0) {
|
|
84
|
+
cleanup?.();
|
|
85
|
+
cleanup = void 0;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/components/floatingScrollbarOwnership.ts
|
|
91
|
+
var targets = /* @__PURE__ */ new Map();
|
|
92
|
+
function registerFloatingScrollbar(track, target) {
|
|
93
|
+
targets.set(track, { target, dragging: false });
|
|
94
|
+
return () => {
|
|
95
|
+
targets.delete(track);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function setFloatingScrollbarDragging(track, dragging) {
|
|
99
|
+
const entry = targets.get(track);
|
|
100
|
+
if (entry) entry.dragging = dragging;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/components/FloatingScrollbarProvider.tsx
|
|
104
|
+
var scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
105
|
+
var clippingOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay", "hidden", "clip"]);
|
|
106
|
+
function isRootScroller(target) {
|
|
107
|
+
return target === document.scrollingElement || target === document.documentElement;
|
|
108
|
+
}
|
|
109
|
+
function canScroll(target, axis) {
|
|
110
|
+
if (target.matches(".sia-table__viewport, [data-sia-native-scrollbar]")) return false;
|
|
111
|
+
if (isRootScroller(target)) {
|
|
112
|
+
const rootStyle = getComputedStyle(target);
|
|
113
|
+
const bodyStyle = getComputedStyle(document.body);
|
|
114
|
+
const overflow2 = axis === "horizontal" ? [rootStyle.overflowX, bodyStyle.overflowX] : [rootStyle.overflowY, bodyStyle.overflowY];
|
|
115
|
+
if (overflow2.some((value) => value === "hidden" || value === "clip")) return false;
|
|
116
|
+
return axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
|
|
117
|
+
}
|
|
118
|
+
const style = getComputedStyle(target);
|
|
119
|
+
const overflow = axis === "horizontal" ? style.overflowX : style.overflowY;
|
|
120
|
+
if (!scrollableOverflow.has(overflow)) return false;
|
|
121
|
+
const hasOverflow = axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
|
|
122
|
+
return hasOverflow;
|
|
123
|
+
}
|
|
124
|
+
function visibleRect(target) {
|
|
125
|
+
if (isRootScroller(target)) {
|
|
126
|
+
return { top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0, width: window.innerWidth, height: window.innerHeight };
|
|
127
|
+
}
|
|
128
|
+
const ownRect = target.getBoundingClientRect();
|
|
129
|
+
let top = Math.max(0, ownRect.top);
|
|
130
|
+
let right = Math.min(window.innerWidth, ownRect.right);
|
|
131
|
+
let bottom = Math.min(window.innerHeight, ownRect.bottom);
|
|
132
|
+
let left = Math.max(0, ownRect.left);
|
|
133
|
+
let parent = target.parentElement;
|
|
134
|
+
while (parent && parent !== document.body && parent !== document.documentElement) {
|
|
135
|
+
const style = getComputedStyle(parent);
|
|
136
|
+
const clipX = clippingOverflow.has(style.overflowX);
|
|
137
|
+
const clipY = clippingOverflow.has(style.overflowY);
|
|
138
|
+
if (clipX || clipY) {
|
|
139
|
+
const rect = parent.getBoundingClientRect();
|
|
140
|
+
if (clipX) {
|
|
141
|
+
left = Math.max(left, rect.left);
|
|
142
|
+
right = Math.min(right, rect.right);
|
|
143
|
+
}
|
|
144
|
+
if (clipY) {
|
|
145
|
+
top = Math.max(top, rect.top);
|
|
146
|
+
bottom = Math.min(bottom, rect.bottom);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
parent = parent.parentElement;
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
top,
|
|
153
|
+
right,
|
|
154
|
+
bottom,
|
|
155
|
+
left,
|
|
156
|
+
width: Math.max(0, right - left),
|
|
157
|
+
height: Math.max(0, bottom - top)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function createTrack(axis) {
|
|
161
|
+
const track = document.createElement("div");
|
|
162
|
+
const thumb = document.createElement("div");
|
|
163
|
+
track.className = `sia-scrollbar-track sia-floating-scrollbar sia-floating-scrollbar--${axis}`;
|
|
164
|
+
thumb.className = "sia-floating-scrollbar__thumb";
|
|
165
|
+
track.dataset.axis = axis;
|
|
166
|
+
track.setAttribute("aria-hidden", "true");
|
|
167
|
+
track.append(thumb);
|
|
168
|
+
return { track, thumb };
|
|
169
|
+
}
|
|
170
|
+
function FloatingScrollbarProvider({ disabled = false, targetRef }) {
|
|
171
|
+
(0, import_react2.useEffect)(() => {
|
|
172
|
+
if (targetRef) return disabled ? void 0 : startFloatingScrollbars(targetRef);
|
|
173
|
+
const token = /* @__PURE__ */ Symbol();
|
|
174
|
+
globalProviders.set(token, !disabled);
|
|
175
|
+
syncDefaultScrollbars();
|
|
176
|
+
return () => {
|
|
177
|
+
globalProviders.delete(token);
|
|
178
|
+
syncDefaultScrollbars();
|
|
179
|
+
};
|
|
180
|
+
}, [disabled, targetRef]);
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
var automatic = false;
|
|
184
|
+
var stopGlobal;
|
|
185
|
+
var globalProviders = /* @__PURE__ */ new Map();
|
|
186
|
+
function syncDefaultScrollbars() {
|
|
187
|
+
if (typeof document === "undefined" || !document.body) return;
|
|
188
|
+
const enabled = (automatic || globalProviders.size > 0) && ![...globalProviders.values()].includes(false);
|
|
189
|
+
if (enabled && !stopGlobal) stopGlobal = startFloatingScrollbars();
|
|
190
|
+
if (!enabled && stopGlobal) {
|
|
191
|
+
stopGlobal();
|
|
192
|
+
stopGlobal = void 0;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function initializeDefaultScrollbars() {
|
|
196
|
+
if (typeof document === "undefined" || automatic) return;
|
|
197
|
+
automatic = true;
|
|
198
|
+
if (document.body) syncDefaultScrollbars();
|
|
199
|
+
else document.addEventListener("DOMContentLoaded", syncDefaultScrollbars, { once: true });
|
|
200
|
+
}
|
|
201
|
+
function startFloatingScrollbars(targetRef) {
|
|
202
|
+
const releaseProximity = acquireScrollbarProximity();
|
|
203
|
+
const layer = document.createElement("div");
|
|
204
|
+
layer.className = "sia-floating-scrollbar-layer";
|
|
205
|
+
layer.setAttribute("aria-hidden", "true");
|
|
206
|
+
document.body.append(layer);
|
|
207
|
+
const entries = /* @__PURE__ */ new Map();
|
|
208
|
+
let scanFrame = 0;
|
|
209
|
+
let updateFrame = 0;
|
|
210
|
+
const dirtyStyles = /* @__PURE__ */ new Set();
|
|
211
|
+
let fullScan = true;
|
|
212
|
+
const setEntryVisible = (entry, visible) => {
|
|
213
|
+
entry.horizontalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
|
|
214
|
+
entry.verticalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
|
|
215
|
+
};
|
|
216
|
+
const showEntry = (entry) => {
|
|
217
|
+
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
218
|
+
entry.hideTimer = null;
|
|
219
|
+
setEntryVisible(entry, true);
|
|
220
|
+
};
|
|
221
|
+
const scheduleHide = (entry, delay = 500) => {
|
|
222
|
+
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
223
|
+
entry.hideTimer = window.setTimeout(() => {
|
|
224
|
+
entry.hideTimer = null;
|
|
225
|
+
if (!entry.hoveringTarget && !entry.hoveringTrack && !entry.dragging) setEntryVisible(entry, false);
|
|
226
|
+
}, delay);
|
|
227
|
+
};
|
|
228
|
+
const updateEntry = (entry) => {
|
|
229
|
+
const { target, horizontalTrack, horizontalThumb, verticalTrack, verticalThumb } = entry;
|
|
230
|
+
const hasHorizontal = canScroll(target, "horizontal");
|
|
231
|
+
const hasVertical = canScroll(target, "vertical");
|
|
232
|
+
const rect = visibleRect(target);
|
|
233
|
+
const thickness = 10;
|
|
234
|
+
horizontalTrack.hidden = !hasHorizontal || rect.width <= thickness || rect.height <= 0;
|
|
235
|
+
verticalTrack.hidden = !hasVertical || rect.height <= thickness || rect.width <= 0;
|
|
236
|
+
if (!horizontalTrack.hidden) {
|
|
237
|
+
const trackWidth = Math.max(0, rect.width - (hasVertical ? thickness : 0));
|
|
238
|
+
const thumbWidth = Math.max(24, Math.min(trackWidth, trackWidth * target.clientWidth / target.scrollWidth));
|
|
239
|
+
const travel = Math.max(0, trackWidth - thumbWidth);
|
|
240
|
+
const maxScroll = Math.max(1, target.scrollWidth - target.clientWidth);
|
|
241
|
+
horizontalTrack.style.left = `${rect.left}px`;
|
|
242
|
+
horizontalTrack.style.top = `${rect.bottom - thickness}px`;
|
|
243
|
+
horizontalTrack.style.width = `${trackWidth}px`;
|
|
244
|
+
horizontalTrack.style.height = `${thickness}px`;
|
|
245
|
+
horizontalThumb.style.width = `${thumbWidth}px`;
|
|
246
|
+
horizontalThumb.style.transform = `translate3d(${travel * target.scrollLeft / maxScroll}px, 0, 0)`;
|
|
247
|
+
}
|
|
248
|
+
if (!verticalTrack.hidden) {
|
|
249
|
+
const trackHeight = Math.max(0, rect.height - (hasHorizontal ? thickness : 0));
|
|
250
|
+
const thumbHeight = Math.max(24, Math.min(trackHeight, trackHeight * target.clientHeight / target.scrollHeight));
|
|
251
|
+
const travel = Math.max(0, trackHeight - thumbHeight);
|
|
252
|
+
const maxScroll = Math.max(1, target.scrollHeight - target.clientHeight);
|
|
253
|
+
verticalTrack.style.left = `${rect.right - thickness}px`;
|
|
254
|
+
verticalTrack.style.top = `${rect.top}px`;
|
|
255
|
+
verticalTrack.style.width = `${thickness}px`;
|
|
256
|
+
verticalTrack.style.height = `${trackHeight}px`;
|
|
257
|
+
verticalThumb.style.height = `${thumbHeight}px`;
|
|
258
|
+
verticalThumb.style.transform = `translate3d(0, ${travel * target.scrollTop / maxScroll}px, 0)`;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
const scheduleUpdateAll = () => {
|
|
262
|
+
if (updateFrame) return;
|
|
263
|
+
updateFrame = window.requestAnimationFrame(() => {
|
|
264
|
+
updateFrame = 0;
|
|
265
|
+
entries.forEach(updateEntry);
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
const bindTrackDrag = (entry, axis, track, thumb) => {
|
|
269
|
+
const target = entry.target;
|
|
270
|
+
const onTrackPointerEnter = () => {
|
|
271
|
+
entry.hoveringTrack = true;
|
|
272
|
+
showEntry(entry);
|
|
273
|
+
};
|
|
274
|
+
const onTrackPointerLeave = () => {
|
|
275
|
+
entry.hoveringTrack = false;
|
|
276
|
+
scheduleHide(entry);
|
|
277
|
+
};
|
|
278
|
+
const onTrackPointerDown = (event) => {
|
|
279
|
+
if (event.target === thumb || event.button !== 0) return;
|
|
280
|
+
event.preventDefault();
|
|
281
|
+
event.stopPropagation();
|
|
282
|
+
const trackRect = track.getBoundingClientRect();
|
|
283
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
284
|
+
const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
|
|
285
|
+
const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
|
|
286
|
+
const pointer = axis === "vertical" ? event.clientY - trackRect.top : event.clientX - trackRect.left;
|
|
287
|
+
const ratio = Math.max(0, Math.min(1, (pointer - thumbLength / 2) / Math.max(1, trackLength - thumbLength)));
|
|
288
|
+
if (axis === "vertical") target.scrollTop = ratio * (target.scrollHeight - target.clientHeight);
|
|
289
|
+
else target.scrollLeft = ratio * (target.scrollWidth - target.clientWidth);
|
|
290
|
+
};
|
|
291
|
+
const onThumbPointerDown = (event) => {
|
|
292
|
+
if (event.button !== 0) return;
|
|
293
|
+
event.preventDefault();
|
|
294
|
+
event.stopPropagation();
|
|
295
|
+
entry.dragging = true;
|
|
296
|
+
setFloatingScrollbarDragging(track, true);
|
|
297
|
+
showEntry(entry);
|
|
298
|
+
thumb.setPointerCapture(event.pointerId);
|
|
299
|
+
const startPointer = axis === "vertical" ? event.clientY : event.clientX;
|
|
300
|
+
const startScroll = axis === "vertical" ? target.scrollTop : target.scrollLeft;
|
|
301
|
+
const trackRect = track.getBoundingClientRect();
|
|
302
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
303
|
+
const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
|
|
304
|
+
const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
|
|
305
|
+
const maxScroll = axis === "vertical" ? target.scrollHeight - target.clientHeight : target.scrollWidth - target.clientWidth;
|
|
306
|
+
const travel = Math.max(1, trackLength - thumbLength);
|
|
307
|
+
const onPointerMove = (moveEvent) => {
|
|
308
|
+
if (moveEvent.pointerId !== event.pointerId) return;
|
|
309
|
+
const pointer = axis === "vertical" ? moveEvent.clientY : moveEvent.clientX;
|
|
310
|
+
const nextScroll = startScroll + (pointer - startPointer) * maxScroll / travel;
|
|
311
|
+
if (axis === "vertical") target.scrollTop = nextScroll;
|
|
312
|
+
else target.scrollLeft = nextScroll;
|
|
313
|
+
};
|
|
314
|
+
const onPointerUp = (upEvent) => {
|
|
315
|
+
if (upEvent.pointerId !== event.pointerId) return;
|
|
316
|
+
entry.dragging = false;
|
|
317
|
+
setFloatingScrollbarDragging(track, false);
|
|
318
|
+
thumb.releasePointerCapture(event.pointerId);
|
|
319
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
320
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
321
|
+
window.removeEventListener("pointercancel", onPointerUp);
|
|
322
|
+
scheduleHide(entry);
|
|
323
|
+
};
|
|
324
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
325
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
326
|
+
window.addEventListener("pointercancel", onPointerUp);
|
|
327
|
+
};
|
|
328
|
+
track.addEventListener("pointerenter", onTrackPointerEnter);
|
|
329
|
+
track.addEventListener("pointerleave", onTrackPointerLeave);
|
|
330
|
+
track.addEventListener("pointerdown", onTrackPointerDown);
|
|
331
|
+
thumb.addEventListener("pointerdown", onThumbPointerDown);
|
|
332
|
+
return () => {
|
|
333
|
+
track.removeEventListener("pointerenter", onTrackPointerEnter);
|
|
334
|
+
track.removeEventListener("pointerleave", onTrackPointerLeave);
|
|
335
|
+
track.removeEventListener("pointerdown", onTrackPointerDown);
|
|
336
|
+
thumb.removeEventListener("pointerdown", onThumbPointerDown);
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
const resizeObserver = new ResizeObserver((observedEntries) => {
|
|
340
|
+
observedEntries.forEach(({ target }) => {
|
|
341
|
+
const entry = entries.get(target);
|
|
342
|
+
if (entry) updateEntry(entry);
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
const addTarget = (target) => {
|
|
346
|
+
if (entries.has(target)) return;
|
|
347
|
+
const horizontal = createTrack("horizontal");
|
|
348
|
+
const vertical = createTrack("vertical");
|
|
349
|
+
const releaseHorizontalOwner = registerFloatingScrollbar(horizontal.track, target);
|
|
350
|
+
const releaseVerticalOwner = registerFloatingScrollbar(vertical.track, target);
|
|
351
|
+
layer.append(horizontal.track, vertical.track);
|
|
352
|
+
const onPointerEnter = () => {
|
|
353
|
+
const entry2 = entries.get(target);
|
|
354
|
+
if (!entry2) return;
|
|
355
|
+
entry2.hoveringTarget = true;
|
|
356
|
+
showEntry(entry2);
|
|
357
|
+
};
|
|
358
|
+
const onPointerLeave = () => {
|
|
359
|
+
const entry2 = entries.get(target);
|
|
360
|
+
if (!entry2) return;
|
|
361
|
+
entry2.hoveringTarget = false;
|
|
362
|
+
scheduleHide(entry2);
|
|
363
|
+
};
|
|
364
|
+
const onScroll = () => {
|
|
365
|
+
const entry2 = entries.get(target);
|
|
366
|
+
if (!entry2) return;
|
|
367
|
+
updateEntry(entry2);
|
|
368
|
+
showEntry(entry2);
|
|
369
|
+
scheduleHide(entry2, 700);
|
|
370
|
+
};
|
|
371
|
+
target.addEventListener("pointerenter", onPointerEnter);
|
|
372
|
+
target.addEventListener("pointerleave", onPointerLeave);
|
|
373
|
+
target.addEventListener("scroll", onScroll, { passive: true });
|
|
374
|
+
const entry = {
|
|
375
|
+
target,
|
|
376
|
+
horizontalTrack: horizontal.track,
|
|
377
|
+
horizontalThumb: horizontal.thumb,
|
|
378
|
+
verticalTrack: vertical.track,
|
|
379
|
+
verticalThumb: vertical.thumb,
|
|
380
|
+
hideTimer: null,
|
|
381
|
+
hoveringTarget: target.matches(":hover"),
|
|
382
|
+
hoveringTrack: false,
|
|
383
|
+
dragging: false,
|
|
384
|
+
cleanup: () => void 0
|
|
385
|
+
};
|
|
386
|
+
const cleanupHorizontal = bindTrackDrag(entry, "horizontal", horizontal.track, horizontal.thumb);
|
|
387
|
+
const cleanupVertical = bindTrackDrag(entry, "vertical", vertical.track, vertical.thumb);
|
|
388
|
+
entry.cleanup = () => {
|
|
389
|
+
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
390
|
+
cleanupHorizontal();
|
|
391
|
+
cleanupVertical();
|
|
392
|
+
releaseHorizontalOwner();
|
|
393
|
+
releaseVerticalOwner();
|
|
394
|
+
target.removeEventListener("pointerenter", onPointerEnter);
|
|
395
|
+
target.removeEventListener("pointerleave", onPointerLeave);
|
|
396
|
+
target.removeEventListener("scroll", onScroll);
|
|
397
|
+
resizeObserver.unobserve(target);
|
|
398
|
+
target.removeAttribute("data-sia-floating-scrollbar");
|
|
399
|
+
horizontal.track.remove();
|
|
400
|
+
vertical.track.remove();
|
|
401
|
+
};
|
|
402
|
+
entries.set(target, entry);
|
|
403
|
+
target.setAttribute("data-sia-floating-scrollbar", "");
|
|
404
|
+
resizeObserver.observe(target);
|
|
405
|
+
updateEntry(entry);
|
|
406
|
+
if (entry.hoveringTarget) showEntry(entry);
|
|
407
|
+
};
|
|
408
|
+
const removeTarget = (target) => {
|
|
409
|
+
const entry = entries.get(target);
|
|
410
|
+
if (!entry) return;
|
|
411
|
+
entry.cleanup();
|
|
412
|
+
entries.delete(target);
|
|
413
|
+
};
|
|
414
|
+
const scanTargets = () => {
|
|
415
|
+
scanFrame = 0;
|
|
416
|
+
const managedSelector = ".sia-table__viewport, .sia-scrollbar-track, .sia-floating-scrollbar-layer";
|
|
417
|
+
const discovered = /* @__PURE__ */ new Set();
|
|
418
|
+
if (!targetRef) {
|
|
419
|
+
const roots = fullScan ? [document.body] : [...dirtyStyles].filter((node) => node.isConnected);
|
|
420
|
+
for (const root of roots) {
|
|
421
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
|
|
422
|
+
acceptNode: (node) => node.matches(managedSelector) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
|
|
423
|
+
});
|
|
424
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
425
|
+
if (node instanceof HTMLElement) discovered.add(node);
|
|
426
|
+
}
|
|
427
|
+
for (let node = root; node; node = node.parentElement) discovered.add(node);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
const candidates = (targetRef ? [targetRef.current] : [document.scrollingElement, ...discovered]).filter((target) => target instanceof HTMLElement);
|
|
431
|
+
const nextTargets = /* @__PURE__ */ new Set();
|
|
432
|
+
candidates.forEach((target) => {
|
|
433
|
+
if (canScroll(target, "horizontal") || canScroll(target, "vertical")) {
|
|
434
|
+
nextTargets.add(target);
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
nextTargets.forEach((target) => {
|
|
438
|
+
if (entries.has(target) || !target.hasAttribute("data-sia-floating-scrollbar")) addTarget(target);
|
|
439
|
+
});
|
|
440
|
+
entries.forEach((_entry, target) => {
|
|
441
|
+
if (!target.isConnected || (fullScan || candidates.includes(target)) && !nextTargets.has(target)) removeTarget(target);
|
|
442
|
+
else updateEntry(_entry);
|
|
443
|
+
});
|
|
444
|
+
dirtyStyles.clear();
|
|
445
|
+
fullScan = false;
|
|
446
|
+
};
|
|
447
|
+
const scheduleScan = (complete = true) => {
|
|
448
|
+
fullScan ||= complete;
|
|
449
|
+
if (scanFrame) return;
|
|
450
|
+
scanFrame = window.requestAnimationFrame(scanTargets);
|
|
451
|
+
};
|
|
452
|
+
const previousStyle = document.createElement("div").style;
|
|
453
|
+
const positionProperties = /* @__PURE__ */ new Set(["left", "top", "transform"]);
|
|
454
|
+
const mutationObserver = new MutationObserver((mutations) => {
|
|
455
|
+
let relevant = false;
|
|
456
|
+
for (const mutation of mutations) {
|
|
457
|
+
const target = mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
|
|
458
|
+
if (!target || layer.contains(target) || target.closest(".sia-table__viewport, .sia-scrollbar-track, .sia-floating-scrollbar-layer")) continue;
|
|
459
|
+
if (mutation.type === "childList") {
|
|
460
|
+
const changed = [...mutation.addedNodes, ...mutation.removedNodes];
|
|
461
|
+
if (changed.length && changed.every((node) => node instanceof Element && node.matches(".sia-floating-scrollbar-layer, .sia-scrollbar-track"))) continue;
|
|
462
|
+
if (target === document.body && changed.length && changed.every((node) => node instanceof HTMLElement && node.matches(".sia-popup-portal"))) {
|
|
463
|
+
changed.forEach((node) => {
|
|
464
|
+
if (node instanceof HTMLElement && node.isConnected) dirtyStyles.add(node);
|
|
465
|
+
});
|
|
466
|
+
relevant = true;
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
const popup = target.closest(".sia-popup-portal");
|
|
471
|
+
if (popup) {
|
|
472
|
+
dirtyStyles.add(popup);
|
|
473
|
+
relevant = true;
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
if (mutation.type === "attributes" && mutation.attributeName === "class" && target instanceof HTMLElement && target.matches(".sia-select")) {
|
|
477
|
+
const oldClasses = new Set((mutation.oldValue ?? "").split(/\s+/).filter(Boolean));
|
|
478
|
+
const newClasses = new Set(target.classList);
|
|
479
|
+
const changed = [.../* @__PURE__ */ new Set([...oldClasses, ...newClasses])].filter((name) => oldClasses.has(name) !== newClasses.has(name));
|
|
480
|
+
if (changed.every((name) => name === "is-open")) {
|
|
481
|
+
dirtyStyles.add(target);
|
|
482
|
+
relevant = true;
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
relevant = true;
|
|
487
|
+
let positionOnly = false;
|
|
488
|
+
if (mutation.type === "attributes" && mutation.attributeName === "style" && target instanceof HTMLElement) {
|
|
489
|
+
previousStyle.cssText = mutation.oldValue ?? "";
|
|
490
|
+
const keys = /* @__PURE__ */ new Set([...Array.from(previousStyle), ...Array.from(target.style)]);
|
|
491
|
+
const changed = [...keys].filter((key) => previousStyle.getPropertyValue(key) !== target.style.getPropertyValue(key) || previousStyle.getPropertyPriority(key) !== target.style.getPropertyPriority(key));
|
|
492
|
+
if (!changed.length) continue;
|
|
493
|
+
const fixedSize = target.style.width.endsWith("px") && target.style.height.endsWith("px");
|
|
494
|
+
positionOnly = fixedSize && changed.every((key) => positionProperties.has(key)) && ["absolute", "fixed"].includes(getComputedStyle(target).position);
|
|
495
|
+
}
|
|
496
|
+
if (positionOnly && target instanceof HTMLElement) dirtyStyles.add(target);
|
|
497
|
+
else fullScan = true;
|
|
498
|
+
}
|
|
499
|
+
if (relevant) scheduleScan(false);
|
|
500
|
+
});
|
|
501
|
+
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ["class", "style", "hidden", "data-sia-native-scrollbar", "data-sia-floating-scrollbar"] });
|
|
502
|
+
const onResize = () => scheduleScan();
|
|
503
|
+
window.addEventListener("resize", onResize);
|
|
504
|
+
window.addEventListener("scroll", scheduleUpdateAll, true);
|
|
505
|
+
scheduleScan();
|
|
506
|
+
return () => {
|
|
507
|
+
releaseProximity();
|
|
508
|
+
mutationObserver.disconnect();
|
|
509
|
+
resizeObserver.disconnect();
|
|
510
|
+
window.removeEventListener("resize", onResize);
|
|
511
|
+
window.removeEventListener("scroll", scheduleUpdateAll, true);
|
|
512
|
+
if (scanFrame) window.cancelAnimationFrame(scanFrame);
|
|
513
|
+
if (updateFrame) window.cancelAnimationFrame(updateFrame);
|
|
514
|
+
entries.forEach((entry) => entry.cleanup());
|
|
515
|
+
entries.clear();
|
|
516
|
+
layer.remove();
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
|
|
27
520
|
// src/components/titleTooltip.tsx
|
|
28
521
|
var import_client = require("react-dom/client");
|
|
29
522
|
|
|
30
523
|
// src/components/PopupPortal.tsx
|
|
31
|
-
var
|
|
524
|
+
var import_react4 = require("react");
|
|
32
525
|
var import_react_dom = require("react-dom");
|
|
526
|
+
|
|
527
|
+
// src/components/overlayMotion.ts
|
|
528
|
+
var import_react3 = require("react");
|
|
529
|
+
|
|
530
|
+
// src/components/popupFluidMotion.ts
|
|
531
|
+
var popupEnterDuration = 260;
|
|
532
|
+
var popupExitDuration = 140;
|
|
533
|
+
var popupInitialScale = 0.88;
|
|
534
|
+
var popupTravelOffset = 6;
|
|
535
|
+
function popupFluidFrames(placement, open = true) {
|
|
536
|
+
const side = placement.split("-")[0];
|
|
537
|
+
const axis = side === "left" || side === "right" ? "X" : "Y";
|
|
538
|
+
const sign = side === "left" || side === "top" ? 1 : -1;
|
|
539
|
+
const hidden = { opacity: 0, transform: `translate${axis}(${sign * popupTravelOffset}px) scale(${popupInitialScale})` };
|
|
540
|
+
const visible = { opacity: 1, transform: "none" };
|
|
541
|
+
return open ? [
|
|
542
|
+
{ ...hidden, offset: 0 },
|
|
543
|
+
{ opacity: 1, transform: "scale(1.11, 1.085)", offset: 0.68 },
|
|
544
|
+
{ opacity: 1, transform: "scale(.945, .965)", offset: 0.86 },
|
|
545
|
+
{ ...visible, offset: 1 }
|
|
546
|
+
] : [{ ...visible, offset: 0 }, { ...hidden, offset: 1 }];
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// src/components/overlayMotion.ts
|
|
550
|
+
function motionFrames(kind, placement) {
|
|
551
|
+
if (kind === "fade") return [{ opacity: 0 }, { opacity: 1 }];
|
|
552
|
+
if (kind === "toast") return [
|
|
553
|
+
{ opacity: 0, transform: "translateY(-6px)", offset: 0 },
|
|
554
|
+
{ opacity: 1, transform: "translateY(3px)", offset: 0.68 },
|
|
555
|
+
{ opacity: 1, transform: "translateY(-1px)", offset: 0.86 },
|
|
556
|
+
{ opacity: 1, transform: "none", offset: 1 }
|
|
557
|
+
];
|
|
558
|
+
if (kind === "drawer") {
|
|
559
|
+
const axis = placement === "left" || placement === "right" ? "X" : "Y";
|
|
560
|
+
const sign = placement === "left" || placement === "top" ? -1 : 1;
|
|
561
|
+
const outside = `translate${axis}(${sign * 100}%)`;
|
|
562
|
+
return [
|
|
563
|
+
{ transform: outside, offset: 0 },
|
|
564
|
+
{ transform: `translate${axis}(0) scale${axis}(1.065)`, offset: 0.68 },
|
|
565
|
+
{ transform: `translate${axis}(0) scale${axis}(.975)`, offset: 0.86 },
|
|
566
|
+
{ transform: "none", offset: 1 }
|
|
567
|
+
];
|
|
568
|
+
}
|
|
569
|
+
const modal = kind === "modal";
|
|
570
|
+
return [
|
|
571
|
+
{ opacity: 0, transform: `translateY(${modal ? 18 : -6}px) scale(${modal ? 0.9 : 0.88})`, offset: 0 },
|
|
572
|
+
{ opacity: 1, transform: modal ? "scale(1.075, 1.05)" : "scale(1.11, 1.085)", offset: 0.68 },
|
|
573
|
+
{ opacity: 1, transform: modal ? "scale(.965, .98)" : "scale(.945, .965)", offset: 0.86 },
|
|
574
|
+
{ opacity: 1, transform: "none", offset: 1 }
|
|
575
|
+
];
|
|
576
|
+
}
|
|
577
|
+
function useOverlayMotion(open, ref, kind, placement = "bottom", ready = true, onFinish, enabled = true) {
|
|
578
|
+
const [phase, setPhase] = (0, import_react3.useState)(open ? "entering" : "closed");
|
|
579
|
+
const present = open || phase !== "closed";
|
|
580
|
+
const [entered, setEntered] = (0, import_react3.useState)(false);
|
|
581
|
+
const position = (0, import_react3.useRef)();
|
|
582
|
+
const snapshot = (0, import_react3.useRef)();
|
|
583
|
+
const notify = (0, import_react3.useRef)();
|
|
584
|
+
const callback = (0, import_react3.useRef)(onFinish);
|
|
585
|
+
callback.current = onFinish;
|
|
586
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
587
|
+
const node = ref.current;
|
|
588
|
+
if (!present || !ready || !node) return;
|
|
589
|
+
let cancelled = false;
|
|
590
|
+
let animation;
|
|
591
|
+
let surfaceAnimation;
|
|
592
|
+
let maskAnimation;
|
|
593
|
+
const panel = kind === "drawer" || kind === "modal";
|
|
594
|
+
const fluid = kind === "popup";
|
|
595
|
+
const mask = kind === "modal" ? node.closest(".sia-modal-root") : kind === "drawer" ? node.closest(".sia-drawer-root")?.querySelector(".sia-drawer__mask") : null;
|
|
596
|
+
setPhase(open ? "entering" : "closing");
|
|
597
|
+
const finish = () => {
|
|
598
|
+
if (cancelled) return;
|
|
599
|
+
position.current = void 0;
|
|
600
|
+
snapshot.current = void 0;
|
|
601
|
+
if (open) {
|
|
602
|
+
animation?.cancel();
|
|
603
|
+
surfaceAnimation?.cancel();
|
|
604
|
+
maskAnimation?.cancel();
|
|
605
|
+
}
|
|
606
|
+
notify.current = open;
|
|
607
|
+
setEntered(open);
|
|
608
|
+
setPhase(open ? "open" : "closed");
|
|
609
|
+
node.dispatchEvent(new Event("sia-overlay-motion-end", { bubbles: true }));
|
|
610
|
+
};
|
|
611
|
+
const reduced = node.ownerDocument.defaultView?.matchMedia("(prefers-reduced-motion: reduce)");
|
|
612
|
+
const completeImmediately = () => {
|
|
613
|
+
animation?.cancel();
|
|
614
|
+
surfaceAnimation?.cancel();
|
|
615
|
+
maskAnimation?.cancel();
|
|
616
|
+
finish();
|
|
617
|
+
};
|
|
618
|
+
if (!enabled || reduced?.matches || !node.animate) {
|
|
619
|
+
finish();
|
|
620
|
+
} else {
|
|
621
|
+
let frames = fluid ? popupFluidFrames(placement, open) : motionFrames(kind, placement);
|
|
622
|
+
const start = snapshot.current;
|
|
623
|
+
const enterDuration = fluid ? popupEnterDuration : kind === "drawer" ? 320 : kind === "modal" ? 240 : kind === "fade" ? 180 : 280;
|
|
624
|
+
let duration = fluid && !open ? popupExitDuration : panel && !open ? kind === "drawer" ? 180 : 160 : enterDuration;
|
|
625
|
+
if (fluid && start) {
|
|
626
|
+
const current = new DOMMatrix(start.transform);
|
|
627
|
+
const destination = new DOMMatrix(String(frames[frames.length - 1].transform));
|
|
628
|
+
const remaining = Math.min(1, Math.max(0.15, Math.max(Math.abs(destination.a - current.a), Math.abs(destination.d - current.d)) / (1 - popupInitialScale), Math.hypot(current.e - destination.e, current.f - destination.f) / popupTravelOffset));
|
|
629
|
+
frames = [{ offset: 0, transform: start.transform, opacity: start.opacity }, { ...frames[frames.length - 1], offset: 1 }];
|
|
630
|
+
duration *= remaining;
|
|
631
|
+
}
|
|
632
|
+
if (panel) {
|
|
633
|
+
if (!open) frames = [{ transform: start?.transform ?? "none", opacity: start?.opacity ?? 1 }, { ...frames[0], offset: 1 }];
|
|
634
|
+
else if (start) frames = [{ ...frames[0], transform: start.transform, opacity: start.opacity }, ...frames.slice(1)];
|
|
635
|
+
}
|
|
636
|
+
const options = {
|
|
637
|
+
duration,
|
|
638
|
+
easing: fluid ? open ? "cubic-bezier(.2,.7,.2,1)" : "cubic-bezier(.4,0,1,1)" : panel && !open ? "cubic-bezier(.4,0,1,1)" : kind === "fade" ? "ease-in-out" : "cubic-bezier(.2,.7,.2,1)",
|
|
639
|
+
direction: panel || fluid || open ? "normal" : "reverse",
|
|
640
|
+
fill: "both"
|
|
641
|
+
};
|
|
642
|
+
animation = node.animate(frames, options);
|
|
643
|
+
if (!panel && !fluid && position.current !== void 0) animation.currentTime = open ? position.current : duration - position.current;
|
|
644
|
+
position.current = void 0;
|
|
645
|
+
snapshot.current = void 0;
|
|
646
|
+
if (mask) {
|
|
647
|
+
maskAnimation = mask.animate([{ opacity: start?.maskOpacity ?? (open ? 0 : 1) }, { opacity: open ? 1 : 0 }], { ...options, pseudoElement: kind === "modal" ? "::before" : void 0 });
|
|
648
|
+
maskAnimation.currentTime = animation.currentTime;
|
|
649
|
+
if (animation.startTime !== null) maskAnimation.startTime = animation.startTime;
|
|
650
|
+
}
|
|
651
|
+
if (kind === "toast") {
|
|
652
|
+
const surfaceFrames = motionFrames("message", placement).map((frame) => ({
|
|
653
|
+
offset: frame.offset,
|
|
654
|
+
transform: String(frame.transform).replace(/translateY\([^)]*\)\s*/g, "")
|
|
655
|
+
}));
|
|
656
|
+
surfaceAnimation = node.animate(surfaceFrames, { ...options, pseudoElement: "::before" });
|
|
657
|
+
surfaceAnimation.currentTime = animation.currentTime;
|
|
658
|
+
if (animation.startTime !== null) surfaceAnimation.startTime = animation.startTime;
|
|
659
|
+
}
|
|
660
|
+
animation.finished.then(finish, () => {
|
|
661
|
+
});
|
|
662
|
+
reduced?.addEventListener("change", completeImmediately, { once: true });
|
|
663
|
+
}
|
|
664
|
+
return () => {
|
|
665
|
+
cancelled = true;
|
|
666
|
+
reduced?.removeEventListener("change", completeImmediately);
|
|
667
|
+
if (animation && (animation.playState === "running" || animation.playState === "paused")) {
|
|
668
|
+
if (panel || fluid) {
|
|
669
|
+
const css = node.ownerDocument.defaultView.getComputedStyle(node);
|
|
670
|
+
snapshot.current = {
|
|
671
|
+
transform: css.transform,
|
|
672
|
+
opacity: css.opacity,
|
|
673
|
+
maskOpacity: mask ? node.ownerDocument.defaultView.getComputedStyle(mask, kind === "modal" ? "::before" : null).opacity : void 0
|
|
674
|
+
};
|
|
675
|
+
} else {
|
|
676
|
+
const time = Number(animation.currentTime ?? 0);
|
|
677
|
+
const duration = Number(animation.effect?.getTiming().duration ?? 0);
|
|
678
|
+
position.current = open ? time : duration - time;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
animation?.cancel();
|
|
682
|
+
surfaceAnimation?.cancel();
|
|
683
|
+
maskAnimation?.cancel();
|
|
684
|
+
};
|
|
685
|
+
}, [open, present, ready, kind, placement, enabled, ref]);
|
|
686
|
+
(0, import_react3.useEffect)(() => {
|
|
687
|
+
if (notify.current === void 0) return;
|
|
688
|
+
const completedOpen = notify.current;
|
|
689
|
+
notify.current = void 0;
|
|
690
|
+
if (completedOpen === open) callback.current?.(completedOpen);
|
|
691
|
+
}, [phase, open]);
|
|
692
|
+
return { present, entered, settled: phase === "open", closing: !open, phase };
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// src/components/PopupPortal.tsx
|
|
33
696
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
697
|
function setForwardedRef(ref, value) {
|
|
35
698
|
if (typeof ref === "function") ref(value);
|
|
@@ -38,21 +701,23 @@ function setForwardedRef(ref, value) {
|
|
|
38
701
|
function clamp(value, min, max) {
|
|
39
702
|
return Math.min(Math.max(value, min), Math.max(min, max));
|
|
40
703
|
}
|
|
41
|
-
var PopupPortal = (0,
|
|
704
|
+
var PopupPortal = (0, import_react4.forwardRef)(function PopupPortal2({
|
|
42
705
|
anchorRef,
|
|
43
706
|
open = true,
|
|
44
707
|
placement = "bottom-start",
|
|
45
708
|
offset = 6,
|
|
46
709
|
viewportPadding = 8,
|
|
710
|
+
afterOpenChange,
|
|
47
711
|
className = "",
|
|
48
712
|
style,
|
|
49
713
|
children,
|
|
50
714
|
...props
|
|
51
715
|
}, forwardedRef) {
|
|
52
|
-
const popupRef = (0,
|
|
53
|
-
const [position, setPosition] = (0,
|
|
54
|
-
(
|
|
55
|
-
|
|
716
|
+
const popupRef = (0, import_react4.useRef)(null);
|
|
717
|
+
const [position, setPosition] = (0, import_react4.useState)();
|
|
718
|
+
const motion = useOverlayMotion(open, popupRef, "popup", position?.placement ?? placement, !!position, afterOpenChange);
|
|
719
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
720
|
+
if (!motion.present || typeof document === "undefined") {
|
|
56
721
|
setPosition(void 0);
|
|
57
722
|
return;
|
|
58
723
|
}
|
|
@@ -61,7 +726,7 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
|
|
|
61
726
|
const popup = popupRef.current;
|
|
62
727
|
if (!anchor || !popup) return;
|
|
63
728
|
const anchorRect = anchor.getBoundingClientRect();
|
|
64
|
-
const popupRect = popup.
|
|
729
|
+
const popupRect = { width: popup.offsetWidth, height: popup.offsetHeight };
|
|
65
730
|
const viewportWidth = document.documentElement.clientWidth;
|
|
66
731
|
const viewportHeight = document.documentElement.clientHeight;
|
|
67
732
|
let resolvedPlacement = placement;
|
|
@@ -103,18 +768,28 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
|
|
|
103
768
|
setPosition((current) => current && current.top === next.top && current.left === next.left && current.anchorWidth === next.anchorWidth && current.availableHeight === next.availableHeight && current.placement === next.placement ? current : next);
|
|
104
769
|
};
|
|
105
770
|
update();
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
771
|
+
let frame = 0;
|
|
772
|
+
const schedule = () => {
|
|
773
|
+
if (!frame) frame = requestAnimationFrame(() => {
|
|
774
|
+
frame = 0;
|
|
775
|
+
update();
|
|
776
|
+
});
|
|
777
|
+
};
|
|
778
|
+
window.addEventListener("resize", schedule);
|
|
779
|
+
window.addEventListener("scroll", schedule, true);
|
|
780
|
+
window.addEventListener("sia-overlay-motion-end", schedule);
|
|
781
|
+
const observer = new ResizeObserver(schedule);
|
|
109
782
|
if (anchorRef.current) observer.observe(anchorRef.current);
|
|
110
783
|
if (popupRef.current) observer.observe(popupRef.current);
|
|
111
784
|
return () => {
|
|
112
|
-
window.removeEventListener("resize",
|
|
113
|
-
window.removeEventListener("scroll",
|
|
785
|
+
window.removeEventListener("resize", schedule);
|
|
786
|
+
window.removeEventListener("scroll", schedule, true);
|
|
787
|
+
window.removeEventListener("sia-overlay-motion-end", schedule);
|
|
788
|
+
cancelAnimationFrame(frame);
|
|
114
789
|
observer.disconnect();
|
|
115
790
|
};
|
|
116
|
-
}, [anchorRef, offset,
|
|
117
|
-
if (!
|
|
791
|
+
}, [anchorRef, offset, motion.present, placement, viewportPadding]);
|
|
792
|
+
if (!motion.present || typeof document === "undefined") return null;
|
|
118
793
|
return (0, import_react_dom.createPortal)(
|
|
119
794
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
120
795
|
"div",
|
|
@@ -126,13 +801,19 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
|
|
|
126
801
|
className: `sia-popup-portal ${className}`.trim(),
|
|
127
802
|
"data-sia-popup-layer": "",
|
|
128
803
|
"data-placement": position?.placement ?? placement,
|
|
804
|
+
"data-state": motion.closing ? "closing" : "open",
|
|
805
|
+
"aria-hidden": motion.closing || void 0,
|
|
129
806
|
style: {
|
|
130
807
|
...style,
|
|
131
808
|
"--sia-popup-anchor-width": `${position?.anchorWidth ?? anchorRef.current?.getBoundingClientRect().width ?? 0}px`,
|
|
132
809
|
"--sia-popup-available-height": position ? `${position.availableHeight}px` : void 0,
|
|
133
810
|
top: position?.top ?? 0,
|
|
134
811
|
left: position?.left ?? 0,
|
|
135
|
-
visibility: position ? "visible" : "hidden"
|
|
812
|
+
visibility: position ? "visible" : "hidden",
|
|
813
|
+
animation: "none",
|
|
814
|
+
pointerEvents: motion.closing ? "none" : style?.pointerEvents,
|
|
815
|
+
// 以靠近触发器的边缘中心为缩放原点,业务显式原点优先。
|
|
816
|
+
transformOrigin: style?.transformOrigin ?? ((position?.placement ?? placement).startsWith("left") ? "right center" : (position?.placement ?? placement).startsWith("right") ? "left center" : (position?.placement ?? placement).startsWith("top") ? "center bottom" : "center top")
|
|
136
817
|
},
|
|
137
818
|
...withTitleTooltip(props),
|
|
138
819
|
children
|
|
@@ -144,7 +825,7 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
|
|
|
144
825
|
|
|
145
826
|
// src/components/titleTooltip.tsx
|
|
146
827
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
147
|
-
var
|
|
828
|
+
var installedKey = /* @__PURE__ */ Symbol.for("sia.ui.titleTooltip.installed");
|
|
148
829
|
function withTitleTooltip(props) {
|
|
149
830
|
if (!props || typeof props !== "object" || !("title" in props)) return props;
|
|
150
831
|
const { title, ...rest } = props;
|
|
@@ -152,8 +833,9 @@ function withTitleTooltip(props) {
|
|
|
152
833
|
return { ...rest, "data-sia-title": title == null ? void 0 : String(title) };
|
|
153
834
|
}
|
|
154
835
|
function installTitleTooltips(doc) {
|
|
155
|
-
|
|
156
|
-
|
|
836
|
+
const owner = doc;
|
|
837
|
+
if (owner[installedKey]) return;
|
|
838
|
+
owner[installedKey] = true;
|
|
157
839
|
let hovered = null;
|
|
158
840
|
let focused = null;
|
|
159
841
|
let keyboardFocus = true;
|
|
@@ -187,8 +869,23 @@ function installTitleTooltips(doc) {
|
|
|
187
869
|
if (ids.length) active.setAttribute("aria-describedby", ids.join(" "));
|
|
188
870
|
else active.removeAttribute("aria-describedby");
|
|
189
871
|
}
|
|
872
|
+
const closing = active;
|
|
190
873
|
active = null;
|
|
191
|
-
root
|
|
874
|
+
if (closing && root) root.render(/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
875
|
+
PopupPortal,
|
|
876
|
+
{
|
|
877
|
+
anchorRef: { current: closing },
|
|
878
|
+
open: false,
|
|
879
|
+
placement: "top-start",
|
|
880
|
+
id: tooltipId,
|
|
881
|
+
role: "tooltip",
|
|
882
|
+
className: "sia-title-tooltip",
|
|
883
|
+
afterOpenChange: (opened) => {
|
|
884
|
+
if (!opened && !active) root?.render(null);
|
|
885
|
+
},
|
|
886
|
+
children: closing.getAttribute("data-sia-title")
|
|
887
|
+
}
|
|
888
|
+
));
|
|
192
889
|
};
|
|
193
890
|
const render = () => {
|
|
194
891
|
const text = active?.getAttribute("data-sia-title");
|
|
@@ -286,22 +983,22 @@ function installTitleTooltips(doc) {
|
|
|
286
983
|
}
|
|
287
984
|
|
|
288
985
|
// src/components/shared.ts
|
|
289
|
-
var
|
|
290
|
-
var ControlSizeContext = (0,
|
|
986
|
+
var import_react5 = require("react");
|
|
987
|
+
var ControlSizeContext = (0, import_react5.createContext)("medium");
|
|
291
988
|
function useControlSize(size) {
|
|
292
|
-
const inherited = (0,
|
|
989
|
+
const inherited = (0, import_react5.useContext)(ControlSizeContext);
|
|
293
990
|
return size ?? inherited;
|
|
294
991
|
}
|
|
295
|
-
var PlaceholderModeContext = (0,
|
|
992
|
+
var PlaceholderModeContext = (0, import_react5.createContext)("default");
|
|
296
993
|
function usePlaceholderMode(mode) {
|
|
297
|
-
const inherited = (0,
|
|
994
|
+
const inherited = (0, import_react5.useContext)(PlaceholderModeContext);
|
|
298
995
|
return mode ?? inherited;
|
|
299
996
|
}
|
|
300
997
|
function useControllableState({ value, defaultValue, onChange }) {
|
|
301
|
-
const [internalValue, setInternalValue] = (0,
|
|
998
|
+
const [internalValue, setInternalValue] = (0, import_react5.useState)(defaultValue);
|
|
302
999
|
const controlled = value !== void 0;
|
|
303
1000
|
const currentValue = controlled ? value : internalValue;
|
|
304
|
-
const setValue = (0,
|
|
1001
|
+
const setValue = (0, import_react5.useCallback)((nextValue) => {
|
|
305
1002
|
if (Object.is(currentValue, nextValue)) return;
|
|
306
1003
|
if (!controlled) setInternalValue(nextValue);
|
|
307
1004
|
onChange?.(nextValue);
|
|
@@ -321,10 +1018,10 @@ function useFloatingPlaceholder({ mode, placeholder, filled, active = false }) {
|
|
|
321
1018
|
}
|
|
322
1019
|
|
|
323
1020
|
// src/components/DatePicker.tsx
|
|
324
|
-
var
|
|
1021
|
+
var import_react9 = require("react");
|
|
325
1022
|
|
|
326
1023
|
// src/components/Icon.tsx
|
|
327
|
-
var
|
|
1024
|
+
var import_react7 = require("react");
|
|
328
1025
|
|
|
329
1026
|
// src/components/IconCatalog.tsx
|
|
330
1027
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -1135,13 +1832,13 @@ var filledIconBounds = {
|
|
|
1135
1832
|
};
|
|
1136
1833
|
|
|
1137
1834
|
// src/components/iconGeometry.tsx
|
|
1138
|
-
var
|
|
1835
|
+
var import_react6 = require("react");
|
|
1139
1836
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1140
1837
|
function compensateStroke(node, scale) {
|
|
1141
|
-
return
|
|
1142
|
-
if (!(0,
|
|
1838
|
+
return import_react6.Children.map(node, (child) => {
|
|
1839
|
+
if (!(0, import_react6.isValidElement)(child)) return child;
|
|
1143
1840
|
const props = child.props;
|
|
1144
|
-
return (0,
|
|
1841
|
+
return (0, import_react6.cloneElement)(child, {
|
|
1145
1842
|
...props.strokeWidth === void 0 ? {} : { strokeWidth: Number(props.strokeWidth) / scale },
|
|
1146
1843
|
...props.children === void 0 ? {} : { children: compensateStroke(props.children, scale) }
|
|
1147
1844
|
});
|
|
@@ -1473,7 +2170,7 @@ var filledIconPaths = {
|
|
|
1473
2170
|
var FILLED_ICON_NAMES = Object.freeze(Object.keys(filledIconPaths));
|
|
1474
2171
|
var normalizedOutlinePaths = normalizeIconPaths(iconPaths, outlineIconBounds);
|
|
1475
2172
|
var normalizedFilledPaths = normalizeIconPaths(filledIconPaths, filledIconBounds);
|
|
1476
|
-
var Icon = (0,
|
|
2173
|
+
var Icon = (0, import_react7.forwardRef)(function Icon2({ name, tone = "inherit", size = "1em", strokeWidth = 1.8, rotate = 0, spin = false, pulse = false, label, variant = "outline", className = "", style, ...props }, ref) {
|
|
1477
2174
|
const resolvedSize = typeof size === "number" ? `${size}px` : size;
|
|
1478
2175
|
const toneColor = tone === "inherit" ? void 0 : `var(--sia-color-${tone === "danger" ? "error" : tone === "primary" ? "primary-text" : tone})`;
|
|
1479
2176
|
const mergedStyle = { "--sia-icon-size": resolvedSize, "--sia-icon-rotate": `${rotate}deg`, color: toneColor, ...style };
|
|
@@ -1498,442 +2195,7 @@ var Icon = (0, import_react4.forwardRef)(function Icon2({ name, tone = "inherit"
|
|
|
1498
2195
|
});
|
|
1499
2196
|
|
|
1500
2197
|
// src/components/DatePickerPanel.tsx
|
|
1501
|
-
var
|
|
1502
|
-
|
|
1503
|
-
// src/components/FloatingScrollbarProvider.tsx
|
|
1504
|
-
var import_react6 = require("react");
|
|
1505
|
-
|
|
1506
|
-
// src/components/useScrollbarProximity.ts
|
|
1507
|
-
var import_react5 = require("react");
|
|
1508
|
-
var users = 0;
|
|
1509
|
-
var cleanup;
|
|
1510
|
-
function useScrollbarProximity() {
|
|
1511
|
-
(0, import_react5.useEffect)(() => {
|
|
1512
|
-
if (users++ === 0) {
|
|
1513
|
-
let frame = 0;
|
|
1514
|
-
let x = -Infinity;
|
|
1515
|
-
let y = -Infinity;
|
|
1516
|
-
const nearby = /* @__PURE__ */ new Set();
|
|
1517
|
-
const clear = () => {
|
|
1518
|
-
nearby.forEach((track) => track.removeAttribute("data-scrollbar-near"));
|
|
1519
|
-
nearby.clear();
|
|
1520
|
-
};
|
|
1521
|
-
const update = () => {
|
|
1522
|
-
frame = 0;
|
|
1523
|
-
const next = /* @__PURE__ */ new Set();
|
|
1524
|
-
document.querySelectorAll(".sia-scrollbar-track").forEach((track) => {
|
|
1525
|
-
const rect = track.getBoundingClientRect();
|
|
1526
|
-
const proximity = Number.parseFloat(getComputedStyle(track).getPropertyValue("--sia-scrollbar-proximity")) || 16;
|
|
1527
|
-
if (rect.width && rect.height && x >= rect.left - proximity && x <= rect.right + proximity && y >= rect.top - proximity && y <= rect.bottom + proximity) {
|
|
1528
|
-
next.add(track);
|
|
1529
|
-
if (!nearby.has(track)) track.setAttribute("data-scrollbar-near", "true");
|
|
1530
|
-
}
|
|
1531
|
-
});
|
|
1532
|
-
nearby.forEach((track) => {
|
|
1533
|
-
if (!next.has(track)) track.removeAttribute("data-scrollbar-near");
|
|
1534
|
-
});
|
|
1535
|
-
nearby.clear();
|
|
1536
|
-
next.forEach((track) => nearby.add(track));
|
|
1537
|
-
};
|
|
1538
|
-
const move = (event) => {
|
|
1539
|
-
if (event.pointerType === "touch") return;
|
|
1540
|
-
x = event.clientX;
|
|
1541
|
-
y = event.clientY;
|
|
1542
|
-
if (!frame) frame = requestAnimationFrame(update);
|
|
1543
|
-
};
|
|
1544
|
-
const leave = () => {
|
|
1545
|
-
x = y = -Infinity;
|
|
1546
|
-
clear();
|
|
1547
|
-
};
|
|
1548
|
-
document.addEventListener("pointermove", move, { passive: true });
|
|
1549
|
-
document.documentElement.addEventListener("pointerleave", leave);
|
|
1550
|
-
window.addEventListener("blur", leave);
|
|
1551
|
-
cleanup = () => {
|
|
1552
|
-
if (frame) cancelAnimationFrame(frame);
|
|
1553
|
-
document.removeEventListener("pointermove", move);
|
|
1554
|
-
document.documentElement.removeEventListener("pointerleave", leave);
|
|
1555
|
-
window.removeEventListener("blur", leave);
|
|
1556
|
-
clear();
|
|
1557
|
-
};
|
|
1558
|
-
}
|
|
1559
|
-
return () => {
|
|
1560
|
-
if (--users === 0) {
|
|
1561
|
-
cleanup?.();
|
|
1562
|
-
cleanup = void 0;
|
|
1563
|
-
}
|
|
1564
|
-
};
|
|
1565
|
-
}, []);
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
// src/components/floatingScrollbarOwnership.ts
|
|
1569
|
-
var targets = /* @__PURE__ */ new Map();
|
|
1570
|
-
function registerFloatingScrollbar(track, target) {
|
|
1571
|
-
targets.set(track, { target, dragging: false });
|
|
1572
|
-
return () => {
|
|
1573
|
-
targets.delete(track);
|
|
1574
|
-
};
|
|
1575
|
-
}
|
|
1576
|
-
function setFloatingScrollbarDragging(track, dragging) {
|
|
1577
|
-
const entry = targets.get(track);
|
|
1578
|
-
if (entry) entry.dragging = dragging;
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
// src/components/FloatingScrollbarProvider.tsx
|
|
1582
|
-
var scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
1583
|
-
var clippingOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay", "hidden", "clip"]);
|
|
1584
|
-
function isRootScroller(target) {
|
|
1585
|
-
return target === document.scrollingElement || target === document.documentElement;
|
|
1586
|
-
}
|
|
1587
|
-
function canScroll(target, axis) {
|
|
1588
|
-
if (target.matches(".sia-table__viewport, [data-sia-native-scrollbar]")) return false;
|
|
1589
|
-
if (isRootScroller(target)) {
|
|
1590
|
-
return axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
|
|
1591
|
-
}
|
|
1592
|
-
const style = getComputedStyle(target);
|
|
1593
|
-
const overflow = axis === "horizontal" ? style.overflowX : style.overflowY;
|
|
1594
|
-
const hasOverflow = axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
|
|
1595
|
-
return hasOverflow && scrollableOverflow.has(overflow);
|
|
1596
|
-
}
|
|
1597
|
-
function visibleRect(target) {
|
|
1598
|
-
if (isRootScroller(target)) {
|
|
1599
|
-
return { top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0, width: window.innerWidth, height: window.innerHeight };
|
|
1600
|
-
}
|
|
1601
|
-
const ownRect = target.getBoundingClientRect();
|
|
1602
|
-
let top = Math.max(0, ownRect.top);
|
|
1603
|
-
let right = Math.min(window.innerWidth, ownRect.right);
|
|
1604
|
-
let bottom = Math.min(window.innerHeight, ownRect.bottom);
|
|
1605
|
-
let left = Math.max(0, ownRect.left);
|
|
1606
|
-
let parent = target.parentElement;
|
|
1607
|
-
while (parent && parent !== document.body && parent !== document.documentElement) {
|
|
1608
|
-
const style = getComputedStyle(parent);
|
|
1609
|
-
const clipX = clippingOverflow.has(style.overflowX);
|
|
1610
|
-
const clipY = clippingOverflow.has(style.overflowY);
|
|
1611
|
-
if (clipX || clipY) {
|
|
1612
|
-
const rect = parent.getBoundingClientRect();
|
|
1613
|
-
if (clipX) {
|
|
1614
|
-
left = Math.max(left, rect.left);
|
|
1615
|
-
right = Math.min(right, rect.right);
|
|
1616
|
-
}
|
|
1617
|
-
if (clipY) {
|
|
1618
|
-
top = Math.max(top, rect.top);
|
|
1619
|
-
bottom = Math.min(bottom, rect.bottom);
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
parent = parent.parentElement;
|
|
1623
|
-
}
|
|
1624
|
-
return {
|
|
1625
|
-
top,
|
|
1626
|
-
right,
|
|
1627
|
-
bottom,
|
|
1628
|
-
left,
|
|
1629
|
-
width: Math.max(0, right - left),
|
|
1630
|
-
height: Math.max(0, bottom - top)
|
|
1631
|
-
};
|
|
1632
|
-
}
|
|
1633
|
-
function createTrack(axis) {
|
|
1634
|
-
const track = document.createElement("div");
|
|
1635
|
-
const thumb = document.createElement("div");
|
|
1636
|
-
track.className = `sia-scrollbar-track sia-floating-scrollbar sia-floating-scrollbar--${axis}`;
|
|
1637
|
-
thumb.className = "sia-floating-scrollbar__thumb";
|
|
1638
|
-
track.dataset.axis = axis;
|
|
1639
|
-
track.setAttribute("aria-hidden", "true");
|
|
1640
|
-
track.append(thumb);
|
|
1641
|
-
return { track, thumb };
|
|
1642
|
-
}
|
|
1643
|
-
function FloatingScrollbarProvider({ disabled = false, targetRef }) {
|
|
1644
|
-
useScrollbarProximity();
|
|
1645
|
-
(0, import_react6.useEffect)(() => {
|
|
1646
|
-
if (disabled) return;
|
|
1647
|
-
const layer = document.createElement("div");
|
|
1648
|
-
layer.className = "sia-floating-scrollbar-layer";
|
|
1649
|
-
layer.setAttribute("aria-hidden", "true");
|
|
1650
|
-
document.body.append(layer);
|
|
1651
|
-
const entries = /* @__PURE__ */ new Map();
|
|
1652
|
-
let scanFrame = 0;
|
|
1653
|
-
let updateFrame = 0;
|
|
1654
|
-
const dirtyStyles = /* @__PURE__ */ new Set();
|
|
1655
|
-
let fullScan = true;
|
|
1656
|
-
const setEntryVisible = (entry, visible) => {
|
|
1657
|
-
entry.horizontalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
|
|
1658
|
-
entry.verticalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
|
|
1659
|
-
};
|
|
1660
|
-
const showEntry = (entry) => {
|
|
1661
|
-
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
1662
|
-
entry.hideTimer = null;
|
|
1663
|
-
setEntryVisible(entry, true);
|
|
1664
|
-
};
|
|
1665
|
-
const scheduleHide = (entry, delay = 500) => {
|
|
1666
|
-
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
1667
|
-
entry.hideTimer = window.setTimeout(() => {
|
|
1668
|
-
entry.hideTimer = null;
|
|
1669
|
-
if (!entry.hoveringTarget && !entry.hoveringTrack && !entry.dragging) setEntryVisible(entry, false);
|
|
1670
|
-
}, delay);
|
|
1671
|
-
};
|
|
1672
|
-
const updateEntry = (entry) => {
|
|
1673
|
-
const { target, horizontalTrack, horizontalThumb, verticalTrack, verticalThumb } = entry;
|
|
1674
|
-
const hasHorizontal = canScroll(target, "horizontal");
|
|
1675
|
-
const hasVertical = canScroll(target, "vertical");
|
|
1676
|
-
const rect = visibleRect(target);
|
|
1677
|
-
const thickness = 10;
|
|
1678
|
-
horizontalTrack.hidden = !hasHorizontal || rect.width <= thickness || rect.height <= 0;
|
|
1679
|
-
verticalTrack.hidden = !hasVertical || rect.height <= thickness || rect.width <= 0;
|
|
1680
|
-
if (!horizontalTrack.hidden) {
|
|
1681
|
-
const trackWidth = Math.max(0, rect.width - (hasVertical ? thickness : 0));
|
|
1682
|
-
const thumbWidth = Math.max(24, Math.min(trackWidth, trackWidth * target.clientWidth / target.scrollWidth));
|
|
1683
|
-
const travel = Math.max(0, trackWidth - thumbWidth);
|
|
1684
|
-
const maxScroll = Math.max(1, target.scrollWidth - target.clientWidth);
|
|
1685
|
-
horizontalTrack.style.left = `${rect.left}px`;
|
|
1686
|
-
horizontalTrack.style.top = `${rect.bottom - thickness}px`;
|
|
1687
|
-
horizontalTrack.style.width = `${trackWidth}px`;
|
|
1688
|
-
horizontalTrack.style.height = `${thickness}px`;
|
|
1689
|
-
horizontalThumb.style.width = `${thumbWidth}px`;
|
|
1690
|
-
horizontalThumb.style.transform = `translate3d(${travel * target.scrollLeft / maxScroll}px, 0, 0)`;
|
|
1691
|
-
}
|
|
1692
|
-
if (!verticalTrack.hidden) {
|
|
1693
|
-
const trackHeight = Math.max(0, rect.height - (hasHorizontal ? thickness : 0));
|
|
1694
|
-
const thumbHeight = Math.max(24, Math.min(trackHeight, trackHeight * target.clientHeight / target.scrollHeight));
|
|
1695
|
-
const travel = Math.max(0, trackHeight - thumbHeight);
|
|
1696
|
-
const maxScroll = Math.max(1, target.scrollHeight - target.clientHeight);
|
|
1697
|
-
verticalTrack.style.left = `${rect.right - thickness}px`;
|
|
1698
|
-
verticalTrack.style.top = `${rect.top}px`;
|
|
1699
|
-
verticalTrack.style.width = `${thickness}px`;
|
|
1700
|
-
verticalTrack.style.height = `${trackHeight}px`;
|
|
1701
|
-
verticalThumb.style.height = `${thumbHeight}px`;
|
|
1702
|
-
verticalThumb.style.transform = `translate3d(0, ${travel * target.scrollTop / maxScroll}px, 0)`;
|
|
1703
|
-
}
|
|
1704
|
-
};
|
|
1705
|
-
const scheduleUpdateAll = () => {
|
|
1706
|
-
if (updateFrame) return;
|
|
1707
|
-
updateFrame = window.requestAnimationFrame(() => {
|
|
1708
|
-
updateFrame = 0;
|
|
1709
|
-
entries.forEach(updateEntry);
|
|
1710
|
-
});
|
|
1711
|
-
};
|
|
1712
|
-
const bindTrackDrag = (entry, axis, track, thumb) => {
|
|
1713
|
-
const target = entry.target;
|
|
1714
|
-
const onTrackPointerEnter = () => {
|
|
1715
|
-
entry.hoveringTrack = true;
|
|
1716
|
-
showEntry(entry);
|
|
1717
|
-
};
|
|
1718
|
-
const onTrackPointerLeave = () => {
|
|
1719
|
-
entry.hoveringTrack = false;
|
|
1720
|
-
scheduleHide(entry);
|
|
1721
|
-
};
|
|
1722
|
-
const onTrackPointerDown = (event) => {
|
|
1723
|
-
if (event.target === thumb || event.button !== 0) return;
|
|
1724
|
-
event.preventDefault();
|
|
1725
|
-
event.stopPropagation();
|
|
1726
|
-
const trackRect = track.getBoundingClientRect();
|
|
1727
|
-
const thumbRect = thumb.getBoundingClientRect();
|
|
1728
|
-
const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
|
|
1729
|
-
const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
|
|
1730
|
-
const pointer = axis === "vertical" ? event.clientY - trackRect.top : event.clientX - trackRect.left;
|
|
1731
|
-
const ratio = Math.max(0, Math.min(1, (pointer - thumbLength / 2) / Math.max(1, trackLength - thumbLength)));
|
|
1732
|
-
if (axis === "vertical") target.scrollTop = ratio * (target.scrollHeight - target.clientHeight);
|
|
1733
|
-
else target.scrollLeft = ratio * (target.scrollWidth - target.clientWidth);
|
|
1734
|
-
};
|
|
1735
|
-
const onThumbPointerDown = (event) => {
|
|
1736
|
-
if (event.button !== 0) return;
|
|
1737
|
-
event.preventDefault();
|
|
1738
|
-
event.stopPropagation();
|
|
1739
|
-
entry.dragging = true;
|
|
1740
|
-
setFloatingScrollbarDragging(track, true);
|
|
1741
|
-
showEntry(entry);
|
|
1742
|
-
thumb.setPointerCapture(event.pointerId);
|
|
1743
|
-
const startPointer = axis === "vertical" ? event.clientY : event.clientX;
|
|
1744
|
-
const startScroll = axis === "vertical" ? target.scrollTop : target.scrollLeft;
|
|
1745
|
-
const trackRect = track.getBoundingClientRect();
|
|
1746
|
-
const thumbRect = thumb.getBoundingClientRect();
|
|
1747
|
-
const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
|
|
1748
|
-
const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
|
|
1749
|
-
const maxScroll = axis === "vertical" ? target.scrollHeight - target.clientHeight : target.scrollWidth - target.clientWidth;
|
|
1750
|
-
const travel = Math.max(1, trackLength - thumbLength);
|
|
1751
|
-
const onPointerMove = (moveEvent) => {
|
|
1752
|
-
if (moveEvent.pointerId !== event.pointerId) return;
|
|
1753
|
-
const pointer = axis === "vertical" ? moveEvent.clientY : moveEvent.clientX;
|
|
1754
|
-
const nextScroll = startScroll + (pointer - startPointer) * maxScroll / travel;
|
|
1755
|
-
if (axis === "vertical") target.scrollTop = nextScroll;
|
|
1756
|
-
else target.scrollLeft = nextScroll;
|
|
1757
|
-
};
|
|
1758
|
-
const onPointerUp = (upEvent) => {
|
|
1759
|
-
if (upEvent.pointerId !== event.pointerId) return;
|
|
1760
|
-
entry.dragging = false;
|
|
1761
|
-
setFloatingScrollbarDragging(track, false);
|
|
1762
|
-
thumb.releasePointerCapture(event.pointerId);
|
|
1763
|
-
window.removeEventListener("pointermove", onPointerMove);
|
|
1764
|
-
window.removeEventListener("pointerup", onPointerUp);
|
|
1765
|
-
window.removeEventListener("pointercancel", onPointerUp);
|
|
1766
|
-
scheduleHide(entry);
|
|
1767
|
-
};
|
|
1768
|
-
window.addEventListener("pointermove", onPointerMove);
|
|
1769
|
-
window.addEventListener("pointerup", onPointerUp);
|
|
1770
|
-
window.addEventListener("pointercancel", onPointerUp);
|
|
1771
|
-
};
|
|
1772
|
-
track.addEventListener("pointerenter", onTrackPointerEnter);
|
|
1773
|
-
track.addEventListener("pointerleave", onTrackPointerLeave);
|
|
1774
|
-
track.addEventListener("pointerdown", onTrackPointerDown);
|
|
1775
|
-
thumb.addEventListener("pointerdown", onThumbPointerDown);
|
|
1776
|
-
return () => {
|
|
1777
|
-
track.removeEventListener("pointerenter", onTrackPointerEnter);
|
|
1778
|
-
track.removeEventListener("pointerleave", onTrackPointerLeave);
|
|
1779
|
-
track.removeEventListener("pointerdown", onTrackPointerDown);
|
|
1780
|
-
thumb.removeEventListener("pointerdown", onThumbPointerDown);
|
|
1781
|
-
};
|
|
1782
|
-
};
|
|
1783
|
-
const resizeObserver = new ResizeObserver((observedEntries) => {
|
|
1784
|
-
observedEntries.forEach(({ target }) => {
|
|
1785
|
-
const entry = entries.get(target);
|
|
1786
|
-
if (entry) updateEntry(entry);
|
|
1787
|
-
});
|
|
1788
|
-
});
|
|
1789
|
-
const addTarget = (target) => {
|
|
1790
|
-
if (entries.has(target)) return;
|
|
1791
|
-
const horizontal = createTrack("horizontal");
|
|
1792
|
-
const vertical = createTrack("vertical");
|
|
1793
|
-
const releaseHorizontalOwner = registerFloatingScrollbar(horizontal.track, target);
|
|
1794
|
-
const releaseVerticalOwner = registerFloatingScrollbar(vertical.track, target);
|
|
1795
|
-
layer.append(horizontal.track, vertical.track);
|
|
1796
|
-
const onPointerEnter = () => {
|
|
1797
|
-
const entry2 = entries.get(target);
|
|
1798
|
-
if (!entry2) return;
|
|
1799
|
-
entry2.hoveringTarget = true;
|
|
1800
|
-
showEntry(entry2);
|
|
1801
|
-
};
|
|
1802
|
-
const onPointerLeave = () => {
|
|
1803
|
-
const entry2 = entries.get(target);
|
|
1804
|
-
if (!entry2) return;
|
|
1805
|
-
entry2.hoveringTarget = false;
|
|
1806
|
-
scheduleHide(entry2);
|
|
1807
|
-
};
|
|
1808
|
-
const onScroll = () => {
|
|
1809
|
-
const entry2 = entries.get(target);
|
|
1810
|
-
if (!entry2) return;
|
|
1811
|
-
updateEntry(entry2);
|
|
1812
|
-
showEntry(entry2);
|
|
1813
|
-
scheduleHide(entry2, 700);
|
|
1814
|
-
};
|
|
1815
|
-
target.addEventListener("pointerenter", onPointerEnter);
|
|
1816
|
-
target.addEventListener("pointerleave", onPointerLeave);
|
|
1817
|
-
target.addEventListener("scroll", onScroll, { passive: true });
|
|
1818
|
-
const entry = {
|
|
1819
|
-
target,
|
|
1820
|
-
horizontalTrack: horizontal.track,
|
|
1821
|
-
horizontalThumb: horizontal.thumb,
|
|
1822
|
-
verticalTrack: vertical.track,
|
|
1823
|
-
verticalThumb: vertical.thumb,
|
|
1824
|
-
hideTimer: null,
|
|
1825
|
-
hoveringTarget: target.matches(":hover"),
|
|
1826
|
-
hoveringTrack: false,
|
|
1827
|
-
dragging: false,
|
|
1828
|
-
cleanup: () => void 0
|
|
1829
|
-
};
|
|
1830
|
-
const cleanupHorizontal = bindTrackDrag(entry, "horizontal", horizontal.track, horizontal.thumb);
|
|
1831
|
-
const cleanupVertical = bindTrackDrag(entry, "vertical", vertical.track, vertical.thumb);
|
|
1832
|
-
entry.cleanup = () => {
|
|
1833
|
-
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
1834
|
-
cleanupHorizontal();
|
|
1835
|
-
cleanupVertical();
|
|
1836
|
-
releaseHorizontalOwner();
|
|
1837
|
-
releaseVerticalOwner();
|
|
1838
|
-
target.removeEventListener("pointerenter", onPointerEnter);
|
|
1839
|
-
target.removeEventListener("pointerleave", onPointerLeave);
|
|
1840
|
-
target.removeEventListener("scroll", onScroll);
|
|
1841
|
-
resizeObserver.unobserve(target);
|
|
1842
|
-
target.removeAttribute("data-sia-floating-scrollbar");
|
|
1843
|
-
horizontal.track.remove();
|
|
1844
|
-
vertical.track.remove();
|
|
1845
|
-
};
|
|
1846
|
-
entries.set(target, entry);
|
|
1847
|
-
target.setAttribute("data-sia-floating-scrollbar", "");
|
|
1848
|
-
resizeObserver.observe(target);
|
|
1849
|
-
updateEntry(entry);
|
|
1850
|
-
if (entry.hoveringTarget) showEntry(entry);
|
|
1851
|
-
};
|
|
1852
|
-
const removeTarget = (target) => {
|
|
1853
|
-
const entry = entries.get(target);
|
|
1854
|
-
if (!entry) return;
|
|
1855
|
-
entry.cleanup();
|
|
1856
|
-
entries.delete(target);
|
|
1857
|
-
};
|
|
1858
|
-
const scanTargets = () => {
|
|
1859
|
-
scanFrame = 0;
|
|
1860
|
-
const managedSelector = ".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track, .sia-floating-scrollbar-layer";
|
|
1861
|
-
const discovered = /* @__PURE__ */ new Set();
|
|
1862
|
-
if (!targetRef) {
|
|
1863
|
-
const roots = fullScan ? [document.body] : [...dirtyStyles].filter((node) => node.isConnected);
|
|
1864
|
-
for (const root of roots) {
|
|
1865
|
-
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
|
|
1866
|
-
acceptNode: (node) => node.matches(managedSelector) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
|
|
1867
|
-
});
|
|
1868
|
-
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
1869
|
-
if (node instanceof HTMLElement) discovered.add(node);
|
|
1870
|
-
}
|
|
1871
|
-
for (let node = root; node; node = node.parentElement) discovered.add(node);
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
const candidates = (targetRef ? [targetRef.current] : [document.scrollingElement, ...discovered]).filter((target) => target instanceof HTMLElement);
|
|
1875
|
-
const nextTargets = /* @__PURE__ */ new Set();
|
|
1876
|
-
candidates.forEach((target) => {
|
|
1877
|
-
if (canScroll(target, "horizontal") || canScroll(target, "vertical")) {
|
|
1878
|
-
nextTargets.add(target);
|
|
1879
|
-
if (entries.has(target) || !target.hasAttribute("data-sia-floating-scrollbar")) addTarget(target);
|
|
1880
|
-
}
|
|
1881
|
-
});
|
|
1882
|
-
entries.forEach((_entry, target) => {
|
|
1883
|
-
if (!target.isConnected || (fullScan || candidates.includes(target)) && !nextTargets.has(target)) removeTarget(target);
|
|
1884
|
-
else updateEntry(_entry);
|
|
1885
|
-
});
|
|
1886
|
-
dirtyStyles.clear();
|
|
1887
|
-
fullScan = false;
|
|
1888
|
-
};
|
|
1889
|
-
const scheduleScan = (complete = true) => {
|
|
1890
|
-
fullScan ||= complete;
|
|
1891
|
-
if (scanFrame) return;
|
|
1892
|
-
scanFrame = window.requestAnimationFrame(scanTargets);
|
|
1893
|
-
};
|
|
1894
|
-
const previousStyle = document.createElement("div").style;
|
|
1895
|
-
const positionProperties = /* @__PURE__ */ new Set(["left", "top", "transform"]);
|
|
1896
|
-
const mutationObserver = new MutationObserver((mutations) => {
|
|
1897
|
-
let relevant = false;
|
|
1898
|
-
for (const mutation of mutations) {
|
|
1899
|
-
const target = mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
|
|
1900
|
-
if (!target || layer.contains(target) || target.closest(".sia-table__viewport, [data-sia-native-scrollbar], .sia-scrollbar-track")) continue;
|
|
1901
|
-
relevant = true;
|
|
1902
|
-
let positionOnly = false;
|
|
1903
|
-
if (mutation.type === "attributes" && mutation.attributeName === "style" && target instanceof HTMLElement) {
|
|
1904
|
-
previousStyle.cssText = mutation.oldValue ?? "";
|
|
1905
|
-
const keys = /* @__PURE__ */ new Set([...Array.from(previousStyle), ...Array.from(target.style)]);
|
|
1906
|
-
const changed = [...keys].filter((key) => previousStyle.getPropertyValue(key) !== target.style.getPropertyValue(key) || previousStyle.getPropertyPriority(key) !== target.style.getPropertyPriority(key));
|
|
1907
|
-
if (!changed.length) continue;
|
|
1908
|
-
const fixedSize = target.style.width.endsWith("px") && target.style.height.endsWith("px");
|
|
1909
|
-
positionOnly = fixedSize && changed.every((key) => positionProperties.has(key)) && ["absolute", "fixed"].includes(getComputedStyle(target).position);
|
|
1910
|
-
}
|
|
1911
|
-
if (positionOnly && target instanceof HTMLElement) dirtyStyles.add(target);
|
|
1912
|
-
else fullScan = true;
|
|
1913
|
-
}
|
|
1914
|
-
if (relevant) scheduleScan(false);
|
|
1915
|
-
});
|
|
1916
|
-
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ["class", "style", "hidden"] });
|
|
1917
|
-
const onResize = () => scheduleScan();
|
|
1918
|
-
window.addEventListener("resize", onResize);
|
|
1919
|
-
window.addEventListener("scroll", scheduleUpdateAll, true);
|
|
1920
|
-
scheduleScan();
|
|
1921
|
-
return () => {
|
|
1922
|
-
mutationObserver.disconnect();
|
|
1923
|
-
resizeObserver.disconnect();
|
|
1924
|
-
window.removeEventListener("resize", onResize);
|
|
1925
|
-
window.removeEventListener("scroll", scheduleUpdateAll, true);
|
|
1926
|
-
if (scanFrame) window.cancelAnimationFrame(scanFrame);
|
|
1927
|
-
if (updateFrame) window.cancelAnimationFrame(updateFrame);
|
|
1928
|
-
entries.forEach((entry) => entry.cleanup());
|
|
1929
|
-
entries.clear();
|
|
1930
|
-
layer.remove();
|
|
1931
|
-
};
|
|
1932
|
-
}, [disabled, targetRef]);
|
|
1933
|
-
return null;
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1936
|
-
// src/components/DatePickerPanel.tsx
|
|
2198
|
+
var import_react8 = require("react");
|
|
1937
2199
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1938
2200
|
function pad(value) {
|
|
1939
2201
|
return String(value).padStart(2, "0");
|
|
@@ -2077,12 +2339,12 @@ function TimePanel({
|
|
|
2077
2339
|
onChange
|
|
2078
2340
|
}) {
|
|
2079
2341
|
const [hour = "00", minute = "00", second = "00"] = value.split(":");
|
|
2080
|
-
const columnsRef = (0,
|
|
2081
|
-
const hourRef = (0,
|
|
2082
|
-
const minuteRef = (0,
|
|
2083
|
-
const secondRef = (0,
|
|
2342
|
+
const columnsRef = (0, import_react8.useRef)(null);
|
|
2343
|
+
const hourRef = (0, import_react8.useRef)(null);
|
|
2344
|
+
const minuteRef = (0, import_react8.useRef)(null);
|
|
2345
|
+
const secondRef = (0, import_react8.useRef)(null);
|
|
2084
2346
|
const columnRefs = [hourRef, minuteRef, secondRef];
|
|
2085
|
-
(0,
|
|
2347
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
2086
2348
|
for (const column of columnsRef.current?.children ?? []) {
|
|
2087
2349
|
const selected = column.querySelector('[aria-selected="true"]');
|
|
2088
2350
|
const first = column.firstElementChild;
|
|
@@ -2223,23 +2485,23 @@ function DatePicker({
|
|
|
2223
2485
|
...props
|
|
2224
2486
|
}) {
|
|
2225
2487
|
const size = useControlSize(sizeProp);
|
|
2226
|
-
const id = (0,
|
|
2227
|
-
const rootRef = (0,
|
|
2228
|
-
const popupRef = (0,
|
|
2488
|
+
const id = (0, import_react9.useId)();
|
|
2489
|
+
const rootRef = (0, import_react9.useRef)(null);
|
|
2490
|
+
const popupRef = (0, import_react9.useRef)(null);
|
|
2229
2491
|
const initialValue = defaultValue ?? (multiple ? [] : "");
|
|
2230
2492
|
const [currentValue, setCurrentValue] = useControllableState({ value, defaultValue: initialValue, onChange });
|
|
2231
2493
|
const [visible, setVisible] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
|
|
2232
|
-
const [draftValue, setDraftValue] = (0,
|
|
2494
|
+
const [draftValue, setDraftValue] = (0, import_react9.useState)(currentValue);
|
|
2233
2495
|
const firstCurrent = Array.isArray(currentValue) ? currentValue[0] : currentValue;
|
|
2234
|
-
const [viewMonth, setViewMonth] = (0,
|
|
2235
|
-
const [draftTime, setDraftTime] = (0,
|
|
2496
|
+
const [viewMonth, setViewMonth] = (0, import_react9.useState)(() => startOfMonth(parseDate(dayFromValue(firstCurrent)) ?? /* @__PURE__ */ new Date()));
|
|
2497
|
+
const [draftTime, setDraftTime] = (0, import_react9.useState)(() => timePart(firstCurrent, defaultTimeFrom(showTime)));
|
|
2236
2498
|
const resolvedNeedConfirm = needConfirm ?? Boolean(showTime);
|
|
2237
2499
|
const showSecond = showSecondFrom(showTime);
|
|
2238
|
-
const selectedDates = (0,
|
|
2500
|
+
const selectedDates = (0, import_react9.useMemo)(() => {
|
|
2239
2501
|
const values = Array.isArray(draftValue) ? draftValue : draftValue ? [draftValue] : [];
|
|
2240
2502
|
return values.map(dayFromValue).filter(Boolean);
|
|
2241
2503
|
}, [draftValue]);
|
|
2242
|
-
(0,
|
|
2504
|
+
(0, import_react9.useEffect)(() => {
|
|
2243
2505
|
if (!visible) return void 0;
|
|
2244
2506
|
const close = (event) => {
|
|
2245
2507
|
const target = event.target;
|
|
@@ -2413,15 +2675,15 @@ function DateRangePicker({
|
|
|
2413
2675
|
...props
|
|
2414
2676
|
}) {
|
|
2415
2677
|
const size = useControlSize(sizeProp);
|
|
2416
|
-
const id = (0,
|
|
2417
|
-
const rootRef = (0,
|
|
2418
|
-
const popupRef = (0,
|
|
2678
|
+
const id = (0, import_react9.useId)();
|
|
2679
|
+
const rootRef = (0, import_react9.useRef)(null);
|
|
2680
|
+
const popupRef = (0, import_react9.useRef)(null);
|
|
2419
2681
|
const [currentValue, setCurrentValue] = useControllableState({ value: value === void 0 ? void 0 : Array.isArray(value) ? value : ["", ""], defaultValue, onChange });
|
|
2420
2682
|
const [visible, setVisible] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
|
|
2421
|
-
const [draftValue, setDraftValue] = (0,
|
|
2422
|
-
const [activeIndex, setActiveIndex] = (0,
|
|
2423
|
-
const indicatorRef = (0,
|
|
2424
|
-
(0,
|
|
2683
|
+
const [draftValue, setDraftValue] = (0, import_react9.useState)(currentValue);
|
|
2684
|
+
const [activeIndex, setActiveIndex] = (0, import_react9.useState)(endpointDisabled[0] || currentValue[0] && !currentValue[1] ? 1 : 0);
|
|
2685
|
+
const indicatorRef = (0, import_react9.useRef)(null);
|
|
2686
|
+
(0, import_react9.useLayoutEffect)(() => {
|
|
2425
2687
|
const field = rootRef.current?.querySelector(`[data-range-endpoint="${activeIndex}"]`);
|
|
2426
2688
|
const indicator = indicatorRef.current;
|
|
2427
2689
|
if (!field || !indicator) return;
|
|
@@ -2438,22 +2700,22 @@ function DateRangePicker({
|
|
|
2438
2700
|
}
|
|
2439
2701
|
return () => observer.disconnect();
|
|
2440
2702
|
});
|
|
2441
|
-
const [confirmedIndex, setConfirmedIndex] = (0,
|
|
2442
|
-
const [presetSelected, setPresetSelected] = (0,
|
|
2443
|
-
const [hoverDate, setHoverDate] = (0,
|
|
2444
|
-
const [viewMonth, setViewMonth] = (0,
|
|
2445
|
-
const [endViewMonth, setEndViewMonth] = (0,
|
|
2703
|
+
const [confirmedIndex, setConfirmedIndex] = (0, import_react9.useState)(null);
|
|
2704
|
+
const [presetSelected, setPresetSelected] = (0, import_react9.useState)(false);
|
|
2705
|
+
const [hoverDate, setHoverDate] = (0, import_react9.useState)("");
|
|
2706
|
+
const [viewMonth, setViewMonth] = (0, import_react9.useState)(() => startOfMonth(parseDate(dayFromValue(currentValue[0] || currentValue[1])) ?? /* @__PURE__ */ new Date()));
|
|
2707
|
+
const [endViewMonth, setEndViewMonth] = (0, import_react9.useState)(() => startOfMonth(parseDate(dayFromValue(currentValue[1])) ?? addMonths(parseDate(dayFromValue(currentValue[0])) ?? /* @__PURE__ */ new Date(), 1)));
|
|
2446
2708
|
const showSecond = showSecondFrom(showTime);
|
|
2447
2709
|
const defaultTime = defaultTimeFrom(showTime);
|
|
2448
2710
|
const defaultEndTime = defaultTimeFrom(showTime, 1);
|
|
2449
|
-
const [times, setTimes] = (0,
|
|
2711
|
+
const [times, setTimes] = (0, import_react9.useState)([
|
|
2450
2712
|
timePart(currentValue[0], defaultTime),
|
|
2451
2713
|
timePart(currentValue[1], defaultEndTime)
|
|
2452
2714
|
]);
|
|
2453
2715
|
const resolvedNeedConfirm = needConfirm ?? Boolean(showTime);
|
|
2454
2716
|
const rangeDates = [dayFromValue(draftValue[0]), dayFromValue(draftValue[1])];
|
|
2455
2717
|
const invalidDateTimeRange = Boolean(showTime && draftValue[0] && draftValue[1] && draftValue[0] > draftValue[1]);
|
|
2456
|
-
(0,
|
|
2718
|
+
(0, import_react9.useEffect)(() => {
|
|
2457
2719
|
if (!visible) return void 0;
|
|
2458
2720
|
const close = (event) => {
|
|
2459
2721
|
const target = event.target;
|
|
@@ -2781,16 +3043,130 @@ function DateRangePicker({
|
|
|
2781
3043
|
})(DatePicker || (DatePicker = {}));
|
|
2782
3044
|
|
|
2783
3045
|
// src/components/Select.tsx
|
|
2784
|
-
var
|
|
3046
|
+
var import_react21 = require("react");
|
|
3047
|
+
|
|
3048
|
+
// src/components/OverlayContentSkeleton.tsx
|
|
3049
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3050
|
+
var controlSelector = '.sia-input-control, .sia-textarea-control, .sia-input-number, .sia-select__trigger, .sia-switch-wrap, .sia-checkbox, .sia-radio, input, textarea, select, button, img, svg, canvas, video, [role="combobox"], [role="checkbox"], [role="radio"], [role="switch"], [contenteditable="true"], .sia-table';
|
|
3051
|
+
function captureOverlaySkeleton(body) {
|
|
3052
|
+
const bounds = body.getBoundingClientRect();
|
|
3053
|
+
const scaleX = body.offsetWidth ? bounds.width / body.offsetWidth : 1;
|
|
3054
|
+
const scaleY = body.offsetHeight ? bounds.height / body.offsetHeight : 1;
|
|
3055
|
+
const css = getComputedStyle(body);
|
|
3056
|
+
const paddingLeft = parseFloat(css.paddingLeft) || 0;
|
|
3057
|
+
const paddingTop = parseFloat(css.paddingTop) || 0;
|
|
3058
|
+
const width = Math.max(0, body.clientWidth - paddingLeft - (parseFloat(css.paddingRight) || 0));
|
|
3059
|
+
const height = Math.max(0, body.clientHeight - paddingTop - (parseFloat(css.paddingBottom) || 0));
|
|
3060
|
+
const blocks = [];
|
|
3061
|
+
const addRect = (rect, radius) => {
|
|
3062
|
+
const x = (rect.left - bounds.left) / (scaleX || 1) - body.clientLeft - paddingLeft;
|
|
3063
|
+
const y = (rect.top - bounds.top) / (scaleY || 1) - body.clientTop - paddingTop;
|
|
3064
|
+
const left = Math.max(0, x), top = Math.max(0, y);
|
|
3065
|
+
const right = Math.min(width, x + rect.width / (scaleX || 1));
|
|
3066
|
+
const bottom = Math.min(height, y + rect.height / (scaleY || 1));
|
|
3067
|
+
if (right - left < 2 || bottom - top < 2 || blocks.length >= 80) return;
|
|
3068
|
+
blocks.push({ position: "absolute", left, top, width: right - left, height: bottom - top, borderRadius: radius });
|
|
3069
|
+
};
|
|
3070
|
+
const pending = [];
|
|
3071
|
+
for (let index = Math.min(body.childNodes.length, 600) - 1; index >= 0; index--) pending.push(body.childNodes[index]);
|
|
3072
|
+
let inspected = 0;
|
|
3073
|
+
while (pending.length && inspected++ < 600 && blocks.length < 80) {
|
|
3074
|
+
const node = pending.pop();
|
|
3075
|
+
if (node instanceof Element) {
|
|
3076
|
+
if (node.matches("script, style, [hidden], .sia-skeleton, .sia-scrollbar-track")) continue;
|
|
3077
|
+
const style = getComputedStyle(node);
|
|
3078
|
+
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0") continue;
|
|
3079
|
+
if (node.matches(controlSelector)) {
|
|
3080
|
+
addRect(node.getBoundingClientRect(), style.borderRadius || "4px");
|
|
3081
|
+
continue;
|
|
3082
|
+
}
|
|
3083
|
+
for (let index = Math.min(node.childNodes.length, 600 - inspected - pending.length) - 1; index >= 0; index--) pending.push(node.childNodes[index]);
|
|
3084
|
+
} else if (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) {
|
|
3085
|
+
const range = document.createRange();
|
|
3086
|
+
range.selectNodeContents(node);
|
|
3087
|
+
for (const rect of Array.from(range.getClientRects()).slice(0, 3)) addRect(rect, "4px");
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
return { height, blocks };
|
|
3091
|
+
}
|
|
3092
|
+
function OverlayContentSkeleton({ layout }) {
|
|
3093
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "sia-skeleton sia-overlay-content-skeleton", "aria-hidden": "true", style: { position: "relative", height: layout.height, overflow: "hidden" }, children: layout.blocks.map((style, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "sia-skeleton__block", style }, index)) });
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
// src/components/useOverlayExitPlaceholder.ts
|
|
3097
|
+
var import_react10 = require("react");
|
|
3098
|
+
function useOverlayExitPlaceholder(open, present, panelRef, bodyRef, captureContent) {
|
|
3099
|
+
const layout = (0, import_react10.useRef)();
|
|
3100
|
+
const dimensions = (0, import_react10.useRef)({ panelHeight: 0, bodyHeight: 0 });
|
|
3101
|
+
(0, import_react10.useLayoutEffect)(() => {
|
|
3102
|
+
if (!open || !present) {
|
|
3103
|
+
if (present && bodyRef.current) bodyRef.current.scrollTop = bodyRef.current.scrollLeft = 0;
|
|
3104
|
+
return;
|
|
3105
|
+
}
|
|
3106
|
+
if (!captureContent) layout.current = void 0;
|
|
3107
|
+
const panel = panelRef.current;
|
|
3108
|
+
const body = bodyRef.current;
|
|
3109
|
+
if (!panel) return;
|
|
3110
|
+
const measure = () => {
|
|
3111
|
+
dimensions.current = { panelHeight: panel.offsetHeight, bodyHeight: body?.offsetHeight ?? 0 };
|
|
3112
|
+
if (captureContent && body) layout.current = captureOverlaySkeleton(body);
|
|
3113
|
+
};
|
|
3114
|
+
let frame = 0;
|
|
3115
|
+
const schedule = () => {
|
|
3116
|
+
if (!frame) frame = requestAnimationFrame(() => {
|
|
3117
|
+
frame = 0;
|
|
3118
|
+
measure();
|
|
3119
|
+
});
|
|
3120
|
+
};
|
|
3121
|
+
measure();
|
|
3122
|
+
const observer = new ResizeObserver(measure);
|
|
3123
|
+
observer.observe(panel);
|
|
3124
|
+
if (body) observer.observe(body);
|
|
3125
|
+
const mutations = new MutationObserver(schedule);
|
|
3126
|
+
const beforePointerAction = (event) => {
|
|
3127
|
+
if (event.target instanceof Element && event.target.closest('button, [role="button"]')) measure();
|
|
3128
|
+
};
|
|
3129
|
+
const beforeKeyboardAction = (event) => {
|
|
3130
|
+
if (event.key === "Escape") measure();
|
|
3131
|
+
};
|
|
3132
|
+
if (captureContent && body) {
|
|
3133
|
+
mutations.observe(body, { subtree: true, childList: true, characterData: true, attributes: true, attributeFilter: ["style", "class", "hidden"] });
|
|
3134
|
+
body.addEventListener("scroll", schedule, { passive: true });
|
|
3135
|
+
panel.addEventListener("pointerdown", beforePointerAction, true);
|
|
3136
|
+
panel.addEventListener("keydown", beforeKeyboardAction, true);
|
|
3137
|
+
}
|
|
3138
|
+
return () => {
|
|
3139
|
+
observer.disconnect();
|
|
3140
|
+
mutations.disconnect();
|
|
3141
|
+
if (frame) cancelAnimationFrame(frame);
|
|
3142
|
+
body?.removeEventListener("scroll", schedule);
|
|
3143
|
+
panel.removeEventListener("pointerdown", beforePointerAction, true);
|
|
3144
|
+
panel.removeEventListener("keydown", beforeKeyboardAction, true);
|
|
3145
|
+
};
|
|
3146
|
+
});
|
|
3147
|
+
const closing = !open && present;
|
|
3148
|
+
const panelStyle = closing && dimensions.current.panelHeight > 0 ? { height: dimensions.current.panelHeight, boxSizing: "border-box", overflow: "hidden" } : void 0;
|
|
3149
|
+
const bodyStyle = closing && dimensions.current.bodyHeight > 0 ? { height: dimensions.current.bodyHeight, flex: "0 0 auto", boxSizing: "border-box" } : void 0;
|
|
3150
|
+
return { panelStyle, bodyStyle, layout: layout.current, hadBody: dimensions.current.bodyHeight > 0 };
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
// src/components/Skeleton.tsx
|
|
3154
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3155
|
+
function Skeleton({ rows = 6, columns = 2, rowHeight = 30, gap = 16, className = "", style, ...props }) {
|
|
3156
|
+
const count = (value, fallback, min, max) => Number.isFinite(value) ? Math.min(max, Math.max(min, Math.floor(value))) : fallback;
|
|
3157
|
+
const rowCount = count(rows, 6, 1, 30);
|
|
3158
|
+
const columnCount = count(columns, 2, 1, 4);
|
|
3159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { role: "status", "aria-label": "\u6B63\u5728\u51C6\u5907\u5185\u5BB9", className: `sia-skeleton ${className}`.trim(), style: { display: "grid", gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))`, gap: count(gap, 16, 0, 64), ...style }, ...withTitleTooltip(props), children: Array.from({ length: rowCount * columnCount }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "sia-skeleton__block", "aria-hidden": "true", style: { height: count(rowHeight, 30, 8, 200) } }, index)) });
|
|
3160
|
+
}
|
|
2785
3161
|
|
|
2786
3162
|
// src/components/Modal.tsx
|
|
2787
|
-
var
|
|
3163
|
+
var import_react13 = require("react");
|
|
2788
3164
|
var import_client2 = require("react-dom/client");
|
|
2789
3165
|
|
|
2790
3166
|
// src/components/Button.tsx
|
|
2791
|
-
var
|
|
2792
|
-
var
|
|
2793
|
-
var Button = (0,
|
|
3167
|
+
var import_react11 = require("react");
|
|
3168
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3169
|
+
var Button = (0, import_react11.forwardRef)(function Button2({
|
|
2794
3170
|
variant = "default",
|
|
2795
3171
|
size: sizeProp,
|
|
2796
3172
|
loading = false,
|
|
@@ -2806,7 +3182,33 @@ var Button = (0, import_react9.forwardRef)(function Button2({
|
|
|
2806
3182
|
...props
|
|
2807
3183
|
}, forwardedRef) {
|
|
2808
3184
|
const size = useControlSize(sizeProp);
|
|
2809
|
-
const localRef = (0,
|
|
3185
|
+
const localRef = (0, import_react11.useRef)(null);
|
|
3186
|
+
const bounceRef = (0, import_react11.useRef)(null);
|
|
3187
|
+
const waveTimerRef = (0, import_react11.useRef)();
|
|
3188
|
+
(0, import_react11.useEffect)(() => () => {
|
|
3189
|
+
bounceRef.current?.cancel();
|
|
3190
|
+
window.clearTimeout(waveTimerRef.current);
|
|
3191
|
+
}, []);
|
|
3192
|
+
function playBounce(button) {
|
|
3193
|
+
if (!button.animate || window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
|
3194
|
+
const current = getComputedStyle(button).scale;
|
|
3195
|
+
bounceRef.current?.cancel();
|
|
3196
|
+
const base = getComputedStyle(button).scale;
|
|
3197
|
+
const [x = 1, y = x] = base === "none" ? [] : base.split(/\s+/).map(Number);
|
|
3198
|
+
const scaled = (factor) => `${x * factor} ${y * factor}`;
|
|
3199
|
+
const animation = button.animate([
|
|
3200
|
+
{ scale: current === "none" ? "1" : current, offset: 0 },
|
|
3201
|
+
// 宽按钮保持等比缩放,以更明显的过冲表现弹性但不改变布局占位。
|
|
3202
|
+
{ scale: scaled(0.9), offset: 0.2 },
|
|
3203
|
+
{ scale: scaled(1.09), offset: 0.52 },
|
|
3204
|
+
{ scale: scaled(0.96), offset: 0.78 },
|
|
3205
|
+
{ scale: scaled(1), offset: 1 }
|
|
3206
|
+
], { duration: 320, easing: "cubic-bezier(.3, 0, .25, 1)" });
|
|
3207
|
+
bounceRef.current = animation;
|
|
3208
|
+
animation.onfinish = () => {
|
|
3209
|
+
if (bounceRef.current === animation) bounceRef.current = null;
|
|
3210
|
+
};
|
|
3211
|
+
}
|
|
2810
3212
|
function setRef(node) {
|
|
2811
3213
|
localRef.current = node;
|
|
2812
3214
|
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
@@ -2814,17 +3216,20 @@ var Button = (0, import_react9.forwardRef)(function Button2({
|
|
|
2814
3216
|
}
|
|
2815
3217
|
function handleClick(event) {
|
|
2816
3218
|
const button = localRef.current;
|
|
3219
|
+
if (disabled || loading) return;
|
|
3220
|
+
if (button) playBounce(button);
|
|
2817
3221
|
if (button && variant === "primary") {
|
|
2818
3222
|
const rect = button.getBoundingClientRect();
|
|
2819
|
-
button.style.setProperty("--sia-wave-x", `${event.clientX - rect.left}px`);
|
|
2820
|
-
button.style.setProperty("--sia-wave-y", `${event.clientY - rect.top}px`);
|
|
3223
|
+
button.style.setProperty("--sia-wave-x", `${event.detail === 0 ? button.offsetWidth / 2 : (event.clientX - rect.left) * button.offsetWidth / rect.width}px`);
|
|
3224
|
+
button.style.setProperty("--sia-wave-y", `${event.detail === 0 ? button.offsetHeight / 2 : (event.clientY - rect.top) * button.offsetHeight / rect.height}px`);
|
|
2821
3225
|
button.dataset.wave = "active";
|
|
2822
|
-
window.
|
|
3226
|
+
window.clearTimeout(waveTimerRef.current);
|
|
3227
|
+
waveTimerRef.current = window.setTimeout(() => delete button.dataset.wave, 360);
|
|
2823
3228
|
}
|
|
2824
3229
|
onClick?.(event);
|
|
2825
3230
|
}
|
|
2826
3231
|
const mergedStyle = block ? { ...style, width: "100%" } : style ?? {};
|
|
2827
|
-
return /* @__PURE__ */ (0,
|
|
3232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2828
3233
|
"button",
|
|
2829
3234
|
{
|
|
2830
3235
|
ref: setRef,
|
|
@@ -2836,16 +3241,16 @@ var Button = (0, import_react9.forwardRef)(function Button2({
|
|
|
2836
3241
|
style: mergedStyle,
|
|
2837
3242
|
...withTitleTooltip(props),
|
|
2838
3243
|
children: [
|
|
2839
|
-
loading ? /* @__PURE__ */ (0,
|
|
2840
|
-
children !== void 0 && children !== null ? /* @__PURE__ */ (0,
|
|
2841
|
-
!loading && icon && iconPosition === "end" ? /* @__PURE__ */ (0,
|
|
3244
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sia-button__spinner", "aria-hidden": "true" }) : icon && iconPosition === "start" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sia-button__icon", children: icon }) : null,
|
|
3245
|
+
children !== void 0 && children !== null ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children }) : null,
|
|
3246
|
+
!loading && icon && iconPosition === "end" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sia-button__icon", children: icon }) : null
|
|
2842
3247
|
]
|
|
2843
3248
|
}
|
|
2844
3249
|
);
|
|
2845
3250
|
});
|
|
2846
3251
|
|
|
2847
3252
|
// src/components/Overlay.tsx
|
|
2848
|
-
var
|
|
3253
|
+
var import_react12 = require("react");
|
|
2849
3254
|
var import_react_dom2 = require("react-dom");
|
|
2850
3255
|
var bodyLockCount = 0;
|
|
2851
3256
|
var previousBodyOverflow = "";
|
|
@@ -2888,11 +3293,11 @@ function firstModalInput(panel) {
|
|
|
2888
3293
|
);
|
|
2889
3294
|
return [...candidates ?? []].find((element) => (element.tabIndex >= 0 || element.isContentEditable && !element.hasAttribute("tabindex")) && !element.matches(":disabled, [readonly], [aria-readonly='true']") && !element.closest('[hidden], [inert], [aria-hidden="true"], [aria-disabled="true"]') && element.getClientRects().length > 0 && getComputedStyle(element).visibility === "visible");
|
|
2890
3295
|
}
|
|
2891
|
-
function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, autoFocusInput = false) {
|
|
2892
|
-
const overlayIdRef = (0,
|
|
2893
|
-
const closeRef = (0,
|
|
3296
|
+
function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, autoFocusInput = false, contentReady = true) {
|
|
3297
|
+
const overlayIdRef = (0, import_react12.useRef)(/* @__PURE__ */ Symbol("sia-overlay"));
|
|
3298
|
+
const closeRef = (0, import_react12.useRef)(onRequestClose);
|
|
2894
3299
|
closeRef.current = onRequestClose;
|
|
2895
|
-
(0,
|
|
3300
|
+
(0, import_react12.useEffect)(() => {
|
|
2896
3301
|
if (!open || typeof document === "undefined") return void 0;
|
|
2897
3302
|
const overlayId = overlayIdRef.current;
|
|
2898
3303
|
const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -2900,14 +3305,6 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, au
|
|
|
2900
3305
|
overlayPanels.set(overlayId, panelRef);
|
|
2901
3306
|
overlayListeners.forEach((listener) => listener());
|
|
2902
3307
|
const unlockBody = lockBodyScroll();
|
|
2903
|
-
const focusTimer = window.setTimeout(() => {
|
|
2904
|
-
const panel = panelRef.current;
|
|
2905
|
-
if (!panel || overlayStack.at(-1) !== overlayId) return;
|
|
2906
|
-
if (panel.contains(document.activeElement) && document.activeElement !== panel) return;
|
|
2907
|
-
const [firstFocusable] = focusableElements(panel);
|
|
2908
|
-
const input = autoFocusInput ? firstModalInput(panel) : void 0;
|
|
2909
|
-
(input ?? firstFocusable ?? panel).focus({ preventScroll: true });
|
|
2910
|
-
}, 0);
|
|
2911
3308
|
function handleKeyDown(event) {
|
|
2912
3309
|
if (overlayStack.at(-1) !== overlayId) return;
|
|
2913
3310
|
if (event.key === "Escape" && keyboard) {
|
|
@@ -2934,7 +3331,6 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, au
|
|
|
2934
3331
|
}
|
|
2935
3332
|
document.addEventListener("keydown", handleKeyDown);
|
|
2936
3333
|
return () => {
|
|
2937
|
-
window.clearTimeout(focusTimer);
|
|
2938
3334
|
document.removeEventListener("keydown", handleKeyDown);
|
|
2939
3335
|
const index = overlayStack.lastIndexOf(overlayId);
|
|
2940
3336
|
if (index >= 0) overlayStack.splice(index, 1);
|
|
@@ -2944,6 +3340,17 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, au
|
|
|
2944
3340
|
previouslyFocused?.focus({ preventScroll: true });
|
|
2945
3341
|
};
|
|
2946
3342
|
}, [keyboard, open, panelRef, autoFocusInput]);
|
|
3343
|
+
(0, import_react12.useEffect)(() => {
|
|
3344
|
+
if (!open) return;
|
|
3345
|
+
const timer = window.setTimeout(() => {
|
|
3346
|
+
const panel = panelRef.current;
|
|
3347
|
+
if (!panel || overlayStack.at(-1) !== overlayIdRef.current) return;
|
|
3348
|
+
if (panel.contains(document.activeElement) && document.activeElement !== panel) return;
|
|
3349
|
+
const first = contentReady ? (autoFocusInput ? firstModalInput(panel) : void 0) ?? focusableElements(panel)[0] : void 0;
|
|
3350
|
+
(first ?? panel).focus({ preventScroll: true });
|
|
3351
|
+
}, 0);
|
|
3352
|
+
return () => window.clearTimeout(timer);
|
|
3353
|
+
}, [open, panelRef, autoFocusInput, contentReady]);
|
|
2947
3354
|
}
|
|
2948
3355
|
function OverlayPortal({ children, container }) {
|
|
2949
3356
|
if (typeof document === "undefined") return null;
|
|
@@ -2952,18 +3359,19 @@ function OverlayPortal({ children, container }) {
|
|
|
2952
3359
|
}
|
|
2953
3360
|
|
|
2954
3361
|
// src/components/Modal.tsx
|
|
2955
|
-
var
|
|
3362
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2956
3363
|
var modalHandles = /* @__PURE__ */ new Set();
|
|
2957
|
-
var MODAL_MOTION_DURATION = 220;
|
|
2958
3364
|
var typeIcons = {
|
|
2959
|
-
info: /* @__PURE__ */ (0,
|
|
2960
|
-
success: /* @__PURE__ */ (0,
|
|
2961
|
-
warning: /* @__PURE__ */ (0,
|
|
2962
|
-
error: /* @__PURE__ */ (0,
|
|
2963
|
-
confirm: /* @__PURE__ */ (0,
|
|
3365
|
+
info: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "info", size: 23, variant: "filled" }),
|
|
3366
|
+
success: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "circle-check", size: 23, variant: "filled" }),
|
|
3367
|
+
warning: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "warning", size: 23, variant: "filled" }),
|
|
3368
|
+
error: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "circle-close", size: 23, variant: "filled" }),
|
|
3369
|
+
confirm: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "question", size: 23, variant: "filled" })
|
|
2964
3370
|
};
|
|
2965
|
-
var ModalRoot = (0,
|
|
3371
|
+
var ModalRoot = (0, import_react13.forwardRef)(function Modal({
|
|
2966
3372
|
open,
|
|
3373
|
+
deferContent = false,
|
|
3374
|
+
loadingFallback,
|
|
2967
3375
|
autoFocus = true,
|
|
2968
3376
|
title,
|
|
2969
3377
|
children,
|
|
@@ -2992,34 +3400,15 @@ var ModalRoot = (0, import_react11.forwardRef)(function Modal({
|
|
|
2992
3400
|
style,
|
|
2993
3401
|
...props
|
|
2994
3402
|
}, forwardedRef) {
|
|
2995
|
-
const localRef = (0,
|
|
2996
|
-
const
|
|
2997
|
-
const
|
|
2998
|
-
const [
|
|
2999
|
-
const
|
|
3000
|
-
const
|
|
3001
|
-
|
|
3002
|
-
const
|
|
3003
|
-
(0,
|
|
3004
|
-
if (!open || !rendered) return void 0;
|
|
3005
|
-
const timer = window.setTimeout(() => afterOpenChangeRef.current?.(true), MODAL_MOTION_DURATION);
|
|
3006
|
-
return () => window.clearTimeout(timer);
|
|
3007
|
-
}, [open, rendered]);
|
|
3008
|
-
(0, import_react11.useEffect)(() => {
|
|
3009
|
-
if (open) {
|
|
3010
|
-
setRendered(true);
|
|
3011
|
-
setClosing(false);
|
|
3012
|
-
return void 0;
|
|
3013
|
-
}
|
|
3014
|
-
if (!rendered) return void 0;
|
|
3015
|
-
setClosing(true);
|
|
3016
|
-
const timer = window.setTimeout(() => {
|
|
3017
|
-
setRendered(false);
|
|
3018
|
-
setClosing(false);
|
|
3019
|
-
afterOpenChangeRef.current?.(false);
|
|
3020
|
-
}, MODAL_MOTION_DURATION);
|
|
3021
|
-
return () => window.clearTimeout(timer);
|
|
3022
|
-
}, [open, rendered]);
|
|
3403
|
+
const localRef = (0, import_react13.useRef)(null);
|
|
3404
|
+
const bodyRef = (0, import_react13.useRef)(null);
|
|
3405
|
+
const titleId = (0, import_react13.useId)();
|
|
3406
|
+
const [submitting, setSubmitting] = (0, import_react13.useState)(false);
|
|
3407
|
+
const motion = useOverlayMotion(open, localRef, "modal", "bottom", true, afterOpenChange);
|
|
3408
|
+
const { present: rendered, closing } = motion;
|
|
3409
|
+
const bodyReady = !closing && (!deferContent || motion.settled);
|
|
3410
|
+
const exitPlaceholder = useOverlayExitPlaceholder(open, rendered, localRef, bodyRef, bodyReady && loadingFallback === void 0);
|
|
3411
|
+
const submitLock = (0, import_react13.useRef)(false);
|
|
3023
3412
|
function setRef(node) {
|
|
3024
3413
|
localRef.current = node;
|
|
3025
3414
|
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
@@ -3031,7 +3420,7 @@ var ModalRoot = (0, import_react11.forwardRef)(function Modal({
|
|
|
3031
3420
|
onOpenChange?.(false);
|
|
3032
3421
|
}
|
|
3033
3422
|
async function handleOk() {
|
|
3034
|
-
if (submitLock.current || confirmLoading) return;
|
|
3423
|
+
if (!bodyReady || submitLock.current || confirmLoading) return;
|
|
3035
3424
|
submitLock.current = true;
|
|
3036
3425
|
if (!onOk) {
|
|
3037
3426
|
onOpenChange?.(false);
|
|
@@ -3054,49 +3443,50 @@ var ModalRoot = (0, import_react11.forwardRef)(function Modal({
|
|
|
3054
3443
|
setSubmitting(false);
|
|
3055
3444
|
}
|
|
3056
3445
|
}
|
|
3057
|
-
useOverlayLifecycle(rendered, localRef, requestClose, keyboard, autoFocus);
|
|
3446
|
+
useOverlayLifecycle(rendered, localRef, requestClose, keyboard, autoFocus, bodyReady);
|
|
3058
3447
|
if (!rendered) return null;
|
|
3059
3448
|
const mergedStyle = {
|
|
3060
3449
|
...height !== void 0 ? { display: "flex", flexDirection: "column", height, maxHeight: "calc(100dvh - 48px)" } : {},
|
|
3061
3450
|
...style,
|
|
3062
3451
|
"--sia-modal-width": typeof width === "number" ? `${width}px` : width
|
|
3063
3452
|
};
|
|
3064
|
-
const loading = submitting || confirmLoading;
|
|
3065
|
-
const defaultFooter = /* @__PURE__ */ (0,
|
|
3066
|
-
showCancel ? /* @__PURE__ */ (0,
|
|
3067
|
-
/* @__PURE__ */ (0,
|
|
3453
|
+
const loading = submitting || confirmLoading || !bodyReady;
|
|
3454
|
+
const defaultFooter = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
3455
|
+
showCancel ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { ...cancelButtonProps, onClick: requestClose, disabled: loading || cancelButtonProps?.disabled, children: cancelText }) : null,
|
|
3456
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { variant: "primary", ...okButtonProps, onClick: handleOk, loading, children: okText })
|
|
3068
3457
|
] });
|
|
3069
|
-
return /* @__PURE__ */ (0,
|
|
3458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(OverlayPortal, { container: getContainer, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3070
3459
|
"div",
|
|
3071
3460
|
{
|
|
3072
3461
|
className: `sia-modal-root${centered ? " sia-modal-root--centered" : ""}`,
|
|
3073
3462
|
"data-state": closing ? "closing" : "open",
|
|
3463
|
+
"data-content-pending": !bodyReady || void 0,
|
|
3074
3464
|
style: { zIndex },
|
|
3075
3465
|
onMouseDown: (event) => {
|
|
3076
3466
|
if (event.target === event.currentTarget && maskClosable) requestClose();
|
|
3077
3467
|
},
|
|
3078
|
-
children: /* @__PURE__ */ (0,
|
|
3468
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3079
3469
|
"div",
|
|
3080
3470
|
{
|
|
3081
3471
|
ref: setRef,
|
|
3082
3472
|
className: `sia-modal sia-modal--${type} ${className}`.trim(),
|
|
3083
|
-
style: mergedStyle,
|
|
3473
|
+
style: { ...mergedStyle, ...exitPlaceholder.panelStyle, animation: "none" },
|
|
3084
3474
|
role: "dialog",
|
|
3085
3475
|
"aria-modal": "true",
|
|
3086
3476
|
"aria-labelledby": title ? titleId : void 0,
|
|
3087
3477
|
tabIndex: -1,
|
|
3088
3478
|
...withTitleTooltip(props),
|
|
3089
3479
|
children: [
|
|
3090
|
-
/* @__PURE__ */ (0,
|
|
3091
|
-
/* @__PURE__ */ (0,
|
|
3092
|
-
typeIcons[type] ? /* @__PURE__ */ (0,
|
|
3093
|
-
title ? /* @__PURE__ */ (0,
|
|
3480
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "sia-modal__header", style: height !== void 0 ? { flexShrink: 0 } : void 0, children: [
|
|
3481
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "sia-modal__heading", children: [
|
|
3482
|
+
typeIcons[type] ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "sia-modal__type-icon", "aria-hidden": "true", children: typeIcons[type] }) : null,
|
|
3483
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("strong", { id: titleId, children: title }) : null
|
|
3094
3484
|
] }),
|
|
3095
|
-
closable ? /* @__PURE__ */ (0,
|
|
3485
|
+
closable ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "sia-modal__close", "aria-label": "\u5173\u95ED\u5BF9\u8BDD\u6846", onClick: requestClose, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "close", size: 17 }) }) : null
|
|
3096
3486
|
] }),
|
|
3097
|
-
children !== void 0 ? /* @__PURE__ */ (0,
|
|
3098
|
-
footer !== null ? /* @__PURE__ */ (0,
|
|
3099
|
-
footer === void 0 && footerExtra != null ? /* @__PURE__ */ (0,
|
|
3487
|
+
children !== void 0 || closing && exitPlaceholder.hadBody ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: bodyRef, className: `sia-modal__body${deferContent && bodyReady ? " sia-overlay-body--ready" : ""}`, "aria-busy": !bodyReady, style: { ...height !== void 0 ? { flex: 1, minHeight: 0, overflow: "auto" } : {}, ...exitPlaceholder.bodyStyle }, children: bodyReady ? children : loadingFallback !== void 0 ? loadingFallback : closing && exitPlaceholder.layout ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(OverlayContentSkeleton, { layout: exitPlaceholder.layout }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Skeleton, {}) }) : null,
|
|
3488
|
+
footer !== null && (bodyReady || closing && motion.entered || footer === void 0) ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "sia-modal__footer", style: height !== void 0 ? { flexShrink: 0 } : void 0, children: [
|
|
3489
|
+
footer === void 0 && footerExtra != null ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { marginRight: "auto" }, children: footerExtra }) : null,
|
|
3100
3490
|
footer ?? defaultFooter
|
|
3101
3491
|
] }) : null
|
|
3102
3492
|
]
|
|
@@ -3130,11 +3520,11 @@ function openModal(config) {
|
|
|
3130
3520
|
render();
|
|
3131
3521
|
}
|
|
3132
3522
|
function ModalInstance() {
|
|
3133
|
-
(0,
|
|
3523
|
+
(0, import_react13.useEffect)(() => {
|
|
3134
3524
|
mounted = true;
|
|
3135
3525
|
if (!currentOpen) render();
|
|
3136
3526
|
}, []);
|
|
3137
|
-
return /* @__PURE__ */ (0,
|
|
3527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ModalRoot, { ...currentConfig, open: !mounted || currentOpen, onOpenChange: (nextOpen) => {
|
|
3138
3528
|
currentConfig.onOpenChange?.(nextOpen);
|
|
3139
3529
|
if (!nextOpen) closeWithMotion();
|
|
3140
3530
|
}, afterOpenChange: (nextOpen) => {
|
|
@@ -3146,7 +3536,7 @@ function openModal(config) {
|
|
|
3146
3536
|
} });
|
|
3147
3537
|
}
|
|
3148
3538
|
function render() {
|
|
3149
|
-
root.render(/* @__PURE__ */ (0,
|
|
3539
|
+
root.render(/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ModalInstance, {}));
|
|
3150
3540
|
}
|
|
3151
3541
|
const handle = {
|
|
3152
3542
|
destroy: closeWithMotion,
|
|
@@ -3191,12 +3581,12 @@ var Modal2 = Object.assign(ModalRoot, {
|
|
|
3191
3581
|
});
|
|
3192
3582
|
|
|
3193
3583
|
// src/components/Input.tsx
|
|
3194
|
-
var
|
|
3584
|
+
var import_react15 = require("react");
|
|
3195
3585
|
|
|
3196
3586
|
// src/components/TextArea.tsx
|
|
3197
|
-
var
|
|
3198
|
-
var
|
|
3199
|
-
var TextArea = (0,
|
|
3587
|
+
var import_react14 = require("react");
|
|
3588
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3589
|
+
var TextArea = (0, import_react14.forwardRef)(function TextArea2({
|
|
3200
3590
|
label,
|
|
3201
3591
|
hint,
|
|
3202
3592
|
status = "default",
|
|
@@ -3214,9 +3604,9 @@ var TextArea = (0, import_react12.forwardRef)(function TextArea2({
|
|
|
3214
3604
|
...props
|
|
3215
3605
|
}, ref) {
|
|
3216
3606
|
const size = useControlSize(sizeProp);
|
|
3217
|
-
const fallbackId = (0,
|
|
3607
|
+
const fallbackId = (0, import_react14.useId)();
|
|
3218
3608
|
const textAreaId = id ?? fallbackId;
|
|
3219
|
-
const [uncontrolledValue, setUncontrolledValue] = (0,
|
|
3609
|
+
const [uncontrolledValue, setUncontrolledValue] = (0, import_react14.useState)(() => defaultValue === void 0 ? "" : String(defaultValue));
|
|
3220
3610
|
const currentText = value !== void 0 ? String(value) : uncontrolledValue;
|
|
3221
3611
|
const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: currentText.length > 0 });
|
|
3222
3612
|
const hintId = `${textAreaId}-hint`;
|
|
@@ -3225,8 +3615,8 @@ var TextArea = (0, import_react12.forwardRef)(function TextArea2({
|
|
|
3225
3615
|
setUncontrolledValue(event.target.value);
|
|
3226
3616
|
onChange?.(event);
|
|
3227
3617
|
}
|
|
3228
|
-
const control = /* @__PURE__ */ (0,
|
|
3229
|
-
/* @__PURE__ */ (0,
|
|
3618
|
+
const control = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: `sia-textarea-control sia-textarea-control--${size} sia-textarea-control--${status}${floating.className}${disabled ? " is-disabled" : ""}`, children: [
|
|
3619
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3230
3620
|
"textarea",
|
|
3231
3621
|
{
|
|
3232
3622
|
...withTitleTooltip(props),
|
|
@@ -3244,22 +3634,22 @@ var TextArea = (0, import_react12.forwardRef)(function TextArea2({
|
|
|
3244
3634
|
}
|
|
3245
3635
|
),
|
|
3246
3636
|
floating.label,
|
|
3247
|
-
showCount ? /* @__PURE__ */ (0,
|
|
3637
|
+
showCount ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: `sia-textarea-control__count${maxLength !== void 0 && currentText.length >= maxLength ? " is-limit" : ""}`, "aria-live": "polite", children: [
|
|
3248
3638
|
currentText.length,
|
|
3249
3639
|
maxLength !== void 0 ? `/${maxLength}` : null
|
|
3250
3640
|
] }) : null
|
|
3251
3641
|
] });
|
|
3252
|
-
if (!label && !hint) return /* @__PURE__ */ (0,
|
|
3253
|
-
return /* @__PURE__ */ (0,
|
|
3254
|
-
label ? /* @__PURE__ */ (0,
|
|
3642
|
+
if (!label && !hint) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: `sia-field ${className}`.trim(), children: control });
|
|
3643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: `sia-field ${className}`.trim(), children: [
|
|
3644
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { className: "sia-field__label", htmlFor: textAreaId, children: label }) : null,
|
|
3255
3645
|
control,
|
|
3256
|
-
hint ? /* @__PURE__ */ (0,
|
|
3646
|
+
hint ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { id: hintId, className: `sia-field__hint sia-field__hint--${status}`, children: hint }) : null
|
|
3257
3647
|
] });
|
|
3258
3648
|
});
|
|
3259
3649
|
|
|
3260
3650
|
// src/components/Input.tsx
|
|
3261
|
-
var
|
|
3262
|
-
var Input = (0,
|
|
3651
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3652
|
+
var Input = (0, import_react15.forwardRef)(function Input2({
|
|
3263
3653
|
label,
|
|
3264
3654
|
hint,
|
|
3265
3655
|
status = "default",
|
|
@@ -3282,14 +3672,14 @@ var Input = (0, import_react13.forwardRef)(function Input2({
|
|
|
3282
3672
|
...props
|
|
3283
3673
|
}, forwardedRef) {
|
|
3284
3674
|
const size = useControlSize(sizeProp);
|
|
3285
|
-
const fallbackId = (0,
|
|
3675
|
+
const fallbackId = (0, import_react15.useId)();
|
|
3286
3676
|
const inputId = id ?? fallbackId;
|
|
3287
|
-
const localRef = (0,
|
|
3288
|
-
const [uncontrolledValue, setUncontrolledValue] = (0,
|
|
3677
|
+
const localRef = (0, import_react15.useRef)(null);
|
|
3678
|
+
const [uncontrolledValue, setUncontrolledValue] = (0, import_react15.useState)(() => defaultValue === void 0 ? "" : String(defaultValue));
|
|
3289
3679
|
const currentText = value !== void 0 ? String(value) : uncontrolledValue;
|
|
3290
3680
|
const hasValue = currentText.length > 0;
|
|
3291
|
-
const [expanded, setExpanded] = (0,
|
|
3292
|
-
const [expandedDraft, setExpandedDraft] = (0,
|
|
3681
|
+
const [expanded, setExpanded] = (0, import_react15.useState)(false);
|
|
3682
|
+
const [expandedDraft, setExpandedDraft] = (0, import_react15.useState)("");
|
|
3293
3683
|
const floatingPlaceholder = usePlaceholderMode(placeholderMode) === "floating" && Boolean(placeholder);
|
|
3294
3684
|
const hintId = `${inputId}-hint`;
|
|
3295
3685
|
const describedBy = [props["aria-describedby"], hint ? hintId : null].filter(Boolean).join(" ") || void 0;
|
|
@@ -3325,7 +3715,7 @@ var Input = (0, import_react13.forwardRef)(function Input2({
|
|
|
3325
3715
|
event.preventDefault();
|
|
3326
3716
|
localRef.current?.focus({ preventScroll: true });
|
|
3327
3717
|
}
|
|
3328
|
-
const input = /* @__PURE__ */ (0,
|
|
3718
|
+
const input = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3329
3719
|
"input",
|
|
3330
3720
|
{
|
|
3331
3721
|
...withTitleTooltip(props),
|
|
@@ -3342,15 +3732,15 @@ var Input = (0, import_react13.forwardRef)(function Input2({
|
|
|
3342
3732
|
onChange: handleChange
|
|
3343
3733
|
}
|
|
3344
3734
|
);
|
|
3345
|
-
const control = /* @__PURE__ */ (0,
|
|
3346
|
-
prefix ? /* @__PURE__ */ (0,
|
|
3347
|
-
floatingPlaceholder ? /* @__PURE__ */ (0,
|
|
3735
|
+
const control = /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { onMouseDown: handleControlMouseDown, className: `sia-input-control sia-input-control--${size} sia-input-control--${status}${floatingPlaceholder ? " sia-input-control--floating" : ""}${floatingPlaceholder && hasValue ? " is-filled" : ""}${disabled ? " is-disabled" : ""}`, children: [
|
|
3736
|
+
prefix ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "sia-input-control__affix", children: prefix }) : null,
|
|
3737
|
+
floatingPlaceholder ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "sia-input-control__input-wrap", children: [
|
|
3348
3738
|
input,
|
|
3349
|
-
/* @__PURE__ */ (0,
|
|
3739
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "sia-input-control__floating-placeholder", "aria-hidden": "true", children: placeholder })
|
|
3350
3740
|
] }) : input,
|
|
3351
|
-
allowClear && hasValue && !disabled ? /* @__PURE__ */ (0,
|
|
3352
|
-
suffix ? /* @__PURE__ */ (0,
|
|
3353
|
-
expandable && !disabled && !props.readOnly && (!props.type || props.type === "text") ? /* @__PURE__ */ (0,
|
|
3741
|
+
allowClear && hasValue && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { className: "sia-input-control__clear", type: "button", "aria-label": "\u6E05\u7A7A\u8F93\u5165", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
|
|
3742
|
+
suffix ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "sia-input-control__affix", children: suffix }) : null,
|
|
3743
|
+
expandable && !disabled && !props.readOnly && (!props.type || props.type === "text") ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3354
3744
|
"button",
|
|
3355
3745
|
{
|
|
3356
3746
|
type: "button",
|
|
@@ -3362,15 +3752,15 @@ var Input = (0, import_react13.forwardRef)(function Input2({
|
|
|
3362
3752
|
setExpandedDraft(currentText);
|
|
3363
3753
|
setExpanded(true);
|
|
3364
3754
|
},
|
|
3365
|
-
children: /* @__PURE__ */ (0,
|
|
3755
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { name: "expand", size: 15 })
|
|
3366
3756
|
}
|
|
3367
3757
|
) : null,
|
|
3368
|
-
showCount ? /* @__PURE__ */ (0,
|
|
3758
|
+
showCount ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: `sia-input-control__count${maxLength !== void 0 && currentText.length >= maxLength ? " is-limit" : ""}`, "aria-live": "polite", children: [
|
|
3369
3759
|
currentText.length,
|
|
3370
3760
|
maxLength !== void 0 ? `/${maxLength}` : null
|
|
3371
3761
|
] }) : null
|
|
3372
3762
|
] });
|
|
3373
|
-
const editor = expandable ? /* @__PURE__ */ (0,
|
|
3763
|
+
const editor = expandable ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3374
3764
|
Modal2,
|
|
3375
3765
|
{
|
|
3376
3766
|
open: expanded,
|
|
@@ -3391,7 +3781,7 @@ var Input = (0, import_react13.forwardRef)(function Input2({
|
|
|
3391
3781
|
setUncontrolledValue(next);
|
|
3392
3782
|
setExpanded(false);
|
|
3393
3783
|
},
|
|
3394
|
-
children: /* @__PURE__ */ (0,
|
|
3784
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3395
3785
|
TextArea,
|
|
3396
3786
|
{
|
|
3397
3787
|
"aria-label": "\u5C55\u5F00\u7F16\u8F91\u5185\u5BB9",
|
|
@@ -3407,32 +3797,71 @@ var Input = (0, import_react13.forwardRef)(function Input2({
|
|
|
3407
3797
|
)
|
|
3408
3798
|
}
|
|
3409
3799
|
) : null;
|
|
3410
|
-
if (!label && !hint) return /* @__PURE__ */ (0,
|
|
3411
|
-
/* @__PURE__ */ (0,
|
|
3800
|
+
if (!label && !hint) return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
3801
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `sia-field ${className}`.trim(), children: control }),
|
|
3412
3802
|
editor
|
|
3413
3803
|
] });
|
|
3414
|
-
return /* @__PURE__ */ (0,
|
|
3415
|
-
/* @__PURE__ */ (0,
|
|
3416
|
-
label ? /* @__PURE__ */ (0,
|
|
3804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
3805
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: `sia-field ${className}`.trim(), children: [
|
|
3806
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { className: "sia-field__label", htmlFor: inputId, children: label }) : null,
|
|
3417
3807
|
control,
|
|
3418
|
-
hint ? /* @__PURE__ */ (0,
|
|
3808
|
+
hint ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id: hintId, className: `sia-field__hint sia-field__hint--${status}`, children: hint }) : null
|
|
3419
3809
|
] }),
|
|
3420
3810
|
editor
|
|
3421
3811
|
] });
|
|
3422
3812
|
});
|
|
3423
3813
|
|
|
3814
|
+
// src/components/usePressFeedback.ts
|
|
3815
|
+
var import_react16 = require("react");
|
|
3816
|
+
function usePressFeedback() {
|
|
3817
|
+
const running = (0, import_react16.useRef)();
|
|
3818
|
+
const cleanup2 = (0, import_react16.useRef)();
|
|
3819
|
+
(0, import_react16.useEffect)(() => () => cleanup2.current?.(), []);
|
|
3820
|
+
return (node, compact = true) => {
|
|
3821
|
+
if (!node?.animate) return;
|
|
3822
|
+
const media = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
3823
|
+
if (media.matches) return;
|
|
3824
|
+
const from = getComputedStyle(node).scale;
|
|
3825
|
+
cleanup2.current?.();
|
|
3826
|
+
const animation = node.animate([
|
|
3827
|
+
{ scale: from === "none" ? "1" : from, offset: 0 },
|
|
3828
|
+
// 小控件放大过冲和二次回收,避免十几像素的图形回弹难以察觉。
|
|
3829
|
+
{ scale: compact ? ".68" : ".92", offset: 0.18 },
|
|
3830
|
+
{ scale: compact ? "1.34" : "1.08", offset: 0.46 },
|
|
3831
|
+
{ scale: compact ? ".88" : ".96", offset: 0.7 },
|
|
3832
|
+
{ scale: compact ? "1.08" : "1.025", offset: 0.86 },
|
|
3833
|
+
{ scale: "1", offset: 1 }
|
|
3834
|
+
], { duration: compact ? 360 : 320, easing: "cubic-bezier(.3,0,.25,1)" });
|
|
3835
|
+
running.current = animation;
|
|
3836
|
+
const stop = () => {
|
|
3837
|
+
animation.cancel();
|
|
3838
|
+
media.removeEventListener("change", stop);
|
|
3839
|
+
if (running.current === animation) {
|
|
3840
|
+
running.current = void 0;
|
|
3841
|
+
cleanup2.current = void 0;
|
|
3842
|
+
}
|
|
3843
|
+
};
|
|
3844
|
+
cleanup2.current = stop;
|
|
3845
|
+
media.addEventListener("change", stop, { once: true });
|
|
3846
|
+
animation.onfinish = stop;
|
|
3847
|
+
};
|
|
3848
|
+
}
|
|
3849
|
+
|
|
3424
3850
|
// src/components/Checkbox.tsx
|
|
3425
|
-
var
|
|
3426
|
-
var
|
|
3427
|
-
var CheckboxGroupContext = (0,
|
|
3428
|
-
var CheckboxRoot = (0,
|
|
3851
|
+
var import_react17 = require("react");
|
|
3852
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3853
|
+
var CheckboxGroupContext = (0, import_react17.createContext)(null);
|
|
3854
|
+
var CheckboxRoot = (0, import_react17.forwardRef)(function Checkbox({ value, size: sizeProp, shape: shapeProp, indeterminate = false, children, disabled, checked, defaultChecked, className = "", onChange, ...props }, forwardedRef) {
|
|
3429
3855
|
const size = useControlSize(sizeProp);
|
|
3430
|
-
const group = (0,
|
|
3431
|
-
const
|
|
3432
|
-
const
|
|
3856
|
+
const group = (0, import_react17.useContext)(CheckboxGroupContext);
|
|
3857
|
+
const shape = shapeProp ?? group?.shape ?? "square";
|
|
3858
|
+
const localRef = (0, import_react17.useRef)(null);
|
|
3859
|
+
const controlRef = (0, import_react17.useRef)(null);
|
|
3860
|
+
const press = usePressFeedback();
|
|
3861
|
+
const fallbackId = (0, import_react17.useId)();
|
|
3433
3862
|
const grouped = group !== null && value !== void 0;
|
|
3434
3863
|
const currentChecked = grouped ? group.values.includes(value) : checked;
|
|
3435
|
-
(0,
|
|
3864
|
+
(0, import_react17.useEffect)(() => {
|
|
3436
3865
|
if (localRef.current) localRef.current.indeterminate = indeterminate;
|
|
3437
3866
|
}, [indeterminate]);
|
|
3438
3867
|
function setRef(node) {
|
|
@@ -3440,8 +3869,8 @@ var CheckboxRoot = (0, import_react14.forwardRef)(function Checkbox({ value, siz
|
|
|
3440
3869
|
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
3441
3870
|
else if (forwardedRef) forwardedRef.current = node;
|
|
3442
3871
|
}
|
|
3443
|
-
return /* @__PURE__ */ (0,
|
|
3444
|
-
/* @__PURE__ */ (0,
|
|
3872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: `sia-checkbox sia-checkbox--${size} sia-checkbox--${shape}${disabled || group?.disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
|
|
3873
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3445
3874
|
"input",
|
|
3446
3875
|
{
|
|
3447
3876
|
...withTitleTooltip(props),
|
|
@@ -3453,6 +3882,10 @@ var CheckboxRoot = (0, import_react14.forwardRef)(function Checkbox({ value, siz
|
|
|
3453
3882
|
disabled: disabled || group?.disabled,
|
|
3454
3883
|
checked: currentChecked,
|
|
3455
3884
|
defaultChecked: grouped ? void 0 : defaultChecked,
|
|
3885
|
+
onClick: (event) => {
|
|
3886
|
+
props.onClick?.(event);
|
|
3887
|
+
if (!event.defaultPrevented && !event.currentTarget.disabled) press(controlRef.current);
|
|
3888
|
+
},
|
|
3456
3889
|
"aria-checked": indeterminate ? "mixed" : currentChecked,
|
|
3457
3890
|
onChange: (event) => {
|
|
3458
3891
|
if (grouped) group.toggle(value, event.currentTarget.checked);
|
|
@@ -3460,12 +3893,13 @@ var CheckboxRoot = (0, import_react14.forwardRef)(function Checkbox({ value, siz
|
|
|
3460
3893
|
}
|
|
3461
3894
|
}
|
|
3462
3895
|
),
|
|
3463
|
-
/* @__PURE__ */ (0,
|
|
3464
|
-
children !== void 0 ? /* @__PURE__ */ (0,
|
|
3896
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { ref: controlRef, className: "sia-checkbox__control", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", {}) }),
|
|
3897
|
+
children !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "sia-checkbox__label", children }) : null
|
|
3465
3898
|
] });
|
|
3466
3899
|
});
|
|
3467
3900
|
function CheckboxGroup({
|
|
3468
3901
|
size: sizeProp,
|
|
3902
|
+
shape = "square",
|
|
3469
3903
|
columns,
|
|
3470
3904
|
direction = "horizontal",
|
|
3471
3905
|
gap,
|
|
@@ -3485,7 +3919,8 @@ function CheckboxGroup({
|
|
|
3485
3919
|
gap: gap === void 0 ? void 0 : typeof gap === "number" ? Math.max(0, gap) : `${Math.max(0, gap[0])}px ${Math.max(0, gap[1])}px`
|
|
3486
3920
|
};
|
|
3487
3921
|
const [values, setValues] = useControllableState({ value, defaultValue, onChange });
|
|
3488
|
-
const context = (0,
|
|
3922
|
+
const context = (0, import_react17.useMemo)(() => ({
|
|
3923
|
+
shape,
|
|
3489
3924
|
values,
|
|
3490
3925
|
disabled,
|
|
3491
3926
|
name,
|
|
@@ -3493,11 +3928,11 @@ function CheckboxGroup({
|
|
|
3493
3928
|
const next = checked ? values.includes(optionValue) ? values : [...values, optionValue] : values.filter((item) => item !== optionValue);
|
|
3494
3929
|
setValues(next);
|
|
3495
3930
|
}
|
|
3496
|
-
}), [disabled, name, setValues, values]);
|
|
3497
|
-
return /* @__PURE__ */ (0,
|
|
3931
|
+
}), [disabled, name, setValues, values, shape]);
|
|
3932
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ControlSizeContext.Provider, { value: size, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CheckboxGroupContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `sia-checkbox-group${gridColumns ? " sia-checkbox-group--grid" : direction === "vertical" ? " sia-checkbox-group--vertical" : ""} ${className}`.trim(), style: layoutStyle, role: "group", children: [
|
|
3498
3933
|
options?.map((option) => {
|
|
3499
3934
|
const normalized = typeof option === "object" ? option : { label: String(option), value: option };
|
|
3500
|
-
return /* @__PURE__ */ (0,
|
|
3935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CheckboxRoot, { value: normalized.value, disabled: normalized.disabled, children: normalized.label }, normalized.value);
|
|
3501
3936
|
}),
|
|
3502
3937
|
children
|
|
3503
3938
|
] }) }) });
|
|
@@ -3508,12 +3943,12 @@ var Checkbox2 = Object.assign(CheckboxRoot, {
|
|
|
3508
3943
|
});
|
|
3509
3944
|
|
|
3510
3945
|
// src/components/SelectionPanel.tsx
|
|
3511
|
-
var
|
|
3946
|
+
var import_react19 = require("react");
|
|
3512
3947
|
|
|
3513
3948
|
// src/components/FloatingDisplay.tsx
|
|
3514
|
-
var
|
|
3949
|
+
var import_react18 = require("react");
|
|
3515
3950
|
var import_react_dom3 = require("react-dom");
|
|
3516
|
-
var
|
|
3951
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3517
3952
|
var FLOATING_GAP = 9;
|
|
3518
3953
|
var FLOATING_VIEWPORT_PADDING = 8;
|
|
3519
3954
|
var FLOATING_ARROW_EDGE_OFFSET = 16;
|
|
@@ -3598,23 +4033,24 @@ function Floating({
|
|
|
3598
4033
|
role = "tooltip",
|
|
3599
4034
|
onOpenChange
|
|
3600
4035
|
}) {
|
|
3601
|
-
const rootRef = (0,
|
|
3602
|
-
const triggerElementRef = (0,
|
|
3603
|
-
const overlayRef = (0,
|
|
3604
|
-
const enterTimer = (0,
|
|
3605
|
-
const leaveTimer = (0,
|
|
3606
|
-
const contentId = (0,
|
|
4036
|
+
const rootRef = (0, import_react18.useRef)(null);
|
|
4037
|
+
const triggerElementRef = (0, import_react18.useRef)(null);
|
|
4038
|
+
const overlayRef = (0, import_react18.useRef)(null);
|
|
4039
|
+
const enterTimer = (0, import_react18.useRef)();
|
|
4040
|
+
const leaveTimer = (0, import_react18.useRef)();
|
|
4041
|
+
const contentId = (0, import_react18.useId)();
|
|
3607
4042
|
const triggers = Array.isArray(trigger) ? trigger : [trigger];
|
|
3608
4043
|
const [visible, setVisible] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
|
|
3609
|
-
const [position, setPosition] = (0,
|
|
3610
|
-
const
|
|
3611
|
-
(0,
|
|
3612
|
-
|
|
4044
|
+
const [position, setPosition] = (0, import_react18.useState)();
|
|
4045
|
+
const motion = useOverlayMotion(!!visible, overlayRef, "tooltip", "bottom", !!position, void 0, !overlayClassName.includes("sia-form-item__error-popover"));
|
|
4046
|
+
const [portalContainer, setPortalContainer] = (0, import_react18.useState)(null);
|
|
4047
|
+
(0, import_react18.useLayoutEffect)(() => {
|
|
4048
|
+
if (!motion.present) return;
|
|
3613
4049
|
setPortalContainer(rootRef.current?.closest(".sia-modal-root, .sia-drawer-root") ?? document.body);
|
|
3614
4050
|
});
|
|
3615
|
-
const setVisibleRef = (0,
|
|
4051
|
+
const setVisibleRef = (0, import_react18.useRef)(setVisible);
|
|
3616
4052
|
setVisibleRef.current = setVisible;
|
|
3617
|
-
const closeSelfRef = (0,
|
|
4053
|
+
const closeSelfRef = (0, import_react18.useRef)();
|
|
3618
4054
|
if (!closeSelfRef.current) closeSelfRef.current = () => setVisibleRef.current(false);
|
|
3619
4055
|
const exclusiveTooltip = role === "tooltip" && triggers.includes("hover");
|
|
3620
4056
|
function openNow() {
|
|
@@ -3642,7 +4078,7 @@ function Floating({
|
|
|
3642
4078
|
if (delay <= 0) closeNow();
|
|
3643
4079
|
else leaveTimer.current = window.setTimeout(closeNow, delay * 1e3);
|
|
3644
4080
|
}
|
|
3645
|
-
(0,
|
|
4081
|
+
(0, import_react18.useEffect)(() => {
|
|
3646
4082
|
if (!visible || !triggers.includes("click")) return;
|
|
3647
4083
|
const close = (event) => {
|
|
3648
4084
|
const target = event.target;
|
|
@@ -3651,8 +4087,8 @@ function Floating({
|
|
|
3651
4087
|
document.addEventListener("pointerdown", close);
|
|
3652
4088
|
return () => document.removeEventListener("pointerdown", close);
|
|
3653
4089
|
}, [triggers.join("|"), visible]);
|
|
3654
|
-
(0,
|
|
3655
|
-
if (!
|
|
4090
|
+
(0, import_react18.useLayoutEffect)(() => {
|
|
4091
|
+
if (!motion.present) {
|
|
3656
4092
|
setPosition(void 0);
|
|
3657
4093
|
return;
|
|
3658
4094
|
}
|
|
@@ -3666,36 +4102,46 @@ function Floating({
|
|
|
3666
4102
|
const anchor2 = getAnchor();
|
|
3667
4103
|
if (anchor2) {
|
|
3668
4104
|
const rect = anchor2.getBoundingClientRect();
|
|
3669
|
-
const next = resolveFloatingPosition(rect, overlayRef.current.
|
|
4105
|
+
const next = resolveFloatingPosition(rect, { width: overlayRef.current.offsetWidth, height: overlayRef.current.offsetHeight }, placement, typeof arrow === "object" && !!arrow.pointAtCenter, autoAdjustOverflow);
|
|
3670
4106
|
next.hidden = isFloatingAnchorHidden(anchor2, rect) || isAnchorBehindOverlay(anchor2);
|
|
3671
|
-
setPosition(next);
|
|
4107
|
+
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);
|
|
3672
4108
|
}
|
|
3673
4109
|
};
|
|
3674
4110
|
update();
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
4111
|
+
let frame = 0;
|
|
4112
|
+
const schedule = () => {
|
|
4113
|
+
if (!frame) frame = requestAnimationFrame(() => {
|
|
4114
|
+
frame = 0;
|
|
4115
|
+
update();
|
|
4116
|
+
});
|
|
4117
|
+
};
|
|
4118
|
+
const unsubscribeLayers = subscribeOverlayLayers(schedule);
|
|
4119
|
+
window.addEventListener("resize", schedule);
|
|
4120
|
+
window.addEventListener("scroll", schedule, true);
|
|
4121
|
+
window.addEventListener("animationend", schedule, true);
|
|
4122
|
+
window.addEventListener("transitionend", schedule, true);
|
|
4123
|
+
window.addEventListener("sia-overlay-motion-end", schedule);
|
|
4124
|
+
const observer = new ResizeObserver(schedule);
|
|
3681
4125
|
if (rootRef.current) observer.observe(rootRef.current);
|
|
3682
4126
|
const anchor = getAnchor();
|
|
3683
4127
|
if (anchor) observer.observe(anchor);
|
|
3684
4128
|
if (overlayRef.current) observer.observe(overlayRef.current);
|
|
3685
4129
|
return () => {
|
|
3686
|
-
window.removeEventListener("resize",
|
|
3687
|
-
window.removeEventListener("scroll",
|
|
3688
|
-
window.removeEventListener("animationend",
|
|
3689
|
-
window.removeEventListener("transitionend",
|
|
4130
|
+
window.removeEventListener("resize", schedule);
|
|
4131
|
+
window.removeEventListener("scroll", schedule, true);
|
|
4132
|
+
window.removeEventListener("animationend", schedule, true);
|
|
4133
|
+
window.removeEventListener("transitionend", schedule, true);
|
|
4134
|
+
window.removeEventListener("sia-overlay-motion-end", schedule);
|
|
4135
|
+
cancelAnimationFrame(frame);
|
|
3690
4136
|
observer.disconnect();
|
|
3691
4137
|
unsubscribeLayers();
|
|
3692
4138
|
};
|
|
3693
|
-
}, [children, content, placement,
|
|
3694
|
-
(0,
|
|
4139
|
+
}, [children, content, placement, motion.present, portalContainer, autoAdjustOverflow, typeof arrow === "object" && arrow.pointAtCenter]);
|
|
4140
|
+
(0, import_react18.useEffect)(() => () => {
|
|
3695
4141
|
clearTimers();
|
|
3696
4142
|
if (activeTooltipClose === closeSelfRef.current) activeTooltipClose = void 0;
|
|
3697
4143
|
}, []);
|
|
3698
|
-
const child = (0,
|
|
4144
|
+
const child = (0, import_react18.cloneElement)(children, {
|
|
3699
4145
|
...triggers.includes("hover") ? { onMouseEnter: (event) => {
|
|
3700
4146
|
triggerElementRef.current = event.currentTarget;
|
|
3701
4147
|
children.props.onMouseEnter?.(event);
|
|
@@ -3720,13 +4166,15 @@ function Floating({
|
|
|
3720
4166
|
} } : {},
|
|
3721
4167
|
"aria-describedby": visible ? contentId : void 0
|
|
3722
4168
|
});
|
|
3723
|
-
const overlay =
|
|
3724
|
-
/* @__PURE__ */ (0,
|
|
4169
|
+
const overlay = motion.present && content !== null && content !== void 0 && typeof document !== "undefined" ? (0, import_react_dom3.createPortal)(
|
|
4170
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
3725
4171
|
"span",
|
|
3726
4172
|
{
|
|
3727
4173
|
ref: overlayRef,
|
|
3728
4174
|
id: contentId,
|
|
3729
4175
|
role,
|
|
4176
|
+
"data-state": motion.closing ? "closing" : "open",
|
|
4177
|
+
"aria-hidden": motion.closing || void 0,
|
|
3730
4178
|
"data-custom-color": color ? "" : void 0,
|
|
3731
4179
|
className: `sia-floating__overlay sia-floating__overlay--${position?.placement ?? normalizeFloatingPlacement(placement)} ${overlayClassName}`.trim(),
|
|
3732
4180
|
style: {
|
|
@@ -3735,32 +4183,40 @@ function Floating({
|
|
|
3735
4183
|
"--sia-floating-arrow-y": position?.arrowY == null ? void 0 : `${position.arrowY}px`,
|
|
3736
4184
|
top: position?.top ?? 0,
|
|
3737
4185
|
left: position?.left ?? 0,
|
|
3738
|
-
visibility: position && !position.hidden ? "visible" : "hidden"
|
|
4186
|
+
visibility: position && !position.hidden ? "visible" : "hidden",
|
|
4187
|
+
animation: "none",
|
|
4188
|
+
pointerEvents: motion.closing ? "none" : void 0
|
|
3739
4189
|
},
|
|
3740
4190
|
onMouseEnter: triggers.includes("hover") ? () => show() : void 0,
|
|
3741
4191
|
onMouseLeave: triggers.includes("hover") ? () => hide(mouseLeaveDelay) : void 0,
|
|
3742
4192
|
children: [
|
|
3743
4193
|
content,
|
|
3744
|
-
arrow ? /* @__PURE__ */ (0,
|
|
4194
|
+
arrow ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "sia-floating__arrow" }) : null
|
|
3745
4195
|
]
|
|
3746
4196
|
}
|
|
3747
4197
|
),
|
|
3748
4198
|
portalContainer ?? document.body
|
|
3749
4199
|
) : null;
|
|
3750
|
-
return /* @__PURE__ */ (0,
|
|
3751
|
-
/* @__PURE__ */ (0,
|
|
4200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
4201
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { ref: rootRef, className: `sia-floating ${className}`.trim(), children: child }),
|
|
3752
4202
|
overlay
|
|
3753
4203
|
] });
|
|
3754
4204
|
}
|
|
3755
4205
|
function Tooltip(props) {
|
|
3756
|
-
return /* @__PURE__ */ (0,
|
|
4206
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Floating, { ...props, content: props.title });
|
|
4207
|
+
}
|
|
4208
|
+
|
|
4209
|
+
// src/components/selectionValues.ts
|
|
4210
|
+
function normalizeSelectionValues(values, options) {
|
|
4211
|
+
const known = new Set(options.filter((option) => option.optionType !== "divider").map((option) => option.value));
|
|
4212
|
+
return values.filter((value) => typeof value === "number" || value.trim().length > 0 || known.has(value));
|
|
3757
4213
|
}
|
|
3758
4214
|
|
|
3759
4215
|
// src/components/SelectionPanel.tsx
|
|
3760
|
-
var
|
|
4216
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3761
4217
|
function SelectionPanel({
|
|
3762
4218
|
options,
|
|
3763
|
-
value,
|
|
4219
|
+
value: rawValue,
|
|
3764
4220
|
onChange,
|
|
3765
4221
|
multiple = false,
|
|
3766
4222
|
allowDeselect = false,
|
|
@@ -3779,26 +4235,27 @@ function SelectionPanel({
|
|
|
3779
4235
|
autoFocusSearch = false,
|
|
3780
4236
|
groupCheckable = false
|
|
3781
4237
|
}) {
|
|
3782
|
-
const
|
|
4238
|
+
const value = (0, import_react19.useMemo)(() => normalizeSelectionValues(rawValue, options), [rawValue, options]);
|
|
4239
|
+
const [localSearch, setLocalSearch] = (0, import_react19.useState)("");
|
|
3783
4240
|
const search = searchValue ?? localSearch;
|
|
3784
|
-
const [scrollTop, setScrollTop] = (0,
|
|
3785
|
-
const [active, setActive] = (0,
|
|
3786
|
-
const [keyboardActive, setKeyboardActive] = (0,
|
|
3787
|
-
const [deselectedHover, setDeselectedHover] = (0,
|
|
3788
|
-
const listRef = (0,
|
|
3789
|
-
const id = (0,
|
|
3790
|
-
const selected = (0,
|
|
4241
|
+
const [scrollTop, setScrollTop] = (0, import_react19.useState)(0);
|
|
4242
|
+
const [active, setActive] = (0, import_react19.useState)();
|
|
4243
|
+
const [keyboardActive, setKeyboardActive] = (0, import_react19.useState)(false);
|
|
4244
|
+
const [deselectedHover, setDeselectedHover] = (0, import_react19.useState)();
|
|
4245
|
+
const listRef = (0, import_react19.useRef)(null);
|
|
4246
|
+
const id = (0, import_react19.useId)();
|
|
4247
|
+
const selected = (0, import_react19.useMemo)(() => new Set(value), [value]);
|
|
3791
4248
|
const count = Math.max(1, Math.floor(columns));
|
|
3792
|
-
const allOptions = (0,
|
|
4249
|
+
const allOptions = (0, import_react19.useMemo)(() => {
|
|
3793
4250
|
if (!includeUnknownValues) return [...options];
|
|
3794
4251
|
const known = new Set(options.filter((option) => option.optionType !== "divider").map((option) => option.value));
|
|
3795
4252
|
return [...value.filter((item) => !known.has(item)).map((item) => ({ value: item, label: String(item), group: "\u81EA\u5B9A\u4E49\u503C" })), ...options];
|
|
3796
4253
|
}, [options, value, includeUnknownValues]);
|
|
3797
|
-
const filtered = (0,
|
|
4254
|
+
const filtered = (0, import_react19.useMemo)(
|
|
3798
4255
|
() => allOptions.filter((option) => (!selectedOnly || selected.has(option.value)) && (!search || option.optionType !== "divider" && [option.label, option.value].some((text) => String(text ?? "").toLowerCase().includes(search.toLowerCase())))),
|
|
3799
4256
|
[allOptions, selectedOnly, selected, search]
|
|
3800
4257
|
);
|
|
3801
|
-
const rows = (0,
|
|
4258
|
+
const rows = (0, import_react19.useMemo)(() => {
|
|
3802
4259
|
const groups = /* @__PURE__ */ new Map();
|
|
3803
4260
|
filtered.forEach((option) => {
|
|
3804
4261
|
const items = groups.get(option.group) ?? [];
|
|
@@ -3824,7 +4281,7 @@ function SelectionPanel({
|
|
|
3824
4281
|
const virtual = filtered.length > 100;
|
|
3825
4282
|
const renderedRows = virtual ? rows.filter((row) => row.top + row.height >= scrollTop - 100 && row.top <= scrollTop + maxHeight + 100) : rows;
|
|
3826
4283
|
const enabled = filtered.filter((option) => !option.disabled && option.optionType !== "divider");
|
|
3827
|
-
(0,
|
|
4284
|
+
(0, import_react19.useEffect)(() => {
|
|
3828
4285
|
setScrollTop(0);
|
|
3829
4286
|
if (listRef.current) listRef.current.scrollTop = 0;
|
|
3830
4287
|
setActive(void 0);
|
|
@@ -3851,7 +4308,7 @@ function SelectionPanel({
|
|
|
3851
4308
|
if (!multiple || !groupCheckable) return title;
|
|
3852
4309
|
const editable = items.filter((option) => !option.disabled && option.optionType !== "divider");
|
|
3853
4310
|
const all = editable.length > 0 && editable.every((option) => selected.has(option.value));
|
|
3854
|
-
return /* @__PURE__ */ (0,
|
|
4311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3855
4312
|
Checkbox2,
|
|
3856
4313
|
{
|
|
3857
4314
|
checked: all,
|
|
@@ -3867,7 +4324,7 @@ function SelectionPanel({
|
|
|
3867
4324
|
);
|
|
3868
4325
|
}
|
|
3869
4326
|
function help(option) {
|
|
3870
|
-
return option.description != null && option.description !== false ? /* @__PURE__ */ (0,
|
|
4327
|
+
return option.description != null && option.description !== false ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Tooltip, { title: option.description, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3871
4328
|
"span",
|
|
3872
4329
|
{
|
|
3873
4330
|
role: "img",
|
|
@@ -3879,13 +4336,13 @@ function SelectionPanel({
|
|
|
3879
4336
|
},
|
|
3880
4337
|
onKeyDown: (event) => event.stopPropagation(),
|
|
3881
4338
|
style: { display: "inline-flex", marginInlineStart: 4 },
|
|
3882
|
-
children: /* @__PURE__ */ (0,
|
|
4339
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Icon, { name: "help-circle", size: 14 })
|
|
3883
4340
|
}
|
|
3884
4341
|
) }) : null;
|
|
3885
4342
|
}
|
|
3886
|
-
return /* @__PURE__ */ (0,
|
|
3887
|
-
/* @__PURE__ */ (0,
|
|
3888
|
-
showSearch && /* @__PURE__ */ (0,
|
|
4343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "sia-selection-panel", children: [
|
|
4344
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FloatingScrollbarProvider, { targetRef: listRef }),
|
|
4345
|
+
showSearch && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3889
4346
|
Input,
|
|
3890
4347
|
{
|
|
3891
4348
|
"aria-label": "\u641C\u7D22\u9009\u9879",
|
|
@@ -3899,17 +4356,17 @@ function SelectionPanel({
|
|
|
3899
4356
|
}
|
|
3900
4357
|
}
|
|
3901
4358
|
),
|
|
3902
|
-
multiple && showActions && /* @__PURE__ */ (0,
|
|
3903
|
-
/* @__PURE__ */ (0,
|
|
3904
|
-
/* @__PURE__ */ (0,
|
|
3905
|
-
/* @__PURE__ */ (0,
|
|
3906
|
-
/* @__PURE__ */ (0,
|
|
4359
|
+
multiple && showActions && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "sia-selection-panel__actions", children: [
|
|
4360
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !enabled.length, onClick: () => batch("all"), children: "\u5168\u9009" }),
|
|
4361
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !enabled.length, onClick: () => batch("invert"), children: "\u53CD\u9009" }),
|
|
4362
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !value.length, onClick: () => batch("clear"), children: "\u6E05\u7A7A" }),
|
|
4363
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { children: [
|
|
3907
4364
|
"\u5DF2\u9009 ",
|
|
3908
4365
|
value.length,
|
|
3909
4366
|
" \u9879"
|
|
3910
4367
|
] })
|
|
3911
4368
|
] }),
|
|
3912
|
-
/* @__PURE__ */ (0,
|
|
4369
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3913
4370
|
"div",
|
|
3914
4371
|
{
|
|
3915
4372
|
ref: listRef,
|
|
@@ -3946,12 +4403,12 @@ function SelectionPanel({
|
|
|
3946
4403
|
toggle(enabled[index], true);
|
|
3947
4404
|
}
|
|
3948
4405
|
},
|
|
3949
|
-
children: loading ? /* @__PURE__ */ (0,
|
|
4406
|
+
children: loading ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { role: "status", children: "\u52A0\u8F7D\u4E2D\u2026" }) : !rows.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "sia-selection-panel__empty", children: "\u6682\u65E0\u5339\u914D\u9009\u9879" }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { height: totalHeight, position: "relative" }, children: renderedRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3950
4407
|
"div",
|
|
3951
4408
|
{
|
|
3952
4409
|
className: row.title !== void 0 ? "sia-selection-panel__group" : "sia-selection-panel__row",
|
|
3953
4410
|
style: { position: "absolute", top: row.top, height: row.height, width: "100%", gridTemplateColumns: `repeat(${count}, minmax(0, 1fr))` },
|
|
3954
|
-
children: row.title !== void 0 ? groupHeading(row.title, row.items ?? []) : row.items?.map((option, index) => option.optionType === "divider" ? /* @__PURE__ */ (0,
|
|
4411
|
+
children: row.title !== void 0 ? groupHeading(row.title, row.items ?? []) : row.items?.map((option, index) => option.optionType === "divider" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { role: "separator", className: "sia-selection-panel__divider" }, `divider-${index}`) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Tooltip, { title: option.disabled ? option.disabledTip : void 0, placement: "right", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3955
4412
|
"div",
|
|
3956
4413
|
{
|
|
3957
4414
|
role: "option",
|
|
@@ -3967,18 +4424,18 @@ function SelectionPanel({
|
|
|
3967
4424
|
onClick: (event) => {
|
|
3968
4425
|
if (!event.target.closest(".sia-checkbox")) toggle(option);
|
|
3969
4426
|
},
|
|
3970
|
-
children: multiple ? /* @__PURE__ */ (0,
|
|
3971
|
-
/* @__PURE__ */ (0,
|
|
4427
|
+
children: multiple ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Checkbox2, { checked: selected.has(option.value), disabled: disabled || loading || option.disabled, tabIndex: -1, onChange: () => toggle(option), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "sia-selection-panel__text", children: [
|
|
4428
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "sia-selection-panel__label", children: [
|
|
3972
4429
|
showValue || displayField === "label" ? option.label : String(option.value),
|
|
3973
4430
|
help(option)
|
|
3974
4431
|
] }),
|
|
3975
|
-
showValue && /* @__PURE__ */ (0,
|
|
3976
|
-
] }) }) : /* @__PURE__ */ (0,
|
|
3977
|
-
/* @__PURE__ */ (0,
|
|
4432
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: String(option.value) })
|
|
4433
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "sia-selection-panel__text", children: [
|
|
4434
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "sia-selection-panel__label", children: [
|
|
3978
4435
|
showValue || displayField === "label" ? option.label : String(option.value),
|
|
3979
4436
|
help(option)
|
|
3980
4437
|
] }),
|
|
3981
|
-
showValue && /* @__PURE__ */ (0,
|
|
4438
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: String(option.value) })
|
|
3982
4439
|
] })
|
|
3983
4440
|
}
|
|
3984
4441
|
) }, `${typeof option.value}-${option.value}`))
|
|
@@ -3991,14 +4448,14 @@ function SelectionPanel({
|
|
|
3991
4448
|
}
|
|
3992
4449
|
|
|
3993
4450
|
// src/components/OverflowTags.tsx
|
|
3994
|
-
var
|
|
3995
|
-
var
|
|
3996
|
-
function OverflowTags({ items, maxCount, className = "", tagClassName, restClassName = "" }) {
|
|
3997
|
-
const rootRef = (0,
|
|
3998
|
-
const measureRef = (0,
|
|
4451
|
+
var import_react20 = require("react");
|
|
4452
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
4453
|
+
function OverflowTags({ items, maxCount, expandToFit = false, className = "", tagClassName, restClassName = "" }) {
|
|
4454
|
+
const rootRef = (0, import_react20.useRef)(null);
|
|
4455
|
+
const measureRef = (0, import_react20.useRef)(null);
|
|
3999
4456
|
const limit = Math.min(items.length, Math.max(0, Math.floor(maxCount) || 0));
|
|
4000
|
-
const [
|
|
4001
|
-
(0,
|
|
4457
|
+
const [layout, setLayout] = (0, import_react20.useState)({ count: 0, minimumWidths: [] });
|
|
4458
|
+
(0, import_react20.useLayoutEffect)(() => {
|
|
4002
4459
|
const root = rootRef.current;
|
|
4003
4460
|
const measure = measureRef.current;
|
|
4004
4461
|
if (!root || !measure) return;
|
|
@@ -4012,24 +4469,36 @@ function OverflowTags({ items, maxCount, className = "", tagClassName, restClass
|
|
|
4012
4469
|
const rest = count2 < items.length ? gap + widths[limit + count2] : 0;
|
|
4013
4470
|
if (used + rest <= root.clientWidth) fitting = count2;
|
|
4014
4471
|
}
|
|
4015
|
-
|
|
4472
|
+
const minimumWidths = Array.from({ length: fitting }, (_, index) => {
|
|
4473
|
+
const tag = measure.children[index];
|
|
4474
|
+
return expandToFit && tag.scrollWidth > tag.clientWidth ? widths[index] : 0;
|
|
4475
|
+
});
|
|
4476
|
+
setLayout((previous) => previous.count === fitting && minimumWidths.every((width, index) => previous.minimumWidths[index] === width) ? previous : { count: fitting, minimumWidths });
|
|
4016
4477
|
};
|
|
4017
4478
|
update();
|
|
4018
4479
|
const observer = new ResizeObserver(update);
|
|
4019
4480
|
observer.observe(root);
|
|
4020
4481
|
for (const child of measure.children) observer.observe(child);
|
|
4021
4482
|
return () => observer.disconnect();
|
|
4022
|
-
}, [items, limit]);
|
|
4023
|
-
const count = Math.min(
|
|
4024
|
-
return /* @__PURE__ */ (0,
|
|
4025
|
-
items.slice(0, count).map((item) => /* @__PURE__ */ (0,
|
|
4026
|
-
|
|
4483
|
+
}, [items, limit, expandToFit]);
|
|
4484
|
+
const count = Math.min(layout.count, limit);
|
|
4485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { ref: rootRef, className: `sia-overflow-tags ${className}`.trim(), children: [
|
|
4486
|
+
items.slice(0, count).map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4487
|
+
"span",
|
|
4488
|
+
{
|
|
4489
|
+
className: tagClassName,
|
|
4490
|
+
style: expandToFit && layout.minimumWidths[index] ? { flex: "0 1 auto", minWidth: layout.minimumWidths[index], maxWidth: "none" } : void 0,
|
|
4491
|
+
children: item.label
|
|
4492
|
+
},
|
|
4493
|
+
item.key
|
|
4494
|
+
)),
|
|
4495
|
+
items.length > count ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: `${tagClassName} sia-overflow-tags__rest ${restClassName}`.trim(), children: [
|
|
4027
4496
|
"+",
|
|
4028
4497
|
items.length - count
|
|
4029
4498
|
] }) : null,
|
|
4030
|
-
/* @__PURE__ */ (0,
|
|
4031
|
-
items.slice(0, limit).map((item) => /* @__PURE__ */ (0,
|
|
4032
|
-
Array.from({ length: limit + 1 }, (_, index) => /* @__PURE__ */ (0,
|
|
4499
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { ref: measureRef, className: "sia-overflow-tags__measure", "aria-hidden": "true", children: [
|
|
4500
|
+
items.slice(0, limit).map((item) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: tagClassName, children: item.label }, item.key)),
|
|
4501
|
+
Array.from({ length: limit + 1 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: `${tagClassName} ${restClassName}`.trim(), children: [
|
|
4033
4502
|
"+",
|
|
4034
4503
|
items.length - index
|
|
4035
4504
|
] }, `rest-${index}`))
|
|
@@ -4038,12 +4507,12 @@ function OverflowTags({ items, maxCount, className = "", tagClassName, restClass
|
|
|
4038
4507
|
}
|
|
4039
4508
|
|
|
4040
4509
|
// src/components/Select.tsx
|
|
4041
|
-
var
|
|
4510
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4042
4511
|
function defaultFilterOption(query, option) {
|
|
4043
4512
|
const keyword = query.toLowerCase();
|
|
4044
4513
|
return [option.label, option.value].some((value) => String(value).toLowerCase().includes(keyword));
|
|
4045
4514
|
}
|
|
4046
|
-
var Select = (0,
|
|
4515
|
+
var Select = (0, import_react21.forwardRef)(function Select2({
|
|
4047
4516
|
options,
|
|
4048
4517
|
mode = "single",
|
|
4049
4518
|
popupMode: popupModeProp,
|
|
@@ -4062,12 +4531,12 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4062
4531
|
showValue = false,
|
|
4063
4532
|
allowInput = false,
|
|
4064
4533
|
inputMaxLength,
|
|
4065
|
-
searchPlaceholder = "\u641C\u7D22\u9009\u9879",
|
|
4534
|
+
searchPlaceholder = allowInput ? "\u8F93\u5165\u6216\u641C\u7D22" : "\u641C\u7D22\u9009\u9879",
|
|
4066
4535
|
onSearch,
|
|
4067
4536
|
filterOption = defaultFilterOption,
|
|
4068
4537
|
showSelectAll = true,
|
|
4069
4538
|
showActions = mode === "multiple",
|
|
4070
|
-
maxTagCount
|
|
4539
|
+
maxTagCount,
|
|
4071
4540
|
virtual = true,
|
|
4072
4541
|
virtualThreshold = 100,
|
|
4073
4542
|
listHeight = 256,
|
|
@@ -4082,27 +4551,27 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4082
4551
|
}, forwardedRef) {
|
|
4083
4552
|
const showSearch = showSearchProp ?? options.length > 15;
|
|
4084
4553
|
const size = useControlSize(sizeProp);
|
|
4085
|
-
const fallbackId = (0,
|
|
4554
|
+
const fallbackId = (0, import_react21.useId)();
|
|
4086
4555
|
const selectId = id ?? fallbackId;
|
|
4087
4556
|
const listboxId = `${selectId}-listbox`;
|
|
4088
|
-
const rootRef = (0,
|
|
4089
|
-
const popupRef = (0,
|
|
4090
|
-
const searchRef = (0,
|
|
4091
|
-
const listRef = (0,
|
|
4092
|
-
const [open, setOpen] = (0,
|
|
4557
|
+
const rootRef = (0, import_react21.useRef)(null);
|
|
4558
|
+
const popupRef = (0, import_react21.useRef)(null);
|
|
4559
|
+
const searchRef = (0, import_react21.useRef)(null);
|
|
4560
|
+
const listRef = (0, import_react21.useRef)(null);
|
|
4561
|
+
const [open, setOpen] = (0, import_react21.useState)(false);
|
|
4093
4562
|
const automaticMode = popupModeProp ?? (options.length > modalThreshold ? "modal" : "dropdown");
|
|
4094
|
-
const [openedMode, setOpenedMode] = (0,
|
|
4563
|
+
const [openedMode, setOpenedMode] = (0, import_react21.useState)(automaticMode);
|
|
4095
4564
|
const popupMode = open ? openedMode : automaticMode;
|
|
4096
|
-
const [modalValues, setModalValues] = (0,
|
|
4097
|
-
const [modalSubmitting, setModalSubmitting] = (0,
|
|
4098
|
-
const modalSubmitLock = (0,
|
|
4099
|
-
const [selectedOnly, setSelectedOnly] = (0,
|
|
4100
|
-
const [query, setQuery] = (0,
|
|
4101
|
-
const [activeIndex, setActiveIndex] = (0,
|
|
4102
|
-
const [scrollTop, setScrollTop] = (0,
|
|
4103
|
-
const [dropdownFontSize, setDropdownFontSize] = (0,
|
|
4104
|
-
const pendingSelectedScroll = (0,
|
|
4105
|
-
const deferredQuery = (0,
|
|
4565
|
+
const [modalValues, setModalValues] = (0, import_react21.useState)([]);
|
|
4566
|
+
const [modalSubmitting, setModalSubmitting] = (0, import_react21.useState)(false);
|
|
4567
|
+
const modalSubmitLock = (0, import_react21.useRef)(false);
|
|
4568
|
+
const [selectedOnly, setSelectedOnly] = (0, import_react21.useState)(false);
|
|
4569
|
+
const [query, setQuery] = (0, import_react21.useState)("");
|
|
4570
|
+
const [activeIndex, setActiveIndex] = (0, import_react21.useState)(-1);
|
|
4571
|
+
const [scrollTop, setScrollTop] = (0, import_react21.useState)(0);
|
|
4572
|
+
const [dropdownFontSize, setDropdownFontSize] = (0, import_react21.useState)();
|
|
4573
|
+
const pendingSelectedScroll = (0, import_react21.useRef)(false);
|
|
4574
|
+
const deferredQuery = (0, import_react21.useDeferredValue)(query.trim());
|
|
4106
4575
|
const initialValue = defaultValue === void 0 ? mode === "multiple" ? [] : null : defaultValue;
|
|
4107
4576
|
const [currentValue, setCurrentValue] = useControllableState({
|
|
4108
4577
|
value,
|
|
@@ -4117,20 +4586,20 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4117
4586
|
}
|
|
4118
4587
|
}
|
|
4119
4588
|
});
|
|
4120
|
-
const selectedValues = (0,
|
|
4589
|
+
const selectedValues = (0, import_react21.useMemo)(() => {
|
|
4121
4590
|
if (currentValue == null || currentValue === "" && !options.some((option) => option.value === "")) return [];
|
|
4122
4591
|
if (mode === "multiple") return Array.isArray(currentValue) ? currentValue : currentValue === null ? [] : [currentValue];
|
|
4123
4592
|
return Array.isArray(currentValue) ? currentValue.slice(0, 1) : currentValue === null ? [] : [currentValue];
|
|
4124
4593
|
}, [currentValue, mode, options]);
|
|
4125
|
-
const selectedValueSet = (0,
|
|
4126
|
-
const availableOptions = (0,
|
|
4594
|
+
const selectedValueSet = (0, import_react21.useMemo)(() => new Set(selectedValues), [selectedValues]);
|
|
4595
|
+
const availableOptions = (0, import_react21.useMemo)(() => {
|
|
4127
4596
|
if (!allowInput) return options;
|
|
4128
4597
|
const optionValueSet = new Set(options.map((option) => option.value));
|
|
4129
4598
|
const selectedCustomOptions = selectedValues.filter((selectedValue) => !optionValueSet.has(selectedValue)).map((selectedValue) => ({ label: String(selectedValue), value: selectedValue }));
|
|
4130
4599
|
return selectedCustomOptions.length ? [...selectedCustomOptions, ...options] : options;
|
|
4131
4600
|
}, [allowInput, options, selectedValues]);
|
|
4132
|
-
const selectedOptions = (0,
|
|
4133
|
-
const filteredOptions = (0,
|
|
4601
|
+
const selectedOptions = (0, import_react21.useMemo)(() => selectedValues.map((selectedValue) => availableOptions.find((option) => option.value === selectedValue)).filter((option) => option !== void 0), [availableOptions, selectedValues]);
|
|
4602
|
+
const filteredOptions = (0, import_react21.useMemo)(() => deferredQuery ? availableOptions.filter((option) => filterOption(deferredQuery, option)) : availableOptions, [availableOptions, deferredQuery, filterOption]);
|
|
4134
4603
|
const inputValue = query.trim();
|
|
4135
4604
|
const exactInputOption = inputValue ? availableOptions.find((option) => String(option.value).toLowerCase() === inputValue.toLowerCase() || typeof option.label === "string" && option.label.toLowerCase() === inputValue.toLowerCase()) : void 0;
|
|
4136
4605
|
const canSubmitInput = allowInput && Boolean(inputValue) && !exactInputOption;
|
|
@@ -4144,7 +4613,7 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4144
4613
|
const renderedOptions = virtualEnabled ? filteredOptions.slice(virtualStart, virtualEnd) : filteredOptions;
|
|
4145
4614
|
const enabledFilteredOptions = filteredOptions.filter((option) => !option.disabled);
|
|
4146
4615
|
const allFilteredSelected = enabledFilteredOptions.length > 0 && enabledFilteredOptions.every((option) => selectedValueSet.has(option.value));
|
|
4147
|
-
(0,
|
|
4616
|
+
(0, import_react21.useEffect)(() => {
|
|
4148
4617
|
if (!open || popupMode === "modal") return void 0;
|
|
4149
4618
|
function closeFromOutside(event) {
|
|
4150
4619
|
const target = event.target;
|
|
@@ -4153,13 +4622,15 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4153
4622
|
document.addEventListener("mousedown", closeFromOutside);
|
|
4154
4623
|
return () => document.removeEventListener("mousedown", closeFromOutside);
|
|
4155
4624
|
}, [open, popupMode]);
|
|
4156
|
-
(0,
|
|
4157
|
-
if (open
|
|
4158
|
-
|
|
4159
|
-
|
|
4625
|
+
(0, import_react21.useEffect)(() => {
|
|
4626
|
+
if (!open || popupMode !== "dropdown" || !(showSearch || allowInput)) return;
|
|
4627
|
+
const frame = requestAnimationFrame(() => searchRef.current?.focus({ preventScroll: true }));
|
|
4628
|
+
return () => cancelAnimationFrame(frame);
|
|
4629
|
+
}, [allowInput, open, popupMode, showSearch]);
|
|
4630
|
+
(0, import_react21.useEffect)(() => {
|
|
4160
4631
|
if (disabled || loading) closeDropdown();
|
|
4161
4632
|
}, [disabled, loading]);
|
|
4162
|
-
(0,
|
|
4633
|
+
(0, import_react21.useEffect)(() => {
|
|
4163
4634
|
if (!open || popupMode !== "dropdown" || !pendingSelectedScroll.current || query) return;
|
|
4164
4635
|
const index = filteredOptions.findIndex((option) => selectedValueSet.has(option.value));
|
|
4165
4636
|
if (index < 0) return;
|
|
@@ -4174,7 +4645,7 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4174
4645
|
});
|
|
4175
4646
|
return () => cancelAnimationFrame(frame);
|
|
4176
4647
|
}, [open, popupMode, filteredOptions, selectedValueSet, virtualEnabled, optionHeight, query]);
|
|
4177
|
-
(0,
|
|
4648
|
+
(0, import_react21.useLayoutEffect)(() => {
|
|
4178
4649
|
if (!open || popupMode !== "dropdown") return;
|
|
4179
4650
|
const trigger = rootRef.current?.querySelector(".sia-select__trigger");
|
|
4180
4651
|
if (trigger) setDropdownFontSize(getComputedStyle(trigger).fontSize);
|
|
@@ -4332,7 +4803,7 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4332
4803
|
function renderOption(option, renderedIndex) {
|
|
4333
4804
|
const optionIndex = virtualEnabled ? virtualStart + renderedIndex : renderedIndex;
|
|
4334
4805
|
const selected = selectedValueSet.has(option.value);
|
|
4335
|
-
return /* @__PURE__ */ (0,
|
|
4806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
4336
4807
|
"div",
|
|
4337
4808
|
{
|
|
4338
4809
|
id: `${listboxId}-${optionIndex}`,
|
|
@@ -4345,11 +4816,11 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4345
4816
|
onMouseDown: (event) => event.preventDefault(),
|
|
4346
4817
|
onClick: () => selectOption(option),
|
|
4347
4818
|
children: [
|
|
4348
|
-
/* @__PURE__ */ (0,
|
|
4349
|
-
/* @__PURE__ */ (0,
|
|
4350
|
-
showValue ? /* @__PURE__ */ (0,
|
|
4819
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "sia-select__option-content", children: [
|
|
4820
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "sia-select__option-label", children: option.label }),
|
|
4821
|
+
showValue ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("small", { className: "sia-select__option-value", children: String(option.value) }) : null
|
|
4351
4822
|
] }),
|
|
4352
|
-
selected ? /* @__PURE__ */ (0,
|
|
4823
|
+
selected ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon, { name: "check", size: 15 }) : null
|
|
4353
4824
|
]
|
|
4354
4825
|
},
|
|
4355
4826
|
`${typeof option.value}-${option.value}`
|
|
@@ -4363,8 +4834,8 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4363
4834
|
setModalValues([...modalValues.filter((value2) => !editable.has(value2)), ...modalEnabled.filter((option) => operation === "all" || operation === "invert" && !modalValues.includes(option.value)).map((option) => option.value)]);
|
|
4364
4835
|
}
|
|
4365
4836
|
const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: hasValue, active: open });
|
|
4366
|
-
return /* @__PURE__ */ (0,
|
|
4367
|
-
/* @__PURE__ */ (0,
|
|
4837
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { ref: rootRef, className: `sia-select sia-select--${size} sia-select--${status}${open ? " is-open" : ""}${disabled ? " is-disabled" : ""}${multiple ? " sia-select--multiple" : ""} ${className}`.trim(), style, children: [
|
|
4838
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
4368
4839
|
"button",
|
|
4369
4840
|
{
|
|
4370
4841
|
...withTitleTooltip(props),
|
|
@@ -4382,29 +4853,29 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4382
4853
|
onClick: () => open ? closeDropdown() : openDropdown(),
|
|
4383
4854
|
onKeyDown: handleTriggerKeyDown,
|
|
4384
4855
|
children: [
|
|
4385
|
-
multiple && hasValue ? /* @__PURE__ */ (0,
|
|
4386
|
-
loading ? /* @__PURE__ */ (0,
|
|
4856
|
+
multiple && hasValue ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(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__ */ (0, import_jsx_runtime19.jsx)("span", { className: `sia-select__value${hasValue ? "" : " is-placeholder"}`, children: selectedOptions[0]?.label ?? placeholder }),
|
|
4857
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "sia-select__spinner", "aria-hidden": "true" }) : null,
|
|
4387
4858
|
floating.label,
|
|
4388
|
-
/* @__PURE__ */ (0,
|
|
4859
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon, { className: "sia-select__arrow", name: "chevron-down", size: 15 })
|
|
4389
4860
|
]
|
|
4390
4861
|
}
|
|
4391
4862
|
),
|
|
4392
|
-
allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ (0,
|
|
4393
|
-
/* @__PURE__ */ (0,
|
|
4394
|
-
/* @__PURE__ */ (0,
|
|
4395
|
-
showSearch || allowInput ? /* @__PURE__ */ (0,
|
|
4396
|
-
/* @__PURE__ */ (0,
|
|
4397
|
-
/* @__PURE__ */ (0,
|
|
4863
|
+
allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { className: "sia-select__clear", type: "button", "aria-label": "\u6E05\u7A7A\u9009\u62E9", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
|
|
4864
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(PopupPortal, { ref: popupRef, onKeyDown: handleDropdownEscape, anchorRef: rootRef, open: open && popupMode === "dropdown", style: { fontSize: dropdownFontSize }, className: `sia-select__dropdown${filteredOptions.length === 0 && !canSubmitInput ? " sia-select__dropdown--empty" : ""}`, children: [
|
|
4865
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(FloatingScrollbarProvider, { targetRef: listRef }),
|
|
4866
|
+
showSearch || allowInput ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "sia-select__search", children: [
|
|
4867
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon, { name: "search", size: 15 }),
|
|
4868
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("input", { ref: searchRef, value: query, maxLength: inputMaxLength, onChange: handleSearchChange, onKeyDown: (event) => handleInteractionKeyDown(event, true), placeholder: searchPlaceholder, "aria-label": searchPlaceholder })
|
|
4398
4869
|
] }) : null,
|
|
4399
|
-
canSubmitInput ? /* @__PURE__ */ (0,
|
|
4400
|
-
/* @__PURE__ */ (0,
|
|
4401
|
-
/* @__PURE__ */ (0,
|
|
4870
|
+
canSubmitInput ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("button", { type: "button", className: "sia-select__input-option", onMouseDown: (event) => event.preventDefault(), onClick: submitInputValue, children: [
|
|
4871
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon, { name: "plus", size: 14 }),
|
|
4872
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { children: [
|
|
4402
4873
|
"\u4F7F\u7528\u201C",
|
|
4403
4874
|
inputValue,
|
|
4404
4875
|
"\u201D"
|
|
4405
4876
|
] })
|
|
4406
4877
|
] }) : null,
|
|
4407
|
-
/* @__PURE__ */ (0,
|
|
4878
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4408
4879
|
"div",
|
|
4409
4880
|
{
|
|
4410
4881
|
ref: listRef,
|
|
@@ -4415,23 +4886,23 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4415
4886
|
"aria-multiselectable": multiple || void 0,
|
|
4416
4887
|
style: { maxHeight: listHeight },
|
|
4417
4888
|
onScroll: handleListScroll,
|
|
4418
|
-
children: filteredOptions.length > 0 ? virtualEnabled ? /* @__PURE__ */ (0,
|
|
4889
|
+
children: filteredOptions.length > 0 ? virtualEnabled ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "sia-select__virtual-space", style: { height: filteredOptions.length * optionHeight }, children: renderedOptions.map(renderOption) }) : renderedOptions.map(renderOption) : canSubmitInput ? null : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "sia-select__empty", children: notFoundContent })
|
|
4419
4890
|
}
|
|
4420
4891
|
),
|
|
4421
|
-
showActions ? /* @__PURE__ */ (0,
|
|
4422
|
-
/* @__PURE__ */ (0,
|
|
4892
|
+
showActions ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "sia-select__actions", children: [
|
|
4893
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { children: [
|
|
4423
4894
|
"\u5171 ",
|
|
4424
4895
|
filteredOptions.length,
|
|
4425
4896
|
" \u6761"
|
|
4426
4897
|
] }),
|
|
4427
|
-
multiple && showSelectAll ? /* @__PURE__ */ (0,
|
|
4428
|
-
/* @__PURE__ */ (0,
|
|
4429
|
-
/* @__PURE__ */ (0,
|
|
4898
|
+
multiple && showSelectAll ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
4899
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", disabled: allFilteredSelected || !enabledFilteredOptions.length, onClick: selectAllFiltered, children: "\u5168\u9009" }),
|
|
4900
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", disabled: !enabledFilteredOptions.length, onClick: invertFiltered, children: "\u53CD\u9009" })
|
|
4430
4901
|
] }) : null,
|
|
4431
|
-
multiple || allowClear ? /* @__PURE__ */ (0,
|
|
4902
|
+
multiple || allowClear ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", danger: true, disabled: !hasValue, onClick: clearSelection, children: "\u6E05\u7A7A" }) : null
|
|
4432
4903
|
] }) : null
|
|
4433
4904
|
] }),
|
|
4434
|
-
popupMode === "modal" ? /* @__PURE__ */ (0,
|
|
4905
|
+
popupMode === "modal" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4435
4906
|
Modal2,
|
|
4436
4907
|
{
|
|
4437
4908
|
className: "sia-select-modal",
|
|
@@ -4443,30 +4914,30 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4443
4914
|
if (!next) closeDropdown();
|
|
4444
4915
|
},
|
|
4445
4916
|
onCancel: closeDropdown,
|
|
4446
|
-
footer: /* @__PURE__ */ (0,
|
|
4447
|
-
/* @__PURE__ */ (0,
|
|
4448
|
-
/* @__PURE__ */ (0,
|
|
4449
|
-
/* @__PURE__ */ (0,
|
|
4450
|
-
/* @__PURE__ */ (0,
|
|
4917
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "sia-select-modal__footer", children: [
|
|
4918
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: modalConfig?.footerExtra }),
|
|
4919
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { children: [
|
|
4920
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { disabled: modalSubmitting, onClick: closeDropdown, children: "\u53D6\u6D88" }),
|
|
4921
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "primary", loading: modalSubmitting, disabled: disabled || loading, onClick: confirmModalSelection, children: "\u786E\u5B9A" })
|
|
4451
4922
|
] })
|
|
4452
4923
|
] }),
|
|
4453
|
-
children: open ? /* @__PURE__ */ (0,
|
|
4454
|
-
modalConfig?.headerExtra != null && modalConfig.headerExtra !== false ? /* @__PURE__ */ (0,
|
|
4455
|
-
/* @__PURE__ */ (0,
|
|
4456
|
-
/* @__PURE__ */ (0,
|
|
4457
|
-
/* @__PURE__ */ (0,
|
|
4458
|
-
/* @__PURE__ */ (0,
|
|
4924
|
+
children: open ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
4925
|
+
modalConfig?.headerExtra != null && modalConfig.headerExtra !== false ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "sia-select-modal__header-extra", children: modalConfig.headerExtra }) : null,
|
|
4926
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "sia-select-modal__heading", children: [
|
|
4927
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { role: "tablist", "aria-label": "\u9009\u9879\u8303\u56F4", children: [
|
|
4928
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { role: "tab", "aria-selected": !selectedOnly, variant: "link", onClick: () => setSelectedOnly(false), children: "\u5168\u90E8" }),
|
|
4929
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Button, { role: "tab", "aria-selected": selectedOnly, variant: "link", onClick: () => setSelectedOnly(true), children: [
|
|
4459
4930
|
"\u5DF2\u9009\u9879(",
|
|
4460
4931
|
modalValues.length,
|
|
4461
4932
|
")"
|
|
4462
4933
|
] })
|
|
4463
4934
|
] }),
|
|
4464
|
-
/* @__PURE__ */ (0,
|
|
4935
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4465
4936
|
Input,
|
|
4466
4937
|
{
|
|
4467
4938
|
"aria-label": searchPlaceholder,
|
|
4468
4939
|
placeholder: searchPlaceholder,
|
|
4469
|
-
prefix: /* @__PURE__ */ (0,
|
|
4940
|
+
prefix: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon, { name: "search", size: 14 }),
|
|
4470
4941
|
value: query,
|
|
4471
4942
|
allowClear: true,
|
|
4472
4943
|
onChange: (event) => {
|
|
@@ -4476,8 +4947,8 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4476
4947
|
}
|
|
4477
4948
|
)
|
|
4478
4949
|
] }),
|
|
4479
|
-
multiple && showSelectAll ? /* @__PURE__ */ (0,
|
|
4480
|
-
/* @__PURE__ */ (0,
|
|
4950
|
+
multiple && showSelectAll ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "sia-select-modal__actions", children: [
|
|
4951
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4481
4952
|
Checkbox2,
|
|
4482
4953
|
{
|
|
4483
4954
|
checked: modalEnabled.length > 0 && modalEnabled.every((option) => modalValues.includes(option.value)),
|
|
@@ -4487,10 +4958,10 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4487
4958
|
children: "\u5168\u9009"
|
|
4488
4959
|
}
|
|
4489
4960
|
),
|
|
4490
|
-
/* @__PURE__ */ (0,
|
|
4491
|
-
/* @__PURE__ */ (0,
|
|
4961
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", disabled: !modalEnabled.length, onClick: () => modalBatch("invert"), children: "\u53CD\u9009" }),
|
|
4962
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", danger: true, disabled: !modalValues.length, onClick: () => setModalValues([]), children: "\u6E05\u7A7A" })
|
|
4492
4963
|
] }) : null,
|
|
4493
|
-
allowInput && canSubmitInput ? /* @__PURE__ */ (0,
|
|
4964
|
+
allowInput && canSubmitInput ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Button, { variant: "link", onClick: () => {
|
|
4494
4965
|
setModalValues(multiple ? [.../* @__PURE__ */ new Set([...modalValues, inputValue])] : [inputValue]);
|
|
4495
4966
|
setQuery("");
|
|
4496
4967
|
}, children: [
|
|
@@ -4498,7 +4969,7 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4498
4969
|
inputValue,
|
|
4499
4970
|
"\u201D"
|
|
4500
4971
|
] }) : null,
|
|
4501
|
-
/* @__PURE__ */ (0,
|
|
4972
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4502
4973
|
SelectionPanel,
|
|
4503
4974
|
{
|
|
4504
4975
|
options: modalFiltered,
|
|
@@ -4523,7 +4994,7 @@ var Select = (0, import_react18.forwardRef)(function Select2({
|
|
|
4523
4994
|
});
|
|
4524
4995
|
|
|
4525
4996
|
// src/components/SelectDateRange.tsx
|
|
4526
|
-
var
|
|
4997
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
4527
4998
|
function SelectDateRange({
|
|
4528
4999
|
options,
|
|
4529
5000
|
value,
|
|
@@ -4546,8 +5017,8 @@ function SelectDateRange({
|
|
|
4546
5017
|
const size = useControlSize(sizeProp);
|
|
4547
5018
|
const initialValue = defaultValue ?? { select: options[0]?.value ?? "", range: ["", ""] };
|
|
4548
5019
|
const [currentValue, setCurrentValue] = useControllableState({ value: value === void 0 ? void 0 : value && typeof value === "object" ? value : { select: "", range: ["", ""] }, defaultValue: initialValue, onChange });
|
|
4549
|
-
return /* @__PURE__ */ (0,
|
|
4550
|
-
/* @__PURE__ */ (0,
|
|
5020
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `sia-select-date-range sia-select-date-range--${size} ${className}`.trim(), role: "group", "aria-label": `${selectAriaLabel}\u4E0E${rangeAriaLabel}`, ...withTitleTooltip(props), style: { ...style, "--sia-select-date-range-select-width": typeof selectWidth === "number" ? `${selectWidth}px` : selectWidth }, children: [
|
|
5021
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4551
5022
|
Select,
|
|
4552
5023
|
{
|
|
4553
5024
|
className: "sia-select-date-range__select",
|
|
@@ -4565,7 +5036,7 @@ function SelectDateRange({
|
|
|
4565
5036
|
}
|
|
4566
5037
|
}
|
|
4567
5038
|
),
|
|
4568
|
-
/* @__PURE__ */ (0,
|
|
5039
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4569
5040
|
DatePicker.RangePicker,
|
|
4570
5041
|
{
|
|
4571
5042
|
className: "sia-select-date-range__picker",
|
|
@@ -4582,6 +5053,9 @@ function SelectDateRange({
|
|
|
4582
5053
|
)
|
|
4583
5054
|
] });
|
|
4584
5055
|
}
|
|
5056
|
+
|
|
5057
|
+
// src/select-date-range.ts
|
|
5058
|
+
initializeDefaultScrollbars();
|
|
4585
5059
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4586
5060
|
0 && (module.exports = {
|
|
4587
5061
|
SelectDateRange
|