diff --git a/src/lib/components/dictionary/test/page/tabs/calculation.svelte b/src/lib/components/dictionary/test/page/tabs/calculation.svelte index cb3d6fa..2c4c8f4 100644 --- a/src/lib/components/dictionary/test/page/tabs/calculation.svelte +++ b/src/lib/components/dictionary/test/page/tabs/calculation.svelte @@ -18,9 +18,6 @@ let cursorIndex = $state(0); let showLiteralPopover = $state(false); let literalPopoverType = $state(('string')); -$inspect(tokens) - // let expression = $state(''); - // let cursorPosition = $state(0); function uid() { return Math.random().toString(36).slice(2, 9); @@ -106,92 +103,6 @@ $inspect(tokens) props.calFormState.form[key] = []; props.calFormState.validateField?.(key, [], false); } - - // function unselectAll(key) { - // props.calFormState.form[key] = []; - // props.calFormState.validateField?.(key, [], false); - // } - - // function getErrorStatus(formulaCode = '') { - // const selected = props.calFormState.form.FormulaInput; - // if (!Array.isArray(selected)) return []; - - // return selected.map((item) => ({ - // value: item.value, - // done: new RegExp(`\\b${item.value}\\b`, 'i').test(formulaCode) - // })); - // } - - // function addToExpression(text) { - // const before = expression.slice(0, cursorPosition); - // const after = expression.slice(cursorPosition); - // expression = before + text + after; - // cursorPosition += text.length; - // } - - // function addOperator(op) { - // addToExpression(op); - // props.calFormState.form.FormulaCode = expression; - // props.calFormState.validateField?.('FormulaCode', expression, false); - // } - - // function addValue(val) { - // addToExpression(val); - // props.calFormState.form.FormulaCode = expression; - // props.calFormState.validateField?.('FormulaCode', expression, false); - // } - - // function handleInput(e) { - // expression = e.target.value; - // cursorPosition = e.target.selectionStart; - // formState.form.FormulaCode = expression; - // formState.validateField?.('FormulaCode', expression, false); - // } - - // function handleClick(e) { - // cursorPosition = e.target.selectionStart; - // } - - // function handleContainerClick(e) { - // const rect = e.currentTarget.getBoundingClientRect(); - // const text = expression; - // const charWidth = 8.5; - // const padding = 12; - // const clickX = e.clientX - rect.left - padding; - // let newPos = Math.floor(clickX / charWidth); - // newPos = Math.max(0, Math.min(newPos, text.length)); - // cursorPosition = newPos; - // } - - // function moveCursorLeft() { - // if (cursorPosition > 0) { - // cursorPosition -= 1; - // } - // } - - // function moveCursorRight() { - // if (cursorPosition < expression.length) { - // cursorPosition += 1; - // } - // } - - // function deleteChar() { - // if (cursorPosition > 0) { - // const before = expression.slice(0, cursorPosition - 1); - // const after = expression.slice(cursorPosition); - // expression = before + after; - // cursorPosition -= 1; - // props.calFormState.form.FormulaCode = expression; - // props.calFormState.validateField?.('FormulaCode', expression, false); - // } - // } - - // function clearExpression() { - // expression = ''; - // cursorPosition = 0; - // props.calFormState.form.FormulaCode = expression; - // props.calFormState.validateField?.('FormulaCode', expression, false); - // }
Enter Text Value
- { - if (e.key === 'Enter' && stringLiteralInput.trim()) { - onAddLiteral(`"${stringLiteralInput.trim()}"`); - stringLiteralInput = ''; - } - }} - /> -Enter Text Value
+ { + if (e.key === 'Enter' && stringLiteralInput.trim()) { + onAddLiteral(`"${stringLiteralInput.trim()}"`); + stringLiteralInput = ''; + } + }} + /> +Enter Number Value
+ { + if (e.key === 'Enter' && numberLiteralInput != null && !isNaN(numberLiteralInput)) { + onAddLiteral(String(numberLiteralInput)); + numberLiteralInput = null; + } + }} + /> +{expressionString}
Enter Number Value
- { - if (e.key === 'Enter' && numberLiteralInput != null && !isNaN(numberLiteralInput)) { - onAddLiteral(String(numberLiteralInput)); - numberLiteralInput = null; - } - }} - /> -{expressionString}
-