|
1 | 1 | import { UmbMemberTypePickerContext } from './input-member-type.context.js'; |
2 | 2 | import { css, html, customElement, property, state, repeat, when } from '@umbraco-cms/backoffice/external/lit'; |
3 | 3 | import { splitStringToArray } from '@umbraco-cms/backoffice/utils'; |
4 | | -import { UUIFormControlMixin } from '@umbraco-cms/backoffice/external/uui'; |
5 | 4 | import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; |
6 | 5 | import type { UmbUniqueItemModel } from '@umbraco-cms/backoffice/models'; |
| 6 | +import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation'; |
7 | 7 |
|
8 | 8 | @customElement('umb-input-member-type') |
9 | | -export class UmbInputMemberTypeElement extends UUIFormControlMixin(UmbLitElement, '') { |
| 9 | +export class UmbInputMemberTypeElement 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,13 +62,12 @@ export class UmbInputMemberTypeElement extends UUIFormControlMixin(UmbLitElement |
60 | 62 | return this.#pickerContext.getSelection(); |
61 | 63 | } |
62 | 64 |
|
63 | | - @property() |
64 | | - public set value(idsString: string) { |
65 | | - // Its with full purpose we don't call super.value, as thats being handled by the observation of the context selection. [NL] |
66 | | - this.selection = splitStringToArray(idsString); |
| 65 | + @property({ type: String }) |
| 66 | + public set value(selectionString: string | undefined) { |
| 67 | + this.selection = splitStringToArray(selectionString); |
67 | 68 | } |
68 | | - public get value(): string { |
69 | | - return this.selection.join(','); |
| 69 | + public get value(): string | undefined { |
| 70 | + return this.selection.length > 0 ? this.selection.join(',') : undefined; |
70 | 71 | } |
71 | 72 |
|
72 | 73 | @state() |
|
0 commit comments