diff --git a/src/Umbraco.Web.UI.Client/src/packages/property-editors/number/property-editor-ui-number.element.ts b/src/Umbraco.Web.UI.Client/src/packages/property-editors/number/property-editor-ui-number.element.ts
index 1388910bb7..f4317acc81 100644
--- a/src/Umbraco.Web.UI.Client/src/packages/property-editors/number/property-editor-ui-number.element.ts
+++ b/src/Umbraco.Web.UI.Client/src/packages/property-editors/number/property-editor-ui-number.element.ts
@@ -1,13 +1,13 @@
-import { css, html, customElement, property, state, ifDefined } from '@umbraco-cms/backoffice/external/lit';
-import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
-import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/extension-registry';
+import { css, customElement, html, ifDefined, property, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
+import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-editor';
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
+import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/extension-registry';
@customElement('umb-property-editor-ui-number')
export class UmbPropertyEditorUINumberElement extends UmbLitElement implements UmbPropertyEditorUiElement {
@property({ type: Number })
- value: undefined | number = undefined;
+ value?: number;
@state()
private _max?: number;
@@ -19,28 +19,36 @@ export class UmbPropertyEditorUINumberElement extends UmbLitElement implements U
private _step?: number;
public set config(config: UmbPropertyEditorConfigCollection | undefined) {
- this._min = config?.getValueByAlias('min');
- this._max = config?.getValueByAlias('max');
- this._step = config?.getValueByAlias('step');
+ if (!config) return;
+ this._min = this.#parseInt(config.getValueByAlias('min'));
+ this._max = this.#parseInt(config.getValueByAlias('max'));
+ this._step = this.#parseInt(config.getValueByAlias('step'));
}
- private onInput(e: InputEvent) {
- this.value = Number((e.target as HTMLInputElement).value);
- this.dispatchEvent(new CustomEvent('property-value-change'));
+ #parseInt(input: unknown): number | undefined {
+ const num = Number(input);
+ return Number.isNaN(num) ? undefined : num;
+ }
+
+ #onInput(e: InputEvent & { target: HTMLInputElement }) {
+ this.value = this.#parseInt(e.target.value);
+ this.dispatchEvent(new UmbPropertyValueChangeEvent());
}
render() {
- return html``;
+ return html`
+
+
+ `;
}
static styles = [
- UmbTextStyles,
css`
uui-input {
width: 100%;