df-ae-forms-package 1.0.90 → 1.0.92
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 +70 -35
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +70 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5062,7 +5062,7 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
5062
5062
|
, {
|
|
5063
5063
|
// Cast to FormComponentType[] to satisfy TableView typing; gridComponents
|
|
5064
5064
|
// are always child form components of the datagrid.
|
|
5065
|
-
templateComponents: gridComponents, dataEntries: dataEntries, renderFormComponent: renderFormComponent || renderComponent, mode: mode, allowAddRemoveEntries: properties.datagrid?.allowAddRemoveEntries ?? true, addAnotherText: properties.datagrid?.addAnotherText ?? 'Add Entry', removeText: properties.datagrid?.removeText ?? 'Remove', maxEntries: properties.datagrid?.maxEntries ?? 10, minEntries: properties.datagrid?.minEntries ?? 1, displayAsGrid: properties.datagrid?.displayAsGrid ?? true, onAddEntry:
|
|
5065
|
+
templateComponents: gridComponents, dataEntries: dataEntries, renderFormComponent: renderFormComponent || renderComponent, mode: mode, allowAddRemoveEntries: properties.datagrid?.allowAddRemoveEntries ?? true, addAnotherText: properties.datagrid?.addAnotherText ?? 'Add Entry', removeText: properties.datagrid?.removeText ?? 'Remove', maxEntries: properties.datagrid?.maxEntries ?? 10, minEntries: properties.datagrid?.minEntries ?? 1, displayAsGrid: properties.datagrid?.displayAsGrid ?? true, onAddEntry: handleAddEntry, onRemoveEntry: handleRemoveEntry, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, columnView: properties.datagrid?.columnView, shouldShowComponent: shouldShowComponent })) }))] }));
|
|
5066
5066
|
};
|
|
5067
5067
|
|
|
5068
5068
|
const DraggableChild = ({ child, selectedChild, mode, onChildSelect, onChildDelete, renderFormComponent, isOverlay = false, isChildrenEditMode = false, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue }) => {
|
|
@@ -5303,6 +5303,18 @@ const DfFormSection = ({ id, properties, mode = 'edit', formData = {}, onValueCh
|
|
|
5303
5303
|
|
|
5304
5304
|
// Dynamic imports to avoid circular dependencies
|
|
5305
5305
|
const DfFormTable$1 = React.lazy(() => Promise.resolve().then(function () { return dfFormTable; }));
|
|
5306
|
+
// Normalize a table row from API format (object with numeric keys) into a proper array.
|
|
5307
|
+
// The API may return cells as [{"0": {cell}, "1": {cell}}, ...] instead of [[cell, cell], ...].
|
|
5308
|
+
const normalizeTableRow = (row) => {
|
|
5309
|
+
if (Array.isArray(row))
|
|
5310
|
+
return row;
|
|
5311
|
+
if (row && typeof row === 'object') {
|
|
5312
|
+
const keys = Object.keys(row).filter(k => !isNaN(Number(k))).sort((a, b) => Number(a) - Number(b));
|
|
5313
|
+
if (keys.length > 0)
|
|
5314
|
+
return keys.map(k => row[k]);
|
|
5315
|
+
}
|
|
5316
|
+
return [];
|
|
5317
|
+
};
|
|
5306
5318
|
const DfFormPreview = ({ formComponents = [], currentDevice = 'desktop', isPreviewMode = false, initialFormData = [], onSubmit, onFormDataChange, formTitle, formDescription, formTemplateId,
|
|
5307
5319
|
// Add component management props for edit mode
|
|
5308
5320
|
onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, selectedComponent, workOrderNumber, assetNumber, isStandalone, user, onCreateIssue, onUpdateIssue }) => {
|
|
@@ -5361,13 +5373,11 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
5361
5373
|
// Handle nested components in table cells
|
|
5362
5374
|
if (component.cells && Array.isArray(component.cells)) {
|
|
5363
5375
|
component.cells.forEach((row, _rowIndex) => {
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
});
|
|
5370
|
-
}
|
|
5376
|
+
normalizeTableRow(row).forEach((cell, _cellIndex) => {
|
|
5377
|
+
if (cell && cell.components && Array.isArray(cell.components)) {
|
|
5378
|
+
initializeComponentValues(cell.components, values);
|
|
5379
|
+
}
|
|
5380
|
+
});
|
|
5371
5381
|
});
|
|
5372
5382
|
}
|
|
5373
5383
|
// Handle nested components in datagrid entries
|
|
@@ -5430,11 +5440,10 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
5430
5440
|
extractNotesAndAttachments(comp.children);
|
|
5431
5441
|
if (comp.cells && Array.isArray(comp.cells))
|
|
5432
5442
|
comp.cells.forEach((row) => {
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
});
|
|
5443
|
+
normalizeTableRow(row).forEach((cell) => {
|
|
5444
|
+
if (cell && cell.components)
|
|
5445
|
+
extractNotesAndAttachments(cell.components);
|
|
5446
|
+
});
|
|
5438
5447
|
});
|
|
5439
5448
|
if (comp.entries)
|
|
5440
5449
|
comp.entries.forEach((entry) => {
|
|
@@ -5473,8 +5482,9 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
5473
5482
|
}
|
|
5474
5483
|
if (validatedComponent.cells && Array.isArray(validatedComponent.cells)) {
|
|
5475
5484
|
validatedComponent.cells = validatedComponent.cells.map((row) => {
|
|
5476
|
-
|
|
5477
|
-
|
|
5485
|
+
const normalizedRow = normalizeTableRow(row);
|
|
5486
|
+
if (normalizedRow.length > 0) {
|
|
5487
|
+
return normalizedRow.map((cell) => {
|
|
5478
5488
|
if (cell && cell.components && Array.isArray(cell.components)) {
|
|
5479
5489
|
return {
|
|
5480
5490
|
...cell,
|
|
@@ -5621,13 +5631,13 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
5621
5631
|
if (component.name === 'table' && component.cells) {
|
|
5622
5632
|
return {
|
|
5623
5633
|
...component,
|
|
5624
|
-
cells: component.cells.map((row) =>
|
|
5634
|
+
cells: component.cells.map((row) => normalizeTableRow(row).map((cell) => {
|
|
5625
5635
|
const updatedCell = { ...cell };
|
|
5626
5636
|
if (updatedCell.components) {
|
|
5627
5637
|
updatedCell.components = updateComponentValue(updatedCell.components);
|
|
5628
5638
|
}
|
|
5629
5639
|
return updatedCell;
|
|
5630
|
-
})
|
|
5640
|
+
}))
|
|
5631
5641
|
};
|
|
5632
5642
|
}
|
|
5633
5643
|
if (component.name === 'datagrid' && component.entries) {
|
|
@@ -6234,13 +6244,13 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6234
6244
|
updatedComponent.children = updateComponentValues(updatedComponent.children);
|
|
6235
6245
|
}
|
|
6236
6246
|
if (updatedComponent.name === 'table' && updatedComponent.cells) {
|
|
6237
|
-
updatedComponent.cells = updatedComponent.cells.map((row) =>
|
|
6247
|
+
updatedComponent.cells = updatedComponent.cells.map((row) => normalizeTableRow(row).map((cell) => {
|
|
6238
6248
|
const updatedCell = { ...cell };
|
|
6239
6249
|
if (updatedCell.components) {
|
|
6240
6250
|
updatedCell.components = updateComponentValues(updatedCell.components);
|
|
6241
6251
|
}
|
|
6242
6252
|
return updatedCell;
|
|
6243
|
-
})
|
|
6253
|
+
}));
|
|
6244
6254
|
}
|
|
6245
6255
|
if (updatedComponent.name === 'datagrid' && updatedComponent.entries) {
|
|
6246
6256
|
updatedComponent.entries = updatedComponent.entries.map((entry) => {
|
|
@@ -6423,7 +6433,7 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6423
6433
|
// Handle notes change for table cell components
|
|
6424
6434
|
const updatedComponents = localFormComponents.map(comp => {
|
|
6425
6435
|
if (comp.id === component.id && comp.cells) {
|
|
6426
|
-
const updatedCells = comp.cells.map((row) =>
|
|
6436
|
+
const updatedCells = comp.cells.map((row) => normalizeTableRow(row).map((cell) => {
|
|
6427
6437
|
if (cell.components) {
|
|
6428
6438
|
const updatedCellComponents = cell.components.map((cellComp) => {
|
|
6429
6439
|
if (cellComp.id === componentId) {
|
|
@@ -6440,7 +6450,7 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6440
6450
|
return { ...cell, components: updatedCellComponents };
|
|
6441
6451
|
}
|
|
6442
6452
|
return cell;
|
|
6443
|
-
})
|
|
6453
|
+
}));
|
|
6444
6454
|
return { ...comp, cells: updatedCells };
|
|
6445
6455
|
}
|
|
6446
6456
|
return comp;
|
|
@@ -6450,7 +6460,7 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6450
6460
|
// Handle attachment change for table cell components
|
|
6451
6461
|
const updatedComponents = localFormComponents.map(comp => {
|
|
6452
6462
|
if (comp.id === component.id && comp.cells) {
|
|
6453
|
-
const updatedCells = comp.cells.map((row) =>
|
|
6463
|
+
const updatedCells = comp.cells.map((row) => normalizeTableRow(row).map((cell) => {
|
|
6454
6464
|
if (cell.components) {
|
|
6455
6465
|
const updatedCellComponents = cell.components.map((cellComp) => {
|
|
6456
6466
|
if (cellComp.id === componentId) {
|
|
@@ -6467,7 +6477,7 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6467
6477
|
return { ...cell, components: updatedCellComponents };
|
|
6468
6478
|
}
|
|
6469
6479
|
return cell;
|
|
6470
|
-
})
|
|
6480
|
+
}));
|
|
6471
6481
|
return { ...comp, cells: updatedCells };
|
|
6472
6482
|
}
|
|
6473
6483
|
return comp;
|
|
@@ -6544,6 +6554,8 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6544
6554
|
}
|
|
6545
6555
|
return comp;
|
|
6546
6556
|
});
|
|
6557
|
+
// CRITICAL: Update local state immediately so new entries render without Angular round-trip
|
|
6558
|
+
setLocalFormComponents(updatedComponents);
|
|
6547
6559
|
onFormDataChange?.(updatedComponents);
|
|
6548
6560
|
// Also update formValues for nested components
|
|
6549
6561
|
if (change.value.entries && Array.isArray(change.value.entries)) {
|
|
@@ -6773,6 +6785,26 @@ const DfFormComments = ({ comment = '', onSave, placeholder = 'Enter your reason
|
|
|
6773
6785
|
return (jsxRuntime.jsxs("div", { className: `df-form-comments ${className}`, children: [jsxRuntime.jsxs("div", { className: "df-form-comments__header", children: [jsxRuntime.jsx("h3", { className: "df-form-comments__title", children: "Comments" }), jsxRuntime.jsx("button", { className: "df-form-comments__toggle", type: "button", onClick: toggleComments, "aria-expanded": isExpanded, "aria-label": "Toggle comments section", disabled: disabled, children: isExpanded ? (jsxRuntime.jsx("span", { className: "df-form-comments__toggle-icon", children: "\u25BC" })) : (jsxRuntime.jsx("span", { className: "df-form-comments__toggle-icon", children: "\u25B6" })) })] }), jsxRuntime.jsx("div", { className: `df-form-comments__content ${isExpanded ? 'df-form-comments__content--expanded' : ''}`, children: jsxRuntime.jsx("div", { className: "df-form-comments__input-container", children: jsxRuntime.jsx("div", { className: "df-form-comments__input-line", children: jsxRuntime.jsx("input", { type: "text", id: "comment-input", className: "df-form-comments__input", value: currentComment, onChange: handleInputChange, onBlur: handleInputBlur, onFocus: handleInputFocus, placeholder: placeholder, disabled: disabled }) }) }) })] }));
|
|
6774
6786
|
};
|
|
6775
6787
|
|
|
6788
|
+
// Normalize a row from the API format (object with numeric keys) into a proper TableCell array.
|
|
6789
|
+
// The API may return cells as [{"0": {cell}, "1": {cell}}, ...] instead of [[cell, cell], ...].
|
|
6790
|
+
const normalizeRow = (row) => {
|
|
6791
|
+
if (Array.isArray(row))
|
|
6792
|
+
return row;
|
|
6793
|
+
if (row && typeof row === 'object') {
|
|
6794
|
+
// Convert object with numeric keys to array, sorted by key
|
|
6795
|
+
const keys = Object.keys(row).filter(k => !isNaN(Number(k))).sort((a, b) => Number(a) - Number(b));
|
|
6796
|
+
if (keys.length > 0) {
|
|
6797
|
+
return keys.map(k => row[k]);
|
|
6798
|
+
}
|
|
6799
|
+
}
|
|
6800
|
+
return [];
|
|
6801
|
+
};
|
|
6802
|
+
// Normalize the entire cells structure from API format to TableCell[][]
|
|
6803
|
+
const normalizeCells = (cells) => {
|
|
6804
|
+
if (!cells || !Array.isArray(cells))
|
|
6805
|
+
return [];
|
|
6806
|
+
return cells.map(normalizeRow);
|
|
6807
|
+
};
|
|
6776
6808
|
// Function to ensure table cell components have proper IDs
|
|
6777
6809
|
const ensureComponentHasId = (component) => {
|
|
6778
6810
|
if (!component.id) {
|
|
@@ -6857,19 +6889,22 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
|
|
|
6857
6889
|
};
|
|
6858
6890
|
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 }) => {
|
|
6859
6891
|
const [isCollapsed, setIsCollapsed] = React.useState(false); // Always start expanded to show drop zones
|
|
6892
|
+
// CRITICAL: Normalize cells from API format (object with numeric keys) to proper 2D array
|
|
6893
|
+
// The API may return cells as [{"0": {cell}, "1": {cell}}, ...] instead of [[cell, cell], ...]
|
|
6894
|
+
const normalizedCells = React.useMemo(() => normalizeCells(properties.cells), [properties.cells]);
|
|
6860
6895
|
// Check if table has any components in any cells
|
|
6861
|
-
const hasAnyComponents =
|
|
6896
|
+
const hasAnyComponents = normalizedCells.some((row) => row.some((cell) => cell.components && cell.components.length > 0)) || false;
|
|
6862
6897
|
// Initialize and update table cells when rows/columns change
|
|
6863
6898
|
// Only trigger when cells are truly missing or structure doesn't match rows/columns
|
|
6864
6899
|
React.useEffect(() => {
|
|
6865
6900
|
// Get rows and columns from table properties (where they're actually stored)
|
|
6866
6901
|
const currentRows = Number(properties.table?.rows || properties.basic?.rows || 3);
|
|
6867
6902
|
const currentColumns = Number(properties.table?.columns || properties.basic?.columns || 3);
|
|
6868
|
-
const currentCells =
|
|
6903
|
+
const currentCells = normalizedCells;
|
|
6869
6904
|
// Check if we need to update the table structure
|
|
6870
6905
|
const needsUpdate = currentCells.length === 0 ||
|
|
6871
6906
|
currentCells.length !== currentRows ||
|
|
6872
|
-
(currentCells.length > 0 &&
|
|
6907
|
+
(currentCells.length > 0 && currentCells[0].length !== currentColumns);
|
|
6873
6908
|
if (needsUpdate) {
|
|
6874
6909
|
const newCells = [];
|
|
6875
6910
|
for (let row = 0; row < currentRows; row++) {
|
|
@@ -6878,7 +6913,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6878
6913
|
const cellId = `cell-${row}-${col}`;
|
|
6879
6914
|
// Try to preserve existing components if the cell exists
|
|
6880
6915
|
let existingComponents = [];
|
|
6881
|
-
if (
|
|
6916
|
+
if (currentCells[row] && currentCells[row][col]) {
|
|
6882
6917
|
existingComponents = (currentCells[row][col].components || []).map(ensureComponentHasId);
|
|
6883
6918
|
}
|
|
6884
6919
|
rowCells.push({
|
|
@@ -6896,7 +6931,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6896
6931
|
value: { ...properties, cells: newCells }
|
|
6897
6932
|
});
|
|
6898
6933
|
}
|
|
6899
|
-
}, [properties.table?.rows, properties.table?.columns, properties.basic?.rows, properties.basic?.columns,
|
|
6934
|
+
}, [properties.table?.rows, properties.table?.columns, properties.basic?.rows, properties.basic?.columns, normalizedCells, id, onValueChange]);
|
|
6900
6935
|
const handleTableClick = React.useCallback((event) => {
|
|
6901
6936
|
event.stopPropagation();
|
|
6902
6937
|
onSelect?.();
|
|
@@ -6913,7 +6948,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6913
6948
|
const handleComponentDelete = React.useCallback((component, event) => {
|
|
6914
6949
|
event.stopPropagation();
|
|
6915
6950
|
// Find and remove the component from the table cell
|
|
6916
|
-
const updatedCells =
|
|
6951
|
+
const updatedCells = normalizedCells.map((row) => row.map((cell) => {
|
|
6917
6952
|
if (cell.components && cell.components.some((comp) => comp.id === component.id)) {
|
|
6918
6953
|
const filteredComponents = cell.components.filter((comp) => comp.id !== component.id);
|
|
6919
6954
|
return {
|
|
@@ -6922,7 +6957,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6922
6957
|
};
|
|
6923
6958
|
}
|
|
6924
6959
|
return cell;
|
|
6925
|
-
})
|
|
6960
|
+
}));
|
|
6926
6961
|
// Update the table with the modified cells
|
|
6927
6962
|
if (onValueChange) {
|
|
6928
6963
|
onValueChange({
|
|
@@ -6932,13 +6967,13 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6932
6967
|
}
|
|
6933
6968
|
// Don't call parent delete handler for table cell components
|
|
6934
6969
|
// The parent delete handler is for deleting entire fields, not components within table cells
|
|
6935
|
-
}, [onComponentDelete, properties, onValueChange, id]);
|
|
6970
|
+
}, [onComponentDelete, normalizedCells, properties, onValueChange, id]);
|
|
6936
6971
|
// CRITICAL FIX: Ensure all table cell components have proper IDs with table and cell position
|
|
6937
6972
|
// Use useMemo to prevent ID regeneration on every render
|
|
6938
6973
|
const cellsWithIds = React.useMemo(() => {
|
|
6939
|
-
if (
|
|
6974
|
+
if (normalizedCells.length === 0)
|
|
6940
6975
|
return [];
|
|
6941
|
-
return
|
|
6976
|
+
return normalizedCells.map((row, rowIndex) => row.map((cell, cellIndex) => ({
|
|
6942
6977
|
...cell,
|
|
6943
6978
|
components: (cell.components && Array.isArray(cell.components))
|
|
6944
6979
|
? cell.components.map((comp, compIndex) => {
|
|
@@ -6957,8 +6992,8 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6957
6992
|
};
|
|
6958
6993
|
})
|
|
6959
6994
|
: []
|
|
6960
|
-
}))
|
|
6961
|
-
}, [
|
|
6995
|
+
})));
|
|
6996
|
+
}, [normalizedCells, id]); // Only recalculate if cells or table ID changes
|
|
6962
6997
|
// CRITICAL FIX: Update the parent component with the cells that have proper IDs
|
|
6963
6998
|
// Skip this in package to prevent flickering - cells are managed by parent
|
|
6964
6999
|
// useEffect(() => {
|