df-ae-forms-package 1.0.78 → 1.0.80

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
@@ -5146,7 +5146,7 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
5146
5146
  whiteSpace: 'nowrap',
5147
5147
  overflow: 'hidden',
5148
5148
  textOverflow: 'ellipsis'
5149
- }, children: component.basic?.label || `Column ${index + 1}` }, `header-${component.id}`))) })), dataEntries.length > 0 ? (dataEntries.map((entry, entryIndex) => (jsxRuntime.jsxs("div", { className: "table-row", style: {
5149
+ }, children: component.basic?.label || `Column ${index + 1}` }, `header-${component.id || index}`))) })), dataEntries.length > 0 ? (dataEntries.map((entry, entryIndex) => (jsxRuntime.jsxs("div", { className: "table-row", style: {
5150
5150
  // Use flex column for column view, grid for row view
5151
5151
  display: columnView ? 'flex' : 'grid',
5152
5152
  flexDirection: columnView ? 'column' : 'row',
@@ -6148,19 +6148,25 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6148
6148
  validatedComponent.children = getValidatedComponents(validatedComponent.children);
6149
6149
  }
6150
6150
  if (validatedComponent.cells && Array.isArray(validatedComponent.cells)) {
6151
- validatedComponent.cells = validatedComponent.cells.map((row) => {
6152
- if (Array.isArray(row)) {
6153
- return row.map((cell) => {
6151
+ validatedComponent.cells = validatedComponent.cells.map((rowOrCell) => {
6152
+ if (Array.isArray(rowOrCell)) {
6153
+ // Standard 2D: rowOrCell is an array of cells
6154
+ return rowOrCell.map((cell) => {
6154
6155
  if (cell && cell.components && Array.isArray(cell.components)) {
6155
- return {
6156
- ...cell,
6157
- components: getValidatedComponents(cell.components)
6158
- };
6156
+ return { ...cell, components: getValidatedComponents(cell.components) };
6159
6157
  }
6160
6158
  return cell;
6161
6159
  });
6162
6160
  }
6163
- return row;
6161
+ else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
6162
+ // Flat 1D: rowOrCell IS the cell object
6163
+ const cell = rowOrCell;
6164
+ if (cell.components && Array.isArray(cell.components)) {
6165
+ return { ...cell, components: getValidatedComponents(cell.components) };
6166
+ }
6167
+ return cell;
6168
+ }
6169
+ return rowOrCell;
6164
6170
  });
6165
6171
  }
6166
6172
  if (validatedComponent.entries && Array.isArray(validatedComponent.entries)) {
@@ -6992,13 +6998,25 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6992
6998
  updatedComponent.children = updateComponentValues(updatedComponent.children);
6993
6999
  }
6994
7000
  if (updatedComponent.name === 'table' && updatedComponent.cells) {
6995
- updatedComponent.cells = updatedComponent.cells.map((row) => row.map((cell) => {
6996
- const updatedCell = { ...cell };
6997
- if (updatedCell.components) {
6998
- updatedCell.components = updateComponentValues(updatedCell.components);
7001
+ updatedComponent.cells = updatedComponent.cells.map((rowOrCell) => {
7002
+ if (Array.isArray(rowOrCell)) {
7003
+ return rowOrCell.map((cell) => {
7004
+ const updatedCell = { ...cell };
7005
+ if (updatedCell.components) {
7006
+ updatedCell.components = updateComponentValues(updatedCell.components);
7007
+ }
7008
+ return updatedCell;
7009
+ });
7010
+ }
7011
+ else {
7012
+ // 1D flat cell
7013
+ const updatedCell = { ...rowOrCell };
7014
+ if (updatedCell.components) {
7015
+ updatedCell.components = updateComponentValues(updatedCell.components);
7016
+ }
7017
+ return updatedCell;
6999
7018
  }
7000
- return updatedCell;
7001
- }));
7019
+ });
7002
7020
  }
7003
7021
  if (updatedComponent.name === 'datagrid' && updatedComponent.entries) {
7004
7022
  updatedComponent.entries = updatedComponent.entries.map((entry) => {
@@ -7179,24 +7197,35 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
7179
7197
  // Handle notes change for table cell components
7180
7198
  const updatedComponents = formComponents.map(comp => {
7181
7199
  if (comp.id === component.id && comp.cells) {
7182
- const updatedCells = comp.cells.map((row) => row.map((cell) => {
7183
- if (cell.components) {
7184
- const updatedCellComponents = cell.components.map((cellComp) => {
7185
- if (cellComp.id === componentId) {
7186
- return {
7187
- ...cellComp,
7188
- basic: {
7189
- ...cellComp.basic,
7190
- notes
7200
+ const updatedCells = comp.cells.map((rowOrCell) => {
7201
+ if (Array.isArray(rowOrCell)) {
7202
+ return rowOrCell.map((cell) => {
7203
+ if (cell.components) {
7204
+ const updatedCellComponents = cell.components.map((cellComp) => {
7205
+ if (cellComp.id === componentId) {
7206
+ return { ...cellComp, basic: { ...cellComp.basic, notes } };
7191
7207
  }
7192
- };
7208
+ return cellComp;
7209
+ });
7210
+ return { ...cell, components: updatedCellComponents };
7193
7211
  }
7194
- return cellComp;
7212
+ return cell;
7195
7213
  });
7196
- return { ...cell, components: updatedCellComponents };
7197
7214
  }
7198
- return cell;
7199
- }));
7215
+ else {
7216
+ const cell = rowOrCell;
7217
+ if (cell.components) {
7218
+ const updatedCellComponents = cell.components.map((cellComp) => {
7219
+ if (cellComp.id === componentId) {
7220
+ return { ...cellComp, basic: { ...cellComp.basic, notes } };
7221
+ }
7222
+ return cellComp;
7223
+ });
7224
+ return { ...cell, components: updatedCellComponents };
7225
+ }
7226
+ return cell;
7227
+ }
7228
+ });
7200
7229
  return { ...comp, cells: updatedCells };
7201
7230
  }
7202
7231
  return comp;
@@ -7206,24 +7235,35 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
7206
7235
  // Handle attachment change for table cell components
7207
7236
  const updatedComponents = formComponents.map(comp => {
7208
7237
  if (comp.id === component.id && comp.cells) {
7209
- const updatedCells = comp.cells.map((row) => row.map((cell) => {
7210
- if (cell.components) {
7211
- const updatedCellComponents = cell.components.map((cellComp) => {
7212
- if (cellComp.id === componentId) {
7213
- return {
7214
- ...cellComp,
7215
- basic: {
7216
- ...cellComp.basic,
7217
- attachments: attachments || []
7238
+ const updatedCells = comp.cells.map((rowOrCell) => {
7239
+ if (Array.isArray(rowOrCell)) {
7240
+ return rowOrCell.map((cell) => {
7241
+ if (cell.components) {
7242
+ const updatedCellComponents = cell.components.map((cellComp) => {
7243
+ if (cellComp.id === componentId) {
7244
+ return { ...cellComp, basic: { ...cellComp.basic, attachments: attachments || [] } };
7218
7245
  }
7219
- };
7246
+ return cellComp;
7247
+ });
7248
+ return { ...cell, components: updatedCellComponents };
7220
7249
  }
7221
- return cellComp;
7250
+ return cell;
7222
7251
  });
7223
- return { ...cell, components: updatedCellComponents };
7224
7252
  }
7225
- return cell;
7226
- }));
7253
+ else {
7254
+ const cell = rowOrCell;
7255
+ if (cell.components) {
7256
+ const updatedCellComponents = cell.components.map((cellComp) => {
7257
+ if (cellComp.id === componentId) {
7258
+ return { ...cellComp, basic: { ...cellComp.basic, attachments: attachments || [] } };
7259
+ }
7260
+ return cellComp;
7261
+ });
7262
+ return { ...cell, components: updatedCellComponents };
7263
+ }
7264
+ return cell;
7265
+ }
7266
+ });
7227
7267
  return { ...comp, cells: updatedCells };
7228
7268
  }
7229
7269
  return comp;
@@ -7623,15 +7663,22 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
7623
7663
  const raw = properties.cells;
7624
7664
  if (!raw || !Array.isArray(raw) || raw.length === 0)
7625
7665
  return [];
7666
+ // DEBUG: Log cell structure to understand API format
7667
+ console.log('[DfFormTable] raw cells (first item):', JSON.stringify(raw[0], null, 2));
7668
+ console.log('[DfFormTable] is first item array?', Array.isArray(raw[0]));
7669
+ console.log('[DfFormTable] total cells:', raw.length);
7626
7670
  // Check if it's already a 2D array (first element is an array)
7627
7671
  if (Array.isArray(raw[0])) {
7672
+ console.log('[DfFormTable] Using 2D array format');
7628
7673
  return raw;
7629
7674
  }
7630
7675
  // It's a flat 1D array — reconstruct 2D using each cell's row/column
7676
+ console.log('[DfFormTable] Using 1D flat format, reconstructing 2D grid');
7631
7677
  const grid = [];
7632
7678
  raw.forEach((cell) => {
7633
7679
  const r = typeof cell.row === 'number' ? cell.row : 0;
7634
7680
  const c = typeof cell.column === 'number' ? cell.column : 0;
7681
+ console.log(`[DfFormTable] Cell at row=${r} col=${c}, components count:`, cell.components?.length ?? 0);
7635
7682
  if (!grid[r])
7636
7683
  grid[r] = [];
7637
7684
  grid[r][c] = cell;
@@ -7836,7 +7883,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
7836
7883
  fontSize: '14px',
7837
7884
  textAlign: 'center'
7838
7885
  }, children: columnName }, `header-${colIndex}`));
7839
- }) }) })), jsxRuntime.jsx("tbody", { children: cellsWithIds.map((row, rowIndex) => (jsxRuntime.jsx("tr", { className: "table-row", children: row.map((cell) => (jsxRuntime.jsx(TableCellComponent, { cell: cell, mode: mode, onComponentSelect: onComponentSelect || (() => { }), onComponentDelete: handleComponentDelete, onComponentEdit: onComponentEdit, selectedComponent: selectedComponent || null, renderFormComponent: renderComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, tableId: id, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue }, cell.id))) }, rowIndex))) })] })] }))] }));
7886
+ }) }) })), jsxRuntime.jsx("tbody", { children: cellsWithIds.filter(row => Array.isArray(row) && row.length > 0).map((row, rowIndex) => (jsxRuntime.jsx("tr", { className: "table-row", children: row.filter(cell => cell != null).map((cell) => (jsxRuntime.jsx(TableCellComponent, { cell: cell, mode: mode, onComponentSelect: onComponentSelect || (() => { }), onComponentDelete: handleComponentDelete, onComponentEdit: onComponentEdit, selectedComponent: selectedComponent || null, renderFormComponent: renderComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, tableId: id, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue }, cell.id))) }, rowIndex))) })] })] }))] }));
7840
7887
  };
7841
7888
 
7842
7889
  var dfFormTable = /*#__PURE__*/Object.freeze({