df-ae-forms-package 1.0.93 → 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 +9 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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,
|
|
@@ -4991,7 +4994,9 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
4991
4994
|
}, [properties, onValueChange, id, onEntryRemove]);
|
|
4992
4995
|
// Use our own render function to ensure proper onComponentUpdate handling
|
|
4993
4996
|
const renderComponent = React.useCallback((field, hideLabel = false) => {
|
|
4994
|
-
|
|
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 || '' : '');
|
|
4995
5000
|
const commonProps = {
|
|
4996
5001
|
id: field.id,
|
|
4997
5002
|
properties: field,
|
|
@@ -5048,7 +5053,7 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
5048
5053
|
default:
|
|
5049
5054
|
return jsxRuntime.jsxs("div", { className: "unknown-component", children: ["Unknown component: ", field.name] });
|
|
5050
5055
|
}
|
|
5051
|
-
}, [mode, handleComponentValueChange]);
|
|
5056
|
+
}, [mode, handleComponentValueChange, formData, localFormData]);
|
|
5052
5057
|
const gridStyle = {
|
|
5053
5058
|
backgroundColor: properties.styles.backgroundColor || 'var(--df-color-fb-container)',
|
|
5054
5059
|
borderColor: properties.styles.borderColor || 'var(--df-color-fb-border)',
|