@visns-studio/visns-components 4.7.8 → 4.7.9

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/package.json CHANGED
@@ -75,7 +75,7 @@
75
75
  "react-dom": "^17.0.0 || ^18.0.0"
76
76
  },
77
77
  "name": "@visns-studio/visns-components",
78
- "version": "4.7.8",
78
+ "version": "4.7.9",
79
79
  "description": "Various packages to assist in the development of our Custom Applications.",
80
80
  "main": "src/index.js",
81
81
  "files": [
@@ -1572,13 +1572,29 @@ function Field({
1572
1572
 
1573
1573
  const handleAddEntry = (form) => {
1574
1574
  if (form) {
1575
- let f = form;
1575
+ let f = { ...form }; // Create a copy of the form object to avoid direct mutation
1576
1576
 
1577
1577
  form.fields.forEach((item, itemKey) => {
1578
- if (item.hasOwnProperty('dataId') && formData[item.dataId]) {
1579
- f.fields[itemKey].value = formData[item.dataId].value
1580
- ? formData[item.dataId].value
1581
- : formData[item.dataId];
1578
+ if (item.hasOwnProperty('dataId')) {
1579
+ let value;
1580
+
1581
+ if (Array.isArray(item.dataId)) {
1582
+ // If dataId is an array, nest the keys to access formData
1583
+ value = item.dataId.reduce((acc, key) => {
1584
+ return acc && acc[key] ? acc[key] : undefined;
1585
+ }, formData);
1586
+ } else {
1587
+ // If dataId is not an array, access formData directly
1588
+ value = formData[item.dataId]
1589
+ ? formData[item.dataId].value ||
1590
+ formData[item.dataId]
1591
+ : undefined;
1592
+ }
1593
+
1594
+ // Set the value if it exists
1595
+ if (value !== undefined) {
1596
+ f.fields[itemKey].value = value;
1597
+ }
1582
1598
  }
1583
1599
  });
1584
1600