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

atinc / ngx-tethys / edbc1d43-1648-411a-a6bc-f24c9aa3f654

27 Mar 2025 06:13AM UTC coverage: 90.236% (+0.06%) from 90.179%
edbc1d43-1648-411a-a6bc-f24c9aa3f654

push

circleci

web-flow
Merge pull request #3282 from atinc/v19.0.0-next

5598 of 6865 branches covered (81.54%)

Branch coverage included in aggregate %.

8 of 8 new or added lines in 7 files covered. (100.0%)

157 existing lines in 46 files now uncovered.

13357 of 14141 relevant lines covered (94.46%)

992.51 hits per line

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

91.43
/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
19
 */
13✔
20
@Component({
21
    selector: 'thy-native-select',
22
    templateUrl: './native-select.component.html',
18✔
23
    providers: [
9✔
24
        {
25
            provide: NG_VALUE_ACCESSOR,
26
            useExisting: forwardRef(() => ThyNativeSelect),
27
            multi: true
19✔
28
        }
29
    ],
30
    imports: [ThyInputDirective, FormsModule, ThyIcon],
10✔
31
    host: {
10✔
32
        '[attr.tabindex]': 'tabIndex',
33
        '(focus)': 'onFocus($event)',
10✔
34
        '(blur)': 'onBlur($event)'
10✔
35
    }
10✔
36
})
10✔
37
export class ThyNativeSelect extends TabIndexDisabledControlValueAccessorMixin implements ControlValueAccessor, OnInit {
10✔
38
    private elementRef = inject(ElementRef);
10✔
39

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

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

48
    private hostRenderer = useHostRenderer();
49

2✔
50
    @HostBinding('class.thy-select') _isSelect = true;
1✔
51

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

57
    @Input() name: string;
58

1✔
59
    @Input({ transform: coerceBooleanProperty }) thyAllowClear = false;
1✔
60

1✔
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();
78
    }
10✔
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