From 65f8fd06d3d690261f15fc7fe5a38fd7c18ee7ee Mon Sep 17 00:00:00 2001 From: Carter Date: Thu, 16 Jul 2026 12:47:56 -0600 Subject: [PATCH] hotfix: mode node id inputs --- src/component/ComponentForm.tsx | 26 ++++++++++++++++++++++---- src/component/ComponentMode.json | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/component/ComponentForm.tsx b/src/component/ComponentForm.tsx index dbebbb5..266c402 100644 --- a/src/component/ComponentForm.tsx +++ b/src/component/ComponentForm.tsx @@ -457,11 +457,29 @@ export default function ComponentForm(props: Props) { setForm(f); }; + const modeDictionaryValue = (dictionary: any, key: string): number | undefined => { + if (!Array.isArray(dictionary)) { + return undefined; + } + let entry = dictionary.find((elem: any) => elem.key === key); + return typeof entry?.value === "number" ? entry.value : undefined; + }; + const isCoefficientValid = () => { let calibrate = form.component.settings.calibrate; let coefficient = Number(form.coefficient); - let valid = !isNaN(coefficient) && (!calibrate || (calibrate && coefficient > 0)); - return valid; + if (isNaN(coefficient)) { + return false; + } + if (!calibrate) { + return true; + } + if (compMode && compMode.mode.entryA === "number") { + let minimum = modeDictionaryValue(compMode.mode.dictionaryA, "min") ?? 0; + let maximum = modeDictionaryValue(compMode.mode.dictionaryA, "max") ?? 100; + return coefficient >= minimum && coefficient <= maximum; + } + return coefficient > 0; }; const changeCoefficient = (event: any) => { @@ -485,8 +503,8 @@ export default function ComponentForm(props: Props) { }; const isOffsetValid = (min?: number, max?: number) => { - let minimum = min ?? 0; - let maximum = max ?? 100; + let minimum = min ?? modeDictionaryValue(compMode?.mode.dictionaryB, "min") ?? 0; + let maximum = max ?? modeDictionaryValue(compMode?.mode.dictionaryB, "max") ?? 100; if (compMode && form.component.settings.calibrate) { return Number(form.offset) <= maximum && Number(form.offset) >= minimum; } diff --git a/src/component/ComponentMode.json b/src/component/ComponentMode.json index 2c66a6e..da36459 100644 --- a/src/component/ComponentMode.json +++ b/src/component/ComponentMode.json @@ -110,7 +110,7 @@ "dictionaryA": [ { "key": "min", - "value": 1, + "value": 0, "restricted": false }, {