>({
}
// Default input field (text, email, date, time, url, password, number, integer, float)
- const inputType = attr.type === 'email' ? 'email' :
- attr.type === 'date' ? 'date' :
- attr.type === 'time' ? 'time' :
- attr.type === 'timestamp' ? 'datetime-local' :
- attr.type === 'url' ? 'url' :
- attr.type === 'password' ? 'password' :
- (attr.type === 'number' || attr.type === 'integer' || attr.type === 'float') ? 'number' :
- 'text';
+ const inputType = attributeTypeToInputType(attr.type);
return (
@@ -674,7 +673,7 @@ export function FormGeneratorForm
>({
value={value || ''}
onChange={(e) => {
let newValue: any = e.target.value;
- if (attr.type === 'number' || attr.type === 'integer' || attr.type === 'float') {
+ if (isNumberType(attr.type)) {
newValue = e.target.value === '' ? '' : Number(e.target.value);
}
handleFieldChange(attr.name, newValue);
diff --git a/src/components/FormGenerator/FormGeneratorList/FormGeneratorList.tsx b/src/components/FormGenerator/FormGeneratorList/FormGeneratorList.tsx
index d53779c..0c1ba9e 100644
--- a/src/components/FormGenerator/FormGeneratorList/FormGeneratorList.tsx
+++ b/src/components/FormGenerator/FormGeneratorList/FormGeneratorList.tsx
@@ -13,12 +13,18 @@ import {
import { formatUnixTimestamp } from '../../../utils/time';
import TextField from '../../UiComponents/TextField/TextField';
import { FormGeneratorControls } from '../FormGeneratorControls';
+import {
+ isSelectType,
+ isCheckboxType,
+ attributeTypeToInputType
+} from '../../../utils/attributeTypeMapper';
+import type { AttributeType } from '../../../utils/attributeTypeMapper';
// Types for the FormGeneratorList
export interface FieldConfig {
key: string;
label: string;
- type?: 'string' | 'number' | 'date' | 'boolean' | 'enum' | 'readonly';
+ type?: AttributeType;
editable?: boolean;
required?: boolean;
formatter?: (value: any, row: any) => React.ReactNode;
@@ -456,7 +462,7 @@ export function FormGeneratorList>({
);
}
- if (field.type === 'enum' && field.options) {
+ if (isSelectType(field.type || 'string') && field.options) {
return (