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

IgniteUI / igniteui-angular / 13416627295

19 Feb 2025 03:46PM CUT coverage: 91.615% (+0.02%) from 91.595%
13416627295

Pull #15246

github

web-flow
Merge 2a114cdda into 10ddb05cf
Pull Request #15246: fix(excel-export): Get correct grid column collection from row island…

12987 of 15218 branches covered (85.34%)

3 of 3 new or added lines in 1 file covered. (100.0%)

380 existing lines in 31 files now uncovered.

26385 of 28800 relevant lines covered (91.61%)

34358.69 hits per line

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

96.0
/projects/igniteui-angular/src/lib/radio/radio.component.ts
1
import {
2
    AfterViewInit,
3
    Component,
4
    EventEmitter,
5
    HostBinding,
6
    HostListener,
7
    Input,
8
    booleanAttribute
9
} from '@angular/core';
10
import { ControlValueAccessor } from '@angular/forms';
11
import { EditorProvider, EDITOR_PROVIDER } from '../core/edit-provider';
12
import { IgxRippleDirective } from '../directives/ripple/ripple.directive';
13
import { CheckboxBaseDirective } from '../checkbox/checkbox-base.directive';
14

15
/**
16
 * **Ignite UI for Angular Radio Button** -
17
 * [Documentation](https://www.infragistics.com/products/ignite-ui-angular/angular/components/radio_button.html)
18
 *
19
 * The Ignite UI Radio Button allows the user to select a single option from an available set of options that are listed side by side.
20
 *
21
 * Example:
22
 * ```html
23
 * <igx-radio>
24
 *   Simple radio button
25
 * </igx-radio>
26
 * ```
27
 */
28
@Component({
29
    selector: 'igx-radio',
30
    providers: [{
31
            provide: EDITOR_PROVIDER,
32
            useExisting: IgxRadioComponent,
33
            multi: true
34
        }],
35
    templateUrl: 'radio.component.html',
36
    imports: [IgxRippleDirective]
37
})
38
export class IgxRadioComponent
2✔
39
    extends CheckboxBaseDirective
40
    implements AfterViewInit, ControlValueAccessor, EditorProvider {
41
    /** @hidden @internal */
42
    public blurRadio = new EventEmitter();
60✔
43

44
    /**
45
     * Returns the class of the radio component.
46
     * ```typescript
47
     * let radioClass = this.radio.cssClass;
48
     * ```
49
     *
50
     * @memberof IgxRadioComponent
51
     */
52
    @HostBinding('class.igx-radio')
53
    public override cssClass = 'igx-radio';
60✔
54

55
    /**
56
     * Sets/gets  the `checked` attribute.
57
     * Default value is `false`.
58
     * ```html
59
     * <igx-radio [checked]="true"></igx-radio>
60
     * ```
61
     * ```typescript
62
     * let isChecked =  this.radio.checked;
63
     * ```
64
     *
65
     * @memberof IgxRadioComponent
66
     */
67
    @HostBinding('class.igx-radio--checked')
68
    @Input({ transform: booleanAttribute })
69
    public override set checked(value: boolean) {
70
        this._checked = value;
84✔
71
    }
72
    public override get checked() {
73
        return this._checked;
994✔
74
    }
75

76
    /**
77
     * Sets/gets  the `disabled` attribute.
78
     * Default value is `false`.
79
     * ```html
80
     * <igx-radio disabled></igx-radio>
81
     * ```
82
     * ```typescript
83
     * let isDisabled =  this.radio.disabled;
84
     * ```
85
     *
86
     * @memberof IgxRadioComponent
87
     */
88
    @HostBinding('class.igx-radio--disabled')
89
    @Input({ transform: booleanAttribute })
90
    public override disabled = false;
60✔
91

92
    /**
93
     * Sets/gets whether the radio button is invalid.
94
     * Default value is `false`.
95
     * ```html
96
     * <igx-radio invalid></igx-radio>
97
     * ```
98
     * ```typescript
99
     * let isInvalid =  this.radio.invalid;
100
     * ```
101
     *
102
     * @memberof IgxRadioComponent
103
     */
104
    @HostBinding('class.igx-radio--invalid')
105
    @Input({ transform: booleanAttribute })
106
    public override invalid = false;
60✔
107

108
    /**
109
     * Sets/gets whether the radio component is on focus.
110
     * Default value is `false`.
111
     * ```typescript
112
     * this.radio.focus = true;
113
     * ```
114
     * ```typescript
115
     * let isFocused =  this.radio.focused;
116
     * ```
117
     *
118
     * @memberof IgxRadioComponent
119
     */
120
    @HostBinding('class.igx-radio--focused')
121
    public override focused = false;
60✔
122

123
    /**
124
     * @hidden
125
     * @internal
126
     */
127
    @HostListener('change', ['$event'])
128
    public _changed(event: Event) {
129
        if (event instanceof Event) {
9!
UNCOV
130
            event.preventDefault();
×
131
        }
132
    }
133

134
    /**
135
     * @hidden
136
     */
137
    @HostListener('click')
138
    public override _onCheckboxClick() {
139
        this.select();
8✔
140
    }
141

142
    /**
143
     * Selects the current radio button.
144
     * ```typescript
145
     * this.radio.select();
146
     * ```
147
     *
148
     * @memberof IgxRadioComponent
149
     */
150
    public select() {
151
        if (!this.checked) {
13✔
152
            this.checked = true;
9✔
153
            this.change.emit({
9✔
154
                value: this.value,
155
                owner: this,
156
                checked: this.checked,
157
            });
158
            this._onChangeCallback(this.value);
9✔
159
        }
160
    }
161

162
    /**
163
     * Deselects the current radio button.
164
     * ```typescript
165
     * this.radio.deselect();
166
     * ```
167
     *
168
     * @memberof IgxRadioComponent
169
     */
170
    public deselect() {
171
        this.checked = false;
27✔
172
        this.focused = false;
27✔
173
        this.cdr.markForCheck();
27✔
174
    }
175

176
    /**
177
     * Checks whether the provided value is consistent to the current radio button.
178
     * If it is, the checked attribute will have value `true`;
179
     * ```typescript
180
     * this.radio.writeValue('radioButtonValue');
181
     * ```
182
     */
183
    public override writeValue(value: any) {
184
        this.value = this.value ?? value;
30✔
185

186
        if (value === this.value) {
30✔
187
            if (!this.checked) {
4✔
188
                this.checked = true;
4✔
189
            }
190
        } else {
191
            this.deselect();
26✔
192
        }
193
    }
194

195
    /**
196
     * @hidden
197
     */
198
    @HostListener('blur')
199
    public override onBlur() {
200
        super.onBlur();
6✔
201
        this.blurRadio.emit();
6✔
202
    }
203
}
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