• 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

10.0
/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 { NgClass, NgTemplateOutlet } from '@angular/common';
4
import {
5
    ChangeDetectionStrategy,
6
    Component,
7
    ElementRef,
8
    ModelSignal,
9
    OnInit,
10
    TemplateRef,
11
    contentChild,
12
    inject,
13
    input,
14
    model,
15
    output,
1✔
16
    viewChild
17
} from '@angular/core';
×
18
import { ThyIcon } from 'ngx-tethys/icon';
×
19
import { ThyPopover } from 'ngx-tethys/popover';
×
20
import { coerceBooleanProperty } from 'ngx-tethys/util';
×
21

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

65
    public groupHeaderPaddingLeft = 0;
66

67
    readonly _thyMenuGroup = viewChild<ElementRef>('thyMenuGroup');
68

69
    readonly headerContentTemplateRef = contentChild<TemplateRef<any>>('headerContent');
70

71
    /**
72
     * 分组标题
73
     */
74
    readonly thyTitle = input<string>('');
75

76
    /**
77
     * 是否处于收起状态
1✔
78
     */
79
    readonly thyCollapsed: ModelSignal<boolean> = model(false);
80

81
    /**
82
     * 是否支持展开收起
83
     */
84
    readonly thyCollapsible = input(false, { transform: coerceBooleanProperty });
85

86
    /**
87
     * 是否显示 Icon
88
     */
89
    readonly thyShowIcon = input(false, { transform: coerceBooleanProperty });
90

91
    /**
92
     * 图标
93
     */
94
    readonly thyIcon = input<string, string>('folder-bold', {
95
        transform: (value: string) => value || 'folder-bold'
96
    });
97

98
    /**
99
     * 操作图标
100
     */
101
    readonly thyActionIcon = input<string, string>('more', {
102
        transform: (value: string) => value || 'more'
103
    });
104

105
    /**
106
     *是否显示操作
107
     */
108
    readonly thyShowAction = input(false, { transform: coerceBooleanProperty });
109

110
    /**
111
     * 操作阻止冒泡事件
112
     */
113
    readonly thyActionStopPropagation = input(true, { transform: coerceBooleanProperty });
114

115
    /**
116
     * Action 点击事件
117
     */
118
    readonly thyOnActionClick = output<Event>();
119

120
    readonly thyCollapsedChange = output<boolean>();
121

122
    /**
123
     * 设置 Action 菜单
124
     */
125
    readonly thyActionMenu = input<ComponentType<any> | TemplateRef<any>>();
126

127
    constructor() {}
128

129
    ngOnInit(): void {}
130

131
    collapseGroup(): void {
132
        if (!this.thyCollapsible()) {
133
            return;
134
        }
135
        this.thyCollapsed.set(!this.thyCollapsed());
136
        this.thyCollapsedChange.emit(this.thyCollapsed());
137
    }
138

139
    onActionClick(event: Event): void {
140
        if (this.thyActionStopPropagation()) {
141
            event.stopPropagation();
142
        }
143
        if (this.thyActionMenu()) {
144
            this.popover.open(this.thyActionMenu(), {
145
                origin: event.currentTarget as HTMLElement,
146
                insideClosable: true,
147
                placement: 'bottom'
148
            });
149
        } else {
150
            this.thyOnActionClick.emit(event);
151
        }
152
    }
153
}
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