df-ae-forms-package 1.0.92 → 1.0.94
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 +23 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4566,7 +4566,7 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
|
|
|
4566
4566
|
position: 'sticky',
|
|
4567
4567
|
bottom: 0,
|
|
4568
4568
|
zIndex: 5
|
|
4569
|
-
}, children: jsxRuntime.jsxs("button", { onClick: onAddEntry, disabled: dataEntries.length >= maxEntries, style: {
|
|
4569
|
+
}, children: jsxRuntime.jsxs("button", { onClick: () => { console.log('[TableView] Add Entry button clicked (grid view)', 'entries:', dataEntries.length, 'max:', maxEntries); onAddEntry(); }, disabled: dataEntries.length >= maxEntries, style: {
|
|
4570
4570
|
padding: '8px 16px',
|
|
4571
4571
|
backgroundColor: dataEntries.length >= maxEntries ? '#f3f4f6' : '#10b981',
|
|
4572
4572
|
color: dataEntries.length >= maxEntries ? '#9ca3af' : '#ffffff',
|
|
@@ -4688,7 +4688,7 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
|
|
|
4688
4688
|
borderRadius: '8px',
|
|
4689
4689
|
display: 'flex',
|
|
4690
4690
|
justifyContent: 'center'
|
|
4691
|
-
}, children: jsxRuntime.jsxs("button", { onClick: onAddEntry, disabled: dataEntries.length >= maxEntries, style: {
|
|
4691
|
+
}, children: jsxRuntime.jsxs("button", { onClick: () => { console.log('[TableView] Add Entry button clicked (list view)', 'entries:', dataEntries.length, 'max:', maxEntries); onAddEntry(); }, disabled: dataEntries.length >= maxEntries, style: {
|
|
4692
4692
|
padding: '8px 16px',
|
|
4693
4693
|
backgroundColor: dataEntries.length >= maxEntries ? '#f3f4f6' : '#10b981',
|
|
4694
4694
|
color: dataEntries.length >= maxEntries ? '#9ca3af' : '#ffffff',
|
|
@@ -4712,6 +4712,7 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
|
|
|
4712
4712
|
const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueChange, onSelect, isSelected = false, className = '', onDataGridSelect, onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, selectedComponent, renderFormComponent, onEntryAdd, onEntryRemove, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, shouldShowComponent }) => {
|
|
4713
4713
|
const [isCollapsed, setIsCollapsed] = React.useState(false);
|
|
4714
4714
|
const hasInitialized = React.useRef(false);
|
|
4715
|
+
const [localFormData, setLocalFormData] = React.useState(formData);
|
|
4715
4716
|
// Get all components in the grid and sanitize them to ensure no data leaks into templates
|
|
4716
4717
|
let gridComponents = (properties.templateComponents || []).map(comp => ({
|
|
4717
4718
|
...comp,
|
|
@@ -4926,8 +4927,10 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
4926
4927
|
// Handle component value change for form data updates (test mode)
|
|
4927
4928
|
const handleComponentValueChange = React.useCallback((change) => {
|
|
4928
4929
|
if (mode === 'test') {
|
|
4929
|
-
//
|
|
4930
|
-
//
|
|
4930
|
+
// CRITICAL: Update local formData immediately so the value persists in the UI
|
|
4931
|
+
// without waiting for the parent round-trip (which resets values for entry 2+)
|
|
4932
|
+
setLocalFormData(prev => ({ ...prev, [change.id]: change.value }));
|
|
4933
|
+
// Also propagate up to parent for persistence
|
|
4931
4934
|
if (onValueChange) {
|
|
4932
4935
|
onValueChange({
|
|
4933
4936
|
id: change.id,
|
|
@@ -4938,6 +4941,10 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
4938
4941
|
// In edit/preview modes, don't handle value changes as components are read-only
|
|
4939
4942
|
}, [mode, onValueChange]);
|
|
4940
4943
|
const handleAddEntry = React.useCallback(() => {
|
|
4944
|
+
console.log('[DfFormDataGrid] handleAddEntry called');
|
|
4945
|
+
console.log('[DfFormDataGrid] gridComponents:', gridComponents.length, gridComponents.map(c => c.id));
|
|
4946
|
+
console.log('[DfFormDataGrid] current entries:', properties.entries?.length);
|
|
4947
|
+
console.log('[DfFormDataGrid] onValueChange exists:', !!onValueChange);
|
|
4941
4948
|
// Use timestamp and random string to ensure uniqueness even if entries are deleted
|
|
4942
4949
|
const uniqueSuffix = `${Date.now()}-${Math.random().toString(36).substr(2, 5)}`;
|
|
4943
4950
|
const newEntryId = `entry-${uniqueSuffix}`;
|
|
@@ -4959,13 +4966,19 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
4959
4966
|
}),
|
|
4960
4967
|
styles: {}
|
|
4961
4968
|
};
|
|
4969
|
+
console.log('[DfFormDataGrid] newEntry created:', newEntry.id, 'with', newEntry.components.length, 'components');
|
|
4962
4970
|
const updatedEntries = [...properties.entries, newEntry];
|
|
4971
|
+
console.log('[DfFormDataGrid] updatedEntries count:', updatedEntries.length);
|
|
4963
4972
|
if (onValueChange) {
|
|
4973
|
+
console.log('[DfFormDataGrid] calling onValueChange with updated entries');
|
|
4964
4974
|
onValueChange({
|
|
4965
4975
|
id,
|
|
4966
4976
|
value: { ...properties, entries: updatedEntries }
|
|
4967
4977
|
});
|
|
4968
4978
|
}
|
|
4979
|
+
else {
|
|
4980
|
+
console.log('[DfFormDataGrid] WARNING: onValueChange is not defined!');
|
|
4981
|
+
}
|
|
4969
4982
|
onEntryAdd?.();
|
|
4970
4983
|
}, [properties, onValueChange, id, onEntryAdd, gridComponents]);
|
|
4971
4984
|
const handleRemoveEntry = React.useCallback((entryIndex) => {
|
|
@@ -4981,7 +4994,9 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
4981
4994
|
}, [properties, onValueChange, id, onEntryRemove]);
|
|
4982
4995
|
// Use our own render function to ensure proper onComponentUpdate handling
|
|
4983
4996
|
const renderComponent = React.useCallback((field, hideLabel = false) => {
|
|
4984
|
-
|
|
4997
|
+
// CRITICAL: Use localFormData (not formData prop) so values persist in entry 2+ immediately
|
|
4998
|
+
const effectiveFormData = { ...formData, ...localFormData };
|
|
4999
|
+
const formValue = mode === 'test' ? (effectiveFormData[field.id] ?? ('defaultValue' in field.basic ? field.basic.defaultValue || '' : '')) : ('defaultValue' in field.basic ? field.basic.defaultValue || '' : '');
|
|
4985
5000
|
const commonProps = {
|
|
4986
5001
|
id: field.id,
|
|
4987
5002
|
properties: field,
|
|
@@ -5038,7 +5053,7 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
5038
5053
|
default:
|
|
5039
5054
|
return jsxRuntime.jsxs("div", { className: "unknown-component", children: ["Unknown component: ", field.name] });
|
|
5040
5055
|
}
|
|
5041
|
-
}, [mode, handleComponentValueChange]);
|
|
5056
|
+
}, [mode, handleComponentValueChange, formData, localFormData]);
|
|
5042
5057
|
const gridStyle = {
|
|
5043
5058
|
backgroundColor: properties.styles.backgroundColor || 'var(--df-color-fb-container)',
|
|
5044
5059
|
borderColor: properties.styles.borderColor || 'var(--df-color-fb-border)',
|
|
@@ -6542,8 +6557,10 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
|
|
|
6542
6557
|
});
|
|
6543
6558
|
onFormDataChange?.(updatedComponents);
|
|
6544
6559
|
}, onValueChange: (change) => {
|
|
6560
|
+
console.log('[DfFormPreview] datagrid onValueChange received:', change.id, 'hasEntries:', change.value && typeof change.value === 'object' && 'entries' in change.value);
|
|
6545
6561
|
// Handle datagrid value changes (entries updates)
|
|
6546
6562
|
if (change.id === component.id && change.value && typeof change.value === 'object' && 'entries' in change.value) {
|
|
6563
|
+
console.log('[DfFormPreview] datagrid entries update - entries count:', change.value.entries?.length);
|
|
6547
6564
|
// Update localFormComponents with new entries structure
|
|
6548
6565
|
const updatedComponents = localFormComponents.map(comp => {
|
|
6549
6566
|
if (comp.id === component.id) {
|