• 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.26
/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';
×
19
import { coerceBooleanProperty, isString } from 'ngx-tethys/util';
×
20
import { ThyIcon } from 'ngx-tethys/icon';
×
21
import { NgTemplateOutlet } from '@angular/common';
×
22

×
23
const DEFAULT_ARROW_ICON = 'angle-right';
×
24

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

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

53
    /**
54
     * 是否处于激活展开状态
55
     */
×
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

© 2026 Coveralls, Inc