dynamic-mui 1.0.59 → 1.0.60
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/build/asset-manifest.json +3 -3
- package/build/index.html +1 -1
- package/build/static/js/main.a7616168.js +3 -0
- package/build/static/js/main.a7616168.js.map +1 -0
- package/dist-modules/components/FormGenerator.js +25 -1
- package/dist-modules/components/controls/Select/select.js +21 -9
- package/dist-modules/data/select.js +1 -0
- package/docs/asset-manifest.json +2 -2
- package/docs/build/bundle.a0d48865.js +2 -0
- package/docs/index.html +1 -1
- package/package.json +9 -9
- package/build/static/js/main.7ce6ae00.js +0 -3
- package/build/static/js/main.7ce6ae00.js.map +0 -1
- package/docs/build/bundle.f167def1.js +0 -2
- /package/build/static/js/{main.7ce6ae00.js.LICENSE.txt → main.a7616168.js.LICENSE.txt} +0 -0
- /package/docs/build/{bundle.f167def1.js.LICENSE.txt → bundle.a0d48865.js.LICENSE.txt} +0 -0
|
@@ -14,6 +14,7 @@ var _mui = _interopRequireDefault(require("../config/mui"));
|
|
|
14
14
|
var _DynamicComponent = _interopRequireDefault(require("./DynamicComponent"));
|
|
15
15
|
var _helper = require("../util/helper");
|
|
16
16
|
var _useUpdateEffect = _interopRequireDefault(require("../util/useUpdateEffect"));
|
|
17
|
+
var _validation = _interopRequireDefault(require("../util/validation"));
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -35,6 +36,28 @@ const ClearFormData = id => {
|
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
38
|
exports.ClearFormData = ClearFormData;
|
|
39
|
+
const getAllMandatoryFields = fields => fields.filter(field => {
|
|
40
|
+
var _field$rules;
|
|
41
|
+
return field === null || field === void 0 || (_field$rules = field.rules) === null || _field$rules === void 0 || (_field$rules = _field$rules.validation) === null || _field$rules === void 0 ? void 0 : _field$rules.some(validation => validation.rule === 'mandatory');
|
|
42
|
+
});
|
|
43
|
+
const getErrors = (fields, guid) => {
|
|
44
|
+
const mandatoryFields = getAllMandatoryFields(fields);
|
|
45
|
+
return mandatoryFields.reduce((acc, field) => {
|
|
46
|
+
var _field$rules2;
|
|
47
|
+
field === null || field === void 0 || (_field$rules2 = field.rules) === null || _field$rules2 === void 0 || (_field$rules2 = _field$rules2.validation) === null || _field$rules2 === void 0 || _field$rules2.forEach(rule => {
|
|
48
|
+
var _response$guid$field$;
|
|
49
|
+
const fieldValue = (_response$guid$field$ = response[guid][field.id]) === null || _response$guid$field$ === void 0 ? void 0 : _response$guid$field$.toString();
|
|
50
|
+
const isClean = fieldValue && _validation.default[rule.rule](fieldValue, rule.value);
|
|
51
|
+
if (!isClean) {
|
|
52
|
+
acc.push({
|
|
53
|
+
...rule,
|
|
54
|
+
id: field.id
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return acc;
|
|
59
|
+
}, []);
|
|
60
|
+
};
|
|
38
61
|
function FormGenerator(_ref) {
|
|
39
62
|
let {
|
|
40
63
|
data = [],
|
|
@@ -77,7 +100,8 @@ function FormGenerator(_ref) {
|
|
|
77
100
|
}, []);
|
|
78
101
|
const handleSubmit = (0, _react.useCallback)((submitCallback, formData, formGuid) => {
|
|
79
102
|
if (typeof submitCallback === 'function') {
|
|
80
|
-
|
|
103
|
+
const errors = getErrors();
|
|
104
|
+
submitCallback(response, errors, formData, formGuid);
|
|
81
105
|
}
|
|
82
106
|
}, []);
|
|
83
107
|
const onStepUpdate = (currentStep, isScreenChange, isLastStep) => {
|
|
@@ -27,18 +27,30 @@ const checkedIcon = /*#__PURE__*/_react.default.createElement(_CheckBox.default,
|
|
|
27
27
|
const getValue = function () {
|
|
28
28
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
29
29
|
let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
30
|
-
|
|
30
|
+
let isMultiple = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
31
|
+
if (isMultiple) {
|
|
32
|
+
let separator = ',';
|
|
33
|
+
if (defaultValue.includes(',')) separator = ',';else if (defaultValue.includes(';')) separator = ';';
|
|
34
|
+
const dValueSet = new Set(defaultValue.split(separator));
|
|
35
|
+
return options.filter(_ref => {
|
|
36
|
+
let {
|
|
37
|
+
value
|
|
38
|
+
} = _ref;
|
|
39
|
+
return dValueSet.has(value);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return options.find(_ref2 => {
|
|
31
43
|
let {
|
|
32
44
|
value
|
|
33
|
-
} =
|
|
34
|
-
return
|
|
45
|
+
} = _ref2;
|
|
46
|
+
return value === defaultValue;
|
|
35
47
|
});
|
|
36
48
|
};
|
|
37
|
-
function Select(
|
|
49
|
+
function Select(_ref3) {
|
|
38
50
|
let {
|
|
39
51
|
attributes,
|
|
40
52
|
onChange
|
|
41
|
-
} =
|
|
53
|
+
} = _ref3;
|
|
42
54
|
const {
|
|
43
55
|
MuiAttributes = {},
|
|
44
56
|
options = [],
|
|
@@ -46,8 +58,7 @@ function Select(_ref2) {
|
|
|
46
58
|
id = '',
|
|
47
59
|
InputProps = {}
|
|
48
60
|
} = attributes;
|
|
49
|
-
const [value, setValue] = _react.default.useState((attributes === null || attributes === void 0 ? void 0 : attributes.value) && getValue(options, attributes === null || attributes === void 0 ? void 0 : attributes.value));
|
|
50
|
-
// const [inputValue, setInputValue] = React.useState('');
|
|
61
|
+
const [value, setValue] = _react.default.useState((attributes === null || attributes === void 0 ? void 0 : attributes.value) && getValue(options, attributes === null || attributes === void 0 ? void 0 : attributes.value, MuiAttributes.multiple));
|
|
51
62
|
const getMuiAttributes = () => {
|
|
52
63
|
if (MuiAttributes.multiple) {
|
|
53
64
|
MuiAttributes.renderOption = function (props) {
|
|
@@ -68,10 +79,11 @@ function Select(_ref2) {
|
|
|
68
79
|
}
|
|
69
80
|
return MuiAttributes;
|
|
70
81
|
};
|
|
82
|
+
const extractValue = option => (option === null || option === void 0 ? void 0 : option.title) || (option === null || option === void 0 ? void 0 : option.label) || (option === null || option === void 0 ? void 0 : option.value);
|
|
71
83
|
const onChangeEvent = (0, _react.useCallback)((event, newValue) => {
|
|
72
84
|
setValue(newValue);
|
|
73
85
|
if (newValue) {
|
|
74
|
-
const data = MuiAttributes.multiple ?
|
|
86
|
+
const data = MuiAttributes.multiple ? newValue.map(extractValue) : extractValue(newValue);
|
|
75
87
|
onChange({
|
|
76
88
|
id,
|
|
77
89
|
value: data,
|
|
@@ -80,7 +92,7 @@ function Select(_ref2) {
|
|
|
80
92
|
} else onChange({
|
|
81
93
|
id,
|
|
82
94
|
value: '',
|
|
83
|
-
|
|
95
|
+
option: newValue
|
|
84
96
|
});
|
|
85
97
|
}, []);
|
|
86
98
|
return /*#__PURE__*/_react.default.createElement(_Autocomplete.default, _extends({}, getMuiAttributes(), {
|
package/docs/asset-manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
|
-
"main.js": "/DinakaranS/-dynamic-mui/build/bundle.
|
|
3
|
+
"main.js": "/DinakaranS/-dynamic-mui/build/bundle.a0d48865.js",
|
|
4
4
|
"index.html": "/DinakaranS/-dynamic-mui/index.html"
|
|
5
5
|
},
|
|
6
6
|
"entrypoints": [
|
|
7
|
-
"build/bundle.
|
|
7
|
+
"build/bundle.a0d48865.js"
|
|
8
8
|
]
|
|
9
9
|
}
|