@base-ui/react
Version:
Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.
29 lines (28 loc) • 860 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hide = void 0;
const hide = exports.hide = {
name: 'hide',
async fn(state) {
const {
width,
height,
x,
y
} = state.rects.reference;
const anchorHidden = width === 0 && height === 0 && x === 0 && y === 0;
// Mirrors Floating UI's `hide()` referenceHidden strategy. Floating UI injects
// `detectOverflow` into the middleware platform before invoking middleware.
const overflow = await state.platform.detectOverflow(state, {
elementContext: 'reference'
});
const referenceHidden = overflow.top - height >= 0 || overflow.right - width >= 0 || overflow.bottom - height >= 0 || overflow.left - width >= 0;
return {
data: {
referenceHidden: referenceHidden || anchorHidden
}
};
}
};