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

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

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

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

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

×
19
    private hostRenderer = useHostRenderer();
×
20

21
    /**
22
     * 设置 Active 样式类,可以是一个或多个CSS类
23
     * @type string[] | string
×
24
     */
25
    @Input()
×
26
    set thyDropdownActive(data: string[] | string) {
×
27
        this.classes = coerceArray(data).filter(c => !!c);
28
    }
×
29

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

×
35
    constructor(private elementRef: ElementRef, @Optional() private trigger?: ThyDropdownDirective) {}
36

37
    ngOnInit(): void {}
38

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

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