awing-library 2.1.30-beta → 2.1.31-beta
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.
|
@@ -43,14 +43,14 @@ var GeoFencing_1 = __importDefault(require("../../ACM-AXN/GeoFencing"));
|
|
|
43
43
|
var i18n_1 = __importDefault(require("../../i18n"));
|
|
44
44
|
var omit = require('lodash/omit');
|
|
45
45
|
function DataInput(props) {
|
|
46
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
46
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
47
47
|
var t = (0, react_i18next_1.useTranslation)(undefined, { i18n: i18n_1.default }).t;
|
|
48
48
|
var fieldDefinition = props.fieldDefinition, onChange = props.onChange, value = props.value, error = props.error, disableHelperText = props.disableHelperText;
|
|
49
49
|
var fieldName = fieldDefinition.fieldName, type = fieldDefinition.type, onValidate = fieldDefinition.onValidate, min = fieldDefinition.min, max = fieldDefinition.max, other = __rest(fieldDefinition, ["fieldName", "type", "onValidate", "min", "max"]);
|
|
50
|
-
var
|
|
50
|
+
var _k = react_2.default.useState(t('Common.InvalidData')), errorText = _k[0], setErrorText = _k[1];
|
|
51
51
|
var checkValidationValue = function (fieldDefinition, val) {
|
|
52
52
|
if (!fieldDefinition.required &&
|
|
53
|
-
(val === undefined || val === null || val === '' || val ===
|
|
53
|
+
(val === undefined || val === null || val === '' || (Array.isArray(val) && val.length === 0)))
|
|
54
54
|
return true;
|
|
55
55
|
if (fieldDefinition.onValidate)
|
|
56
56
|
return fieldDefinition.onValidate(val, fieldDefinition === null || fieldDefinition === void 0 ? void 0 : fieldDefinition.length, fieldDefinition === null || fieldDefinition === void 0 ? void 0 : fieldDefinition.pattern);
|
|
@@ -63,6 +63,8 @@ function DataInput(props) {
|
|
|
63
63
|
else
|
|
64
64
|
return (0, validation_1.notNullValid)(val);
|
|
65
65
|
}
|
|
66
|
+
case 'multiple-hierarchical':
|
|
67
|
+
return (0, validation_1.arrayIsNotEmptyValid)(val);
|
|
66
68
|
case 'month':
|
|
67
69
|
case 'date':
|
|
68
70
|
return (0, validation_1.dateValid)(val);
|
|
@@ -108,10 +110,10 @@ function DataInput(props) {
|
|
|
108
110
|
case 'autocomplete': {
|
|
109
111
|
return ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, { multiple: fieldDefinition.multiple, options: fieldDefinition.options, getOptionLabel: function (option) { var _a, _b; return (_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.text) !== null && _b !== void 0 ? _b : ''; }, isOptionEqualToValue: function (option, value) {
|
|
110
112
|
return (option === null || option === void 0 ? void 0 : option.value) === (value === null || value === void 0 ? void 0 : value.value);
|
|
111
|
-
}, onChange: function (e, value) {
|
|
113
|
+
}, disableclearable: fieldDefinition.disableClearable, onChange: function (e, value) {
|
|
112
114
|
var newValue = fieldDefinition.multiple
|
|
113
|
-
? value.map(function (x) { return x.value; })
|
|
114
|
-
: value.value;
|
|
115
|
+
? value.map(function (x) { return x === null || x === void 0 ? void 0 : x.value; })
|
|
116
|
+
: value === null || value === void 0 ? void 0 : value.value;
|
|
115
117
|
onChange(newValue, checkValidationValue(fieldDefinition, newValue));
|
|
116
118
|
}, value: fieldDefinition.multiple
|
|
117
119
|
? fieldDefinition.options.filter(function (x) {
|
|
@@ -155,7 +157,7 @@ function DataInput(props) {
|
|
|
155
157
|
}, readOnly: fieldDefinition.readOnly }));
|
|
156
158
|
}
|
|
157
159
|
case 'date-range': {
|
|
158
|
-
var
|
|
160
|
+
var _l = other, isDayBlocked = _l.isDayBlocked, isOutsideRange = _l.isOutsideRange;
|
|
159
161
|
return ((0, jsx_runtime_1.jsx)(AWING_1.DateRangePicker, { noBorder: true, variant: "standard", textFieldProps: __assign({ fullWidth: true, style: { margin: '8px 0px' } }, omit(other, ['isDayBlocked', 'isOutsideRange'])), value: {
|
|
160
162
|
startDate: (value === null || value === void 0 ? void 0 : value[0]) || null,
|
|
161
163
|
endDate: (value === null || value === void 0 ? void 0 : value[1]) || null,
|
|
@@ -208,6 +210,13 @@ function DataInput(props) {
|
|
|
208
210
|
}), { children: (_a = item.label) !== null && _a !== void 0 ? _a : item.text }), "".concat(fieldName.toString(), "-opt-").concat(index)));
|
|
209
211
|
})] })));
|
|
210
212
|
}
|
|
213
|
+
case 'multiple-hierarchical': {
|
|
214
|
+
return ((0, jsx_runtime_1.jsx)(AWING_1.MultipleHierarchicalChoice, __assign({}, fieldDefinition, { variant: "standard", value: value, onChange: function (value) {
|
|
215
|
+
onChange(value, checkValidationValue(fieldDefinition, value));
|
|
216
|
+
}, error: error, helperText: !disableHelperText && error
|
|
217
|
+
? (_h = fieldDefinition.helperText) !== null && _h !== void 0 ? _h : t('Common.InvalidData')
|
|
218
|
+
: '' })));
|
|
219
|
+
}
|
|
211
220
|
case 'geo-fencing': {
|
|
212
221
|
var configs = fieldDefinition.configs, label = fieldDefinition.label, initValue = fieldDefinition.initValue, value_1 = fieldDefinition.value, limit = fieldDefinition.limit, isOnlyMap = fieldDefinition.isOnlyMap;
|
|
213
222
|
return ((0, jsx_runtime_1.jsx)("div", { style: { marginTop: '16px' }, children: (0, jsx_runtime_1.jsx)(GeoFencing_1.default, { configs: configs, label: label, initValue: initValue, value: value_1, limit: limit, isOnlyMap: isOnlyMap, onChange: function (newValue) {
|
|
@@ -218,7 +227,7 @@ function DataInput(props) {
|
|
|
218
227
|
return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ id: fieldName.toString(), name: fieldName.toString(), type: fieldDefinition.type, fullWidth: true, variant: "standard" }, other, { value: value !== null && value !== void 0 ? value : '', onChange: function (event) {
|
|
219
228
|
return onChange(event.target.value, checkValidationValue(fieldDefinition, event.target.value));
|
|
220
229
|
}, error: error, helperText: !disableHelperText && error
|
|
221
|
-
? (
|
|
230
|
+
? (_j = fieldDefinition.helperText) !== null && _j !== void 0 ? _j : t('Common.InvalidData')
|
|
222
231
|
: '' })));
|
|
223
232
|
}
|
|
224
233
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { BaseTextFieldProps } from '@mui/material/TextField';
|
|
3
|
-
import { DataObject, MenuOption } from '../../AWING';
|
|
3
|
+
import { DataObject, IMultipleHierarchicalChoiceProps, MenuOption } from '../../AWING';
|
|
4
4
|
import { IMainObj, IListFunctions } from '../../AWING/LogicExpression/interface';
|
|
5
5
|
import { GeoFencingValue, IConfig } from '../../ACM-AXN/GeoFencing/interface';
|
|
6
6
|
import { Moment } from 'moment';
|
|
@@ -44,6 +44,7 @@ export type AutocompleteFieldDefinition<T extends DataObject> = BaseFieldDefinit
|
|
|
44
44
|
type: 'autocomplete';
|
|
45
45
|
options: Array<MenuOption>;
|
|
46
46
|
loading?: boolean;
|
|
47
|
+
disableClearable?: boolean;
|
|
47
48
|
};
|
|
48
49
|
export interface CheckBoxFieldDefinition<T extends DataObject> extends BaseFieldDefinition<T> {
|
|
49
50
|
type: 'checkbox';
|
|
@@ -122,5 +123,8 @@ export type SelectFieldDefinition<T extends DataObject> = BaseFieldDefinition<T>
|
|
|
122
123
|
row?: Partial<T>;
|
|
123
124
|
onDisabledSelectItem?: (value: any, row?: Partial<T>) => boolean;
|
|
124
125
|
};
|
|
125
|
-
export type
|
|
126
|
+
export type MultipleHierarchicalDefinition<T extends DataObject> = BaseFieldDefinition<T> & Omit<IMultipleHierarchicalChoiceProps, 'defaultValue' | 'onChange'> & {
|
|
127
|
+
type: 'multiple-hierarchical';
|
|
128
|
+
};
|
|
129
|
+
export type FieldDefinition<T extends DataObject> = AsyncAutocompleteFieldDefinition<T> | AutocompleteFieldDefinition<T> | LogicExpressionDefinition<T> | CheckBoxFieldDefinition<T> | DateTimeFieldDefinition<T> | DateRangeFieldDefinition<T> | NumberFieldDefinition<T> | RadioFieldDefinition<T> | SelectFieldDefinition<T> | TextFieldDefinition<T> | GeoFencingDefinition<T> | MultipleHierarchicalDefinition<T>;
|
|
126
130
|
export {};
|