diff --git a/types/datatables.net-autofill/datatables.net-autofill-tests.ts b/types/datatables.net-autofill/datatables.net-autofill-tests.ts new file mode 100644 index 0000000000..0ad00b4395 --- /dev/null +++ b/types/datatables.net-autofill/datatables.net-autofill-tests.ts @@ -0,0 +1,8 @@ +const config: DataTables.Settings = { + // AutoFill extension options + autoFill: { + alwaysAsk: true, + enable: true, + columns: [1, 2] + } +}; diff --git a/types/datatables.net-autofill/index.d.ts b/types/datatables.net-autofill/index.d.ts new file mode 100644 index 0000000000..2f05d608be --- /dev/null +++ b/types/datatables.net-autofill/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for datatables.net-autofill 2.2 +// Project: https://datatables.net +// Definitions by: Andy Ma +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/// +/// + +declare namespace DataTables { + interface Settings { + /* + * autoFill extension options + */ + autoFill?: boolean | AutoFillSettings; + } + + interface AutoFillSettings { + /* + * Always ask the end user if an action should be taken or not + */ + alwaysAsk?: boolean; + /* + * Select the columns that can be auto filled + */ + columns: string | number[]; + /* + * + * Initial enablement state of AutoFill + */ + enable?: boolean; + } +} diff --git a/types/datatables.net-autofill/tsconfig.json b/types/datatables.net-autofill/tsconfig.json new file mode 100644 index 0000000000..e17d5de5da --- /dev/null +++ b/types/datatables.net-autofill/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "datatables.net-autofill-tests.ts" + ] +} diff --git a/types/datatables.net-autofill/tslint.json b/types/datatables.net-autofill/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/datatables.net-autofill/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/datatables.net-colreorder/datatables.net-colreorder-tests.ts b/types/datatables.net-colreorder/datatables.net-colreorder-tests.ts new file mode 100644 index 0000000000..a6126baf44 --- /dev/null +++ b/types/datatables.net-colreorder/datatables.net-colreorder-tests.ts @@ -0,0 +1,12 @@ +$(document).ready(() => { + const config: DataTables.Settings = { + // ColReorder extension options + colReorder: { + fixedColumnsLeft: 0, + fixedColumnsRight: 0, + order: [1, 2, 3], + realtime: true, + reorderCallback: () => {}, + } + }; +}); diff --git a/types/datatables.net-colreorder/index.d.ts b/types/datatables.net-colreorder/index.d.ts new file mode 100644 index 0000000000..8254cd71dc --- /dev/null +++ b/types/datatables.net-colreorder/index.d.ts @@ -0,0 +1,64 @@ +// Type definitions for datatables.net-colReorder 1.4 +// Project: https://datatables.net/extensions/colreorder/ +// Definitions by: Andy Ma +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/// +/// + +declare namespace DataTables { + interface Settings { + /* + * colReorder extension options + */ + colReorder?: boolean | ColReorderSettings; + } + + interface ColReorderSettings { + /* + * Number of columns (counting from the left) to disallow reordering of, '0' in default + */ + fixedColumnsLeft?: number; + + /* + * Number of columns (counting from the right) to disallow reordering of, '0' in default + */ + fixedColumnsRight?: number; + + /* + * Set a default order for the columns in the table + */ + order?: number[]; + + /* + * Enable / disable live reordering of columns during a drag, 'true' in default + */ + realtime?: boolean; + /* + * Callback after reorder + */ + reorderCallback: () => void; + } + + interface Api { + colReorder: { + /* + * Programmatically reorder columns + */ + move(from: number, to: number, drop: boolean, invalidate: boolean): Api; + /* + * Get / set column order + */ + order(newOrder?: number[], originalIndexes?: boolean): Api; + /* + * Restore the loaded column order + */ + reset(): Api; + /* + * Convert one or more column indexes to and from current and original indexes + */ + transpose(idx?: number | number[], direction?: "toCurrent" | "toOriginal" | "fromOriginal" | "fromCurrent"): Api; + }; + } +} diff --git a/types/datatables.net-colreorder/tsconfig.json b/types/datatables.net-colreorder/tsconfig.json new file mode 100644 index 0000000000..ec5e47bb49 --- /dev/null +++ b/types/datatables.net-colreorder/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "datatables.net-colreorder-tests.ts" + ] +} diff --git a/types/datatables.net-colreorder/tslint.json b/types/datatables.net-colreorder/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/datatables.net-colreorder/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/datatables.net-select/index.d.ts b/types/datatables.net-select/index.d.ts index e24f6b8ab6..563a51fc25 100644 --- a/types/datatables.net-select/index.d.ts +++ b/types/datatables.net-select/index.d.ts @@ -44,6 +44,41 @@ declare namespace DataTables { /* * Set the selection style for end user interaction with the table */ - style?: string; + style?: "api" | "single" | "multi" | "os" | "multi+shift"; + } + + interface Api { + select: { + /* + * Get the current selection style applied to the table + */ + style(): string; + /* + * Set the table's selection style + */ + style(s: "api" | "single" | "multi" | "os"): Api; + }; + } + + interface RowMethods { + /** + * Select a row + */ + select(): Api; + /** + * Deselect a row + */ + deselect(): Api; + } + + interface RowsMethods { + /** + * Select multiple rows + */ + select(): Api; + /** + * Deselect a row + */ + deselect(): Api; } } diff --git a/types/datatables.net/datatables.net-tests.ts b/types/datatables.net/datatables.net-tests.ts index e5cb5184fd..0c9f3db3cc 100644 --- a/types/datatables.net/datatables.net-tests.ts +++ b/types/datatables.net/datatables.net-tests.ts @@ -225,7 +225,7 @@ let config: DataTables.Settings = { ], // Data ajax: "url", - data: {}, + data: [], // Features autoWidth: true, deferRender: true, diff --git a/types/datatables.net/index.d.ts b/types/datatables.net/index.d.ts index cdddc98789..c0a37145ab 100644 --- a/types/datatables.net/index.d.ts +++ b/types/datatables.net/index.d.ts @@ -28,6 +28,10 @@ declare namespace DataTables { } interface Api extends CoreMethods { + /** + * API should be array-like + */ + [key: number]: any; /** * Returns DataTables API instance * @@ -221,7 +225,7 @@ declare namespace DataTables { * @param event Event name to remove. * @param callback Specific callback function to remove if you want to unbind a single event listener. */ - off(event: string, callback?: ((e: Event, settings: Settings, json: any) => void)): Api; + off(event: string, callback?: ((e: Event, ...args: any[]) => void)): Api; /** * Table events listener. @@ -229,7 +233,7 @@ declare namespace DataTables { * @param event Event to listen for. * @param callback Specific callback function to remove if you want to unbind a single event listener. */ - on(event: string, callback: ((e: Event, settings: Settings, json: any) => void)): Api; + on(event: string, callback: ((e: Event, ...args: any[]) => void)): Api; /** * Listen for a table event once and then remove the listener. @@ -237,7 +241,7 @@ declare namespace DataTables { * @param event Event to listen for. * @param callback Specific callback function to remove if you want to unbind a single event listener. */ - one(event: string, callback: ((e: Event, settings: Settings, json: any) => void)): Api; + one(event: string, callback: ((e: Event, ...args: any[]) => void)): Api; /** * Page Methods / object @@ -1297,7 +1301,7 @@ declare namespace DataTables { /** * Data to use as the display data for the table. Since: 1.10 */ - data?: object; + data?: any[]; //#endregion "Data" @@ -1931,6 +1935,7 @@ declare namespace DataTables { } interface ColumnLegacy { + idx: number; aDataSort: any; asSorting: string[]; bSearchable: boolean;