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