awing-library 2.1.2-dev.536 → 2.1.2-dev.537

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.
@@ -1 +1 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/AWING/DataForm/container.tsx"],"names":[],"mappings":"AAIA,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,2CAkQzE"}
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,2CA4PzE"}
@@ -1,7 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Box, Grid, Paper, Typography } from "@mui/material";
3
3
  import DataInput from "../DataInput/index.js";
4
- import { keysIn } from "lodash";
5
4
  import { useEffect, useRef, useState } from "react";
6
5
  import { calculateFormValid, handleFields, updateFieldsWithFormulas } from "./utils.js";
7
6
  function DataForm(props) {
@@ -12,15 +11,11 @@ function DataForm(props) {
12
11
  const [dataFormState, setDataFormState] = useState(()=>{
13
12
  const fieldsToUpdate = {};
14
13
  const validation = {};
14
+ const isEditMode = !!(propsOldValue && Object.keys(propsOldValue).length > 0);
15
15
  fields.forEach((fieldDef)=>{
16
16
  const fieldName = fieldDef.fieldName;
17
- if (oldValue?.[fieldName] !== void 0) {
18
- fieldsToUpdate[fieldName] = oldValue[fieldName];
19
- validation[fieldName] = true;
20
- } else if (void 0 !== fieldDef.defaultValue) {
21
- fieldsToUpdate[fieldName] = fieldDef.defaultValue;
22
- validation[fieldName] = true;
23
- } else validation[fieldName] = true;
17
+ if (!isEditMode && void 0 !== fieldDef.defaultValue) fieldsToUpdate[fieldName] = fieldDef.defaultValue;
18
+ validation[fieldName] = true;
24
19
  });
25
20
  return {
26
21
  fieldsToUpdate: fieldsToUpdate,
@@ -28,46 +23,24 @@ function DataForm(props) {
28
23
  };
29
24
  });
30
25
  useEffect(()=>{
31
- if (!oldValue) return;
32
- const o = {
33
- ...oldValue
34
- };
35
- fields.map((fieldDef)=>{
36
- const fieldName = fieldDef.fieldName;
37
- if (props?.oldValue?.[fieldName] !== oldValue?.[fieldName]) o[fieldName] = props?.oldValue?.[fieldName];
38
- });
39
- if (keysIn(o).length) setOldValue(o);
40
- calculateFormValid(dataFormState, fields, o, onValidateForm, onFormValid);
41
- }, [
42
- oldValue?.versionId,
43
- fields
44
- ]);
45
- useEffect(()=>{
46
- const versionId = propsOldValue?.versionId;
47
- if (propsOldValue && versionId && versionId > 0) {
26
+ if (propsOldValue) {
27
+ const isNewPropsPopulated = !!(propsOldValue && Object.keys(propsOldValue).length > 0);
28
+ const isCurrentOldValueEmpty = !oldValue || 0 === Object.keys(oldValue).length;
48
29
  setOldValue(propsOldValue);
49
- setDataFormState((pre)=>{
50
- const newFieldsToUpdate = {
51
- ...pre.fieldsToUpdate
52
- };
53
- const newValidation = {
54
- ...pre.validation
55
- };
56
- fields.forEach((fieldDef)=>{
57
- const fieldName = fieldDef.fieldName;
58
- if (props?.oldValue?.[fieldName] !== oldValue?.[fieldName]) {
59
- newFieldsToUpdate[fieldName] = props?.oldValue?.[fieldName];
60
- newValidation[fieldName] = true;
61
- }
30
+ if (isNewPropsPopulated) setDataFormState((pre)=>{
31
+ if (!isCurrentOldValueEmpty && Object.keys(pre.fieldsToUpdate).length > 0) return pre;
32
+ const newValidation = {};
33
+ fields.forEach((field)=>{
34
+ newValidation[field.fieldName] = true;
62
35
  });
63
36
  return {
64
- fieldsToUpdate: newFieldsToUpdate,
37
+ fieldsToUpdate: {},
65
38
  validation: newValidation
66
39
  };
67
40
  });
68
41
  }
69
42
  }, [
70
- propsOldValue && propsOldValue?.versionId
43
+ JSON.stringify(propsOldValue)
71
44
  ]);
72
45
  const handleChange = (fieldName, newValue, valid)=>{
73
46
  setDataFormState((pre)=>{
@@ -6,10 +6,10 @@ 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
- "../DataInput": function(module) {
9
+ "AWING/DataInput": function(module) {
10
10
  module.exports = __WEBPACK_EXTERNAL_MODULE__DataInput_index_js_c7933a4f__;
11
11
  },
12
- "../helper": function(module) {
12
+ "AWING/helper": function(module) {
13
13
  module.exports = __WEBPACK_EXTERNAL_MODULE__helper_js_663c9e82__;
14
14
  }
15
15
  };
@@ -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__("../DataInput");
26
+ var index_js_ = __webpack_require__("AWING/DataInput");
27
27
  jest.mock('../DataInput', ()=>({
28
28
  __esModule: true,
29
29
  default: jest.fn(),
@@ -91,10 +91,10 @@ jest.mock('@mui/material', ()=>({
91
91
  children: children
92
92
  })
93
93
  }));
94
- const mockInputFactory = __webpack_require__("../DataInput")["default"];
95
- const mockCalculateValue = __webpack_require__("../helper").calculateValue;
96
- const mockConvertFormulaToBinaryTree = __webpack_require__("../helper").convertFormulaToBinaryTree;
97
- const mockReplaceFieldsValue = __webpack_require__("../helper").replaceFieldsValue;
94
+ const mockInputFactory = __webpack_require__("AWING/DataInput")["default"];
95
+ const mockCalculateValue = __webpack_require__("AWING/helper").calculateValue;
96
+ const mockConvertFormulaToBinaryTree = __webpack_require__("AWING/helper").convertFormulaToBinaryTree;
97
+ const mockReplaceFieldsValue = __webpack_require__("AWING/helper").replaceFieldsValue;
98
98
  describe('DataForm Component', ()=>{
99
99
  const mockFields = [
100
100
  {
@@ -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
- "../DataInput": function(module) {
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__("../DataInput")["default"];
101
+ const mockInputFactory = __webpack_require__("AWING/DataInput")["default"];
102
102
  describe('DataForm Optimized - Performance Tests', ()=>{
103
103
  let inputRenderCounts = {};
104
104
  const mockFields = [
@@ -1 +1 @@
1
- {"version":3,"file":"AddOrEdit.d.ts","sourceRoot":"","sources":["../../../src/AWING/DirectoryForm/AddOrEdit.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,SAAS,CAAC;AAG7D,QAAA,MAAM,eAAe,UAAW,cAAc,4CA2H7C,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"AddOrEdit.d.ts","sourceRoot":"","sources":["../../../src/AWING/DirectoryForm/AddOrEdit.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,SAAS,CAAC;AAG7D,QAAA,MAAM,eAAe,UAAW,cAAc,4CAoI7C,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -116,7 +116,7 @@ const CreateDirectory = (props)=>{
116
116
  onUpdate: handleUpdate,
117
117
  fields: fields,
118
118
  oldValue: directory
119
- })
119
+ }, `${parentDirectoryId}_${directory?.versionId || 0}`)
120
120
  });
121
121
  };
122
122
  const AddOrEdit = CreateDirectory;
@@ -202,7 +202,7 @@ const CreateOrEdit = ()=>{
202
202
  ...newValue
203
203
  }));
204
204
  }
205
- }, objectFilter.objectTypeCode)
205
+ }, `${objectFilterId || 'new'}_${objectFilter.versionId || 0}`)
206
206
  });
207
207
  };
208
208
  const ObjectFilter_CreateOrEdit = CreateOrEdit;
@@ -1 +1 @@
1
- {"version":3,"file":"CreateOrEdit.d.ts","sourceRoot":"","sources":["../../../../src/Features/SYSTEM/Role/CreateOrEdit.tsx"],"names":[],"mappings":"AAUA,QAAA,MAAM,YAAY,+CAsHjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"CreateOrEdit.d.ts","sourceRoot":"","sources":["../../../../src/Features/SYSTEM/Role/CreateOrEdit.tsx"],"names":[],"mappings":"AAUA,QAAA,MAAM,YAAY,+CAuHjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -101,7 +101,7 @@ const CreateOrEdit = ()=>{
101
101
  getOptionValue: (option)=>option?.value
102
102
  }
103
103
  ]
104
- })
104
+ }, `${currentRole?.id || 'new'}_${currentRole?.versionId || 0}`)
105
105
  });
106
106
  };
