UNPKG

@veracity/vui

Version:

Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.

53 lines (51 loc) 1.79 kB
import { mergeRefs } from "../utils/react.js"; import { cs } from "../utils/styles.js"; import zIndices_default from "../theme/foundations/zIndices.js"; import { useStyleConfig } from "../core/theme.js"; import vui from "../core/vui.js"; import { Box } from "../box/box.js"; import { usePopoverContext } from "./context.js"; import { jsx } from "react/jsx-runtime"; import { FloatingFocusManager, FloatingPortal } from "@floating-ui/react"; //#region src/popover/popoverContent.tsx /** Displays provided content in an overlaying wrapper. */ const PopoverContent = vui((props, ref) => { const { children, className, ...rest } = props; const popoverProps = usePopoverContext() ?? {}; const { context, floatingStyles, getFloatingProps, isLazy, isMounted, isOpen, setPopper, transitionStyles } = popoverProps; const styles = useStyleConfig("Popover", { ...popoverProps, ...props }); const shouldRenderChildren = isLazy ? isOpen : true; const zIndex = zIndices_default.popover; if (!isMounted) return null; return /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(FloatingFocusManager, { context, initialFocus: -1, modal: false, children: /* @__PURE__ */ jsx(Box, { bg: "white", borderRadius: "md", boxShadow: "2", className: cs("vui-popoverContent", className), overflowY: "auto", ref: mergeRefs(setPopper, ref), ring: 0, style: { ...floatingStyles, ...transitionStyles, zIndex }, ...getFloatingProps?.() ?? {}, ...styles.content, ...rest, children: shouldRenderChildren ? children : null }) }) }); }); PopoverContent.displayName = "PopoverContent"; //#endregion export { PopoverContent, PopoverContent as default }; globalThis.__vuiVersion__ = "5.3.1" //# sourceMappingURL=popoverContent.js.map