tablefilter 0.7.6 → 0.7.7
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/dist/starter.html +2 -2
- package/dist/tablefilter/tablefilter.js +1 -1
- package/dist/tablefilter/tf-1-7e29d0dbe6e0e0a4ff05.js +1 -0
- package/dist/tablefilter/{tf-2-025e1e774794d5827df8.js → tf-2-0ea691278d572212426a.js} +2 -2
- package/dist/tablefilter.cjs.js +203 -30
- package/dist/tablefilter.esm.js +203 -30
- package/dist/tablefilter.umd.js +203 -30
- package/package.json +1 -1
- package/src/components/tf-pager.js +325 -0
- package/src/components/tf-results-per-page.js +181 -0
- package/src/modules/paging.js +270 -46
- package/dist/tablefilter/tf-1-bc5a8b07e0d66035b05b.js +0 -1
package/dist/tablefilter.cjs.js
CHANGED
|
@@ -15050,6 +15050,12 @@ var Paging = class Paging extends Feature {
|
|
|
15050
15050
|
* @private
|
|
15051
15051
|
*/
|
|
15052
15052
|
this.pgAfter = null;
|
|
15053
|
+
/**
|
|
15054
|
+
* <tf-pager> custom element host, when the bridge is active
|
|
15055
|
+
* @type {DOMElement}
|
|
15056
|
+
* @private
|
|
15057
|
+
*/
|
|
15058
|
+
this.pagerEl = null;
|
|
15053
15059
|
let startRow = tf.refRow;
|
|
15054
15060
|
let nrows = tf.getRowsNb(true);
|
|
15055
15061
|
this.nbPages = Math.ceil((nrows - startRow) / this.pageLength);
|
|
@@ -15090,6 +15096,7 @@ var Paging = class Paging extends Feature {
|
|
|
15090
15096
|
}
|
|
15091
15097
|
},
|
|
15092
15098
|
slcPagesChange: null,
|
|
15099
|
+
pagerPageChange: null,
|
|
15093
15100
|
nextEvt: null,
|
|
15094
15101
|
prevEvt: null,
|
|
15095
15102
|
lastEvt: null,
|
|
@@ -15100,9 +15107,7 @@ var Paging = class Paging extends Feature {
|
|
|
15100
15107
|
* Initialize DOM elements
|
|
15101
15108
|
*/
|
|
15102
15109
|
init() {
|
|
15103
|
-
let slcPages;
|
|
15104
15110
|
let tf = this.tf;
|
|
15105
|
-
let evt = this.evt;
|
|
15106
15111
|
if (this.initialized) return;
|
|
15107
15112
|
this.emitter.emit("initializing-feature", this, !isNull(this.tgtId));
|
|
15108
15113
|
if (this.hasResultsPerPage) {
|
|
@@ -15112,6 +15117,60 @@ var Paging = class Paging extends Feature {
|
|
|
15112
15117
|
this.setResultsPerPage();
|
|
15113
15118
|
}
|
|
15114
15119
|
}
|
|
15120
|
+
let targetEl = !this.tgtId ? tf.feature("toolbar").container(this.toolbarPosition) : elm(this.tgtId);
|
|
15121
|
+
if (typeof customElements !== "undefined" && customElements.get("tf-pager") && !tf.enableIcons && !this.hasBtnHtml()) this.initCE(targetEl);
|
|
15122
|
+
else this.initLegacy(targetEl);
|
|
15123
|
+
this.setPagingInfo();
|
|
15124
|
+
if (!tf.fltGrid) {
|
|
15125
|
+
tf.validateAllRows();
|
|
15126
|
+
this.setPagingInfo(tf.validRowsIndex);
|
|
15127
|
+
}
|
|
15128
|
+
this.emitter.on(["after-filtering"], bound(this.resetPagingInfo, this));
|
|
15129
|
+
this.emitter.on(["change-page"], bound(this.changePageHandler, this));
|
|
15130
|
+
this.emitter.on(["change-page-results"], bound(this.changePageResultsHandler, this));
|
|
15131
|
+
/** @inherited */
|
|
15132
|
+
this.initialized = true;
|
|
15133
|
+
this.emitter.emit("feature-initialized", this);
|
|
15134
|
+
}
|
|
15135
|
+
/**
|
|
15136
|
+
* Initialize using the <tf-pager> custom element
|
|
15137
|
+
* @param {DOMElement} targetEl Target container element
|
|
15138
|
+
* @private
|
|
15139
|
+
*/
|
|
15140
|
+
initCE(targetEl) {
|
|
15141
|
+
let evt = this.evt;
|
|
15142
|
+
let tf = this.tf;
|
|
15143
|
+
let pagerEl = document.createElement("tf-pager");
|
|
15144
|
+
pagerEl.className = this.pgCssClass();
|
|
15145
|
+
pagerEl.setAttribute("selector-type", this.pageSelectorType);
|
|
15146
|
+
pagerEl.setAttribute("page-text", this.pageText);
|
|
15147
|
+
pagerEl.setAttribute("of-text", this.ofText);
|
|
15148
|
+
if (!this.hasBtns) pagerEl.setAttribute("buttons", "false");
|
|
15149
|
+
this.setPagerButtons(pagerEl);
|
|
15150
|
+
if (!this.isEnabled()) pagerEl.setAttribute("disabled", "");
|
|
15151
|
+
targetEl.appendChild(pagerEl);
|
|
15152
|
+
this.pagerEl = pagerEl;
|
|
15153
|
+
this.pageSlc = pagerEl.shadowRoot.querySelector(this.pageSelectorType === "input" ? "[part=\"page-input\"]" : "[part=\"page-select\"]");
|
|
15154
|
+
this.bindPagerButton("first", evt.first);
|
|
15155
|
+
this.bindPagerButton("prev", evt.prev);
|
|
15156
|
+
this.bindPagerButton("next", evt.next);
|
|
15157
|
+
this.bindPagerButton("last", evt.last);
|
|
15158
|
+
evt.pagerPageChange = (event) => {
|
|
15159
|
+
let page = parseInt(event.detail.page, 10);
|
|
15160
|
+
if (isNaN(page)) return;
|
|
15161
|
+
if (this.pageSelectorType === "input" && tf.sorted) tf.filter();
|
|
15162
|
+
this.changePage(page - 1);
|
|
15163
|
+
};
|
|
15164
|
+
addEvt(pagerEl, "page-change", evt.pagerPageChange);
|
|
15165
|
+
}
|
|
15166
|
+
/**
|
|
15167
|
+
* Initialize using the legacy spans, controls and select
|
|
15168
|
+
* @param {DOMElement} targetEl Target container element
|
|
15169
|
+
* @private
|
|
15170
|
+
*/
|
|
15171
|
+
initLegacy(targetEl) {
|
|
15172
|
+
let slcPages;
|
|
15173
|
+
let evt = this.evt;
|
|
15115
15174
|
evt.slcPagesChange = (event) => {
|
|
15116
15175
|
let slc = event.target;
|
|
15117
15176
|
this.changePage(slc.selectedIndex);
|
|
@@ -15168,7 +15227,6 @@ var Paging = class Paging extends Feature {
|
|
|
15168
15227
|
addEvt(btnFirstSpan, "click", evt.first);
|
|
15169
15228
|
}
|
|
15170
15229
|
}
|
|
15171
|
-
let targetEl = !this.tgtId ? tf.feature("toolbar").container(this.toolbarPosition) : elm(this.tgtId);
|
|
15172
15230
|
targetEl.appendChild(btnFirstSpan);
|
|
15173
15231
|
targetEl.appendChild(btnPrevSpan);
|
|
15174
15232
|
let pgBeforeSpan = createElm("span");
|
|
@@ -15194,17 +15252,87 @@ var Paging = class Paging extends Feature {
|
|
|
15194
15252
|
this.pgBefore = pgBeforeSpan;
|
|
15195
15253
|
this.pgAfter = pgAfterSpan;
|
|
15196
15254
|
this.pageSlc = slcPages;
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
15206
|
-
|
|
15207
|
-
|
|
15255
|
+
}
|
|
15256
|
+
/**
|
|
15257
|
+
* The legacy paging classes, applied to the <tf-pager> host
|
|
15258
|
+
* @return {String} Space-separated class list
|
|
15259
|
+
* @private
|
|
15260
|
+
*/
|
|
15261
|
+
pgCssClass() {
|
|
15262
|
+
return [
|
|
15263
|
+
this.btnCssClass,
|
|
15264
|
+
this.pgSlcCssClass,
|
|
15265
|
+
this.pgInpCssClass,
|
|
15266
|
+
this.nbPgSpanCssClass
|
|
15267
|
+
].join(" ");
|
|
15268
|
+
}
|
|
15269
|
+
/**
|
|
15270
|
+
* Whether a `btn_*_page_html` value is set
|
|
15271
|
+
* @return {Boolean} True when any button HTML is configured
|
|
15272
|
+
* @private
|
|
15273
|
+
*/
|
|
15274
|
+
hasBtnHtml() {
|
|
15275
|
+
return Boolean(this.btnFirstPageHtml || this.btnPrevPageHtml || this.btnNextPageHtml || this.btnLastPageHtml);
|
|
15276
|
+
}
|
|
15277
|
+
/**
|
|
15278
|
+
* Set the `btn_*_page_text` captions on the <tf-pager> buttons
|
|
15279
|
+
* (paging.js:390-444).
|
|
15280
|
+
* @param {DOMElement} pagerEl <tf-pager> host
|
|
15281
|
+
* @private
|
|
15282
|
+
*/
|
|
15283
|
+
setPagerButtons(pagerEl) {
|
|
15284
|
+
[
|
|
15285
|
+
{
|
|
15286
|
+
part: "first",
|
|
15287
|
+
text: this.btnFirstPageText
|
|
15288
|
+
},
|
|
15289
|
+
{
|
|
15290
|
+
part: "prev",
|
|
15291
|
+
text: this.btnPrevPageText
|
|
15292
|
+
},
|
|
15293
|
+
{
|
|
15294
|
+
part: "next",
|
|
15295
|
+
text: this.btnNextPageText
|
|
15296
|
+
},
|
|
15297
|
+
{
|
|
15298
|
+
part: "last",
|
|
15299
|
+
text: this.btnLastPageText
|
|
15300
|
+
}
|
|
15301
|
+
].forEach((btn) => {
|
|
15302
|
+
pagerEl.setAttribute(`${btn.part}-text`, btn.text);
|
|
15303
|
+
});
|
|
15304
|
+
}
|
|
15305
|
+
/**
|
|
15306
|
+
* Bind a paging handler to a <tf-pager> button
|
|
15307
|
+
* @param {String} part Button part name
|
|
15308
|
+
* @param {Function} handler Paging handler
|
|
15309
|
+
* @private
|
|
15310
|
+
*/
|
|
15311
|
+
bindPagerButton(part, handler) {
|
|
15312
|
+
addEvt(this.pagerEl.shadowRoot.querySelector(`[part="${part}"]`), "click", handler);
|
|
15313
|
+
}
|
|
15314
|
+
/**
|
|
15315
|
+
* Remove a paging handler from a <tf-pager> button
|
|
15316
|
+
* @param {String} part Button part name
|
|
15317
|
+
* @param {Function} handler Paging handler
|
|
15318
|
+
* @private
|
|
15319
|
+
*/
|
|
15320
|
+
unbindPagerButton(part, handler) {
|
|
15321
|
+
removeEvt(this.pagerEl.shadowRoot.querySelector(`[part="${part}"]`), "click", handler);
|
|
15322
|
+
}
|
|
15323
|
+
/**
|
|
15324
|
+
* Paging entries shared by the legacy select and <tf-pager>: page
|
|
15325
|
+
* number as visible text, start row as value
|
|
15326
|
+
* @return {Array<Object>} Page entries
|
|
15327
|
+
* @private
|
|
15328
|
+
*/
|
|
15329
|
+
pageEntries() {
|
|
15330
|
+
let entries = [];
|
|
15331
|
+
for (let z = 0; z < this.nbPages; z++) entries.push({
|
|
15332
|
+
text: String(z + 1),
|
|
15333
|
+
value: String(z * this.pageLength)
|
|
15334
|
+
});
|
|
15335
|
+
return entries;
|
|
15208
15336
|
}
|
|
15209
15337
|
/**
|
|
15210
15338
|
* Reset paging when filters are already instantiated
|
|
@@ -15233,15 +15361,22 @@ var Paging = class Paging extends Feature {
|
|
|
15233
15361
|
let cont = !this.tgtId ? tf.feature("toolbar").container(this.toolbarPosition) : elm(this.tgtId);
|
|
15234
15362
|
tf.validRowsIndex = validRows || tf.getValidRows(true);
|
|
15235
15363
|
this.nbPages = Math.ceil(tf.validRowsIndex.length / this.pageLength);
|
|
15236
|
-
this.
|
|
15237
|
-
|
|
15364
|
+
if (this.pagerEl) {
|
|
15365
|
+
this.pagerEl.setTotalPages(this.nbPages);
|
|
15366
|
+
this.pagerEl.setPages(this.pageEntries());
|
|
15367
|
+
this.pagerEl.setPage(this.currentPageNb);
|
|
15368
|
+
} else {
|
|
15369
|
+
this.pgCont.innerHTML = this.nbPages;
|
|
15370
|
+
if (this.pageSelectorType === "select") this.pageSlc.innerHTML = "";
|
|
15371
|
+
}
|
|
15238
15372
|
if (this.nbPages > 0) {
|
|
15239
15373
|
cont.style.visibility = "visible";
|
|
15240
|
-
if (this.
|
|
15241
|
-
|
|
15242
|
-
|
|
15374
|
+
if (!this.pagerEl) {
|
|
15375
|
+
if (this.pageSelectorType === "select") this.pageEntries().forEach((entry, z) => {
|
|
15376
|
+
this.pageSlc.options[z] = createOpt(entry.text, entry.value, false);
|
|
15377
|
+
});
|
|
15378
|
+
else this.pageSlc.value = this.currentPageNb;
|
|
15243
15379
|
}
|
|
15244
|
-
else this.pageSlc.value = this.currentPageNb;
|
|
15245
15380
|
} else
|
|
15246
15381
|
/*** if no results paging select and buttons are hidden ***/
|
|
15247
15382
|
cont.style.visibility = "hidden";
|
|
@@ -15360,7 +15495,8 @@ var Paging = class Paging extends Feature {
|
|
|
15360
15495
|
if (index >= 0 && index <= this.nbPages - 1) {
|
|
15361
15496
|
this.onBeforeChangePage(this, index + 1);
|
|
15362
15497
|
this.currentPageNb = parseInt(index, 10) + 1;
|
|
15363
|
-
if (this.
|
|
15498
|
+
if (this.pagerEl) this.pagerEl.setPage(this.currentPageNb);
|
|
15499
|
+
else if (this.pageSelectorType === "select") this.pageSlc.options[index].selected = true;
|
|
15364
15500
|
else this.pageSlc.value = this.currentPageNb;
|
|
15365
15501
|
this.startPagingRow = this.pageSelectorType === "select" ? this.pageSlc.value : index * this.pageLength;
|
|
15366
15502
|
this.groupByPage();
|
|
@@ -15392,7 +15528,8 @@ var Paging = class Paging extends Feature {
|
|
|
15392
15528
|
if (!isNaN(this.pageLength)) {
|
|
15393
15529
|
if (this.startPagingRow >= tf.nbFilterableRows) this.startPagingRow = tf.nbFilterableRows - this.pageLength;
|
|
15394
15530
|
this.setPagingInfo();
|
|
15395
|
-
if (
|
|
15531
|
+
if (this.pagerEl) this.pagerEl.setPage(Math.min(slcPagesSelIndex, this.nbPages - 1) + 1);
|
|
15532
|
+
else if (pageSelectorType === "select") {
|
|
15396
15533
|
let slcIdx = pageSlc.options.length - 1 <= slcPagesSelIndex ? pageSlc.options.length - 1 : slcPagesSelIndex;
|
|
15397
15534
|
pageSlc.options[slcIdx].selected = true;
|
|
15398
15535
|
}
|
|
@@ -15433,10 +15570,53 @@ var Paging = class Paging extends Feature {
|
|
|
15433
15570
|
this.changeResultsPerPage(pageLength);
|
|
15434
15571
|
}
|
|
15435
15572
|
/**
|
|
15573
|
+
* Disable paging and reflect the state on the pager element
|
|
15574
|
+
*/
|
|
15575
|
+
disable() {
|
|
15576
|
+
super.disable();
|
|
15577
|
+
if (this.pagerEl) this.pagerEl.setAttribute("disabled", "");
|
|
15578
|
+
}
|
|
15579
|
+
/**
|
|
15580
|
+
* Enable paging and reflect the state on the pager element
|
|
15581
|
+
*/
|
|
15582
|
+
enable() {
|
|
15583
|
+
super.enable();
|
|
15584
|
+
if (this.pagerEl) this.pagerEl.removeAttribute("disabled");
|
|
15585
|
+
}
|
|
15586
|
+
/**
|
|
15436
15587
|
* Remove paging feature
|
|
15437
15588
|
*/
|
|
15438
15589
|
destroy() {
|
|
15439
15590
|
if (!this.initialized) return;
|
|
15591
|
+
if (this.pagerEl) this.destroyCE();
|
|
15592
|
+
else this.destroyLegacy();
|
|
15593
|
+
if (this.hasResultsPerPage) this.removeResultsPerPage();
|
|
15594
|
+
this.emitter.off(["after-filtering"], bound(this.resetPagingInfo, this));
|
|
15595
|
+
this.emitter.off(["change-page"], bound(this.changePageHandler, this));
|
|
15596
|
+
this.emitter.off(["change-page-results"], bound(this.changePageResultsHandler, this));
|
|
15597
|
+
this.pageSlc = null;
|
|
15598
|
+
this.nbPages = 0;
|
|
15599
|
+
this.initialized = false;
|
|
15600
|
+
}
|
|
15601
|
+
/**
|
|
15602
|
+
* Remove the <tf-pager> element and the handlers bound to it
|
|
15603
|
+
* @private
|
|
15604
|
+
*/
|
|
15605
|
+
destroyCE() {
|
|
15606
|
+
let evt = this.evt;
|
|
15607
|
+
removeEvt(this.pagerEl, "page-change", evt.pagerPageChange);
|
|
15608
|
+
this.unbindPagerButton("first", evt.first);
|
|
15609
|
+
this.unbindPagerButton("prev", evt.prev);
|
|
15610
|
+
this.unbindPagerButton("next", evt.next);
|
|
15611
|
+
this.unbindPagerButton("last", evt.last);
|
|
15612
|
+
removeElm(this.pagerEl);
|
|
15613
|
+
this.pagerEl = null;
|
|
15614
|
+
}
|
|
15615
|
+
/**
|
|
15616
|
+
* Remove the legacy paging controls and the handlers bound to them
|
|
15617
|
+
* @private
|
|
15618
|
+
*/
|
|
15619
|
+
destroyLegacy() {
|
|
15440
15620
|
let evt = this.evt;
|
|
15441
15621
|
if (this.pageSlc) {
|
|
15442
15622
|
if (this.pageSelectorType === "select") removeEvt(this.pageSlc, "change", evt.slcPagesChange);
|
|
@@ -15475,13 +15655,6 @@ var Paging = class Paging extends Feature {
|
|
|
15475
15655
|
removeElm(this.pgCont);
|
|
15476
15656
|
this.pgCont = null;
|
|
15477
15657
|
}
|
|
15478
|
-
if (this.hasResultsPerPage) this.removeResultsPerPage();
|
|
15479
|
-
this.emitter.off(["after-filtering"], bound(this.resetPagingInfo, this));
|
|
15480
|
-
this.emitter.off(["change-page"], bound(this.changePageHandler, this));
|
|
15481
|
-
this.emitter.off(["change-page-results"], bound(this.changePageResultsHandler, this));
|
|
15482
|
-
this.pageSlc = null;
|
|
15483
|
-
this.nbPages = 0;
|
|
15484
|
-
this.initialized = false;
|
|
15485
15658
|
}
|
|
15486
15659
|
};
|
|
15487
15660
|
//#endregion
|
|
@@ -15544,7 +15717,7 @@ var TableFilter = class {
|
|
|
15544
15717
|
* Current version
|
|
15545
15718
|
* @type {String}
|
|
15546
15719
|
*/
|
|
15547
|
-
this.version = "0.7.
|
|
15720
|
+
this.version = "0.7.7";
|
|
15548
15721
|
/**
|
|
15549
15722
|
* Current year
|
|
15550
15723
|
* @type {Number}
|
package/dist/tablefilter.esm.js
CHANGED
|
@@ -15053,6 +15053,12 @@ var Paging = class Paging extends Feature {
|
|
|
15053
15053
|
* @private
|
|
15054
15054
|
*/
|
|
15055
15055
|
this.pgAfter = null;
|
|
15056
|
+
/**
|
|
15057
|
+
* <tf-pager> custom element host, when the bridge is active
|
|
15058
|
+
* @type {DOMElement}
|
|
15059
|
+
* @private
|
|
15060
|
+
*/
|
|
15061
|
+
this.pagerEl = null;
|
|
15056
15062
|
let startRow = tf.refRow;
|
|
15057
15063
|
let nrows = tf.getRowsNb(true);
|
|
15058
15064
|
this.nbPages = Math.ceil((nrows - startRow) / this.pageLength);
|
|
@@ -15093,6 +15099,7 @@ var Paging = class Paging extends Feature {
|
|
|
15093
15099
|
}
|
|
15094
15100
|
},
|
|
15095
15101
|
slcPagesChange: null,
|
|
15102
|
+
pagerPageChange: null,
|
|
15096
15103
|
nextEvt: null,
|
|
15097
15104
|
prevEvt: null,
|
|
15098
15105
|
lastEvt: null,
|
|
@@ -15103,9 +15110,7 @@ var Paging = class Paging extends Feature {
|
|
|
15103
15110
|
* Initialize DOM elements
|
|
15104
15111
|
*/
|
|
15105
15112
|
init() {
|
|
15106
|
-
let slcPages;
|
|
15107
15113
|
let tf = this.tf;
|
|
15108
|
-
let evt = this.evt;
|
|
15109
15114
|
if (this.initialized) return;
|
|
15110
15115
|
this.emitter.emit("initializing-feature", this, !isNull(this.tgtId));
|
|
15111
15116
|
if (this.hasResultsPerPage) {
|
|
@@ -15115,6 +15120,60 @@ var Paging = class Paging extends Feature {
|
|
|
15115
15120
|
this.setResultsPerPage();
|
|
15116
15121
|
}
|
|
15117
15122
|
}
|
|
15123
|
+
let targetEl = !this.tgtId ? tf.feature("toolbar").container(this.toolbarPosition) : elm(this.tgtId);
|
|
15124
|
+
if (typeof customElements !== "undefined" && customElements.get("tf-pager") && !tf.enableIcons && !this.hasBtnHtml()) this.initCE(targetEl);
|
|
15125
|
+
else this.initLegacy(targetEl);
|
|
15126
|
+
this.setPagingInfo();
|
|
15127
|
+
if (!tf.fltGrid) {
|
|
15128
|
+
tf.validateAllRows();
|
|
15129
|
+
this.setPagingInfo(tf.validRowsIndex);
|
|
15130
|
+
}
|
|
15131
|
+
this.emitter.on(["after-filtering"], bound(this.resetPagingInfo, this));
|
|
15132
|
+
this.emitter.on(["change-page"], bound(this.changePageHandler, this));
|
|
15133
|
+
this.emitter.on(["change-page-results"], bound(this.changePageResultsHandler, this));
|
|
15134
|
+
/** @inherited */
|
|
15135
|
+
this.initialized = true;
|
|
15136
|
+
this.emitter.emit("feature-initialized", this);
|
|
15137
|
+
}
|
|
15138
|
+
/**
|
|
15139
|
+
* Initialize using the <tf-pager> custom element
|
|
15140
|
+
* @param {DOMElement} targetEl Target container element
|
|
15141
|
+
* @private
|
|
15142
|
+
*/
|
|
15143
|
+
initCE(targetEl) {
|
|
15144
|
+
let evt = this.evt;
|
|
15145
|
+
let tf = this.tf;
|
|
15146
|
+
let pagerEl = document.createElement("tf-pager");
|
|
15147
|
+
pagerEl.className = this.pgCssClass();
|
|
15148
|
+
pagerEl.setAttribute("selector-type", this.pageSelectorType);
|
|
15149
|
+
pagerEl.setAttribute("page-text", this.pageText);
|
|
15150
|
+
pagerEl.setAttribute("of-text", this.ofText);
|
|
15151
|
+
if (!this.hasBtns) pagerEl.setAttribute("buttons", "false");
|
|
15152
|
+
this.setPagerButtons(pagerEl);
|
|
15153
|
+
if (!this.isEnabled()) pagerEl.setAttribute("disabled", "");
|
|
15154
|
+
targetEl.appendChild(pagerEl);
|
|
15155
|
+
this.pagerEl = pagerEl;
|
|
15156
|
+
this.pageSlc = pagerEl.shadowRoot.querySelector(this.pageSelectorType === "input" ? "[part=\"page-input\"]" : "[part=\"page-select\"]");
|
|
15157
|
+
this.bindPagerButton("first", evt.first);
|
|
15158
|
+
this.bindPagerButton("prev", evt.prev);
|
|
15159
|
+
this.bindPagerButton("next", evt.next);
|
|
15160
|
+
this.bindPagerButton("last", evt.last);
|
|
15161
|
+
evt.pagerPageChange = (event) => {
|
|
15162
|
+
let page = parseInt(event.detail.page, 10);
|
|
15163
|
+
if (isNaN(page)) return;
|
|
15164
|
+
if (this.pageSelectorType === "input" && tf.sorted) tf.filter();
|
|
15165
|
+
this.changePage(page - 1);
|
|
15166
|
+
};
|
|
15167
|
+
addEvt(pagerEl, "page-change", evt.pagerPageChange);
|
|
15168
|
+
}
|
|
15169
|
+
/**
|
|
15170
|
+
* Initialize using the legacy spans, controls and select
|
|
15171
|
+
* @param {DOMElement} targetEl Target container element
|
|
15172
|
+
* @private
|
|
15173
|
+
*/
|
|
15174
|
+
initLegacy(targetEl) {
|
|
15175
|
+
let slcPages;
|
|
15176
|
+
let evt = this.evt;
|
|
15118
15177
|
evt.slcPagesChange = (event) => {
|
|
15119
15178
|
let slc = event.target;
|
|
15120
15179
|
this.changePage(slc.selectedIndex);
|
|
@@ -15171,7 +15230,6 @@ var Paging = class Paging extends Feature {
|
|
|
15171
15230
|
addEvt(btnFirstSpan, "click", evt.first);
|
|
15172
15231
|
}
|
|
15173
15232
|
}
|
|
15174
|
-
let targetEl = !this.tgtId ? tf.feature("toolbar").container(this.toolbarPosition) : elm(this.tgtId);
|
|
15175
15233
|
targetEl.appendChild(btnFirstSpan);
|
|
15176
15234
|
targetEl.appendChild(btnPrevSpan);
|
|
15177
15235
|
let pgBeforeSpan = createElm("span");
|
|
@@ -15197,17 +15255,87 @@ var Paging = class Paging extends Feature {
|
|
|
15197
15255
|
this.pgBefore = pgBeforeSpan;
|
|
15198
15256
|
this.pgAfter = pgAfterSpan;
|
|
15199
15257
|
this.pageSlc = slcPages;
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
15206
|
-
|
|
15207
|
-
|
|
15208
|
-
|
|
15209
|
-
|
|
15210
|
-
|
|
15258
|
+
}
|
|
15259
|
+
/**
|
|
15260
|
+
* The legacy paging classes, applied to the <tf-pager> host
|
|
15261
|
+
* @return {String} Space-separated class list
|
|
15262
|
+
* @private
|
|
15263
|
+
*/
|
|
15264
|
+
pgCssClass() {
|
|
15265
|
+
return [
|
|
15266
|
+
this.btnCssClass,
|
|
15267
|
+
this.pgSlcCssClass,
|
|
15268
|
+
this.pgInpCssClass,
|
|
15269
|
+
this.nbPgSpanCssClass
|
|
15270
|
+
].join(" ");
|
|
15271
|
+
}
|
|
15272
|
+
/**
|
|
15273
|
+
* Whether a `btn_*_page_html` value is set
|
|
15274
|
+
* @return {Boolean} True when any button HTML is configured
|
|
15275
|
+
* @private
|
|
15276
|
+
*/
|
|
15277
|
+
hasBtnHtml() {
|
|
15278
|
+
return Boolean(this.btnFirstPageHtml || this.btnPrevPageHtml || this.btnNextPageHtml || this.btnLastPageHtml);
|
|
15279
|
+
}
|
|
15280
|
+
/**
|
|
15281
|
+
* Set the `btn_*_page_text` captions on the <tf-pager> buttons
|
|
15282
|
+
* (paging.js:390-444).
|
|
15283
|
+
* @param {DOMElement} pagerEl <tf-pager> host
|
|
15284
|
+
* @private
|
|
15285
|
+
*/
|
|
15286
|
+
setPagerButtons(pagerEl) {
|
|
15287
|
+
[
|
|
15288
|
+
{
|
|
15289
|
+
part: "first",
|
|
15290
|
+
text: this.btnFirstPageText
|
|
15291
|
+
},
|
|
15292
|
+
{
|
|
15293
|
+
part: "prev",
|
|
15294
|
+
text: this.btnPrevPageText
|
|
15295
|
+
},
|
|
15296
|
+
{
|
|
15297
|
+
part: "next",
|
|
15298
|
+
text: this.btnNextPageText
|
|
15299
|
+
},
|
|
15300
|
+
{
|
|
15301
|
+
part: "last",
|
|
15302
|
+
text: this.btnLastPageText
|
|
15303
|
+
}
|
|
15304
|
+
].forEach((btn) => {
|
|
15305
|
+
pagerEl.setAttribute(`${btn.part}-text`, btn.text);
|
|
15306
|
+
});
|
|
15307
|
+
}
|
|
15308
|
+
/**
|
|
15309
|
+
* Bind a paging handler to a <tf-pager> button
|
|
15310
|
+
* @param {String} part Button part name
|
|
15311
|
+
* @param {Function} handler Paging handler
|
|
15312
|
+
* @private
|
|
15313
|
+
*/
|
|
15314
|
+
bindPagerButton(part, handler) {
|
|
15315
|
+
addEvt(this.pagerEl.shadowRoot.querySelector(`[part="${part}"]`), "click", handler);
|
|
15316
|
+
}
|
|
15317
|
+
/**
|
|
15318
|
+
* Remove a paging handler from a <tf-pager> button
|
|
15319
|
+
* @param {String} part Button part name
|
|
15320
|
+
* @param {Function} handler Paging handler
|
|
15321
|
+
* @private
|
|
15322
|
+
*/
|
|
15323
|
+
unbindPagerButton(part, handler) {
|
|
15324
|
+
removeEvt(this.pagerEl.shadowRoot.querySelector(`[part="${part}"]`), "click", handler);
|
|
15325
|
+
}
|
|
15326
|
+
/**
|
|
15327
|
+
* Paging entries shared by the legacy select and <tf-pager>: page
|
|
15328
|
+
* number as visible text, start row as value
|
|
15329
|
+
* @return {Array<Object>} Page entries
|
|
15330
|
+
* @private
|
|
15331
|
+
*/
|
|
15332
|
+
pageEntries() {
|
|
15333
|
+
let entries = [];
|
|
15334
|
+
for (let z = 0; z < this.nbPages; z++) entries.push({
|
|
15335
|
+
text: String(z + 1),
|
|
15336
|
+
value: String(z * this.pageLength)
|
|
15337
|
+
});
|
|
15338
|
+
return entries;
|
|
15211
15339
|
}
|
|
15212
15340
|
/**
|
|
15213
15341
|
* Reset paging when filters are already instantiated
|
|
@@ -15236,15 +15364,22 @@ var Paging = class Paging extends Feature {
|
|
|
15236
15364
|
let cont = !this.tgtId ? tf.feature("toolbar").container(this.toolbarPosition) : elm(this.tgtId);
|
|
15237
15365
|
tf.validRowsIndex = validRows || tf.getValidRows(true);
|
|
15238
15366
|
this.nbPages = Math.ceil(tf.validRowsIndex.length / this.pageLength);
|
|
15239
|
-
this.
|
|
15240
|
-
|
|
15367
|
+
if (this.pagerEl) {
|
|
15368
|
+
this.pagerEl.setTotalPages(this.nbPages);
|
|
15369
|
+
this.pagerEl.setPages(this.pageEntries());
|
|
15370
|
+
this.pagerEl.setPage(this.currentPageNb);
|
|
15371
|
+
} else {
|
|
15372
|
+
this.pgCont.innerHTML = this.nbPages;
|
|
15373
|
+
if (this.pageSelectorType === "select") this.pageSlc.innerHTML = "";
|
|
15374
|
+
}
|
|
15241
15375
|
if (this.nbPages > 0) {
|
|
15242
15376
|
cont.style.visibility = "visible";
|
|
15243
|
-
if (this.
|
|
15244
|
-
|
|
15245
|
-
|
|
15377
|
+
if (!this.pagerEl) {
|
|
15378
|
+
if (this.pageSelectorType === "select") this.pageEntries().forEach((entry, z) => {
|
|
15379
|
+
this.pageSlc.options[z] = createOpt(entry.text, entry.value, false);
|
|
15380
|
+
});
|
|
15381
|
+
else this.pageSlc.value = this.currentPageNb;
|
|
15246
15382
|
}
|
|
15247
|
-
else this.pageSlc.value = this.currentPageNb;
|
|
15248
15383
|
} else
|
|
15249
15384
|
/*** if no results paging select and buttons are hidden ***/
|
|
15250
15385
|
cont.style.visibility = "hidden";
|
|
@@ -15363,7 +15498,8 @@ var Paging = class Paging extends Feature {
|
|
|
15363
15498
|
if (index >= 0 && index <= this.nbPages - 1) {
|
|
15364
15499
|
this.onBeforeChangePage(this, index + 1);
|
|
15365
15500
|
this.currentPageNb = parseInt(index, 10) + 1;
|
|
15366
|
-
if (this.
|
|
15501
|
+
if (this.pagerEl) this.pagerEl.setPage(this.currentPageNb);
|
|
15502
|
+
else if (this.pageSelectorType === "select") this.pageSlc.options[index].selected = true;
|
|
15367
15503
|
else this.pageSlc.value = this.currentPageNb;
|
|
15368
15504
|
this.startPagingRow = this.pageSelectorType === "select" ? this.pageSlc.value : index * this.pageLength;
|
|
15369
15505
|
this.groupByPage();
|
|
@@ -15395,7 +15531,8 @@ var Paging = class Paging extends Feature {
|
|
|
15395
15531
|
if (!isNaN(this.pageLength)) {
|
|
15396
15532
|
if (this.startPagingRow >= tf.nbFilterableRows) this.startPagingRow = tf.nbFilterableRows - this.pageLength;
|
|
15397
15533
|
this.setPagingInfo();
|
|
15398
|
-
if (
|
|
15534
|
+
if (this.pagerEl) this.pagerEl.setPage(Math.min(slcPagesSelIndex, this.nbPages - 1) + 1);
|
|
15535
|
+
else if (pageSelectorType === "select") {
|
|
15399
15536
|
let slcIdx = pageSlc.options.length - 1 <= slcPagesSelIndex ? pageSlc.options.length - 1 : slcPagesSelIndex;
|
|
15400
15537
|
pageSlc.options[slcIdx].selected = true;
|
|
15401
15538
|
}
|
|
@@ -15436,10 +15573,53 @@ var Paging = class Paging extends Feature {
|
|
|
15436
15573
|
this.changeResultsPerPage(pageLength);
|
|
15437
15574
|
}
|
|
15438
15575
|
/**
|
|
15576
|
+
* Disable paging and reflect the state on the pager element
|
|
15577
|
+
*/
|
|
15578
|
+
disable() {
|
|
15579
|
+
super.disable();
|
|
15580
|
+
if (this.pagerEl) this.pagerEl.setAttribute("disabled", "");
|
|
15581
|
+
}
|
|
15582
|
+
/**
|
|
15583
|
+
* Enable paging and reflect the state on the pager element
|
|
15584
|
+
*/
|
|
15585
|
+
enable() {
|
|
15586
|
+
super.enable();
|
|
15587
|
+
if (this.pagerEl) this.pagerEl.removeAttribute("disabled");
|
|
15588
|
+
}
|
|
15589
|
+
/**
|
|
15439
15590
|
* Remove paging feature
|
|
15440
15591
|
*/
|
|
15441
15592
|
destroy() {
|
|
15442
15593
|
if (!this.initialized) return;
|
|
15594
|
+
if (this.pagerEl) this.destroyCE();
|
|
15595
|
+
else this.destroyLegacy();
|
|
15596
|
+
if (this.hasResultsPerPage) this.removeResultsPerPage();
|
|
15597
|
+
this.emitter.off(["after-filtering"], bound(this.resetPagingInfo, this));
|
|
15598
|
+
this.emitter.off(["change-page"], bound(this.changePageHandler, this));
|
|
15599
|
+
this.emitter.off(["change-page-results"], bound(this.changePageResultsHandler, this));
|
|
15600
|
+
this.pageSlc = null;
|
|
15601
|
+
this.nbPages = 0;
|
|
15602
|
+
this.initialized = false;
|
|
15603
|
+
}
|
|
15604
|
+
/**
|
|
15605
|
+
* Remove the <tf-pager> element and the handlers bound to it
|
|
15606
|
+
* @private
|
|
15607
|
+
*/
|
|
15608
|
+
destroyCE() {
|
|
15609
|
+
let evt = this.evt;
|
|
15610
|
+
removeEvt(this.pagerEl, "page-change", evt.pagerPageChange);
|
|
15611
|
+
this.unbindPagerButton("first", evt.first);
|
|
15612
|
+
this.unbindPagerButton("prev", evt.prev);
|
|
15613
|
+
this.unbindPagerButton("next", evt.next);
|
|
15614
|
+
this.unbindPagerButton("last", evt.last);
|
|
15615
|
+
removeElm(this.pagerEl);
|
|
15616
|
+
this.pagerEl = null;
|
|
15617
|
+
}
|
|
15618
|
+
/**
|
|
15619
|
+
* Remove the legacy paging controls and the handlers bound to them
|
|
15620
|
+
* @private
|
|
15621
|
+
*/
|
|
15622
|
+
destroyLegacy() {
|
|
15443
15623
|
let evt = this.evt;
|
|
15444
15624
|
if (this.pageSlc) {
|
|
15445
15625
|
if (this.pageSelectorType === "select") removeEvt(this.pageSlc, "change", evt.slcPagesChange);
|
|
@@ -15478,13 +15658,6 @@ var Paging = class Paging extends Feature {
|
|
|
15478
15658
|
removeElm(this.pgCont);
|
|
15479
15659
|
this.pgCont = null;
|
|
15480
15660
|
}
|
|
15481
|
-
if (this.hasResultsPerPage) this.removeResultsPerPage();
|
|
15482
|
-
this.emitter.off(["after-filtering"], bound(this.resetPagingInfo, this));
|
|
15483
|
-
this.emitter.off(["change-page"], bound(this.changePageHandler, this));
|
|
15484
|
-
this.emitter.off(["change-page-results"], bound(this.changePageResultsHandler, this));
|
|
15485
|
-
this.pageSlc = null;
|
|
15486
|
-
this.nbPages = 0;
|
|
15487
|
-
this.initialized = false;
|
|
15488
15661
|
}
|
|
15489
15662
|
};
|
|
15490
15663
|
//#endregion
|
|
@@ -15547,7 +15720,7 @@ var TableFilter = class {
|
|
|
15547
15720
|
* Current version
|
|
15548
15721
|
* @type {String}
|
|
15549
15722
|
*/
|
|
15550
|
-
this.version = "0.7.
|
|
15723
|
+
this.version = "0.7.7";
|
|
15551
15724
|
/**
|
|
15552
15725
|
* Current year
|
|
15553
15726
|
* @type {Number}
|