• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / 0bbb2cec-209e-4d8a-b1b3-6bc54e05daa6

04 Sep 2023 08:40AM UTC coverage: 15.616% (-74.6%) from 90.2%
0bbb2cec-209e-4d8a-b1b3-6bc54e05daa6

Pull #2829

circleci

cmm-va
fix: add test
Pull Request #2829: fix: add tabIndex

300 of 6386 branches covered (0.0%)

Branch coverage included in aggregate %.

78 of 78 new or added lines in 26 files covered. (100.0%)

2849 of 13779 relevant lines covered (20.68%)

83.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

13.79
/src/input/input-count.component.ts
1
import { Component, OnInit, ChangeDetectionStrategy, Input, ChangeDetectorRef, Optional } from '@angular/core';
2
import { ThyInputDirective } from './input.directive';
3
import { UnsubscribeMixin } from 'ngx-tethys/core';
4
import { takeUntil, switchMap, filter, tap } from 'rxjs/operators';
5
import { Subject } from 'rxjs';
6
import { ThyInputGroupComponent } from './input-group.component';
7

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

×
25
    /**
×
26
     * 输入框组件,如果不传默认会读取外层 thy-input-group 下的 thyInput 指令
27
     * @type ThyInputDirective
28
     */
×
29
    @Input() set thyInput(value: ThyInputDirective) {
30
        this.hasInput = true;
×
31
        this.thyInput$.next(value);
32
    }
×
33

×
34
    maxLength: number | string;
35

×
36
    inputLength = 0;
37

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

40
    constructor(private changeDetectorRef: ChangeDetectorRef, @Optional() private inputGroup: ThyInputGroupComponent) {
41
        super();
42
        this.setup();
43
    }
×
44

×
45
    setup() {
46
        this.thyInput$
47
            .pipe(
1✔
48
                filter(input => {
49
                    return !!input;
50
                }),
51
                tap(input => {
1✔
52
                    this.maxLength = input.nativeElement.getAttribute('maxlength');
53
                    this.changeDetectorRef.markForCheck();
54
                }),
55
                takeUntil(this.ngUnsubscribe$),
1✔
56
                switchMap(input => {
57
                    return input.ngControl.valueChanges;
58
                }),
59
                tap(value => {
60
                    this.inputLength = value?.length || 0;
61
                    this.changeDetectorRef.markForCheck();
62
                }),
63
                takeUntil(this.ngUnsubscribe$)
64
            )
65
            .subscribe();
66
    }
67

68
    ngOnInit(): void {
69
        if (!this.hasInput && this.inputGroup && this.inputGroup.inputDirective) {
70
            this.thyInput$.next(this.inputGroup.inputDirective);
71
        }
72
    }
73
}
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