datatables.net-select 2.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! Select for DataTables 2.1.0
1
+ /*! Select for DataTables 3.0.0
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.0';
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(
@@ -646,7 +656,8 @@ function initCheckboxHeader( dt, headerCheckbox ) {
646
656
  if (this.checked) {
647
657
  if (headerCheckbox == 'select-page') {
648
658
  dt.rows({page: 'current'}).select();
649
- } else {
659
+ }
660
+ else {
650
661
  dt.rows({search: 'applied'}).select();
651
662
  }
652
663
  }
@@ -690,6 +701,140 @@ function initCheckboxHeader( dt, headerCheckbox ) {
690
701
  });
691
702
  }
692
703
 
704
+ function keysSet(dt) {
705
+ var ctx = dt.settings()[0];
706
+ var flag = ctx._select.keys;
707
+ var namespace = 'dts-keys-' + ctx.sTableId;
708
+
709
+ if (flag) {
710
+ // Need a tabindex of the `tr` elements to make them focusable by the browser
711
+ $(dt.rows({page: 'current'}).nodes()).attr('tabindex', 0);
712
+
713
+ dt.on('draw.' + namespace, function () {
714
+ $(dt.rows({page: 'current'}).nodes()).attr('tabindex', 0);
715
+ });
716
+
717
+ // Listen on document for tab, up and down
718
+ $(document).on('keydown.' + namespace, function (e) {
719
+ var key = e.keyCode;
720
+ var active = document.activeElement;
721
+
722
+ // Can't use e.key as it wasn't widely supported until 2017
723
+ // 9 Tab
724
+ // 13 Return
725
+ // 32 Space
726
+ // 38 ArrowUp
727
+ // 40 ArrowDown
728
+ if (! [9, 13, 32, 38, 40].includes(key)) {
729
+ return;
730
+ }
731
+
732
+ var nodes = dt.rows({page: 'current'}).nodes().toArray();
733
+ var idx = nodes.indexOf(active);
734
+ var preventDefault = true;
735
+
736
+ // Only take an action if a row has focus
737
+ if (idx === -1) {
738
+ return;
739
+ }
740
+
741
+ if (key === 9) {
742
+ // Tab focus change
743
+ if (e.shift === false && idx === nodes.length - 1) {
744
+ keysPageDown(dt);
745
+ }
746
+ else if (e.shift === true && idx === 0) {
747
+ keysPageUp(dt);
748
+ }
749
+ else {
750
+ // Browser will do it for us
751
+ preventDefault = false;
752
+ }
753
+ }
754
+ else if (key === 13 || key === 32) {
755
+ // Row selection / deselection
756
+ var row = dt.row(active);
757
+
758
+ if (row.selected()) {
759
+ row.deselect();
760
+ }
761
+ else {
762
+ row.select();
763
+ }
764
+ }
765
+ else if (key === 38) {
766
+ // Move up
767
+ if (idx > 0) {
768
+ nodes[idx-1].focus();
769
+ }
770
+ else {
771
+ keysPageUp(dt);
772
+ }
773
+ }
774
+ else {
775
+ // Move down
776
+ if (idx < nodes.length -1) {
777
+ nodes[idx+1].focus();
778
+ }
779
+ else {
780
+ keysPageDown(dt);
781
+ }
782
+ }
783
+
784
+ if (preventDefault) {
785
+ e.stopPropagation();
786
+ e.preventDefault();
787
+ }
788
+ });
789
+ }
790
+ else {
791
+ // Stop the rows from being able to gain focus
792
+ $(dt.rows().nodes()).removeAttr('tabindex');
793
+
794
+ // Nuke events
795
+ dt.off('draw.' + namespace);
796
+ $(document).off('keydown.' + namespace);
797
+ }
798
+ }
799
+
800
+ /**
801
+ * Change to the next page and focus on the first row
802
+ *
803
+ * @param {DataTable.Api} dt DataTable instance
804
+ */
805
+ function keysPageDown(dt) {
806
+ // Is there another page to turn to?
807
+ var info = dt.page.info();
808
+
809
+ if (info.page < info.pages - 1) {
810
+ dt
811
+ .one('draw', function () {
812
+ dt.row(':first-child').node().focus();
813
+ })
814
+ .page('next')
815
+ .draw(false);
816
+ }
817
+ }
818
+
819
+ /**
820
+ * Change to the previous page and focus on the last row
821
+ *
822
+ * @param {DataTable.Api} dt DataTable instance
823
+ */
824
+ function keysPageUp(dt) {
825
+ // Is there another page to turn to?
826
+ var info = dt.page.info();
827
+
828
+ if (info.page > 0) {
829
+ dt
830
+ .one('draw', function () {
831
+ dt.row(':last-child').node().focus();
832
+ })
833
+ .page('previous')
834
+ .draw(false);
835
+ }
836
+ }
837
+
693
838
  /**
694
839
  * Determine the counts used to define the header checkbox's state
695
840
  *
@@ -752,7 +897,10 @@ function init(ctx) {
752
897
  var api = new DataTable.Api(ctx);
753
898
  ctx._select_init = true;
754
899
 
755
- // _select_set contains a list of the ids of all rows that are selected
900
+ // When `additive` then `_select_set` contains a list of the row ids that
901
+ // are selected. If `subtractive` then all rows are selected, except those
902
+ // in `_select_set`, which is a list of ids.
903
+ ctx._select_mode = 'additive';
756
904
  ctx._select_set = [];
757
905
 
758
906
  // Row callback so that classes can be added to rows and cells if the item
@@ -770,7 +918,8 @@ function init(ctx) {
770
918
  // Row
771
919
  if (
772
920
  d._select_selected ||
773
- (id !== 'undefined' && ctx._select_set.includes(id))
921
+ (ctx._select_mode === 'additive' && ctx._select_set.includes(id)) ||
922
+ (ctx._select_mode === 'subtractive' && ! ctx._select_set.includes(id))
774
923
  ) {
775
924
  d._select_selected = true;
776
925
 
@@ -980,7 +1129,16 @@ function _cumulativeEvents(api) {
980
1129
 
981
1130
  var ctx = api.settings()[0];
982
1131
 
983
- _add(api, ctx._select_set, indexes);
1132
+ if (ctx._select_mode === 'additive') {
1133
+ // Add row to the selection list if it isn't already there
1134
+ _add(api, ctx._select_set, indexes);
1135
+ }
1136
+ else {
1137
+ // Subtractive - if a row is selected it should not in the list
1138
+ // as in subtractive mode the list gives the rows which are not
1139
+ // selected
1140
+ _remove(api, ctx._select_set, indexes);
1141
+ }
984
1142
  });
985
1143
 
986
1144
  api.on('deselect', function (e, dt, type, indexes) {
@@ -991,7 +1149,14 @@ function _cumulativeEvents(api) {
991
1149
 
992
1150
  var ctx = api.settings()[0];
993
1151
 
994
- _remove(api, ctx._select_set, indexes);
1152
+ if (ctx._select_mode === 'additive') {
1153
+ // List is of those rows selected, so remove it
1154
+ _remove(api, ctx._select_set, indexes);
1155
+ }
1156
+ else {
1157
+ // List is of rows which are deselected, so add it!
1158
+ _add(api, ctx._select_set, indexes);
1159
+ }
995
1160
  });
996
1161
  }
997
1162
 
@@ -1143,6 +1308,22 @@ apiRegister('select.items()', function (items) {
1143
1308
  });
1144
1309
  });
1145
1310
 
1311
+ apiRegister('select.keys()', function (flag) {
1312
+ if (flag === undefined) {
1313
+ return this.context[0]._select.keys;
1314
+ }
1315
+
1316
+ return this.iterator('table', function (ctx) {
1317
+ if (!ctx._select) {
1318
+ DataTable.select.init(new DataTable.Api(ctx));
1319
+ }
1320
+
1321
+ ctx._select.keys = flag;
1322
+
1323
+ keysSet(new DataTable.Api(ctx));
1324
+ });
1325
+ });
1326
+
1146
1327
  // Takes effect from the _next_ selection. None disables future selection, but
1147
1328
  // does not clear the current selection. Use the `deselect` methods for that
1148
1329
  apiRegister('select.style()', function (style) {
@@ -1226,12 +1407,45 @@ apiRegister('select.last()', function (set) {
1226
1407
  return ctx._select_lastCell;
1227
1408
  });
1228
1409
 
1229
- apiRegister('select.cumulative()', function () {
1410
+ apiRegister('select.cumulative()', function (mode) {
1411
+ if (mode) {
1412
+ return this.iterator('table', function (ctx) {
1413
+ if (ctx._select_mode === mode) {
1414
+ return;
1415
+ }
1416
+
1417
+ var dt = new DataTable.Api(ctx);
1418
+
1419
+ // Convert from the current mode, to the new
1420
+ if (mode === 'subtractive') {
1421
+ // For subtractive mode we track the row ids which are not selected
1422
+ var unselected = dt.rows({selected: false}).ids().toArray();
1423
+
1424
+ ctx._select_mode = mode;
1425
+ ctx._select_set.length = 0;
1426
+ ctx._select_set.push.apply(ctx._select_set, unselected);
1427
+ }
1428
+ else {
1429
+ // Switching to additive, so selected rows are to be used
1430
+ var selected = dt.rows({selected: true}).ids().toArray();
1431
+
1432
+ ctx._select_mode = mode;
1433
+ ctx._select_set.length = 0;
1434
+ ctx._select_set.push.apply(ctx._select_set, selected);
1435
+ }
1436
+ }).draw(false);
1437
+ }
1438
+
1230
1439
  let ctx = this.context[0];
1231
1440
 
1232
- return ctx && ctx._select_set
1233
- ? ctx._select_set
1234
- : [];
1441
+ if (ctx && ctx._select_set) {
1442
+ return {
1443
+ mode: ctx._select_mode,
1444
+ rows: ctx._select_set
1445
+ };
1446
+ }
1447
+
1448
+ return null;
1235
1449
  });
1236
1450
 
1237
1451
  apiRegisterPlural('rows().select()', 'row().select()', function (select) {
@@ -1306,6 +1520,22 @@ apiRegister('row().selected()', function () {
1306
1520
  return false;
1307
1521
  });
1308
1522
 
1523
+ apiRegister('row().focus()', function () {
1524
+ var ctx = this.context[0];
1525
+
1526
+ if (ctx && this.length && ctx.aoData[this[0]] && ctx.aoData[this[0]].nTr) {
1527
+ ctx.aoData[this[0]].nTr.focus();
1528
+ }
1529
+ });
1530
+
1531
+ apiRegister('row().blur()', function () {
1532
+ var ctx = this.context[0];
1533
+
1534
+ if (ctx && this.length && ctx.aoData[this[0]] && ctx.aoData[this[0]].nTr) {
1535
+ ctx.aoData[this[0]].nTr.blur();
1536
+ }
1537
+ });
1538
+
1309
1539
  apiRegisterPlural('columns().select()', 'column().select()', function (select) {
1310
1540
  var api = this;
1311
1541
 
@@ -1,4 +1,4 @@
1
- /*! Select for DataTables 2.1.0
1
+ /*! Select for DataTables 3.0.0
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
+ !function(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){"use strict";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"),u(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"),u(o,t,[e.target,e]),t.isDefaultPrevented())||_(s,!0)})}function u(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 d(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.0",v.select.init=function(o){var e,t,s,l,c,n,a,i,r,u,d,f,h,_,p=o.settings()[0];if(!v.versionCheck("2"))throw"Warning: Select requires DataTables 2 or newer";!p._select&&(e=o.state.loaded(),t=function(e,t,s){if(null!==s&&void 0!==s.select){if(o.rows({selected:!0}).any()&&o.rows().deselect(),void 0!==s.select.rows&&o.rows(s.select.rows).select(),o.columns({selected:!0}).any()&&o.columns().deselect(),void 0!==s.select.columns&&o.columns(s.select.columns).select(),o.cells({selected:!0}).any()&&o.cells().deselect(),void 0!==s.select.cells)for(var l=0;l<s.select.cells.length;l++)o.cell(s.select.cells[l].row,s.select.cells[l].column).select();o.state.save()}},o.on("stateSaveParams",function(e,t,s){s.select={},s.select.rows=o.rows({selected:!0}).ids(!0).toArray(),s.select.columns=o.columns({selected:!0})[0],s.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)}),l=p.oInit.select,s=v.defaults.select,s=void 0===l?s:l,l="row",a=!(n=!(c="api")),u="td, th",d="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&&(a=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&&(u=s.selector),void 0!==s.className&&(d=s.className),void 0!==s.headerCheckbox&&(f=s.headerCheckbox),void 0!==s.selectable&&(i=s.selectable),void 0!==s.keys)&&(_=s.keys),o.select.selector(u),o.select.items(l),o.select.style(c),o.select.blurable(n),o.select.toggleable(a),o.select.info(r),o.select.keys(_),o.select.selectable(i),p._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,s;n=f,s=(c=o).settings()[0].aoColumns,c.columns().iterator("column",function(e,t){var l;g(s[t])&&(t=c.column(t).header(),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=function(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,u(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?d(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():d(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),u(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){u(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){u(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){u(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){u(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){u(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){u(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.0
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 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 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.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),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.0
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.0';
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(
@@ -606,7 +616,8 @@ function initCheckboxHeader( dt, headerCheckbox ) {
606
616
  if (this.checked) {
607
617
  if (headerCheckbox == 'select-page') {
608
618
  dt.rows({page: 'current'}).select();
609
- } else {
619
+ }
620
+ else {
610
621
  dt.rows({search: 'applied'}).select();
611
622
  }
612
623
  }
@@ -650,6 +661,140 @@ function initCheckboxHeader( dt, headerCheckbox ) {
650
661
  });
651
662
  }
652
663
 
664
+ function keysSet(dt) {
665
+ var ctx = dt.settings()[0];
666
+ var flag = ctx._select.keys;
667
+ var namespace = 'dts-keys-' + ctx.sTableId;
668
+
669
+ if (flag) {
670
+ // Need a tabindex of the `tr` elements to make them focusable by the browser
671
+ $(dt.rows({page: 'current'}).nodes()).attr('tabindex', 0);
672
+
673
+ dt.on('draw.' + namespace, function () {
674
+ $(dt.rows({page: 'current'}).nodes()).attr('tabindex', 0);
675
+ });
676
+
677
+ // Listen on document for tab, up and down
678
+ $(document).on('keydown.' + namespace, function (e) {
679
+ var key = e.keyCode;
680
+ var active = document.activeElement;
681
+
682
+ // Can't use e.key as it wasn't widely supported until 2017
683
+ // 9 Tab
684
+ // 13 Return
685
+ // 32 Space
686
+ // 38 ArrowUp
687
+ // 40 ArrowDown
688
+ if (! [9, 13, 32, 38, 40].includes(key)) {
689
+ return;
690
+ }
691
+
692
+ var nodes = dt.rows({page: 'current'}).nodes().toArray();
693
+ var idx = nodes.indexOf(active);
694
+ var preventDefault = true;
695
+
696
+ // Only take an action if a row has focus
697
+ if (idx === -1) {
698
+ return;
699
+ }
700
+
701
+ if (key === 9) {
702
+ // Tab focus change
703
+ if (e.shift === false && idx === nodes.length - 1) {
704
+ keysPageDown(dt);
705
+ }
706
+ else if (e.shift === true && idx === 0) {
707
+ keysPageUp(dt);
708
+ }
709
+ else {
710
+ // Browser will do it for us
711
+ preventDefault = false;
712
+ }
713
+ }
714
+ else if (key === 13 || key === 32) {
715
+ // Row selection / deselection
716
+ var row = dt.row(active);
717
+
718
+ if (row.selected()) {
719
+ row.deselect();
720
+ }
721
+ else {
722
+ row.select();
723
+ }
724
+ }
725
+ else if (key === 38) {
726
+ // Move up
727
+ if (idx > 0) {
728
+ nodes[idx-1].focus();
729
+ }
730
+ else {
731
+ keysPageUp(dt);
732
+ }
733
+ }
734
+ else {
735
+ // Move down
736
+ if (idx < nodes.length -1) {
737
+ nodes[idx+1].focus();
738
+ }
739
+ else {
740
+ keysPageDown(dt);
741
+ }
742
+ }
743
+
744
+ if (preventDefault) {
745
+ e.stopPropagation();
746
+ e.preventDefault();
747
+ }
748
+ });
749
+ }
750
+ else {
751
+ // Stop the rows from being able to gain focus
752
+ $(dt.rows().nodes()).removeAttr('tabindex');
753
+
754
+ // Nuke events
755
+ dt.off('draw.' + namespace);
756
+ $(document).off('keydown.' + namespace);
757
+ }
758
+ }
759
+
760
+ /**
761
+ * Change to the next page and focus on the first row
762
+ *
763
+ * @param {DataTable.Api} dt DataTable instance
764
+ */
765
+ function keysPageDown(dt) {
766
+ // Is there another page to turn to?
767
+ var info = dt.page.info();
768
+
769
+ if (info.page < info.pages - 1) {
770
+ dt
771
+ .one('draw', function () {
772
+ dt.row(':first-child').node().focus();
773
+ })
774
+ .page('next')
775
+ .draw(false);
776
+ }
777
+ }
778
+
779
+ /**
780
+ * Change to the previous page and focus on the last row
781
+ *
782
+ * @param {DataTable.Api} dt DataTable instance
783
+ */
784
+ function keysPageUp(dt) {
785
+ // Is there another page to turn to?
786
+ var info = dt.page.info();
787
+
788
+ if (info.page > 0) {
789
+ dt
790
+ .one('draw', function () {
791
+ dt.row(':last-child').node().focus();
792
+ })
793
+ .page('previous')
794
+ .draw(false);
795
+ }
796
+ }
797
+
653
798
  /**
654
799
  * Determine the counts used to define the header checkbox's state
655
800
  *
@@ -712,7 +857,10 @@ function init(ctx) {
712
857
  var api = new DataTable.Api(ctx);
713
858
  ctx._select_init = true;
714
859
 
715
- // _select_set contains a list of the ids of all rows that are selected
860
+ // When `additive` then `_select_set` contains a list of the row ids that
861
+ // are selected. If `subtractive` then all rows are selected, except those
862
+ // in `_select_set`, which is a list of ids.
863
+ ctx._select_mode = 'additive';
716
864
  ctx._select_set = [];
717
865
 
718
866
  // Row callback so that classes can be added to rows and cells if the item
@@ -730,7 +878,8 @@ function init(ctx) {
730
878
  // Row
731
879
  if (
732
880
  d._select_selected ||
733
- (id !== 'undefined' && ctx._select_set.includes(id))
881
+ (ctx._select_mode === 'additive' && ctx._select_set.includes(id)) ||
882
+ (ctx._select_mode === 'subtractive' && ! ctx._select_set.includes(id))
734
883
  ) {
735
884
  d._select_selected = true;
736
885
 
@@ -940,7 +1089,16 @@ function _cumulativeEvents(api) {
940
1089
 
941
1090
  var ctx = api.settings()[0];
942
1091
 
943
- _add(api, ctx._select_set, indexes);
1092
+ if (ctx._select_mode === 'additive') {
1093
+ // Add row to the selection list if it isn't already there
1094
+ _add(api, ctx._select_set, indexes);
1095
+ }
1096
+ else {
1097
+ // Subtractive - if a row is selected it should not in the list
1098
+ // as in subtractive mode the list gives the rows which are not
1099
+ // selected
1100
+ _remove(api, ctx._select_set, indexes);
1101
+ }
944
1102
  });
945
1103
 
946
1104
  api.on('deselect', function (e, dt, type, indexes) {
@@ -951,7 +1109,14 @@ function _cumulativeEvents(api) {
951
1109
 
952
1110
  var ctx = api.settings()[0];
953
1111
 
954
- _remove(api, ctx._select_set, indexes);
1112
+ if (ctx._select_mode === 'additive') {
1113
+ // List is of those rows selected, so remove it
1114
+ _remove(api, ctx._select_set, indexes);
1115
+ }
1116
+ else {
1117
+ // List is of rows which are deselected, so add it!
1118
+ _add(api, ctx._select_set, indexes);
1119
+ }
955
1120
  });
956
1121
  }
957
1122
 
@@ -1103,6 +1268,22 @@ apiRegister('select.items()', function (items) {
1103
1268
  });
1104
1269
  });
1105
1270
 
1271
+ apiRegister('select.keys()', function (flag) {
1272
+ if (flag === undefined) {
1273
+ return this.context[0]._select.keys;
1274
+ }
1275
+
1276
+ return this.iterator('table', function (ctx) {
1277
+ if (!ctx._select) {
1278
+ DataTable.select.init(new DataTable.Api(ctx));
1279
+ }
1280
+
1281
+ ctx._select.keys = flag;
1282
+
1283
+ keysSet(new DataTable.Api(ctx));
1284
+ });
1285
+ });
1286
+
1106
1287
  // Takes effect from the _next_ selection. None disables future selection, but
1107
1288
  // does not clear the current selection. Use the `deselect` methods for that
1108
1289
  apiRegister('select.style()', function (style) {
@@ -1186,12 +1367,45 @@ apiRegister('select.last()', function (set) {
1186
1367
  return ctx._select_lastCell;
1187
1368
  });
1188
1369
 
1189
- apiRegister('select.cumulative()', function () {
1370
+ apiRegister('select.cumulative()', function (mode) {
1371
+ if (mode) {
1372
+ return this.iterator('table', function (ctx) {
1373
+ if (ctx._select_mode === mode) {
1374
+ return;
1375
+ }
1376
+
1377
+ var dt = new DataTable.Api(ctx);
1378
+
1379
+ // Convert from the current mode, to the new
1380
+ if (mode === 'subtractive') {
1381
+ // For subtractive mode we track the row ids which are not selected
1382
+ var unselected = dt.rows({selected: false}).ids().toArray();
1383
+
1384
+ ctx._select_mode = mode;
1385
+ ctx._select_set.length = 0;
1386
+ ctx._select_set.push.apply(ctx._select_set, unselected);
1387
+ }
1388
+ else {
1389
+ // Switching to additive, so selected rows are to be used
1390
+ var selected = dt.rows({selected: true}).ids().toArray();
1391
+
1392
+ ctx._select_mode = mode;
1393
+ ctx._select_set.length = 0;
1394
+ ctx._select_set.push.apply(ctx._select_set, selected);
1395
+ }
1396
+ }).draw(false);
1397
+ }
1398
+
1190
1399
  let ctx = this.context[0];
1191
1400
 
1192
- return ctx && ctx._select_set
1193
- ? ctx._select_set
1194
- : [];
1401
+ if (ctx && ctx._select_set) {
1402
+ return {
1403
+ mode: ctx._select_mode,
1404
+ rows: ctx._select_set
1405
+ };
1406
+ }
1407
+
1408
+ return null;
1195
1409
  });
1196
1410
 
1197
1411
  apiRegisterPlural('rows().select()', 'row().select()', function (select) {
@@ -1266,6 +1480,22 @@ apiRegister('row().selected()', function () {
1266
1480
  return false;
1267
1481
  });
1268
1482
 
1483
+ apiRegister('row().focus()', function () {
1484
+ var ctx = this.context[0];
1485
+
1486
+ if (ctx && this.length && ctx.aoData[this[0]] && ctx.aoData[this[0]].nTr) {
1487
+ ctx.aoData[this[0]].nTr.focus();
1488
+ }
1489
+ });
1490
+
1491
+ apiRegister('row().blur()', function () {
1492
+ var ctx = this.context[0];
1493
+
1494
+ if (ctx && this.length && ctx.aoData[this[0]] && ctx.aoData[this[0]].nTr) {
1495
+ ctx.aoData[this[0]].nTr.blur();
1496
+ }
1497
+ });
1498
+
1269
1499
  apiRegisterPlural('columns().select()', 'column().select()', function (select) {
1270
1500
  var api = this;
1271
1501
 
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.0",
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
  *