@aquera/nile-elements 0.1.32-beta-1.3 → 0.1.32-beta-1.5

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.
Files changed (107) hide show
  1. package/README.md +7 -0
  2. package/demo/index.html +262 -27
  3. package/demo/variables.css +17 -0
  4. package/demo/variables_v2.css +17 -0
  5. package/dist/{fixture-161dee0b.cjs.js → fixture-d5b55278.cjs.js} +3 -3
  6. package/dist/fixture-d5b55278.cjs.js.map +1 -0
  7. package/dist/{fixture-372df3b0.esm.js → fixture-df8b52d7.esm.js} +1 -1
  8. package/dist/index.cjs.js +1 -1
  9. package/dist/index.esm.js +1 -1
  10. package/dist/internal/animate.cjs.js +1 -1
  11. package/dist/internal/animate.cjs.js.map +1 -1
  12. package/dist/internal/animate.esm.js +1 -1
  13. package/dist/nile-accordion/nile-accordian.test.cjs.js +1 -1
  14. package/dist/nile-accordion/nile-accordian.test.esm.js +1 -1
  15. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
  16. package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
  17. package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
  18. package/dist/nile-avatar/nile-avatar.test.esm.js +1 -1
  19. package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
  20. package/dist/nile-badge/nile-badge.test.esm.js +1 -1
  21. package/dist/nile-button/nile-button.test.cjs.js +1 -1
  22. package/dist/nile-button/nile-button.test.esm.js +1 -1
  23. package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +1 -1
  24. package/dist/nile-button-toggle-group/nile-button-toggle-group.test.esm.js +1 -1
  25. package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
  26. package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
  27. package/dist/nile-card/nile-card.test.cjs.js +1 -1
  28. package/dist/nile-card/nile-card.test.esm.js +1 -1
  29. package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -1
  30. package/dist/nile-checkbox/nile-checkbox.test.esm.js +1 -1
  31. package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
  32. package/dist/nile-chip/nile-chip.test.esm.js +1 -1
  33. package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
  34. package/dist/nile-dialog/nile-dialog.test.esm.js +1 -1
  35. package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
  36. package/dist/nile-drawer/nile-drawer.test.esm.js +1 -1
  37. package/dist/nile-dropdown/nile-dropdown.test.cjs.js +1 -1
  38. package/dist/nile-dropdown/nile-dropdown.test.esm.js +1 -1
  39. package/dist/nile-empty-state/nile-empty-state.test.cjs.js +1 -1
  40. package/dist/nile-empty-state/nile-empty-state.test.esm.js +1 -1
  41. package/dist/nile-error-message/nile-error-message.test.cjs.js +1 -1
  42. package/dist/nile-error-message/nile-error-message.test.esm.js +1 -1
  43. package/dist/nile-form-group/nile-form-group.test.cjs.js +1 -1
  44. package/dist/nile-form-group/nile-form-group.test.esm.js +1 -1
  45. package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
  46. package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
  47. package/dist/nile-hero/nile-hero.test.cjs.js +1 -1
  48. package/dist/nile-hero/nile-hero.test.esm.js +1 -1
  49. package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
  50. package/dist/nile-icon/nile-icon.test.esm.js +1 -1
  51. package/dist/nile-input/nile-input.test.cjs.js +1 -1
  52. package/dist/nile-input/nile-input.test.esm.js +1 -1
  53. package/dist/nile-link/nile-link.test.cjs.js +1 -1
  54. package/dist/nile-link/nile-link.test.esm.js +1 -1
  55. package/dist/nile-loader/nile-loader.test.cjs.js +1 -1
  56. package/dist/nile-loader/nile-loader.test.esm.js +1 -1
  57. package/dist/nile-popover/nile-popover.test.cjs.js +1 -1
  58. package/dist/nile-popover/nile-popover.test.esm.js +1 -1
  59. package/dist/nile-popup/nile-popup.test.cjs.js +1 -1
  60. package/dist/nile-popup/nile-popup.test.esm.js +1 -1
  61. package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +1 -1
  62. package/dist/nile-progress-bar/nile-progress-bar.test.esm.js +1 -1
  63. package/dist/nile-radio/nile-radio.test.cjs.js +1 -1
  64. package/dist/nile-radio/nile-radio.test.esm.js +1 -1
  65. package/dist/nile-radio-group/nile-radio-group.test.cjs.js +1 -1
  66. package/dist/nile-radio-group/nile-radio-group.test.esm.js +1 -1
  67. package/dist/nile-select/nile-select.test.cjs.js +1 -1
  68. package/dist/nile-select/nile-select.test.esm.js +1 -1
  69. package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +1 -1
  70. package/dist/nile-slide-toggle/nile-slide-toggle.test.esm.js +1 -1
  71. package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
  72. package/dist/nile-tab-group/nile-tab-group.test.esm.js +1 -1
  73. package/dist/nile-textarea/nile-textarea.test.cjs.js +1 -1
  74. package/dist/nile-textarea/nile-textarea.test.esm.js +1 -1
  75. package/dist/nile-tooltip/index.cjs.js +1 -1
  76. package/dist/nile-tooltip/index.esm.js +1 -1
  77. package/dist/nile-tooltip/nile-tooltip-utils.cjs.js +2 -0
  78. package/dist/nile-tooltip/nile-tooltip-utils.cjs.js.map +1 -0
  79. package/dist/nile-tooltip/nile-tooltip-utils.esm.js +1 -0
  80. package/dist/nile-tooltip/nile-tooltip.cjs.js +1 -1
  81. package/dist/nile-tooltip/nile-tooltip.cjs.js.map +1 -1
  82. package/dist/nile-tooltip/nile-tooltip.css.cjs.js +1 -1
  83. package/dist/nile-tooltip/nile-tooltip.css.cjs.js.map +1 -1
  84. package/dist/nile-tooltip/nile-tooltip.css.esm.js +59 -56
  85. package/dist/nile-tooltip/nile-tooltip.esm.js +23 -28
  86. package/dist/nile-tooltip/nile-tooltip.test.cjs.js +2 -0
  87. package/dist/nile-tooltip/nile-tooltip.test.cjs.js.map +1 -0
  88. package/dist/nile-tooltip/nile-tooltip.test.esm.js +51 -0
  89. package/dist/src/nile-tooltip/nile-tooltip-utils.d.ts +18 -0
  90. package/dist/src/nile-tooltip/nile-tooltip-utils.js +151 -0
  91. package/dist/src/nile-tooltip/nile-tooltip-utils.js.map +1 -0
  92. package/dist/src/nile-tooltip/nile-tooltip.css.js +48 -45
  93. package/dist/src/nile-tooltip/nile-tooltip.css.js.map +1 -1
  94. package/dist/src/nile-tooltip/nile-tooltip.d.ts +23 -44
  95. package/dist/src/nile-tooltip/nile-tooltip.js +157 -227
  96. package/dist/src/nile-tooltip/nile-tooltip.js.map +1 -1
  97. package/dist/src/nile-tooltip/nile-tooltip.test.d.ts +1 -0
  98. package/dist/src/nile-tooltip/nile-tooltip.test.js +158 -0
  99. package/dist/src/nile-tooltip/nile-tooltip.test.js.map +1 -0
  100. package/dist/tsconfig.tsbuildinfo +1 -1
  101. package/package.json +1 -1
  102. package/src/nile-tooltip/nile-tooltip-utils.ts +190 -0
  103. package/src/nile-tooltip/nile-tooltip.css.ts +49 -46
  104. package/src/nile-tooltip/nile-tooltip.test.ts +178 -0
  105. package/src/nile-tooltip/nile-tooltip.ts +155 -237
  106. package/vscode-html-custom-data.json +81 -81
  107. package/dist/fixture-161dee0b.cjs.js.map +0 -1
