df-ae-forms-package 1.0.79 → 1.0.81
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.d.ts +1 -0
- package/dist/index.esm.js +61 -175
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +61 -175
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -785,6 +785,7 @@ interface DfFormTableProps {
|
|
|
785
785
|
};
|
|
786
786
|
onCreateIssue?: (issueData: any, attachments: File[]) => Promise<any>;
|
|
787
787
|
onUpdateIssue?: (issueId: string, updateData: any) => Promise<void>;
|
|
788
|
+
shouldShowComponent?: (id: string) => boolean;
|
|
788
789
|
}
|
|
789
790
|
declare const DfFormTable: React.FC<DfFormTableProps>;
|
|
790
791
|
|
package/dist/index.esm.js
CHANGED
|
@@ -6017,24 +6017,16 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6017
6017
|
}
|
|
6018
6018
|
}
|
|
6019
6019
|
}
|
|
6020
|
-
// Handle nested components in table cells
|
|
6020
|
+
// Handle nested components in table cells (2D array: row → cell → components)
|
|
6021
6021
|
if (component.cells && Array.isArray(component.cells)) {
|
|
6022
|
-
component.cells.forEach((
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
rowOrCell.forEach((cell, _cellIndex) => {
|
|
6022
|
+
component.cells.forEach((row) => {
|
|
6023
|
+
if (Array.isArray(row)) {
|
|
6024
|
+
row.forEach((cell) => {
|
|
6026
6025
|
if (cell && cell.components && Array.isArray(cell.components)) {
|
|
6027
6026
|
initializeComponentValues(cell.components, values);
|
|
6028
6027
|
}
|
|
6029
6028
|
});
|
|
6030
6029
|
}
|
|
6031
|
-
// Handle 1D array (flat) structure
|
|
6032
|
-
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
6033
|
-
const cell = rowOrCell;
|
|
6034
|
-
if (cell && cell.components && Array.isArray(cell.components)) {
|
|
6035
|
-
initializeComponentValues(cell.components, values);
|
|
6036
|
-
}
|
|
6037
|
-
}
|
|
6038
6030
|
});
|
|
6039
6031
|
}
|
|
6040
6032
|
// Handle nested components in datagrid entries
|
|
@@ -6146,20 +6138,10 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6146
6138
|
validatedComponent.children = getValidatedComponents(validatedComponent.children);
|
|
6147
6139
|
}
|
|
6148
6140
|
if (validatedComponent.cells && Array.isArray(validatedComponent.cells)) {
|
|
6149
|
-
validatedComponent.cells = validatedComponent.cells.map((row) => {
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
return {
|
|
6154
|
-
...cell,
|
|
6155
|
-
components: getValidatedComponents(cell.components)
|
|
6156
|
-
};
|
|
6157
|
-
}
|
|
6158
|
-
return cell;
|
|
6159
|
-
});
|
|
6160
|
-
}
|
|
6161
|
-
return row;
|
|
6162
|
-
});
|
|
6141
|
+
validatedComponent.cells = validatedComponent.cells.map((row) => row.map((cell) => ({
|
|
6142
|
+
...cell,
|
|
6143
|
+
components: cell.components ? getValidatedComponents(cell.components) : []
|
|
6144
|
+
})));
|
|
6163
6145
|
}
|
|
6164
6146
|
if (validatedComponent.entries && Array.isArray(validatedComponent.entries)) {
|
|
6165
6147
|
validatedComponent.entries = validatedComponent.entries.map((entry) => {
|
|
@@ -6239,24 +6221,16 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6239
6221
|
visibility[component.basic.label] = true;
|
|
6240
6222
|
}
|
|
6241
6223
|
}
|
|
6242
|
-
// Handle nested components in table cells
|
|
6224
|
+
// Handle nested components in table cells (2D: row → cell → components)
|
|
6243
6225
|
if (component.cells && Array.isArray(component.cells)) {
|
|
6244
|
-
component.cells.forEach((
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
rowOrCell.forEach((cell) => {
|
|
6226
|
+
component.cells.forEach((row) => {
|
|
6227
|
+
if (Array.isArray(row)) {
|
|
6228
|
+
row.forEach((cell) => {
|
|
6248
6229
|
if (cell.components && Array.isArray(cell.components)) {
|
|
6249
6230
|
evaluateComponentConditionalLogic(cell.components, visibility, currentFormValues, fullSchema);
|
|
6250
6231
|
}
|
|
6251
6232
|
});
|
|
6252
6233
|
}
|
|
6253
|
-
// Handle 1D array (flat) structure
|
|
6254
|
-
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
6255
|
-
const cell = rowOrCell;
|
|
6256
|
-
if (cell.components && Array.isArray(cell.components)) {
|
|
6257
|
-
evaluateComponentConditionalLogic(cell.components, visibility, currentFormValues, fullSchema);
|
|
6258
|
-
}
|
|
6259
|
-
}
|
|
6260
6234
|
});
|
|
6261
6235
|
}
|
|
6262
6236
|
// Handle nested components in datagrid entries
|
|
@@ -7186,86 +7160,46 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
7186
7160
|
} }));
|
|
7187
7161
|
case 'table':
|
|
7188
7162
|
return (jsx(React.Suspense, { fallback: jsx("div", { children: "Loading table..." }), children: jsx(DfFormTable$1, { ...commonProps, properties: component, formData: formValues, formTemplateId: formTemplateId, mode: commonProps.mode, validationErrors: validationErrors, touchedFields: touchedFields, formSubmitted: formSubmitted, onThresholdActionCompletion: handleThresholdActionCompletion, onThresholdIssueRaised: handleThresholdIssueRaised, workOrderNumber: workOrderNumber, assetNumber: assetNumber, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, onNotesChange: (componentId, notes) => {
|
|
7189
|
-
// Handle notes change for table cell components
|
|
7190
7163
|
const updatedComponents = formComponents.map(comp => {
|
|
7191
7164
|
if (comp.id === component.id && comp.cells) {
|
|
7192
|
-
const updatedCells = comp.cells.map((
|
|
7193
|
-
if (
|
|
7194
|
-
return
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
return cellComp;
|
|
7201
|
-
});
|
|
7202
|
-
return { ...cell, components: updatedCellComponents };
|
|
7203
|
-
}
|
|
7204
|
-
return cell;
|
|
7205
|
-
});
|
|
7206
|
-
}
|
|
7207
|
-
else {
|
|
7208
|
-
const cell = rowOrCell;
|
|
7209
|
-
if (cell.components) {
|
|
7210
|
-
const updatedCellComponents = cell.components.map((cellComp) => {
|
|
7211
|
-
if (cellComp.id === componentId) {
|
|
7212
|
-
return { ...cellComp, basic: { ...cellComp.basic, notes } };
|
|
7213
|
-
}
|
|
7214
|
-
return cellComp;
|
|
7215
|
-
});
|
|
7216
|
-
return { ...cell, components: updatedCellComponents };
|
|
7217
|
-
}
|
|
7218
|
-
return cell;
|
|
7165
|
+
const updatedCells = comp.cells.map((row) => row.map((cell) => {
|
|
7166
|
+
if (cell.components) {
|
|
7167
|
+
return {
|
|
7168
|
+
...cell,
|
|
7169
|
+
components: cell.components.map((cellComp) => cellComp.id === componentId
|
|
7170
|
+
? { ...cellComp, basic: { ...cellComp.basic, notes } }
|
|
7171
|
+
: cellComp)
|
|
7172
|
+
};
|
|
7219
7173
|
}
|
|
7220
|
-
|
|
7174
|
+
return cell;
|
|
7175
|
+
}));
|
|
7221
7176
|
return { ...comp, cells: updatedCells };
|
|
7222
7177
|
}
|
|
7223
7178
|
return comp;
|
|
7224
7179
|
});
|
|
7225
7180
|
onFormDataChange?.(updatedComponents);
|
|
7226
7181
|
}, onAttachmentChange: (componentId, attachments) => {
|
|
7227
|
-
// Handle attachment change for table cell components
|
|
7228
7182
|
const updatedComponents = formComponents.map(comp => {
|
|
7229
7183
|
if (comp.id === component.id && comp.cells) {
|
|
7230
|
-
const updatedCells = comp.cells.map((
|
|
7231
|
-
if (
|
|
7232
|
-
return
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
return cellComp;
|
|
7239
|
-
});
|
|
7240
|
-
return { ...cell, components: updatedCellComponents };
|
|
7241
|
-
}
|
|
7242
|
-
return cell;
|
|
7243
|
-
});
|
|
7244
|
-
}
|
|
7245
|
-
else {
|
|
7246
|
-
const cell = rowOrCell;
|
|
7247
|
-
if (cell.components) {
|
|
7248
|
-
const updatedCellComponents = cell.components.map((cellComp) => {
|
|
7249
|
-
if (cellComp.id === componentId) {
|
|
7250
|
-
return { ...cellComp, basic: { ...cellComp.basic, attachments: attachments || [] } };
|
|
7251
|
-
}
|
|
7252
|
-
return cellComp;
|
|
7253
|
-
});
|
|
7254
|
-
return { ...cell, components: updatedCellComponents };
|
|
7255
|
-
}
|
|
7256
|
-
return cell;
|
|
7184
|
+
const updatedCells = comp.cells.map((row) => row.map((cell) => {
|
|
7185
|
+
if (cell.components) {
|
|
7186
|
+
return {
|
|
7187
|
+
...cell,
|
|
7188
|
+
components: cell.components.map((cellComp) => cellComp.id === componentId
|
|
7189
|
+
? { ...cellComp, basic: { ...cellComp.basic, attachments: attachments || [] } }
|
|
7190
|
+
: cellComp)
|
|
7191
|
+
};
|
|
7257
7192
|
}
|
|
7258
|
-
|
|
7193
|
+
return cell;
|
|
7194
|
+
}));
|
|
7259
7195
|
return { ...comp, cells: updatedCells };
|
|
7260
7196
|
}
|
|
7261
7197
|
return comp;
|
|
7262
7198
|
});
|
|
7263
7199
|
onFormDataChange?.(updatedComponents);
|
|
7264
7200
|
}, renderFormComponent: (field) => {
|
|
7265
|
-
// CRITICAL: Pass the field to renderFormComponent which has access to latest formValues
|
|
7266
|
-
// renderFormComponent uses formValues[field.id] internally, so it will get the correct value
|
|
7267
7201
|
return renderFormComponent(field);
|
|
7268
|
-
} }) }));
|
|
7202
|
+
}, shouldShowComponent: shouldShowComponent }) }));
|
|
7269
7203
|
case 'datagrid':
|
|
7270
7204
|
return (jsx(DfFormDataGrid, { ...commonProps, properties: component, formData: formValues, formTemplateId: formTemplateId, mode: commonProps.mode, onThresholdActionCompletion: handleThresholdActionCompletion, onThresholdIssueRaised: handleThresholdIssueRaised, onNotesChange: (componentId, notes) => {
|
|
7271
7205
|
handleComponentNotesChange(componentId, notes);
|
|
@@ -7575,12 +7509,13 @@ const ensureComponentHasId = (component) => {
|
|
|
7575
7509
|
}
|
|
7576
7510
|
return component;
|
|
7577
7511
|
};
|
|
7578
|
-
const SimpleTableComponent = ({ component, mode, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue }) => {
|
|
7512
|
+
const SimpleTableComponent = ({ component, mode, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, shouldShowComponent }) => {
|
|
7579
7513
|
const formValue = formData[component.id];
|
|
7514
|
+
const isVisible = shouldShowComponent ? shouldShowComponent(component.id) : true;
|
|
7580
7515
|
// Check if component has notes or attachments for submission view
|
|
7581
7516
|
const hasSubmissionData = mode === 'preview' && ((component.basic?.notes && component.basic.notes.trim().length > 0) ||
|
|
7582
7517
|
(component.basic?.attachments && Array.isArray(component.basic.attachments) && component.basic.attachments.length > 0));
|
|
7583
|
-
return (jsxs("div", { className:
|
|
7518
|
+
return (jsxs("div", { className: `simple-table-component ${(!isVisible && mode !== 'edit') ? 'conditionally-hidden' : ''}`, style: { display: (isVisible || mode === 'edit') ? undefined : 'none' }, children: [renderFormComponent(component), mode === 'test' && !['section', 'table', 'heading', 'file', 'instructions', 'signature', 'location', 'datagrid'].includes(component.name) && (jsx(ComponentActionFeatures, { component: component, mode: "test", formTemplateId: formTemplateId, formValue: formValue, formData: formData, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange ? (notes) => onNotesChange(component.id, notes) : undefined, onAttachmentChange: onAttachmentChange ? (attachments) => onAttachmentChange(component.id, attachments) : undefined, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue })), hasSubmissionData && (jsx(ComponentSubmissionActions, { component: component }))] }));
|
|
7584
7519
|
};
|
|
7585
7520
|
const DraggableTableComponent = ({ component, selectedComponent, mode, onComponentSelect, onComponentDelete, onComponentEdit, renderFormComponent, isOverlay = false, }) => {
|
|
7586
7521
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging, isSorting, } = useSortable({
|
|
@@ -7601,7 +7536,7 @@ const DraggableTableComponent = ({ component, selectedComponent, mode, onCompone
|
|
|
7601
7536
|
onComponentDelete(component, e);
|
|
7602
7537
|
}, type: "button", title: "Delete Component", children: jsx(Trash2, { size: 12 }) })] }))] }));
|
|
7603
7538
|
};
|
|
7604
|
-
const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, tableId, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue }) => {
|
|
7539
|
+
const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, tableId, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, shouldShowComponent }) => {
|
|
7605
7540
|
const dropZoneId = `table-cell-${tableId}-${cell.row}-${cell.column}`;
|
|
7606
7541
|
const { setNodeRef, isOver } = useDroppable({
|
|
7607
7542
|
id: dropZoneId,
|
|
@@ -7636,7 +7571,7 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
|
|
|
7636
7571
|
cell.components.map((component) => {
|
|
7637
7572
|
// Only ensure ID if it's truly missing - don't regenerate existing IDs
|
|
7638
7573
|
const componentWithId = component.id ? component : ensureComponentHasId(component);
|
|
7639
|
-
return (jsx(SimpleTableComponent, { component: componentWithId, mode: mode, renderFormComponent: renderFormComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue }, componentWithId.id));
|
|
7574
|
+
return (jsx(SimpleTableComponent, { component: componentWithId, mode: mode, renderFormComponent: renderFormComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, shouldShowComponent: shouldShowComponent }, componentWithId.id));
|
|
7640
7575
|
}))) : (
|
|
7641
7576
|
// Only show drop zone content in edit mode
|
|
7642
7577
|
mode === 'edit' ? (jsx("div", { className: "empty-cell-placeholder", children: jsxs("div", { className: "cell-info", children: [jsx("span", { className: "drop-zone-text", children: "Drag and Drop a form component" }), jsxs("span", { className: "cell-coordinates", children: ["Cell (", cell.row + 1, ", ", cell.column + 1, ")"] })] }) })) : (
|
|
@@ -7647,37 +7582,13 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
|
|
|
7647
7582
|
visibility: 'hidden' // Hide content but maintain space
|
|
7648
7583
|
}, children: "\u00A0" }))) }) }));
|
|
7649
7584
|
};
|
|
7650
|
-
const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationErrors = {}, touchedFields = {}, formSubmitted = false, onValueChange, onSelect, isSelected = false, className = '', onTableSelect, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue }) => {
|
|
7651
|
-
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
7652
|
-
//
|
|
7653
|
-
//
|
|
7654
|
-
|
|
7655
|
-
const raw = properties.cells;
|
|
7656
|
-
if (!raw || !Array.isArray(raw) || raw.length === 0)
|
|
7657
|
-
return [];
|
|
7658
|
-
// Check if it's already a 2D array (first element is an array)
|
|
7659
|
-
if (Array.isArray(raw[0])) {
|
|
7660
|
-
return raw;
|
|
7661
|
-
}
|
|
7662
|
-
// It's a flat 1D array — reconstruct 2D using each cell's row/column
|
|
7663
|
-
const grid = [];
|
|
7664
|
-
raw.forEach((cell) => {
|
|
7665
|
-
const r = typeof cell.row === 'number' ? cell.row : 0;
|
|
7666
|
-
const c = typeof cell.column === 'number' ? cell.column : 0;
|
|
7667
|
-
if (!grid[r])
|
|
7668
|
-
grid[r] = [];
|
|
7669
|
-
grid[r][c] = cell;
|
|
7670
|
-
});
|
|
7671
|
-
return grid;
|
|
7672
|
-
}, [properties.cells]);
|
|
7585
|
+
const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationErrors = {}, touchedFields = {}, formSubmitted = false, onValueChange, onSelect, isSelected = false, className = '', onTableSelect, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, shouldShowComponent }) => {
|
|
7586
|
+
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
7587
|
+
// By the time cells arrive here, DfFormPreview.getValidatedComponents has already
|
|
7588
|
+
// normalized them from 1D flat (API format) to proper 2D arrays.
|
|
7589
|
+
// So we can use properties.cells directly, exactly like the website version.
|
|
7673
7590
|
// Check if table has any components in any cells
|
|
7674
|
-
const hasAnyComponents =
|
|
7675
|
-
// Initialize and update table cells when rows/columns change
|
|
7676
|
-
// CRITICAL: Skip cell initialization updates to prevent flickering when user types
|
|
7677
|
-
useEffect(() => {
|
|
7678
|
-
// Skip updates to prevent flickering - cells are already initialized
|
|
7679
|
-
return;
|
|
7680
|
-
}, [properties.table?.rows, properties.table?.columns, properties.basic?.rows, properties.basic?.columns, properties.cells, id, onValueChange]); // Watch for rows/columns changes
|
|
7591
|
+
const hasAnyComponents = properties.cells?.some((row) => Array.isArray(row) && row.some((cell) => cell && cell.components && cell.components.length > 0)) || false;
|
|
7681
7592
|
const handleTableClick = useCallback((event) => {
|
|
7682
7593
|
event.stopPropagation();
|
|
7683
7594
|
onSelect?.();
|
|
@@ -7693,54 +7604,29 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7693
7604
|
};
|
|
7694
7605
|
const handleComponentDelete = useCallback((component, event) => {
|
|
7695
7606
|
event.stopPropagation();
|
|
7696
|
-
|
|
7697
|
-
const updatedCells = normalizedCells.map(row => (Array.isArray(row) ? row : []).map(cell => {
|
|
7607
|
+
const updatedCells = properties.cells.map((row) => row.map((cell) => {
|
|
7698
7608
|
if (cell && cell.components && cell.components.some((comp) => comp.id === component.id)) {
|
|
7699
|
-
|
|
7700
|
-
return {
|
|
7701
|
-
...cell,
|
|
7702
|
-
components: filteredComponents
|
|
7703
|
-
};
|
|
7609
|
+
return { ...cell, components: cell.components.filter((comp) => comp.id !== component.id) };
|
|
7704
7610
|
}
|
|
7705
7611
|
return cell;
|
|
7706
7612
|
}));
|
|
7707
|
-
|
|
7708
|
-
if (onValueChange) {
|
|
7709
|
-
onValueChange({
|
|
7710
|
-
id,
|
|
7711
|
-
value: { ...properties, cells: updatedCells }
|
|
7712
|
-
});
|
|
7713
|
-
}
|
|
7714
|
-
// Don't call parent delete handler for table cell components
|
|
7715
|
-
// The parent delete handler is for deleting entire fields, not components within table cells
|
|
7613
|
+
onValueChange?.({ id, value: { ...properties, cells: updatedCells } });
|
|
7716
7614
|
}, [onComponentDelete, properties, onValueChange, id]);
|
|
7717
|
-
//
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
const cellsWithIds = useMemo(() => {
|
|
7721
|
-
if (!normalizedCells || normalizedCells.length === 0)
|
|
7722
|
-
return [];
|
|
7723
|
-
return normalizedCells.map((row, rowIndex) => (Array.isArray(row) ? row : []).map((cell, cellIndex) => ({
|
|
7615
|
+
// Ensure all table cell components have IDs (matching website ensureTableCellComponentsHaveIds)
|
|
7616
|
+
const ensureTableCellComponentsHaveIds = (cells) => {
|
|
7617
|
+
return cells.map((row) => (Array.isArray(row) ? row : []).map((cell) => ({
|
|
7724
7618
|
...cell,
|
|
7725
|
-
components: (cell
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
return comp;
|
|
7732
|
-
}
|
|
7733
|
-
// Generate unique ID that includes table ID, row, cell, and component index
|
|
7734
|
-
// This ensures no conflicts with other components
|
|
7735
|
-
const uniqueId = `${comp.name || 'component'}-table-${id}-row-${rowIndex}-cell-${cellIndex}-comp-${compIndex}`;
|
|
7736
|
-
return {
|
|
7737
|
-
...comp,
|
|
7738
|
-
id: uniqueId
|
|
7739
|
-
};
|
|
7740
|
-
})
|
|
7741
|
-
: []
|
|
7619
|
+
components: (cell?.components || []).map((comp) => {
|
|
7620
|
+
if (!comp.id || comp.id.trim() === '') {
|
|
7621
|
+
return { ...comp, id: `table-cell-${comp.name}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}` };
|
|
7622
|
+
}
|
|
7623
|
+
return comp;
|
|
7624
|
+
})
|
|
7742
7625
|
})));
|
|
7743
|
-
}
|
|
7626
|
+
};
|
|
7627
|
+
const cellsWithIds = properties.cells && properties.cells.length > 0
|
|
7628
|
+
? ensureTableCellComponentsHaveIds(properties.cells)
|
|
7629
|
+
: [];
|
|
7744
7630
|
// CRITICAL FIX: Update the parent component with the cells that have proper IDs
|
|
7745
7631
|
// Skip this in package to prevent flickering - cells are managed by parent
|
|
7746
7632
|
// useEffect(() => {
|
|
@@ -7868,7 +7754,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7868
7754
|
fontSize: '14px',
|
|
7869
7755
|
textAlign: 'center'
|
|
7870
7756
|
}, children: columnName }, `header-${colIndex}`));
|
|
7871
|
-
}) }) })), jsx("tbody", { children: cellsWithIds.filter(row => Array.isArray(row) && row.length > 0).map((row, rowIndex) => (jsx("tr", { className: "table-row", children: row.filter(cell => cell != null).map((cell) => (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))) })] })] }))] }));
|
|
7757
|
+
}) }) })), jsx("tbody", { children: cellsWithIds.filter(row => Array.isArray(row) && row.length > 0).map((row, rowIndex) => (jsx("tr", { className: "table-row", children: row.filter(cell => cell != null).map((cell) => (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, shouldShowComponent: shouldShowComponent }, cell.id))) }, rowIndex))) })] })] }))] }));
|
|
7872
7758
|
};
|
|
7873
7759
|
|
|
7874
7760
|
var dfFormTable = /*#__PURE__*/Object.freeze({
|