• 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

13.51
/src/input/input-group.component.ts
1
import {
2
    Component,
3
    HostBinding,
4
    Input,
5
    ContentChild,
6
    TemplateRef,
7
    ViewEncapsulation,
8
    ChangeDetectionStrategy,
9
    AfterContentChecked,
10
    OnInit,
1✔
11
    ElementRef,
12
    OnDestroy
13
} from '@angular/core';
14
import { MixinBase, ThyTranslate, mixinUnsubscribe } from 'ngx-tethys/core';
15
import { useHostRenderer } from '@tethys/cdk/dom';
16
import { ThyInputDirective } from './input.directive';
17
import { NgIf, NgTemplateOutlet } from '@angular/common';
18
import { FocusMonitor } from '@angular/cdk/a11y';
19
import { takeUntil } from 'rxjs/operators';
20

1✔
21
export type InputGroupSize = 'sm' | 'lg' | 'md' | '';
22

×
23
const inputGroupSizeMap = {
24
    sm: ['input-group-sm'],
25
    lg: ['input-group-lg'],
×
26
    md: ['input-group-md']
×
27
};
28

29
/**
30
 * 输入框分组
×
31
 * @name thy-input-group
32
 * @order 20
33
 */
×
34
@Component({
×
35
    selector: 'thy-input-group',
36
    templateUrl: './input-group.component.html',
37
    changeDetection: ChangeDetectionStrategy.OnPush,
38
    encapsulation: ViewEncapsulation.None,
×
39
    host: {
×
40
        class: 'thy-input-group',
41
        '[class.form-control]': 'prefixTemplate || suffixTemplate',
42
        '[class.thy-input-group-with-prefix]': 'prefixTemplate',
×
43
        '[class.thy-input-group-with-suffix]': 'suffixTemplate'
44
    },
45
    standalone: true,
46
    imports: [NgIf, NgTemplateOutlet]
×
47
})
×
48
export class ThyInputGroupComponent extends mixinUnsubscribe(MixinBase) implements OnInit, AfterContentChecked, OnDestroy {
×
49
    private hostRenderer = useHostRenderer();
×
50

×
51
    public appendText: string;
×
52

53
    public prependText: string;
54

×
55
    @HostBinding('class.disabled') disabled = false;
56

57
    /**
58
     * 输入框上添加的后置文本
×
59
     */
×
60
    @Input()
61
    set thyAppendText(value: string) {
62
        this.appendText = value;
×
63
    }
64

65
    /**
66
     * 输入框上添加的后置文本多语言 Key
67
     */
×
68
    @Input()
69
    set thyAppendTextTranslateKey(value: string) {
70
        if (value) {
×
71
            this.appendText = this.thyTranslate.instant(value);
×
72
        }
73
    }
1✔
74

75
    /**
76
     * 输入框上添加的前置文本
77
     */
78
    @Input()
1✔
79
    set thyPrependText(value: string) {
80
        this.prependText = value;
81
    }
82

83
    /**
84
     * 输入框上添加的前置文本多语言 Key
85
     */
86
    @Input()
87
    set thyPrependTextTranslateKey(value: string) {
88
        if (value) {
89
            this.prependText = this.thyTranslate.instant(value);
90
        }
91
    }
92

1✔
93
    /**
94
     * 输入框分组大小
95
     * @type 'sm' | 'lg' | 'md' | ''
96
     * @default ''
97
     */
98
    @Input()
99
    set thySize(size: InputGroupSize) {
100
        if (size && inputGroupSizeMap[size]) {
101
            this.hostRenderer.updateClass(inputGroupSizeMap[size]);
102
        } else {
103
            this.hostRenderer.updateClass([]);
104
        }
105
    }
106

107
    /**
108
     * 后置模板
109
     */
110
    @ContentChild('append') appendTemplate: TemplateRef<unknown>;
111

112
    /**
113
     * 前置模板
114
     */
115
    @ContentChild('prepend') prependTemplate: TemplateRef<unknown>;
116

117
    /**
118
     * 前缀
119
     */
120
    @ContentChild('prefix') prefixTemplate: TemplateRef<unknown>;
121

122
    /**
123
     * 后缀
124
     */
125
    @ContentChild('suffix') suffixTemplate: TemplateRef<unknown>;
126

127
    /**
128
     * @private
129
     */
130
    @ContentChild(ThyInputDirective) inputDirective: ThyInputDirective;
131

132
    constructor(private thyTranslate: ThyTranslate, private elementRef: ElementRef, private focusMonitor: FocusMonitor) {
133
        super();
134
    }
135

136
    ngOnInit() {
137
        this.focusMonitor
138
            .monitor(this.elementRef.nativeElement, true)
139
            .pipe(takeUntil(this.ngUnsubscribe$))
140
            .subscribe(origin => {
141
                if (origin) {
142
                    this.hostRenderer.addClass('form-control-active');
143
                } else {
144
                    this.hostRenderer.removeClass('form-control-active');
145
                }
146
            });
147
    }
148

149
    ngAfterContentChecked(): void {
150
        this.disabled = !!this.inputDirective?.nativeElement?.hasAttribute('disabled');
151
    }
152

153
    ngOnDestroy() {
154
        super.ngOnDestroy();
155
        this.focusMonitor.stopMonitoring(this.elementRef.nativeElement);
156
    }
157
}
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