df-ae-forms-package 1.0.83 → 1.0.84

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 CHANGED
@@ -7592,44 +7592,10 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
7592
7592
  };
7593
7593
  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, shouldShowComponent }) => {
7594
7594
  const [isCollapsed, setIsCollapsed] = useState(false);
7595
- // Initialize and update table cells when rows/columns change (matching main website)
7596
- useEffect(() => {
7597
- const currentRows = Number(properties.table?.rows || properties.basic?.rows || 3);
7598
- const currentColumns = Number(properties.table?.columns || properties.basic?.columns || 3);
7599
- const currentCells = properties.cells || [];
7600
- // Check if we need to update the table structure
7601
- const needsUpdate = currentCells.length === 0 ||
7602
- currentCells.length !== currentRows ||
7603
- (currentCells.length > 0 && Array.isArray(currentCells[0]) && currentCells[0].length !== currentColumns);
7604
- if (needsUpdate) {
7605
- const newCells = [];
7606
- for (let row = 0; row < currentRows; row++) {
7607
- const rowCells = [];
7608
- for (let col = 0; col < currentColumns; col++) {
7609
- const cellId = `cell-${row}-${col}`;
7610
- // Try to preserve existing components if the cell exists
7611
- let existingComponents = [];
7612
- if (currentCells[row] && Array.isArray(currentCells[row]) && currentCells[row][col]) {
7613
- existingComponents = (currentCells[row][col].components || []).map(ensureComponentHasId);
7614
- }
7615
- rowCells.push({
7616
- id: cellId,
7617
- row,
7618
- column: col,
7619
- components: existingComponents,
7620
- styles: {}
7621
- });
7622
- }
7623
- newCells.push(rowCells);
7624
- }
7625
- if (onValueChange) {
7626
- onValueChange({
7627
- id,
7628
- value: { ...properties, cells: newCells }
7629
- });
7630
- }
7631
- }
7632
- }, [properties.table?.rows, properties.table?.columns, properties.basic?.rows, properties.basic?.columns, properties.cells, id, onValueChange]);
7595
+ // NOTE: Unlike the main website, the package does NOT have a cell initialization useEffect.
7596
+ // In the main website, onValueChange handles component structure updates (updating cells).
7597
+ // In the package, onValueChange maps to onFormValueChange which only handles simple form values.
7598
+ // The cells are already properly structured from the API and processed by the useMemo in DfFormPreview.
7633
7599
  // Check if table has any components in any cells
7634
7600
  const hasAnyComponents = properties.cells?.some((row) => {
7635
7601
  if (Array.isArray(row)) {
@@ -7694,18 +7660,10 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
7694
7660
  const cellsWithIds = properties.cells && properties.cells.length > 0
7695
7661
  ? ensureTableCellComponentsHaveIds(properties.cells)
7696
7662
  : [];
7697
- // CRITICAL FIX: Update the parent component with the cells that have proper IDs (matching main website)
7698
- useEffect(() => {
7699
- if (cellsWithIds.length > 0 && JSON.stringify(cellsWithIds) !== JSON.stringify(properties.cells)) {
7700
- onValueChange?.({
7701
- id: id,
7702
- value: {
7703
- ...properties,
7704
- cells: cellsWithIds
7705
- }
7706
- });
7707
- }
7708
- }, [cellsWithIds, properties.cells, id, onValueChange]);
7663
+ // NOTE: Unlike the main website, we do NOT sync cellsWithIds back via onValueChange.
7664
+ // In the package, onValueChange = onFormValueChange which handles simple form values,
7665
+ // not component structure updates. Syncing would corrupt the state.
7666
+ // cellsWithIds is used only for rendering.
7709
7667
  // CRITICAL: Create a stable renderComponent that doesn't recreate on every render
7710
7668
  // Match main app implementation - directly access formData from closure
7711
7669
  const renderComponent = renderFormComponent || useCallback((field) => {