|
| 1 | +// Type definitions for DataTables SearchBuilder |
| 2 | +// |
| 3 | +// Project: https://datatables.net/extensions/searchbuilder/, https://datatables.net |
1 | 4 |
|
2 |
| -// Dist-DataTables-SearchBuilder-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 {IDefaults, IDetails, II18n} from './searchBuilder'; |
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 | + * SearchBuilder extension options |
| 24 | + */ |
| 25 | + searchBuilder?: boolean | string[] | ConfigSearchBuilder | ConfigSearchBuilder[]; |
| 26 | + } |
| 27 | + |
| 28 | + interface ConfigLanguage { |
| 29 | + /** |
| 30 | + * SearchBuilder language options |
| 31 | + */ |
| 32 | + searchBuilder?: ConfigSearchBuilderLanguage; |
| 33 | + } |
| 34 | + |
| 35 | + interface Api<T> { |
| 36 | + /** |
| 37 | + * SearchBuilder methods container |
| 38 | + * |
| 39 | + * @returns Api for chaining with the additional SearchBuilder methods |
| 40 | + */ |
| 41 | + searchBuilder: ApiSearchBuilder<T>; |
| 42 | + } |
| 43 | + |
| 44 | + interface ApiStatic { |
| 45 | + /** |
| 46 | + * SearchBuilder class |
| 47 | + */ |
| 48 | + SearchBuilder: { |
| 49 | + /** |
| 50 | + * Create a new SearchBuilder instance for the target DataTable |
| 51 | + */ |
| 52 | + new (dt: Api<any>, settings: string[] | ConfigSearchBuilder | ConfigSearchBuilder[]); |
| 53 | + |
| 54 | + /** |
| 55 | + * SearchBuilder version |
| 56 | + */ |
| 57 | + version: string; |
| 58 | + |
| 59 | + /** |
| 60 | + * Default configuration values |
| 61 | + */ |
| 62 | + defaults: ConfigSearchBuilder; |
| 63 | + } |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | + |
| 68 | +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 69 | + * Options |
| 70 | + */ |
| 71 | + |
| 72 | +interface ConfigSearchBuilder extends Partial<IDefaults> {} |
| 73 | + |
| 74 | +interface ConfigSearchBuilderLanguage extends DeepPartial<II18n> {} |
| 75 | + |
| 76 | + |
| 77 | +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 78 | + * API |
| 79 | + */ |
| 80 | +interface ApiSearchBuilder<T> extends Api<T> { |
| 81 | + /** |
| 82 | + * Returns the node of the SearchBuilder Container |
| 83 | + */ |
| 84 | + container(): JQuery<HTMLElement>; |
| 85 | + |
| 86 | + /** |
| 87 | + * Gets the details of the current SearchBuilder setup |
| 88 | + */ |
| 89 | + getDetails(): IDetails; |
| 90 | + |
| 91 | + /** |
| 92 | + * Rebuild the search to a given state. |
| 93 | + * |
| 94 | + * @param state Object of the same structure that is returned from searchBuilder.getDetails(). |
| 95 | + * This contains all of the details needed to rebuild the state. |
| 96 | + * @returns self for chaining |
| 97 | + */ |
| 98 | + rebuild(state: IDetails): Api<T>; |
| 99 | +} |
0 commit comments