Files
Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/property-editors/label/property-editor-ui-label.element.ts
Lee Kelleher f9c2b9594f Label property-editor, adds UFM template support (#19610)
* Adds `labelTemplate` config to Label editor

* Code tidyup for Label editor element

* Adds "format-bytes" UFM filter

* Renamed "format-bytes" to "bytes"

* Label element tidy-up + copilot amends

* Added `formatBytes` options

* Simplified condition, thanks CodeScene

* Reverted element export
2025-06-30 12:18:02 +00:00

40 lines
1.1 KiB
TypeScript

import { customElement, html, property, state, when } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import type {
UmbPropertyEditorUiElement,
UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
/**
* @element umb-property-editor-ui-label
*/
@customElement('umb-property-editor-ui-label')
export class UmbPropertyEditorUILabelElement extends UmbLitElement implements UmbPropertyEditorUiElement {
@state()
private _labelTemplate?: string;
@property()
value = '';
@property({ attribute: false })
public set config(config: UmbPropertyEditorConfigCollection | undefined) {
this._labelTemplate = config?.getValueByAlias('labelTemplate');
}
override render() {
return when(
this._labelTemplate?.length,
() => html`<umb-ufm-render inline .markdown=${this._labelTemplate} .value=${this.value}></umb-ufm-render>`,
() => html`${this.value ?? ''}`,
);
}
}
export default UmbPropertyEditorUILabelElement;
declare global {
interface HTMLElementTagNameMap {
'umb-property-editor-ui-label': UmbPropertyEditorUILabelElement;
}
}