Skip to content

Commit 363d452

Browse files
authored
Merge pull request #6739 from IgniteUI/pbozhinov/switch-docs-annotations-9.0.x
docs(igxSwitch): updates API Docs for the igxSwitch
2 parents b49c370 + 3187b14 commit 363d452

File tree

1 file changed

+87
-85
lines changed

1 file changed

+87
-85
lines changed

projects/igniteui-angular/src/lib/switch/switch.component.ts

Lines changed: 87 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,22 @@ export interface IChangeSwitchEventArgs extends IBaseEventArgs {
2929
const noop = () => { };
3030
let nextId = 0;
3131
/**
32-
* **Ignite UI for Angular Switch** -
33-
* [Documentation](https://www.infragistics.com/products/ignite-ui-angular/angular/components/switch.html)
32+
*
33+
* The Switch component is a binary choice selection component.
34+
*
35+
* @igxModule IgxSwitchModule
36+
*
37+
* @igxTheme igx-switch-theme, igx-tooltip-theme
38+
*
39+
* @igxKeywords switch, states, tooltip
40+
*
41+
* @igxGroup Data Entry & Display
42+
*
43+
* @remarks
3444
*
3545
* The Ignite UI Switch lets the user toggle between on/off or true/false states.
3646
*
37-
* Example:
47+
* @example
3848
* ```html
3949
* <igx-switch [checked]="true">
4050
* Simple switch
@@ -48,228 +58,208 @@ let nextId = 0;
4858
})
4959
export class IgxSwitchComponent implements ControlValueAccessor, EditorProvider {
5060
/**
51-
*@hidden
61+
* @hidden
62+
* @internal
5263
*/
5364
protected _value: any;
5465
/**
55-
* Returns reference to the native checkbox element.
66+
* Returns a reference to the native checkbox element.
67+
*
68+
* @example
5669
* ```typescript
5770
* let checkboxElement = this.switch.nativeCheckbox;
5871
* ```
59-
* @memberof IgxSwitchComponent
6072
*/
6173
@ViewChild('checkbox', { static: true }) public nativeCheckbox: ElementRef;
6274
/**
6375
* Returns reference to the native label element.
76+
*
77+
* @example
6478
* ```typescript
6579
* let labelElement = this.switch.nativeLabel;
6680
* ```
67-
* @memberof IgxSwitchComponent
6881
*/
6982
@ViewChild('label', { static: true }) public nativeLabel;
7083
/**
7184
* Returns reference to the label placeholder element.
85+
*
86+
* @example
7287
* ```typescript
73-
* let labelPlaceholder = this.switch.placeholderLabel;
88+
* let labelPlaceholder = this.switch.placeholderLabel;
7489
* ```
75-
* @memberof IgxSwitchComponent
7690
*/
7791
@ViewChild('placeholderLabel', { static: true }) public placeholderLabel;
7892

7993
/**
8094
* Sets/gets the `id` of the switch component.
8195
* If not set, the `id` of the first switch component will be `"igx-switch-0"`.
96+
*
97+
* @example
8298
* ```html
8399
* <igx-switch id="my-first-switch"></igx-switch>
84100
* ```
85-
* ```typescript
86-
* let switchId = this.switch.id;
87-
* ```
88-
* @memberof IgxSwitchComponent
89101
*/
90102
@HostBinding('attr.id')
91103
@Input() public id = `igx-switch-${nextId++}`;
92104
/**
93-
* Sets/gets the id of the `label` element in the switch component.
105+
* Sets/gets the id of the `label` element of the switch component.
94106
* If not set, the label of the first switch component will have value `"igx-switch-0-label"`.
107+
*
108+
* @example
95109
* ```html
96110
* <igx-switch labelId="Label1"></igx-switch>
97111
* ```
98-
* ```typescript
99-
* let labelId = this.switch.labelId;
100-
* ```
101-
* @memberof IgxSwitchComponent
102112
*/
103113
@Input() public labelId = `${this.id}-label`;
104114
/**
105115
* Sets/gets the `value` attribute of the switch component.
116+
*
117+
* @example
106118
* ```html
107-
* <igx-switch [value] = "switchValue"></igx-switch>
108-
* ```
109-
* ```typescript
110-
* let value = this.switch.value;
119+
* <igx-switch [value]="switchValue"></igx-switch>
111120
* ```
112-
* @memberof IgxSwitchComponent
113121
*/
114122
@Input() public value: any;
115123
/**
116124
* Sets/gets the `name` attribute of the switch component.
125+
*
126+
* @example
117127
* ```html
118-
* <igx-switch name = "Switch1"></igx-switch>
119-
* ```
120-
* ```typescript
121-
* let name = this.switch.name;
128+
* <igx-switch name="Switch1"></igx-switch>
122129
* ```
123-
* @memberof IgxSwitchComponent
124130
*/
125131
@Input() public name: string;
126132
/**
127133
* Sets/gets the value of the `tabindex` attribute.
134+
*
135+
* @example
128136
* ```html
129137
* <igx-switch [tabindex]="1"></igx-switch>
130138
* ```
131-
* ```typescript
132-
* let tabIndex = this.switch.tabindex;
133-
* ```
134-
* @memberof IgxSwitchComponent
135139
*/
136140
@Input() public tabindex: number = null;
137141
/**
138142
* Sets/gets the position of the `label` in the switch component.
139143
* If not set, `labelPosition` will have value `"after"`.
144+
*
145+
* @example
140146
* ```html
141147
* <igx-switch labelPosition="before"></igx-switch>
142148
* ```
143-
* ```typescript
144-
* let labelPosition = this.switch.labelPosition;
145-
* ```
146-
* @memberof IgxSwitchComponent
147149
*/
148150
@Input() public labelPosition: SwitchLabelPosition | string = 'after';
149151
/**
150152
* Enables/Disables the ripple effect
151153
* If not set, `disableRipple` will have value `false`.
154+
*
155+
* @example
152156
* ```html
153157
* <igx-switch [disableRipple]="true"></igx-switch>
154158
* ```
155-
* ```typescript
156-
* let isRippleDisabled = this.switch.disableRipple;
157-
* ```
158-
* @memberof IgxSwitchComponent
159159
*/
160160
@Input() public disableRipple = false;
161161
/**
162162
* Sets/gets whether switch is required.
163163
* If not set, `required` will have value `false`.
164+
*
165+
* @example
164166
* ```html
165167
* <igx-switch [required]="true"></igx-switch>
166168
* ```
167-
* ```typescript
168-
* let isRequired = this.switch.required;
169-
* ```
170-
* @memberof IgxSwitchComponent
171169
*/
172170
@Input() public required = false;
173171
/**
174172
* Sets/gets the `aria-labelledBy` attribute.
175173
* If not set, the value of `aria-labelledBy` will be equal to the value of `labelId` attribute.
174+
*
175+
* @example
176176
* ```html
177177
* <igx-switch aria-labelledby = "Label1"></igx-switch>
178178
* ```
179-
* ```typescript
180-
* let ariaLabelledBy = this.switch.ariaLabelledBy;
181-
* ```
182-
* @memberof IgxSwitchComponent
183179
*/
184180
@Input('aria-labelledby')
185181
public ariaLabelledBy = this.labelId;
186182
/**
187183
* Sets/gets the value of the `aria-label` attribute.
184+
*
185+
* @example
188186
* ```html
189187
* <igx-switch aria-label="Label1"></igx-switch>
190188
* ```
191-
* ```typescript
192-
* let ariaLabel = this.switch.ariaLabel;
193-
* ```
194-
* @memberof IgxSwitchComponent
195189
*/
196190
@Input('aria-label')
197191
public ariaLabel: string | null = null;
198192
/**
199193
* An event that is emitted after the switch state is changed.
200194
* Provides references to the `IgxSwitchComponent` and the `checked` property as event arguments.
201-
* @memberof IgxSwitchComponent
202195
*/
203196
@Output()
204197
readonly change: EventEmitter<IChangeSwitchEventArgs> = new EventEmitter<IChangeSwitchEventArgs>();
205198
/**
206-
*@hidden
207-
* @memberof IgxSwitchComponent
199+
* @hidden
200+
* @internal
208201
*/
209202
private _onTouchedCallback: () => void = noop;
210203
/**
211-
*@hidden
212-
* @memberof IgxSwitchComponent
204+
* @hidden
205+
* @internal
213206
*/
214207
private _onChangeCallback: (_: any) => void = noop;
215208
/**
216209
* Returns the class of the switch component.
210+
*
211+
* @example
217212
* ```typescript
218213
* let switchClass = this.switch.cssClass;
219214
* ```
220-
* @memberof IgxSwitchComponent
221215
*/
222216
@HostBinding('class.igx-switch')
223217
public cssClass = 'igx-switch';
224218
/**
225219
* Sets/gets whether the switch is on or off.
226220
* Default value is 'false'.
221+
*
222+
* @example
227223
* ```html
228-
* <igx-switch [checked] = "true"></igx-switch>
229-
* ```
230-
* ```typescript
231-
* let isChecked = this.switch.checked;
224+
* <igx-switch [checked]="true"></igx-switch>
232225
* ```
233-
* @memberof IgxSwitchComponent
234226
*/
235227
@HostBinding('class.igx-switch--checked')
236228
@Input() public checked = false;
237229
/**
238230
* Sets/gets the `disabled` attribute.
239231
* Default value is `false`.
232+
*
233+
* @example
240234
* ```html
241-
* <igx-switch [disabled] = "true"><igx-switch>
242-
* ```
243-
* ```typescript
244-
* let isDisabled = this.switch.disabled;
235+
* <igx-switch [disabled]="true"><igx-switch>
245236
* ```
246-
* @memberof IgxSwitchComponent
247237
*/
248238
@HostBinding('class.igx-switch--disabled')
249239
@Input() public disabled = false;
250240
/**
251241
* Sets/gets whether the switch component is on focus.
252242
* Default value is `false`.
243+
*
244+
* @example
253245
* ```typescript
254246
* this.switch.focused = true;
255247
* ```
256-
* ```typescript
257-
* let isFocused = this.switch.focused;
258-
* ```
259-
* @memberof IgxSwitchComponent
260248
*/
261249
@HostBinding('class.igx-switch--focused')
262250
public focused = false;
263251
/**
264-
*@hidden
252+
* @hidden
253+
* @internal
265254
*/
266255
public inputId = `${this.id}-input`;
267256
/**
268257
* Toggles the checked state of the switch.
258+
*
259+
* @example
269260
* ```typescript
270261
* this.switch.toggle();
271262
* ```
272-
* @memberof IgxSwitchComponent
273263
*/
274264
public toggle() {
275265
if (this.disabled) {
@@ -282,13 +272,15 @@ export class IgxSwitchComponent implements ControlValueAccessor, EditorProvider
282272
this._onChangeCallback(this.checked);
283273
}
284274
/**
285-
*@hidden
275+
* @hidden
276+
* @internal
286277
*/
287278
public _onSwitchChange(event) {
288279
event.stopPropagation();
289280
}
290281
/**
291-
*@hidden
282+
* @hidden
283+
* @internal
292284
*/
293285
public _onSwitchClick(event) {
294286
event.stopPropagation();
@@ -299,38 +291,46 @@ export class IgxSwitchComponent implements ControlValueAccessor, EditorProvider
299291
}
300292
}
301293
/**
302-
*@hidden
294+
* @hidden
295+
* @internal
303296
*/
304297
public _onLabelClick(event) {
305298
this.toggle();
306299
}
307300
/**
308-
*@hidden
301+
* @hidden
302+
* @internal
309303
*/
310304
public onFocus(event) {
311305
this.focused = true;
312306
}
313307
/**
314-
*@hidden
308+
* @hidden
309+
* @internal
315310
*/
316311
public onBlur(event) {
317312
this.focused = false;
318313
this._onTouchedCallback();
319314
}
320315
/**
321-
*@hidden
316+
* @hidden
317+
* @internal
322318
*/
323319
public writeValue(value) {
324320
this._value = value;
325321
this.checked = !!this._value;
326322
}
327-
/** @hidden */
328-
getEditElement() {
323+
/**
324+
* @hidden
325+
* @internal
326+
* */
327+
public getEditElement() {
329328
return this.nativeCheckbox.nativeElement;
330329
}
331330

332331
/**
333-
*@hidden
332+
* @hidden
333+
* @internal
334334
*/
335335
public get labelClass(): string {
336336
switch (this.labelPosition) {
@@ -342,11 +342,13 @@ export class IgxSwitchComponent implements ControlValueAccessor, EditorProvider
342342
}
343343
}
344344
/**
345-
*@hidden
345+
* @hidden
346+
* @internal
346347
*/
347348
public registerOnChange(fn: (_: any) => void) { this._onChangeCallback = fn; }
348349
/**
349-
*@hidden
350+
* @hidden
351+
* @internal
350352
*/
351353
public registerOnTouched(fn: () => void) { this._onTouchedCallback = fn; }
352354
}

0 commit comments

Comments
 (0)