UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

37 lines (36 loc) 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BottomPanePortal = void 0; const tslib_1 = require("tslib"); // biome-ignore lint: lint/style/useImportType const React = tslib_1.__importStar(require("react")); const nano_theme_1 = require("nano-theme"); const EntangledPortal_1 = require("../../../../components/EntangledPortal"); const spanClass = (0, nano_theme_1.rule)({ pe: 'none', }); const gap = 4; const position = (base, dest) => { let x = base.x - (dest.width >> 1); let y = base.y; if (x < gap) x = gap; else if (x + dest.width + gap > window.innerWidth) x = window.innerWidth - dest.width - gap; const { scrollY } = window; const body = document.body; const html = document.documentElement; const pageHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight); if (base.y + dest.height + scrollY > pageHeight) y = base.y - (base.y + dest.height + scrollY - pageHeight); return [x, y]; }; const span = { className: spanClass }; const entangledProps = { position, span, }; const BottomPanePortal = ({ children }) => { return React.createElement(EntangledPortal_1.EntangledPortal, { ...entangledProps }, children); }; exports.BottomPanePortal = BottomPanePortal;