datatables.net-select 3.1.3 → 4.0.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/types/types.d.ts CHANGED
@@ -1,382 +1,383 @@
1
- // Type definitions for DataTables Select
2
- //
3
- // Project: https://datatables.net/extensions/select/, https://datatables.net
4
- // Definitions by:
5
- // SpryMedia
6
- // Jared Szechy <https://github.com/szechyjs>
7
-
8
- /// <reference types="jquery" />
9
-
10
- import DataTables, {ObjectColumnRender} from 'datatables.net';
11
-
12
- export default DataTables;
1
+ import DataTables, { CellIdx } from 'datatables.net';
2
+ export { default } from 'datatables.net';
13
3
 
14
4
  type StyleType = 'api' | 'single' | 'multi' | 'os' | 'multi+shift';
15
-
5
+ type Selectable = (data: any, tr: HTMLElement, idx: number) => boolean;
6
+ type HeaderCheckbox = boolean | 'none' | 'select-all' | 'select-page';
16
7
  declare module 'datatables.net' {
17
- interface Config {
18
- /*
19
- * Select extension options
20
- */
21
- select?: boolean | string | ConfigSelect;
22
- }
23
-
24
- interface ConfigLanguage {
25
- /**
26
- * Select language options
27
- */
28
- select?: ConfigSelectLanguage;
29
- }
30
-
31
- interface Api<T> {
32
- select: ApiSelect<Api<T>>
33
- }
34
-
35
- interface ApiSelectorModifier {
36
- /**
37
- * Pick rows / columns / cells which are selected
38
- */
39
- selected?: boolean | undefined;
40
- }
41
-
42
- interface ApiRowMethods<T> {
43
- /**
44
- * Blur a row
45
- */
46
- blur(): Api<T>;
47
-
48
- /**
49
- * Deselect a row
50
- */
51
- deselect(): Api<T>;
52
-
53
- /**
54
- * Keyboard focus on a row
55
- */
56
- focus(): Api<T>;
57
-
58
- /**
59
- * Select a row
60
- */
61
- select(): Api<T>;
62
- }
63
-
64
- interface ApiRowsMethods<T> {
65
- /**
66
- * Select multiple rows
67
- */
68
- select(): Api<T>;
69
-
70
- /**
71
- * Deselect a row
72
- */
73
- deselect(): Api<T>;
74
- }
75
-
76
- interface ApiCellMethods<T> {
77
- /**
78
- * Select cell
79
- */
80
- select(): Api<T>;
81
-
82
- /**
83
- * Deselect a cell
84
- */
85
- deselect(): Api<T>;
86
- }
87
-
88
- interface ApiCellsMethods<T> {
89
- /**
90
- * Select multiple cells
91
- */
92
- select(): Api<T>;
93
-
94
- /**
95
- * Deselect cells
96
- */
97
- deselect(): Api<T>;
98
- }
99
-
100
- interface DataTablesStatic {
101
- /**
102
- * Select static methods
103
- */
104
- select: {
105
- /**
106
- * Class names used by Select
107
- */
108
- classes: {
109
- /**
110
- * Class name(s) to use for the checkbox. Space separated.
111
- */
112
- checkbox: string;
113
- }
114
-
115
- /**
116
- * Initialise Select (for use on tables which were not in the document
117
- * when they were initialised).
118
- */
119
- init: <T=any>(api: Api<T>) => void;
120
-
121
- /**
122
- * Select version
123
- */
124
- version: string;
125
- }
126
- }
127
-
128
- interface DataTablesStaticRender {
129
- /**
130
- * Display a checkbox in the column's cells to be used for and represent
131
- * row selection.
132
- */
133
- select(): ObjectColumnRender;
134
-
135
- /**
136
- * Display a checkbox in the column's cells to be used for and represent
137
- * row selection, with the `value` and `name` attributes for the checkbox
138
- * `input` being set by properties from the row's data object.
139
- *
140
- * @param valueProp Name of the data property where the `value` for the
141
- * checkbox is.
142
- * @param nameProp Name of the data property where the `name` for the
143
- * checkbox is.
144
- */
145
- select(valueProp: string, nameProp: string): ObjectColumnRender;
146
- }
147
-
148
- interface Buttons {
149
- /** Select all rows in the table */
150
- selectAll: {
151
- extend: 'selectAll';
152
- selectorModifier?: ApiSelectorModifier;
153
- }
154
-
155
- /** Change selection type to cells. Shows as active when cell selection is enabled */
156
- selectCells: {
157
- extend: 'selectCells';
158
- }
159
-
160
- /** Change selection type to columns. Shows as active when cell selection is enabled */
161
- selectColumns: {
162
- extend: 'selectColumns';
163
- }
164
-
165
- /** Button which is enabled only when one or more rows are selected. Provide your own action function. */
166
- selected: {
167
- extend: 'selected';
168
- limitTo?: string[];
169
- }
170
-
171
- /** Button which is enabled only when a single row is selected. Provide your own action function. */
172
- selectedSingle: {
173
- extend: 'selected';
174
- }
175
-
176
- /** Deselect all currently selected rows. */
177
- selectNone: {
178
- extend: 'selectNone';
179
- }
180
-
181
- /** Change selection type to rows. Shows as active when cell selection is enabled */
182
- selectRows: {
183
- extend: 'selectRows';
184
- }
185
-
186
- /**
187
- * Toggle a filter that will reduce the rows displayed to just those which are selected. Uses
188
- * its own action function - don't provide your own.
189
- */
190
- showSelected: {
191
- extend: 'showSelected';
192
- }
193
- }
8
+ interface Config {
9
+ select?: boolean | string | ConfigSelect;
10
+ }
11
+ interface Defaults {
12
+ select?: boolean | string | ConfigSelect;
13
+ }
14
+ interface ConfigLanguage {
15
+ /**
16
+ * Select language options
17
+ */
18
+ select?: ConfigSelectLanguage;
19
+ }
20
+ interface Api<T> {
21
+ select: ApiSelect<Api<T>>;
22
+ }
23
+ interface ApiSelectorModifier {
24
+ /**
25
+ * Pick rows / columns / cells which are selected
26
+ */
27
+ selected?: boolean | undefined;
28
+ }
29
+ interface ApiRowMethods<T> {
30
+ /**
31
+ * Blur a row
32
+ */
33
+ blur(): ApiRowMethods<T>;
34
+ /**
35
+ * Deselect a row
36
+ */
37
+ deselect(): ApiRowMethods<T>;
38
+ /**
39
+ * Keyboard focus on a row
40
+ */
41
+ focus(): ApiRowMethods<T>;
42
+ /**
43
+ * Select a row
44
+ */
45
+ select(): ApiRowMethods<T>;
46
+ /**
47
+ * Is a row selected
48
+ */
49
+ selected(): boolean;
50
+ }
51
+ interface ApiRowsMethods<T> {
52
+ /**
53
+ * Select multiple rows
54
+ *
55
+ * @param toggle Can be false to deselect
56
+ */
57
+ select(this: ApiRowsMethods<T>, toggle?: boolean): ApiRowsMethods<T>;
58
+ /**
59
+ * Deselect a row
60
+ */
61
+ deselect(this: ApiRowsMethods<T>): ApiRowsMethods<T>;
62
+ }
63
+ interface ApiCellMethods<T> {
64
+ /**
65
+ * Select cell
66
+ */
67
+ select(): ApiCellMethods<T>;
68
+ /**
69
+ * Deselect a cell
70
+ */
71
+ deselect(): ApiCellMethods<T>;
72
+ }
73
+ interface ApiColumnsMethods<T> {
74
+ /**
75
+ * Select multiple columns
76
+ *
77
+ * @param toggle Can be false to deselect
78
+ */
79
+ select(this: ApiColumnsMethods<T>, toggle?: boolean): ApiColumnsMethods<T>;
80
+ /**
81
+ * Deselect columns
82
+ */
83
+ deselect(this: ApiColumnsMethods<T>): ApiColumnsMethods<T>;
84
+ }
85
+ interface ApiColumnMethods<T> {
86
+ /**
87
+ * Select a column
88
+ */
89
+ select(): ApiColumnMethods<T>;
90
+ /**
91
+ * Deselect a column
92
+ */
93
+ deselect(): ApiColumnMethods<T>;
94
+ }
95
+ interface ApiCellsMethods<T> {
96
+ /**
97
+ * Select multiple cells
98
+ *
99
+ * @param toggle Can be false to deselect
100
+ */
101
+ select(this: ApiCellsMethods<T>, toggle?: boolean): ApiCellsMethods<T>;
102
+ /**
103
+ * Deselect cells
104
+ */
105
+ deselect(this: ApiCellsMethods<T>): ApiCellsMethods<T>;
106
+ }
107
+ interface DataTablesStatic {
108
+ /**
109
+ * Select static methods
110
+ */
111
+ select: {
112
+ /**
113
+ * Class names used by Select
114
+ */
115
+ classes: {
116
+ /**
117
+ * Class name(s) to use for the checkbox. Space separated.
118
+ */
119
+ checkbox: string;
120
+ };
121
+ /**
122
+ * Initialise Select (for use on tables which were not in the document
123
+ * when they were initialised).
124
+ */
125
+ init: <T = any>(api: Api<T>) => void;
126
+ /**
127
+ * Select version
128
+ */
129
+ version: string;
130
+ };
131
+ }
132
+ interface DataTablesStaticRender {
133
+ /**
134
+ * Display a checkbox in the column's cells to be used for and represent
135
+ * row selection.
136
+ */
137
+ select(): any;
138
+ /**
139
+ * Display a checkbox in the column's cells to be used for and represent
140
+ * row selection, with the `value` and `name` attributes for the checkbox
141
+ * `input` being set by properties from the row's data object.
142
+ *
143
+ * @param valueProp Name of the data property where the `value` for the
144
+ * checkbox is.
145
+ * @param nameProp Name of the data property where the `name` for the
146
+ * checkbox is.
147
+ */
148
+ select(valueProp: string, nameProp: string): any;
149
+ }
150
+ interface Buttons {
151
+ /** Select all rows in the table */
152
+ selectAll: {
153
+ extend: 'selectAll';
154
+ selectorModifier?: ApiSelectorModifier;
155
+ };
156
+ /** Change selection type to cells. Shows as active when cell selection is enabled */
157
+ selectCells: {
158
+ extend: 'selectCells';
159
+ };
160
+ /** Change selection type to columns. Shows as active when cell selection is enabled */
161
+ selectColumns: {
162
+ extend: 'selectColumns';
163
+ };
164
+ /** Button which is enabled only when one or more rows are selected. Provide your own action function. */
165
+ selected: {
166
+ extend: 'selected';
167
+ limitTo?: string[];
168
+ };
169
+ /** Button which is enabled only when a single row is selected. Provide your own action function. */
170
+ selectedSingle: {
171
+ extend: 'selected';
172
+ };
173
+ /** Deselect all currently selected rows. */
174
+ selectNone: {
175
+ extend: 'selectNone';
176
+ };
177
+ /** Change selection type to rows. Shows as active when cell selection is enabled */
178
+ selectRows: {
179
+ extend: 'selectRows';
180
+ };
181
+ /**
182
+ * Toggle a filter that will reduce the rows displayed to just those which are selected. Uses
183
+ * its own action function - don't provide your own.
184
+ */
185
+ showSelected: {
186
+ extend: 'showSelected';
187
+ };
188
+ }
189
+ interface Context {
190
+ _select_lastCell: CellIdx;
191
+ _select: {
192
+ blurable?: boolean;
193
+ className?: string;
194
+ info?: boolean;
195
+ infoEls: HTMLElement[];
196
+ items?: string;
197
+ keys?: boolean;
198
+ keysWrap?: boolean;
199
+ selector?: string;
200
+ selectable?: Selectable;
201
+ style?: string;
202
+ toggleable?: boolean;
203
+ };
204
+ _select_mode: 'additive' | 'subtractive';
205
+ _select_set: string[];
206
+ _select_init: boolean;
207
+ }
208
+ interface RowContext {
209
+ _select_selected: boolean;
210
+ _selected_cells: boolean[];
211
+ }
212
+ interface ColumnContext {
213
+ _select_selected: boolean;
214
+ }
194
215
  }
