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.esm.js
CHANGED
|
@@ -4710,6 +4710,7 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
|
|
|
4710
4710
|
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 }) => {
|
|
4711
4711
|
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
4712
4712
|
const hasInitialized = useRef(false);
|
|
4713
|
+
const [localFormData, setLocalFormData] = useState(formData);
|
|
4713
4714
|
// Get all components in the grid and sanitize them to ensure no data leaks into templates
|
|
4714
4715
|
let gridComponents = (properties.templateComponents || []).map(comp => ({
|
|
4715
4716
|
...comp,
|
|
@@ -4924,8 +4925,10 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
4924
4925
|
// Handle component value change for form data updates (test mode)
|
|
4925
4926
|
const handleComponentValueChange = useCallback((change) => {
|
|
4926
4927
|
if (mode === 'test') {
|
|
4927
|
-
//
|
|
4928
|
-
//
|
|
4928
|
+
// CRITICAL: Update local formData immediately so the value persists in the UI
|
|
4929
|
+
// without waiting for the parent round-trip (which resets values for entry 2+)
|
|
4930
|
+
setLocalFormData(prev => ({ ...prev, [change.id]: change.value }));
|
|
4931
|
+
// Also propagate up to parent for persistence
|
|
4929
4932
|
if (onValueChange) {
|
|
4930
4933
|
onValueChange({
|
|
4931
4934
|
id: change.id,
|
|
@@ -4989,7 +4992,9 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
4989
4992
|
}, [properties, onValueChange, id, onEntryRemove]);
|
|
4990
4993
|
// Use our own render function to ensure proper onComponentUpdate handling
|
|
4991
4994
|
const renderComponent = useCallback((field, hideLabel = false) => {
|
|
4992
|
-
|
|
4995
|
+
// CRITICAL: Use localFormData (not formData prop) so values persist in entry 2+ immediately
|
|
4996
|
+
const effectiveFormData = { ...formData, ...localFormData };
|
|
4997
|
+
const formValue = mode === 'test' ? (effectiveFormData[field.id] ?? ('defaultValue' in field.basic ? field.basic.defaultValue || '' : '')) : ('defaultValue' in field.basic ? field.basic.defaultValue || '' : '');
|
|
4993
4998
|
const commonProps = {
|
|
4994
4999
|
id: field.id,
|
|
4995
5000
|
properties: field,
|
|
@@ -5046,7 +5051,7 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
5046
5051
|
default:
|
|
5047
5052
|
return jsxs("div", { className: "unknown-component", children: ["Unknown component: ", field.name] });
|
|
5048
5053
|
}
|
|
5049
|
-
}, [mode, handleComponentValueChange]);
|
|
5054
|
+
}, [mode, handleComponentValueChange, formData, localFormData]);
|
|
5050
5055
|
const gridStyle = {
|
|
5051
5056
|
backgroundColor: properties.styles.backgroundColor || 'var(--df-color-fb-container)',
|
|
5052
5057
|
borderColor: properties.styles.borderColor || 'var(--df-color-fb-border)',
|