UNPKG

@yandex/ui

Version:

Yandex UI components

27 lines (26 loc) 1.22 kB
import React, { ComponentType, RefObject, Ref } from 'react'; export interface IWrappedComponentProps { /** * Видимость компонента. */ visible?: boolean; /** * Ссылка на DOM элемент, в рамках которого не нужно отслеживать клик. */ targetRef?: Ref<HTMLElement>; } export interface IWithOutsideClickProps extends IWrappedComponentProps { /** * Обработчик вызывающийся после того, как произошло нажатие на escape. */ onEscapeKeyDown?: (event: KeyboardEvent) => void; /** * Обработчик вызывающийся после того, как произошел клик вне компонента. */ onOutsideClick?: (event: MouseEvent) => void; /** * Ссылки на DOM элементы, в рамках которых не нужно отслеживать клик. */ ignoreRefs?: RefObject<HTMLElement>[]; } export declare const withOutsideClick: <TProps extends IWrappedComponentProps>(WrappedComponent: React.ComponentType<TProps>) => React.ComponentType<TProps & IWithOutsideClickProps>;