• 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

97.44
/src/collapse/collapse-item.component.ts
1
import { collapseMotion } from 'ngx-tethys/core';
2

3
import {
4
    ChangeDetectorRef,
5
    Component,
6
    ChangeDetectionStrategy,
7
    OnDestroy,
8
    OnInit,
9
    TemplateRef,
10
    inject,
1✔
11
    input,
12
    output,
13
    computed,
14
    model
15
} from '@angular/core';
16

1✔
17
import { IThyCollapseItemComponent, THY_COLLAPSE_COMPONENT } from './collapse.token';
18
import { SafeAny } from 'ngx-tethys/types';
80✔
19
import { coerceBooleanProperty, isString } from 'ngx-tethys/util';
80✔
20
import { ThyIcon } from 'ngx-tethys/icon';
80✔
21
import { NgTemplateOutlet } from '@angular/common';
80✔
22

80✔
23
const DEFAULT_ARROW_ICON = 'angle-right';
80✔
24

80✔
25
/**
80✔
26
 * 折叠面板项组件
70✔
27
 * @name thy-collapse-panel,thy-collapse-item
70✔
28
 * @order 20
29
 */
80✔
30
@Component({
61✔
31
    selector: 'thy-collapse-panel, thy-collapse-item',
61✔
32
    templateUrl: './collapse-item.component.html',
33
    exportAs: 'ThyCollapseComponent',
80✔
34
    animations: [collapseMotion],
82✔
35
    host: {
82✔
36
        '[class.thy-collapse-item]': 'true',
12✔
37
        '[class.thy-collapse-no-arrow]': '!showArrow()',
38
        '[class.thy-collapse-item-active]': 'thyActive()',
70✔
39
        '[class.thy-collapse-item-disabled]': 'thyDisabled()'
40
    },
80✔
41
    changeDetection: ChangeDetectionStrategy.OnPush,
80✔
42
    imports: [NgTemplateOutlet, ThyIcon]
43
})
44
export class ThyCollapseItem implements IThyCollapseItemComponent, OnInit, OnDestroy {
80✔
45
    private cdr = inject(ChangeDetectorRef);
46
    private thyCollapseComponent = inject(THY_COLLAPSE_COMPONENT, { host: true })!;
UNCOV
47

×
48
    /**
49
     * 标题
50
     */
4✔
51
    readonly thyTitle = input<string>();
3✔
52

53
    /**
54
     * 是否处于激活展开状态
55
     */
80✔
56
    thyActive = model<boolean>(false);
57

1✔
58
    /**
59
     * 是否禁用当前面板
60
     */
61
    readonly thyDisabled = input(false, { transform: coerceBooleanProperty });
62

63
    /**
64
     * 自定义面板头
65
     */
66
    readonly thyHeaderTemplate = input<TemplateRef<SafeAny>>();
67

1✔
68
    /**
69
     * 自定义箭头(展开收起)图标,设置为 false 表示隐藏图标
70
     */
71
    thyArrowIcon = model<string | TemplateRef<SafeAny> | boolean>(DEFAULT_ARROW_ICON);
72

73
    readonly arrowIconTemplate = computed(() => {
74
        const arrowIcon = this.thyArrowIcon();
75
        return arrowIcon instanceof TemplateRef ? arrowIcon : null;
76
    });
77

78
    readonly arrowIcon = computed(() => {
79
        const arrowIcon = this.thyArrowIcon();
80
        return isString(arrowIcon) ? arrowIcon : DEFAULT_ARROW_ICON;
81
    });
82

83
    readonly showArrow = computed(() => {
84
        const arrowIcon = this.thyArrowIcon();
85
        if (!(arrowIcon instanceof TemplateRef) && !isString(arrowIcon)) {
86
            return this.thyArrowIcon();
87
        }
88
        return true;
89
    });
90

91
    /**
92
     * 额外附加模板
93
     */
94
    readonly thyExtra = input<TemplateRef<SafeAny>>();
95

96
    /**
97
     * 展开收起事件
98
     */
99
    readonly thyActiveChange = output<{ active: boolean; event: Event }>();
100

101
    ngOnInit() {
102
        this.thyCollapseComponent.addPanel(this);
103
    }
104

105
    markForCheck(): void {
106
        this.cdr.markForCheck();
107
    }
108

109
    activeChange(event: Event) {
110
        if (!this.thyDisabled()) {
111
            this.thyCollapseComponent.click(this, event);
112
        }
113
    }
114

115
    ngOnDestroy(): void {
116
        this.thyCollapseComponent.removePanel(this);
117
    }
118
}
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