@wix/design-system
Version:
@wix/design-system
28 lines • 1.65 kB
JavaScript
import React, { forwardRef } from 'react';
import { FloatingPortal, FloatingFocusManager, FloatingOverlay, } from '@floating-ui/react';
import { mergeRefs } from '../../../utils/mergeRefs';
import { usePopoverNextContext } from '../../hooks/usePopoverNextContext';
import { st, classes } from './Content.st.css.js';
import { APPEND_TO } from '../../PopoverNext.constants';
const Content = forwardRef(function Content({ style, ...props }, propRef) {
const { dataHook, focusManagerEnabled, context, appendTo, portalRoot, zIndex, popoverStyles, interactions, open, skin, transitionStyles, overlay, } = usePopoverNextContext();
const ref = mergeRefs(context.refs.setFloating, propRef);
if (!open) {
return null;
}
const content = (React.createElement(FloatingFocusManager, { context: context, disabled: !focusManagerEnabled },
React.createElement(React.Fragment, null,
overlay === true ? React.createElement(FloatingOverlay, null) : (overlay ?? null),
React.createElement("div", { ref: ref, "data-hook": `${dataHook}-content`, className: st(classes.root, { skin }), style: { ...popoverStyles, zIndex, ...transitionStyles, ...style }, ...interactions.getFloatingProps(props) }, props.children))));
if (appendTo === APPEND_TO.window || appendTo === APPEND_TO.viewport) {
return React.createElement(FloatingPortal, null, content);
}
else if (portalRoot) {
return (React.createElement(FloatingPortal, { root: portalRoot, preserveTabOrder: false }, content));
}
else {
return content;
}
});
export default Content;
//# sourceMappingURL=Content.js.map