df-ae-forms-package 1.0.70 → 1.0.72

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.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 row of comp.cells) {
183
- for (const cell of row) {
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 row of item.cells) {
227
- for (const cell of row) {
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
  }
@@ -6012,14 +6033,22 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6012
6033
  }
6013
6034
  // Handle nested components in table cells
6014
6035
  if (component.cells && Array.isArray(component.cells)) {
6015
- component.cells.forEach((row, _rowIndex) => {
6016
- if (Array.isArray(row)) {
6017
- row.forEach((cell, _cellIndex) => {
6036
+ component.cells.forEach((rowOrCell, _rowIndex) => {
6037
+ // Handle 2D array (standard)
6038
+ if (Array.isArray(rowOrCell)) {
6039
+ rowOrCell.forEach((cell, _cellIndex) => {
6018
6040
  if (cell && cell.components && Array.isArray(cell.components)) {
6019
6041
  initializeComponentValues(cell.components, values);
6020
6042
  }
6021
6043
  });
6022
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
+ }
6023
6052
  });
6024
6053
  }
6025
6054
  // Handle nested components in datagrid entries
@@ -6080,11 +6109,23 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6080
6109
  // Recurse
6081
6110
  if (comp.children)
6082
6111
  extractNotesAndAttachments(comp.children);
6083
- if (comp.cells)
6084
- comp.cells.forEach((row) => row.forEach((cell) => {
6085
- if (cell.components)
6086
- extractNotesAndAttachments(cell.components);
6087
- }));
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
+ }
6088
6129
  if (comp.entries)
6089
6130
  comp.entries.forEach((entry) => {
6090
6131
  if (entry.components)
@@ -6121,9 +6162,10 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6121
6162
  validatedComponent.children = getValidatedComponents(validatedComponent.children);
6122
6163
  }
6123
6164
  if (validatedComponent.cells && Array.isArray(validatedComponent.cells)) {
6124
- validatedComponent.cells = validatedComponent.cells.map((row) => {
6125
- if (Array.isArray(row)) {
6126
- return row.map((cell) => {
6165
+ validatedComponent.cells = validatedComponent.cells.map((rowOrCell) => {
6166
+ // Handle 2D array
6167
+ if (Array.isArray(rowOrCell)) {
6168
+ return rowOrCell.map((cell) => {
6127
6169
  if (cell && cell.components && Array.isArray(cell.components)) {
6128
6170
  return {
6129
6171
  ...cell,
@@ -6133,7 +6175,18 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6133
6175
  return cell;
6134
6176
  });
6135
6177
  }
6136
- return row;
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;
6137
6190
  });
6138
6191
  }
6139
6192
  if (validatedComponent.entries && Array.isArray(validatedComponent.entries)) {
@@ -6218,12 +6271,22 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6218
6271
  }
6219
6272
  // Handle nested components in table cells
6220
6273
  if (component.cells && Array.isArray(component.cells)) {
6221
- component.cells.forEach((row) => {
6222
- row.forEach((cell) => {
6274
+ component.cells.forEach((rowOrCell) => {
6275
+ // Handle 2D array (standard)
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;
6223
6286
  if (cell.components && Array.isArray(cell.components)) {
6224
6287
  evaluateComponentConditionalLogic(cell.components, visibility, currentFormValues, fullSchema);
6225
6288
  }
6226
- });
6289
+ }
6227
6290
  });
6228
6291
  }
6229
6292
  // Handle nested components in datagrid entries
@@ -6258,19 +6321,12 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6258
6321
  }, [formComponents, formValues]);
6259
6322
  // Check if a component should be visible based on conditional logic
6260
6323
  const shouldShowComponent = React.useCallback((componentId) => {
6261
- // Recursive find to get the component to check its type and alternate ID
6262
- // We need this because formComponents might only be top-level
6263
- const component = conditionalLogicService.findComponent(formComponents, componentId);
6264
- // Table and datagrid components are always visible at the root level (their contents handle logic)
6265
- if (component && (component.name === 'table' || component.name === 'datagrid')) {
6266
- return true;
6324
+ // Check the visibility map first
6325
+ if (componentVisibility.hasOwnProperty(componentId)) {
6326
+ return componentVisibility[componentId] === true;
6267
6327
  }
6268
- // Default to visible if not explicitly hidden
6269
- // Check both id and _id for maximum resilience
6270
- const isVisible = (componentVisibility[componentId] !== false) &&
6271
- (!component?._id || componentVisibility[component._id] !== false) &&
6272
- (!component?.id || componentVisibility[component.id] !== false);
6273
- return isVisible;
6328
+ // If not in visibility map, component should be visible by default
6329
+ return true;
6274
6330
  }, [componentVisibility, formComponents]);
6275
6331
  // Handle form value changes and re-evaluate conditional logic
6276
6332
  const onFormValueChange = React.useCallback((change) => {