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

atinc / ngx-tethys / #102

26 May 2026 08:11AM UTC coverage: 91.111% (+0.7%) from 90.407%
#102

push

web-flow
build: bump docgeni to 2.8.0-next.5 (#3809)

4571 of 5491 branches covered (83.25%)

Branch coverage included in aggregate %.

13141 of 13949 relevant lines covered (94.21%)

966.75 hits per line

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

90.0
/src/select/native-select/native-select.component.ts
1
import { Component, forwardRef, OnInit, input, viewChild, model, signal, ElementRef } 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
import { useHostRenderer } from '@tethys/cdk/dom';
6
import { ThyIcon } from 'ngx-tethys/icon';
7
import { ThyInputDirective } from 'ngx-tethys/input';
8
import { SafeAny } from 'ngx-tethys/types';
9

10
export type InputSize = 'xs' | 'sm' | 'md' | 'lg' | '';
11

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

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

10✔
40
    readonly innerValue = model<SafeAny>(null);
41

10✔
42
    readonly disabled = signal<boolean>(false);
43

10✔
44
    private hostRenderer = useHostRenderer();
45

10✔
46
    readonly thySize = input<InputSize>();
47

10✔
48
    readonly name = input<string>();
49

10✔
50
    readonly thyAllowClear = input(false, { transform: coerceBooleanProperty });
51

10✔
52
    writeValue(obj: any): void {
53
        if (obj !== this.innerValue()) {
54
            this.innerValue.set(obj);
18✔
55
        }
9✔
56
    }
57

58
    setDisabledState?(isDisabled: boolean): void {
59
        this.disabled.set(isDisabled);
60
    }
19✔
61

62
    constructor() {
63
        super();
64
    }
10✔
65

66
    ngModelChange() {
67
        this.onChangeFn(this.innerValue());
68
        this.onTouchedFn();
×
69
    }
×
70

71
    ngOnInit() {
72
        const size = this.thySize();
73
        const classes = size ? [`thy-select-${size}`] : [];
9✔
74
        this.hostRenderer.updateClass(classes);
9!
75
    }
9✔
76

77
    onBlur(event: FocusEvent) {
78
        if (elementMatchClosest(event?.relatedTarget as HTMLElement, 'thy-native-select')) {
79
            return;
2✔
80
        }
1✔
81
        this.onTouchedFn();
82
    }
1✔
83

84
    onFocus(event?: Event) {
85
        this.selectElement().nativeElement.focus();
86
    }
1✔
87

88
    clearSelectValue(event: Event) {
89
        event.stopPropagation();
90
        this.innerValue.set('');
1✔
91
        this.onChangeFn(this.innerValue());
1✔
92
    }
1✔
93
}
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

© 2026 Coveralls, Inc