@sia.soul/sia-react-ui 0.1.142 → 0.1.144

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/{Button-BiL3Wjsd.d.ts → Button-C8W8ZHWV.d.ts} +1 -1
  2. package/dist/{Button-O_pNB3SQ.d.cts → Button-CxKBjLda.d.cts} +1 -1
  3. package/dist/{Select-DeD4O8FL.d.ts → Select-CTSd8zum.d.ts} +14 -10
  4. package/dist/{Select-Y0e9kaxE.d.cts → Select-bKLket9n.d.cts} +14 -10
  5. package/dist/chart.cjs +1051 -335
  6. package/dist/chart.js +5 -5
  7. package/dist/chunk-4OHS7RXE.js +1004 -0
  8. package/dist/{chunk-WIRIEIRO.js → chunk-4TYHSAR3.js} +5 -5
  9. package/dist/{chunk-TUGCP3GB.js → chunk-566S64IP.js} +5 -5
  10. package/dist/{chunk-CZ2ITBRW.js → chunk-7SEGBB6V.js} +34 -5
  11. package/dist/{chunk-KY6A5IJH.js → chunk-ETQJ2DQ2.js} +1 -1
  12. package/dist/{chunk-WD56MJO2.js → chunk-F52O2MOV.js} +7 -3
  13. package/dist/{chunk-PQBCD54U.js → chunk-JRXYM5YH.js} +167 -64
  14. package/dist/{chunk-SCEHVGKV.js → chunk-LKLPCYEP.js} +2 -2
  15. package/dist/{chunk-3KYG7IU7.js → chunk-MD4CGSOR.js} +105 -61
  16. package/dist/{chunk-PGP4TEPP.js → chunk-ORSQAJ22.js} +154 -494
  17. package/dist/{chunk-SO7IJZIR.js → chunk-PD3K5U5Y.js} +2 -2
  18. package/dist/{chunk-UVHC6OEX.js → chunk-WCYVBO2N.js} +342 -123
  19. package/dist/{core-DYo5C4Si.d.cts → core-COaZfusa.d.cts} +51 -24
  20. package/dist/{core-sWwvVAmP.d.ts → core-CvfsQGuT.d.ts} +51 -24
  21. package/dist/core.cjs +1996 -1250
  22. package/dist/core.css +413 -344
  23. package/dist/core.d.cts +3 -3
  24. package/dist/core.d.ts +3 -3
  25. package/dist/core.js +18 -9
  26. package/dist/game.cjs +1984 -1169
  27. package/dist/game.css +182 -177
  28. package/dist/game.d.cts +1 -1
  29. package/dist/game.d.ts +1 -1
  30. package/dist/game.js +8 -3
  31. package/dist/index.cjs +4660 -3541
  32. package/dist/index.css +413 -344
  33. package/dist/index.d.cts +78 -81
  34. package/dist/index.d.ts +78 -81
  35. package/dist/index.js +1083 -715
  36. package/dist/markdown-editor.cjs +727 -40
  37. package/dist/markdown-editor.js +8 -3
  38. package/dist/rich-text-editor.cjs +1265 -308
  39. package/dist/rich-text-editor.js +12 -7
  40. package/dist/{select-date-range-X6a9Y-Te.d.ts → select-date-range-C8cacfmb.d.ts} +1 -1
  41. package/dist/{select-date-range-DiBQQ0Rn.d.cts → select-date-range-Dad0IdD4.d.cts} +1 -1
  42. package/dist/select-date-range.cjs +1277 -806
  43. package/dist/select-date-range.d.cts +3 -3
  44. package/dist/select-date-range.d.ts +3 -3
  45. package/dist/select-date-range.js +13 -8
  46. package/package.json +9 -2
  47. package/dist/chunk-NZMUW5XI.js +0 -292
