• 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

11.76
/src/input/input-count.component.ts
1
import { Component, OnInit, ChangeDetectionStrategy, inject, DestroyRef, input, effect, signal } from '@angular/core';
2
import { ThyInputDirective } from './input.directive';
3
import { switchMap, filter, tap } from 'rxjs/operators';
4
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
import { Subject } from 'rxjs';
6
import { ThyInputGroup } from './input-group.component';
7

8
/**
9
 * 输入框输入文字展示
10
 * @name thy-input-count
11
 * @order 40
12
 */
13
@Component({
1✔
14
    selector: 'thy-input-count',
UNCOV
15
    template: '{{inputLength()}} / {{maxLength()}}',
×
UNCOV
16
    changeDetection: ChangeDetectionStrategy.OnPush,
×
UNCOV
17
    host: {
×
UNCOV
18
        class: 'thy-input-count text-muted'
×
UNCOV
19
    }
×
UNCOV
20
})
×
UNCOV
21
export class ThyInputCount implements OnInit {
×
UNCOV
22
    private inputGroup = inject(ThyInputGroup, { optional: true })!;
×
UNCOV
23

×
UNCOV
24
    private readonly destroyRef = inject(DestroyRef);
×
UNCOV
25

×
UNCOV
26
    private hasInput = false;
×
UNCOV
27

×
28
    /**
29
     * 输入框组件,如果不传默认会读取外层 thy-input-group 下的 thyInput 指令
30
     * @type ThyInputDirective
31
     */
UNCOV
32
    readonly thyInput = input<ThyInputDirective>();
×
33

UNCOV
34
    maxLength = signal<number | string>(undefined);
×
35

UNCOV
36
    inputLength = signal(0);
×
37

UNCOV
38
    thyInput$ = new Subject<ThyInputDirective>();
×
39

UNCOV
40
    constructor() {
×
41
        this.setup();
42

43
        effect(() => {
44
            const input = this.thyInput();
UNCOV
45
            if (input) {
×
UNCOV
46
                this.hasInput = true;
×
UNCOV
47
                this.thyInput$.next(input);
×
48
            }
49
        });
50
    }
1✔
51

1✔
52
    setup() {
53
        this.thyInput$
54
            .pipe(
55
                filter(input => {
1✔
56
                    return !!input;
57
                }),
58
                tap(input => {
59
                    this.maxLength.set(input.nativeElement.getAttribute('maxlength'));
60
                }),
61
                takeUntilDestroyed(this.destroyRef),
62
                switchMap(input => {
63
                    return input.ngControl.valueChanges;
64
                }),
65
                tap(value => {
66
                    this.inputLength.set(value?.length || 0);
67
                }),
68
                takeUntilDestroyed(this.destroyRef)
69
            )
70
            .subscribe();
71
    }
72

73
    ngOnInit(): void {
74
        const inputDirective = this.inputGroup.inputDirective();
75
        if (!this.hasInput && this.inputGroup && inputDirective) {
76
            this.thyInput$.next(inputDirective);
77
        }
78
    }
79
}
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