• 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

23.81
/src/strength/strength.component.ts
1
import { ThyTranslate } from 'ngx-tethys/core';
2

3
import { Component, computed, forwardRef, HostBinding, inject, input, OnInit, Signal } from '@angular/core';
4
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
5
import { injectLocale, ThyStrengthLocale } from 'ngx-tethys/i18n';
6

7
enum ThyStrengthEnum {
8
    highest = 4,
9
    high = 3,
1✔
10
    average = 2,
1✔
11
    low = 1
1✔
12
}
1✔
13

1✔
14
/**
2✔
15
 * 程度展示组件
16
 * @name thy-strength
17
 * @order 10
18
 */
19
@Component({
20
    selector: 'thy-strength',
1✔
21
    templateUrl: 'strength.component.html',
22
    providers: [
×
23
        {
×
24
            provide: NG_VALUE_ACCESSOR,
×
25
            useExisting: forwardRef(() => ThyStrength),
×
26
            multi: true
×
27
        }
28
    ]
29
})
30
export class ThyStrength implements OnInit, ControlValueAccessor {
31
    translate = inject(ThyTranslate);
32

33
    @HostBinding('class.password-strength-container') styleClass = true;
34

35
    strength: ThyStrengthEnum;
36

37
    locale: Signal<ThyStrengthLocale> = injectLocale('strength');
38

39
    readonly strengthMap = computed(() => {
40
        return {
41
            [ThyStrengthEnum.highest]: {
42
                level: 'highest',
43
                text: this.highestKey()
44
            },
45
            [ThyStrengthEnum.high]: {
×
46
                level: 'high',
×
47
                text: this.highKey()
×
48
            },
49
            [ThyStrengthEnum.average]: {
×
50
                level: 'average',
×
51
                text: this.averageKey()
52
            },
×
53
            [ThyStrengthEnum.low]: {
×
54
                level: 'low',
55
                text: this.lowKey()
×
56
            }
×
57
        };
58
    });
×
59

×
60
    /**
61
     * 组件标题,描述程度所指类型
62
     */
63
    readonly titleKey = input<string, string>('', { transform: (value: string) => this.translate.instant(value) || '' });
×
64

×
65
    /**
×
66
     * 程度最高值文本
67
     */
68
    readonly highestKey = input<string, string>(this.locale().highest, {
×
69
        transform: (value: string) => this.translate.instant(value) || this.locale().highest
70
    });
71

×
72
    /**
73
     * 程度为高值时展示的文本
1✔
74
     */
75
    readonly highKey = input<string, string>(this.locale().high, {
76
        transform: (value: string) => this.translate.instant(value) || this.locale().high
77
    });
78

79
    /**
80
     * 程度为中值时展示的文本
81
     */
82
    readonly averageKey = input<string, string>(this.locale().medium, {
1✔
83
        transform: (value: string) => this.translate.instant(value) || this.locale().medium
84
    });
85

86
    /**
87
     * 程度为低值时展示的文本
88
     */
89
    readonly lowKey = input<string, string>(this.locale().low, {
×
90
        transform: (value: string) => this.translate.instant(value) || this.locale().low
91
    });
92

93
    private _onChange = Function.prototype;
94

95
    private _onTouched = Function.prototype;
96

97
    ngOnInit() {}
98

99
    writeValue(value: ThyStrengthEnum) {
100
        this.strength = value;
101
        this._onChange(value);
102
        this._onTouched();
103
    }
104

105
    registerOnChange(fn: (value: any) => any): void {
106
        this._onChange = fn;
107
    }
108

109
    registerOnTouched(fn: () => any): void {
110
        this._onTouched = fn;
111
    }
112
}
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