df-ae-forms-package 1.0.87 → 1.0.89
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 +19 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +19 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -6406,7 +6406,9 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6406
6406
|
return renderFormComponent(field);
|
|
6407
6407
|
} }));
|
|
6408
6408
|
case 'table':
|
|
6409
|
-
return (jsx(React.Suspense, { fallback: jsx("div", { children: "Loading table..." }), children: jsx(DfFormTable$1, { ...commonProps, properties: component, formData: formValues, formTemplateId: formTemplateId, mode: commonProps.mode, validationErrors: validationErrors, touchedFields: touchedFields, formSubmitted: formSubmitted, onThresholdActionCompletion: handleThresholdActionCompletion, onThresholdIssueRaised: handleThresholdIssueRaised, workOrderNumber: workOrderNumber, assetNumber: assetNumber, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue,
|
|
6409
|
+
return (jsx(React.Suspense, { fallback: jsx("div", { children: "Loading table..." }), children: jsx(DfFormTable$1, { ...commonProps, properties: component, formData: formValues, formTemplateId: formTemplateId, mode: commonProps.mode, validationErrors: validationErrors, touchedFields: touchedFields, formSubmitted: formSubmitted, onThresholdActionCompletion: handleThresholdActionCompletion, onThresholdIssueRaised: handleThresholdIssueRaised, workOrderNumber: workOrderNumber, assetNumber: assetNumber, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, renderFormComponent: (field) => {
|
|
6410
|
+
return renderFormComponent(field);
|
|
6411
|
+
}, onNotesChange: (componentId, notes) => {
|
|
6410
6412
|
// Handle notes change for table cell components
|
|
6411
6413
|
const updatedComponents = formComponents.map(comp => {
|
|
6412
6414
|
if (comp.id === component.id && comp.cells) {
|
|
@@ -6460,10 +6462,6 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6460
6462
|
return comp;
|
|
6461
6463
|
});
|
|
6462
6464
|
onFormDataChange?.(updatedComponents);
|
|
6463
|
-
}, renderFormComponent: (field) => {
|
|
6464
|
-
// CRITICAL: Pass the field to renderFormComponent which has access to latest formValues
|
|
6465
|
-
// renderFormComponent uses formValues[field.id] internally, so it will get the correct value
|
|
6466
|
-
return renderFormComponent(field);
|
|
6467
6465
|
} }) }));
|
|
6468
6466
|
case 'datagrid':
|
|
6469
6467
|
return (jsx(DfFormDataGrid, { ...commonProps, properties: component, formData: formValues, formTemplateId: formTemplateId, mode: commonProps.mode, onThresholdActionCompletion: handleThresholdActionCompletion, onThresholdIssueRaised: handleThresholdIssueRaised, onNotesChange: (componentId, notes) => {
|
|
@@ -6849,7 +6847,7 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
|
|
|
6849
6847
|
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 }) => {
|
|
6850
6848
|
const [isCollapsed, setIsCollapsed] = useState(false); // Always start expanded to show drop zones
|
|
6851
6849
|
// Check if table has any components in any cells
|
|
6852
|
-
const hasAnyComponents = properties.cells?.some(row => row.some(cell => cell.components && cell.components.length > 0)) || false;
|
|
6850
|
+
const hasAnyComponents = properties.cells?.some((row) => Array.isArray(row) && row.some((cell) => cell.components && cell.components.length > 0)) || false;
|
|
6853
6851
|
// Initialize and update table cells when rows/columns change
|
|
6854
6852
|
// Only trigger when cells are truly missing or structure doesn't match rows/columns
|
|
6855
6853
|
useEffect(() => {
|
|
@@ -6858,10 +6856,9 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6858
6856
|
const currentColumns = Number(properties.table?.columns || properties.basic?.columns || 3);
|
|
6859
6857
|
const currentCells = properties.cells || [];
|
|
6860
6858
|
// Check if we need to update the table structure
|
|
6861
|
-
// Only update if cells are empty or row/column count doesn't match
|
|
6862
6859
|
const needsUpdate = currentCells.length === 0 ||
|
|
6863
6860
|
currentCells.length !== currentRows ||
|
|
6864
|
-
(currentCells.length > 0 && currentCells[0].length !== currentColumns);
|
|
6861
|
+
(currentCells.length > 0 && Array.isArray(currentCells[0]) && currentCells[0].length !== currentColumns);
|
|
6865
6862
|
if (needsUpdate) {
|
|
6866
6863
|
const newCells = [];
|
|
6867
6864
|
for (let row = 0; row < currentRows; row++) {
|
|
@@ -6870,7 +6867,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6870
6867
|
const cellId = `cell-${row}-${col}`;
|
|
6871
6868
|
// Try to preserve existing components if the cell exists
|
|
6872
6869
|
let existingComponents = [];
|
|
6873
|
-
if (currentCells[row] && currentCells[row][col]) {
|
|
6870
|
+
if (Array.isArray(currentCells[row]) && currentCells[row][col]) {
|
|
6874
6871
|
existingComponents = (currentCells[row][col].components || []).map(ensureComponentHasId);
|
|
6875
6872
|
}
|
|
6876
6873
|
rowCells.push({
|
|
@@ -6888,7 +6885,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6888
6885
|
value: { ...properties, cells: newCells }
|
|
6889
6886
|
});
|
|
6890
6887
|
}
|
|
6891
|
-
}, [properties.table?.rows, properties.table?.columns, properties.basic?.rows, properties.basic?.columns, properties.cells?.length, id, onValueChange]);
|
|
6888
|
+
}, [properties.table?.rows, properties.table?.columns, properties.basic?.rows, properties.basic?.columns, properties.cells?.length, id, onValueChange]);
|
|
6892
6889
|
const handleTableClick = useCallback((event) => {
|
|
6893
6890
|
event.stopPropagation();
|
|
6894
6891
|
onSelect?.();
|
|
@@ -6905,16 +6902,16 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6905
6902
|
const handleComponentDelete = useCallback((component, event) => {
|
|
6906
6903
|
event.stopPropagation();
|
|
6907
6904
|
// Find and remove the component from the table cell
|
|
6908
|
-
const updatedCells = properties.cells.map(row => row.map(cell => {
|
|
6909
|
-
if (cell.components && cell.components.some(comp => comp.id === component.id)) {
|
|
6910
|
-
const filteredComponents = cell.components.filter(comp => comp.id !== component.id);
|
|
6905
|
+
const updatedCells = properties.cells.map((row) => Array.isArray(row) ? row.map((cell) => {
|
|
6906
|
+
if (cell.components && cell.components.some((comp) => comp.id === component.id)) {
|
|
6907
|
+
const filteredComponents = cell.components.filter((comp) => comp.id !== component.id);
|
|
6911
6908
|
return {
|
|
6912
6909
|
...cell,
|
|
6913
6910
|
components: filteredComponents
|
|
6914
6911
|
};
|
|
6915
6912
|
}
|
|
6916
6913
|
return cell;
|
|
6917
|
-
}));
|
|
6914
|
+
}) : row);
|
|
6918
6915
|
// Update the table with the modified cells
|
|
6919
6916
|
if (onValueChange) {
|
|
6920
6917
|
onValueChange({
|
|
@@ -6930,7 +6927,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6930
6927
|
const cellsWithIds = useMemo(() => {
|
|
6931
6928
|
if (!properties.cells)
|
|
6932
6929
|
return [];
|
|
6933
|
-
return properties.cells.map((row, rowIndex) => row.map((cell, cellIndex) => ({
|
|
6930
|
+
return properties.cells.map((row, rowIndex) => Array.isArray(row) ? row.map((cell, cellIndex) => ({
|
|
6934
6931
|
...cell,
|
|
6935
6932
|
components: (cell.components && Array.isArray(cell.components))
|
|
6936
6933
|
? cell.components.map((comp, compIndex) => {
|
|
@@ -6949,7 +6946,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6949
6946
|
};
|
|
6950
6947
|
})
|
|
6951
6948
|
: []
|
|
6952
|
-
})));
|
|
6949
|
+
})) : []);
|
|
6953
6950
|
}, [properties.cells, id]); // Only recalculate if cells or table ID changes
|
|
6954
6951
|
// CRITICAL FIX: Update the parent component with the cells that have proper IDs
|
|
6955
6952
|
// Skip this in package to prevent flickering - cells are managed by parent
|
|
@@ -6960,10 +6957,12 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6960
6957
|
// Always defined to avoid conditional hook calls (React hooks rule)
|
|
6961
6958
|
const fallbackRenderComponent = useCallback((field) => {
|
|
6962
6959
|
// CRITICAL: Only ensure ID if it's missing - don't regenerate existing IDs
|
|
6960
|
+
// This prevents component remounting and losing input state
|
|
6963
6961
|
const componentWithId = field.id ? field : ensureComponentHasId(field);
|
|
6964
6962
|
// Get form value - directly access formData from closure (matches main app)
|
|
6965
6963
|
const formValue = formData[componentWithId.id] || ('defaultValue' in componentWithId.basic ? componentWithId.basic.defaultValue || '' : '');
|
|
6966
6964
|
// CRITICAL: Ensure formValue is always a string for number inputs
|
|
6965
|
+
// This prevents validation errors when formValue is a number type
|
|
6967
6966
|
let normalizedFormValue = formValue;
|
|
6968
6967
|
if (componentWithId.name === 'number-input' && typeof formValue === 'number') {
|
|
6969
6968
|
normalizedFormValue = String(formValue);
|
|
@@ -6995,18 +6994,21 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
6995
6994
|
case 'textarea':
|
|
6996
6995
|
return jsx(DfFormTextarea, { ...commonProps, properties: componentWithId, readonly: false, disabled: false });
|
|
6997
6996
|
case 'select':
|
|
6997
|
+
// Map basic.options to top-level options for select component
|
|
6998
6998
|
const selectProps = {
|
|
6999
6999
|
...componentWithId,
|
|
7000
7000
|
options: componentWithId.basic?.options || []
|
|
7001
7001
|
};
|
|
7002
7002
|
return jsx(DfFormSelect, { ...commonProps, properties: selectProps, disabled: false });
|
|
7003
7003
|
case 'checkbox':
|
|
7004
|
+
// Map basic.options to top-level options for checkbox component
|
|
7004
7005
|
const checkboxProps = {
|
|
7005
7006
|
...componentWithId,
|
|
7006
7007
|
options: componentWithId.basic?.options || []
|
|
7007
7008
|
};
|
|
7008
7009
|
return jsx(DfFormCheckbox, { ...commonProps, properties: checkboxProps, formValue: [], disabled: false });
|
|
7009
7010
|
case 'radio':
|
|
7011
|
+
// Map basic.options to top-level options for radio component
|
|
7010
7012
|
const radioProps = {
|
|
7011
7013
|
...componentWithId,
|
|
7012
7014
|
options: componentWithId.basic?.options || []
|
|
@@ -7028,6 +7030,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7028
7030
|
case 'datagrid':
|
|
7029
7031
|
return (jsx(DfFormDataGrid, { ...commonProps, properties: componentWithId, formData: formData, mode: mode, onNotesChange: () => { }, onAttachmentChange: () => { } }));
|
|
7030
7032
|
case 'segment':
|
|
7033
|
+
// Map basic.options for segment
|
|
7031
7034
|
const segmentProps = {
|
|
7032
7035
|
...componentWithId,
|
|
7033
7036
|
options: componentWithId.basic?.options || []
|