• 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

9.09
/src/shared/option/group/option-group.component.ts
1
import {
2
    Component,
3
    HostBinding,
4
    Input,
5
    ContentChildren,
6
    QueryList,
7
    NgZone,
8
    OnDestroy,
9
    AfterContentInit,
10
    ChangeDetectorRef,
11
    inject
1✔
12
} from '@angular/core';
UNCOV
13
import { Observable, defer, Subject, merge } from 'rxjs';
×
UNCOV
14
import { ThyOptionVisibleChangeEvent, ThyOption } from '../option.component';
×
UNCOV
15
import { take, switchMap, startWith, takeUntil, debounceTime, map } from 'rxjs/operators';
×
UNCOV
16
import { coerceBooleanProperty } from 'ngx-tethys/util';
×
UNCOV
17

×
UNCOV
18
/**
×
19
 * @private
×
20
 */
×
21
@Component({
22
    selector: 'thy-option-group',
×
23
    templateUrl: './option-group.component.html'
24
})
25
export class ThySelectOptionGroup implements OnDestroy, AfterContentInit {
UNCOV
26
    private _ngZone = inject(NgZone);
×
27
    private cdr = inject(ChangeDetectorRef);
28

UNCOV
29
    _hidden = false;
×
UNCOV
30
    @Input({ transform: coerceBooleanProperty })
×
31
    @HostBinding(`class.disabled`)
32
    thyDisabled: boolean;
33

UNCOV
34
    @HostBinding('class.thy-option-item-group') _isOptionGroup = true;
×
UNCOV
35

×
36
    @HostBinding('class.thy-select-option-group-hidden')
UNCOV
37
    get hidden(): boolean {
×
UNCOV
38
        return this._hidden;
×
UNCOV
39
    }
×
40

41
    @Input() thyGroupLabel: string;
UNCOV
42

×
UNCOV
43
    @ContentChildren(ThyOption) options: QueryList<ThyOption>;
×
44

45
    _destroy$: Subject<void> = new Subject<void>();
UNCOV
46

×
47
    optionVisibleChanges: Observable<ThyOptionVisibleChangeEvent> = defer(() => {
48
        if (this.options) {
49
            return merge(...this.options.map(option => option.visibleChange));
UNCOV
50
        }
×
UNCOV
51
        return this._ngZone.onStable.asObservable().pipe(
×
52
            take(1),
53
            switchMap(() => this.optionVisibleChanges)
54
        );
UNCOV
55
    }) as Observable<ThyOptionVisibleChangeEvent>;
×
UNCOV
56

×
57
    ngAfterContentInit() {
58
        this.options.changes.pipe(startWith(null), takeUntil(this._destroy$)).subscribe(() => {
1✔
59
            this._resetOptions();
60
        });
61
    }
62

63
    _resetOptions() {
64
        const changedOrDestroyed$ = merge(this.options.changes, this._destroy$);
65
        merge(...this.options.map(option => option.visibleChange))
66
            .pipe(
1✔
67
                takeUntil(changedOrDestroyed$),
68
                debounceTime(10),
69
                map((event: ThyOptionVisibleChangeEvent) => {
70
                    const hasOption = this.options.find(option => {
71
                        if (!option.hidden) {
72
                            return true;
73
                        }
74
                    });
75
                    if (hasOption) {
76
                        return false;
77
                    } else {
78
                        return true;
79
                    }
80
                })
81
            )
82
            .subscribe((data: boolean) => {
83
                this._hidden = data;
84
                this.cdr.markForCheck();
85
            });
86
    }
87

88
    ngOnDestroy() {
89
        this._destroy$.next();
90
        this._destroy$.complete();
91
    }
92
}
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