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