forked from DataTables/Buttons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.d.ts
589 lines (483 loc) · 17.4 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
// Type definitions for JQuery DataTables Buttons extension 1.4
// Project: http://datatables.net/extensions/buttons/, https://datatables.net
// Definitions by: Kiarash Ghiaseddin <https://github.com/Silver-Connection>, Sam Germano <https://github.com/SammyG4Free>, Jim Hartford <https://github.com/jimhartford>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="jquery" />
/// <reference types="datatables.net"/>
declare namespace DataTables {
interface Settings {
/**
* Buttons extension options
*/
buttons?: boolean | string[] | ButtonsSettings | ButtonSettings[];
}
interface LanguageSettings {
buttons?: {};
}
interface StaticFunctions {
Buttons: ButtonStaticFunctions;
}
interface ButtonStaticFunctions {
new (dt: Api<any>, settings: boolean | string[] | ButtonsSettings | ButtonSettings[]): undefined;
version: string;
defaults: ButtonsSettings;
}
interface ExtSettings {
buttons: ExtButtonsSettings;
}
interface Api<T> {
/**
* Select a single button from the button instances attached to a DataTable.
*
* @param groupSelector Button group (instance) selector. Provides the ability to select a button from a specific instance of the Buttons class.
* @param buttonSelector Selector to obtain the button that should be acted upon.
*/
button(groupSelector?: number | string | Array<number | string>, buttonSelector?: null | number | string | Node | JQuery<HTMLElement> | Array<null | number | string | Node | JQuery<HTMLElement>>): ButtonApi;
buttons: ButtonsGlobalApi;
}
interface ButtonsGlobalApi {
(groupSelector?: any, buttonSelector?: any): ButtonsApi;
/**
* Resize the Flash movie clips to take account of the current button dimensions.
*
* @returns Unmodified DataTable API instance for chaining
*/
resize(): Api<any>;
/**
* Display / hide an information message to the end user to indicate that something has happened.
*
* @returns DataTables API instance for chaining.
*/
info(title: string, message?: string, time?: number): Api<any>;
/**
* Get meta information that is common to many different button types.
*
* @returns An object with properties which contain the filename, messageTop, messageBottom and title.
*/
exportInfo(options?: ButtonsApiExportInfoParameter): ButtonsApiExportInfoReturn;
/**
* Obtain data from a DataTable that is suitable for exporting by saving into a file or copying to clipboard.
*
* @returns An object with 3 properties, one each for the data in the header, body and footer.
*/
exportData(options?: ButtonsApiExportDataParameter): ButtonsApiExportDataReturn;
}
interface ButtonApi {
/**
* Get the action function for the selected button.
*
* @returns The action function for the selected button.
*/
action(): FunctionButtonAction;
/**
* Set the action function for the selected button.
*
* @param set the function that is to be triggered on an action.
* @returns DataTables Api for chaining
*/
action(set: FunctionButtonAction): Api<any>;
/**
* Get the active state for the selected button.
*
* @returns true if currently active, otherwise false.
*/
active(): boolean;
/**
* Set the active state for the selected button.
*
* @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button.
*/
active(state: boolean): Api<any>;
/**
* Create a new button, adding it to the selected button instance and inserting immediately into the document.
*
* @returns New DataTables API instance with the result set containing the newly created button. This means it is possible to immediately using the chaining API to manipulate the button.
*/
add(index: number | string, config: string|FunctionButtom|ButtonSettings): Api<any>;
/**
* Disable the selected buttons.
*
* @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button.
*/
disable(): Api<any>;
/**
* Set the enabled state for the selected button.
*
* @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button.
*/
enable(state?: boolean): Api<any>;
/**
* Get a jQuery object that contains a reference to the node for the selected button.
*
* @returns A jQuery object that contains the node of the selected button
*/
node(): JQuery;
/**
* Determine if a button is currently in the processing state or not.
*
* @returns true if the button is currently in its processing state, false otherwise.
*/
processing(): boolean;
/**
* Set the processing state for the selected button.
*
* @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the buttons.
*/
processing(set: boolean): Api<any>;
/**
* Remove the selected button from the display. The button is destroyed and can no longer be used once removed.
*
* @returns DataTables API instance.
*/
remove(): Api<any>;
/**
* Get the display text for the selected button
*
* @returns The current display string from the button.
*/
text(): string;
/**
* Set the display text for the selected button
*
* @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the buttons.
*/
text(title: string | FunctionButtonText): Api<any>;
/**
* Programmatically trigger the action of the selected button.
*
* @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button.
*/
trigger(): Api<any>;
}
interface ButtonsApi {
/**
* Get the action function for the selected button.
*
* @returns DataTables API instance which contains the action functions for the selected buttons
*/
action(): Api<Array<FunctionButtonAction>>;
/**
* Set the action function for the selected button.
*
* @param set the function that is to be triggered on an action.
* @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons.
*/
action(set: FunctionButtonAction): Api<Array<any>>;
/**
* Get the active state for the selected button.
*
* @returns API instance which contains true if currently active, otherwise false for each selected button in the result set.
*/
active(): Api<Array<boolean>>;
/**
* Set the active state for the selected button.
*
* @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons.
*/
active(state: boolean): Api<Array<any>>;
/**
* Get a jQuery instance that contains a reference to the button container instance.
*/
container(): JQuery;
/**
* Get a jQuery instance that contains a reference to the button container instances.
*
* @returns jQuery instance that contains the container elements for the selected button instances.
*/
containers(): JQuery;
/**
* Destroy the selected button instances, removing the container and all button elements from the document.
*
* @returns DataTables API instance.
*/
destroy(): Api<any>;
/**
* Disable the selected buttons.
*
* @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons.
*/
disable(): Api<Array<any>>;
/**
* Set the enabled state for the selected button.
*
* @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons.
*/
enable(state?: boolean): Api<Array<any>>;
/**
* Get a jQuery object that contains a reference to the node for the selected button.
*
* @returns A jQuery object that contains the node of the selected button
*/
nodes(): JQuery;
/**
* Set the processing state for the selected button.
*
* @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons.
*/
processing(set: boolean): Api<any>;
/**
* Remove the selected button from the display. The button is destroyed and can no longer be used once removed.
*
* @returns DataTables API instance.
*/
remove(): Api<any>;
/**
* Get the display text for the selected button
*
* @returns The current display string from the button.
*/
text(): string;
/**
* Set the display text for the selected button
*
* @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the buttons.
*/
text(title: string | FunctionButtonText): Api<Array<string>>;
/**
* Programmatically trigger the action of the selected button.
*
* @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button.
*/
trigger(): Api<Array<any>>;
}
interface ButtonsApiExportInfoParameter {
extension?: string | (() => string);
filename?: string | (() => string);
messageBottom?: null | string | (() => string);
messageTop?: null | string | (() => string);
title?: null | string | (() => string);
}
interface ButtonsApiExportInfoReturn {
filename: string;
messageTop: string;
messageBottom: string;
title: string;
}
interface ButtonsApiExportDataParameter {
rows?: any;
columns?: any;
modifier?: any;
orthogonal?: string;
stripHtml?: boolean;
stripNewlines?: boolean;
decodeEntities?: boolean;
trim?: boolean;
format?: any;
}
interface ButtonsApiExportDataReturn {
header: string[];
footer: string[];
body: string[];
}
//#region "Button Settings"
interface ButtonsSettings {
name?: string;
tabIndex?: number;
buttons: Array<string|FunctionButtom|ButtonSettings>;
dom?: ButtonDomSettings;
}
interface ButtonDomSettings {
button?: ButtonDomButtomButton;
buttonContainer?: ButtonDomButtomCommon;
buttonLiner?: ButtonDomButtomCommon;
collection?: ButtonDomButtomCommon;
container?: ButtonDomButtomCommon;
}
interface ButtonDomButtomCommon {
className?: string;
tag?: string;
}
interface ButtonDomButtomButton extends ButtonDomButtomCommon {
active?: string;
disabled?: string;
}
interface ButtomSettingsCommon {
/**
* Action to take when the button is activated
*/
action?: FunctionButtonAction;
/**
* Ensure that any requirements have been satisfied before initialising a button
*/
available?: FunctionButtonAvailable;
/**
* Set the class name for the button
*/
className?: string;
/**
* Function that is called when the button is destroyed
*/
destroy?: FunctionButtonInit;
/**
* Set a button's initial enabled state
*/
enabled?: boolean;
/**
* Define which button type the button should be based on
*/
extend?: string;
/**
* Initialisation function that can be used to add events specific to this button
*/
init?: FunctionButtonInit;
/**
* Define an activation key for a button
*/
key?: string | ButtonKey;
/**
* Set a name for each selection
*/
name?: string;
/**
* Unique namespace for every button
*/
namespace?: string;
/**
* The text to show in the button
*/
text?: string | FunctionButtonText;
/**
* Button 'title' attribute text
*/
titleAttr?: string;
}
interface ButtonKey {
key?: string;
shiftKey?: boolean;
altKey?: boolean;
ctrlKey?: boolean;
metaKey?: boolean;
}
/**
* A function that will be executed upon creation of the buttons.
*/
type FunctionButtom = (dt: Api<any>) => ButtomSettingsCommon;
type FunctionButtonText = (dt: Api<any>, node: JQuery, config: any) => string;
type FunctionButtonAvailable = (dt: Api<any>, config: any) => boolean;
type FunctionButtonInit = (dt: Api<any>, node: JQuery, config: any) => void;
type FunctionButtonAction = (e: any, dt: Api<any>, node: JQuery, config: ButtonSettings) => void;
type FunctionButtonCustomize = (win: Window|string) => void;
type FunctionExtButtonsCollectionText = (a: any) => string;
interface ExtButtonsSettings {
collection: ExtButtonsCollectionSettings;
}
interface ExtButtonsCollectionSettings {
action: FunctionButtonAction;
autoClose: boolean;
background: boolean;
backgroundClassName: string;
className: string;
collectionLayout: string;
fade: number;
text: FunctionExtButtonsCollectionText;
}
//#endregion "Button Defaults"
//#region "Add-Ons"
/**
* Buttons extension options
*/
interface ButtonSettings extends ButtomSettingsCommon {
//#region (HTML-)File-Export
/**
* CSV / EXCEL: Define what the exported filename should be
*/
filename?: string;
/**
* COPY / CSV: field separator
*/
fieldSeparator?: string;
/**
* COPY / CSV: field boundary
*/
fieldBoundary?: string;
/**
* COPY / CSV: field separator
*/
newLine?: string;
/**
* CSV / EXCEL / PDF: file extension
*/
extension?: string;
/**
* CSV: UTF-8 boom
*/
bom?: boolean;
/**
* CSV: charset
*/
charset?: string|boolean;
/**
* CSV: escape char
*/
escapeChar?: string;
/**
* EXCEL
*/
customizeData?: FunctionButtonCustomizeData;
/**
* PDF: portrait / landscape
*/
orientation?: string;
/**
* PDF: A3 / A4 / A5 / LEGAL / LETTER / TABLOID
*/
pageSize?: string;
//#endregion (HTML-)File-Export
//#region Export and Print
/**
* COPY / CSV / EXCEL / PDF / PRINT: show header
*/
exportOptions?: ButtonExportOptions | object;
/**
* COPY / CSV / EXCEL / PDF / PRINT: show header
*/
customize?: FunctionButtonCustomize;
/**
* COPY / CSV / EXCEL / PDF / PRINT: show header
*/
header?: boolean;
/**
* COPY / CSV / EXCEL / PDF / PRINT: show footer
*/
footer?: boolean;
/**
* COPY / PRINT: title
*/
title?: string;
/**
* COPY / EXCEL / PDF / PRINT: field separator
*/
messageTop?: string;
/**
* COPY / EXCEL / PDF / PRINT: field separator
*/
messageBottom?: string;
/**
* PDF / PRINT: Extra message
*/
message?: string|Api<any>|JQuery|object;
/**
* PRINT: Show print dialoge on click
*/
autoPrint?: boolean;
//#endregion Export and Print
//#region ColVis
/**
* COLVIS: Column selector
*/
columns?: any;
/**
* COLVIS:
*/
columnText?: FunctionButtonColvisColumnText;
//#endregion ColVis
}
type ButtonSelectorTypes = string | number | JQuery<any>;
interface ButtonExportOptions {
columns?: ButtonSelectorTypes | ButtonSelectorTypes[];
}
type FunctionButtonCustomizeData = (content: any) => void;
type FunctionButtonColvisColumnText = (dt: Api<any>, i: number, title: string) => string;
//#endregion "button-settings
}