df-ae-forms-package 1.0.71 → 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 +160 -58
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +160 -58
- 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,15 +6265,32 @@ 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)) {
|
|
6274
|
-
component.cells.forEach((
|
|
6275
|
-
|
|
6278
|
+
component.cells.forEach((rowOrCell) => {
|
|
6279
|
+
// Handle 2D array (standard)
|
|
6280
|
+
if (Array.isArray(rowOrCell)) {
|
|
6281
|
+
rowOrCell.forEach((cell) => {
|
|
6282
|
+
if (cell.components && Array.isArray(cell.components)) {
|
|
6283
|
+
evaluateComponentConditionalLogic(cell.components, visibility, currentFormValues, fullSchema);
|
|
6284
|
+
}
|
|
6285
|
+
});
|
|
6286
|
+
}
|
|
6287
|
+
// Handle 1D array (flat)
|
|
6288
|
+
else if (typeof rowOrCell === 'object' && rowOrCell !== null) {
|
|
6289
|
+
const cell = rowOrCell;
|
|
6276
6290
|
if (cell.components && Array.isArray(cell.components)) {
|
|
6277
6291
|
evaluateComponentConditionalLogic(cell.components, visibility, currentFormValues, fullSchema);
|
|
6278
6292
|
}
|
|
6279
|
-
}
|
|
6293
|
+
}
|
|
6280
6294
|
});
|
|
6281
6295
|
}
|
|
6282
6296
|
// Handle nested components in datagrid entries
|
|
@@ -6311,19 +6325,25 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6311
6325
|
}, [formComponents, formValues]);
|
|
6312
6326
|
// Check if a component should be visible based on conditional logic
|
|
6313
6327
|
const shouldShowComponent = React.useCallback((componentId) => {
|
|
6314
|
-
//
|
|
6315
|
-
|
|
6328
|
+
// Check the visibility map first for the exact ID
|
|
6329
|
+
if (componentVisibility.hasOwnProperty(componentId)) {
|
|
6330
|
+
return componentVisibility[componentId] === true;
|
|
6331
|
+
}
|
|
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)
|
|
6316
6334
|
const component = conditionalLogicService.findComponent(formComponents, componentId);
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
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
|
+
}
|
|
6320
6344
|
}
|
|
6321
|
-
//
|
|
6322
|
-
|
|
6323
|
-
const isVisible = (componentVisibility[componentId] !== false) &&
|
|
6324
|
-
(!component?._id || componentVisibility[component._id] !== false) &&
|
|
6325
|
-
(!component?.id || componentVisibility[component.id] !== false);
|
|
6326
|
-
return isVisible;
|
|
6345
|
+
// If not found in visibility map by any identifier, component should be visible by default
|
|
6346
|
+
return true;
|
|
6327
6347
|
}, [componentVisibility, formComponents]);
|
|
6328
6348
|
// Handle form value changes and re-evaluate conditional logic
|
|
6329
6349
|
const onFormValueChange = React.useCallback((change) => {
|
|
@@ -6400,13 +6420,28 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6400
6420
|
if (component.name === 'table' && component.cells) {
|
|
6401
6421
|
return {
|
|
6402
6422
|
...component,
|
|
6403
|
-
cells: component.cells.map((
|
|
6404
|
-
|
|
6405
|
-
if (
|
|
6406
|
-
|
|
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;
|
|
6407
6442
|
}
|
|
6408
|
-
return
|
|
6409
|
-
})
|
|
6443
|
+
return rowOrCell;
|
|
6444
|
+
})
|
|
6410
6445
|
};
|
|
6411
6446
|
}
|
|
6412
6447
|
if (component.name === 'datagrid' && component.entries) {
|
|
@@ -7633,8 +7668,18 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
|
|
|
7633
7668
|
};
|
|
7634
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 }) => {
|
|
7635
7670
|
const [isCollapsed, setIsCollapsed] = React.useState(false); // Always start expanded to show drop zones
|
|
7636
|
-
// Check if table has any components in any cells
|
|
7637
|
-
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;
|
|
7638
7683
|
// Initialize and update table cells when rows/columns change
|
|
7639
7684
|
// CRITICAL: Skip cell initialization updates to prevent flickering when user types
|
|
7640
7685
|
React.useEffect(() => {
|
|
@@ -7656,17 +7701,34 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7656
7701
|
};
|
|
7657
7702
|
const handleComponentDelete = React.useCallback((component, event) => {
|
|
7658
7703
|
event.stopPropagation();
|
|
7659
|
-
// Find and remove the component from the table cell
|
|
7660
|
-
const updatedCells = properties.cells.map(
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
return {
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
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
|
+
});
|
|
7667
7718
|
}
|
|
7668
|
-
|
|
7669
|
-
|
|
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
|
+
});
|
|
7670
7732
|
// Update the table with the modified cells
|
|
7671
7733
|
if (onValueChange) {
|
|
7672
7734
|
onValueChange({
|
|
@@ -7682,26 +7744,56 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7682
7744
|
const cellsWithIds = React.useMemo(() => {
|
|
7683
7745
|
if (!properties.cells)
|
|
7684
7746
|
return [];
|
|
7685
|
-
return properties.cells.map((
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
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
|
+
});
|
|
7705
7797
|
}, [properties.cells, id]); // Only recalculate if cells or table ID changes
|
|
7706
7798
|
// CRITICAL FIX: Update the parent component with the cells that have proper IDs
|
|
7707
7799
|
// Skip this in package to prevent flickering - cells are managed by parent
|
|
@@ -7830,7 +7922,17 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7830
7922
|
fontSize: '14px',
|
|
7831
7923
|
textAlign: 'center'
|
|
7832
7924
|
}, children: columnName }, `header-${colIndex}`));
|
|
7833
|
-
}) }) })), 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
|
+
}) })] })] }))] }));
|
|
7834
7936
|
};
|
|
7835
7937
|
|
|
7836
7938
|
var dfFormTable = /*#__PURE__*/Object.freeze({
|