@@ -34,12 +34,662 @@ __export(markdown_editor_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(markdown_editor_exports);
36
36
 
37
+ // src/components/FloatingScrollbarProvider.tsx
38
+ var import_react2 = require("react");
39
+
40
+ // src/components/useScrollbarProximity.ts
41
+ var import_react = require("react");
42
+ var users = 0;
43
+ var cleanup;
44
+ function acquireScrollbarProximity() {
45
+ if (users++ === 0) {
46
+ let frame = 0;
47
+ let x = -Infinity;
48
+ let y = -Infinity;
49
+ const nearby = /* @__PURE__ */ new Set();
50
+ const clear = () => {
51
+ nearby.forEach((track) => track.removeAttribute("data-scrollbar-near"));
52
+ nearby.clear();
53
+ };
54
+ const update = () => {
55
+ frame = 0;
56
+ const next = /* @__PURE__ */ new Set();
57
+ document.querySelectorAll(".sia-scrollbar-track").forEach((track) => {
58
+ const rect = track.getBoundingClientRect();
59
+ const proximity = Number.parseFloat(getComputedStyle(track).getPropertyValue("--sia-scrollbar-proximity")) || 16;
60
+ if (rect.width && rect.height && x >= rect.left - proximity && x <= rect.right + proximity && y >= rect.top - proximity && y <= rect.bottom + proximity) {
61
+ next.add(track);
62
+ if (!nearby.has(track)) track.setAttribute("data-scrollbar-near", "true");
63
+ }
64
+ });
65
+ nearby.forEach((track) => {
66
+ if (!next.has(track)) track.removeAttribute("data-scrollbar-near");
67
+ });
68
+ nearby.clear();
69
+ next.forEach((track) => nearby.add(track));
70
+ };
71
+ const move = (event) => {
72
+ if (event.pointerType === "touch") return;
73
+ x = event.clientX;
74
+ y = event.clientY;
75
+ if (!frame) frame = requestAnimationFrame(update);
76
+ };
77
+ const leave = () => {
78
+ x = y = -Infinity;
79
+ clear();
80
+ };
81
+ document.addEventListener("pointermove", move, { passive: true });
82
+ document.documentElement.addEventListener("pointerleave", leave);
83
+ window.addEventListener("blur", leave);
84
+ cleanup = () => {
85
+ if (frame) cancelAnimationFrame(frame);
86
+ document.removeEventListener("pointermove", move);
87
+ document.documentElement.removeEventListener("pointerleave", leave);
88
+ window.removeEventListener("blur", leave);
89
+ clear();
90
+ };
91
+ }
92
+ return () => {
93
+ if (--users === 0) {
94
+ cleanup?.();
95
+ cleanup = void 0;
96
+ }
97
+ };
98
+ }
99
+
100
+ // src/components/floatingScrollbarOwnership.ts
101
+ var targets = /* @__PURE__ */ new Map();
102
+ function registerFloatingScrollbar(track, target) {
103
+ targets.set(track, { target, dragging: false });
104
+ return () => {
105
+ targets.delete(track);
106
+ };
107
+ }
108
+ function setFloatingScrollbarDragging(track, dragging) {
109
+ const entry = targets.get(track);
110
+ if (entry) entry.dragging = dragging;
111
+ }
112
+
113
+ // src/components/FloatingScrollbarProvider.tsx
114
+ var scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
115
+ var clippingOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay", "hidden", "clip"]);
116
+ function isRootScroller(target) {
117
+ return target === document.scrollingElement || target === document.documentElement;
118
+ }
119
+ function canScroll(target, axis) {
120
+ if (target.matches(".sia-table__viewport, [data-sia-native-scrollbar]")) return false;
121
+ if (isRootScroller(target)) {
122
+ const rootStyle = getComputedStyle(target);
123
+ const bodyStyle = getComputedStyle(document.body);
124
+ const overflow2 = axis === "horizontal" ? [rootStyle.overflowX, bodyStyle.overflowX] : [rootStyle.overflowY, bodyStyle.overflowY];
125
+ if (overflow2.some((value) => value === "hidden" || value === "clip")) return false;
126
+ return axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
127
+ }
128
+ const style = getComputedStyle(target);
129
+ const overflow = axis === "horizontal" ? style.overflowX : style.overflowY;
130
+ if (!scrollableOverflow.has(overflow)) return false;
131
+ const hasOverflow = axis === "horizontal" ? target.scrollWidth > target.clientWidth + 1 : target.scrollHeight > target.clientHeight + 1;
132
+ return hasOverflow;
133
+ }
134
+ function visibleRect(target) {
135
+ if (isRootScroller(target)) {
136
+ return { top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0, width: window.innerWidth, height: window.innerHeight };
137
+ }
138
+ const ownRect = target.getBoundingClientRect();
139
+ let top = Math.max(0, ownRect.top);
140
+ let right = Math.min(window.innerWidth, ownRect.right);
141
+ let bottom = Math.min(window.innerHeight, ownRect.bottom);
142
+ let left = Math.max(0, ownRect.left);
143
+ let parent = target.parentElement;
144
+ while (parent && parent !== document.body && parent !== document.documentElement) {
145
+ const style = getComputedStyle(parent);
146
+ const clipX = clippingOverflow.has(style.overflowX);
147
+ const clipY = clippingOverflow.has(style.overflowY);
148
+ if (clipX || clipY) {
149
+ const rect = parent.getBoundingClientRect();
150
+ if (clipX) {
151
+ left = Math.max(left, rect.left);
152
+ right = Math.min(right, rect.right);
153
+ }
154
+ if (clipY) {
155
+ top = Math.max(top, rect.top);
156
+ bottom = Math.min(bottom, rect.bottom);
157
+ }
158
+ }
159
+ parent = parent.parentElement;
160
+ }
161
+ return {
162
+ top,
163
+ right,
164
+ bottom,
165
+ left,
166
+ width: Math.max(0, right - left),
167
+ height: Math.max(0, bottom - top)
168
+ };
169
+ }
170
+ function createTrack(axis) {
171
+ const track = document.createElement("div");
172
+ const thumb = document.createElement("div");
173
+ track.className = `sia-scrollbar-track sia-floating-scrollbar sia-floating-scrollbar--${axis}`;
174
+ thumb.className = "sia-floating-scrollbar__thumb";
175
+ track.dataset.axis = axis;
176
+ track.setAttribute("aria-hidden", "true");
177
+ track.append(thumb);
178
+ return { track, thumb };
179
+ }
180
+ var automatic = false;
181
+ var stopGlobal;
182
+ var globalProviders = /* @__PURE__ */ new Map();
183
+ function syncDefaultScrollbars() {
184
+ if (typeof document === "undefined" || !document.body) return;
185
+ const enabled = (automatic || globalProviders.size > 0) && ![...globalProviders.values()].includes(false);
186
+ if (enabled && !stopGlobal) stopGlobal = startFloatingScrollbars();
187
+ if (!enabled && stopGlobal) {
188
+ stopGlobal();
189
+ stopGlobal = void 0;
190
+ }
191
+ }
192
+ function initializeDefaultScrollbars() {
193
+ if (typeof document === "undefined" || automatic) return;
194
+ automatic = true;
195
+ if (document.body) syncDefaultScrollbars();
196
+ else document.addEventListener("DOMContentLoaded", syncDefaultScrollbars, { once: true });
197
+ }
198
+ function startFloatingScrollbars(targetRef) {
199
+ const releaseProximity = acquireScrollbarProximity();
200
+ const layer = document.createElement("div");
201
+ layer.className = "sia-floating-scrollbar-layer";
202
+ layer.setAttribute("aria-hidden", "true");
203
+ document.body.append(layer);
204
+ const entries = /* @__PURE__ */ new Map();
205
+ let scanFrame = 0;
206
+ let updateFrame = 0;
207
+ const dirtyStyles = /* @__PURE__ */ new Set();
208
+ let fullScan = true;
209
+ const setEntryVisible = (entry, visible) => {
210
+ entry.horizontalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
211
+ entry.verticalTrack.classList.toggle("sia-floating-scrollbar--visible", visible);
212
+ };
213
+ const showEntry = (entry) => {
214
+ if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
215
+ entry.hideTimer = null;
216
+ setEntryVisible(entry, true);
217
+ };
218
+ const scheduleHide = (entry, delay = 500) => {
219
+ if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
220
+ entry.hideTimer = window.setTimeout(() => {
221
+ entry.hideTimer = null;
222
+ if (!entry.hoveringTarget && !entry.hoveringTrack && !entry.dragging) setEntryVisible(entry, false);
223
+ }, delay);
224
+ };
225
+ const updateEntry = (entry) => {
226
+ const { target, horizontalTrack, horizontalThumb, verticalTrack, verticalThumb } = entry;
227
+ const hasHorizontal = canScroll(target, "horizontal");
228
+ const hasVertical = canScroll(target, "vertical");
229
+ const rect = visibleRect(target);
230
+ const thickness = 10;
231
+ horizontalTrack.hidden = !hasHorizontal || rect.width <= thickness || rect.height <= 0;
232
+ verticalTrack.hidden = !hasVertical || rect.height <= thickness || rect.width <= 0;
233
+ if (!horizontalTrack.hidden) {
234
+ const trackWidth = Math.max(0, rect.width - (hasVertical ? thickness : 0));
235
+ const thumbWidth = Math.max(24, Math.min(trackWidth, trackWidth * target.clientWidth / target.scrollWidth));
236
+ const travel = Math.max(0, trackWidth - thumbWidth);
237
+ const maxScroll = Math.max(1, target.scrollWidth - target.clientWidth);
238
+ horizontalTrack.style.left = `${rect.left}px`;
239
+ horizontalTrack.style.top = `${rect.bottom - thickness}px`;
240
+ horizontalTrack.style.width = `${trackWidth}px`;
241
+ horizontalTrack.style.height = `${thickness}px`;
242
+ horizontalThumb.style.width = `${thumbWidth}px`;
243
+ horizontalThumb.style.transform = `translate3d(${travel * target.scrollLeft / maxScroll}px, 0, 0)`;
244
+ }
245
+ if (!verticalTrack.hidden) {
246
+ const trackHeight = Math.max(0, rect.height - (hasHorizontal ? thickness : 0));
247
+ const thumbHeight = Math.max(24, Math.min(trackHeight, trackHeight * target.clientHeight / target.scrollHeight));
248
+ const travel = Math.max(0, trackHeight - thumbHeight);
249
+ const maxScroll = Math.max(1, target.scrollHeight - target.clientHeight);
250
+ verticalTrack.style.left = `${rect.right - thickness}px`;
251
+ verticalTrack.style.top = `${rect.top}px`;
252
+ verticalTrack.style.width = `${thickness}px`;
253
+ verticalTrack.style.height = `${trackHeight}px`;
254
+ verticalThumb.style.height = `${thumbHeight}px`;
255
+ verticalThumb.style.transform = `translate3d(0, ${travel * target.scrollTop / maxScroll}px, 0)`;
256
+ }
257
+ };
258
+ const scheduleUpdateAll = () => {
259
+ if (updateFrame) return;
260
+ updateFrame = window.requestAnimationFrame(() => {
261
+ updateFrame = 0;
262
+ entries.forEach(updateEntry);
263
+ });
264
+ };
265
+ const bindTrackDrag = (entry, axis, track, thumb) => {
266
+ const target = entry.target;
267
+ const onTrackPointerEnter = () => {
268
+ entry.hoveringTrack = true;
269
+ showEntry(entry);
270
+ };
271
+ const onTrackPointerLeave = () => {
272
+ entry.hoveringTrack = false;
273
+ scheduleHide(entry);
274
+ };
275
+ const onTrackPointerDown = (event) => {
276
+ if (event.target === thumb || event.button !== 0) return;
277
+ event.preventDefault();
278
+ event.stopPropagation();
279
+ const trackRect = track.getBoundingClientRect();
280
+ const thumbRect = thumb.getBoundingClientRect();
281
+ const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
282
+ const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
283
+ const pointer = axis === "vertical" ? event.clientY - trackRect.top : event.clientX - trackRect.left;
284
+ const ratio = Math.max(0, Math.min(1, (pointer - thumbLength / 2) / Math.max(1, trackLength - thumbLength)));
285
+ if (axis === "vertical") target.scrollTop = ratio * (target.scrollHeight - target.clientHeight);
286
+ else target.scrollLeft = ratio * (target.scrollWidth - target.clientWidth);
287
+ };
288
+ const onThumbPointerDown = (event) => {
289
+ if (event.button !== 0) return;
290
+ event.preventDefault();
291
+ event.stopPropagation();
292
+ entry.dragging = true;
293
+ setFloatingScrollbarDragging(track, true);
294
+ showEntry(entry);
295
+ thumb.setPointerCapture(event.pointerId);
296
+ const startPointer = axis === "vertical" ? event.clientY : event.clientX;
297
+ const startScroll = axis === "vertical" ? target.scrollTop : target.scrollLeft;
298
+ const trackRect = track.getBoundingClientRect();
299
+ const thumbRect = thumb.getBoundingClientRect();
300
+ const trackLength = axis === "vertical" ? trackRect.height : trackRect.width;
301
+ const thumbLength = axis === "vertical" ? thumbRect.height : thumbRect.width;
302
+ const maxScroll = axis === "vertical" ? target.scrollHeight - target.clientHeight : target.scrollWidth - target.clientWidth;
303
+ const travel = Math.max(1, trackLength - thumbLength);
304
+ const onPointerMove = (moveEvent) => {
305
+ if (moveEvent.pointerId !== event.pointerId) return;
306
+ const pointer = axis === "vertical" ? moveEvent.clientY : moveEvent.clientX;
307
+ const nextScroll = startScroll + (pointer - startPointer) * maxScroll / travel;
308
+ if (axis === "vertical") target.scrollTop = nextScroll;
309
+ else target.scrollLeft = nextScroll;
310
+ };
311
+ const onPointerUp = (upEvent) => {
312
+ if (upEvent.pointerId !== event.pointerId) return;
313
+ entry.dragging = false;
314
+ setFloatingScrollbarDragging(track, false);
315
+ thumb.releasePointerCapture(event.pointerId);
316
+ window.removeEventListener("pointermove", onPointerMove);
317
+ window.removeEventListener("pointerup", onPointerUp);
318
+ window.removeEventListener("pointercancel", onPointerUp);
319
+ scheduleHide(entry);
320
+ };
321
+ window.addEventListener("pointermove", onPointerMove);
322
+ window.addEventListener("pointerup", onPointerUp);
323
+ window.addEventListener("pointercancel", onPointerUp);
324
+ };
325
+ track.addEventListener("pointerenter", onTrackPointerEnter);
326
+ track.addEventListener("pointerleave", onTrackPointerLeave);
327
+ track.addEventListener("pointerdown", onTrackPointerDown);
328
+ thumb.addEventListener("pointerdown", onThumbPointerDown);
329
+ return () => {
330
+ track.removeEventListener("pointerenter", onTrackPointerEnter);
331
+ track.removeEventListener("pointerleave", onTrackPointerLeave);
332
+ track.removeEventListener("pointerdown", onTrackPointerDown);
333
+ thumb.removeEventListener("pointerdown", onThumbPointerDown);
334
+ };
335
+ };
336
+ const resizeObserver = new ResizeObserver((observedEntries) => {
337
+ observedEntries.forEach(({ target }) => {
338
+ const entry = entries.get(target);
339
+ if (entry) updateEntry(entry);
340
+ });
341
+ });
342
+ const addTarget = (target) => {
343
+ if (entries.has(target)) return;
344
+ const horizontal = createTrack("horizontal");
345
+ const vertical = createTrack("vertical");
346
+ const releaseHorizontalOwner = registerFloatingScrollbar(horizontal.track, target);
347
+ const releaseVerticalOwner = registerFloatingScrollbar(vertical.track, target);
348
+ layer.append(horizontal.track, vertical.track);
349
+ const onPointerEnter = () => {
350
+ const entry2 = entries.get(target);
351
+ if (!entry2) return;
352
+ entry2.hoveringTarget = true;
353
+ showEntry(entry2);
354
+ };
355
+ const onPointerLeave = () => {
356
+ const entry2 = entries.get(target);
357
+ if (!entry2) return;
358
+ entry2.hoveringTarget = false;
359
+ scheduleHide(entry2);
360
+ };
361
+ const onScroll = () => {
362
+ const entry2 = entries.get(target);
363
+ if (!entry2) return;
364
+ updateEntry(entry2);
365
+ showEntry(entry2);
366
+ scheduleHide(entry2, 700);
367
+ };
368
+ target.addEventListener("pointerenter", onPointerEnter);
369
+ target.addEventListener("pointerleave", onPointerLeave);
370
+ target.addEventListener("scroll", onScroll, { passive: true });
371
+ const entry = {
372
+ target,
373
+ horizontalTrack: horizontal.track,
374
+ horizontalThumb: horizontal.thumb,
375
+ verticalTrack: vertical.track,
376
+ verticalThumb: vertical.thumb,
377
+ hideTimer: null,
378
+ hoveringTarget: target.matches(":hover"),
379
+ hoveringTrack: false,
380
+ dragging: false,
381
+ cleanup: () => void 0
382
+ };
383
+ const cleanupHorizontal = bindTrackDrag(entry, "horizontal", horizontal.track, horizontal.thumb);
384
+ const cleanupVertical = bindTrackDrag(entry, "vertical", vertical.track, vertical.thumb);
385
+ entry.cleanup = () => {
386
+ if (entry.hideTimer !== null) window.clearTimeout(entry.hideTimer);
387
+ cleanupHorizontal();
388
+ cleanupVertical();
389
+ releaseHorizontalOwner();
390
+ releaseVerticalOwner();
391
+ target.removeEventListener("pointerenter", onPointerEnter);
392
+ target.removeEventListener("pointerleave", onPointerLeave);
393
+ target.removeEventListener("scroll", onScroll);
394
+ resizeObserver.unobserve(target);
395
+ target.removeAttribute("data-sia-floating-scrollbar");
396
+ horizontal.track.remove();
397
+ vertical.track.remove();
398
+ };
399
+ entries.set(target, entry);
400
+ target.setAttribute("data-sia-floating-scrollbar", "");
401
+ resizeObserver.observe(target);
402
+ updateEntry(entry);
403
+ if (entry.hoveringTarget) showEntry(entry);
404
+ };
405
+ const removeTarget = (target) => {
406
+ const entry = entries.get(target);
407
+ if (!entry) return;
408
+ entry.cleanup();
409
+ entries.delete(target);
410
+ };
411
+ const scanTargets = () => {
412
+ scanFrame = 0;
413
+ const managedSelector = ".sia-table__viewport, .sia-scrollbar-track, .sia-floating-scrollbar-layer";
414
+ const discovered = /* @__PURE__ */ new Set();
415
+ if (!targetRef) {
416
+ const roots = fullScan ? [document.body] : [...dirtyStyles].filter((node) => node.isConnected);
417
+ for (const root of roots) {
418
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
419
+ acceptNode: (node) => node.matches(managedSelector) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
420
+ });
421
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
422
+ if (node instanceof HTMLElement) discovered.add(node);
423
+ }
424
+ for (let node = root; node; node = node.parentElement) discovered.add(node);
425
+ }
426
+ }
427
+ const candidates = (targetRef ? [targetRef.current] : [document.scrollingElement, ...discovered]).filter((target) => target instanceof HTMLElement);
428
+ const nextTargets = /* @__PURE__ */ new Set();
429
+ candidates.forEach((target) => {
430
+ if (canScroll(target, "horizontal") || canScroll(target, "vertical")) {
431
+ nextTargets.add(target);
432
+ }
433
+ });
434
+ nextTargets.forEach((target) => {
435
+ if (entries.has(target) || !target.hasAttribute("data-sia-floating-scrollbar")) addTarget(target);
436
+ });
437
+ entries.forEach((_entry, target) => {
438
+ if (!target.isConnected || (fullScan || candidates.includes(target)) && !nextTargets.has(target)) removeTarget(target);
439
+ else updateEntry(_entry);
440
+ });
441
+ dirtyStyles.clear();
442
+ fullScan = false;
443
+ };
444
+ const scheduleScan = (complete = true) => {
445
+ fullScan ||= complete;
446
+ if (scanFrame) return;
447
+ scanFrame = window.requestAnimationFrame(scanTargets);
448
+ };
449
+ const previousStyle = document.createElement("div").style;
450
+ const positionProperties = /* @__PURE__ */ new Set(["left", "top", "transform"]);
451
+ const mutationObserver = new MutationObserver((mutations) => {
452
+ let relevant = false;
453
+ for (const mutation of mutations) {
454
+ const target = mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
455
+ if (!target || layer.contains(target) || target.closest(".sia-table__viewport, .sia-scrollbar-track, .sia-floating-scrollbar-layer")) continue;
456
+ if (mutation.type === "childList") {
457
+ const changed = [...mutation.addedNodes, ...mutation.removedNodes];
458
+ if (changed.length && changed.every((node) => node instanceof Element && node.matches(".sia-floating-scrollbar-layer, .sia-scrollbar-track"))) continue;
459
+ if (target === document.body && changed.length && changed.every((node) => node instanceof HTMLElement && node.matches(".sia-popup-portal"))) {
460
+ changed.forEach((node) => {
461
+ if (node instanceof HTMLElement && node.isConnected) dirtyStyles.add(node);
462
+ });
463
+ relevant = true;
464
+ continue;
465
+ }
466
+ }
467
+ const popup = target.closest(".sia-popup-portal");
468
+ if (popup) {
469
+ dirtyStyles.add(popup);
470
+ relevant = true;
471
+ continue;
472
+ }
473
+ if (mutation.type === "attributes" && mutation.attributeName === "class" && target instanceof HTMLElement && target.matches(".sia-select")) {
474
+ const oldClasses = new Set((mutation.oldValue ?? "").split(/\s+/).filter(Boolean));
475
+ const newClasses = new Set(target.classList);
476
+ const changed = [.../* @__PURE__ */ new Set([...oldClasses, ...newClasses])].filter((name) => oldClasses.has(name) !== newClasses.has(name));
477
+ if (changed.every((name) => name === "is-open")) {
478
+ dirtyStyles.add(target);
479
+ relevant = true;
480
+ continue;
481
+ }
482
+ }
483
+ relevant = true;
484
+ let positionOnly = false;
485
+ if (mutation.type === "attributes" && mutation.attributeName === "style" && target instanceof HTMLElement) {
486
+ previousStyle.cssText = mutation.oldValue ?? "";
487
+ const keys = /* @__PURE__ */ new Set([...Array.from(previousStyle), ...Array.from(target.style)]);
488
+ const changed = [...keys].filter((key) => previousStyle.getPropertyValue(key) !== target.style.getPropertyValue(key) || previousStyle.getPropertyPriority(key) !== target.style.getPropertyPriority(key));
489
+ if (!changed.length) continue;
490
+ const fixedSize = target.style.width.endsWith("px") && target.style.height.endsWith("px");
491
+ positionOnly = fixedSize && changed.every((key) => positionProperties.has(key)) && ["absolute", "fixed"].includes(getComputedStyle(target).position);
492
+ }
493
+ if (positionOnly && target instanceof HTMLElement) dirtyStyles.add(target);
494
+ else fullScan = true;
495
+ }
496
+ if (relevant) scheduleScan(false);
497
+ });
498
+ mutationObserver.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ["class", "style", "hidden", "data-sia-native-scrollbar", "data-sia-floating-scrollbar"] });
499
+ const onResize = () => scheduleScan();
500
+ window.addEventListener("resize", onResize);
501
+ window.addEventListener("scroll", scheduleUpdateAll, true);
502
+ scheduleScan();
503
+ return () => {
504
+ releaseProximity();
505
+ mutationObserver.disconnect();
506
+ resizeObserver.disconnect();
507
+ window.removeEventListener("resize", onResize);
508
+ window.removeEventListener("scroll", scheduleUpdateAll, true);
509
+ if (scanFrame) window.cancelAnimationFrame(scanFrame);
510
+ if (updateFrame) window.cancelAnimationFrame(updateFrame);
511
+ entries.forEach((entry) => entry.cleanup());
512
+ entries.clear();
513
+ layer.remove();
514
+ };
515
+ }
516
+
37
517
  // src/components/titleTooltip.tsx
