nuvox 0.1.3 → 0.1.4
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/CHANGELOG.md +42 -0
- package/dist/react/index.cjs +28 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +28 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -80,6 +80,12 @@ function withAccentOverride(color, children) {
|
|
|
80
80
|
import { useLayoutEffect, useRef } from "react";
|
|
81
81
|
import { createPortal } from "react-dom";
|
|
82
82
|
var TRACKED_ATTRIBUTES = ["data-theme", "data-accent"];
|
|
83
|
+
var portalAnchors = /* @__PURE__ */ new WeakMap();
|
|
84
|
+
function getPortalAnchor(portalNode) {
|
|
85
|
+
return portalAnchors.get(portalNode) ?? null;
|
|
86
|
+
}
|
|
87
|
+
var nextNestedStackOffset = 0;
|
|
88
|
+
var NESTED_OVERRIDE_BASE_Z_INDEX = 1150;
|
|
83
89
|
function ThemedPortal({ anchorRef, children, container }) {
|
|
84
90
|
const portalElRef = useRef(null);
|
|
85
91
|
if (!portalElRef.current && typeof document !== "undefined") {
|
|
@@ -91,6 +97,14 @@ function ThemedPortal({ anchorRef, children, container }) {
|
|
|
91
97
|
const portalEl = portalElRef.current;
|
|
92
98
|
if (!portalEl) return;
|
|
93
99
|
target.appendChild(portalEl);
|
|
100
|
+
if (anchorRef.current) {
|
|
101
|
+
portalAnchors.set(portalEl, anchorRef.current);
|
|
102
|
+
const enclosingPortal = anchorRef.current.closest("[data-nuvox-portal]");
|
|
103
|
+
if (enclosingPortal) {
|
|
104
|
+
portalEl.style.position = "relative";
|
|
105
|
+
portalEl.style.zIndex = String(NESTED_OVERRIDE_BASE_Z_INDEX + nextNestedStackOffset++);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
94
108
|
function syncAttribute(attr) {
|
|
95
109
|
const anchor2 = anchorRef.current;
|
|
96
110
|
if (!anchor2 || !portalEl) return;
|
|
@@ -15173,6 +15187,19 @@ function getOpenIntent(key) {
|
|
|
15173
15187
|
|
|
15174
15188
|
// src/theme-engine/useClickOutside.ts
|
|
15175
15189
|
import { useEffect as useEffect5 } from "react";
|
|
15190
|
+
function isNestedWithinRefs(target, refs) {
|
|
15191
|
+
if (!(target instanceof Element)) return false;
|
|
15192
|
+
let current = target;
|
|
15193
|
+
for (let depth = 0; depth < 20; depth++) {
|
|
15194
|
+
const portalNode = current.closest("[data-nuvox-portal]");
|
|
15195
|
+
if (!portalNode) return false;
|
|
15196
|
+
const anchor = getPortalAnchor(portalNode);
|
|
15197
|
+
if (!anchor) return false;
|
|
15198
|
+
if (refs.some((ref) => ref.current?.contains(anchor))) return true;
|
|
15199
|
+
current = anchor;
|
|
15200
|
+
}
|
|
15201
|
+
return false;
|
|
15202
|
+
}
|
|
15176
15203
|
function useClickOutside(isOpen, refs, onOutsideClick) {
|
|
15177
15204
|
useEffect5(() => {
|
|
15178
15205
|
if (!isOpen) return;
|
|
@@ -15180,7 +15207,7 @@ function useClickOutside(isOpen, refs, onOutsideClick) {
|
|
|
15180
15207
|
const target = e.target;
|
|
15181
15208
|
const isInside = refs.some((ref) => ref.current?.contains(target));
|
|
15182
15209
|
if (isInside) return;
|
|
15183
|
-
if (target
|
|
15210
|
+
if (isNestedWithinRefs(target, refs)) return;
|
|
15184
15211
|
onOutsideClick();
|
|
15185
15212
|
}
|
|
15186
15213
|
document.addEventListener("pointerdown", onPointerDown, true);
|