File tree Expand file tree Collapse file tree 4 files changed +26
-17
lines changed
src/components/radio-group Expand file tree Collapse file tree 4 files changed +26
-17
lines changed Original file line number Diff line number Diff line change @@ -31,13 +31,7 @@ export default class IgcRadioGroupComponent extends LitElement {
3131 private _name ! : string ;
3232 private _value ! : string ;
3333
34- @property ( { type : Boolean , reflect : true } )
35- private disabled = false ;
36-
37- @property ( { type : Boolean , reflect : true } )
38- private labelBefore = false ;
39-
40- @queryAssignedElements ( { flatten : true } )
34+ @queryAssignedElements ( { selector : 'igc-radio' , flatten : true } )
4135 private _radios ! : NodeListOf < IgcRadioComponent > ;
4236
4337 /**
@@ -93,12 +87,20 @@ export default class IgcRadioGroupComponent extends LitElement {
9387 }
9488
9589 private _observerCallback ( ) {
96- const radios = Array . from ( this . _radios as unknown as Element [ ] ) . filter (
97- ( el ) => el . tagName . toLowerCase ( ) === 'igc-radio'
98- ) as IgcRadioComponent [ ] ;
99- this . disabled = radios . every ( ( radio ) => radio . disabled ) ;
100- this . labelBefore =
101- radios . some ( ( radio ) => radio . labelPosition === 'before' ) ?? false ;
90+ const radios = Array . from ( this . _radios ) ;
91+ const setState = ( state : string , condition : boolean ) =>
92+ condition
93+ ? this . _internals . states . add ( state )
94+ : this . _internals . states . delete ( state ) ;
95+
96+ setState (
97+ 'disabled' ,
98+ radios . every ( ( radio ) => radio . disabled )
99+ ) ;
100+ setState (
101+ 'labelBefore' ,
102+ radios . some ( ( radio ) => radio . labelPosition === 'before' )
103+ ) ;
102104 }
103105
104106 constructor ( ) {
Original file line number Diff line number Diff line change 1212 flex-direction : column ;
1313 gap : rem (8px );
1414 width : max-content ;
15+
16+ ::slotted (label ) {
17+ margin-block-end : rem (8px );
18+ }
1519}
1620
17- :host ([alignment = ' vertical' ][ labelBefore ]) {
21+ :host (:state(labelBefore) [alignment = ' vertical' ]) {
1822 ::slotted (* ) {
1923 align-self : flex-end ;
2024 }
Original file line number Diff line number Diff line change @@ -5,13 +5,12 @@ $theme: $material;
55
66:host {
77 ::slotted (label ) {
8- margin-block-end : rem (16px );
98 color : var-get ($theme , ' color' );
109 }
1110}
1211
13- :host ([ disabled ] ) {
12+ :host (:state( disabled) ) {
1413 ::slotted (label ) {
1514 color : var-get ($theme , ' disabled-color' );
1615 }
17- }
16+ }
Original file line number Diff line number Diff line change 1010
1111:host ([alignment = ' vertical' ]) {
1212 gap : 0 ;
13+
14+ ::slotted (label ) {
15+ margin-block-end : rem (16px );
16+ }
1317}
1418
1519:host ([alignment = ' horizontal' ]) {
You can’t perform that action at this time.
0 commit comments