|
| 1 | +// Type definitions for DataTables KeyTable |
| 2 | +// |
| 3 | +// Project: https://datatables.net/extensions/keytable/, https://datatables.net |
| 4 | +// Definitions by: |
| 5 | +// SpryMedia |
| 6 | +// Konstantin Kuznetsov <https://github.com/Arik-neKrol> |
1 | 7 |
|
2 | | -// Dist-DataTables-KeyTable-SemanticUI integration with SemanticUI exports the DataTables API having |
3 | | -// set default values to complete the ingeration. |
4 | | -import Api from "datatables.net"; |
| 8 | +/// <reference types="jquery" /> |
5 | 9 |
|
6 | | -export default Api; |
| 10 | +import DataTables, {Api} from 'datatables.net'; |
7 | 11 |
|
| 12 | +export default DataTables; |
| 13 | + |
| 14 | +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 15 | + * DataTables' types integration |
| 16 | + */ |
| 17 | +declare module 'datatables.net' { |
| 18 | + interface Config { |
| 19 | + /** |
| 20 | + * KeyTable extension options |
| 21 | + */ |
| 22 | + keys?: boolean | ConfigKeyTable; |
| 23 | + } |
| 24 | + |
| 25 | + interface Api<T> { |
| 26 | + /** |
| 27 | + * KeyTable methods container |
| 28 | + * |
| 29 | + * @returns Api for chaining with the additional KeyTable methods |
| 30 | + */ |
| 31 | + keys: ApiKeyTableMethods<T>; |
| 32 | + } |
| 33 | + |
| 34 | + interface ApiCell<T> { |
| 35 | + /** |
| 36 | + * Blur focus from the currently focused cell |
| 37 | + */ |
| 38 | + blur(): Api<T>; |
| 39 | + } |
| 40 | + |
| 41 | + interface ApiCellMethods<T> { |
| 42 | + /** |
| 43 | + * Focus on a cell |
| 44 | + */ |
| 45 | + focus(): Api<T>; |
| 46 | + } |
| 47 | + |
| 48 | + interface ApiStatic { |
| 49 | + /** |
| 50 | + * KeyTable class |
| 51 | + */ |
| 52 | + KeyTable: { |
| 53 | + /** |
| 54 | + * Create a new KeyTable instance for the target DataTable |
| 55 | + */ |
| 56 | + new (dt: Api<any>, settings: boolean | ConfigKeyTable); |
| 57 | + |
| 58 | + /** |
| 59 | + * KeyTable version |
| 60 | + */ |
| 61 | + version: string; |
| 62 | + |
| 63 | + /** |
| 64 | + * Default configuration values |
| 65 | + */ |
| 66 | + defaults: ConfigKeyTable; |
| 67 | + } |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | + |
| 72 | +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 73 | + * Options |
| 74 | + */ |
| 75 | + |
| 76 | +interface ConfigKeyTable { |
| 77 | + /** |
| 78 | + * Allow KeyTable's focus to be blurred (removed) from a table |
| 79 | + * |
| 80 | + * When set to true this option allows the table to lose focus (i.e. to be blurred), |
| 81 | + * while false will not allow the table to lose focus. |
| 82 | + */ |
| 83 | + blurable?: boolean; |
| 84 | + |
| 85 | + /** |
| 86 | + * Set the class name used for the focused cell |
| 87 | + * |
| 88 | + * The class name to be added and removed from cells as they gain and loose focus. |
| 89 | + */ |
| 90 | + className?: string; |
| 91 | + |
| 92 | + /** |
| 93 | + * Enable / disable clipboard interaction with KeyTable |
| 94 | + * |
| 95 | + * A boolean flag that can optionally be used to disable KeyTables' clipboard interaction. |
| 96 | + */ |
| 97 | + clipboard?: boolean; |
| 98 | + |
| 99 | + /** |
| 100 | + * Set the orthogonal data point for the data to copy to clipboard. |
| 101 | + */ |
| 102 | + clipboardOrthogonal?: string; |
| 103 | + |
| 104 | + /** |
| 105 | + * Select the columns that can gain focus |
| 106 | + * |
| 107 | + * The columns that can gain focus. This accepts all of the options of column-selector |
| 108 | + * such as class name selector, jQuery pseudo selects and column index selectors. |
| 109 | + */ |
| 110 | + columns?: any; |
| 111 | + |
| 112 | + /** |
| 113 | + * Control if editing should be activated immediately upon focus |
| 114 | + * |
| 115 | + * true to enable editing on focus, false to disable. |
| 116 | + */ |
| 117 | + editOnFocus?: boolean; |
| 118 | + |
| 119 | + /** |
| 120 | + * Attach an Editor instance for Excel like editing |
| 121 | + * |
| 122 | + * The Editor instance to use for editing of the table |
| 123 | + */ |
| 124 | + editor?: any; |
| 125 | + |
| 126 | + /** |
| 127 | + * Cell to receive initial focus in the table |
| 128 | + * |
| 129 | + * The cell that will receive focus when the table is initialised. This accepts all of |
| 130 | + * the options of cell-selector such as class name selector, jQuery pseudo selects and |
| 131 | + * cell index selectors. |
| 132 | + */ |
| 133 | + focus?: any; |
| 134 | + |
| 135 | + /** |
| 136 | + * Limit the keys that KeyTable will listen for and take action on |
| 137 | + * |
| 138 | + * As null KeyTable will listen for all key presses, regardless of what key is pressed. |
| 139 | + * an array you can limit the keys that KeyTable will take action on to just the key |
| 140 | + * codes given in the array. |
| 141 | + */ |
| 142 | + keys?: number[] | null; |
| 143 | + |
| 144 | + /** |
| 145 | + * Set the table's tab index for when it will receive focus |
| 146 | + * |
| 147 | + * The tab index for the table. Like all other tab indexes, this can be -1 to disallow |
| 148 | + * tabbing into the table. |
| 149 | + */ |
| 150 | + tabIndex?: number; |
| 151 | +} |
| 152 | + |
| 153 | + |
| 154 | +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 155 | + * API |
| 156 | + */ |
| 157 | + |
| 158 | +interface ApiKeyTableMethods<T> extends Api<T> { |
| 159 | + /** |
| 160 | + * Disable KeyTable's interactions (mouse and keyboard) |
| 161 | + * |
| 162 | + * @returns DataTables API instance |
| 163 | + */ |
| 164 | + disable(): Api<T>; |
| 165 | + |
| 166 | + /** |
| 167 | + * Enable or disable KeyTable's interactions (mouse and keyboard) |
| 168 | + * |
| 169 | + * @param options This option can be given as the following values: true - Fully enable KeyTable; false - Fully disable KeyTable (keys.disable()); "navigation-only" - Respond to navigation inputs only; |
| 170 | + * @returns DataTables API instance |
| 171 | + */ |
| 172 | + enable(options?: string | boolean): Api<T>; |
| 173 | + |
| 174 | + /** |
| 175 | + * Determine if KeyTable is enabled on this table |
| 176 | + * |
| 177 | + * @returns Current state |
| 178 | + */ |
| 179 | + enabled(): boolean | 'navigation-only'; |
| 180 | + |
| 181 | + /** |
| 182 | + * Move the focus from the current cell to one adjacent to it. |
| 183 | + * |
| 184 | + * @param direction String representing the direction that the focus should move in |
| 185 | + * @returns DataTables API instance. |
| 186 | + */ |
| 187 | + move(direction: string): Api<T>; |
| 188 | +} |
0 commit comments