df-ae-forms-package 1.0.76 → 1.0.78
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 +54 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +54 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -6019,14 +6019,22 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6019
6019
|
}
|
|
6020
6020
|
// Handle nested components in table cells
|
|
6021
6021
|
if (component.cells && Array.isArray(component.cells)) {
|
|
6022
|
-
component.cells.forEach((
|
|
6023
|
-
|
|
6024
|
-
|
|
6022
|
+
component.cells.forEach((rowOrCell, _rowIndex) => {
|
|
6023
|
+
// Handle 2D array (standard)
|
|
6024
|
+
if (Array.isArray(rowOrCell)) {
|
|
6025
|
+
rowOrCell.forEach((cell, _cellIndex) => {
|
|
6025
6026
|
if (cell && cell.components && Array.isArray(cell.components)) {
|
|
6026
6027
|
initializeComponentValues(cell.components, values);
|
|
6027
6028
|
}
|
|
6028
6029
|
});
|
|
6029
6030
|
}
|
|
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
|
+
}
|
|
6030
6038
|
});
|
|
6031
6039
|
}
|
|
6032
6040
|
// Handle nested components in datagrid entries
|
|
@@ -6233,12 +6241,22 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6233
6241
|
}
|
|
6234
6242
|
// Handle nested components in table cells
|
|
6235
6243
|
if (component.cells && Array.isArray(component.cells)) {
|
|
6236
|
-
component.cells.forEach((
|
|
6237
|
-
|
|
6244
|
+
component.cells.forEach((rowOrCell) => {
|
|
6245
|
+
// Handle 2D array (standard)
|
|
6246
|
+
if (Array.isArray(rowOrCell)) {
|
|
6247
|
+
rowOrCell.forEach((cell) => {
|
|
6248
|
+
if (cell.components && Array.isArray(cell.components)) {
|
|
6249
|
+
evaluateComponentConditionalLogic(cell.components, visibility, currentFormValues, fullSchema);
|
|
6250
|
+
}
|
|
6251
|
+
});
|
|
6252
|
+
}
|
|
6253
|
+
// Handle 1D array (flat) structure
|
|
6254
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
6255
|
+
const cell = rowOrCell;
|
|
6238
6256
|
if (cell.components && Array.isArray(cell.components)) {
|
|
6239
6257
|
evaluateComponentConditionalLogic(cell.components, visibility, currentFormValues, fullSchema);
|
|
6240
6258
|
}
|
|
6241
|
-
}
|
|
6259
|
+
}
|
|
6242
6260
|
});
|
|
6243
6261
|
}
|
|
6244
6262
|
// Handle nested components in datagrid entries
|
|
@@ -7597,8 +7615,29 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
|
|
|
7597
7615
|
};
|
|
7598
7616
|
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 }) => {
|
|
7599
7617
|
const [isCollapsed, setIsCollapsed] = useState(false); // Always start expanded to show drop zones
|
|
7618
|
+
// Normalize cells: API may return a flat 1D array of cells (each with .row/.column)
|
|
7619
|
+
// or a proper 2D array of rows. Always convert to 2D for consistent rendering.
|
|
7620
|
+
const normalizedCells = useMemo(() => {
|
|
7621
|
+
const raw = properties.cells;
|
|
7622
|
+
if (!raw || !Array.isArray(raw) || raw.length === 0)
|
|
7623
|
+
return [];
|
|
7624
|
+
// Check if it's already a 2D array (first element is an array)
|
|
7625
|
+
if (Array.isArray(raw[0])) {
|
|
7626
|
+
return raw;
|
|
7627
|
+
}
|
|
7628
|
+
// It's a flat 1D array — reconstruct 2D using each cell's row/column
|
|
7629
|
+
const grid = [];
|
|
7630
|
+
raw.forEach((cell) => {
|
|
7631
|
+
const r = typeof cell.row === 'number' ? cell.row : 0;
|
|
7632
|
+
const c = typeof cell.column === 'number' ? cell.column : 0;
|
|
7633
|
+
if (!grid[r])
|
|
7634
|
+
grid[r] = [];
|
|
7635
|
+
grid[r][c] = cell;
|
|
7636
|
+
});
|
|
7637
|
+
return grid;
|
|
7638
|
+
}, [properties.cells]);
|
|
7600
7639
|
// Check if table has any components in any cells
|
|
7601
|
-
const hasAnyComponents =
|
|
7640
|
+
const hasAnyComponents = normalizedCells.some(row => Array.isArray(row) && row.some(cell => cell && cell.components && cell.components.length > 0)) || false;
|
|
7602
7641
|
// Initialize and update table cells when rows/columns change
|
|
7603
7642
|
// CRITICAL: Skip cell initialization updates to prevent flickering when user types
|
|
7604
7643
|
useEffect(() => {
|
|
@@ -7621,9 +7660,9 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7621
7660
|
const handleComponentDelete = useCallback((component, event) => {
|
|
7622
7661
|
event.stopPropagation();
|
|
7623
7662
|
// Find and remove the component from the table cell
|
|
7624
|
-
const updatedCells =
|
|
7625
|
-
if (cell.components && cell.components.some(comp => comp.id === component.id)) {
|
|
7626
|
-
const filteredComponents = cell.components.filter(comp => comp.id !== component.id);
|
|
7663
|
+
const updatedCells = normalizedCells.map(row => (Array.isArray(row) ? row : []).map(cell => {
|
|
7664
|
+
if (cell && cell.components && cell.components.some((comp) => comp.id === component.id)) {
|
|
7665
|
+
const filteredComponents = cell.components.filter((comp) => comp.id !== component.id);
|
|
7627
7666
|
return {
|
|
7628
7667
|
...cell,
|
|
7629
7668
|
components: filteredComponents
|
|
@@ -7643,12 +7682,13 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7643
7682
|
}, [onComponentDelete, properties, onValueChange, id]);
|
|
7644
7683
|
// CRITICAL FIX: Ensure all table cell components have proper IDs with table and cell position
|
|
7645
7684
|
// Use useMemo to prevent ID regeneration on every render
|
|
7685
|
+
// Uses normalizedCells so it works whether API returns 1D or 2D cell arrays
|
|
7646
7686
|
const cellsWithIds = useMemo(() => {
|
|
7647
|
-
if (!
|
|
7687
|
+
if (!normalizedCells || normalizedCells.length === 0)
|
|
7648
7688
|
return [];
|
|
7649
|
-
return
|
|
7689
|
+
return normalizedCells.map((row, rowIndex) => (Array.isArray(row) ? row : []).map((cell, cellIndex) => ({
|
|
7650
7690
|
...cell,
|
|
7651
|
-
components: (cell.components && Array.isArray(cell.components))
|
|
7691
|
+
components: (cell && cell.components && Array.isArray(cell.components))
|
|
7652
7692
|
? cell.components.map((comp, compIndex) => {
|
|
7653
7693
|
// CRITICAL: Only generate ID if it's missing - never regenerate existing IDs
|
|
7654
7694
|
// This prevents component remounting and losing input state
|
|
@@ -7666,7 +7706,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7666
7706
|
})
|
|
7667
7707
|
: []
|
|
7668
7708
|
})));
|
|
7669
|
-
}, [
|
|
7709
|
+
}, [normalizedCells, id]); // Only recalculate if cells or table ID changes
|
|
7670
7710
|
// CRITICAL FIX: Update the parent component with the cells that have proper IDs
|
|
7671
7711
|
// Skip this in package to prevent flickering - cells are managed by parent
|
|
7672
7712
|
// useEffect(() => {
|