@aquera/nile-elements 0.1.33 → 0.1.34-beta-1.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.
- package/README.md +20 -6
- package/demo/index.css +7 -4
- package/demo/index.html +19 -35
- package/dist/{fixture-161dee0b.cjs.js → fixture-d5b55278.cjs.js} +3 -3
- package/dist/fixture-d5b55278.cjs.js.map +1 -0
- package/dist/{fixture-372df3b0.esm.js → fixture-df8b52d7.esm.js} +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/internal/animate.cjs.js +1 -1
- package/dist/internal/animate.cjs.js.map +1 -1
- package/dist/internal/animate.esm.js +1 -1
- package/dist/nile-accordion/nile-accordian.test.cjs.js +1 -1
- package/dist/nile-accordion/nile-accordian.test.esm.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
- package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
- package/dist/nile-avatar/nile-avatar.test.esm.js +1 -1
- package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
- package/dist/nile-badge/nile-badge.test.esm.js +1 -1
- package/dist/nile-button/nile-button.test.cjs.js +1 -1
- package/dist/nile-button/nile-button.test.esm.js +1 -1
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +1 -1
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.esm.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
- package/dist/nile-card/nile-card.test.cjs.js +1 -1
- package/dist/nile-card/nile-card.test.esm.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.esm.js +1 -1
- package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.test.esm.js +1 -1
- package/dist/nile-code-editor/extensionSetup.cjs.js +1 -1
- package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -1
- package/dist/nile-code-editor/extensionSetup.esm.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.esm.js +2 -2
- package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.test.esm.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.esm.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.test.cjs.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.test.esm.js +1 -1
- package/dist/nile-empty-state/nile-empty-state.test.cjs.js +1 -1
- package/dist/nile-empty-state/nile-empty-state.test.esm.js +1 -1
- package/dist/nile-error-message/nile-error-message.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.cjs.js.map +1 -1
- package/dist/nile-error-message/nile-error-message.css.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.css.cjs.js.map +1 -1
- package/dist/nile-error-message/nile-error-message.css.esm.js +6 -4
- package/dist/nile-error-message/nile-error-message.esm.js +4 -4
- package/dist/nile-error-message/nile-error-message.test.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.test.esm.js +1 -1
- package/dist/nile-error-notification/nile-error-notification.css.cjs.js +1 -1
- package/dist/nile-error-notification/nile-error-notification.css.cjs.js.map +1 -1
- package/dist/nile-error-notification/nile-error-notification.css.esm.js +1 -1
- package/dist/nile-form-group/nile-form-group.test.cjs.js +1 -1
- package/dist/nile-form-group/nile-form-group.test.esm.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
- package/dist/nile-hero/nile-hero.test.cjs.js +1 -1
- package/dist/nile-hero/nile-hero.test.esm.js +1 -1
- package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
- package/dist/nile-icon/nile-icon.test.esm.js +1 -1
- package/dist/nile-input/nile-input.css.cjs.js +1 -1
- package/dist/nile-input/nile-input.css.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.css.esm.js +8 -0
- package/dist/nile-input/nile-input.test.cjs.js +1 -1
- package/dist/nile-input/nile-input.test.esm.js +1 -1
- package/dist/nile-link/nile-link.test.cjs.js +1 -1
- package/dist/nile-link/nile-link.test.esm.js +1 -1
- package/dist/nile-loader/nile-loader.test.cjs.js +1 -1
- package/dist/nile-loader/nile-loader.test.esm.js +1 -1
- package/dist/nile-popover/nile-popover.test.cjs.js +1 -1
- package/dist/nile-popover/nile-popover.test.esm.js +1 -1
- package/dist/nile-popup/nile-popup.test.cjs.js +1 -1
- package/dist/nile-popup/nile-popup.test.esm.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.test.esm.js +1 -1
- package/dist/nile-radio/nile-radio.test.cjs.js +1 -1
- package/dist/nile-radio/nile-radio.test.esm.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.test.cjs.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.test.esm.js +1 -1
- package/dist/nile-select/nile-select.test.cjs.js +1 -1
- package/dist/nile-select/nile-select.test.esm.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.test.esm.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.esm.js +1 -1
- package/dist/nile-table/nile-table.cjs.js.map +1 -1
- package/dist/nile-textarea/nile-textarea.test.cjs.js +1 -1
- package/dist/nile-textarea/nile-textarea.test.esm.js +1 -1
- package/dist/nile-tooltip/index.cjs.js +1 -1
- package/dist/nile-tooltip/index.esm.js +1 -1
- package/dist/nile-tooltip/nile-tooltip-utils.cjs.js +2 -0
- package/dist/nile-tooltip/nile-tooltip-utils.cjs.js.map +1 -0
- package/dist/nile-tooltip/nile-tooltip-utils.esm.js +1 -0
- package/dist/nile-tooltip/nile-tooltip.cjs.js +1 -1
- package/dist/nile-tooltip/nile-tooltip.cjs.js.map +1 -1
- package/dist/nile-tooltip/nile-tooltip.css.cjs.js +1 -1
- package/dist/nile-tooltip/nile-tooltip.css.cjs.js.map +1 -1
- package/dist/nile-tooltip/nile-tooltip.css.esm.js +59 -56
- package/dist/nile-tooltip/nile-tooltip.esm.js +23 -28
- package/dist/nile-tooltip/nile-tooltip.test.cjs.js +2 -0
- package/dist/nile-tooltip/nile-tooltip.test.cjs.js.map +1 -0
- package/dist/nile-tooltip/nile-tooltip.test.esm.js +51 -0
- package/dist/src/nile-code-editor/extensionSetup.d.ts +2 -1
- package/dist/src/nile-code-editor/extensionSetup.js +8 -0
- package/dist/src/nile-code-editor/extensionSetup.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +1 -0
- package/dist/src/nile-code-editor/nile-code-editor.js +7 -2
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-error-message/nile-error-message.css.js +6 -4
- package/dist/src/nile-error-message/nile-error-message.css.js.map +1 -1
- package/dist/src/nile-error-message/nile-error-message.d.ts +4 -0
- package/dist/src/nile-error-message/nile-error-message.js +20 -0
- package/dist/src/nile-error-message/nile-error-message.js.map +1 -1
- package/dist/src/nile-error-notification/nile-error-notification.css.js +1 -1
- package/dist/src/nile-error-notification/nile-error-notification.css.js.map +1 -1
- package/dist/src/nile-input/nile-input.css.js +8 -0
- package/dist/src/nile-input/nile-input.css.js.map +1 -1
- package/dist/src/nile-table/nile-table.js.map +1 -1
- package/dist/src/nile-tooltip/nile-tooltip-utils.d.ts +18 -0
- package/dist/src/nile-tooltip/nile-tooltip-utils.js +151 -0
- package/dist/src/nile-tooltip/nile-tooltip-utils.js.map +1 -0
- package/dist/src/nile-tooltip/nile-tooltip.css.js +48 -45
- package/dist/src/nile-tooltip/nile-tooltip.css.js.map +1 -1
- package/dist/src/nile-tooltip/nile-tooltip.d.ts +23 -44
- package/dist/src/nile-tooltip/nile-tooltip.js +157 -227
- package/dist/src/nile-tooltip/nile-tooltip.js.map +1 -1
- package/dist/src/nile-tooltip/nile-tooltip.test.d.ts +1 -0
- package/dist/src/nile-tooltip/nile-tooltip.test.js +158 -0
- package/dist/src/nile-tooltip/nile-tooltip.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/nile-code-editor/extensionSetup.ts +13 -1
- package/src/nile-code-editor/nile-code-editor.ts +5 -2
- package/src/nile-error-message/nile-error-message.css.ts +6 -4
- package/src/nile-error-message/nile-error-message.ts +18 -0
- package/src/nile-error-notification/nile-error-notification.css.ts +1 -1
- package/src/nile-input/nile-input.css.ts +8 -0
- package/src/nile-table/nile-table.ts +2 -2
- package/src/nile-tooltip/nile-tooltip-utils.ts +190 -0
- package/src/nile-tooltip/nile-tooltip.css.ts +49 -46
- package/src/nile-tooltip/nile-tooltip.test.ts +178 -0
- package/src/nile-tooltip/nile-tooltip.ts +155 -237
- package/vscode-html-custom-data.json +100 -83
- 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
|
-
|
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
|
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' = '
|
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
|
-
|
93
|
-
|
94
|
-
|
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
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
|
-
|
108
|
-
|
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
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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
|
-
|
128
|
-
super.
|
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
|
-
|
138
|
-
|
139
|
-
|
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
|
-
|
144
|
-
|
145
|
-
|
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
|
-
|
154
|
-
|
155
|
-
this.show();
|
88
|
+
if (!validPlacements.includes(this.originalPlacement)) {
|
89
|
+
this.originalPlacement = 'bottom';
|
156
90
|
}
|
157
91
|
}
|
158
92
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
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
|
168
|
-
|
169
|
-
|
170
|
-
|
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
|
178
|
-
if (this.
|
179
|
-
|
180
|
-
|
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
|
-
|
188
|
-
const
|
189
|
-
|
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
|
-
|
193
|
-
|
194
|
-
|
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
|
-
|
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
|
-
|
203
|
-
|
204
|
-
|
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
|
-
|
213
|
-
|
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
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
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
|
-
|
236
|
-
|
237
|
-
|
238
|
-
this.
|
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
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
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
|
-
|
249
|
-
|
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
|
-
|
259
|
-
|
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
|
-
<
|
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
|
-
'
|
210
|
+
'tooltip__body--large': this.size === 'large',
|
273
211
|
})}
|
274
|
-
|
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
|
-
<
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
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
|
+
|