@@ -3,14 +3,14 @@ import { formatInternationalPhoneNumberForDisplay } from "@openclaw/normalizatio
33import { html , nothing , type TemplateResult } from "lit" ;
44import { ref } from "lit/directives/ref.js" ;
55import { i18n , t } from "../i18n/index.ts" ;
6- import { formatUnknownText } from "../lib/format.ts" ;
76import {
87 isSupportedConfigValueValid ,
98 normalizeNumericValue ,
109 numericInputConstraints ,
1110} from "./config-form.constraints.ts" ;
1211import {
1312 configEnumOptionLabel ,
13+ formatConfigValueText ,
1414 getSensitiveRenderState ,
1515 isSecretRefObject ,
1616 jsonValue ,
@@ -23,8 +23,8 @@ import {
2323} from "./config-form.node.shared.ts" ;
2424import {
2525 coerceConfigFormNumberString ,
26- formatConfigFormNumber ,
2726 isConfigFormDecimalNumberString ,
27+ isConfigFormUnsafeIntegerString ,
2828} from "./config-form.numeric.ts" ;
2929import {
3030 beginScalarEdit ,
@@ -61,10 +61,6 @@ function setControlValidity(target: HTMLInputElement, message: string): boolean
6161 return ! message ;
6262}
6363
64- function formatScalarInputValue ( value : unknown ) : string {
65- return typeof value === "number" ? formatConfigFormNumber ( value ) : formatUnknownText ( value ) ;
66- }
67-
6864function syncScalarInputIdentity (
6965 element : Element | undefined ,
7066 controlIdentity : unknown ,
@@ -163,11 +159,7 @@ function coerceTextInputValue(
163159 return numberCandidate ;
164160 }
165161 if ( isConfigFormDecimalNumberString ( value ) ) {
166- return stringCandidateValid &&
167- / ^ - ? \d + $ / u. test ( trimmed ) &&
168- ! Number . isSafeInteger ( Number ( trimmed ) )
169- ? value
170- : undefined ;
162+ return stringCandidateValid && isConfigFormUnsafeIntegerString ( trimmed ) ? value : undefined ;
171163 }
172164 }
173165 if ( currentBranch === "string" && stringCandidateValid ) {
@@ -300,7 +292,7 @@ export function renderTextInput(
300292 : redactedPlaceholder ( )
301293 : ( hint ?. placeholder ??
302294 ( schema . default !== undefined
303- ? t ( "configForm.defaultValue" , { value : formatScalarInputValue ( schema . default ) } )
295+ ? t ( "configForm.defaultValue" , { value : formatConfigValueText ( schema . default ) } )
304296 : "" ) ) ;
305297 const displayValue = effectiveRedacted
306298 ? ""
@@ -318,7 +310,7 @@ export function renderTextInput(
318310 const controlIdentity = params . controlIdentity ?? params . sourceIdentity ?? value ;
319311 const sourceIdentity = params . sourceIdentity ?? value ;
320312 const controlPathKey = configFieldId ( path , "scalar-identity" ) ;
321- const renderedValue = formatScalarInputValue ( displayValue ) ;
313+ const renderedValue = formatConfigValueText ( displayValue ) ;
322314 const presentationIdentity = [
323315 effectiveRedacted ? "redacted" : "visible" ,
324316 effectiveInputType ,
@@ -524,7 +516,7 @@ export function renderNumberInput(params: ConfigNodeRenderParams): TemplateResul
524516 const controlIdentity = params . controlIdentity ?? params . sourceIdentity ?? value ;
525517 const sourceIdentity = params . sourceIdentity ?? value ;
526518 const controlPathKey = configFieldId ( path , "scalar-identity" ) ;
527- const renderedValue = formatScalarInputValue ( displayValue ) ;
519+ const renderedValue = formatConfigValueText ( displayValue ) ;
528520 const revalidate = ( target : HTMLInputElement ) => {
529521 setControlValidity (
530522 target ,
@@ -582,7 +574,7 @@ export function renderNumberInput(params: ConfigNodeRenderParams): TemplateResul
582574 aria-describedby =${ helpId ?? nothing }
583575 aria-invalid="false"
584576 placeholder=${ schema . default !== undefined
585- ? t ( "configForm.defaultValue" , { value : formatScalarInputValue ( schema . default ) } )
577+ ? t ( "configForm.defaultValue" , { value : formatConfigValueText ( schema . default ) } )
586578 : nothing }
587579 min=${ constraints . min ?? nothing }
588580 max=${ constraints . max ?? nothing }
@@ -616,7 +608,7 @@ export function renderNumberInput(params: ConfigNodeRenderParams): TemplateResul
616608 return ;
617609 }
618610 const normalized = normalizeNumericValue ( state . parsed , schema ) ;
619- target . value = formatConfigFormNumber ( normalized ) ;
611+ target . value = formatConfigValueText ( normalized ) ;
620612 if ( setControlValidity ( target , numericConstraintMessage ( normalized , schema ) ) ) {
621613 commitScalarValue ( target , normalized ) ;
622614 }
@@ -706,7 +698,7 @@ export function renderSelect(
706698 ?disabled=${ params . isRequired && schema . default === undefined }
707699 >
708700 ${ schema . default !== undefined
709- ? t ( "configForm.defaultValue" , { value : formatUnknownText ( schema . default ) } )
701+ ? t ( "configForm.defaultValue" , { value : formatConfigValueText ( schema . default ) } )
710702 : t ( "configForm.select" ) }
711703 </ option >
712704 ${ canSelectNull
0 commit comments