tablefilter 0.7.7 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/starter.html +2 -2
- package/dist/tablefilter/tablefilter.js +1 -1
- package/dist/tablefilter/tf-1-dca7dae32ca501c46faf.js +1 -0
- package/dist/tablefilter/{tf-2-0ea691278d572212426a.js → tf-2-eaf25ea22f7cd033d053.js} +2 -2
- package/dist/tablefilter.cjs.js +300 -58
- package/dist/tablefilter.esm.js +300 -58
- package/dist/tablefilter.umd.js +300 -58
- package/package.json +8 -7
- package/src/components/tf-checklist.js +571 -0
- package/src/modules/checkList.js +405 -93
- package/src/number.js +13 -1
- package/dist/tablefilter/tf-1-7e29d0dbe6e0e0a4ff05.js +0 -1
package/dist/tablefilter.cjs.js
CHANGED
|
@@ -889,11 +889,23 @@ function bound(fn, scope) {
|
|
|
889
889
|
//#region src/number.js
|
|
890
890
|
/**
|
|
891
891
|
* Formats a numeric value with configurable separators and affixes.
|
|
892
|
+
*
|
|
893
|
+
* Supported options: `locale`, `decimal`, `integerSeparator`, `precision`,
|
|
894
|
+
* `round`, `prefix` and `suffix`. The `format-number` options `truncate`,
|
|
895
|
+
* `padLeft`, `padRight`, `negativeType`, `negativeLeftSymbol`,
|
|
896
|
+
* `negativeRightSymbol`, `negativeOut`, `decimalsSeparator` and `noUnits`
|
|
897
|
+
* have no effect. `integerSeparator: null` disables grouping. Values of
|
|
898
|
+
* magnitude 1e21 and above are rendered in full instead of exponential
|
|
899
|
+
* notation.
|
|
900
|
+
*
|
|
901
|
+
* Requires `Intl.NumberFormat.prototype.formatToParts` (Chrome 64+, Edge 79+,
|
|
902
|
+
* Firefox 58+, Safari 11+, Node 10+).
|
|
892
903
|
* @param {Number|String} value Numeric value
|
|
893
904
|
* @param {Object} [options={}] Formatting options
|
|
894
905
|
* @param {String} [options.locale='en'] Intl locale
|
|
895
906
|
* @param {String} [options.decimal] Decimal separator override
|
|
896
|
-
* @param {String} [options.integerSeparator] Thousands separator override
|
|
907
|
+
* @param {String|null} [options.integerSeparator] Thousands separator override:
|
|
908
|
+
* `undefined` uses locale default grouping, `null` or `''` disables grouping
|
|
897
909
|
* @param {Number} [options.precision] Fixed number of fraction digits
|
|
898
910
|
* @param {Number} [options.round] Maximum number of fraction digits
|
|
899
911
|
* @param {String} [options.prefix=''] Value prefix
|
|
@@ -10282,6 +10294,30 @@ var CheckList = class CheckList extends BaseDropdown {
|
|
|
10282
10294
|
*/
|
|
10283
10295
|
this.containers = [];
|
|
10284
10296
|
/**
|
|
10297
|
+
* `<tf-checklist>` hosts, when the bridge is active
|
|
10298
|
+
* @type {Array}
|
|
10299
|
+
* @private
|
|
10300
|
+
*/
|
|
10301
|
+
this.ceElms = [];
|
|
10302
|
+
/**
|
|
10303
|
+
* Handlers bound to each `<tf-checklist>` host
|
|
10304
|
+
* @type {Array}
|
|
10305
|
+
* @private
|
|
10306
|
+
*/
|
|
10307
|
+
this.ceEvt = [];
|
|
10308
|
+
/**
|
|
10309
|
+
* Selected values reported by each `<tf-checklist>` host
|
|
10310
|
+
* @type {Array}
|
|
10311
|
+
* @private
|
|
10312
|
+
*/
|
|
10313
|
+
this.ceValues = [];
|
|
10314
|
+
/**
|
|
10315
|
+
* Trigger names cached per column for `<tf-checklist>` hosts
|
|
10316
|
+
* @type {Array}
|
|
10317
|
+
* @private
|
|
10318
|
+
*/
|
|
10319
|
+
this.ceNames = [];
|
|
10320
|
+
/**
|
|
10285
10321
|
* Css class for the container of the checklist filter (div)
|
|
10286
10322
|
* @type {String}
|
|
10287
10323
|
*/
|
|
@@ -10351,6 +10387,83 @@ var CheckList = class CheckList extends BaseDropdown {
|
|
|
10351
10387
|
}
|
|
10352
10388
|
}
|
|
10353
10389
|
/**
|
|
10390
|
+
* `<tf-checklist>` selection event handler
|
|
10391
|
+
* @param {Number} colIndex Column index
|
|
10392
|
+
* @param {Event} evt `selection-change` event
|
|
10393
|
+
* @private
|
|
10394
|
+
*/
|
|
10395
|
+
onCESelectionChange(colIndex, evt) {
|
|
10396
|
+
let tf = this.tf;
|
|
10397
|
+
let host = this.ceElms[colIndex];
|
|
10398
|
+
let values = evt.detail && isArray(evt.detail.values) ? evt.detail.values.slice() : [];
|
|
10399
|
+
values = this.normalizeCESelection(colIndex, values);
|
|
10400
|
+
this.ceValues[colIndex] = values;
|
|
10401
|
+
this.syncCEText(colIndex);
|
|
10402
|
+
this.emitter.emit("filter-focus", tf, host);
|
|
10403
|
+
tf.filter();
|
|
10404
|
+
}
|
|
10405
|
+
/**
|
|
10406
|
+
* `<tf-checklist>` open event handler used by the load-on-demand
|
|
10407
|
+
* feature: the options are rendered on the first expansion
|
|
10408
|
+
* @param {Number} colIndex Column index
|
|
10409
|
+
* @param {Event} evt `open-change` event
|
|
10410
|
+
* @private
|
|
10411
|
+
*/
|
|
10412
|
+
onCEOpenChange(colIndex, evt) {
|
|
10413
|
+
let host = this.ceElms[colIndex];
|
|
10414
|
+
if (!evt.detail || !evt.detail.open || !host) return;
|
|
10415
|
+
if (host.getAttribute("filled") !== "1") this.build(colIndex);
|
|
10416
|
+
}
|
|
10417
|
+
/**
|
|
10418
|
+
* Keep the reset option exclusive. The element toggles every option
|
|
10419
|
+
* independently, while the legacy checklist clears the other
|
|
10420
|
+
* selections when the reset item is picked and unchecks the reset
|
|
10421
|
+
* item when another option is picked (checkList.js:391-425).
|
|
10422
|
+
* @param {Number} colIndex Column index
|
|
10423
|
+
* @param {Array} values Selected values reported by the element
|
|
10424
|
+
* @returns {Array} Normalized selection
|
|
10425
|
+
* @private
|
|
10426
|
+
*/
|
|
10427
|
+
normalizeCESelection(colIndex, values) {
|
|
10428
|
+
let host = this.ceElms[colIndex];
|
|
10429
|
+
let previous = this.ceValues[colIndex] || [];
|
|
10430
|
+
let hasReset = values.indexOf("") !== -1;
|
|
10431
|
+
if (!host || !hasReset || values.length === 1) return values;
|
|
10432
|
+
let normalized = previous.indexOf("") === -1 ? [""] : values.filter((value) => value !== "");
|
|
10433
|
+
host.setSelectedValues(normalized);
|
|
10434
|
+
return normalized;
|
|
10435
|
+
}
|
|
10436
|
+
/**
|
|
10437
|
+
* Render the trigger text from the column name and the selection
|
|
10438
|
+
* count, and name the listbox from the same column name
|
|
10439
|
+
* (v1-webcomponents-investigation.md:247-289)
|
|
10440
|
+
* @param {Number} colIndex Column index
|
|
10441
|
+
* @private
|
|
10442
|
+
*/
|
|
10443
|
+
syncCEText(colIndex) {
|
|
10444
|
+
let host = this.ceElms[colIndex];
|
|
10445
|
+
if (!host) return;
|
|
10446
|
+
let name = this.getCEName(colIndex);
|
|
10447
|
+
let count = (this.ceValues[colIndex] || []).filter((value) => value !== "").length;
|
|
10448
|
+
host.setAttribute("trigger-text", count ? `${name} (${count})` : name);
|
|
10449
|
+
host.setAttribute("listbox-label", `${name} options`);
|
|
10450
|
+
}
|
|
10451
|
+
/**
|
|
10452
|
+
* Return the trigger name for a column: its header text, or a
|
|
10453
|
+
* position-based fallback when the header is empty
|
|
10454
|
+
* @param {Number} colIndex Column index
|
|
10455
|
+
* @returns {String} Column name
|
|
10456
|
+
* @private
|
|
10457
|
+
*/
|
|
10458
|
+
getCEName(colIndex) {
|
|
10459
|
+
let name = this.ceNames[colIndex];
|
|
10460
|
+
if (!name) {
|
|
10461
|
+
name = this.tf.getHeadersText()[colIndex] || `Column ${colIndex + 1}`;
|
|
10462
|
+
this.ceNames[colIndex] = name;
|
|
10463
|
+
}
|
|
10464
|
+
return name;
|
|
10465
|
+
}
|
|
10466
|
+
/**
|
|
10354
10467
|
* Refresh all checklist filters
|
|
10355
10468
|
*/
|
|
10356
10469
|
refreshAll() {
|
|
@@ -10364,6 +10477,61 @@ var CheckList = class CheckList extends BaseDropdown {
|
|
|
10364
10477
|
* @param {DOMElement} container Dom element containing the filter
|
|
10365
10478
|
*/
|
|
10366
10479
|
init(colIndex, isExternal, container) {
|
|
10480
|
+
if (!this.initialized) {
|
|
10481
|
+
this.onBuildChecklistFilter = (tf, colIndex, isLinked) => this.build(colIndex, isLinked);
|
|
10482
|
+
this.onSelectChecklistOptions = (tf, colIndex, values) => this.selectOptions(colIndex, values);
|
|
10483
|
+
this.onRowsChanged = () => this.refreshAll();
|
|
10484
|
+
this.onAfterFiltering = () => this.linkFilters();
|
|
10485
|
+
this.emitter.on(["build-checklist-filter"], this.onBuildChecklistFilter);
|
|
10486
|
+
this.emitter.on(["select-checklist-options"], this.onSelectChecklistOptions);
|
|
10487
|
+
this.emitter.on(["rows-changed"], this.onRowsChanged);
|
|
10488
|
+
this.emitter.on(["after-filtering"], this.onAfterFiltering);
|
|
10489
|
+
/** @inherited */
|
|
10490
|
+
this.initialized = true;
|
|
10491
|
+
}
|
|
10492
|
+
if (typeof customElements !== "undefined" && customElements.get("tf-checklist")) this.initCE(colIndex, isExternal, container);
|
|
10493
|
+
else this.initLegacy(colIndex, isExternal, container);
|
|
10494
|
+
}
|
|
10495
|
+
/**
|
|
10496
|
+
* Initialize using the <tf-checklist> custom element
|
|
10497
|
+
* @param {Number} colIndex Column index
|
|
10498
|
+
* @param {Boolean} isExternal External filter flag
|
|
10499
|
+
* @param {DOMElement} container Dom element containing the filter
|
|
10500
|
+
* @private
|
|
10501
|
+
*/
|
|
10502
|
+
initCE(colIndex, isExternal, container) {
|
|
10503
|
+
let tf = this.tf;
|
|
10504
|
+
let externalFltTgtId = isExternal ? tf.externalFltIds[colIndex] : null;
|
|
10505
|
+
let host = document.createElement("tf-checklist");
|
|
10506
|
+
host.id = tf.buildFilterId(colIndex);
|
|
10507
|
+
host.className = this.containerCssClass;
|
|
10508
|
+
host.setAttribute("col", String(colIndex));
|
|
10509
|
+
if (externalFltTgtId) elm(externalFltTgtId).appendChild(host);
|
|
10510
|
+
else container.appendChild(host);
|
|
10511
|
+
this.containers[colIndex] = host;
|
|
10512
|
+
this.ceElms[colIndex] = host;
|
|
10513
|
+
this.ceValues[colIndex] = [];
|
|
10514
|
+
tf.fltIds.push(host.id);
|
|
10515
|
+
let evt = this.ceEvt[colIndex] = {
|
|
10516
|
+
selectionChange: (e) => this.onCESelectionChange(colIndex, e),
|
|
10517
|
+
openChange: (e) => this.onCEOpenChange(colIndex, e)
|
|
10518
|
+
};
|
|
10519
|
+
addEvt(host, "selection-change", evt.selectionChange);
|
|
10520
|
+
addEvt(host, "open-change", evt.openChange);
|
|
10521
|
+
if (!tf.loadFltOnDemand) this.build(colIndex);
|
|
10522
|
+
else {
|
|
10523
|
+
host.setAttribute("trigger-text", this.activateText);
|
|
10524
|
+
host.setAttribute("listbox-label", `${this.activateText} options`);
|
|
10525
|
+
}
|
|
10526
|
+
}
|
|
10527
|
+
/**
|
|
10528
|
+
* Initialize using the legacy div/ul/li structure
|
|
10529
|
+
* @param {Number} colIndex Column index
|
|
10530
|
+
* @param {Boolean} isExternal External filter flag
|
|
10531
|
+
* @param {DOMElement} container Dom element containing the filter
|
|
10532
|
+
* @private
|
|
10533
|
+
*/
|
|
10534
|
+
initLegacy(colIndex, isExternal, container) {
|
|
10367
10535
|
let tf = this.tf;
|
|
10368
10536
|
let externalFltTgtId = isExternal ? tf.externalFltIds[colIndex] : null;
|
|
10369
10537
|
let divCont = createElm("div", ["id", `${this.prfx}${colIndex}_${tf.id}`], ["ct", colIndex], ["filled", "0"]);
|
|
@@ -10377,12 +10545,6 @@ var CheckList = class CheckList extends BaseDropdown {
|
|
|
10377
10545
|
addEvt(divCont, "click", (evt) => this.onCheckListClick(evt));
|
|
10378
10546
|
divCont.appendChild(createText(this.activateText));
|
|
10379
10547
|
}
|
|
10380
|
-
this.emitter.on(["build-checklist-filter"], (tf, colIndex, isLinked) => this.build(colIndex, isLinked));
|
|
10381
|
-
this.emitter.on(["select-checklist-options"], (tf, colIndex, values) => this.selectOptions(colIndex, values));
|
|
10382
|
-
this.emitter.on(["rows-changed"], () => this.refreshAll());
|
|
10383
|
-
this.emitter.on(["after-filtering"], () => this.linkFilters());
|
|
10384
|
-
/** @inherited */
|
|
10385
|
-
this.initialized = true;
|
|
10386
10548
|
}
|
|
10387
10549
|
/**
|
|
10388
10550
|
* Build checklist UI
|
|
@@ -10397,9 +10559,6 @@ var CheckList = class CheckList extends BaseDropdown {
|
|
|
10397
10559
|
this.opts = [];
|
|
10398
10560
|
/** @inherited */
|
|
10399
10561
|
this.optsTxt = [];
|
|
10400
|
-
let flt = this.containers[colIndex];
|
|
10401
|
-
let ul = createElm("ul", ["id", tf.fltIds[colIndex]], ["colIndex", colIndex]);
|
|
10402
|
-
ul.className = this.filterCssClass;
|
|
10403
10562
|
let caseSensitive = tf.caseSensitive;
|
|
10404
10563
|
/** @inherited */
|
|
10405
10564
|
this.isCustom = tf.isCustomOptions(colIndex);
|
|
@@ -10415,7 +10574,6 @@ var CheckList = class CheckList extends BaseDropdown {
|
|
|
10415
10574
|
if (isLinked && tf.disableExcludedOptions)
|
|
10416
10575
|
/** @inherited */
|
|
10417
10576
|
this.excludedOpts = [];
|
|
10418
|
-
flt.innerHTML = "";
|
|
10419
10577
|
tf.eachRow()((row) => {
|
|
10420
10578
|
let cellValue = tf.getCellValue(row.cells[colIndex]);
|
|
10421
10579
|
let cellString = matchCase(cellValue, caseSensitive);
|
|
@@ -10432,6 +10590,38 @@ var CheckList = class CheckList extends BaseDropdown {
|
|
|
10432
10590
|
});
|
|
10433
10591
|
this.opts = this.sortOptions(colIndex, this.opts);
|
|
10434
10592
|
if (this.excludedOpts) this.excludedOpts = this.sortOptions(colIndex, this.excludedOpts);
|
|
10593
|
+
if (this.ceElms[colIndex]) this.buildCE(colIndex);
|
|
10594
|
+
else this.buildLegacy(colIndex);
|
|
10595
|
+
}
|
|
10596
|
+
/**
|
|
10597
|
+
* Render the options into a <tf-checklist> host
|
|
10598
|
+
* @param {Number} colIndex Column index
|
|
10599
|
+
* @private
|
|
10600
|
+
*/
|
|
10601
|
+
buildCE(colIndex) {
|
|
10602
|
+
let tf = this.tf;
|
|
10603
|
+
let host = this.ceElms[colIndex];
|
|
10604
|
+
host.setOptions(this.getOptionEntries(colIndex).filter((entry) => !entry.hidden).map((entry) => ({
|
|
10605
|
+
value: entry.value,
|
|
10606
|
+
text: entry.text,
|
|
10607
|
+
disabled: entry.disabled
|
|
10608
|
+
})));
|
|
10609
|
+
host.setAttribute("filled", "1");
|
|
10610
|
+
this.ceValues[colIndex] = [];
|
|
10611
|
+
this.syncCEText(colIndex);
|
|
10612
|
+
this.emitter.emit("after-populating-filter", tf, colIndex, host);
|
|
10613
|
+
}
|
|
10614
|
+
/**
|
|
10615
|
+
* Render the options into the legacy ul element
|
|
10616
|
+
* @param {Number} colIndex Column index
|
|
10617
|
+
* @private
|
|
10618
|
+
*/
|
|
10619
|
+
buildLegacy(colIndex) {
|
|
10620
|
+
let tf = this.tf;
|
|
10621
|
+
let flt = this.containers[colIndex];
|
|
10622
|
+
let ul = createElm("ul", ["id", tf.fltIds[colIndex]], ["colIndex", colIndex]);
|
|
10623
|
+
ul.className = this.filterCssClass;
|
|
10624
|
+
flt.innerHTML = "";
|
|
10435
10625
|
this.addChecks(colIndex, ul);
|
|
10436
10626
|
if (tf.loadFltOnDemand) flt.innerHTML = "";
|
|
10437
10627
|
flt.appendChild(ul);
|
|
@@ -10439,60 +10629,59 @@ var CheckList = class CheckList extends BaseDropdown {
|
|
|
10439
10629
|
this.emitter.emit("after-populating-filter", tf, colIndex, flt);
|
|
10440
10630
|
}
|
|
10441
10631
|
/**
|
|
10632
|
+
* Return the checklist entries in render order: the reset option,
|
|
10633
|
+
* the optional empty and non-empty options, then the column values.
|
|
10634
|
+
* A `hidden` entry is rendered with `display: none` by the legacy
|
|
10635
|
+
* path and skipped by `<tf-checklist>`, which has no hidden option
|
|
10636
|
+
* state (checkList.js:321-324, :345-347).
|
|
10637
|
+
* @param {Number} colIndex Column index
|
|
10638
|
+
* @returns {Array} Option entries
|
|
10639
|
+
* @private
|
|
10640
|
+
*/
|
|
10641
|
+
getOptionEntries(colIndex) {
|
|
10642
|
+
let tf = this.tf;
|
|
10643
|
+
let entries = [{
|
|
10644
|
+
value: "",
|
|
10645
|
+
text: tf.getClearFilterText(colIndex),
|
|
10646
|
+
hidden: !this.enableResetOption
|
|
10647
|
+
}];
|
|
10648
|
+
if (tf.enableEmptyOption) entries.push({
|
|
10649
|
+
value: tf.emOperator,
|
|
10650
|
+
text: tf.emptyText
|
|
10651
|
+
});
|
|
10652
|
+
if (tf.enableNonEmptyOption) entries.push({
|
|
10653
|
+
value: tf.nmOperator,
|
|
10654
|
+
text: tf.nonEmptyText
|
|
10655
|
+
});
|
|
10656
|
+
this.opts.forEach((val, y) => {
|
|
10657
|
+
entries.push({
|
|
10658
|
+
value: val,
|
|
10659
|
+
text: this.isCustom ? this.optsTxt[y] : val,
|
|
10660
|
+
disabled: tf.linkedFilters && tf.disableExcludedOptions && has(this.excludedOpts, matchCase(val, tf.caseSensitive), tf.caseSensitive),
|
|
10661
|
+
hidden: val === ""
|
|
10662
|
+
});
|
|
10663
|
+
});
|
|
10664
|
+
return entries;
|
|
10665
|
+
}
|
|
10666
|
+
/**
|
|
10442
10667
|
* Add checklist options
|
|
10443
10668
|
* @param {Number} colIndex Column index
|
|
10444
10669
|
* @param {Object} ul Ul element
|
|
10445
10670
|
* @private
|
|
10446
10671
|
*/
|
|
10447
10672
|
addChecks(colIndex, ul) {
|
|
10448
|
-
let
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
let val = this.opts[y];
|
|
10452
|
-
let lbl = this.isCustom ? this.optsTxt[y] : val;
|
|
10453
|
-
let fltId = tf.fltIds[colIndex];
|
|
10454
|
-
let lblIdx = y + chkCt;
|
|
10455
|
-
let li = createCheckItem(`${fltId}_${lblIdx}`, val, lbl, ["data-idx", lblIdx]);
|
|
10673
|
+
let fltId = this.tf.fltIds[colIndex];
|
|
10674
|
+
this.getOptionEntries(colIndex).forEach((entry, idx) => {
|
|
10675
|
+
let li = createCheckItem(`${fltId}_${idx}`, entry.value, entry.text, ["data-idx", idx]);
|
|
10456
10676
|
li.className = this.itemCssClass;
|
|
10457
|
-
if (
|
|
10677
|
+
if (entry.disabled) {
|
|
10458
10678
|
addClass(li, this.disabledItemCssClass);
|
|
10459
10679
|
li.check.disabled = true;
|
|
10460
10680
|
li.disabled = true;
|
|
10461
10681
|
} else addEvt(li.check, "click", (evt) => this.optionClick(evt));
|
|
10462
10682
|
ul.appendChild(li);
|
|
10463
|
-
if (
|
|
10464
|
-
}
|
|
10465
|
-
}
|
|
10466
|
-
/**
|
|
10467
|
-
* Add checklist header option
|
|
10468
|
-
* @param {Number} colIndex Column index
|
|
10469
|
-
* @param {Object} ul Ul element
|
|
10470
|
-
* @private
|
|
10471
|
-
*/
|
|
10472
|
-
addTChecks(colIndex, ul) {
|
|
10473
|
-
let tf = this.tf;
|
|
10474
|
-
let chkCt = 1;
|
|
10475
|
-
let fltId = tf.fltIds[colIndex];
|
|
10476
|
-
let li0 = createCheckItem(`${fltId}_0`, "", tf.getClearFilterText(colIndex), ["data-idx", 0]);
|
|
10477
|
-
li0.className = this.itemCssClass;
|
|
10478
|
-
ul.appendChild(li0);
|
|
10479
|
-
addEvt(li0.check, "click", (evt) => this.optionClick(evt));
|
|
10480
|
-
if (!this.enableResetOption) li0.style.display = NONE;
|
|
10481
|
-
if (tf.enableEmptyOption) {
|
|
10482
|
-
let li1 = createCheckItem(`${fltId}_1`, tf.emOperator, tf.emptyText, ["data-idx", 1]);
|
|
10483
|
-
li1.className = this.itemCssClass;
|
|
10484
|
-
ul.appendChild(li1);
|
|
10485
|
-
addEvt(li1.check, "click", (evt) => this.optionClick(evt));
|
|
10486
|
-
chkCt++;
|
|
10487
|
-
}
|
|
10488
|
-
if (tf.enableNonEmptyOption) {
|
|
10489
|
-
let li2 = createCheckItem(`${fltId}_2`, tf.nmOperator, tf.nonEmptyText, ["data-idx", 2]);
|
|
10490
|
-
li2.className = this.itemCssClass;
|
|
10491
|
-
ul.appendChild(li2);
|
|
10492
|
-
addEvt(li2.check, "click", (evt) => this.optionClick(evt));
|
|
10493
|
-
chkCt++;
|
|
10494
|
-
}
|
|
10495
|
-
return chkCt;
|
|
10683
|
+
if (entry.hidden) li.style.display = NONE;
|
|
10684
|
+
});
|
|
10496
10685
|
}
|
|
10497
10686
|
/**
|
|
10498
10687
|
* Set/unset value of passed item option in filter's DOM element attribute
|
|
@@ -10549,6 +10738,10 @@ var CheckList = class CheckList extends BaseDropdown {
|
|
|
10549
10738
|
* @param {Array} values Array of option values to select
|
|
10550
10739
|
*/
|
|
10551
10740
|
selectOptions(colIndex, values = []) {
|
|
10741
|
+
if (this.ceElms[colIndex]) {
|
|
10742
|
+
this.selectOptionsCE(colIndex, values);
|
|
10743
|
+
return;
|
|
10744
|
+
}
|
|
10552
10745
|
let tf = this.tf;
|
|
10553
10746
|
let flt = tf.getFilterElement(colIndex);
|
|
10554
10747
|
if (!flt || values.length === 0) return;
|
|
@@ -10566,11 +10759,40 @@ var CheckList = class CheckList extends BaseDropdown {
|
|
|
10566
10759
|
});
|
|
10567
10760
|
}
|
|
10568
10761
|
/**
|
|
10762
|
+
* Select options on a <tf-checklist> host. Values are matched against
|
|
10763
|
+
* the rendered entries the way the legacy `selectOptions()` matches
|
|
10764
|
+
* the checkbox values, and the reset value (`''`) clears the
|
|
10765
|
+
* selection instead of being selected (checkList.js:457-477).
|
|
10766
|
+
* @param {Number} colIndex Column index
|
|
10767
|
+
* @param {Array} values Array of option values to select
|
|
10768
|
+
* @private
|
|
10769
|
+
*/
|
|
10770
|
+
selectOptionsCE(colIndex, values) {
|
|
10771
|
+
let tf = this.tf;
|
|
10772
|
+
let host = this.ceElms[colIndex];
|
|
10773
|
+
if (!host) return;
|
|
10774
|
+
if (isArray(values) && values.length === 0) return;
|
|
10775
|
+
let requested = (isArray(values) ? values : []).filter((value) => String(value) !== "");
|
|
10776
|
+
let selected = [];
|
|
10777
|
+
this.getOptionEntries(colIndex).filter((entry) => !entry.hidden).forEach((entry) => {
|
|
10778
|
+
let value = matchCase(String(entry.value), tf.caseSensitive);
|
|
10779
|
+
if (has(requested, value, tf.caseSensitive)) selected.push(entry.value);
|
|
10780
|
+
});
|
|
10781
|
+
host.setSelectedValues(selected);
|
|
10782
|
+
this.ceValues[colIndex] = selected;
|
|
10783
|
+
this.syncCEText(colIndex);
|
|
10784
|
+
}
|
|
10785
|
+
/**
|
|
10569
10786
|
* Get filter values for a given column index
|
|
10570
10787
|
* @param {Number} colIndex Column index
|
|
10571
10788
|
* @returns {Array} values Collection of selected values
|
|
10572
10789
|
*/
|
|
10573
10790
|
getValues(colIndex) {
|
|
10791
|
+
let host = this.ceElms[colIndex];
|
|
10792
|
+
if (host) {
|
|
10793
|
+
let values = host.getSelectedValues();
|
|
10794
|
+
return values.length === 0 ? [""] : values;
|
|
10795
|
+
}
|
|
10574
10796
|
let tf = this.tf;
|
|
10575
10797
|
let flt = tf.getFilterElement(colIndex);
|
|
10576
10798
|
if (!flt) return [];
|
|
@@ -10581,13 +10803,33 @@ var CheckList = class CheckList extends BaseDropdown {
|
|
|
10581
10803
|
return values;
|
|
10582
10804
|
}
|
|
10583
10805
|
/**
|
|
10806
|
+
* Remove the <tf-checklist> hosts and the handlers bound to them
|
|
10807
|
+
* @private
|
|
10808
|
+
*/
|
|
10809
|
+
destroyCE() {
|
|
10810
|
+
this.ceElms.forEach((host, colIndex) => {
|
|
10811
|
+
if (!host) return;
|
|
10812
|
+
let evt = this.ceEvt[colIndex];
|
|
10813
|
+
if (evt) {
|
|
10814
|
+
removeEvt(host, "selection-change", evt.selectionChange);
|
|
10815
|
+
removeEvt(host, "open-change", evt.openChange);
|
|
10816
|
+
}
|
|
10817
|
+
if (host.parentNode) removeElm(host);
|
|
10818
|
+
});
|
|
10819
|
+
this.ceElms = [];
|
|
10820
|
+
this.ceEvt = [];
|
|
10821
|
+
this.ceValues = [];
|
|
10822
|
+
}
|
|
10823
|
+
/**
|
|
10584
10824
|
* Destroy CheckList instance
|
|
10585
10825
|
*/
|
|
10586
10826
|
destroy() {
|
|
10587
|
-
|
|
10588
|
-
this.emitter.off(["
|
|
10589
|
-
this.emitter.off(["
|
|
10590
|
-
this.emitter.off(["
|
|
10827
|
+
if (!this.initialized) return;
|
|
10828
|
+
this.emitter.off(["build-checklist-filter"], this.onBuildChecklistFilter);
|
|
10829
|
+
this.emitter.off(["select-checklist-options"], this.onSelectChecklistOptions);
|
|
10830
|
+
this.emitter.off(["rows-changed"], this.onRowsChanged);
|
|
10831
|
+
this.emitter.off(["after-filtering"], this.onAfterFiltering);
|
|
10832
|
+
this.destroyCE();
|
|
10591
10833
|
this.initialized = false;
|
|
10592
10834
|
}
|
|
10593
10835
|
};
|
|
@@ -15717,7 +15959,7 @@ var TableFilter = class {
|
|
|
15717
15959
|
* Current version
|
|
15718
15960
|
* @type {String}
|
|
15719
15961
|
*/
|
|
15720
|
-
this.version = "0.7.
|
|
15962
|
+
this.version = "0.7.8";
|
|
15721
15963
|
/**
|
|
15722
15964
|
* Current year
|
|
15723
15965
|
* @type {Number}
|