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

atinc / ngx-tethys / 4209e40d-4a53-48f5-b396-81cec1d9cc0f

15 Apr 2025 10:18AM UTC coverage: 90.175% (+0.001%) from 90.174%
4209e40d-4a53-48f5-b396-81cec1d9cc0f

push

circleci

minlovehua
feat: demo

5591 of 6865 branches covered (81.44%)

Branch coverage included in aggregate %.

76 of 80 new or added lines in 36 files covered. (95.0%)

67 existing lines in 12 files now uncovered.

13353 of 14143 relevant lines covered (94.41%)

991.7 hits per line

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

88.0
/src/shared/option/list-option/list-option.component.ts
1
import { Component, Input, HostBinding, ElementRef, ChangeDetectorRef, HostListener, inject } from '@angular/core';
2
import { Highlightable } from '@angular/cdk/a11y';
3
import { IThyOptionComponent, THY_LIST_OPTION_PARENT_COMPONENT } from '../option.token';
4
import { ThyIcon } from 'ngx-tethys/icon';
5

6
import { coerceBooleanProperty } from 'ngx-tethys/util';
7

1✔
8
let _uniqueIdCounter = 0;
9

10
/**
11
 * @private
12
 * @order 30
1✔
13
 */
14
@Component({
111✔
15
    selector: 'thy-list-option,[thy-list-option]',
111✔
16
    templateUrl: './list-option.component.html',
111✔
17
    standalone: true,
111✔
18
    imports: [ThyIcon]
111✔
19
})
111✔
20
export class ThyListOption implements IThyOptionComponent, Highlightable {
21
    element = inject<ElementRef<HTMLElement>>(ElementRef);
22
    private changeDetector = inject(ChangeDetectorRef);
494✔
23
    parentSelectionList = inject(THY_LIST_OPTION_PARENT_COMPONENT, { optional: true })!;
24

25
    @HostBinding(`class.thy-list-option`)
494✔
26
    get _isListOption() {
27
        return this.parentSelectionList.layout === 'list';
UNCOV
28
    }
×
29

30
    @HostBinding(`class.thy-grid-option`)
31
    get _parentLayout() {
494✔
32
        return this.parentSelectionList.layout === 'grid';
33
    }
34

6!
35
    @HostBinding(`attr.role`) _role = 'option';
6✔
36

6✔
37
    @HostBinding(`attr.tabindex`) _tabIndex = -1;
38

39
    @Input() id = `thy-list-option-${_uniqueIdCounter++}`;
40

41
    @Input() thyValue: any;
42

43
    @Input({ transform: coerceBooleanProperty })
44
    set thyDisabled(value: boolean) {
45
        this.disabled = value;
46
    }
47

48
    @HostBinding(`class.disabled`) disabled?: boolean;
13✔
49

13✔
50
    /** Whether the option is selected. */
51
    @HostBinding(`class.active`)
52
    get selected() {
3✔
53
        return this.parentSelectionList.isSelected(this);
54
    }
55

56
    @HostListener('click', ['$event'])
57
    onClick(event: Event) {
58
        if (this.parentSelectionList.multiple || !this.parentSelectionList.isSelected(this)) {
UNCOV
59
            this.parentSelectionList.toggleOption(this, event);
×
60
            this.parentSelectionList.setActiveOption(this);
61
        }
1✔
62
    }
63

64
    // @HostListener('focus', ['$event'])
65
    // onFocus(event: Event) {
66
    //     this.parentSelectionList.setFocusedOption(this, event);
67
    // }
68

69
    /** Allows for programmatic focusing of the option. */
70
    // focus(origin?: FocusOrigin): void {
71
    //     this.element.nativeElement.focus();
72
    // }
73

74
    setActiveStyles(): void {
1✔
75
        this.element.nativeElement.classList.add('hover');
76
        this.parentSelectionList.scrollIntoView(this);
77
    }
78

79
    setInactiveStyles(): void {
80
        this.element.nativeElement.classList.remove('hover');
81
    }
82

83
    /**
84
     * Returns the list item's text label. Implemented as a part of the FocusKeyManager.
85
     * @docs-private
86
     */
87
    getLabel() {
88
        return '';
89
    }
90
}
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