|
| 1 | +// Type definitions for DataTables SearchPanes |
| 2 | +// |
| 3 | +// Project: https://datatables.net/extensions/SearchPanes/, https://datatables.net |
1 | 4 |
|
2 |
| -// Dist-DataTables-SearchPanes-Bootstrap4 integration with Bootstrap4 exports the DataTables API having |
3 |
| -// set default values to complete the ingeration. |
4 |
| -import Api from "datatables.net"; |
| 5 | +/// <reference types="jquery" /> |
5 | 6 |
|
6 |
| -export default Api; |
| 7 | +import DataTables, {Api} from 'datatables.net'; |
| 8 | +import * as paneType from './paneType'; |
7 | 9 |
|
| 10 | +export default DataTables; |
| 11 | + |
| 12 | +type DeepPartial<T> = T extends object ? { |
| 13 | + [P in keyof T]?: DeepPartial<T[P]>; |
| 14 | +} : T; |
| 15 | + |
| 16 | + |
| 17 | +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 18 | + * DataTables' types integration |
| 19 | + */ |
| 20 | +declare module 'datatables.net' { |
| 21 | + interface Config { |
| 22 | + /** |
| 23 | + * SearchPanes extension options |
| 24 | + */ |
| 25 | + searchPanes?: boolean | string[] | ConfigSearchPanes | ConfigSearchPanes[]; |
| 26 | + } |
| 27 | + |
| 28 | + interface ConfigLanguage { |
| 29 | + /** |
| 30 | + * SearchBuilder language options |
| 31 | + */ |
| 32 | + searchPanes?: ConfigSearchPanesLanguage; |
| 33 | + } |
| 34 | + |
| 35 | + interface Api<T> { |
| 36 | + /** |
| 37 | + * SearchPanes methods container |
| 38 | + * |
| 39 | + * @returns Api for chaining with the additional SearchPanes methods |
| 40 | + */ |
| 41 | + searchPanes: ApiSearchPanes<T>; |
| 42 | + } |
| 43 | + |
| 44 | + interface ApiStatic { |
| 45 | + /** |
| 46 | + * SearchPanes class |
| 47 | + */ |
| 48 | + SearchPanes: { |
| 49 | + /** |
| 50 | + * Create a new SearchPanes instance for the target DataTable |
| 51 | + */ |
| 52 | + new (dt: Api<any>, settings: string[] | ConfigSearchPanes | ConfigSearchPanes[]); |
| 53 | + |
| 54 | + /** |
| 55 | + * SearchPanes version |
| 56 | + */ |
| 57 | + version: string; |
| 58 | + |
| 59 | + /** |
| 60 | + * Default configuration values |
| 61 | + */ |
| 62 | + defaults: ConfigSearchPanes; |
| 63 | + } |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | + |
| 68 | +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 69 | + * Options |
| 70 | + */ |
| 71 | + |
| 72 | +interface ConfigSearchPanes extends DeepPartial<paneType.IDefaults> {} |
| 73 | + |
| 74 | +interface ConfigSearchPanesLanguage extends DeepPartial<paneType.IDefaults['i18n']> {} |
| 75 | + |
| 76 | + |
| 77 | +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 78 | + * API |
| 79 | + */ |
| 80 | +interface ApiSearchPanes<T> extends Api<T> { |
| 81 | + /** |
| 82 | + * Clears the selections in all of the panes |
| 83 | + * |
| 84 | + * @returns self for chaining |
| 85 | + */ |
| 86 | + clearSelections(): Api<T>; |
| 87 | + |
| 88 | + /** |
| 89 | + * Returns the node of the SearchPanes container |
| 90 | + * |
| 91 | + * @returns The node of the SearchPanes container |
| 92 | + */ |
| 93 | + container(): JQuery<HTMLElement>; |
| 94 | + |
| 95 | + /** |
| 96 | + * Rebuilds the SearchPanes, regathering the options from the table. |
| 97 | + * |
| 98 | + * @param index Optional. The index of a specific pane to rebuild |
| 99 | + * @param maintainSelect Optional. Whether to remake the selections once the pane has been rebuilt. |
| 100 | + * @returns self for chaining |
| 101 | + */ |
| 102 | + rebuildPane(index?: number, maintainSelect?: boolean): Api<T>; |
| 103 | + |
| 104 | + /** |
| 105 | + * Resize all of the SearchPanes to fill the container appropriately. |
| 106 | + * |
| 107 | + * @returns self for chaining |
| 108 | + */ |
| 109 | + resizePanes(): Api<T>; |
| 110 | +} |
0 commit comments