df-ae-forms-package 1.0.94 → 1.0.95
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 +16 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4712,7 +4712,13 @@ 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
|
-
|
|
4715
|
+
// Use a ref for localFormData so renderComponent doesn't need it in deps
|
|
4716
|
+
// This prevents DfFormInput from resetting its internal state on every keystroke
|
|
4717
|
+
const localFormDataRef = React.useRef({ ...formData });
|
|
4718
|
+
// Keep ref in sync with formData prop (parent updates), but never overwrite user-typed values
|
|
4719
|
+
React.useEffect(() => {
|
|
4720
|
+
localFormDataRef.current = { ...formData, ...localFormDataRef.current };
|
|
4721
|
+
}, [formData]);
|
|
4716
4722
|
// Get all components in the grid and sanitize them to ensure no data leaks into templates
|
|
4717
4723
|
let gridComponents = (properties.templateComponents || []).map(comp => ({
|
|
4718
4724
|
...comp,
|
|
@@ -4927,9 +4933,9 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
4927
4933
|
// Handle component value change for form data updates (test mode)
|
|
4928
4934
|
const handleComponentValueChange = React.useCallback((change) => {
|
|
4929
4935
|
if (mode === 'test') {
|
|
4930
|
-
// CRITICAL: Update
|
|
4936
|
+
// CRITICAL: Update localFormDataRef immediately so the value persists in the UI
|
|
4931
4937
|
// without waiting for the parent round-trip (which resets values for entry 2+)
|
|
4932
|
-
|
|
4938
|
+
localFormDataRef.current = { ...localFormDataRef.current, [change.id]: change.value };
|
|
4933
4939
|
// Also propagate up to parent for persistence
|
|
4934
4940
|
if (onValueChange) {
|
|
4935
4941
|
onValueChange({
|
|
@@ -4994,9 +5000,12 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
4994
5000
|
}, [properties, onValueChange, id, onEntryRemove]);
|
|
4995
5001
|
// Use our own render function to ensure proper onComponentUpdate handling
|
|
4996
5002
|
const renderComponent = React.useCallback((field, hideLabel = false) => {
|
|
4997
|
-
// CRITICAL: Use
|
|
4998
|
-
|
|
4999
|
-
const
|
|
5003
|
+
// CRITICAL: Use localFormDataRef (not formData prop) so values persist in entry 2+ immediately
|
|
5004
|
+
// Also fall back to field.basic.value which is updated by DfFormPreview's updateComponentValue after round-trip
|
|
5005
|
+
const effectiveFormData = { ...formData, ...localFormDataRef.current };
|
|
5006
|
+
const formValue = mode === 'test'
|
|
5007
|
+
? (effectiveFormData[field.id] ?? field.basic?.value ?? ('defaultValue' in field.basic ? field.basic.defaultValue || '' : ''))
|
|
5008
|
+
: ('defaultValue' in field.basic ? field.basic.defaultValue || '' : '');
|
|
5000
5009
|
const commonProps = {
|
|
5001
5010
|
id: field.id,
|
|
5002
5011
|
properties: field,
|
|
@@ -5053,7 +5062,7 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
5053
5062
|
default:
|
|
5054
5063
|
return jsxRuntime.jsxs("div", { className: "unknown-component", children: ["Unknown component: ", field.name] });
|
|
5055
5064
|
}
|
|
5056
|
-
}, [mode, handleComponentValueChange, formData
|
|
5065
|
+
}, [mode, handleComponentValueChange, formData]);
|
|
5057
5066
|
const gridStyle = {
|
|
5058
5067
|
backgroundColor: properties.styles.backgroundColor || 'var(--df-color-fb-container)',
|
|
5059
5068
|
borderColor: properties.styles.borderColor || 'var(--df-color-fb-border)',
|