// @flow import React from 'react' import ReactDOM from 'react-dom' import { Popper, Manager as PopperManager, PopperProps, Reference as PopperReference, } from 'react-popper' import { buildCss } from '../utilities/props' import { Card } from '../' type PbPopoverProps = { className?: String, offset?: Boolean, reference: PopperReference, show?: Boolean, } & PopperProps const POPOVER_OFFSET_Y = { offset: { offset: '0, 8', }, } const popoverModifiers = ({ modifiers, offset }) => { return offset ? { ...modifiers, ...POPOVER_OFFSET_Y } : modifiers } const Popover = ({ children, className, modifiers, offset, placement, referenceElement, show, }: PbPopoverProps) => ( {({ placement, ref, scheduleUpdate, style }) => { scheduleUpdate() return (
{ children }
) } }
) const PbReactPopover = ({ className, children, modifiers = {}, offset = false, placement = 'left', portal = 'body', reference, referenceElement, show = false, usePortal = false, }: PbPopoverProps) => { const popoverComponent = ( {children} ) return ( {({ ref }) => ( )} {ReactDOM.createPortal( popoverComponent, document.querySelector(portal) )} {popoverComponent} ) } export default PbReactPopover