@evoke-platform/ui-components 1.0.0-dev.1.10.9 → 1.0.0-dev.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +2 -2
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +2 -2
- package/dist/published/components/custom/FormField/FormField.d.ts +3 -0
- package/dist/published/components/custom/FormField/FormField.js +4 -1
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +7 -9
- package/dist/published/components/custom/FormField/Select/Select.js +2 -2
- package/package.json +1 -1
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Autocomplete, TextField } from '../../../core';
|
3
3
|
import InputFieldComponent from '../InputFieldComponent/InputFieldComponent';
|
4
4
|
const BooleanSelect = (props) => {
|
5
|
-
const { property, defaultValue, error, errorMessage, readOnly, size, placeholder } = props;
|
5
|
+
const { property, defaultValue, error, errorMessage, readOnly, size, placeholder, onBlur } = props;
|
6
6
|
const [value, setValue] = useState(defaultValue);
|
7
7
|
const id = property.id;
|
8
8
|
useEffect(() => {
|
@@ -22,6 +22,6 @@ const BooleanSelect = (props) => {
|
|
22
22
|
value: false,
|
23
23
|
},
|
24
24
|
];
|
25
|
-
return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { id: id, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, fullWidth: true, style: { background: 'white' }, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), value: value, onChange: handleChange, inputValue: value, options: booleanOptions, disableClearable: true, style: { background: 'white', borderRadius: '8px' } }));
|
25
|
+
return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { id: id, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, style: { background: 'white' }, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), value: value, onChange: handleChange, inputValue: value, options: booleanOptions, disableClearable: true, style: { background: 'white', borderRadius: '8px' } }));
|
26
26
|
};
|
27
27
|
export default BooleanSelect;
|
@@ -26,7 +26,7 @@ const asMonthDayYearFormat = (date) => {
|
|
26
26
|
}
|
27
27
|
};
|
28
28
|
const DatePickerSelect = (props) => {
|
29
|
-
const { property, defaultValue, error, errorMessage, readOnly, required, size } = props;
|
29
|
+
const { property, defaultValue, error, errorMessage, readOnly, required, size, onBlur } = props;
|
30
30
|
const [value, setValue] = useState(asCalendarDate(defaultValue));
|
31
31
|
const id = property.id;
|
32
32
|
useEffect(() => {
|
@@ -37,6 +37,6 @@ const DatePickerSelect = (props) => {
|
|
37
37
|
props.onChange(id, date, property);
|
38
38
|
};
|
39
39
|
return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, Object.assign(Object.assign({}, props), { defaultValue: asMonthDayYearFormat(value) })))) : (React.createElement(LocalizationProvider, null,
|
40
|
-
React.createElement(DatePicker, { value: value, onChange: handleChange, inputFormat: "MM/dd/yyyy", renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { id: id, error: error, errorMessage: errorMessage, fullWidth: true, required: required, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium' }))) })));
|
40
|
+
React.createElement(DatePicker, { value: value, onChange: handleChange, inputFormat: "MM/dd/yyyy", renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium' }))) })));
|
41
41
|
};
|
42
42
|
export default DatePickerSelect;
|
@@ -1,11 +1,14 @@
|
|
1
1
|
export declare type FormFieldProps = {
|
2
2
|
property: ObjectProperty;
|
3
3
|
onChange: Function;
|
4
|
+
onBlur?: Function;
|
4
5
|
defaultValue?: unknown;
|
5
6
|
error?: boolean;
|
6
7
|
errorMessage?: string;
|
7
8
|
required?: boolean;
|
8
9
|
readOnly?: boolean;
|
10
|
+
min?: number;
|
11
|
+
max?: number;
|
9
12
|
selectOptions?: Array<string>;
|
10
13
|
locale?: string;
|
11
14
|
size?: 'small' | 'medium';
|
@@ -5,13 +5,14 @@ import FileUploadControl from './FileUpload/FileUpload';
|
|
5
5
|
import InputFieldComponent from './InputFieldComponent/InputFieldComponent';
|
6
6
|
import Select from './Select/Select';
|
7
7
|
const FormField = (props) => {
|
8
|
-
const { defaultValue, error, onChange, property, readOnly, selectOptions, required, size, placeholder, errorMessage, mask } = props;
|
8
|
+
const { defaultValue, error, onChange, property, readOnly, selectOptions, required, size, placeholder, errorMessage, onBlur, mask, max, min } = props;
|
9
9
|
const id = property.id;
|
10
10
|
let control;
|
11
11
|
const commonProps = {
|
12
12
|
id,
|
13
13
|
property,
|
14
14
|
onChange,
|
15
|
+
onBlur,
|
15
16
|
error,
|
16
17
|
errorMessage,
|
17
18
|
readOnly,
|
@@ -20,6 +21,8 @@ const FormField = (props) => {
|
|
20
21
|
required,
|
21
22
|
size,
|
22
23
|
placeholder,
|
24
|
+
min,
|
25
|
+
max
|
23
26
|
};
|
24
27
|
switch (property.type) {
|
25
28
|
case 'boolean':
|
package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js
CHANGED
@@ -23,11 +23,11 @@ const NumericFormat = (props) => {
|
|
23
23
|
value: values.floatValue,
|
24
24
|
},
|
25
25
|
});
|
26
|
-
},
|
26
|
+
}, isNumericString: true, fixedDecimalScale: true, allowNegative: false })));
|
27
27
|
};
|
28
28
|
const InputFieldComponent = (props) => {
|
29
29
|
var _a;
|
30
|
-
const { property, defaultValue, error, errorMessage, readOnly, required, size, placeholder, mask } = props;
|
30
|
+
const { property, defaultValue, error, errorMessage, onBlur, readOnly, required, size, placeholder, mask, min, max } = props;
|
31
31
|
const [value, setValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
|
32
32
|
const [inputValue, setInputValue] = useState('');
|
33
33
|
const id = property.id;
|
@@ -47,11 +47,9 @@ const InputFieldComponent = (props) => {
|
|
47
47
|
setInputValue(selectValue);
|
48
48
|
};
|
49
49
|
const InputProps = property.type === 'number'
|
50
|
-
? {
|
51
|
-
inputComponent: NumericFormat,
|
52
|
-
}
|
50
|
+
? { inputComponent: NumericFormat, min, max }
|
53
51
|
: property.type === 'integer'
|
54
|
-
? { inputProps: { min
|
52
|
+
? { inputProps: { min, max } }
|
55
53
|
: null;
|
56
54
|
const selectOptions = (_a = property.enum) !== null && _a !== void 0 ? _a : [];
|
57
55
|
if (property.enum && !property.enum.includes(value)) {
|
@@ -60,7 +58,7 @@ const InputFieldComponent = (props) => {
|
|
60
58
|
//widgets had it like this, as strings w/isOptionEqualToValue
|
61
59
|
selectOptions.push(value);
|
62
60
|
}
|
63
|
-
return property.enum && !readOnly ? (React.createElement(Autocomplete, { id: id, options: selectOptions, onChange: handleSelectChange, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, fullWidth: true, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), disableClearable: true, value: value, isOptionEqualToValue: (option, value) => {
|
61
|
+
return property.enum && !readOnly ? (React.createElement(Autocomplete, { id: id, options: selectOptions, onChange: handleSelectChange, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, fullWidth: true, onBlur: onBlur, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), disableClearable: true, value: value, isOptionEqualToValue: (option, value) => {
|
64
62
|
return option.value === value;
|
65
63
|
}, error: error, required: required, inputValue: inputValue !== null && inputValue !== void 0 ? inputValue : '', onInputChange: handleInputValueChange })) : !mask ? (React.createElement(TextField, { id: id, sx: readOnly
|
66
64
|
? {
|
@@ -72,7 +70,7 @@ const InputFieldComponent = (props) => {
|
|
72
70
|
backgroundColor: '#f4f6f8',
|
73
71
|
},
|
74
72
|
}
|
75
|
-
: undefined, error: error, errorMessage: errorMessage, value: value, onChange: !readOnly ? handleChange : undefined, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), required: required, fullWidth: true, placeholder: placeholder, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium', type: property.type === 'integer' ? 'number' : 'text', multiline: property.type === 'string' && !!readOnly })) : (React.createElement(InputMask, { mask: mask, value: value, onChange: !readOnly ? handleChange : undefined, alwaysShowMask: true },
|
73
|
+
: undefined, error: error, errorMessage: errorMessage, value: value, onChange: !readOnly ? handleChange : undefined, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), required: required, fullWidth: true, onBlur: onBlur, placeholder: placeholder, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium', type: property.type === 'integer' ? 'number' : 'text', multiline: property.type === 'string' && !!readOnly })) : (React.createElement(InputMask, { mask: mask, value: value, onChange: !readOnly ? handleChange : undefined, alwaysShowMask: true },
|
76
74
|
React.createElement(TextField, { id: id, sx: readOnly
|
77
75
|
? {
|
78
76
|
'& .MuiOutlinedInput-notchedOutline': {
|
@@ -83,6 +81,6 @@ const InputFieldComponent = (props) => {
|
|
83
81
|
backgroundColor: '#f4f6f8',
|
84
82
|
},
|
85
83
|
}
|
86
|
-
: undefined, error: error, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), fullWidth: true, type: property.type === 'integer' ? 'number' : 'text' })));
|
84
|
+
: undefined, error: error, errorMessage: errorMessage, onBlur: onBlur, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), fullWidth: true, type: property.type === 'integer' ? 'number' : 'text' })));
|
87
85
|
};
|
88
86
|
export default InputFieldComponent;
|
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Autocomplete, TextField } from '../../../core';
|
3
3
|
import InputFieldComponent from '../InputFieldComponent/InputFieldComponent';
|
4
4
|
const Select = (props) => {
|
5
|
-
const { property, defaultValue, error, errorMessage, readOnly, selectOptions, required, size } = props;
|
5
|
+
const { property, defaultValue, error, errorMessage, onBlur, readOnly, selectOptions, required, size } = props;
|
6
6
|
const [value, setValue] = useState(defaultValue);
|
7
7
|
const [inputValue, setInputValue] = useState('');
|
8
8
|
useEffect(() => {
|
@@ -27,6 +27,6 @@ const Select = (props) => {
|
|
27
27
|
setInputValue(selectValue);
|
28
28
|
}
|
29
29
|
};
|
30
|
-
return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { multiple: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? true : false, id: id, renderInput: (params) => React.createElement(TextField, Object.assign({}, params, { value: value, fullWidth: true })), value: value, onChange: handleChange, options: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? property === null || property === void 0 ? void 0 : property.enum : selectOptions, disableClearable: true, inputValue: inputValue !== null && inputValue !== void 0 ? inputValue : '', error: error, errorMessage: errorMessage, required: required, onInputChange: handleInputValueChange, filterOptions: (option) => { var _a; return (property === null || property === void 0 ? void 0 : property.type) === 'array' ? (_a = property === null || property === void 0 ? void 0 : property.enum) === null || _a === void 0 ? void 0 : _a.filter((item) => item !== option.value) : option; }, size: size }));
|
30
|
+
return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { multiple: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? true : false, id: id, renderInput: (params) => React.createElement(TextField, Object.assign({}, params, { value: value, fullWidth: true, onBlur: onBlur })), value: value, onChange: handleChange, options: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? property === null || property === void 0 ? void 0 : property.enum : selectOptions, disableClearable: true, inputValue: inputValue !== null && inputValue !== void 0 ? inputValue : '', error: error, errorMessage: errorMessage, required: required, onInputChange: handleInputValueChange, filterOptions: (option) => { var _a; return (property === null || property === void 0 ? void 0 : property.type) === 'array' ? (_a = property === null || property === void 0 ? void 0 : property.enum) === null || _a === void 0 ? void 0 : _a.filter((item) => item !== option.value) : option; }, size: size }));
|
31
31
|
};
|
32
32
|
export default Select;
|