UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

31 lines (30 loc) 990 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TopPanePortal = 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); const y = base.y - dest.height; if (x < gap) x = gap; else if (x + dest.width + gap > window.innerWidth) x = window.innerWidth - dest.width - gap; return [x, y]; }; const span = { className: spanClass }; const entangledProps = { position, span, }; const TopPanePortal = ({ children }) => { return React.createElement(EntangledPortal_1.EntangledPortal, { ...entangledProps }, children); }; exports.TopPanePortal = TopPanePortal;