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

atinc / ngx-tethys / 5af4dda6-8936-4a96-ad62-339570f9c292

22 Feb 2024 08:45AM UTC coverage: 90.604%. Remained the same
5af4dda6-8936-4a96-ad62-339570f9c292

Pull #3022

circleci

why520crazy
build: release 17.0.0-next.1
Pull Request #3022: feat: upgrade ng to 17 #INFR-11427 (#3021)

5425 of 6642 branches covered (81.68%)

Branch coverage included in aggregate %.

13504 of 14250 relevant lines covered (94.76%)

981.28 hits per line

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

91.67
/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 { TabIndexDisabledControlValueAccessorMixin, InputBoolean } from 'ngx-tethys/core';
4
import { elementMatchClosest } from 'ngx-tethys/util';
5

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

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

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

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

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

9✔
48
    private hostRenderer = useHostRenderer();
49

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

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

1✔
57
    @Input() name: string;
58

59
    @Input() @InputBoolean() thyAllowClear = false;
1✔
60

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

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

71
    constructor(private elementRef: ElementRef) {
72
        super();
73
    }
74

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

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

85
    onBlur(event: FocusEvent) {
10✔
86
        if (elementMatchClosest(event?.relatedTarget as HTMLElement, 'thy-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

© 2026 Coveralls, Inc