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