38
518
  var import_client = require("react-dom/client");
39
519
 
40
520
  // src/components/PopupPortal.tsx
41
- var import_react = require("react");
521
+ var import_react4 = require("react");
42
522
  var import_react_dom = require("react-dom");
523
+
524
+ // src/components/overlayMotion.ts
525
+ var import_react3 = require("react");
526
+
527
+ // src/components/popupFluidMotion.ts
528
+ var popupEnterDuration = 260;
529
+ var popupExitDuration = 140;
530
+ var popupInitialScale = 0.88;
531
+ var popupTravelOffset = 6;
532
+ function popupFluidFrames(placement, open = true) {
533
+ const side = placement.split("-")[0];
534
+ const axis = side === "left" || side === "right" ? "X" : "Y";
535
+ const sign = side === "left" || side === "top" ? 1 : -1;
536
+ const hidden = { opacity: 0, transform: `translate${axis}(${sign * popupTravelOffset}px) scale(${popupInitialScale})` };
537
+ const visible = { opacity: 1, transform: "none" };
538
+ return open ? [
539
+ { ...hidden, offset: 0 },
540
+ { opacity: 1, transform: "scale(1.11, 1.085)", offset: 0.68 },
541
+ { opacity: 1, transform: "scale(.945, .965)", offset: 0.86 },
542
+ { ...visible, offset: 1 }
543
+ ] : [{ ...visible, offset: 0 }, { ...hidden, offset: 1 }];
544
+ }
545
+
546
+ // src/components/overlayMotion.ts
547
+ function motionFrames(kind, placement) {
548
+ if (kind === "fade") return [{ opacity: 0 }, { opacity: 1 }];
549
+ if (kind === "toast") return [
550
+ { opacity: 0, transform: "translateY(-6px)", offset: 0 },
551
+ { opacity: 1, transform: "translateY(3px)", offset: 0.68 },
552
+ { opacity: 1, transform: "translateY(-1px)", offset: 0.86 },
553
+ { opacity: 1, transform: "none", offset: 1 }
554
+ ];
555
+ if (kind === "drawer") {
556
+ const axis = placement === "left" || placement === "right" ? "X" : "Y";
557
+ const sign = placement === "left" || placement === "top" ? -1 : 1;
558
+ const outside = `translate${axis}(${sign * 100}%)`;
559
+ return [
560
+ { transform: outside, offset: 0 },
561
+ { transform: `translate${axis}(0) scale${axis}(1.065)`, offset: 0.68 },
562
+ { transform: `translate${axis}(0) scale${axis}(.975)`, offset: 0.86 },
563
+ { transform: "none", offset: 1 }
564
+ ];
565
+ }
566
+ const modal = kind === "modal";
567
+ return [
568
+ { opacity: 0, transform: `translateY(${modal ? 18 : -6}px) scale(${modal ? 0.9 : 0.88})`, offset: 0 },
569
+ { opacity: 1, transform: modal ? "scale(1.075, 1.05)" : "scale(1.11, 1.085)", offset: 0.68 },
570
+ { opacity: 1, transform: modal ? "scale(.965, .98)" : "scale(.945, .965)", offset: 0.86 },
571
+ { opacity: 1, transform: "none", offset: 1 }
572
+ ];
573
+ }
574
+ function useOverlayMotion(open, ref, kind, placement = "bottom", ready = true, onFinish, enabled = true) {
575
+ const [phase, setPhase] = (0, import_react3.useState)(open ? "entering" : "closed");
576
+ const present = open || phase !== "closed";
577
+ const [entered, setEntered] = (0, import_react3.useState)(false);
578
+ const position = (0, import_react3.useRef)();
579
+ const snapshot = (0, import_react3.useRef)();
580
+ const notify = (0, import_react3.useRef)();
581
+ const callback = (0, import_react3.useRef)(onFinish);
582
+ callback.current = onFinish;
583
+ (0, import_react3.useLayoutEffect)(() => {
584
+ const node = ref.current;
585
+ if (!present || !ready || !node) return;
586
+ let cancelled = false;
587
+ let animation;
588
+ let surfaceAnimation;
589
+ let maskAnimation;
590
+ const panel = kind === "drawer" || kind === "modal";
591
+ const fluid = kind === "popup";
592
+ const mask = kind === "modal" ? node.closest(".sia-modal-root") : kind === "drawer" ? node.closest(".sia-drawer-root")?.querySelector(".sia-drawer__mask") : null;
593
+ setPhase(open ? "entering" : "closing");
594
+ const finish = () => {
595
+ if (cancelled) return;
596
+ position.current = void 0;
597
+ snapshot.current = void 0;
598
+ if (open) {
599
+ animation?.cancel();
600
+ surfaceAnimation?.cancel();
601
+ maskAnimation?.cancel();
602
+ }
603
+ notify.current = open;
604
+ setEntered(open);
605
+ setPhase(open ? "open" : "closed");
606
+ node.dispatchEvent(new Event("sia-overlay-motion-end", { bubbles: true }));
607
+ };
608
+ const reduced = node.ownerDocument.defaultView?.matchMedia("(prefers-reduced-motion: reduce)");
609
+ const completeImmediately = () => {
610
+ animation?.cancel();
611
+ surfaceAnimation?.cancel();
612
+ maskAnimation?.cancel();
613
+ finish();
614
+ };
615
+ if (!enabled || reduced?.matches || !node.animate) {
616
+ finish();
617
+ } else {
618
+ let frames = fluid ? popupFluidFrames(placement, open) : motionFrames(kind, placement);
619
+ const start = snapshot.current;
620
+ const enterDuration = fluid ? popupEnterDuration : kind === "drawer" ? 320 : kind === "modal" ? 240 : kind === "fade" ? 180 : 280;
621
+ let duration = fluid && !open ? popupExitDuration : panel && !open ? kind === "drawer" ? 180 : 160 : enterDuration;
622
+ if (fluid && start) {
623
+ const current = new DOMMatrix(start.transform);
624
+ const destination = new DOMMatrix(String(frames[frames.length - 1].transform));
625
+ 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));
626
+ frames = [{ offset: 0, transform: start.transform, opacity: start.opacity }, { ...frames[frames.length - 1], offset: 1 }];
627
+ duration *= remaining;
628
+ }
629
+ if (panel) {
630
+ if (!open) frames = [{ transform: start?.transform ?? "none", opacity: start?.opacity ?? 1 }, { ...frames[0], offset: 1 }];
631
+ else if (start) frames = [{ ...frames[0], transform: start.transform, opacity: start.opacity }, ...frames.slice(1)];
632
+ }
633
+ const options = {
634
+ duration,
635
+ 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)",
636
+ direction: panel || fluid || open ? "normal" : "reverse",
637
+ fill: "both"
638
+ };
639
+ animation = node.animate(frames, options);
640
+ if (!panel && !fluid && position.current !== void 0) animation.currentTime = open ? position.current : duration - position.current;
641
+ position.current = void 0;
642
+ snapshot.current = void 0;
643
+ if (mask) {
644
+ maskAnimation = mask.animate([{ opacity: start?.maskOpacity ?? (open ? 0 : 1) }, { opacity: open ? 1 : 0 }], { ...options, pseudoElement: kind === "modal" ? "::before" : void 0 });
645
+ maskAnimation.currentTime = animation.currentTime;
646
+ if (animation.startTime !== null) maskAnimation.startTime = animation.startTime;
647
+ }
648
+ if (kind === "toast") {
649
+ const surfaceFrames = motionFrames("message", placement).map((frame) => ({
650
+ offset: frame.offset,
651
+ transform: String(frame.transform).replace(/translateY\([^)]*\)\s*/g, "")
652
+ }));
653
+ surfaceAnimation = node.animate(surfaceFrames, { ...options, pseudoElement: "::before" });
654
+ surfaceAnimation.currentTime = animation.currentTime;
655
+ if (animation.startTime !== null) surfaceAnimation.startTime = animation.startTime;
656
+ }
657
+ animation.finished.then(finish, () => {
658
+ });
659
+ reduced?.addEventListener("change", completeImmediately, { once: true });
660
+ }
661
+ return () => {
662
+ cancelled = true;
663
+ reduced?.removeEventListener("change", completeImmediately);
664
+ if (animation && (animation.playState === "running" || animation.playState === "paused")) {
665
+ if (panel || fluid) {
666
+ const css = node.ownerDocument.defaultView.getComputedStyle(node);
667
+ snapshot.current = {
668
+ transform: css.transform,
669
+ opacity: css.opacity,
670
+ maskOpacity: mask ? node.ownerDocument.defaultView.getComputedStyle(mask, kind === "modal" ? "::before" : null).opacity : void 0
671
+ };
672
+ } else {
673
+ const time = Number(animation.currentTime ?? 0);
674
+ const duration = Number(animation.effect?.getTiming().duration ?? 0);
675
+ position.current = open ? time : duration - time;
676
+ }
677
+ }
678
+ animation?.cancel();
679
+ surfaceAnimation?.cancel();
680
+ maskAnimation?.cancel();
681
+ };
682
+ }, [open, present, ready, kind, placement, enabled, ref]);
683
+ (0, import_react3.useEffect)(() => {
684
+ if (notify.current === void 0) return;
685
+ const completedOpen = notify.current;
686
+ notify.current = void 0;
687
+ if (completedOpen === open) callback.current?.(completedOpen);
688
+ }, [phase, open]);
689
+ return { present, entered, settled: phase === "open", closing: !open, phase };
690
+ }
691
+
692
+ // src/components/PopupPortal.tsx
43
693
  var import_jsx_runtime = require("react/jsx-runtime");
