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