• 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

8.7
/src/mention/suggestions/suggestions.component.ts
1
import { ThySelectionListChange, ThySelectionList } from 'ngx-tethys/list';
2
import { ThyPopoverRef } from 'ngx-tethys/popover';
3
import { Observable, of, Subject } from 'rxjs';
4
import { catchError, debounceTime, switchMap, take } from 'rxjs/operators';
5
import { Component, ElementRef, NgZone, OnDestroy, OnInit, inject, signal, input } from '@angular/core';
6
import { SeekQueryResult } from '../adapter/adapter';
7
import { Mention, MentionDefaultDataItem, MentionSuggestionSelectEvent } from '../interfaces';
8
import { ThyListOption } from 'ngx-tethys/shared';
9
import { ThyLoading } from 'ngx-tethys/loading';
10
import { NgTemplateOutlet, SlicePipe } from '@angular/common';
11

12
/**
13
 * @private
14
 */
15
@Component({
1✔
16
    selector: 'thy-mention-suggestions',
UNCOV
17
    templateUrl: './suggestions.component.html',
×
UNCOV
18
    imports: [NgTemplateOutlet, ThyLoading, ThySelectionList, ThyListOption, SlicePipe],
×
UNCOV
19
    host: { class: 'thy-mention-suggestions' }
×
UNCOV
20
})
×
UNCOV
21
export class ThyMentionSuggestions<TItem = MentionDefaultDataItem> implements OnInit, OnDestroy {
×
UNCOV
22
    readonly mention = input<Mention<TItem>>();
×
UNCOV
23

×
UNCOV
24
    data = signal<TItem[]>([]);
×
UNCOV
25

×
UNCOV
26
    suggestionSelect$ = new Subject<MentionSuggestionSelectEvent>();
×
27

UNCOV
28
    debounce = 150;
×
UNCOV
29

×
30
    loadingDone = signal(true);
×
31

×
32
    private search$ = new Subject<SeekQueryResult>();
33

UNCOV
34
    private elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
×
35

36
    private ngZone = inject(NgZone);
37

×
38
    private popoverRef = inject<ThyPopoverRef<any>>(ThyPopoverRef);
×
39

40
    constructor() {
UNCOV
41
        this.search$
×
UNCOV
42
            .pipe(
×
UNCOV
43
                switchMap(query => {
×
UNCOV
44
                    const data = this.mention().search(query.term, this.mention().data);
×
45
                    if (data instanceof Observable) {
×
46
                        this.loadingDone.set(false);
UNCOV
47
                        return (data as Observable<TItem[]>).pipe(debounceTime(this.debounce));
×
UNCOV
48
                    } else {
×
49
                        return of(data as TItem[]);
50
                    }
51
                }),
52
                catchError(() => {
53
                    this.loadingDone.set(false);
UNCOV
54
                    return of([]);
×
55
                })
×
56
            )
57
            .subscribe(data => {
58
                this.loadingDone.set(true);
UNCOV
59
                this.data.set(data || []);
×
60

61
                if (this.popoverRef) {
UNCOV
62
                    if (this.mention().autoClose && this.data().length === 0) {
×
63
                        this.popoverRef.close();
64
                    }
UNCOV
65
                    this.ngZone.onStable.pipe(take(1)).subscribe(() => {
×
66
                        this.popoverRef.updatePosition();
67
                    });
UNCOV
68
                }
×
69
            });
70
    }
1✔
71

1✔
72
    ngOnInit(): void {
73
        if (this.mention().popoverClass) {
74
            this.elementRef.nativeElement.classList.add(this.mention().popoverClass);
75
        }
1✔
76
    }
77

78
    search(query: SeekQueryResult) {
79
        this.search$.next(query);
80
    }
81

82
    select(item: TItem, event: Event) {
83
        this.suggestionSelect$.next({ event, item });
84
    }
85

86
    selectionChange(event: ThySelectionListChange<TItem>) {
87
        this.select(event.value, event.event);
88
    }
89

90
    ngOnDestroy() {
91
        this.search$.complete();
92
    }
93
}
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