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