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

atinc / ngx-tethys / #55

30 Jul 2025 07:08AM UTC coverage: 9.866% (-80.4%) from 90.297%
#55

push

why520crazy
feat(empty): add setMessage for update display text #TINFR-2616

92 of 6794 branches covered (1.35%)

Branch coverage included in aggregate %.

2014 of 14552 relevant lines covered (13.84%)

6.15 hits per line

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

75.0
/src/dropdown/dropdown-menu.component.ts
1
import { coerceCssPixelValue } from '@angular/cdk/coercion';
2
import { NgTemplateOutlet } from '@angular/common';
3
import {
4
    ChangeDetectionStrategy,
5
    Component,
6
    Directive,
7
    HostBinding,
1✔
8
    TemplateRef,
9
    ViewEncapsulation,
10
    input,
11
    viewChild
1✔
12
} from '@angular/core';
13
import { SafeAny } from 'ngx-tethys/types';
×
14
import { coerceBooleanProperty } from 'ngx-tethys/util';
15

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

18
export const THY_DROPDOWN_DEFAULT_WIDTH = '240px';
19

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

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

59
    /**
60
     * 设置菜单宽度
61
     */
62
    readonly thyWidth = input(THY_DROPDOWN_DEFAULT_WIDTH, { transform: coerceCssPixelValue });
63

64
    /**
65
     * 是否直接渲染 dropdown-menu 中的元素
66
     */
67
    readonly thyImmediateRender = input(false, { transform: coerceBooleanProperty });
68

69
    constructor() {}
70
}
71

72
/**
73
 * 下拉菜单分组
1✔
74
 * @name thy-dropdown-menu-group
75
 * @order 50
×
76
 */
77
@Component({
1✔
78
    selector: 'thy-dropdown-menu-group',
1✔
79
    template: `
80
        <div class="dropdown-menu-group-title">{{ thyTitle() }}</div>
81
        <ng-content></ng-content>
82
    `,
1✔
83
    changeDetection: ChangeDetectionStrategy.OnPush,
84
    host: {
85
        class: 'dropdown-menu-group'
86
    }
87
})
88
export class ThyDropdownMenuGroup {
89
    /**
90
     * 分组标题
91
     */
92
    readonly thyTitle = input<string>();
93

94
    constructor() {}
95
}
96

97
/**
98
 * 下拉菜单分割线
99
 * @name thy-dropdown-menu-divider
100
 */
101
@Component({
1✔
102
    selector: 'thy-dropdown-menu-divider',
103
    template: ` <!-- <div class="dropdown-menu-divider-title">{{ title }}</div> --> `,
1✔
104
    host: {
105
        class: 'dropdown-menu-divider'
1✔
106
    },
107
    changeDetection: ChangeDetectionStrategy.OnPush
108
})
109
export class ThyDropdownMenuDivider {
110
    constructor() {}
111
}
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