@underverse-ui/underverse 2.0.21 → 2.0.23
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/api-reference.json +1 -1
- package/dist/{EmojiPicker-SFPFCRI4.js → EmojiPicker-NV3GQYWI.js} +4 -4
- package/dist/{chunk-PZCD342B.js → chunk-A4GUPKHM.js} +4 -4
- package/dist/{chunk-PZCD342B.js.map → chunk-A4GUPKHM.js.map} +1 -1
- package/dist/{chunk-MSTO23JM.js → chunk-AEMS6WGX.js} +6 -6
- package/dist/{chunk-LQCKCWVZ.js → chunk-F7MX3XXK.js} +3 -3
- package/dist/{chunk-SBDZKVUJ.js → chunk-LRIRY4DG.js} +2 -2
- package/dist/{chunk-RSLY7UU2.js → chunk-O7AAN6W6.js} +233 -123
- package/dist/chunk-O7AAN6W6.js.map +1 -0
- package/dist/{chunk-NJ53GV74.js → chunk-ZQWVWDGS.js} +3 -3
- package/dist/index.cjs +235 -127
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -6
- package/dist/{menu-bar-JXYQ5CH5.js → menu-bar-E7MNW6UC.js} +4 -4
- package/dist/ueditor.cjs +234 -126
- package/dist/ueditor.cjs.map +1 -1
- package/dist/ueditor.js +4 -4
- package/package.json +3 -1
- package/dist/chunk-RSLY7UU2.js.map +0 -1
- /package/dist/{EmojiPicker-SFPFCRI4.js.map → EmojiPicker-NV3GQYWI.js.map} +0 -0
- /package/dist/{chunk-MSTO23JM.js.map → chunk-AEMS6WGX.js.map} +0 -0
- /package/dist/{chunk-LQCKCWVZ.js.map → chunk-F7MX3XXK.js.map} +0 -0
- /package/dist/{chunk-SBDZKVUJ.js.map → chunk-LRIRY4DG.js.map} +0 -0
- /package/dist/{chunk-NJ53GV74.js.map → chunk-ZQWVWDGS.js.map} +0 -0
- /package/dist/{menu-bar-JXYQ5CH5.js.map → menu-bar-E7MNW6UC.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -4,19 +4,19 @@ import {
|
|
|
4
4
|
extractImageSrcsFromHtml,
|
|
5
5
|
normalizeImageUrl,
|
|
6
6
|
prepareUEditorContentForSave
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-AEMS6WGX.js";
|
|
8
8
|
import {
|
|
9
9
|
EmojiPicker_default
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-F7MX3XXK.js";
|
|
11
11
|
import {
|
|
12
12
|
getEmojiImageUrl,
|
|
13
13
|
getEmojiUnifiedCode,
|
|
14
14
|
setEmojiBaseUrl
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-LRIRY4DG.js";
|
|
16
16
|
import "./chunk-4TYW5K4J.js";
|
|
17
17
|
import {
|
|
18
18
|
Modal_default
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-ZQWVWDGS.js";
|
|
20
20
|
import {
|
|
21
21
|
DropdownMenuItem,
|
|
22
22
|
DropdownMenuSeparator,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
shadcnAnimationStyles,
|
|
32
32
|
useShadCNAnimations,
|
|
33
33
|
useUnderverseUIConfig
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-O7AAN6W6.js";
|
|
35
35
|
import {
|
|
36
36
|
ForceInternalTranslationsProvider,
|
|
37
37
|
NextIntlAdapter,
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
useUnderverseLocale,
|
|
58
58
|
useUnderverseTranslations,
|
|
59
59
|
vi_default
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-A4GUPKHM.js";
|
|
61
61
|
import {
|
|
62
62
|
__export,
|
|
63
63
|
__require
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
Modal_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZQWVWDGS.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_TABLE_ROW_HEIGHT,
|
|
7
7
|
DEFAULT_UEDITOR_IMAGE_MAX_FILE_SIZE,
|
|
@@ -21,11 +21,11 @@ import {
|
|
|
21
21
|
sanitizeUEditorUrl,
|
|
22
22
|
useDropdownMenuClose,
|
|
23
23
|
useSharedEditorUiRenderState
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-O7AAN6W6.js";
|
|
25
25
|
import {
|
|
26
26
|
cn,
|
|
27
27
|
useSmartTranslations
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-A4GUPKHM.js";
|
|
29
29
|
import "./chunk-NSBPE2FW.js";
|
|
30
30
|
|
|
31
31
|
// src/components/UEditor/menu-bar.tsx
|
|
@@ -945,4 +945,4 @@ var MenuBar = ({
|
|
|
945
945
|
export {
|
|
946
946
|
MenuBar
|
|
947
947
|
};
|
|
948
|
-
//# sourceMappingURL=menu-bar-
|
|
948
|
+
//# sourceMappingURL=menu-bar-E7MNW6UC.js.map
|
package/dist/ueditor.cjs
CHANGED
|
@@ -2333,8 +2333,7 @@ function UEditorPortalProvider({
|
|
|
2333
2333
|
function useUEditorPortalContainerGetter() {
|
|
2334
2334
|
return React6.useContext(UEditorPortalContext);
|
|
2335
2335
|
}
|
|
2336
|
-
function resolveUEditorPortalContainer(getPortalContainer, fallbackGetPortalContainer) {
|
|
2337
|
-
if (typeof document === "undefined") return null;
|
|
2336
|
+
function resolveUEditorPortalContainer(getPortalContainer, fallbackGetPortalContainer, fallbackDocument) {
|
|
2338
2337
|
const getters = [getPortalContainer, fallbackGetPortalContainer];
|
|
2339
2338
|
for (const getter of getters) {
|
|
2340
2339
|
if (!getter) continue;
|
|
@@ -2344,7 +2343,8 @@ function resolveUEditorPortalContainer(getPortalContainer, fallbackGetPortalCont
|
|
|
2344
2343
|
} catch {
|
|
2345
2344
|
}
|
|
2346
2345
|
}
|
|
2347
|
-
return
|
|
2346
|
+
if (fallbackDocument) return fallbackDocument.body;
|
|
2347
|
+
return typeof document !== "undefined" ? document.body : null;
|
|
2348
2348
|
}
|
|
2349
2349
|
var React6, import_jsx_runtime6, UEditorPortalContext;
|
|
2350
2350
|
var init_portal_context = __esm({
|
|
@@ -2387,6 +2387,26 @@ function overflowAmount(left, width, viewportWidth, padding) {
|
|
|
2387
2387
|
const overflowRight = Math.max(0, left + width - max);
|
|
2388
2388
|
return overflowLeft + overflowRight;
|
|
2389
2389
|
}
|
|
2390
|
+
function getScrollAncestors(trigger, ownerWindow) {
|
|
2391
|
+
const ancestors = [];
|
|
2392
|
+
let current = trigger.parentElement;
|
|
2393
|
+
while (current) {
|
|
2394
|
+
try {
|
|
2395
|
+
const style = ownerWindow.getComputedStyle(current);
|
|
2396
|
+
const overflow = `${style.overflow} ${style.overflowX} ${style.overflowY}`;
|
|
2397
|
+
if (/(auto|scroll|overlay|hidden)/.test(overflow)) ancestors.push(current);
|
|
2398
|
+
} catch {
|
|
2399
|
+
}
|
|
2400
|
+
current = current.parentElement;
|
|
2401
|
+
}
|
|
2402
|
+
return ancestors;
|
|
2403
|
+
}
|
|
2404
|
+
function isFiniteRect(rect) {
|
|
2405
|
+
return [rect.top, rect.right, rect.bottom, rect.left, rect.width, rect.height].every(Number.isFinite);
|
|
2406
|
+
}
|
|
2407
|
+
function isFullyOutsideViewport(rect, viewportWidth, viewportHeight) {
|
|
2408
|
+
return rect.bottom < 0 || rect.right < 0 || rect.top > viewportHeight || rect.left > viewportWidth;
|
|
2409
|
+
}
|
|
2390
2410
|
function computePopoverPosition(args) {
|
|
2391
2411
|
const { triggerRect, contentSize, placement, offset, padding, viewport, constrainToAvailableHeight } = args;
|
|
2392
2412
|
let { side, align } = normalizePlacement(placement);
|
|
@@ -2484,17 +2504,19 @@ var init_Popover = __esm({
|
|
|
2484
2504
|
const isControlled = open !== void 0;
|
|
2485
2505
|
const [internalOpen, setInternalOpen] = React7.useState(false);
|
|
2486
2506
|
const triggerRef = React7.useRef(null);
|
|
2507
|
+
const [triggerDocument, setTriggerDocument] = React7.useState(null);
|
|
2487
2508
|
const positionerRef = React7.useRef(null);
|
|
2488
2509
|
const panelRef = React7.useRef(null);
|
|
2510
|
+
const pendingFrameRef = React7.useRef(null);
|
|
2511
|
+
const closeRequestedRef = React7.useRef(false);
|
|
2489
2512
|
const lastAppliedRef = React7.useRef(null);
|
|
2490
2513
|
const globalConfig = useUnderverseUIConfig();
|
|
2491
2514
|
const resolvedBorderMode = borderMode ?? globalConfig.popover?.borderMode ?? globalConfig.borderMode;
|
|
2492
2515
|
const isOpen = isControlled ? open : internalOpen;
|
|
2493
2516
|
const contextGetPortalContainer = useUEditorPortalContainerGetter();
|
|
2494
|
-
const
|
|
2495
|
-
const
|
|
2496
|
-
|
|
2497
|
-
useShadCNAnimations(portalDocument);
|
|
2517
|
+
const requestedPortalContainer = isOpen && triggerDocument ? resolveUEditorPortalContainer(getPortalContainer, contextGetPortalContainer, triggerDocument) : null;
|
|
2518
|
+
const portalContainer = requestedPortalContainer?.ownerDocument === triggerDocument ? requestedPortalContainer : triggerDocument?.body ?? null;
|
|
2519
|
+
useShadCNAnimations(isOpen ? triggerDocument : null);
|
|
2498
2520
|
const setIsOpen = React7.useCallback(
|
|
2499
2521
|
(next) => {
|
|
2500
2522
|
if (!isControlled) setInternalOpen(next);
|
|
@@ -2505,126 +2527,205 @@ var init_Popover = __esm({
|
|
|
2505
2527
|
const offset = 4;
|
|
2506
2528
|
const padding = 8;
|
|
2507
2529
|
const initialPlacement = React7.useMemo(() => normalizePlacement(placement), [placement]);
|
|
2530
|
+
const cancelScheduledPositionUpdate = React7.useCallback(() => {
|
|
2531
|
+
const pending = pendingFrameRef.current;
|
|
2532
|
+
if (!pending) return;
|
|
2533
|
+
pendingFrameRef.current = null;
|
|
2534
|
+
try {
|
|
2535
|
+
pending.ownerWindow.cancelAnimationFrame(pending.frameId);
|
|
2536
|
+
} catch {
|
|
2537
|
+
}
|
|
2538
|
+
}, []);
|
|
2539
|
+
const closeWhenPositioningIsUnsafe = React7.useCallback(() => {
|
|
2540
|
+
const positionerEl = positionerRef.current;
|
|
2541
|
+
if (positionerEl) {
|
|
2542
|
+
positionerEl.style.visibility = "hidden";
|
|
2543
|
+
positionerEl.style.pointerEvents = "none";
|
|
2544
|
+
}
|
|
2545
|
+
if (closeRequestedRef.current) return;
|
|
2546
|
+
closeRequestedRef.current = true;
|
|
2547
|
+
setIsOpen(false);
|
|
2548
|
+
}, [setIsOpen]);
|
|
2508
2549
|
const updatePosition = React7.useCallback(() => {
|
|
2509
2550
|
const triggerEl = triggerRef.current;
|
|
2510
2551
|
const positionerEl = positionerRef.current;
|
|
2511
2552
|
const panelEl = panelRef.current;
|
|
2512
|
-
if (!triggerEl || !positionerEl || !panelEl
|
|
2553
|
+
if (!triggerEl || !positionerEl || !panelEl) return;
|
|
2554
|
+
const ownerDocument = triggerEl.ownerDocument;
|
|
2555
|
+
const ownerWindow = ownerDocument.defaultView;
|
|
2556
|
+
if (!ownerWindow || ownerWindow.closed || !triggerEl.isConnected || !positionerEl.isConnected || positionerEl.ownerDocument !== ownerDocument || panelEl.ownerDocument !== ownerDocument) {
|
|
2557
|
+
closeWhenPositioningIsUnsafe();
|
|
2558
|
+
return;
|
|
2559
|
+
}
|
|
2513
2560
|
const contentEl = panelEl.firstElementChild;
|
|
2514
|
-
if (!contentEl)
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
const widthPx = widthWanted == null ? void 0 : Math.max(0, Math.round(widthWanted));
|
|
2518
|
-
if (widthPx == null) {
|
|
2519
|
-
if (positionerEl.style.width) positionerEl.style.width = "";
|
|
2520
|
-
} else if (positionerEl.style.width !== `${widthPx}px`) {
|
|
2521
|
-
positionerEl.style.width = `${widthPx}px`;
|
|
2561
|
+
if (!contentEl) {
|
|
2562
|
+
closeWhenPositioningIsUnsafe();
|
|
2563
|
+
return;
|
|
2522
2564
|
}
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
width
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2565
|
+
try {
|
|
2566
|
+
const triggerRect = triggerEl.getBoundingClientRect();
|
|
2567
|
+
const viewportWidth = ownerWindow.innerWidth;
|
|
2568
|
+
const viewportHeight = ownerWindow.innerHeight;
|
|
2569
|
+
if (!isFiniteRect(triggerRect) || !Number.isFinite(viewportWidth) || !Number.isFinite(viewportHeight) || viewportWidth <= 0 || viewportHeight <= 0 || isFullyOutsideViewport(triggerRect, viewportWidth, viewportHeight)) {
|
|
2570
|
+
closeWhenPositioningIsUnsafe();
|
|
2571
|
+
return;
|
|
2572
|
+
}
|
|
2573
|
+
const widthWanted = matchTriggerWidth ? triggerRect.width : contentWidth;
|
|
2574
|
+
const widthPx = widthWanted == null ? void 0 : Math.max(0, Math.round(widthWanted));
|
|
2575
|
+
if (widthPx == null) {
|
|
2576
|
+
if (positionerEl.style.width) positionerEl.style.width = "";
|
|
2577
|
+
} else if (positionerEl.style.width !== `${widthPx}px`) {
|
|
2578
|
+
positionerEl.style.width = `${widthPx}px`;
|
|
2579
|
+
}
|
|
2580
|
+
const prevApplied = lastAppliedRef.current;
|
|
2581
|
+
const measuredWidth = positionerEl.offsetWidth;
|
|
2582
|
+
const measuredHeight = positionerEl.offsetHeight;
|
|
2583
|
+
const contentRect = positionerEl.getBoundingClientRect();
|
|
2584
|
+
const contentBoxWidth = measuredWidth || contentRect.width;
|
|
2585
|
+
const contentBoxHeight = Math.max(measuredHeight, contentRect.height);
|
|
2586
|
+
const next = computePopoverPosition({
|
|
2587
|
+
triggerRect,
|
|
2588
|
+
contentSize: { width: contentBoxWidth, height: contentBoxHeight },
|
|
2589
|
+
placement,
|
|
2590
|
+
offset,
|
|
2591
|
+
padding,
|
|
2592
|
+
viewport: {
|
|
2593
|
+
width: viewportWidth,
|
|
2594
|
+
height: viewportHeight
|
|
2595
|
+
},
|
|
2596
|
+
constrainToAvailableHeight
|
|
2597
|
+
});
|
|
2598
|
+
const top = Math.round(next.top);
|
|
2599
|
+
const left = Math.round(next.left);
|
|
2600
|
+
const applied = prevApplied && prevApplied.positioner === positionerEl && Math.abs(prevApplied.top - top) < 0.5 && Math.abs(prevApplied.left - left) < 0.5 && prevApplied.side === next.side && prevApplied.align === next.align && prevApplied.width === widthPx && prevApplied.availableHeight === next.availableHeight;
|
|
2601
|
+
if (applied) return;
|
|
2602
|
+
lastAppliedRef.current = {
|
|
2603
|
+
positioner: positionerEl,
|
|
2604
|
+
top,
|
|
2605
|
+
left,
|
|
2606
|
+
side: next.side,
|
|
2607
|
+
align: next.align,
|
|
2608
|
+
width: widthPx,
|
|
2609
|
+
availableHeight: next.availableHeight
|
|
2610
|
+
};
|
|
2611
|
+
positionerEl.style.transform = `translate3d(${left}px, ${top}px, 0)`;
|
|
2612
|
+
positionerEl.style.setProperty("--underverse-popover-available-height", `${next.availableHeight}px`);
|
|
2613
|
+
positionerEl.dataset.side = next.side;
|
|
2614
|
+
positionerEl.dataset.align = next.align;
|
|
2615
|
+
panelEl.style.transformOrigin = getTransformOrigin(next.side, next.align);
|
|
2616
|
+
if (positionerEl.style.visibility !== "visible") positionerEl.style.visibility = "visible";
|
|
2617
|
+
if (positionerEl.style.pointerEvents !== "auto") positionerEl.style.pointerEvents = "auto";
|
|
2618
|
+
} catch {
|
|
2619
|
+
closeWhenPositioningIsUnsafe();
|
|
2620
|
+
}
|
|
2621
|
+
}, [placement, matchTriggerWidth, contentWidth, constrainToAvailableHeight, closeWhenPositioningIsUnsafe]);
|
|
2622
|
+
const schedulePositionUpdate = React7.useCallback(() => {
|
|
2623
|
+
if (pendingFrameRef.current) return;
|
|
2624
|
+
const triggerEl = triggerRef.current;
|
|
2625
|
+
const ownerWindow = triggerEl?.ownerDocument.defaultView;
|
|
2626
|
+
if (!triggerEl || !ownerWindow || ownerWindow.closed) {
|
|
2627
|
+
closeWhenPositioningIsUnsafe();
|
|
2628
|
+
return;
|
|
2629
|
+
}
|
|
2630
|
+
try {
|
|
2631
|
+
const frameId = ownerWindow.requestAnimationFrame(() => {
|
|
2632
|
+
pendingFrameRef.current = null;
|
|
2633
|
+
updatePosition();
|
|
2634
|
+
});
|
|
2635
|
+
pendingFrameRef.current = { ownerWindow, frameId };
|
|
2636
|
+
} catch {
|
|
2637
|
+
closeWhenPositioningIsUnsafe();
|
|
2638
|
+
}
|
|
2639
|
+
}, [closeWhenPositioningIsUnsafe, updatePosition]);
|
|
2561
2640
|
React7.useLayoutEffect(() => {
|
|
2562
|
-
if (
|
|
2641
|
+
if (isOpen) {
|
|
2642
|
+
closeRequestedRef.current = false;
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
lastAppliedRef.current = null;
|
|
2646
|
+
cancelScheduledPositionUpdate();
|
|
2647
|
+
}, [cancelScheduledPositionUpdate, isOpen]);
|
|
2648
|
+
React7.useLayoutEffect(() => {
|
|
2649
|
+
if (!isOpen || !portalContainer) return;
|
|
2563
2650
|
updatePosition();
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
updatePosition();
|
|
2568
|
-
raf2 = portalWindow.requestAnimationFrame(() => updatePosition());
|
|
2569
|
-
});
|
|
2570
|
-
return () => {
|
|
2571
|
-
portalWindow.cancelAnimationFrame(raf1);
|
|
2572
|
-
portalWindow.cancelAnimationFrame(raf2);
|
|
2573
|
-
};
|
|
2574
|
-
}, [isOpen, portalWindow, updatePosition]);
|
|
2651
|
+
schedulePositionUpdate();
|
|
2652
|
+
return cancelScheduledPositionUpdate;
|
|
2653
|
+
}, [cancelScheduledPositionUpdate, isOpen, portalContainer, schedulePositionUpdate, updatePosition]);
|
|
2575
2654
|
React7.useEffect(() => {
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2655
|
+
const triggerEl = triggerRef.current;
|
|
2656
|
+
const positionerEl = positionerRef.current;
|
|
2657
|
+
if (!isOpen || !triggerEl || !positionerEl || !portalContainer) return;
|
|
2658
|
+
const ownerDocument = triggerEl.ownerDocument;
|
|
2659
|
+
const ownerWindow = ownerDocument.defaultView;
|
|
2660
|
+
if (!ownerWindow || ownerWindow.closed || portalContainer.ownerDocument !== ownerDocument) {
|
|
2661
|
+
closeWhenPositioningIsUnsafe();
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
const scrollAncestors = getScrollAncestors(triggerEl, ownerWindow);
|
|
2665
|
+
const passiveOptions = { passive: true };
|
|
2666
|
+
for (const ancestor of scrollAncestors) {
|
|
2667
|
+
ancestor.addEventListener("scroll", schedulePositionUpdate, passiveOptions);
|
|
2668
|
+
}
|
|
2669
|
+
ownerWindow.addEventListener("scroll", schedulePositionUpdate, passiveOptions);
|
|
2670
|
+
ownerWindow.addEventListener("resize", schedulePositionUpdate);
|
|
2671
|
+
ownerDocument.addEventListener("scroll", schedulePositionUpdate, { capture: true, passive: true });
|
|
2672
|
+
const visualViewport = ownerWindow.visualViewport;
|
|
2673
|
+
visualViewport?.addEventListener("scroll", schedulePositionUpdate, passiveOptions);
|
|
2674
|
+
visualViewport?.addEventListener("resize", schedulePositionUpdate);
|
|
2675
|
+
const ResizeObserverCtor = ownerWindow.ResizeObserver;
|
|
2676
|
+
const resizeObserver = ResizeObserverCtor ? new ResizeObserverCtor(schedulePositionUpdate) : null;
|
|
2677
|
+
resizeObserver?.observe(triggerEl);
|
|
2678
|
+
resizeObserver?.observe(positionerEl);
|
|
2679
|
+
const contentEl = panelRef.current?.firstElementChild;
|
|
2680
|
+
if (contentEl) resizeObserver?.observe(contentEl);
|
|
2681
|
+
const MutationObserverCtor = ownerWindow.MutationObserver;
|
|
2682
|
+
const mutationObserver = MutationObserverCtor ? new MutationObserverCtor(() => {
|
|
2683
|
+
const currentTrigger = triggerRef.current;
|
|
2684
|
+
if (!currentTrigger || !currentTrigger.isConnected || currentTrigger.ownerDocument !== ownerDocument) {
|
|
2685
|
+
closeWhenPositioningIsUnsafe();
|
|
2686
|
+
}
|
|
2687
|
+
}) : null;
|
|
2688
|
+
if (mutationObserver && ownerDocument.documentElement) {
|
|
2689
|
+
mutationObserver.observe(ownerDocument.documentElement, { childList: true, subtree: true });
|
|
2690
|
+
}
|
|
2691
|
+
schedulePositionUpdate();
|
|
2596
2692
|
return () => {
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2693
|
+
for (const ancestor of scrollAncestors) {
|
|
2694
|
+
ancestor.removeEventListener("scroll", schedulePositionUpdate);
|
|
2695
|
+
}
|
|
2696
|
+
ownerWindow.removeEventListener("scroll", schedulePositionUpdate);
|
|
2697
|
+
ownerWindow.removeEventListener("resize", schedulePositionUpdate);
|
|
2698
|
+
ownerDocument.removeEventListener("scroll", schedulePositionUpdate, true);
|
|
2699
|
+
visualViewport?.removeEventListener("scroll", schedulePositionUpdate);
|
|
2700
|
+
visualViewport?.removeEventListener("resize", schedulePositionUpdate);
|
|
2701
|
+
resizeObserver?.disconnect();
|
|
2702
|
+
mutationObserver?.disconnect();
|
|
2703
|
+
cancelScheduledPositionUpdate();
|
|
2601
2704
|
};
|
|
2602
|
-
}, [
|
|
2705
|
+
}, [
|
|
2706
|
+
cancelScheduledPositionUpdate,
|
|
2707
|
+
closeWhenPositioningIsUnsafe,
|
|
2708
|
+
isOpen,
|
|
2709
|
+
portalContainer,
|
|
2710
|
+
schedulePositionUpdate
|
|
2711
|
+
]);
|
|
2603
2712
|
React7.useEffect(() => {
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
const
|
|
2608
|
-
if (
|
|
2609
|
-
|
|
2610
|
-
return () => ro.disconnect();
|
|
2611
|
-
}, [isOpen, portalWindow, updatePosition]);
|
|
2612
|
-
React7.useLayoutEffect(() => {
|
|
2613
|
-
if (!isOpen) {
|
|
2614
|
-
lastAppliedRef.current = null;
|
|
2713
|
+
const triggerEl = triggerRef.current;
|
|
2714
|
+
if (!isOpen || !triggerEl || !portalContainer) return;
|
|
2715
|
+
const ownerDocument = triggerEl.ownerDocument;
|
|
2716
|
+
const ownerWindow = ownerDocument.defaultView;
|
|
2717
|
+
if (!ownerWindow || portalContainer.ownerDocument !== ownerDocument) {
|
|
2718
|
+
closeWhenPositioningIsUnsafe();
|
|
2615
2719
|
return;
|
|
2616
2720
|
}
|
|
2617
|
-
}, [isOpen]);
|
|
2618
|
-
React7.useEffect(() => {
|
|
2619
|
-
if (!isOpen || !portalDocument || !portalWindow) return;
|
|
2620
2721
|
const handleClickOutside = (event) => {
|
|
2621
2722
|
const target = event.target;
|
|
2622
|
-
const
|
|
2723
|
+
const currentTrigger = triggerRef.current;
|
|
2623
2724
|
const popoverEl = positionerRef.current;
|
|
2624
|
-
if (!
|
|
2625
|
-
if (
|
|
2725
|
+
if (!currentTrigger || !popoverEl) return;
|
|
2726
|
+
if (currentTrigger.contains(target)) return;
|
|
2626
2727
|
if (popoverEl.contains(target)) return;
|
|
2627
|
-
if (target instanceof
|
|
2728
|
+
if (target instanceof ownerWindow.Element && target.closest("[data-popover]")) return;
|
|
2628
2729
|
setIsOpen(false);
|
|
2629
2730
|
};
|
|
2630
2731
|
const handleEscape = (event) => {
|
|
@@ -2632,18 +2733,30 @@ var init_Popover = __esm({
|
|
|
2632
2733
|
setIsOpen(false);
|
|
2633
2734
|
}
|
|
2634
2735
|
};
|
|
2635
|
-
|
|
2636
|
-
|
|
2736
|
+
ownerDocument.addEventListener("mousedown", handleClickOutside);
|
|
2737
|
+
ownerDocument.addEventListener("keydown", handleEscape);
|
|
2637
2738
|
return () => {
|
|
2638
|
-
|
|
2639
|
-
|
|
2739
|
+
ownerDocument.removeEventListener("mousedown", handleClickOutside);
|
|
2740
|
+
ownerDocument.removeEventListener("keydown", handleEscape);
|
|
2640
2741
|
};
|
|
2641
|
-
}, [
|
|
2742
|
+
}, [closeWhenPositioningIsUnsafe, isOpen, portalContainer, setIsOpen]);
|
|
2642
2743
|
const handleTriggerClick = () => {
|
|
2643
2744
|
if (!disabled) {
|
|
2644
2745
|
setIsOpen(!isOpen);
|
|
2645
2746
|
}
|
|
2646
2747
|
};
|
|
2748
|
+
const triggerProps = trigger.props;
|
|
2749
|
+
const childRef = triggerProps.ref;
|
|
2750
|
+
const setTriggerNode = React7.useCallback((node) => {
|
|
2751
|
+
triggerRef.current = node;
|
|
2752
|
+
if (node) {
|
|
2753
|
+
setTriggerDocument((currentDocument) => currentDocument === node.ownerDocument ? currentDocument : node.ownerDocument);
|
|
2754
|
+
}
|
|
2755
|
+
}, []);
|
|
2756
|
+
const composedTriggerRef = React7.useMemo(
|
|
2757
|
+
() => mergeRefs(childRef, setTriggerNode),
|
|
2758
|
+
[childRef, setTriggerNode]
|
|
2759
|
+
);
|
|
2647
2760
|
const popoverContent = isOpen && portalContainer ? (0, import_react_dom.createPortal)(
|
|
2648
2761
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2649
2762
|
"div",
|
|
@@ -2699,13 +2812,9 @@ var init_Popover = __esm({
|
|
|
2699
2812
|
) : null;
|
|
2700
2813
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
2701
2814
|
(() => {
|
|
2702
|
-
const triggerProps = trigger.props;
|
|
2703
|
-
const childRef = triggerProps.ref;
|
|
2704
2815
|
return React7.cloneElement(trigger, {
|
|
2705
2816
|
...triggerProps,
|
|
2706
|
-
ref:
|
|
2707
|
-
triggerRef.current = node;
|
|
2708
|
-
}),
|
|
2817
|
+
ref: composedTriggerRef,
|
|
2709
2818
|
onClick: chainEventHandlers(
|
|
2710
2819
|
(e) => {
|
|
2711
2820
|
triggerRef.current = e.currentTarget;
|
|
@@ -5657,14 +5766,12 @@ var init_DropdownMenu = __esm({
|
|
|
5657
5766
|
"use strict";
|
|
5658
5767
|
"use client";
|
|
5659
5768
|
init_cn();
|
|
5660
|
-
init_animations();
|
|
5661
5769
|
import_react29 = __toESM(require("react"), 1);
|
|
5662
5770
|
init_react_compose();
|
|
5663
5771
|
init_Popover();
|
|
5664
5772
|
import_lucide_react10 = require("lucide-react");
|
|
5665
5773
|
init_radius();
|
|
5666
5774
|
init_UnderverseConfigContext();
|
|
5667
|
-
init_portal_context();
|
|
5668
5775
|
import_jsx_runtime22 = require("react/jsx-runtime");
|
|
5669
5776
|
DropdownMenuContext = import_react29.default.createContext(null);
|
|
5670
5777
|
DropdownMenu = ({
|
|
@@ -5699,7 +5806,6 @@ var init_DropdownMenu = __esm({
|
|
|
5699
5806
|
const [activeIndex, setActiveIndex] = useResettingIndex3(open);
|
|
5700
5807
|
const parentMenu = import_react29.default.useContext(DropdownMenuContext);
|
|
5701
5808
|
const hoverCloseTimeoutRef = import_react29.default.useRef(null);
|
|
5702
|
-
const getPortalContainer = useUEditorPortalContainerGetter();
|
|
5703
5809
|
const cancelHoverClose = import_react29.default.useCallback(() => {
|
|
5704
5810
|
if (hoverCloseTimeoutRef.current === null) return;
|
|
5705
5811
|
clearTimeout(hoverCloseTimeoutRef.current);
|
|
@@ -5732,7 +5838,6 @@ var init_DropdownMenu = __esm({
|
|
|
5732
5838
|
item.focus();
|
|
5733
5839
|
item.scrollIntoView({ block: "nearest" });
|
|
5734
5840
|
}, [getEnabledMenuItems, setActiveIndex]);
|
|
5735
|
-
useShadCNAnimations();
|
|
5736
5841
|
const globalConfig = useUnderverseUIConfig();
|
|
5737
5842
|
const resolvedBorderMode = borderMode ?? globalConfig.dropdownMenu?.borderMode ?? globalConfig.borderMode;
|
|
5738
5843
|
import_react29.default.useEffect(() => {
|
|
@@ -5853,8 +5958,11 @@ var init_DropdownMenu = __esm({
|
|
|
5853
5958
|
triggerRef.current = node;
|
|
5854
5959
|
}, [childRef]);
|
|
5855
5960
|
const handleTriggerKeyDown = import_react29.default.useCallback((event) => {
|
|
5856
|
-
const
|
|
5857
|
-
const scheduleFrame =
|
|
5961
|
+
const triggerWindow = event.currentTarget.ownerDocument.defaultView;
|
|
5962
|
+
const scheduleFrame = (callback) => {
|
|
5963
|
+
if (triggerWindow) triggerWindow.requestAnimationFrame(callback);
|
|
5964
|
+
else callback(0);
|
|
5965
|
+
};
|
|
5858
5966
|
if (!disabled) {
|
|
5859
5967
|
if (event.key === "ArrowDown") {
|
|
5860
5968
|
event.preventDefault();
|
|
@@ -5873,7 +5981,7 @@ var init_DropdownMenu = __esm({
|
|
|
5873
5981
|
}
|
|
5874
5982
|
}
|
|
5875
5983
|
triggerOnKeyDown?.(event);
|
|
5876
|
-
}, [disabled, focusMenuItem, getEnabledMenuItems,
|
|
5984
|
+
}, [disabled, focusMenuItem, getEnabledMenuItems, setOpen, triggerOnKeyDown]);
|
|
5877
5985
|
const handleTriggerClick = import_react29.default.useCallback((event) => {
|
|
5878
5986
|
if (openOnHover && !disabled) {
|
|
5879
5987
|
cancelHoverClose();
|