@@ -4,58 +4,25 @@
4
4
  * This source code is licensed under the BSD-3-Clause license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
-
8
- import { LitElement, CSSResultArray, TemplateResult } from 'lit';
9
- import { styles } from './nile-tooltip.css';
10
- import '../nile-popup/nile-popup';
11
- import { animateTo, parseDuration, stopAnimations } from '../internal/animate';
12
- import { classMap } from 'lit/directives/class-map.js';
7
+ import { LitElement, html, css, CSSResultArray } from 'lit';
13
8
  import { customElement, property, query } from 'lit/decorators.js';
14
- import {
15
- getAnimation,
16
- setDefaultAnimation,
17
- } from '../utilities/animation-registry';
18
- import { html } from 'lit';
19
- // import { LocalizeController } from '../utilities/localize';
20
- import { waitForEvent } from '../internal/event';
21
- import { watch } from '../internal/watch';
9
+ import { classMap } from 'lit/directives/class-map.js';
10
+ import { styles } from './nile-tooltip.css';
22
11
  import NileElement from '../internal/nile-element';
23
- import type { CSSResultGroup } from 'lit';
24
- import type NilePopup from '../nile-popup/nile-popup';
12
+ import { isInViewport, getValidTooltipPosition, getCaretPosition } from './nile-tooltip-utils';
25
13
  /**
26
14
  * Nile icon component.
27
15
  *
28
16
  * @tag nile-tooltip
29
17
  *
30
18
  */
