datatables.net-searchbuilder 1.5.0 → 1.7.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,5 +1,5 @@
1
- /*! SearchBuilder 1.5.0
2
- * ©SpryMedia Ltd - datatables.net/license/mit
1
+ /*! SearchBuilder 1.7.0
2
+ -dev * ©SpryMedia Ltd - datatables.net/license/mit
3
3
  */
4
4
 
5
5
  import jQuery from 'jquery';
@@ -32,11 +32,12 @@ let $ = jQuery;
32
32
  * The Criteria class is used within SearchBuilder to represent a search criteria
33
33
  */
34
34
  var Criteria = /** @class */ (function () {
35
- function Criteria(table, opts, topGroup, index, depth, serverData) {
36
- var _this = this;
35
+ function Criteria(table, opts, topGroup, index, depth, serverData, liveSearch) {
37
36
  if (index === void 0) { index = 0; }
38
37
  if (depth === void 0) { depth = 1; }
39
38
  if (serverData === void 0) { serverData = undefined; }
39
+ if (liveSearch === void 0) { liveSearch = false; }
40
+ var _this = this;
40
41
  // Check that the required version of DataTables is included
41
42
  if (!dataTable$3 || !dataTable$3.versionCheck || !dataTable$3.versionCheck('1.10.0')) {
42
43
  throw new Error('SearchPane requires DataTables 1.10 or newer');
@@ -56,6 +57,7 @@ let $ = jQuery;
56
57
  dt: table,
57
58
  filled: false,
58
59
  index: index,
60
+ liveSearch: liveSearch,
59
61
  origData: undefined,
60
62
  preventRedraw: false,
61
63
  serverData: serverData,
@@ -149,7 +151,19 @@ let $ = jQuery;
149
151
  .replace(/"/g, '"');
150
152
  };
151
153
  /**
152
- * Parses formatted numbers down to a form where they can be compared
154
+ * Redraw the DataTable with the current search parameters
155
+ */
156
+ Criteria.prototype.doSearch = function () {
157
+ // Only do the search if live search is disabled, otherwise the search
158
+ // is triggered by the button at the top level group.
159
+ if (this.c.liveSearch) {
160
+ this.s.dt.draw();
161
+ }
162
+ };
163
+ /**
164
+ * Parses formatted numbers down to a form where they can be compared.
165
+ * Note that this does not account for different decimal characters. Use
166
+ * parseNumber instead on the instance.
153
167
  *
154
168
  * @param val the value to convert
155
169
  * @returns the converted value
@@ -171,11 +185,11 @@ let $ = jQuery;
171
185
  this.setListeners();
172
186
  // Trigger the inserted events for the value elements as they are inserted
173
187
  if (this.dom.value[0] !== undefined) {
174
- this.dom.value[0].trigger('dtsb-inserted');
188
+ $$3(this.dom.value[0]).trigger('dtsb-inserted');
175
189
  }
176
190
  for (var i = 1; i < this.dom.value.length; i++) {
177
191
  this.dom.inputCont.append(this.dom.value[i]);
178
- this.dom.value[i].trigger('dtsb-inserted');
192
+ $$3(this.dom.value[i]).trigger('dtsb-inserted');
179
193
  }
180
194
  // If this is a top level criteria then don't let it move left
181
195
  if (this.s.depth > 1) {
@@ -213,28 +227,28 @@ let $ = jQuery;
213
227
  * @returns boolean Whether the criteria has passed
214
228
  */
215
229
  Criteria.prototype.search = function (rowData, rowIdx) {
230
+ var settings = this.s.dt.settings()[0];
216
231
  var condition = this.s.conditions[this.s.condition];
217
232
  if (this.s.condition !== undefined && condition !== undefined) {
218
233
  var filter = rowData[this.s.dataIdx];
219
234
  // This check is in place for if a custom decimal character is in place
220
235
  if (this.s.type.includes('num') &&
221
- (this.s.dt.settings()[0].oLanguage.sDecimal !== '' ||
222
- this.s.dt.settings()[0].oLanguage.sThousands !== '')) {
236
+ (settings.oLanguage.sDecimal !== '' ||
237
+ settings.oLanguage.sThousands !== '')) {
223
238
  var splitRD = [rowData[this.s.dataIdx]];
224
- if (this.s.dt.settings()[0].oLanguage.sDecimal !== '') {
225
- splitRD = rowData[this.s.dataIdx].split(this.s.dt.settings()[0].oLanguage.sDecimal);
239
+ if (settings.oLanguage.sDecimal !== '') {
240
+ splitRD = rowData[this.s.dataIdx].split(settings.oLanguage.sDecimal);
226
241
  }
227
- if (this.s.dt.settings()[0].oLanguage.sThousands !== '') {
242
+ if (settings.oLanguage.sThousands !== '') {
228
243
  for (var i = 0; i < splitRD.length; i++) {
229
- splitRD[i] = splitRD[i].replace(this.s.dt.settings()[0].oLanguage.sThousands, ',');
244
+ splitRD[i] = splitRD[i].replace(settings.oLanguage.sThousands, ',');
230
245
  }
231
246
  }
232
247
  filter = splitRD.join('.');
233
248
  }
234
249
  // If orthogonal data is in place we need to get it's values for searching
235
250
  if (this.c.orthogonal.search !== 'filter') {
236
- var settings = this.s.dt.settings()[0];
237
- filter = settings.oApi._fnGetCellData(settings, rowIdx, this.s.dataIdx, typeof this.c.orthogonal === 'string' ?
251
+ filter = settings.fastData(rowIdx, this.s.dataIdx, typeof this.c.orthogonal === 'string' ?
238
252
  this.c.orthogonal :
239
253
  this.c.orthogonal.search);
240
254
  }
@@ -270,18 +284,20 @@ let $ = jQuery;
270
284
  */
271
285
  Criteria.prototype.getDetails = function (deFormatDates) {
272
286
  if (deFormatDates === void 0) { deFormatDates = false; }
287
+ var i;
288
+ var settings = this.s.dt.settings()[0];
273
289
  // This check is in place for if a custom decimal character is in place
274
290
  if (this.s.type !== null &&
275
291
  this.s.type.includes('num') &&
276
- (this.s.dt.settings()[0].oLanguage.sDecimal !== '' || this.s.dt.settings()[0].oLanguage.sThousands !== '')) {
277
- for (var i = 0; i < this.s.value.length; i++) {
292
+ (settings.oLanguage.sDecimal !== '' || settings.oLanguage.sThousands !== '')) {
293
+ for (i = 0; i < this.s.value.length; i++) {
278
294
  var splitRD = [this.s.value[i].toString()];
279
- if (this.s.dt.settings()[0].oLanguage.sDecimal !== '') {
280
- splitRD = this.s.value[i].split(this.s.dt.settings()[0].oLanguage.sDecimal);
295
+ if (settings.oLanguage.sDecimal !== '') {
296
+ splitRD = this.s.value[i].split(settings.oLanguage.sDecimal);
281
297
  }
282
- if (this.s.dt.settings()[0].oLanguage.sThousands !== '') {
298
+ if (settings.oLanguage.sThousands !== '') {
283
299
  for (var j = 0; j < splitRD.length; j++) {
284
- splitRD[j] = splitRD[j].replace(this.s.dt.settings()[0].oLanguage.sThousands, ',');
300
+ splitRD[j] = splitRD[j].replace(settings.oLanguage.sThousands, ',');
285
301
  }
286
302
  }
287
303
  this.s.value[i] = splitRD.join('.');
@@ -290,14 +306,14 @@ let $ = jQuery;
290
306
  else if (this.s.type !== null && deFormatDates) {
291
307
  if (this.s.type.includes('date') ||
292
308
  this.s.type.includes('time')) {
293
- for (var i = 0; i < this.s.value.length; i++) {
309
+ for (i = 0; i < this.s.value.length; i++) {
294
310
  if (this.s.value[i].match(/^\d{4}-([0]\d|1[0-2])-([0-2]\d|3[01])$/g) === null) {
295
311
  this.s.value[i] = '';
296
312
  }
297
313
  }
298
314
  }
299
315
  else if (this.s.type.includes('moment')) {
300
- for (var i = 0; i < this.s.value.length; i++) {
316
+ for (i = 0; i < this.s.value.length; i++) {
301
317
  if (this.s.value[i] &&
302
318
  this.s.value[i].length > 0 &&
303
319
  moment()(this.s.value[i], this.s.dateFormat, true).isValid()) {
@@ -306,7 +322,7 @@ let $ = jQuery;
306
322
  }
307
323
  }
308
324
  else if (this.s.type.includes('luxon')) {
309
- for (var i = 0; i < this.s.value.length; i++) {
325
+ for (i = 0; i < this.s.value.length; i++) {
310
326
  if (this.s.value[i] &&
311
327
  this.s.value[i].length > 0 &&
312
328
  luxon().DateTime.fromFormat(this.s.value[i], this.s.dateFormat).invalid === null) {
@@ -316,7 +332,7 @@ let $ = jQuery;
316
332
  }
317
333
  }
318
334
  if (this.s.type.includes('num') && this.s.dt.page.info().serverSide) {
319
- for (var i = 0; i < this.s.value.length; i++) {
335
+ for (i = 0; i < this.s.value.length; i++) {
320
336
  this.s.value[i] = this.s.value[i].replace(/[^0-9.\-]/g, '');
321
337
  }
322
338
  }
@@ -336,6 +352,20 @@ let $ = jQuery;
336
352
  Criteria.prototype.getNode = function () {
337
353
  return this.dom.container;
338
354
  };
355
+ /**
356
+ * Parses formatted numbers down to a form where they can be compared
357
+ *
358
+ * @param val the value to convert
359
+ * @returns the converted value
360
+ */
361
+ Criteria.prototype.parseNumber = function (val) {
362
+ var decimal = this.s.dt.i18n('decimal');
363
+ // Remove any periods and then replace the decimal with a period
364
+ if (decimal && decimal !== '.') {
365
+ val = val.replace(/\./g, '').replace(decimal, '.');
366
+ }
367
+ return +val.replace(/(?!^-)[^0-9.]/g, '');
368
+ };
339
369
  /**
340
370
  * Populates the criteria data, condition and value(s) as far as has been selected
341
371
  */
@@ -358,7 +388,7 @@ let $ = jQuery;
358
388
  Criteria.prototype.rebuild = function (loadedCriteria) {
359
389
  // Check to see if the previously selected data exists, if so select it
360
390
  var foundData = false;
361
- var dataIdx;
391
+ var dataIdx, i;
362
392
  this._populateData();
363
393
  // If a data selection has previously been made attempt to find and select it
364
394
  if (loadedCriteria.data !== undefined) {
@@ -371,7 +401,7 @@ let $ = jQuery;
371
401
  $$3(this).prop('selected', true);
372
402
  data_1.removeClass(italic_1);
373
403
  foundData = true;
374
- dataIdx = $$3(this).val();
404
+ dataIdx = parseInt($$3(this).val(), 10);
375
405
  }
376
406
  else {
377
407
  $$3(this).removeProp('selected');
@@ -390,8 +420,7 @@ let $ = jQuery;
390
420
  var condition = void 0;
391
421
  // Check to see if the previously selected condition exists, if so select it
392
422
  var options = this.dom.condition.children('option');
393
- // eslint-disable-next-line @typescript-eslint/prefer-for-of
394
- for (var i = 0; i < options.length; i++) {
423
+ for (i = 0; i < options.length; i++) {
395
424
  var option = $$3(options[i]);
396
425
  if (loadedCriteria.condition !== undefined &&
397
426
  option.val() === loadedCriteria.condition &&
@@ -409,11 +438,10 @@ let $ = jQuery;
409
438
  this.dom.conditionTitle.removeProp('selected');
410
439
  this.dom.conditionTitle.remove();
411
440
  this.dom.condition.removeClass(this.classes.italic);
412
- // eslint-disable-next-line @typescript-eslint/prefer-for-of
413
- for (var i = 0; i < options.length; i++) {
414
- var option = $$3(options[i]);
415
- if (option.val() !== this.s.condition) {
416
- option.removeProp('selected');
441
+ for (i = 0; i < options.length; i++) {
442
+ var opt = $$3(options[i]);
443
+ if (opt.val() !== this.s.condition) {
444
+ opt.removeProp('selected');
417
445
  }
418
446
  }
419
447
  this._populateValue(loadedCriteria);
@@ -434,7 +462,6 @@ let $ = jQuery;
434
462
  _this.dom.dataTitle.removeProp('selected');
435
463
  // Need to go over every option to identify the correct selection
436
464
  var options = _this.dom.data.children('option.' + _this.classes.option);
437
- // eslint-disable-next-line @typescript-eslint/prefer-for-of
438
465
  for (var i = 0; i < options.length; i++) {
439
466
  var option = $$3(options[i]);
440
467
  if (option.val() === _this.dom.data.val()) {
@@ -453,7 +480,7 @@ let $ = jQuery;
453
480
  // remove it from the search and trigger a new search
454
481
  if (_this.s.filled) {
455
482
  _this.s.filled = false;
456
- _this.s.dt.draw();
483
+ _this.doSearch();
457
484
  _this.setListeners();
458
485
  }
459
486
  _this.s.dt.state.save();
@@ -469,7 +496,6 @@ let $ = jQuery;
469
496
  _this.dom.conditionTitle.removeProp('selected');
470
497
  // Need to go over every option to identify the correct selection
471
498
  var options = _this.dom.condition.children('option.' + _this.classes.option);
472
- // eslint-disable-next-line @typescript-eslint/prefer-for-of
473
499
  for (var i = 0; i < options.length; i++) {
474
500
  var option = $$3(options[i]);
475
501
  if (option.val() === _this.dom.condition.val()) {
@@ -494,13 +520,13 @@ let $ = jQuery;
494
520
  // it from the search and trigger a new search
495
521
  if (_this.s.filled && val !== undefined && _this.dom.inputCont.has(val[0]).length !== 0) {
496
522
  _this.s.filled = false;
497
- _this.s.dt.draw();
523
+ _this.doSearch();
498
524
  _this.setListeners();
499
525
  }
500
526
  }
501
527
  if (_this.dom.value.length === 0 ||
502
528
  _this.dom.value.length === 1 && _this.dom.value[0] === undefined) {
503
- _this.s.dt.draw();
529
+ _this.doSearch();
504
530
  }
505
531
  }
506
532
  else {
@@ -558,20 +584,18 @@ let $ = jQuery;
558
584
  * Clears the value elements
559
585
  */
560
586
  Criteria.prototype._clearValue = function () {
587
+ var val;
561
588
  if (this.s.condition !== undefined) {
562
589
  if (this.dom.value.length > 0 && this.dom.value[0] !== undefined) {
563
- var _loop_1 = function (val) {
590
+ // Remove all of the value elements
591
+ for (var _i = 0, _a = this.dom.value; _i < _a.length; _i++) {
592
+ val = _a[_i];
564
593
  if (val !== undefined) {
565
594
  // Timeout is annoying but because of IOS
566
595
  setTimeout(function () {
567
596
  val.remove();
568
597
  }, 50);
569
598
  }
570
- };
571
- // Remove all of the value elements
572
- for (var _i = 0, _a = this.dom.value; _i < _a.length; _i++) {
573
- var val = _a[_i];
574
- _loop_1(val);
575
599
  }
576
600
  }
577
601
  // Call the init function to get the value elements for this condition
@@ -581,27 +605,24 @@ let $ = jQuery;
581
605
  .empty()
582
606
  .append(this.dom.value[0])
583
607
  .insertAfter(this.dom.condition);
584
- this.dom.value[0].trigger('dtsb-inserted');
608
+ $$3(this.dom.value[0]).trigger('dtsb-inserted');
585
609
  // Insert all of the value elements
586
610
  for (var i = 1; i < this.dom.value.length; i++) {
587
611
  this.dom.inputCont.append(this.dom.value[i]);
588
- this.dom.value[i].trigger('dtsb-inserted');
612
+ $$3(this.dom.value[i]).trigger('dtsb-inserted');
589
613
  }
590
614
  }
591
615
  }
592
616
  else {
593
- var _loop_2 = function (val) {
617
+ // Remove all of the value elements
618
+ for (var _b = 0, _c = this.dom.value; _b < _c.length; _b++) {
619
+ val = _c[_b];
594
620
  if (val !== undefined) {
595
621
  // Timeout is annoying but because of IOS
596
622
  setTimeout(function () {
597
623
  val.remove();
598
624
  }, 50);
599
625
  }
600
- };
601
- // Remove all of the value elements
602
- for (var _b = 0, _c = this.dom.value; _b < _c.length; _b++) {
603
- var val = _c[_b];
604
- _loop_2(val);
605
626
  }
606
627
  // Append the default valueTitle to the default select element
607
628
  this.dom.valueTitle
@@ -637,9 +658,10 @@ let $ = jQuery;
637
658
  var conditionsLength = Object.keys(this.s.conditions).length;
638
659
  var colInits = this.s.dt.settings()[0].aoColumns;
639
660
  var column = +this.dom.data.children('option:selected').val();
661
+ var condition, condName;
640
662
  // If there are no conditions stored then we need to get them from the appropriate type
641
663
  if (conditionsLength === 0) {
642
- this.s.type = this.s.dt.columns().type().toArray()[column];
664
+ this.s.type = this.s.dt.column(column).type();
643
665
  if (colInits !== undefined) {
644
666
  var colInit = colInits[column];
645
667
  if (colInit.searchBuilderType !== undefined && colInit.searchBuilderType !== null) {
@@ -649,10 +671,13 @@ let $ = jQuery;
649
671
  this.s.type = colInit.sType;
650
672
  }
651
673
  }
652
- // If the column type is still unknown, call a draw to try reading it again
674
+ // If the column type is still unknown use the internal API to detect type
653
675
  if (this.s.type === null || this.s.type === undefined) {
654
- $$3.fn.dataTable.ext.oApi._fnColumnTypes(this.s.dt.settings()[0]);
655
- this.s.type = this.s.dt.columns().type().toArray()[column];
676
+ // This can only happen in DT1 - DT2 will do the invalidation of the type itself
677
+ if ($$3.fn.dataTable.ext.oApi) {
678
+ $$3.fn.dataTable.ext.oApi._fnColumnTypes(this.s.dt.settings()[0]);
679
+ }
680
+ this.s.type = this.s.dt.column(column).type();
656
681
  }
657
682
  // Enable the condition element
658
683
  this.dom.condition
@@ -689,7 +714,7 @@ let $ = jQuery;
689
714
  }
690
715
  // Add all of the conditions to the select element
691
716
  for (var _i = 0, _a = Object.keys(conditionObj); _i < _a.length; _i++) {
692
- var condition = _a[_i];
717
+ condition = _a[_i];
693
718
  if (conditionObj[condition] !== null) {
694
719
  // Serverside processing does not supply the options for the select elements
695
720
  // Instead input elements need to be used for these instead
@@ -707,7 +732,7 @@ let $ = jQuery;
707
732
  }
708
733
  }
709
734
  this.s.conditions[condition] = conditionObj[condition];
710
- var condName = conditionObj[condition].conditionName;
735
+ condName = conditionObj[condition].conditionName;
711
736
  if (typeof condName === 'function') {
712
737
  condName = condName(this.s.dt, this.c.i18n);
713
738
  }
@@ -724,18 +749,18 @@ let $ = jQuery;
724
749
  else if (conditionsLength > 0) {
725
750
  this.dom.condition.empty().removeAttr('disabled').addClass(this.classes.italic);
726
751
  for (var _b = 0, _c = Object.keys(this.s.conditions); _b < _c.length; _b++) {
727
- var condition = _c[_b];
728
- var condName = this.s.conditions[condition].conditionName;
729
- if (typeof condName === 'function') {
730
- condName = condName(this.s.dt, this.c.i18n);
752
+ condition = _c[_b];
753
+ var name_1 = this.s.conditions[condition].conditionName;
754
+ if (typeof name_1 === 'function') {
755
+ name_1 = name_1(this.s.dt, this.c.i18n);
731
756
  }
732
757
  var newOpt = $$3('<option>', {
733
- text: condName,
758
+ text: name_1,
734
759
  value: condition
735
760
  })
736
761
  .addClass(this.classes.option)
737
762
  .addClass(this.classes.notItalic);
738
- if (this.s.condition !== undefined && this.s.condition === condName) {
763
+ if (this.s.condition !== undefined && this.s.condition === name_1) {
739
764
  newOpt.prop('selected', true);
740
765
  this.dom.condition.removeClass(this.classes.italic);
741
766
  }
@@ -767,7 +792,7 @@ let $ = jQuery;
767
792
  // Need to check against the stored conditions so we can match the token "cond" to the option
768
793
  for (var _e = 0, _f = Object.keys(this.s.conditions); _e < _f.length; _e++) {
769
794
  var cond = _f[_e];
770
- var condName = this.s.conditions[cond].conditionName;
795
+ condName = this.s.conditions[cond].conditionName;
771
796
  if (
772
797
  // If the conditionName matches the text of the option
773
798
  (typeof condName === 'string' ? condName : condName(this.s.dt, this.c.i18n)) ===
@@ -830,13 +855,14 @@ let $ = jQuery;
830
855
  Criteria.prototype._populateValue = function (loadedCriteria) {
831
856
  var _this = this;
832
857
  var prevFilled = this.s.filled;
858
+ var i;
833
859
  this.s.filled = false;
834
860
  // Remove any previous value elements
835
861
  // Timeout is annoying but because of IOS
836
862
  setTimeout(function () {
837
863
  _this.dom.defaultValue.remove();
838
864
  }, 50);
839
- var _loop_3 = function (val) {
865
+ var _loop_1 = function (val) {
840
866
  // Timeout is annoying but because of IOS
841
867
  setTimeout(function () {
842
868
  if (val !== undefined) {
@@ -846,12 +872,11 @@ let $ = jQuery;
846
872
  };
847
873
  for (var _i = 0, _a = this.dom.value; _i < _a.length; _i++) {
848
874
  var val = _a[_i];
849
- _loop_3(val);
875
+ _loop_1(val);
850
876
  }
851
877
  var children = this.dom.inputCont.children();
852
878
  if (children.length > 1) {
853
- // eslint-disable-next-line @typescript-eslint/prefer-for-of
854
- for (var i = 0; i < children.length; i++) {
879
+ for (i = 0; i < children.length; i++) {
855
880
  $$3(children[i]).remove();
856
881
  }
857
882
  }
@@ -871,12 +896,12 @@ let $ = jQuery;
871
896
  this.dom.inputCont.empty();
872
897
  // Insert value elements and trigger the inserted event
873
898
  if (this.dom.value[0] !== undefined) {
874
- this.dom.value[0]
899
+ $$3(this.dom.value[0])
875
900
  .appendTo(this.dom.inputCont)
876
901
  .trigger('dtsb-inserted');
877
902
  }
878
- for (var i = 1; i < this.dom.value.length; i++) {
879
- this.dom.value[i]
903
+ for (i = 1; i < this.dom.value.length; i++) {
904
+ $$3(this.dom.value[i])
880
905
  .insertAfter(this.dom.value[i - 1])
881
906
  .trigger('dtsb-inserted');
882
907
  }
@@ -888,7 +913,7 @@ let $ = jQuery;
888
913
  // If using SSP we want to restrict the amount of server calls that take place
889
914
  // and this will already have taken place
890
915
  if (!this.s.dt.page.info().serverSide) {
891
- this.s.dt.draw();
916
+ this.doSearch();
892
917
  }
893
918
  this.setListeners();
894
919
  }
@@ -956,7 +981,7 @@ let $ = jQuery;
956
981
  if (array === void 0) { array = false; }
957
982
  var column = that.dom.data.children('option:selected').val();
958
983
  var indexArray = that.s.dt.rows().indexes().toArray();
959
- var settings = that.s.dt.settings()[0];
984
+ var fastData = that.s.dt.settings()[0].fastData;
960
985
  that.dom.valueTitle.prop('selected', true);
961
986
  // Declare select element to be used with all of the default classes and listeners.
962
987
  var el = $$3('<select/>')
@@ -978,7 +1003,7 @@ let $ = jQuery;
978
1003
  // Only add one option for each possible value
979
1004
  for (var _i = 0, indexArray_1 = indexArray; _i < indexArray_1.length; _i++) {
980
1005
  var index = indexArray_1[_i];
981
- var filter = settings.oApi._fnGetCellData(settings, index, column, typeof that.c.orthogonal === 'string' ?
1006
+ var filter = fastData(index, column, typeof that.c.orthogonal === 'string' ?
982
1007
  that.c.orthogonal :
983
1008
  that.c.orthogonal.search);
984
1009
  var value = {
@@ -986,7 +1011,7 @@ let $ = jQuery;
986
1011
  filter.replace(/[\r\n\u2028]/g, ' ') : // Need to replace certain characters to match search values
987
1012
  filter,
988
1013
  index: index,
989
- text: settings.oApi._fnGetCellData(settings, index, column, typeof that.c.orthogonal === 'string' ?
1014
+ text: fastData(index, column, typeof that.c.orthogonal === 'string' ?
990
1015
  that.c.orthogonal :
991
1016
  that.c.orthogonal.display)
992
1017
  };
@@ -1279,14 +1304,14 @@ let $ = jQuery;
1279
1304
  i18n: i18n
1280
1305
  })
1281
1306
  .on('change.dtsb', searchDelay !== null ?
1282
- that.s.dt.settings()[0].oApi._fnThrottle(function () {
1307
+ DataTable.util.throttle(function () {
1283
1308
  return fn(that, this);
1284
1309
  }, searchDelay) :
1285
1310
  function () {
1286
1311
  fn(that, _this);
1287
1312
  })
1288
1313
  .on('input.dtsb keypress.dtsb', function (e) {
1289
- that.s.dt.settings()[0].oApi._fnThrottle(function () {
1314
+ DataTable.util.throttle(function () {
1290
1315
  var code = e.keyCode || e.which;
1291
1316
  return fn(that, this, code);
1292
1317
  }, searchDelay === null ? 0 : searchDelay);
@@ -1303,7 +1328,7 @@ let $ = jQuery;
1303
1328
  i18n: i18n
1304
1329
  })
1305
1330
  .on('change.dtsb', searchDelay !== null ?
1306
- that.s.dt.settings()[0].oApi._fnThrottle(function () {
1331
+ DataTable.util.throttle(function () {
1307
1332
  return fn(that, this);
1308
1333
  }, searchDelay) :
1309
1334
  function () {
@@ -1313,7 +1338,7 @@ let $ = jQuery;
1313
1338
  !(that.s.dt.settings()[0].oInit.search !== undefined &&
1314
1339
  that.s.dt.settings()[0].oInit.search["return"]) &&
1315
1340
  searchDelay !== null ?
1316
- that.s.dt.settings()[0].oApi._fnThrottle(function () {
1341
+ DataTable.util.throttle(function () {
1317
1342
  return fn(that, this);
1318
1343
  }, searchDelay) :
1319
1344
  function (e) {
@@ -1403,6 +1428,7 @@ let $ = jQuery;
1403
1428
  // When the value is changed the criteria is now complete so can be included in searches
1404
1429
  // Get the condition from the map based on the key that has been selected for the condition
1405
1430
  var condition = that.s.conditions[that.s.condition];
1431
+ var i;
1406
1432
  that.s.filled = condition.isInputValid(that.dom.value, that);
1407
1433
  that.s.value = condition.inputValue(that.dom.value, that);
1408
1434
  if (!that.s.filled) {
@@ -1410,38 +1436,23 @@ let $ = jQuery;
1410
1436
  !(that.s.dt.settings()[0].oInit.search !== undefined &&
1411
1437
  that.s.dt.settings()[0].oInit.search["return"]) ||
1412
1438
  code === 13) {
1413
- that.s.dt.draw();
1439
+ that.doSearch();
1414
1440
  }
1415
1441
  return;
1416
1442
  }
1417
1443
  if (!Array.isArray(that.s.value)) {
1418
1444
  that.s.value = [that.s.value];
1419
1445
  }
1420
- for (var i = 0; i < that.s.value.length; i++) {
1446
+ for (i = 0; i < that.s.value.length; i++) {
1421
1447
  // If the value is an array we need to sort it
1422
1448
  if (Array.isArray(that.s.value[i])) {
1423
1449
  that.s.value[i].sort();
1424
1450
  }
1425
- // Otherwise replace the decimal place character for i18n
1426
- else if (that.s.type.includes('num') &&
1427
- (that.s.dt.settings()[0].oLanguage.sDecimal !== '' ||
1428
- that.s.dt.settings()[0].oLanguage.sThousands !== '')) {
1429
- var splitRD = [that.s.value[i].toString()];
1430
- if (that.s.dt.settings()[0].oLanguage.sDecimal !== '') {
1431
- splitRD = that.s.value[i].split(that.s.dt.settings()[0].oLanguage.sDecimal);
1432
- }
1433
- if (that.s.dt.settings()[0].oLanguage.sThousands !== '') {
1434
- for (var j = 0; j < splitRD.length; j++) {
1435
- splitRD[j] = splitRD[j].replace(that.s.dt.settings()[0].oLanguage.sThousands, ',');
1436
- }
1437
- }
1438
- that.s.value[i] = splitRD.join('.');
1439
- }
1440
1451
  }
1441
1452
  // Take note of the cursor position so that we can refocus there later
1442
1453
  var idx = null;
1443
1454
  var cursorPos = null;
1444
- for (var i = 0; i < that.dom.value.length; i++) {
1455
+ for (i = 0; i < that.dom.value.length; i++) {
1445
1456
  if (el === that.dom.value[i][0]) {
1446
1457
  idx = i;
1447
1458
  if (el.selectionStart !== undefined) {
@@ -1454,7 +1465,7 @@ let $ = jQuery;
1454
1465
  that.s.dt.settings()[0].oInit.search["return"]) ||
1455
1466
  code === 13) {
1456
1467
  // Trigger a search
1457
- that.s.dt.draw();
1468
+ that.doSearch();
1458
1469
  }
1459
1470
  // Refocus the element and set the correct cursor position
1460
1471
  if (idx !== null) {
@@ -1468,7 +1479,6 @@ let $ = jQuery;
1468
1479
  // The order of the conditions will make eslint sad :(
1469
1480
  // Has to be in this order so that they are displayed correctly in select elements
1470
1481
  // Also have to disable member ordering for this as the private methods used are not yet declared otherwise
1471
- // eslint-disable-next-line @typescript-eslint/member-ordering
1472
1482
  Criteria.dateConditions = {
1473
1483
  '=': {
1474
1484
  conditionName: function (dt, i18n) {
@@ -1482,7 +1492,6 @@ let $ = jQuery;
1482
1492
  return value === comparison[0];
1483
1493
  }
1484
1494
  },
1485
- // eslint-disable-next-line sort-keys
1486
1495
  '!=': {
1487
1496
  conditionName: function (dt, i18n) {
1488
1497
  return dt.i18n('searchBuilder.conditions.date.not', i18n.conditions.date.not);
@@ -1536,7 +1545,6 @@ let $ = jQuery;
1536
1545
  }
1537
1546
  }
1538
1547
  },
1539
- // eslint-disable-next-line sort-keys
1540
1548
  '!between': {
1541
1549
  conditionName: function (dt, i18n) {
1542
1550
  return dt.i18n('searchBuilder.conditions.date.notBetween', i18n.conditions.date.notBetween);
@@ -1569,7 +1577,6 @@ let $ = jQuery;
1569
1577
  return value === null || value === undefined || value.length === 0;
1570
1578
  }
1571
1579
  },
1572
- // eslint-disable-next-line sort-keys
1573
1580
  '!null': {
1574
1581
  conditionName: function (dt, i18n) {
1575
1582
  return dt.i18n('searchBuilder.conditions.date.notEmpty', i18n.conditions.date.notEmpty);
@@ -1589,7 +1596,6 @@ let $ = jQuery;
1589
1596
  // The order of the conditions will make eslint sad :(
1590
1597
  // Has to be in this order so that they are displayed correctly in select elements
1591
1598
  // Also have to disable member ordering for this as the private methods used are not yet declared otherwise
1592
- // eslint-disable-next-line @typescript-eslint/member-ordering
1593
1599
  Criteria.momentDateConditions = {
1594
1600
  '=': {
1595
1601
  conditionName: function (dt, i18n) {
@@ -1603,7 +1609,6 @@ let $ = jQuery;
1603
1609
  moment()(comparison[0], that.s.dateFormat).valueOf();
1604
1610
  }
1605
1611
  },
1606
- // eslint-disable-next-line sort-keys
1607
1612
  '!=': {
1608
1613
  conditionName: function (dt, i18n) {
1609
1614
  return dt.i18n('searchBuilder.conditions.date.not', i18n.conditions.date.not);
@@ -1657,7 +1662,6 @@ let $ = jQuery;
1657
1662
  }
1658
1663
  }
1659
1664
  },
1660
- // eslint-disable-next-line sort-keys
1661
1665
  '!between': {
1662
1666
  conditionName: function (dt, i18n) {
1663
1667
  return dt.i18n('searchBuilder.conditions.date.notBetween', i18n.conditions.date.notBetween);
@@ -1692,7 +1696,6 @@ let $ = jQuery;
1692
1696
  return value === null || value === undefined || value.length === 0;
1693
1697
  }
1694
1698
  },
1695
- // eslint-disable-next-line sort-keys
1696
1699
  '!null': {
1697
1700
  conditionName: function (dt, i18n) {
1698
1701
  return dt.i18n('searchBuilder.conditions.date.notEmpty', i18n.conditions.date.notEmpty);
@@ -1712,7 +1715,6 @@ let $ = jQuery;
1712
1715
  // The order of the conditions will make eslint sad :(
1713
1716
  // Has to be in this order so that they are displayed correctly in select elements
1714
1717
  // Also have to disable member ordering for this as the private methods used are not yet declared otherwise
1715
- // eslint-disable-next-line @typescript-eslint/member-ordering
1716
1718
  Criteria.luxonDateConditions = {
1717
1719
  '=': {
1718
1720
  conditionName: function (dt, i18n) {
@@ -1726,7 +1728,6 @@ let $ = jQuery;
1726
1728
  === luxon().DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
1727
1729
  }
1728
1730
  },
1729
- // eslint-disable-next-line sort-keys
1730
1731
  '!=': {
1731
1732
  conditionName: function (dt, i18n) {
1732
1733
  return dt.i18n('searchBuilder.conditions.date.not', i18n.conditions.date.not);
@@ -1782,7 +1783,6 @@ let $ = jQuery;
1782
1783
  }
1783
1784
  }
1784
1785
  },
1785
- // eslint-disable-next-line sort-keys
1786
1786
  '!between': {
1787
1787
  conditionName: function (dt, i18n) {
1788
1788
  return dt.i18n('searchBuilder.conditions.date.notBetween', i18n.conditions.date.notBetween);
@@ -1817,7 +1817,6 @@ let $ = jQuery;
1817
1817
  return value === null || value === undefined || value.length === 0;
1818
1818
  }
1819
1819
  },
1820
- // eslint-disable-next-line sort-keys
1821
1820
  '!null': {
1822
1821
  conditionName: function (dt, i18n) {
1823
1822
  return dt.i18n('searchBuilder.conditions.date.notEmpty', i18n.conditions.date.notEmpty);
@@ -1837,7 +1836,6 @@ let $ = jQuery;
1837
1836
  // The order of the conditions will make eslint sad :(
1838
1837
  // Has to be in this order so that they are displayed correctly in select elements
1839
1838
  // Also have to disable member ordering for this as the private methods used are not yet declared otherwise
1840
- // eslint-disable-next-line @typescript-eslint/member-ordering
1841
1839
  Criteria.numConditions = {
1842
1840
  '=': {
1843
1841
  conditionName: function (dt, i18n) {
@@ -1850,7 +1848,6 @@ let $ = jQuery;
1850
1848
  return +value === +comparison[0];
1851
1849
  }
1852
1850
  },
1853
- // eslint-disable-next-line sort-keys
1854
1851
  '!=': {
1855
1852
  conditionName: function (dt, i18n) {
1856
1853
  return dt.i18n('searchBuilder.conditions.number.not', i18n.conditions.number.not);
@@ -1895,7 +1892,6 @@ let $ = jQuery;
1895
1892
  return +value >= +comparison[0];
1896
1893
  }
1897
1894
  },
1898
- // eslint-disable-next-line sort-keys
1899
1895
  '>': {
1900
1896
  conditionName: function (dt, i18n) {
1901
1897
  return dt.i18n('searchBuilder.conditions.number.gt', i18n.conditions.number.gt);
@@ -1923,7 +1919,6 @@ let $ = jQuery;
1923
1919
  }
1924
1920
  }
1925
1921
  },
1926
- // eslint-disable-next-line sort-keys
1927
1922
  '!between': {
1928
1923
  conditionName: function (dt, i18n) {
1929
1924
  return dt.i18n('searchBuilder.conditions.number.notBetween', i18n.conditions.number.notBetween);
@@ -1955,7 +1950,6 @@ let $ = jQuery;
1955
1950
  return value === null || value === undefined || value.length === 0;
1956
1951
  }
1957
1952
  },
1958
- // eslint-disable-next-line sort-keys
1959
1953
  '!null': {
1960
1954
  conditionName: function (dt, i18n) {
1961
1955
  return dt.i18n('searchBuilder.conditions.number.notEmpty', i18n.conditions.number.notEmpty);
@@ -1975,7 +1969,6 @@ let $ = jQuery;
1975
1969
  // The order of the conditions will make eslint sad :(
1976
1970
  // Has to be in this order so that they are displayed correctly in select elements
1977
1971
  // Also have to disable member ordering for this as the private methods used are not yet declared otherwise
1978
- // eslint-disable-next-line @typescript-eslint/member-ordering
1979
1972
  Criteria.numFmtConditions = {
1980
1973
  '=': {
1981
1974
  conditionName: function (dt, i18n) {
@@ -1984,11 +1977,10 @@ let $ = jQuery;
1984
1977
  init: Criteria.initSelect,
1985
1978
  inputValue: Criteria.inputValueSelect,
1986
1979
  isInputValid: Criteria.isInputValidSelect,
1987
- search: function (value, comparison) {
1988
- return Criteria.parseNumFmt(value) === Criteria.parseNumFmt(comparison[0]);
1980
+ search: function (value, comparison, criteria) {
1981
+ return criteria.parseNumber(value) === criteria.parseNumber(comparison[0]);
1989
1982
  }
1990
1983
  },
1991
- // eslint-disable-next-line sort-keys
1992
1984
  '!=': {
1993
1985
  conditionName: function (dt, i18n) {
1994
1986
  return dt.i18n('searchBuilder.conditions.number.not', i18n.conditions.number.not);
@@ -1996,8 +1988,8 @@ let $ = jQuery;
1996
1988
  init: Criteria.initSelect,
1997
1989
  inputValue: Criteria.inputValueSelect,
1998
1990
  isInputValid: Criteria.isInputValidSelect,
1999
- search: function (value, comparison) {
2000
- return Criteria.parseNumFmt(value) !== Criteria.parseNumFmt(comparison[0]);
1991
+ search: function (value, comparison, criteria) {
1992
+ return criteria.parseNumber(value) !== criteria.parseNumber(comparison[0]);
2001
1993
  }
2002
1994
  },
2003
1995
  '<': {
@@ -2007,8 +1999,8 @@ let $ = jQuery;
2007
1999
  init: Criteria.initInput,
2008
2000
  inputValue: Criteria.inputValueInput,
2009
2001
  isInputValid: Criteria.isInputValidInput,
2010
- search: function (value, comparison) {
2011
- return Criteria.parseNumFmt(value) < Criteria.parseNumFmt(comparison[0]);
2002
+ search: function (value, comparison, criteria) {
2003
+ return criteria.parseNumber(value) < criteria.parseNumber(comparison[0]);
2012
2004
  }
2013
2005
  },
2014
2006
  '<=': {
@@ -2018,8 +2010,8 @@ let $ = jQuery;
2018
2010
  init: Criteria.initInput,
2019
2011
  inputValue: Criteria.inputValueInput,
2020
2012
  isInputValid: Criteria.isInputValidInput,
2021
- search: function (value, comparison) {
2022
- return Criteria.parseNumFmt(value) <= Criteria.parseNumFmt(comparison[0]);
2013
+ search: function (value, comparison, criteria) {
2014
+ return criteria.parseNumber(value) <= criteria.parseNumber(comparison[0]);
2023
2015
  }
2024
2016
  },
2025
2017
  '>=': {
@@ -2029,11 +2021,10 @@ let $ = jQuery;
2029
2021
  init: Criteria.initInput,
2030
2022
  inputValue: Criteria.inputValueInput,
2031
2023
  isInputValid: Criteria.isInputValidInput,
2032
- search: function (value, comparison) {
2033
- return Criteria.parseNumFmt(value) >= Criteria.parseNumFmt(comparison[0]);
2024
+ search: function (value, comparison, criteria) {
2025
+ return criteria.parseNumber(value) >= criteria.parseNumber(comparison[0]);
2034
2026
  }
2035
2027
  },
2036
- // eslint-disable-next-line sort-keys
2037
2028
  '>': {
2038
2029
  conditionName: function (dt, i18n) {
2039
2030
  return dt.i18n('searchBuilder.conditions.number.gt', i18n.conditions.number.gt);
@@ -2041,8 +2032,8 @@ let $ = jQuery;
2041
2032
  init: Criteria.initInput,
2042
2033
  inputValue: Criteria.inputValueInput,
2043
2034
  isInputValid: Criteria.isInputValidInput,
2044
- search: function (value, comparison) {
2045
- return Criteria.parseNumFmt(value) > Criteria.parseNumFmt(comparison[0]);
2035
+ search: function (value, comparison, criteria) {
2036
+ return criteria.parseNumber(value) > criteria.parseNumber(comparison[0]);
2046
2037
  }
2047
2038
  },
2048
2039
  'between': {
@@ -2052,10 +2043,10 @@ let $ = jQuery;
2052
2043
  init: Criteria.init2Input,
2053
2044
  inputValue: Criteria.inputValueInput,
2054
2045
  isInputValid: Criteria.isInputValidInput,
2055
- search: function (value, comparison) {
2056
- var val = Criteria.parseNumFmt(value);
2057
- var comp0 = Criteria.parseNumFmt(comparison[0]);
2058
- var comp1 = Criteria.parseNumFmt(comparison[1]);
2046
+ search: function (value, comparison, criteria) {
2047
+ var val = criteria.parseNumber(value);
2048
+ var comp0 = criteria.parseNumber(comparison[0]);
2049
+ var comp1 = criteria.parseNumber(comparison[1]);
2059
2050
  if (+comp0 < +comp1) {
2060
2051
  return +comp0 <= +val && +val <= +comp1;
2061
2052
  }
@@ -2064,7 +2055,6 @@ let $ = jQuery;
2064
2055
  }
2065
2056
  }
2066
2057
  },
2067
- // eslint-disable-next-line sort-keys
2068
2058
  '!between': {
2069
2059
  conditionName: function (dt, i18n) {
2070
2060
  return dt.i18n('searchBuilder.conditions.number.notBetween', i18n.conditions.number.notBetween);
@@ -2072,10 +2062,10 @@ let $ = jQuery;
2072
2062
  init: Criteria.init2Input,
2073
2063
  inputValue: Criteria.inputValueInput,
2074
2064
  isInputValid: Criteria.isInputValidInput,
2075
- search: function (value, comparison) {
2076
- var val = Criteria.parseNumFmt(value);
2077
- var comp0 = Criteria.parseNumFmt(comparison[0]);
2078
- var comp1 = Criteria.parseNumFmt(comparison[1]);
2065
+ search: function (value, comparison, criteria) {
2066
+ var val = criteria.parseNumber(value);
2067
+ var comp0 = criteria.parseNumber(comparison[0]);
2068
+ var comp1 = criteria.parseNumber(comparison[1]);
2079
2069
  if (+comp0 < +comp1) {
2080
2070
  return !(+comp0 <= +val && +val <= +comp1);
2081
2071
  }
@@ -2099,7 +2089,6 @@ let $ = jQuery;
2099
2089
  return value === null || value === undefined || value.length === 0;
2100
2090
  }
2101
2091
  },
2102
- // eslint-disable-next-line sort-keys
2103
2092
  '!null': {
2104
2093
  conditionName: function (dt, i18n) {
2105
2094
  return dt.i18n('searchBuilder.conditions.number.notEmpty', i18n.conditions.number.notEmpty);
@@ -2119,7 +2108,6 @@ let $ = jQuery;
2119
2108
  // The order of the conditions will make eslint sad :(
2120
2109
  // Has to be in this order so that they are displayed correctly in select elements
2121
2110
  // Also have to disable member ordering for this as the private methods used are not yet declared otherwise
2122
- // eslint-disable-next-line @typescript-eslint/member-ordering
2123
2111
  Criteria.stringConditions = {
2124
2112
  '=': {
2125
2113
  conditionName: function (dt, i18n) {
@@ -2132,7 +2120,6 @@ let $ = jQuery;
2132
2120
  return value === comparison[0];
2133
2121
  }
2134
2122
  },
2135
- // eslint-disable-next-line sort-keys
2136
2123
  '!=': {
2137
2124
  conditionName: function (dt, i18n) {
2138
2125
  return dt.i18n('searchBuilder.conditions.string.not', i18n.conditions.string.not);
@@ -2155,7 +2142,6 @@ let $ = jQuery;
2155
2142
  return value.toLowerCase().indexOf(comparison[0].toLowerCase()) === 0;
2156
2143
  }
2157
2144
  },
2158
- // eslint-disable-next-line sort-keys
2159
2145
  '!starts': {
2160
2146
  conditionName: function (dt, i18n) {
2161
2147
  return dt.i18n('searchBuilder.conditions.string.notStartsWith', i18n.conditions.string.notStartsWith);
@@ -2167,7 +2153,6 @@ let $ = jQuery;
2167
2153
  return value.toLowerCase().indexOf(comparison[0].toLowerCase()) !== 0;
2168
2154
  }
2169
2155
  },
2170
- // eslint-disable-next-line sort-keys
2171
2156
  'contains': {
2172
2157
  conditionName: function (dt, i18n) {
2173
2158
  return dt.i18n('searchBuilder.conditions.string.contains', i18n.conditions.string.contains);
@@ -2179,7 +2164,6 @@ let $ = jQuery;
2179
2164
  return value.toLowerCase().includes(comparison[0].toLowerCase());
2180
2165
  }
2181
2166
  },
2182
- // eslint-disable-next-line sort-keys
2183
2167
  '!contains': {
2184
2168
  conditionName: function (dt, i18n) {
2185
2169
  return dt.i18n('searchBuilder.conditions.string.notContains', i18n.conditions.string.notContains);
@@ -2202,7 +2186,6 @@ let $ = jQuery;
2202
2186
  return value.toLowerCase().endsWith(comparison[0].toLowerCase());
2203
2187
  }
2204
2188
  },
2205
- // eslint-disable-next-line sort-keys
2206
2189
  '!ends': {
2207
2190
  conditionName: function (dt, i18n) {
2208
2191
  return dt.i18n('searchBuilder.conditions.string.notEndsWith', i18n.conditions.string.notEndsWith);
@@ -2229,7 +2212,6 @@ let $ = jQuery;
2229
2212
  return value === null || value === undefined || value.length === 0;
2230
2213
  }
2231
2214
  },
2232
- // eslint-disable-next-line sort-keys
2233
2215
  '!null': {
2234
2216
  conditionName: function (dt, i18n) {
2235
2217
  return dt.i18n('searchBuilder.conditions.string.notEmpty', i18n.conditions.string.notEmpty);
@@ -2248,7 +2230,6 @@ let $ = jQuery;
2248
2230
  };
2249
2231
  // The order of the conditions will make eslint sad :(
2250
2232
  // Also have to disable member ordering for this as the private methods used are not yet declared otherwise
2251
- // eslint-disable-next-line @typescript-eslint/member-ordering
2252
2233
  Criteria.arrayConditions = {
2253
2234
  'contains': {
2254
2235
  conditionName: function (dt, i18n) {
@@ -2272,7 +2253,6 @@ let $ = jQuery;
2272
2253
  return value.indexOf(comparison[0]) === -1;
2273
2254
  }
2274
2255
  },
2275
- // eslint-disable-next-line sort-keys
2276
2256
  '=': {
2277
2257
  conditionName: function (dt, i18n) {
2278
2258
  return dt.i18n('searchBuilder.conditions.array.equals', i18n.conditions.array.equals);
@@ -2292,7 +2272,6 @@ let $ = jQuery;
2292
2272
  return false;
2293
2273
  }
2294
2274
  },
2295
- // eslint-disable-next-line sort-keys
2296
2275
  '!=': {
2297
2276
  conditionName: function (dt, i18n) {
2298
2277
  return dt.i18n('searchBuilder.conditions.array.not', i18n.conditions.array.not);
@@ -2327,7 +2306,6 @@ let $ = jQuery;
2327
2306
  return value === null || value === undefined || value.length === 0;
2328
2307
  }
2329
2308
  },
2330
- // eslint-disable-next-line sort-keys
2331
2309
  '!null': {
2332
2310
  conditionName: function (dt, i18n) {
2333
2311
  return dt.i18n('searchBuilder.conditions.array.notEmpty', i18n.conditions.array.notEmpty);
@@ -2346,7 +2324,6 @@ let $ = jQuery;
2346
2324
  };
2347
2325
  // eslint will be sad because we have to disable member ordering for this as the
2348
2326
  // private static properties used are not yet declared otherwise
2349
- // eslint-disable-next-line @typescript-eslint/member-ordering
2350
2327
  Criteria.defaults = {
2351
2328
  columns: true,
2352
2329
  conditions: {
@@ -2382,6 +2359,7 @@ let $ = jQuery;
2382
2359
  logicOr: 'Or',
2383
2360
  right: '>',
2384
2361
  rightTitle: 'Indent criteria',
2362
+ search: 'Search',
2385
2363
  title: {
2386
2364
  0: 'Custom Search Builder',
2387
2365
  _: 'Custom Search Builder (%d)'
@@ -2389,6 +2367,7 @@ let $ = jQuery;
2389
2367
  value: 'Value',
2390
2368
  valueJoiner: 'and'
2391
2369
  },
2370
+ liveSearch: true,
2392
2371
  logic: 'AND',
2393
2372
  orthogonal: {
2394
2373
  display: 'display',
@@ -2455,7 +2434,12 @@ let $ = jQuery;
2455
2434
  .addClass(this.classes.button)
2456
2435
  .attr('type', 'button'),
2457
2436
  logicContainer: $$2('<div/>')
2458
- .addClass(this.classes.logicContainer)
2437
+ .addClass(this.classes.logicContainer),
2438
+ search: $$2('<button/>')
2439
+ .addClass(this.classes.search)
2440
+ .addClass(this.classes.button)
2441
+ .attr('type', 'button')
2442
+ .css('display', 'none')
2459
2443
  };
2460
2444
  // A reference to the top level group is maintained throughout any subgroups and criteria that may be created
2461
2445
  if (this.s.topGroup === undefined) {
@@ -2471,6 +2455,7 @@ let $ = jQuery;
2471
2455
  // Turn off listeners
2472
2456
  this.dom.add.off('.dtsb');
2473
2457
  this.dom.logic.off('.dtsb');
2458
+ this.dom.search.off('.dtsb');
2474
2459
  // Trigger event for groups at a higher level to pick up on
2475
2460
  this.dom.container
2476
2461
  .trigger('dtsb-destroy')
@@ -2481,7 +2466,6 @@ let $ = jQuery;
2481
2466
  * Gets the details required to rebuild the group
2482
2467
  */
2483
2468
  // Eslint upset at empty object but needs to be done
2484
- // eslint-disable-next-line @typescript-eslint/ban-types
2485
2469
  Group.prototype.getDetails = function (deFormatDates) {
2486
2470
  if (deFormatDates === void 0) { deFormatDates = false; }
2487
2471
  if (this.s.criteria.length === 0) {
@@ -2512,6 +2496,7 @@ let $ = jQuery;
2512
2496
  * @param loadedDetails the details required to rebuild the group
2513
2497
  */
2514
2498
  Group.prototype.rebuild = function (loadedDetails) {
2499
+ var crit;
2515
2500
  // If no criteria are stored then just return
2516
2501
  if (loadedDetails.criteria === undefined ||
2517
2502
  loadedDetails.criteria === null ||
@@ -2525,7 +2510,7 @@ let $ = jQuery;
2525
2510
  // Add all of the criteria, be it a sub group or a criteria
2526
2511
  if (Array.isArray(loadedDetails.criteria)) {
2527
2512
  for (var _i = 0, _a = loadedDetails.criteria; _i < _a.length; _i++) {
2528
- var crit = _a[_i];
2513
+ crit = _a[_i];
2529
2514
  if (crit.logic !== undefined) {
2530
2515
  this._addPrevGroup(crit);
2531
2516
  }
@@ -2536,7 +2521,7 @@ let $ = jQuery;
2536
2521
  }
2537
2522
  // For all of the criteria children, update the arrows incase they require changing and set the listeners
2538
2523
  for (var _b = 0, _c = this.s.criteria; _b < _c.length; _b++) {
2539
- var crit = _c[_b];
2524
+ crit = _c[_b];
2540
2525
  if (crit.criteria instanceof Criteria) {
2541
2526
  crit.criteria.updateArrows(this.s.criteria.length > 1);
2542
2527
  this._setCriteriaListeners(crit.criteria);
@@ -2555,6 +2540,9 @@ let $ = jQuery;
2555
2540
  this.dom.container
2556
2541
  .append(this.dom.logicContainer)
2557
2542
  .append(this.dom.add);
2543
+ if (!this.c.liveSearch) {
2544
+ this.dom.container.append(this.dom.search);
2545
+ }
2558
2546
  // Sort the criteria by index so that they appear in the correct order
2559
2547
  this.s.criteria.sort(function (a, b) {
2560
2548
  if (a.criteria.s.index < b.criteria.s.index) {
@@ -2641,10 +2629,14 @@ let $ = jQuery;
2641
2629
  // Set criteria left margin
2642
2630
  this.dom.container.css('margin-left', 0);
2643
2631
  }
2632
+ this.dom.search.css('display', 'none');
2644
2633
  return;
2645
2634
  }
2646
2635
  this.dom.clear.height('0px');
2647
2636
  this.dom.logicContainer.append(this.dom.clear);
2637
+ if (!this.s.isChild) {
2638
+ this.dom.search.css('display', 'inline-block');
2639
+ }
2648
2640
  // Prepend logic button
2649
2641
  this.dom.container.prepend(this.dom.logicContainer);
2650
2642
  for (var _i = 0, _a = this.s.criteria; _i < _a.length; _i++) {
@@ -2692,6 +2684,11 @@ let $ = jQuery;
2692
2684
  _this.s.dt.state.save();
2693
2685
  return false;
2694
2686
  });
2687
+ this.dom.search
2688
+ .off('click.dtsb')
2689
+ .on('click.dtsb', function () {
2690
+ _this.s.dt.draw();
2691
+ });
2695
2692
  for (var _i = 0, _a = this.s.criteria; _i < _a.length; _i++) {
2696
2693
  var crit = _a[_i];
2697
2694
  crit.criteria.setListeners();
@@ -2707,7 +2704,7 @@ let $ = jQuery;
2707
2704
  Group.prototype.addCriteria = function (crit) {
2708
2705
  if (crit === void 0) { crit = null; }
2709
2706
  var index = crit === null ? this.s.criteria.length : crit.s.index;
2710
- var criteria = new Criteria(this.s.dt, this.s.opts, this.s.topGroup, index, this.s.depth, this.s.serverData);
2707
+ var criteria = new Criteria(this.s.dt, this.s.opts, this.s.topGroup, index, this.s.depth, this.s.serverData, this.c.liveSearch);
2711
2708
  // If a Criteria has been passed in then set the values to continue that
2712
2709
  if (crit !== null) {
2713
2710
  criteria.c = crit.c;
@@ -2888,6 +2885,7 @@ let $ = jQuery;
2888
2885
  */
2889
2886
  Group.prototype._removeCriteria = function (criteria, group) {
2890
2887
  if (group === void 0) { group = false; }
2888
+ var i;
2891
2889
  // If removing a criteria and there is only then then just destroy the group
2892
2890
  if (this.s.criteria.length <= 1 && this.s.isChild) {
2893
2891
  this.destroy();
@@ -2895,7 +2893,7 @@ let $ = jQuery;
2895
2893
  else {
2896
2894
  // Otherwise splice the given criteria out and redo the indexes
2897
2895
  var last = void 0;
2898
- for (var i = 0; i < this.s.criteria.length; i++) {
2896
+ for (i = 0; i < this.s.criteria.length; i++) {
2899
2897
  if (this.s.criteria[i].index === criteria.s.index &&
2900
2898
  (!group || this.s.criteria[i].criteria instanceof Group)) {
2901
2899
  last = i;
@@ -2905,7 +2903,7 @@ let $ = jQuery;
2905
2903
  if (last !== undefined) {
2906
2904
  this.s.criteria.splice(last, 1);
2907
2905
  }
2908
- for (var i = 0; i < this.s.criteria.length; i++) {
2906
+ for (i = 0; i < this.s.criteria.length; i++) {
2909
2907
  this.s.criteria[i].index = i;
2910
2908
  this.s.criteria[i].criteria.s.index = i;
2911
2909
  }
@@ -3032,6 +3030,7 @@ let $ = jQuery;
3032
3030
  Group.prototype._setup = function () {
3033
3031
  this.setListeners();
3034
3032
  this.dom.add.html(this.s.dt.i18n('searchBuilder.add', this.c.i18n.add));
3033
+ this.dom.search.html(this.s.dt.i18n('searchBuilder.search', this.c.i18n.search));
3035
3034
  this.dom.logic.children().first().html(this.c.logic === 'OR'
3036
3035
  ? this.s.dt.i18n('searchBuilder.logicOr', this.c.i18n.logicOr)
3037
3036
  : this.s.dt.i18n('searchBuilder.logicAnd', this.c.i18n.logicAnd));
@@ -3046,6 +3045,9 @@ let $ = jQuery;
3046
3045
  this.dom.container.append(this.dom.logicContainer);
3047
3046
  }
3048
3047
  this.dom.container.append(this.dom.add);
3048
+ if (!this.c.liveSearch) {
3049
+ this.dom.container.append(this.dom.search);
3050
+ }
3049
3051
  };
3050
3052
  /**
3051
3053
  * Sets the listener for the logic button
@@ -3085,7 +3087,8 @@ let $ = jQuery;
3085
3087
  group: 'dtsb-group',
3086
3088
  inputButton: 'dtsb-iptbtn',
3087
3089
  logic: 'dtsb-logic',
3088
- logicContainer: 'dtsb-logicContainer'
3090
+ logicContainer: 'dtsb-logicContainer',
3091
+ search: 'dtsb-search'
3089
3092
  };
3090
3093
  Group.defaults = {
3091
3094
  columns: true,
@@ -3104,6 +3107,7 @@ let $ = jQuery;
3104
3107
  enterSearch: false,
3105
3108
  filterChanged: undefined,
3106
3109
  greyscale: false,
3110
+ liveSearch: true,
3107
3111
  i18n: {
3108
3112
  add: 'Add Condition',
3109
3113
  button: {
@@ -3121,6 +3125,7 @@ let $ = jQuery;
3121
3125
  logicOr: 'Or',
3122
3126
  right: '>',
3123
3127
  rightTitle: 'Indent criteria',
3128
+ search: 'Search',
3124
3129
  title: {
3125
3130
  0: 'Custom Search Builder',
3126
3131
  _: 'Custom Search Builder (%d)'
@@ -3218,7 +3223,6 @@ let $ = jQuery;
3218
3223
  * Gets the details required to rebuild the SearchBuilder as it currently is
3219
3224
  */
3220
3225
  // eslint upset at empty object but that is what it is
3221
- // eslint-disable-next-line @typescript-eslint/ban-types
3222
3226
  SearchBuilder.prototype.getDetails = function (deFormatDates) {
3223
3227
  if (deFormatDates === void 0) { deFormatDates = false; }
3224
3228
  return this.s.topGroup.getDetails(deFormatDates);
@@ -3288,16 +3292,19 @@ let $ = jQuery;
3288
3292
  SearchBuilder.prototype._setUp = function (loadState) {
3289
3293
  var _this = this;
3290
3294
  if (loadState === void 0) { loadState = true; }
3291
- // Register an Api method for getting the column type
3292
- $$1.fn.DataTable.Api.registerPlural('columns().type()', 'column().type()', function () {
3293
- return this.iterator('column', function (settings, column) {
3294
- return settings.aoColumns[column].sType;
3295
- }, 1);
3296
- });
3295
+ // Register an Api method for getting the column type. DataTables 2 has
3296
+ // this built in
3297
+ if (typeof this.s.dt.column().type !== 'function') {
3298
+ DataTable.Api.registerPlural('columns().types()', 'column().type()', function () {
3299
+ return this.iterator('column', function (settings, column) {
3300
+ return settings.aoColumns[column].sType;
3301
+ }, 1);
3302
+ });
3303
+ }
3297
3304
  // Check that DateTime is included, If not need to check if it could be used
3298
3305
  // eslint-disable-next-line no-extra-parens
3299
3306
  if (!dataTable$1.DateTime) {
3300
- var types = this.s.dt.columns().type().toArray();
3307
+ var types = this.s.dt.columns().types().toArray();
3301
3308
  if (types === undefined || types.includes(undefined) || types.includes(null)) {
3302
3309
  types = [];
3303
3310
  for (var _i = 0, _a = this.s.dt.settings()[0].aoColumns; _i < _a.length; _i++) {
@@ -3306,10 +3313,13 @@ let $ = jQuery;
3306
3313
  }
3307
3314
  }
3308
3315
  var columnIdxs = this.s.dt.columns().toArray();
3309
- // If the types are not yet set then draw to see if they can be retrieved then
3316
+ // If the column type is still unknown use the internal API to detect type
3310
3317
  if (types === undefined || types.includes(undefined) || types.includes(null)) {
3311
- $$1.fn.dataTable.ext.oApi._fnColumnTypes(this.s.dt.settings()[0]);
3312
- types = this.s.dt.columns().type().toArray();
3318
+ // This can only happen in DT1 - DT2 will do the invalidation of the type itself
3319
+ if ($$1.fn.dataTable.ext.oApi) {
3320
+ $$1.fn.dataTable.ext.oApi._fnColumnTypes(this.s.dt.settings()[0]);
3321
+ }
3322
+ types = this.s.dt.columns().types().toArray();
3313
3323
  }
3314
3324
  for (var i = 0; i < columnIdxs[0].length; i++) {
3315
3325
  var column = columnIdxs[0][i];
@@ -3348,7 +3358,9 @@ let $ = jQuery;
3348
3358
  data.searchBuilder = _this._collapseArray(_this.getDetails(true));
3349
3359
  }
3350
3360
  });
3351
- this.s.dt.on('column-reorder', function () {
3361
+ this.s.dt.on(dataTable$1.versionCheck('2')
3362
+ ? 'columns-reordered'
3363
+ : 'column-reorder', function () {
3352
3364
  _this.rebuild(_this.getDetails());
3353
3365
  });
3354
3366
  if (loadState) {
@@ -3563,7 +3575,7 @@ let $ = jQuery;
3563
3575
  _this.dom.clearAll.remove();
3564
3576
  });
3565
3577
  };
3566
- SearchBuilder.version = '1.5.0';
3578
+ SearchBuilder.version = '1.7.0';
3567
3579
  SearchBuilder.classes = {
3568
3580
  button: 'dtsb-button',
3569
3581
  clearAll: 'dtsb-clearAll',
@@ -3589,6 +3601,7 @@ let $ = jQuery;
3589
3601
  enterSearch: false,
3590
3602
  filterChanged: undefined,
3591
3603
  greyscale: false,
3604
+ liveSearch: true,
3592
3605
  i18n: {
3593
3606
  add: 'Add Condition',
3594
3607
  button: {
@@ -3652,6 +3665,7 @@ let $ = jQuery;
3652
3665
  logicOr: 'Or',
3653
3666
  right: '>',
3654
3667
  rightTitle: 'Indent criteria',
3668
+ search: 'Search',
3655
3669
  title: {
3656
3670
  0: 'Custom Search Builder',
3657
3671
  _: 'Custom Search Builder (%d)'
@@ -3669,8 +3683,8 @@ let $ = jQuery;
3669
3683
  return SearchBuilder;
3670
3684
  }());
3671
3685
 
3672
- /*! SearchBuilder 1.5.0
3673
- * ©SpryMedia Ltd - datatables.net/license/mit
3686
+ /*! SearchBuilder 1.7.0
3687
+ -dev * ©SpryMedia Ltd - datatables.net/license/mit
3674
3688
  */
3675
3689
  setJQuery($);
3676
3690
  setJQuery$1($);
@@ -3780,11 +3794,11 @@ let $ = jQuery;
3780
3794
  fnInit: _init
3781
3795
  });
3782
3796
  // DataTables 2 layout feature
3783
- if (DataTable.ext.features) {
3784
- DataTable.ext.features.register('searchBuilder', _init);
3797
+ if (DataTable.feature) {
3798
+ DataTable.feature.register('searchBuilder', _init);
3785
3799
  }
3786
3800
 
3787
- }());
3801
+ })();
3788
3802
 
3789
3803
 
3790
3804
  export default DataTable;