You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by sh...@apache.org on 2025/11/20 02:51:52 UTC
(answer) branch dev updated (20cd4d7c -> 54e602c5)
This is an automated email from the ASF dual-hosted git repository.
shuai pushed a change to branch dev
in repository https://gitbox.apache.org/repos/asf/answer.git
from 20cd4d7c fix(deps): update protoc-gen-validate dependency to a new version
new 666ab706 feat(ui): add min values for inputs and context-based keyboards for inputs
new 157dbfd0 feat(ui): add types, logic and defaults for min, max value of input component of form
new 54e602c5 fix(ui): refactor number input props (min,max)
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
ui/src/components/SchemaForm/components/Input.tsx | 21 +++++++++++++++++++++
ui/src/components/SchemaForm/index.tsx | 12 ++++++++++++
ui/src/components/SchemaForm/types.ts | 12 ++++++++++++
ui/src/pages/Admin/Privileges/index.tsx | 2 ++
ui/src/pages/Admin/Write/index.tsx | 10 ++++++++++
5 files changed, 57 insertions(+)
(answer) 03/03: fix(ui): refactor number input props (min,max)
Posted by sh...@apache.org.
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 54e602c5e6ad9a8c49187eadc4d480fbd7892a97
Author: Dinesht04 <di...@gmail.com>
AuthorDate: Wed Nov 19 15:28:58 2025 +0530
fix(ui): refactor number input props (min,max)
---
ui/src/components/SchemaForm/components/Input.tsx | 9 ++++++---
ui/src/components/SchemaForm/index.tsx | 2 +-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/ui/src/components/SchemaForm/components/Input.tsx b/ui/src/components/SchemaForm/components/Input.tsx
index 3a2c0397..d84d7d55 100644
--- a/ui/src/components/SchemaForm/components/Input.tsx
+++ b/ui/src/components/SchemaForm/components/Input.tsx
@@ -50,10 +50,14 @@ const Index: FC<Props> = ({
formData,
readOnly = false,
min = 0,
- max = 65355,
+ max,
inputMode = 'text',
}) => {
const fieldObject = formData[fieldName];
+ const numberInputProps =
+ type === 'number'
+ ? { min, ...(max != null && max > 0 ? { max } : {}) }
+ : {};
const handleChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = evt.currentTarget;
const state = {
@@ -75,8 +79,7 @@ const Index: FC<Props> = ({
placeholder={placeholder}
type={type}
value={fieldObject?.value || ''}
- min={min}
- max={max}
+ {...numberInputProps}
inputMode={inputMode}
onChange={handleChange}
disabled={readOnly}
diff --git a/ui/src/components/SchemaForm/index.tsx b/ui/src/components/SchemaForm/index.tsx
index 5bde2fdc..171b5f67 100644
--- a/ui/src/components/SchemaForm/index.tsx
+++ b/ui/src/components/SchemaForm/index.tsx
@@ -260,7 +260,7 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = (
enum: enumValues = [],
enumNames = [],
max_length = 0,
- max = 65355,
+ max,
min = 0,
} = properties[key];
const { 'ui:widget': widget = 'input', 'ui:options': uiOpt } =
(answer) 01/03: feat(ui): add min values for inputs and context-based keyboards for inputs
Posted by sh...@apache.org.
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 666ab706a66f7c39c8bb758c0abc2c08c15d4967
Author: Dinesht04 <di...@gmail.com>
AuthorDate: Thu Nov 13 02:22:58 2025 +0530
feat(ui): add min values for inputs and context-based keyboards for inputs
---
ui/src/components/SchemaForm/components/Input.tsx | 15 +++++++++++++++
ui/src/components/SchemaForm/index.tsx | 3 +++
ui/src/components/SchemaForm/types.ts | 10 ++++++++++
ui/src/pages/Admin/Privileges/index.tsx | 2 ++
ui/src/pages/Admin/Write/index.tsx | 10 ++++++++++
5 files changed, 40 insertions(+)
diff --git a/ui/src/components/SchemaForm/components/Input.tsx b/ui/src/components/SchemaForm/components/Input.tsx
index 1a3fe319..c0fd084c 100644
--- a/ui/src/components/SchemaForm/components/Input.tsx
+++ b/ui/src/components/SchemaForm/components/Input.tsx
@@ -29,6 +29,17 @@ interface Props {
onChange?: (fd: Type.FormDataType) => void;
formData: Type.FormDataType;
readOnly: boolean;
+ minValue?: number;
+ inputMode?:
+ | 'text'
+ | 'search'
+ | 'none'
+ | 'tel'
+ | 'url'
+ | 'email'
+ | 'numeric'
+ | 'decimal'
+ | undefined;
}
const Index: FC<Props> = ({
type = 'text',
@@ -37,6 +48,8 @@ const Index: FC<Props> = ({
onChange,
formData,
readOnly = false,
+ minValue = 0,
+ inputMode = 'text',
}) => {
const fieldObject = formData[fieldName];
const handleChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
@@ -60,6 +73,8 @@ const Index: FC<Props> = ({
placeholder={placeholder}
type={type}
value={fieldObject?.value || ''}
+ min={minValue}
+ inputMode={inputMode}
onChange={handleChange}
disabled={readOnly}
isInvalid={fieldObject?.isInvalid}
diff --git a/ui/src/components/SchemaForm/index.tsx b/ui/src/components/SchemaForm/index.tsx
index 421e0b1e..23b193b4 100644
--- a/ui/src/components/SchemaForm/index.tsx
+++ b/ui/src/components/SchemaForm/index.tsx
@@ -368,6 +368,9 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = (
{widget === 'input' ? (
<Input
type={uiOpt && 'inputType' in uiOpt ? uiOpt.inputType : 'text'}
+ inputMode={
+ uiOpt && 'inputMode' in uiOpt ? uiOpt.inputMode : 'text'
+ }
placeholder={
uiOpt && 'placeholder' in uiOpt ? uiOpt.placeholder : ''
}
diff --git a/ui/src/components/SchemaForm/types.ts b/ui/src/components/SchemaForm/types.ts
index db1aa8a5..eaedf902 100644
--- a/ui/src/components/SchemaForm/types.ts
+++ b/ui/src/components/SchemaForm/types.ts
@@ -88,6 +88,16 @@ export interface InputOptions extends BaseUIOptions {
| 'time'
| 'url'
| 'week';
+ inputMode?:
+ | 'text'
+ | 'search'
+ | 'none'
+ | 'tel'
+ | 'url'
+ | 'email'
+ | 'numeric'
+ | 'decimal'
+ | undefined;
}
export interface SelectOptions extends BaseUIOptions {}
export interface UploadOptions extends BaseUIOptions {
diff --git a/ui/src/pages/Admin/Privileges/index.tsx b/ui/src/pages/Admin/Privileges/index.tsx
index 5276912a..f0930c7a 100644
--- a/ui/src/pages/Admin/Privileges/index.tsx
+++ b/ui/src/pages/Admin/Privileges/index.tsx
@@ -90,6 +90,8 @@ const Index: FC = () => {
}
return true;
},
+ inputType: 'number',
+ inputMode: 'numeric',
},
};
});
diff --git a/ui/src/pages/Admin/Write/index.tsx b/ui/src/pages/Admin/Write/index.tsx
index 86d44d6d..fee2d28c 100644
--- a/ui/src/pages/Admin/Write/index.tsx
+++ b/ui/src/pages/Admin/Write/index.tsx
@@ -261,6 +261,8 @@ const Index: FC = () => {
<Form.Label>{t('min_tags.label')}</Form.Label>
<Form.Control
type="number"
+ inputMode="numeric"
+ min={0}
value={formData.min_tags.value}
isInvalid={formData.min_tags.isInvalid}
onChange={(evt) => {
@@ -302,6 +304,8 @@ const Index: FC = () => {
<Form.Label>{t('min_content.label')}</Form.Label>
<Form.Control
type="number"
+ inputMode="numeric"
+ min={0}
value={formData.min_content.value}
isInvalid={formData.min_content.isInvalid}
onChange={(evt) => {
@@ -344,6 +348,8 @@ const Index: FC = () => {
<Form.Label>{t('image_size.label')}</Form.Label>
<Form.Control
type="number"
+ inputMode="numeric"
+ min={0}
value={formData.max_image_size.value}
isInvalid={formData.max_image_size.isInvalid}
onChange={(evt) => {
@@ -366,6 +372,8 @@ const Index: FC = () => {
<Form.Label>{t('attachment_size.label')}</Form.Label>
<Form.Control
type="number"
+ inputMode="numeric"
+ min={0}
value={formData.max_attachment_size.value}
isInvalid={formData.max_attachment_size.isInvalid}
onChange={(evt) => {
@@ -388,6 +396,8 @@ const Index: FC = () => {
<Form.Label>{t('image_megapixels.label')}</Form.Label>
<Form.Control
type="number"
+ inputMode="numeric"
+ min={0}
isInvalid={formData.max_image_megapixel.isInvalid}
value={formData.max_image_megapixel.value}
onChange={(evt) => {
(answer) 02/03: feat(ui): add types, logic and defaults for min, max value of input component of form
Posted by sh...@apache.org.
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 <di...@gmail.com>
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;
};