This is an automated email from the ASF dual-hosted git repository. shuai pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/answer.git
commit 157dbfd08a1474534fe3548ef02243bf421ba020 Author: Dinesht04 <[email protected]> AuthorDate: Fri Nov 14 02:28:46 2025 +0530 feat(ui): add types, logic and defaults for min, max value of input component of form --- ui/src/components/SchemaForm/components/Input.tsx | 9 ++++++--- ui/src/components/SchemaForm/index.tsx | 9 +++++++++ ui/src/components/SchemaForm/types.ts | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ui/src/components/SchemaForm/components/Input.tsx b/ui/src/components/SchemaForm/components/Input.tsx index c0fd084c..3a2c0397 100644 --- a/ui/src/components/SchemaForm/components/Input.tsx +++ b/ui/src/components/SchemaForm/components/Input.tsx @@ -29,7 +29,8 @@ interface Props { onChange?: (fd: Type.FormDataType) => void; formData: Type.FormDataType; readOnly: boolean; - minValue?: number; + min?: number; + max?: number; inputMode?: | 'text' | 'search' @@ -48,7 +49,8 @@ const Index: FC<Props> = ({ onChange, formData, readOnly = false, - minValue = 0, + min = 0, + max = 65355, inputMode = 'text', }) => { const fieldObject = formData[fieldName]; @@ -73,7 +75,8 @@ const Index: FC<Props> = ({ placeholder={placeholder} type={type} value={fieldObject?.value || ''} - min={minValue} + min={min} + max={max} inputMode={inputMode} onChange={handleChange} disabled={readOnly} diff --git a/ui/src/components/SchemaForm/index.tsx b/ui/src/components/SchemaForm/index.tsx index 23b193b4..5bde2fdc 100644 --- a/ui/src/components/SchemaForm/index.tsx +++ b/ui/src/components/SchemaForm/index.tsx @@ -260,6 +260,8 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = ( enum: enumValues = [], enumNames = [], max_length = 0, + max = 65355, + min = 0, } = properties[key]; const { 'ui:widget': widget = 'input', 'ui:options': uiOpt } = uiSchema?.[key] || {}; @@ -374,6 +376,8 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = ( placeholder={ uiOpt && 'placeholder' in uiOpt ? uiOpt.placeholder : '' } + min={min} + max={max} fieldName={key} onChange={onChange} formData={formData} @@ -408,9 +412,14 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = ( type={ uiOpt && 'inputType' in uiOpt ? uiOpt.inputType : 'text' } + inputMode={ + uiOpt && 'inputMode' in uiOpt ? uiOpt.inputMode : 'text' + } placeholder={ uiOpt && 'placeholder' in uiOpt ? uiOpt.placeholder : '' } + min={min} + max={max} fieldName={key} onChange={onChange} formData={formData} diff --git a/ui/src/components/SchemaForm/types.ts b/ui/src/components/SchemaForm/types.ts index eaedf902..55cf8e99 100644 --- a/ui/src/components/SchemaForm/types.ts +++ b/ui/src/components/SchemaForm/types.ts @@ -49,6 +49,8 @@ export interface JSONSchema { description?: string; enum?: Array<string | boolean | number>; enumNames?: string[]; + min?: number; + max?: number; default?: string | boolean | number | any[]; max_length?: number; };
