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