UNPKG

3.17 kBTypeScriptView Raw
1/**
2 * @internal
3 */
4export interface IEventRecord {
5 target: any;
6 eventName: string;
7 parent: any;
8 callback: (args?: any) => void;
9 elementCallback?: (...args: any[]) => void;
10 objectCallback?: (args?: any) => void;
11 options?: boolean | AddEventListenerOptions;
12}
13/**
14 * @internal
15 */
16export interface IEventRecordsByName {
17 [eventName: string]: IEventRecordList;
18}
19/**
20 * @internal
21 */
22export interface IEventRecordList {
23 [id: string]: IEventRecord[] | number;
24 count: number;
25}
26/**
27 * @internal
28 */
29export interface IDeclaredEventsByName {
30 [eventName: string]: boolean;
31}
32/** An instance of EventGroup allows anything with a handle to it to trigger events on it.
33 * If the target is an HTMLElement, the event will be attached to the element and can be
34 * triggered as usual (like clicking for onClick).
35 * The event can be triggered by calling EventGroup.raise() here. If the target is an
36 * HTMLElement, the event gets raised and is handled by the browser. Otherwise, it gets
37 * handled here in EventGroup, and the handler is called in the context of the parent
38 * (which is passed in in the constructor).
39 *
40 * @public
41 * {@docCategory EventGroup}
42 */
43export declare class EventGroup {
44 private static _uniqueId;
45 private _parent;
46 private _eventRecords;
47 private _id;
48 private _isDisposed;
49 /** For IE8, bubbleEvent is ignored here and must be dealt with by the handler.
50 * Events raised here by default have bubbling set to false and cancelable set to true.
51 * This applies also to built-in events being raised manually here on HTMLElements,
52 * which may lead to unexpected behavior if it differs from the defaults.
53 *
54 */
55 static raise(target: any, eventName: string, eventArgs?: any, bubbleEvent?: boolean): boolean | undefined;
56 static isObserved(target: any, eventName: string): boolean;
57 /** Check to see if the target has declared support of the given event. */
58 static isDeclared(target: any, eventName: string): boolean;
59 static stopPropagation(event: any): void;
60 private static _isElement;
61 /** parent: the context in which events attached to non-HTMLElements are called */
62 constructor(parent: any);
63 dispose(): void;
64 /** On the target, attach a set of events, where the events object is a name to function mapping. */
65 onAll(target: any, events: {
66 [key: string]: (args?: any) => void;
67 }, useCapture?: boolean): void;
68 /**
69 * On the target, attach an event whose handler will be called in the context of the parent
70 * of this instance of EventGroup.
71 */
72 on(target: any, eventName: string, callback: (args?: any) => void, options?: boolean | AddEventListenerOptions): void;
73 off(target?: any, eventName?: string, callback?: (args?: any) => void, options?: boolean | AddEventListenerOptions): void;
74 /** Trigger the given event in the context of this instance of EventGroup. */
75 raise(eventName: string, eventArgs?: any, bubbleEvent?: boolean): boolean | undefined;
76 /** Declare an event as being supported by this instance of EventGroup. */
77 declare(event: string | string[]): void;
78}