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 CHANGED
@@ -4564,7 +4564,7 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
4564
4564
  position: 'sticky',
4565
4565
  bottom: 0,
4566
4566
  zIndex: 5
4567
- }, children: jsxs("button", { onClick: onAddEntry, disabled: dataEntries.length >= maxEntries, style: {
4567
+ }, children: jsxs("button", { onClick: () => { console.log('[TableView] Add Entry button clicked (grid view)', 'entries:', dataEntries.length, 'max:', maxEntries); onAddEntry(); }, disabled: dataEntries.length >= maxEntries, style: {
4568
4568
  padding: '8px 16px',
4569
4569
  backgroundColor: dataEntries.length >= maxEntries ? '#f3f4f6' : '#10b981',
4570
4570
  color: dataEntries.length >= maxEntries ? '#9ca3af' : '#ffffff',
@@ -4686,7 +4686,7 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
4686
4686
  borderRadius: '8px',
4687
4687
  display: 'flex',
4688
4688
  justifyContent: 'center'
4689
- }, children: jsxs("button", { onClick: onAddEntry, disabled: dataEntries.length >= maxEntries, style: {
4689
+ }, children: jsxs("button", { onClick: () => { console.log('[TableView] Add Entry button clicked (list view)', 'entries:', dataEntries.length, 'max:', maxEntries); onAddEntry(); }, disabled: dataEntries.length >= maxEntries, style: {
4690
4690
  padding: '8px 16px',
4691
4691
  backgroundColor: dataEntries.length >= maxEntries ? '#f3f4f6' : '#10b981',
4692
4692
  color: dataEntries.length >= maxEntries ? '#9ca3af' : '#ffffff',
@@ -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
- // In test mode, update form data through the parent's onValueChange
4928
- // This allows the form data to be updated for interactive components
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,
@@ -4936,6 +4939,10 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
4936
4939
  // In edit/preview modes, don't handle value changes as components are read-only
4937
4940
  }, [mode, onValueChange]);
4938
4941
  const handleAddEntry = useCallback(() => {
4942
+ console.log('[DfFormDataGrid] handleAddEntry called');
4943
+ console.log('[DfFormDataGrid] gridComponents:', gridComponents.length, gridComponents.map(c => c.id));
4944
+ console.log('[DfFormDataGrid] current entries:', properties.entries?.length);
4945
+ console.log('[DfFormDataGrid] onValueChange exists:', !!onValueChange);
4939
4946
  // Use timestamp and random string to ensure uniqueness even if entries are deleted
4940
4947
  const uniqueSuffix = `${Date.now()}-${Math.random().toString(36).substr(2, 5)}`;
4941
4948
  const newEntryId = `entry-${uniqueSuffix}`;
@@ -4957,13 +4964,19 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
4957
4964
  }),
4958
4965
  styles: {}
4959
4966
  };
4967
+ console.log('[DfFormDataGrid] newEntry created:', newEntry.id, 'with', newEntry.components.length, 'components');
4960
4968
  const updatedEntries = [...properties.entries, newEntry];
4969
+ console.log('[DfFormDataGrid] updatedEntries count:', updatedEntries.length);
4961
4970
  if (onValueChange) {
4971
+ console.log('[DfFormDataGrid] calling onValueChange with updated entries');
4962
4972
  onValueChange({
4963
4973
  id,
4964
4974
  value: { ...properties, entries: updatedEntries }
4965
4975
  });
4966
4976
  }
4977
+ else {
4978
+ console.log('[DfFormDataGrid] WARNING: onValueChange is not defined!');
4979
+ }
4967
4980
  onEntryAdd?.();
4968
4981
  }, [properties, onValueChange, id, onEntryAdd, gridComponents]);
4969
4982
  const handleRemoveEntry = useCallback((entryIndex) => {
@@ -4979,7 +4992,9 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
4979
4992
  }, [properties, onValueChange, id, onEntryRemove]);
4980
4993
  // Use our own render function to ensure proper onComponentUpdate handling
4981
4994
  const renderComponent = useCallback((field, hideLabel = false) => {
4982
- const formValue = mode === 'test' ? (formData[field.id] || ('defaultValue' in field.basic ? field.basic.defaultValue || '' : '')) : ('defaultValue' in field.basic ? field.basic.defaultValue || '' : '');
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 || '' : '');
4983
4998
  const commonProps = {
4984
4999
  id: field.id,
4985
5000
  properties: field,
@@ -5036,7 +5051,7 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
5036
5051
  default:
5037
5052
  return jsxs("div", { className: "unknown-component", children: ["Unknown component: ", field.name] });
5038
5053
  }
5039
- }, [mode, handleComponentValueChange]);
5054
+ }, [mode, handleComponentValueChange, formData, localFormData]);
5040
5055
  const gridStyle = {
5041
5056
  backgroundColor: properties.styles.backgroundColor || 'var(--df-color-fb-container)',
5042
5057
  borderColor: properties.styles.borderColor || 'var(--df-color-fb-border)',
@@ -6540,8 +6555,10 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6540
6555
  });
6541
6556
  onFormDataChange?.(updatedComponents);
6542
6557
  }, onValueChange: (change) => {
6558
+ console.log('[DfFormPreview] datagrid onValueChange received:', change.id, 'hasEntries:', change.value && typeof change.value === 'object' && 'entries' in change.value);
6543
6559
  // Handle datagrid value changes (entries updates)
6544
6560
  if (change.id === component.id && change.value && typeof change.value === 'object' && 'entries' in change.value) {
6561
+ console.log('[DfFormPreview] datagrid entries update - entries count:', change.value.entries?.length);
6545
6562
  // Update localFormComponents with new entries structure
6546
6563
  const updatedComponents = localFormComponents.map(comp => {
6547
6564
  if (comp.id === component.id) {