stencil-click-outside
Version:
Decorator for StencilJs to run annotated method on click outside of component.
34 lines (33 loc) • 1.17 kB
TypeScript
import { ComponentInterface } from '@stencil/core';
declare type ClickOutsideDecorator = (target: ComponentInterface, propertyKey: string) => void;
declare interface ClickOutsideOptions {
triggerEvents?: string;
exclude?: string;
}
/**
* Call this function as soon as the click outside of annotated method's host is done.
* @example
```
@ClickOutside()
callback() {
// this will run when click outside of element (host component) is done.
}
```
*/
export declare function ClickOutside(opt?: ClickOutsideOptions): ClickOutsideDecorator;
/**
* Register callback function for HTMLElement to be executed when user clicks outside of element.
* @example
```
<span
ref={spanEl => registerClickOutside(this, spanEl, () => this.test())}>
Hello, World!
</span>;
```
*/
export declare function registerClickOutside(component: ComponentInterface, element: HTMLElement, callback: () => void, opt?: ClickOutsideOptions): void;
/**
* Remove click outside callback function for HTMLElement.
*/
export declare function removeClickOutside(component: ComponentInterface, element: HTMLElement, callback: () => void, opt?: ClickOutsideOptions): void;
export {};