@yakad/ui 1.3.145 → 1.3.146
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.
|
@@ -22,4 +22,4 @@ export interface WithInteractionsProps extends StackProps {
|
|
|
22
22
|
onMouseHoverStart?: (e: MouseEvent) => void;
|
|
23
23
|
onMouseHoverLeave?: (e: MouseEvent) => void;
|
|
24
24
|
}
|
|
25
|
-
export declare const WithInteractions: import("react").ForwardRefExoticComponent<WithInteractionsProps & import("react").RefAttributes<
|
|
25
|
+
export declare const WithInteractions: import("react").ForwardRefExoticComponent<WithInteractionsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -10,5 +10,5 @@ export interface WithOverlayProps extends WithInteractionsProps {
|
|
|
10
10
|
overlay?: AllowedOverlays;
|
|
11
11
|
children?: React.ReactElement;
|
|
12
12
|
}
|
|
13
|
-
export declare
|
|
13
|
+
export declare const WithOverlay: import("react").ForwardRefExoticComponent<WithOverlayProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
14
|
export {};
|
|
@@ -11,13 +11,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { useState, cloneElement, useEffect, useRef } from "react";
|
|
15
|
-
import { WithInteractions, } from "..";
|
|
14
|
+
import { useState, cloneElement, useEffect, useRef, forwardRef, useImperativeHandle, } from "react";
|
|
16
15
|
import { createPortal } from "react-dom";
|
|
17
|
-
|
|
16
|
+
import { WithInteractions, } from "..";
|
|
17
|
+
export const WithOverlay = forwardRef(function WithOverlay(_a, forwardedRef) {
|
|
18
18
|
var { trigger = "onClick", overlay, children, onRightClick, onClick } = _a, restProps = __rest(_a, ["trigger", "overlay", "children", "onRightClick", "onClick"]);
|
|
19
19
|
// Get Triggers ref and send to Overlay
|
|
20
20
|
const triggerRef = useRef(null);
|
|
21
|
+
// Let the parent access our DOM node
|
|
22
|
+
useImperativeHandle(forwardedRef, () => triggerRef.current);
|
|
21
23
|
const [showOverlay, setShowOverlay] = useState(false);
|
|
22
24
|
// Disable Body Scroll on showOverlay
|
|
23
25
|
useEffect(() => {
|
|
@@ -35,7 +37,8 @@ export function WithOverlay(_a) {
|
|
|
35
37
|
(_b = (_a = overlay.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
36
38
|
setShowOverlay(false);
|
|
37
39
|
},
|
|
38
|
-
}), document.getElementsByClassName("portalRoot")[0] ||
|
|
40
|
+
}), document.getElementsByClassName("portalRoot")[0] ||
|
|
41
|
+
document.body);
|
|
39
42
|
return (_jsxs(_Fragment, { children: [_jsx(WithInteractions, Object.assign({ ref: triggerRef }, restProps, { onRightClick: (e) => {
|
|
40
43
|
trigger === "onRightClick" && setShowOverlay(true);
|
|
41
44
|
onRightClick === null || onRightClick === void 0 ? void 0 : onRightClick(e);
|
|
@@ -43,4 +46,4 @@ export function WithOverlay(_a) {
|
|
|
43
46
|
trigger === "onClick" && setShowOverlay(true);
|
|
44
47
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
45
48
|
}, children: children })), showOverlay && teleport] }));
|
|
46
|
-
}
|
|
49
|
+
});
|