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

atinc / ngx-tethys / c0ef8457-a839-451f-8b72-80fd73106231

02 Apr 2024 02:27PM UTC coverage: 90.524% (-0.06%) from 90.585%
c0ef8457-a839-451f-8b72-80fd73106231

Pull #3062

circleci

minlovehua
refactor(all): use the transform attribute of @Input() instead of @InputBoolean() and @InputNumber()
Pull Request #3062: refactor(all): use the transform attribute of @input() instead of @InputBoolean() and @InputNumber()

4987 of 6108 branches covered (81.65%)

Branch coverage included in aggregate %.

217 of 223 new or added lines in 82 files covered. (97.31%)

202 existing lines in 53 files now uncovered.

12246 of 12929 relevant lines covered (94.72%)

1055.59 hits per line

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

95.24
/src/dropdown/dropdown-menu.component.ts
1
import { NgIf, NgTemplateOutlet } from '@angular/common';
2
import {
3
    ChangeDetectionStrategy,
4
    Component,
5
    Directive,
1✔
6
    HostBinding,
7
    Input,
8
    TemplateRef,
9
    ViewChild,
1✔
10
    ViewEncapsulation,
11
    booleanAttribute
1✔
12
} from '@angular/core';
13
import { InputCssPixel } from 'ngx-tethys/core';
1✔
14
import { SafeAny } from 'ngx-tethys/types';
15

16
export type ThyDropdownMenuDividerType = 'default' | 'crossing' | '';
17

1✔
18
export const THY_DROPDOWN_DEFAULT_WIDTH = '240px';
19

20
/**
21
 * @private
22
 */
23
@Directive()
24
export class ThyDropdownAbstractMenu {
25
    @HostBinding('class.thy-dropdown-menu') addDropdownMenuClass = true;
26
}
1✔
27

UNCOV
28
/**
×
29
 * 下拉菜单组件
30
 * @name thy-dropdown-menu
31
 * @order 20
53✔
32
 */
53✔
33
@Component({
34
    selector: 'thy-dropdown-menu',
1✔
35
    template: `
1✔
36
        <ng-container *ngIf="thyImmediateRender; then content"> </ng-container>
37
        <ng-template #dropdownMenu>
38
            <div class="thy-dropdown-menu" [style.width]="thyWidth">
39
                <ng-container *ngTemplateOutlet="content"></ng-container>
40
            </div>
41
        </ng-template>
1✔
42
        <ng-template #content>
43
            <ng-content></ng-content>
44
        </ng-template>
45
    `,
1✔
46
    encapsulation: ViewEncapsulation.None,
47
    changeDetection: ChangeDetectionStrategy.OnPush,
48
    host: {
49
        '[class.thy-dropdown-menu]': 'thyImmediateRender',
50
        '[style.width]': "thyImmediateRender ? thyWidth : ''"
51
    },
52
    standalone: true,
53
    imports: [NgIf, NgTemplateOutlet]
54
})
55
export class ThyDropdownMenuComponent {
56
    get template() {
57
        return this.templateRef;
58
    }
59

60
    @ViewChild('dropdownMenu', { static: true }) templateRef!: TemplateRef<SafeAny>;
61

62
    /**
63
     * 设置菜单宽度
64
     * @default 240px
65
     */
66
    @Input()
67
    @InputCssPixel()
68
    thyWidth: number | string = THY_DROPDOWN_DEFAULT_WIDTH;
69

70
    /**
71
     * 是否直接渲染 dropdown-menu 中的元素
72
     * @default false
73
     */
74
    @Input({ transform: booleanAttribute }) thyImmediateRender = false;
75

76
    constructor() {}
1✔
77
}
78

6✔
79
/**
80
 * 下拉菜单分组
81
 * @name thy-dropdown-menu-group
1✔
82
 * @order 50
1✔
83
 */
84
@Component({
85
    selector: 'thy-dropdown-menu-group',
86
    template: `
1✔
87
        <div class="dropdown-menu-group-title">{{ title }}</div>
88
        <ng-content></ng-content>
89
    `,
90
    changeDetection: ChangeDetectionStrategy.OnPush,
91
    host: {
92
        class: 'dropdown-menu-group'
93
    },
94
    standalone: true
95
})
96
export class ThyDropdownMenuGroup {
97
    title: string;
98

99
    /**
100
     * 分组标题
101
     */
102
    @Input()
103
    set thyTitle(value: string) {
104
        this.title = value;
105
    }
106

1✔
107
    constructor() {}
108
}
1✔
109

110
/**
1✔
111
 * 下拉菜单分割线
112
 * @name thy-dropdown-menu-divider
113
 */
114
@Component({
115
    selector: 'thy-dropdown-menu-divider',
116
    template: ` <!-- <div class="dropdown-menu-divider-title">{{ title }}</div> --> `,
117
    host: {
118
        class: 'dropdown-menu-divider'
119
    },
120
    changeDetection: ChangeDetectionStrategy.OnPush,
121
    standalone: true
122
})
123
export class ThyDropdownMenuDivider {
124
    constructor() {}
125
}
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