df-ae-forms-package 1.0.69 → 1.0.71
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/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +85 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +85 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -178,9 +178,21 @@ class ConditionalLogicService {
|
|
|
178
178
|
if (found)
|
|
179
179
|
return found;
|
|
180
180
|
}
|
|
181
|
-
if (comp.name === 'table' && comp.cells) {
|
|
182
|
-
for (const
|
|
183
|
-
|
|
181
|
+
if (comp.name === 'table' && comp.cells && Array.isArray(comp.cells)) {
|
|
182
|
+
for (const rowOrCell of comp.cells) {
|
|
183
|
+
// Handle 2D array structure (standard: cells[row][col])
|
|
184
|
+
if (Array.isArray(rowOrCell)) {
|
|
185
|
+
for (const cell of rowOrCell) {
|
|
186
|
+
if (cell.components) {
|
|
187
|
+
const found = this.findComponent(cell.components, componentId);
|
|
188
|
+
if (found)
|
|
189
|
+
return found;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Handle 1D array structure (flat: cells[i]) - robust fallback
|
|
194
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
195
|
+
const cell = rowOrCell;
|
|
184
196
|
if (cell.components) {
|
|
185
197
|
const found = this.findComponent(cell.components, componentId);
|
|
186
198
|
if (found)
|
|
@@ -222,9 +234,18 @@ class ConditionalLogicService {
|
|
|
222
234
|
traverse(item.children);
|
|
223
235
|
if (item.templateComponents)
|
|
224
236
|
traverse(item.templateComponents);
|
|
225
|
-
if (item.cells) {
|
|
226
|
-
for (const
|
|
227
|
-
|
|
237
|
+
if (item.cells && Array.isArray(item.cells)) {
|
|
238
|
+
for (const rowOrCell of item.cells) {
|
|
239
|
+
// Handle 2D array structure (standard)
|
|
240
|
+
if (Array.isArray(rowOrCell)) {
|
|
241
|
+
for (const cell of rowOrCell) {
|
|
242
|
+
if (cell.components)
|
|
243
|
+
traverse(cell.components);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
// Handle 1D array structure (flat)
|
|
247
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
248
|
+
const cell = rowOrCell;
|
|
228
249
|
if (cell.components)
|
|
229
250
|
traverse(cell.components);
|
|
230
251
|
}
|
|
@@ -5999,17 +6020,35 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
5999
6020
|
values[component.id] = '';
|
|
6000
6021
|
}
|
|
6001
6022
|
}
|
|
6023
|
+
// CRITICAL: Also store by label and _id so conditional logic can find values.
|
|
6024
|
+
// condition.when stores the component LABEL (set in ConditionalLogicComponent.tsx line 163).
|
|
6025
|
+
// getComponentValue() checks formValues[label] first, so we must populate it here
|
|
6026
|
+
// to ensure show/hide logic evaluates correctly on initial load (before any user interaction).
|
|
6027
|
+
if (component.basic?.label) {
|
|
6028
|
+
values[component.basic.label] = values[component.id];
|
|
6029
|
+
}
|
|
6030
|
+
if (component._id) {
|
|
6031
|
+
values[component._id] = values[component.id];
|
|
6032
|
+
}
|
|
6002
6033
|
}
|
|
6003
6034
|
// Handle nested components in table cells
|
|
6004
6035
|
if (component.cells && Array.isArray(component.cells)) {
|
|
6005
|
-
component.cells.forEach((
|
|
6006
|
-
|
|
6007
|
-
|
|
6036
|
+
component.cells.forEach((rowOrCell, _rowIndex) => {
|
|
6037
|
+
// Handle 2D array (standard)
|
|
6038
|
+
if (Array.isArray(rowOrCell)) {
|
|
6039
|
+
rowOrCell.forEach((cell, _cellIndex) => {
|
|
6008
6040
|
if (cell && cell.components && Array.isArray(cell.components)) {
|
|
6009
6041
|
initializeComponentValues(cell.components, values);
|
|
6010
6042
|
}
|
|
6011
6043
|
});
|
|
6012
6044
|
}
|
|
6045
|
+
// Handle 1D array (flat)
|
|
6046
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
6047
|
+
const cell = rowOrCell;
|
|
6048
|
+
if (cell && cell.components && Array.isArray(cell.components)) {
|
|
6049
|
+
initializeComponentValues(cell.components, values);
|
|
6050
|
+
}
|
|
6051
|
+
}
|
|
6013
6052
|
});
|
|
6014
6053
|
}
|
|
6015
6054
|
// Handle nested components in datagrid entries
|
|
@@ -6070,11 +6109,23 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6070
6109
|
// Recurse
|
|
6071
6110
|
if (comp.children)
|
|
6072
6111
|
extractNotesAndAttachments(comp.children);
|
|
6073
|
-
if (comp.cells)
|
|
6074
|
-
comp.cells.forEach((
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6112
|
+
if (comp.cells && Array.isArray(comp.cells)) {
|
|
6113
|
+
comp.cells.forEach((rowOrCell) => {
|
|
6114
|
+
// Handle 2D array
|
|
6115
|
+
if (Array.isArray(rowOrCell)) {
|
|
6116
|
+
rowOrCell.forEach((cell) => {
|
|
6117
|
+
if (cell.components)
|
|
6118
|
+
extractNotesAndAttachments(cell.components);
|
|
6119
|
+
});
|
|
6120
|
+
}
|
|
6121
|
+
// Handle 1D array
|
|
6122
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
6123
|
+
const cell = rowOrCell;
|
|
6124
|
+
if (cell.components)
|
|
6125
|
+
extractNotesAndAttachments(cell.components);
|
|
6126
|
+
}
|
|
6127
|
+
});
|
|
6128
|
+
}
|
|
6078
6129
|
if (comp.entries)
|
|
6079
6130
|
comp.entries.forEach((entry) => {
|
|
6080
6131
|
if (entry.components)
|
|
@@ -6111,9 +6162,10 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6111
6162
|
validatedComponent.children = getValidatedComponents(validatedComponent.children);
|
|
6112
6163
|
}
|
|
6113
6164
|
if (validatedComponent.cells && Array.isArray(validatedComponent.cells)) {
|
|
6114
|
-
validatedComponent.cells = validatedComponent.cells.map((
|
|
6115
|
-
|
|
6116
|
-
|
|
6165
|
+
validatedComponent.cells = validatedComponent.cells.map((rowOrCell) => {
|
|
6166
|
+
// Handle 2D array
|
|
6167
|
+
if (Array.isArray(rowOrCell)) {
|
|
6168
|
+
return rowOrCell.map((cell) => {
|
|
6117
6169
|
if (cell && cell.components && Array.isArray(cell.components)) {
|
|
6118
6170
|
return {
|
|
6119
6171
|
...cell,
|
|
@@ -6123,7 +6175,18 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6123
6175
|
return cell;
|
|
6124
6176
|
});
|
|
6125
6177
|
}
|
|
6126
|
-
|
|
6178
|
+
// Handle 1D array
|
|
6179
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
6180
|
+
const cell = rowOrCell;
|
|
6181
|
+
if (cell && cell.components && Array.isArray(cell.components)) {
|
|
6182
|
+
return {
|
|
6183
|
+
...cell,
|
|
6184
|
+
components: getValidatedComponents(cell.components)
|
|
6185
|
+
};
|
|
6186
|
+
}
|
|
6187
|
+
return cell;
|
|
6188
|
+
}
|
|
6189
|
+
return rowOrCell;
|
|
6127
6190
|
});
|
|
6128
6191
|
}
|
|
6129
6192
|
if (validatedComponent.entries && Array.isArray(validatedComponent.entries)) {
|
|
@@ -6171,8 +6234,10 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6171
6234
|
// Initialize notes and attachments state
|
|
6172
6235
|
setComponentNotes(prev => ({ ...initialNotes, ...prev }));
|
|
6173
6236
|
setComponentAttachments(prev => ({ ...initialAttachments, ...prev }));
|
|
6174
|
-
// Evaluate initial conditional logic
|
|
6175
|
-
|
|
6237
|
+
// Evaluate initial conditional logic with the freshly computed initialValues.
|
|
6238
|
+
// We pass initialValues explicitly because setFormValues is async and formValues
|
|
6239
|
+
// in the closure is still the old state at this point.
|
|
6240
|
+
evaluateConditionalLogic(initialValues, validatedFormComponents);
|
|
6176
6241
|
}, [initialFormData, formComponents]);
|
|
6177
6242
|
// Synchronize component visibility whenever form values or components change
|
|
6178
6243
|
React.useEffect(() => {
|