UNPKG

3.97 kBTypeScriptView Raw
1import { ComponentRef } from '@angular/core';
2import { Observable, Subject } from 'rxjs';
3import * as i0 from "@angular/core";
4export type NbTriggerValues = 'noop' | 'click' | 'hover' | 'hint' | 'focus';
5export declare enum NbTrigger {
6 NOOP = "noop",
7 CLICK = "click",
8 HOVER = "hover",
9 HINT = "hint",
10 FOCUS = "focus"
11}
12/**
13 * Provides entity with two event stream: show and hide.
14 * Each stream provides different events depends on implementation.
15 * We have three main trigger strategies: click, hint and hover.
16 * */
17export interface NbTriggerStrategy {
18 show$: Observable<never | Event>;
19 hide$: Observable<never | Event>;
20 destroy(): any;
21}
22/**
23 * TODO maybe we have to use renderer.listen instead of observableFromEvent?
24 * Renderer provides capability use it in service worker, ssr and so on.
25 * */
26export declare abstract class NbTriggerStrategyBase implements NbTriggerStrategy {
27 protected document: Document;
28 protected host: HTMLElement;
29 protected container: () => ComponentRef<any>;
30 destroy(): void;
31 protected destroyed$: Subject<void>;
32 protected isNotOnHostOrContainer(element: Element): boolean;
33 protected isOnHostOrContainer(element: Element): boolean;
34 protected isOnHost(element: Element): boolean;
35 protected isOnContainer(element: Element): boolean;
36 abstract show$: Observable<Event>;
37 abstract hide$: Observable<Event>;
38 constructor(document: Document, host: HTMLElement, container: () => ComponentRef<any>);
39}
40/**
41 * Creates show and hide event streams.
42 * Fires toggle event when the click was performed on the host element.
43 * Fires close event when the click was performed on the document but
44 * not on the host or container.
45 * */
46export declare class NbClickTriggerStrategy extends NbTriggerStrategyBase {
47 protected click$: Observable<[boolean, Event]>;
48 readonly show$: Observable<Event>;
49 readonly hide$: Observable<Event>;
50}
51/**
52 * Creates show and hide event streams.
53 * Fires open event when a mouse hovers over the host element and stay over at least 100 milliseconds.
54 * Fires close event when the mouse leaves the host element and stops out of the host and popover container.
55 * */
56export declare class NbHoverTriggerStrategy extends NbTriggerStrategyBase {
57 show$: Observable<Event>;
58 hide$: Observable<Event>;
59}
60/**
61 * Creates show and hide event streams.
62 * Fires open event when a mouse hovers over the host element and stay over at least 100 milliseconds.
63 * Fires close event when the mouse leaves the host element.
64 * */
65export declare class NbHintTriggerStrategy extends NbTriggerStrategyBase {
66 show$: Observable<Event>;
67 hide$: Observable<Event>;
68}
69/**
70 * Creates show and hide event streams.
71 * Fires open event when a focus is on the host element and stay over at least 100 milliseconds.
72 * Fires close event when the focus leaves the host element.
73 * */
74export declare class NbFocusTriggerStrategy extends NbTriggerStrategyBase {
75 protected focusOut$: Observable<Event>;
76 protected clickIn$: Observable<Event>;
77 protected clickOut$: Observable<Event>;
78 protected tabKeyPress$: Observable<Event>;
79 show$: Observable<Event>;
80 hide$: Observable<Event>;
81}
82/**
83 * Creates empty show and hide event streams.
84 * */
85export declare class NbNoopTriggerStrategy extends NbTriggerStrategyBase {
86 show$: Observable<Event>;
87 hide$: Observable<Event>;
88}
89export declare class NbTriggerStrategyBuilderService {
90 protected _document: any;
91 protected _host: HTMLElement;
92 protected _container: () => ComponentRef<any>;
93 protected _trigger: NbTrigger;
94 constructor(_document: any);
95 trigger(trigger: NbTrigger): this;
96 host(host: HTMLElement): this;
97 container(container: () => ComponentRef<any>): this;
98 build(): NbTriggerStrategy;
99 static ɵfac: i0.ɵɵFactoryDeclaration<NbTriggerStrategyBuilderService, never>;
100 static ɵprov: i0.ɵɵInjectableDeclaration<NbTriggerStrategyBuilderService>;
101}