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

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

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

16.67
/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 { mixinUnsubscribe, MixinBase } 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
const _Base = mixinUnsubscribe(MixinBase);
1✔
9

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

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

36
    maxLength: number | string;
×
37

38
    inputLength = 0;
×
39

×
40
    thyInput$ = new Subject<ThyInputDirective>();
41

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

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

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