195
-
196
216
  interface ConfigSelect {
197
- /**
198
- * Indicate if the selected items will be removed when clicking outside of the table
199
- */
200
- blurable?: boolean;
201
-
202
- /**
203
- * Set the class name that will be applied to selected items
204
- */
205
- className?: string;
206
-
207
- /** Control automatic addition of header checkbox */
208
- headerCheckbox?: boolean | 'none' | 'select-all' | 'select-page';
209
-
210
- /**
211
- * Enable / disable the display for item selection information in the table summary
212
- */
213
- info?: boolean;
214
-
215
- /**
216
- * Set which table items to select (rows, columns or cells)
217
- */
218
- items?: string;
219
-
220
- /** Set keyboard accessability (tab and arrow keys) */
221
- keys?: boolean;
222
-
223
- /** Allow keyboard navigation to wrap */
224
- keysWrap?: boolean;
225
-
226
- /** Set a function that will determine if a row should be selectable. */
227
- selectable?: (data: any, tr: HTMLTableRowElement | null, index: number) => boolean;
228
-
229
- /**
230
- * Set the element selector used for mouse event capture to select items
231
- */
232
- selector?: string;
233
-
234
- /**
235
- * Set the selection style for end user interaction with the table
236
- */
237
- style?: StyleType;
238
-
239
- /** Disable the deselection of selected rows when clicked */
240
- toggleable?: boolean;
217
+ /**
218
+ * Indicate if the selected items will be removed when clicking outside of the table
219
+ */
220
+ blurable?: boolean;
221
+ /**
222
+ * Set the class name that will be applied to selected items
223
+ */
224
+ className?: string;
225
+ /** Control automatic addition of header checkbox */
226
+ headerCheckbox?: HeaderCheckbox;
227
+ /**
228
+ * Enable / disable the display for item selection information in the table summary
229
+ */
230
+ info?: boolean;
231
+ /**
232
+ * Set which table items to select (rows, columns or cells)
233
+ */
234
+ items?: string;
235
+ /** Set keyboard accessability (tab and arrow keys) */
236
+ keys?: boolean;
237
+ /** Allow keyboard navigation to wrap */
238
+ keysWrap?: boolean;
239
+ /** Set a function that will determine if a row should be selectable. */
240
+ selectable?: (data: any, tr: HTMLTableRowElement | null, index: number) => boolean;
241
+ /**
242
+ * Set the element selector used for mouse event capture to select items
243
+ */
244
+ selector?: string;
245
+ /**
246
+ * Set the selection style for end user interaction with the table
247
+ */
248
+ style?: StyleType;
249
+ /** Disable the deselection of selected rows when clicked */
250
+ toggleable?: boolean;
241
251
  }
