@haiilo/catalyst 6.2.0 → 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.
@@ -15,9 +15,14 @@ class CatTooltip {
15
15
  this.showDelay = 250;
16
16
  this.hideDelay = 0;
17
17
  this.longTouchDuration = 1000;
18
+ this.boundShowListener = this.showListener.bind(this);
19
+ this.boundHideListener = this.hideListener.bind(this);
20
+ this.boundWindowTouchStartListener = this.windowTouchStartListener.bind(this);
21
+ this.boundTouchStartListener = this.touchStartListener.bind(this);
22
+ this.boundTouchEndListener = this.touchEndListener.bind(this);
18
23
  }
19
24
  handleKeyDown({ key }) {
20
- key === 'Escape' && this.hideListener();
25
+ key === 'Escape' && this.hideTooltip();
21
26
  }
22
27
  componentDidLoad() {
23
28
  const slot = this.hostElement.shadowRoot?.querySelector('slot');
@@ -26,15 +31,15 @@ class CatTooltip {
26
31
  this.trigger.setAttribute('aria-describedby', this.id);
27
32
  }
28
33
  if (isTouchScreen) {
29
- window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));
30
- this.trigger?.addEventListener('touchstart', this.touchStartListener.bind(this));
31
- this.trigger?.addEventListener('touchend', this.touchEndListener.bind(this));
34
+ window.addEventListener('touchstart', this.boundWindowTouchStartListener);
35
+ this.trigger?.addEventListener('touchstart', this.boundTouchStartListener);
36
+ this.trigger?.addEventListener('touchend', this.boundTouchEndListener);
32
37
  }
33
38
  else {
34
- this.trigger?.addEventListener('focusin', this.showListener.bind(this));
35
- this.trigger?.addEventListener('focusout', this.hideListener.bind(this));
36
- this.trigger?.addEventListener('mouseenter', this.showListener.bind(this));
37
- this.trigger?.addEventListener('mouseleave', this.hideListener.bind(this));
39
+ this.trigger?.addEventListener('focusin', this.boundShowListener);
40
+ this.trigger?.addEventListener('focusout', this.boundHideListener);
41
+ this.trigger?.addEventListener('mouseenter', this.boundShowListener);
42
+ this.trigger?.addEventListener('mouseleave', this.boundHideListener);
38
43
  }
39
44
  }
