df-ae-forms-package 1.0.72 → 1.0.73
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 +145 -46
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +145 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6247,11 +6247,8 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6247
6247
|
const evaluateComponentConditionalLogic = (components, visibility, currentFormValues, fullSchema) => {
|
|
6248
6248
|
components.forEach(component => {
|
|
6249
6249
|
if (component.id) {
|
|
6250
|
-
//
|
|
6251
|
-
if (component.
|
|
6252
|
-
visibility[component.id] = true;
|
|
6253
|
-
}
|
|
6254
|
-
else if (component.conditional) {
|
|
6250
|
+
// Handle conditional logic for all components including table and datagrid
|
|
6251
|
+
if (component.conditional) {
|
|
6255
6252
|
// Use the proper conditional logic service
|
|
6256
6253
|
const result = conditionalLogicService.evaluateConditionalLogic(component.conditional, fullSchema, currentFormValues);
|
|
6257
6254
|
visibility[component.id] = result.shouldShow;
|
|
@@ -6268,6 +6265,13 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6268
6265
|
if (component.basic?.label)
|
|
6269
6266
|
visibility[component.basic.label] = true;
|
|
6270
6267
|
}
|
|
6268
|
+
// Process nested components in table and datagrid regardless of parent visibility
|
|
6269
|
+
if (component.name === 'table' || component.name === 'datagrid') {
|
|
6270
|
+
// Still add the parent to visibility map (as visible if no conditional logic)
|
|
6271
|
+
if (!component.conditional) {
|
|
6272
|
+
visibility[component.id] = true;
|
|
6273
|
+
}
|
|
6274
|
+
}
|
|
6271
6275
|
}
|
|
6272
6276
|
// Handle nested components in table cells
|
|
6273
6277
|
if (component.cells && Array.isArray(component.cells)) {
|
|
@@ -6321,11 +6325,24 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6321
6325
|
}, [formComponents, formValues]);
|
|
6322
6326
|
// Check if a component should be visible based on conditional logic
|
|
6323
6327
|
const shouldShowComponent = React.useCallback((componentId) => {
|
|
6324
|
-
// Check the visibility map first
|
|
6328
|
+
// Check the visibility map first for the exact ID
|
|
6325
6329
|
if (componentVisibility.hasOwnProperty(componentId)) {
|
|
6326
6330
|
return componentVisibility[componentId] === true;
|
|
6327
6331
|
}
|
|
6328
|
-
// If not
|
|
6332
|
+
// If not found by exact ID, try to find the component in formComponents
|
|
6333
|
+
// and check if it exists in visibility map by other identifiers (_id, label)
|
|
6334
|
+
const component = conditionalLogicService.findComponent(formComponents, componentId);
|
|
6335
|
+
if (component) {
|
|
6336
|
+
// Check visibility by _id if available
|
|
6337
|
+
if (component._id && componentVisibility.hasOwnProperty(component._id)) {
|
|
6338
|
+
return componentVisibility[component._id] === true;
|
|
6339
|
+
}
|
|
6340
|
+
// Check visibility by label if available
|
|
6341
|
+
if (component.basic?.label && componentVisibility.hasOwnProperty(component.basic.label)) {
|
|
6342
|
+
return componentVisibility[component.basic.label] === true;
|
|
6343
|
+
}
|
|
6344
|
+
}
|
|
6345
|
+
// If not found in visibility map by any identifier, component should be visible by default
|
|
6329
6346
|
return true;
|
|
6330
6347
|
}, [componentVisibility, formComponents]);
|
|
6331
6348
|
// Handle form value changes and re-evaluate conditional logic
|
|
@@ -6403,13 +6420,28 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6403
6420
|
if (component.name === 'table' && component.cells) {
|
|
6404
6421
|
return {
|
|
6405
6422
|
...component,
|
|
6406
|
-
cells: component.cells.map((
|
|
6407
|
-
|
|
6408
|
-
if (
|
|
6409
|
-
|
|
6423
|
+
cells: component.cells.map((rowOrCell) => {
|
|
6424
|
+
// Handle 2D array (standard)
|
|
6425
|
+
if (Array.isArray(rowOrCell)) {
|
|
6426
|
+
return rowOrCell.map((cell) => {
|
|
6427
|
+
const updatedCell = { ...cell };
|
|
6428
|
+
if (updatedCell.components) {
|
|
6429
|
+
updatedCell.components = updateComponentValue(updatedCell.components);
|
|
6430
|
+
}
|
|
6431
|
+
return updatedCell;
|
|
6432
|
+
});
|
|
6433
|
+
}
|
|
6434
|
+
// Handle 1D array (flat)
|
|
6435
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
6436
|
+
const cell = rowOrCell;
|
|
6437
|
+
const updatedCell = { ...cell };
|
|
6438
|
+
if (updatedCell.components) {
|
|
6439
|
+
updatedCell.components = updateComponentValue(updatedCell.components);
|
|
6440
|
+
}
|
|
6441
|
+
return updatedCell;
|
|
6410
6442
|
}
|
|
6411
|
-
return
|
|
6412
|
-
})
|
|
6443
|
+
return rowOrCell;
|
|
6444
|
+
})
|
|
6413
6445
|
};
|
|
6414
6446
|
}
|
|
6415
6447
|
if (component.name === 'datagrid' && component.entries) {
|
|
@@ -7636,8 +7668,18 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
|
|
|
7636
7668
|
};
|
|
7637
7669
|
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 }) => {
|
|
7638
7670
|
const [isCollapsed, setIsCollapsed] = React.useState(false); // Always start expanded to show drop zones
|
|
7639
|
-
// Check if table has any components in any cells
|
|
7640
|
-
const hasAnyComponents = properties.cells?.some(
|
|
7671
|
+
// Check if table has any components in any cells - handle both 2D and 1D structures
|
|
7672
|
+
const hasAnyComponents = properties.cells?.some((rowOrCell) => {
|
|
7673
|
+
// Handle 2D array structure (each row is an array of cells)
|
|
7674
|
+
if (Array.isArray(rowOrCell)) {
|
|
7675
|
+
return rowOrCell.some((cell) => cell.components && cell.components.length > 0);
|
|
7676
|
+
}
|
|
7677
|
+
// Handle 1D array structure (each element is a cell)
|
|
7678
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
7679
|
+
return rowOrCell.components && rowOrCell.components.length > 0;
|
|
7680
|
+
}
|
|
7681
|
+
return false;
|
|
7682
|
+
}) || false;
|
|
7641
7683
|
// Initialize and update table cells when rows/columns change
|
|
7642
7684
|
// CRITICAL: Skip cell initialization updates to prevent flickering when user types
|
|
7643
7685
|
React.useEffect(() => {
|
|
@@ -7659,17 +7701,34 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7659
7701
|
};
|
|
7660
7702
|
const handleComponentDelete = React.useCallback((component, event) => {
|
|
7661
7703
|
event.stopPropagation();
|
|
7662
|
-
// Find and remove the component from the table cell
|
|
7663
|
-
const updatedCells = properties.cells.map(
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
return {
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7704
|
+
// Find and remove the component from the table cell - handle both 2D and 1D structures
|
|
7705
|
+
const updatedCells = properties.cells.map((rowOrCell) => {
|
|
7706
|
+
// Handle 2D array structure (each row is an array of cells)
|
|
7707
|
+
if (Array.isArray(rowOrCell)) {
|
|
7708
|
+
return rowOrCell.map((cell) => {
|
|
7709
|
+
if (cell.components && cell.components.some((comp) => comp.id === component.id)) {
|
|
7710
|
+
const filteredComponents = cell.components.filter((comp) => comp.id !== component.id);
|
|
7711
|
+
return {
|
|
7712
|
+
...cell,
|
|
7713
|
+
components: filteredComponents
|
|
7714
|
+
};
|
|
7715
|
+
}
|
|
7716
|
+
return cell;
|
|
7717
|
+
});
|
|
7670
7718
|
}
|
|
7671
|
-
|
|
7672
|
-
|
|
7719
|
+
// Handle 1D array structure (each element is a cell)
|
|
7720
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
7721
|
+
if (rowOrCell.components && rowOrCell.components.some((comp) => comp.id === component.id)) {
|
|
7722
|
+
const filteredComponents = rowOrCell.components.filter((comp) => comp.id !== component.id);
|
|
7723
|
+
return {
|
|
7724
|
+
...rowOrCell,
|
|
7725
|
+
components: filteredComponents
|
|
7726
|
+
};
|
|
7727
|
+
}
|
|
7728
|
+
return rowOrCell;
|
|
7729
|
+
}
|
|
7730
|
+
return rowOrCell;
|
|
7731
|
+
});
|
|
7673
7732
|
// Update the table with the modified cells
|
|
7674
7733
|
if (onValueChange) {
|
|
7675
7734
|
onValueChange({
|
|
@@ -7685,26 +7744,56 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7685
7744
|
const cellsWithIds = React.useMemo(() => {
|
|
7686
7745
|
if (!properties.cells)
|
|
7687
7746
|
return [];
|
|
7688
|
-
return properties.cells.map((
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7747
|
+
return properties.cells.map((rowOrCell, rowIndex) => {
|
|
7748
|
+
// Handle 2D array structure (each row is an array of cells)
|
|
7749
|
+
if (Array.isArray(rowOrCell)) {
|
|
7750
|
+
return rowOrCell.map((cell, cellIndex) => ({
|
|
7751
|
+
...cell,
|
|
7752
|
+
components: (cell.components && Array.isArray(cell.components))
|
|
7753
|
+
? cell.components.map((comp, compIndex) => {
|
|
7754
|
+
// CRITICAL: Only generate ID if it's missing - never regenerate existing IDs
|
|
7755
|
+
// This prevents component remounting and losing input state
|
|
7756
|
+
if (comp.id && typeof comp.id === 'string' && comp.id.trim() !== '') {
|
|
7757
|
+
// ID already exists - keep it as is
|
|
7758
|
+
return comp;
|
|
7759
|
+
}
|
|
7760
|
+
// Generate unique ID that includes table ID, row, cell, and component index
|
|
7761
|
+
// This ensures no conflicts with other components
|
|
7762
|
+
const uniqueId = `${comp.name || 'component'}-table-${id}-row-${rowIndex}-cell-${cellIndex}-comp-${compIndex}`;
|
|
7763
|
+
return {
|
|
7764
|
+
...comp,
|
|
7765
|
+
id: uniqueId
|
|
7766
|
+
};
|
|
7767
|
+
})
|
|
7768
|
+
: []
|
|
7769
|
+
}));
|
|
7770
|
+
}
|
|
7771
|
+
// Handle 1D array structure (each element is a cell)
|
|
7772
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
7773
|
+
const cell = rowOrCell;
|
|
7774
|
+
return {
|
|
7775
|
+
...cell,
|
|
7776
|
+
components: (cell.components && Array.isArray(cell.components))
|
|
7777
|
+
? cell.components.map((comp, compIndex) => {
|
|
7778
|
+
// CRITICAL: Only generate ID if it's missing - never regenerate existing IDs
|
|
7779
|
+
// This prevents component remounting and losing input state
|
|
7780
|
+
if (comp.id && typeof comp.id === 'string' && comp.id.trim() !== '') {
|
|
7781
|
+
// ID already exists - keep it as is
|
|
7782
|
+
return comp;
|
|
7783
|
+
}
|
|
7784
|
+
// Generate unique ID that includes table ID, row, cell, and component index
|
|
7785
|
+
// This ensures no conflicts with other components
|
|
7786
|
+
const uniqueId = `${comp.name || 'component'}-table-${id}-row-${rowIndex}-cell-0-comp-${compIndex}`;
|
|
7787
|
+
return {
|
|
7788
|
+
...comp,
|
|
7789
|
+
id: uniqueId
|
|
7790
|
+
};
|
|
7791
|
+
})
|
|
7792
|
+
: []
|
|
7793
|
+
};
|
|
7794
|
+
}
|
|
7795
|
+
return [];
|
|
7796
|
+
});
|
|
7708
7797
|
}, [properties.cells, id]); // Only recalculate if cells or table ID changes
|
|
7709
7798
|
// CRITICAL FIX: Update the parent component with the cells that have proper IDs
|
|
7710
7799
|
// Skip this in package to prevent flickering - cells are managed by parent
|
|
@@ -7833,7 +7922,17 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7833
7922
|
fontSize: '14px',
|
|
7834
7923
|
textAlign: 'center'
|
|
7835
7924
|
}, children: columnName }, `header-${colIndex}`));
|
|
7836
|
-
}) }) })), jsxRuntime.jsx("tbody", { children: cellsWithIds.map((
|
|
7925
|
+
}) }) })), jsxRuntime.jsx("tbody", { children: cellsWithIds.map((rowOrCell, rowIndex) => {
|
|
7926
|
+
// Handle 2D array structure (each row is an array of cells)
|
|
7927
|
+
if (Array.isArray(rowOrCell)) {
|
|
7928
|
+
return (jsxRuntime.jsx("tr", { className: "table-row", children: rowOrCell.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));
|
|
7929
|
+
}
|
|
7930
|
+
// Handle 1D array structure (each element is a cell)
|
|
7931
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
7932
|
+
return (jsxRuntime.jsx("tr", { className: "table-row", children: jsxRuntime.jsx(TableCellComponent, { cell: rowOrCell, 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 }, rowOrCell.id) }, rowIndex));
|
|
7933
|
+
}
|
|
7934
|
+
return null;
|
|
7935
|
+
}) })] })] }))] }));
|
|
7837
7936
|
};
|
|
7838
7937
|
|
|
7839
7938
|
var dfFormTable = /*#__PURE__*/Object.freeze({
|