import { useMemo , useRef } from 'react' ; import { isBoolean , MakeOptional , uniqueId } from '@remirror/core' ; import { CallbackPositioner , defaultAbsolutePosition , Positioner , PositionerParam , StringPositioner , } from '@remirror/extension-positioner' ; import { useMultiPositioner , UseMultiPositionerReturn } from './use-multi-positioner' ; export interface UsePositionerReturn extends MakeOptional < UseMultiPositionerReturn , 'ref' > { /**
     * When `true`, the position is active and the positioner will be displayed.
     */ active : boolean ; } param isActive remarks param positioner param activeOrDeps export function usePositioner ( positioner , isActive ? ) ; export function usePositioner ( positioner , deps ) ; export function usePositioner ( positioner , activeOrDeps ? ) { const deps = activeOrDeps == null || isBoolean ( activeOrDeps ) ? [ positioner ] : activeOrDeps ; const isActive = isBoolean ( activeOrDeps ) ? activeOrDeps : true ; const key = useRef ( uniqueId ( ) ) ; const positions = useMultiPositioner ( positioner , deps ) ; const position = positions [ 0 ] ; return useMemo ( ( ) => { if ( position && isActive ) { return { ... position , active : true } ; } return { ... defaultAbsolutePosition , active : false , key : key . current } ; } , [ isActive , position ] ) ; }