@haiilo/catalyst 6.1.4 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10978,9 +10978,14 @@ const CatTooltip = class {
10978
10978
  this.showDelay = 250;
10979
10979
  this.hideDelay = 0;
10980
10980
  this.longTouchDuration = 1000;
10981
+ this.boundShowListener = this.showListener.bind(this);
10982
+ this.boundHideListener = this.hideListener.bind(this);
10983
+ this.boundWindowTouchStartListener = this.windowTouchStartListener.bind(this);
10984
+ this.boundTouchStartListener = this.touchStartListener.bind(this);
10985
+ this.boundTouchEndListener = this.touchEndListener.bind(this);
10981
10986
  }
10982
10987
  handleKeyDown({ key }) {
10983
- key === 'Escape' && this.hideListener();
10988
+ key === 'Escape' && this.hideTooltip();
10984
10989
  }
10985
10990
  componentDidLoad() {
10986
10991
  const slot = this.hostElement.shadowRoot?.querySelector('slot');
@@ -10989,15 +10994,15 @@ const CatTooltip = class {
10989
10994
  this.trigger.setAttribute('aria-describedby', this.id);
10990
10995
  }
10991
10996
  if (isTouchDevice) {
10992
- window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));
10993
- this.trigger?.addEventListener('touchstart', this.touchStartListener.bind(this));
10994
- this.trigger?.addEventListener('touchend', this.touchEndListener.bind(this));
10997
+ window.addEventListener('touchstart', this.boundWindowTouchStartListener);
10998
+ this.trigger?.addEventListener('touchstart', this.boundTouchStartListener);
10999
+ this.trigger?.addEventListener('touchend', this.boundTouchEndListener);
10995
11000
  }
10996
11001
  else {
10997
- this.trigger?.addEventListener('focusin', this.showListener.bind(this));
10998
- this.trigger?.addEventListener('focusout', this.hideListener.bind(this));
10999
- this.trigger?.addEventListener('mouseenter', this.showListener.bind(this));
11000
- this.trigger?.addEventListener('mouseleave', this.hideListener.bind(this));
11002
+ this.trigger?.addEventListener('focusin', this.boundShowListener);
11003
+ this.trigger?.addEventListener('focusout', this.boundHideListener);
11004
+ this.trigger?.addEventListener('mouseenter', this.boundShowListener);
11005
+ this.trigger?.addEventListener('mouseleave', this.boundHideListener);
11001
11006
  }
11002
11007
  }
11003
11008
  componentWillRender() {
@@ -11006,15 +11011,15 @@ const CatTooltip = class {
11006
11011
  }
11007
11012
  disconnectedCallback() {
11008
11013
  if (isTouchDevice) {
11009
- window.removeEventListener('touchstart', this.windowTouchStartListener.bind(this));
11010
- this.trigger?.removeEventListener('touchstart', this.touchStartListener.bind(this));
11011
- this.trigger?.removeEventListener('touchend', this.touchEndListener.bind(this));
11014
+ window.removeEventListener('touchstart', this.boundWindowTouchStartListener);
11015
+ this.trigger?.removeEventListener('touchstart', this.boundTouchStartListener);
11016
+ this.trigger?.removeEventListener('touchend', this.boundTouchEndListener);
11012
11017
  }
11013
11018
  else {
11014
- this.trigger?.removeEventListener('mouseenter', this.showListener.bind(this));
11015
- this.trigger?.removeEventListener('mouseleave', this.hideListener.bind(this));
11016
- this.trigger?.removeEventListener('focusin', this.showListener.bind(this));
11017
- this.trigger?.removeEventListener('focusout', this.hideListener.bind(this));
11019
+ this.trigger?.removeEventListener('mouseenter', this.boundShowListener);
11020
+ this.trigger?.removeEventListener('mouseleave', this.boundHideListener);
11021
+ this.trigger?.removeEventListener('focusin', this.boundShowListener);
11022
+ this.trigger?.removeEventListener('focusout', this.boundHideListener);
11018
11023
  }
11019
11024
  }
11020
11025
  render() {
@@ -11043,42 +11048,53 @@ const CatTooltip = class {
11043
11048
  }
11044
11049
  showListener() {
11045
11050
  window.clearTimeout(this.hideTimeout);
11046
- this.showTimeout = window.setTimeout(() => {
11047
- this.showTooltip();
11048
- }, this.showDelay);
11051
+ this.hideTimeout = undefined;
11052
+ if (!this.showTimeout) {
11053
+ this.showTimeout = window.setTimeout(() => {
11054
+ this.showTimeout = undefined;
11055
+ this.showTooltip();
11056
+ }, this.showDelay);
11057
+ }
11049
11058
  }
11050
11059
  hideListener() {
11051
11060
  window.clearTimeout(this.showTimeout);
11052
- this.hideTimeout = window.setTimeout(() => {
11053
- this.tooltip?.classList.remove('tooltip-show');
11054
- this.hideTooltip();
11055
- }, this.hideDelay);
11061
+ this.showTimeout = undefined;
11062
+ if (!this.hideTimeout) {
11063
+ this.hideTimeout = window.setTimeout(() => {
11064
+ this.hideTimeout = undefined;
11065
+ this.hideTooltip();
11066
+ }, this.hideDelay);
11067
+ }
11056
11068
  }
11057
11069
  touchStartListener(event) {
11058
11070
  event.stopPropagation();
11059
- this.touchTimeout = window.setTimeout(() => {
11060
- this.showTooltip();
11061
- }, this.longTouchDuration);
11071
+ if (!this.touchTimeout) {
11072
+ this.touchTimeout = window.setTimeout(() => {
11073
+ this.touchTimeout = undefined;
11074
+ this.showTooltip();
11075
+ }, this.longTouchDuration);
11076
+ }
11062
11077
  }
11063
11078
  touchEndListener() {
11064
- if (this.touchTimeout) {
11065
- window.clearTimeout(this.touchTimeout);
11066
- this.hideTooltip();
11067
- }
11079
+ window.clearTimeout(this.touchTimeout);
11080
+ this.touchTimeout = undefined;
11081
+ this.hideTooltip();
11068
11082
  }
11069
11083
  windowTouchStartListener() {
11070
- this.tooltip?.classList.remove('tooltip-show');
11084
+ this.hideTooltip();
11071
11085
  }
11072
11086
  showTooltip() {
11073
11087
  if (this.trigger && this.tooltip) {
11074
11088
  this.cleanupFloatingUi = autoUpdate(this.trigger, this.tooltip, () => this.update());
11075
11089
  }
11076
- !this.hidden && this.tooltip?.classList.add('tooltip-show');
11090
+ if (!this.hidden) {
11091
+ this.tooltip?.classList.add('tooltip-show');
11092
+ }
11077
11093
  }
11078
11094
  hideTooltip() {
11079
- if (this.cleanupFloatingUi) {
11080
- this.cleanupFloatingUi();
11081
- }
11095
+ this.tooltip?.classList.remove('tooltip-show');
11096
+ this.cleanupFloatingUi?.();
11097
+ this.cleanupFloatingUi = undefined;
11082
11098
  }
11083
11099
  get hostElement() { return index.getElement(this); }
11084
11100
  };