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

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

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

9.38
/src/menu/item/action/menu-item-action.component.ts
1
import { ThyPopover, ThyPopoverConfig } from 'ngx-tethys/popover';
2
import { coerceBooleanProperty } from 'ngx-tethys/util';
3

4
import { ComponentType } from '@angular/cdk/portal';
5
import { Component, ElementRef, OnDestroy, OnInit, Renderer2, TemplateRef, inject, input } from '@angular/core';
6

7
/**
8
 * 菜单项操作组件
9
 * @name thy-menu-item-action,[thy-menu-item-action],[thyMenuItemAction]
10
 * @order 25
11
 */
12
@Component({
1✔
13
    selector: 'thy-menu-item-action,[thy-menu-item-action],[thyMenuItemAction]',
UNCOV
14
    templateUrl: './menu-item-action.component.html',
×
UNCOV
15
    host: {
×
UNCOV
16
        class: 'thy-menu-item-action'
×
UNCOV
17
    }
×
UNCOV
18
})
×
UNCOV
19
export class ThyMenuItemAction implements OnInit, OnDestroy {
×
UNCOV
20
    private popover = inject(ThyPopover);
×
UNCOV
21
    private renderer = inject(Renderer2);
×
22
    private elementRef = inject(ElementRef);
23

UNCOV
24
    _boundEvent = false;
×
25

×
26
    /**
UNCOV
27
     * 设置 Action 菜单
×
UNCOV
28
     */
×
UNCOV
29
    readonly thyActionMenu = input<ComponentType<any> | TemplateRef<any>>();
×
UNCOV
30

×
31
    /**
UNCOV
32
     * 是否阻止事件冒泡
×
UNCOV
33
     */
×
UNCOV
34
    readonly thyStopPropagation = input(true, { transform: coerceBooleanProperty });
×
UNCOV
35

×
UNCOV
36
    /**
×
37
     * 弹出框的参数
38
     * @default { placement: "bottomLeft", insideClosable: true }
39
     */
40
    readonly thyPopoverOptions = input<ThyPopoverConfig>();
41

UNCOV
42
    private bindClickEvent() {
×
UNCOV
43
        if (this._boundEvent) {
×
44
            return;
45
        }
46
        this._boundEvent = true;
47
        this.removeClickListenerFn = this.renderer.listen(this.elementRef.nativeElement, 'click', event => {
48
            if (this.thyStopPropagation()) {
UNCOV
49
                event.stopPropagation();
×
50
            }
51
            if (this.thyActionMenu()) {
UNCOV
52
                const activeClass = 'action-active';
×
53
                const wrapDOM = (event.target as HTMLElement).closest('.thy-menu-item');
54
                wrapDOM?.classList.add(activeClass);
1✔
55
                const popoverRef = this.popover.open(
56
                    this.thyActionMenu(),
57
                    Object.assign(
58
                        {
59
                            origin: event.currentTarget as HTMLElement,
60
                            insideClosable: true,
1✔
61
                            placement: 'bottomLeft',
62
                            originActiveClass: 'active'
63
                        },
64
                        this.thyPopoverOptions()
65
                    )
66
                );
67
                popoverRef?.afterClosed().subscribe(() => {
68
                    wrapDOM?.classList.remove(activeClass);
69
                });
70
            }
71
        });
72
    }
73

74
    private removeClickListenerFn: VoidFunction | null = null;
75

76
    ngOnInit(): void {
77
        this.bindClickEvent();
78
    }
79

80
    ngOnDestroy(): void {
81
        this.removeClickListenerFn?.();
82
    }
83
}
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