UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

18 lines (17 loc) 804 B
import * as React from 'react'; import { ExpandableToolbar } from './ExpandableToolbar'; export const AutoExpandableToolbar = ({ menu, disabled, onPopupClose, ...rest }) => { const expandPoint = React.useRef({ x: 32, y: 32, dx: 1, dy: 1 }); return (React.createElement("div", { ref: (el) => { if (!el) return; const rect = el.getBoundingClientRect(); if (!rect) return; expandPoint.current.dx = 1; expandPoint.current.dy = 1; expandPoint.current.x = rect.x - 100; expandPoint.current.y = rect.y - 48; } }, React.createElement(ExpandableToolbar, { ...rest, menu: menu, expandPoint: () => expandPoint.current, disabled: disabled, onPopupClose: onPopupClose }))); };