@@ -18,7 +18,7 @@ import {
1818 coerceNumberProperty ,
1919} from "@angular/cdk/coercion" ;
2020import { DxcToggleComponent } from "./dxc-toggle/dxc-toggle.component" ;
21- import { ChangeDetectorRef } from ' @angular/core' ;
21+ import { ChangeDetectorRef } from " @angular/core" ;
2222import { v4 as uuidv4 } from "uuid" ;
2323
2424@Component ( {
@@ -76,7 +76,7 @@ export class DxcToggleGroupComponent implements OnInit {
7676 tabIndexValue : 0 ,
7777 } ) ;
7878 constructor ( private utils : CssUtils , private ref : ChangeDetectorRef ) {
79- this . toggleGroupId = `file-input${ uuidv4 ( ) } ` ;
79+ this . toggleGroupId = `file-input${ uuidv4 ( ) } ` ;
8080 }
8181
8282 ngOnInit ( ) {
@@ -91,7 +91,7 @@ export class DxcToggleGroupComponent implements OnInit {
9191 ngAfterContentInit ( ) {
9292 // reference to the dxc-toggles and manipulating them depending on the given data
9393 if ( this . toggleGroup ) {
94- this . toggleGroup . forEach ( ( item :DxcToggleComponent , index : number ) => {
94+ this . toggleGroup . forEach ( ( item : DxcToggleComponent , index : number ) => {
9595 item . onClick . subscribe ( ( value ) => {
9696 if ( ! this . disabled ) {
9797 this . valueChanged ( value ) ;
@@ -105,11 +105,10 @@ export class DxcToggleGroupComponent implements OnInit {
105105
106106 setTimeout ( ( ) => {
107107 item . tabIndexValue = this . disabled ? - 1 : this . tabIndex ;
108- item . role = this . multiple ? ' switch' : ' radio' ;
108+ item . role = this . multiple ? " switch" : " radio" ;
109109 this . setToggleSelected ( item ) ;
110110 } ) ;
111111 } ) ;
112-
113112 }
114113 }
115114
@@ -127,8 +126,6 @@ export class DxcToggleGroupComponent implements OnInit {
127126 }
128127 }
129128
130-
131-
132129 private valueChanged ( selectedOption : any ) : void {
133130 let newSelectedOptions = [ ] ;
134131 //handle When value is defined
@@ -143,7 +140,8 @@ export class DxcToggleGroupComponent implements OnInit {
143140 }
144141 this . selectedOptions = newSelectedOptions ;
145142 } else {
146- this . selectedOptions = selectedOption === this . selectedOptions ? null : selectedOption ;
143+ this . selectedOptions =
144+ selectedOption === this . selectedOptions ? null : selectedOption ;
147145 }
148146 } else if ( this . multiple ) {
149147 newSelectedOptions = this . value . map ( ( v ) => v ) ;
@@ -153,22 +151,26 @@ export class DxcToggleGroupComponent implements OnInit {
153151 } else {
154152 newSelectedOptions . push ( selectedOption ) ;
155153 }
156- } else {
154+ } else {
157155 newSelectedOptions = selectedOption ;
158156 }
159157 this . changeSelectedToggle ( this . multiple ? selectedOption : null ) ;
160158 // Emit the new selected values
161- this . onChange . emit ( this . isControlled ? newSelectedOptions : this . selectedOptions ) ;
159+ this . onChange . emit (
160+ this . isControlled ? newSelectedOptions : this . selectedOptions
161+ ) ;
162162 }
163163
164- private changeSelectedToggle ( selectedValue ? : string ) {
164+ private changeSelectedToggle ( selectedValue ?: string ) {
165165 if ( this . toggleGroup ) {
166- if ( selectedValue ) {
167- const filterToggles = this . toggleGroup . filter ( item => item . value === selectedValue ) ;
166+ if ( selectedValue ) {
167+ const filterToggles = this . toggleGroup . filter (
168+ ( item ) => item . value === selectedValue
169+ ) ;
168170 filterToggles . forEach ( ( item ) => {
169171 this . setToggleSelected ( item ) ;
170172 } ) ;
171- } else {
173+ } else {
172174 this . toggleGroup . forEach ( ( item ) => {
173175 this . setToggleSelected ( item ) ;
174176 } ) ;
@@ -179,9 +181,13 @@ export class DxcToggleGroupComponent implements OnInit {
179181
180182 private setToggleSelected ( item : DxcToggleComponent ) {
181183 if ( this . multiple ) {
182- this . isControlled ? item . selected = this . value . includes ( item . value ) : item . selected = this . selectedOptions . includes ( item . value ) ;
184+ this . isControlled
185+ ? ( item . selected = this . value . includes ( item . value ) )
186+ : ( item . selected = this . selectedOptions . includes ( item . value ) ) ;
183187 } else {
184- this . isControlled ? item . selected = item . value === this . value : item . selected = item . value === this . selectedOptions ;
188+ this . isControlled
189+ ? ( item . selected = item . value === this . value )
190+ : ( item . selected = item . value === this . selectedOptions ) ;
185191 }
186192 }
187193
@@ -205,8 +211,7 @@ export class DxcToggleGroupComponent implements OnInit {
205211 cursor : not-allowed;
206212 }
207213 & .selected {
208- background : var (
209- --toggleGroup-selectedDisabledBackgroundColor );
214+ background : var (--toggleGroup-selectedDisabledBackgroundColor );
210215 color : var (--toggleGroup-selectedDisabledFontColor );
211216 .icon img ,
212217 .icon svg {
@@ -250,9 +255,7 @@ export class DxcToggleGroupComponent implements OnInit {
250255 fill : var (--toggleGroup-selectedFontColor );
251256 }
252257 & : active {
253- background : var (
254- --toggleGroup-selectedActiveBackgroundColor
255- );
258+ background : var (--toggleGroup-selectedActiveBackgroundColor );
256259 color : # ffffff ;
257260 }
258261 & : hover {
@@ -273,44 +276,49 @@ export class DxcToggleGroupComponent implements OnInit {
273276 display : inline-flex;
274277 flex-direction : column;
275278 ${ this . utils . getMargins ( inputs . margin ) } ;
276- label{
277- color : ${ this . disabled ? 'var(--toggleGroup-disabledLabelFontColor)' : 'var(--toggleGroup-labelFontColor)' } ;
279+ label {
280+ color : ${ this . disabled
281+ ? "var(--toggleGroup-disabledLabelFontColor)"
282+ : "var(--toggleGroup-labelFontColor)" } ;
278283 font- family: var(- - to ggleGroup- labelFontFamily);
279284 font- size: var(- - to ggleGroup- labelFontSize);
280285 font- style: var(- - to ggleGroup- labelFontStyle);
281286 font- weight: var(- - to ggleGroup- labelFontWeight);
282287 line-height: var(- - to ggleGroup- labelLineHeight);
283-
284288 }
285289
286-
287- .helperText {
288- color : ${ this . disabled ? 'var(--toggleGroup-disabledHelperTextFontColor)' : 'var(--toggleGroup-helperTextFontColor)' } ;
289- font-family : var (--toggleGroup-helperTextFontFamily );
290- font-size : var (--toggleGroup-helperTextFontSize );
291- font-style : var (--toggleGroup-helperTextFontStyle );
292- font-weight : var (--toggleGroup-helperTextFontWeight );
293- line-height : var (--toggleGroup-helperTextLineHeight );
294- }
295- .toggleContainer {
290+ .helperText {
291+ color : ${ this . disabled
292+ ? "var(--toggleGroup-disabledHelperTextFontColor)"
293+ : "var(--toggleGroup-helperTextFontColor)" } ;
294+ font-family : var (--toggleGroup-helperTextFontFamily );
295+ font-size : var (--toggleGroup-helperTextFontSize );
296+ font-style : var (--toggleGroup-helperTextFontStyle );
297+ font-weight : var (--toggleGroup-helperTextFontWeight );
298+ line-height : var (--toggleGroup-helperTextLineHeight );
299+ }
300+ .toggleContainer {
296301 display : inline-flex;
297302 flex-direction : row;
298- opacity : 1 px ;
299- height : calc ( 48px - 4 px - 4 px ) ;
303+ opacity : 1 ;
304+ height : 48px ;
300305 padding : 4px ;
301306 margin-top : var (--toggleGroup-containerMarginTop );
302307 border-width : var (--toggleGroup-containerBorderThickness );
303308 border-style : var (--toggleGroup-containerBorderStyle );
304309 border-radius : var (--toggleGroup-containerBorderRadius );
305310 border-color : var (--toggleGroup-containerBorderColor );
306311 background-color : var (--toggleGroup-containerBackgroundColor );
307- padding : 4px ;
308312 margin-top : var (--toggleGroup-containerMarginTop );
309313 align-items : center;
310314 min-height : 40px ;
315+ box-sizing : border-box;
311316 }
312-
313317 ${ this . disabledStyles ( ) } ;
318+
319+ dxc- to ggle: not (: last- of- type) {
320+ margin- right: 4px;
321+ }
314322 ` ;
315323 }
316324}
0 commit comments