11import { LitElement , html , nothing } from 'lit' ;
2- import { property } from 'lit/decorators.js' ;
2+ import { property , queryAssignedElements } from 'lit/decorators.js' ;
33import { type Ref , createRef , ref } from 'lit/directives/ref.js' ;
44
55import { themes } from '../../theming/theming-decorator.js' ;
66import { addKeybindings } from '../common/controllers/key-bindings.js' ;
77import { registerComponent } from '../common/definitions/register.js' ;
88import type { Constructor } from '../common/mixins/constructor.js' ;
99import { EventEmitterMixin } from '../common/mixins/event-emitter.js' ;
10+ import { isEmpty } from '../common/util.js' ;
1011import IgcIconComponent from '../icon/icon.js' ;
1112import type { StyleVariant } from '../types.js' ;
1213import { styles } from './themes/chip.base.css.js' ;
@@ -84,6 +85,18 @@ export default class IgcChipComponent extends EventEmitterMixin<
8485 @property ( { reflect : true } )
8586 public variant ! : StyleVariant ;
8687
88+ @queryAssignedElements ( { slot : 'prefix' } )
89+ protected prefixes ! : Array < HTMLElement > ;
90+
91+ @queryAssignedElements ( { slot : 'start' } )
92+ protected contentStart ! : Array < HTMLElement > ;
93+
94+ @queryAssignedElements ( { slot : 'suffix' } )
95+ protected suffixes ! : Array < HTMLElement > ;
96+
97+ @queryAssignedElements ( { slot : 'end' } )
98+ protected contentEnd ! : Array < HTMLElement > ;
99+
87100 constructor ( ) {
88101 super ( ) ;
89102
@@ -120,7 +133,12 @@ export default class IgcChipComponent extends EventEmitterMixin<
120133 aria-disabled ="${ this . disabled ? 'true' : 'false' } "
121134 @click =${ this . handleSelect }
122135 >
123- < span part ="prefix ">
136+ < span
137+ part ="prefix "
138+ .hidden =${ isEmpty ( this . prefixes ) &&
139+ isEmpty ( this . contentStart ) &&
140+ ! this . selected }
141+ >
124142 ${ this . selectable && this . selected
125143 ? html `< slot name ="select ">
126144 < igc-icon name ="selected " collection ="default "> </ igc-icon >
@@ -130,7 +148,12 @@ export default class IgcChipComponent extends EventEmitterMixin<
130148 < slot name ="prefix "> </ slot >
131149 </ span >
132150 < slot > </ slot >
133- < span part ="suffix ">
151+ < span
152+ part ="suffix "
153+ .hidden =${ isEmpty ( this . suffixes ) &&
154+ isEmpty ( this . contentEnd ) &&
155+ ! this . removable }
156+ >
134157 < slot name ="end "> </ slot >
135158 < slot name ="suffix "> </ slot >
136159 ${ this . removable && ! this . disabled
0 commit comments