UNPKG

@procore/core-react

Version:
45 lines 1.61 kB
import React from 'react'; import { Portal } from '../Portal/Portal'; import { Anchor } from '../_hooks/Anchor'; /** * @deprecatedSince 11 * @deprecated Intended for internal library development. */ export var Overlay = /*#__PURE__*/React.forwardRef(function Overlay(_ref, overlayRef) { var _ref$canFlip = _ref.canFlip, canFlip = _ref$canFlip === void 0 ? true : _ref$canFlip, children = _ref.children, _ref$padding = _ref.padding, padding = _ref$padding === void 0 ? 2 : _ref$padding, _ref$placement = _ref.placement, placement = _ref$placement === void 0 ? 'bottom' : _ref$placement, _ref$shrinkOverlay = _ref.shrinkOverlay, shrinkOverlay = _ref$shrinkOverlay === void 0 ? false : _ref$shrinkOverlay, targetRef = _ref.targetRef, container = _ref.container, isFlyout = _ref.isFlyout; var ref = // eslint-disable-next-line react-hooks/rules-of-hooks overlayRef || React.useRef(null); return /*#__PURE__*/React.createElement(Portal, { container: container }, /*#__PURE__*/React.createElement(Anchor, { canFlip: canFlip, dependencies: [children], onLayout: function onLayout(anchor) { if (!ref.current) { return; } var left = Math.floor(anchor.left); var top = Math.floor(anchor.top); ref.current.style.transform = "translateZ(0) translate(".concat(left, "px, ").concat(top, "px)"); }, overlayRef: ref, padding: padding, placement: placement, targetRef: targetRef, shrinkOverlay: shrinkOverlay, isFlyout: isFlyout }, children)); }); //# sourceMappingURL=Overlay.js.map