40
45
  componentWillRender() {
@@ -43,15 +48,15 @@ class CatTooltip {
43
48
  }
44
49
  disconnectedCallback() {
45
50
  if (isTouchScreen) {
46
- window.removeEventListener('touchstart', this.windowTouchStartListener.bind(this));
47
- this.trigger?.removeEventListener('touchstart', this.touchStartListener.bind(this));
48
- this.trigger?.removeEventListener('touchend', this.touchEndListener.bind(this));
51
+ window.removeEventListener('touchstart', this.boundWindowTouchStartListener);
52
+ this.trigger?.removeEventListener('touchstart', this.boundTouchStartListener);
53
+ this.trigger?.removeEventListener('touchend', this.boundTouchEndListener);
49
54
  }
50
55
  else {
51
- this.trigger?.removeEventListener('mouseenter', this.showListener.bind(this));
52
- this.trigger?.removeEventListener('mouseleave', this.hideListener.bind(this));
53
- this.trigger?.removeEventListener('focusin', this.showListener.bind(this));
54
- this.trigger?.removeEventListener('focusout', this.hideListener.bind(this));
56
+ this.trigger?.removeEventListener('mouseenter', this.boundShowListener);
57
+ this.trigger?.removeEventListener('mouseleave', this.boundHideListener);
58
+ this.trigger?.removeEventListener('focusin', this.boundShowListener);
59
+ this.trigger?.removeEventListener('focusout', this.boundHideListener);
55
60
  }
56
61
  }
57
62
  render() {
@@ -80,42 +85,53 @@ class CatTooltip {
80
85
  }
81
86
  showListener() {
82
87
  window.clearTimeout(this.hideTimeout);
83
- this.showTimeout = window.setTimeout(() => {
84
- this.showTooltip();
85
- }, this.showDelay);
88
+ this.hideTimeout = undefined;
89
+ if (!this.showTimeout) {
90
+ this.showTimeout = window.setTimeout(() => {
91
+ this.showTimeout = undefined;
92
+ this.showTooltip();
93
+ }, this.showDelay);
94
+ }
86
95
  }
87
96
  hideListener() {
88
97
  window.clearTimeout(this.showTimeout);
89
- this.hideTimeout = window.setTimeout(() => {
90
- this.tooltip?.classList.remove('tooltip-show');
91
- this.hideTooltip();
92
- }, this.hideDelay);
98
+ this.showTimeout = undefined;
99
+ if (!this.hideTimeout) {
100
+ this.hideTimeout = window.setTimeout(() => {
101
+ this.hideTimeout = undefined;
102
+ this.hideTooltip();
103
+ }, this.hideDelay);
104
+ }
93
105
  }
94
106
  touchStartListener(event) {
95
107
  event.stopPropagation();
96
- this.touchTimeout = window.setTimeout(() => {
97
- this.showTooltip();
98
- }, this.longTouchDuration);
108
+ if (!this.touchTimeout) {
109
+ this.touchTimeout = window.setTimeout(() => {
110
+ this.touchTimeout = undefined;
111
+ this.showTooltip();
112
+ }, this.longTouchDuration);
113
+ }
99
114
  }
100
115
  touchEndListener() {
101
- if (this.touchTimeout) {
102
- window.clearTimeout(this.touchTimeout);
103
- this.hideTooltip();
104
- }
116
+ window.clearTimeout(this.touchTimeout);
117
+ this.touchTimeout = undefined;
118
+ this.hideTooltip();
105
119
  }
106
120
  windowTouchStartListener() {
107
- this.tooltip?.classList.remove('tooltip-show');
121
+ this.hideTooltip();
108
122
  }
109
123
  showTooltip() {
110
124
  if (this.trigger && this.tooltip) {
111
125
  this.cleanupFloatingUi = autoUpdate(this.trigger, this.tooltip, () => this.update());
112
126
  }
113
- !this.hidden && this.tooltip?.classList.add('tooltip-show');
127
+ if (!this.hidden) {
128
+ this.tooltip?.classList.add('tooltip-show');
129
+ }
114
130
  }
115
131
  hideTooltip() {
116
- if (this.cleanupFloatingUi) {
117
- this.cleanupFloatingUi();
118
- }
132
+ this.tooltip?.classList.remove('tooltip-show');
133
+ this.cleanupFloatingUi?.();
134
+ this.cleanupFloatingUi = undefined;
119
135
  }
120
136
  static get is() { return "cat-tooltip"; }
121
137
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- {"version":3,"file":"cat-tooltip.js","sourceRoot":"","sources":["../../../src/components/cat-tooltip/cat-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAa,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAA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;MACrB,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;MACvC,IAAI,CAAC,WAAW,EAAE,CAAC;KACpB;EACH,CAAC;EAEO,wBAAwB;IAC9B,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;EACjD,CAAC;EAEO,WAAW;IACjB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE;MAChC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;KACtF;IACD,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;EAC9D,CAAC;EAEO,WAAW;IACjB,IAAI,IAAI,CAAC,iBAAiB,EAAE;MAC1B,IAAI,CAAC,iBAAiB,EAAE,CAAC;KAC1B;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AApLuB,iBAAM,GAAG,CAAC,AAAJ,CAAK;AACX,wBAAa,GAAG,CAAC,AAAJ,CAAK;SAF/B,UAAU","sourcesContent":["import { autoUpdate, computePosition, flip, offset, Placement, shift } from '@floating-ui/dom';\nimport { Component, Element, h, Host, Listen, Prop, State } from '@stencil/core';\nimport isTouchScreen from '../../utils/is-touch-screen';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-tooltip',\n styleUrl: 'cat-tooltip.scss',\n shadow: true\n})\nexport class CatTooltip {\n private static readonly OFFSET = 4;\n private static readonly SHIFT_PADDING = 4;\n private readonly id = `cat-tooltip-${nextUniqueId++}`;\n private tooltip?: HTMLElement;\n private trigger?: Element;\n private showTimeout?: number;\n private hideTimeout?: number;\n private touchTimeout?: number;\n private hidden = false;\n private cleanupFloatingUi?: () => void;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedContent = false;\n\n /**\n * The content of the tooltip.\n */\n @Prop() content = '';\n\n /**\n * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,\n * and invisible. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * The placement of the tooltip.\n */\n @Prop() placement: Placement = 'top';\n\n /**\n * Use round tooltip edges.\n */\n @Prop() round = false;\n\n /**\n * The size of the tooltip.\n */\n @Prop() size: 's' | 'm' | 'l' = 'm';\n\n /**\n * The delay time for showing tooltip in ms.\n */\n @Prop() showDelay = 250;\n\n /**\n * The delay time for hiding tooltip in ms.\n */\n @Prop() hideDelay = 0;\n\n /**\n * The duration of tap to show the tooltip.\n */\n @Prop() longTouchDuration = 1000;\n\n @Listen('keydown')\n handleKeyDown({ key }: KeyboardEvent) {\n key === 'Escape' && this.hideListener();\n }\n\n componentDidLoad(): void {\n const slot = this.hostElement.shadowRoot?.querySelector('slot');\n this.trigger = slot?.assignedElements?.()?.[0];\n if (this.trigger && !this.trigger.hasAttribute('aria-describedby')) {\n this.trigger.setAttribute('aria-describedby', this.id);\n }\n\n if (isTouchScreen) {\n window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));\n this.trigger?.addEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.addEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.addEventListener('focusin', this.showListener.bind(this));\n this.trigger?.addEventListener('focusout', this.hideListener.bind(this));\n this.trigger?.addEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.addEventListener('mouseleave', this.hideListener.bind(this));\n }\n }\n\n componentWillRender(): void {\n this.hasSlottedContent = !!this.hostElement.querySelector('[slot=\"content\"]');\n this.hidden = this.disabled || (!this.content && !this.hasSlottedContent);\n }\n\n disconnectedCallback(): void {\n if (isTouchScreen) {\n window.removeEventListener('touchstart', this.windowTouchStartListener.bind(this));\n this.trigger?.removeEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.removeEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.removeEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.removeEventListener('mouseleave', this.hideListener.bind(this));\n this.trigger?.removeEventListener('focusin', this.showListener.bind(this));\n this.trigger?.removeEventListener('focusout', this.hideListener.bind(this));\n }\n }\n\n render() {\n return (\n <Host>\n <slot />\n <div\n ref={el => (this.tooltip = el)}\n id={this.id}\n aria-hidden={this.hidden}\n class={{\n tooltip: true,\n 'tooltip-hidden': this.hidden,\n 'tooltip-round': this.round,\n [`tooltip-${this.size}`]: Boolean(this.size)\n }}\n >\n {this.hasSlottedContent ? <slot name=\"content\" /> : this.content}\n </div>\n </Host>\n );\n }\n\n private async update() {\n if (this.trigger && this.tooltip) {\n await computePosition(this.trigger, this.tooltip, {\n strategy: 'fixed',\n placement: this.placement,\n middleware: [offset(CatTooltip.OFFSET), flip(), shift({ padding: CatTooltip.SHIFT_PADDING })]\n }).then(({ x, y }) => {\n if (this.tooltip) {\n Object.assign(this.tooltip.style, {\n left: `${Math.max(0, x)}px`,\n top: `${y}px`\n });\n }\n });\n }\n }\n\n private showListener() {\n window.clearTimeout(this.hideTimeout);\n this.showTimeout = window.setTimeout(() => {\n this.showTooltip();\n }, this.showDelay);\n }\n\n private hideListener() {\n window.clearTimeout(this.showTimeout);\n this.hideTimeout = window.setTimeout(() => {\n this.tooltip?.classList.remove('tooltip-show');\n this.hideTooltip();\n }, this.hideDelay);\n }\n\n private touchStartListener(event: Event) {\n event.stopPropagation();\n this.touchTimeout = window.setTimeout(() => {\n this.showTooltip();\n }, this.longTouchDuration);\n }\n\n private touchEndListener() {\n if (this.touchTimeout) {\n window.clearTimeout(this.touchTimeout);\n this.hideTooltip();\n }\n }\n\n private windowTouchStartListener() {\n this.tooltip?.classList.remove('tooltip-show');\n }\n\n private showTooltip() {\n if (this.trigger && this.tooltip) {\n this.cleanupFloatingUi = autoUpdate(this.trigger, this.tooltip, () => this.update());\n }\n !this.hidden && this.tooltip?.classList.add('tooltip-show');\n }\n\n private hideTooltip() {\n if (this.cleanupFloatingUi) {\n this.cleanupFloatingUi();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"cat-tooltip.js","sourceRoot":"","sources":["../../../src/components/cat-tooltip/cat-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAa,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAExD,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB,MAKa,UAAU;EAkBrB;IAfiB,OAAE,GAAG,eAAe,YAAY,EAAE,EAAE,CAAC;IAM9C,WAAM,GAAG,KAAK,CAAC;6BAmBM,KAAK;mBAKhB,EAAE;oBAMD,KAAK;qBAKO,KAAK;iBAKpB,KAAK;gBAKW,GAAG;qBAKf,GAAG;qBAKH,CAAC;6BAKO,IAAI;IAlD9B,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,CAAC,6BAA6B,GAAG,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9E,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IA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EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;KACtF;IACD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;MAChB,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;KAC7C;EACH,CAAC;EAEO,WAAW;IACjB,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAC/C,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;IAC3B,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;EACrC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA7MuB,iBAAM,GAAG,CAAC,AAAJ,CAAK;AACX,wBAAa,GAAG,CAAC,AAAJ,CAAK;SAF/B,UAAU","sourcesContent":["import { autoUpdate, computePosition, flip, offset, Placement, shift } from '@floating-ui/dom';\nimport { Component, Element, h, Host, Listen, Prop, State } from '@stencil/core';\nimport isTouchScreen from '../../utils/is-touch-screen';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-tooltip',\n styleUrl: 'cat-tooltip.scss',\n shadow: true\n})\nexport class CatTooltip {\n private static readonly OFFSET = 4;\n private static readonly SHIFT_PADDING = 4;\n private readonly id = `cat-tooltip-${nextUniqueId++}`;\n private tooltip?: HTMLElement;\n private trigger?: Element;\n private showTimeout?: number;\n private hideTimeout?: number;\n private touchTimeout?: number;\n private hidden = false;\n private cleanupFloatingUi?: () => void;\n\n private readonly boundShowListener: () => void;\n private readonly boundHideListener: () => void;\n private readonly boundWindowTouchStartListener: () => void;\n private readonly boundTouchStartListener: (event: Event) => void;\n private readonly boundTouchEndListener: () => void;\n\n constructor() {\n this.boundShowListener = this.showListener.bind(this);\n this.boundHideListener = this.hideListener.bind(this);\n this.boundWindowTouchStartListener = this.windowTouchStartListener.bind(this);\n this.boundTouchStartListener = this.touchStartListener.bind(this);\n this.boundTouchEndListener = this.touchEndListener.bind(this);\n }\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedContent = false;\n\n /**\n * The content of the tooltip.\n */\n @Prop() content = '';\n\n /**\n * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,\n * and invisible. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * The placement of the tooltip.\n */\n @Prop() placement: Placement = 'top';\n\n /**\n * Use round tooltip edges.\n */\n @Prop() round = false;\n\n /**\n * The size of the tooltip.\n */\n @Prop() size: 's' | 'm' | 'l' = 'm';\n\n /**\n * The delay time for showing tooltip in ms.\n */\n @Prop() showDelay = 250;\n\n /**\n * The delay time for hiding tooltip in ms.\n */\n @Prop() hideDelay = 0;\n\n /**\n * The duration of tap to show the tooltip.\n */\n @Prop() longTouchDuration = 1000;\n\n @Listen('keydown')\n handleKeyDown({ key }: KeyboardEvent) {\n key === 'Escape' && this.hideTooltip();\n }\n\n componentDidLoad(): void {\n const slot = this.hostElement.shadowRoot?.querySelector('slot');\n this.trigger = slot?.assignedElements?.()?.[0];\n if (this.trigger && !this.trigger.hasAttribute('aria-describedby')) {\n this.trigger.setAttribute('aria-describedby', this.id);\n }\n\n if (isTouchScreen) {\n window.addEventListener('touchstart', this.boundWindowTouchStartListener);\n this.trigger?.addEventListener('touchstart', this.boundTouchStartListener);\n this.trigger?.addEventListener('touchend', this.boundTouchEndListener);\n } else {\n this.trigger?.addEventListener('focusin', this.boundShowListener);\n this.trigger?.addEventListener('focusout', this.boundHideListener);\n this.trigger?.addEventListener('mouseenter', this.boundShowListener);\n this.trigger?.addEventListener('mouseleave', this.boundHideListener);\n }\n }\n\n componentWillRender(): void {\n this.hasSlottedContent = !!this.hostElement.querySelector('[slot=\"content\"]');\n this.hidden = this.disabled || (!this.content && !this.hasSlottedContent);\n }\n\n disconnectedCallback(): void {\n if (isTouchScreen) {\n window.removeEventListener('touchstart', this.boundWindowTouchStartListener);\n this.trigger?.removeEventListener('touchstart', this.boundTouchStartListener);\n this.trigger?.removeEventListener('touchend', this.boundTouchEndListener);\n } else {\n this.trigger?.removeEventListener('mouseenter', this.boundShowListener);\n this.trigger?.removeEventListener('mouseleave', this.boundHideListener);\n this.trigger?.removeEventListener('focusin', this.boundShowListener);\n this.trigger?.removeEventListener('focusout', this.boundHideListener);\n }\n }\n\n render() {\n return (\n <Host>\n <slot />\n <div\n ref={el => (this.tooltip = el)}\n id={this.id}\n aria-hidden={this.hidden}\n class={{\n tooltip: true,\n 'tooltip-hidden': this.hidden,\n 'tooltip-round': this.round,\n [`tooltip-${this.size}`]: Boolean(this.size)\n }}\n >\n {this.hasSlottedContent ? <slot name=\"content\" /> : this.content}\n </div>\n </Host>\n );\n }\n\n private async update() {\n if (this.trigger && this.tooltip) {\n await computePosition(this.trigger, this.tooltip, {\n strategy: 'fixed',\n placement: this.placement,\n middleware: [offset(CatTooltip.OFFSET), flip(), shift({ padding: CatTooltip.SHIFT_PADDING })]\n }).then(({ x, y }) => {\n if (this.tooltip) {\n Object.assign(this.tooltip.style, {\n left: `${Math.max(0, x)}px`,\n top: `${y}px`\n });\n }\n });\n }\n }\n\n private showListener() {\n window.clearTimeout(this.hideTimeout);\n this.hideTimeout = undefined;\n if (!this.showTimeout) {\n this.showTimeout = window.setTimeout(() => {\n this.showTimeout = undefined;\n this.showTooltip();\n }, this.showDelay);\n }\n }\n\n private hideListener() {\n window.clearTimeout(this.showTimeout);\n this.showTimeout = undefined;\n if (!this.hideTimeout) {\n this.hideTimeout = window.setTimeout(() => {\n this.hideTimeout = undefined;\n this.hideTooltip();\n }, this.hideDelay);\n }\n }\n\n private touchStartListener(event: Event) {\n event.stopPropagation();\n if (!this.touchTimeout) {\n this.touchTimeout = window.setTimeout(() => {\n this.touchTimeout = undefined;\n this.showTooltip();\n }, this.longTouchDuration);\n }\n }\n\n private touchEndListener() {\n window.clearTimeout(this.touchTimeout);\n this.touchTimeout = undefined;\n this.hideTooltip();\n }\n\n private windowTouchStartListener() {\n this.hideTooltip();\n }\n\n private showTooltip() {\n if (this.trigger && this.tooltip) {\n this.cleanupFloatingUi = autoUpdate(this.trigger, this.tooltip, () => this.update());\n }\n if (!this.hidden) {\n this.tooltip?.classList.add('tooltip-show');\n }\n }\n\n private hideTooltip() {\n this.tooltip?.classList.remove('tooltip-show');\n this.cleanupFloatingUi?.();\n this.cleanupFloatingUi = undefined;\n }\n}\n"]}
@@ -22,9 +22,14 @@ const CatTooltip$1 = /*@__PURE__*/ proxyCustomElement(class CatTooltip extends H
22
22
  this.showDelay = 250;
23
23
  this.hideDelay = 0;
24
24
  this.longTouchDuration = 1000;
25
+ this.boundShowListener = this.showListener.bind(this);
26
+ this.boundHideListener = this.hideListener.bind(this);
27
+ this.boundWindowTouchStartListener = this.windowTouchStartListener.bind(this);
28
+ this.boundTouchStartListener = this.touchStartListener.bind(this);
29
+ this.boundTouchEndListener = this.touchEndListener.bind(this);
25
30
  }
26
31
  handleKeyDown({ key }) {
27
- key === 'Escape' && this.hideListener();
32
+ key === 'Escape' && this.hideTooltip();
28
33
  }
29
34
  componentDidLoad() {
30
35
  const slot = this.hostElement.shadowRoot?.querySelector('slot');
@@ -33,15 +38,15 @@ const CatTooltip$1 = /*@__PURE__*/ proxyCustomElement(class CatTooltip extends H
33
38
  this.trigger.setAttribute('aria-describedby', this.id);
34
39
  }
35
40
  if (isTouchDevice) {
36
- window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));
37
- this.trigger?.addEventListener('touchstart', this.touchStartListener.bind(this));
38
- this.trigger?.addEventListener('touchend', this.touchEndListener.bind(this));
41
+ window.addEventListener('touchstart', this.boundWindowTouchStartListener);
42
+ this.trigger?.addEventListener('touchstart', this.boundTouchStartListener);
43
+ this.trigger?.addEventListener('touchend', this.boundTouchEndListener);
39
44
  }
40
45
  else {
41
- this.trigger?.addEventListener('focusin', this.showListener.bind(this));
42
- this.trigger?.addEventListener('focusout', this.hideListener.bind(this));
43
- this.trigger?.addEventListener('mouseenter', this.showListener.bind(this));
44
- this.trigger?.addEventListener('mouseleave', this.hideListener.bind(this));
46
+ this.trigger?.addEventListener('focusin', this.boundShowListener);
47
+ this.trigger?.addEventListener('focusout', this.boundHideListener);
48
+ this.trigger?.addEventListener('mouseenter', this.boundShowListener);
49
+ this.trigger?.addEventListener('mouseleave', this.boundHideListener);
45
50
  }
46
51
  }
47
52
  componentWillRender() {
@@ -50,15 +55,15 @@ const CatTooltip$1 = /*@__PURE__*/ proxyCustomElement(class CatTooltip extends H
50
55
  }
51
56
  disconnectedCallback() {
52
57
  if (isTouchDevice) {
53
- window.removeEventListener('touchstart', this.windowTouchStartListener.bind(this));
54
- this.trigger?.removeEventListener('touchstart', this.touchStartListener.bind(this));
55
- this.trigger?.removeEventListener('touchend', this.touchEndListener.bind(this));
58
+ window.removeEventListener('touchstart', this.boundWindowTouchStartListener);
59
+ this.trigger?.removeEventListener('touchstart', this.boundTouchStartListener);
60
+ this.trigger?.removeEventListener('touchend', this.boundTouchEndListener);
56
61
  }
57
62
  else {
58
- this.trigger?.removeEventListener('mouseenter', this.showListener.bind(this));
59
- this.trigger?.removeEventListener('mouseleave', this.hideListener.bind(this));
60
- this.trigger?.removeEventListener('focusin', this.showListener.bind(this));
61
- this.trigger?.removeEventListener('focusout', this.hideListener.bind(this));
63
+ this.trigger?.removeEventListener('mouseenter', this.boundShowListener);
64
+ this.trigger?.removeEventListener('mouseleave', this.boundHideListener);
65
+ this.trigger?.removeEventListener('focusin', this.boundShowListener);
66
+ this.trigger?.removeEventListener('focusout', this.boundHideListener);
62
67
  }
63
68
  }
64
69
  render() {
@@ -87,42 +92,53 @@ const CatTooltip$1 = /*@__PURE__*/ proxyCustomElement(class CatTooltip extends H
87
92
  }
88
93
  showListener() {
89
94
  window.clearTimeout(this.hideTimeout);
90
- this.showTimeout = window.setTimeout(() => {
91
- this.showTooltip();
92
- }, this.showDelay);
95
+ this.hideTimeout = undefined;
96
+ if (!this.showTimeout) {
97
+ this.showTimeout = window.setTimeout(() => {
98
+ this.showTimeout = undefined;
99
+ this.showTooltip();
100
+ }, this.showDelay);
101
+ }
93
102
  }
94
103
  hideListener() {
95
104
  window.clearTimeout(this.showTimeout);
96
- this.hideTimeout = window.setTimeout(() => {
97
- this.tooltip?.classList.remove('tooltip-show');
98
- this.hideTooltip();
99
- }, this.hideDelay);
105
+ this.showTimeout = undefined;
106
+ if (!this.hideTimeout) {
107
+ this.hideTimeout = window.setTimeout(() => {
108
+ this.hideTimeout = undefined;
109
+ this.hideTooltip();
110
+ }, this.hideDelay);
111
+ }
100
112
  }
101
113
  touchStartListener(event) {
102
114
  event.stopPropagation();
103
- this.touchTimeout = window.setTimeout(() => {
104
- this.showTooltip();
105
- }, this.longTouchDuration);
115
+ if (!this.touchTimeout) {
116
+ this.touchTimeout = window.setTimeout(() => {
117
+ this.touchTimeout = undefined;
118
+ this.showTooltip();
119
+ }, this.longTouchDuration);
120
+ }
106
121
  }
107
122
  touchEndListener() {
108
- if (this.touchTimeout) {
109
- window.clearTimeout(this.touchTimeout);
110
- this.hideTooltip();
111
- }
123
+ window.clearTimeout(this.touchTimeout);
124
+ this.touchTimeout = undefined;
125
+ this.hideTooltip();
112
126
  }
113
127
  windowTouchStartListener() {
114
- this.tooltip?.classList.remove('tooltip-show');
128
+ this.hideTooltip();
115
129
  }
116
130
  showTooltip() {
117
131
  if (this.trigger && this.tooltip) {
118
132
  this.cleanupFloatingUi = autoUpdate(this.trigger, this.tooltip, () => this.update());
119
133
  }
120
- !this.hidden && this.tooltip?.classList.add('tooltip-show');
134
+ if (!this.hidden) {
135
+ this.tooltip?.classList.add('tooltip-show');
136
+ }
121
137
  }
122
138
  hideTooltip() {
123
- if (this.cleanupFloatingUi) {
124
- this.cleanupFloatingUi();
125
- }
139
+ this.tooltip?.classList.remove('tooltip-show');
140
+ this.cleanupFloatingUi?.();
141
+ this.cleanupFloatingUi = undefined;
126
142
  }
127
143
  get hostElement() { return this; }
128
144
  static get style() { return catTooltipCss; }
@@ -1 +1 @@
1
- {"file":"cat-tooltip.js","mappings":";;;AAAA,MAAM,aAAa,GAAG,cAAc,IAAI,MAAM,IAAI,SAAS,CAAC,cAAc,GAAG,CAAC;;ACA9E,MAAM,aAAa,GAAG,gsCAAgsC;;ACIttC,IAAI,YAAY,GAAG,CAAC,CAAC;MAORA,YAAU;;;;;IAGJ,OAAE,GAAG,eAAe,YAAY,EAAE,EAAE,CAAC;IAM9C,WAAM,GAAG,KAAK,CAAC;6BAKM,KAAK;mBAKhB,EAAE;oBAMD,KAAK;qBAKO,KAAK;iBAKpB,KAAK;gBAKW,GAAG;qBAKf,GAAG;qBAKH,CAAC;6BAKO,IAAI;;EAGhC,aAAa,CAAC,EAAE,GAAG,EAAiB;IAClC,GAAG,KAAK,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;GACzC;EAED,gBAAgB;IACd,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,gBAAgB,IAAI,GAAG,CAAC,CAAC,CAAC;IAC/C,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAAE;MAClE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,kBAAkB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;KACxD;IAED,IAAIC,aAAa,EAAE;MACjB,MAAM,CAAC,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;MAChF,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,kBAAkB,CAAC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AC,YAAY,EAAE;MACrB,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;MACvC,IAAI,CAAC,WAAW,EAAE,CAAC;KACpB;GACF;EAEO,wBAAwB;IAC9B,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;GAChD;EAEO,WAAW;IACjB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE;MAChC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;KACtF;IACD,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;GAC7D;EAEO,WAAW;IACjB,IAAI,IAAI,CAAC,iBAAiB,EAAE;MAC1B,IAAI,CAAC,iBAAiB,EAAE,CAAC;KAC1B;GACF;;;;;;;;;;;;;;AApLuBD,mBAAM,GAAG,CAAH,CAAK;AACXA,0BAAa,GAAG,CAAH,CAAK;;;;;;;;;;;;;;;;;;;;","names":["CatTooltip","isTouchScreen"],"sources":["src/utils/is-touch-screen.ts","src/components/cat-tooltip/cat-tooltip.scss?tag=cat-tooltip&encapsulation=shadow","src/components/cat-tooltip/cat-tooltip.tsx"],"sourcesContent":["const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n\nexport default isTouchDevice;\n","@use 'variables' as *;\n@use 'mixins' as *;\n\n$-max-width: 20rem;\n$-box-shadow: rgb(0 0 0 / 8%) 0 1px 8px 0;\n$-shift-padding: 0.25rem; // padding given to the shift() middleware\n\n:host {\n display: contents;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.tooltip {\n --cat-font-color-head: cat-token('color.ui.font.tooltip', $wrap: false);\n --cat-font-color-body: cat-token('color.ui.font.tooltip', $wrap: false);\n position: fixed;\n width: max-content;\n top: 0;\n left: 0;\n box-sizing: border-box;\n @include cat-body('s', 500);\n background-color: cat-token('color.ui.background.tooltip');\n border-radius: cat-border-radius('m');\n color: cat-token('color.ui.font.tooltip');\n transition: opacity cat-token('time.transition.m') linear, visibility cat-token('time.transition.m') linear;\n visibility: hidden;\n opacity: 0;\n box-shadow: $-box-shadow;\n z-index: $cat-tooltip-z-index;\n max-width: min(calc(100vw - 2 * $-shift-padding), $-max-width);\n\n &-hidden {\n @include cat-visually-hidden;\n }\n\n &-show {\n opacity: 1;\n visibility: visible;\n }\n}\n\n// ----- round\n\n.tooltip-round {\n border-radius: 10rem;\n}\n\n// ----- size\n\n.tooltip-s {\n padding: 0.375rem 0.5rem;\n\n &.tooltip-round {\n padding: 0.375rem 0.75rem;\n }\n}\n\n.tooltip-m {\n padding: 0.75rem;\n\n &.tooltip-round {\n padding: 0.75rem 1rem;\n }\n}\n\n.tooltip-l {\n padding: 1rem;\n\n &.tooltip-round {\n padding: 1rem 1.5rem;\n }\n}\n","import { autoUpdate, computePosition, flip, offset, Placement, shift } from '@floating-ui/dom';\nimport { Component, Element, h, Host, Listen, Prop, State } from '@stencil/core';\nimport isTouchScreen from '../../utils/is-touch-screen';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-tooltip',\n styleUrl: 'cat-tooltip.scss',\n shadow: true\n})\nexport class CatTooltip {\n private static readonly OFFSET = 4;\n private static readonly SHIFT_PADDING = 4;\n private readonly id = `cat-tooltip-${nextUniqueId++}`;\n private tooltip?: HTMLElement;\n private trigger?: Element;\n private showTimeout?: number;\n private hideTimeout?: number;\n private touchTimeout?: number;\n private hidden = false;\n private cleanupFloatingUi?: () => void;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedContent = false;\n\n /**\n * The content of the tooltip.\n */\n @Prop() content = '';\n\n /**\n * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,\n * and invisible. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * The placement of the tooltip.\n */\n @Prop() placement: Placement = 'top';\n\n /**\n * Use round tooltip edges.\n */\n @Prop() round = false;\n\n /**\n * The size of the tooltip.\n */\n @Prop() size: 's' | 'm' | 'l' = 'm';\n\n /**\n * The delay time for showing tooltip in ms.\n */\n @Prop() showDelay = 250;\n\n /**\n * The delay time for hiding tooltip in ms.\n */\n @Prop() hideDelay = 0;\n\n /**\n * The duration of tap to show the tooltip.\n */\n @Prop() longTouchDuration = 1000;\n\n @Listen('keydown')\n handleKeyDown({ key }: KeyboardEvent) {\n key === 'Escape' && this.hideListener();\n }\n\n componentDidLoad(): void {\n const slot = this.hostElement.shadowRoot?.querySelector('slot');\n this.trigger = slot?.assignedElements?.()?.[0];\n if (this.trigger && !this.trigger.hasAttribute('aria-describedby')) {\n this.trigger.setAttribute('aria-describedby', this.id);\n }\n\n if (isTouchScreen) {\n window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));\n this.trigger?.addEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.addEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.addEventListener('focusin', this.showListener.bind(this));\n this.trigger?.addEventListener('focusout', this.hideListener.bind(this));\n this.trigger?.addEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.addEventListener('mouseleave', this.hideListener.bind(this));\n }\n }\n\n componentWillRender(): void {\n this.hasSlottedContent = !!this.hostElement.querySelector('[slot=\"content\"]');\n this.hidden = this.disabled || (!this.content && !this.hasSlottedContent);\n }\n\n disconnectedCallback(): void {\n if (isTouchScreen) {\n window.removeEventListener('touchstart', this.windowTouchStartListener.bind(this));\n this.trigger?.removeEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.removeEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.removeEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.removeEventListener('mouseleave', this.hideListener.bind(this));\n this.trigger?.removeEventListener('focusin', this.showListener.bind(this));\n this.trigger?.removeEventListener('focusout', this.hideListener.bind(this));\n }\n }\n\n render() {\n return (\n <Host>\n <slot />\n <div\n ref={el => (this.tooltip = el)}\n id={this.id}\n aria-hidden={this.hidden}\n class={{\n tooltip: true,\n 'tooltip-hidden': this.hidden,\n 'tooltip-round': this.round,\n [`tooltip-${this.size}`]: Boolean(this.size)\n }}\n >\n {this.hasSlottedContent ? <slot name=\"content\" /> : this.content}\n </div>\n </Host>\n );\n }\n\n private async update() {\n if (this.trigger && this.tooltip) {\n await computePosition(this.trigger, this.tooltip, {\n strategy: 'fixed',\n placement: this.placement,\n middleware: [offset(CatTooltip.OFFSET), flip(), shift({ padding: CatTooltip.SHIFT_PADDING })]\n }).then(({ x, y }) => {\n if (this.tooltip) {\n Object.assign(this.tooltip.style, {\n left: `${Math.max(0, x)}px`,\n top: `${y}px`\n });\n }\n });\n }\n }\n\n private showListener() {\n window.clearTimeout(this.hideTimeout);\n this.showTimeout = window.setTimeout(() => {\n this.showTooltip();\n }, this.showDelay);\n }\n\n private hideListener() {\n window.clearTimeout(this.showTimeout);\n this.hideTimeout = window.setTimeout(() => {\n this.tooltip?.classList.remove('tooltip-show');\n this.hideTooltip();\n }, this.hideDelay);\n }\n\n private touchStartListener(event: Event) {\n event.stopPropagation();\n this.touchTimeout = window.setTimeout(() => {\n this.showTooltip();\n }, this.longTouchDuration);\n }\n\n private touchEndListener() {\n if (this.touchTimeout) {\n window.clearTimeout(this.touchTimeout);\n this.hideTooltip();\n }\n }\n\n private windowTouchStartListener() {\n this.tooltip?.classList.remove('tooltip-show');\n }\n\n private showTooltip() {\n if (this.trigger && this.tooltip) {\n this.cleanupFloatingUi = autoUpdate(this.trigger, this.tooltip, () => this.update());\n }\n !this.hidden && this.tooltip?.classList.add('tooltip-show');\n }\n\n private hideTooltip() {\n if (this.cleanupFloatingUi) {\n this.cleanupFloatingUi();\n }\n }\n}\n"],"version":3}
1
+ {"file":"cat-tooltip.js","mappings":";;;AAAA,MAAM,aAAa,GAAG,cAAc,IAAI,MAAM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AAC;QAC9B,IAAI,CAAC,WAAW,EAAE,CAAC;OACpB,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;KAC5B;GACF;EAEO,gBAAgB;IACtB,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACvC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;IAC9B,IAAI,CAAC,WAAW,EAAE,CAAC;GACpB;EAEO,wBAAwB;IAC9B,IAAI,CAAC,WAAW,EAAE,CAAC;GACpB;EAEO,WAAW;IACjB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE;MAChC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;KACtF;IACD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;MAChB,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;KAC7C;GACF;EAEO,WAAW;IACjB,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAC/C,IAAI,CAAC,iBAAiB,IAAI,CAAC;IAC3B,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;GACpC;;;;;;;;;;;;;;AA7MuBD,mBAAM,GAAG,CAAH,CAAK;AACXA,0BAAa,GAAG,CAAH,CAAK;;;;;;;;;;;;;;;;;;;;","names":["CatTooltip","isTouchScreen"],"sources":["src/utils/is-touch-screen.ts","src/components/cat-tooltip/cat-tooltip.scss?tag=cat-tooltip&encapsulation=shadow","src/components/cat-tooltip/cat-tooltip.tsx"],"sourcesContent":["const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n\nexport default isTouchDevice;\n","@use 'variables' as *;\n@use 'mixins' as *;\n\n$-max-width: 20rem;\n$-box-shadow: rgb(0 0 0 / 8%) 0 1px 8px 0;\n$-shift-padding: 0.25rem; // padding given to the shift() middleware\n\n:host {\n display: contents;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.tooltip {\n --cat-font-color-head: cat-token('color.ui.font.tooltip', $wrap: false);\n --cat-font-color-body: cat-token('color.ui.font.tooltip', $wrap: false);\n position: fixed;\n width: max-content;\n top: 0;\n left: 0;\n box-sizing: border-box;\n @include cat-body('s', 500);\n background-color: cat-token('color.ui.background.tooltip');\n border-radius: cat-border-radius('m');\n color: cat-token('color.ui.font.tooltip');\n transition: opacity cat-token('time.transition.m') linear, visibility cat-token('time.transition.m') linear;\n visibility: hidden;\n opacity: 0;\n box-shadow: $-box-shadow;\n z-index: $cat-tooltip-z-index;\n max-width: min(calc(100vw - 2 * $-shift-padding), $-max-width);\n\n &-hidden {\n @include cat-visually-hidden;\n }\n\n &-show {\n opacity: 1;\n visibility: visible;\n }\n}\n\n// ----- round\n\n.tooltip-round {\n border-radius: 10rem;\n}\n\n// ----- size\n\n.tooltip-s {\n padding: 0.375rem 0.5rem;\n\n &.tooltip-round {\n padding: 0.375rem 0.75rem;\n }\n}\n\n.tooltip-m {\n padding: 0.75rem;\n\n &.tooltip-round {\n padding: 0.75rem 1rem;\n }\n}\n\n.tooltip-l {\n padding: 1rem;\n\n &.tooltip-round {\n padding: 1rem 1.5rem;\n }\n}\n","import { autoUpdate, computePosition, flip, offset, Placement, shift } from '@floating-ui/dom';\nimport { Component, Element, h, Host, Listen, Prop, State } from '@stencil/core';\nimport isTouchScreen from '../../utils/is-touch-screen';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-tooltip',\n styleUrl: 'cat-tooltip.scss',\n shadow: true\n})\nexport class CatTooltip {\n private static readonly OFFSET = 4;\n private static readonly SHIFT_PADDING = 4;\n private readonly id = `cat-tooltip-${nextUniqueId++}`;\n private tooltip?: HTMLElement;\n private trigger?: Element;\n private showTimeout?: number;\n private hideTimeout?: number;\n private touchTimeout?: number;\n private hidden = false;\n private cleanupFloatingUi?: () => void;\n\n private readonly boundShowListener: () => void;\n private readonly boundHideListener: () => void;\n private readonly boundWindowTouchStartListener: () => void;\n private readonly boundTouchStartListener: (event: Event) => void;\n private readonly boundTouchEndListener: () => void;\n\n constructor() {\n this.boundShowListener = this.showListener.bind(this);\n this.boundHideListener = this.hideListener.bind(this);\n this.boundWindowTouchStartListener = this.windowTouchStartListener.bind(this);\n this.boundTouchStartListener = this.touchStartListener.bind(this);\n this.boundTouchEndListener = this.touchEndListener.bind(this);\n }\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedContent = false;\n\n /**\n * The content of the tooltip.\n */\n @Prop() content = '';\n\n /**\n * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,\n * and invisible. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * The placement of the tooltip.\n */\n @Prop() placement: Placement = 'top';\n\n /**\n * Use round tooltip edges.\n */\n @Prop() round = false;\n\n /**\n * The size of the tooltip.\n */\n @Prop() size: 's' | 'm' | 'l' = 'm';\n\n /**\n * The delay time for showing tooltip in ms.\n */\n @Prop() showDelay = 250;\n\n /**\n * The delay time for hiding tooltip in ms.\n */\n @Prop() hideDelay = 0;\n\n /**\n * The duration of tap to show the tooltip.\n */\n @Prop() longTouchDuration = 1000;\n\n @Listen('keydown')\n handleKeyDown({ key }: KeyboardEvent) {\n key === 'Escape' && this.hideTooltip();\n }\n\n componentDidLoad(): void {\n const slot = this.hostElement.shadowRoot?.querySelector('slot');\n this.trigger = slot?.assignedElements?.()?.[0];\n if (this.trigger && !this.trigger.hasAttribute('aria-describedby')) {\n this.trigger.setAttribute('aria-describedby', this.id);\n }\n\n if (isTouchScreen) {\n window.addEventListener('touchstart', this.boundWindowTouchStartListener);\n this.trigger?.addEventListener('touchstart', this.boundTouchStartListener);\n this.trigger?.addEventListener('touchend', this.boundTouchEndListener);\n } else {\n this.trigger?.addEventListener('focusin', this.boundShowListener);\n this.trigger?.addEventListener('focusout', this.boundHideListener);\n this.trigger?.addEventListener('mouseenter', this.boundShowListener);\n this.trigger?.addEventListener('mouseleave', this.boundHideListener);\n }\n }\n\n componentWillRender(): void {\n this.hasSlottedContent = !!this.hostElement.querySelector('[slot=\"content\"]');\n this.hidden = this.disabled || (!this.content && !this.hasSlottedContent);\n }\n\n disconnectedCallback(): void {\n if (isTouchScreen) {\n window.removeEventListener('touchstart', this.boundWindowTouchStartListener);\n this.trigger?.removeEventListener('touchstart', this.boundTouchStartListener);\n this.trigger?.removeEventListener('touchend', this.boundTouchEndListener);\n } else {\n this.trigger?.removeEventListener('mouseenter', this.boundShowListener);\n this.trigger?.removeEventListener('mouseleave', this.boundHideListener);\n this.trigger?.removeEventListener('focusin', this.boundShowListener);\n this.trigger?.removeEventListener('focusout', this.boundHideListener);\n }\n }\n\n render() {\n return (\n <Host>\n <slot />\n <div\n ref={el => (this.tooltip = el)}\n id={this.id}\n aria-hidden={this.hidden}\n class={{\n tooltip: true,\n 'tooltip-hidden': this.hidden,\n 'tooltip-round': this.round,\n [`tooltip-${this.size}`]: Boolean(this.size)\n }}\n >\n {this.hasSlottedContent ? <slot name=\"content\" /> : this.content}\n </div>\n </Host>\n );\n }\n\n private async update() {\n if (this.trigger && this.tooltip) {\n await computePosition(this.trigger, this.tooltip, {\n strategy: 'fixed',\n placement: this.placement,\n middleware: [offset(CatTooltip.OFFSET), flip(), shift({ padding: CatTooltip.SHIFT_PADDING })]\n }).then(({ x, y }) => {\n if (this.tooltip) {\n Object.assign(this.tooltip.style, {\n left: `${Math.max(0, x)}px`,\n top: `${y}px`\n });\n }\n });\n }\n }\n\n private showListener() {\n window.clearTimeout(this.hideTimeout);\n this.hideTimeout = undefined;\n if (!this.showTimeout) {\n this.showTimeout = window.setTimeout(() => {\n this.showTimeout = undefined;\n this.showTooltip();\n }, this.showDelay);\n }\n }\n\n private hideListener() {\n window.clearTimeout(this.showTimeout);\n this.showTimeout = undefined;\n if (!this.hideTimeout) {\n this.hideTimeout = window.setTimeout(() => {\n this.hideTimeout = undefined;\n this.hideTooltip();\n }, this.hideDelay);\n }\n }\n\n private touchStartListener(event: Event) {\n event.stopPropagation();\n if (!this.touchTimeout) {\n this.touchTimeout = window.setTimeout(() => {\n this.touchTimeout = undefined;\n this.showTooltip();\n }, this.longTouchDuration);\n }\n }\n\n private touchEndListener() {\n window.clearTimeout(this.touchTimeout);\n this.touchTimeout = undefined;\n this.hideTooltip();\n }\n\n private windowTouchStartListener() {\n this.hideTooltip();\n }\n\n private showTooltip() {\n if (this.trigger && this.tooltip) {\n this.cleanupFloatingUi = autoUpdate(this.trigger, this.tooltip, () => this.update());\n }\n if (!this.hidden) {\n this.tooltip?.classList.add('tooltip-show');\n }\n }\n\n private hideTooltip() {\n this.tooltip?.classList.remove('tooltip-show');\n this.cleanupFloatingUi?.();\n this.cleanupFloatingUi = undefined;\n }\n}\n"],"version":3}
@@ -10974,9 +10974,14 @@ const CatTooltip = class {
10974
10974
  this.showDelay = 250;
10975
10975
  this.hideDelay = 0;
10976
10976
  this.longTouchDuration = 1000;
10977
+ this.boundShowListener = this.showListener.bind(this);
10978
+ this.boundHideListener = this.hideListener.bind(this);
10979
+ this.boundWindowTouchStartListener = this.windowTouchStartListener.bind(this);
10980
+ this.boundTouchStartListener = this.touchStartListener.bind(this);
10981
+ this.boundTouchEndListener = this.touchEndListener.bind(this);
10977
10982
  }
10978
10983
  handleKeyDown({ key }) {
10979
- key === 'Escape' && this.hideListener();
10984
+ key === 'Escape' && this.hideTooltip();
10980
10985
  }
10981
10986
  componentDidLoad() {
10982
10987
  const slot = this.hostElement.shadowRoot?.querySelector('slot');
@@ -10985,15 +10990,15 @@ const CatTooltip = class {
10985
10990
  this.trigger.setAttribute('aria-describedby', this.id);
10986
10991
  }
10987
10992
  if (isTouchDevice) {
10988
- window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));
10989
- this.trigger?.addEventListener('touchstart', this.touchStartListener.bind(this));
10990
- this.trigger?.addEventListener('touchend', this.touchEndListener.bind(this));
10993
+ window.addEventListener('touchstart', this.boundWindowTouchStartListener);
10994
+ this.trigger?.addEventListener('touchstart', this.boundTouchStartListener);
10995
+ this.trigger?.addEventListener('touchend', this.boundTouchEndListener);
10991
10996
  }
10992
10997
  else {
10993
- this.trigger?.addEventListener('focusin', this.showListener.bind(this));
10994
- this.trigger?.addEventListener('focusout', this.hideListener.bind(this));
10995
- this.trigger?.addEventListener('mouseenter', this.showListener.bind(this));
10996
- this.trigger?.addEventListener('mouseleave', this.hideListener.bind(this));
10998
+ this.trigger?.addEventListener('focusin', this.boundShowListener);
10999
+ this.trigger?.addEventListener('focusout', this.boundHideListener);
11000
+ this.trigger?.addEventListener('mouseenter', this.boundShowListener);
11001
+ this.trigger?.addEventListener('mouseleave', this.boundHideListener);
10997
11002
  }
10998
11003
  }
10999
11004
  componentWillRender() {
@@ -11002,15 +11007,15 @@ const CatTooltip = class {
11002
11007
  }
11003
11008
  disconnectedCallback() {
11004
11009
  if (isTouchDevice) {
11005
- window.removeEventListener('touchstart', this.windowTouchStartListener.bind(this));
11006
- this.trigger?.removeEventListener('touchstart', this.touchStartListener.bind(this));
11007
- this.trigger?.removeEventListener('touchend', this.touchEndListener.bind(this));
11010
+ window.removeEventListener('touchstart', this.boundWindowTouchStartListener);
11011
+ this.trigger?.removeEventListener('touchstart', this.boundTouchStartListener);
11012
+ this.trigger?.removeEventListener('touchend', this.boundTouchEndListener);
11008
11013
  }
11009
11014
  else {
11010
- this.trigger?.removeEventListener('mouseenter', this.showListener.bind(this));
11011
- this.trigger?.removeEventListener('mouseleave', this.hideListener.bind(this));
11012
- this.trigger?.removeEventListener('focusin', this.showListener.bind(this));
11013
- this.trigger?.removeEventListener('focusout', this.hideListener.bind(this));
11015
+ this.trigger?.removeEventListener('mouseenter', this.boundShowListener);
11016
+ this.trigger?.removeEventListener('mouseleave', this.boundHideListener);
11017
+ this.trigger?.removeEventListener('focusin', this.boundShowListener);
11018
+ this.trigger?.removeEventListener('focusout', this.boundHideListener);
11014
11019
  }
11015
11020
  }
11016
11021
  render() {
@@ -11039,42 +11044,53 @@ const CatTooltip = class {
11039
11044
  }
11040
11045
  showListener() {
11041
11046
  window.clearTimeout(this.hideTimeout);
11042
- this.showTimeout = window.setTimeout(() => {
11043
- this.showTooltip();
11044
- }, this.showDelay);
11047
+ this.hideTimeout = undefined;
11048
+ if (!this.showTimeout) {
11049
+ this.showTimeout = window.setTimeout(() => {
11050
+ this.showTimeout = undefined;
11051
+ this.showTooltip();
11052
+ }, this.showDelay);
11053
+ }
11045
11054
  }
11046
11055
  hideListener() {
11047
11056
  window.clearTimeout(this.showTimeout);
11048
- this.hideTimeout = window.setTimeout(() => {
11049
- this.tooltip?.classList.remove('tooltip-show');
11050
- this.hideTooltip();
11051
- }, this.hideDelay);
11057
+ this.showTimeout = undefined;
11058
+ if (!this.hideTimeout) {
11059
+ this.hideTimeout = window.setTimeout(() => {
11060
+ this.hideTimeout = undefined;
11061
+ this.hideTooltip();
11062
+ }, this.hideDelay);
11063
+ }
11052
11064
  }
11053
11065
  touchStartListener(event) {
11054
11066
  event.stopPropagation();
11055
- this.touchTimeout = window.setTimeout(() => {
11056
- this.showTooltip();
11057
- }, this.longTouchDuration);
11067
+ if (!this.touchTimeout) {
11068
+ this.touchTimeout = window.setTimeout(() => {
11069
+ this.touchTimeout = undefined;
11070
+ this.showTooltip();
11071
+ }, this.longTouchDuration);
11072
+ }
11058
11073
  }
11059
11074
  touchEndListener() {
11060
- if (this.touchTimeout) {
11061
- window.clearTimeout(this.touchTimeout);
11062
- this.hideTooltip();
11063
- }
11075
+ window.clearTimeout(this.touchTimeout);
11076
+ this.touchTimeout = undefined;
11077
+ this.hideTooltip();
11064
11078
  }
11065
11079
  windowTouchStartListener() {
11066
- this.tooltip?.classList.remove('tooltip-show');
11080
+ this.hideTooltip();
11067
11081
  }
11068
11082
  showTooltip() {
11069
11083
  if (this.trigger && this.tooltip) {
11070
11084
  this.cleanupFloatingUi = autoUpdate(this.trigger, this.tooltip, () => this.update());
11071
11085
  }
11072
- !this.hidden && this.tooltip?.classList.add('tooltip-show');
11086
+ if (!this.hidden) {
11087
+ this.tooltip?.classList.add('tooltip-show');
11088
+ }
11073
11089
  }
11074
11090
  hideTooltip() {
11075
- if (this.cleanupFloatingUi) {
11076
- this.cleanupFloatingUi();
11077
- }
11091
+ this.tooltip?.classList.remove('tooltip-show');
11092
+ this.cleanupFloatingUi?.();
11093
+ this.cleanupFloatingUi = undefined;
11078
11094
  }
11079
11095
  get hostElement() { return getElement(this); }
11080
11096
  };