@wordpress/components
Version:
UI components for WordPress.
46 lines (37 loc) • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.overlayMiddlewares = overlayMiddlewares;
var _reactDom = require("@floating-ui/react-dom");
/**
* External dependencies
*/
function overlayMiddlewares() {
return [{
name: 'overlay',
fn(_ref) {
let {
rects
} = _ref;
return rects.reference;
}
}, (0, _reactDom.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