@@ -34,6 +34,15 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
3434 return this . _items ;
3535 }
3636
37+ /**
38+ * Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.
39+ * @type {boolean }
40+ * @attr
41+ * @default false
42+ */
43+ @property ( { type : Boolean , reflect : true } )
44+ readonly = false ;
45+
3746 @state ( )
3847 private _matches : Array < TagResponseModel > = [ ] ;
3948
@@ -188,18 +197,7 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
188197 <uui- tag id= "input-width-tracker" aria-hidden = "true" style = "visibility:hidden;opacity:0;position:absolute;" >
189198 ${ this . _currentInput }
190199 </ uui- tag>
191- <uui- tag look= "outline" id = "main-tag" @click = "${ this . focus } " slot = "trigger" >
192- <input
193- id= "tag-input"
194- aria-label = "tag input"
195- placeholder = "Enter tag"
196- .value = "${ this . _currentInput ?? undefined } "
197- @keydown = "${ this . #onKeydown} "
198- @input = "${ this . #onInput} "
199- @blur = "${ this . #onBlur} " / >
200- <uui- icon id= "icon-add" name = "icon-add" > </ uui- icon>
201- ${ this . #renderTagOptions( ) }
202- </ uui- tag>
200+ ${ this . #renderAddButton( ) }
203201 </ span>
204202 </ div>
205203 ` ;
@@ -210,7 +208,7 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
210208 return html `
211209 <uui- tag class= "tag" >
212210 <span> ${ tag } </ span>
213- <uui - icon name = "icon-wrong" @click = " ${ ( ) => this . #delete ( tag ) } " > < / uui - icon >
211+ ${ this . #renderRemoveButton ( tag ) }
214212 </ uui- tag>
215213 ` ;
216214 } ) } `;
@@ -233,14 +231,39 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
233231 name= "${ tag . group ?? '' } "
234232 @click = "${ ( ) => this . #optionClick( index ) } "
235233 @keydown = "${ ( e : KeyboardEvent ) => this . #optionKeydown( e , index ) } "
236- value= "${ tag . text ?? '' } " / >
234+ value= "${ tag . text ?? '' } "
235+ ?readonly = ${ this . readonly } / >
237236 <label for = "tag-${ tag . id } " > ${ tag . text } </ label> ` ;
238237 } ,
239238 ) }
240239 </ div>
241240 ` ;
242241 }
243242
243+ #renderAddButton( ) {
244+ if ( this . readonly ) return nothing ;
245+
246+ return html `
247+ <uui- tag look= "outline" id = "main- tag" @click = "${ this . focus } " slot= "trigger">
248+ <input
249+ id= "tag-input"
250+ aria-label = "tag input"
251+ placeholder= "Enter tag"
252+ .value = "${ this . _currentInput ?? undefined } "
253+ @keydown = "${ this . #onKeydown} "
254+ @input = "${ this . #onInput} "
255+ @blur = "${ this . #onBlur} " / >
256+ <uui- icon id= "icon-add" name = "icon- add"> </ uui- icon>
257+ ${ this . #renderTagOptions( ) }
258+ </ uui- tag>
259+ ` ;
260+ }
261+
262+ #renderRemoveButton( tag : string ) {
263+ if ( this . readonly ) return nothing ;
264+ return html ` <uui- icon name= "icon-wrong" @click = "${ ( ) => this . #delete( tag ) } " > </ uui- icon> ` ;
265+ }
266+
244267 static styles = [
245268 css `
246269 # wrapper {
@@ -253,6 +276,7 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
253276 border : 1px solid var (--uui-color-border );
254277 background-color : var (--uui-input-background-color , var (--uui-color-surface ));
255278 flex : 1 ;
279+ min-height : 40px ;
256280 }
257281
258282 # main-tag-wrapper {
0 commit comments