feat(ui): add types, logic and defaults for min, max value of input component of form

This commit is contained in:
Dinesht04
2025-11-14 02:28:46 +05:30
committed by dashuai
parent 666ab706a6
commit 157dbfd08a
3 changed files with 17 additions and 3 deletions
@@ -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}
+9
View File
@@ -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}
+2
View File
@@ -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;
};