df-ae-forms-package 1.0.97 → 1.0.99
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 +112 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +112 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -6493,12 +6493,9 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6493
6493
|
onFormDataChange?.(updatedComponents);
|
|
6494
6494
|
} }) }));
|
|
6495
6495
|
case 'datagrid':
|
|
6496
|
-
// Align package datagrid wiring with main app behaviour:
|
|
6497
|
-
// - Let DfFormDataGrid manage entry structure via onValueChange
|
|
6498
|
-
// - Use the shared onFormValueChange handler for nested field values
|
|
6499
|
-
// - Keep notes/attachments wiring as before
|
|
6500
6496
|
return (jsx(DfFormDataGrid, { ...commonProps, properties: component, formData: formValues, formTemplateId: formTemplateId, mode: commonProps.mode, onThresholdActionCompletion: handleThresholdActionCompletion, onThresholdIssueRaised: handleThresholdIssueRaised, onNotesChange: (componentId, notes) => {
|
|
6501
6497
|
handleComponentNotesChange(componentId, notes);
|
|
6498
|
+
// Handle notes change for datagrid entry components
|
|
6502
6499
|
const updatedComponents = localFormComponents.map(comp => {
|
|
6503
6500
|
if (comp.id === component.id && comp.entries) {
|
|
6504
6501
|
const updatedEntries = comp.entries.map((entry) => {
|
|
@@ -6526,6 +6523,7 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6526
6523
|
onFormDataChange?.(updatedComponents);
|
|
6527
6524
|
}, onAttachmentChange: (componentId, attachments) => {
|
|
6528
6525
|
handleComponentAttachmentChange(componentId, attachments);
|
|
6526
|
+
// Handle attachment change for datagrid entry components
|
|
6529
6527
|
const updatedComponents = localFormComponents.map(comp => {
|
|
6530
6528
|
if (comp.id === component.id && comp.entries) {
|
|
6531
6529
|
const updatedEntries = comp.entries.map((entry) => {
|
|
@@ -6551,7 +6549,116 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6551
6549
|
return comp;
|
|
6552
6550
|
});
|
|
6553
6551
|
onFormDataChange?.(updatedComponents);
|
|
6554
|
-
}, onValueChange:
|
|
6552
|
+
}, onValueChange: (change) => {
|
|
6553
|
+
console.log('[DfFormPreview] datagrid onValueChange received:', change.id, 'hasEntries:', change.value && typeof change.value === 'object' && 'entries' in change.value);
|
|
6554
|
+
// Handle datagrid value changes (entries updates)
|
|
6555
|
+
if (change.id === component.id && change.value && typeof change.value === 'object' && 'entries' in change.value) {
|
|
6556
|
+
console.log('[DfFormPreview] datagrid entries update - entries count:', change.value.entries?.length);
|
|
6557
|
+
// Update localFormComponents with new entries structure
|
|
6558
|
+
const updatedComponents = localFormComponents.map(comp => {
|
|
6559
|
+
if (comp.id === component.id) {
|
|
6560
|
+
return {
|
|
6561
|
+
...comp,
|
|
6562
|
+
...change.value
|
|
6563
|
+
};
|
|
6564
|
+
}
|
|
6565
|
+
return comp;
|
|
6566
|
+
});
|
|
6567
|
+
// CRITICAL: Update local state immediately so new entries render without Angular round-trip
|
|
6568
|
+
setLocalFormComponents(updatedComponents);
|
|
6569
|
+
onFormDataChange?.(updatedComponents);
|
|
6570
|
+
// Also update formValues for nested components
|
|
6571
|
+
if (change.value.entries && Array.isArray(change.value.entries)) {
|
|
6572
|
+
change.value.entries.forEach((entry) => {
|
|
6573
|
+
if (entry.components && Array.isArray(entry.components)) {
|
|
6574
|
+
entry.components.forEach((nestedComp) => {
|
|
6575
|
+
const nestedValue = formValues[nestedComp.id];
|
|
6576
|
+
if (nestedValue !== undefined) ;
|
|
6577
|
+
else {
|
|
6578
|
+
// Initialize with defaultValue if available
|
|
6579
|
+
const defaultValue = nestedComp.basic?.defaultValue;
|
|
6580
|
+
if (defaultValue !== undefined) {
|
|
6581
|
+
setFormValues(prev => ({
|
|
6582
|
+
...prev,
|
|
6583
|
+
[nestedComp.id]: defaultValue
|
|
6584
|
+
}));
|
|
6585
|
+
}
|
|
6586
|
+
}
|
|
6587
|
+
});
|
|
6588
|
+
}
|
|
6589
|
+
});
|
|
6590
|
+
}
|
|
6591
|
+
}
|
|
6592
|
+
else {
|
|
6593
|
+
// For nested component value changes, use the regular handler
|
|
6594
|
+
onFormValueChange(change);
|
|
6595
|
+
}
|
|
6596
|
+
}, onEntryAdd: () => {
|
|
6597
|
+
// CRITICAL: Entry has already been added via onValueChange in DfFormDataGrid
|
|
6598
|
+
// Get the updated component from localFormComponents (which should have been updated by onValueChange)
|
|
6599
|
+
const currentComponent = localFormComponents.find(comp => comp.id === component.id);
|
|
6600
|
+
if (currentComponent && currentComponent.entries) {
|
|
6601
|
+
// Entry should already be in the component via onValueChange
|
|
6602
|
+
// Just ensure localFormComponents is in sync (no-op if already synced)
|
|
6603
|
+
const updatedComponents = localFormComponents.map(comp => {
|
|
6604
|
+
if (comp.id === component.id) {
|
|
6605
|
+
// Ensure entries are properly structured
|
|
6606
|
+
return {
|
|
6607
|
+
...comp,
|
|
6608
|
+
entries: comp.entries || []
|
|
6609
|
+
};
|
|
6610
|
+
}
|
|
6611
|
+
return comp;
|
|
6612
|
+
});
|
|
6613
|
+
onFormDataChange?.(updatedComponents);
|
|
6614
|
+
}
|
|
6615
|
+
else {
|
|
6616
|
+
// Fallback: If component doesn't have entries yet, try to get from formValues
|
|
6617
|
+
setTimeout(() => {
|
|
6618
|
+
const datagridValue = formValues[component.id];
|
|
6619
|
+
if (datagridValue && typeof datagridValue === 'object' && 'entries' in datagridValue) {
|
|
6620
|
+
const updatedComponents = localFormComponents.map(comp => {
|
|
6621
|
+
if (comp.id === component.id) {
|
|
6622
|
+
return {
|
|
6623
|
+
...comp,
|
|
6624
|
+
entries: datagridValue.entries
|
|
6625
|
+
};
|
|
6626
|
+
}
|
|
6627
|
+
return comp;
|
|
6628
|
+
});
|
|
6629
|
+
onFormDataChange?.(updatedComponents);
|
|
6630
|
+
}
|
|
6631
|
+
}, 100);
|
|
6632
|
+
}
|
|
6633
|
+
}, onEntryRemove: (entryIndex) => {
|
|
6634
|
+
// Handle entry remove - update form components
|
|
6635
|
+
const updatedComponents = localFormComponents.map(comp => {
|
|
6636
|
+
if (comp.id === component.id && comp.entries) {
|
|
6637
|
+
const currentEntries = comp.entries || [];
|
|
6638
|
+
const updatedEntries = currentEntries
|
|
6639
|
+
.filter((_, index) => index !== entryIndex)
|
|
6640
|
+
.map((entry, index) => ({
|
|
6641
|
+
...entry,
|
|
6642
|
+
index,
|
|
6643
|
+
id: `entry-${comp.id}-${index}`,
|
|
6644
|
+
components: entry.components?.map((comp, compIndex) => {
|
|
6645
|
+
const templateComp = (comp.templateComponents || [])[compIndex];
|
|
6646
|
+
return {
|
|
6647
|
+
...comp,
|
|
6648
|
+
id: templateComp ? `${templateComp.id}-entry-${index}-${compIndex}` : comp.id
|
|
6649
|
+
};
|
|
6650
|
+
}) || []
|
|
6651
|
+
}));
|
|
6652
|
+
return {
|
|
6653
|
+
...comp,
|
|
6654
|
+
entries: updatedEntries
|
|
6655
|
+
};
|
|
6656
|
+
}
|
|
6657
|
+
return comp;
|
|
6658
|
+
});
|
|
6659
|
+
onFormDataChange?.(updatedComponents);
|
|
6660
|
+
}, renderFormComponent: (field) => {
|
|
6661
|
+
// Ensure the nested component gets the proper form value
|
|
6555
6662
|
return renderFormComponent(field);
|
|
6556
6663
|
} }));
|
|
6557
6664
|
case 'file':
|