@@ -42,12 +42,12 @@ let NEXT_ID = 0;
42
42
* **Ignite UI for Angular Button Group** -
43
43
* [Documentation](https://www.infragistics.com/products/ignite-ui-angular/angular/components/buttongroup.html)
44
44
*
45
- * The Ignite UI Button Group displays a group of buttons either vertically or horizontally. The group supports
46
- * single, multiple and toggle selection.
45
+ * The Ignite UI Button Group displays a group of buttons either vertically or horizontally. The group supports
46
+ * single, multi and singleRequired selection.
47
47
*
48
48
* Example:
49
49
* ```html
50
- * <igx-buttongroup multiSelection="true " [values]="fontOptions">
50
+ * <igx-buttongroup selectionMode="multi " [values]="fontOptions">
51
51
* </igx-buttongroup>
52
52
* ```
53
53
* The `fontOptions` value shown above is defined as:
@@ -75,7 +75,7 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
75
75
/**
76
76
* An @Input property that sets the value of the `id` attribute. If not set it will be automatically generated.
77
77
* ```html
78
- * <igx-buttongroup [id]="'igx-dialog-56'" [multiSelection ]="! multi" [values]="alignOptions">
78
+ * <igx-buttongroup [id]="'igx-dialog-56'" [selectionMode ]="' multi' " [values]="alignOptions">
79
79
* ```
80
80
*/
81
81
@HostBinding ( 'attr.id' )
@@ -96,7 +96,7 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
96
96
* //..
97
97
* ```
98
98
* ```html
99
- * <igx-buttongroup [itemContentCssClass]="style1" [multiSelection ]="! multi" [values]="alignOptions">
99
+ * <igx-buttongroup [itemContentCssClass]="style1" [selectionMode ]="' multi' " [values]="alignOptions">
100
100
* ```
101
101
*/
102
102
@Input ( )
@@ -119,12 +119,12 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
119
119
}
120
120
121
121
/**
122
- * An @Input property that enables selecting multiple buttons. By default, multi- selection is false .
122
+ * An @Input property that sets the selection mode of the buttons. By default, the selection mode is single .
123
123
* ```html
124
- * <igx-buttongroup [multiSelection ]="false " [alignment]="alignment"></igx-buttongroup>
124
+ * <igx-buttongroup [selectionMode ]="'multi' " [alignment]="alignment"></igx-buttongroup>
125
125
* ```
126
126
*/
127
- @Input ( ) public multiSelection = false ;
127
+ @Input ( ) public selectionMode : 'single' | 'singleRequired' | 'multi' = 'single' ;
128
128
129
129
/**
130
130
* An @Input property that allows setting the buttons in the button group.
@@ -149,15 +149,15 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
149
149
* //..
150
150
* ```
151
151
* ```html
152
- * <igx-buttongroup [multiSelection ]="false " [values]="cities"></igx-buttongroup>
152
+ * <igx-buttongroup [selectionMode ]="'single' " [values]="cities"></igx-buttongroup>
153
153
* ```
154
154
*/
155
155
@Input ( ) public values : any ;
156
156
157
157
/**
158
158
* An @Input property that allows you to disable the `igx-buttongroup` component. By default it's false.
159
159
* ```html
160
- * <igx-buttongroup [disabled]="true" [multiSelection ]="multi" [values]="fontOptions"></igx-buttongroup>
160
+ * <igx-buttongroup [disabled]="true" [selectionMode ]="' multi' " [values]="fontOptions"></igx-buttongroup>
161
161
* ```
162
162
*/
163
163
@Input ( )
@@ -182,7 +182,7 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
182
182
* //..
183
183
* ```
184
184
* ```html
185
- * <igx-buttongroup [multiSelection ]="false " [values]="cities" [alignment]="alignment"></igx-buttongroup>
185
+ * <igx-buttongroup [selectionMode ]="'single' " [values]="cities" [alignment]="alignment"></igx-buttongroup>
186
186
* ```
187
187
*/
188
188
@Input ( )
@@ -214,7 +214,7 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
214
214
* //...
215
215
* ```
216
216
* ```html
217
- * <igx-buttongroup #MyChild [multiSelection ]="! multi" (selected)="selectedHandler($event)"></igx-buttongroup>
217
+ * <igx-buttongroup #MyChild [selectionMode ]="' multi' " (selected)="selectedHandler($event)"></igx-buttongroup>
218
218
* <igx-toast #toast>You have made a selection!</igx-toast>
219
219
* ```
220
220
*/
@@ -232,7 +232,7 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
232
232
* //...
233
233
* ```
234
234
* ```html
235
- * <igx-buttongroup> #MyChild [multiSelection ]="multi" (deselected)="deselectedHandler($event)"></igx-buttongroup>
235
+ * <igx-buttongroup> #MyChild [selectionMode ]="' multi' " (deselected)="deselectedHandler($event)"></igx-buttongroup>
236
236
* <igx-toast #toast>You have deselected a button!</igx-toast>
237
237
* ```
238
238
*/
@@ -338,8 +338,8 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
338
338
this . values [ indexInViewButtons ] . selected = true ;
339
339
}
340
340
341
- // deselect other buttons if multiSelection is not enabled
342
- if ( ! this . multiSelection && this . selectedIndexes . length > 1 ) {
341
+ // deselect other buttons if selectionMode is not multi
342
+ if ( this . selectionMode !== 'multi' && this . selectedIndexes . length > 1 ) {
343
343
this . buttons . forEach ( ( _ , i ) => {
344
344
if ( i !== index && this . selectedIndexes . indexOf ( i ) !== - 1 ) {
345
345
this . deselectButton ( i ) ;
@@ -448,7 +448,7 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
448
448
const button = this . buttons [ index ] ;
449
449
const args : IButtonGroupEventArgs = { cancel : false , owner : this , button, index } ;
450
450
451
- if ( ! this . multiSelection ) {
451
+ if ( this . selectionMode !== 'multi' ) {
452
452
this . buttons . forEach ( ( b , i ) => {
453
453
if ( i !== index && this . selectedIndexes . indexOf ( i ) !== - 1 ) {
454
454
this . deselected . emit ( { cancel : false , owner : this , button : b , index : i } ) ;
@@ -462,9 +462,11 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
462
462
this . selectButton ( index ) ;
463
463
}
464
464
} else {
465
- this . deselected . emit ( args ) ;
466
- if ( ! args . cancel ) {
467
- this . deselectButton ( index ) ;
465
+ if ( this . selectionMode !== 'singleRequired' ) {
466
+ this . deselected . emit ( args ) ;
467
+ if ( ! args . cancel ) {
468
+ this . deselectButton ( index ) ;
469
+ }
468
470
}
469
471
}
470
472
}
0 commit comments