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

atinc / ngx-tethys / #102

26 May 2026 08:11AM UTC coverage: 91.111% (+0.7%) from 90.407%
#102

push

web-flow
build: bump docgeni to 2.8.0-next.5 (#3809)

4571 of 5491 branches covered (83.25%)

Branch coverage included in aggregate %.

13141 of 13949 relevant lines covered (94.21%)

966.75 hits per line

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

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

19
/**
20
 * @internal
21
 */
22
@Component({
23
    selector: 'thy-tooltip',
24
    templateUrl: './tooltip.component.html',
25
    encapsulation: ViewEncapsulation.None,
26
    changeDetection: ChangeDetectionStrategy.OnPush,
27
    host: {
28
        '[class.thy-scale-enter]': 'this.visibility() === "visible"',
29
        '[class.thy-scale-leave]': 'this.visibility() === "hidden"'
30
    },
31
    imports: [NgTemplateOutlet]
32
})
33
export class ThyTooltip implements OnInit {
34
    private changeDetectorRef = inject(ChangeDetectorRef);
35

1✔
36
    @HostBinding(`class.thy-tooltip`) addTooltipContainerClass = true;
24✔
37

38
    _content!: string | TemplateRef<HTMLElement>;
24✔
39

40
    data!: any;
41

42
    private readonly onHide = new Subject<void>();
43

44
    private hostRenderer = useHostRenderer();
24✔
45

46
    visibility = signal<ThyTooltipVisibility>('initial');
24✔
47

48
    showTimeoutId!: number | null | any;
24✔
49

50
    hideTimeoutId!: number | null | any;
24✔
51

52
    tooltipClasses: string[] = [];
53

54
    isTemplateRef = false;
55

56
    get content() {
24✔
57
        return this._content;
58
    }
24✔
59

60
    set content(value: string | TemplateRef<HTMLElement>) {
61
        this._content = value;
42✔
62
        this.isTemplateRef = value instanceof TemplateRef;
63
    }
64

65
    private updateClasses() {
25✔
66
        let classes: string[] = [];
25✔
67

68
        if (this.tooltipClasses) {
69
            classes = classes.concat(this.tooltipClasses);
70
        }
24✔
71

72
        this.hostRenderer.updateClass(classes);
24✔
73
    }
24✔
74

75
    ngOnInit() {}
76

24✔
77
    markForCheck(): void {
78
        this.changeDetectorRef.markForCheck();
79
    }
80

81
    isVisible() {
82
        return this.visibility() === 'visible';
77✔
83
    }
84

85
    show(delay: number): void {
86
        // Cancel the delayed hide if it is scheduled
63✔
87
        if (this.hideTimeoutId) {
88
            clearTimeout(this.hideTimeoutId);
89
            this.hideTimeoutId = null;
90
        }
91

24!
92
        // Body interactions should cancel the tooltip if there is a delay in showing.
×
93
        this.showTimeoutId = setTimeout(() => {
×
94
            this.visibility.set('visible');
95
            this.showTimeoutId = null;
96
            this.markForCheck();
97
        }, delay);
24✔
98
    }
24✔
99

22✔
100
    hide(delay: number): void {
22✔
101
        // Cancel the delayed show if it is scheduled
22✔
102
        if (this.showTimeoutId) {
103
            clearTimeout(this.showTimeoutId);
104
            this.showTimeoutId = null;
105
        }
106
        this.hideTimeoutId = setTimeout(() => {
107
            this.visibility.set('hidden');
30✔
108
            this.hideTimeoutId = null;
2✔
109
            this.markForCheck();
2✔
110
        }, delay);
111
    }
112

30✔
113
    @HostListener('transitionend', ['$event'])
30✔
114
    onTransitionEnd(event: TransitionEvent): void {
30✔
115
        if (event.propertyName === 'opacity' || event.propertyName === 'transform') {
30✔
116
            if (this.visibility() === 'hidden') {
117
                this.onHide.next();
118
            }
119
        }
120
    }
53✔
121

122
    afterHidden(): Observable<void> {
123
        return this.onHide.asObservable();
124
    }
53✔
125

53✔
126
    setTooltipClass(classes: string | string[]) {
9✔
127
        this.tooltipClasses = coerceArray(classes);
128
        this.updateClasses();
53✔
129
        // this.markForCheck();
27✔
130
    }
131
}
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

© 2026 Coveralls, Inc