datatables.net-select 2.1.0 → 3.0.1

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/Readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Select for DataTables
2
2
 
3
- This package contains distribution files for the [Select extension](https://datatables.net/extensions/select) for [DataTables](https://datatables.net/). Only the core software for this library is contained in this package - to be correctly styled, a styling package for Select must also be included. Styling options include DataTable's native styling, [Bootstrap](http://getbootstrap.com) and [Foundation](http://foundation.zurb.com/).
3
+ This is the distribution package for the [Select extension](https://datatables.net/extensions/select) for [DataTables](https://datatables.net/). Only the core software for this library is contained in this package - to be correctly styled, a styling package for Select must also be included. Please see the [npm installation documentation on the DataTables site](https://datatables.net/manual/installation#Node.js-/-NPM) for full details.
4
4
 
5
5
  Select provides table item selection capabilities - rows, columns and cells can be selected individually or collectively. Complex selection operations such as operating system style selection (ctrl/cmd and shift click) for multiple rows can be enabled with a single option for a DataTable.
6
6
 
@@ -9,42 +9,37 @@ Select provides table item selection capabilities - rows, columns and cells can
9
9
 
10
10
  ### Browser
11
11
 
12
- For inclusion of this library using a standard `<script>` tag, rather than using this package, it is recommended that you use the [DataTables download builder](//datatables.net/download) which can create CDN or locally hosted packages for you, will all dependencies satisfied.
12
+ To use DataTables with a simple `<script>` tag, rather than using this package, it is recommended that you use the [DataTables download builder](//datatables.net/download) which can create CDN or locally hosted packages for you, will all dependencies satisfied.
13
13
 
14
14
  ### npm
15
15
 
16
+ For installation via npm, yarn and other similar package managers, install this package with your package manager - e.g.:
17
+
16
18
  ```
19
+ npm install datatables.net
17
20
  npm install datatables.net-select
18
21
  ```
19
22
 
20
- ES3 Syntax
21
- ```
22
- var $ = require( 'jquery' );
23
- require( 'datatables.net-select' )( window, $ );
24
- ```
23
+ Then, to load and initialise DataTables and Select in your code use:
25
24
 
26
- ES6 Syntax
27
25
  ```
26
+ import DataTable from 'datatables.net';
28
27
  import 'datatables.net-select'
29
- ```
30
28
 
31
- ### bower
32
-
33
- ```
34
- bower install --save datatables.net-select
29
+ new DataTable('#myTable', {
30
+ // initialisation options
31
+ });
35
32
  ```
36
33
 
37
34
 
38
-
39
35
  ## Documentation
40
36
 
41
- Full documentation and examples for Select can be found [on the website](https://datatables.net/extensions/select).
37
+ Full documentation and examples for Select can be found [on the DataTables website](https://datatables.net/extensions/select).
42
38
 
43
39
  ## Bug / Support
44
40
 
45
41
  Support for DataTables is available through the [DataTables forums](//datatables.net/forums) and [commercial support options](//datatables.net/support) are available.
46
42
 
47
-
48
43
  ### Contributing
49
44
 
50
45
  If you are thinking of contributing code to DataTables, first of all, thank you! All fixes, patches and enhancements to DataTables are very warmly welcomed. This repository is a distribution repo, so patches and issues sent to this repo will not be accepted. Instead, please direct pull requests to the [DataTables/Select](http://github.com/DataTables/Select). For issues / bugs, please direct your questions to the [DataTables forums](//datatables.net/forums).
@@ -1,4 +1,4 @@
1
- /*! Select for DataTables 2.1.0
1
+ /*! Select for DataTables 3.0.1
2
2
  * © SpryMedia Ltd - datatables.net/license/mit
3
3
  */
4
4
 
@@ -56,7 +56,7 @@ DataTable.select.classes = {
56
56
  checkbox: 'dt-select-checkbox'
57
57
  };
58
58
 
59
- DataTable.select.version = '2.1.0';
59
+ DataTable.select.version = '3.0.1';
60
60
 
61
61
  DataTable.select.init = function (dt) {
62
62
  var ctx = dt.settings()[0];
@@ -132,6 +132,7 @@ DataTable.select.init = function (dt) {
132
132
  var className = 'selected';
133
133
  var headerCheckbox = true;
134
134
  var setStyle = false;
135
+ var keys = false;
135
136
 
136
137
  ctx._select = {
137
138
  infoEls: []
@@ -187,6 +188,10 @@ DataTable.select.init = function (dt) {
187
188
  if (opts.selectable !== undefined) {
188
189
  selectable = opts.selectable;
189
190
  }
191
+
192
+ if (opts.keys !== undefined) {
193
+ keys = opts.keys;
194
+ }
190
195
  }
191
196
 
192
197
  dt.select.selector(selector);
@@ -195,6 +200,7 @@ DataTable.select.init = function (dt) {
195
200
  dt.select.blurable(blurable);
196
201
  dt.select.toggleable(toggleable);
197
202
  dt.select.info(info);
203
+ dt.select.keys(keys);
198
204
  dt.select.selectable(selectable);
199
205
  ctx._select.className = className;
200
206
 
@@ -574,14 +580,18 @@ function info(api, node) {
574
580
  return;
575
581
  }
576
582
 
577
- // If _select_set has any length, then ids are available and should be used
578
- // as the counter. Otherwise use the API to workout how many rows are
579
- // selected.
580
- var rowSetLength = api.settings()[0]._select_set.length;
583
+ var ctx = api.settings()[0];
584
+ var rowSetLength = ctx._select_set.length;
581
585
  var rows = rowSetLength ? rowSetLength : api.rows({ selected: true }).count();
582
586
  var columns = api.columns({ selected: true }).count();
583
587
  var cells = api.cells({ selected: true }).count();
584
588
 
589
+ // If subtractive selection, then we need to take the number of rows and
590
+ // subtract those that have been deselected
591
+ if (ctx._select_mode === 'subtractive') {
592
+ rows = api.page.info().recordsDisplay - rowSetLength;
593
+ }
594
+
585
595
  var add = function (el, name, num) {
586
596
  el.append(
587
597
  $('<span class="select-item"/>').append(
@@ -631,7 +641,14 @@ function initCheckboxHeader( dt, headerCheckbox ) {
631
641
  if (! isCheckboxColumn(col)) {
632
642
  return;
633
643
  }
644
+
634
645
  var header = dt.column(idx).header();
646
+ var liner = $('div.dt-column-header', header);
647
+
648
+ // DataTables 2.3 as an extra wrapper element
649
+ if (liner.length) {
650
+ header = liner;
651
+ }
635
652
 
636
653
  if (! $('input', header).length) {
637
654
  // If no checkbox yet, insert one
@@ -646,7 +663,8 @@ function initCheckboxHeader( dt, headerCheckbox ) {
646
663
  if (this.checked) {
647
664
  if (headerCheckbox == 'select-page') {
648
665
  dt.rows({page: 'current'}).select();
649
- } else {
666
+ }
667
+ else {
650
668
  dt.rows({search: 'applied'}).select();
651
669
  }
652
670
  }
@@ -690,6 +708,140 @@ function initCheckboxHeader( dt, headerCheckbox ) {
690
708
  });
691
709
  }
692
710
 
711
+ function keysSet(dt) {
712
+ var ctx = dt.settings()[0];
713
+ var flag = ctx._select.keys;
714
+ var namespace = 'dts-keys-' + ctx.sTableId;
715
+
716
+ if (flag) {
717
+ // Need a tabindex of the `tr` elements to make them focusable by the browser
718
+ $(dt.rows({page: 'current'}).nodes()).attr('tabindex', 0);
719
+
720
+ dt.on('draw.' + namespace, function () {
721
+ $(dt.rows({page: 'current'}).nodes()).attr('tabindex', 0);
722
+ });
723
+
724
+ // Listen on document for tab, up and down
725
+ $(document).on('keydown.' + namespace, function (e) {
726
+ var key = e.keyCode;
727
+ var active = document.activeElement;
728
+
729
+ // Can't use e.key as it wasn't widely supported until 2017
730
+ // 9 Tab
731
+ // 13 Return
732
+ // 32 Space
733
+ // 38 ArrowUp
734
+ // 40 ArrowDown
735
+ if (! [9, 13, 32, 38, 40].includes(key)) {
736
+ return;
737
+ }
738
+
739
+ var nodes = dt.rows({page: 'current'}).nodes().toArray();
740
+ var idx = nodes.indexOf(active);
741
+ var preventDefault = true;
742
+
743
+ // Only take an action if a row has focus
744
+ if (idx === -1) {
745
+ return;
746
+ }
747
+
748
+ if (key === 9) {
749
+ // Tab focus change
750
+ if (e.shift === false && idx === nodes.length - 1) {
751
+ keysPageDown(dt);
752
+ }
753
+ else if (e.shift === true && idx === 0) {
754
+ keysPageUp(dt);
755
+ }
756
+ else {
757
+ // Browser will do it for us
758
+ preventDefault = false;
759
+ }
760
+ }
761
+ else if (key === 13 || key === 32) {
762
+ // Row selection / deselection
763
+ var row = dt.row(active);
764
+
765
+ if (row.selected()) {
766
+ row.deselect();
767
+ }
768
+ else {
769
+ row.select();
770
+ }
771
+ }
772
+ else if (key === 38) {
773
+ // Move up
774
+ if (idx > 0) {
775
+ nodes[idx-1].focus();
776
+ }
777
+ else {
778
+ keysPageUp(dt);
779
+ }
780
+ }
781
+ else {
782
+ // Move down
783
+ if (idx < nodes.length -1) {
784
+ nodes[idx+1].focus();
785
+ }
786
+ else {
787
+ keysPageDown(dt);
788
+ }
789
+ }
790
+
791
+ if (preventDefault) {
792
+ e.stopPropagation();
793
+ e.preventDefault();
794
+ }
795
+ });
796
+ }
797
+ else {
798
+ // Stop the rows from being able to gain focus
799
+ $(dt.rows().nodes()).removeAttr('tabindex');
800
+
801
+ // Nuke events
802
+ dt.off('draw.' + namespace);
803
+ $(document).off('keydown.' + namespace);
804
+ }
805
+ }
806
+
807
+ /**
808
+ * Change to the next page and focus on the first row
809
+ *
810
+ * @param {DataTable.Api} dt DataTable instance
811
+ */
812
+ function keysPageDown(dt) {
813
+ // Is there another page to turn to?
814
+ var info = dt.page.info();
815
+
816
+ if (info.page < info.pages - 1) {
817
+ dt
818
+ .one('draw', function () {
819
+ dt.row(':first-child').node().focus();
820
+ })
821
+ .page('next')
822
+ .draw(false);
823
+ }
824
+ }
825
+
826
+ /**
827
+ * Change to the previous page and focus on the last row
828
+ *
829
+ * @param {DataTable.Api} dt DataTable instance
830
+ */
831
+ function keysPageUp(dt) {
832
+ // Is there another page to turn to?
833
+ var info = dt.page.info();
834
+
835
+ if (info.page > 0) {
836
+ dt
837
+ .one('draw', function () {
838
+ dt.row(':last-child').node().focus();
839
+ })
840
+ .page('previous')
841
+ .draw(false);
842
+ }
843
+ }
844
+
693
845
  /**
694
846
  * Determine the counts used to define the header checkbox's state
695
847
  *
@@ -752,7 +904,10 @@ function init(ctx) {
752
904
  var api = new DataTable.Api(ctx);
753
905
  ctx._select_init = true;
754
906
 
755
- // _select_set contains a list of the ids of all rows that are selected
907
+ // When `additive` then `_select_set` contains a list of the row ids that
908
+ // are selected. If `subtractive` then all rows are selected, except those
909
+ // in `_select_set`, which is a list of ids.
910
+ ctx._select_mode = 'additive';
756
911
  ctx._select_set = [];
757
912
 
758
913
  // Row callback so that classes can be added to rows and cells if the item
@@ -770,7 +925,8 @@ function init(ctx) {
770
925
  // Row
771
926
  if (
772
927
  d._select_selected ||
773
- (id !== 'undefined' && ctx._select_set.includes(id))
928
+ (ctx._select_mode === 'additive' && ctx._select_set.includes(id)) ||
929
+ (ctx._select_mode === 'subtractive' && ! ctx._select_set.includes(id))
774
930
  ) {
775
931
  d._select_selected = true;
776
932
 
@@ -980,7 +1136,16 @@ function _cumulativeEvents(api) {
980
1136
 
981
1137
  var ctx = api.settings()[0];
982
1138
 
983
- _add(api, ctx._select_set, indexes);
1139
+ if (ctx._select_mode === 'additive') {
1140
+ // Add row to the selection list if it isn't already there
1141
+ _add(api, ctx._select_set, indexes);
1142
+ }
1143
+ else {
1144
+ // Subtractive - if a row is selected it should not in the list
1145
+ // as in subtractive mode the list gives the rows which are not
1146
+ // selected
1147
+ _remove(api, ctx._select_set, indexes);
1148
+ }
984
1149
  });
985
1150
 
986
1151
  api.on('deselect', function (e, dt, type, indexes) {
@@ -991,7 +1156,14 @@ function _cumulativeEvents(api) {
991
1156
 
992
1157
  var ctx = api.settings()[0];
993
1158
 
994
- _remove(api, ctx._select_set, indexes);
1159
+ if (ctx._select_mode === 'additive') {
1160
+ // List is of those rows selected, so remove it
1161
+ _remove(api, ctx._select_set, indexes);
1162
+ }
1163
+ else {
1164
+ // List is of rows which are deselected, so add it!
1165
+ _add(api, ctx._select_set, indexes);
1166
+ }
995
1167
  });
996
1168
  }
997
1169
 
@@ -1143,6 +1315,22 @@ apiRegister('select.items()', function (items) {
1143
1315
  });
1144
1316
  });
1145
1317
 
1318
+ apiRegister('select.keys()', function (flag) {
1319
+ if (flag === undefined) {
1320
+ return this.context[0]._select.keys;
1321
+ }
1322
+
1323
+ return this.iterator('table', function (ctx) {
1324
+ if (!ctx._select) {
1325
+ DataTable.select.init(new DataTable.Api(ctx));
1326
+ }
1327
+
1328
+ ctx._select.keys = flag;
1329
+
1330
+ keysSet(new DataTable.Api(ctx));
1331
+ });
1332
+ });
1333
+
1146
1334
  // Takes effect from the _next_ selection. None disables future selection, but
1147
1335
  // does not clear the current selection. Use the `deselect` methods for that
1148
1336
  apiRegister('select.style()', function (style) {
@@ -1226,12 +1414,45 @@ apiRegister('select.last()', function (set) {
1226
1414
  return ctx._select_lastCell;
1227
1415
  });
1228
1416
 
1229
- apiRegister('select.cumulative()', function () {
1417
+ apiRegister('select.cumulative()', function (mode) {
1418
+ if (mode) {
1419
+ return this.iterator('table', function (ctx) {
1420
+ if (ctx._select_mode === mode) {
1421
+ return;
1422
+ }
1423
+
1424
+ var dt = new DataTable.Api(ctx);
1425
+
1426
+ // Convert from the current mode, to the new
1427
+ if (mode === 'subtractive') {
1428
+ // For subtractive mode we track the row ids which are not selected
1429
+ var unselected = dt.rows({selected: false}).ids().toArray();
1430
+
1431
+ ctx._select_mode = mode;
1432
+ ctx._select_set.length = 0;
1433
+ ctx._select_set.push.apply(ctx._select_set, unselected);
1434
+ }
1435
+ else {
1436
+ // Switching to additive, so selected rows are to be used
1437
+ var selected = dt.rows({selected: true}).ids().toArray();
1438
+
1439
+ ctx._select_mode = mode;
1440
+ ctx._select_set.length = 0;
1441
+ ctx._select_set.push.apply(ctx._select_set, selected);
1442
+ }
1443
+ }).draw(false);
1444
+ }
1445
+
1230
1446
  let ctx = this.context[0];
1231
1447
 
1232
- return ctx && ctx._select_set
1233
- ? ctx._select_set
1234
- : [];
1448
+ if (ctx && ctx._select_set) {
1449
+ return {
1450
+ mode: ctx._select_mode,
1451
+ rows: ctx._select_set
1452
+ };
1453
+ }
1454
+
1455
+ return null;
1235
1456
  });
1236
1457
 
1237
1458
  apiRegisterPlural('rows().select()', 'row().select()', function (select) {
@@ -1306,6 +1527,22 @@ apiRegister('row().selected()', function () {
1306
1527
  return false;
1307
1528
  });
1308
1529
 
1530
+ apiRegister('row().focus()', function () {
1531
+ var ctx = this.context[0];
1532
+
1533
+ if (ctx && this.length && ctx.aoData[this[0]] && ctx.aoData[this[0]].nTr) {
1534
+ ctx.aoData[this[0]].nTr.focus();
1535
+ }
1536
+ });
1537
+
1538
+ apiRegister('row().blur()', function () {
1539
+ var ctx = this.context[0];
1540
+
1541
+ if (ctx && this.length && ctx.aoData[this[0]] && ctx.aoData[this[0]].nTr) {
1542
+ ctx.aoData[this[0]].nTr.blur();
1543
+ }
1544
+ });
1545
+
1309
1546
  apiRegisterPlural('columns().select()', 'column().select()', function (select) {
1310
1547
  var api = this;
1311
1548
 
@@ -1,4 +1,4 @@
1
- /*! Select for DataTables 2.1.0
1
+ /*! Select for DataTables 3.0.1
2
2
  * © SpryMedia Ltd - datatables.net/license/mit
3
3
  */
4
- !function(l){var s,c;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return l(e,window,document)}):"object"==typeof exports?(s=require("jquery"),c=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||s(e),c(e,t),l(t,e,e.document)}:(c(window,s),module.exports=l(s,window,window.document))):l(jQuery,window,document)}(function(m,i,e){"use strict";var p=m.fn.dataTable;function r(n,e,t){function l(t,l){l<t&&(e=l,l=t,t=e);var e,s=!1;return n.columns(":visible").indexes().filter(function(e){return e===t&&(s=!0),e===l?!(s=!1):s})}function s(t,l){var e,s=n.rows({search:"applied"}).indexes(),c=(s.indexOf(t)>s.indexOf(l)&&(e=l,l=t,t=e),!1);return s.filter(function(e){return e===t&&(c=!0),e===l?!(c=!1):c})}var c,t=n.cells({selected:!0}).any()||t?(c=l(t.column,e.column),s(t.row,e.row)):(c=l(0,e.column),s(0,e.row)),t=n.cells(t,c).flatten();n.cells(e,{selected:!0}).any()?n.cells(t).deselect():n.cells(t).select()}function v(e){var t=p.select.classes.checkbox;return e?t.replace(/ /g,"."):t}function c(e){var t=e.settings()[0]._select.selector;m(e.table().container()).off("mousedown.dtSelect",t).off("mouseup.dtSelect",t).off("click.dtSelect",t),m("body").off("click.dtSelect"+_(e.table().node()))}function n(o){var a,t=m(o.table().container()),l=o.settings()[0],s=l._select.selector;t.on("mousedown.dtSelect",s,function(e){(e.shiftKey||e.metaKey||e.ctrlKey)&&t.css("-moz-user-select","none").one("selectstart.dtSelect",s,function(){return!1}),i.getSelection&&(a=i.getSelection())}).on("mouseup.dtSelect",s,function(){t.css("-moz-user-select","")}).on("click.dtSelect",s,function(e){var t,l=o.select.items();if(a){var s=i.getSelection();if((!s.anchorNode||m(s.anchorNode).closest("table")[0]===o.table().node())&&s!==a)return}var c,s=o.settings()[0],n=o.table().container();m(e.target).closest("div.dt-container")[0]==n&&(n=o.cell(m(e.target).closest("td, th"))).any()&&(c=m.Event("user-select.dt"),u(o,c,[l,n,e]),c.isDefaultPrevented()||(c=n.index(),"row"===l?(t=c.row,h(e,o,s,"row",t)):"column"===l?(t=n.index().column,h(e,o,s,"column",t)):"cell"===l&&(t=n.index(),h(e,o,s,"cell",t)),s._select_lastCell=c))}),m("body").on("click.dtSelect"+_(o.table().node()),function(e){var t;!l._select.blurable||m(e.target).parents().filter(o.table().container()).length||0===m(e.target).parents("html").length||m(e.target).parents("div.DTE").length||(t=m.Event("select-blur.dt"),u(o,t,[e.target,e]),t.isDefaultPrevented())||f(l,!0)})}function u(e,t,l,s){s&&!e.flatten().length||("string"==typeof t&&(t+=".dt"),l.unshift(e),m(e.table().node()).trigger(t,l))}function b(e){return e.mRender&&"selectCheckbox"===e.mRender._name}function s(s,e){var t,l,c,n,o;"api"!==s.select.style()&&!1!==s.select.info()&&(o=s.settings()[0]._select_set.length||s.rows({selected:!0}).count(),t=s.columns({selected:!0}).count(),l=s.cells({selected:!0}).count(),c=function(e,t,l){e.append(m('<span class="select-item"/>').append(s.i18n("select."+t+"s",{_:"%d "+t+"s selected",0:"",1:"1 "+t+" selected"},l)))},e=m(e),c(n=m('<span class="select-info"/>'),"row",o),c(n,"column",t),c(n,"cell",l),(o=e.children("span.select-info")).length&&o.remove(),""!==n.text())&&e.append(n)}function o(o){var r,a=new p.Api(o);o._select_init=!0,o._select_set=[],o.aoRowCreatedCallback.push(function(e,t,l){var s,c,n=o.aoData[l],l=a.row(l).id();for((n._select_selected||"undefined"!==l&&o._select_set.includes(l))&&(n._select_selected=!0,m(e).addClass(o._select.className).find("input."+v(!0)).prop("checked",!0)),s=0,c=o.aoColumns.length;s<c;s++)(o.aoColumns[s]._select_selected||n._selected_cells&&n._selected_cells[s])&&m(n.anCells[s]).addClass(o._select.className)}),(r=a).on("select",function(e,t,l,s){if("row"===l)for(var l=r.settings()[0],c=r,n=l._select_set,o=s,a=0;a<o.length;a++){var i=c.row(o[a]).id();i&&"undefined"!==i&&!n.includes(i)&&n.push(i)}}),r.on("deselect",function(e,t,l,s){if("row"===l)for(var l=r.settings()[0],c=r,n=l._select_set,o=s,a=0;a<o.length;a++){var i=c.row(o[a]).id(),i=n.indexOf(i);-1!==i&&n.splice(i,1)}}),a.on("info.dt",function(e,t,l){t._select.infoEls.includes(l)||t._select.infoEls.push(l),s(a,l)}),a.on("select.dtSelect.dt deselect.dtSelect.dt",function(){o._select.infoEls.forEach(function(e){s(a,e)}),a.state.save()}),a.on("destroy.dtSelect",function(){m(a.rows({selected:!0}).nodes()).removeClass(a.settings()[0]._select.className),m("input."+v(!0),a.table().header()).remove(),c(a),a.off(".dtSelect"),m("body").off(".dtSelect"+_(a.table().node()))})}function d(e,t,l,s){var c,n=e[t+"s"]({search:"applied"}).indexes(),s=n.indexOf(s),o=n.indexOf(l);e[t+"s"]({selected:!0}).any()||-1!==s?(o<s&&(c=o,o=s,s=c),n.splice(o+1,n.length),n.splice(0,s)):n.splice(n.indexOf(l)+1,n.length),e[t](l,{selected:!0}).any()?(n.splice(n.indexOf(l),1),e[t+"s"](n).deselect()):e[t+"s"](n).select()}function f(e,t){!t&&"single"!==e._select.style||((t=new p.Api(e)).rows({selected:!0}).deselect(),t.columns({selected:!0}).deselect(),t.cells({selected:!0}).deselect())}function h(e,t,l,s,c){var n=t.select.style(),o=t.select.toggleable(),a=t[s](c,{selected:!0}).any();a&&!o||("os"===n?e.ctrlKey||e.metaKey?t[s](c).select(!a):e.shiftKey?"cell"===s?r(t,c,l._select_lastCell||null):d(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):(o=t[s+"s"]({selected:!0}),a&&1===o.flatten().length?t[s](c).deselect():(o.deselect(),t[s](c).select())):"multi+shift"==n&&e.shiftKey?"cell"===s?r(t,c,l._select_lastCell||null):d(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):t[s](c).select(!a))}function _(e){return e.id.replace(/[^a-zA-Z0-9\-\_]/g,"-")}p.select={},p.select.classes={checkbox:"dt-select-checkbox"},p.select.version="2.1.0",p.select.init=function(o){var e,t,l,s,c,n,a,i,r,u,d,f,h,_=o.settings()[0];if(!p.versionCheck("2"))throw"Warning: Select requires DataTables 2 or newer";!_._select&&(e=o.state.loaded(),t=function(e,t,l){if(null!==l&&void 0!==l.select){if(o.rows({selected:!0}).any()&&o.rows().deselect(),void 0!==l.select.rows&&o.rows(l.select.rows).select(),o.columns({selected:!0}).any()&&o.columns().deselect(),void 0!==l.select.columns&&o.columns(l.select.columns).select(),o.cells({selected:!0}).any()&&o.cells().deselect(),void 0!==l.select.cells)for(var s=0;s<l.select.cells.length;s++)o.cell(l.select.cells[s].row,l.select.cells[s].column).select();o.state.save()}},o.on("stateSaveParams",function(e,t,l){l.select={},l.select.rows=o.rows({selected:!0}).ids(!0).toArray(),l.select.columns=o.columns({selected:!0})[0],l.select.cells=o.cells({selected:!0})[0].map(function(e){return{row:o.row(e.row).id(!0),column:e.column}})}).on("stateLoadParams",t).one("init",function(){t(0,0,e)}),s=_.oInit.select,l=p.defaults.select,l=void 0===s?l:s,s="row",a=!(n=!(c="api")),u="td, th",d="selected",h=!(f=r=!(i=null)),_._select={infoEls:[]},!0===l?(c="os",h=!0):"string"==typeof l?(c=l,h=!0):m.isPlainObject(l)&&(void 0!==l.blurable&&(n=l.blurable),void 0!==l.toggleable&&(a=l.toggleable),void 0!==l.info&&(r=l.info),void 0!==l.items&&(s=l.items),h=(c=void 0!==l.style?l.style:"os",!0),void 0!==l.selector&&(u=l.selector),void 0!==l.className&&(d=l.className),void 0!==l.headerCheckbox&&(f=l.headerCheckbox),void 0!==l.selectable)&&(i=l.selectable),o.select.selector(u),o.select.items(s),o.select.style(c),o.select.blurable(n),o.select.toggleable(a),o.select.info(r),o.select.selectable(i),_._select.className=d,!h&&m(o.table().node()).hasClass("selectable")&&o.select.style("os"),f||"select-page"===f||"select-all"===f)&&o.ready(function(){var c,n,l;n=f,l=(c=o).settings()[0].aoColumns,c.columns().iterator("column",function(e,t){var s;b(l[t])&&(t=c.column(t).header(),m("input",t).length||(s=m("<input>").attr({class:v(!0),type:"checkbox","aria-label":c.i18n("select.aria.headerCheckbox")||"Select all rows"}).appendTo(t).on("change",function(){this.checked?("select-page"==n?c.rows({page:"current"}):c.rows({search:"applied"})).select():("select-page"==n?c.rows({page:"current",selected:!0}):c.rows({selected:!0})).deselect()}).on("click",function(e){e.stopPropagation()}),c.on("draw select deselect",function(e,t,l){"row"!==l&&l||((l=function(e,t){var l=e.settings()[0],s=l._select.selectable,c=0,n=("select-page"==t?e.rows({page:"current",selected:!0}):e.rows({selected:!0})).count(),o=("select-page"==t?e.rows({page:"current",selected:!0}):e.rows({search:"applied",selected:!0})).count();if(s)for(var a=("select-page"==t?e.rows({page:"current"}):e.rows({search:"applied"})).indexes(),i=0;i<a.length;i++){var r=l.aoData[a[i]];s(r._aData,r.nTr,a[i])&&c++}else c=("select-page"==t?e.rows({page:"current"}):e.rows({search:"applied"})).count();return{available:c,count:n,search:o}}(c,n)).search&&l.search<=l.count&&l.search===l.available?s.prop("checked",!0).prop("indeterminate",!1):0===l.search&&0===l.count?s.prop("checked",!1).prop("indeterminate",!1):s.prop("checked",!1).prop("indeterminate",!0))})))})})},m.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(e,i){p.ext.selector[i.type].push(function(e,t,l){var s,c=t.selected,n=[];if(!0!==c&&!1!==c)return l;for(var o=0,a=l.length;o<a;o++)(s=e[i.prop][l[o]])&&(!0===c&&!0===s._select_selected||!1===c&&!s._select_selected)&&n.push(l[o]);return n})}),p.ext.selector.cell.push(function(e,t,l){var s,c=t.selected,n=[];if(void 0===c)return l;for(var o=0,a=l.length;o<a;o++)(s=e.aoData[l[o].row])&&(!0===c&&s._selected_cells&&!0===s._selected_cells[l[o].column]||!1===c&&(!s._selected_cells||!s._selected_cells[l[o].column]))&&n.push(l[o]);return n});var t=p.Api.register,l=p.Api.registerPlural;function a(t,l){return function(e){return e.i18n("buttons."+t,l)}}function w(e){e=e._eventNamespace;return"draw.dt.DT"+e+" select.dt.DT"+e+" deselect.dt.DT"+e}t("select()",function(){return this.iterator("table",function(e){p.select.init(new p.Api(e))})}),t("select.blurable()",function(t){return void 0===t?this.context[0]._select.blurable:this.iterator("table",function(e){e._select.blurable=t})}),t("select.toggleable()",function(t){return void 0===t?this.context[0]._select.toggleable:this.iterator("table",function(e){e._select.toggleable=t})}),t("select.info()",function(t){return void 0===t?this.context[0]._select.info:this.iterator("table",function(e){e._select.info=t})}),t("select.items()",function(t){return void 0===t?this.context[0]._select.items:this.iterator("table",function(e){e._select.items=t,u(new p.Api(e),"selectItems",[t])})}),t("select.style()",function(l){return void 0===l?this.context[0]._select.style:this.iterator("table",function(e){e._select||p.select.init(new p.Api(e)),e._select_init||o(e),e._select.style=l;var t=new p.Api(e);"api"!==l?t.ready(function(){c(t),n(t)}):c(t),u(new p.Api(e),"selectStyle",[l])})}),t("select.selector()",function(s){return void 0===s?this.context[0]._select.selector:this.iterator("table",function(e){var t=new p.Api(e),l=e._select.style;c(t),e._select.selector=s,l&&"api"!==l?t.ready(function(){c(t),n(t)}):c(t)})}),t("select.selectable()",function(e){var t=this.context[0];return e?(t._select.selectable=e,this):t._select.selectable}),t("select.last()",function(e){var t=this.context[0];return e?(t._select_lastCell=e,this):t._select_lastCell}),t("select.cumulative()",function(){var e=this.context[0];return e&&e._select_set?e._select_set:[]}),l("rows().select()","row().select()",function(e){var o=this,a=[];return!1===e?this.deselect():(this.iterator("row",function(e,t){f(e);var l=e.aoData[t],s=e.aoColumns;if(e._select.selectable&&!1===e._select.selectable(l._aData,l.nTr,t))return;m(l.nTr).addClass(e._select.className),l._select_selected=!0,a.push(t);for(var c=0;c<s.length;c++){var n=s[c];null===n.sType&&o.columns().types(),b(n)&&((n=l.anCells)&&n[c]&&m("input."+v(!0),n[c]).prop("checked",!0),null!==l._aSortData)&&(l._aSortData[c]=null)}}),this.iterator("table",function(e){u(o,"select",["row",a],!0)}),this)}),t("row().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoData[this[0]]&&e.aoData[this[0]]._select_selected)}),l("columns().select()","column().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("column",function(e,t){f(e),e.aoColumns[t]._select_selected=!0;t=new p.Api(e).column(t);m(t.header()).addClass(e._select.className),m(t.footer()).addClass(e._select.className),t.nodes().to$().addClass(e._select.className)}),this.iterator("table",function(e,t){u(l,"select",["column",l[t]],!0)}),this)}),t("column().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoColumns[this[0]]&&e.aoColumns[this[0]]._select_selected)}),l("cells().select()","cell().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("cell",function(e,t,l){f(e);t=e.aoData[t];void 0===t._selected_cells&&(t._selected_cells=[]),t._selected_cells[l]=!0,t.anCells&&m(t.anCells[l]).addClass(e._select.className)}),this.iterator("table",function(e,t){u(l,"select",["cell",l.cells(l[t]).indexes().toArray()],!0)}),this)}),t("cell().selected()",function(){var e=this.context[0];if(e&&this.length){e=e.aoData[this[0][0].row];if(e&&e._selected_cells&&e._selected_cells[this[0][0].column])return!0}return!1}),l("rows().deselect()","row().deselect()",function(){var o=this;return this.iterator("row",function(e,t){var l=e.aoData[t],s=e.aoColumns;m(l.nTr).removeClass(e._select.className),l._select_selected=!1,e._select_lastCell=null;for(var c=0;c<s.length;c++){var n=s[c];null===n.sType&&o.columns().types(),b(n)&&((n=l.anCells)&&n[c]&&m("input."+v(!0),l.anCells[c]).prop("checked",!1),null!==l._aSortData)&&(l._aSortData[c]=null)}}),this.iterator("table",function(e,t){u(o,"deselect",["row",o[t]],!0)}),this}),l("columns().deselect()","column().deselect()",function(){var l=this;return this.iterator("column",function(s,e){s.aoColumns[e]._select_selected=!1;var t=new p.Api(s),l=t.column(e);m(l.header()).removeClass(s._select.className),m(l.footer()).removeClass(s._select.className),t.cells(null,e).indexes().each(function(e){var t=s.aoData[e.row],l=t._selected_cells;!t.anCells||l&&l[e.column]||m(t.anCells[e.column]).removeClass(s._select.className)})}),this.iterator("table",function(e,t){u(l,"deselect",["column",l[t]],!0)}),this}),l("cells().deselect()","cell().deselect()",function(){var l=this;return this.iterator("cell",function(e,t,l){t=e.aoData[t];void 0!==t._selected_cells&&(t._selected_cells[l]=!1),t.anCells&&!e.aoColumns[l]._select_selected&&m(t.anCells[l]).removeClass(e._select.className)}),this.iterator("table",function(e,t){u(l,"deselect",["cell",l[t]],!0)}),this});var g=0;return m.extend(p.ext.buttons,{selected:{text:a("selected","Selected"),className:"buttons-selected",limitTo:["rows","columns","cells"],init:function(l,e,s){var c=this;s._eventNamespace=".select"+g++,l.on(w(s),function(){var e,t;c.enable((e=l,!(-1===(t=s).limitTo.indexOf("rows")||!e.rows({selected:!0}).any())||!(-1===t.limitTo.indexOf("columns")||!e.columns({selected:!0}).any())||!(-1===t.limitTo.indexOf("cells")||!e.cells({selected:!0}).any())))}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},selectedSingle:{text:a("selectedSingle","Selected single"),className:"buttons-selected-single",init:function(t,e,l){var s=this;l._eventNamespace=".select"+g++,t.on(w(l),function(){var e=t.rows({selected:!0}).flatten().length+t.columns({selected:!0}).flatten().length+t.cells({selected:!0}).flatten().length;s.enable(1===e)}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},selectAll:{text:a("selectAll","Select all"),className:"buttons-select-all",action:function(e,t,l,s){var c=this.select.items(),n=s.selectorModifier;(n?("function"==typeof n&&(n=n.call(t,e,t,l,s)),this[c+"s"](n)):this[c+"s"]()).select()}},selectNone:{text:a("selectNone","Deselect all"),className:"buttons-select-none",action:function(){f(this.settings()[0],!0)},init:function(t,e,l){var s=this;l._eventNamespace=".select"+g++,t.on(w(l),function(){var e=t.rows({selected:!0}).flatten().length+t.columns({selected:!0}).flatten().length+t.cells({selected:!0}).flatten().length;s.enable(0<e)}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},showSelected:{text:a("showSelected","Show only selected"),className:"buttons-show-selected",action:function(e,t){var s;t.search.fixed("dt-select")?(t.search.fixed("dt-select",null),this.active(!1)):(s=t.settings()[0].aoData,t.search.fixed("dt-select",function(e,t,l){return s[l]._select_selected}),this.active(!0)),t.draw()}}}),m.each(["Row","Column","Cell"],function(e,t){var c=t.toLowerCase();p.ext.buttons["select"+t+"s"]={text:a("select"+t+"s","Select "+c+"s"),className:"buttons-select-"+c+"s",action:function(){this.select.items(c)},init:function(e){var s=this;this.active(e.select.items()===c),e.on("selectItems.dt.DT",function(e,t,l){s.active(l===c)})}}}),p.type("select-checkbox",{className:"dt-select",detect:p.versionCheck("2.1")?{oneOf:function(){return!1},allOf:function(){return!1},init:function(e,t,l){return b(t)}}:function(e){return"select-checkbox"===e&&e},order:{pre:function(e){return"X"===e?-1:0}}}),m.extend(!0,p.defaults.oLanguage,{select:{aria:{rowCheckbox:"Select row"}}}),p.render.select=function(e,t){function l(e,t,l,s){var c=s.settings.aoData[s.row],n=c._select_selected,o=s.settings.oLanguage.select.aria.rowCheckbox,a=s.settings._select.selectable;return"display"!==t?"type"===t?"select-checkbox":"filter"!==t&&n?"X":"":a&&!1===a(l,c.nTr,s.row)?"":m("<input>").attr({"aria-label":o,class:v(),name:r?r(l):null,type:"checkbox",value:i?i(l):null,checked:n}).on("input",function(e){e.preventDefault(),this.checked=m(this).closest("tr").hasClass("selected")})[0]}var i=e?p.util.get(e):null,r=t?p.util.get(t):null;return l._name="selectCheckbox",l},p.ext.order["select-checkbox"]=function(t,e){return this.api().column(e,{order:"index"}).nodes().map(function(e){return"row"===t._select.items?m(e).parent().hasClass(t._select.className).toString():"cell"===t._select.items&&m(e).hasClass(t._select.className).toString()})},m.fn.DataTable.select=p.select,m(e).on("i18n.dt.dtSelect preInit.dt.dtSelect",function(e,t){"dt"===e.namespace&&p.select.init(new p.Api(t))}),p});
4
+ (s=>{var l,c;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return s(e,window,document)}):"object"==typeof exports?(l=require("jquery"),c=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||l(e),c(e,t),s(t,e,e.document)}:(c(window,l),module.exports=s(l,window,window.document))):s(jQuery,window,document)})(function(m,i,a){var v=m.fn.dataTable;function r(n,e,t){function s(t,s){s<t&&(e=s,s=t,t=e);var e,l=!1;return n.columns(":visible").indexes().filter(function(e){return e===t&&(l=!0),e===s?!(l=!1):l})}function l(t,s){var e,l=n.rows({search:"applied"}).indexes(),c=(l.indexOf(t)>l.indexOf(s)&&(e=s,s=t,t=e),!1);return l.filter(function(e){return e===t&&(c=!0),e===s?!(c=!1):c})}var c,t=n.cells({selected:!0}).any()||t?(c=s(t.column,e.column),l(t.row,e.row)):(c=s(0,e.column),l(0,e.row)),t=n.cells(t,c).flatten();n.cells(e,{selected:!0}).any()?n.cells(t).deselect():n.cells(t).select()}function w(e){var t=v.select.classes.checkbox;return e?t.replace(/ /g,"."):t}function n(e){var t=e.settings()[0]._select.selector;m(e.table().container()).off("mousedown.dtSelect",t).off("mouseup.dtSelect",t).off("click.dtSelect",t),m("body").off("click.dtSelect"+b(e.table().node()))}function c(o){var a,t=m(o.table().container()),s=o.settings()[0],l=s._select.selector;t.on("mousedown.dtSelect",l,function(e){(e.shiftKey||e.metaKey||e.ctrlKey)&&t.css("-moz-user-select","none").one("selectstart.dtSelect",l,function(){return!1}),i.getSelection&&(a=i.getSelection())}).on("mouseup.dtSelect",l,function(){t.css("-moz-user-select","")}).on("click.dtSelect",l,function(e){var t,s=o.select.items();if(a){var l=i.getSelection();if((!l.anchorNode||m(l.anchorNode).closest("table")[0]===o.table().node())&&l!==a)return}var c,l=o.settings()[0],n=o.table().container();m(e.target).closest("div.dt-container")[0]==n&&(n=o.cell(m(e.target).closest("td, th"))).any()&&(c=m.Event("user-select.dt"),d(o,c,[s,n,e]),c.isDefaultPrevented()||(c=n.index(),"row"===s?(t=c.row,p(e,o,l,"row",t)):"column"===s?(t=n.index().column,p(e,o,l,"column",t)):"cell"===s&&(t=n.index(),p(e,o,l,"cell",t)),l._select_lastCell=c))}),m("body").on("click.dtSelect"+b(o.table().node()),function(e){var t;!s._select.blurable||m(e.target).parents().filter(o.table().container()).length||0===m(e.target).parents("html").length||m(e.target).parents("div.DTE").length||(t=m.Event("select-blur.dt"),d(o,t,[e.target,e]),t.isDefaultPrevented())||_(s,!0)})}function d(e,t,s,l){l&&!e.flatten().length||("string"==typeof t&&(t+=".dt"),s.unshift(e),m(e.table().node()).trigger(t,s))}function g(e){return e.mRender&&"selectCheckbox"===e.mRender._name}function l(l,e){var t,s,c,n,o;"api"!==l.select.style()&&!1!==l.select.info()&&(o=(n=(c=l.settings()[0])._select_set.length)||l.rows({selected:!0}).count(),t=l.columns({selected:!0}).count(),s=l.cells({selected:!0}).count(),"subtractive"===c._select_mode&&(o=l.page.info().recordsDisplay-n),c=function(e,t,s){e.append(m('<span class="select-item"/>').append(l.i18n("select."+t+"s",{_:"%d "+t+"s selected",0:"",1:"1 "+t+" selected"},s)))},n=m(e),c(e=m('<span class="select-info"/>'),"row",o),c(e,"column",t),c(e,"cell",s),(o=n.children("span.select-info")).length&&o.remove(),""!==e.text())&&n.append(e)}function u(e){var t=e.page.info();t.page<t.pages-1&&e.one("draw",function(){e.row(":first-child").node().focus()}).page("next").draw(!1)}function f(e){0<e.page.info().page&&e.one("draw",function(){e.row(":last-child").node().focus()}).page("previous").draw(!1)}function o(o){var c,a=new v.Api(o);o._select_init=!0,o._select_mode="additive",o._select_set=[],o.aoRowCreatedCallback.push(function(e,t,s){var l,c,n=o.aoData[s],s=a.row(s).id();for((n._select_selected||"additive"===o._select_mode&&o._select_set.includes(s)||"subtractive"===o._select_mode&&!o._select_set.includes(s))&&(n._select_selected=!0,m(e).addClass(o._select.className).find("input."+w(!0)).prop("checked",!0)),l=0,c=o.aoColumns.length;l<c;l++)(o.aoColumns[l]._select_selected||n._selected_cells&&n._selected_cells[l])&&m(n.anCells[l]).addClass(o._select.className)}),(c=a).on("select",function(e,t,s,l){"row"===s&&("additive"===(s=c.settings()[0])._select_mode?y:x)(c,s._select_set,l)}),c.on("deselect",function(e,t,s,l){"row"===s&&("additive"===(s=c.settings()[0])._select_mode?x:y)(c,s._select_set,l)}),a.on("info.dt",function(e,t,s){t._select.infoEls.includes(s)||t._select.infoEls.push(s),l(a,s)}),a.on("select.dtSelect.dt deselect.dtSelect.dt",function(){o._select.infoEls.forEach(function(e){l(a,e)}),a.state.save()}),a.on("destroy.dtSelect",function(){m(a.rows({selected:!0}).nodes()).removeClass(a.settings()[0]._select.className),m("input."+w(!0),a.table().header()).remove(),n(a),a.off(".dtSelect"),m("body").off(".dtSelect"+b(a.table().node()))})}function h(e,t,s,l){var c,n=e[t+"s"]({search:"applied"}).indexes(),l=n.indexOf(l),o=n.indexOf(s);e[t+"s"]({selected:!0}).any()||-1!==l?(o<l&&(c=o,o=l,l=c),n.splice(o+1,n.length),n.splice(0,l)):n.splice(n.indexOf(s)+1,n.length),e[t](s,{selected:!0}).any()?(n.splice(n.indexOf(s),1),e[t+"s"](n).deselect()):e[t+"s"](n).select()}function _(e,t){!t&&"single"!==e._select.style||((t=new v.Api(e)).rows({selected:!0}).deselect(),t.columns({selected:!0}).deselect(),t.cells({selected:!0}).deselect())}function p(e,t,s,l,c){var n=t.select.style(),o=t.select.toggleable(),a=t[l](c,{selected:!0}).any();a&&!o||("os"===n?e.ctrlKey||e.metaKey?t[l](c).select(!a):e.shiftKey?"cell"===l?r(t,c,s._select_lastCell||null):h(t,l,c,s._select_lastCell?s._select_lastCell[l]:null):(o=t[l+"s"]({selected:!0}),a&&1===o.flatten().length?t[l](c).deselect():(o.deselect(),t[l](c).select())):"multi+shift"==n&&e.shiftKey?"cell"===l?r(t,c,s._select_lastCell||null):h(t,l,c,s._select_lastCell?s._select_lastCell[l]:null):t[l](c).select(!a))}function b(e){return e.id.replace(/[^a-zA-Z0-9\-\_]/g,"-")}function y(e,t,s){for(var l=0;l<s.length;l++){var c=e.row(s[l]).id();c&&"undefined"!==c&&!t.includes(c)&&t.push(c)}}function x(e,t,s){for(var l=0;l<s.length;l++){var c=e.row(s[l]).id(),c=t.indexOf(c);-1!==c&&t.splice(c,1)}}v.select={},v.select.classes={checkbox:"dt-select-checkbox"},v.select.version="3.0.1",v.select.init=function(a){var e,t,s,l,c,n,o,i,r,d,u,f,h,_,p=a.settings()[0];if(!v.versionCheck("2"))throw"Warning: Select requires DataTables 2 or newer";!p._select&&(e=a.state.loaded(),t=function(e,t,s){if(null!==s&&void 0!==s.select){if(a.rows({selected:!0}).any()&&a.rows().deselect(),void 0!==s.select.rows&&a.rows(s.select.rows).select(),a.columns({selected:!0}).any()&&a.columns().deselect(),void 0!==s.select.columns&&a.columns(s.select.columns).select(),a.cells({selected:!0}).any()&&a.cells().deselect(),void 0!==s.select.cells)for(var l=0;l<s.select.cells.length;l++)a.cell(s.select.cells[l].row,s.select.cells[l].column).select();a.state.save()}},a.on("stateSaveParams",function(e,t,s){s.select={},s.select.rows=a.rows({selected:!0}).ids(!0).toArray(),s.select.columns=a.columns({selected:!0})[0],s.select.cells=a.cells({selected:!0})[0].map(function(e){return{row:a.row(e.row).id(!0),column:e.column}})}).on("stateLoadParams",t).one("init",function(){t(0,0,e)}),l=p.oInit.select,s=v.defaults.select,s=void 0===l?s:l,l="row",o=!(n=!(c="api")),d="td, th",u="selected",_=h=!(f=r=!(i=null)),p._select={infoEls:[]},!0===s?(c="os",h=!0):"string"==typeof s?(c=s,h=!0):m.isPlainObject(s)&&(void 0!==s.blurable&&(n=s.blurable),void 0!==s.toggleable&&(o=s.toggleable),void 0!==s.info&&(r=s.info),void 0!==s.items&&(l=s.items),h=(c=void 0!==s.style?s.style:"os",!0),void 0!==s.selector&&(d=s.selector),void 0!==s.className&&(u=s.className),void 0!==s.headerCheckbox&&(f=s.headerCheckbox),void 0!==s.selectable&&(i=s.selectable),void 0!==s.keys)&&(_=s.keys),a.select.selector(d),a.select.items(l),a.select.style(c),a.select.blurable(n),a.select.toggleable(o),a.select.info(r),a.select.keys(_),a.select.selectable(i),p._select.className=u,!h&&m(a.table().node()).hasClass("selectable")&&a.select.style("os"),f||"select-page"===f||"select-all"===f)&&a.ready(function(){var c,n,o;n=f,o=(c=a).settings()[0].aoColumns,c.columns().iterator("column",function(e,t){var s,l;g(o[t])&&(t=c.column(t).header(),(s=m("div.dt-column-header",t)).length&&(t=s),m("input",t).length||(l=m("<input>").attr({class:w(!0),type:"checkbox","aria-label":c.i18n("select.aria.headerCheckbox")||"Select all rows"}).appendTo(t).on("change",function(){this.checked?("select-page"==n?c.rows({page:"current"}):c.rows({search:"applied"})).select():("select-page"==n?c.rows({page:"current",selected:!0}):c.rows({selected:!0})).deselect()}).on("click",function(e){e.stopPropagation()}),c.on("draw select deselect",function(e,t,s){"row"!==s&&s||((s=((e,t)=>{var s=e.settings()[0],l=s._select.selectable,c=0,n=("select-page"==t?e.rows({page:"current",selected:!0}):e.rows({selected:!0})).count(),o=("select-page"==t?e.rows({page:"current",selected:!0}):e.rows({search:"applied",selected:!0})).count();if(l)for(var a=("select-page"==t?e.rows({page:"current"}):e.rows({search:"applied"})).indexes(),i=0;i<a.length;i++){var r=s.aoData[a[i]];l(r._aData,r.nTr,a[i])&&c++}else c=("select-page"==t?e.rows({page:"current"}):e.rows({search:"applied"})).count();return{available:c,count:n,search:o}})(c,n)).search&&s.search<=s.count&&s.search===s.available?l.prop("checked",!0).prop("indeterminate",!1):0===s.search&&0===s.count?l.prop("checked",!1).prop("indeterminate",!1):l.prop("checked",!1).prop("indeterminate",!0))})))})})},m.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(e,i){v.ext.selector[i.type].push(function(e,t,s){var l,c=t.selected,n=[];if(!0!==c&&!1!==c)return s;for(var o=0,a=s.length;o<a;o++)(l=e[i.prop][s[o]])&&(!0===c&&!0===l._select_selected||!1===c&&!l._select_selected)&&n.push(s[o]);return n})}),v.ext.selector.cell.push(function(e,t,s){var l,c=t.selected,n=[];if(void 0===c)return s;for(var o=0,a=s.length;o<a;o++)(l=e.aoData[s[o].row])&&(!0===c&&l._selected_cells&&!0===l._selected_cells[s[o].column]||!1===c&&(!l._selected_cells||!l._selected_cells[s[o].column]))&&n.push(s[o]);return n});var e=v.Api.register,t=v.Api.registerPlural;function s(t,s){return function(e){return e.i18n("buttons."+t,s)}}function C(e){e=e._eventNamespace;return"draw.dt.DT"+e+" select.dt.DT"+e+" deselect.dt.DT"+e}e("select()",function(){return this.iterator("table",function(e){v.select.init(new v.Api(e))})}),e("select.blurable()",function(t){return void 0===t?this.context[0]._select.blurable:this.iterator("table",function(e){e._select.blurable=t})}),e("select.toggleable()",function(t){return void 0===t?this.context[0]._select.toggleable:this.iterator("table",function(e){e._select.toggleable=t})}),e("select.info()",function(t){return void 0===t?this.context[0]._select.info:this.iterator("table",function(e){e._select.info=t})}),e("select.items()",function(t){return void 0===t?this.context[0]._select.items:this.iterator("table",function(e){e._select.items=t,d(new v.Api(e),"selectItems",[t])})}),e("select.keys()",function(s){return void 0===s?this.context[0]._select.keys:this.iterator("table",function(e){var o,t;e._select||v.select.init(new v.Api(e)),e._select.keys=s,o=new v.Api(e),t=(e=o.settings()[0])._select.keys,e="dts-keys-"+e.sTableId,t?(m(o.rows({page:"current"}).nodes()).attr("tabindex",0),o.on("draw."+e,function(){m(o.rows({page:"current"}).nodes()).attr("tabindex",0)}),m(a).on("keydown."+e,function(e){var t,s,l,c=e.keyCode,n=a.activeElement;[9,13,32,38,40].includes(c)&&(l=!0,-1!==(s=(t=o.rows({page:"current"}).nodes().toArray()).indexOf(n)))&&(9===c?!1===e.shift&&s===t.length-1?u(o):!0===e.shift&&0===s?f(o):l=!1:13===c||32===c?(n=o.row(n)).selected()?n.deselect():n.select():38===c?0<s?t[s-1].focus():f(o):s<t.length-1?t[s+1].focus():u(o),l)&&(e.stopPropagation(),e.preventDefault())})):(m(o.rows().nodes()).removeAttr("tabindex"),o.off("draw."+e),m(a).off("keydown."+e))})}),e("select.style()",function(s){return void 0===s?this.context[0]._select.style:this.iterator("table",function(e){e._select||v.select.init(new v.Api(e)),e._select_init||o(e),e._select.style=s;var t=new v.Api(e);"api"!==s?t.ready(function(){n(t),c(t)}):n(t),d(new v.Api(e),"selectStyle",[s])})}),e("select.selector()",function(l){return void 0===l?this.context[0]._select.selector:this.iterator("table",function(e){var t=new v.Api(e),s=e._select.style;n(t),e._select.selector=l,s&&"api"!==s?t.ready(function(){n(t),c(t)}):n(t)})}),e("select.selectable()",function(e){var t=this.context[0];return e?(t._select.selectable=e,this):t._select.selectable}),e("select.last()",function(e){var t=this.context[0];return e?(t._select_lastCell=e,this):t._select_lastCell}),e("select.cumulative()",function(l){var e;return l?this.iterator("table",function(e){var t,s;e._select_mode!==l&&(t=new v.Api(e),"subtractive"===l?(s=t.rows({selected:!1}).ids().toArray(),e._select_mode=l,e._select_set.length=0,e._select_set.push.apply(e._select_set,s)):(s=t.rows({selected:!0}).ids().toArray(),e._select_mode=l,e._select_set.length=0,e._select_set.push.apply(e._select_set,s)))}).draw(!1):(e=this.context[0])&&e._select_set?{mode:e._select_mode,rows:e._select_set}:null}),t("rows().select()","row().select()",function(e){var o=this,a=[];return!1===e?this.deselect():(this.iterator("row",function(e,t){_(e);var s=e.aoData[t],l=e.aoColumns;if(e._select.selectable&&!1===e._select.selectable(s._aData,s.nTr,t))return;m(s.nTr).addClass(e._select.className),s._select_selected=!0,a.push(t);for(var c=0;c<l.length;c++){var n=l[c];null===n.sType&&o.columns().types(),g(n)&&((n=s.anCells)&&n[c]&&m("input."+w(!0),n[c]).prop("checked",!0),null!==s._aSortData)&&(s._aSortData[c]=null)}}),this.iterator("table",function(e){d(o,"select",["row",a],!0)}),this)}),e("row().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoData[this[0]]&&e.aoData[this[0]]._select_selected)}),e("row().focus()",function(){var e=this.context[0];e&&this.length&&e.aoData[this[0]]&&e.aoData[this[0]].nTr&&e.aoData[this[0]].nTr.focus()}),e("row().blur()",function(){var e=this.context[0];e&&this.length&&e.aoData[this[0]]&&e.aoData[this[0]].nTr&&e.aoData[this[0]].nTr.blur()}),t("columns().select()","column().select()",function(e){var s=this;return!1===e?this.deselect():(this.iterator("column",function(e,t){_(e),e.aoColumns[t]._select_selected=!0;t=new v.Api(e).column(t);m(t.header()).addClass(e._select.className),m(t.footer()).addClass(e._select.className),t.nodes().to$().addClass(e._select.className)}),this.iterator("table",function(e,t){d(s,"select",["column",s[t]],!0)}),this)}),e("column().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoColumns[this[0]]&&e.aoColumns[this[0]]._select_selected)}),t("cells().select()","cell().select()",function(e){var s=this;return!1===e?this.deselect():(this.iterator("cell",function(e,t,s){_(e);t=e.aoData[t];void 0===t._selected_cells&&(t._selected_cells=[]),t._selected_cells[s]=!0,t.anCells&&m(t.anCells[s]).addClass(e._select.className)}),this.iterator("table",function(e,t){d(s,"select",["cell",s.cells(s[t]).indexes().toArray()],!0)}),this)}),e("cell().selected()",function(){var e=this.context[0];if(e&&this.length){e=e.aoData[this[0][0].row];if(e&&e._selected_cells&&e._selected_cells[this[0][0].column])return!0}return!1}),t("rows().deselect()","row().deselect()",function(){var o=this;return this.iterator("row",function(e,t){var s=e.aoData[t],l=e.aoColumns;m(s.nTr).removeClass(e._select.className),s._select_selected=!1,e._select_lastCell=null;for(var c=0;c<l.length;c++){var n=l[c];null===n.sType&&o.columns().types(),g(n)&&((n=s.anCells)&&n[c]&&m("input."+w(!0),s.anCells[c]).prop("checked",!1),null!==s._aSortData)&&(s._aSortData[c]=null)}}),this.iterator("table",function(e,t){d(o,"deselect",["row",o[t]],!0)}),this}),t("columns().deselect()","column().deselect()",function(){var s=this;return this.iterator("column",function(l,e){l.aoColumns[e]._select_selected=!1;var t=new v.Api(l),s=t.column(e);m(s.header()).removeClass(l._select.className),m(s.footer()).removeClass(l._select.className),t.cells(null,e).indexes().each(function(e){var t=l.aoData[e.row],s=t._selected_cells;!t.anCells||s&&s[e.column]||m(t.anCells[e.column]).removeClass(l._select.className)})}),this.iterator("table",function(e,t){d(s,"deselect",["column",s[t]],!0)}),this}),t("cells().deselect()","cell().deselect()",function(){var s=this;return this.iterator("cell",function(e,t,s){t=e.aoData[t];void 0!==t._selected_cells&&(t._selected_cells[s]=!1),t.anCells&&!e.aoColumns[s]._select_selected&&m(t.anCells[s]).removeClass(e._select.className)}),this.iterator("table",function(e,t){d(s,"deselect",["cell",s[t]],!0)}),this});var k=0;return m.extend(v.ext.buttons,{selected:{text:s("selected","Selected"),className:"buttons-selected",limitTo:["rows","columns","cells"],init:function(s,e,l){var c=this;l._eventNamespace=".select"+k++,s.on(C(l),function(){var e,t;c.enable((e=s,!(-1===(t=l).limitTo.indexOf("rows")||!e.rows({selected:!0}).any())||!(-1===t.limitTo.indexOf("columns")||!e.columns({selected:!0}).any())||!(-1===t.limitTo.indexOf("cells")||!e.cells({selected:!0}).any())))}),this.disable()},destroy:function(e,t,s){e.off(s._eventNamespace)}},selectedSingle:{text:s("selectedSingle","Selected single"),className:"buttons-selected-single",init:function(t,e,s){var l=this;s._eventNamespace=".select"+k++,t.on(C(s),function(){var e=t.rows({selected:!0}).flatten().length+t.columns({selected:!0}).flatten().length+t.cells({selected:!0}).flatten().length;l.enable(1===e)}),this.disable()},destroy:function(e,t,s){e.off(s._eventNamespace)}},selectAll:{text:s("selectAll","Select all"),className:"buttons-select-all",action:function(e,t,s,l){var c=this.select.items(),n=l.selectorModifier;(n?("function"==typeof n&&(n=n.call(t,e,t,s,l)),this[c+"s"](n)):this[c+"s"]()).select()}},selectNone:{text:s("selectNone","Deselect all"),className:"buttons-select-none",action:function(){_(this.settings()[0],!0)},init:function(t,e,s){var l=this;s._eventNamespace=".select"+k++,t.on(C(s),function(){var e=t.rows({selected:!0}).flatten().length+t.columns({selected:!0}).flatten().length+t.cells({selected:!0}).flatten().length;l.enable(0<e)}),this.disable()},destroy:function(e,t,s){e.off(s._eventNamespace)}},showSelected:{text:s("showSelected","Show only selected"),className:"buttons-show-selected",action:function(e,t){var l;t.search.fixed("dt-select")?(t.search.fixed("dt-select",null),this.active(!1)):(l=t.settings()[0].aoData,t.search.fixed("dt-select",function(e,t,s){return l[s]._select_selected}),this.active(!0)),t.draw()}}}),m.each(["Row","Column","Cell"],function(e,t){var c=t.toLowerCase();v.ext.buttons["select"+t+"s"]={text:s("select"+t+"s","Select "+c+"s"),className:"buttons-select-"+c+"s",action:function(){this.select.items(c)},init:function(e){var l=this;this.active(e.select.items()===c),e.on("selectItems.dt.DT",function(e,t,s){l.active(s===c)})}}}),v.type("select-checkbox",{className:"dt-select",detect:v.versionCheck("2.1")?{oneOf:function(){return!1},allOf:function(){return!1},init:function(e,t,s){return g(t)}}:function(e){return"select-checkbox"===e&&e},order:{pre:function(e){return"X"===e?-1:0}}}),m.extend(!0,v.defaults.oLanguage,{select:{aria:{rowCheckbox:"Select row"}}}),v.render.select=function(e,t){function s(e,t,s,l){var c=l.settings.aoData[l.row],n=c._select_selected,o=l.settings.oLanguage.select.aria.rowCheckbox,a=l.settings._select.selectable;return"display"!==t?"type"===t?"select-checkbox":"filter"!==t&&n?"X":"":a&&!1===a(s,c.nTr,l.row)?"":m("<input>").attr({"aria-label":o,class:w(),name:r?r(s):null,type:"checkbox",value:i?i(s):null,checked:n}).on("input",function(e){e.preventDefault(),this.checked=m(this).closest("tr").hasClass("selected")})[0]}var i=e?v.util.get(e):null,r=t?v.util.get(t):null;return s._name="selectCheckbox",s},v.ext.order["select-checkbox"]=function(t,e){return this.api().column(e,{order:"index"}).nodes().map(function(e){return"row"===t._select.items?m(e).parent().hasClass(t._select.className).toString():"cell"===t._select.items&&m(e).hasClass(t._select.className).toString()})},m.fn.DataTable.select=v.select,m(a).on("i18n.dt.dtSelect preInit.dt.dtSelect",function(e,t){"dt"===e.namespace&&v.select.init(new v.Api(t))}),v});
@@ -1,4 +1,4 @@
1
- /*! Select for DataTables 2.1.0
1
+ /*! Select for DataTables 3.0.1
2
2
  * © SpryMedia Ltd - datatables.net/license/mit
3
3
  */
4
- import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;function cellRange(n,e,t){function l(t,l){l<t&&(e=l,l=t,t=e);var e,s=!1;return n.columns(":visible").indexes().filter(function(e){return e===t&&(s=!0),e===l?!(s=!1):s})}function s(t,l){var e,s=n.rows({search:"applied"}).indexes(),c=(s.indexOf(t)>s.indexOf(l)&&(e=l,l=t,t=e),!1);return s.filter(function(e){return e===t&&(c=!0),e===l?!(c=!1):c})}var c,t=n.cells({selected:!0}).any()||t?(c=l(t.column,e.column),s(t.row,e.row)):(c=l(0,e.column),s(0,e.row)),t=n.cells(t,c).flatten();n.cells(e,{selected:!0}).any()?n.cells(t).deselect():n.cells(t).select()}function checkboxClass(e){var t=DataTable.select.classes.checkbox;return e?t.replace(/ /g,"."):t}function disableMouseSelection(e){var t=e.settings()[0]._select.selector;$(e.table().container()).off("mousedown.dtSelect",t).off("mouseup.dtSelect",t).off("click.dtSelect",t),$("body").off("click.dtSelect"+_safeId(e.table().node()))}function enableMouseSelection(a){var o,t=$(a.table().container()),l=a.settings()[0],s=l._select.selector;t.on("mousedown.dtSelect",s,function(e){(e.shiftKey||e.metaKey||e.ctrlKey)&&t.css("-moz-user-select","none").one("selectstart.dtSelect",s,function(){return!1}),window.getSelection&&(o=window.getSelection())}).on("mouseup.dtSelect",s,function(){t.css("-moz-user-select","")}).on("click.dtSelect",s,function(e){var t,l=a.select.items();if(o){var s=window.getSelection();if((!s.anchorNode||$(s.anchorNode).closest("table")[0]===a.table().node())&&s!==o)return}var c,s=a.settings()[0],n=a.table().container();$(e.target).closest("div.dt-container")[0]==n&&(n=a.cell($(e.target).closest("td, th"))).any()&&(c=$.Event("user-select.dt"),eventTrigger(a,c,[l,n,e]),c.isDefaultPrevented()||(c=n.index(),"row"===l?(t=c.row,typeSelect(e,a,s,"row",t)):"column"===l?(t=n.index().column,typeSelect(e,a,s,"column",t)):"cell"===l&&(t=n.index(),typeSelect(e,a,s,"cell",t)),s._select_lastCell=c))}),$("body").on("click.dtSelect"+_safeId(a.table().node()),function(e){var t;!l._select.blurable||$(e.target).parents().filter(a.table().container()).length||0===$(e.target).parents("html").length||$(e.target).parents("div.DTE").length||(t=$.Event("select-blur.dt"),eventTrigger(a,t,[e.target,e]),t.isDefaultPrevented())||clear(l,!0)})}function eventTrigger(e,t,l,s){s&&!e.flatten().length||("string"==typeof t&&(t+=".dt"),l.unshift(e),$(e.table().node()).trigger(t,l))}function isCheckboxColumn(e){return e.mRender&&"selectCheckbox"===e.mRender._name}function info(s,e){var t,l,c,n,a;"api"!==s.select.style()&&!1!==s.select.info()&&(a=s.settings()[0]._select_set.length||s.rows({selected:!0}).count(),t=s.columns({selected:!0}).count(),l=s.cells({selected:!0}).count(),c=function(e,t,l){e.append($('<span class="select-item"/>').append(s.i18n("select."+t+"s",{_:"%d "+t+"s selected",0:"",1:"1 "+t+" selected"},l)))},e=$(e),c(n=$('<span class="select-info"/>'),"row",a),c(n,"column",t),c(n,"cell",l),(a=e.children("span.select-info")).length&&a.remove(),""!==n.text())&&e.append(n)}function initCheckboxHeader(c,n){var l=c.settings()[0].aoColumns;c.columns().iterator("column",function(e,t){var s;isCheckboxColumn(l[t])&&(t=c.column(t).header(),$("input",t).length||(s=$("<input>").attr({class:checkboxClass(!0),type:"checkbox","aria-label":c.i18n("select.aria.headerCheckbox")||"Select all rows"}).appendTo(t).on("change",function(){this.checked?("select-page"==n?c.rows({page:"current"}):c.rows({search:"applied"})).select():("select-page"==n?c.rows({page:"current",selected:!0}):c.rows({selected:!0})).deselect()}).on("click",function(e){e.stopPropagation()}),c.on("draw select deselect",function(e,t,l){"row"!==l&&l||((l=headerCheckboxState(c,n)).search&&l.search<=l.count&&l.search===l.available?s.prop("checked",!0).prop("indeterminate",!1):0===l.search&&0===l.count?s.prop("checked",!1).prop("indeterminate",!1):s.prop("checked",!1).prop("indeterminate",!0))})))})}function headerCheckboxState(e,t){var l=e.settings()[0],s=l._select.selectable,c=0,n=("select-page"==t?e.rows({page:"current",selected:!0}):e.rows({selected:!0})).count(),a=("select-page"==t?e.rows({page:"current",selected:!0}):e.rows({search:"applied",selected:!0})).count();if(s)for(var o=("select-page"==t?e.rows({page:"current"}):e.rows({search:"applied"})).indexes(),i=0;i<o.length;i++){var r=l.aoData[o[i]];s(r._aData,r.nTr,o[i])&&c++}else c=("select-page"==t?e.rows({page:"current"}):e.rows({search:"applied"})).count();return{available:c,count:n,search:a}}function init(a){var o=new DataTable.Api(a);a._select_init=!0,a._select_set=[],a.aoRowCreatedCallback.push(function(e,t,l){var s,c,n=a.aoData[l],l=o.row(l).id();for((n._select_selected||"undefined"!==l&&a._select_set.includes(l))&&(n._select_selected=!0,$(e).addClass(a._select.className).find("input."+checkboxClass(!0)).prop("checked",!0)),s=0,c=a.aoColumns.length;s<c;s++)(a.aoColumns[s]._select_selected||n._selected_cells&&n._selected_cells[s])&&$(n.anCells[s]).addClass(a._select.className)}),_cumulativeEvents(o),o.on("info.dt",function(e,t,l){t._select.infoEls.includes(l)||t._select.infoEls.push(l),info(o,l)}),o.on("select.dtSelect.dt deselect.dtSelect.dt",function(){a._select.infoEls.forEach(function(e){info(o,e)}),o.state.save()}),o.on("destroy.dtSelect",function(){$(o.rows({selected:!0}).nodes()).removeClass(o.settings()[0]._select.className),$("input."+checkboxClass(!0),o.table().header()).remove(),disableMouseSelection(o),o.off(".dtSelect"),$("body").off(".dtSelect"+_safeId(o.table().node()))})}function rowColumnRange(e,t,l,s){var c,n=e[t+"s"]({search:"applied"}).indexes(),s=n.indexOf(s),a=n.indexOf(l);e[t+"s"]({selected:!0}).any()||-1!==s?(a<s&&(c=a,a=s,s=c),n.splice(a+1,n.length),n.splice(0,s)):n.splice(n.indexOf(l)+1,n.length),e[t](l,{selected:!0}).any()?(n.splice(n.indexOf(l),1),e[t+"s"](n).deselect()):e[t+"s"](n).select()}function clear(e,t){!t&&"single"!==e._select.style||((t=new DataTable.Api(e)).rows({selected:!0}).deselect(),t.columns({selected:!0}).deselect(),t.cells({selected:!0}).deselect())}function typeSelect(e,t,l,s,c){var n=t.select.style(),a=t.select.toggleable(),o=t[s](c,{selected:!0}).any();o&&!a||("os"===n?e.ctrlKey||e.metaKey?t[s](c).select(!o):e.shiftKey?"cell"===s?cellRange(t,c,l._select_lastCell||null):rowColumnRange(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):(a=t[s+"s"]({selected:!0}),o&&1===a.flatten().length?t[s](c).deselect():(a.deselect(),t[s](c).select())):"multi+shift"==n&&e.shiftKey?"cell"===s?cellRange(t,c,l._select_lastCell||null):rowColumnRange(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):t[s](c).select(!o))}function _safeId(e){return e.id.replace(/[^a-zA-Z0-9\-\_]/g,"-")}function _cumulativeEvents(c){c.on("select",function(e,t,l,s){"row"===l&&(l=c.settings()[0],_add(c,l._select_set,s))}),c.on("deselect",function(e,t,l,s){"row"===l&&(l=c.settings()[0],_remove(c,l._select_set,s))})}function _add(e,t,l){for(var s=0;s<l.length;s++){var c=e.row(l[s]).id();c&&"undefined"!==c&&!t.includes(c)&&t.push(c)}}function _remove(e,t,l){for(var s=0;s<l.length;s++){var c=e.row(l[s]).id(),c=t.indexOf(c);-1!==c&&t.splice(c,1)}}DataTable.select={},DataTable.select.classes={checkbox:"dt-select-checkbox"},DataTable.select.version="2.1.0",DataTable.select.init=function(c){var e,t,l,s,n,a,o,i,r,u,d,f,h,p=c.settings()[0];if(!DataTable.versionCheck("2"))throw"Warning: Select requires DataTables 2 or newer";!p._select&&(e=c.state.loaded(),t=function(e,t,l){if(null!==l&&void 0!==l.select){if(c.rows({selected:!0}).any()&&c.rows().deselect(),void 0!==l.select.rows&&c.rows(l.select.rows).select(),c.columns({selected:!0}).any()&&c.columns().deselect(),void 0!==l.select.columns&&c.columns(l.select.columns).select(),c.cells({selected:!0}).any()&&c.cells().deselect(),void 0!==l.select.cells)for(var s=0;s<l.select.cells.length;s++)c.cell(l.select.cells[s].row,l.select.cells[s].column).select();c.state.save()}},c.on("stateSaveParams",function(e,t,l){l.select={},l.select.rows=c.rows({selected:!0}).ids(!0).toArray(),l.select.columns=c.columns({selected:!0})[0],l.select.cells=c.cells({selected:!0})[0].map(function(e){return{row:c.row(e.row).id(!0),column:e.column}})}).on("stateLoadParams",t).one("init",function(){t(0,0,e)}),s=p.oInit.select,l=DataTable.defaults.select,l=void 0===s?l:s,s="row",o=!(a=!(n="api")),u="td, th",d="selected",h=!(f=r=!(i=null)),p._select={infoEls:[]},!0===l?(n="os",h=!0):"string"==typeof l?(n=l,h=!0):$.isPlainObject(l)&&(void 0!==l.blurable&&(a=l.blurable),void 0!==l.toggleable&&(o=l.toggleable),void 0!==l.info&&(r=l.info),void 0!==l.items&&(s=l.items),h=(n=void 0!==l.style?l.style:"os",!0),void 0!==l.selector&&(u=l.selector),void 0!==l.className&&(d=l.className),void 0!==l.headerCheckbox&&(f=l.headerCheckbox),void 0!==l.selectable)&&(i=l.selectable),c.select.selector(u),c.select.items(s),c.select.style(n),c.select.blurable(a),c.select.toggleable(o),c.select.info(r),c.select.selectable(i),p._select.className=d,!h&&$(c.table().node()).hasClass("selectable")&&c.select.style("os"),f||"select-page"===f||"select-all"===f)&&c.ready(function(){initCheckboxHeader(c,f)})},$.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(e,i){DataTable.ext.selector[i.type].push(function(e,t,l){var s,c=t.selected,n=[];if(!0!==c&&!1!==c)return l;for(var a=0,o=l.length;a<o;a++)(s=e[i.prop][l[a]])&&(!0===c&&!0===s._select_selected||!1===c&&!s._select_selected)&&n.push(l[a]);return n})}),DataTable.ext.selector.cell.push(function(e,t,l){var s,c=t.selected,n=[];if(void 0===c)return l;for(var a=0,o=l.length;a<o;a++)(s=e.aoData[l[a].row])&&(!0===c&&s._selected_cells&&!0===s._selected_cells[l[a].column]||!1===c&&(!s._selected_cells||!s._selected_cells[l[a].column]))&&n.push(l[a]);return n});var apiRegister=DataTable.Api.register,apiRegisterPlural=DataTable.Api.registerPlural;function i18n(t,l){return function(e){return e.i18n("buttons."+t,l)}}function namespacedEvents(e){e=e._eventNamespace;return"draw.dt.DT"+e+" select.dt.DT"+e+" deselect.dt.DT"+e}function enabled(e,t){return!(-1===t.limitTo.indexOf("rows")||!e.rows({selected:!0}).any())||!(-1===t.limitTo.indexOf("columns")||!e.columns({selected:!0}).any())||!(-1===t.limitTo.indexOf("cells")||!e.cells({selected:!0}).any())}apiRegister("select()",function(){return this.iterator("table",function(e){DataTable.select.init(new DataTable.Api(e))})}),apiRegister("select.blurable()",function(t){return void 0===t?this.context[0]._select.blurable:this.iterator("table",function(e){e._select.blurable=t})}),apiRegister("select.toggleable()",function(t){return void 0===t?this.context[0]._select.toggleable:this.iterator("table",function(e){e._select.toggleable=t})}),apiRegister("select.info()",function(t){return void 0===t?this.context[0]._select.info:this.iterator("table",function(e){e._select.info=t})}),apiRegister("select.items()",function(t){return void 0===t?this.context[0]._select.items:this.iterator("table",function(e){e._select.items=t,eventTrigger(new DataTable.Api(e),"selectItems",[t])})}),apiRegister("select.style()",function(l){return void 0===l?this.context[0]._select.style:this.iterator("table",function(e){e._select||DataTable.select.init(new DataTable.Api(e)),e._select_init||init(e),e._select.style=l;var t=new DataTable.Api(e);"api"!==l?t.ready(function(){disableMouseSelection(t),enableMouseSelection(t)}):disableMouseSelection(t),eventTrigger(new DataTable.Api(e),"selectStyle",[l])})}),apiRegister("select.selector()",function(s){return void 0===s?this.context[0]._select.selector:this.iterator("table",function(e){var t=new DataTable.Api(e),l=e._select.style;disableMouseSelection(t),e._select.selector=s,l&&"api"!==l?t.ready(function(){disableMouseSelection(t),enableMouseSelection(t)}):disableMouseSelection(t)})}),apiRegister("select.selectable()",function(e){var t=this.context[0];return e?(t._select.selectable=e,this):t._select.selectable}),apiRegister("select.last()",function(e){var t=this.context[0];return e?(t._select_lastCell=e,this):t._select_lastCell}),apiRegister("select.cumulative()",function(){var e=this.context[0];return e&&e._select_set?e._select_set:[]}),apiRegisterPlural("rows().select()","row().select()",function(e){var a=this,o=[];return!1===e?this.deselect():(this.iterator("row",function(e,t){clear(e);var l=e.aoData[t],s=e.aoColumns;if(e._select.selectable&&!1===e._select.selectable(l._aData,l.nTr,t))return;$(l.nTr).addClass(e._select.className),l._select_selected=!0,o.push(t);for(var c=0;c<s.length;c++){var n=s[c];null===n.sType&&a.columns().types(),isCheckboxColumn(n)&&((n=l.anCells)&&n[c]&&$("input."+checkboxClass(!0),n[c]).prop("checked",!0),null!==l._aSortData)&&(l._aSortData[c]=null)}}),this.iterator("table",function(e){eventTrigger(a,"select",["row",o],!0)}),this)}),apiRegister("row().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoData[this[0]]&&e.aoData[this[0]]._select_selected)}),apiRegisterPlural("columns().select()","column().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("column",function(e,t){clear(e),e.aoColumns[t]._select_selected=!0;t=new DataTable.Api(e).column(t);$(t.header()).addClass(e._select.className),$(t.footer()).addClass(e._select.className),t.nodes().to$().addClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"select",["column",l[t]],!0)}),this)}),apiRegister("column().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoColumns[this[0]]&&e.aoColumns[this[0]]._select_selected)}),apiRegisterPlural("cells().select()","cell().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("cell",function(e,t,l){clear(e);t=e.aoData[t];void 0===t._selected_cells&&(t._selected_cells=[]),t._selected_cells[l]=!0,t.anCells&&$(t.anCells[l]).addClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"select",["cell",l.cells(l[t]).indexes().toArray()],!0)}),this)}),apiRegister("cell().selected()",function(){var e=this.context[0];if(e&&this.length){e=e.aoData[this[0][0].row];if(e&&e._selected_cells&&e._selected_cells[this[0][0].column])return!0}return!1}),apiRegisterPlural("rows().deselect()","row().deselect()",function(){var a=this;return this.iterator("row",function(e,t){var l=e.aoData[t],s=e.aoColumns;$(l.nTr).removeClass(e._select.className),l._select_selected=!1,e._select_lastCell=null;for(var c=0;c<s.length;c++){var n=s[c];null===n.sType&&a.columns().types(),isCheckboxColumn(n)&&((n=l.anCells)&&n[c]&&$("input."+checkboxClass(!0),l.anCells[c]).prop("checked",!1),null!==l._aSortData)&&(l._aSortData[c]=null)}}),this.iterator("table",function(e,t){eventTrigger(a,"deselect",["row",a[t]],!0)}),this}),apiRegisterPlural("columns().deselect()","column().deselect()",function(){var l=this;return this.iterator("column",function(s,e){s.aoColumns[e]._select_selected=!1;var t=new DataTable.Api(s),l=t.column(e);$(l.header()).removeClass(s._select.className),$(l.footer()).removeClass(s._select.className),t.cells(null,e).indexes().each(function(e){var t=s.aoData[e.row],l=t._selected_cells;!t.anCells||l&&l[e.column]||$(t.anCells[e.column]).removeClass(s._select.className)})}),this.iterator("table",function(e,t){eventTrigger(l,"deselect",["column",l[t]],!0)}),this}),apiRegisterPlural("cells().deselect()","cell().deselect()",function(){var l=this;return this.iterator("cell",function(e,t,l){t=e.aoData[t];void 0!==t._selected_cells&&(t._selected_cells[l]=!1),t.anCells&&!e.aoColumns[l]._select_selected&&$(t.anCells[l]).removeClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"deselect",["cell",l[t]],!0)}),this});var _buttonNamespace=0;$.extend(DataTable.ext.buttons,{selected:{text:i18n("selected","Selected"),className:"buttons-selected",limitTo:["rows","columns","cells"],init:function(e,t,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,e.on(namespacedEvents(l),function(){s.enable(enabled(e,l))}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},selectedSingle:{text:i18n("selectedSingle","Selected single"),className:"buttons-selected-single",init:function(t,e,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,t.on(namespacedEvents(l),function(){var e=t.rows({selected:!0}).flatten().length+t.columns({selected:!0}).flatten().length+t.cells({selected:!0}).flatten().length;s.enable(1===e)}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},selectAll:{text:i18n("selectAll","Select all"),className:"buttons-select-all",action:function(e,t,l,s){var c=this.select.items(),n=s.selectorModifier;(n?("function"==typeof n&&(n=n.call(t,e,t,l,s)),this[c+"s"](n)):this[c+"s"]()).select()}},selectNone:{text:i18n("selectNone","Deselect all"),className:"buttons-select-none",action:function(){clear(this.settings()[0],!0)},init:function(t,e,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,t.on(namespacedEvents(l),function(){var e=t.rows({selected:!0}).flatten().length+t.columns({selected:!0}).flatten().length+t.cells({selected:!0}).flatten().length;s.enable(0<e)}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},showSelected:{text:i18n("showSelected","Show only selected"),className:"buttons-show-selected",action:function(e,t){var s;t.search.fixed("dt-select")?(t.search.fixed("dt-select",null),this.active(!1)):(s=t.settings()[0].aoData,t.search.fixed("dt-select",function(e,t,l){return s[l]._select_selected}),this.active(!0)),t.draw()}}}),$.each(["Row","Column","Cell"],function(e,t){var c=t.toLowerCase();DataTable.ext.buttons["select"+t+"s"]={text:i18n("select"+t+"s","Select "+c+"s"),className:"buttons-select-"+c+"s",action:function(){this.select.items(c)},init:function(e){var s=this;this.active(e.select.items()===c),e.on("selectItems.dt.DT",function(e,t,l){s.active(l===c)})}}}),DataTable.type("select-checkbox",{className:"dt-select",detect:DataTable.versionCheck("2.1")?{oneOf:function(){return!1},allOf:function(){return!1},init:function(e,t,l){return isCheckboxColumn(t)}}:function(e){return"select-checkbox"===e&&e},order:{pre:function(e){return"X"===e?-1:0}}}),$.extend(!0,DataTable.defaults.oLanguage,{select:{aria:{rowCheckbox:"Select row"}}}),DataTable.render.select=function(e,t){function l(e,t,l,s){var c=s.settings.aoData[s.row],n=c._select_selected,a=s.settings.oLanguage.select.aria.rowCheckbox,o=s.settings._select.selectable;return"display"!==t?"type"===t?"select-checkbox":"filter"!==t&&n?"X":"":o&&!1===o(l,c.nTr,s.row)?"":$("<input>").attr({"aria-label":a,class:checkboxClass(),name:r?r(l):null,type:"checkbox",value:i?i(l):null,checked:n}).on("input",function(e){e.preventDefault(),this.checked=$(this).closest("tr").hasClass("selected")})[0]}var i=e?DataTable.util.get(e):null,r=t?DataTable.util.get(t):null;return l._name="selectCheckbox",l},DataTable.ext.order["select-checkbox"]=function(t,e){return this.api().column(e,{order:"index"}).nodes().map(function(e){return"row"===t._select.items?$(e).parent().hasClass(t._select.className).toString():"cell"===t._select.items&&$(e).hasClass(t._select.className).toString()})},$.fn.DataTable.select=DataTable.select,$(document).on("i18n.dt.dtSelect preInit.dt.dtSelect",function(e,t){"dt"===e.namespace&&DataTable.select.init(new DataTable.Api(t))});export default DataTable;
4
+ import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;function cellRange(n,e,t){function l(t,l){l<t&&(e=l,l=t,t=e);var e,s=!1;return n.columns(":visible").indexes().filter(function(e){return e===t&&(s=!0),e===l?!(s=!1):s})}function s(t,l){var e,s=n.rows({search:"applied"}).indexes(),c=(s.indexOf(t)>s.indexOf(l)&&(e=l,l=t,t=e),!1);return s.filter(function(e){return e===t&&(c=!0),e===l?!(c=!1):c})}var c,t=n.cells({selected:!0}).any()||t?(c=l(t.column,e.column),s(t.row,e.row)):(c=l(0,e.column),s(0,e.row)),t=n.cells(t,c).flatten();n.cells(e,{selected:!0}).any()?n.cells(t).deselect():n.cells(t).select()}function checkboxClass(e){var t=DataTable.select.classes.checkbox;return e?t.replace(/ /g,"."):t}function disableMouseSelection(e){var t=e.settings()[0]._select.selector;$(e.table().container()).off("mousedown.dtSelect",t).off("mouseup.dtSelect",t).off("click.dtSelect",t),$("body").off("click.dtSelect"+_safeId(e.table().node()))}function enableMouseSelection(a){var o,t=$(a.table().container()),l=a.settings()[0],s=l._select.selector;t.on("mousedown.dtSelect",s,function(e){(e.shiftKey||e.metaKey||e.ctrlKey)&&t.css("-moz-user-select","none").one("selectstart.dtSelect",s,function(){return!1}),window.getSelection&&(o=window.getSelection())}).on("mouseup.dtSelect",s,function(){t.css("-moz-user-select","")}).on("click.dtSelect",s,function(e){var t,l=a.select.items();if(o){var s=window.getSelection();if((!s.anchorNode||$(s.anchorNode).closest("table")[0]===a.table().node())&&s!==o)return}var c,s=a.settings()[0],n=a.table().container();$(e.target).closest("div.dt-container")[0]==n&&(n=a.cell($(e.target).closest("td, th"))).any()&&(c=$.Event("user-select.dt"),eventTrigger(a,c,[l,n,e]),c.isDefaultPrevented()||(c=n.index(),"row"===l?(t=c.row,typeSelect(e,a,s,"row",t)):"column"===l?(t=n.index().column,typeSelect(e,a,s,"column",t)):"cell"===l&&(t=n.index(),typeSelect(e,a,s,"cell",t)),s._select_lastCell=c))}),$("body").on("click.dtSelect"+_safeId(a.table().node()),function(e){var t;!l._select.blurable||$(e.target).parents().filter(a.table().container()).length||0===$(e.target).parents("html").length||$(e.target).parents("div.DTE").length||(t=$.Event("select-blur.dt"),eventTrigger(a,t,[e.target,e]),t.isDefaultPrevented())||clear(l,!0)})}function eventTrigger(e,t,l,s){s&&!e.flatten().length||("string"==typeof t&&(t+=".dt"),l.unshift(e),$(e.table().node()).trigger(t,l))}function isCheckboxColumn(e){return e.mRender&&"selectCheckbox"===e.mRender._name}function info(s,e){var t,l,c,n,a;"api"!==s.select.style()&&!1!==s.select.info()&&(a=(n=(c=s.settings()[0])._select_set.length)||s.rows({selected:!0}).count(),t=s.columns({selected:!0}).count(),l=s.cells({selected:!0}).count(),"subtractive"===c._select_mode&&(a=s.page.info().recordsDisplay-n),c=function(e,t,l){e.append($('<span class="select-item"/>').append(s.i18n("select."+t+"s",{_:"%d "+t+"s selected",0:"",1:"1 "+t+" selected"},l)))},n=$(e),c(e=$('<span class="select-info"/>'),"row",a),c(e,"column",t),c(e,"cell",l),(a=n.children("span.select-info")).length&&a.remove(),""!==e.text())&&n.append(e)}function initCheckboxHeader(c,n){var a=c.settings()[0].aoColumns;c.columns().iterator("column",function(e,t){var l,s;isCheckboxColumn(a[t])&&(t=c.column(t).header(),(l=$("div.dt-column-header",t)).length&&(t=l),$("input",t).length||(s=$("<input>").attr({class:checkboxClass(!0),type:"checkbox","aria-label":c.i18n("select.aria.headerCheckbox")||"Select all rows"}).appendTo(t).on("change",function(){this.checked?("select-page"==n?c.rows({page:"current"}):c.rows({search:"applied"})).select():("select-page"==n?c.rows({page:"current",selected:!0}):c.rows({selected:!0})).deselect()}).on("click",function(e){e.stopPropagation()}),c.on("draw select deselect",function(e,t,l){"row"!==l&&l||((l=headerCheckboxState(c,n)).search&&l.search<=l.count&&l.search===l.available?s.prop("checked",!0).prop("indeterminate",!1):0===l.search&&0===l.count?s.prop("checked",!1).prop("indeterminate",!1):s.prop("checked",!1).prop("indeterminate",!0))})))})}function keysSet(a){var e=a.settings()[0],t=e._select.keys,e="dts-keys-"+e.sTableId;t?($(a.rows({page:"current"}).nodes()).attr("tabindex",0),a.on("draw."+e,function(){$(a.rows({page:"current"}).nodes()).attr("tabindex",0)}),$(document).on("keydown."+e,function(e){var t,l,s,c=e.keyCode,n=document.activeElement;[9,13,32,38,40].includes(c)&&(s=!0,-1!==(l=(t=a.rows({page:"current"}).nodes().toArray()).indexOf(n)))&&(9===c?!1===e.shift&&l===t.length-1?keysPageDown(a):!0===e.shift&&0===l?keysPageUp(a):s=!1:13===c||32===c?(n=a.row(n)).selected()?n.deselect():n.select():38===c?0<l?t[l-1].focus():keysPageUp(a):l<t.length-1?t[l+1].focus():keysPageDown(a),s)&&(e.stopPropagation(),e.preventDefault())})):($(a.rows().nodes()).removeAttr("tabindex"),a.off("draw."+e),$(document).off("keydown."+e))}function keysPageDown(e){var t=e.page.info();t.page<t.pages-1&&e.one("draw",function(){e.row(":first-child").node().focus()}).page("next").draw(!1)}function keysPageUp(e){0<e.page.info().page&&e.one("draw",function(){e.row(":last-child").node().focus()}).page("previous").draw(!1)}function headerCheckboxState(e,t){var l=e.settings()[0],s=l._select.selectable,c=0,n=("select-page"==t?e.rows({page:"current",selected:!0}):e.rows({selected:!0})).count(),a=("select-page"==t?e.rows({page:"current",selected:!0}):e.rows({search:"applied",selected:!0})).count();if(s)for(var o=("select-page"==t?e.rows({page:"current"}):e.rows({search:"applied"})).indexes(),i=0;i<o.length;i++){var r=l.aoData[o[i]];s(r._aData,r.nTr,o[i])&&c++}else c=("select-page"==t?e.rows({page:"current"}):e.rows({search:"applied"})).count();return{available:c,count:n,search:a}}function init(a){var o=new DataTable.Api(a);a._select_init=!0,a._select_mode="additive",a._select_set=[],a.aoRowCreatedCallback.push(function(e,t,l){var s,c,n=a.aoData[l],l=o.row(l).id();for((n._select_selected||"additive"===a._select_mode&&a._select_set.includes(l)||"subtractive"===a._select_mode&&!a._select_set.includes(l))&&(n._select_selected=!0,$(e).addClass(a._select.className).find("input."+checkboxClass(!0)).prop("checked",!0)),s=0,c=a.aoColumns.length;s<c;s++)(a.aoColumns[s]._select_selected||n._selected_cells&&n._selected_cells[s])&&$(n.anCells[s]).addClass(a._select.className)}),_cumulativeEvents(o),o.on("info.dt",function(e,t,l){t._select.infoEls.includes(l)||t._select.infoEls.push(l),info(o,l)}),o.on("select.dtSelect.dt deselect.dtSelect.dt",function(){a._select.infoEls.forEach(function(e){info(o,e)}),o.state.save()}),o.on("destroy.dtSelect",function(){$(o.rows({selected:!0}).nodes()).removeClass(o.settings()[0]._select.className),$("input."+checkboxClass(!0),o.table().header()).remove(),disableMouseSelection(o),o.off(".dtSelect"),$("body").off(".dtSelect"+_safeId(o.table().node()))})}function rowColumnRange(e,t,l,s){var c,n=e[t+"s"]({search:"applied"}).indexes(),s=n.indexOf(s),a=n.indexOf(l);e[t+"s"]({selected:!0}).any()||-1!==s?(a<s&&(c=a,a=s,s=c),n.splice(a+1,n.length),n.splice(0,s)):n.splice(n.indexOf(l)+1,n.length),e[t](l,{selected:!0}).any()?(n.splice(n.indexOf(l),1),e[t+"s"](n).deselect()):e[t+"s"](n).select()}function clear(e,t){!t&&"single"!==e._select.style||((t=new DataTable.Api(e)).rows({selected:!0}).deselect(),t.columns({selected:!0}).deselect(),t.cells({selected:!0}).deselect())}function typeSelect(e,t,l,s,c){var n=t.select.style(),a=t.select.toggleable(),o=t[s](c,{selected:!0}).any();o&&!a||("os"===n?e.ctrlKey||e.metaKey?t[s](c).select(!o):e.shiftKey?"cell"===s?cellRange(t,c,l._select_lastCell||null):rowColumnRange(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):(a=t[s+"s"]({selected:!0}),o&&1===a.flatten().length?t[s](c).deselect():(a.deselect(),t[s](c).select())):"multi+shift"==n&&e.shiftKey?"cell"===s?cellRange(t,c,l._select_lastCell||null):rowColumnRange(t,s,c,l._select_lastCell?l._select_lastCell[s]:null):t[s](c).select(!o))}function _safeId(e){return e.id.replace(/[^a-zA-Z0-9\-\_]/g,"-")}function _cumulativeEvents(c){c.on("select",function(e,t,l,s){"row"===l&&("additive"===(l=c.settings()[0])._select_mode?_add:_remove)(c,l._select_set,s)}),c.on("deselect",function(e,t,l,s){"row"===l&&("additive"===(l=c.settings()[0])._select_mode?_remove:_add)(c,l._select_set,s)})}function _add(e,t,l){for(var s=0;s<l.length;s++){var c=e.row(l[s]).id();c&&"undefined"!==c&&!t.includes(c)&&t.push(c)}}function _remove(e,t,l){for(var s=0;s<l.length;s++){var c=e.row(l[s]).id(),c=t.indexOf(c);-1!==c&&t.splice(c,1)}}DataTable.select={},DataTable.select.classes={checkbox:"dt-select-checkbox"},DataTable.select.version="3.0.1",DataTable.select.init=function(c){var e,t,l,s,n,a,o,i,r,u,d,f,h,_,p=c.settings()[0];if(!DataTable.versionCheck("2"))throw"Warning: Select requires DataTables 2 or newer";!p._select&&(e=c.state.loaded(),t=function(e,t,l){if(null!==l&&void 0!==l.select){if(c.rows({selected:!0}).any()&&c.rows().deselect(),void 0!==l.select.rows&&c.rows(l.select.rows).select(),c.columns({selected:!0}).any()&&c.columns().deselect(),void 0!==l.select.columns&&c.columns(l.select.columns).select(),c.cells({selected:!0}).any()&&c.cells().deselect(),void 0!==l.select.cells)for(var s=0;s<l.select.cells.length;s++)c.cell(l.select.cells[s].row,l.select.cells[s].column).select();c.state.save()}},c.on("stateSaveParams",function(e,t,l){l.select={},l.select.rows=c.rows({selected:!0}).ids(!0).toArray(),l.select.columns=c.columns({selected:!0})[0],l.select.cells=c.cells({selected:!0})[0].map(function(e){return{row:c.row(e.row).id(!0),column:e.column}})}).on("stateLoadParams",t).one("init",function(){t(0,0,e)}),s=p.oInit.select,l=DataTable.defaults.select,l=void 0===s?l:s,s="row",o=!(a=!(n="api")),u="td, th",d="selected",_=h=!(f=r=!(i=null)),p._select={infoEls:[]},!0===l?(n="os",h=!0):"string"==typeof l?(n=l,h=!0):$.isPlainObject(l)&&(void 0!==l.blurable&&(a=l.blurable),void 0!==l.toggleable&&(o=l.toggleable),void 0!==l.info&&(r=l.info),void 0!==l.items&&(s=l.items),h=(n=void 0!==l.style?l.style:"os",!0),void 0!==l.selector&&(u=l.selector),void 0!==l.className&&(d=l.className),void 0!==l.headerCheckbox&&(f=l.headerCheckbox),void 0!==l.selectable&&(i=l.selectable),void 0!==l.keys)&&(_=l.keys),c.select.selector(u),c.select.items(s),c.select.style(n),c.select.blurable(a),c.select.toggleable(o),c.select.info(r),c.select.keys(_),c.select.selectable(i),p._select.className=d,!h&&$(c.table().node()).hasClass("selectable")&&c.select.style("os"),f||"select-page"===f||"select-all"===f)&&c.ready(function(){initCheckboxHeader(c,f)})},$.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(e,i){DataTable.ext.selector[i.type].push(function(e,t,l){var s,c=t.selected,n=[];if(!0!==c&&!1!==c)return l;for(var a=0,o=l.length;a<o;a++)(s=e[i.prop][l[a]])&&(!0===c&&!0===s._select_selected||!1===c&&!s._select_selected)&&n.push(l[a]);return n})}),DataTable.ext.selector.cell.push(function(e,t,l){var s,c=t.selected,n=[];if(void 0===c)return l;for(var a=0,o=l.length;a<o;a++)(s=e.aoData[l[a].row])&&(!0===c&&s._selected_cells&&!0===s._selected_cells[l[a].column]||!1===c&&(!s._selected_cells||!s._selected_cells[l[a].column]))&&n.push(l[a]);return n});var apiRegister=DataTable.Api.register,apiRegisterPlural=DataTable.Api.registerPlural;function i18n(t,l){return function(e){return e.i18n("buttons."+t,l)}}function namespacedEvents(e){e=e._eventNamespace;return"draw.dt.DT"+e+" select.dt.DT"+e+" deselect.dt.DT"+e}function enabled(e,t){return!(-1===t.limitTo.indexOf("rows")||!e.rows({selected:!0}).any())||!(-1===t.limitTo.indexOf("columns")||!e.columns({selected:!0}).any())||!(-1===t.limitTo.indexOf("cells")||!e.cells({selected:!0}).any())}apiRegister("select()",function(){return this.iterator("table",function(e){DataTable.select.init(new DataTable.Api(e))})}),apiRegister("select.blurable()",function(t){return void 0===t?this.context[0]._select.blurable:this.iterator("table",function(e){e._select.blurable=t})}),apiRegister("select.toggleable()",function(t){return void 0===t?this.context[0]._select.toggleable:this.iterator("table",function(e){e._select.toggleable=t})}),apiRegister("select.info()",function(t){return void 0===t?this.context[0]._select.info:this.iterator("table",function(e){e._select.info=t})}),apiRegister("select.items()",function(t){return void 0===t?this.context[0]._select.items:this.iterator("table",function(e){e._select.items=t,eventTrigger(new DataTable.Api(e),"selectItems",[t])})}),apiRegister("select.keys()",function(t){return void 0===t?this.context[0]._select.keys:this.iterator("table",function(e){e._select||DataTable.select.init(new DataTable.Api(e)),e._select.keys=t,keysSet(new DataTable.Api(e))})}),apiRegister("select.style()",function(l){return void 0===l?this.context[0]._select.style:this.iterator("table",function(e){e._select||DataTable.select.init(new DataTable.Api(e)),e._select_init||init(e),e._select.style=l;var t=new DataTable.Api(e);"api"!==l?t.ready(function(){disableMouseSelection(t),enableMouseSelection(t)}):disableMouseSelection(t),eventTrigger(new DataTable.Api(e),"selectStyle",[l])})}),apiRegister("select.selector()",function(s){return void 0===s?this.context[0]._select.selector:this.iterator("table",function(e){var t=new DataTable.Api(e),l=e._select.style;disableMouseSelection(t),e._select.selector=s,l&&"api"!==l?t.ready(function(){disableMouseSelection(t),enableMouseSelection(t)}):disableMouseSelection(t)})}),apiRegister("select.selectable()",function(e){var t=this.context[0];return e?(t._select.selectable=e,this):t._select.selectable}),apiRegister("select.last()",function(e){var t=this.context[0];return e?(t._select_lastCell=e,this):t._select_lastCell}),apiRegister("select.cumulative()",function(s){var e;return s?this.iterator("table",function(e){var t,l;e._select_mode!==s&&(t=new DataTable.Api(e),"subtractive"===s?(l=t.rows({selected:!1}).ids().toArray(),e._select_mode=s,e._select_set.length=0,e._select_set.push.apply(e._select_set,l)):(l=t.rows({selected:!0}).ids().toArray(),e._select_mode=s,e._select_set.length=0,e._select_set.push.apply(e._select_set,l)))}).draw(!1):(e=this.context[0])&&e._select_set?{mode:e._select_mode,rows:e._select_set}:null}),apiRegisterPlural("rows().select()","row().select()",function(e){var a=this,o=[];return!1===e?this.deselect():(this.iterator("row",function(e,t){clear(e);var l=e.aoData[t],s=e.aoColumns;if(e._select.selectable&&!1===e._select.selectable(l._aData,l.nTr,t))return;$(l.nTr).addClass(e._select.className),l._select_selected=!0,o.push(t);for(var c=0;c<s.length;c++){var n=s[c];null===n.sType&&a.columns().types(),isCheckboxColumn(n)&&((n=l.anCells)&&n[c]&&$("input."+checkboxClass(!0),n[c]).prop("checked",!0),null!==l._aSortData)&&(l._aSortData[c]=null)}}),this.iterator("table",function(e){eventTrigger(a,"select",["row",o],!0)}),this)}),apiRegister("row().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoData[this[0]]&&e.aoData[this[0]]._select_selected)}),apiRegister("row().focus()",function(){var e=this.context[0];e&&this.length&&e.aoData[this[0]]&&e.aoData[this[0]].nTr&&e.aoData[this[0]].nTr.focus()}),apiRegister("row().blur()",function(){var e=this.context[0];e&&this.length&&e.aoData[this[0]]&&e.aoData[this[0]].nTr&&e.aoData[this[0]].nTr.blur()}),apiRegisterPlural("columns().select()","column().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("column",function(e,t){clear(e),e.aoColumns[t]._select_selected=!0;t=new DataTable.Api(e).column(t);$(t.header()).addClass(e._select.className),$(t.footer()).addClass(e._select.className),t.nodes().to$().addClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"select",["column",l[t]],!0)}),this)}),apiRegister("column().selected()",function(){var e=this.context[0];return!!(e&&this.length&&e.aoColumns[this[0]]&&e.aoColumns[this[0]]._select_selected)}),apiRegisterPlural("cells().select()","cell().select()",function(e){var l=this;return!1===e?this.deselect():(this.iterator("cell",function(e,t,l){clear(e);t=e.aoData[t];void 0===t._selected_cells&&(t._selected_cells=[]),t._selected_cells[l]=!0,t.anCells&&$(t.anCells[l]).addClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"select",["cell",l.cells(l[t]).indexes().toArray()],!0)}),this)}),apiRegister("cell().selected()",function(){var e=this.context[0];if(e&&this.length){e=e.aoData[this[0][0].row];if(e&&e._selected_cells&&e._selected_cells[this[0][0].column])return!0}return!1}),apiRegisterPlural("rows().deselect()","row().deselect()",function(){var a=this;return this.iterator("row",function(e,t){var l=e.aoData[t],s=e.aoColumns;$(l.nTr).removeClass(e._select.className),l._select_selected=!1,e._select_lastCell=null;for(var c=0;c<s.length;c++){var n=s[c];null===n.sType&&a.columns().types(),isCheckboxColumn(n)&&((n=l.anCells)&&n[c]&&$("input."+checkboxClass(!0),l.anCells[c]).prop("checked",!1),null!==l._aSortData)&&(l._aSortData[c]=null)}}),this.iterator("table",function(e,t){eventTrigger(a,"deselect",["row",a[t]],!0)}),this}),apiRegisterPlural("columns().deselect()","column().deselect()",function(){var l=this;return this.iterator("column",function(s,e){s.aoColumns[e]._select_selected=!1;var t=new DataTable.Api(s),l=t.column(e);$(l.header()).removeClass(s._select.className),$(l.footer()).removeClass(s._select.className),t.cells(null,e).indexes().each(function(e){var t=s.aoData[e.row],l=t._selected_cells;!t.anCells||l&&l[e.column]||$(t.anCells[e.column]).removeClass(s._select.className)})}),this.iterator("table",function(e,t){eventTrigger(l,"deselect",["column",l[t]],!0)}),this}),apiRegisterPlural("cells().deselect()","cell().deselect()",function(){var l=this;return this.iterator("cell",function(e,t,l){t=e.aoData[t];void 0!==t._selected_cells&&(t._selected_cells[l]=!1),t.anCells&&!e.aoColumns[l]._select_selected&&$(t.anCells[l]).removeClass(e._select.className)}),this.iterator("table",function(e,t){eventTrigger(l,"deselect",["cell",l[t]],!0)}),this});var _buttonNamespace=0;$.extend(DataTable.ext.buttons,{selected:{text:i18n("selected","Selected"),className:"buttons-selected",limitTo:["rows","columns","cells"],init:function(e,t,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,e.on(namespacedEvents(l),function(){s.enable(enabled(e,l))}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},selectedSingle:{text:i18n("selectedSingle","Selected single"),className:"buttons-selected-single",init:function(t,e,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,t.on(namespacedEvents(l),function(){var e=t.rows({selected:!0}).flatten().length+t.columns({selected:!0}).flatten().length+t.cells({selected:!0}).flatten().length;s.enable(1===e)}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},selectAll:{text:i18n("selectAll","Select all"),className:"buttons-select-all",action:function(e,t,l,s){var c=this.select.items(),n=s.selectorModifier;(n?("function"==typeof n&&(n=n.call(t,e,t,l,s)),this[c+"s"](n)):this[c+"s"]()).select()}},selectNone:{text:i18n("selectNone","Deselect all"),className:"buttons-select-none",action:function(){clear(this.settings()[0],!0)},init:function(t,e,l){var s=this;l._eventNamespace=".select"+_buttonNamespace++,t.on(namespacedEvents(l),function(){var e=t.rows({selected:!0}).flatten().length+t.columns({selected:!0}).flatten().length+t.cells({selected:!0}).flatten().length;s.enable(0<e)}),this.disable()},destroy:function(e,t,l){e.off(l._eventNamespace)}},showSelected:{text:i18n("showSelected","Show only selected"),className:"buttons-show-selected",action:function(e,t){var s;t.search.fixed("dt-select")?(t.search.fixed("dt-select",null),this.active(!1)):(s=t.settings()[0].aoData,t.search.fixed("dt-select",function(e,t,l){return s[l]._select_selected}),this.active(!0)),t.draw()}}}),$.each(["Row","Column","Cell"],function(e,t){var c=t.toLowerCase();DataTable.ext.buttons["select"+t+"s"]={text:i18n("select"+t+"s","Select "+c+"s"),className:"buttons-select-"+c+"s",action:function(){this.select.items(c)},init:function(e){var s=this;this.active(e.select.items()===c),e.on("selectItems.dt.DT",function(e,t,l){s.active(l===c)})}}}),DataTable.type("select-checkbox",{className:"dt-select",detect:DataTable.versionCheck("2.1")?{oneOf:function(){return!1},allOf:function(){return!1},init:function(e,t,l){return isCheckboxColumn(t)}}:function(e){return"select-checkbox"===e&&e},order:{pre:function(e){return"X"===e?-1:0}}}),$.extend(!0,DataTable.defaults.oLanguage,{select:{aria:{rowCheckbox:"Select row"}}}),DataTable.render.select=function(e,t){function l(e,t,l,s){var c=s.settings.aoData[s.row],n=c._select_selected,a=s.settings.oLanguage.select.aria.rowCheckbox,o=s.settings._select.selectable;return"display"!==t?"type"===t?"select-checkbox":"filter"!==t&&n?"X":"":o&&!1===o(l,c.nTr,s.row)?"":$("<input>").attr({"aria-label":a,class:checkboxClass(),name:r?r(l):null,type:"checkbox",value:i?i(l):null,checked:n}).on("input",function(e){e.preventDefault(),this.checked=$(this).closest("tr").hasClass("selected")})[0]}var i=e?DataTable.util.get(e):null,r=t?DataTable.util.get(t):null;return l._name="selectCheckbox",l},DataTable.ext.order["select-checkbox"]=function(t,e){return this.api().column(e,{order:"index"}).nodes().map(function(e){return"row"===t._select.items?$(e).parent().hasClass(t._select.className).toString():"cell"===t._select.items&&$(e).hasClass(t._select.className).toString()})},$.fn.DataTable.select=DataTable.select,$(document).on("i18n.dt.dtSelect preInit.dt.dtSelect",function(e,t){"dt"===e.namespace&&DataTable.select.init(new DataTable.Api(t))});export default DataTable;
@@ -1,4 +1,4 @@
1
- /*! Select for DataTables 2.1.0
1
+ /*! Select for DataTables 3.0.1
2
2
  * © SpryMedia Ltd - datatables.net/license/mit
3
3
  */
4
4
 
@@ -16,7 +16,7 @@ DataTable.select.classes = {
16
16
  checkbox: 'dt-select-checkbox'
17
17
  };
18
18
 
19
- DataTable.select.version = '2.1.0';
19
+ DataTable.select.version = '3.0.1';
20
20
 
21
21
  DataTable.select.init = function (dt) {
22
22
  var ctx = dt.settings()[0];
@@ -92,6 +92,7 @@ DataTable.select.init = function (dt) {
92
92
  var className = 'selected';
93
93
  var headerCheckbox = true;
94
94
  var setStyle = false;
95
+ var keys = false;
95
96
 
96
97
  ctx._select = {
97
98
  infoEls: []
@@ -147,6 +148,10 @@ DataTable.select.init = function (dt) {
147
148
  if (opts.selectable !== undefined) {
148
149
  selectable = opts.selectable;
149
150
  }
151
+
152
+ if (opts.keys !== undefined) {
153
+ keys = opts.keys;
154
+ }
150
155
  }
151
156
 
152
157
  dt.select.selector(selector);
@@ -155,6 +160,7 @@ DataTable.select.init = function (dt) {
155
160
  dt.select.blurable(blurable);
156
161
  dt.select.toggleable(toggleable);
157
162
  dt.select.info(info);
163
+ dt.select.keys(keys);
158
164
  dt.select.selectable(selectable);
159
165
  ctx._select.className = className;
160
166
 
@@ -534,14 +540,18 @@ function info(api, node) {
534
540
  return;
535
541
  }
536
542
 
537
- // If _select_set has any length, then ids are available and should be used
538
- // as the counter. Otherwise use the API to workout how many rows are
539
- // selected.
540
- var rowSetLength = api.settings()[0]._select_set.length;
543
+ var ctx = api.settings()[0];
544
+ var rowSetLength = ctx._select_set.length;
541
545
  var rows = rowSetLength ? rowSetLength : api.rows({ selected: true }).count();
542
546
  var columns = api.columns({ selected: true }).count();
543
547
  var cells = api.cells({ selected: true }).count();
544
548
 
549
+ // If subtractive selection, then we need to take the number of rows and
550
+ // subtract those that have been deselected
551
+ if (ctx._select_mode === 'subtractive') {
552
+ rows = api.page.info().recordsDisplay - rowSetLength;
553
+ }
554
+
545
555
  var add = function (el, name, num) {
546
556
  el.append(
547
557
  $('<span class="select-item"/>').append(
@@ -591,7 +601,14 @@ function initCheckboxHeader( dt, headerCheckbox ) {
591
601
  if (! isCheckboxColumn(col)) {
592
602
  return;
593
603
  }
604
+
594
605
  var header = dt.column(idx).header();
606
+ var liner = $('div.dt-column-header', header);
607
+
608
+ // DataTables 2.3 as an extra wrapper element
609
+ if (liner.length) {
610
+ header = liner;
611
+ }
595
612
 
596
613
  if (! $('input', header).length) {
597
614
  // If no checkbox yet, insert one
@@ -606,7 +623,8 @@ function initCheckboxHeader( dt, headerCheckbox ) {
606
623
  if (this.checked) {
607
624
  if (headerCheckbox == 'select-page') {
608
625
  dt.rows({page: 'current'}).select();
609
- } else {
626
+ }
627
+ else {
610
628
  dt.rows({search: 'applied'}).select();
611
629
  }
612
630
  }
@@ -650,6 +668,140 @@ function initCheckboxHeader( dt, headerCheckbox ) {
650
668
  });
651
669
  }
652
670
 
671
+ function keysSet(dt) {
672
+ var ctx = dt.settings()[0];
673
+ var flag = ctx._select.keys;
674
+ var namespace = 'dts-keys-' + ctx.sTableId;
675
+
676
+ if (flag) {
677
+ // Need a tabindex of the `tr` elements to make them focusable by the browser
678
+ $(dt.rows({page: 'current'}).nodes()).attr('tabindex', 0);
679
+
680
+ dt.on('draw.' + namespace, function () {
681
+ $(dt.rows({page: 'current'}).nodes()).attr('tabindex', 0);
682
+ });
683
+
684
+ // Listen on document for tab, up and down
685
+ $(document).on('keydown.' + namespace, function (e) {
686
+ var key = e.keyCode;
687
+ var active = document.activeElement;
688
+
689
+ // Can't use e.key as it wasn't widely supported until 2017
690
+ // 9 Tab
691
+ // 13 Return
692
+ // 32 Space
693
+ // 38 ArrowUp
694
+ // 40 ArrowDown
695
+ if (! [9, 13, 32, 38, 40].includes(key)) {
696
+ return;
697
+ }
698
+
699
+ var nodes = dt.rows({page: 'current'}).nodes().toArray();
700
+ var idx = nodes.indexOf(active);
701
+ var preventDefault = true;
702
+
703
+ // Only take an action if a row has focus
704
+ if (idx === -1) {
705
+ return;
706
+ }
707
+
708
+ if (key === 9) {
709
+ // Tab focus change
710
+ if (e.shift === false && idx === nodes.length - 1) {
711
+ keysPageDown(dt);
712
+ }
713
+ else if (e.shift === true && idx === 0) {
714
+ keysPageUp(dt);
715
+ }
716
+ else {
717
+ // Browser will do it for us
718
+ preventDefault = false;
719
+ }
720
+ }
721
+ else if (key === 13 || key === 32) {
722
+ // Row selection / deselection
723
+ var row = dt.row(active);
724
+
725
+ if (row.selected()) {
726
+ row.deselect();
727
+ }
728
+ else {
729
+ row.select();
730
+ }
731
+ }
732
+ else if (key === 38) {
733
+ // Move up
734
+ if (idx > 0) {
735
+ nodes[idx-1].focus();
736
+ }
737
+ else {
738
+ keysPageUp(dt);
739
+ }
740
+ }
741
+ else {
742
+ // Move down
743
+ if (idx < nodes.length -1) {
744
+ nodes[idx+1].focus();
745
+ }
746
+ else {
747
+ keysPageDown(dt);
748
+ }
749
+ }
750
+
751
+ if (preventDefault) {
752
+ e.stopPropagation();
753
+ e.preventDefault();
754
+ }
755
+ });
756
+ }
757
+ else {
758
+ // Stop the rows from being able to gain focus
759
+ $(dt.rows().nodes()).removeAttr('tabindex');
760
+
761
+ // Nuke events
762
+ dt.off('draw.' + namespace);
763
+ $(document).off('keydown.' + namespace);
764
+ }
765
+ }
766
+
767
+ /**
768
+ * Change to the next page and focus on the first row
769
+ *
770
+ * @param {DataTable.Api} dt DataTable instance
771
+ */
772
+ function keysPageDown(dt) {
773
+ // Is there another page to turn to?
774
+ var info = dt.page.info();
775
+
776
+ if (info.page < info.pages - 1) {
777
+ dt
778
+ .one('draw', function () {
779
+ dt.row(':first-child').node().focus();
780
+ })
781
+ .page('next')
782
+ .draw(false);
783
+ }
784
+ }
785
+
786
+ /**
787
+ * Change to the previous page and focus on the last row
788
+ *
789
+ * @param {DataTable.Api} dt DataTable instance
790
+ */
791
+ function keysPageUp(dt) {
792
+ // Is there another page to turn to?
793
+ var info = dt.page.info();
794
+
795
+ if (info.page > 0) {
796
+ dt
797
+ .one('draw', function () {
798
+ dt.row(':last-child').node().focus();
799
+ })
800
+ .page('previous')
801
+ .draw(false);
802
+ }
803
+ }
804
+
653
805
  /**
654
806
  * Determine the counts used to define the header checkbox's state
655
807
  *
@@ -712,7 +864,10 @@ function init(ctx) {
712
864
  var api = new DataTable.Api(ctx);
713
865
  ctx._select_init = true;
714
866
 
715
- // _select_set contains a list of the ids of all rows that are selected
867
+ // When `additive` then `_select_set` contains a list of the row ids that
868
+ // are selected. If `subtractive` then all rows are selected, except those
869
+ // in `_select_set`, which is a list of ids.
870
+ ctx._select_mode = 'additive';
716
871
  ctx._select_set = [];
717
872
 
718
873
  // Row callback so that classes can be added to rows and cells if the item
@@ -730,7 +885,8 @@ function init(ctx) {
730
885
  // Row
731
886
  if (
732
887
  d._select_selected ||
733
- (id !== 'undefined' && ctx._select_set.includes(id))
888
+ (ctx._select_mode === 'additive' && ctx._select_set.includes(id)) ||
889
+ (ctx._select_mode === 'subtractive' && ! ctx._select_set.includes(id))
734
890
  ) {
735
891
  d._select_selected = true;
736
892
 
@@ -940,7 +1096,16 @@ function _cumulativeEvents(api) {
940
1096
 
941
1097
  var ctx = api.settings()[0];
942
1098
 
943
- _add(api, ctx._select_set, indexes);
1099
+ if (ctx._select_mode === 'additive') {
1100
+ // Add row to the selection list if it isn't already there
1101
+ _add(api, ctx._select_set, indexes);
1102
+ }
1103
+ else {
1104
+ // Subtractive - if a row is selected it should not in the list
1105
+ // as in subtractive mode the list gives the rows which are not
1106
+ // selected
1107
+ _remove(api, ctx._select_set, indexes);
1108
+ }
944
1109
  });
945
1110
 
946
1111
  api.on('deselect', function (e, dt, type, indexes) {
@@ -951,7 +1116,14 @@ function _cumulativeEvents(api) {
951
1116
 
952
1117
  var ctx = api.settings()[0];
953
1118
 
954
- _remove(api, ctx._select_set, indexes);
1119
+ if (ctx._select_mode === 'additive') {
1120
+ // List is of those rows selected, so remove it
1121
+ _remove(api, ctx._select_set, indexes);
1122
+ }
1123
+ else {
1124
+ // List is of rows which are deselected, so add it!
1125
+ _add(api, ctx._select_set, indexes);
1126
+ }
955
1127
  });
956
1128
  }
957
1129
 
@@ -1103,6 +1275,22 @@ apiRegister('select.items()', function (items) {
1103
1275
  });
1104
1276
  });
1105
1277
 
1278
+ apiRegister('select.keys()', function (flag) {
1279
+ if (flag === undefined) {
1280
+ return this.context[0]._select.keys;
1281
+ }
1282
+
1283
+ return this.iterator('table', function (ctx) {
1284
+ if (!ctx._select) {
1285
+ DataTable.select.init(new DataTable.Api(ctx));
1286
+ }
1287
+
1288
+ ctx._select.keys = flag;
1289
+
1290
+ keysSet(new DataTable.Api(ctx));
1291
+ });
1292
+ });
1293
+
1106
1294
  // Takes effect from the _next_ selection. None disables future selection, but
1107
1295
  // does not clear the current selection. Use the `deselect` methods for that
1108
1296
  apiRegister('select.style()', function (style) {
@@ -1186,12 +1374,45 @@ apiRegister('select.last()', function (set) {
1186
1374
  return ctx._select_lastCell;
1187
1375
  });
1188
1376
 
1189
- apiRegister('select.cumulative()', function () {
1377
+ apiRegister('select.cumulative()', function (mode) {
1378
+ if (mode) {
1379
+ return this.iterator('table', function (ctx) {
1380
+ if (ctx._select_mode === mode) {
1381
+ return;
1382
+ }
1383
+
1384
+ var dt = new DataTable.Api(ctx);
1385
+
1386
+ // Convert from the current mode, to the new
1387
+ if (mode === 'subtractive') {
1388
+ // For subtractive mode we track the row ids which are not selected
1389
+ var unselected = dt.rows({selected: false}).ids().toArray();
1390
+
1391
+ ctx._select_mode = mode;
1392
+ ctx._select_set.length = 0;
1393
+ ctx._select_set.push.apply(ctx._select_set, unselected);
1394
+ }
1395
+ else {
1396
+ // Switching to additive, so selected rows are to be used
1397
+ var selected = dt.rows({selected: true}).ids().toArray();
1398
+
1399
+ ctx._select_mode = mode;
1400
+ ctx._select_set.length = 0;
1401
+ ctx._select_set.push.apply(ctx._select_set, selected);
1402
+ }
1403
+ }).draw(false);
1404
+ }
1405
+
1190
1406
  let ctx = this.context[0];
1191
1407
 
1192
- return ctx && ctx._select_set
1193
- ? ctx._select_set
1194
- : [];
1408
+ if (ctx && ctx._select_set) {
1409
+ return {
1410
+ mode: ctx._select_mode,
1411
+ rows: ctx._select_set
1412
+ };
1413
+ }
1414
+
1415
+ return null;
1195
1416
  });
1196
1417
 
1197
1418
  apiRegisterPlural('rows().select()', 'row().select()', function (select) {
@@ -1266,6 +1487,22 @@ apiRegister('row().selected()', function () {
1266
1487
  return false;
1267
1488
  });
1268
1489
 
1490
+ apiRegister('row().focus()', function () {
1491
+ var ctx = this.context[0];
1492
+
1493
+ if (ctx && this.length && ctx.aoData[this[0]] && ctx.aoData[this[0]].nTr) {
1494
+ ctx.aoData[this[0]].nTr.focus();
1495
+ }
1496
+ });
1497
+
1498
+ apiRegister('row().blur()', function () {
1499
+ var ctx = this.context[0];
1500
+
1501
+ if (ctx && this.length && ctx.aoData[this[0]] && ctx.aoData[this[0]].nTr) {
1502
+ ctx.aoData[this[0]].nTr.blur();
1503
+ }
1504
+ });
1505
+
1269
1506
  apiRegisterPlural('columns().select()', 'column().select()', function (select) {
1270
1507
  var api = this;
1271
1508
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "js/dataTables.select.js",
5
5
  "module": "js/dataTables.select.mjs",
6
6
  "types": "./types/types.d.ts",
7
- "version": "2.1.0",
7
+ "version": "3.0.1",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",
package/types/types.d.ts CHANGED
@@ -34,14 +34,24 @@ declare module 'datatables.net' {
34
34
 
35
35
  interface ApiRowMethods<T> {
36
36
  /**
37
- * Select a row
37
+ * Blur a row
38
38
  */
39
- select(): Api<T>;
39
+ blur(): Api<T>;
40
40
 
41
41
  /**
42
42
  * Deselect a row
43
43
  */
44
44
  deselect(): Api<T>;
45
+
46
+ /**
47
+ * Keyboard focus on a row
48
+ */
49
+ focus(): Api<T>;
50
+
51
+ /**
52
+ * Select a row
53
+ */
54
+ select(): Api<T>;
45
55
  }
46
56
 
47
57
  interface ApiRowsMethods<T> {
@@ -127,6 +137,53 @@ declare module 'datatables.net' {
127
137
  */
128
138
  select(valueProp: string, nameProp: string): ObjectColumnRender;
129
139
  }
140
+
141
+ interface Buttons {
142
+ /** Select all rows in the table */
143
+ selectAll: {
144
+ extend: 'selectAll';
145
+ selectorModifier?: ApiSelectorModifier;
146
+ }
147
+
148
+ /** Change selection type to cells. Shows as active when cell selection is enabled */
149
+ selectCells: {
150
+ extend: 'selectCells';
151
+ }
152
+
153
+ /** Change selection type to columns. Shows as active when cell selection is enabled */
154
+ selectColumns: {
155
+ extend: 'selectColumns';
156
+ }
157
+
158
+ /** Button which is enabled only when one or more rows are selected. Provide your own action function. */
159
+ selected: {
160
+ extend: 'selected';
161
+ limitTo?: string[];
162
+ }
163
+
164
+ /** Button which is enabled only when a single row is selected. Provide your own action function. */
165
+ selectedSingle: {
166
+ extend: 'selected';
167
+ }
168
+
169
+ /** Deselect all currently selected rows. */
170
+ selectNone: {
171
+ extend: 'selectNone';
172
+ }
173
+
174
+ /** Change selection type to rows. Shows as active when cell selection is enabled */
175
+ selectRows: {
176
+ extend: 'selectRows';
177
+ }
178
+
179
+ /**
180
+ * Toggle a filter that will reduce the rows displayed to just those which are selected. Uses
181
+ * its own action function - don't provide your own.
182
+ */
183
+ showSelected: {
184
+ extend: 'showSelected';
185
+ }
186
+ }
130
187
  }
131
188
 
132
189
  interface ConfigSelect {
@@ -150,6 +207,9 @@ interface ConfigSelect {
150
207
  */
151
208
  items?: string;
152
209
 
210
+ /** Set keyboard accessability (tab and arrow keys) */
211
+ keys?: boolean;
212
+
153
213
  /**
154
214
  * Set the element selector used for mouse event capture to select items
155
215
  */
@@ -214,6 +274,21 @@ interface ApiSelect<Api> {
214
274
  */
215
275
  items(set: string): Api;
216
276
 
277
+ /**
278
+ * Get Select's keyboard navigation state
279
+ *
280
+ * @returns The keyboard navigation state of Select
281
+ */
282
+ keys(): boolean;
283
+
284
+ /**
285
+ * Set Select's keyboard navigation state
286
+ *
287
+ * @param set Enable (true) or disable (false) row keyboard navigation
288
+ * @returns DataTables API instance for chaining.
289
+ */
290
+ keys(set: boolean): Api;
291
+
217
292
  /**
218
293
  * Get the current item selector string applied to the table.
219
294
  *