datatables.net 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "js/dataTables.js",
5
5
  "module": "js/dataTables.mjs",
6
6
  "types": "./types/types.d.ts",
7
- "version": "2.2.2",
7
+ "version": "2.3.0",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",
package/types/types.d.ts CHANGED
@@ -109,7 +109,7 @@ export interface OrderName {
109
109
  dir: 'asc' | 'desc';
110
110
  }
111
111
 
112
- export type OrderArray = [number, 'asc' | 'desc'];
112
+ export type OrderArray = [number, 'asc' | 'desc' | ''];
113
113
 
114
114
  export type OrderCombined = OrderIdx | OrderName | OrderArray;
115
115
 
@@ -231,7 +231,14 @@ type LayoutElement = {
231
231
  features: LayoutFeatures;
232
232
  }
233
233
 
234
- type Layout = Partial<Record<LayoutKeys, LayoutElement | LayoutFeatures | null>>;
234
+ type Layout = Partial<Record<LayoutKeys,
235
+ LayoutElement |
236
+ LayoutFeatures |
237
+ (() => HTMLElement) |
238
+ HTMLElement |
239
+ JQuery<HTMLElement> |
240
+ null
241
+ >>;
235
242
 
236
243
 
237
244
  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -388,6 +395,13 @@ export interface Config {
388
395
  */
389
396
  lengthMenu?: Array<(number | string)> | Array<Array<(number | string)>>;
390
397
 
398
+ /**
399
+ * Add event listeners during the DataTables startup
400
+ */
401
+ on?: {
402
+ [name: string]: ((this: HTMLElement, e: Event, ...args: any[]) => void);
403
+ };
404
+
391
405
  /**
392
406
  * Control which cell the order event handler will be applied to in a column.
393
407
  */
@@ -419,7 +433,18 @@ export interface Config {
419
433
  /**
420
434
  * Feature control ordering (sorting) abilities in DataTables.
421
435
  */
422
- ordering?: boolean;
436
+ ordering?: boolean | {
437
+ /**
438
+ * Control the showing of the ordering icons in the table header.
439
+ */
440
+ indicators?: boolean;
441
+
442
+ /**
443
+ * Control the addition of a click event handler on the table headers to activate
444
+ * ordering.
445
+ */
446
+ handler?: boolean;
447
+ };
423
448
 
424
449
  /**
425
450
  * Multiple column ordering ability control.
@@ -602,6 +627,9 @@ export interface ConfigLanguage {
602
627
  infoPostFix?: string;
603
628
  decimal?: string;
604
629
  thousands?: string;
630
+
631
+ /** Labels for page length entries */
632
+ lengthLabels?: { [key: string | number]: string};
605
633
  lengthMenu?: string;
606
634
  loadingRecords?: string;
607
635
  processing?: string;
@@ -1148,7 +1176,9 @@ export interface Api<T=any> {
1148
1176
  * @param initialValue Value to use as the first argument of the first call to the fn callback.
1149
1177
  * @returns Result from the final call to the fn callback function.
1150
1178
  */
1151
- reduce(fn: ((current: number, value: any, index: number, dt: Api<any>) => number), initialValue?: any): any;
1179
+ reduce(fn: (current: T, value: T, index: number, dt: Api<any>) => T): T;
1180
+ reduce(fn: (current: T, value: T, index: number, dt: Api<any>) => T, initialValue: T): T;
1181
+ reduce<U>(fn: (current: U, value: T, index: number, dt: Api<any>) => U, initialValue: U): U;
1152
1182
 
1153
1183
  /**
1154
1184
  * Apply a callback function against and accumulator and each element in the Api's result set (right-to-left).
@@ -1157,7 +1187,9 @@ export interface Api<T=any> {
1157
1187
  * @param initialValue Value to use as the first argument of the first call to the fn callback.
1158
1188
  * @returns Result from the final call to the fn callback function.
1159
1189
  */
1160
- reduceRight(fn: ((current: number, value: any, index: number, dt: Api<any>) => number), initialValue?: any): any;
1190
+ reduceRight(fn: (current: T, value: T, index: number, dt: Api<any>) => T): T;
1191
+ reduceRight(fn: (current: T, value: T, index: number, dt: Api<any>) => T, initialValue: T): T;
1192
+ reduceRight<U>(fn: (current: U, value: T, index: number, dt: Api<any>) => U, initialValue: U): U;
1161
1193
 
1162
1194
  /**
1163
1195
  * Reverse the result set of the API instance and return the original array.
@@ -1272,7 +1304,7 @@ export interface Api<T=any> {
1272
1304
  * impact for bubbling events.
1273
1305
  * @returns Api instance for chaining
1274
1306
  */
1275
- trigger( name: string, args: any[], bubbles?: boolean): Api<T>;
1307
+ trigger(name: string, args?: any[], bubbles?: boolean): Api<T>;
1276
1308
 
1277
1309
  /**
1278
1310
  * Create a new API instance containing only the unique items from the elements in an instance's result set.
@@ -1292,18 +1324,25 @@ export interface Api<T=any> {
1292
1324
 
1293
1325
 
1294
1326
  export interface ApiSelectorModifier {
1327
+ /**
1328
+ * The order in which the resolved columns should be returned in.
1329
+ *
1330
+ * * `implied` - the order given in the selector (default)
1331
+ * * `index` - column index order
1332
+ */
1333
+ columnOrder?: 'index' | 'implied';
1295
1334
  /**
1296
1335
  * The order modifier provides the ability to control which order the rows are
1297
1336
  * processed in. Can be one of 'current', 'applied', 'index', 'original', or
1298
1337
  * the column index that you want the order to be applied from.
1299
1338
  */
1300
- order?: string | number;
1339
+ order?: 'current' | 'applied' | 'index' | 'original' | number;
1301
1340
 
1302
1341
  /**
1303
1342
  * The search modifier provides the ability to govern which rows are used by the selector using the search options that are applied to the table.
1304
1343
  * Values: 'none', 'applied', 'removed'
1305
1344
  */
1306
- search?: string;
1345
+ search?: 'none' | 'applied' | 'removed';
1307
1346
 
1308
1347
  /**
1309
1348
  * The searchPlaceholder modifier provides the ability to provide informational text for an input control when it has no value.
@@ -1314,7 +1353,7 @@ export interface ApiSelectorModifier {
1314
1353
  * The page modifier allows you to control if the selector should consider all data in the table, regardless of paging, or if only the rows in the currently disabled page should be used.
1315
1354
  * Values: 'all', 'current'
1316
1355
  */
1317
- page?: string;
1356
+ page?: 'all' | 'current';
1318
1357
  }
1319
1358
 
1320
1359
  export interface AjaxMethods extends Api<any> {
@@ -1896,6 +1935,13 @@ export interface ApiColumnMethods<T> extends Omit<Api<T>, 'init' | 'data' | 'ord
1896
1935
  */
1897
1936
  init(): ConfigColumns;
1898
1937
 
1938
+ /**
1939
+ * Get the name for the selected column (set by `columns.name`).
1940
+ *
1941
+ * @returns Column name or null if not set.
1942
+ */
1943
+ name(): string | null;
1944
+
1899
1945
  /**
1900
1946
  * Obtain the th / td nodes for the selected column
1901
1947
  *
@@ -2129,6 +2175,13 @@ export interface ApiColumnsMethods<T> extends Omit<Api<T>, 'init' | 'data' | 'or
2129
2175
  */
2130
2176
  init(): Api<ConfigColumns>;
2131
2177
 
2178
+ /**
2179
+ * Get the names for the selected columns (set by `columns.name`).
2180
+ *
2181
+ * @returns Column names (each entry can be null if not set).
2182
+ */
2183
+ names(): string | null;
2184
+
2132
2185
  /**
2133
2186
  * Obtain the th / td nodes for the selected columns
2134
2187
  *
@@ -2790,7 +2843,8 @@ export interface DataTablesStatic {
2790
2843
  * Usage:
2791
2844
  * $.fn.dataTable.versionCheck("1.10.0");
2792
2845
  * @param version Version string
2793
- * @returns true if this version of DataTables is greater or equal to the required version, or false if this version of DataTales is not suitable
2846
+ * @returns true if this version of DataTables is greater or equal to the required version, or
2847
+ * false if this version of DataTables is not suitable
2794
2848
  */
2795
2849
  versionCheck(version: string): boolean;
2796
2850
  }
@@ -3060,6 +3114,9 @@ export interface AjaxSettings extends JQueryAjaxSettings {
3060
3114
  /** Mapping for `recordsFiltered` property */
3061
3115
  recordsFiltered: AjaxDataSrc;
3062
3116
  };
3117
+
3118
+ /** Format to submit the data parameters as in the Ajax request */
3119
+ submitAs?: 'http' | 'json';
3063
3120
  }
3064
3121
 
3065
3122
  interface FunctionColumnData {
@@ -3092,6 +3149,7 @@ export interface CellMetaSettings {
3092
3149
  export interface DataTablesStaticExt {
3093
3150
  builder: string;
3094
3151
  buttons: DataTablesStaticExtButtons;
3152
+ ccContent: IColumnControlContent;
3095
3153
  classes: ExtClassesSettings;
3096
3154
  errMode: string;
3097
3155
  feature: any[];
@@ -3115,6 +3173,10 @@ export interface DataTablesStaticExtButtons {
3115
3173
  // Intentionally empty, completed in Buttons extension
3116
3174
  }
3117
3175
 
3176
+ export interface IColumnControlContent {
3177
+ [name: string]: any;
3178
+ }
3179
+
3118
3180
  /**
3119
3181
  * Classes used by DataTables. Used for styling integration. Note
3120
3182
  * that these all use legacy Hungarian notation.
@@ -3317,38 +3379,38 @@ export type ExtTypeSettingsDetect = ((data: any, settings: InternalSettings) =>
3317
3379
  init?: (settings: InternalSettings, column: any, index: number) => boolean
3318
3380
  };
3319
3381
 
3320
- type FunctionAjax = (data: object, callback: ((data: any) => void), settings: InternalSettings) => void;
3382
+ type FunctionAjax = (this: JQueryDataTables, data: object, callback: ((data: any) => void), settings: InternalSettings) => void;
3321
3383
 
3322
- type FunctionAjaxData = (data: AjaxData, settings: InternalSettings) => string | object;
3384
+ type FunctionAjaxData = (this: JQueryDataTables, data: AjaxData, settings: InternalSettings) => string | object;
3323
3385
 
3324
- type FunctionColumnRender = (data: any, type: any, row: any, meta: CellMetaSettings) => any;
3386
+ type FunctionColumnRender = (this: JQueryDataTables, data: any, type: any, row: any, meta: CellMetaSettings) => any;
3325
3387
 
3326
- type FunctionColumnCreatedCell = (cell: HTMLTableCellElement, cellData: any, rowData: any, row: number, col: number) => void;
3388
+ type FunctionColumnCreatedCell = (this: JQueryDataTables, cell: HTMLTableCellElement, cellData: any, rowData: any, row: number, col: number) => void;
3327
3389
 
3328
- type FunctionCreateRow = (row: HTMLTableRowElement, data: any[] | object, dataIndex: number, cells: HTMLTableCellElement[]) => void;
3390
+ type FunctionCreateRow = (this: JQueryDataTables, row: HTMLTableRowElement, data: any[] | object, dataIndex: number, cells: HTMLTableCellElement[]) => void;
3329
3391
 
3330
- type FunctionDrawCallback = (settings: InternalSettings) => void;
3392
+ type FunctionDrawCallback = (this: JQueryDataTables, settings: InternalSettings) => void;
3331
3393
 
3332
- type FunctionFooterCallback = (tr: HTMLTableRowElement, data: any[], start: number, end: number, display: any[]) => void;
3394
+ type FunctionFooterCallback = (this: JQueryDataTables, tr: HTMLTableRowElement, data: any[], start: number, end: number, display: any[]) => void;
3333
3395
 
3334
- type FunctionFormatNumber = (formatNumber: number) => void;
3396
+ type FunctionFormatNumber = (this: JQueryDataTables, formatNumber: number) => void;
3335
3397
 
3336
- type FunctionHeaderCallback = (tr: HTMLTableRowElement, data: any[], start: number, end: number, display: any[]) => void;
3398
+ type FunctionHeaderCallback = (this: JQueryDataTables, tr: HTMLTableRowElement, data: any[], start: number, end: number, display: any[]) => void;
3337
3399
 
3338
- type FunctionInfoCallback = (settings: InternalSettings, start: number, end: number, mnax: number, total: number, pre: string) => void;
3400
+ type FunctionInfoCallback = (this: JQueryDataTables, settings: InternalSettings, start: number, end: number, mnax: number, total: number, pre: string) => void;
3339
3401
 
3340
- type FunctionInitComplete = (settings: InternalSettings, json: object) => void;
3402
+ type FunctionInitComplete = (this: JQueryDataTables, settings: InternalSettings, json: object) => void;
3341
3403
 
3342
- type FunctionPreDrawCallback = (settings: InternalSettings) => void;
3404
+ type FunctionPreDrawCallback = (this: JQueryDataTables, settings: InternalSettings) => void;
3343
3405
 
3344
- type FunctionRowCallback = (row: HTMLTableRowElement, data: any[] | object, index: number) => void;
3406
+ type FunctionRowCallback = (this: JQueryDataTables, row: HTMLTableRowElement, data: any[] | object, index: number) => void;
3345
3407
 
3346
- type FunctionStateLoadCallback = (settings: InternalSettings) => void;
3408
+ type FunctionStateLoadCallback = (this: JQueryDataTables, settings: InternalSettings, callback: ((state) => void)) => void | object;
3347
3409
 
3348
- type FunctionStateLoaded = (settings: InternalSettings, data: object) => void;
3410
+ type FunctionStateLoaded = (this: JQueryDataTables, settings: InternalSettings, data: object) => void;
3349
3411
 
3350
- type FunctionStateLoadParams = (settings: InternalSettings, data: object) => void;
3412
+ type FunctionStateLoadParams = (this: JQueryDataTables, settings: InternalSettings, data: object) => void;
3351
3413
 
3352
- type FunctionStateSaveCallback = (settings: InternalSettings, data: object) => void;
3414
+ type FunctionStateSaveCallback = (this: JQueryDataTables, settings: InternalSettings, data: object) => void;
3353
3415
 
3354
- type FunctionStateSaveParams = (settings: InternalSettings, data: object) => void;
3416
+ type FunctionStateSaveParams = (this: JQueryDataTables, settings: InternalSettings, data: object) => void;