UNPKG

@engie-group/fluid-design-system-react

Version:

Fluid Design System React

21 lines (18 loc) 1.45 kB
import { jsx } from 'react/jsx-runtime'; import { FloatingFocusManager, FloatingPortal } from '../../../node_modules/.pnpm/@floating-ui_react@0.27.3_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react/dist/floating-ui.react.js'; import { Root as Slot } from '../../../node_modules/.pnpm/@radix-ui_react-slot@1.2.3_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-slot/dist/index.js'; import React__default from 'react'; import { usePopoverContext } from '../NJPopoverContext.js'; import { usePopoverInteractionContext } from '../NJPopoverInteractionContext.js'; const NJPopoverContent = (props) => { const { isOpen, refs, floatingStyles, context } = usePopoverContext(); const popoverInteractionContext = usePopoverInteractionContext(); const getFloatingProps = popoverInteractionContext?.getFloatingProps; const { children, inline } = props; const Component = React__default.isValidElement(children) ? Slot : 'div'; const baseContent = (jsx(Component, { ref: refs.setFloating, style: floatingStyles, ...getFloatingProps?.(), children: children })); const content = props.focusManagerProps ? (jsx(FloatingFocusManager, { context: context, ...props.focusManagerProps, children: baseContent })) : (baseContent); const Parent = inline ? React__default.Fragment : FloatingPortal; return isOpen ? jsx(Parent, { children: content }) : undefined; }; export { NJPopoverContent };