7
7
} from '@umbraco-ui/uui-combobox-list/lib' ;
8
8
import { iconRemove } from '@umbraco-ui/uui-icon-registry-essential/lib/svgs' ;
9
9
import type { UUIPopoverContainerElement } from '@umbraco-ui/uui-popover-container/lib' ;
10
- import { css , html , LitElement } from 'lit' ;
10
+ import { css , html , LitElement , nothing } from 'lit' ;
11
11
import {
12
12
property ,
13
13
query ,
@@ -103,6 +103,15 @@ export class UUIComboboxElement extends UUIFormControlMixin(LitElement, '') {
103
103
@property ( { type : Boolean , reflect : true } )
104
104
disabled = false ;
105
105
106
+ /**
107
+ * Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.
108
+ * @type {boolean }
109
+ * @attr
110
+ * @default false
111
+ */
112
+ @property ( { type : Boolean , reflect : true } )
113
+ readonly = false ;
114
+
106
115
@query ( '#combobox-input' )
107
116
private _input ! : HTMLInputElement ;
108
117
@@ -239,11 +248,13 @@ export class UUIComboboxElement extends UUIFormControlMixin(LitElement, '') {
239
248
} ;
240
249
241
250
#onToggle = ( ) => {
251
+ if ( this . readonly ) return ;
242
252
this . open = ! this . open ;
243
253
} ;
244
254
245
255
#onOpen = ( ) => {
246
256
if ( this . open ) return ;
257
+ if ( this . readonly ) return ;
247
258
this . open = true ;
248
259
} ;
249
260
@@ -298,12 +309,13 @@ export class UUIComboboxElement extends UUIFormControlMixin(LitElement, '') {
298
309
.value = ${ this . _displayValue }
299
310
auto complete= "off"
300
311
.disabled = ${ this . disabled }
312
+ .readonly = ${ this . readonly }
301
313
popovertarget= "combobox-popover"
302
314
@click = ${ this . #onToggle}
303
315
@input = ${ this . #onInput}
304
316
@keydown = ${ this . #onKeyDown} >
305
317
<slot name= "input-prepend" slot = "prepend" > </ slot>
306
- ${ this . disabled ? '' : this . #renderClearButton( ) }
318
+ ${ this . #renderClearButton( ) }
307
319
<div id= "expand-symbol-wrapper" slot = "append" >
308
320
<uui- symbol- expand .open = ${ this . _isOpen } > </ uui- symbol- expand >
309
321
</ div>
@@ -312,6 +324,9 @@ export class UUIComboboxElement extends UUIFormControlMixin(LitElement, '') {
312
324
} ;
313
325
314
326
#renderClearButton = ( ) => {
327
+ if ( this . disabled ) return nothing ;
328
+ if ( this . readonly ) return nothing ;
329
+
315
330
return this . value || this . search
316
331
? html `<uui- butto n
317
332
id= "clear-button"
0 commit comments