107
107
  const Role_CreateOrEdit = CreateOrEdit;
@@ -1 +1 @@
1
- {"version":3,"file":"CreateOrEdit.d.ts","sourceRoot":"","sources":["../../../../src/Features/SYSTEM/RoleTag/CreateOrEdit.tsx"],"names":[],"mappings":"AAUA,QAAA,MAAM,YAAY,+CA+GjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"CreateOrEdit.d.ts","sourceRoot":"","sources":["../../../../src/Features/SYSTEM/RoleTag/CreateOrEdit.tsx"],"names":[],"mappings":"AAUA,QAAA,MAAM,YAAY,+CAgHjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -101,7 +101,7 @@ const CreateOrEdit = ()=>{
101
101
  getOptionValue: (option)=>option?.value
102
102
  }
103
103
  ]
104
- })
104
+ }, `${oldRoleTag?.id || 'new'}_${oldRoleTag?.versionId || 0}`)
105
105
  });
106
106
  };
107
107
  const RoleTag_CreateOrEdit = CreateOrEdit;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaInformation.d.ts","sourceRoot":"","sources":["../../../../../src/Features/SYSTEM/Schema/components/SchemaInformation.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,oBAAoB;IACjC,qBAAqB,EAAE,MAAM,GAAG,EAAE,CAAC;IACnC,mBAAmB,EAAE,MAAM,OAAO,CAAC;CACtC;AAED,QAAA,MAAM,iBAAiB,gGA2GrB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"SchemaInformation.d.ts","sourceRoot":"","sources":["../../../../../src/Features/SYSTEM/Schema/components/SchemaInformation.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,oBAAoB;IACjC,qBAAqB,EAAE,MAAM,GAAG,EAAE,CAAC;IACnC,mBAAmB,EAAE,MAAM,OAAO,CAAC;CACtC;AAED,QAAA,MAAM,iBAAiB,gGA4GrB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
@@ -86,7 +86,7 @@ const SchemaInformation_SchemaInformation = /*#__PURE__*/ forwardRef((_props, re
86
86
  name: schema?.name
87
87
  },
88
88
  padding: 'none'
89
- }),
89
+ }, schema?.id || 'new'),
90
90
  /*#__PURE__*/ jsx(Typography, {
91
91
  sx: {
92
92
  fontWeight: 'bold',
@@ -1 +1 @@
1
- {"version":3,"file":"Edit.d.ts","sourceRoot":"","sources":["../../../../src/Features/SYSTEM/User/Edit.tsx"],"names":[],"mappings":"AAkBA,QAAA,MAAM,IAAI,+CA6MT,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Edit.d.ts","sourceRoot":"","sources":["../../../../src/Features/SYSTEM/User/Edit.tsx"],"names":[],"mappings":"AAkBA,QAAA,MAAM,IAAI,+CA8MT,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -173,7 +173,7 @@ const Edit = ()=>{
173
173
  setReadyForSubmit(formValid);
174
174
  }
175
175
  }
176
- })
176
+ }, `${userId}_${user?.versionId || 0}`)
177
177
  });
178
178
  };
179
179
  const User_Edit = Edit;
@@ -1 +1 @@
1
- {"version":3,"file":"Information.d.ts","sourceRoot":"","sources":["../../../../../src/Features/SYSTEM/Workflow/component/Information.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG/C,UAAU,KAAK;IACX,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC9B,iBAAiB,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1F,iBAAiB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACzD;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAK,EAAE,KAAK,2CAuD/C"}
1
+ {"version":3,"file":"Information.d.ts","sourceRoot":"","sources":["../../../../../src/Features/SYSTEM/Workflow/component/Information.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG/C,UAAU,KAAK;IACX,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC9B,iBAAiB,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1F,iBAAiB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACzD;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAK,EAAE,KAAK,2CAwD/C"}
@@ -52,6 +52,6 @@ function Information(props) {
52
52
  oldValue: formData,
53
53
  onUpdate: onUpdateFormValid,
54
54
  padding: "none"
55
- });
55
+ }, `${formData?.id || 'new'}_${formData?.versionId || 0}`);
56
56
  }
57
57
  export { Information as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.2-dev.536",
3
+ "version": "2.1.2-dev.537",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {