@@ -34,6 +34,15 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
34
34
return this . _items ;
35
35
}
36
36
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
+
37
46
@state ( )
38
47
private _matches : Array < TagResponseModel > = [ ] ;
39
48
@@ -188,18 +197,7 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
188
197
<uui- tag id= "input-width-tracker" aria-hidden = "true" style = "visibility:hidden;opacity:0;position:absolute;" >
189
198
${ this . _currentInput }
190
199
</ 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( ) }
203
201
</ span>
204
202
</ div>
205
203
` ;
@@ -210,7 +208,7 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
210
208
return html `
211
209
<uui- tag class= "tag" >
212
210
<span> ${ tag } </ span>
213
- <uui - icon name = "icon-wrong" @click = " ${ ( ) => this . #delete ( tag ) } " > < / uui - icon >
211
+ ${ this . #renderRemoveButton ( tag ) }
214
212
</ uui- tag>
215
213
` ;
216
214
} ) } `;
@@ -233,14 +231,39 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
233
231
name= "${ tag . group ?? '' } "
234
232
@click = "${ ( ) => this . #optionClick( index ) } "
235
233
@keydown = "${ ( e : KeyboardEvent ) => this . #optionKeydown( e , index ) } "
236
- value= "${ tag . text ?? '' } " / >
234
+ value= "${ tag . text ?? '' } "
235
+ ?readonly = ${ this . readonly } / >
237
236
<label for = "tag-${ tag . id } " > ${ tag . text } </ label> ` ;
238
237
} ,
239
238
) }
240
239
</ div>
241
240
` ;
242
241
}
243
242
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
+
244
267
static override styles = [
245
268
css `
246
269
# wrapper {
@@ -253,6 +276,7 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
253
276
border : 1px solid var (--uui-color-border );
254
277
background-color : var (--uui-input-background-color , var (--uui-color-surface ));
255
278
flex : 1 ;
279
+ min-height : 40px ;
256
280
}
257
281
258
282
# main-tag-wrapper {
0 commit comments