datatables.net-searchbuilder 1.7.1 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! SearchBuilder 1.
|
|
1
|
+
/*! SearchBuilder 1.8.1
|
|
2
2
|
* ©SpryMedia Ltd - datatables.net/license/mit
|
|
3
3
|
*/
|
|
4
4
|
|
|
@@ -12,12 +12,20 @@ let $ = jQuery;
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var $$3;
|
|
15
|
-
var dataTable$
|
|
15
|
+
var dataTable$2;
|
|
16
|
+
/** Get a moment object. Attempt to get from DataTables for module loading first. */
|
|
16
17
|
function moment() {
|
|
17
|
-
|
|
18
|
+
var used = DataTable.use('moment');
|
|
19
|
+
return used
|
|
20
|
+
? used
|
|
21
|
+
: window.moment;
|
|
18
22
|
}
|
|
23
|
+
/** Get a luxon object. Attempt to get from DataTables for module loading first. */
|
|
19
24
|
function luxon() {
|
|
20
|
-
|
|
25
|
+
var used = DataTable.use('luxon');
|
|
26
|
+
return used
|
|
27
|
+
? used
|
|
28
|
+
: window.luxon;
|
|
21
29
|
}
|
|
22
30
|
/**
|
|
23
31
|
* Sets the value of jQuery for use in the file
|
|
@@ -26,7 +34,7 @@ let $ = jQuery;
|
|
|
26
34
|
*/
|
|
27
35
|
function setJQuery$2(jq) {
|
|
28
36
|
$$3 = jq;
|
|
29
|
-
dataTable$
|
|
37
|
+
dataTable$2 = jq.fn.dataTable;
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* The Criteria class is used within SearchBuilder to represent a search criteria
|
|
@@ -38,10 +46,6 @@ let $ = jQuery;
|
|
|
38
46
|
if (serverData === void 0) { serverData = undefined; }
|
|
39
47
|
if (liveSearch === void 0) { liveSearch = false; }
|
|
40
48
|
var _this = this;
|
|
41
|
-
// Check that the required version of DataTables is included
|
|
42
|
-
if (!dataTable$3 || !dataTable$3.versionCheck || !dataTable$3.versionCheck('1.10.0')) {
|
|
43
|
-
throw new Error('SearchPane requires DataTables 1.10 or newer');
|
|
44
|
-
}
|
|
45
49
|
this.classes = $$3.extend(true, {}, Criteria.classes);
|
|
46
50
|
// Get options from user and any extra conditions/column types defined by plug-ins
|
|
47
51
|
this.c = $$3.extend(true, {}, Criteria.defaults, $$3.fn.dataTable.ext.searchBuilder, opts);
|
|
@@ -130,7 +134,7 @@ let $ = jQuery;
|
|
|
130
134
|
val.addClass(this.classes.greyscale);
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
|
-
$$3(window).on('resize.dtsb', dataTable$
|
|
137
|
+
$$3(window).on('resize.dtsb', dataTable$2.util.throttle(function () {
|
|
134
138
|
_this.s.topGroup.trigger('dtsb-redrawLogic');
|
|
135
139
|
}));
|
|
136
140
|
this._buildCriteria();
|
|
@@ -232,7 +236,8 @@ let $ = jQuery;
|
|
|
232
236
|
if (this.s.condition !== undefined && condition !== undefined) {
|
|
233
237
|
var filter = rowData[this.s.dataIdx];
|
|
234
238
|
// This check is in place for if a custom decimal character is in place
|
|
235
|
-
if (this.s.type
|
|
239
|
+
if (this.s.type &&
|
|
240
|
+
this.s.type.includes('num') &&
|
|
236
241
|
(settings.oLanguage.sDecimal !== '' ||
|
|
237
242
|
settings.oLanguage.sThousands !== '')) {
|
|
238
243
|
var splitRD = [rowData[this.s.dataIdx]];
|
|
@@ -288,7 +293,7 @@ let $ = jQuery;
|
|
|
288
293
|
var settings = this.s.dt.settings()[0];
|
|
289
294
|
// This check is in place for if a custom decimal character is in place
|
|
290
295
|
if (this.s.type !== null &&
|
|
291
|
-
this.s.type
|
|
296
|
+
["num", "num-fmt", "html-num", "html-num-fmt"].includes(this.s.type) &&
|
|
292
297
|
(settings.oLanguage.sDecimal !== '' || settings.oLanguage.sThousands !== '')) {
|
|
293
298
|
for (i = 0; i < this.s.value.length; i++) {
|
|
294
299
|
var splitRD = [this.s.value[i].toString()];
|
|
@@ -331,7 +336,7 @@ let $ = jQuery;
|
|
|
331
336
|
}
|
|
332
337
|
}
|
|
333
338
|
}
|
|
334
|
-
if (this.s.type.includes('num') && this.s.dt.page.info().serverSide) {
|
|
339
|
+
if (this.s.type && this.s.type.includes('num') && this.s.dt.page.info().serverSide) {
|
|
335
340
|
for (i = 0; i < this.s.value.length; i++) {
|
|
336
341
|
this.s.value[i] = this.s.value[i].replace(/[^0-9.\-]/g, '');
|
|
337
342
|
}
|
|
@@ -656,12 +661,13 @@ let $ = jQuery;
|
|
|
656
661
|
Criteria.prototype._populateCondition = function () {
|
|
657
662
|
var conditionOpts = [];
|
|
658
663
|
var conditionsLength = Object.keys(this.s.conditions).length;
|
|
659
|
-
var
|
|
664
|
+
var dt = this.s.dt;
|
|
665
|
+
var colInits = dt.settings()[0].aoColumns;
|
|
660
666
|
var column = +this.dom.data.children('option:selected').val();
|
|
661
667
|
var condition, condName;
|
|
662
668
|
// If there are no conditions stored then we need to get them from the appropriate type
|
|
663
669
|
if (conditionsLength === 0) {
|
|
664
|
-
this.s.type =
|
|
670
|
+
this.s.type = dt.column(column).type();
|
|
665
671
|
if (colInits !== undefined) {
|
|
666
672
|
var colInit = colInits[column];
|
|
667
673
|
if (colInit.searchBuilderType !== undefined && colInit.searchBuilderType !== null) {
|
|
@@ -675,9 +681,9 @@ let $ = jQuery;
|
|
|
675
681
|
if (this.s.type === null || this.s.type === undefined) {
|
|
676
682
|
// This can only happen in DT1 - DT2 will do the invalidation of the type itself
|
|
677
683
|
if ($$3.fn.dataTable.ext.oApi) {
|
|
678
|
-
$$3.fn.dataTable.ext.oApi._fnColumnTypes(
|
|
684
|
+
$$3.fn.dataTable.ext.oApi._fnColumnTypes(dt.settings()[0]);
|
|
679
685
|
}
|
|
680
|
-
this.s.type =
|
|
686
|
+
this.s.type = dt.column(column).type();
|
|
681
687
|
}
|
|
682
688
|
// Enable the condition element
|
|
683
689
|
this.dom.condition
|
|
@@ -687,9 +693,9 @@ let $ = jQuery;
|
|
|
687
693
|
.addClass(this.classes.italic);
|
|
688
694
|
this.dom.conditionTitle
|
|
689
695
|
.prop('selected', true);
|
|
690
|
-
var decimal =
|
|
696
|
+
var decimal = dt.settings()[0].oLanguage.sDecimal;
|
|
691
697
|
// This check is in place for if a custom decimal character is in place
|
|
692
|
-
if (decimal !== '' && this.s.type.indexOf(decimal) === this.s.type.length - decimal.length) {
|
|
698
|
+
if (decimal !== '' && this.s.type && this.s.type.indexOf(decimal) === this.s.type.length - decimal.length) {
|
|
693
699
|
if (this.s.type.includes('num-fmt')) {
|
|
694
700
|
this.s.type = this.s.type.replace(decimal, '');
|
|
695
701
|
}
|
|
@@ -698,27 +704,36 @@ let $ = jQuery;
|
|
|
698
704
|
}
|
|
699
705
|
}
|
|
700
706
|
// Select which conditions are going to be used based on the column type
|
|
701
|
-
var conditionObj =
|
|
702
|
-
|
|
703
|
-
this.s.type
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
707
|
+
var conditionObj = void 0;
|
|
708
|
+
if (this.c.conditions[this.s.type] !== undefined) {
|
|
709
|
+
conditionObj = this.c.conditions[this.s.type];
|
|
710
|
+
}
|
|
711
|
+
else if (this.s.type && this.s.type.includes('datetime-')) {
|
|
712
|
+
// Date / time data types in DataTables are driven by Luxon or
|
|
713
|
+
// Moment.js.
|
|
714
|
+
conditionObj = DataTable.use('moment')
|
|
715
|
+
? this.c.conditions.moment
|
|
716
|
+
: this.c.conditions.luxon;
|
|
717
|
+
this.s.dateFormat = this.s.type.replace(/datetime-/g, '');
|
|
718
|
+
}
|
|
719
|
+
else if (this.s.type && this.s.type.includes('moment')) {
|
|
720
|
+
conditionObj = this.c.conditions.moment;
|
|
710
721
|
this.s.dateFormat = this.s.type.replace(/moment-/g, '');
|
|
711
722
|
}
|
|
712
|
-
else if (this.s.type.includes('luxon')) {
|
|
723
|
+
else if (this.s.type && this.s.type.includes('luxon')) {
|
|
724
|
+
conditionObj = this.c.conditions.luxon;
|
|
713
725
|
this.s.dateFormat = this.s.type.replace(/luxon-/g, '');
|
|
714
726
|
}
|
|
727
|
+
else {
|
|
728
|
+
conditionObj = this.c.conditions.string;
|
|
729
|
+
}
|
|
715
730
|
// Add all of the conditions to the select element
|
|
716
731
|
for (var _i = 0, _a = Object.keys(conditionObj); _i < _a.length; _i++) {
|
|
717
732
|
condition = _a[_i];
|
|
718
733
|
if (conditionObj[condition] !== null) {
|
|
719
734
|
// Serverside processing does not supply the options for the select elements
|
|
720
735
|
// Instead input elements need to be used for these instead
|
|
721
|
-
if (
|
|
736
|
+
if (dt.page.info().serverSide && conditionObj[condition].init === Criteria.initSelect) {
|
|
722
737
|
var col = colInits[column];
|
|
723
738
|
if (this.s.serverData && this.s.serverData[col.data]) {
|
|
724
739
|
conditionObj[condition].init = Criteria.initSelectSSP;
|
|
@@ -734,7 +749,7 @@ let $ = jQuery;
|
|
|
734
749
|
this.s.conditions[condition] = conditionObj[condition];
|
|
735
750
|
condName = conditionObj[condition].conditionName;
|
|
736
751
|
if (typeof condName === 'function') {
|
|
737
|
-
condName = condName(
|
|
752
|
+
condName = condName(dt, this.c.i18n);
|
|
738
753
|
}
|
|
739
754
|
conditionOpts.push($$3('<option>', {
|
|
740
755
|
text: condName,
|
|
@@ -752,7 +767,7 @@ let $ = jQuery;
|
|
|
752
767
|
condition = _c[_b];
|
|
753
768
|
var name_1 = this.s.conditions[condition].conditionName;
|
|
754
769
|
if (typeof name_1 === 'function') {
|
|
755
|
-
name_1 = name_1(
|
|
770
|
+
name_1 = name_1(dt, this.c.i18n);
|
|
756
771
|
}
|
|
757
772
|
var newOpt = $$3('<option>', {
|
|
758
773
|
text: name_1,
|
|
@@ -795,7 +810,7 @@ let $ = jQuery;
|
|
|
795
810
|
condName = this.s.conditions[cond].conditionName;
|
|
796
811
|
if (
|
|
797
812
|
// If the conditionName matches the text of the option
|
|
798
|
-
(typeof condName === 'string' ? condName : condName(
|
|
813
|
+
(typeof condName === 'string' ? condName : condName(dt, this.c.i18n)) ===
|
|
799
814
|
conditionOpts[i].text() &&
|
|
800
815
|
// and the tokens match
|
|
801
816
|
cond === defaultCondition) {
|
|
@@ -1419,7 +1434,7 @@ let $ = jQuery;
|
|
|
1419
1434
|
values.push(Criteria._escapeHTML(element.val()));
|
|
1420
1435
|
}
|
|
1421
1436
|
}
|
|
1422
|
-
return values;
|
|
1437
|
+
return values.map(dataTable$2.util.diacritics);
|
|
1423
1438
|
};
|
|
1424
1439
|
/**
|
|
1425
1440
|
* Function that is run on each element as a call back when a search should be triggered
|
|
@@ -2379,7 +2394,6 @@ let $ = jQuery;
|
|
|
2379
2394
|
}());
|
|
2380
2395
|
|
|
2381
2396
|
var $$2;
|
|
2382
|
-
var dataTable$2;
|
|
2383
2397
|
/**
|
|
2384
2398
|
* Sets the value of jQuery for use in the file
|
|
2385
2399
|
*
|
|
@@ -2387,7 +2401,7 @@ let $ = jQuery;
|
|
|
2387
2401
|
*/
|
|
2388
2402
|
function setJQuery$1(jq) {
|
|
2389
2403
|
$$2 = jq;
|
|
2390
|
-
|
|
2404
|
+
jq.fn.dataTable;
|
|
2391
2405
|
}
|
|
2392
2406
|
/**
|
|
2393
2407
|
* The Group class is used within SearchBuilder to represent a group of criteria
|
|
@@ -2398,10 +2412,6 @@ let $ = jQuery;
|
|
|
2398
2412
|
if (isChild === void 0) { isChild = false; }
|
|
2399
2413
|
if (depth === void 0) { depth = 1; }
|
|
2400
2414
|
if (serverData === void 0) { serverData = undefined; }
|
|
2401
|
-
// Check that the required version of DataTables is included
|
|
2402
|
-
if (!dataTable$2 || !dataTable$2.versionCheck || !dataTable$2.versionCheck('1.10.0')) {
|
|
2403
|
-
throw new Error('SearchBuilder requires DataTables 1.10 or newer');
|
|
2404
|
-
}
|
|
2405
2415
|
this.classes = $$2.extend(true, {}, Group.classes);
|
|
2406
2416
|
// Get options from user
|
|
2407
2417
|
this.c = $$2.extend(true, {}, Group.defaults, opts);
|
|
@@ -3162,8 +3172,8 @@ let $ = jQuery;
|
|
|
3162
3172
|
function SearchBuilder(builderSettings, opts) {
|
|
3163
3173
|
var _this = this;
|
|
3164
3174
|
// Check that the required version of DataTables is included
|
|
3165
|
-
if (!dataTable$1 || !dataTable$1.versionCheck || !dataTable$1.versionCheck('
|
|
3166
|
-
throw new Error('SearchBuilder requires DataTables
|
|
3175
|
+
if (!dataTable$1 || !dataTable$1.versionCheck || !dataTable$1.versionCheck('2')) {
|
|
3176
|
+
throw new Error('SearchBuilder requires DataTables 2 or newer');
|
|
3167
3177
|
}
|
|
3168
3178
|
var table = new dataTable$1.Api(builderSettings);
|
|
3169
3179
|
this.classes = $$1.extend(true, {}, SearchBuilder.classes);
|
|
@@ -3225,7 +3235,9 @@ let $ = jQuery;
|
|
|
3225
3235
|
// eslint upset at empty object but that is what it is
|
|
3226
3236
|
SearchBuilder.prototype.getDetails = function (deFormatDates) {
|
|
3227
3237
|
if (deFormatDates === void 0) { deFormatDates = false; }
|
|
3228
|
-
return this.s.topGroup
|
|
3238
|
+
return this.s.topGroup
|
|
3239
|
+
? this.s.topGroup.getDetails(deFormatDates)
|
|
3240
|
+
: {};
|
|
3229
3241
|
};
|
|
3230
3242
|
/**
|
|
3231
3243
|
* Getter for the node of the container for the searchBuilder
|
|
@@ -3358,9 +3370,7 @@ let $ = jQuery;
|
|
|
3358
3370
|
data.searchBuilder = _this._collapseArray(_this.getDetails(true));
|
|
3359
3371
|
}
|
|
3360
3372
|
});
|
|
3361
|
-
this.s.dt.on(
|
|
3362
|
-
? 'columns-reordered'
|
|
3363
|
-
: 'column-reorder', function () {
|
|
3373
|
+
this.s.dt.on('columns-reordered', function () {
|
|
3364
3374
|
_this.rebuild(_this.getDetails());
|
|
3365
3375
|
});
|
|
3366
3376
|
if (loadState) {
|
|
@@ -3575,7 +3585,7 @@ let $ = jQuery;
|
|
|
3575
3585
|
_this.dom.clearAll.remove();
|
|
3576
3586
|
});
|
|
3577
3587
|
};
|
|
3578
|
-
SearchBuilder.version = '1.
|
|
3588
|
+
SearchBuilder.version = '1.8.1';
|
|
3579
3589
|
SearchBuilder.classes = {
|
|
3580
3590
|
button: 'dtsb-button',
|
|
3581
3591
|
clearAll: 'dtsb-clearAll',
|
|
@@ -3683,7 +3693,7 @@ let $ = jQuery;
|
|
|
3683
3693
|
return SearchBuilder;
|
|
3684
3694
|
}());
|
|
3685
3695
|
|
|
3686
|
-
/*! SearchBuilder 1.
|
|
3696
|
+
/*! SearchBuilder 1.8.1
|
|
3687
3697
|
* ©SpryMedia Ltd - datatables.net/license/mit
|
|
3688
3698
|
*/
|
|
3689
3699
|
setJQuery($);
|
|
@@ -3725,12 +3735,15 @@ let $ = jQuery;
|
|
|
3725
3735
|
},
|
|
3726
3736
|
config: {},
|
|
3727
3737
|
init: function (dt, node, config) {
|
|
3728
|
-
var
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3738
|
+
var that = this;
|
|
3739
|
+
var sb = new DataTable.SearchBuilder(dt, config.config);
|
|
3740
|
+
dt.on('draw', function () {
|
|
3741
|
+
var count = sb.s.topGroup
|
|
3742
|
+
? sb.s.topGroup.count()
|
|
3743
|
+
: 0;
|
|
3744
|
+
that.text(dt.i18n('searchBuilder.button', sb.c.i18n.button, count));
|
|
3745
|
+
});
|
|
3746
|
+
that.text(config.text || dt.i18n('searchBuilder.button', sb.c.i18n.button, 0));
|
|
3734
3747
|
config._searchBuilder = sb;
|
|
3735
3748
|
},
|
|
3736
3749
|
text: null
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "js/dataTables.searchBuilder.js",
|
|
5
5
|
"module": "js/dataTables.searchBuilder.mjs",
|
|
6
6
|
"types": "./types/types.d.ts",
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.8.1",
|
|
8
8
|
"files": [
|
|
9
9
|
"js/**/*.js",
|
|
10
10
|
"js/**/*.mjs",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"sort"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"datatables.net": "1
|
|
24
|
+
"datatables.net": "^2.1",
|
|
25
25
|
"jquery": ">=1.7"
|
|
26
26
|
},
|
|
27
27
|
"moduleType": [
|
package/types/types.d.ts
CHANGED