@sia.soul/sia-react-ui 0.1.142 → 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-TUGCP3GB.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-3KYG7IU7.js → chunk-MD4CGSOR.js} +105 -61
- package/dist/{chunk-PGP4TEPP.js → chunk-ORSQAJ22.js} +154 -494
- 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 +1996 -1250
- package/dist/core.css +413 -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 +4654 -3541
- package/dist/index.css +413 -344
- package/dist/index.d.cts +77 -80
- package/dist/index.d.ts +77 -80
- 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 +1277 -806
- 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
|
@@ -35,12 +35,670 @@ __export(rich_text_editor_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(rich_text_editor_exports);
|
|
37
37
|
|
|
38
|
+
// src/components/FloatingScrollbarProvider.tsx
|
|
39
|
+
var import_react2 = require("react");
|
|
40
|
+
|
|
41
|
+
// src/components/useScrollbarProximity.ts
|
|
42
|
+
var import_react = require("react");
|
|
43
|
+
var users = 0;
|
|
44
|
+
var cleanup;
|
|
45
|
+
function acquireScrollbarProximity() {
|
|
46
|
+
if (users++ === 0) {
|
|
47
|
+
let frame = 0;
|
|
48
|
+
let x = -Infinity;
|
|
49
|
+
let y = -Infinity;
|
|
50
|
+
const nearby = /* @__PURE__ */ new Set();
|
|
51
|
+
const clear = () => {
|
|
52
|
+
nearby.forEach((track) => track.removeAttribute("data-scrollbar-near"));
|
|
53
|
+
nearby.clear();
|
|
54
|
+
};
|
|
55
|
+
const update = () => {
|
|
56
|
+
frame = 0;
|
|
57
|
+
const next = /* @__PURE__ */ new Set();
|
|
58
|
+
document.querySelectorAll(".sia-scrollbar-track").forEach((track) => {
|
|
59
|
+
const rect = track.getBoundingClientRect();
|
|
60
|
+
const proximity = Number.parseFloat(getComputedStyle(track).getPropertyValue("--sia-scrollbar-proximity")) || 16;
|
|
61
|
+
if (rect.width && rect.height && x >= rect.left - proximity && x <= rect.right + proximity && y >= rect.top - proximity && y <= rect.bottom + proximity) {
|
|
62
|
+
next.add(track);
|
|
63
|
+
if (!nearby.has(track)) track.setAttribute("data-scrollbar-near", "true");
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
nearby.forEach((track) => {
|
|
67
|
+
if (!next.has(track)) track.removeAttribute("data-scrollbar-near");
|
|
68
|
+
});
|
|
69
|
+
nearby.clear();
|
|
70
|
+
next.forEach((track) => nearby.add(track));
|
|
71
|
+
};
|
|
72
|
+
const move = (event) => {
|
|
73
|
+
if (event.pointerType === "touch") return;
|
|
74
|
+
x = event.clientX;
|
|
75
|
+
y = event.clientY;
|
|
76
|
+
if (!frame) frame = requestAnimationFrame(update);
|
|
77
|
+
};
|
|
78
|
+
const leave = () => {
|
|
79
|
+
x = y = -Infinity;
|
|
80
|
+
clear();
|
|
81
|
+
};
|
|
82
|
+
document.addEventListener("pointermove", move, { passive: true });
|
|
83
|
+
document.documentElement.addEventListener("pointerleave", leave);
|
|
84
|
+
window.addEventListener("blur", leave);
|
|
85
|
+
cleanup = () => {
|
|
86
|
+
if (frame) cancelAnimationFrame(frame);
|
|
87
|
+
document.removeEventListener("pointermove", move);
|
|
88
|
+
document.documentElement.removeEventListener("pointerleave", leave);
|
|
89
|
+
window.removeEventListener("blur", leave);
|
|
90
|
+
clear();
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return () => {
|
|
94
|
+
if (--users === 0) {
|
|
95
|
+
cleanup?.();
|
|
96
|
+
cleanup = void 0;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/components/floatingScrollbarOwnership.ts
|
|
102
|
+
var targets = /* @__PURE__ */ new Map();
|
|
103
|
+
function registerFloatingScrollbar(track, target) {
|
|
104
|
+
targets.set(track, { target, dragging: false });
|
|
105
|
+
return () => {
|
|
106
|
+
targets.delete(track);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function setFloatingScrollbarDragging(track, dragging) {
|
|
110
|
+
const entry = targets.get(track);
|
|
111
|
+
if (entry) entry.dragging = dragging;
|
|
112
|
+
}
|
|
113
|
+
function resolveFloatingScrollbarTarget(target) {
|
|
114
|
+
const track = target instanceof Element ? target.closest(".sia-floating-scrollbar") : null;
|
|
115
|
+
return track && targets.get(track)?.target || target;
|
|
116
|
+
}
|
|
117
|
+
function hasFloatingScrollbarInteraction(container) {
|
|
118
|
+
if (!container) return false;
|
|
119
|
+
return [...targets].some(([track, entry]) => container.contains(entry.target) && (entry.dragging || track.matches(":hover")));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/components/FloatingScrollbarProvider.tsx
|
|
123
|
+
var scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
124
|
+
var clippingOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay", "hidden", "clip"]);
|
|
125
|
+
function isRootScroller(target) {
|
|
126
|
+
return target === document.scrollingElement || target === document.documentElement;
|
|
127
|
+
}
|
|
128
|
+
function canScroll(target, axis) {
|
|
129
|
+
if (target.matches(".sia-table__viewport, [data-sia-native-scrollbar]")) return false;
|
|
130
|
+
if (isRootScroller(target)) {
|
|
131
|
+
const rootStyle = getComputedStyle(target);
|
|
132
|
+
const bodyStyle = getComputedStyle(document.body);
|
|
133
|
+
const overflow2 = axis === "horizontal" ? [rootStyle.overflowX, bodyStyle.overflowX] : [rootStyle.overflowY, bodyStyle.overflowY];
|
|
134
|
+
if (overflow2.some((value) => value === "hidden" || value === "clip")) return false;
|
|
135
|
+
return axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
|
|
136
|
+
}
|
|
137
|
+
const style = getComputedStyle(target);
|
|
138
|
+
const overflow = axis === "horizontal" ? style.overflowX : style.overflowY;
|
|
139
|
+
if (!scrollableOverflow.has(overflow)) return false;
|
|
140
|
+
const hasOverflow = axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
|
|
141
|
+
return hasOverflow;
|
|
142
|
+
}
|
|
143
|
+
function visibleRect(target) {
|
|
144
|
+
if (isRootScroller(target)) {
|
|
145
|
+
return { top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0, width: window.innerWidth, height: window.innerHeight };
|
|
146
|
+
}
|
|
147
|
+
const ownRect = target.getBoundingClientRect();
|
|
148
|
+
let top = Math.max(0, ownRect.top);
|
|
149
|
+
let right = Math.min(window.innerWidth, ownRect.right);
|
|
150
|
+
let bottom = Math.min(window.innerHeight, ownRect.bottom);
|
|
151
|
+
let left = Math.max(0, ownRect.left);
|
|
152
|
+
let parent = target.parentElement;
|
|
153
|
+
while (parent && parent !== document.body && parent !== document.documentElement) {
|
|
154
|
+
const style = getComputedStyle(parent);
|
|
155
|
+
const clipX = clippingOverflow.has(style.overflowX);
|
|
156
|
+
const clipY = clippingOverflow.has(style.overflowY);
|
|
157
|
+
if (clipX || clipY) {
|
|
158
|
+
const rect = parent.getBoundingClientRect();
|
|
159
|
+
if (clipX) {
|
|
160
|
+
left = Math.max(left, rect.left);
|
|
161
|
+
right = Math.min(right, rect.right);
|
|
162
|
+
}
|
|
163
|
+
if (clipY) {
|
|
164
|
+
top = Math.max(top, rect.top);
|
|
165
|
+
bottom = Math.min(bottom, rect.bottom);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
parent = parent.parentElement;
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
top,
|
|
172
|
+
right,
|
|
173
|
+
bottom,
|
|
174
|
+
left,
|
|
175
|
+
width: Math.max(0, right - left),
|
|
176
|
+
height: Math.max(0, bottom - top)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function createTrack(axis) {
|
|
180
|
+
const track = document.createElement("div");
|
|
181
|
+
const thumb = document.createElement("div");
|
|
182
|
+
track.className = `sia-scrollbar-track sia-floating-scrollbar sia-floating-scrollbar--${axis}`;
|
|
183
|
+
thumb.className = "sia-floating-scrollbar__thumb";
|
|
184
|
+
track.dataset.axis = axis;
|
|
185
|
+
track.setAttribute("aria-hidden", "true");
|
|
186
|
+
track.append(thumb);
|
|
187
|
+
return { track, thumb };
|
|
188
|
+
}
|
|
189
|
+
var automatic = false;
|
|
190
|
+
var stopGlobal;
|
|
191
|
+
var globalProviders = /* @__PURE__ */ new Map();
|
|
192
|
+
function syncDefaultScrollbars() {
|
|
193
|
+
if (typeof document === "undefined" || !document.body) return;
|
|
194
|
+
const enabled = (automatic || globalProviders.size > 0) && ![...globalProviders.values()].includes(false);
|
|
195
|
+
if (enabled && !stopGlobal) stopGlobal = startFloatingScrollbars();
|
|
196
|
+
if (!enabled && stopGlobal) {
|
|
197
|
+
stopGlobal();
|
|
198
|
+
stopGlobal = void 0;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function initializeDefaultScrollbars() {
|
|
202
|
+
if (typeof document === "undefined" || automatic) return;
|
|
203
|
+
automatic = true;
|
|
204
|
+
if (document.body) syncDefaultScrollbars();
|
|
205
|
+
else document.addEventListener("DOMContentLoaded", syncDefaultScrollbars, { once: true });
|
|
206
|
+
}
|
|
207
|
+
function startFloatingScrollbars(targetRef) {
|
|
208
|
+
const releaseProximity = acquireScrollbarProximity();
|
|
209
|
+
const layer = document.createElement("div");
|
|
210
|
+
layer.className = "sia-floating-scrollbar-layer";
|
|
211
|
+
layer.setAttribute("aria-hidden", "true");
|
|
212
|
+
document.body.append(layer);
|
|
213
|
+
const entries = /* @__PURE__ */ new Map();
|
|
214
|
+
let scanFrame = 0;
|
|
215
|
+
let updateFrame = 0;
|
|
216
|
+
const dirtyStyles = /* @__PURE__ */ new Set();
|
|
217
|
+
let fullScan = true;
|
|
218
|
+
const setEntryVisible = (entry, visible) => {
|
|
219
|
+
entry.horizontalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
|
|
220
|
+
entry.verticalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
|
|
221
|
+
};
|
|
222
|
+
const showEntry = (entry) => {
|
|
223
|
+
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
224
|
+
entry.hideTimer = null;
|
|
225
|
+
setEntryVisible(entry, true);
|
|
226
|
+
};
|
|
227
|
+
const scheduleHide = (entry, delay = 500) => {
|
|
228
|
+
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
229
|
+
entry.hideTimer = window.setTimeout(() => {
|
|
230
|
+
entry.hideTimer = null;
|
|
231
|
+
if (!entry.hoveringTarget && !entry.hoveringTrack && !entry.dragging) setEntryVisible(entry, false);
|
|
232
|
+
}, delay);
|
|
233
|
+
};
|
|
234
|
+
const updateEntry = (entry) => {
|
|
235
|
+
const { target, horizontalTrack, horizontalThumb, verticalTrack, verticalThumb } = entry;
|
|
236
|
+
const hasHorizontal = canScroll(target, "horizontal");
|
|
237
|
+
const hasVertical = canScroll(target, "vertical");
|
|
238
|
+
const rect = visibleRect(target);
|
|
239
|
+
const thickness = 10;
|
|
240
|
+
horizontalTrack.hidden = !hasHorizontal || rect.width <= thickness || rect.height <= 0;
|
|
241
|
+
verticalTrack.hidden = !hasVertical || rect.height <= thickness || rect.width <= 0;
|
|
242
|
+
if (!horizontalTrack.hidden) {
|
|
243
|
+
const trackWidth = Math.max(0, rect.width - (hasVertical ? thickness : 0));
|
|
244
|
+
const thumbWidth = Math.max(24, Math.min(trackWidth, trackWidth * target.clientWidth / target.scrollWidth));
|
|
245
|
+
const travel = Math.max(0, trackWidth - thumbWidth);
|
|
246
|
+
const maxScroll = Math.max(1, target.scrollWidth - target.clientWidth);
|
|
247
|
+
horizontalTrack.style.left = `${rect.left}px`;
|
|
248
|
+
horizontalTrack.style.top = `${rect.bottom - thickness}px`;
|
|
249
|
+
horizontalTrack.style.width = `${trackWidth}px`;
|
|
250
|
+
horizontalTrack.style.height = `${thickness}px`;
|
|
251
|
+
horizontalThumb.style.width = `${thumbWidth}px`;
|
|
252
|
+
horizontalThumb.style.transform = `translate3d(${travel * target.scrollLeft / maxScroll}px, 0, 0)`;
|
|
253
|
+
}
|
|
254
|
+
if (!verticalTrack.hidden) {
|
|
255
|
+
const trackHeight = Math.max(0, rect.height - (hasHorizontal ? thickness : 0));
|
|
256
|
+
const thumbHeight = Math.max(24, Math.min(trackHeight, trackHeight * target.clientHeight / target.scrollHeight));
|
|
257
|
+
const travel = Math.max(0, trackHeight - thumbHeight);
|
|
258
|
+
const maxScroll = Math.max(1, target.scrollHeight - target.clientHeight);
|
|
259
|
+
verticalTrack.style.left = `${rect.right - thickness}px`;
|
|
260
|
+
verticalTrack.style.top = `${rect.top}px`;
|
|
261
|
+
verticalTrack.style.width = `${thickness}px`;
|
|
262
|
+
verticalTrack.style.height = `${trackHeight}px`;
|
|
263
|
+
verticalThumb.style.height = `${thumbHeight}px`;
|
|
264
|
+
verticalThumb.style.transform = `translate3d(0, ${travel * target.scrollTop / maxScroll}px, 0)`;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
const scheduleUpdateAll = () => {
|
|
268
|
+
if (updateFrame) return;
|
|
269
|
+
updateFrame = window.requestAnimationFrame(() => {
|
|
270
|
+
updateFrame = 0;
|
|
271
|
+
entries.forEach(updateEntry);
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
const bindTrackDrag = (entry, axis, track, thumb) => {
|
|
275
|
+
const target = entry.target;
|
|
276
|
+
const onTrackPointerEnter = () => {
|
|
277
|
+
entry.hoveringTrack = true;
|
|
278
|
+
showEntry(entry);
|
|
279
|
+
};
|
|
280
|
+
const onTrackPointerLeave = () => {
|
|
281
|
+
entry.hoveringTrack = false;
|
|
282
|
+
scheduleHide(entry);
|
|
283
|
+
};
|
|
284
|
+
const onTrackPointerDown = (event) => {
|
|
285
|
+
if (event.target === thumb || event.button !== 0) return;
|
|
286
|
+
event.preventDefault();
|
|
287
|
+
event.stopPropagation();
|
|
288
|
+
const trackRect = track.getBoundingClientRect();
|
|
289
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
290
|
+
const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
|
|
291
|
+
const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
|
|
292
|
+
const pointer = axis === "vertical" ? event.clientY - trackRect.top : event.clientX - trackRect.left;
|
|
293
|
+
const ratio = Math.max(0, Math.min(1, (pointer - thumbLength / 2) / Math.max(1, trackLength - thumbLength)));
|
|
294
|
+
if (axis === "vertical") target.scrollTop = ratio * (target.scrollHeight - target.clientHeight);
|
|
295
|
+
else target.scrollLeft = ratio * (target.scrollWidth - target.clientWidth);
|
|
296
|
+
};
|
|
297
|
+
const onThumbPointerDown = (event) => {
|
|
298
|
+
if (event.button !== 0) return;
|
|
299
|
+
event.preventDefault();
|
|
300
|
+
event.stopPropagation();
|
|
301
|
+
entry.dragging = true;
|
|
302
|
+
setFloatingScrollbarDragging(track, true);
|
|
303
|
+
showEntry(entry);
|
|
304
|
+
thumb.setPointerCapture(event.pointerId);
|
|
305
|
+
const startPointer = axis === "vertical" ? event.clientY : event.clientX;
|
|
306
|
+
const startScroll = axis === "vertical" ? target.scrollTop : target.scrollLeft;
|
|
307
|
+
const trackRect = track.getBoundingClientRect();
|
|
308
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
309
|
+
const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
|
|
310
|
+
const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
|
|
311
|
+
const maxScroll = axis === "vertical" ? target.scrollHeight - target.clientHeight : target.scrollWidth - target.clientWidth;
|
|
312
|
+
const travel = Math.max(1, trackLength - thumbLength);
|
|
313
|
+
const onPointerMove = (moveEvent) => {
|
|
314
|
+
if (moveEvent.pointerId !== event.pointerId) return;
|
|
315
|
+
const pointer = axis === "vertical" ? moveEvent.clientY : moveEvent.clientX;
|
|
316
|
+
const nextScroll = startScroll + (pointer - startPointer) * maxScroll / travel;
|
|
317
|
+
if (axis === "vertical") target.scrollTop = nextScroll;
|
|
318
|
+
else target.scrollLeft = nextScroll;
|
|
319
|
+
};
|
|
320
|
+
const onPointerUp = (upEvent) => {
|
|
321
|
+
if (upEvent.pointerId !== event.pointerId) return;
|
|
322
|
+
entry.dragging = false;
|
|
323
|
+
setFloatingScrollbarDragging(track, false);
|
|
324
|
+
thumb.releasePointerCapture(event.pointerId);
|
|
325
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
326
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
327
|
+
window.removeEventListener("pointercancel", onPointerUp);
|
|
328
|
+
scheduleHide(entry);
|
|
329
|
+
};
|
|
330
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
331
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
332
|
+
window.addEventListener("pointercancel", onPointerUp);
|
|
333
|
+
};
|
|
334
|
+
track.addEventListener("pointerenter", onTrackPointerEnter);
|
|
335
|
+
track.addEventListener("pointerleave", onTrackPointerLeave);
|
|
336
|
+
track.addEventListener("pointerdown", onTrackPointerDown);
|
|
337
|
+
thumb.addEventListener("pointerdown", onThumbPointerDown);
|
|
338
|
+
return () => {
|
|
339
|
+
track.removeEventListener("pointerenter", onTrackPointerEnter);
|
|
340
|
+
track.removeEventListener("pointerleave", onTrackPointerLeave);
|
|
341
|
+
track.removeEventListener("pointerdown", onTrackPointerDown);
|
|
342
|
+
thumb.removeEventListener("pointerdown", onThumbPointerDown);
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
const resizeObserver = new ResizeObserver((observedEntries) => {
|
|
346
|
+
observedEntries.forEach(({ target }) => {
|
|
347
|
+
const entry = entries.get(target);
|
|
348
|
+
if (entry) updateEntry(entry);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
const addTarget = (target) => {
|
|
352
|
+
if (entries.has(target)) return;
|
|
353
|
+
const horizontal = createTrack("horizontal");
|
|
354
|
+
const vertical = createTrack("vertical");
|
|
355
|
+
const releaseHorizontalOwner = registerFloatingScrollbar(horizontal.track, target);
|
|
356
|
+
const releaseVerticalOwner = registerFloatingScrollbar(vertical.track, target);
|
|
357
|
+
layer.append(horizontal.track, vertical.track);
|
|
358
|
+
const onPointerEnter = () => {
|
|
359
|
+
const entry2 = entries.get(target);
|
|
360
|
+
if (!entry2) return;
|
|
361
|
+
entry2.hoveringTarget = true;
|
|
362
|
+
showEntry(entry2);
|
|
363
|
+
};
|
|
364
|
+
const onPointerLeave = () => {
|
|
365
|
+
const entry2 = entries.get(target);
|
|
366
|
+
if (!entry2) return;
|
|
367
|
+
entry2.hoveringTarget = false;
|
|
368
|
+
scheduleHide(entry2);
|
|
369
|
+
};
|
|
370
|
+
const onScroll = () => {
|
|
371
|
+
const entry2 = entries.get(target);
|
|
372
|
+
if (!entry2) return;
|
|
373
|
+
updateEntry(entry2);
|
|
374
|
+
showEntry(entry2);
|
|
375
|
+
scheduleHide(entry2, 700);
|
|
376
|
+
};
|
|
377
|
+
target.addEventListener("pointerenter", onPointerEnter);
|
|
378
|
+
target.addEventListener("pointerleave", onPointerLeave);
|
|
379
|
+
target.addEventListener("scroll", onScroll, { passive: true });
|
|
380
|
+
const entry = {
|
|
381
|
+
target,
|
|
382
|
+
horizontalTrack: horizontal.track,
|
|
383
|
+
horizontalThumb: horizontal.thumb,
|
|
384
|
+
verticalTrack: vertical.track,
|
|
385
|
+
verticalThumb: vertical.thumb,
|
|
386
|
+
hideTimer: null,
|
|
387
|
+
hoveringTarget: target.matches(":hover"),
|
|
388
|
+
hoveringTrack: false,
|
|
389
|
+
dragging: false,
|
|
390
|
+
cleanup: () => void 0
|
|
391
|
+
};
|
|
392
|
+
const cleanupHorizontal = bindTrackDrag(entry, "horizontal", horizontal.track, horizontal.thumb);
|
|
393
|
+
const cleanupVertical = bindTrackDrag(entry, "vertical", vertical.track, vertical.thumb);
|
|
394
|
+
entry.cleanup = () => {
|
|
395
|
+
if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
|
|
396
|
+
cleanupHorizontal();
|
|
397
|
+
cleanupVertical();
|
|
398
|
+
releaseHorizontalOwner();
|
|
399
|
+
releaseVerticalOwner();
|
|
400
|
+
target.removeEventListener("pointerenter", onPointerEnter);
|
|
401
|
+
target.removeEventListener("pointerleave", onPointerLeave);
|
|
402
|
+
target.removeEventListener("scroll", onScroll);
|
|
403
|
+
resizeObserver.unobserve(target);
|
|
404
|
+
target.removeAttribute("data-sia-floating-scrollbar");
|
|
405
|
+
horizontal.track.remove();
|
|
406
|
+
vertical.track.remove();
|
|
407
|
+
};
|
|
408
|
+
entries.set(target, entry);
|
|
409
|
+
target.setAttribute("data-sia-floating-scrollbar", "");
|
|
410
|
+
resizeObserver.observe(target);
|
|
411
|
+
updateEntry(entry);
|
|
412
|
+
if (entry.hoveringTarget) showEntry(entry);
|
|
413
|
+
};
|
|
414
|
+
const removeTarget = (target) => {
|
|
415
|
+
const entry = entries.get(target);
|
|
416
|
+
if (!entry) return;
|
|
417
|
+
entry.cleanup();
|
|
418
|
+
entries.delete(target);
|
|
419
|
+
};
|
|
420
|
+
const scanTargets = () => {
|
|
421
|
+
scanFrame = 0;
|
|
422
|
+
const managedSelector = ".sia-table__viewport, .sia-scrollbar-track, .sia-floating-scrollbar-layer";
|
|
423
|
+
const discovered = /* @__PURE__ */ new Set();
|
|
424
|
+
if (!targetRef) {
|
|
425
|
+
const roots = fullScan ? [document.body] : [...dirtyStyles].filter((node) => node.isConnected);
|
|
426
|
+
for (const root of roots) {
|
|
427
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
|
|
428
|
+
acceptNode: (node) => node.matches(managedSelector) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
|
|
429
|
+
});
|
|
430
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
431
|
+
if (node instanceof HTMLElement) discovered.add(node);
|
|
432
|
+
}
|
|
433
|
+
for (let node = root; node; node = node.parentElement) discovered.add(node);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
const candidates = (targetRef ? [targetRef.current] : [document.scrollingElement, ...discovered]).filter((target) => target instanceof HTMLElement);
|
|
437
|
+
const nextTargets = /* @__PURE__ */ new Set();
|
|
438
|
+
candidates.forEach((target) => {
|
|
439
|
+
if (canScroll(target, "horizontal") || canScroll(target, "vertical")) {
|
|
440
|
+
nextTargets.add(target);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
nextTargets.forEach((target) => {
|
|
444
|
+
if (entries.has(target) || !target.hasAttribute("data-sia-floating-scrollbar")) addTarget(target);
|
|
445
|
+
});
|
|
446
|
+
entries.forEach((_entry, target) => {
|
|
447
|
+
if (!target.isConnected || (fullScan || candidates.includes(target)) && !nextTargets.has(target)) removeTarget(target);
|
|
448
|
+
else updateEntry(_entry);
|
|
449
|
+
});
|
|
450
|
+
dirtyStyles.clear();
|
|
451
|
+
fullScan = false;
|
|
452
|
+
};
|
|
453
|
+
const scheduleScan = (complete = true) => {
|
|
454
|
+
fullScan ||= complete;
|
|
455
|
+
if (scanFrame) return;
|
|
456
|
+
scanFrame = window.requestAnimationFrame(scanTargets);
|
|
457
|
+
};
|
|
458
|
+
const previousStyle = document.createElement("div").style;
|
|
459
|
+
const positionProperties = /* @__PURE__ */ new Set(["left", "top", "transform"]);
|
|
460
|
+
const mutationObserver = new MutationObserver((mutations) => {
|
|
461
|
+
let relevant = false;
|
|
462
|
+
for (const mutation of mutations) {
|
|
463
|
+
const target = mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
|
|
464
|
+
if (!target || layer.contains(target) || target.closest(".sia-table__viewport, .sia-scrollbar-track, .sia-floating-scrollbar-layer")) continue;
|
|
465
|
+
if (mutation.type === "childList") {
|
|
466
|
+
const changed = [...mutation.addedNodes, ...mutation.removedNodes];
|
|
467
|
+
if (changed.length && changed.every((node) => node instanceof Element && node.matches(".sia-floating-scrollbar-layer, .sia-scrollbar-track"))) continue;
|
|
468
|
+
if (target === document.body && changed.length && changed.every((node) => node instanceof HTMLElement && node.matches(".sia-popup-portal"))) {
|
|
469
|
+
changed.forEach((node) => {
|
|
470
|
+
if (node instanceof HTMLElement && node.isConnected) dirtyStyles.add(node);
|
|
471
|
+
});
|
|
472
|
+
relevant = true;
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
const popup = target.closest(".sia-popup-portal");
|
|
477
|
+
if (popup) {
|
|
478
|
+
dirtyStyles.add(popup);
|
|
479
|
+
relevant = true;
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
if (mutation.type === "attributes" && mutation.attributeName === "class" && target instanceof HTMLElement && target.matches(".sia-select")) {
|
|
483
|
+
const oldClasses = new Set((mutation.oldValue ?? "").split(/\s+/).filter(Boolean));
|
|
484
|
+
const newClasses = new Set(target.classList);
|
|
485
|
+
const changed = [.../* @__PURE__ */ new Set([...oldClasses, ...newClasses])].filter((name) => oldClasses.has(name) !== newClasses.has(name));
|
|
486
|
+
if (changed.every((name) => name === "is-open")) {
|
|
487
|
+
dirtyStyles.add(target);
|
|
488
|
+
relevant = true;
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
relevant = true;
|
|
493
|
+
let positionOnly = false;
|
|
494
|
+
if (mutation.type === "attributes" && mutation.attributeName === "style" && target instanceof HTMLElement) {
|
|
495
|
+
previousStyle.cssText = mutation.oldValue ?? "";
|
|
496
|
+
const keys = /* @__PURE__ */ new Set([...Array.from(previousStyle), ...Array.from(target.style)]);
|
|
497
|
+
const changed = [...keys].filter((key) => previousStyle.getPropertyValue(key) !== target.style.getPropertyValue(key) || previousStyle.getPropertyPriority(key) !== target.style.getPropertyPriority(key));
|
|
498
|
+
if (!changed.length) continue;
|
|
499
|
+
const fixedSize = target.style.width.endsWith("px") && target.style.height.endsWith("px");
|
|
500
|
+
positionOnly = fixedSize && changed.every((key) => positionProperties.has(key)) && ["absolute", "fixed"].includes(getComputedStyle(target).position);
|
|
501
|
+
}
|
|
502
|
+
if (positionOnly && target instanceof HTMLElement) dirtyStyles.add(target);
|
|
503
|
+
else fullScan = true;
|
|
504
|
+
}
|
|
505
|
+
if (relevant) scheduleScan(false);
|
|
506
|
+
});
|
|
507
|
+
mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ["class", "style", "hidden", "data-sia-native-scrollbar", "data-sia-floating-scrollbar"] });
|
|
508
|
+
const onResize = () => scheduleScan();
|
|
509
|
+
window.addEventListener("resize", onResize);
|
|
510
|
+
window.addEventListener("scroll", scheduleUpdateAll, true);
|
|
511
|
+
scheduleScan();
|
|
512
|
+
return () => {
|
|
513
|
+
releaseProximity();
|
|
514
|
+
mutationObserver.disconnect();
|
|
515
|
+
resizeObserver.disconnect();
|
|
516
|
+
window.removeEventListener("resize", onResize);
|
|
517
|
+
window.removeEventListener("scroll", scheduleUpdateAll, true);
|
|
518
|
+
if (scanFrame) window.cancelAnimationFrame(scanFrame);
|
|
519
|
+
if (updateFrame) window.cancelAnimationFrame(updateFrame);
|
|
520
|
+
entries.forEach((entry) => entry.cleanup());
|
|
521
|
+
entries.clear();
|
|
522
|
+
layer.remove();
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
|
|
38
526
|
// src/components/titleTooltip.tsx
|
|
39
527
|
var import_client = require("react-dom/client");
|
|
40
528
|
|
|
41
529
|
// src/components/PopupPortal.tsx
|
|
42
|
-
var
|
|
530
|
+
var import_react4 = require("react");
|
|
43
531
|
var import_react_dom = require("react-dom");
|
|
532
|
+
|
|
533
|
+
// src/components/overlayMotion.ts
|
|
534
|
+
var import_react3 = require("react");
|
|
535
|
+
|
|
536
|
+
// src/components/popupFluidMotion.ts
|
|
537
|
+
var popupEnterDuration = 260;
|
|
538
|
+
var popupExitDuration = 140;
|
|
539
|
+
var popupInitialScale = 0.88;
|
|
540
|
+
var popupTravelOffset = 6;
|
|
541
|
+
function popupFluidFrames(placement, open = true) {
|
|
542
|
+
const side = placement.split("-")[0];
|
|
543
|
+
const axis = side === "left" || side === "right" ? "X" : "Y";
|
|
544
|
+
const sign = side === "left" || side === "top" ? 1 : -1;
|
|
545
|
+
const hidden = { opacity: 0, transform: `translate${axis}(${sign * popupTravelOffset}px) scale(${popupInitialScale})` };
|
|
546
|
+
const visible = { opacity: 1, transform: "none" };
|
|
547
|
+
return open ? [
|
|
548
|
+
{ ...hidden, offset: 0 },
|
|
549
|
+
{ opacity: 1, transform: "scale(1.11, 1.085)", offset: 0.68 },
|
|
550
|
+
{ opacity: 1, transform: "scale(.945, .965)", offset: 0.86 },
|
|
551
|
+
{ ...visible, offset: 1 }
|
|
552
|
+
] : [{ ...visible, offset: 0 }, { ...hidden, offset: 1 }];
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// src/components/overlayMotion.ts
|
|
556
|
+
function motionFrames(kind, placement) {
|
|
557
|
+
if (kind === "fade") return [{ opacity: 0 }, { opacity: 1 }];
|
|
558
|
+
if (kind === "toast") return [
|
|
559
|
+
{ opacity: 0, transform: "translateY(-6px)", offset: 0 },
|
|
560
|
+
{ opacity: 1, transform: "translateY(3px)", offset: 0.68 },
|
|
561
|
+
{ opacity: 1, transform: "translateY(-1px)", offset: 0.86 },
|
|
562
|
+
{ opacity: 1, transform: "none", offset: 1 }
|
|
563
|
+
];
|
|
564
|
+
if (kind === "drawer") {
|
|
565
|
+
const axis = placement === "left" || placement === "right" ? "X" : "Y";
|
|
566
|
+
const sign = placement === "left" || placement === "top" ? -1 : 1;
|
|
567
|
+
const outside = `translate${axis}(${sign * 100}%)`;
|
|
568
|
+
return [
|
|
569
|
+
{ transform: outside, offset: 0 },
|
|
570
|
+
{ transform: `translate${axis}(0) scale${axis}(1.065)`, offset: 0.68 },
|
|
571
|
+
{ transform: `translate${axis}(0) scale${axis}(.975)`, offset: 0.86 },
|
|
572
|
+
{ transform: "none", offset: 1 }
|
|
573
|
+
];
|
|
574
|
+
}
|
|
575
|
+
const modal = kind === "modal";
|
|
576
|
+
return [
|
|
577
|
+
{ opacity: 0, transform: `translateY(${modal ? 18 : -6}px) scale(${modal ? 0.9 : 0.88})`, offset: 0 },
|
|
578
|
+
{ opacity: 1, transform: modal ? "scale(1.075, 1.05)" : "scale(1.11, 1.085)", offset: 0.68 },
|
|
579
|
+
{ opacity: 1, transform: modal ? "scale(.965, .98)" : "scale(.945, .965)", offset: 0.86 },
|
|
580
|
+
{ opacity: 1, transform: "none", offset: 1 }
|
|
581
|
+
];
|
|
582
|
+
}
|
|
583
|
+
function useOverlayMotion(open, ref, kind, placement = "bottom", ready = true, onFinish, enabled = true) {
|
|
584
|
+
const [phase, setPhase] = (0, import_react3.useState)(open ? "entering" : "closed");
|
|
585
|
+
const present = open || phase !== "closed";
|
|
586
|
+
const [entered, setEntered] = (0, import_react3.useState)(false);
|
|
587
|
+
const position = (0, import_react3.useRef)();
|
|
588
|
+
const snapshot = (0, import_react3.useRef)();
|
|
589
|
+
const notify = (0, import_react3.useRef)();
|
|
590
|
+
const callback = (0, import_react3.useRef)(onFinish);
|
|
591
|
+
callback.current = onFinish;
|
|
592
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
593
|
+
const node = ref.current;
|
|
594
|
+
if (!present || !ready || !node) return;
|
|
595
|
+
let cancelled = false;
|
|
596
|
+
let animation;
|
|
597
|
+
let surfaceAnimation;
|
|
598
|
+
let maskAnimation;
|
|
599
|
+
const panel = kind === "drawer" || kind === "modal";
|
|
600
|
+
const fluid = kind === "popup";
|
|
601
|
+
const mask = kind === "modal" ? node.closest(".sia-modal-root") : kind === "drawer" ? node.closest(".sia-drawer-root")?.querySelector(".sia-drawer__mask") : null;
|
|
602
|
+
setPhase(open ? "entering" : "closing");
|
|
603
|
+
const finish = () => {
|
|
604
|
+
if (cancelled) return;
|
|
605
|
+
position.current = void 0;
|
|
606
|
+
snapshot.current = void 0;
|
|
607
|
+
if (open) {
|
|
608
|
+
animation?.cancel();
|
|
609
|
+
surfaceAnimation?.cancel();
|
|
610
|
+
maskAnimation?.cancel();
|
|
611
|
+
}
|
|
612
|
+
notify.current = open;
|
|
613
|
+
setEntered(open);
|
|
614
|
+
setPhase(open ? "open" : "closed");
|
|
615
|
+
node.dispatchEvent(new Event("sia-overlay-motion-end", { bubbles: true }));
|
|
616
|
+
};
|
|
617
|
+
const reduced = node.ownerDocument.defaultView?.matchMedia("(prefers-reduced-motion: reduce)");
|
|
618
|
+
const completeImmediately = () => {
|
|
619
|
+
animation?.cancel();
|
|
620
|
+
surfaceAnimation?.cancel();
|
|
621
|
+
maskAnimation?.cancel();
|
|
622
|
+
finish();
|
|
623
|
+
};
|
|
624
|
+
if (!enabled || reduced?.matches || !node.animate) {
|
|
625
|
+
finish();
|
|
626
|
+
} else {
|
|
627
|
+
let frames = fluid ? popupFluidFrames(placement, open) : motionFrames(kind, placement);
|
|
628
|
+
const start = snapshot.current;
|
|
629
|
+
const enterDuration = fluid ? popupEnterDuration : kind === "drawer" ? 320 : kind === "modal" ? 240 : kind === "fade" ? 180 : 280;
|
|
630
|
+
let duration = fluid && !open ? popupExitDuration : panel && !open ? kind === "drawer" ? 180 : 160 : enterDuration;
|
|
631
|
+
if (fluid && start) {
|
|
632
|
+
const current = new DOMMatrix(start.transform);
|
|
633
|
+
const destination = new DOMMatrix(String(frames[frames.length - 1].transform));
|
|
634
|
+
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));
|
|
635
|
+
frames = [{ offset: 0, transform: start.transform, opacity: start.opacity }, { ...frames[frames.length - 1], offset: 1 }];
|
|
636
|
+
duration *= remaining;
|
|
637
|
+
}
|
|
638
|
+
if (panel) {
|
|
639
|
+
if (!open) frames = [{ transform: start?.transform ?? "none", opacity: start?.opacity ?? 1 }, { ...frames[0], offset: 1 }];
|
|
640
|
+
else if (start) frames = [{ ...frames[0], transform: start.transform, opacity: start.opacity }, ...frames.slice(1)];
|
|
641
|
+
}
|
|
642
|
+
const options = {
|
|
643
|
+
duration,
|
|
644
|
+
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)",
|
|
645
|
+
direction: panel || fluid || open ? "normal" : "reverse",
|
|
646
|
+
fill: "both"
|
|
647
|
+
};
|
|
648
|
+
animation = node.animate(frames, options);
|
|
649
|
+
if (!panel && !fluid && position.current !== void 0) animation.currentTime = open ? position.current : duration - position.current;
|
|
650
|
+
position.current = void 0;
|
|
651
|
+
snapshot.current = void 0;
|
|
652
|
+
if (mask) {
|
|
653
|
+
maskAnimation = mask.animate([{ opacity: start?.maskOpacity ?? (open ? 0 : 1) }, { opacity: open ? 1 : 0 }], { ...options, pseudoElement: kind === "modal" ? "::before" : void 0 });
|
|
654
|
+
maskAnimation.currentTime = animation.currentTime;
|
|
655
|
+
if (animation.startTime !== null) maskAnimation.startTime = animation.startTime;
|
|
656
|
+
}
|
|
657
|
+
if (kind === "toast") {
|
|
658
|
+
const surfaceFrames = motionFrames("message", placement).map((frame) => ({
|
|
659
|
+
offset: frame.offset,
|
|
660
|
+
transform: String(frame.transform).replace(/translateY\([^)]*\)\s*/g, "")
|
|
661
|
+
}));
|
|
662
|
+
surfaceAnimation = node.animate(surfaceFrames, { ...options, pseudoElement: "::before" });
|
|
663
|
+
surfaceAnimation.currentTime = animation.currentTime;
|
|
664
|
+
if (animation.startTime !== null) surfaceAnimation.startTime = animation.startTime;
|
|
665
|
+
}
|
|
666
|
+
animation.finished.then(finish, () => {
|
|
667
|
+
});
|
|
668
|
+
reduced?.addEventListener("change", completeImmediately, { once: true });
|
|
669
|
+
}
|
|
670
|
+
return () => {
|
|
671
|
+
cancelled = true;
|
|
672
|
+
reduced?.removeEventListener("change", completeImmediately);
|
|
673
|
+
if (animation && (animation.playState === "running" || animation.playState === "paused")) {
|
|
674
|
+
if (panel || fluid) {
|
|
675
|
+
const css = node.ownerDocument.defaultView.getComputedStyle(node);
|
|
676
|
+
snapshot.current = {
|
|
677
|
+
transform: css.transform,
|
|
678
|
+
opacity: css.opacity,
|
|
679
|
+
maskOpacity: mask ? node.ownerDocument.defaultView.getComputedStyle(mask, kind === "modal" ? "::before" : null).opacity : void 0
|
|
680
|
+
};
|
|
681
|
+
} else {
|
|
682
|
+
const time = Number(animation.currentTime ?? 0);
|
|
683
|
+
const duration = Number(animation.effect?.getTiming().duration ?? 0);
|
|
684
|
+
position.current = open ? time : duration - time;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
animation?.cancel();
|
|
688
|
+
surfaceAnimation?.cancel();
|
|
689
|
+
maskAnimation?.cancel();
|
|
690
|
+
};
|
|
691
|
+
}, [open, present, ready, kind, placement, enabled, ref]);
|
|
692
|
+
(0, import_react3.useEffect)(() => {
|
|
693
|
+
if (notify.current === void 0) return;
|
|
694
|
+
const completedOpen = notify.current;
|
|
695
|
+
notify.current = void 0;
|
|
696
|
+
if (completedOpen === open) callback.current?.(completedOpen);
|
|
697
|
+
}, [phase, open]);
|
|
698
|
+
return { present, entered, settled: phase === "open", closing: !open, phase };
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// src/components/PopupPortal.tsx
|
|
44
702
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
703
|
function setForwardedRef(ref, value) {
|
|
46
704
|
if (typeof ref === "function") ref(value);
|
|
@@ -49,21 +707,23 @@ function setForwardedRef(ref, value) {
|
|
|
49
707
|
function clamp(value, min, max) {
|
|
50
708
|
return Math.min(Math.max(value, min), Math.max(min, max));
|
|
51
709
|
}
|
|
52
|
-
var PopupPortal = (0,
|
|
710
|
+
var PopupPortal = (0, import_react4.forwardRef)(function PopupPortal2({
|
|
53
711
|
anchorRef,
|
|
54
712
|
open = true,
|
|
55
713
|
placement = "bottom-start",
|
|
56
714
|
offset = 6,
|
|
57
715
|
viewportPadding = 8,
|
|
716
|
+
afterOpenChange,
|
|
58
717
|
className = "",
|
|
59
718
|
style,
|
|
60
719
|
children,
|
|
61
720
|
...props
|
|
62
721
|
}, forwardedRef) {
|
|
63
|
-
const popupRef = (0,
|
|
64
|
-
const [position, setPosition] = (0,
|
|
65
|
-
(
|
|
66
|
-
|
|
722
|
+
const popupRef = (0, import_react4.useRef)(null);
|
|
723
|
+
const [position, setPosition] = (0, import_react4.useState)();
|
|
724
|
+
const motion = useOverlayMotion(open, popupRef, "popup", position?.placement ?? placement, !!position, afterOpenChange);
|
|
725
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
726
|
+
if (!motion.present || typeof document === "undefined") {
|
|
67
727
|
setPosition(void 0);
|
|
68
728
|
return;
|
|
69
729
|
}
|
|
@@ -72,7 +732,7 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
|
|
|
72
732
|
const popup = popupRef.current;
|
|
73
733
|
if (!anchor || !popup) return;
|
|
74
734
|
const anchorRect = anchor.getBoundingClientRect();
|
|
75
|
-
const popupRect = popup.
|
|
735
|
+
const popupRect = { width: popup.offsetWidth, height: popup.offsetHeight };
|
|
76
736
|
const viewportWidth = document.documentElement.clientWidth;
|
|
77
737
|
const viewportHeight = document.documentElement.clientHeight;
|
|
78
738
|
let resolvedPlacement = placement;
|
|
@@ -114,18 +774,28 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
|
|
|
114
774
|
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);
|
|
115
775
|
};
|
|
116
776
|
update();
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
777
|
+
let frame = 0;
|
|
778
|
+
const schedule = () => {
|
|
779
|
+
if (!frame) frame = requestAnimationFrame(() => {
|
|
780
|
+
frame = 0;
|
|
781
|
+
update();
|
|
782
|
+
});
|
|
783
|
+
};
|
|
784
|
+
window.addEventListener("resize", schedule);
|
|
785
|
+
window.addEventListener("scroll", schedule, true);
|
|
786
|
+
window.addEventListener("sia-overlay-motion-end", schedule);
|
|
787
|
+
const observer = new ResizeObserver(schedule);
|
|
120
788
|
if (anchorRef.current) observer.observe(anchorRef.current);
|
|
121
789
|
if (popupRef.current) observer.observe(popupRef.current);
|
|
122
790
|
return () => {
|
|
123
|
-
window.removeEventListener("resize",
|
|
124
|
-
window.removeEventListener("scroll",
|
|
791
|
+
window.removeEventListener("resize", schedule);
|
|
792
|
+
window.removeEventListener("scroll", schedule, true);
|
|
793
|
+
window.removeEventListener("sia-overlay-motion-end", schedule);
|
|
794
|
+
cancelAnimationFrame(frame);
|
|
125
795
|
observer.disconnect();
|
|
126
796
|
};
|
|
127
|
-
}, [anchorRef, offset,
|
|
128
|
-
if (!
|
|
797
|
+
}, [anchorRef, offset, motion.present, placement, viewportPadding]);
|
|
798
|
+
if (!motion.present || typeof document === "undefined") return null;
|
|
129
799
|
return (0, import_react_dom.createPortal)(
|
|
130
800
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
131
801
|
"div",
|
|
@@ -137,13 +807,19 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
|
|
|
137
807
|
className: `sia-popup-portal ${className}`.trim(),
|
|
138
808
|
"data-sia-popup-layer": "",
|
|
139
809
|
"data-placement": position?.placement ?? placement,
|
|
810
|
+
"data-state": motion.closing ? "closing" : "open",
|
|
811
|
+
"aria-hidden": motion.closing || void 0,
|
|
140
812
|
style: {
|
|
141
813
|
...style,
|
|
142
814
|
"--sia-popup-anchor-width": `${position?.anchorWidth ?? anchorRef.current?.getBoundingClientRect().width ?? 0}px`,
|
|
143
815
|
"--sia-popup-available-height": position ? `${position.availableHeight}px` : void 0,
|
|
144
816
|
top: position?.top ?? 0,
|
|
145
817
|
left: position?.left ?? 0,
|
|
146
|
-
visibility: position ? "visible" : "hidden"
|
|
818
|
+
visibility: position ? "visible" : "hidden",
|
|
819
|
+
animation: "none",
|
|
820
|
+
pointerEvents: motion.closing ? "none" : style?.pointerEvents,
|
|
821
|
+
// 以靠近触发器的边缘中心为缩放原点,业务显式原点优先。
|
|
822
|
+
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")
|
|
147
823
|
},
|
|
148
824
|
...withTitleTooltip(props),
|
|
149
825
|
children
|
|
@@ -155,7 +831,7 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
|
|
|
155
831
|
|
|
156
832
|
// src/components/titleTooltip.tsx
|
|
157
833
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
158
|
-
var
|
|
834
|
+
var installedKey = /* @__PURE__ */ Symbol.for("sia.ui.titleTooltip.installed");
|
|
159
835
|
function withTitleTooltip(props) {
|
|
160
836
|
if (!props || typeof props !== "object" || !("title" in props)) return props;
|
|
161
837
|
const { title, ...rest } = props;
|
|
@@ -163,8 +839,9 @@ function withTitleTooltip(props) {
|
|
|
163
839
|
return { ...rest, "data-sia-title": title == null ? void 0 : String(title) };
|
|
164
840
|
}
|
|
165
841
|
function installTitleTooltips(doc) {
|
|
166
|
-
|
|
167
|
-
|
|
842
|
+
const owner = doc;
|
|
843
|
+
if (owner[installedKey]) return;
|
|
844
|
+
owner[installedKey] = true;
|
|
168
845
|
let hovered = null;
|
|
169
846
|
let focused = null;
|
|
170
847
|
let keyboardFocus = true;
|
|
@@ -198,8 +875,23 @@ function installTitleTooltips(doc) {
|
|
|
198
875
|
if (ids.length) active.setAttribute("aria-describedby", ids.join(" "));
|
|
199
876
|
else active.removeAttribute("aria-describedby");
|
|
200
877
|
}
|
|
878
|
+
const closing = active;
|
|
201
879
|
active = null;
|
|
202
|
-
root
|
|
880
|
+
if (closing && root) root.render(/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
881
|
+
PopupPortal,
|
|
882
|
+
{
|
|
883
|
+
anchorRef: { current: closing },
|
|
884
|
+
open: false,
|
|
885
|
+
placement: "top-start",
|
|
886
|
+
id: tooltipId,
|
|
887
|
+
role: "tooltip",
|
|
888
|
+
className: "sia-title-tooltip",
|
|
889
|
+
afterOpenChange: (opened) => {
|
|
890
|
+
if (!opened && !active) root?.render(null);
|
|
891
|
+
},
|
|
892
|
+
children: closing.getAttribute("data-sia-title")
|
|
893
|
+
}
|
|
894
|
+
));
|
|
203
895
|
};
|
|
204
896
|
const render = () => {
|
|
205
897
|
const text = active?.getAttribute("data-sia-title");
|
|
@@ -297,22 +989,22 @@ function installTitleTooltips(doc) {
|
|
|
297
989
|
}
|
|
298
990
|
|
|
299
991
|
// src/components/shared.ts
|
|
300
|
-
var
|
|
301
|
-
var ControlSizeContext = (0,
|
|
992
|
+
var import_react5 = require("react");
|
|
993
|
+
var ControlSizeContext = (0, import_react5.createContext)("medium");
|
|
302
994
|
function useControlSize(size) {
|
|
303
|
-
const inherited = (0,
|
|
995
|
+
const inherited = (0, import_react5.useContext)(ControlSizeContext);
|
|
304
996
|
return size ?? inherited;
|
|
305
997
|
}
|
|
306
|
-
var PlaceholderModeContext = (0,
|
|
998
|
+
var PlaceholderModeContext = (0, import_react5.createContext)("default");
|
|
307
999
|
function usePlaceholderMode(mode) {
|
|
308
|
-
const inherited = (0,
|
|
1000
|
+
const inherited = (0, import_react5.useContext)(PlaceholderModeContext);
|
|
309
1001
|
return mode ?? inherited;
|
|
310
1002
|
}
|
|
311
1003
|
function useControllableState({ value, defaultValue, onChange }) {
|
|
312
|
-
const [internalValue, setInternalValue] = (0,
|
|
1004
|
+
const [internalValue, setInternalValue] = (0, import_react5.useState)(defaultValue);
|
|
313
1005
|
const controlled = value !== void 0;
|
|
314
1006
|
const currentValue = controlled ? value : internalValue;
|
|
315
|
-
const setValue = (0,
|
|
1007
|
+
const setValue = (0, import_react5.useCallback)((nextValue) => {
|
|
316
1008
|
if (Object.is(currentValue, nextValue)) return;
|
|
317
1009
|
if (!controlled) setInternalValue(nextValue);
|
|
318
1010
|
onChange?.(nextValue);
|
|
@@ -332,7 +1024,7 @@ function useFloatingPlaceholder({ mode, placeholder, filled, active = false }) {
|
|
|
332
1024
|
}
|
|
333
1025
|
|
|
334
1026
|
// src/components/RichTextEditor.tsx
|
|
335
|
-
var
|
|
1027
|
+
var import_react18 = require("react");
|
|
336
1028
|
var import_dompurify = __toESM(require("dompurify"), 1);
|
|
337
1029
|
var import_core = require("@tiptap/core");
|
|
338
1030
|
var import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
|
|
@@ -347,9 +1039,9 @@ var import_extension_task_item = __toESM(require("@tiptap/extension-task-item"),
|
|
|
347
1039
|
var import_markdown = require("@tiptap/markdown");
|
|
348
1040
|
|
|
349
1041
|
// src/components/Button.tsx
|
|
350
|
-
var
|
|
1042
|
+
var import_react6 = require("react");
|
|
351
1043
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
352
|
-
var Button = (0,
|
|
1044
|
+
var Button = (0, import_react6.forwardRef)(function Button2({
|
|
353
1045
|
variant = "default",
|
|
354
1046
|
size: sizeProp,
|
|
355
1047
|
loading = false,
|
|
@@ -365,7 +1057,33 @@ var Button = (0, import_react3.forwardRef)(function Button2({
|
|
|
365
1057
|
...props
|
|
366
1058
|
}, forwardedRef) {
|
|
367
1059
|
const size = useControlSize(sizeProp);
|
|
368
|
-
const localRef = (0,
|
|
1060
|
+
const localRef = (0, import_react6.useRef)(null);
|
|
1061
|
+
const bounceRef = (0, import_react6.useRef)(null);
|
|
1062
|
+
const waveTimerRef = (0, import_react6.useRef)();
|
|
1063
|
+
(0, import_react6.useEffect)(() => () => {
|
|
1064
|
+
bounceRef.current?.cancel();
|
|
1065
|
+
window.clearTimeout(waveTimerRef.current);
|
|
1066
|
+
}, []);
|
|
1067
|
+
function playBounce(button) {
|
|
1068
|
+
if (!button.animate || window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
|
1069
|
+
const current = getComputedStyle(button).scale;
|
|
1070
|
+
bounceRef.current?.cancel();
|
|
1071
|
+
const base = getComputedStyle(button).scale;
|
|
1072
|
+
const [x = 1, y = x] = base === "none" ? [] : base.split(/\s+/).map(Number);
|
|
1073
|
+
const scaled = (factor) => `${x * factor} ${y * factor}`;
|
|
1074
|
+
const animation = button.animate([
|
|
1075
|
+
{ scale: current === "none" ? "1" : current, offset: 0 },
|
|
1076
|
+
// 宽按钮保持等比缩放,以更明显的过冲表现弹性但不改变布局占位。
|
|
1077
|
+
{ scale: scaled(0.9), offset: 0.2 },
|
|
1078
|
+
{ scale: scaled(1.09), offset: 0.52 },
|
|
1079
|
+
{ scale: scaled(0.96), offset: 0.78 },
|
|
1080
|
+
{ scale: scaled(1), offset: 1 }
|
|
1081
|
+
], { duration: 320, easing: "cubic-bezier(.3, 0, .25, 1)" });
|
|
1082
|
+
bounceRef.current = animation;
|
|
1083
|
+
animation.onfinish = () => {
|
|
1084
|
+
if (bounceRef.current === animation) bounceRef.current = null;
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
369
1087
|
function setRef(node) {
|
|
370
1088
|
localRef.current = node;
|
|
371
1089
|
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
@@ -373,12 +1091,15 @@ var Button = (0, import_react3.forwardRef)(function Button2({
|
|
|
373
1091
|
}
|
|
374
1092
|
function handleClick(event) {
|
|
375
1093
|
const button = localRef.current;
|
|
1094
|
+
if (disabled || loading) return;
|
|
1095
|
+
if (button) playBounce(button);
|
|
376
1096
|
if (button && variant === "primary") {
|
|
377
1097
|
const rect = button.getBoundingClientRect();
|
|
378
|
-
button.style.setProperty("--sia-wave-x", `${event.clientX - rect.left}px`);
|
|
379
|
-
button.style.setProperty("--sia-wave-y", `${event.clientY - rect.top}px`);
|
|
1098
|
+
button.style.setProperty("--sia-wave-x", `${event.detail === 0 ? button.offsetWidth / 2 : (event.clientX - rect.left) * button.offsetWidth / rect.width}px`);
|
|
1099
|
+
button.style.setProperty("--sia-wave-y", `${event.detail === 0 ? button.offsetHeight / 2 : (event.clientY - rect.top) * button.offsetHeight / rect.height}px`);
|
|
380
1100
|
button.dataset.wave = "active";
|
|
381
|
-
window.
|
|
1101
|
+
window.clearTimeout(waveTimerRef.current);
|
|
1102
|
+
waveTimerRef.current = window.setTimeout(() => delete button.dataset.wave, 360);
|
|
382
1103
|
}
|
|
383
1104
|
onClick?.(event);
|
|
384
1105
|
}
|
|
@@ -404,10 +1125,10 @@ var Button = (0, import_react3.forwardRef)(function Button2({
|
|
|
404
1125
|
});
|
|
405
1126
|
|
|
406
1127
|
// src/components/Dropdown.tsx
|
|
407
|
-
var
|
|
1128
|
+
var import_react12 = require("react");
|
|
408
1129
|
|
|
409
1130
|
// src/components/Icon.tsx
|
|
410
|
-
var
|
|
1131
|
+
var import_react8 = require("react");
|
|
411
1132
|
|
|
412
1133
|
// src/components/IconCatalog.tsx
|
|
413
1134
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -1218,13 +1939,13 @@ var filledIconBounds = {
|
|
|
1218
1939
|
};
|
|
1219
1940
|
|
|
1220
1941
|
// src/components/iconGeometry.tsx
|
|
1221
|
-
var
|
|
1942
|
+
var import_react7 = require("react");
|
|
1222
1943
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1223
1944
|
function compensateStroke(node, scale) {
|
|
1224
|
-
return
|
|
1225
|
-
if (!(0,
|
|
1945
|
+
return import_react7.Children.map(node, (child) => {
|
|
1946
|
+
if (!(0, import_react7.isValidElement)(child)) return child;
|
|
1226
1947
|
const props = child.props;
|
|
1227
|
-
return (0,
|
|
1948
|
+
return (0, import_react7.cloneElement)(child, {
|
|
1228
1949
|
...props.strokeWidth === void 0 ? {} : { strokeWidth: Number(props.strokeWidth) / scale },
|
|
1229
1950
|
...props.children === void 0 ? {} : { children: compensateStroke(props.children, scale) }
|
|
1230
1951
|
});
|
|
@@ -1556,7 +2277,7 @@ var filledIconPaths = {
|
|
|
1556
2277
|
var FILLED_ICON_NAMES = Object.freeze(Object.keys(filledIconPaths));
|
|
1557
2278
|
var normalizedOutlinePaths = normalizeIconPaths(iconPaths, outlineIconBounds);
|
|
1558
2279
|
var normalizedFilledPaths = normalizeIconPaths(filledIconPaths, filledIconBounds);
|
|
1559
|
-
var Icon = (0,
|
|
2280
|
+
var Icon = (0, import_react8.forwardRef)(function Icon2({ name, tone = "inherit", size = "1em", strokeWidth = 1.8, rotate = 0, spin = false, pulse = false, label, variant = "outline", className = "", style, ...props }, ref) {
|
|
1560
2281
|
const resolvedSize = typeof size === "number" ? `${size}px` : size;
|
|
1561
2282
|
const toneColor = tone === "inherit" ? void 0 : `var(--sia-color-${tone === "danger" ? "error" : tone === "primary" ? "primary-text" : tone})`;
|
|
1562
2283
|
const mergedStyle = { "--sia-icon-size": resolvedSize, "--sia-icon-rotate": `${rotate}deg`, color: toneColor, ...style };
|
|
@@ -1581,22 +2302,100 @@ var Icon = (0, import_react5.forwardRef)(function Icon2({ name, tone = "inherit"
|
|
|
1581
2302
|
});
|
|
1582
2303
|
|
|
1583
2304
|
// src/components/Navigation.tsx
|
|
1584
|
-
var
|
|
2305
|
+
var import_react10 = require("react");
|
|
1585
2306
|
|
|
1586
|
-
// src/components/
|
|
1587
|
-
var
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
2307
|
+
// src/components/MenuSelectionMotion.tsx
|
|
2308
|
+
var import_react9 = require("react");
|
|
2309
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2310
|
+
function MenuSelectionMotion({ rootRef, enabled }) {
|
|
2311
|
+
const indicatorRef = (0, import_react9.useRef)(null);
|
|
2312
|
+
const previous = (0, import_react9.useRef)();
|
|
2313
|
+
const animation = (0, import_react9.useRef)();
|
|
2314
|
+
(0, import_react9.useLayoutEffect)(() => {
|
|
2315
|
+
const indicator = indicatorRef.current;
|
|
2316
|
+
const root = rootRef.current ?? indicator?.parentElement;
|
|
2317
|
+
if (!root || !indicator) return;
|
|
2318
|
+
let frame = 0;
|
|
2319
|
+
const media = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
2320
|
+
const update = () => {
|
|
2321
|
+
const candidates = [...root.querySelectorAll(".sia-menu__entry.is-selected > .sia-menu__item")].filter((button) => button.closest(".sia-menu-motion-surface") === root && !button.closest('[aria-hidden="true"]') && button.getClientRects().length > 0);
|
|
2322
|
+
const target = enabled && candidates.length === 1 ? candidates[0] : void 0;
|
|
2323
|
+
root.querySelectorAll("[data-sia-menu-highlight]").forEach((button) => {
|
|
2324
|
+
if (button !== target && button.closest(".sia-menu-motion-surface") === root) button.removeAttribute("data-sia-menu-highlight");
|
|
2325
|
+
});
|
|
2326
|
+
if (!target || root.offsetWidth === 0) {
|
|
2327
|
+
animation.current?.cancel();
|
|
2328
|
+
indicator.style.display = "none";
|
|
2329
|
+
previous.current = void 0;
|
|
2330
|
+
return;
|
|
2331
|
+
}
|
|
2332
|
+
const bounds = root.getBoundingClientRect();
|
|
2333
|
+
const scaleX = bounds.width / root.offsetWidth || 1;
|
|
2334
|
+
const scaleY = bounds.height / root.offsetHeight || 1;
|
|
2335
|
+
const box = (node) => {
|
|
2336
|
+
const rect = node.getBoundingClientRect();
|
|
2337
|
+
return { x: (rect.left - bounds.left) / scaleX + root.scrollLeft - root.clientLeft, y: (rect.top - bounds.top) / scaleY + root.scrollTop - root.clientTop, width: rect.width / scaleX, height: rect.height / scaleY };
|
|
2338
|
+
};
|
|
2339
|
+
const next = { ...box(target), key: target.dataset.menuKey ?? "" };
|
|
2340
|
+
if (!target.hasAttribute("data-sia-menu-highlight")) target.dataset.siaMenuHighlight = "";
|
|
2341
|
+
indicator.style.borderRadius = getComputedStyle(target).borderRadius;
|
|
2342
|
+
indicator.style.opacity = target.parentElement ? getComputedStyle(target.parentElement).opacity : "1";
|
|
2343
|
+
const last = previous.current;
|
|
2344
|
+
if (last && last.key === next.key && ["x", "y", "width", "height"].every((key) => Math.abs(last[key] - next[key]) < 0.5)) return;
|
|
2345
|
+
const from = animation.current?.playState === "running" ? box(indicator) : last;
|
|
2346
|
+
animation.current?.cancel();
|
|
2347
|
+
indicator.style.display = "block";
|
|
2348
|
+
indicator.style.width = `${next.width}px`;
|
|
2349
|
+
indicator.style.height = `${next.height}px`;
|
|
2350
|
+
indicator.style.transform = `translate(${next.x}px, ${next.y}px)`;
|
|
2351
|
+
previous.current = next;
|
|
2352
|
+
if (from && last?.key !== next.key && !media.matches && indicator.animate) {
|
|
2353
|
+
const running = indicator.animate([
|
|
2354
|
+
{ transform: `translate(${from.x}px, ${from.y}px) scale(${from.width / next.width}, ${from.height / next.height})` },
|
|
2355
|
+
{ transform: `translate(${next.x}px, ${next.y}px) scale(1)` }
|
|
2356
|
+
], { duration: 260, easing: "cubic-bezier(.22,.8,.25,1)" });
|
|
2357
|
+
animation.current = running;
|
|
2358
|
+
running.finished.then(() => {
|
|
2359
|
+
if (animation.current === running) {
|
|
2360
|
+
running.cancel();
|
|
2361
|
+
animation.current = void 0;
|
|
2362
|
+
}
|
|
2363
|
+
}, () => {
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
};
|
|
2367
|
+
const schedule = () => {
|
|
2368
|
+
if (!frame) frame = requestAnimationFrame(() => {
|
|
2369
|
+
frame = 0;
|
|
2370
|
+
update();
|
|
2371
|
+
});
|
|
2372
|
+
};
|
|
2373
|
+
const reduceMotion = () => {
|
|
2374
|
+
animation.current?.cancel();
|
|
2375
|
+
update();
|
|
2376
|
+
};
|
|
2377
|
+
update();
|
|
2378
|
+
const observer = new ResizeObserver(schedule);
|
|
2379
|
+
observer.observe(root);
|
|
2380
|
+
root.querySelectorAll(".sia-menu__item").forEach((button) => observer.observe(button));
|
|
2381
|
+
root.addEventListener("transitionend", schedule);
|
|
2382
|
+
media.addEventListener("change", reduceMotion);
|
|
2383
|
+
return () => {
|
|
2384
|
+
observer.disconnect();
|
|
2385
|
+
cancelAnimationFrame(frame);
|
|
2386
|
+
root.removeEventListener("transitionend", schedule);
|
|
2387
|
+
media.removeEventListener("change", reduceMotion);
|
|
2388
|
+
};
|
|
2389
|
+
});
|
|
2390
|
+
(0, import_react9.useLayoutEffect)(() => () => {
|
|
2391
|
+
animation.current?.cancel();
|
|
2392
|
+
}, []);
|
|
2393
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { ref: indicatorRef, className: "sia-menu__selection", role: "presentation", "aria-hidden": "true" });
|
|
1595
2394
|
}
|
|
1596
2395
|
|
|
1597
2396
|
// src/components/Navigation.tsx
|
|
1598
|
-
var
|
|
1599
|
-
var
|
|
2397
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2398
|
+
var import_react11 = require("react");
|
|
1600
2399
|
function MenuPopup({
|
|
1601
2400
|
anchorRef,
|
|
1602
2401
|
popupRef,
|
|
@@ -1605,35 +2404,28 @@ function MenuPopup({
|
|
|
1605
2404
|
placement,
|
|
1606
2405
|
menuId,
|
|
1607
2406
|
theme,
|
|
2407
|
+
multiple,
|
|
1608
2408
|
children,
|
|
1609
2409
|
onMouseEnter,
|
|
1610
2410
|
onMouseLeave
|
|
1611
2411
|
}) {
|
|
1612
|
-
const
|
|
1613
|
-
const [fontSize, setFontSize] = (0,
|
|
1614
|
-
(0,
|
|
2412
|
+
const listRef = (0, import_react10.useRef)(null);
|
|
2413
|
+
const [fontSize, setFontSize] = (0, import_react10.useState)();
|
|
2414
|
+
(0, import_react10.useLayoutEffect)(() => {
|
|
1615
2415
|
const anchor = anchorRef.current;
|
|
1616
|
-
if (!
|
|
2416
|
+
if (!open || !anchor) return;
|
|
1617
2417
|
const syncFontSize = () => setFontSize(getComputedStyle(anchor).fontSize);
|
|
1618
2418
|
syncFontSize();
|
|
1619
2419
|
const observer = new ResizeObserver(syncFontSize);
|
|
1620
2420
|
observer.observe(anchor);
|
|
1621
2421
|
return () => observer.disconnect();
|
|
1622
|
-
});
|
|
1623
|
-
(0,
|
|
1624
|
-
if (open) {
|
|
1625
|
-
setMounted(true);
|
|
1626
|
-
return void 0;
|
|
1627
|
-
}
|
|
1628
|
-
const timer = window.setTimeout(() => setMounted(false), 160);
|
|
1629
|
-
return () => window.clearTimeout(timer);
|
|
1630
|
-
}, [open]);
|
|
1631
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2422
|
+
}, [open, anchorRef, children]);
|
|
2423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1632
2424
|
PopupPortal,
|
|
1633
2425
|
{
|
|
1634
2426
|
ref: popupRef,
|
|
1635
2427
|
anchorRef,
|
|
1636
|
-
open
|
|
2428
|
+
open,
|
|
1637
2429
|
placement,
|
|
1638
2430
|
offset: placement.startsWith("right") || placement.startsWith("left") ? 16 : 4,
|
|
1639
2431
|
className: `sia-menu__popup sia-menu--${theme}${open ? " is-open" : " is-closing"}`,
|
|
@@ -1642,7 +2434,10 @@ function MenuPopup({
|
|
|
1642
2434
|
"data-sia-menu-path": JSON.stringify(keyPath),
|
|
1643
2435
|
onMouseEnter,
|
|
1644
2436
|
onMouseLeave,
|
|
1645
|
-
children: /* @__PURE__ */ (0,
|
|
2437
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("ul", { ref: listRef, className: "sia-menu__popup-list sia-menu-motion-surface", role: "menu", children: [
|
|
2438
|
+
children,
|
|
2439
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MenuSelectionMotion, { rootRef: listRef, enabled: !multiple })
|
|
2440
|
+
] })
|
|
1646
2441
|
}
|
|
1647
2442
|
);
|
|
1648
2443
|
}
|
|
@@ -1653,11 +2448,12 @@ function MenuEntry({
|
|
|
1653
2448
|
props,
|
|
1654
2449
|
reserveIcon
|
|
1655
2450
|
}) {
|
|
1656
|
-
const anchorRef = (0,
|
|
1657
|
-
const popupRef = (0,
|
|
1658
|
-
const
|
|
1659
|
-
const
|
|
1660
|
-
(0,
|
|
2451
|
+
const anchorRef = (0, import_react10.useRef)(null);
|
|
2452
|
+
const popupRef = (0, import_react10.useRef)(null);
|
|
2453
|
+
const submenuRef = (0, import_react10.useRef)(null);
|
|
2454
|
+
const closeTimerRef = (0, import_react10.useRef)(void 0);
|
|
2455
|
+
const toggleRef = (0, import_react10.useRef)(props.toggle);
|
|
2456
|
+
(0, import_react10.useLayoutEffect)(() => {
|
|
1661
2457
|
toggleRef.current = props.toggle;
|
|
1662
2458
|
});
|
|
1663
2459
|
const hasChildren = Boolean(item.children?.length);
|
|
@@ -1666,7 +2462,24 @@ function MenuEntry({
|
|
|
1666
2462
|
const path = [item.key, ...parents];
|
|
1667
2463
|
const collapsed = props.inlineCollapsed && level === 0;
|
|
1668
2464
|
const inlineSubmenu = props.mode === "inline" && !collapsed;
|
|
1669
|
-
(0,
|
|
2465
|
+
(0, import_react10.useLayoutEffect)(() => {
|
|
2466
|
+
const submenu2 = submenuRef.current;
|
|
2467
|
+
if (!inlineSubmenu || !submenu2) return;
|
|
2468
|
+
const measure = () => {
|
|
2469
|
+
const children = [...submenu2.children].filter((child) => !child.classList.contains("sia-menu__selection"));
|
|
2470
|
+
const first = children[0], last = children.at(-1);
|
|
2471
|
+
if (!first || !last) return;
|
|
2472
|
+
const height = `${Math.ceil(last.offsetTop + last.offsetHeight - first.offsetTop + parseFloat(getComputedStyle(first).marginTop) + parseFloat(getComputedStyle(last).marginBottom) + 8)}px`;
|
|
2473
|
+
if (submenu2.style.getPropertyValue("--sia-menu-submenu-height") !== height)
|
|
2474
|
+
submenu2.style.setProperty("--sia-menu-submenu-height", height);
|
|
2475
|
+
};
|
|
2476
|
+
measure();
|
|
2477
|
+
const observer = new ResizeObserver(measure);
|
|
2478
|
+
for (const child of submenu2.children)
|
|
2479
|
+
if (child.classList.contains("sia-menu__entry") || child.classList.contains("sia-menu__group")) observer.observe(child);
|
|
2480
|
+
return () => observer.disconnect();
|
|
2481
|
+
}, [inlineSubmenu, item.children, isOpen]);
|
|
2482
|
+
(0, import_react10.useEffect)(() => () => {
|
|
1670
2483
|
if (closeTimerRef.current !== void 0) window.clearTimeout(closeTimerRef.current);
|
|
1671
2484
|
}, []);
|
|
1672
2485
|
function cancelClose() {
|
|
@@ -1687,9 +2500,9 @@ function MenuEntry({
|
|
|
1687
2500
|
}, 100);
|
|
1688
2501
|
}
|
|
1689
2502
|
const hover = props.triggerSubMenuAction === "hover" && hasChildren && !inlineSubmenu;
|
|
1690
|
-
const submenu = hasChildren ? /* @__PURE__ */ (0,
|
|
2503
|
+
const submenu = hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MenuLevel, { items: item.children ?? [], level: level + 1, parents: [item.key, ...parents], props }) : null;
|
|
1691
2504
|
const popupPlacement = props.mode === "horizontal" && level === 0 ? "bottom-start" : "right-start";
|
|
1692
|
-
return /* @__PURE__ */ (0,
|
|
2505
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1693
2506
|
"li",
|
|
1694
2507
|
{
|
|
1695
2508
|
className: `sia-menu__entry${isOpen ? " is-open" : ""}${isSelected ? " is-selected" : ""}${item.disabled ? " is-disabled" : ""}${item.danger ? " is-danger" : ""}`,
|
|
@@ -1699,7 +2512,7 @@ function MenuEntry({
|
|
|
1699
2512
|
} : void 0,
|
|
1700
2513
|
onMouseLeave: hover ? scheduleClose : void 0,
|
|
1701
2514
|
children: [
|
|
1702
|
-
/* @__PURE__ */ (0,
|
|
2515
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1703
2516
|
"button",
|
|
1704
2517
|
{
|
|
1705
2518
|
ref: anchorRef,
|
|
@@ -1709,21 +2522,25 @@ function MenuEntry({
|
|
|
1709
2522
|
style: { paddingInlineStart: props.mode === "inline" && !props.inlineCollapsed ? 12 + level * props.inlineIndent : void 0 },
|
|
1710
2523
|
...withTitleTooltip({ title: collapsed ? item.title ?? (typeof item.label === "string" ? item.label : void 0) : item.title }),
|
|
1711
2524
|
disabled: item.disabled,
|
|
2525
|
+
"aria-label": collapsed ? item.title ?? (typeof item.label === "string" ? item.label : void 0) : void 0,
|
|
1712
2526
|
"aria-current": isSelected ? "page" : void 0,
|
|
1713
2527
|
"data-menu-key": item.key,
|
|
1714
2528
|
"data-applied": item.applied || void 0,
|
|
1715
2529
|
"aria-expanded": hasChildren ? isOpen : void 0,
|
|
1716
2530
|
onClick: (event) => hasChildren ? props.toggle(item.key) : props.select(item, path, event),
|
|
1717
2531
|
children: [
|
|
1718
|
-
reserveIcon ? /* @__PURE__ */ (0,
|
|
1719
|
-
item.applied ? /* @__PURE__ */ (0,
|
|
1720
|
-
!collapsed ? /* @__PURE__ */ (0,
|
|
1721
|
-
!collapsed && item.extra ? /* @__PURE__ */ (0,
|
|
1722
|
-
!collapsed && hasChildren ? /* @__PURE__ */ (0,
|
|
2532
|
+
reserveIcon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "sia-menu__icon", style: item.iconSize ? { width: item.iconSize, height: item.iconSize, flexBasis: item.iconSize } : void 0, "aria-hidden": !item.icon || void 0, children: item.icon }) : null,
|
|
2533
|
+
item.applied ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "sia-menu__applied", role: "img", "aria-label": item.appliedLabel ?? "\u5F53\u524D\u4F7F\u7528", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "circle-check", variant: "filled", size: 32 }) }) : null,
|
|
2534
|
+
!collapsed ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "sia-menu__label", children: item.label }) : null,
|
|
2535
|
+
!collapsed && item.extra ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "sia-menu__extra", children: item.extra }) : null,
|
|
2536
|
+
!collapsed && hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { className: "sia-menu__expand-icon", name: "chevron-down", size: 13 }) : null
|
|
1723
2537
|
]
|
|
1724
2538
|
}
|
|
1725
2539
|
),
|
|
1726
|
-
hasChildren ? inlineSubmenu ? /* @__PURE__ */ (0,
|
|
2540
|
+
hasChildren ? inlineSubmenu ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("ul", { ref: submenuRef, className: "sia-menu__submenu sia-menu-motion-surface", role: "menu", "aria-hidden": !isOpen, children: [
|
|
2541
|
+
submenu,
|
|
2542
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MenuSelectionMotion, { rootRef: submenuRef, enabled: !props.multiple })
|
|
2543
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1727
2544
|
MenuPopup,
|
|
1728
2545
|
{
|
|
1729
2546
|
anchorRef,
|
|
@@ -1733,6 +2550,7 @@ function MenuEntry({
|
|
|
1733
2550
|
placement: popupPlacement,
|
|
1734
2551
|
menuId: props.menuId,
|
|
1735
2552
|
theme: props.theme,
|
|
2553
|
+
multiple: props.multiple,
|
|
1736
2554
|
onMouseEnter: hover ? cancelClose : void 0,
|
|
1737
2555
|
onMouseLeave: hover ? scheduleClose : void 0,
|
|
1738
2556
|
children: submenu
|
|
@@ -1752,13 +2570,13 @@ function MenuLevel({
|
|
|
1752
2570
|
props,
|
|
1753
2571
|
reserveIcon = hasMenuIcon(items)
|
|
1754
2572
|
}) {
|
|
1755
|
-
return /* @__PURE__ */ (0,
|
|
1756
|
-
if (item.type === "divider") return /* @__PURE__ */ (0,
|
|
1757
|
-
if (item.type === "group") return /* @__PURE__ */ (0,
|
|
1758
|
-
/* @__PURE__ */ (0,
|
|
1759
|
-
/* @__PURE__ */ (0,
|
|
2573
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: items.map((item, index) => {
|
|
2574
|
+
if (item.type === "divider") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { className: "sia-menu__divider", role: "separator" }, item.key || `divider-${index}`);
|
|
2575
|
+
if (item.type === "group") return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("li", { className: "sia-menu__group", children: [
|
|
2576
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "sia-menu__group-title", children: item.label }),
|
|
2577
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { role: "group", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MenuLevel, { items: item.children ?? [], level: level + 1, parents: [...parents, item.key], props, reserveIcon }) })
|
|
1760
2578
|
] }, item.key);
|
|
1761
|
-
return /* @__PURE__ */ (0,
|
|
2579
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MenuEntry, { item, level, parents, props, reserveIcon }, item.key);
|
|
1762
2580
|
}) });
|
|
1763
2581
|
}
|
|
1764
2582
|
function Menu({
|
|
@@ -1785,15 +2603,15 @@ function Menu({
|
|
|
1785
2603
|
style,
|
|
1786
2604
|
...rest
|
|
1787
2605
|
}) {
|
|
1788
|
-
const menuId = (0,
|
|
1789
|
-
const rootRef = (0,
|
|
2606
|
+
const menuId = (0, import_react10.useId)();
|
|
2607
|
+
const rootRef = (0, import_react10.useRef)(null);
|
|
1790
2608
|
const [selected, setSelected] = useControllableState({ value: selectedKeys, defaultValue: defaultSelectedKeys });
|
|
1791
2609
|
const [open, setOpen] = useControllableState({ value: openKeys, defaultValue: defaultOpenKeys, onChange: (next) => onOpenChange?.([...next]) });
|
|
1792
|
-
const pendingOpenRef = (0,
|
|
1793
|
-
(0,
|
|
2610
|
+
const pendingOpenRef = (0, import_react10.useRef)(open);
|
|
2611
|
+
(0, import_react10.useLayoutEffect)(() => {
|
|
1794
2612
|
pendingOpenRef.current = open;
|
|
1795
2613
|
});
|
|
1796
|
-
const popupPaths = (0,
|
|
2614
|
+
const popupPaths = (0, import_react10.useMemo)(() => {
|
|
1797
2615
|
const paths = /* @__PURE__ */ new Map();
|
|
1798
2616
|
const visit = (entries, parents) => {
|
|
1799
2617
|
for (const entry of entries) {
|
|
@@ -1805,9 +2623,9 @@ function Menu({
|
|
|
1805
2623
|
visit(items, []);
|
|
1806
2624
|
return paths;
|
|
1807
2625
|
}, [items]);
|
|
1808
|
-
const revealedKey = (0,
|
|
2626
|
+
const revealedKey = (0, import_react10.useRef)();
|
|
1809
2627
|
const firstSelected = selected[0];
|
|
1810
|
-
(0,
|
|
2628
|
+
(0, import_react10.useLayoutEffect)(() => {
|
|
1811
2629
|
if (!autoScrollSelected || firstSelected === void 0) {
|
|
1812
2630
|
revealedKey.current = void 0;
|
|
1813
2631
|
return;
|
|
@@ -1816,9 +2634,12 @@ function Menu({
|
|
|
1816
2634
|
if (!root || revealedKey.current === firstSelected || mode === "horizontal") return;
|
|
1817
2635
|
const reveal = () => {
|
|
1818
2636
|
if (revealedKey.current === firstSelected || root.clientHeight === 0) return;
|
|
1819
|
-
const target = Array.from(root.querySelectorAll(".sia-menu__item")).find((element) => element.dataset.menuKey === firstSelected && element.getBoundingClientRect().height > 0);
|
|
2637
|
+
const target = Array.from(root.querySelectorAll(".sia-menu__item")).find((element) => element.dataset.menuKey === firstSelected && element.getBoundingClientRect().height > 0 && !element.closest('[aria-hidden="true"]'));
|
|
1820
2638
|
if (!target) return;
|
|
1821
2639
|
const bounds = root.getBoundingClientRect(), item = target.getBoundingClientRect();
|
|
2640
|
+
for (let parent = target.parentElement; parent && parent !== root; parent = parent.parentElement) {
|
|
2641
|
+
if (parent.classList.contains("sia-menu__submenu") && item.bottom > parent.getBoundingClientRect().bottom + 1) return;
|
|
2642
|
+
}
|
|
1822
2643
|
const top = bounds.top + root.clientTop, bottom = top + root.clientHeight;
|
|
1823
2644
|
if (item.top < top || item.bottom > bottom)
|
|
1824
2645
|
root.scrollTop += item.top - top - Math.max(0, (root.clientHeight - item.height) / 2);
|
|
@@ -1827,9 +2648,10 @@ function Menu({
|
|
|
1827
2648
|
reveal();
|
|
1828
2649
|
const observer = new ResizeObserver(reveal);
|
|
1829
2650
|
observer.observe(root);
|
|
2651
|
+
root.querySelectorAll(".sia-menu__submenu").forEach((submenu) => observer.observe(submenu));
|
|
1830
2652
|
return () => observer.disconnect();
|
|
1831
|
-
}, [autoScrollSelected, firstSelected, items, mode]);
|
|
1832
|
-
(0,
|
|
2653
|
+
}, [autoScrollSelected, firstSelected, items, mode, open]);
|
|
2654
|
+
(0, import_react10.useEffect)(() => {
|
|
1833
2655
|
if (mode === "inline" || !open.length) return void 0;
|
|
1834
2656
|
const closeOutside = (event) => {
|
|
1835
2657
|
const target = resolveFloatingScrollbarTarget(event.target);
|
|
@@ -1861,12 +2683,54 @@ function Menu({
|
|
|
1861
2683
|
else onSelect?.({ ...info, selectedKeys: [...next] });
|
|
1862
2684
|
if (mode !== "inline") setOpen([]);
|
|
1863
2685
|
}
|
|
2686
|
+
function handleMenuKeyDown(event) {
|
|
2687
|
+
rest.onKeyDown?.(event);
|
|
2688
|
+
if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
2689
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
2690
|
+
const button = target?.closest("button.sia-menu__item");
|
|
2691
|
+
const level = button?.closest('ul[role="menu"]') ?? rootRef.current;
|
|
2692
|
+
if (!level) return;
|
|
2693
|
+
const enabled = Array.from(level.querySelectorAll("button.sia-menu__item:not(:disabled)")).filter((item) => item.closest('ul[role="menu"]') === level && item.getClientRects().length > 0);
|
|
2694
|
+
const index = button ? enabled.indexOf(button) : -1;
|
|
2695
|
+
if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
|
|
2696
|
+
event.preventDefault();
|
|
2697
|
+
event.stopPropagation();
|
|
2698
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? enabled.length - 1 : event.key === "ArrowDown" ? index + 1 : (index < 0 ? enabled.length : index) - 1;
|
|
2699
|
+
enabled[(next + enabled.length) % enabled.length]?.focus();
|
|
2700
|
+
return;
|
|
2701
|
+
}
|
|
2702
|
+
if (event.key === "ArrowRight" && button?.hasAttribute("aria-expanded")) {
|
|
2703
|
+
event.preventDefault();
|
|
2704
|
+
event.stopPropagation();
|
|
2705
|
+
const key = button.dataset.menuKey;
|
|
2706
|
+
toggle(key, true);
|
|
2707
|
+
requestAnimationFrame(() => {
|
|
2708
|
+
const popup = [...document.querySelectorAll(".sia-menu__popup[data-sia-menu-owner]")].find((node) => node.dataset.siaMenuOwner === menuId && JSON.parse(node.dataset.siaMenuPath ?? "[]")[0] === key);
|
|
2709
|
+
const inline = button.parentElement?.querySelector(":scope > .sia-menu__submenu");
|
|
2710
|
+
(popup ?? inline)?.querySelector("button.sia-menu__item:not(:disabled)")?.focus();
|
|
2711
|
+
});
|
|
2712
|
+
return;
|
|
2713
|
+
}
|
|
2714
|
+
if (event.key === "ArrowLeft" || event.key === "Escape") {
|
|
2715
|
+
const popup = button?.closest(".sia-menu__popup");
|
|
2716
|
+
const parentKey = popup ? JSON.parse(popup.dataset.siaMenuPath ?? "[]")[0] : level.classList.contains("sia-menu__submenu") ? level.parentElement?.querySelector(":scope > button")?.dataset.menuKey : void 0;
|
|
2717
|
+
if (!parentKey) return;
|
|
2718
|
+
event.preventDefault();
|
|
2719
|
+
event.stopPropagation();
|
|
2720
|
+
toggle(parentKey, false);
|
|
2721
|
+
const roots = [rootRef.current, ...document.querySelectorAll(".sia-menu__popup[data-sia-menu-owner]")].filter((node) => node && (node === rootRef.current || node.dataset.siaMenuOwner === menuId));
|
|
2722
|
+
roots.flatMap((node) => [...node.querySelectorAll("button.sia-menu__item")]).find((item) => item.dataset.menuKey === parentKey)?.focus();
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
1864
2725
|
const gridStyle = mode === "grid" ? { "--sia-menu-grid-columns": gridColumns === "auto" ? "repeat(auto-fill, minmax(88px, 1fr))" : `repeat(${Number.isFinite(gridColumns) ? Math.max(1, Math.floor(Number(gridColumns))) : 2}, minmax(0, 1fr))` } : {};
|
|
1865
|
-
return /* @__PURE__ */ (0,
|
|
2726
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("ul", { ref: rootRef, className: `sia-menu sia-menu-motion-surface sia-menu--${mode} sia-menu--${theme}${inlineCollapsed ? " sia-menu--collapsed" : ""} ${className}`.trim(), role: "menu", ...withTitleTooltip(rest), onKeyDown: handleMenuKeyDown, style: { ...gridStyle, ...style }, "data-sia-menu-owner": menuId, children: [
|
|
2727
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MenuLevel, { items, level: 0, parents: [], props: { interactionCursor, menuId, mode, theme, multiple, selectable, inlineCollapsed, inlineIndent, triggerSubMenuAction, selected, open, select, toggle } }),
|
|
2728
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MenuSelectionMotion, { rootRef, enabled: !multiple })
|
|
2729
|
+
] });
|
|
1866
2730
|
}
|
|
1867
2731
|
|
|
1868
2732
|
// src/components/Dropdown.tsx
|
|
1869
|
-
var
|
|
2733
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1870
2734
|
var placementMap = {
|
|
1871
2735
|
bottomLeft: "bottom-start",
|
|
1872
2736
|
bottomRight: "bottom-end",
|
|
@@ -1899,19 +2763,18 @@ function DropdownInternal({
|
|
|
1899
2763
|
onKeyDown,
|
|
1900
2764
|
...props
|
|
1901
2765
|
}) {
|
|
1902
|
-
const rootRef = (0,
|
|
1903
|
-
const contextAnchorRef = (0,
|
|
1904
|
-
const popupRef = (0,
|
|
1905
|
-
const openTimerRef = (0,
|
|
1906
|
-
const closeTimerRef = (0,
|
|
1907
|
-
const [internalOpen, setInternalOpen] = (0,
|
|
1908
|
-
const [
|
|
1909
|
-
const [contextPoint, setContextPoint] = (0, import_react8.useState)();
|
|
2766
|
+
const rootRef = (0, import_react12.useRef)(null);
|
|
2767
|
+
const contextAnchorRef = (0, import_react12.useRef)(null);
|
|
2768
|
+
const popupRef = (0, import_react12.useRef)(null);
|
|
2769
|
+
const openTimerRef = (0, import_react12.useRef)(void 0);
|
|
2770
|
+
const closeTimerRef = (0, import_react12.useRef)(void 0);
|
|
2771
|
+
const [internalOpen, setInternalOpen] = (0, import_react12.useState)(defaultOpen);
|
|
2772
|
+
const [contextPoint, setContextPoint] = (0, import_react12.useState)();
|
|
1910
2773
|
const visible = open ?? internalOpen;
|
|
1911
2774
|
const triggerSet = new Set(trigger);
|
|
1912
2775
|
const pointAtCenter = typeof arrow === "object" && arrow.pointAtCenter;
|
|
1913
|
-
const [triggerFontSize, setTriggerFontSize] = (0,
|
|
1914
|
-
(0,
|
|
2776
|
+
const [triggerFontSize, setTriggerFontSize] = (0, import_react12.useState)();
|
|
2777
|
+
(0, import_react12.useLayoutEffect)(() => {
|
|
1915
2778
|
if (!visible || !rootRef.current) return;
|
|
1916
2779
|
const root = rootRef.current;
|
|
1917
2780
|
const target = root.querySelector("button, [role='button'], a") ?? (root.firstElementChild !== contextAnchorRef.current ? root.firstElementChild : null) ?? root;
|
|
@@ -1920,7 +2783,7 @@ function DropdownInternal({
|
|
|
1920
2783
|
const observer = new ResizeObserver(syncFontSize);
|
|
1921
2784
|
observer.observe(target);
|
|
1922
2785
|
return () => observer.disconnect();
|
|
1923
|
-
});
|
|
2786
|
+
}, [visible, children]);
|
|
1924
2787
|
function clearTimer(ref) {
|
|
1925
2788
|
if (ref.current === void 0) return;
|
|
1926
2789
|
window.clearTimeout(ref.current);
|
|
@@ -1946,19 +2809,8 @@ function DropdownInternal({
|
|
|
1946
2809
|
clearTimer(closeTimerRef);
|
|
1947
2810
|
closeTimerRef.current = window.setTimeout(() => updateOpen(false, "trigger"), Math.max(0, closeDelay));
|
|
1948
2811
|
}
|
|
1949
|
-
(0,
|
|
1950
|
-
|
|
1951
|
-
setMounted(true);
|
|
1952
|
-
return void 0;
|
|
1953
|
-
}
|
|
1954
|
-
const timer = window.setTimeout(() => setMounted(false), 160);
|
|
1955
|
-
return () => window.clearTimeout(timer);
|
|
1956
|
-
}, [visible]);
|
|
1957
|
-
(0, import_react8.useEffect)(() => {
|
|
1958
|
-
if (!visible && !mounted) setContextPoint(void 0);
|
|
1959
|
-
}, [mounted, visible]);
|
|
1960
|
-
(0, import_react8.useEffect)(() => () => clearTimers(), []);
|
|
1961
|
-
(0, import_react8.useEffect)(() => {
|
|
2812
|
+
(0, import_react12.useEffect)(() => () => clearTimers(), []);
|
|
2813
|
+
(0, import_react12.useEffect)(() => {
|
|
1962
2814
|
if (!visible) return void 0;
|
|
1963
2815
|
const contextMenuTrigger = triggerSet.has("contextMenu");
|
|
1964
2816
|
const closeOutside = (event) => {
|
|
@@ -1988,15 +2840,15 @@ function DropdownInternal({
|
|
|
1988
2840
|
document.removeEventListener("pointerover", keepOpenOverNestedMenu);
|
|
1989
2841
|
};
|
|
1990
2842
|
}, [visible]);
|
|
1991
|
-
(0,
|
|
1992
|
-
if (!visible || !
|
|
2843
|
+
(0, import_react12.useEffect)(() => {
|
|
2844
|
+
if (!visible || !autoFocus) return void 0;
|
|
1993
2845
|
const frame = window.requestAnimationFrame(() => {
|
|
1994
2846
|
popupRef.current?.querySelector(
|
|
1995
2847
|
"[data-sia-dropdown-autofocus], input:not(:disabled), textarea:not(:disabled), .sia-menu__item:not(:disabled)"
|
|
1996
2848
|
)?.focus();
|
|
1997
2849
|
});
|
|
1998
2850
|
return () => window.cancelAnimationFrame(frame);
|
|
1999
|
-
}, [autoFocus,
|
|
2851
|
+
}, [autoFocus, visible]);
|
|
2000
2852
|
function handleMenuClick(info) {
|
|
2001
2853
|
info.domEvent.stopPropagation();
|
|
2002
2854
|
menu.onClick?.(info);
|
|
@@ -2037,7 +2889,7 @@ function DropdownInternal({
|
|
|
2037
2889
|
updateOpen(true, "trigger");
|
|
2038
2890
|
}
|
|
2039
2891
|
}
|
|
2040
|
-
const menuNode = /* @__PURE__ */ (0,
|
|
2892
|
+
const menuNode = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2041
2893
|
Menu,
|
|
2042
2894
|
{
|
|
2043
2895
|
mode: "vertical",
|
|
@@ -2054,11 +2906,11 @@ function DropdownInternal({
|
|
|
2054
2906
|
className: "sia-dropdown__menu"
|
|
2055
2907
|
}
|
|
2056
2908
|
);
|
|
2057
|
-
const triggerNode = showTriggerIcon && (0,
|
|
2909
|
+
const triggerNode = showTriggerIcon && (0, import_react12.isValidElement)(children) && children.type === Button && children.props.children !== void 0 && children.props.children !== null ? (0, import_react12.cloneElement)(children, {}, /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "sia-dropdown__trigger-content", children: [
|
|
2058
2910
|
children.props.children,
|
|
2059
|
-
/* @__PURE__ */ (0,
|
|
2911
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "chevron-down", size: 14, className: "sia-dropdown__trigger-icon" })
|
|
2060
2912
|
] })) : children;
|
|
2061
|
-
return /* @__PURE__ */ (0,
|
|
2913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2062
2914
|
"span",
|
|
2063
2915
|
{
|
|
2064
2916
|
ref: rootRef,
|
|
@@ -2074,7 +2926,7 @@ function DropdownInternal({
|
|
|
2074
2926
|
...withTitleTooltip(props),
|
|
2075
2927
|
children: [
|
|
2076
2928
|
triggerNode,
|
|
2077
|
-
/* @__PURE__ */ (0,
|
|
2929
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2078
2930
|
"span",
|
|
2079
2931
|
{
|
|
2080
2932
|
ref: contextAnchorRef,
|
|
@@ -2083,12 +2935,15 @@ function DropdownInternal({
|
|
|
2083
2935
|
"aria-hidden": "true"
|
|
2084
2936
|
}
|
|
2085
2937
|
),
|
|
2086
|
-
/* @__PURE__ */ (0,
|
|
2938
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2087
2939
|
PopupPortal,
|
|
2088
2940
|
{
|
|
2089
2941
|
ref: popupRef,
|
|
2090
2942
|
anchorRef: contextPoint ? contextAnchorRef : popupAnchorRef ?? rootRef,
|
|
2091
|
-
open:
|
|
2943
|
+
open: visible,
|
|
2944
|
+
afterOpenChange: (nextOpen) => {
|
|
2945
|
+
if (!nextOpen) setContextPoint(void 0);
|
|
2946
|
+
},
|
|
2092
2947
|
placement: contextPoint ? "bottom-start" : placementMap[placement],
|
|
2093
2948
|
offset: contextPoint ? 2 : 6,
|
|
2094
2949
|
className: `sia-dropdown__popup${visible ? " is-open" : " is-closing"}${arrow ? " sia-dropdown__popup--arrow" : ""}${pointAtCenter ? " sia-dropdown__popup--arrow-center" : ""} ${popupClassName}`.trim(),
|
|
@@ -2110,7 +2965,7 @@ function DropdownInternal({
|
|
|
2110
2965
|
);
|
|
2111
2966
|
}
|
|
2112
2967
|
function DropdownRoot(props) {
|
|
2113
|
-
return /* @__PURE__ */ (0,
|
|
2968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DropdownInternal, { ...props });
|
|
2114
2969
|
}
|
|
2115
2970
|
function DropdownButton({
|
|
2116
2971
|
children,
|
|
@@ -2123,16 +2978,16 @@ function DropdownButton({
|
|
|
2123
2978
|
trigger = ["click"],
|
|
2124
2979
|
...dropdownProps
|
|
2125
2980
|
}) {
|
|
2126
|
-
const groupRef = (0,
|
|
2127
|
-
return /* @__PURE__ */ (0,
|
|
2128
|
-
/* @__PURE__ */ (0,
|
|
2129
|
-
/* @__PURE__ */ (0,
|
|
2981
|
+
const groupRef = (0, import_react12.useRef)(null);
|
|
2982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { ref: groupRef, className: `sia-dropdown-button ${className}`.trim(), children: [
|
|
2983
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Button, { ...buttonProps, disabled: disabled || buttonDisabled, onClick, children }),
|
|
2984
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DropdownInternal, { ...dropdownProps, popupAnchorRef: groupRef, disabled: disabled || dropdownDisabled, trigger, showTriggerIcon: false, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2130
2985
|
Button,
|
|
2131
2986
|
{
|
|
2132
2987
|
...buttonProps,
|
|
2133
2988
|
className: `sia-dropdown-button__arrow ${buttonProps?.className ?? ""}`.trim(),
|
|
2134
2989
|
disabled: disabled || dropdownDisabled,
|
|
2135
|
-
icon: /* @__PURE__ */ (0,
|
|
2990
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "chevron-down", size: 14 }),
|
|
2136
2991
|
"aria-label": "\u5C55\u5F00\u4E0B\u62C9\u83DC\u5355"
|
|
2137
2992
|
}
|
|
2138
2993
|
) })
|
|
@@ -2144,14 +2999,128 @@ var Dropdown = Object.assign(DropdownRoot, {
|
|
|
2144
2999
|
});
|
|
2145
3000
|
|
|
2146
3001
|
// src/components/Input.tsx
|
|
2147
|
-
var
|
|
3002
|
+
var import_react17 = require("react");
|
|
3003
|
+
|
|
3004
|
+
// src/components/OverlayContentSkeleton.tsx
|
|
3005
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3006
|
+
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';
|
|
3007
|
+
function captureOverlaySkeleton(body) {
|
|
3008
|
+
const bounds = body.getBoundingClientRect();
|
|
3009
|
+
const scaleX = body.offsetWidth ? bounds.width / body.offsetWidth : 1;
|
|
3010
|
+
const scaleY = body.offsetHeight ? bounds.height / body.offsetHeight : 1;
|
|
3011
|
+
const css = getComputedStyle(body);
|
|
3012
|
+
const paddingLeft = parseFloat(css.paddingLeft) || 0;
|
|
3013
|
+
const paddingTop = parseFloat(css.paddingTop) || 0;
|
|
3014
|
+
const width = Math.max(0, body.clientWidth - paddingLeft - (parseFloat(css.paddingRight) || 0));
|
|
3015
|
+
const height = Math.max(0, body.clientHeight - paddingTop - (parseFloat(css.paddingBottom) || 0));
|
|
3016
|
+
const blocks = [];
|
|
3017
|
+
const addRect = (rect, radius) => {
|
|
3018
|
+
const x = (rect.left - bounds.left) / (scaleX || 1) - body.clientLeft - paddingLeft;
|
|
3019
|
+
const y = (rect.top - bounds.top) / (scaleY || 1) - body.clientTop - paddingTop;
|
|
3020
|
+
const left = Math.max(0, x), top = Math.max(0, y);
|
|
3021
|
+
const right = Math.min(width, x + rect.width / (scaleX || 1));
|
|
3022
|
+
const bottom = Math.min(height, y + rect.height / (scaleY || 1));
|
|
3023
|
+
if (right - left < 2 || bottom - top < 2 || blocks.length >= 80) return;
|
|
3024
|
+
blocks.push({ position: "absolute", left, top, width: right - left, height: bottom - top, borderRadius: radius });
|
|
3025
|
+
};
|
|
3026
|
+
const pending = [];
|
|
3027
|
+
for (let index = Math.min(body.childNodes.length, 600) - 1; index >= 0; index--) pending.push(body.childNodes[index]);
|
|
3028
|
+
let inspected = 0;
|
|
3029
|
+
while (pending.length && inspected++ < 600 && blocks.length < 80) {
|
|
3030
|
+
const node = pending.pop();
|
|
3031
|
+
if (node instanceof Element) {
|
|
3032
|
+
if (node.matches("script, style, [hidden], .sia-skeleton, .sia-scrollbar-track")) continue;
|
|
3033
|
+
const style = getComputedStyle(node);
|
|
3034
|
+
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0") continue;
|
|
3035
|
+
if (node.matches(controlSelector)) {
|
|
3036
|
+
addRect(node.getBoundingClientRect(), style.borderRadius || "4px");
|
|
3037
|
+
continue;
|
|
3038
|
+
}
|
|
3039
|
+
for (let index = Math.min(node.childNodes.length, 600 - inspected - pending.length) - 1; index >= 0; index--) pending.push(node.childNodes[index]);
|
|
3040
|
+
} else if (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) {
|
|
3041
|
+
const range = document.createRange();
|
|
3042
|
+
range.selectNodeContents(node);
|
|
3043
|
+
for (const rect of Array.from(range.getClientRects()).slice(0, 3)) addRect(rect, "4px");
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
return { height, blocks };
|
|
3047
|
+
}
|
|
3048
|
+
function OverlayContentSkeleton({ layout }) {
|
|
3049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.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_runtime11.jsx)("span", { className: "sia-skeleton__block", style }, index)) });
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
// src/components/useOverlayExitPlaceholder.ts
|
|
3053
|
+
var import_react13 = require("react");
|
|
3054
|
+
function useOverlayExitPlaceholder(open, present, panelRef, bodyRef, captureContent) {
|
|
3055
|
+
const layout = (0, import_react13.useRef)();
|
|
3056
|
+
const dimensions = (0, import_react13.useRef)({ panelHeight: 0, bodyHeight: 0 });
|
|
3057
|
+
(0, import_react13.useLayoutEffect)(() => {
|
|
3058
|
+
if (!open || !present) {
|
|
3059
|
+
if (present && bodyRef.current) bodyRef.current.scrollTop = bodyRef.current.scrollLeft = 0;
|
|
3060
|
+
return;
|
|
3061
|
+
}
|
|
3062
|
+
if (!captureContent) layout.current = void 0;
|
|
3063
|
+
const panel = panelRef.current;
|
|
3064
|
+
const body = bodyRef.current;
|
|
3065
|
+
if (!panel) return;
|
|
3066
|
+
const measure = () => {
|
|
3067
|
+
dimensions.current = { panelHeight: panel.offsetHeight, bodyHeight: body?.offsetHeight ?? 0 };
|
|
3068
|
+
if (captureContent && body) layout.current = captureOverlaySkeleton(body);
|
|
3069
|
+
};
|
|
3070
|
+
let frame = 0;
|
|
3071
|
+
const schedule = () => {
|
|
3072
|
+
if (!frame) frame = requestAnimationFrame(() => {
|
|
3073
|
+
frame = 0;
|
|
3074
|
+
measure();
|
|
3075
|
+
});
|
|
3076
|
+
};
|
|
3077
|
+
measure();
|
|
3078
|
+
const observer = new ResizeObserver(measure);
|
|
3079
|
+
observer.observe(panel);
|
|
3080
|
+
if (body) observer.observe(body);
|
|
3081
|
+
const mutations = new MutationObserver(schedule);
|
|
3082
|
+
const beforePointerAction = (event) => {
|
|
3083
|
+
if (event.target instanceof Element && event.target.closest('button, [role="button"]')) measure();
|
|
3084
|
+
};
|
|
3085
|
+
const beforeKeyboardAction = (event) => {
|
|
3086
|
+
if (event.key === "Escape") measure();
|
|
3087
|
+
};
|
|
3088
|
+
if (captureContent && body) {
|
|
3089
|
+
mutations.observe(body, { subtree: true, childList: true, characterData: true, attributes: true, attributeFilter: ["style", "class", "hidden"] });
|
|
3090
|
+
body.addEventListener("scroll", schedule, { passive: true });
|
|
3091
|
+
panel.addEventListener("pointerdown", beforePointerAction, true);
|
|
3092
|
+
panel.addEventListener("keydown", beforeKeyboardAction, true);
|
|
3093
|
+
}
|
|
3094
|
+
return () => {
|
|
3095
|
+
observer.disconnect();
|
|
3096
|
+
mutations.disconnect();
|
|
3097
|
+
if (frame) cancelAnimationFrame(frame);
|
|
3098
|
+
body?.removeEventListener("scroll", schedule);
|
|
3099
|
+
panel.removeEventListener("pointerdown", beforePointerAction, true);
|
|
3100
|
+
panel.removeEventListener("keydown", beforeKeyboardAction, true);
|
|
3101
|
+
};
|
|
3102
|
+
});
|
|
3103
|
+
const closing = !open && present;
|
|
3104
|
+
const panelStyle = closing && dimensions.current.panelHeight > 0 ? { height: dimensions.current.panelHeight, boxSizing: "border-box", overflow: "hidden" } : void 0;
|
|
3105
|
+
const bodyStyle = closing && dimensions.current.bodyHeight > 0 ? { height: dimensions.current.bodyHeight, flex: "0 0 auto", boxSizing: "border-box" } : void 0;
|
|
3106
|
+
return { panelStyle, bodyStyle, layout: layout.current, hadBody: dimensions.current.bodyHeight > 0 };
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
// src/components/Skeleton.tsx
|
|
3110
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3111
|
+
function Skeleton({ rows = 6, columns = 2, rowHeight = 30, gap = 16, className = "", style, ...props }) {
|
|
3112
|
+
const count = (value, fallback, min, max) => Number.isFinite(value) ? Math.min(max, Math.max(min, Math.floor(value))) : fallback;
|
|
3113
|
+
const rowCount = count(rows, 6, 1, 30);
|
|
3114
|
+
const columnCount = count(columns, 2, 1, 4);
|
|
3115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.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_runtime12.jsx)("span", { className: "sia-skeleton__block", "aria-hidden": "true", style: { height: count(rowHeight, 30, 8, 200) } }, index)) });
|
|
3116
|
+
}
|
|
2148
3117
|
|
|
2149
3118
|
// src/components/Modal.tsx
|
|
2150
|
-
var
|
|
3119
|
+
var import_react15 = require("react");
|
|
2151
3120
|
var import_client2 = require("react-dom/client");
|
|
2152
3121
|
|
|
2153
3122
|
// src/components/Overlay.tsx
|
|
2154
|
-
var
|
|
3123
|
+
var import_react14 = require("react");
|
|
2155
3124
|
var import_react_dom2 = require("react-dom");
|
|
2156
3125
|
var bodyLockCount = 0;
|
|
2157
3126
|
var previousBodyOverflow = "";
|
|
@@ -2181,11 +3150,11 @@ function firstModalInput(panel) {
|
|
|
2181
3150
|
);
|
|
2182
3151
|
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");
|
|
2183
3152
|
}
|
|
2184
|
-
function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, autoFocusInput = false) {
|
|
2185
|
-
const overlayIdRef = (0,
|
|
2186
|
-
const closeRef = (0,
|
|
3153
|
+
function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, autoFocusInput = false, contentReady = true) {
|
|
3154
|
+
const overlayIdRef = (0, import_react14.useRef)(/* @__PURE__ */ Symbol("sia-overlay"));
|
|
3155
|
+
const closeRef = (0, import_react14.useRef)(onRequestClose);
|
|
2187
3156
|
closeRef.current = onRequestClose;
|
|
2188
|
-
(0,
|
|
3157
|
+
(0, import_react14.useEffect)(() => {
|
|
2189
3158
|
if (!open || typeof document === "undefined") return void 0;
|
|
2190
3159
|
const overlayId = overlayIdRef.current;
|
|
2191
3160
|
const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -2193,14 +3162,6 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, au
|
|
|
2193
3162
|
overlayPanels.set(overlayId, panelRef);
|
|
2194
3163
|
overlayListeners.forEach((listener) => listener());
|
|
2195
3164
|
const unlockBody = lockBodyScroll();
|
|
2196
|
-
const focusTimer = window.setTimeout(() => {
|
|
2197
|
-
const panel = panelRef.current;
|
|
2198
|
-
if (!panel || overlayStack.at(-1) !== overlayId) return;
|
|
2199
|
-
if (panel.contains(document.activeElement) && document.activeElement !== panel) return;
|
|
2200
|
-
const [firstFocusable] = focusableElements(panel);
|
|
2201
|
-
const input = autoFocusInput ? firstModalInput(panel) : void 0;
|
|
2202
|
-
(input ?? firstFocusable ?? panel).focus({ preventScroll: true });
|
|
2203
|
-
}, 0);
|
|
2204
3165
|
function handleKeyDown(event) {
|
|
2205
3166
|
if (overlayStack.at(-1) !== overlayId) return;
|
|
2206
3167
|
if (event.key === "Escape" && keyboard) {
|
|
@@ -2227,7 +3188,6 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, au
|
|
|
2227
3188
|
}
|
|
2228
3189
|
document.addEventListener("keydown", handleKeyDown);
|
|
2229
3190
|
return () => {
|
|
2230
|
-
window.clearTimeout(focusTimer);
|
|
2231
3191
|
document.removeEventListener("keydown", handleKeyDown);
|
|
2232
3192
|
const index = overlayStack.lastIndexOf(overlayId);
|
|
2233
3193
|
if (index >= 0) overlayStack.splice(index, 1);
|
|
@@ -2237,6 +3197,17 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, au
|
|
|
2237
3197
|
previouslyFocused?.focus({ preventScroll: true });
|
|
2238
3198
|
};
|
|
2239
3199
|
}, [keyboard, open, panelRef, autoFocusInput]);
|
|
3200
|
+
(0, import_react14.useEffect)(() => {
|
|
3201
|
+
if (!open) return;
|
|
3202
|
+
const timer = window.setTimeout(() => {
|
|
3203
|
+
const panel = panelRef.current;
|
|
3204
|
+
if (!panel || overlayStack.at(-1) !== overlayIdRef.current) return;
|
|
3205
|
+
if (panel.contains(document.activeElement) && document.activeElement !== panel) return;
|
|
3206
|
+
const first = contentReady ? (autoFocusInput ? firstModalInput(panel) : void 0) ?? focusableElements(panel)[0] : void 0;
|
|
3207
|
+
(first ?? panel).focus({ preventScroll: true });
|
|
3208
|
+
}, 0);
|
|
3209
|
+
return () => window.clearTimeout(timer);
|
|
3210
|
+
}, [open, panelRef, autoFocusInput, contentReady]);
|
|
2240
3211
|
}
|
|
2241
3212
|
function OverlayPortal({ children, container }) {
|
|
2242
3213
|
if (typeof document === "undefined") return null;
|
|
@@ -2245,18 +3216,19 @@ function OverlayPortal({ children, container }) {
|
|
|
2245
3216
|
}
|
|
2246
3217
|
|
|
2247
3218
|
// src/components/Modal.tsx
|
|
2248
|
-
var
|
|
3219
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2249
3220
|
var modalHandles = /* @__PURE__ */ new Set();
|
|
2250
|
-
var MODAL_MOTION_DURATION = 220;
|
|
2251
3221
|
var typeIcons = {
|
|
2252
|
-
info: /* @__PURE__ */ (0,
|
|
2253
|
-
success: /* @__PURE__ */ (0,
|
|
2254
|
-
warning: /* @__PURE__ */ (0,
|
|
2255
|
-
error: /* @__PURE__ */ (0,
|
|
2256
|
-
confirm: /* @__PURE__ */ (0,
|
|
3222
|
+
info: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "info", size: 23, variant: "filled" }),
|
|
3223
|
+
success: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "circle-check", size: 23, variant: "filled" }),
|
|
3224
|
+
warning: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "warning", size: 23, variant: "filled" }),
|
|
3225
|
+
error: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "circle-close", size: 23, variant: "filled" }),
|
|
3226
|
+
confirm: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "question", size: 23, variant: "filled" })
|
|
2257
3227
|
};
|
|
2258
|
-
var ModalRoot = (0,
|
|
3228
|
+
var ModalRoot = (0, import_react15.forwardRef)(function Modal({
|
|
2259
3229
|
open,
|
|
3230
|
+
deferContent = false,
|
|
3231
|
+
loadingFallback,
|
|
2260
3232
|
autoFocus = true,
|
|
2261
3233
|
title,
|
|
2262
3234
|
children,
|
|
@@ -2285,34 +3257,15 @@ var ModalRoot = (0, import_react10.forwardRef)(function Modal({
|
|
|
2285
3257
|
style,
|
|
2286
3258
|
...props
|
|
2287
3259
|
}, forwardedRef) {
|
|
2288
|
-
const localRef = (0,
|
|
2289
|
-
const
|
|
2290
|
-
const
|
|
2291
|
-
const [
|
|
2292
|
-
const
|
|
2293
|
-
const
|
|
2294
|
-
|
|
2295
|
-
const
|
|
2296
|
-
(0,
|
|
2297
|
-
if (!open || !rendered) return void 0;
|
|
2298
|
-
const timer = window.setTimeout(() => afterOpenChangeRef.current?.(true), MODAL_MOTION_DURATION);
|
|
2299
|
-
return () => window.clearTimeout(timer);
|
|
2300
|
-
}, [open, rendered]);
|
|
2301
|
-
(0, import_react10.useEffect)(() => {
|
|
2302
|
-
if (open) {
|
|
2303
|
-
setRendered(true);
|
|
2304
|
-
setClosing(false);
|
|
2305
|
-
return void 0;
|
|
2306
|
-
}
|
|
2307
|
-
if (!rendered) return void 0;
|
|
2308
|
-
setClosing(true);
|
|
2309
|
-
const timer = window.setTimeout(() => {
|
|
2310
|
-
setRendered(false);
|
|
2311
|
-
setClosing(false);
|
|
2312
|
-
afterOpenChangeRef.current?.(false);
|
|
2313
|
-
}, MODAL_MOTION_DURATION);
|
|
2314
|
-
return () => window.clearTimeout(timer);
|
|
2315
|
-
}, [open, rendered]);
|
|
3260
|
+
const localRef = (0, import_react15.useRef)(null);
|
|
3261
|
+
const bodyRef = (0, import_react15.useRef)(null);
|
|
3262
|
+
const titleId = (0, import_react15.useId)();
|
|
3263
|
+
const [submitting, setSubmitting] = (0, import_react15.useState)(false);
|
|
3264
|
+
const motion = useOverlayMotion(open, localRef, "modal", "bottom", true, afterOpenChange);
|
|
3265
|
+
const { present: rendered, closing } = motion;
|
|
3266
|
+
const bodyReady = !closing && (!deferContent || motion.settled);
|
|
3267
|
+
const exitPlaceholder = useOverlayExitPlaceholder(open, rendered, localRef, bodyRef, bodyReady && loadingFallback === void 0);
|
|
3268
|
+
const submitLock = (0, import_react15.useRef)(false);
|
|
2316
3269
|
function setRef(node) {
|
|
2317
3270
|
localRef.current = node;
|
|
2318
3271
|
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
@@ -2324,7 +3277,7 @@ var ModalRoot = (0, import_react10.forwardRef)(function Modal({
|
|
|
2324
3277
|
onOpenChange?.(false);
|
|
2325
3278
|
}
|
|
2326
3279
|
async function handleOk() {
|
|
2327
|
-
if (submitLock.current || confirmLoading) return;
|
|
3280
|
+
if (!bodyReady || submitLock.current || confirmLoading) return;
|
|
2328
3281
|
submitLock.current = true;
|
|
2329
3282
|
if (!onOk) {
|
|
2330
3283
|
onOpenChange?.(false);
|
|
@@ -2347,49 +3300,50 @@ var ModalRoot = (0, import_react10.forwardRef)(function Modal({
|
|
|
2347
3300
|
setSubmitting(false);
|
|
2348
3301
|
}
|
|
2349
3302
|
}
|
|
2350
|
-
useOverlayLifecycle(rendered, localRef, requestClose, keyboard, autoFocus);
|
|
3303
|
+
useOverlayLifecycle(rendered, localRef, requestClose, keyboard, autoFocus, bodyReady);
|
|
2351
3304
|
if (!rendered) return null;
|
|
2352
3305
|
const mergedStyle = {
|
|
2353
3306
|
...height !== void 0 ? { display: "flex", flexDirection: "column", height, maxHeight: "calc(100dvh - 48px)" } : {},
|
|
2354
3307
|
...style,
|
|
2355
3308
|
"--sia-modal-width": typeof width === "number" ? `${width}px` : width
|
|
2356
3309
|
};
|
|
2357
|
-
const loading = submitting || confirmLoading;
|
|
2358
|
-
const defaultFooter = /* @__PURE__ */ (0,
|
|
2359
|
-
showCancel ? /* @__PURE__ */ (0,
|
|
2360
|
-
/* @__PURE__ */ (0,
|
|
3310
|
+
const loading = submitting || confirmLoading || !bodyReady;
|
|
3311
|
+
const defaultFooter = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
3312
|
+
showCancel ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { ...cancelButtonProps, onClick: requestClose, disabled: loading || cancelButtonProps?.disabled, children: cancelText }) : null,
|
|
3313
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { variant: "primary", ...okButtonProps, onClick: handleOk, loading, children: okText })
|
|
2361
3314
|
] });
|
|
2362
|
-
return /* @__PURE__ */ (0,
|
|
3315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(OverlayPortal, { container: getContainer, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2363
3316
|
"div",
|
|
2364
3317
|
{
|
|
2365
3318
|
className: `sia-modal-root${centered ? " sia-modal-root--centered" : ""}`,
|
|
2366
3319
|
"data-state": closing ? "closing" : "open",
|
|
3320
|
+
"data-content-pending": !bodyReady || void 0,
|
|
2367
3321
|
style: { zIndex },
|
|
2368
3322
|
onMouseDown: (event) => {
|
|
2369
3323
|
if (event.target === event.currentTarget && maskClosable) requestClose();
|
|
2370
3324
|
},
|
|
2371
|
-
children: /* @__PURE__ */ (0,
|
|
3325
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2372
3326
|
"div",
|
|
2373
3327
|
{
|
|
2374
3328
|
ref: setRef,
|
|
2375
3329
|
className: `sia-modal sia-modal--${type} ${className}`.trim(),
|
|
2376
|
-
style: mergedStyle,
|
|
3330
|
+
style: { ...mergedStyle, ...exitPlaceholder.panelStyle, animation: "none" },
|
|
2377
3331
|
role: "dialog",
|
|
2378
3332
|
"aria-modal": "true",
|
|
2379
3333
|
"aria-labelledby": title ? titleId : void 0,
|
|
2380
3334
|
tabIndex: -1,
|
|
2381
3335
|
...withTitleTooltip(props),
|
|
2382
3336
|
children: [
|
|
2383
|
-
/* @__PURE__ */ (0,
|
|
2384
|
-
/* @__PURE__ */ (0,
|
|
2385
|
-
typeIcons[type] ? /* @__PURE__ */ (0,
|
|
2386
|
-
title ? /* @__PURE__ */ (0,
|
|
3337
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "sia-modal__header", style: height !== void 0 ? { flexShrink: 0 } : void 0, children: [
|
|
3338
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "sia-modal__heading", children: [
|
|
3339
|
+
typeIcons[type] ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "sia-modal__type-icon", "aria-hidden": "true", children: typeIcons[type] }) : null,
|
|
3340
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("strong", { id: titleId, children: title }) : null
|
|
2387
3341
|
] }),
|
|
2388
|
-
closable ? /* @__PURE__ */ (0,
|
|
3342
|
+
closable ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "sia-modal__close", "aria-label": "\u5173\u95ED\u5BF9\u8BDD\u6846", onClick: requestClose, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "close", size: 17 }) }) : null
|
|
2389
3343
|
] }),
|
|
2390
|
-
children !== void 0 ? /* @__PURE__ */ (0,
|
|
2391
|
-
footer !== null ? /* @__PURE__ */ (0,
|
|
2392
|
-
footer === void 0 && footerExtra != null ? /* @__PURE__ */ (0,
|
|
3344
|
+
children !== void 0 || closing && exitPlaceholder.hadBody ? /* @__PURE__ */ (0, import_jsx_runtime13.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_runtime13.jsx)(OverlayContentSkeleton, { layout: exitPlaceholder.layout }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Skeleton, {}) }) : null,
|
|
3345
|
+
footer !== null && (bodyReady || closing && motion.entered || footer === void 0) ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "sia-modal__footer", style: height !== void 0 ? { flexShrink: 0 } : void 0, children: [
|
|
3346
|
+
footer === void 0 && footerExtra != null ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style: { marginRight: "auto" }, children: footerExtra }) : null,
|
|
2393
3347
|
footer ?? defaultFooter
|
|
2394
3348
|
] }) : null
|
|
2395
3349
|
]
|
|
@@ -2410,7 +3364,7 @@ function openModal(config) {
|
|
|
2410
3364
|
let currentOpen = true;
|
|
2411
3365
|
let destroyed = false;
|
|
2412
3366
|
let mounted = false;
|
|
2413
|
-
function
|
|
3367
|
+
function cleanup2() {
|
|
2414
3368
|
if (destroyed) return;
|
|
2415
3369
|
destroyed = true;
|
|
2416
3370
|
root.unmount();
|
|
@@ -2423,23 +3377,23 @@ function openModal(config) {
|
|
|
2423
3377
|
render();
|
|
2424
3378
|
}
|
|
2425
3379
|
function ModalInstance() {
|
|
2426
|
-
(0,
|
|
3380
|
+
(0, import_react15.useEffect)(() => {
|
|
2427
3381
|
mounted = true;
|
|
2428
3382
|
if (!currentOpen) render();
|
|
2429
3383
|
}, []);
|
|
2430
|
-
return /* @__PURE__ */ (0,
|
|
3384
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ModalRoot, { ...currentConfig, open: !mounted || currentOpen, onOpenChange: (nextOpen) => {
|
|
2431
3385
|
currentConfig.onOpenChange?.(nextOpen);
|
|
2432
3386
|
if (!nextOpen) closeWithMotion();
|
|
2433
3387
|
}, afterOpenChange: (nextOpen) => {
|
|
2434
3388
|
try {
|
|
2435
3389
|
currentConfig.afterOpenChange?.(nextOpen);
|
|
2436
3390
|
} finally {
|
|
2437
|
-
if (!nextOpen) queueMicrotask(
|
|
3391
|
+
if (!nextOpen) queueMicrotask(cleanup2);
|
|
2438
3392
|
}
|
|
2439
3393
|
} });
|
|
2440
3394
|
}
|
|
2441
3395
|
function render() {
|
|
2442
|
-
root.render(/* @__PURE__ */ (0,
|
|
3396
|
+
root.render(/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ModalInstance, {}));
|
|
2443
3397
|
}
|
|
2444
3398
|
const handle = {
|
|
2445
3399
|
destroy: closeWithMotion,
|
|
@@ -2484,9 +3438,9 @@ var Modal2 = Object.assign(ModalRoot, {
|
|
|
2484
3438
|
});
|
|
2485
3439
|
|
|
2486
3440
|
// src/components/TextArea.tsx
|
|
2487
|
-
var
|
|
2488
|
-
var
|
|
2489
|
-
var TextArea = (0,
|
|
3441
|
+
var import_react16 = require("react");
|
|
3442
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3443
|
+
var TextArea = (0, import_react16.forwardRef)(function TextArea2({
|
|
2490
3444
|
label,
|
|
2491
3445
|
hint,
|
|
2492
3446
|
status = "default",
|
|
@@ -2504,9 +3458,9 @@ var TextArea = (0, import_react11.forwardRef)(function TextArea2({
|
|
|
2504
3458
|
...props
|
|
2505
3459
|
}, ref) {
|
|
2506
3460
|
const size = useControlSize(sizeProp);
|
|
2507
|
-
const fallbackId = (0,
|
|
3461
|
+
const fallbackId = (0, import_react16.useId)();
|
|
2508
3462
|
const textAreaId = id ?? fallbackId;
|
|
2509
|
-
const [uncontrolledValue, setUncontrolledValue] = (0,
|
|
3463
|
+
const [uncontrolledValue, setUncontrolledValue] = (0, import_react16.useState)(() => defaultValue === void 0 ? "" : String(defaultValue));
|
|
2510
3464
|
const currentText = value !== void 0 ? String(value) : uncontrolledValue;
|
|
2511
3465
|
const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: currentText.length > 0 });
|
|
2512
3466
|
const hintId = `${textAreaId}-hint`;
|
|
@@ -2515,8 +3469,8 @@ var TextArea = (0, import_react11.forwardRef)(function TextArea2({
|
|
|
2515
3469
|
setUncontrolledValue(event.target.value);
|
|
2516
3470
|
onChange?.(event);
|
|
2517
3471
|
}
|
|
2518
|
-
const control = /* @__PURE__ */ (0,
|
|
2519
|
-
/* @__PURE__ */ (0,
|
|
3472
|
+
const control = /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: `sia-textarea-control sia-textarea-control--${size} sia-textarea-control--${status}${floating.className}${disabled ? " is-disabled" : ""}`, children: [
|
|
3473
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2520
3474
|
"textarea",
|
|
2521
3475
|
{
|
|
2522
3476
|
...withTitleTooltip(props),
|
|
@@ -2534,22 +3488,22 @@ var TextArea = (0, import_react11.forwardRef)(function TextArea2({
|
|
|
2534
3488
|
}
|
|
2535
3489
|
),
|
|
2536
3490
|
floating.label,
|
|
2537
|
-
showCount ? /* @__PURE__ */ (0,
|
|
3491
|
+
showCount ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: `sia-textarea-control__count${maxLength !== void 0 && currentText.length >= maxLength ? " is-limit" : ""}`, "aria-live": "polite", children: [
|
|
2538
3492
|
currentText.length,
|
|
2539
3493
|
maxLength !== void 0 ? `/${maxLength}` : null
|
|
2540
3494
|
] }) : null
|
|
2541
3495
|
] });
|
|
2542
|
-
if (!label && !hint) return /* @__PURE__ */ (0,
|
|
2543
|
-
return /* @__PURE__ */ (0,
|
|
2544
|
-
label ? /* @__PURE__ */ (0,
|
|
3496
|
+
if (!label && !hint) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `sia-field ${className}`.trim(), children: control });
|
|
3497
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: `sia-field ${className}`.trim(), children: [
|
|
3498
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { className: "sia-field__label", htmlFor: textAreaId, children: label }) : null,
|
|
2545
3499
|
control,
|
|
2546
|
-
hint ? /* @__PURE__ */ (0,
|
|
3500
|
+
hint ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id: hintId, className: `sia-field__hint sia-field__hint--${status}`, children: hint }) : null
|
|
2547
3501
|
] });
|
|
2548
3502
|
});
|
|
2549
3503
|
|
|
2550
3504
|
// src/components/Input.tsx
|
|
2551
|
-
var
|
|
2552
|
-
var Input = (0,
|
|
3505
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3506
|
+
var Input = (0, import_react17.forwardRef)(function Input2({
|
|
2553
3507
|
label,
|
|
2554
3508
|
hint,
|
|
2555
3509
|
status = "default",
|
|
@@ -2572,14 +3526,14 @@ var Input = (0, import_react12.forwardRef)(function Input2({
|
|
|
2572
3526
|
...props
|
|
2573
3527
|
}, forwardedRef) {
|
|
2574
3528
|
const size = useControlSize(sizeProp);
|
|
2575
|
-
const fallbackId = (0,
|
|
3529
|
+
const fallbackId = (0, import_react17.useId)();
|
|
2576
3530
|
const inputId = id ?? fallbackId;
|
|
2577
|
-
const localRef = (0,
|
|
2578
|
-
const [uncontrolledValue, setUncontrolledValue] = (0,
|
|
3531
|
+
const localRef = (0, import_react17.useRef)(null);
|
|
3532
|
+
const [uncontrolledValue, setUncontrolledValue] = (0, import_react17.useState)(() => defaultValue === void 0 ? "" : String(defaultValue));
|
|
2579
3533
|
const currentText = value !== void 0 ? String(value) : uncontrolledValue;
|
|
2580
3534
|
const hasValue = currentText.length > 0;
|
|
2581
|
-
const [expanded, setExpanded] = (0,
|
|
2582
|
-
const [expandedDraft, setExpandedDraft] = (0,
|
|
3535
|
+
const [expanded, setExpanded] = (0, import_react17.useState)(false);
|
|
3536
|
+
const [expandedDraft, setExpandedDraft] = (0, import_react17.useState)("");
|
|
2583
3537
|
const floatingPlaceholder = usePlaceholderMode(placeholderMode) === "floating" && Boolean(placeholder);
|
|
2584
3538
|
const hintId = `${inputId}-hint`;
|
|
2585
3539
|
const describedBy = [props["aria-describedby"], hint ? hintId : null].filter(Boolean).join(" ") || void 0;
|
|
@@ -2615,7 +3569,7 @@ var Input = (0, import_react12.forwardRef)(function Input2({
|
|
|
2615
3569
|
event.preventDefault();
|
|
2616
3570
|
localRef.current?.focus({ preventScroll: true });
|
|
2617
3571
|
}
|
|
2618
|
-
const input = /* @__PURE__ */ (0,
|
|
3572
|
+
const input = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2619
3573
|
"input",
|
|
2620
3574
|
{
|
|
2621
3575
|
...withTitleTooltip(props),
|
|
@@ -2632,15 +3586,15 @@ var Input = (0, import_react12.forwardRef)(function Input2({
|
|
|
2632
3586
|
onChange: handleChange
|
|
2633
3587
|
}
|
|
2634
3588
|
);
|
|
2635
|
-
const control = /* @__PURE__ */ (0,
|
|
2636
|
-
prefix ? /* @__PURE__ */ (0,
|
|
2637
|
-
floatingPlaceholder ? /* @__PURE__ */ (0,
|
|
3589
|
+
const control = /* @__PURE__ */ (0, import_jsx_runtime15.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: [
|
|
3590
|
+
prefix ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "sia-input-control__affix", children: prefix }) : null,
|
|
3591
|
+
floatingPlaceholder ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "sia-input-control__input-wrap", children: [
|
|
2638
3592
|
input,
|
|
2639
|
-
/* @__PURE__ */ (0,
|
|
3593
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "sia-input-control__floating-placeholder", "aria-hidden": "true", children: placeholder })
|
|
2640
3594
|
] }) : input,
|
|
2641
|
-
allowClear && hasValue && !disabled ? /* @__PURE__ */ (0,
|
|
2642
|
-
suffix ? /* @__PURE__ */ (0,
|
|
2643
|
-
expandable && !disabled && !props.readOnly && (!props.type || props.type === "text") ? /* @__PURE__ */ (0,
|
|
3595
|
+
allowClear && hasValue && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "sia-input-control__clear", type: "button", "aria-label": "\u6E05\u7A7A\u8F93\u5165", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
|
|
3596
|
+
suffix ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "sia-input-control__affix", children: suffix }) : null,
|
|
3597
|
+
expandable && !disabled && !props.readOnly && (!props.type || props.type === "text") ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2644
3598
|
"button",
|
|
2645
3599
|
{
|
|
2646
3600
|
type: "button",
|
|
@@ -2652,15 +3606,15 @@ var Input = (0, import_react12.forwardRef)(function Input2({
|
|
|
2652
3606
|
setExpandedDraft(currentText);
|
|
2653
3607
|
setExpanded(true);
|
|
2654
3608
|
},
|
|
2655
|
-
children: /* @__PURE__ */ (0,
|
|
3609
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Icon, { name: "expand", size: 15 })
|
|
2656
3610
|
}
|
|
2657
3611
|
) : null,
|
|
2658
|
-
showCount ? /* @__PURE__ */ (0,
|
|
3612
|
+
showCount ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: `sia-input-control__count${maxLength !== void 0 && currentText.length >= maxLength ? " is-limit" : ""}`, "aria-live": "polite", children: [
|
|
2659
3613
|
currentText.length,
|
|
2660
3614
|
maxLength !== void 0 ? `/${maxLength}` : null
|
|
2661
3615
|
] }) : null
|
|
2662
3616
|
] });
|
|
2663
|
-
const editor = expandable ? /* @__PURE__ */ (0,
|
|
3617
|
+
const editor = expandable ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2664
3618
|
Modal2,
|
|
2665
3619
|
{
|
|
2666
3620
|
open: expanded,
|
|
@@ -2681,7 +3635,7 @@ var Input = (0, import_react12.forwardRef)(function Input2({
|
|
|
2681
3635
|
setUncontrolledValue(next);
|
|
2682
3636
|
setExpanded(false);
|
|
2683
3637
|
},
|
|
2684
|
-
children: /* @__PURE__ */ (0,
|
|
3638
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2685
3639
|
TextArea,
|
|
2686
3640
|
{
|
|
2687
3641
|
"aria-label": "\u5C55\u5F00\u7F16\u8F91\u5185\u5BB9",
|
|
@@ -2697,22 +3651,22 @@ var Input = (0, import_react12.forwardRef)(function Input2({
|
|
|
2697
3651
|
)
|
|
2698
3652
|
}
|
|
2699
3653
|
) : null;
|
|
2700
|
-
if (!label && !hint) return /* @__PURE__ */ (0,
|
|
2701
|
-
/* @__PURE__ */ (0,
|
|
3654
|
+
if (!label && !hint) return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
3655
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: `sia-field ${className}`.trim(), children: control }),
|
|
2702
3656
|
editor
|
|
2703
3657
|
] });
|
|
2704
|
-
return /* @__PURE__ */ (0,
|
|
2705
|
-
/* @__PURE__ */ (0,
|
|
2706
|
-
label ? /* @__PURE__ */ (0,
|
|
3658
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
3659
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: `sia-field ${className}`.trim(), children: [
|
|
3660
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { className: "sia-field__label", htmlFor: inputId, children: label }) : null,
|
|
2707
3661
|
control,
|
|
2708
|
-
hint ? /* @__PURE__ */ (0,
|
|
3662
|
+
hint ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { id: hintId, className: `sia-field__hint sia-field__hint--${status}`, children: hint }) : null
|
|
2709
3663
|
] }),
|
|
2710
3664
|
editor
|
|
2711
3665
|
] });
|
|
2712
3666
|
});
|
|
2713
3667
|
|
|
2714
3668
|
// src/components/RichTextEditor.tsx
|
|
2715
|
-
var
|
|
3669
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2716
3670
|
function escapeHtml(value) {
|
|
2717
3671
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2718
3672
|
}
|
|
@@ -2728,9 +3682,9 @@ function sanitizeContent(value) {
|
|
|
2728
3682
|
}).replace(/<img\b/giu, '<img loading="lazy" decoding="async"');
|
|
2729
3683
|
}
|
|
2730
3684
|
function RichTextContent({ content, emptyText = "\u6682\u65E0\u5185\u5BB9", className = "", ...props }) {
|
|
2731
|
-
const html = (0,
|
|
2732
|
-
if (!html.trim()) return /* @__PURE__ */ (0,
|
|
2733
|
-
return /* @__PURE__ */ (0,
|
|
3685
|
+
const html = (0, import_react18.useMemo)(() => sanitizeContent(content), [content]);
|
|
3686
|
+
if (!html.trim()) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: `sia-rich-text-content sia-rich-text-content--empty ${className}`.trim(), children: emptyText });
|
|
3687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("article", { className: `sia-rich-text-content ${className}`.trim(), dangerouslySetInnerHTML: { __html: html }, ...withTitleTooltip(props) });
|
|
2734
3688
|
}
|
|
2735
3689
|
function RichTextEditor({
|
|
2736
3690
|
value,
|
|
@@ -2751,31 +3705,31 @@ function RichTextEditor({
|
|
|
2751
3705
|
"aria-label": ariaLabel,
|
|
2752
3706
|
...props
|
|
2753
3707
|
}) {
|
|
2754
|
-
const initialValueRef = (0,
|
|
2755
|
-
const lastEmittedValueRef = (0,
|
|
2756
|
-
const onChangeRef = (0,
|
|
2757
|
-
const onPasteImageRef = (0,
|
|
2758
|
-
const saveShortcutRef = (0,
|
|
2759
|
-
const contentFormatRef = (0,
|
|
2760
|
-
const editorElementRef = (0,
|
|
2761
|
-
const editorRef = (0,
|
|
2762
|
-
const [editor, setEditor] = (0,
|
|
2763
|
-
const [linkEditorOpen, setLinkEditorOpen] = (0,
|
|
2764
|
-
const [linkHref, setLinkHref] = (0,
|
|
2765
|
-
const [, setEditorRevision] = (0,
|
|
2766
|
-
(0,
|
|
3708
|
+
const initialValueRef = (0, import_react18.useRef)(value ?? defaultValue);
|
|
3709
|
+
const lastEmittedValueRef = (0, import_react18.useRef)(value ?? defaultValue);
|
|
3710
|
+
const onChangeRef = (0, import_react18.useRef)(onChange);
|
|
3711
|
+
const onPasteImageRef = (0, import_react18.useRef)(onPasteImage);
|
|
3712
|
+
const saveShortcutRef = (0, import_react18.useRef)(saveShortcut);
|
|
3713
|
+
const contentFormatRef = (0, import_react18.useRef)(contentFormat);
|
|
3714
|
+
const editorElementRef = (0, import_react18.useRef)(null);
|
|
3715
|
+
const editorRef = (0, import_react18.useRef)(null);
|
|
3716
|
+
const [editor, setEditor] = (0, import_react18.useState)(null);
|
|
3717
|
+
const [linkEditorOpen, setLinkEditorOpen] = (0, import_react18.useState)(false);
|
|
3718
|
+
const [linkHref, setLinkHref] = (0, import_react18.useState)("");
|
|
3719
|
+
const [, setEditorRevision] = (0, import_react18.useState)(0);
|
|
3720
|
+
(0, import_react18.useEffect)(() => {
|
|
2767
3721
|
onChangeRef.current = onChange;
|
|
2768
3722
|
}, [onChange]);
|
|
2769
|
-
(0,
|
|
3723
|
+
(0, import_react18.useEffect)(() => {
|
|
2770
3724
|
onPasteImageRef.current = onPasteImage;
|
|
2771
3725
|
}, [onPasteImage]);
|
|
2772
|
-
(0,
|
|
3726
|
+
(0, import_react18.useEffect)(() => {
|
|
2773
3727
|
saveShortcutRef.current = saveShortcut;
|
|
2774
3728
|
}, [saveShortcut]);
|
|
2775
|
-
(0,
|
|
3729
|
+
(0, import_react18.useEffect)(() => {
|
|
2776
3730
|
contentFormatRef.current = contentFormat;
|
|
2777
3731
|
}, [contentFormat]);
|
|
2778
|
-
const extensions = (0,
|
|
3732
|
+
const extensions = (0, import_react18.useMemo)(() => [
|
|
2779
3733
|
import_starter_kit.default.configure({
|
|
2780
3734
|
heading: { levels: [1, 2, 3, 4, 5, 6] },
|
|
2781
3735
|
link: { openOnClick: false, autolink: true, linkOnPaste: true },
|
|
@@ -2791,7 +3745,7 @@ function RichTextEditor({
|
|
|
2791
3745
|
import_extension_task_item.default.configure({ nested: true }),
|
|
2792
3746
|
import_markdown.Markdown.configure({ markedOptions: { gfm: true } })
|
|
2793
3747
|
], [placeholder]);
|
|
2794
|
-
(0,
|
|
3748
|
+
(0, import_react18.useEffect)(() => {
|
|
2795
3749
|
const element = editorElementRef.current;
|
|
2796
3750
|
if (!element) return;
|
|
2797
3751
|
const nextEditor = new import_core.Editor({
|
|
@@ -2848,10 +3802,10 @@ function RichTextEditor({
|
|
|
2848
3802
|
nextEditor.destroy();
|
|
2849
3803
|
};
|
|
2850
3804
|
}, [ariaLabel, extensions]);
|
|
2851
|
-
(0,
|
|
3805
|
+
(0, import_react18.useEffect)(() => {
|
|
2852
3806
|
editor?.setEditable(!disabled);
|
|
2853
3807
|
}, [disabled, editor]);
|
|
2854
|
-
(0,
|
|
3808
|
+
(0, import_react18.useEffect)(() => {
|
|
2855
3809
|
if (!editor || value === void 0 || value === lastEmittedValueRef.current) return;
|
|
2856
3810
|
editor.commands.setContent(value, { emitUpdate: false, contentType: contentFormat });
|
|
2857
3811
|
lastEmittedValueRef.current = value;
|
|
@@ -2872,7 +3826,7 @@ function RichTextEditor({
|
|
|
2872
3826
|
setLinkEditorOpen(false);
|
|
2873
3827
|
}
|
|
2874
3828
|
function formatButton(label, action, active = false, disabledByState = false, content) {
|
|
2875
|
-
return /* @__PURE__ */ (0,
|
|
3829
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2876
3830
|
Button,
|
|
2877
3831
|
{
|
|
2878
3832
|
type: "button",
|
|
@@ -2910,27 +3864,27 @@ function RichTextEditor({
|
|
|
2910
3864
|
}
|
|
2911
3865
|
};
|
|
2912
3866
|
const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: editor ? !editor.isEmpty : Boolean(value ?? defaultValue) });
|
|
2913
|
-
return /* @__PURE__ */ (0,
|
|
3867
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { ...withTitleTooltip(props), id, style: mergedStyle, className: `sia-rich-text-editor${floating.className}${disabled ? " is-disabled" : ""} sia-rich-text-editor--${toolbar} ${className}`.trim(), children: [
|
|
2914
3868
|
floating.label,
|
|
2915
|
-
/* @__PURE__ */ (0,
|
|
2916
|
-
/* @__PURE__ */ (0,
|
|
2917
|
-
toolbar === "full" ? /* @__PURE__ */ (0,
|
|
2918
|
-
formatButton("\u64A4\u9500", () => editor?.chain().focus().undo().run(), false, !editor?.can().undo(), /* @__PURE__ */ (0,
|
|
2919
|
-
formatButton("\u91CD\u505A", () => editor?.chain().focus().redo().run(), false, !editor?.can().redo(), /* @__PURE__ */ (0,
|
|
2920
|
-
/* @__PURE__ */ (0,
|
|
2921
|
-
/* @__PURE__ */ (0,
|
|
3869
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "sia-rich-text-editor__toolbar", "aria-label": "\u6587\u672C\u683C\u5F0F\u5DE5\u5177\u680F", children: [
|
|
3870
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "sia-rich-text-editor__toolbar-main", children: [
|
|
3871
|
+
toolbar === "full" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
3872
|
+
formatButton("\u64A4\u9500", () => editor?.chain().focus().undo().run(), false, !editor?.can().undo(), /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "undo" })),
|
|
3873
|
+
formatButton("\u91CD\u505A", () => editor?.chain().focus().redo().run(), false, !editor?.can().redo(), /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "redo" })),
|
|
3874
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "sia-rich-text-editor__divider" }),
|
|
3875
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Dropdown, { menu: blockTypeMenu, trigger: ["click"], placement: "bottomLeft", disabled: disabled || !editor, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Button, { type: "button", variant: "text", size: "small", className: "sia-rich-text-editor__block-type", disabled: disabled || !editor, "aria-label": "\u6BB5\u843D\u683C\u5F0F", title: "\u6BB5\u843D\u683C\u5F0F", onMouseDown: (event) => event.preventDefault(), children: [
|
|
2922
3876
|
currentBlockLabel,
|
|
2923
|
-
/* @__PURE__ */ (0,
|
|
3877
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "chevron-down", size: 13 })
|
|
2924
3878
|
] }) }),
|
|
2925
|
-
/* @__PURE__ */ (0,
|
|
3879
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "sia-rich-text-editor__divider" })
|
|
2926
3880
|
] }) : null,
|
|
2927
|
-
formatButton("\u52A0\u7C97", () => editor?.chain().focus().toggleBold().run(), Boolean(editor?.isActive("bold")), false, /* @__PURE__ */ (0,
|
|
2928
|
-
formatButton("\u659C\u4F53", () => editor?.chain().focus().toggleItalic().run(), Boolean(editor?.isActive("italic")), false, /* @__PURE__ */ (0,
|
|
2929
|
-
toolbar === "full" ? /* @__PURE__ */ (0,
|
|
2930
|
-
formatButton("\u4E0B\u5212\u7EBF", () => editor?.chain().focus().toggleUnderline().run(), Boolean(editor?.isActive("underline")), false, /* @__PURE__ */ (0,
|
|
2931
|
-
formatButton("\u5220\u9664\u7EBF", () => editor?.chain().focus().toggleStrike().run(), Boolean(editor?.isActive("strike")), false, /* @__PURE__ */ (0,
|
|
3881
|
+
formatButton("\u52A0\u7C97", () => editor?.chain().focus().toggleBold().run(), Boolean(editor?.isActive("bold")), false, /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("strong", { children: "B" })),
|
|
3882
|
+
formatButton("\u659C\u4F53", () => editor?.chain().focus().toggleItalic().run(), Boolean(editor?.isActive("italic")), false, /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("em", { children: "I" })),
|
|
3883
|
+
toolbar === "full" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
3884
|
+
formatButton("\u4E0B\u5212\u7EBF", () => editor?.chain().focus().toggleUnderline().run(), Boolean(editor?.isActive("underline")), false, /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("u", { children: "U" })),
|
|
3885
|
+
formatButton("\u5220\u9664\u7EBF", () => editor?.chain().focus().toggleStrike().run(), Boolean(editor?.isActive("strike")), false, /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("s", { children: "S" })),
|
|
2932
3886
|
formatButton("\u884C\u5185\u4EE3\u7801", () => editor?.chain().focus().toggleCode().run(), Boolean(editor?.isActive("code")), false, "</>"),
|
|
2933
|
-
/* @__PURE__ */ (0,
|
|
3887
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2934
3888
|
Dropdown,
|
|
2935
3889
|
{
|
|
2936
3890
|
menu: { items: [] },
|
|
@@ -2940,50 +3894,53 @@ function RichTextEditor({
|
|
|
2940
3894
|
disabled: disabled || !editor,
|
|
2941
3895
|
onOpenChange: openLinkEditor,
|
|
2942
3896
|
popupClassName: "sia-rich-text-editor__link-popup",
|
|
2943
|
-
popupRender: () => /* @__PURE__ */ (0,
|
|
2944
|
-
/* @__PURE__ */ (0,
|
|
2945
|
-
/* @__PURE__ */ (0,
|
|
2946
|
-
editor?.isActive("link") ? /* @__PURE__ */ (0,
|
|
3897
|
+
popupRender: () => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("form", { className: "sia-rich-text-editor__link-form", onSubmit: submitLink, children: [
|
|
3898
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Input, { autoFocus: true, "aria-label": "\u94FE\u63A5\u5730\u5740", value: linkHref, onChange: (event) => setLinkHref(event.target.value), placeholder: "https://example.com" }),
|
|
3899
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { type: "submit", variant: "primary", size: "small", children: "\u5E94\u7528" }),
|
|
3900
|
+
editor?.isActive("link") ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { type: "button", size: "small", onClick: () => {
|
|
2947
3901
|
setLinkHref("");
|
|
2948
3902
|
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
2949
3903
|
setLinkEditorOpen(false);
|
|
2950
3904
|
}, children: "\u79FB\u9664" }) : null
|
|
2951
3905
|
] }),
|
|
2952
|
-
children: /* @__PURE__ */ (0,
|
|
3906
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { type: "button", variant: "text", size: "small", className: `sia-rich-text-editor__tool${editor?.isActive("link") ? " is-active" : ""}`, disabled: disabled || !editor, "aria-label": "\u94FE\u63A5", "aria-pressed": editor?.isActive("link") || void 0, title: "\u94FE\u63A5", onMouseDown: (event) => event.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "link" }) })
|
|
2953
3907
|
}
|
|
2954
3908
|
),
|
|
2955
|
-
/* @__PURE__ */ (0,
|
|
3909
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "sia-rich-text-editor__divider" })
|
|
2956
3910
|
] }) : null,
|
|
2957
3911
|
formatButton("\u65E0\u5E8F\u5217\u8868", () => editor?.chain().focus().toggleBulletList().run(), Boolean(editor?.isActive("bulletList")), false, "\u2022 \u5217\u8868"),
|
|
2958
3912
|
formatButton("\u6709\u5E8F\u5217\u8868", () => editor?.chain().focus().toggleOrderedList().run(), Boolean(editor?.isActive("orderedList")), false, "1. \u5217\u8868"),
|
|
2959
|
-
toolbar === "full" ? /* @__PURE__ */ (0,
|
|
3913
|
+
toolbar === "full" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
2960
3914
|
formatButton("\u4EFB\u52A1\u5217\u8868", () => editor?.chain().focus().toggleTaskList().run(), Boolean(editor?.isActive("taskList")), false, "\u2611 \u4EFB\u52A1"),
|
|
2961
3915
|
formatButton("\u5F15\u7528", () => editor?.chain().focus().toggleBlockquote().run(), Boolean(editor?.isActive("blockquote")), false, "\u275D \u5F15\u7528"),
|
|
2962
3916
|
formatButton("\u4EE3\u7801\u5757", () => editor?.chain().focus().toggleCodeBlock().run(), Boolean(editor?.isActive("codeBlock")), false, "\u4EE3\u7801\u5757"),
|
|
2963
3917
|
formatButton("\u63D2\u5165\u8868\u683C", () => editor?.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(), Boolean(editor?.isActive("table")), false, "\u8868\u683C"),
|
|
2964
|
-
formatButton("\u5206\u5272\u7EBF", () => editor?.chain().focus().setHorizontalRule().run(), false, false, /* @__PURE__ */ (0,
|
|
3918
|
+
formatButton("\u5206\u5272\u7EBF", () => editor?.chain().focus().setHorizontalRule().run(), false, false, /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "minus" }))
|
|
2965
3919
|
] }) : null
|
|
2966
3920
|
] }),
|
|
2967
|
-
onPasteImage ? /* @__PURE__ */ (0,
|
|
2968
|
-
/* @__PURE__ */ (0,
|
|
3921
|
+
onPasteImage ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("small", { children: [
|
|
3922
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "image", size: 14 }),
|
|
2969
3923
|
pasteImageHint
|
|
2970
3924
|
] }) : null
|
|
2971
3925
|
] }),
|
|
2972
|
-
toolbar === "full" && editor?.isActive("table") ? /* @__PURE__ */ (0,
|
|
2973
|
-
/* @__PURE__ */ (0,
|
|
3926
|
+
toolbar === "full" && editor?.isActive("table") ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "sia-rich-text-editor__table-toolbar", "aria-label": "\u8868\u683C\u5DE5\u5177\u680F", children: [
|
|
3927
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: "\u8868\u683C" }),
|
|
2974
3928
|
formatButton("\u524D\u65B9\u63D2\u5165\u5217", () => editor.chain().focus().addColumnBefore().run(), false, !editor.can().addColumnBefore(), "\u524D\u63D2\u5217"),
|
|
2975
3929
|
formatButton("\u540E\u65B9\u63D2\u5165\u5217", () => editor.chain().focus().addColumnAfter().run(), false, !editor.can().addColumnAfter(), "\u540E\u63D2\u5217"),
|
|
2976
3930
|
formatButton("\u5220\u9664\u5F53\u524D\u5217", () => editor.chain().focus().deleteColumn().run(), false, !editor.can().deleteColumn(), "\u5220\u5217"),
|
|
2977
|
-
/* @__PURE__ */ (0,
|
|
3931
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "sia-rich-text-editor__divider" }),
|
|
2978
3932
|
formatButton("\u4E0A\u65B9\u63D2\u5165\u884C", () => editor.chain().focus().addRowBefore().run(), false, !editor.can().addRowBefore(), "\u4E0A\u63D2\u884C"),
|
|
2979
3933
|
formatButton("\u4E0B\u65B9\u63D2\u5165\u884C", () => editor.chain().focus().addRowAfter().run(), false, !editor.can().addRowAfter(), "\u4E0B\u63D2\u884C"),
|
|
2980
3934
|
formatButton("\u5220\u9664\u5F53\u524D\u884C", () => editor.chain().focus().deleteRow().run(), false, !editor.can().deleteRow(), "\u5220\u884C"),
|
|
2981
|
-
/* @__PURE__ */ (0,
|
|
3935
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "sia-rich-text-editor__divider" }),
|
|
2982
3936
|
formatButton("\u5220\u9664\u8868\u683C", () => editor.chain().focus().deleteTable().run(), false, !editor.can().deleteTable(), "\u5220\u9664\u8868\u683C")
|
|
2983
3937
|
] }) : null,
|
|
2984
|
-
/* @__PURE__ */ (0,
|
|
3938
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { ref: editorElementRef, className: "sia-rich-text-editor__content" })
|
|
2985
3939
|
] });
|
|
2986
3940
|
}
|
|
3941
|
+
|
|
3942
|
+
// src/rich-text-editor.ts
|
|
3943
|
+
initializeDefaultScrollbars();
|
|
2987
3944
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2988
3945
|
0 && (module.exports = {
|
|
2989
3946
|
RichTextContent,
|