• 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

18.92
/src/select/select.component.ts
1
import { Component, forwardRef, HostBinding, Input, OnInit } from '@angular/core';
2
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
3
import {
4
    AbstractControlValueAccessor,
5
    Constructor,
6
    InputBoolean,
7
    mixinDisabled,
8
    mixinTabIndex,
9
    ThyCanDisable,
10
    ThyHasTabIndex
11
} from 'ngx-tethys/core';
12
import { elementMatchClosest } from 'ngx-tethys/util';
13

1✔
14
import { NgIf } from '@angular/common';
1✔
15
import { ElementRef, ViewChild } from '@angular/core';
16
import { useHostRenderer } from '@tethys/cdk/dom';
17
import { ThyIconComponent } from 'ngx-tethys/icon';
18
import { ThyInputDirective } from 'ngx-tethys/input';
19

20
export type InputSize = 'xs' | 'sm' | 'md' | 'lg' | '';
1✔
21

22
const noop = () => {};
×
23

24
const _MixinBase: Constructor<ThyHasTabIndex> & Constructor<ThyCanDisable> & typeof AbstractControlValueAccessor = mixinTabIndex(
25
    mixinDisabled(AbstractControlValueAccessor)
×
26
);
×
27

28
/**
29
 * 下拉选择
30
 * @name thy-select
×
31
 * @order 20
32
 */
33
@Component({
×
34
    selector: 'thy-select',
×
35
    templateUrl: './select.component.html',
36
    providers: [
×
37
        {
×
38
            provide: NG_VALUE_ACCESSOR,
×
39
            useExisting: forwardRef(() => ThySelectComponent),
×
40
            multi: true
×
41
        }
×
42
    ],
43
    standalone: true,
44
    imports: [ThyInputDirective, FormsModule, ThyIconComponent, NgIf],
×
45
    host: {
×
46
        '[attr.tabindex]': 'tabIndex',
47
        '(focus)': 'onFocus($event)',
48
        '(blur)': 'onBlur($event)'
×
49
    }
×
50
})
51
export class ThySelectComponent extends _MixinBase implements ControlValueAccessor, OnInit {
52
    @ViewChild('select', { static: true }) selectElement: ElementRef<any>;
×
53

×
54
    // The internal data model
55
    _innerValue: any = null;
×
56
    _disabled = false;
57
    _size: InputSize;
58
    _expandOptions = false;
×
59

60
    private hostRenderer = useHostRenderer();
61

×
62
    @HostBinding('class.thy-select') _isSelect = true;
×
63

×
64
    @Input()
65
    set thySize(value: InputSize) {
1✔
66
        this._size = value;
67
    }
68

1✔
69
    @Input() name: string;
70

71
    @Input() @InputBoolean() thyAllowClear = false;
72

73
    writeValue(obj: any): void {
74
        if (obj !== this._innerValue) {
75
            this._innerValue = obj;
76
        }
1✔
77
    }
78

79
    setDisabledState?(isDisabled: boolean): void {
80
        this._disabled = isDisabled;
1✔
81
    }
82

83
    constructor(private elementRef: ElementRef) {
84
        super();
85
    }
86

87
    ngModelChange() {
×
88
        this.onChangeFn(this._innerValue);
89
        this.onTouchedFn();
90
    }
91

92
    ngOnInit() {
93
        const classes = this._size ? [`thy-select-${this._size}`] : [];
94
        this.hostRenderer.updateClass(classes);
95
    }
96

97
    onBlur(event: FocusEvent) {
98
        if (elementMatchClosest(event?.relatedTarget as HTMLElement, 'thy-select')) {
99
            return;
100
        }
101
        this.onTouchedFn();
102
    }
103

104
    onFocus(event?: Event) {
105
        this.selectElement.nativeElement.focus();
106
    }
107

108
    clearSelectValue(event: Event) {
109
        event.stopPropagation();
110
        this._innerValue = '';
111
        this.onChangeFn(this._innerValue);
112
    }
113
}
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