1 |
|
2 |
|
3 |
|
4 | import { GridOptionsWrapper } from "./gridOptionsWrapper";
|
5 | import { Column } from "./entities/column";
|
6 | import { RowNode } from "./entities/rowNode";
|
7 | export declare class Timer {
|
8 | private timestamp;
|
9 | print(msg: string): void;
|
10 | }
|
11 | export declare class Utils {
|
12 | private static isSafari;
|
13 | private static isIE;
|
14 | private static isEdge;
|
15 | private static isChrome;
|
16 | private static isFirefox;
|
17 | private static isIPad;
|
18 | private static PRINTABLE_CHARACTERS;
|
19 | private static NUMPAD_DEL_NUMLOCK_ON_KEY;
|
20 | private static NUMPAD_DEL_NUMLOCK_ON_CHARCODE;
|
21 | private static doOnceFlags;
|
22 | static doOnce(func: () => void, key: string): void;
|
23 | static areEventsNear(e1: MouseEvent | Touch, e2: MouseEvent | Touch, pixelCount: number): boolean;
|
24 | static shallowCompare(arr1: any[], arr2: any[]): boolean;
|
25 | static getNameOfClass(TheClass: any): string;
|
26 | static values<T>(object: {
|
27 | [key: string]: T;
|
28 | }): T[];
|
29 | static getValueUsingField(data: any, field: string, fieldContainsDots: boolean): any;
|
30 | static getScrollLeft(element: HTMLElement, rtl: boolean): number;
|
31 | static cleanNumber(value: any): number;
|
32 | static setScrollLeft(element: HTMLElement, value: number, rtl: boolean): void;
|
33 | static iterateNamedNodeMap(map: NamedNodeMap, callback: (key: string, value: string) => void): void;
|
34 | static iterateObject<T>(object: {
|
35 | [p: string]: T;
|
36 | } | T[], callback: (key: string, value: T) => void): void;
|
37 | static cloneObject<T>(object: T): T;
|
38 | static map<TItem, TResult>(array: TItem[], callback: (item: TItem) => TResult): TResult[];
|
39 | static mapObject<TResult>(object: any, callback: (item: any) => TResult): TResult[];
|
40 | static forEach<T>(array: T[], callback: (item: T, index: number) => void): void;
|
41 | static filter<T>(array: T[], callback: (item: T) => boolean): T[];
|
42 | static getAllKeysInObjects(objects: any[]): string[];
|
43 | static mergeDeep(dest: any, source: any): void;
|
44 | static assign(object: any, ...sources: any[]): any;
|
45 | static parseYyyyMmDdToDate(yyyyMmDd: string, separator: string): Date;
|
46 | static serializeDateToYyyyMmDd(date: Date, separator: string): string;
|
47 | static pad(num: number, totalStringSize: number): string;
|
48 | static pushAll(target: any[], source: any[]): void;
|
49 | static createArrayOfNumbers(first: number, last: number): number[];
|
50 | static getFunctionParameters(func: any): any;
|
51 | static find<T>(collection: T[] | {
|
52 | [id: string]: T;
|
53 | }, predicate: string | boolean | ((item: T) => void), value?: any): T;
|
54 | static toStrings<T>(array: T[]): string[];
|
55 | static iterateArray<T>(array: T[], callback: (item: T, index: number) => void): void;
|
56 | static isNode(o: any): boolean;
|
57 | static isElement(o: any): boolean;
|
58 | static isNodeOrElement(o: any): boolean;
|
59 | static copyNodeList(nodeList: NodeList): Node[];
|
60 | static isEventFromPrintableCharacter(event: KeyboardEvent): boolean;
|
61 | static addChangeListener(element: HTMLElement, listener: EventListener): void;
|
62 | static makeNull<T>(value: T): T;
|
63 | static missing(value: any): boolean;
|
64 | static missingOrEmpty(value: any[] | string): boolean;
|
65 | static missingOrEmptyObject(value: any): boolean;
|
66 | static exists(value: any): boolean;
|
67 | static firstExistingValue<A>(...values: A[]): A;
|
68 | static anyExists(values: any[]): boolean;
|
69 | static existsAndNotEmpty(value: any[]): boolean;
|
70 | static removeAllChildren(node: HTMLElement): void;
|
71 | static removeElement(parent: HTMLElement, cssSelector: string): void;
|
72 | static removeFromParent(node: Element): void;
|
73 | static isVisible(element: HTMLElement): boolean;
|
74 | /**
|
75 | * loads the template and returns it as an element. makes up for no simple way in
|
76 | * the dom api to load html directly, eg we cannot do this: document.createElement(template)
|
77 | */
|
78 | static loadTemplate(template: string): HTMLElement;
|
79 | static appendHtml(eContainer: HTMLElement, htmlTemplate: string): void;
|
80 | static addOrRemoveCssClass(element: HTMLElement, className: string, addOrRemove: boolean): void;
|
81 | static callIfPresent(func: Function): void;
|
82 | static addCssClass(element: HTMLElement, className: string): void;
|
83 | static containsClass(element: any, className: string): boolean;
|
84 | static getElementAttribute(element: any, attributeName: string): string;
|
85 | static offsetHeight(element: HTMLElement): number;
|
86 | static offsetWidth(element: HTMLElement): number;
|
87 | static sortNumberArray(numberArray: number[]): void;
|
88 | static removeCssClass(element: HTMLElement, className: string): void;
|
89 | static removeRepeatsFromArray<T>(array: T[], object: T): void;
|
90 | static removeFromArray<T>(array: T[], object: T): void;
|
91 | static removeAllFromArray<T>(array: T[], toRemove: T[]): void;
|
92 | static insertIntoArray<T>(array: T[], object: T, toIndex: number): void;
|
93 | static insertArrayIntoArray<T>(dest: T[], src: T[], toIndex: number): void;
|
94 | static moveInArray<T>(array: T[], objectsToMove: T[], toIndex: number): void;
|
95 | static defaultComparator(valueA: any, valueB: any, accentedCompare?: boolean): number;
|
96 | static compareArrays(array1: any[], array2: any[]): boolean;
|
97 | static ensureDomOrder(eContainer: HTMLElement, eChild: HTMLElement, eChildBefore: HTMLElement): void;
|
98 | static insertWithDomOrder(eContainer: HTMLElement, eChild: HTMLElement, eChildBefore: HTMLElement): void;
|
99 | static insertTemplateWithDomOrder(eContainer: HTMLElement, htmlTemplate: string, eChildBefore: HTMLElement): HTMLElement;
|
100 | static every<T>(items: T[], callback: (item: T) => boolean): boolean;
|
101 | static toStringOrNull(value: any): string;
|
102 | static formatWidth(width: number | string): string;
|
103 | static formatNumberTwoDecimalPlacesAndCommas(value: number): string;
|
104 | static formatNumberCommas(value: number): string;
|
105 | static prependDC(parent: HTMLElement, documentFragment: DocumentFragment): void;
|
106 | static iconNameClassMap: {
|
107 | [key: string]: string;
|
108 | };
|
109 | /**
|
110 | * If icon provided, use this (either a string, or a function callback).
|
111 | * if not, then use the default icon from the theme
|
112 | */
|
113 | static createIcon(iconName: string, gridOptionsWrapper: GridOptionsWrapper, column: Column): HTMLElement;
|
114 | static createIconNoSpan(iconName: string, gridOptionsWrapper: GridOptionsWrapper, column: Column): HTMLElement;
|
115 | static addStylesToElement(eElement: any, styles: any): void;
|
116 | static isHorizontalScrollShowing(element: HTMLElement): boolean;
|
117 | static isVerticalScrollShowing(element: HTMLElement): boolean;
|
118 | static getMaxDivHeight(): number;
|
119 | static getScrollbarWidth(): number;
|
120 | static isKeyPressed(event: KeyboardEvent, keyToCheck: number): boolean;
|
121 | static setVisible(element: HTMLElement, visible: boolean): void;
|
122 | static setHidden(element: HTMLElement, hidden: boolean): void;
|
123 | static isBrowserIE(): boolean;
|
124 | static isBrowserEdge(): boolean;
|
125 | static isBrowserSafari(): boolean;
|
126 | static isBrowserChrome(): boolean;
|
127 | static isBrowserFirefox(): boolean;
|
128 | static isUserAgentIPad(): boolean;
|
129 | static getTarget(event: Event): Element;
|
130 | static isElementInEventPath(element: HTMLElement, event: Event): boolean;
|
131 | static createEventPath(event: Event): EventTarget[];
|
132 | static addAgGridEventPath(event: Event): void;
|
133 | static getEventPath(event: Event): EventTarget[];
|
134 | static forEachSnapshotFirst(list: any[], callback: (item: any) => void): void;
|
135 | static getBodyWidth(): number;
|
136 | static getBodyHeight(): number;
|
137 | static setCheckboxState(eCheckbox: any, state: any): void;
|
138 | static traverseNodesWithKey(nodes: RowNode[], callback: (node: RowNode, key: string) => void): void;
|
139 | static camelCaseToHyphen(str: string): string;
|
140 | static hyphenToCamelCase(str: string): string;
|
141 | static cssStyleObjectToMarkup(stylesToUse: any): string;
|
142 | /**
|
143 | * From http://stackoverflow.com/questions/9716468/is-there-any-function-like-isnumeric-in-javascript-to-validate-numbers
|
144 | */
|
145 | static isNumeric(value: any): boolean;
|
146 | static escape(toEscape: string): string;
|
147 | /**
|
148 | * Mouse wheel (and 2-finger trackpad) support on the web sucks. It is
|
149 | * complicated, thus this doc is long and (hopefully) detailed enough to answer
|
150 | * your questions.
|
151 | *
|
152 | * If you need to react to the mouse wheel in a predictable way, this code is
|
153 | * like your bestest friend. * hugs *
|
154 | *
|
155 | * As of today, there are 4 DOM event types you can listen to:
|
156 | *
|
157 | * 'wheel' -- Chrome(31+), FF(17+), IE(9+)
|
158 | * 'mousewheel' -- Chrome, IE(6+), Opera, Safari
|
159 | * 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother!
|
160 | * 'DOMMouseScroll' -- FF(0.9.7+) since 2003
|
161 | *
|
162 | * So what to do? The is the best:
|
163 | *
|
164 | * normalizeWheel.getEventType();
|
165 | *
|
166 | * In your event callback, use this code to get sane interpretation of the
|
167 | * deltas. This code will return an object with properties:
|
168 | *
|
169 | * spinX -- normalized spin speed (use for zoom) - x plane
|
170 | * spinY -- " - y plane
|
171 | * pixelX -- normalized distance (to pixels) - x plane
|
172 | * pixelY -- " - y plane
|
173 | *
|
174 | * Wheel values are provided by the browser assuming you are using the wheel to
|
175 | * scroll a web page by a number of lines or pixels (or pages). Values can vary
|
176 | * significantly on different platforms and browsers, forgetting that you can
|
177 | * scroll at different speeds. Some devices (like trackpads) emit more events
|
178 | * at smaller increments with fine granularity, and some emit massive jumps with
|
179 | * linear speed or acceleration.
|
180 | *
|
181 | * This code does its best to normalize the deltas for you:
|
182 | *
|
183 | * - spin is trying to normalize how far the wheel was spun (or trackpad
|
184 | * dragged). This is super useful for zoom support where you want to
|
185 | * throw away the chunky scroll steps on the PC and make those equal to
|
186 | * the slow and smooth tiny steps on the Mac. Key data: This code tries to
|
187 | * resolve a single slow step on a wheel to 1.
|
188 | *
|
189 | * - pixel is normalizing the desired scroll delta in pixel units. You'll
|
190 | * get the crazy differences between browsers, but at least it'll be in
|
191 | * pixels!
|
192 | *
|
193 | * - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This
|
194 | * should translate to positive value zooming IN, negative zooming OUT.
|
195 | * This matches the newer 'wheel' event.
|
196 | *
|
197 | * Why are there spinX, spinY (or pixels)?
|
198 | *
|
199 | * - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn
|
200 | * with a mouse. It results in side-scrolling in the browser by default.
|
201 | *
|
202 | * - spinY is what you expect -- it's the classic axis of a mouse wheel.
|
203 | *
|
204 | * - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and
|
205 | * probably is by browsers in conjunction with fancy 3D controllers .. but
|
206 | * you know.
|
207 | *
|
208 | * Implementation info:
|
209 | *
|
210 | * Examples of 'wheel' event if you scroll slowly (down) by one step with an
|
211 | * average mouse:
|
212 | *
|
213 | * OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120)
|
214 | * OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12)
|
215 | * OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A)
|
216 | * Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120)
|
217 | * Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120)
|
218 | *
|
219 | * On the trackpad:
|
220 | *
|
221 | * OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6)
|
222 | * OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A)
|
223 | *
|
224 | * On other/older browsers.. it's more complicated as there can be multiple and
|
225 | * also missing delta values.
|
226 | *
|
227 | * The 'wheel' event is more standard:
|
228 | *
|
229 | * http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
|
230 | *
|
231 | * The basics is that it includes a unit, deltaMode (pixels, lines, pages), and
|
232 | * deltaX, deltaY and deltaZ. Some browsers provide other values to maintain
|
233 | * backward compatibility with older events. Those other values help us
|
234 | * better normalize spin speed. Example of what the browsers provide:
|
235 | *
|
236 | * | event.wheelDelta | event.detail
|
237 | * ------------------+------------------+--------------
|
238 | * Safari v5/OS X | -120 | 0
|
239 | * Safari v5/Win7 | -120 | 0
|
240 | * Chrome v17/OS X | -120 | 0
|
241 | * Chrome v17/Win7 | -120 | 0
|
242 | * IE9/Win7 | -120 | undefined
|
243 | * Firefox v4/OS X | undefined | 1
|
244 | * Firefox v4/Win7 | undefined | 3
|
245 | *
|
246 | */
|
247 | static normalizeWheel(event: any): any;
|
248 | /**
|
249 | * https://stackoverflow.com/questions/24004791/can-someone-explain-the-debounce-function-in-javascript
|
250 | */
|
251 | static debounce(func: () => void, wait: number, immediate?: boolean): () => void;
|
252 | static stopPropagationForAgGrid(event: Event): void;
|
253 | static isStopPropagationForAgGrid(event: Event): boolean;
|
254 | static executeInAWhile(funcs: Function[]): void;
|
255 | static executeNextVMTurn(funcs: Function[]): void;
|
256 | static executeAfter(funcs: Function[], millis: number): void;
|
257 | static referenceCompare(left: any, right: any): boolean;
|
258 | static get(source: {
|
259 | [p: string]: any;
|
260 | }, expression: string, defaultValue: any): any;
|
261 | static passiveEvents: string[];
|
262 | static addSafePassiveEventListener(eElement: HTMLElement, event: string, listener: (event?: any) => void): void;
|
263 | static camelCaseToHumanText(camelCase: string): string;
|
264 | static message(msg: string): void;
|
265 | static sortRowNodesByOrder(rowNodes: RowNode[], rowNodeOrder: {
|
266 | [id: string]: number;
|
267 | }): void;
|
268 | static fuzzyCheckStrings(inputValues: string[], validValues: string[], allSuggestions: string[]): {
|
269 | [p: string]: string[];
|
270 | };
|
271 | static fuzzySuggestions(inputValue: string, validValues: string[], allSuggestions: string[]): string[];
|
272 | static get_bigrams(from: string): any[];
|
273 | static string_similarity: (str1: string, str2: string) => number;
|
274 | private static isNumpadDelWithNumlockOnForEdgeOrIe(event);
|
275 | }
|
276 | export declare class NumberSequence {
|
277 | private nextValue;
|
278 | private step;
|
279 | constructor(initValue?: number, step?: number);
|
280 | next(): number;
|
281 | peek(): number;
|
282 | skip(count: number): void;
|
283 | }
|
284 | export declare let _: typeof Utils;
|
285 | export declare type ResolveAndRejectCallback<T> = (resolve: (value: T) => void, reject: (params: any) => void) => void;
|
286 | export declare enum PromiseStatus {
|
287 | IN_PROGRESS = 0,
|
288 | RESOLVED = 1,
|
289 | }
|
290 | export interface ExternalPromise<T> {
|
291 | resolve: (value: T) => void;
|
292 | promise: Promise<T>;
|
293 | }
|
294 | export declare class Promise<T> {
|
295 | private status;
|
296 | private resolution;
|
297 | private listOfWaiters;
|
298 | static all<T>(toCombine: Promise<T>[]): Promise<T[]>;
|
299 | static resolve<T>(value: T): Promise<T>;
|
300 | static external<T>(): ExternalPromise<T>;
|
301 | constructor(callback: ResolveAndRejectCallback<T>);
|
302 | then(func: (result: any) => void): void;
|
303 | firstOneOnly(func: (result: any) => void): void;
|
304 | map<Z>(adapter: (from: T) => Z): Promise<Z>;
|
305 | resolveNow<Z>(ifNotResolvedValue: Z, ifResolved: (current: T) => Z): Z;
|
306 | private onDone(value);
|
307 | private onReject(params);
|
308 | }
|