• 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

7.41
/src/progress/progress.component.ts
1
import { isNumber } from 'ngx-tethys/util';
2

3
import {
4
    ChangeDetectionStrategy,
5
    Component,
6
    computed,
7
    Input,
8
    OnChanges,
9
    OnInit,
10
    QueryList,
11
    SimpleChanges,
12
    TemplateRef,
13
    ViewChildren,
14
    ViewEncapsulation,
15
    numberAttribute,
1✔
16
    input,
UNCOV
17
    signal,
×
UNCOV
18
    viewChildren,
×
UNCOV
19
    effect
×
UNCOV
20
} from '@angular/core';
×
UNCOV
21
import { useHostRenderer } from '@tethys/cdk/dom';
×
UNCOV
22

×
23
import { ThyProgressGapPositionType, ThyProgressShapeType, ThyProgressStackedValue, ThyProgressType } from './interfaces';
24
import { THY_PROGRESS_COMPONENT, ThyParentProgress, ThyProgressStrip } from './progress-strip.component';
UNCOV
25
import { ThyProgressCircle } from './progress-circle.component';
×
26
import { ThyTooltipDirective } from 'ngx-tethys/tooltip';
UNCOV
27
import { NgClass, NgTemplateOutlet } from '@angular/common';
×
UNCOV
28

×
UNCOV
29
/**
×
UNCOV
30
 * 进度条组件
×
UNCOV
31
 * @name thy-progress
×
UNCOV
32
 */
×
33
@Component({
UNCOV
34
    selector: 'thy-progress',
×
UNCOV
35
    templateUrl: './progress.component.html',
×
36
    changeDetection: ChangeDetectionStrategy.OnPush,
UNCOV
37
    encapsulation: ViewEncapsulation.None,
×
UNCOV
38
    providers: [
×
39
        {
UNCOV
40
            provide: THY_PROGRESS_COMPONENT,
×
41
            useExisting: ThyProgress
UNCOV
42
        }
×
UNCOV
43
    ],
×
44
    host: {
UNCOV
45
        class: `thy-progress progress`,
×
UNCOV
46
        '[class.thy-progress-strip]': `thyShape() === 'strip'`,
×
UNCOV
47
        '[class.thy-progress-circle]': `thyShape() === 'circle'`,
×
UNCOV
48
        '[class.progress-stacked]': 'isStacked()',
×
49
        '[attr.max]': 'max()'
UNCOV
50
    },
×
UNCOV
51
    imports: [ThyProgressStrip, NgClass, ThyTooltipDirective, NgTemplateOutlet, ThyProgressCircle]
×
52
})
53
export class ThyProgress implements ThyParentProgress, OnInit, OnChanges {
UNCOV
54
    private hostRenderer = useHostRenderer();
×
55

56
    readonly barsTotalValue = computed(() => {
57
        const value = this.thyValue();
UNCOV
58
        if (Array.isArray(value)) {
×
UNCOV
59
            return value.reduce((total, item) => {
×
UNCOV
60
                return total + item.value;
×
UNCOV
61
            }, 0);
×
UNCOV
62
        }
×
UNCOV
63
        return undefined;
×
UNCOV
64
    });
×
UNCOV
65

×
UNCOV
66
    readonly max = computed(() => {
×
67
        const setMax = this.thyMax();
68
        const barsTotalValue = this.barsTotalValue();
69
        let result: number = 100;
70
        if (isNumber(setMax) && setMax > 0) {
71
            result = setMax;
1✔
72
        } else if (isNumber(barsTotalValue)) {
1✔
73
            result = barsTotalValue;
74
        }
75
        if (result < barsTotalValue) {
76
            result = barsTotalValue;
77
        }
78
        return result;
79
    });
80

81
    readonly isStacked = computed(() => {
82
        return Array.isArray(this.thyValue());
83
    });
84

85
    readonly bars = viewChildren(ThyProgressStrip);
1✔
86

87
    /**
88
     * 进度条类型: `primary` | `success` | `info` | `warning` | `danger`
89
     */
90
    readonly thyType = input<ThyProgressType>('primary');
91

92
    /**
93
     * 进度条大小
94
     * @type xs | sm | md
95
     * @default md
96
     */
97
    readonly thySize = input<string | number>('md');
98

99
    /**
100
     * 进度值,传入数字时显示百分比 = value / max * 100,当传入数组时显示多个 bar,stacked 模式的进度条
101
     * @type number | ThyProgressStackedValue[]
102
     */
103
    readonly thyValue = input<number | ThyProgressStackedValue[], number | ThyProgressStackedValue[]>(undefined, {
104
        transform: (value: number | ThyProgressStackedValue[]) => {
105
            if (Array.isArray(value)) {
106
                return [...value].filter(item => item.value !== 0);
107
            } else {
108
                return value;
109
            }
110
        }
111
    });
112

113
    /**
114
     * 最大值,主要计算百分比进度的分母使用,当 thyValue 传入数组时,自动累加数组中的 value 之和为 max
115
     */
116
    readonly thyMax = input<number, number | string | unknown>(undefined, { transform: numberAttribute });
117

118
    /**
119
     * 鼠标移入进度条时显示的提示文案或者模板
120
     */
121
    readonly thyTips = input<string | TemplateRef<unknown>>(undefined);
122

123
    /**
124
     * 进度形状
125
     * @type strip | circle
126
     */
127
    readonly thyShape = input<ThyProgressShapeType>('strip');
128

129
    /**
130
     * 圆形进度条缺口角度,可取值 0 ~ 360
131
     */
132
    readonly thyGapDegree = input<number, unknown>(undefined, { transform: numberAttribute });
133

134
    /**
135
     * 圆形进度条缺口位置
136
     * @type top | bottom | left | right
137
     */
138
    readonly thyGapPosition = input<ThyProgressGapPositionType>('top');
139

140
    /**
141
     *         圆形进度条线的宽度
142
     */
143
    readonly thyStrokeWidth = input<number, unknown>(undefined, { transform: numberAttribute });
144

145
    constructor() {
146
        effect(() => {
147
            const size = this.thySize();
148
            this.hostRenderer.updateClass(size ? [`progress-${size}`] : []);
149
        });
150
    }
151

152
    ngOnInit() {}
153

154
    ngOnChanges(changes: SimpleChanges): void {}
155
}
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