44
694
  function setForwardedRef(ref, value) {
45
695
  if (typeof ref === "function") ref(value);
@@ -48,21 +698,23 @@ function setForwardedRef(ref, value) {
48
698
  function clamp(value, min, max) {
49
699
  return Math.min(Math.max(value, min), Math.max(min, max));
50
700
  }
51
- var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
701
+ var PopupPortal = (0, import_react4.forwardRef)(function PopupPortal2({
52
702
  anchorRef,
53
703
  open = true,
54
704
  placement = "bottom-start",
55
705
  offset = 6,
56
706
  viewportPadding = 8,
707
+ afterOpenChange,
57
708
  className = "",
58
709
  style,
59
710
  children,
60
711
  ...props
61
712
  }, forwardedRef) {
62
- const popupRef = (0, import_react.useRef)(null);
63
- const [position, setPosition] = (0, import_react.useState)();
64
- (0, import_react.useLayoutEffect)(() => {
65
- if (!open || typeof document === "undefined") {
713
+ const popupRef = (0, import_react4.useRef)(null);
714
+ const [position, setPosition] = (0, import_react4.useState)();
715
+ const motion = useOverlayMotion(open, popupRef, "popup", position?.placement ?? placement, !!position, afterOpenChange);
716
+ (0, import_react4.useLayoutEffect)(() => {
717
+ if (!motion.present || typeof document === "undefined") {
66
718
  setPosition(void 0);
67
719
  return;
68
720
  }
@@ -71,7 +723,7 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
71
723
  const popup = popupRef.current;
72
724
  if (!anchor || !popup) return;
73
725
  const anchorRect = anchor.getBoundingClientRect();
74
- const popupRect = popup.getBoundingClientRect();
726
+ const popupRect = { width: popup.offsetWidth, height: popup.offsetHeight };
75
727
  const viewportWidth = document.documentElement.clientWidth;
76
728
  const viewportHeight = document.documentElement.clientHeight;
77
729
  let resolvedPlacement = placement;
@@ -113,18 +765,28 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
113
765
  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);
114
766
  };
115
767
  update();
116
- window.addEventListener("resize", update);
117
- window.addEventListener("scroll", update, true);
118
- const observer = new ResizeObserver(update);
768
+ let frame = 0;
769
+ const schedule = () => {
770
+ if (!frame) frame = requestAnimationFrame(() => {
771
+ frame = 0;
772
+ update();
773
+ });
774
+ };
775
+ window.addEventListener("resize", schedule);
776
+ window.addEventListener("scroll", schedule, true);
777
+ window.addEventListener("sia-overlay-motion-end", schedule);
778
+ const observer = new ResizeObserver(schedule);
119
779
  if (anchorRef.current) observer.observe(anchorRef.current);
120
780
  if (popupRef.current) observer.observe(popupRef.current);
121
781
  return () => {
122
- window.removeEventListener("resize", update);
123
- window.removeEventListener("scroll", update, true);
782
+ window.removeEventListener("resize", schedule);
783
+ window.removeEventListener("scroll", schedule, true);
784
+ window.removeEventListener("sia-overlay-motion-end", schedule);
785
+ cancelAnimationFrame(frame);
124
786
  observer.disconnect();
125
787
  };
126
- }, [anchorRef, offset, open, placement, viewportPadding]);
127
- if (!open || typeof document === "undefined") return null;
788
+ }, [anchorRef, offset, motion.present, placement, viewportPadding]);
789
+ if (!motion.present || typeof document === "undefined") return null;
128
790
  return (0, import_react_dom.createPortal)(
129
791
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
130
792
  "div",
@@ -136,13 +798,19 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
136
798
  className: `sia-popup-portal ${className}`.trim(),
137
799
  "data-sia-popup-layer": "",
138
800
  "data-placement": position?.placement ?? placement,
801
+ "data-state": motion.closing ? "closing" : "open",
802
+ "aria-hidden": motion.closing || void 0,
139
803
  style: {
140
804
  ...style,
141
805
  "--sia-popup-anchor-width": `${position?.anchorWidth ?? anchorRef.current?.getBoundingClientRect().width ?? 0}px`,
142
806
  "--sia-popup-available-height": position ? `${position.availableHeight}px` : void 0,
143
807
  top: position?.top ?? 0,
144
808
  left: position?.left ?? 0,
145
- visibility: position ? "visible" : "hidden"
809
+ visibility: position ? "visible" : "hidden",
810
+ animation: "none",
811
+ pointerEvents: motion.closing ? "none" : style?.pointerEvents,
812
+ // 以靠近触发器的边缘中心为缩放原点,业务显式原点优先。
813
+ 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")
146
814
  },
147
815
  ...withTitleTooltip(props),
148
816
  children
@@ -154,7 +822,7 @@ var PopupPortal = (0, import_react.forwardRef)(function PopupPortal2({
154
822
 
155
823
  // src/components/titleTooltip.tsx
156
824
  var import_jsx_runtime2 = require("react/jsx-runtime");
157
- var documents = /* @__PURE__ */ new WeakSet();
825
+ var installedKey = /* @__PURE__ */ Symbol.for("sia.ui.titleTooltip.installed");
158
826
  function withTitleTooltip(props) {
159
827
  if (!props || typeof props !== "object" || !("title" in props)) return props;
160
828
  const { title, ...rest } = props;
@@ -162,8 +830,9 @@ function withTitleTooltip(props) {
162
830
  return { ...rest, "data-sia-title": title == null ? void 0 : String(title) };
163
831
  }
164
832
  function installTitleTooltips(doc) {
165
- if (documents.has(doc)) return;
166
- documents.add(doc);
833
+ const owner = doc;
834
+ if (owner[installedKey]) return;
835
+ owner[installedKey] = true;
167
836
  let hovered = null;
168
837
  let focused = null;
169
838
  let keyboardFocus = true;
@@ -197,8 +866,23 @@ function installTitleTooltips(doc) {
197
866
  if (ids.length) active.setAttribute("aria-describedby", ids.join(" "));
198
867
  else active.removeAttribute("aria-describedby");
199
868
  }
869
+ const closing = active;
200
870
  active = null;
201
- root?.render(null);
871
+ if (closing && root) root.render(/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
872
+ PopupPortal,
873
+ {
874
+ anchorRef: { current: closing },
875
+ open: false,
876
+ placement: "top-start",
877
+ id: tooltipId,
878
+ role: "tooltip",
879
+ className: "sia-title-tooltip",
880
+ afterOpenChange: (opened) => {
881
+ if (!opened && !active) root?.render(null);
882
+ },
883
+ children: closing.getAttribute("data-sia-title")
884
+ }
885
+ ));
202
886
  };
203
887
  const render = () => {
204
888
  const text = active?.getAttribute("data-sia-title");
@@ -296,11 +980,11 @@ function installTitleTooltips(doc) {
296
980
  }
297
981
 
298
982
  // src/components/shared.ts
299
- var import_react2 = require("react");
300
- var ControlSizeContext = (0, import_react2.createContext)("medium");
301
- var PlaceholderModeContext = (0, import_react2.createContext)("default");
983
+ var import_react5 = require("react");
984
+ var ControlSizeContext = (0, import_react5.createContext)("medium");
985
+ var PlaceholderModeContext = (0, import_react5.createContext)("default");
302
986
  function usePlaceholderMode(mode) {
303
- const inherited = (0, import_react2.useContext)(PlaceholderModeContext);
987
+ const inherited = (0, import_react5.useContext)(PlaceholderModeContext);
304
988
  return mode ?? inherited;
305
989
  }
306
990
 
@@ -316,7 +1000,7 @@ function useFloatingPlaceholder({ mode, placeholder, filled, active = false }) {
316
1000
  }
317
1001
 
318
1002
  // src/components/MarkdownEditor.tsx
319
- var import_react3 = require("react");
1003
+ var import_react6 = require("react");
320
1004
  var import_dist = require("vditor/dist/index.css");
321
1005
 
322
1006
  // src/components/markdownPaste.ts
@@ -543,21 +1227,21 @@ function MarkdownEditor({
543
1227
  style,
544
1228
  ...props
545
1229
  }) {
546
- const mountRef = (0, import_react3.useRef)(null);
547
- const editorRef = (0, import_react3.useRef)(null);
548
- const onChangeRef = (0, import_react3.useRef)(onChange);
549
- const saveShortcutRef = (0, import_react3.useRef)(saveShortcut);
550
- const uploadImageRef = (0, import_react3.useRef)(onUploadImage);
551
- const disabledRef = (0, import_react3.useRef)(disabled);
552
- const smartMarkdownPasteRef = (0, import_react3.useRef)(smartMarkdownPaste);
553
- const valueRef = (0, import_react3.useRef)(value ?? defaultValue);
554
- const lastEmittedValueRef = (0, import_react3.useRef)(value ?? defaultValue);
555
- const [hasContent, setHasContent] = (0, import_react3.useState)(Boolean((value ?? defaultValue).trim()));
1230
+ const mountRef = (0, import_react6.useRef)(null);
1231
+ const editorRef = (0, import_react6.useRef)(null);
1232
+ const onChangeRef = (0, import_react6.useRef)(onChange);
1233
+ const saveShortcutRef = (0, import_react6.useRef)(saveShortcut);
1234
+ const uploadImageRef = (0, import_react6.useRef)(onUploadImage);
1235
+ const disabledRef = (0, import_react6.useRef)(disabled);
1236
+ const smartMarkdownPasteRef = (0, import_react6.useRef)(smartMarkdownPaste);
1237
+ const valueRef = (0, import_react6.useRef)(value ?? defaultValue);
1238
+ const lastEmittedValueRef = (0, import_react6.useRef)(value ?? defaultValue);
1239
+ const [hasContent, setHasContent] = (0, import_react6.useState)(Boolean((value ?? defaultValue).trim()));
556
1240
  const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: hasContent });
557
- const [ready, setReady] = (0, import_react3.useState)(false);
558
- const [loadError, setLoadError] = (0, import_react3.useState)("");
1241
+ const [ready, setReady] = (0, import_react6.useState)(false);
1242
+ const [loadError, setLoadError] = (0, import_react6.useState)("");
559
1243
  const hasImageUpload = Boolean(onUploadImage);
560
- (0, import_react3.useEffect)(() => {
1244
+ (0, import_react6.useEffect)(() => {
561
1245
  if (value !== void 0) setHasContent(Boolean(value.trim()));
562
1246
  }, [value]);
563
1247
  onChangeRef.current = onChange;
@@ -566,7 +1250,7 @@ function MarkdownEditor({
566
1250
  disabledRef.current = disabled;
567
1251
  smartMarkdownPasteRef.current = smartMarkdownPaste;
568
1252
  valueRef.current = value ?? valueRef.current;
569
- (0, import_react3.useEffect)(() => {
1253
+ (0, import_react6.useEffect)(() => {
570
1254
  const mount = mountRef.current;
571
1255
  if (!mount) return;
572
1256
  let disposed = false;
@@ -668,14 +1352,14 @@ function MarkdownEditor({
668
1352
  if (editorInitialized) createdEditor?.destroy();
669
1353
  };
670
1354
  }, [ariaLabel, assetBaseUrl, hasImageUpload, minHeight, mode, placeholder, floating.enabled]);
671
- (0, import_react3.useEffect)(() => {
1355
+ (0, import_react6.useEffect)(() => {
672
1356
  const editor = editorRef.current;
673
1357
  if (!editor || value === void 0) return;
674
1358
  if (value === lastEmittedValueRef.current || editor.getValue() === value) return;
675
1359
  lastEmittedValueRef.current = value;
676
1360
  editor.setValue(value, true);
677
1361
  }, [ready, value]);
678
- (0, import_react3.useEffect)(() => {
1362
+ (0, import_react6.useEffect)(() => {
679
1363
  const editor = editorRef.current;
680
1364
  if (!editor) return;
681
1365
  if (disabled) editor.disabled();
@@ -705,6 +1389,9 @@ function MarkdownEditor({
705
1389
  }
706
1390
  );
707
1391
  }
1392
+
1393
+ // src/markdown-editor.ts
1394
+ initializeDefaultScrollbars();
708
1395
  // Annotate the CommonJS export names for ESM import in node:
709
1396
  0 && (module.exports = {
710
1397
  MarkdownEditor