• 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

13.04
/src/dropdown/dropdown-active.directive.ts
1
import { AfterContentInit, ContentChildren, Directive, OnInit, QueryList, Signal, computed, inject, input } from '@angular/core';
2
import { useHostRenderer } from '@tethys/cdk/dom';
3
import { coerceArray } from 'ngx-tethys/util';
4
import { mergeMap, startWith } from 'rxjs';
5
import { ThyDropdownDirective } from './dropdown.directive';
6

7
/**
8
 * 跟踪 Dropdown 菜单是否被打开处于激活状态,允许指定一个或多个CSS类,以便在菜单打开状态时添加到元素中
9
 * @name thyDropdownActive
10
 * @order 60
11
 */
12
@Directive({
13
    selector: '[thyDropdownActive]'
1✔
14
})
UNCOV
15
export class ThyDropdownActiveDirective implements OnInit, AfterContentInit {
×
UNCOV
16
    private trigger = inject(ThyDropdownDirective, { optional: true });
×
UNCOV
17

×
18
    readonly classes: Signal<string[]> = computed(() => {
UNCOV
19
        return coerceArray(this.thyDropdownActive()).filter(c => !!c);
×
UNCOV
20
    });
×
21

22
    private hostRenderer = useHostRenderer();
23

UNCOV
24
    /**
×
25
     * 设置 Active 样式类,可以是一个或多个CSS类
UNCOV
26
     * @type string[] | string
×
UNCOV
27
     */
×
28
    readonly thyDropdownActive = input<string[] | string>();
UNCOV
29

×
UNCOV
30
    /**
×
31
     * @private
UNCOV
32
     */
×
33
    @ContentChildren(ThyDropdownDirective, { descendants: true }) triggers!: QueryList<ThyDropdownDirective>;
34

UNCOV
35
    ngOnInit(): void {}
×
36

37
    ngAfterContentInit(): void {
38
        this.triggers.changes
UNCOV
39
            .pipe(
×
UNCOV
40
                startWith(this.triggers.toArray()),
×
UNCOV
41
                mergeMap((triggers: ThyDropdownDirective[]) => {
×
42
                    const result = triggers.map(item => {
43
                        return item.thyActiveChange;
UNCOV
44
                    });
×
45
                    this.trigger && result.push(this.trigger.thyActiveChange);
46
                    return result;
47
                }),
48
                mergeMap(result => {
1✔
49
                    return result;
50
                })
51
            )
52
            .subscribe(active => {
53
                this.update(active);
1✔
54
            });
55
    }
56

57
    update(active: boolean) {
58
        this.classes().forEach(className => {
59
            if (active) {
60
                this.hostRenderer.addClass(className);
61
            } else {
62
                this.hostRenderer.removeClass(className);
63
            }
64
        });
65
    }
66
}
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