|
1 | 1 | import type { UmbSectionItemModel } from '../../repository/index.js'; |
2 | 2 | import { UmbSectionPickerContext } from './input-section.context.js'; |
3 | 3 | import { css, html, customElement, property, state } from '@umbraco-cms/backoffice/external/lit'; |
4 | | -import { UUIFormControlMixin } from '@umbraco-cms/backoffice/external/uui'; |
5 | 4 | import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; |
6 | 5 | import { splitStringToArray } from '@umbraco-cms/backoffice/utils'; |
| 6 | +import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation'; |
7 | 7 |
|
8 | 8 | @customElement('umb-input-section') |
9 | | -export class UmbInputSectionElement extends UUIFormControlMixin(UmbLitElement, '') { |
| 9 | +export class UmbInputSectionElement extends UmbFormControlMixin<string | undefined, typeof UmbLitElement>( |
| 10 | + UmbLitElement, |
| 11 | +) { |
10 | 12 | /** |
11 | 13 | * This is a minimum amount of selected items in this input. |
12 | 14 | * @type {number} |
@@ -60,15 +62,12 @@ export class UmbInputSectionElement extends UUIFormControlMixin(UmbLitElement, ' |
60 | 62 | return this.#pickerContext.getSelection(); |
61 | 63 | } |
62 | 64 |
|
63 | | - @property() |
64 | | - public set value(selectionString: string) { |
65 | | - // Its with full purpose we don't call super.value, as thats being handled by the observation of the context selection. |
66 | | - if (typeof selectionString !== 'string') return; |
67 | | - if (selectionString === this.value) return; |
| 65 | + @property({ type: String }) |
| 66 | + public set value(selectionString: string | undefined) { |
68 | 67 | this.selection = splitStringToArray(selectionString); |
69 | 68 | } |
70 | | - public get value(): string { |
71 | | - return this.selection.join(','); |
| 69 | + public get value(): string | undefined { |
| 70 | + return this.selection.length > 0 ? this.selection.join(',') : undefined; |
72 | 71 | } |
73 | 72 |
|
74 | 73 | @state() |
|
0 commit comments