append getters

This commit is contained in:
Niels Lyngsø
2024-03-01 11:41:41 +01:00
parent 771f74d0fe
commit 7577afd09e
3 changed files with 43 additions and 12 deletions

View File

@@ -110,12 +110,21 @@ export class UmbPropertyContext<ValueType = any> extends UmbControllerBase {
public setAlias(alias: string | undefined): void {
this.#alias.setValue(alias);
}
public getAlias(): string | undefined {
return this.#alias.getValue();
}
public setLabel(label: string | undefined): void {
this.#label.setValue(label);
}
public getLabel(): string | undefined {
return this.#label.getValue();
}
public setDescription(description: string | undefined): void {
this.#description.setValue(description);
}
public getDescription(): string | undefined {
return this.#description.getValue();
}
/**
* Set the value of this property.
* @param value {ValueType} the whole value to be set
@@ -136,6 +145,9 @@ export class UmbPropertyContext<ValueType = any> extends UmbControllerBase {
public setConfig(config: Array<UmbPropertyEditorConfigProperty> | undefined): void {
this.#configValues.setValue(config ?? []);
}
public getConfig(): Array<UmbPropertyEditorConfigProperty> | undefined {
return this.#configValues.getValue();
}
public setVariantId(variantId: UmbVariantId | undefined): void {
this.#variantId.setValue(variantId);
}

View File

@@ -27,9 +27,12 @@ export class UmbPropertyElement extends UmbLitElement {
* @default ''
*/
@property({ type: String })
public set label(label: string) {
public set label(label: string | undefined) {
this.#propertyContext.setLabel(label);
}
public get label() {
return this.#propertyContext.getLabel();
}
/**
* Description: render a description underneath the label.
@@ -38,9 +41,12 @@ export class UmbPropertyElement extends UmbLitElement {
* @default ''
*/
@property({ type: String })
public set description(description: string) {
public set description(description: string | undefined) {
this.#propertyContext.setDescription(description);
}
public get description() {
return this.#propertyContext.getDescription();
}
/**
* Alias
@@ -53,6 +59,9 @@ export class UmbPropertyElement extends UmbLitElement {
public set alias(alias: string) {
this.#propertyContext.setAlias(alias);
}
public get alias() {
return this.#propertyContext.getAlias() ?? '';
}
/**
* Property Editor UI Alias. Render the Property Editor UI registered for this alias.
@@ -62,12 +71,14 @@ export class UmbPropertyElement extends UmbLitElement {
* @default ''
*/
@property({ type: String, attribute: 'property-editor-ui-alias' })
public set propertyEditorUiAlias(value: string) {
if (this._propertyEditorUiAlias === value) return;
public set propertyEditorUiAlias(value: string | undefined) {
this._propertyEditorUiAlias = value;
this._observePropertyEditorUI();
}
private _propertyEditorUiAlias = '';
public get propertyEditorUiAlias(): string {
return this._propertyEditorUiAlias ?? '';
}
private _propertyEditorUiAlias?: string;
/**
* Config. Configuration to pass to the Property Editor UI. This is also the configuration data stored on the Data Type.
@@ -80,6 +91,9 @@ export class UmbPropertyElement extends UmbLitElement {
public set config(value: UmbPropertyEditorConfig | undefined) {
this.#propertyContext.setConfig(value);
}
public get config(): UmbPropertyEditorConfig | undefined {
return this.#propertyContext.getConfig();
}
@state()
private _variantDifference?: string;
@@ -130,13 +144,15 @@ export class UmbPropertyElement extends UmbLitElement {
};
private _observePropertyEditorUI(): void {
this.observe(
umbExtensionsRegistry.byTypeAndAlias('propertyEditorUi', this._propertyEditorUiAlias),
(manifest) => {
this._gotEditorUI(manifest);
},
'_observePropertyEditorUI',
);
if (this._propertyEditorUiAlias) {
this.observe(
umbExtensionsRegistry.byTypeAndAlias('propertyEditorUi', this._propertyEditorUiAlias),
(manifest) => {
this._gotEditorUI(manifest);
},
'_observePropertyEditorUI',
);
}
}
private async _gotEditorUI(manifest?: ManifestPropertyEditorUi | null): Promise<void> {

View File

@@ -21,6 +21,9 @@ export class UmbWorkspaceSplitViewElement extends UmbLitElement {
public set splitViewIndex(index: number) {
this.splitViewContext.setSplitViewIndex(index);
}
public get splitViewIndex(): number {
return this.splitViewContext.getSplitViewIndex()!;
}
splitViewContext = new UmbWorkspaceSplitViewContext(this);