import { createHook , useForkRef } from '@workday/canvas-kit-react/common' ; import { PopupModel } from './usePopupModel' ; import React from 'react' ; import { Placement } from '../Popper' ; /**
 * Hooks a Popper up to a PopupModel
 */ export const usePopupPopper = createHook ( ( { state , events } , ref ) => { const elementRef = useForkRef ( ref , state . stackRef ) ; const onPlacementChange = React . useCallback ( ( placement ) => { if ( placement !== state . placement ) { events . updatePlacement ( { placement } ) ; } } , [ events , state . placement ] ) ; return { open : state . visibility !== 'hidden' , anchorElement : state . targetRef , ref : elementRef , onPlacementChange , } ; } ) ;