• 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

14.29
/src/select/native-select/native-select.component.ts
1
import { Component, forwardRef, HostBinding, Input, OnInit, inject } from '@angular/core';
2
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
3
import { TabIndexDisabledControlValueAccessorMixin } from 'ngx-tethys/core';
4
import { coerceBooleanProperty, elementMatchClosest } from 'ngx-tethys/util';
5

6
import { ElementRef, ViewChild } from '@angular/core';
7
import { useHostRenderer } from '@tethys/cdk/dom';
8
import { ThyIcon } from 'ngx-tethys/icon';
9
import { ThyInputDirective } from 'ngx-tethys/input';
10

11
export type InputSize = 'xs' | 'sm' | 'md' | 'lg' | '';
1✔
12

13
const noop = () => {};
14

15
/**
16
 * 下拉选择
17
 * @name thy-native-select
1✔
18
 * @order 20
UNCOV
19
 */
×
20
@Component({
21
    selector: 'thy-native-select',
UNCOV
22
    templateUrl: './native-select.component.html',
×
UNCOV
23
    providers: [
×
24
        {
25
            provide: NG_VALUE_ACCESSOR,
26
            useExisting: forwardRef(() => ThyNativeSelect),
UNCOV
27
            multi: true
×
28
        }
29
    ],
UNCOV
30
    imports: [ThyInputDirective, FormsModule, ThyIcon],
×
UNCOV
31
    host: {
×
32
        '[attr.tabindex]': 'tabIndex',
UNCOV
33
        '(focus)': 'onFocus($event)',
×
UNCOV
34
        '(blur)': 'onBlur($event)'
×
UNCOV
35
    }
×
UNCOV
36
})
×
UNCOV
37
export class ThyNativeSelect extends TabIndexDisabledControlValueAccessorMixin implements ControlValueAccessor, OnInit {
×
UNCOV
38
    private elementRef = inject(ElementRef);
×
39

40
    @ViewChild('select', { static: true }) selectElement: ElementRef<any>;
41

×
42
    // The internal data model
×
43
    _innerValue: any = null;
44
    _disabled = false;
UNCOV
45
    _size: InputSize;
×
UNCOV
46
    _expandOptions = false;
×
47

48
    private hostRenderer = useHostRenderer();
UNCOV
49

×
UNCOV
50
    @HostBinding('class.thy-select') _isSelect = true;
×
51

UNCOV
52
    @Input()
×
53
    set thySize(value: InputSize) {
54
        this._size = value;
UNCOV
55
    }
×
56

57
    @Input() name: string;
UNCOV
58

×
UNCOV
59
    @Input({ transform: coerceBooleanProperty }) thyAllowClear = false;
×
UNCOV
60

×
61
    writeValue(obj: any): void {
62
        if (obj !== this._innerValue) {
1✔
63
            this._innerValue = obj;
1✔
64
        }
65
    }
66

67
    setDisabledState?(isDisabled: boolean): void {
68
        this._disabled = isDisabled;
69
    }
70

71
    constructor() {
1✔
72
        super();
73
    }
74

75
    ngModelChange() {
76
        this.onChangeFn(this._innerValue);
77
        this.onTouchedFn();
UNCOV
78
    }
×
79

80
    ngOnInit() {
81
        const classes = this._size ? [`thy-select-${this._size}`] : [];
82
        this.hostRenderer.updateClass(classes);
83
    }
84

85
    onBlur(event: FocusEvent) {
86
        if (elementMatchClosest(event?.relatedTarget as HTMLElement, 'thy-native-select')) {
87
            return;
88
        }
89
        this.onTouchedFn();
90
    }
91

92
    onFocus(event?: Event) {
93
        this.selectElement.nativeElement.focus();
94
    }
95

96
    clearSelectValue(event: Event) {
97
        event.stopPropagation();
98
        this._innerValue = '';
99
        this.onChangeFn(this._innerValue);
100
    }
101
}
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