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

atinc / ngx-tethys / e62d3b10-1466-49c3-aabd-707148681fc8

14 Jun 2024 08:24AM UTC coverage: 90.422%. Remained the same
e62d3b10-1466-49c3-aabd-707148681fc8

push

circleci

minlovehua
feat: use the ngx-tethys/util's coerceBooleanProperty instead of booleanAttribute #INFR-12648

5467 of 6692 branches covered (81.69%)

Branch coverage included in aggregate %.

117 of 120 new or added lines in 66 files covered. (97.5%)

183 existing lines in 46 files now uncovered.

13216 of 13970 relevant lines covered (94.6%)

985.91 hits per line

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

65.79
/src/menu/group/menu-group.component.ts
1
import { animate, state, style, transition, trigger } from '@angular/animations';
2
import { ComponentType } from '@angular/cdk/portal';
3
import {
4
    ChangeDetectionStrategy,
5
    Component,
6
    ContentChild,
7
    ElementRef,
8
    EventEmitter,
9
    HostBinding,
10
    Input,
11
    OnInit,
12
    Output,
13
    TemplateRef,
14
    ViewChild
1✔
15
} from '@angular/core';
16
import { ThyPopover } from 'ngx-tethys/popover';
25✔
17
import { ThyIcon } from 'ngx-tethys/icon';
18
import { NgClass, NgIf, NgTemplateOutlet } from '@angular/common';
NEW
19
import { coerceBooleanProperty } from 'ngx-tethys/util';
×
20

21
/**
UNCOV
22
 * 菜单分组组件
×
23
 * @name thy-menu-group,[thy-menu-group],[thyMenuGroup]
24
 * @order 30
UNCOV
25
 */
×
26
@Component({
27
    selector: 'thy-menu-group,[thy-menu-group],[thyMenuGroup]',
28
    templateUrl: './menu-group.component.html',
25✔
29
    animations: [
30
        trigger('detailsContentAnimation', [
UNCOV
31
            state(
×
32
                'void',
33
                style({
34
                    height: '*'
25✔
35
                })
25✔
36
            ),
25✔
37
            state(
25✔
38
                '1',
25✔
39
                style({
25✔
40
                    height: 0,
25✔
41
                    overflow: 'hidden'
25✔
42
                })
25✔
43
            ),
25✔
44
            state(
25✔
45
                '0',
25✔
46
                style({
25✔
47
                    height: '*'
48
                })
49
            ),
50
            transition('* => *', animate('0ms ease-out'))
2✔
51
        ])
1✔
52
    ],
53
    changeDetection: ChangeDetectionStrategy.OnPush,
1✔
54
    standalone: true,
1✔
55
    imports: [NgClass, NgIf, NgTemplateOutlet, ThyIcon]
56
})
57
export class ThyMenuGroup implements OnInit {
×
UNCOV
58
    public _actionMenu: ComponentType<any> | TemplateRef<any>;
×
59

60
    public rightIconClass = 'more';
×
UNCOV
61

×
62
    public iconClass = 'folder-bold';
63

64
    public groupHeaderPaddingLeft = 0;
65

66
    @ViewChild('thyMenuGroup', { static: true }) _thyMenuGroup: ElementRef;
67

UNCOV
68
    @ContentChild('headerContent')
×
69
    headerContentTemplateRef: TemplateRef<any>;
70

71
    @HostBinding('class.thy-menu-group') isThyMenuGroup = true;
1✔
72

73
    @HostBinding('class.has-icon') showIcon = false;
74

1✔
75
    @HostBinding('class.collapsed') isCollapsed = false;
76

77
    /**
78
     * 分组标题
79
     */
80
    @Input() thyTitle = '';
81

82
    /**
83
     * 已废弃,请使用 thyCollapsed
84
     * @deprecated
85
     */
86
    @Input({ transform: coerceBooleanProperty })
87
    set thyExpand(value: boolean) {
88
        this.isCollapsed = !!!value;
89
    }
90

91
    /**
92
     * 是否处于收起状态
93
     * @default false
94
     */
1✔
95
    @Input({ transform: coerceBooleanProperty })
96
    set thyCollapsed(value: boolean) {
97
        this.isCollapsed = value;
98
    }
99

100
    /**
101
     * 是否支持展开收起
102
     */
103
    @Input({ transform: coerceBooleanProperty }) thyCollapsible: boolean = false;
104

105
    /**
106
     * 是否显示 Icon
107
     */
108
    @Input({ transform: coerceBooleanProperty })
109
    set thyShowIcon(value: boolean) {
110
        this.showIcon = value;
111
    }
112

113
    /**
114
     * 图标
115
     */
116
    @Input('thyIcon')
117
    set thyIcon(value: string) {
118
        this.iconClass = value;
119
    }
120

121
    /**
122
     * 操作图标
123
     */
124
    @Input('thyActionIcon')
125
    set thyActionIcon(value: string) {
126
        this.rightIconClass = value;
127
    }
128

129
    /**
130
     *是否显示操作
131
     */
132
    @Input({ transform: coerceBooleanProperty }) thyShowAction = false;
133

134
    /**
135
     * 操作阻止冒泡事件
136
     */
137
    @Input({ transform: coerceBooleanProperty }) thyActionStopPropagation = true;
138

139
    /**
140
     * Action 点击事件
141
     */
142
    @Output() thyOnActionClick: EventEmitter<Event> = new EventEmitter<Event>();
143

144
    @Output() thyCollapsedChange: EventEmitter<boolean> = new EventEmitter<boolean>();
145

146
    /**
147
     * 设置 Action 菜单
148
     */
149
    @Input()
150
    set thyActionMenu(value: ComponentType<any> | TemplateRef<any>) {
151
        this._actionMenu = value;
152
    }
153

154
    constructor(private popover: ThyPopover) {}
155

156
    ngOnInit(): void {}
157

158
    collapseGroup(): void {
159
        if (!this.thyCollapsible) {
160
            return;
161
        }
162
        this.isCollapsed = !this.isCollapsed;
163
        this.thyCollapsedChange.emit(this.isCollapsed);
164
    }
165

166
    onActionClick(event: Event): void {
167
        if (this.thyActionStopPropagation) {
168
            event.stopPropagation();
169
        }
170
        if (this._actionMenu) {
171
            this.popover.open(this._actionMenu, {
172
                origin: event.currentTarget as HTMLElement,
173
                insideClosable: true,
174
                placement: 'bottom'
175
            });
176
        } else {
177
            this.thyOnActionClick.emit(event);
178
        }
179
    }
180
}
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