1
- import { css , customElement , html , property , state , styleMap } from '@umbraco-cms/backoffice/external/lit' ;
1
+ import { css , customElement , html , ifDefined , property , state , styleMap } from '@umbraco-cms/backoffice/external/lit' ;
2
2
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element' ;
3
3
import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-editor' ;
4
4
import type { StyleInfo } from '@umbraco-cms/backoffice/external/lit' ;
5
5
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor' ;
6
6
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/extension-registry' ;
7
- import type { UUITextareaElement } from '@umbraco-cms/backoffice/external/uui' ;
7
+ import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation' ;
8
+ import { UmbTextStyles } from '@umbraco-cms/backoffice/style' ;
8
9
9
10
@customElement ( 'umb-property-editor-ui-textarea' )
10
- export class UmbPropertyEditorUITextareaElement extends UmbLitElement implements UmbPropertyEditorUiElement {
11
- @ property ( )
12
- value = '' ;
13
-
11
+ export class UmbPropertyEditorUITextareaElement
12
+ extends UmbFormControlMixin < string > ( UmbLitElement , undefined )
13
+ implements UmbPropertyEditorUiElement
14
+ {
14
15
/**
15
16
* Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.
16
17
* @type {boolean }
@@ -47,8 +48,14 @@ export class UmbPropertyEditorUITextareaElement extends UmbLitElement implements
47
48
} ;
48
49
}
49
50
50
- #onInput( event : InputEvent & { target : UUITextareaElement } ) {
51
- this . value = event . target . value as string ;
51
+ protected override firstUpdated ( ) : void {
52
+ this . addFormControlElement ( this . shadowRoot ! . querySelector ( 'uui-textarea' ) ! ) ;
53
+ }
54
+
55
+ #onInput( event : InputEvent ) {
56
+ const newValue = ( event . target as HTMLTextAreaElement ) . value ;
57
+ if ( newValue === this . value ) return ;
58
+ this . value = newValue ;
52
59
this . dispatchEvent ( new UmbPropertyValueChangeEvent ( ) ) ;
53
60
}
54
61
@@ -58,15 +65,16 @@ export class UmbPropertyEditorUITextareaElement extends UmbLitElement implements
58
65
label= "Textarea"
59
66
style = ${ styleMap ( this . _css ) }
60
67
.autoHeight = ${ this . _rows ? false : true }
61
- . maxlength = ${ this . _maxChars }
62
- . rows = ${ this . _rows }
68
+ maxlength= ${ ifDefined ( this . _maxChars ) }
69
+ rows= ${ ifDefined ( this . _rows ) }
63
70
.value = ${ this . value ?? '' }
64
71
@input = ${ this . #onInput}
65
72
?readonly = ${ this . readonly } > </ uui- textarea>
66
73
` ;
67
74
}
68
75
69
- static override styles = [
76
+ static styles = [
77
+ UmbTextStyles ,
70
78
css `
71
79
uui- textarea {
72
80
width : 100% ;
0 commit comments