df-ae-forms-package 1.0.72 → 1.0.74
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.esm.js +37 -103
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +37 -103
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -178,21 +178,9 @@ class ConditionalLogicService {
|
|
|
178
178
|
if (found)
|
|
179
179
|
return found;
|
|
180
180
|
}
|
|
181
|
-
if (comp.name === 'table' && comp.cells
|
|
182
|
-
for (const
|
|
183
|
-
|
|
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;
|
|
181
|
+
if (comp.name === 'table' && comp.cells) {
|
|
182
|
+
for (const row of comp.cells) {
|
|
183
|
+
for (const cell of row) {
|
|
196
184
|
if (cell.components) {
|
|
197
185
|
const found = this.findComponent(cell.components, componentId);
|
|
198
186
|
if (found)
|
|
@@ -234,18 +222,9 @@ class ConditionalLogicService {
|
|
|
234
222
|
traverse(item.children);
|
|
235
223
|
if (item.templateComponents)
|
|
236
224
|
traverse(item.templateComponents);
|
|
237
|
-
if (item.cells
|
|
238
|
-
for (const
|
|
239
|
-
|
|
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;
|
|
225
|
+
if (item.cells) {
|
|
226
|
+
for (const row of item.cells) {
|
|
227
|
+
for (const cell of row) {
|
|
249
228
|
if (cell.components)
|
|
250
229
|
traverse(cell.components);
|
|
251
230
|
}
|
|
@@ -6020,35 +5999,17 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6020
5999
|
values[component.id] = '';
|
|
6021
6000
|
}
|
|
6022
6001
|
}
|
|
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
|
-
}
|
|
6033
6002
|
}
|
|
6034
6003
|
// Handle nested components in table cells
|
|
6035
6004
|
if (component.cells && Array.isArray(component.cells)) {
|
|
6036
|
-
component.cells.forEach((
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
rowOrCell.forEach((cell, _cellIndex) => {
|
|
6005
|
+
component.cells.forEach((row, _rowIndex) => {
|
|
6006
|
+
if (Array.isArray(row)) {
|
|
6007
|
+
row.forEach((cell, _cellIndex) => {
|
|
6040
6008
|
if (cell && cell.components && Array.isArray(cell.components)) {
|
|
6041
6009
|
initializeComponentValues(cell.components, values);
|
|
6042
6010
|
}
|
|
6043
6011
|
});
|
|
6044
6012
|
}
|
|
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
|
-
}
|
|
6052
6013
|
});
|
|
6053
6014
|
}
|
|
6054
6015
|
// Handle nested components in datagrid entries
|
|
@@ -6109,23 +6070,11 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6109
6070
|
// Recurse
|
|
6110
6071
|
if (comp.children)
|
|
6111
6072
|
extractNotesAndAttachments(comp.children);
|
|
6112
|
-
if (comp.cells
|
|
6113
|
-
comp.cells.forEach((
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
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
|
-
}
|
|
6073
|
+
if (comp.cells)
|
|
6074
|
+
comp.cells.forEach((row) => row.forEach((cell) => {
|
|
6075
|
+
if (cell.components)
|
|
6076
|
+
extractNotesAndAttachments(cell.components);
|
|
6077
|
+
}));
|
|
6129
6078
|
if (comp.entries)
|
|
6130
6079
|
comp.entries.forEach((entry) => {
|
|
6131
6080
|
if (entry.components)
|
|
@@ -6162,10 +6111,9 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6162
6111
|
validatedComponent.children = getValidatedComponents(validatedComponent.children);
|
|
6163
6112
|
}
|
|
6164
6113
|
if (validatedComponent.cells && Array.isArray(validatedComponent.cells)) {
|
|
6165
|
-
validatedComponent.cells = validatedComponent.cells.map((
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
return rowOrCell.map((cell) => {
|
|
6114
|
+
validatedComponent.cells = validatedComponent.cells.map((row) => {
|
|
6115
|
+
if (Array.isArray(row)) {
|
|
6116
|
+
return row.map((cell) => {
|
|
6169
6117
|
if (cell && cell.components && Array.isArray(cell.components)) {
|
|
6170
6118
|
return {
|
|
6171
6119
|
...cell,
|
|
@@ -6175,18 +6123,7 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6175
6123
|
return cell;
|
|
6176
6124
|
});
|
|
6177
6125
|
}
|
|
6178
|
-
|
|
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;
|
|
6126
|
+
return row;
|
|
6190
6127
|
});
|
|
6191
6128
|
}
|
|
6192
6129
|
if (validatedComponent.entries && Array.isArray(validatedComponent.entries)) {
|
|
@@ -6234,10 +6171,8 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6234
6171
|
// Initialize notes and attachments state
|
|
6235
6172
|
setComponentNotes(prev => ({ ...initialNotes, ...prev }));
|
|
6236
6173
|
setComponentAttachments(prev => ({ ...initialAttachments, ...prev }));
|
|
6237
|
-
// Evaluate initial conditional logic
|
|
6238
|
-
|
|
6239
|
-
// in the closure is still the old state at this point.
|
|
6240
|
-
evaluateConditionalLogic(initialValues, validatedFormComponents);
|
|
6174
|
+
// Evaluate initial conditional logic
|
|
6175
|
+
evaluateConditionalLogic();
|
|
6241
6176
|
}, [initialFormData, formComponents]);
|
|
6242
6177
|
// Synchronize component visibility whenever form values or components change
|
|
6243
6178
|
React.useEffect(() => {
|
|
@@ -6271,22 +6206,12 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6271
6206
|
}
|
|
6272
6207
|
// Handle nested components in table cells
|
|
6273
6208
|
if (component.cells && Array.isArray(component.cells)) {
|
|
6274
|
-
component.cells.forEach((
|
|
6275
|
-
|
|
6276
|
-
if (Array.isArray(rowOrCell)) {
|
|
6277
|
-
rowOrCell.forEach((cell) => {
|
|
6278
|
-
if (cell.components && Array.isArray(cell.components)) {
|
|
6279
|
-
evaluateComponentConditionalLogic(cell.components, visibility, currentFormValues, fullSchema);
|
|
6280
|
-
}
|
|
6281
|
-
});
|
|
6282
|
-
}
|
|
6283
|
-
// Handle 1D array (flat)
|
|
6284
|
-
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
6285
|
-
const cell = rowOrCell;
|
|
6209
|
+
component.cells.forEach((row) => {
|
|
6210
|
+
row.forEach((cell) => {
|
|
6286
6211
|
if (cell.components && Array.isArray(cell.components)) {
|
|
6287
6212
|
evaluateComponentConditionalLogic(cell.components, visibility, currentFormValues, fullSchema);
|
|
6288
6213
|
}
|
|
6289
|
-
}
|
|
6214
|
+
});
|
|
6290
6215
|
});
|
|
6291
6216
|
}
|
|
6292
6217
|
// Handle nested components in datagrid entries
|
|
@@ -6321,12 +6246,19 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6321
6246
|
}, [formComponents, formValues]);
|
|
6322
6247
|
// Check if a component should be visible based on conditional logic
|
|
6323
6248
|
const shouldShowComponent = React.useCallback((componentId) => {
|
|
6324
|
-
//
|
|
6325
|
-
|
|
6326
|
-
|
|
6249
|
+
// Recursive find to get the component to check its type and alternate ID
|
|
6250
|
+
// We need this because formComponents might only be top-level
|
|
6251
|
+
const component = conditionalLogicService.findComponent(formComponents, componentId);
|
|
6252
|
+
// Table and datagrid components are always visible at the root level (their contents handle logic)
|
|
6253
|
+
if (component && (component.name === 'table' || component.name === 'datagrid')) {
|
|
6254
|
+
return true;
|
|
6327
6255
|
}
|
|
6328
|
-
//
|
|
6329
|
-
|
|
6256
|
+
// Default to visible if not explicitly hidden
|
|
6257
|
+
// Check both id and _id for maximum resilience
|
|
6258
|
+
const isVisible = (componentVisibility[componentId] !== false) &&
|
|
6259
|
+
(!component?._id || componentVisibility[component._id] !== false) &&
|
|
6260
|
+
(!component?.id || componentVisibility[component.id] !== false);
|
|
6261
|
+
return isVisible;
|
|
6330
6262
|
}, [componentVisibility, formComponents]);
|
|
6331
6263
|
// Handle form value changes and re-evaluate conditional logic
|
|
6332
6264
|
const onFormValueChange = React.useCallback((change) => {
|
|
@@ -6463,6 +6395,8 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6463
6395
|
validateField(change.id);
|
|
6464
6396
|
}, 150);
|
|
6465
6397
|
}
|
|
6398
|
+
// Re-evaluate immediately to ensure responsive UI
|
|
6399
|
+
evaluateConditionalLogic(newFormValues, updatedComponents);
|
|
6466
6400
|
}, [formComponents, formValues, validationErrors, onFormDataChange, evaluateConditionalLogic]);
|
|
6467
6401
|
// Recursive function to find a component by ID in nested structures
|
|
6468
6402
|
const findComponentById = React.useCallback((components, fieldId) => {
|