19
+
31
20
  @customElement('nile-tooltip')
32
21
  export class NileTooltip extends NileElement {
33
- /**
34
- * The styles for Tooltip
35
- * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
36
- */
37
- public static get styles(): CSSResultArray {
38
- return [styles];
39
- }
40
-
41
- private hoverTimeout: number;
42
- // private readonly localize = new LocalizeController(this);
43
-
44
- @query('slot:not([name])') defaultSlot: HTMLSlotElement;
45
- @query('.tooltip__body') body: HTMLElement;
46
- @query('nile-popup') popup: NilePopup;
47
-
48
- /** The tooltip's content. If you need to display HTML, use the `content` slot instead. */
49
- @property({ type: String, reflect: true }) content = '';
50
-
51
- /** Size Property to decide the tool tip size */
22
+ @property({ type: String }) content = '';
52
23
  @property({ reflect: true }) size: 'small' | 'large' = 'small';
53
-
54
- /**
55
- * The preferred placement of the tooltip. Note that the actual placement may vary as needed to keep the tooltip
56
- * inside of the viewport.
57
- */
58
- @property() placement:
24
+ @property({ type: String })
25
+ placement:
59
26
  | 'top'
60
27
  | 'top-start'
61
28
  | 'top-end'
@@ -67,258 +34,209 @@ export class NileTooltip extends NileElement {
67
34
  | 'bottom-end'
68
35
  | 'left'
69
36
  | 'left-start'
70
- | 'left-end' = 'top';
71
-
72
- /** Disables the tooltip so it won't show when triggered. */
37
+ | 'left-end' = 'bottom';
73
38
  @property({ type: Boolean, reflect: true }) disabled = false;
74
-
75
- /** The distance in pixels from which to offset the tooltip away from its target. */
76
- @property({ type: Number }) distance = 8;
77
-
78
- /** Indicates whether or not the tooltip is open. You can use this in lieu of the show/hide methods. */
79
39
  @property({ type: Boolean, reflect: true }) open = false;
80
-
81
- /** The distance in pixels from which to offset the tooltip along its target. */
82
- @property({ type: Number }) skidding = 0;
83
-
84
40
  /**
85
41
  * Controls how the tooltip is activated. Possible options include `click`, `hover`, `focus`, and `manual`. Multiple
86
42
  * options can be passed by separating them with a space. When manual is used, the tooltip must be activated
87
43
  * programmatically.
88
44
  */
89
- @property() trigger = 'hover focus';
45
+ @property() trigger = 'hover focus';
46
+ @property({ type: Number }) distance = 8;
47
+ private readonly SHIFT_OFFSET = 16;
48
+ /** The distance in pixels from which to offset the tooltip along its target. */
49
+ @property({ type: Number }) skidding = 0;
50
+ @property({ type: Boolean, reflect: true }) hoist = false;
90
51
 
91
- /**
92
- * Enable this option to prevent the tooltip from being clipped when the component is placed inside a container with
93
- * `overflow: auto|hidden|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all,
94
- * scenarios.
95
- */
96
- @property({ type: Boolean }) hoist = false;
52
+ @query('.tooltip') tooltip!: HTMLElement;
53
+ @query('.trigger-container') triggerContainer!: HTMLElement;
54
+ @query('.tooltip-caret') caret!: HTMLElement;
55
+ @query('slot[name="content"]') tooltipSlot!: HTMLSlotElement;
97
56
 
98
- connectedCallback() {
99
- super.connectedCallback();
100
- this.handleBlur = this.handleBlur.bind(this);
101
- this.handleClick = this.handleClick.bind(this);
102
- this.handleFocus = this.handleFocus.bind(this);
103
- this.handleKeyDown = this.handleKeyDown.bind(this);
104
- this.handleMouseOver = this.handleMouseOver.bind(this);
105
- this.handleMouseOut = this.handleMouseOut.bind(this);
57
+ private hasTooltipSlot = false;
58
+ private hoverTimeout: number = 0;
59
+ private caretSize = 6;
60
+ private originalPlacement: string = this.placement;
106
61
 
107
- this.updateComplete.then(() => {
108
- this.addEventListener('blur', this.handleBlur, true);
109
- this.addEventListener('focus', this.handleFocus, true);
110
- this.addEventListener('click', this.handleClick);
111
- this.addEventListener('keydown', this.handleKeyDown);
112
- this.addEventListener('mouseover', this.handleMouseOver);
113
- this.addEventListener('mouseout', this.handleMouseOut);
114
- });
62
+ public static get styles(): CSSResultArray {
63
+ return [styles];
115
64
  }
116
65
 
117
- firstUpdated() {
118
- this.body.hidden = !this.open;
119
-
120
- // If the tooltip is visible on init, update its position
121
- if (this.open) {
122
- this.popup.active = true;
123
- this.popup.reposition();
124
- }
66
+ connectedCallback() {
67
+ super.connectedCallback();
68
+ this.originalPlacement = this.placement;
69
+ window.addEventListener('resize', this.updateTooltipPosition);
70
+ window.addEventListener('scroll', this.updateTooltipPosition, true);
125
71
  }
126
72
 
127
- disconnectedCallback() {
128
- super.disconnectedCallback();
129
- this.removeEventListener('blur', this.handleBlur, true);
130
- this.removeEventListener('focus', this.handleFocus, true);
131
- this.removeEventListener('click', this.handleClick);
132
- this.removeEventListener('keydown', this.handleKeyDown);
133
- this.removeEventListener('mouseover', this.handleMouseOver);
134
- this.removeEventListener('mouseout', this.handleMouseOut);
135
- }
73
+ updated(changedProps: Map<string, unknown>) {
74
+ super.updated?.(changedProps);
136
75
 
137
- private handleBlur() {
138
- if (this.hasTrigger('focus')) {
139
- this.hide();
140
- }
141
- }
76
+ const validPlacements = [
77
+ 'top', 'top-start', 'top-end',
78
+ 'right', 'right-start', 'right-end',
79
+ 'bottom', 'bottom-start', 'bottom-end',
80
+ 'left', 'left-start', 'left-end'
81
+ ];
142
82
 
143
- private handleClick() {
144
- if (this.hasTrigger('click')) {
145
- if (this.open) {
146
- this.hide();
147
- } else {
148
- this.show();
149
- }
83
+ if (!validPlacements.includes(this.placement)) {
84
+ console.warn(`[nile-tooltip] Invalid placement "${this.placement}", defaulting to "bottom".`);
85
+ this.placement = 'bottom';
150
86
  }
151
- }
152
87
 
153
- private handleFocus() {
154
- if (this.hasTrigger('focus')) {
155
- this.show();
88
+ if (!validPlacements.includes(this.originalPlacement)) {
89
+ this.originalPlacement = 'bottom';
156
90
  }
157
91
  }
158
92
 
159
- private handleKeyDown(event: KeyboardEvent) {
160
- // Pressing escape when the target element has focus should dismiss the tooltip
161
- if (this.open && event.key === 'Escape') {
162
- event.stopPropagation();
163
- this.hide();
164
- }
93
+ disconnectedCallback() {
94
+ super.disconnectedCallback();
95
+ window.removeEventListener('resize', this.updateTooltipPosition);
96
+ window.removeEventListener('scroll', this.updateTooltipPosition, true);
165
97
  }
166
98
 
167
- private handleMouseOver() {
168
- if (this.hasTrigger('hover')) {
169
- const delay = parseDuration(
170
- getComputedStyle(this).getPropertyValue('--show-delay')
171
- );
172
- clearTimeout(this.hoverTimeout);
173
- this.hoverTimeout = window.setTimeout(() => this.show(), delay);
174
- }
99
+ private handleTooltipSlotChange() {
100
+ const nodes = this.tooltipSlot.assignedNodes({ flatten: true });
101
+ this.hasTooltipSlot = nodes.length > 0;
102
+ this.requestUpdate();
175
103
  }
176
104
 
177
- private handleMouseOut() {
178
- if (this.hasTrigger('hover')) {
179
- const delay = parseDuration(
180
- getComputedStyle(this).getPropertyValue('--hide-delay')
181
- );
182
- clearTimeout(this.hoverTimeout);
183
- this.hoverTimeout = window.setTimeout(() => this.hide(), delay);
105
+ private updateTooltipPosition = () => {
106
+ if (!isInViewport(this.triggerContainer)) {
107
+ this.open = false;
108
+ return;
184
109
  }
185
- }
186
110
 
187
- private hasTrigger(triggerType: string) {
188
- const triggers = this.trigger.split(' ');
189
- return triggers.includes(triggerType);
190
- }
111
+ const triggerRect = this.triggerContainer.getBoundingClientRect();
112
+ const tooltipRect = this.tooltip.getBoundingClientRect();
113
+ const viewportWidth = window.innerWidth;
114
+ const viewportHeight = window.innerHeight;
115
+
116
+ const { top, left, placement } = getValidTooltipPosition(
117
+ triggerRect,
118
+ tooltipRect,
119
+ this.originalPlacement,
120
+ this.distance,
121
+ this.skidding,
122
+ this.caretSize,
123
+ viewportWidth,
124
+ viewportHeight
125
+ );
126
+
127
+ this.setAttribute('placement', placement);
128
+ this.tooltip.style.top = `${top}px`;
129
+ this.tooltip.style.left = `${left}px`;
130
+
131
+ const { caretLeft, caretTop } = getCaretPosition({
132
+ placement,
133
+ tooltipRect,
134
+ triggerRect,
135
+ caretSize: this.caretSize,
136
+ left,
137
+ top
138
+ });
191
139
 
192
- @watch('open', { waitUntilFirstUpdate: true })
193
- async handleOpenChange() {
194
- if (this.open) {
195
- if (this.disabled) {
196
- return;
197
- }
140
+ this.caret.style.left = `${caretLeft}px`;
141
+ this.caret.style.top = `${caretTop}px`;
142
+ };
198
143
 
199
- // Show
144
+ private showTooltip = () => {
145
+ const trimmedContent = this.content.trim();
146
+ if (!trimmedContent && !this.hasTooltipSlot) {
147
+ return;
148
+ }
149
+ if (!this.disabled && isInViewport(this.triggerContainer)) {
200
150
  this.emit('nile-show');
201
-
202
- await stopAnimations(this.body);
203
- this.body.hidden = false;
204
- this.popup.active = true;
205
- const { keyframes, options } = getAnimation(this, 'tooltip.show', {
206
- dir: '',
151
+ this.open = true;
152
+ this.updateComplete.then(() => {
153
+ this.updateTooltipPosition();
154
+ this.emit('nile-after-show');
207
155
  });
208
- await animateTo(this.popup.popup, keyframes, options);
209
-
210
- this.emit('nile-after-show');
211
156
  } else {
212
- // Hide
213
- this.emit('nile-hide');
214
-
215
- await stopAnimations(this.body);
216
- const { keyframes, options } = getAnimation(this, 'tooltip.hide', {
217
- dir: '',
218
- });
219
- await animateTo(this.popup.popup, keyframes, options);
220
- this.popup.active = false;
221
- this.body.hidden = true;
157
+ this.open = false;
158
+ }
159
+ };
222
160
 
161
+ private hideTooltip = () => {
162
+ this.emit('nile-hide');
163
+ this.open = false;
164
+ setTimeout(() => {
223
165
  this.emit('nile-after-hide');
224
- }
225
- }
166
+ }, 200);
167
+ };
226
168
 
227
- @watch(['content', 'distance', 'hoist', 'placement', 'skidding'])
228
- async handleOptionsChange() {
229
- if (this.hasUpdated) {
230
- await this.updateComplete;
231
- this.popup.reposition();
169
+ private handleMouseOver = () => {
170
+ if (this.trigger.includes('hover')) {
171
+ clearTimeout(this.hoverTimeout);
172
+ this.hoverTimeout = window.setTimeout(() => this.showTooltip(), 150);
232
173
  }
233
- }
174
+ };
234
175
 
235
- @watch('disabled')
236
- handleDisabledChange() {
237
- if (this.disabled && this.open) {
238
- this.hide();
176
+ private handleMouseOut = () => {
177
+ if (this.trigger.includes('hover')) {
178
+ clearTimeout(this.hoverTimeout);
179
+ this.hoverTimeout = window.setTimeout(() => this.hideTooltip(), 0);
239
180
  }
240
- }
181
+ };
241
182
 
242
- /** Shows the tooltip. */
243
- async show() {
244
- if (this.open || !this.content?.trim().length) {
245
- return undefined;
183
+ private handleClick = () => {
184
+ if (this.trigger.includes('click')) {
185
+ if (!this.open && isInViewport(this.triggerContainer)) {
186
+ this.showTooltip();
187
+ } else {
188
+ this.hideTooltip();
189
+ }
246
190
  }
191
+ };
247
192
 
248
- this.open = true;
249
- return waitForEvent(this, 'nile-after-show');
250
- }
251
-
252
- /** Hides the tooltip */
253
- async hide() {
254
- if (!this.open) {
255
- return undefined;
193
+ private handleFocus = () => {
194
+ if (this.trigger.includes('focus')) {
195
+ this.showTooltip();
256
196
  }
197
+ };
257
198
 
258
- this.open = false;
259
- return waitForEvent(this, 'nile-after-hide');
260
- }
199
+ private handleBlur = () => {
200
+ if (this.trigger.includes('focus')) {
201
+ this.hideTooltip();
202
+ }
203
+ };
261
204
 
262
205
  render() {
263
206
  return html`
264
- <nile-popup
265
- part="base"
266
- exportparts="
267
- popup:base__popup,
268
- arrow:base__arrow
269
- "
207
+ <div
270
208
  class=${classMap({
271
209
  tooltip: true,
272
- 'tooltip--open': this.open,
210
+ 'tooltip__body--large': this.size === 'large',
273
211
  })}
274
- placement=${this.placement}
275
- distance=${this.distance}
276
- skidding=${this.skidding}
277
- strategy=${this.hoist ? 'fixed' : 'absolute'}
278
- flip
279
- shift
280
- arrow
212
+ id="tooltip"
281
213
  >
282
- <slot slot="anchor" aria-describedby="tooltip"></slot>
283
-
284
- <slot
285
- name="content"
286
- part="body"
287
- id="tooltip"
288
- class=${classMap({
289
- tooltip__body: true,
290
- 'tooltip__body--large': this.size === 'large',
291
- })}
292
- role="tooltip"
293
- aria-live=${this.open ? 'polite' : 'off'}
294
- >
295
- ${this.content}
296
- </slot>
297
- </nile-popup>
214
+ <div class="tooltip-content" part="content">
215
+ <slot name="content" @slotchange=${this.handleTooltipSlotChange}></slot>
216
+ ${!this.hasTooltipSlot ? html`${this.content}` : null}
217
+ </div>
218
+ <div class="tooltip-caret" style="--caret-size: ${this.caretSize}px;"></div>
219
+ </div>
220
+
221
+ <div
222
+ class="trigger-container"
223
+ tabindex="0"
224
+ @mouseover=${this.handleMouseOver}
225
+ @mouseout=${this.handleMouseOut}
226
+ @click=${this.handleClick}
227
+ @focusin=${this.handleFocus}
228
+ @focusout=${this.handleBlur}
229
+ aria-describedby="tooltip"
230
+ >
231
+ <slot></slot>
232
+ </div>
298
233
  `;
299
234
  }
300
235
  }
301
236
 
302
- setDefaultAnimation('tooltip.show', {
303
- keyframes: [
304
- { opacity: 0, scale: 0.8 },
305
- { opacity: 1, scale: 1 },
306
- ],
307
- options: { duration: 150, easing: 'ease' },
308
- });
309
-
310
- setDefaultAnimation('tooltip.hide', {
311
- keyframes: [
312
- { opacity: 1, scale: 1 },
313
- { opacity: 0, scale: 0.8 },
314
- ],
315
- options: { duration: 150, easing: 'ease' },
316
- });
317
-
318
- export default NileTooltip;
319
-
320
237
  declare global {
321
238
  interface HTMLElementTagNameMap {
322
239
  'nile-tooltip': NileTooltip;
323
240
  }
324
241
  }
242
+