From 45af9dc02c8d855c5ff32f0907f85d00fbe91f86 Mon Sep 17 00:00:00 2001 From: MiB-1 <133959537+MiB-1@users.noreply.github.com> Date: Mon, 24 Nov 2025 10:06:56 +0100 Subject: [PATCH] =?UTF-8?q?feat(LionInputStepper):=20implement=20self-dest?= =?UTF-8?q?ructing=20output=20content=20for=E2=80=A6=20(#2629)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(LionInputStepper): implement self-destructing output content for value display #2602 * chore(LionInputStepper): output for should use _inputId instead of fieldName Co-authored-by: gerjanvangeest * chore(LionInputStepper): add docs for output tag implementation --------- Co-authored-by: gerjanvangeest --- .changeset/giant-ties-attack.md | 8 + .../input-stepper/src/LionInputStepper.js | 66 ++--- .../test/lion-input-stepper.test.js | 256 ++++++++++++++---- 3 files changed, 237 insertions(+), 93 deletions(-) create mode 100644 .changeset/giant-ties-attack.md diff --git a/.changeset/giant-ties-attack.md b/.changeset/giant-ties-attack.md new file mode 100644 index 000000000..90505cd6b --- /dev/null +++ b/.changeset/giant-ties-attack.md @@ -0,0 +1,8 @@ +--- +'@lion/ui': patch +--- + +feat(LionInputStepper): implement self-destructing output content for value display + +1. from
${this.__valueText}
to ${this.\_\_valueText} +2. remove the \_onEnterButton() and \_onLeaveButton() logic. diff --git a/packages/ui/components/input-stepper/src/LionInputStepper.js b/packages/ui/components/input-stepper/src/LionInputStepper.js index 89f8c7531..3c70063bc 100644 --- a/packages/ui/components/input-stepper/src/LionInputStepper.js +++ b/packages/ui/components/input-stepper/src/LionInputStepper.js @@ -1,4 +1,4 @@ -import { html, css, render } from 'lit'; +import { html, css, render, nothing } from 'lit'; import { formatNumber, LocalizeMixin, parseNumber } from '@lion/ui/localize-no-side-effects.js'; import { LionInput } from '@lion/ui/input.js'; import { IsNumber, MinNumber, MaxNumber } from '@lion/ui/form-core.js'; @@ -96,8 +96,6 @@ export class LionInputStepper extends LocalizeMixin(LionInput) { this._increment = this._increment.bind(this); this._decrement = this._decrement.bind(this); - this._onEnterButton = this._onEnterButton.bind(this); - this._onLeaveButton = this._onLeaveButton.bind(this); } connectedCallback() { @@ -244,6 +242,26 @@ export class LionInputStepper extends LocalizeMixin(LionInput) { this._inputNode.removeAttribute('aria-valuenow'); this._inputNode.removeAttribute('aria-valuetext'); } + this._destroyOutputContent(); + } + + _destroyOutputContent() { + const outputElement = /** @type {HTMLElement} */ ( + this.shadowRoot?.querySelector('.input-stepper__value') + ); + + const timeoutValue = outputElement?.dataset?.selfDestruct + ? Number(outputElement.dataset.selfDestruct) + : 2000; + clearTimeout(this.timer); + if (outputElement) { + this.timer = setTimeout(() => { + if (outputElement.parentNode) { + this.__valueText = nothing; + this.requestUpdate(); + } + }, timeoutValue); + } } /** @@ -394,8 +412,6 @@ export class LionInputStepper extends LocalizeMixin(LionInput) {