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

atinc / ngx-tethys / 0bbb2cec-209e-4d8a-b1b3-6bc54e05daa6

04 Sep 2023 08:40AM UTC coverage: 15.616% (-74.6%) from 90.2%
0bbb2cec-209e-4d8a-b1b3-6bc54e05daa6

Pull #2829

circleci

cmm-va
fix: add test
Pull Request #2829: fix: add tabIndex

300 of 6386 branches covered (0.0%)

Branch coverage included in aggregate %.

78 of 78 new or added lines in 26 files covered. (100.0%)

2849 of 13779 relevant lines covered (20.68%)

83.41 hits per line

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

16.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' | '';
13

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

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

×
48
    private hostRenderer = useHostRenderer();
×
49

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

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

57
    @Input() name: string;
×
58

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

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

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

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

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

1✔
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-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