• 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

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,
1✔
14
    ViewChild,
15
    booleanAttribute
25✔
16
} from '@angular/core';
17
import { ThyPopover } from 'ngx-tethys/popover';
UNCOV
18
import { ThyIcon } from 'ngx-tethys/icon';
×
19
import { NgClass, NgIf, NgTemplateOutlet } from '@angular/common';
20

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

×
60
    public rightIconClass = 'more';
×
61

62
    public iconClass = 'folder-bold';
63

64
    public groupHeaderPaddingLeft = 0;
65

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

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

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

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

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

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

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

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

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

105
    /**
106
     * 是否显示 Icon
107
     */
108
    @Input({ alias: 'thyShowIcon', transform: booleanAttribute })
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: booleanAttribute }) thyShowAction = false;
133

134
    /**
135
     * 操作阻止冒泡事件
136
     */
137
    @Input({ transform: booleanAttribute }) 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