df-ae-forms-package 1.0.81 → 1.0.83

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
@@ -5969,9 +5969,47 @@ const DfFormSection = ({ id, properties, mode = 'edit', formData = {}, onValueCh
5969
5969
 
5970
5970
  // Dynamic imports to avoid circular dependencies
5971
5971
  const DfFormTable$1 = React.lazy(() => Promise.resolve().then(function () { return dfFormTable; }));
5972
- const DfFormPreview = ({ formComponents = [], currentDevice = 'desktop', isPreviewMode = false, initialFormData = [], onSubmit, onFormDataChange, formTitle, formDescription, formTemplateId,
5972
+ const DfFormPreview = ({ formComponents: rawFormComponents = [], currentDevice = 'desktop', isPreviewMode = false, initialFormData = [], onSubmit, onFormDataChange, formTitle, formDescription, formTemplateId,
5973
5973
  // Add component management props for edit mode
5974
5974
  onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, selectedComponent, workOrderNumber, assetNumber, isStandalone, user, onCreateIssue, onUpdateIssue }) => {
5975
+ // Ensure all components have IDs (matching main website approach)
5976
+ const formComponents = useMemo(() => {
5977
+ const ensureIds = (components) => {
5978
+ return components.map(comp => {
5979
+ // Reuse existing ID or generate one
5980
+ const id = comp.id || `generated-${Math.random().toString(36).substr(2, 9)}`;
5981
+ const newComp = { ...comp, id };
5982
+ // Recursively handle nested components
5983
+ if (newComp.children && Array.isArray(newComp.children)) {
5984
+ newComp.children = ensureIds(newComp.children);
5985
+ }
5986
+ if (newComp.cells && Array.isArray(newComp.cells)) {
5987
+ newComp.cells = newComp.cells.map((row) => {
5988
+ if (Array.isArray(row)) {
5989
+ return row.map((cell) => ({
5990
+ ...cell,
5991
+ components: cell.components ? ensureIds(cell.components) : []
5992
+ }));
5993
+ }
5994
+ // Handle flat 1D cell (not wrapped in row array)
5995
+ const cell = row;
5996
+ return {
5997
+ ...cell,
5998
+ components: cell.components ? ensureIds(cell.components) : []
5999
+ };
6000
+ });
6001
+ }
6002
+ if (newComp.entries && Array.isArray(newComp.entries)) {
6003
+ newComp.entries = newComp.entries.map((entry) => ({
6004
+ ...entry,
6005
+ components: entry.components ? ensureIds(entry.components) : []
6006
+ }));
6007
+ }
6008
+ return newComp;
6009
+ });
6010
+ };
6011
+ return ensureIds(rawFormComponents || []);
6012
+ }, [rawFormComponents]);
5975
6013
  // Form state
5976
6014
  const [formValues, setFormValues] = useState({});
5977
6015
  const [validationErrors, setValidationErrors] = useState({});
@@ -6072,7 +6110,6 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6072
6110
  const initialValues = {};
6073
6111
  const initialNotes = {};
6074
6112
  const initialAttachments = {};
6075
- const seenIds = new Set();
6076
6113
  // Helper to extract notes and attachments recursively
6077
6114
  const extractNotesAndAttachments = (components) => {
6078
6115
  components.forEach(comp => {
@@ -6109,76 +6146,16 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6109
6146
  });
6110
6147
  });
6111
6148
  };
6112
- // Validate component IDs for uniqueness without mutating original props
6113
- const getValidatedComponents = (components) => {
6114
- return components.map((component, index) => {
6115
- let validatedComponent = { ...component };
6116
- // Ensure component has an ID
6117
- if (!validatedComponent.id || typeof validatedComponent.id !== 'string' || validatedComponent.id.trim() === '') {
6118
- // Determine a base name for the ID
6119
- const name = validatedComponent.name || 'component';
6120
- const label = validatedComponent.basic?.label || '';
6121
- const safeLabel = label.replace(/[^a-zA-Z0-9]/g, '').toLowerCase().substring(0, 10);
6122
- // Generate a unique ID
6123
- validatedComponent.id = `${name}-${safeLabel || 'gen'}-${Date.now()}-${Math.random().toString(36).substr(2, 6)}-${index}`;
6124
- console.warn(`[DfFormPreview] Assigned missing ID: ${validatedComponent.id}`);
6125
- }
6126
- else {
6127
- // Check for duplicates
6128
- if (seenIds.has(validatedComponent.id)) {
6129
- console.error(`[DfFormPreview] Duplicate component ID detected: ${validatedComponent.id}`);
6130
- // Generate a unique ID for duplicate
6131
- validatedComponent.id = `${validatedComponent.id}-duplicate-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
6132
- console.warn(`[DfFormPreview] Generated new unique ID: ${validatedComponent.id}`);
6133
- }
6134
- }
6135
- seenIds.add(validatedComponent.id);
6136
- // Recursively validate nested components
6137
- if (validatedComponent.children && Array.isArray(validatedComponent.children)) {
6138
- validatedComponent.children = getValidatedComponents(validatedComponent.children);
6139
- }
6140
- if (validatedComponent.cells && Array.isArray(validatedComponent.cells)) {
6141
- validatedComponent.cells = validatedComponent.cells.map((row) => row.map((cell) => ({
6142
- ...cell,
6143
- components: cell.components ? getValidatedComponents(cell.components) : []
6144
- })));
6145
- }
6146
- if (validatedComponent.entries && Array.isArray(validatedComponent.entries)) {
6147
- validatedComponent.entries = validatedComponent.entries.map((entry) => {
6148
- if (entry && entry.components && Array.isArray(entry.components)) {
6149
- return {
6150
- ...entry,
6151
- components: getValidatedComponents(entry.components)
6152
- };
6153
- }
6154
- return entry;
6155
- });
6156
- }
6157
- return validatedComponent;
6158
- });
6159
- };
6160
- // Initialize validated components
6161
- let validatedFormComponents = formComponents;
6162
- if (formComponents && formComponents.length > 0) {
6163
- validatedFormComponents = getValidatedComponents(formComponents);
6164
- // Notifying parent of changed components if they were mutated (IDs added/fixed)
6165
- if (JSON.stringify(validatedFormComponents) !== JSON.stringify(formComponents)) {
6166
- onFormDataChange?.(validatedFormComponents);
6167
- }
6168
- }
6169
- let validatedInitialFormData = initialFormData;
6170
- if (initialFormData && initialFormData.length > 0) {
6171
- validatedInitialFormData = getValidatedComponents(initialFormData);
6172
- }
6149
+ // IDs are already ensured by the useMemo at the top - no need for getValidatedComponents
6173
6150
  // Initialize form values from initial data
6174
- if (validatedInitialFormData && validatedInitialFormData.length > 0) {
6175
- initializeComponentValues(validatedInitialFormData, initialValues);
6151
+ if (initialFormData && initialFormData.length > 0) {
6152
+ initializeComponentValues(initialFormData, initialValues);
6176
6153
  }
6177
6154
  // Initialize form values from form components (for submitted data or pre-filled forms)
6178
6155
  // CRITICAL: This must run AFTER initialFormData to pick up any values embedded in the components themselves
6179
- if (validatedFormComponents && validatedFormComponents.length > 0) {
6180
- initializeComponentValues(validatedFormComponents, initialValues);
6181
- extractNotesAndAttachments(validatedFormComponents);
6156
+ if (formComponents && formComponents.length > 0) {
6157
+ initializeComponentValues(formComponents, initialValues);
6158
+ extractNotesAndAttachments(formComponents);
6182
6159
  }
6183
6160
  // Set the state
6184
6161
  setFormValues(prev => {
@@ -6226,11 +6203,18 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6226
6203
  component.cells.forEach((row) => {
6227
6204
  if (Array.isArray(row)) {
6228
6205
  row.forEach((cell) => {
6229
- if (cell.components && Array.isArray(cell.components)) {
6206
+ if (cell && cell.components && Array.isArray(cell.components)) {
6230
6207
  evaluateComponentConditionalLogic(cell.components, visibility, currentFormValues, fullSchema);
6231
6208
  }
6232
6209
  });
6233
6210
  }
6211
+ else {
6212
+ // Handle flat 1D cell
6213
+ const cell = row;
6214
+ if (cell && cell.components && Array.isArray(cell.components)) {
6215
+ evaluateComponentConditionalLogic(cell.components, visibility, currentFormValues, fullSchema);
6216
+ }
6217
+ }
6234
6218
  });
6235
6219
  }
6236
6220
  // Handle nested components in datagrid entries
@@ -6354,13 +6338,24 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6354
6338
  if (component.name === 'table' && component.cells) {
6355
6339
  return {
6356
6340
  ...component,
6357
- cells: component.cells.map((row) => row.map((cell) => {
6341
+ cells: component.cells.map((row) => {
6342
+ if (Array.isArray(row)) {
6343
+ return row.map((cell) => {
6344
+ const updatedCell = { ...cell };
6345
+ if (updatedCell.components) {
6346
+ updatedCell.components = updateComponentValue(updatedCell.components);
6347
+ }
6348
+ return updatedCell;
6349
+ });
6350
+ }
6351
+ // Handle flat 1D cell
6352
+ const cell = row;
6358
6353
  const updatedCell = { ...cell };
6359
6354
  if (updatedCell.components) {
6360
6355
  updatedCell.components = updateComponentValue(updatedCell.components);
6361
6356
  }
6362
6357
  return updatedCell;
6363
- }))
6358
+ })
6364
6359
  };
6365
6360
  }
6366
6361
  if (component.name === 'datagrid' && component.entries) {
@@ -6432,8 +6427,19 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6432
6427
  // Check nested components in table cells
6433
6428
  if (comp.name === 'table' && comp.cells) {
6434
6429
  for (const row of comp.cells) {
6435
- for (const cell of row) {
6436
- if (cell.components) {
6430
+ if (Array.isArray(row)) {
6431
+ for (const cell of row) {
6432
+ if (cell && cell.components) {
6433
+ const found = findComponentById(cell.components, fieldId);
6434
+ if (found)
6435
+ return found;
6436
+ }
6437
+ }
6438
+ }
6439
+ else {
6440
+ // Handle flat 1D cell
6441
+ const cell = row;
6442
+ if (cell && cell.components) {
6437
6443
  const found = findComponentById(cell.components, fieldId);
6438
6444
  if (found)
6439
6445
  return found;
@@ -7162,7 +7168,7 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
7162
7168
  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, onNotesChange: (componentId, notes) => {
7163
7169
  const updatedComponents = formComponents.map(comp => {
7164
7170
  if (comp.id === component.id && comp.cells) {
7165
- const updatedCells = comp.cells.map((row) => row.map((cell) => {
7171
+ const updateCell = (cell) => {
7166
7172
  if (cell.components) {
7167
7173
  return {
7168
7174
  ...cell,
@@ -7172,7 +7178,8 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
7172
7178
  };
7173
7179
  }
7174
7180
  return cell;
7175
- }));
7181
+ };
7182
+ const updatedCells = comp.cells.map((row) => Array.isArray(row) ? row.map(updateCell) : updateCell(row));
7176
7183
  return { ...comp, cells: updatedCells };
7177
7184
  }
7178
7185
  return comp;
@@ -7181,7 +7188,7 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
7181
7188
  }, onAttachmentChange: (componentId, attachments) => {
7182
7189
  const updatedComponents = formComponents.map(comp => {
7183
7190
  if (comp.id === component.id && comp.cells) {
7184
- const updatedCells = comp.cells.map((row) => row.map((cell) => {
7191
+ const updateCell = (cell) => {
7185
7192
  if (cell.components) {
7186
7193
  return {
7187
7194
  ...cell,
@@ -7191,7 +7198,8 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
7191
7198
  };
7192
7199
  }
7193
7200
  return cell;
7194
- }));
7201
+ };
7202
+ const updatedCells = comp.cells.map((row) => Array.isArray(row) ? row.map(updateCell) : updateCell(row));
7195
7203
  return { ...comp, cells: updatedCells };
7196
7204
  }
7197
7205
  return comp;
@@ -7584,11 +7592,53 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
7584
7592
  };
7585
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 }) => {
7586
7594
  const [isCollapsed, setIsCollapsed] = useState(false);
7587
- // By the time cells arrive here, DfFormPreview.getValidatedComponents has already
7588
- // normalized them from 1D flat (API format) to proper 2D arrays.
7589
- // So we can use properties.cells directly, exactly like the website version.
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]);
7590
7633
  // Check if table has any components in any cells
7591
- const hasAnyComponents = properties.cells?.some((row) => Array.isArray(row) && row.some((cell) => cell && cell.components && cell.components.length > 0)) || false;
7634
+ const hasAnyComponents = properties.cells?.some((row) => {
7635
+ if (Array.isArray(row)) {
7636
+ return row.some((cell) => cell && cell.components && cell.components.length > 0);
7637
+ }
7638
+ // Handle flat 1D cell
7639
+ const cell = row;
7640
+ return cell && cell.components && cell.components.length > 0;
7641
+ }) || false;
7592
7642
  const handleTableClick = useCallback((event) => {
7593
7643
  event.stopPropagation();
7594
7644
  onSelect?.();
@@ -7604,34 +7654,58 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
7604
7654
  };
7605
7655
  const handleComponentDelete = useCallback((component, event) => {
7606
7656
  event.stopPropagation();
7607
- const updatedCells = properties.cells.map((row) => row.map((cell) => {
7657
+ const updatedCells = properties.cells.map((row) => {
7658
+ if (Array.isArray(row)) {
7659
+ return row.map((cell) => {
7660
+ if (cell && cell.components && cell.components.some((comp) => comp.id === component.id)) {
7661
+ return { ...cell, components: cell.components.filter((comp) => comp.id !== component.id) };
7662
+ }
7663
+ return cell;
7664
+ });
7665
+ }
7666
+ // Handle flat 1D cell
7667
+ const cell = row;
7608
7668
  if (cell && cell.components && cell.components.some((comp) => comp.id === component.id)) {
7609
7669
  return { ...cell, components: cell.components.filter((comp) => comp.id !== component.id) };
7610
7670
  }
7611
7671
  return cell;
7612
- }));
7672
+ });
7613
7673
  onValueChange?.({ id, value: { ...properties, cells: updatedCells } });
7614
7674
  }, [onComponentDelete, properties, onValueChange, id]);
7615
7675
  // Ensure all table cell components have IDs (matching website ensureTableCellComponentsHaveIds)
7676
+ const ensureCellComponentIds = (cell) => ({
7677
+ ...cell,
7678
+ components: (cell?.components || []).map((comp) => {
7679
+ if (!comp.id || comp.id.trim() === '') {
7680
+ return { ...comp, id: `table-cell-${comp.name}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}` };
7681
+ }
7682
+ return comp;
7683
+ })
7684
+ });
7616
7685
  const ensureTableCellComponentsHaveIds = (cells) => {
7617
- return cells.map((row) => (Array.isArray(row) ? row : []).map((cell) => ({
7618
- ...cell,
7619
- components: (cell?.components || []).map((comp) => {
7620
- if (!comp.id || comp.id.trim() === '') {
7621
- return { ...comp, id: `table-cell-${comp.name}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}` };
7622
- }
7623
- return comp;
7624
- })
7625
- })));
7686
+ return cells.map((row) => {
7687
+ if (Array.isArray(row)) {
7688
+ return row.map(ensureCellComponentIds);
7689
+ }
7690
+ // Handle flat 1D cell
7691
+ return ensureCellComponentIds(row);
7692
+ });
7626
7693
  };
7627
7694
  const cellsWithIds = properties.cells && properties.cells.length > 0
7628
7695
  ? ensureTableCellComponentsHaveIds(properties.cells)
7629
7696
  : [];
7630
- // CRITICAL FIX: Update the parent component with the cells that have proper IDs
7631
- // Skip this in package to prevent flickering - cells are managed by parent
7632
- // useEffect(() => {
7633
- // // Disabled to prevent flickering when user types
7634
- // }, [])
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]);
7635
7709
  // CRITICAL: Create a stable renderComponent that doesn't recreate on every render
7636
7710
  // Match main app implementation - directly access formData from closure
7637
7711
  const renderComponent = renderFormComponent || useCallback((field) => {
@@ -7739,22 +7813,22 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
7739
7813
  if (!hasAnyComponents && mode === 'preview') {
7740
7814
  return null;
7741
7815
  }
7742
- return (jsxs("div", { className: `form-group df-form-table ${isSelected ? 'selected' : ''} ${mode === 'preview' ? 'preview-mode' : mode === 'test' ? 'test-mode' : ''} ${className}`, onClick: handleTableClick, style: tableStyle, children: [jsx("div", { className: "table-header", children: jsx("div", { className: "table-title", onClick: toggleCollapse, children: jsxs("div", { className: "title-content", children: [isCollapsed ? jsx(ChevronRight, { size: 16 }) : jsx(ChevronDown, { size: 16 }), jsx(Table, { size: 16 }), jsx("span", { className: "table-label", children: properties.basic?.label || 'Table' }), properties.validation?.required && (jsx("span", { className: "required-indicator", children: "*" }))] }) }) }), properties.basic?.description && !isCollapsed && (jsx("div", { className: "table-description", children: properties.basic.description })), !isCollapsed && (jsxs("div", { className: "table-content", children: [(() => {
7743
- return null;
7744
- })(), jsxs("table", { style: tableElementStyle, children: [properties.table?.displayAsTable && (mode === 'edit' || properties.table?.showColumns) && (jsx("thead", { children: jsx("tr", { className: "table-header-row", children: Array.from({ length: properties.table?.columns || properties.basic?.columns || 3 }, (_, colIndex) => {
7745
- // Parse column names from the comma-separated string
7746
- const columnNames = properties.table?.columnNames?.split(',').map(name => name.trim()) || [];
7747
- const columnName = columnNames[colIndex] || `Column ${colIndex + 1}`;
7748
- return (jsx("th", { className: "table-header-cell", style: {
7749
- backgroundColor: properties.styles.headerBackgroundColor || (mode === 'preview' || mode === 'test') ? 'var(--df-color-fb-container)' : 'var(--df-color-fb-container)',
7750
- color: properties.styles.headerTextColor || 'var(--df-color-text-dark)',
7751
- padding: '12px',
7752
- border: (mode === 'preview' || mode === 'test') ? '1px solid var(--df-color-fb-border)' : '1px solid var(--df-color-fb-border)',
7753
- fontWeight: '600',
7754
- fontSize: '14px',
7755
- textAlign: 'center'
7756
- }, children: columnName }, `header-${colIndex}`));
7757
- }) }) })), jsx("tbody", { children: cellsWithIds.filter(row => Array.isArray(row) && row.length > 0).map((row, rowIndex) => (jsx("tr", { className: "table-row", children: row.filter(cell => cell != null).map((cell) => (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, shouldShowComponent: shouldShowComponent }, cell.id))) }, rowIndex))) })] })] }))] }));
7816
+ return (jsxs("div", { className: `form-group df-form-table ${isSelected ? 'selected' : ''} ${mode === 'preview' ? 'preview-mode' : mode === 'test' ? 'test-mode' : ''} ${className}`, onClick: handleTableClick, style: tableStyle, children: [jsx("div", { className: "table-header", children: jsx("div", { className: "table-title", onClick: toggleCollapse, children: jsxs("div", { className: "title-content", children: [isCollapsed ? jsx(ChevronRight, { size: 16 }) : jsx(ChevronDown, { size: 16 }), jsx(Table, { size: 16 }), jsx("span", { className: "table-label", children: properties.basic?.label || 'Table' }), properties.validation?.required && (jsx("span", { className: "required-indicator", children: "*" }))] }) }) }), properties.basic?.description && !isCollapsed && (jsx("div", { className: "table-description", children: properties.basic.description })), !isCollapsed && (jsx("div", { className: "table-content", children: jsxs("table", { style: tableElementStyle, children: [properties.table?.displayAsTable && (mode === 'edit' || properties.table?.showColumns) && (jsx("thead", { children: jsx("tr", { className: "table-header-row", children: Array.from({ length: properties.table?.columns || properties.basic?.columns || 3 }, (_, colIndex) => {
7817
+ const columnNames = properties.table?.columnNames?.split(',').map((name) => name.trim()) || [];
7818
+ const columnName = columnNames[colIndex] || `Column ${colIndex + 1}`;
7819
+ return (jsx("th", { className: "table-header-cell", style: {
7820
+ backgroundColor: 'var(--df-color-fb-container)',
7821
+ color: properties.styles.headerTextColor || 'var(--df-color-text-dark)',
7822
+ padding: '12px',
7823
+ border: '1px solid var(--df-color-fb-border)',
7824
+ fontWeight: '600',
7825
+ fontSize: '14px',
7826
+ textAlign: 'center'
7827
+ }, children: columnName }, `header-${colIndex}`));
7828
+ }) }) })), jsx("tbody", { children: cellsWithIds.map((row, rowIndex) => {
7829
+ const rowCells = Array.isArray(row) ? row : [row];
7830
+ return (jsx("tr", { className: "table-row", children: rowCells.map((cell) => (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, shouldShowComponent: shouldShowComponent }, cell.id))) }, rowIndex));
7831
+ }) })] }) }))] }));
7758
7832
  };
7759
7833
 
7760
7834
  var dfFormTable = /*#__PURE__*/Object.freeze({