df-ae-forms-package 1.0.82 → 1.0.83
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 +66 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +66 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -7592,8 +7592,44 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
|
|
|
7592
7592
|
};
|
|
7593
7593
|
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 }) => {
|
|
7594
7594
|
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
7595
|
-
//
|
|
7596
|
-
|
|
7595
|
+
// Initialize and update table cells when rows/columns change (matching main website)
|
|
7596
|
+
useEffect(() => {
|
|
7597
|
+
const currentRows = Number(properties.table?.rows || properties.basic?.rows || 3);
|
|
7598
|
+
const currentColumns = Number(properties.table?.columns || properties.basic?.columns || 3);
|
|
7599
|
+
const currentCells = properties.cells || [];
|
|
7600
|
+
// Check if we need to update the table structure
|
|
7601
|
+
const needsUpdate = currentCells.length === 0 ||
|
|
7602
|
+
currentCells.length !== currentRows ||
|
|
7603
|
+
(currentCells.length > 0 && Array.isArray(currentCells[0]) && currentCells[0].length !== currentColumns);
|
|
7604
|
+
if (needsUpdate) {
|
|
7605
|
+
const newCells = [];
|
|
7606
|
+
for (let row = 0; row < currentRows; row++) {
|
|
7607
|
+
const rowCells = [];
|
|
7608
|
+
for (let col = 0; col < currentColumns; col++) {
|
|
7609
|
+
const cellId = `cell-${row}-${col}`;
|
|
7610
|
+
// Try to preserve existing components if the cell exists
|
|
7611
|
+
let existingComponents = [];
|
|
7612
|
+
if (currentCells[row] && Array.isArray(currentCells[row]) && currentCells[row][col]) {
|
|
7613
|
+
existingComponents = (currentCells[row][col].components || []).map(ensureComponentHasId);
|
|
7614
|
+
}
|
|
7615
|
+
rowCells.push({
|
|
7616
|
+
id: cellId,
|
|
7617
|
+
row,
|
|
7618
|
+
column: col,
|
|
7619
|
+
components: existingComponents,
|
|
7620
|
+
styles: {}
|
|
7621
|
+
});
|
|
7622
|
+
}
|
|
7623
|
+
newCells.push(rowCells);
|
|
7624
|
+
}
|
|
7625
|
+
if (onValueChange) {
|
|
7626
|
+
onValueChange({
|
|
7627
|
+
id,
|
|
7628
|
+
value: { ...properties, cells: newCells }
|
|
7629
|
+
});
|
|
7630
|
+
}
|
|
7631
|
+
}
|
|
7632
|
+
}, [properties.table?.rows, properties.table?.columns, properties.basic?.rows, properties.basic?.columns, properties.cells, id, onValueChange]);
|
|
7597
7633
|
// Check if table has any components in any cells
|
|
7598
7634
|
const hasAnyComponents = properties.cells?.some((row) => {
|
|
7599
7635
|
if (Array.isArray(row)) {
|
|
@@ -7658,11 +7694,18 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7658
7694
|
const cellsWithIds = properties.cells && properties.cells.length > 0
|
|
7659
7695
|
? ensureTableCellComponentsHaveIds(properties.cells)
|
|
7660
7696
|
: [];
|
|
7661
|
-
// CRITICAL FIX: Update the parent component with the cells that have proper IDs
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7697
|
+
// CRITICAL FIX: Update the parent component with the cells that have proper IDs (matching main website)
|
|
7698
|
+
useEffect(() => {
|
|
7699
|
+
if (cellsWithIds.length > 0 && JSON.stringify(cellsWithIds) !== JSON.stringify(properties.cells)) {
|
|
7700
|
+
onValueChange?.({
|
|
7701
|
+
id: id,
|
|
7702
|
+
value: {
|
|
7703
|
+
...properties,
|
|
7704
|
+
cells: cellsWithIds
|
|
7705
|
+
}
|
|
7706
|
+
});
|
|
7707
|
+
}
|
|
7708
|
+
}, [cellsWithIds, properties.cells, id, onValueChange]);
|
|
7666
7709
|
// CRITICAL: Create a stable renderComponent that doesn't recreate on every render
|
|
7667
7710
|
// Match main app implementation - directly access formData from closure
|
|
7668
7711
|
const renderComponent = renderFormComponent || useCallback((field) => {
|
|
@@ -7770,22 +7813,22 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7770
7813
|
if (!hasAnyComponents && mode === 'preview') {
|
|
7771
7814
|
return null;
|
|
7772
7815
|
}
|
|
7773
|
-
return (jsxs("div", { className: `form-group df-form-table ${isSelected ? 'selected' : ''} ${mode === 'preview' ? 'preview-mode' : mode === 'test' ? 'test-mode' : ''} ${className}`, onClick: handleTableClick, style: tableStyle, children: [jsx("div", { className: "table-header", children: jsx("div", { className: "table-title", onClick: toggleCollapse, children: jsxs("div", { className: "title-content", children: [isCollapsed ? jsx(ChevronRight, { size: 16 }) : jsx(ChevronDown, { size: 16 }), jsx(Table, { size: 16 }), jsx("span", { className: "table-label", children: properties.basic?.label || 'Table' }), properties.validation?.required && (jsx("span", { className: "required-indicator", children: "*" }))] }) }) }), properties.basic?.description && !isCollapsed && (jsx("div", { className: "table-description", children: properties.basic.description })), !isCollapsed && (
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7816
|
+
return (jsxs("div", { className: `form-group df-form-table ${isSelected ? 'selected' : ''} ${mode === 'preview' ? 'preview-mode' : mode === 'test' ? 'test-mode' : ''} ${className}`, onClick: handleTableClick, style: tableStyle, children: [jsx("div", { className: "table-header", children: jsx("div", { className: "table-title", onClick: toggleCollapse, children: jsxs("div", { className: "title-content", children: [isCollapsed ? jsx(ChevronRight, { size: 16 }) : jsx(ChevronDown, { size: 16 }), jsx(Table, { size: 16 }), jsx("span", { className: "table-label", children: properties.basic?.label || 'Table' }), properties.validation?.required && (jsx("span", { className: "required-indicator", children: "*" }))] }) }) }), properties.basic?.description && !isCollapsed && (jsx("div", { className: "table-description", children: properties.basic.description })), !isCollapsed && (jsx("div", { className: "table-content", children: jsxs("table", { style: tableElementStyle, children: [properties.table?.displayAsTable && (mode === 'edit' || properties.table?.showColumns) && (jsx("thead", { children: jsx("tr", { className: "table-header-row", children: Array.from({ length: properties.table?.columns || properties.basic?.columns || 3 }, (_, colIndex) => {
|
|
7817
|
+
const columnNames = properties.table?.columnNames?.split(',').map((name) => name.trim()) || [];
|
|
7818
|
+
const columnName = columnNames[colIndex] || `Column ${colIndex + 1}`;
|
|
7819
|
+
return (jsx("th", { className: "table-header-cell", style: {
|
|
7820
|
+
backgroundColor: 'var(--df-color-fb-container)',
|
|
7821
|
+
color: properties.styles.headerTextColor || 'var(--df-color-text-dark)',
|
|
7822
|
+
padding: '12px',
|
|
7823
|
+
border: '1px solid var(--df-color-fb-border)',
|
|
7824
|
+
fontWeight: '600',
|
|
7825
|
+
fontSize: '14px',
|
|
7826
|
+
textAlign: 'center'
|
|
7827
|
+
}, children: columnName }, `header-${colIndex}`));
|
|
7828
|
+
}) }) })), jsx("tbody", { children: cellsWithIds.map((row, rowIndex) => {
|
|
7829
|
+
const rowCells = Array.isArray(row) ? row : [row];
|
|
7830
|
+
return (jsx("tr", { className: "table-row", children: rowCells.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));
|
|
7831
|
+
}) })] }) }))] }));
|
|
7789
7832
|
};
|
|
7790
7833
|
|
|
7791
7834
|
var dfFormTable = /*#__PURE__*/Object.freeze({
|