242
-
243
252
  interface ConfigSelectLanguage {
244
- /** AIRA strings */
245
- aria?: {
246
- /** Text to use as the aria-label for the header checkbox */
247
- headerCheckbox?: string;
248
-
249
- /** Text to use as the aria-label for the row selection checkboxes */
250
- rowCheckbox?: string;
251
- };
252
-
253
- /** Table information summary string for the number of cells selected */
254
- cells?: string | IPlural;
255
-
256
- /** Table information summary string for the number of columns selected */
257
- columns?: string | IPlural;
258
-
259
- /** Table information summary string for the number of rows selected */
260
- rows?: string | IPlural;
253
+ /** AIRA strings */
254
+ aria?: {
255
+ /** Text to use as the aria-label for the header checkbox */
256
+ headerCheckbox?: string;
257
+ /** Text to use as the aria-label for the row selection checkboxes */
258
+ rowCheckbox?: string;
259
+ };
260
+ /** Table information summary string for the number of cells selected */
261
+ cells?: string | IPlural;
262
+ /** Table information summary string for the number of columns selected */
263
+ columns?: string | IPlural;
264
+ /** Table information summary string for the number of rows selected */
265
+ rows?: string | IPlural;
261
266
  }
262
-
263
267
  interface ApiSelect<Api> {
264
- /**
265
- * Initialise Select for a DataTable after the DataTable has been constructed.
266
- *
267
- * @returns DataTables Api instance
268
- */
269
- (): Api;
270
-
271
- /**
272
- * Get the blurable state for the table.
273
- *
274
- * @returns Current state - true if blurable, false otherwise. Note that if multiple tables are defined in the API's context, only the blurable state of the first table will be returned.
275
- */
276
- blurable(): boolean;
277
-
278
- /**
279
- * Set the blurable state for the table's selection options.
280
- *
281
- * @param flag Value to set for the blurable option - true to enable, false to disable.
282
- * @returns DataTables Api instance for chaining
283
- */
284
- blurable(flag: boolean): Api;
285
-
286
- /**
287
- * Get the summary information display state for the table.
288
- *
289
- * @returns Current state - true if information summary shown, false otherwise. Note that if multiple tables are defined in the API's context, only the information state of the first table will be returned.
290
- */
291
- info(): boolean;
292
-
293
- /**
294
- * Set the information summary display state for the table's selection options.
295
- *
296
- * @param flag Value to set for the information summary display state - true to enable, false to disable.
297
- * @returns DataTables API instance for chaining.
298
- */
299
- info(flag: boolean): Api;
300
-
301
- /**
302
- * Get the items that will be selected by user interaction (i.e. a click on the table).
303
- *
304
- * @returns The current item that will be selected when the user interacts with Select's event listeners - this will be the value row, column or cell.
305
- */
306
- items(): string;
307
-
308
- /**
309
- * Set the item type that will be selected by user interaction.
310
- *
311
- * @param set Items to select - this must be one of row, column or cells.
312
- * @returns DataTables API instance for chaining.
313
- */
314
- items(set: string): Api;
315
-
316
- /**
317
- * Get Select's keyboard navigation state
318
- *
319
- * @returns The keyboard navigation state of Select
320
- */
321
- keys(): boolean;
322
-
323
- /**
324
- * Set Select's keyboard navigation state
325
- *
326
- * @param set Enable (true) or disable (false) row keyboard navigation
327
- * @returns DataTables API instance for chaining.
328
- */
329
- keys(set: boolean): Api;
330
-
331
- /**
332
- * Get the current item selector string applied to the table.
333
- *
334
- * @returns the item selector string being used for the table.
335
- */
336
- selector(): string;
337
-
338
- /**
339
- * Set the table's item selector string. Note that any old selectors will be automatically removed if this is used as a selector to ensure that there are no memory leaks in unattached event listeners.
340
- *
341
- * @param set jQuery selector that will select the cells that can trigger item selection.
342
- */
343
- selector(set: string): Api;
344
-
345
- /**
346
- * Get the current selection style applied to the table
347
- *
348
- * @returns The current selection style, this will be one of "api", "single", "multi" or "os".
349
- */
350
- style(): string;
351
-
352
- /**
353
- * Set the table's selection style
354
- *
355
- * @param s Selection style to set - this must be one of "api", "single", "multi" or "os".
356
- * @returns DataTables API instance for chaining.
357
- */
358
- style(s: StyleType): Api;
359
-
360
- /**
361
- * Get the toggle state of Select for the given DataTable.
362
- *
363
- * @returns true if the item can be deselected when clicked on, false if it cannot be.
364
- */
365
- toggleable(): boolean;
366
-
367
- /**
368
- * Set the toggle state of Select for the DataTable.
369
- *
370
- * @param set true to allow item deselection, false to disallow.
371
- * @returns DataTables API instance for chaining.
372
- */
373
- toggleable(set: boolean): Api;
268
+ /**
269
+ * Initialise Select for a DataTable after the DataTable has been constructed.
270
+ *
271
+ * @returns DataTables Api instance
272
+ */
273
+ (): Api;
274
+ /**
275
+ * Get the blurable state for the table.
276
+ *
277
+ * @returns Current state - true if blurable, false otherwise. Note that if multiple tables are defined in the API's context, only the blurable state of the first table will be returned.
278
+ */
279
+ blurable(): boolean;
280
+ /**
281
+ * Set the blurable state for the table's selection options.
282
+ *
283
+ * @param flag Value to set for the blurable option - true to enable, false to disable.
284
+ * @returns DataTables Api instance for chaining
285
+ */
286
+ blurable(flag: boolean): Api;
287
+ /**
288
+ * Get the summary information display state for the table.
289
+ *
290
+ * @returns Current state - true if information summary shown, false otherwise. Note that if multiple tables are defined in the API's context, only the information state of the first table will be returned.
291
+ */
292
+ info(): boolean;
293
+ /**
294
+ * Set the information summary display state for the table's selection options.
295
+ *
296
+ * @param flag Value to set for the information summary display state - true to enable, false to disable.
297
+ * @returns DataTables API instance for chaining.
298
+ */
299
+ info(flag: boolean): Api;
300
+ /**
301
+ * Get the items that will be selected by user interaction (i.e. a click on the table).
302
+ *
303
+ * @returns The current item that will be selected when the user interacts with Select's event listeners - this will be the value row, column or cell.
304
+ */
305
+ items(): string;
306
+ /**
307
+ * Set the item type that will be selected by user interaction.
308
+ *
309
+ * @param set Items to select - this must be one of row, column or cells.
310
+ * @returns DataTables API instance for chaining.
311
+ */
312
+ items(set: string): Api;
313
+ /**
314
+ * Get Select's keyboard navigation state
315
+ *
316
+ * @returns The keyboard navigation state of Select
317
+ */
318
+ keys(): boolean;
319
+ /**
320
+ * Set Select's keyboard navigation state
321
+ *
322
+ * @param set Enable (true) or disable (false) row keyboard navigation
323
+ * @param wrap Allow wrapping or not (default)
324
+ * @returns DataTables API instance for chaining.
325
+ */
326
+ keys(set: boolean, wrap?: boolean): Api;
327
+ /**
328
+ * Get the function used to determine if a row should be selectable.
329
+ */
330
+ selectable(): Selectable;
331
+ /**
332
+ * Set the function used to determine if a row should be selectable.
333
+ *
334
+ * @param set Function
335
+ */
336
+ selectable(set: Selectable): Api;
337
+ /**
338
+ * Get the current item selector string applied to the table.
339
+ *
340
+ * @returns the item selector string being used for the table.
341
+ */
342
+ selector(): string;
343
+ /**
344
+ * Set the table's item selector string. Note that any old selectors will be automatically removed if this is used as a selector to ensure that there are no memory leaks in unattached event listeners.
345
+ *
346
+ * @param set jQuery selector that will select the cells that can trigger item selection.
347
+ */
348
+ selector(set: string): Api;
349
+ /**
350
+ * Get the current selection style applied to the table
351
+ *
352
+ * @returns The current selection style, this will be one of "api", "single", "multi" or "os".
353
+ */
354
+ style(): StyleType;
355
+ /**
356
+ * Set the table's selection style
357
+ *
358
+ * @param s Selection style to set - this must be one of "api", "single", "multi" or "os".
359
+ * @returns DataTables API instance for chaining.
360
+ */
361
+ style(s: StyleType): Api;
362
+ /**
363
+ * Get the toggle state of Select for the given DataTable.
364
+ *
365
+ * @returns true if the item can be deselected when clicked on, false if it cannot be.
366
+ */
367
+ toggleable(): boolean;
368
+ /**
369
+ * Set the toggle state of Select for the DataTable.
370
+ *
371
+ * @param set true to allow item deselection, false to disallow.
372
+ * @returns DataTables API instance for chaining.
373
+ */
374
+ toggleable(set: boolean): Api;
374
375
  }
375
-
376
376
  interface IPlural {
377
- /** Default if there is no specific number given. Use %d where you want the number to show */
378
- _: string;
379
-
380
- /** Specific replacement, e.g. for 0 or 1 commonly. */
381
- [num: number]: string;
377
+ /** Default if there is no specific number given. Use %d where you want the number to show */
378
+ _: string;
379
+ /** Specific replacement, e.g. for 0 or 1 commonly. */
380
+ [num: number]: string;
382
381
  }
382
+
383
+ export type { HeaderCheckbox, Selectable, StyleType };