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

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

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

5.17
/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';
UNCOV
14
import { ThyTooltipVisibility } from './interface';
×
UNCOV
15
import { thyTooltipAnimations } from './tooltip-animations';
×
UNCOV
16
import { coerceArray } from 'ngx-tethys/util';
×
UNCOV
17
import { NgTemplateOutlet } from '@angular/common';
×
UNCOV
18

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

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

×
40
    _content: string | TemplateRef<HTMLElement>;
41

UNCOV
42
    data: any;
×
43

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

UNCOV
46
    private closeOnInteraction = false;
×
47

×
48
    private hostRenderer = useHostRenderer();
×
49

50
    visibility: ThyTooltipVisibility = 'initial';
UNCOV
51

×
UNCOV
52
    showTimeoutId: number | null | any;
×
UNCOV
53

×
UNCOV
54
    hideTimeoutId: number | null | any;
×
UNCOV
55

×
56
    tooltipClasses: string[] = [];
57

58
    isTemplateRef = false;
59

UNCOV
60
    get content() {
×
UNCOV
61
        return this._content;
×
UNCOV
62
    }
×
63

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

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

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

×
UNCOV
76
        this.hostRenderer.updateClass(classes);
×
77
    }
UNCOV
78

×
UNCOV
79
    ngOnInit() {}
×
80

81
    markForCheck(): void {
82
        this.changeDetectorRef.markForCheck();
UNCOV
83
    }
×
84

85
    isVisible() {
UNCOV
86
        return this.visibility === 'visible';
×
UNCOV
87
    }
×
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