• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / edbc1d43-1648-411a-a6bc-f24c9aa3f654

27 Mar 2025 06:13AM UTC coverage: 90.236% (+0.06%) from 90.179%
edbc1d43-1648-411a-a6bc-f24c9aa3f654

push

circleci

web-flow
Merge pull request #3282 from atinc/v19.0.0-next

5598 of 6865 branches covered (81.54%)

Branch coverage included in aggregate %.

8 of 8 new or added lines in 7 files covered. (100.0%)

157 existing lines in 46 files now uncovered.

13357 of 14141 relevant lines covered (94.46%)

992.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.1
/src/tooltip/tooltip.component.ts
1
import {
2
    Component,
3
    ViewEncapsulation,
4
    ChangeDetectionStrategy,
5
    ChangeDetectorRef,
6
    HostBinding,
7
    TemplateRef,
8
    OnInit,
9
    inject
10
} from '@angular/core';
11
import { Observable, Subject } from 'rxjs';
12
import { AnimationEvent } from '@angular/animations';
1✔
13
import { useHostRenderer } from '@tethys/cdk/dom';
14
import { ThyTooltipVisibility } from './interface';
24✔
15
import { thyTooltipAnimations } from './tooltip-animations';
24✔
16
import { coerceArray } from 'ngx-tethys/util';
24✔
17
import { NgTemplateOutlet } from '@angular/common';
24✔
18

24✔
19
/**
24✔
20
 * @internal
24✔
21
 */
24✔
22
@Component({
23
    selector: 'thy-tooltip',
24
    templateUrl: './tooltip.component.html',
41✔
25
    encapsulation: ViewEncapsulation.None,
26
    changeDetection: ChangeDetectionStrategy.OnPush,
27
    animations: [thyTooltipAnimations.tooltipState],
25✔
28
    host: {
25✔
29
        '[@state]': 'visibility',
30
        '(@state.start)': 'animationStart()',
31
        '(@state.done)': 'animationDone($event)'
24✔
32
    },
24!
33
    imports: [NgTemplateOutlet]
24✔
34
})
35
export class ThyTooltip implements OnInit {
24✔
36
    private changeDetectorRef = inject(ChangeDetectorRef);
37

38
    @HostBinding(`class.thy-tooltip`) addTooltipContainerClass = true;
39

77✔
40
    _content: string | TemplateRef<HTMLElement>;
41

42
    data: any;
63✔
43

44
    private readonly onHide: Subject<void> = new Subject();
45

46
    private closeOnInteraction = false;
24!
47

×
UNCOV
48
    private hostRenderer = useHostRenderer();
×
49

50
    visibility: ThyTooltipVisibility = 'initial';
51

24✔
52
    showTimeoutId: number | null | any;
24✔
53

22✔
54
    hideTimeoutId: number | null | any;
22✔
55

22✔
56
    tooltipClasses: string[] = [];
57

58
    isTemplateRef = false;
59

60
    get content() {
30✔
61
        return this._content;
2✔
62
    }
2✔
63

64
    set content(value: string | TemplateRef<HTMLElement>) {
30✔
65
        this._content = value;
30✔
66
        this.isTemplateRef = value instanceof TemplateRef;
30✔
67
    }
30✔
68

69
    private updateClasses() {
70
        let classes: string[] = [];
71

53✔
72
        if (this.tooltipClasses) {
73
            classes = classes.concat(this.tooltipClasses);
74
        }
53✔
75

53✔
76
        this.hostRenderer.updateClass(classes);
9✔
77
    }
78

53✔
79
    ngOnInit() {}
26✔
80

81
    markForCheck(): void {
82
        this.changeDetectorRef.markForCheck();
83
    }
24✔
84

85
    isVisible() {
86
        return this.visibility === 'visible';
24✔
87
    }
24✔
88

89
    show(delay: number): void {
90
        // Cancel the delayed hide if it is scheduled
1✔
91
        if (this.hideTimeoutId) {
92
            clearTimeout(this.hideTimeoutId);
93
            this.hideTimeoutId = null;
94
        }
1✔
95

96
        // Body interactions should cancel the tooltip if there is a delay in showing.
97
        this.closeOnInteraction = true;
98
        this.showTimeoutId = setTimeout(() => {
99
            this.visibility = 'visible';
100
            this.showTimeoutId = null;
101
            this.markForCheck();
102
        }, delay);
103
    }
104

105
    hide(delay: number): void {
106
        // Cancel the delayed show if it is scheduled
107
        if (this.showTimeoutId) {
108
            clearTimeout(this.showTimeoutId);
109
            this.showTimeoutId = null;
110
        }
111

112
        this.hideTimeoutId = setTimeout(() => {
113
            this.visibility = 'hidden';
114
            this.hideTimeoutId = null;
115
            this.markForCheck();
116
        }, delay);
117
    }
118

119
    animationStart() {
120
        this.closeOnInteraction = false;
121
    }
122

123
    animationDone(event: AnimationEvent): void {
124
        const toState = event.toState as ThyTooltipVisibility;
125
        if (toState === 'hidden' && !this.isVisible()) {
126
            this.onHide.next();
127
        }
128
        if (toState === 'visible' || toState === 'hidden') {
129
            this.closeOnInteraction = true;
130
        }
131
    }
132

133
    afterHidden(): Observable<void> {
134
        return this.onHide.asObservable();
135
    }
136

137
    setTooltipClass(classes: string | string[]) {
138
        this.tooltipClasses = coerceArray(classes);
139
        this.updateClasses();
140
        // this.markForCheck();
141
    }
142
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc