UNPKG

@gechiui/compose

Version:
72 lines 2.67 kB
/** * @typedef {import('react').SyntheticEvent} SyntheticEvent */ /** * @callback EventCallback * @param {SyntheticEvent} event input related event. */ /** * @typedef FocusOutsideReactElement * @property {EventCallback} handleFocusOutside callback for a focus outside event. */ /** * @typedef {import('react').MutableRefObject<FocusOutsideReactElement | undefined>} FocusOutsideRef */ /** * @typedef {Object} FocusOutsideReturnValue * @property {EventCallback} onFocus An event handler for focus events. * @property {EventCallback} onBlur An event handler for blur events. * @property {EventCallback} onMouseDown An event handler for mouse down events. * @property {EventCallback} onMouseUp An event handler for mouse up events. * @property {EventCallback} onTouchStart An event handler for touch start events. * @property {EventCallback} onTouchEnd An event handler for touch end events. */ /** * A react hook that can be used to check whether focus has moved outside the * element the event handlers are bound to. * * @param {EventCallback} onFocusOutside A callback triggered when focus moves outside * the element the event handlers are bound to. * * @return {FocusOutsideReturnValue} An object containing event handlers. Bind the event handlers * to a wrapping element element to capture when focus moves * outside that element. */ export default function useFocusOutside(onFocusOutside: EventCallback): FocusOutsideReturnValue; export type FocusNormalizedButton = HTMLButtonElement | HTMLLinkElement | HTMLInputElement; export type SyntheticEvent = import('react').SyntheticEvent; export type EventCallback = (event: SyntheticEvent) => any; export type FocusOutsideReactElement = { /** * callback for a focus outside event. */ handleFocusOutside: EventCallback; }; export type FocusOutsideRef = import('react').MutableRefObject<FocusOutsideReactElement | undefined>; export type FocusOutsideReturnValue = { /** * An event handler for focus events. */ onFocus: EventCallback; /** * An event handler for blur events. */ onBlur: EventCallback; /** * An event handler for mouse down events. */ onMouseDown: EventCallback; /** * An event handler for mouse up events. */ onMouseUp: EventCallback; /** * An event handler for touch start events. */ onTouchStart: EventCallback; /** * An event handler for touch end events. */ onTouchEnd: EventCallback; }; //# sourceMappingURL=index.d.ts.map