tablefilter 0.7.13 → 0.7.15

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.
@@ -15045,7 +15045,7 @@ var sanitizeHtml = (html) => purify_default.sanitize(html == null ? "" : String(
15045
15045
  //#endregion
15046
15046
  //#region src/modules/help.js
15047
15047
  var DEFAULT_INSTR_HTML = "Use the filters above each column to filter and limit table data. Advanced searches can be performed by using the following operators: <br /><b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>=</b>, <b>*</b>, <b>!</b>, <b>{</b>, <b>}</b>, <b>||</b>,<b>&amp;&amp;</b>, <b>[empty]</b>, <b>[nonempty]</b>, <b>rgx:</b><br/><a href=\"https://github.com/koalyptus/TableFilter/wiki/4.-Filter-operators\" target=\"_blank\">Learn more</a><hr/>";
15048
- var FOCUSABLE_TRIGGER = "button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
15048
+ var FOCUSABLE_TRIGGER$1 = "button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
15049
15049
  /**
15050
15050
  * Help UI component
15051
15051
  */
@@ -15213,7 +15213,7 @@ var Help = class Help extends Feature {
15213
15213
  if (this.btnHtml) {
15214
15214
  const trigger = createElm("span");
15215
15215
  trigger.innerHTML = sanitizeHtml(this.btnHtml);
15216
- if (!trigger.firstChild) {} else if (trigger.querySelector(FOCUSABLE_TRIGGER)) while (trigger.firstChild) {
15216
+ if (!trigger.firstChild) {} else if (trigger.querySelector(FOCUSABLE_TRIGGER$1)) while (trigger.firstChild) {
15217
15217
  const node = trigger.firstChild;
15218
15218
  if (node.nodeType === 1) {
15219
15219
  node.slot = "trigger";
@@ -15260,7 +15260,7 @@ var Help = class Help extends Feature {
15260
15260
  */
15261
15261
  applyTriggerLabel(node) {
15262
15262
  if (!this.label) return;
15263
- const target = node.matches(FOCUSABLE_TRIGGER) ? node : node.querySelector(FOCUSABLE_TRIGGER) || node;
15263
+ const target = node.matches(FOCUSABLE_TRIGGER$1) ? node : node.querySelector(FOCUSABLE_TRIGGER$1) || node;
15264
15264
  if (!target.hasAttribute("aria-label")) target.setAttribute("aria-label", this.label);
15265
15265
  }
15266
15266
  /**
@@ -16685,6 +16685,8 @@ HighlightKeyword.meta = {
16685
16685
  };
16686
16686
  //#endregion
16687
16687
  //#region src/modules/popupFilter.js
16688
+ var FOCUSABLE_TRIGGER = "button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
16689
+ var FILTER_TRIGGER_TEXT = "Filter";
16688
16690
  /**
16689
16691
  * Pop-up filter component
16690
16692
  * @export
@@ -16791,6 +16793,37 @@ var PopupFilter = class PopupFilter extends Feature {
16791
16793
  * @private
16792
16794
  */
16793
16795
  this.activeFilterIdx = -1;
16796
+ /**
16797
+ * `<tf-popup-filter>` hosts, keyed by column index
16798
+ * @type {Array}
16799
+ * @private
16800
+ */
16801
+ this.hosts = [];
16802
+ /**
16803
+ * Bound element `open-change` handlers, keyed by column index
16804
+ * @type {Array}
16805
+ * @private
16806
+ */
16807
+ this.ceEvt = [];
16808
+ /**
16809
+ * Whether the bridge is applying an open state to an element
16810
+ * @type {Boolean}
16811
+ * @private
16812
+ */
16813
+ this.syncingCEOpen = false;
16814
+ /**
16815
+ * Stable handlers for emitter and document subscriptions
16816
+ * @private
16817
+ */
16818
+ this.boundHandlers = {
16819
+ mouseup: (event) => this.onMouseup(event),
16820
+ containerClick: (event) => stopEvt(event),
16821
+ beforeFiltering: () => this.setIconsState(),
16822
+ afterFiltering: () => this.closeAll(),
16823
+ cellProcessed: (tf, cellIndex) => this.changeState(cellIndex, true),
16824
+ filtersRowInserted: () => this.buildIcons(),
16825
+ beforeFilterInit: (tf, colIndex) => this.build(colIndex)
16826
+ };
16794
16827
  }
16795
16828
  /**
16796
16829
  * Click event handler for pop-up filter icon
@@ -16833,11 +16866,11 @@ var PopupFilter = class PopupFilter extends Feature {
16833
16866
  tf.headersRow--;
16834
16867
  this.buildIcons();
16835
16868
  }
16836
- this.emitter.on(["before-filtering"], () => this.setIconsState());
16837
- this.emitter.on(["after-filtering"], () => this.closeAll());
16838
- this.emitter.on(["cell-processed"], (tf, cellIndex) => this.changeState(cellIndex, true));
16839
- this.emitter.on(["filters-row-inserted"], () => this.buildIcons());
16840
- this.emitter.on(["before-filter-init"], (tf, colIndex) => this.build(colIndex));
16869
+ this.emitter.on(["before-filtering"], this.boundHandlers.beforeFiltering);
16870
+ this.emitter.on(["after-filtering"], this.boundHandlers.afterFiltering);
16871
+ this.emitter.on(["cell-processed"], this.boundHandlers.cellProcessed);
16872
+ this.emitter.on(["filters-row-inserted"], this.boundHandlers.filtersRowInserted);
16873
+ this.emitter.on(["before-filter-init"], this.boundHandlers.beforeFilterInit);
16841
16874
  /** @inherited */
16842
16875
  this.initialized = true;
16843
16876
  }
@@ -16847,25 +16880,147 @@ var PopupFilter = class PopupFilter extends Feature {
16847
16880
  reset() {
16848
16881
  this.enable();
16849
16882
  this.init();
16850
- this.buildIcons();
16883
+ if (!this.tf.gridLayout) this.buildIcons();
16851
16884
  this.buildAll();
16852
16885
  }
16853
16886
  /**
16887
+ * Whether the feature renders through `<tf-popup-filter>`.
16888
+ * A definition is accepted when it exposes the bridge methods and the
16889
+ * shadow parts the bridge projects into.
16890
+ * @returns {Boolean} True when the bridge renders through the element
16891
+ * @private
16892
+ */
16893
+ canUseCE() {
16894
+ const PopupFilterElement = typeof customElements === "undefined" ? null : customElements.get("tf-popup-filter");
16895
+ if (!PopupFilterElement || typeof PopupFilterElement.prototype.setOpen !== "function" || typeof PopupFilterElement.prototype.setPopupLabel !== "function" || typeof PopupFilterElement.prototype.setLabel !== "function" || typeof PopupFilterElement.prototype.setText !== "function") return false;
16896
+ let probe;
16897
+ try {
16898
+ probe = document.createElement("tf-popup-filter");
16899
+ } catch (e) {
16900
+ return false;
16901
+ }
16902
+ const shadow = probe.shadowRoot;
16903
+ return Boolean(shadow && shadow.querySelector("slot[name=\"trigger\"]") && shadow.querySelector("[part=\"trigger\"]") && shadow.querySelector("[part=\"popup\"]") && shadow.querySelector("slot[part=\"content-slot\"]"));
16904
+ }
16905
+ /**
16854
16906
  * Build all filters icons
16855
16907
  */
16856
16908
  buildIcons() {
16857
16909
  let tf = this.tf;
16910
+ const useCE = this.canUseCE();
16858
16911
  tf.headersRow++;
16859
16912
  tf.eachCol((i) => {
16860
- let icon = createElm("span", ["ci", i]);
16861
- icon.innerHTML = this.iconHtml;
16862
- tf.getHeaderElement(i).appendChild(icon);
16863
- addEvt(icon, "click", (evt) => this.onClick(evt));
16864
- this.fltSpans[i] = icon;
16865
- this.fltIcons[i] = icon.firstChild;
16913
+ if (useCE) this.buildIconCE(i);
16914
+ else this.buildIconLegacy(i);
16866
16915
  }, (i) => tf.getFilterType(i) === NONE);
16867
16916
  }
16868
16917
  /**
16918
+ * Build a filter trigger using <tf-popup-filter>
16919
+ * @param {Number} colIndex Column index
16920
+ * @private
16921
+ */
16922
+ buildIconCE(colIndex) {
16923
+ const existing = this.hosts[colIndex];
16924
+ if (existing && existing.parentNode) return;
16925
+ const host = document.createElement("tf-popup-filter");
16926
+ host.className = this.placeholderCssClass;
16927
+ host.setText(FILTER_TRIGGER_TEXT);
16928
+ host.setLabel(FILTER_TRIGGER_TEXT);
16929
+ const label = this.appendTrigger(host);
16930
+ host.setPopupLabel(label || FILTER_TRIGGER_TEXT);
16931
+ const handler = (event) => this.onCEOpenChange(colIndex, event);
16932
+ this.ceEvt[colIndex] = handler;
16933
+ addEvt(host, "open-change", handler);
16934
+ this.tf.getHeaderElement(colIndex).appendChild(host);
16935
+ this.hosts[colIndex] = host;
16936
+ this.fltIcons[colIndex] = host.querySelector("[slot=\"trigger\"] img[src]");
16937
+ }
16938
+ /**
16939
+ * Append the sanitised `image_html` to the trigger slot
16940
+ * @param {DOMElement} host `<tf-popup-filter>` host
16941
+ * @returns {String} Accessible name of the projected trigger
16942
+ * @private
16943
+ */
16944
+ appendTrigger(host) {
16945
+ const wrapper = createElm("span");
16946
+ wrapper.innerHTML = sanitizeHtml(this.iconHtml);
16947
+ const nodes = [];
16948
+ while (wrapper.firstChild) nodes.push(wrapper.removeChild(wrapper.firstChild));
16949
+ if (!nodes.length) return "";
16950
+ if (!nodes.some((node) => node.nodeType === 1 && (node.matches(FOCUSABLE_TRIGGER) || node.querySelector(FOCUSABLE_TRIGGER)))) {
16951
+ const button = createElm("button");
16952
+ button.type = "button";
16953
+ button.slot = "trigger";
16954
+ nodes.forEach((node) => button.appendChild(node));
16955
+ host.appendChild(button);
16956
+ } else nodes.forEach((node) => {
16957
+ if (node.nodeType === 1) {
16958
+ node.slot = "trigger";
16959
+ host.appendChild(node);
16960
+ } else if (node.nodeType === 3 && node.textContent.trim()) {
16961
+ const text = createElm("span");
16962
+ text.slot = "trigger";
16963
+ text.appendChild(node);
16964
+ host.appendChild(text);
16965
+ }
16966
+ });
16967
+ const label = this.triggerName(host);
16968
+ if (!label) this.applyTriggerLabel(host);
16969
+ return label;
16970
+ }
16971
+ /**
16972
+ * Name the first slotted trigger without an accessible name
16973
+ * @param {DOMElement} host `<tf-popup-filter>` host
16974
+ * @private
16975
+ */
16976
+ applyTriggerLabel(host) {
16977
+ const triggers = host.querySelectorAll("[slot=\"trigger\"]");
16978
+ for (let i = 0; i < triggers.length; i++) {
16979
+ const el = triggers[i];
16980
+ const target = el.matches(FOCUSABLE_TRIGGER) ? el : el.querySelector(FOCUSABLE_TRIGGER);
16981
+ if (target && !target.hasAttribute("aria-label")) {
16982
+ target.setAttribute("aria-label", FILTER_TRIGGER_TEXT);
16983
+ return;
16984
+ }
16985
+ }
16986
+ }
16987
+ /**
16988
+ * Read the accessible name of the first slotted trigger
16989
+ * @param {DOMElement} host `<tf-popup-filter>` host
16990
+ * @returns {String} Trigger name, or an empty string
16991
+ * @private
16992
+ */
16993
+ triggerName(host) {
16994
+ const triggers = host.querySelectorAll("[slot=\"trigger\"]");
16995
+ for (let i = 0; i < triggers.length; i++) {
16996
+ const el = triggers[i];
16997
+ const label = (el.getAttribute("aria-label") || "").trim();
16998
+ if (label) return label;
16999
+ const text = (el.textContent || "").trim();
17000
+ if (text) return text;
17001
+ const image = el.querySelector("img[alt]") || (el.matches("img[alt]") ? el : null);
17002
+ const alt = image ? (image.getAttribute("alt") || "").trim() : "";
17003
+ if (alt) return alt;
17004
+ }
17005
+ return "";
17006
+ }
17007
+ /**
17008
+ * Append the legacy icon to the header
17009
+ * @param {Number} colIndex Column index
17010
+ * @private
17011
+ */
17012
+ buildIconLegacy(colIndex) {
17013
+ const existing = this.fltSpans[colIndex];
17014
+ if (existing && existing.parentNode) return;
17015
+ let tf = this.tf;
17016
+ let icon = createElm("span", ["ci", colIndex]);
17017
+ icon.innerHTML = sanitizeHtml(this.iconHtml);
17018
+ tf.getHeaderElement(colIndex).appendChild(icon);
17019
+ addEvt(icon, "click", (evt) => this.onClick(evt));
17020
+ this.fltSpans[colIndex] = icon;
17021
+ this.fltIcons[colIndex] = icon.firstChild;
17022
+ }
17023
+ /**
16869
17024
  * Build all pop-up filters elements
16870
17025
  */
16871
17026
  buildAll() {
@@ -16879,13 +17034,19 @@ var PopupFilter = class PopupFilter extends Feature {
16879
17034
  build(colIndex, div) {
16880
17035
  let tf = this.tf;
16881
17036
  let contId = `${this.prfxDiv}${tf.id}_${colIndex}`;
16882
- let placeholder = createElm("div", ["class", this.placeholderCssClass]);
16883
17037
  let cont = div || createElm("div", ["id", contId], ["class", this.containerCssClass]);
16884
17038
  tf.externalFltIds[colIndex] = cont.id;
17039
+ addEvt(cont, "click", this.boundHandlers.containerClick);
17040
+ const host = this.hosts[colIndex];
17041
+ if (host) {
17042
+ host.appendChild(cont);
17043
+ this.fltElms[colIndex] = cont;
17044
+ return;
17045
+ }
17046
+ let placeholder = createElm("div", ["class", this.placeholderCssClass]);
16885
17047
  placeholder.appendChild(cont);
16886
17048
  let header = tf.getHeaderElement(colIndex);
16887
17049
  header.insertBefore(placeholder, header.firstChild);
16888
- addEvt(cont, "click", (evt) => stopEvt(evt));
16889
17050
  this.fltElms[colIndex] = cont;
16890
17051
  }
16891
17052
  /**
@@ -16901,14 +17062,24 @@ var PopupFilter = class PopupFilter extends Feature {
16901
17062
  * @param {Number} colIndex Column index
16902
17063
  */
16903
17064
  open(colIndex) {
16904
- let tf = this.tf, container = this.fltElms[colIndex];
17065
+ let tf = this.tf, container = this.fltElms[colIndex], host = this.hosts[colIndex];
17066
+ if (!container) return;
16905
17067
  this.onBeforeOpen(this, container, colIndex);
16906
17068
  container.style.display = "block";
17069
+ if (host) {
17070
+ this.setCEOpen(host, true);
17071
+ if (this.adjustToContainer) {
17072
+ let header = tf.getHeaderElement(colIndex);
17073
+ host.style.width = parseInt(header.clientWidth * .95, 10) + "px";
17074
+ }
17075
+ }
16907
17076
  this.activeFilterIdx = colIndex;
16908
- addEvt(root, "mouseup", (evt) => this.onMouseup(evt));
16909
- if (tf.getFilterType(colIndex) === "input") {
16910
- let flt = tf.getFilterElement(colIndex);
16911
- if (flt) flt.focus();
17077
+ if (!host) {
17078
+ addEvt(root, "mouseup", this.boundHandlers.mouseup);
17079
+ if (tf.getFilterType(colIndex) === "input") {
17080
+ let flt = tf.getFilterElement(colIndex);
17081
+ if (flt) flt.focus();
17082
+ }
16912
17083
  }
16913
17084
  this.onAfterOpen(this, container, colIndex);
16914
17085
  }
@@ -16917,19 +17088,48 @@ var PopupFilter = class PopupFilter extends Feature {
16917
17088
  * @param {Number} colIndex Column index
16918
17089
  */
16919
17090
  close(colIndex) {
16920
- let container = this.fltElms[colIndex];
17091
+ let container = this.fltElms[colIndex], host = this.hosts[colIndex];
17092
+ if (!container) return;
16921
17093
  this.onBeforeClose(this, container, colIndex);
17094
+ if (host) this.setCEOpen(host, false);
16922
17095
  container.style.display = NONE;
16923
17096
  if (this.activeFilterIdx === colIndex) this.activeFilterIdx = -1;
16924
- removeEvt(root, "mouseup", (evt) => this.onMouseup(evt));
17097
+ if (!host) removeEvt(root, "mouseup", this.boundHandlers.mouseup);
16925
17098
  this.onAfterClose(this, container, colIndex);
16926
17099
  }
16927
17100
  /**
17101
+ * Apply an open state to `<tf-popup-filter>` without replaying the
17102
+ * bridge callbacks for its `open-change` event
17103
+ * @param {DOMElement} host `<tf-popup-filter>` host
17104
+ * @param {Boolean} open Whether the popup is open
17105
+ * @private
17106
+ */
17107
+ setCEOpen(host, open) {
17108
+ this.syncingCEOpen = true;
17109
+ host.setOpen(open);
17110
+ this.syncingCEOpen = false;
17111
+ }
17112
+ /**
17113
+ * Drive the bridge from `<tf-popup-filter>` state changes
17114
+ * @param {Number} colIndex Column index
17115
+ * @param {CustomEvent} event Element `open-change` event
17116
+ * @private
17117
+ */
17118
+ onCEOpenChange(colIndex, event) {
17119
+ if (this.syncingCEOpen || !event.detail) return;
17120
+ if (event.detail.open) {
17121
+ this.closeAll(colIndex);
17122
+ this.open(colIndex);
17123
+ } else this.close(colIndex);
17124
+ }
17125
+ /**
16928
17126
  * Check if popup filter for specified column is open
16929
17127
  * @param {Number} colIndex Column index
16930
17128
  * @returns {Boolean}
16931
17129
  */
16932
17130
  isOpen(colIndex) {
17131
+ const host = this.hosts[colIndex];
17132
+ if (host) return host.hasAttribute("open");
16933
17133
  return this.fltElms[colIndex].style.display === "block";
16934
17134
  }
16935
17135
  /**
@@ -16966,28 +17166,38 @@ var PopupFilter = class PopupFilter extends Feature {
16966
17166
  if (!this.initialized) return;
16967
17167
  this.filtersCache = [];
16968
17168
  for (let i = 0; i < this.fltElms.length; i++) {
16969
- let container = this.fltElms[i], placeholder = container.parentNode, icon = this.fltSpans[i], iconImg = this.fltIcons[i];
17169
+ let container = this.fltElms[i], host = this.hosts[i], placeholder = container && container.parentNode, icon = this.fltSpans[i], iconImg = this.fltIcons[i];
16970
17170
  if (container) {
16971
- removeElm(container);
17171
+ removeEvt(container, "click", this.boundHandlers.containerClick);
17172
+ if (container.parentNode) removeElm(container);
16972
17173
  this.filtersCache[i] = container;
16973
17174
  }
16974
17175
  container = null;
16975
- if (placeholder) removeElm(placeholder);
17176
+ if (placeholder && placeholder !== host && placeholder.parentNode) removeElm(placeholder);
16976
17177
  placeholder = null;
16977
- if (icon) removeElm(icon);
17178
+ if (host) {
17179
+ if (this.ceEvt[i]) removeEvt(host, "open-change", this.ceEvt[i]);
17180
+ if (host.parentNode) removeElm(host);
17181
+ }
17182
+ if (icon && icon.parentNode) removeElm(icon);
16978
17183
  icon = null;
16979
- if (iconImg) removeElm(iconImg);
17184
+ if (iconImg && iconImg.parentNode) removeElm(iconImg);
16980
17185
  iconImg = null;
16981
17186
  }
16982
17187
  this.fltElms = [];
16983
17188
  this.fltSpans = [];
16984
17189
  this.fltIcons = [];
17190
+ this.hosts = [];
17191
+ this.ceEvt = [];
17192
+ this.syncingCEOpen = false;
17193
+ this.activeFilterIdx = -1;
17194
+ removeEvt(root, "mouseup", this.boundHandlers.mouseup);
16985
17195
  this.tf.externalFltIds = [];
16986
- this.emitter.off(["before-filtering"], () => this.setIconsState());
16987
- this.emitter.off(["after-filtering"], () => this.closeAll());
16988
- this.emitter.off(["cell-processed"], (tf, cellIndex) => this.changeState(cellIndex, true));
16989
- this.emitter.off(["filters-row-inserted"], () => this.buildIcons());
16990
- this.emitter.off(["before-filter-init"], (tf, colIndex) => this.build(colIndex));
17196
+ this.emitter.off(["before-filtering"], this.boundHandlers.beforeFiltering);
17197
+ this.emitter.off(["after-filtering"], this.boundHandlers.afterFiltering);
17198
+ this.emitter.off(["cell-processed"], this.boundHandlers.cellProcessed);
17199
+ this.emitter.off(["filters-row-inserted"], this.boundHandlers.filtersRowInserted);
17200
+ this.emitter.off(["before-filter-init"], this.boundHandlers.beforeFilterInit);
16991
17201
  this.initialized = false;
16992
17202
  }
16993
17203
  };
@@ -17714,6 +17924,7 @@ var AlternateRows = class AlternateRows extends Feature {
17714
17924
  };
17715
17925
  //#endregion
17716
17926
  //#region src/modules/noResults.js
17927
+ var TOGGLE_EVENTS = ["initialized", "after-filtering"];
17717
17928
  /**
17718
17929
  * UI when filtering yields no matches
17719
17930
  * @export
@@ -17737,18 +17948,18 @@ var NoResults = class NoResults extends Feature {
17737
17948
  * Custom container DOM element
17738
17949
  * @type {DOMElement}
17739
17950
  */
17740
- this.customContainer = defaultsStr(f.custom_container, null);
17951
+ this.customContainer = f.custom_container && typeof f.custom_container.appendChild === "function" ? f.custom_container : null;
17741
17952
  /**
17742
17953
  * ID of custom container element
17743
17954
  * @type {String}
17744
17955
  */
17745
17956
  this.customContainerId = defaultsStr(f.custom_container_id, null);
17746
17957
  /**
17747
- * Indicates if UI is contained in a external element
17958
+ * True when a container element is present or a container id is set
17748
17959
  * @type {Boolean}
17749
17960
  * @private
17750
17961
  */
17751
- this.isExternal = !isEmpty(this.customContainer) || !isEmpty(this.customContainerId);
17962
+ this.isExternal = Boolean(this.customContainer) || Boolean(this.customContainerId);
17752
17963
  /**
17753
17964
  * Css class assigned to container element
17754
17965
  * @type {String}
@@ -17779,23 +17990,67 @@ var NoResults = class NoResults extends Feature {
17779
17990
  * @type {Function}
17780
17991
  */
17781
17992
  this.onAfterHide = defaultsFn(f.on_after_hide_msg, EMPTY_FN);
17993
+ /**
17994
+ * Subscribed toggle handler
17995
+ * @type {Function|null}
17996
+ * @private
17997
+ */
17998
+ this.boundToggle = null;
17782
17999
  }
17783
18000
  /**
17784
18001
  * Initializes NoResults instance
17785
18002
  */
17786
18003
  init() {
17787
18004
  if (this.initialized) return;
17788
- let tf = this.tf;
17789
- let target = this.customContainer || elm(this.customContainerId) || tf.dom();
18005
+ let targetEl = this.isExternal ? this.customContainer || elm(this.customContainerId) : null;
18006
+ if (this.canUseCE(targetEl)) this.initCE(targetEl);
18007
+ else this.initLegacy(targetEl);
18008
+ this.boundToggle = () => this.toggle();
18009
+ this.emitter.on(TOGGLE_EVENTS, this.boundToggle);
18010
+ /** @inherited */
18011
+ this.initialized = true;
18012
+ }
18013
+ /**
18014
+ * Whether the feature renders through `<tf-no-results>`.
18015
+ * @param {DOMElement} targetEl Resolved external container, if any
18016
+ * @returns {Boolean} True when the registered element exposes `setText`
18017
+ * and no external container is configured, or the container resolves
18018
+ * @private
18019
+ */
18020
+ canUseCE(targetEl) {
18021
+ const NoResultsElement = typeof customElements === "undefined" ? null : customElements.get("tf-no-results");
18022
+ return Boolean(NoResultsElement) && typeof NoResultsElement.prototype.setText === "function" && (!this.isExternal || Boolean(targetEl && typeof targetEl.appendChild === "function"));
18023
+ }
18024
+ /**
18025
+ * Initialize using the <tf-no-results> custom element
18026
+ * @param {DOMElement} targetEl External container element
18027
+ * @private
18028
+ */
18029
+ initCE(targetEl) {
18030
+ const host = document.createElement("tf-no-results");
18031
+ host.className = this.cssClass;
18032
+ host.setText("");
18033
+ host.innerHTML = sanitizeHtml(this.content);
18034
+ if (this.isExternal) targetEl.appendChild(host);
18035
+ else {
18036
+ const dom = this.tf.dom();
18037
+ dom.parentNode.insertBefore(host, dom.nextSibling);
18038
+ }
18039
+ this.cont = host;
18040
+ }
18041
+ /**
18042
+ * Initialize using the legacy div container
18043
+ * @param {DOMElement} targetEl External container element
18044
+ * @private
18045
+ */
18046
+ initLegacy(targetEl) {
18047
+ let target = targetEl || this.tf.dom();
17790
18048
  let cont = createElm("div");
17791
18049
  cont.className = this.cssClass;
17792
18050
  cont.innerHTML = this.content;
17793
18051
  if (this.isExternal) target.appendChild(cont);
17794
18052
  else target.parentNode.insertBefore(cont, target.nextSibling);
17795
18053
  this.cont = cont;
17796
- this.emitter.on(["initialized", "after-filtering"], () => this.toggle());
17797
- /** @inherited */
17798
- this.initialized = true;
17799
18054
  }
17800
18055
  /**
17801
18056
  * Toggle no results message
@@ -17838,9 +18093,12 @@ var NoResults = class NoResults extends Feature {
17838
18093
  /** Remove feature */
17839
18094
  destroy() {
17840
18095
  if (!this.initialized) return;
17841
- removeElm(this.cont);
18096
+ if (this.cont && this.cont.parentNode) removeElm(this.cont);
17842
18097
  this.cont = null;
17843
- this.emitter.off(["after-filtering"], () => this.toggle());
18098
+ if (this.boundToggle) {
18099
+ this.emitter.off(TOGGLE_EVENTS, this.boundToggle);
18100
+ this.boundToggle = null;
18101
+ }
17844
18102
  this.initialized = false;
17845
18103
  }
17846
18104
  };
@@ -18734,7 +18992,7 @@ var TableFilter = class {
18734
18992
  * Current version
18735
18993
  * @type {String}
18736
18994
  */
18737
- this.version = "0.7.13";
18995
+ this.version = "0.7.15";
18738
18996
  /**
18739
18997
  * Current year
18740
18998
  * @type {Number}