awing-library 2.1.2-dev.541 → 2.1.2-dev.542
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/AWING/AsyncAutocomplete/Container.d.ts.map +1 -1
- package/dist/AWING/AsyncAutocomplete/Container.js +2 -2
- package/dist/AWING/DataForm/container.d.ts.map +1 -1
- package/dist/AWING/DataForm/container.js +35 -14
- package/dist/AWING/DataForm/container.test.js +3 -3
- package/dist/AWING/DataForm/utils.d.ts.map +1 -1
- package/dist/AWING/DataForm/utils.js +3 -1
- package/dist/AWING/DataForm2/containerOptimized.test.js +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../src/AWING/AsyncAutocomplete/Container.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../src/AWING/AsyncAutocomplete/Container.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC,2CA+N5E"}
|
|
@@ -21,9 +21,9 @@ function AsyncAutocomplete(props) {
|
|
|
21
21
|
const [isOpen, setIsOpen] = useState(open ?? false);
|
|
22
22
|
const [fetched, setFetched] = useState(false);
|
|
23
23
|
useEffect(()=>{
|
|
24
|
-
|
|
24
|
+
value && Object.keys(value).length > 0 ? setInputValue(getOptionLabel(value)) : setInputValue('');
|
|
25
25
|
}, [
|
|
26
|
-
value
|
|
26
|
+
JSON.stringify(value)
|
|
27
27
|
]);
|
|
28
28
|
const fetchRef = useRef(null);
|
|
29
29
|
useEffect(()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/AWING/DataForm/container.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/AWING/DataForm/container.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,2CA6QzE"}
|
|
@@ -14,7 +14,9 @@ function DataForm(props) {
|
|
|
14
14
|
const isEditMode = !!(propsOldValue && Object.keys(propsOldValue).length > 0);
|
|
15
15
|
fields.forEach((fieldDef)=>{
|
|
16
16
|
const fieldName = fieldDef.fieldName;
|
|
17
|
-
if (
|
|
17
|
+
if (isEditMode || void 0 === fieldDef.defaultValue) {
|
|
18
|
+
if (isEditMode && propsOldValue) fieldsToUpdate[fieldName] = propsOldValue[fieldName];
|
|
19
|
+
} else fieldsToUpdate[fieldName] = fieldDef.defaultValue;
|
|
18
20
|
validation[fieldName] = true;
|
|
19
21
|
});
|
|
20
22
|
return {
|
|
@@ -24,18 +26,37 @@ function DataForm(props) {
|
|
|
24
26
|
});
|
|
25
27
|
useEffect(()=>{
|
|
26
28
|
if (propsOldValue) {
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
+
const isFirstLoad = !oldValue || 0 === Object.keys(oldValue).length;
|
|
30
|
+
const newId = propsOldValue?.id;
|
|
31
|
+
const currentId = oldValue?.id;
|
|
32
|
+
const isNewId = newId !== currentId;
|
|
33
|
+
const isNewVersion = propsOldValue?.versionId !== oldValue?.versionId;
|
|
34
|
+
const isContentDifferent = JSON.stringify(propsOldValue) !== JSON.stringify(oldValue);
|
|
29
35
|
setOldValue(propsOldValue);
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
if (isFirstLoad || isNewId || isNewVersion || isContentDifferent) setDataFormState((pre)=>{
|
|
37
|
+
const newFieldsToUpdate = {
|
|
38
|
+
...pre.fieldsToUpdate
|
|
39
|
+
};
|
|
40
|
+
if (isFirstLoad || isNewId) {
|
|
41
|
+
const resetFields = {};
|
|
42
|
+
const newValidation = {};
|
|
43
|
+
fields.forEach((field)=>{
|
|
44
|
+
const fieldName = field.fieldName;
|
|
45
|
+
resetFields[fieldName] = propsOldValue[fieldName];
|
|
46
|
+
newValidation[fieldName] = true;
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
fieldsToUpdate: resetFields,
|
|
50
|
+
validation: newValidation
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
Object.keys(propsOldValue).forEach((key)=>{
|
|
54
|
+
const fieldKey = key;
|
|
55
|
+
newFieldsToUpdate[fieldKey] = propsOldValue[fieldKey];
|
|
35
56
|
});
|
|
36
57
|
return {
|
|
37
|
-
|
|
38
|
-
|
|
58
|
+
...pre,
|
|
59
|
+
fieldsToUpdate: newFieldsToUpdate
|
|
39
60
|
};
|
|
40
61
|
});
|
|
41
62
|
}
|
|
@@ -50,13 +71,12 @@ function DataForm(props) {
|
|
|
50
71
|
let newValidation = {
|
|
51
72
|
...pre.validation
|
|
52
73
|
};
|
|
53
|
-
|
|
54
|
-
else if (newFieldsToUpdate[fieldName] !== newValue) newFieldsToUpdate[fieldName] = newValue;
|
|
74
|
+
newFieldsToUpdate[fieldName] = newValue;
|
|
55
75
|
newValidation[fieldName] = valid;
|
|
56
76
|
if (props.fieldDependencies && props.fieldDependencies[fieldName]) {
|
|
57
77
|
const dependentFields = props.fieldDependencies[fieldName];
|
|
58
78
|
dependentFields.forEach((depField)=>{
|
|
59
|
-
|
|
79
|
+
newFieldsToUpdate[depField] = void 0;
|
|
60
80
|
newValidation[depField] = void 0;
|
|
61
81
|
});
|
|
62
82
|
}
|
|
@@ -108,7 +128,8 @@ function DataForm(props) {
|
|
|
108
128
|
if (onValues) onValues(completeValues, formValid, keyUpdate);
|
|
109
129
|
}, [
|
|
110
130
|
dataFormState,
|
|
111
|
-
keyUpdate
|
|
131
|
+
keyUpdate,
|
|
132
|
+
oldValue
|
|
112
133
|
]);
|
|
113
134
|
const renderField = (fieldDef)=>{
|
|
114
135
|
const { fieldName } = fieldDef;
|
|
@@ -6,7 +6,7 @@ import { fireEvent, render, screen } from "@testing-library/react";
|
|
|
6
6
|
import { Constants } from "../../Commons/Constant.js";
|
|
7
7
|
import container from "./container.js";
|
|
8
8
|
var __webpack_modules__ = {
|
|
9
|
-
"
|
|
9
|
+
"AWING/DataInput": function(module) {
|
|
10
10
|
module.exports = __WEBPACK_EXTERNAL_MODULE__DataInput_index_js_c7933a4f__;
|
|
11
11
|
},
|
|
12
12
|
"../helper": function(module) {
|
|
@@ -23,7 +23,7 @@ function __webpack_require__(moduleId) {
|
|
|
23
23
|
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
24
|
return module.exports;
|
|
25
25
|
}
|
|
26
|
-
var index_js_ = __webpack_require__("
|
|
26
|
+
var index_js_ = __webpack_require__("AWING/DataInput");
|
|
27
27
|
jest.mock('../DataInput', ()=>({
|
|
28
28
|
__esModule: true,
|
|
29
29
|
default: jest.fn(),
|
|
@@ -91,7 +91,7 @@ jest.mock('@mui/material', ()=>({
|
|
|
91
91
|
children: children
|
|
92
92
|
})
|
|
93
93
|
}));
|
|
94
|
-
const mockInputFactory = __webpack_require__("
|
|
94
|
+
const mockInputFactory = __webpack_require__("AWING/DataInput")["default"];
|
|
95
95
|
const mockCalculateValue = __webpack_require__("../helper").calculateValue;
|
|
96
96
|
const mockConvertFormulaToBinaryTree = __webpack_require__("../helper").convertFormulaToBinaryTree;
|
|
97
97
|
const mockReplaceFieldsValue = __webpack_require__("../helper").replaceFieldsValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/AWING/DataForm/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,iBAC1B,aAAa,CAAC,CAAC,CAAC,YACrB,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,YACtB,oBAAoB,CAAC,CAAC,CAAC,yBACV,OAAO;;;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/AWING/DataForm/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,iBAC1B,aAAa,CAAC,CAAC,CAAC,YACrB,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,YACtB,oBAAoB,CAAC,CAAC,CAAC,yBACV,OAAO;;;CA6BjC,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,MAAM,mBACpC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAAE,iBACpD,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,YAChD,OAAO,CAAC,CAAC,CAAC,cACR,OAAO,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,GAAE,CAAC,kBAChC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAAE;;2BAGlC,CAAC;CAyBpC,CAAC;AAGF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,iBAChC,aAAa,CAAC,CAAC,CAAC,UACvB,oBAAoB,CAAC,CAAC,CAAC,EAAE,cACrB,OAAO,CAAC,CAAC,CAAC,mBACL,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,gBAC1C,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,YAsC3C,CAAC;AAGF,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,CAG7C;AAGD,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAGlE;AAGD,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAGrF"}
|
|
@@ -3,7 +3,9 @@ import { calculateValue, convertFormulaToBinaryTree, replaceFieldsValue } from "
|
|
|
3
3
|
import { patternFieldText } from "../../Features/constants.js";
|
|
4
4
|
const handleFields = (dataFormState, oldValue, fieldDef, autoValidateFieldText)=>{
|
|
5
5
|
const { fieldName, value } = fieldDef;
|
|
6
|
-
const
|
|
6
|
+
const fieldKey = fieldName;
|
|
7
|
+
const isFieldDirty = fieldKey in dataFormState.fieldsToUpdate;
|
|
8
|
+
const fieldValue = isFieldDirty ? dataFormState.fieldsToUpdate[fieldKey] : oldValue?.[fieldKey] ?? value;
|
|
7
9
|
const showError = void 0 !== dataFormState.validation[fieldName] ? !dataFormState.validation[fieldName] : void 0;
|
|
8
10
|
if (autoValidateFieldText) {
|
|
9
11
|
if (fieldDef.type === FIELD_TYPE.TEXT || fieldDef.type === FIELD_TYPE.TEXT_AREA) fieldDef.pattern = fieldDef.pattern ? fieldDef.pattern : patternFieldText;
|
|
@@ -5,7 +5,7 @@ import { act, fireEvent, render, screen, waitFor } from "@testing-library/react"
|
|
|
5
5
|
import containerOptimized from "./containerOptimized.js";
|
|
6
6
|
import { createFormStateManager } from "./formStateManager.js";
|
|
7
7
|
var __webpack_modules__ = {
|
|
8
|
-
"
|
|
8
|
+
"AWING/DataInput": function(module) {
|
|
9
9
|
module.exports = __WEBPACK_EXTERNAL_MODULE__DataInput_index_js_c7933a4f__;
|
|
10
10
|
}
|
|
11
11
|
};
|
|
@@ -98,7 +98,7 @@ jest.mock('@mui/material', ()=>({
|
|
|
98
98
|
children: children
|
|
99
99
|
})
|
|
100
100
|
}));
|
|
101
|
-
const mockInputFactory = __webpack_require__("
|
|
101
|
+
const mockInputFactory = __webpack_require__("AWING/DataInput")["default"];
|
|
102
102
|
describe('DataForm Optimized - Performance Tests', ()=>{
|
|
103
103
|
let inputRenderCounts = {};
|
|
104
104
|
const mockFields = [
|