1
1
import { UmbPropertyContext } from './property.context.js' ;
2
- import type { ManifestPropertyEditorUi } from '@umbraco-cms/backoffice/extension-registry' ;
3
- import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry' ;
4
- import { UmbTextStyles } from '@umbraco-cms/backoffice/style' ;
5
- import { css , html , customElement , property , state , nothing } from '@umbraco-cms/backoffice/external/lit' ;
2
+ import { css , customElement , html , property , state , nothing } from '@umbraco-cms/backoffice/external/lit' ;
6
3
import { createExtensionElement } from '@umbraco-cms/backoffice/extension-api' ;
7
- import type { UmbObserverController } from '@umbraco-cms/backoffice/observable-api ' ;
4
+ import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry ' ;
8
5
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element' ;
9
- import type {
10
- UmbPropertyEditorConfigCollection ,
11
- UmbPropertyEditorConfig ,
12
- } from '@umbraco-cms/backoffice/property-editor' ;
6
+ import { UmbTextStyles } from '@umbraco-cms/backoffice/style' ;
13
7
import {
14
8
UmbBindValidationMessageToFormControl ,
15
9
UmbFormControlValidator ,
16
10
UmbObserveValidationStateController ,
17
11
} from '@umbraco-cms/backoffice/validation' ;
18
- import type { UmbPropertyTypeAppearanceModel } from '@umbraco-cms/backoffice/content-type' ;
12
+ import type { ManifestPropertyEditorUi } from '@umbraco-cms/backoffice/extension-registry' ;
13
+ import type {
14
+ UmbPropertyEditorConfigCollection ,
15
+ UmbPropertyEditorConfig ,
16
+ } from '@umbraco-cms/backoffice/property-editor' ;
17
+ import type {
18
+ UmbPropertyTypeAppearanceModel ,
19
+ UmbPropertyTypeValidationModel ,
20
+ } from '@umbraco-cms/backoffice/content-type' ;
21
+ import type { UmbObserverController } from '@umbraco-cms/backoffice/observable-api' ;
19
22
20
23
/**
21
24
* @element umb-property
@@ -112,6 +115,17 @@ export class UmbPropertyElement extends UmbLitElement {
112
115
return this . #propertyContext. getConfig ( ) ;
113
116
}
114
117
118
+ /**
119
+ * Validation: Validation settings for the property.
120
+ */
121
+ @property ( { type : Object , attribute : false } )
122
+ public set validation ( validation : UmbPropertyTypeValidationModel | undefined ) {
123
+ this . #propertyContext. setValidation ( validation ) ;
124
+ }
125
+ public get validation ( ) {
126
+ return this . #propertyContext. getValidation ( ) ;
127
+ }
128
+
115
129
/**
116
130
* DataPath, declare the path to the value of the data that this property represents.
117
131
* @public
@@ -152,6 +166,9 @@ export class UmbPropertyElement extends UmbLitElement {
152
166
@state ( )
153
167
private _orientation : 'horizontal' | 'vertical' = 'horizontal' ;
154
168
169
+ @state ( )
170
+ private _mandatory ?: boolean ;
171
+
155
172
#propertyContext = new UmbPropertyContext ( this ) ;
156
173
157
174
#controlValidator?: UmbFormControlValidator ;
@@ -169,34 +186,46 @@ export class UmbPropertyElement extends UmbLitElement {
169
186
} ,
170
187
null ,
171
188
) ;
189
+
172
190
this . observe (
173
191
this . #propertyContext. label ,
174
192
( label ) => {
175
193
this . _label = label ;
176
194
} ,
177
195
null ,
178
196
) ;
197
+
179
198
this . observe (
180
199
this . #propertyContext. description ,
181
200
( description ) => {
182
201
this . _description = description ;
183
202
} ,
184
203
null ,
185
204
) ;
205
+
186
206
this . observe (
187
207
this . #propertyContext. variantDifference ,
188
208
( variantDifference ) => {
189
209
this . _variantDifference = variantDifference ;
190
210
} ,
191
211
null ,
192
212
) ;
213
+
193
214
this . observe (
194
215
this . #propertyContext. appearance ,
195
216
( appearance ) => {
196
217
this . _orientation = appearance ?. labelOnTop ? 'vertical' : 'horizontal' ;
197
218
} ,
198
219
null ,
199
220
) ;
221
+
222
+ this . observe (
223
+ this . #propertyContext. validation ,
224
+ ( validation ) => {
225
+ this . _mandatory = validation ?. mandatory ;
226
+ } ,
227
+ null ,
228
+ ) ;
200
229
}
201
230
202
231
private _onPropertyEditorChange = ( e : CustomEvent ) : void => {
@@ -297,10 +326,11 @@ export class UmbPropertyElement extends UmbLitElement {
297
326
return html `
298
327
<umb- property- layout
299
328
id= "layout"
300
- .alias = ${ this . _alias }
301
- .label = ${ this . _label }
302
- .description = ${ this . _description }
329
+ .alias = ${ this . _alias ?? '' }
330
+ .label = ${ this . _label ?? '' }
331
+ .description = ${ this . _description ?? '' }
303
332
.orientation = ${ this . _orientation ?? 'horizontal' }
333
+ ?mand ato ry= ${ this . _mandatory }
304
334
?invalid= ${ this . _invalid } >
305
335
${ this . #renderPropertyActionMenu( ) }
306
336
${ this . _variantDifference
0 commit comments