@adsgency_npm/adsgency-ads-ui 0.1.0-alpha.17 → 0.1.0-alpha.19
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/index.cjs +41 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1862,6 +1862,7 @@ var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
|
1862
1862
|
var NestedDismissableLayerContext = React19.createContext(null);
|
|
1863
1863
|
function useNestedDismissableLayerCoordinator() {
|
|
1864
1864
|
const activeLayersRef = React19.useRef(/* @__PURE__ */ new Map());
|
|
1865
|
+
const pointerInteractionHadNestedLayerRef = React19.useRef(false);
|
|
1865
1866
|
const registerNestedLayer = React19.useCallback(
|
|
1866
1867
|
(id, dismiss) => {
|
|
1867
1868
|
const activeLayers = activeLayersRef.current;
|
|
@@ -1879,17 +1880,48 @@ function useNestedDismissableLayerCoordinator() {
|
|
|
1879
1880
|
() => activeLayersRef.current.size > 0,
|
|
1880
1881
|
[]
|
|
1881
1882
|
);
|
|
1883
|
+
const hadActiveNestedLayerAtPointerDown = React19.useCallback(
|
|
1884
|
+
() => pointerInteractionHadNestedLayerRef.current,
|
|
1885
|
+
[]
|
|
1886
|
+
);
|
|
1882
1887
|
const dismissTopNestedLayer = React19.useCallback(() => {
|
|
1883
1888
|
const activeLayers = [...activeLayersRef.current.values()];
|
|
1884
1889
|
activeLayers.at(-1)?.();
|
|
1885
1890
|
}, []);
|
|
1891
|
+
React19.useEffect(() => {
|
|
1892
|
+
const ownerDocument = globalThis.document;
|
|
1893
|
+
if (!ownerDocument) return;
|
|
1894
|
+
const handlePointerDown = () => {
|
|
1895
|
+
pointerInteractionHadNestedLayerRef.current = activeLayersRef.current.size > 0;
|
|
1896
|
+
};
|
|
1897
|
+
const handlePointerCancel = () => {
|
|
1898
|
+
pointerInteractionHadNestedLayerRef.current = false;
|
|
1899
|
+
};
|
|
1900
|
+
const handleKeyDown = () => {
|
|
1901
|
+
pointerInteractionHadNestedLayerRef.current = false;
|
|
1902
|
+
};
|
|
1903
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown, true);
|
|
1904
|
+
ownerDocument.addEventListener("pointercancel", handlePointerCancel);
|
|
1905
|
+
ownerDocument.addEventListener("keydown", handleKeyDown, true);
|
|
1906
|
+
return () => {
|
|
1907
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown, true);
|
|
1908
|
+
ownerDocument.removeEventListener("pointercancel", handlePointerCancel);
|
|
1909
|
+
ownerDocument.removeEventListener("keydown", handleKeyDown, true);
|
|
1910
|
+
};
|
|
1911
|
+
}, []);
|
|
1886
1912
|
return React19.useMemo(
|
|
1887
1913
|
() => ({
|
|
1888
1914
|
dismissTopNestedLayer,
|
|
1889
1915
|
hasActiveNestedLayer,
|
|
1916
|
+
hadActiveNestedLayerAtPointerDown,
|
|
1890
1917
|
registerNestedLayer
|
|
1891
1918
|
}),
|
|
1892
|
-
[
|
|
1919
|
+
[
|
|
1920
|
+
dismissTopNestedLayer,
|
|
1921
|
+
hadActiveNestedLayerAtPointerDown,
|
|
1922
|
+
hasActiveNestedLayer,
|
|
1923
|
+
registerNestedLayer
|
|
1924
|
+
]
|
|
1893
1925
|
);
|
|
1894
1926
|
}
|
|
1895
1927
|
function NestedDismissableLayerProvider({
|
|
@@ -1927,12 +1959,16 @@ var PopoverContentImpl = React20.forwardRef(
|
|
|
1927
1959
|
(event) => {
|
|
1928
1960
|
onPointerDownOutside?.(event);
|
|
1929
1961
|
if (event.defaultPrevented) return;
|
|
1930
|
-
|
|
1962
|
+
const hasActiveNestedLayer = coordinator.hasActiveNestedLayer();
|
|
1963
|
+
const shouldShieldParent = hasActiveNestedLayer || coordinator.hadActiveNestedLayerAtPointerDown();
|
|
1964
|
+
if (!shouldShieldParent) {
|
|
1931
1965
|
shieldNextFocusOutsideRef.current = false;
|
|
1932
1966
|
return;
|
|
1933
1967
|
}
|
|
1934
1968
|
shieldNextFocusOutsideRef.current = true;
|
|
1935
|
-
|
|
1969
|
+
if (hasActiveNestedLayer) {
|
|
1970
|
+
coordinator.dismissTopNestedLayer();
|
|
1971
|
+
}
|
|
1936
1972
|
event.preventDefault();
|
|
1937
1973
|
},
|
|
1938
1974
|
[coordinator, onPointerDownOutside]
|
|
@@ -1947,7 +1983,8 @@ var PopoverContentImpl = React20.forwardRef(
|
|
|
1947
1983
|
event.preventDefault();
|
|
1948
1984
|
return;
|
|
1949
1985
|
}
|
|
1950
|
-
|
|
1986
|
+
const hasActiveNestedLayer = coordinator.hasActiveNestedLayer();
|
|
1987
|
+
if (!hasActiveNestedLayer) return;
|
|
1951
1988
|
coordinator.dismissTopNestedLayer();
|
|
1952
1989
|
event.preventDefault();
|
|
1953
1990
|
},
|