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

atinc / ngx-tethys / 3b40a702-4b4d-4ddb-81a7-a96baae6d682

08 Nov 2024 05:40AM UTC coverage: 90.395% (-0.04%) from 90.431%
3b40a702-4b4d-4ddb-81a7-a96baae6d682

push

circleci

why520crazy
Merge branch 'master' into feat-theme

5503 of 6730 branches covered (81.77%)

Branch coverage included in aggregate %.

424 of 431 new or added lines in 171 files covered. (98.38%)

344 existing lines in 81 files now uncovered.

13150 of 13905 relevant lines covered (94.57%)

999.86 hits per line

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

64.86
/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
    inject
16
} from '@angular/core';
26✔
17
import { ThyPopover } from 'ngx-tethys/popover';
26✔
18
import { ThyIcon } from 'ngx-tethys/icon';
26✔
19
import { NgClass, NgTemplateOutlet } from '@angular/common';
26✔
20
import { coerceBooleanProperty } from 'ngx-tethys/util';
26✔
21

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

×
UNCOV
61
    public _actionMenu: ComponentType<any> | TemplateRef<any>;
×
62

63
    public rightIconClass = 'more';
64

65
    public iconClass = 'folder-bold';
66

67
    public groupHeaderPaddingLeft = 0;
UNCOV
68

×
69
    @ViewChild('thyMenuGroup', { static: true }) _thyMenuGroup: ElementRef;
70

71
    @ContentChild('headerContent')
1✔
72
    headerContentTemplateRef: TemplateRef<any>;
73

74
    @HostBinding('class.thy-menu-group') isThyMenuGroup = true;
75

76
    @HostBinding('class.has-icon') showIcon = false;
77

78
    @HostBinding('class.collapsed') isCollapsed = false;
79

80
    /**
81
     * 分组标题
82
     */
83
    @Input() thyTitle = '';
84

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

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

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

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

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

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

132
    /**
133
     *是否显示操作
134
     */
135
    @Input({ transform: coerceBooleanProperty }) thyShowAction = false;
136

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

142
    /**
143
     * Action 点击事件
144
     */
145
    @Output() thyOnActionClick: EventEmitter<Event> = new EventEmitter<Event>();
146

147
    @Output() thyCollapsedChange: EventEmitter<boolean> = new EventEmitter<boolean>();
148

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

157
    ngOnInit(): void {}
158

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

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

© 2026 Coveralls, Inc