@@ -46,50 +46,240 @@ let nextId = 0;
46
46
templateUrl : 'checkbox.component.html'
47
47
} )
48
48
export class IgxCheckboxComponent implements ControlValueAccessor {
49
+ /**
50
+ *@hidden
51
+ */
49
52
protected _value : any ;
50
-
53
+ /**
54
+ * Returns reference to the native checkbox element.
55
+ * ```typescript
56
+ * let checkboxElement = this.checkbox.checkboxElement;
57
+ * ```
58
+ * @memberof IgxSwitchComponent
59
+ */
51
60
@ViewChild ( 'checkbox' ) public nativeCheckbox ;
61
+ /**
62
+ * Returns reference to the native label element.
63
+ * ```typescript
64
+ * let labelElement = this.checkbox.nativeLabel;
65
+ * ```
66
+ * @memberof IgxSwitchComponent
67
+ */
52
68
@ViewChild ( 'label' ) public nativeLabel ;
69
+ /**
70
+ * Returns reference to the label placeholder element.
71
+ * ```typescript
72
+ * let labelPlaceholder = this.checkbox.placeholderLabel;
73
+ * ```
74
+ * @memberof IgxSwitchComponent
75
+ */
53
76
@ViewChild ( 'placeholderLabel' ) public placeholderLabel ;
54
-
77
+ /**
78
+ * Sets/gets the `id` of the checkbox component.
79
+ * If not set, the `id` of the first checkbox component will be `"igx-checkbox-0"`.
80
+ * ```html
81
+ * <igx-checkbox id="my-first-checkbox"></igx-checkbox>
82
+ * ```
83
+ * ```typescript
84
+ * let checkboxId = this.checkbox.id;
85
+ * ```
86
+ * @memberof IgxCheckboxComponent
87
+ */
55
88
@HostBinding ( 'attr.id' )
56
89
@Input ( ) public id = `igx-checkbox-${ nextId ++ } ` ;
90
+ /**
91
+ * Sets/gets the id of the `label` element.
92
+ * If not set, the id of the `label` in the first checkbox component will be `"igx-checkbox-0-label"`.
93
+ * ```html
94
+ * <igx-checkbox labelId = "Label1"></igx-checkbox>
95
+ * ```
96
+ * ```typescript
97
+ * let labelId = this.checkbox.labelId;
98
+ * ```
99
+ * @memberof IgxCheckboxComponent
100
+ */
57
101
@Input ( ) public labelId = `${ this . id } -label` ;
102
+ /**
103
+ * Sets/gets the `value` attribute.
104
+ * ```html
105
+ * <igx-checkbox [value] = "'CheckboxValue'"></igx-checkbox>
106
+ * ```
107
+ * ```typescript
108
+ * let value = this.checkbox.value;
109
+ * ```
110
+ * @memberof IgxCheckboxComponent
111
+ */
58
112
@Input ( ) public value : any ;
113
+ /**
114
+ * Sets/gets the `name` attribute.
115
+ * ```html
116
+ * <igx-checkbox name = "Checkbox1"></igx-checkbox>
117
+ * ```
118
+ * ```typescript
119
+ * let name = this.checkbox.name;
120
+ * ```
121
+ * @memberof IgxCheckboxComponent
122
+ */
59
123
@Input ( ) public name : string ;
124
+ /**
125
+ * Sets/gets the value of the `tabindex` attribute.
126
+ * ```html
127
+ * <igx-checkbox [tabindex] = "1"></igx-checkbox>
128
+ * ```
129
+ * ```typescript
130
+ * let tabIndex = this.checkbox.tabindex;
131
+ * ```
132
+ * @memberof IgxCheckboxComponent
133
+ */
60
134
@Input ( ) public tabindex : number = null ;
135
+ /**
136
+ * Sets/gets the position of the `label`.
137
+ * If not set, the `labelPosition` will have value `"after"`.
138
+ * ```html
139
+ * <igx-checkbox labelPosition = "before"></igx-checkbox>
140
+ * ```
141
+ * ```typescript
142
+ * let labelPosition = this.checkbox.labelPosition;
143
+ * ```
144
+ * @memberof IgxCheckboxComponent
145
+ */
61
146
@Input ( ) public labelPosition : LabelPosition | string = LabelPosition . AFTER ;
147
+ /**
148
+ * Enables/Disables the ripple effect.
149
+ * If not set, `disableRipple` will have value `false`.
150
+ * ```html
151
+ * <igx-checkbox [disableRipple] = "true"></igx-checkbox>
152
+ * ```
153
+ * ```typescript
154
+ * let isRippleDisabled = this.checkbox.desableRipple;
155
+ * ```
156
+ * @memberof IgxCheckboxComponent
157
+ */
62
158
@Input ( ) public disableRipple = false ;
159
+ /**
160
+ * Sets/gets whether the checkbox is required.
161
+ * If not set, `required` will have value `false`.
162
+ * ```html
163
+ * <igx-checkbox [required] = "true"></igx-checkbox>
164
+ * ```
165
+ * ```typescript
166
+ * let isRequired = this.checkbox.required;
167
+ * ```
168
+ * @memberof IgxCheckboxComponent
169
+ */
63
170
@Input ( ) public required = false ;
64
-
171
+ /**
172
+ * Sets/gets the `aria-labelledby` attribute.
173
+ * If not set, the `aria-labelledby` will be equal to the value of `labelId` attribute.
174
+ * ```html
175
+ * <igx-checkbox aria-labelledby = "Checkbox1"></igx-checkbox>
176
+ * ```
177
+ * ```typescript
178
+ * let ariaLabelledBy = this.checkbox.ariaLabelledBy;
179
+ * ```
180
+ * @memberof IgxCheckboxComponent
181
+ */
65
182
@Input ( 'aria-labelledby' )
66
183
public ariaLabelledBy = this . labelId ;
67
-
184
+ /**
185
+ * Sets/gets the value of the `aria-label` attribute.
186
+ * ```html
187
+ * <igx-checkbox aria-label = "Checkbox1"></igx-checkbox>
188
+ * ```
189
+ * ```typescript
190
+ * let ariaLabel = this.checkbox.aruaLabel;
191
+ * ```
192
+ * @memberof IgxCheckboxComponent
193
+ */
68
194
@Input ( 'aria-label' )
69
195
public ariaLabel : string | null = null ;
70
-
196
+ /**
197
+ * An event that is emitted after the checkbox state is changed.
198
+ * Provides references to the `IgxCheckboxComponent` and the `checked` property as event arguments.
199
+ * @memberof IgxCheckboxComponent
200
+ */
71
201
@Output ( )
72
202
readonly change : EventEmitter < IChangeCheckboxEventArgs > = new EventEmitter < IChangeCheckboxEventArgs > ( ) ;
73
-
203
+ /**
204
+ * Returns the class of the checkbox component.
205
+ * ```typescript
206
+ * let class = this.checkbox.cssClass;
207
+ * ```
208
+ * @memberof IgxCheckboxComponent
209
+ */
74
210
@HostBinding ( 'class.igx-checkbox' )
75
211
public cssClass = 'igx-checkbox' ;
76
-
212
+ /**
213
+ * Sets/gets whether the checkbox component is on focus.
214
+ * Default value is `false`.
215
+ * ```typescript
216
+ * this.checkbox.focused = true;
217
+ * ```
218
+ * ```typescript
219
+ * let isFocused = this.checkbox.focused;
220
+ * ```
221
+ * @memberof IgxCheckboxComponent
222
+ */
77
223
@HostBinding ( 'class.igx-checkbox--focused' )
78
224
public focused = false ;
79
-
225
+ /**
226
+ * Sets/gets the checkbox indeterminate visual state.
227
+ * Default value is `false`;
228
+ * ```html
229
+ * <igx-checkbox [indeterminate] = "true"></igx-checkbox>
230
+ * ```
231
+ * ```typescript
232
+ * let isIndeterminate = this.checkbox.indeterminate;
233
+ * ```
234
+ * @memberof IgxCheckboxComponent
235
+ */
80
236
@HostBinding ( 'class.igx-checkbox--indeterminate' )
81
237
@Input ( ) public indeterminate = false ;
82
-
238
+ /**
239
+ * Sets/gets whether the checkbox is checked.
240
+ * Default value is `false`.
241
+ * ```html
242
+ * <igx-checkbox [checked] = "true"></igx-checkbox>
243
+ * ```
244
+ * ```typescript
245
+ * let isChecked = this.checkbox.checked;
246
+ * ```
247
+ * @memberof IgxCheckboxComponent
248
+ */
83
249
@HostBinding ( 'class.igx-checkbox--checked' )
84
250
@Input ( ) public checked = false ;
85
-
251
+ /**
252
+ * Sets/gets whether the checkbox is disabled.
253
+ * Default value is `false`.
254
+ * ```html
255
+ * <igx-checkbox [disabled] = "true"></igx-checkbox>
256
+ * ```
257
+ * ```typescript
258
+ * let isDesabled = this.checkbox.disabled;
259
+ * ```
260
+ * @memberof IgxCheckboxComponent
261
+ */
86
262
@HostBinding ( 'class.igx-checkbox--disabled' )
87
263
@Input ( ) public disabled = false ;
88
-
264
+ /**
265
+ *@hidden
266
+ */
89
267
public inputId = `${ this . id } -input` ;
268
+ /**
269
+ *@hidden
270
+ */
90
271
private _onTouchedCallback : ( ) => void = noop ;
272
+ /**
273
+ * @hidden
274
+ */
91
275
private _onChangeCallback : ( _ : any ) => void = noop ;
92
-
276
+ /**
277
+ * If `disabled` is `false`, switches the `checked` state.
278
+ * ```typescript
279
+ * this.checkbox.toggle();
280
+ * ```
281
+ * @memberof IgxCheckboxComponent
282
+ */
93
283
public toggle ( ) {
94
284
if ( this . disabled ) {
95
285
return ;
@@ -102,13 +292,17 @@ export class IgxCheckboxComponent implements ControlValueAccessor {
102
292
this . change . emit ( { checked : this . checked , checkbox : this } ) ;
103
293
this . _onChangeCallback ( this . checked ) ;
104
294
}
105
-
295
+ /**
296
+ *@hidden
297
+ */
106
298
public _onCheckboxChange ( event ) {
107
299
// We have to stop the original checkbox change event
108
300
// from bubbling up since we emit our own change event
109
301
event . stopPropagation ( ) ;
110
302
}
111
-
303
+ /**
304
+ *@hidden
305
+ */
112
306
public _onCheckboxClick ( event ) {
113
307
// Since the original checkbox is hidden and the label
114
308
// is used for styling and to change the checked state of the checkbox,
@@ -117,29 +311,39 @@ export class IgxCheckboxComponent implements ControlValueAccessor {
117
311
event . stopPropagation ( ) ;
118
312
this . toggle ( ) ;
119
313
}
120
-
314
+ /**
315
+ *@hidden
316
+ */
121
317
public _onLabelClick ( event ) {
122
318
// We use a span element as a placeholder label
123
319
// in place of the native label, we need to emit
124
320
// the change event separately here alongside
125
321
// the click event emitted on click
126
322
this . toggle ( ) ;
127
323
}
128
-
324
+ /**
325
+ *@hidden
326
+ */
129
327
public onFocus ( event ) {
130
328
this . focused = true ;
131
329
}
132
-
330
+ /**
331
+ *@hidden
332
+ */
133
333
public onBlur ( event ) {
134
334
this . focused = false ;
135
335
this . _onTouchedCallback ( ) ;
136
336
}
137
-
337
+ /**
338
+ *@hidden
339
+ */
138
340
public writeValue ( value ) {
139
341
this . _value = value ;
140
342
this . checked = ! ! this . _value ;
141
343
}
142
-
344
+ /**
345
+ *@hidden
346
+ */
143
347
public get labelClass ( ) : string {
144
348
switch ( this . labelPosition ) {
145
349
case LabelPosition . BEFORE :
@@ -149,8 +353,13 @@ export class IgxCheckboxComponent implements ControlValueAccessor {
149
353
return `${ this . cssClass } __label` ;
150
354
}
151
355
}
152
-
356
+ /**
357
+ *@hidden
358
+ */
153
359
public registerOnChange ( fn : ( _ : any ) => void ) { this . _onChangeCallback = fn ; }
360
+ /**
361
+ *@hidden
362
+ */
154
363
public registerOnTouched ( fn : ( ) => void ) { this . _onTouchedCallback = fn ; }
155
364
}
156
365
@@ -168,7 +377,9 @@ export const IGX_CHECKBOX_REQUIRED_VALIDATOR: Provider = {
168
377
providers : [ IGX_CHECKBOX_REQUIRED_VALIDATOR ]
169
378
} )
170
379
export class IgxCheckboxRequiredDirective extends CheckboxRequiredValidator { }
171
-
380
+ /**
381
+ *The IgxCheckboxModule provides the {@link IgxCheckboxComponent} inside your application.
382
+ */
172
383
@NgModule ( {
173
384
declarations : [ IgxCheckboxComponent , IgxCheckboxRequiredDirective ] ,
174
385
exports : [ IgxCheckboxComponent , IgxCheckboxRequiredDirective ] ,
0 commit comments