@@ -3,6 +3,7 @@ import type { UmbInputContentElement } from './components/input-content/index.js
3
3
import type { UmbContentPickerSource , UmbContentPickerSourceType } from './types.js' ;
4
4
import { html , customElement , property , state } from '@umbraco-cms/backoffice/external/lit' ;
5
5
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element' ;
6
+ import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation' ;
6
7
import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-editor' ;
7
8
import { UMB_DOCUMENT_ENTITY_TYPE } from '@umbraco-cms/backoffice/document' ;
8
9
import { UMB_ENTITY_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace' ;
@@ -15,15 +16,26 @@ import type { UmbTreeStartNode } from '@umbraco-cms/backoffice/tree';
15
16
// import of local component
16
17
import './components/input-content/index.js' ;
17
18
19
+ type UmbContentPickerValueType = UmbInputContentElement [ 'selection' ] ;
20
+
18
21
const elementName = 'umb-property-editor-ui-content-picker' ;
19
22
20
23
/**
21
24
* @element umb-property-editor-ui-content-picker
22
25
*/
23
26
@customElement ( elementName )
24
- export class UmbPropertyEditorUIContentPickerElement extends UmbLitElement implements UmbPropertyEditorUiElement {
27
+ export class UmbPropertyEditorUIContentPickerElement
28
+ extends UmbFormControlMixin < UmbContentPickerValueType | undefined , typeof UmbLitElement > ( UmbLitElement , undefined )
29
+ implements UmbPropertyEditorUiElement
30
+ {
25
31
@property ( { type : Array } )
26
- value : UmbInputContentElement [ 'items' ] = [ ] ;
32
+ public override set value ( value : UmbContentPickerValueType | undefined ) {
33
+ this . #value = value ;
34
+ }
35
+ public override get value ( ) : UmbContentPickerValueType | undefined {
36
+ return this . #value;
37
+ }
38
+ #value?: UmbContentPickerValueType = [ ] ;
27
39
28
40
@state ( )
29
41
_type : UmbContentPickerSource [ 'type' ] = 'content' ;
@@ -73,8 +85,8 @@ export class UmbPropertyEditorUIContentPickerElement extends UmbLitElement imple
73
85
this . _showOpenButton = config . getValueByAlias ( 'showOpenButton' ) ;
74
86
}
75
87
76
- override connectedCallback ( ) {
77
- super . connectedCallback ( ) ;
88
+ override firstUpdated ( ) {
89
+ this . addFormControlElement ( this . shadowRoot ! . querySelector ( 'umb-input-content' ) ! ) ;
78
90
this . #setPickerRootUnique( ) ;
79
91
}
80
92
@@ -98,7 +110,7 @@ export class UmbPropertyEditorUIContentPickerElement extends UmbLitElement imple
98
110
}
99
111
100
112
#onChange( event : CustomEvent & { target : UmbInputContentElement } ) {
101
- this . value = event . target . items ;
113
+ this . value = event . target . selection ;
102
114
this . dispatchEvent ( new UmbPropertyValueChangeEvent ( ) ) ;
103
115
}
104
116
@@ -108,15 +120,19 @@ export class UmbPropertyEditorUIContentPickerElement extends UmbLitElement imple
108
120
? { unique : this . _rootUnique , entityType : this . _rootEntityType }
109
121
: undefined ;
110
122
111
- return html `< umb-input-content
112
- .items =${ this . value }
113
- .type =${ this . _type }
114
- .min=${ this . _min }
115
- .max=${ this . _max }
116
- .startNode=${ startNode }
117
- .allowedContentTypeIds=${ this . _allowedContentTypeUniques ?? '' }
118
- ?showOpenButton=${ this . _showOpenButton }
119
- @change=${ this . #onChange} > </ umb-input-content > ` ;
123
+ return html `
124
+ < umb-input-content
125
+ .selection =${ this . value ?? [ ] }
126
+ .type =${ this . _type }
127
+ .min=${ this . _min }
128
+ .minMessage=${ this . _minMessage }
129
+ .max=${ this . _max }
130
+ .maxMessage=${ this . _maxMessage }
131
+ .startNode=${ startNode }
132
+ .allowedContentTypeIds=${ this . _allowedContentTypeUniques ?? '' }
133
+ ?showOpenButton=${ this . _showOpenButton }
134
+ @change=${ this . #onChange} > </ umb-input-content >
135
+ ` ;
120
136
}
121
137
}
122
138
0 commit comments