UNPKG

@wordpress/components

Version:
38 lines (32 loc) 923 B
/** * External dependencies */ import { size } from '@floating-ui/react-dom'; export function overlayMiddlewares() { return [{ name: 'overlay', fn(_ref) { let { rects } = _ref; return rects.reference; } }, size({ apply(_ref2) { var _elements$floating; let { rects, elements } = _ref2; const { firstElementChild } = (_elements$floating = elements.floating) !== null && _elements$floating !== void 0 ? _elements$floating : {}; // Only HTMLElement instances have the `style` property. if (!(firstElementChild instanceof HTMLElement)) return; // Reduce the height of the popover to the available space. Object.assign(firstElementChild.style, { width: `${rects.reference.width}px`, height: `${rects.reference.height}px` }); } })]; } //# sourceMappingURL=overlay-middlewares.js.map