import React from 'react'; import { FocusControl, FocusHint, FocusOpts, FocusSetter } from './focus'; export declare type PopupType = 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog'; export declare type TogglePopup = (expand?: boolean, f?: FocusHint, opt?: FocusOpts) => void; export declare type PositionPopup = (popup: HTMLElement, button: HTMLElement | null) => void; interface PopupOpts { id?: string; popupId?: string; buttonId?: string; onWrapperBlur?: (e: React.FocusEvent, t: TogglePopup) => void; onWrapperKeyDown?: (e: React.KeyboardEvent, t: TogglePopup) => void; onButtonClick?: (e: React.MouseEvent, t: TogglePopup) => void; onButtonKeyDown?: (e: React.KeyboardEvent, t: TogglePopup) => void; initialExpanded?: boolean; /** Called whenever the popup is expanded, can be used to alter the popup styles. */ positionPopup?: PositionPopup; /** Utilized via `useFocusControl`; to disable focus control, pass a noop function. */ focusControl?: FocusControl; /** * If `true`, clicking the button to expand the popup will cause focus to * enter the popup at `focusIndex` 0. Defaults to false, except for "dialog" * popups which default to true. (Note that triggering the button using key * press enter/spacebar will always enter focus, regardless of this setting.) */ focusOnClickExpand?: boolean; } interface UsePopup { expanded: boolean; toggle: TogglePopup; setFocus: FocusSetter; popupProps: React.HTMLAttributes; buttonProps: React.HTMLAttributes; wrapperProps: React.HTMLAttributes; } declare function usePopup(popupType: PopupType, { id, popupId: inputPopupId, buttonId: inputButtonId, onWrapperBlur, onWrapperKeyDown, onButtonClick, onButtonKeyDown, positionPopup, focusControl, initialExpanded, focusOnClickExpand, }?: PopupOpts): UsePopup; export default usePopup;