df-ae-forms-package 1.0.97 → 1.0.98
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.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +16 -5
- package/dist/index.esm.js +58 -101
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +56 -99
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -716,27 +716,38 @@ declare const DfFormSection: React.FC<DfFormSectionProps>;
|
|
|
716
716
|
interface DfFormDataGridProps {
|
|
717
717
|
id: string;
|
|
718
718
|
properties: IDataGridComponent;
|
|
719
|
+
validationErrors?: Record<string, any>;
|
|
720
|
+
formValue?: any;
|
|
721
|
+
formData?: Record<string, any>;
|
|
722
|
+
readonly?: boolean;
|
|
723
|
+
disabled?: boolean;
|
|
724
|
+
touchedFields?: Record<string, boolean>;
|
|
725
|
+
formSubmitted?: boolean;
|
|
719
726
|
mode?: 'edit' | 'preview' | 'test';
|
|
720
|
-
formData?: any;
|
|
721
727
|
onValueChange?: (change: IFormControlChange) => void;
|
|
728
|
+
onBlur?: () => void;
|
|
729
|
+
onFocus?: () => void;
|
|
722
730
|
onSelect?: () => void;
|
|
723
731
|
isSelected?: boolean;
|
|
724
732
|
className?: string;
|
|
725
|
-
onDataGridSelect?: (
|
|
733
|
+
onDataGridSelect?: (dataGrid: IDataGridComponent) => void;
|
|
734
|
+
onDataGridDelete?: (dataGridId: string) => void;
|
|
735
|
+
onEntryChange?: (entryIndex: number, components: FormComponentType[]) => void;
|
|
726
736
|
onComponentSelect?: (component: FormComponentType) => void;
|
|
727
737
|
onComponentDelete?: (component: FormComponentType, event: React.MouseEvent) => void;
|
|
728
738
|
onComponentEdit?: (component: FormComponentType) => void;
|
|
729
739
|
onComponentUpdate?: (componentId: string, updates: Partial<FormComponentType>) => void;
|
|
730
740
|
selectedComponent?: FormComponentType | null;
|
|
731
|
-
renderFormComponent?: (
|
|
741
|
+
renderFormComponent?: (field: FormComponentType, hideLabel?: boolean) => React.ReactNode;
|
|
742
|
+
onDataGridUpdate?: (dataGridId: string, updates: Partial<IDataGridComponent>) => void;
|
|
732
743
|
onEntryAdd?: () => void;
|
|
733
|
-
onEntryRemove?: (
|
|
744
|
+
onEntryRemove?: (entryIndex: number) => void;
|
|
734
745
|
formTemplateId?: string;
|
|
735
746
|
onThresholdActionCompletion?: (conditionId: string, action: 'notes' | 'attachments' | 'email', completed: boolean) => void;
|
|
736
747
|
onThresholdIssueRaised?: (conditionId: string) => void;
|
|
737
748
|
onNotesChange?: (componentId: string, notes: string) => void;
|
|
738
749
|
onAttachmentChange?: (componentId: string, attachments: File[] | null) => void;
|
|
739
|
-
shouldShowComponent?: (
|
|
750
|
+
shouldShowComponent?: (id: string) => boolean;
|
|
740
751
|
}
|
|
741
752
|
declare const DfFormDataGrid: React.FC<DfFormDataGridProps>;
|
|
742
753
|
|
package/dist/index.esm.js
CHANGED
|
@@ -2,8 +2,8 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import React, { useState, useEffect, useCallback, useRef, useMemo } from 'react';
|
|
3
3
|
import { AlertTriangle, X as X$1, User, Calendar, MessageSquare, UploadCloud, Paperclip, Loader2, Navigation, MapPin, Bold, Italic, List, ListOrdered, Image as Image$1, Check, Mail, AlertCircle, ChevronUp, ChevronDown, ChevronRight, Grid, GripVertical, Edit, Trash2, Table } from 'lucide-react';
|
|
4
4
|
import require$$0, { createPortal } from 'react-dom';
|
|
5
|
-
import { useDroppable
|
|
6
|
-
import {
|
|
5
|
+
import { useDroppable } from '@dnd-kit/core';
|
|
6
|
+
import { SortableContext, horizontalListSortingStrategy, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
7
7
|
import { CSS } from '@dnd-kit/utilities';
|
|
8
8
|
import { v4 } from 'uuid';
|
|
9
9
|
|
|
@@ -4332,57 +4332,20 @@ const DraggableGridComponent = ({ component, selectedComponent, mode, onComponen
|
|
|
4332
4332
|
e.currentTarget.style.backgroundColor = '#ef4444';
|
|
4333
4333
|
}, children: jsx(Trash2, { size: 12 }) })] }))] }));
|
|
4334
4334
|
};
|
|
4335
|
-
|
|
4336
|
-
const GridDropZone = ({ gridComponents, mode, onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, selectedComponent, renderFormComponent, gridId, formData, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, columnView, shouldShowComponent }) => {
|
|
4335
|
+
const GridDropZone = ({ gridComponents, mode, onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, selectedComponent, renderFormComponent, gridId, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, columnView = false, shouldShowComponent }) => {
|
|
4337
4336
|
const { setNodeRef, isOver } = useDroppable({
|
|
4338
4337
|
id: `grid-drop-zone-${gridId}`,
|
|
4339
|
-
disabled: mode !== 'edit'
|
|
4340
|
-
data: {
|
|
4341
|
-
isGridDropZone: true,
|
|
4342
|
-
gridId: gridId
|
|
4343
|
-
}
|
|
4344
|
-
});
|
|
4345
|
-
// Sensors for drag and drop
|
|
4346
|
-
const sensors = useSensors(useSensor(PointerSensor, {
|
|
4347
|
-
activationConstraint: {
|
|
4348
|
-
distance: 8,
|
|
4349
|
-
},
|
|
4350
|
-
}), useSensor(KeyboardSensor, {
|
|
4351
|
-
coordinateGetter: sortableKeyboardCoordinates,
|
|
4352
|
-
}));
|
|
4353
|
-
const handleDragEnd = ((event) => {
|
|
4354
|
-
const { active, over } = event;
|
|
4355
|
-
if (over && active.id !== over.id) {
|
|
4356
|
-
gridComponents.findIndex((item) => item.id === active.id);
|
|
4357
|
-
gridComponents.findIndex((item) => item.id === over.id);
|
|
4358
|
-
}
|
|
4338
|
+
disabled: mode !== 'edit'
|
|
4359
4339
|
});
|
|
4360
|
-
return (jsx("div", { ref: setNodeRef, className:
|
|
4361
|
-
border: isOver ? '2px dashed #3b82f6' : '
|
|
4340
|
+
return (jsx("div", { ref: setNodeRef, className: "grid-drop-zone", style: {
|
|
4341
|
+
border: isOver ? '2px dashed #3b82f6' : '2px dashed #d1d5db',
|
|
4362
4342
|
borderRadius: '8px',
|
|
4363
4343
|
padding: '16px',
|
|
4364
|
-
backgroundColor: isOver ? 'var(--df-color-primary-light)' : '
|
|
4365
|
-
minHeight: '
|
|
4366
|
-
transition: 'all 0.2s ease'
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
color: 'var(--df-color-text-light)',
|
|
4370
|
-
fontSize: '14px',
|
|
4371
|
-
padding: '40px 20px',
|
|
4372
|
-
display: 'flex',
|
|
4373
|
-
flexDirection: 'column',
|
|
4374
|
-
alignItems: 'center',
|
|
4375
|
-
gap: '8px',
|
|
4376
|
-
backgroundColor: 'var(--df-color-fb-container)',
|
|
4377
|
-
border: '1px dashed var(--df-color-fb-border)',
|
|
4378
|
-
borderRadius: '8px'
|
|
4379
|
-
}, children: [jsx("div", { style: {
|
|
4380
|
-
fontWeight: '500',
|
|
4381
|
-
color: isOver ? 'var(--df-color-primary)' : 'var(--df-color-text-dark)'
|
|
4382
|
-
}, children: isOver ? 'Drop components here' : 'Empty DataGrid' }), jsx("div", { style: {
|
|
4383
|
-
fontSize: '12px',
|
|
4384
|
-
color: '#9ca3af'
|
|
4385
|
-
}, children: "Drag and drop components here to create your grid" })] })) : (jsxs(DndContext, { sensors: sensors, onDragEnd: handleDragEnd, children: [jsx(SortableContext, { items: gridComponents.map(c => c.id), strategy: columnView ? verticalListSortingStrategy : horizontalListSortingStrategy, children: jsx("div", { style: {
|
|
4344
|
+
backgroundColor: isOver ? 'var(--df-color-primary-light)' : 'var(--df-color-fb-container)',
|
|
4345
|
+
minHeight: '120px',
|
|
4346
|
+
transition: 'all 0.2s ease',
|
|
4347
|
+
position: 'relative'
|
|
4348
|
+
}, children: gridComponents.length > 0 ? (jsxs(Fragment, { children: [jsx(SortableContext, { items: gridComponents.map(c => c.id), strategy: horizontalListSortingStrategy, children: jsx("div", { style: {
|
|
4386
4349
|
display: 'flex',
|
|
4387
4350
|
flexDirection: columnView ? 'column' : 'row',
|
|
4388
4351
|
flexWrap: 'nowrap',
|
|
@@ -4407,14 +4370,28 @@ const GridDropZone = ({ gridComponents, mode, onComponentSelect, onComponentDele
|
|
|
4407
4370
|
minHeight: '40px',
|
|
4408
4371
|
display: 'flex',
|
|
4409
4372
|
alignItems: 'center',
|
|
4410
|
-
justifyContent: 'center'
|
|
4411
|
-
|
|
4412
|
-
|
|
4373
|
+
justifyContent: 'center'
|
|
4374
|
+
}, children: isOver ? (jsx("span", { style: { color: '#3b82f6', fontWeight: '500' }, children: "Drop component here to add to grid" })) : (jsx("span", { children: "+ Drop more components here" })) })] })) : (jsxs("div", { style: {
|
|
4375
|
+
textAlign: 'center',
|
|
4376
|
+
color: 'var(--df-color-text-light)',
|
|
4377
|
+
fontSize: '14px',
|
|
4378
|
+
padding: '40px 20px',
|
|
4379
|
+
display: 'flex',
|
|
4380
|
+
flexDirection: 'column',
|
|
4381
|
+
alignItems: 'center',
|
|
4382
|
+
gap: '8px',
|
|
4383
|
+
backgroundColor: 'var(--df-color-fb-container)',
|
|
4384
|
+
border: '1px dashed var(--df-color-fb-border)',
|
|
4385
|
+
borderRadius: '8px'
|
|
4386
|
+
}, children: [jsx("div", { style: {
|
|
4387
|
+
fontWeight: '500',
|
|
4388
|
+
color: isOver ? 'var(--df-color-primary)' : 'var(--df-color-text-dark)'
|
|
4389
|
+
}, children: isOver ? 'Drop components here' : 'Empty DataGrid' }), jsx("div", { style: {
|
|
4390
|
+
fontSize: '12px',
|
|
4391
|
+
color: '#9ca3af'
|
|
4392
|
+
}, children: "Drag and drop components here to create your grid" })] })) }));
|
|
4413
4393
|
};
|
|
4414
|
-
|
|
4415
|
-
const TableView = ({ templateComponents, dataEntries, renderFormComponent, mode, allowAddRemoveEntries, addAnotherText, removeText, maxEntries, minEntries, displayAsGrid = true, onAddEntry, onRemoveEntry, formData, // Use current formData to render values
|
|
4416
|
-
formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, columnView, shouldShowComponent }) => {
|
|
4417
|
-
const _formData = formData || {};
|
|
4394
|
+
const TableView = ({ templateComponents, dataEntries, renderFormComponent, mode = 'preview', allowAddRemoveEntries = true, addAnotherText = 'Add Another', removeText = 'Remove', maxEntries = 10, minEntries = 1, displayAsGrid = true, onAddEntry, onRemoveEntry, formData: _formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, columnView = false, shouldShowComponent }) => {
|
|
4418
4395
|
const visibleTemplateComponents = React.useMemo(() => {
|
|
4419
4396
|
if (!shouldShowComponent)
|
|
4420
4397
|
return templateComponents;
|
|
@@ -4476,18 +4453,16 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
|
|
|
4476
4453
|
whiteSpace: 'nowrap',
|
|
4477
4454
|
overflow: 'hidden',
|
|
4478
4455
|
textOverflow: 'ellipsis'
|
|
4479
|
-
}, children: component.basic?.label || `Column ${index + 1}` }, `header-${component.id
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
: undefined,
|
|
4456
|
+
}, children: component.basic?.label || `Column ${index + 1}` }, `header-${component.id}`))) })), dataEntries.length > 0 ? (dataEntries.map((entry, entryIndex) => (jsxs("div", { className: "table-row", style: {
|
|
4457
|
+
display: 'grid',
|
|
4458
|
+
// Change grid columns to 1fr for column view
|
|
4459
|
+
gridTemplateColumns: columnView
|
|
4460
|
+
? '1fr'
|
|
4461
|
+
: `repeat(${visibleTemplateComponents.length}, minmax(150px, 1fr))`,
|
|
4486
4462
|
borderBottom: entryIndex < dataEntries.length - 1 ? '1px solid var(--df-color-fb-border)' : 'none',
|
|
4487
4463
|
backgroundColor: entryIndex % 2 === 0 ? 'var(--df-color-fb-container)' : 'var(--df-color-fb-bg)',
|
|
4488
4464
|
position: 'relative',
|
|
4489
|
-
minWidth: columnView ? '100%' : `${visibleTemplateComponents.length * 150}px
|
|
4490
|
-
padding: columnView ? '16px' : '0'
|
|
4465
|
+
minWidth: columnView ? '100%' : `${visibleTemplateComponents.length * 150}px`
|
|
4491
4466
|
}, children: [visibleTemplateComponents.map((templateComponent, componentIndex) => {
|
|
4492
4467
|
let entryComponent = entry.components?.[componentIndex];
|
|
4493
4468
|
if (!entryComponent) {
|
|
@@ -4513,24 +4488,21 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
|
|
|
4513
4488
|
};
|
|
4514
4489
|
}
|
|
4515
4490
|
return (jsx("div", { style: {
|
|
4516
|
-
padding:
|
|
4491
|
+
padding: '12px 16px',
|
|
4517
4492
|
borderRight: !columnView && componentIndex < visibleTemplateComponents.length - 1 ? '1px solid var(--df-color-fb-border)' : 'none',
|
|
4518
4493
|
// Add bottom border for fields in column view except the last one
|
|
4519
4494
|
borderBottom: columnView && componentIndex < visibleTemplateComponents.length - 1 ? '1px dashed var(--df-color-fb-border)' : 'none',
|
|
4520
|
-
minHeight:
|
|
4495
|
+
minHeight: '60px',
|
|
4521
4496
|
minWidth: columnView ? '100%' : '150px',
|
|
4522
|
-
width: columnView ? '100%' : 'auto',
|
|
4523
4497
|
display: 'flex',
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
overflow: 'hidden',
|
|
4527
|
-
gap: columnView ? '8px' : '0'
|
|
4498
|
+
alignItems: 'center',
|
|
4499
|
+
overflow: 'hidden'
|
|
4528
4500
|
}, children: jsx("div", { style: {
|
|
4529
4501
|
width: '100%',
|
|
4530
|
-
minWidth:
|
|
4502
|
+
minWidth: '120px',
|
|
4531
4503
|
overflow: 'hidden'
|
|
4532
4504
|
}, children: renderFormComponent(entryComponent, !columnView) }) }, `${entry.id}-${componentIndex}`));
|
|
4533
|
-
}), mode === 'test' && allowAddRemoveEntries && dataEntries.length > minEntries && (jsx("button", { onClick: () => onRemoveEntry(entryIndex), disabled: dataEntries.length <= minEntries, style: {
|
|
4505
|
+
}), mode === 'test' && allowAddRemoveEntries && dataEntries.length > minEntries && (jsx("button", { onClick: () => onRemoveEntry?.(entryIndex), disabled: dataEntries.length <= minEntries, style: {
|
|
4534
4506
|
position: 'absolute',
|
|
4535
4507
|
top: '8px',
|
|
4536
4508
|
right: '8px',
|
|
@@ -4564,7 +4536,7 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
|
|
|
4564
4536
|
position: 'sticky',
|
|
4565
4537
|
bottom: 0,
|
|
4566
4538
|
zIndex: 5
|
|
4567
|
-
}, children: jsxs("button", { onClick:
|
|
4539
|
+
}, children: jsxs("button", { onClick: onAddEntry, disabled: dataEntries.length >= maxEntries, style: {
|
|
4568
4540
|
padding: '8px 16px',
|
|
4569
4541
|
backgroundColor: dataEntries.length >= maxEntries ? '#f3f4f6' : '#10b981',
|
|
4570
4542
|
color: dataEntries.length >= maxEntries ? '#9ca3af' : '#ffffff',
|
|
@@ -4602,7 +4574,7 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
|
|
|
4602
4574
|
fontWeight: '600',
|
|
4603
4575
|
color: 'var(--df-color-text-dark)',
|
|
4604
4576
|
fontSize: '14px'
|
|
4605
|
-
}, children: ["Entry #", entryIndex + 1] }), mode === 'test' && allowAddRemoveEntries && dataEntries.length > 1 && (jsx("button", { onClick: () => onRemoveEntry(entryIndex), disabled: dataEntries.length <= minEntries, style: {
|
|
4577
|
+
}, children: ["Entry #", entryIndex + 1] }), mode === 'test' && allowAddRemoveEntries && dataEntries.length > 1 && (jsx("button", { onClick: () => onRemoveEntry?.(entryIndex), disabled: dataEntries.length <= minEntries, style: {
|
|
4606
4578
|
padding: '4px 8px',
|
|
4607
4579
|
backgroundColor: dataEntries.length <= minEntries ? '#f3f4f6' : '#ef4444',
|
|
4608
4580
|
color: dataEntries.length <= minEntries ? '#9ca3af' : '#ffffff',
|
|
@@ -4618,39 +4590,40 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
|
|
|
4618
4590
|
height: '24px',
|
|
4619
4591
|
justifyContent: 'center'
|
|
4620
4592
|
}, title: removeText, children: jsx("span", { style: { fontSize: '14px' }, children: "\u00D7" }) }))] }), jsx("div", { style: {
|
|
4621
|
-
display:
|
|
4622
|
-
|
|
4623
|
-
gridTemplateColumns: !columnView ? 'repeat(auto-fit, minmax(200px, 1fr))' : undefined,
|
|
4593
|
+
display: 'grid',
|
|
4594
|
+
gridTemplateColumns: columnView ? '1fr' : 'repeat(auto-fit, minmax(200px, 1fr))',
|
|
4624
4595
|
gap: '16px'
|
|
4625
4596
|
}, children: visibleTemplateComponents.map((templateComponent, componentIndex) => {
|
|
4597
|
+
// Find the corresponding component in this entry by index first, then by name+label
|
|
4626
4598
|
let entryComponent = entry.components?.[componentIndex];
|
|
4599
|
+
// If no component at this index, try to find by name+label
|
|
4627
4600
|
if (!entryComponent) {
|
|
4628
4601
|
entryComponent = entry.components?.find((comp) => comp.name === templateComponent.name &&
|
|
4629
4602
|
comp.basic?.label === templateComponent.basic?.label);
|
|
4630
4603
|
}
|
|
4631
4604
|
if (!entryComponent) {
|
|
4605
|
+
// Use entry.id (which is unique) instead of entryIndex
|
|
4632
4606
|
const uniqueId = `${templateComponent.id}-${entry.id}-${componentIndex}`;
|
|
4633
4607
|
entryComponent = {
|
|
4634
4608
|
...templateComponent,
|
|
4635
4609
|
id: uniqueId,
|
|
4636
4610
|
basic: {
|
|
4637
4611
|
...templateComponent.basic,
|
|
4638
|
-
showLabel:
|
|
4612
|
+
showLabel: false // Hide label in datagrid cells
|
|
4639
4613
|
}
|
|
4640
4614
|
};
|
|
4641
4615
|
}
|
|
4642
4616
|
else {
|
|
4617
|
+
// Preserve the original ID to maintain form value connections
|
|
4643
4618
|
entryComponent = {
|
|
4644
4619
|
...entryComponent,
|
|
4645
|
-
id: entryComponent.id,
|
|
4620
|
+
id: entryComponent.id, // Keep the original ID
|
|
4646
4621
|
basic: {
|
|
4647
4622
|
...entryComponent.basic,
|
|
4648
|
-
showLabel:
|
|
4623
|
+
showLabel: false // Hide label in datagrid cells
|
|
4649
4624
|
}
|
|
4650
4625
|
};
|
|
4651
4626
|
}
|
|
4652
|
-
if (!entryComponent)
|
|
4653
|
-
return null;
|
|
4654
4627
|
return (jsxs("div", { style: {
|
|
4655
4628
|
display: 'flex',
|
|
4656
4629
|
flexDirection: 'column',
|
|
@@ -4686,7 +4659,7 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
|
|
|
4686
4659
|
borderRadius: '8px',
|
|
4687
4660
|
display: 'flex',
|
|
4688
4661
|
justifyContent: 'center'
|
|
4689
|
-
}, children: jsxs("button", { onClick:
|
|
4662
|
+
}, children: jsxs("button", { onClick: onAddEntry, disabled: dataEntries.length >= maxEntries, style: {
|
|
4690
4663
|
padding: '8px 16px',
|
|
4691
4664
|
backgroundColor: dataEntries.length >= maxEntries ? '#f3f4f6' : '#10b981',
|
|
4692
4665
|
color: dataEntries.length >= maxEntries ? '#9ca3af' : '#ffffff',
|
|
@@ -4699,12 +4672,6 @@ formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChan
|
|
|
4699
4672
|
alignItems: 'center',
|
|
4700
4673
|
gap: '8px',
|
|
4701
4674
|
transition: 'all 0.2s ease'
|
|
4702
|
-
}, onMouseEnter: (e) => {
|
|
4703
|
-
if (dataEntries.length < maxEntries) {
|
|
4704
|
-
e.currentTarget.style.backgroundColor = '#059669';
|
|
4705
|
-
}
|
|
4706
|
-
}, onMouseLeave: (e) => {
|
|
4707
|
-
e.currentTarget.style.backgroundColor = '#10b981';
|
|
4708
4675
|
}, children: [jsx("span", { children: "+" }), addAnotherText] }) }))] }));
|
|
4709
4676
|
};
|
|
4710
4677
|
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 }) => {
|
|
@@ -4936,10 +4903,6 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
4936
4903
|
// In edit/preview modes, don't handle value changes as components are read-only
|
|
4937
4904
|
}, [mode, onValueChange]);
|
|
4938
4905
|
const handleAddEntry = useCallback(() => {
|
|
4939
|
-
console.log('[DfFormDataGrid] handleAddEntry called');
|
|
4940
|
-
console.log('[DfFormDataGrid] gridComponents:', gridComponents.length, gridComponents.map(c => c.id));
|
|
4941
|
-
console.log('[DfFormDataGrid] current entries:', properties.entries?.length);
|
|
4942
|
-
console.log('[DfFormDataGrid] onValueChange exists:', !!onValueChange);
|
|
4943
4906
|
// Use timestamp and random string to ensure uniqueness even if entries are deleted
|
|
4944
4907
|
const uniqueSuffix = `${Date.now()}-${Math.random().toString(36).substr(2, 5)}`;
|
|
4945
4908
|
const newEntryId = `entry-${uniqueSuffix}`;
|
|
@@ -4961,19 +4924,13 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
4961
4924
|
}),
|
|
4962
4925
|
styles: {}
|
|
4963
4926
|
};
|
|
4964
|
-
console.log('[DfFormDataGrid] newEntry created:', newEntry.id, 'with', newEntry.components.length, 'components');
|
|
4965
4927
|
const updatedEntries = [...properties.entries, newEntry];
|
|
4966
|
-
console.log('[DfFormDataGrid] updatedEntries count:', updatedEntries.length);
|
|
4967
4928
|
if (onValueChange) {
|
|
4968
|
-
console.log('[DfFormDataGrid] calling onValueChange with updated entries');
|
|
4969
4929
|
onValueChange({
|
|
4970
4930
|
id,
|
|
4971
4931
|
value: { ...properties, entries: updatedEntries }
|
|
4972
4932
|
});
|
|
4973
4933
|
}
|
|
4974
|
-
else {
|
|
4975
|
-
console.log('[DfFormDataGrid] WARNING: onValueChange is not defined!');
|
|
4976
|
-
}
|
|
4977
4934
|
onEntryAdd?.();
|
|
4978
4935
|
}, [properties, onValueChange, id, onEntryAdd, gridComponents]);
|
|
4979
4936
|
const handleRemoveEntry = useCallback((entryIndex) => {
|
|
@@ -5070,7 +5027,7 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
5070
5027
|
, {
|
|
5071
5028
|
// Cast to FormComponentType[] to satisfy TableView typing; gridComponents
|
|
5072
5029
|
// are always child form components of the datagrid.
|
|
5073
|
-
templateComponents: gridComponents, dataEntries: dataEntries, renderFormComponent: renderFormComponent || renderComponent, mode: mode, allowAddRemoveEntries: properties.datagrid?.allowAddRemoveEntries ?? true, addAnotherText: properties.datagrid?.addAnotherText ?? 'Add Entry', removeText: properties.datagrid?.removeText ?? 'Remove', maxEntries: properties.datagrid?.maxEntries ?? 10, minEntries: properties.datagrid?.minEntries ?? 1, displayAsGrid: properties.datagrid?.displayAsGrid ?? true, onAddEntry: handleAddEntry, onRemoveEntry: handleRemoveEntry, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, columnView: properties.datagrid?.columnView, shouldShowComponent: shouldShowComponent })) }))] }));
|
|
5030
|
+
templateComponents: gridComponents, dataEntries: dataEntries, renderFormComponent: renderFormComponent || renderComponent, mode: mode, allowAddRemoveEntries: properties.datagrid?.allowAddRemoveEntries ?? true, addAnotherText: properties.datagrid?.addAnotherText ?? 'Add Entry', removeText: properties.datagrid?.removeText ?? 'Remove', maxEntries: properties.datagrid?.maxEntries ?? 10, minEntries: properties.datagrid?.minEntries ?? 1, displayAsGrid: properties.datagrid?.displayAsGrid ?? true, onAddEntry: onEntryAdd ? onEntryAdd : handleAddEntry, onRemoveEntry: onEntryRemove ? onEntryRemove : handleRemoveEntry, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, columnView: properties.datagrid?.columnView, shouldShowComponent: shouldShowComponent })) }))] }));
|
|
5074
5031
|
};
|
|
5075
5032
|
|
|
5076
5033
|
const DraggableChild = ({ child, selectedChild, mode, onChildSelect, onChildDelete, renderFormComponent, isOverlay = false, isChildrenEditMode = false, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue }) => {
|