df-ae-forms-package 1.1.6 → 1.1.8

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.d.ts CHANGED
@@ -423,6 +423,8 @@ interface DfFormPreviewProps {
423
423
  };
424
424
  onCreateIssue?: (issueData: any, attachments: File[]) => Promise<any>;
425
425
  onUpdateIssue?: (issueId: string, updateData: any) => Promise<void>;
426
+ allowWorkflowActions?: boolean;
427
+ inEditMode?: boolean;
426
428
  }
427
429
  declare const DfFormPreview: React.FC<DfFormPreviewProps>;
428
430
 
@@ -451,6 +453,8 @@ interface DfFormInputProps {
451
453
  firstName?: string;
452
454
  lastName?: string;
453
455
  };
456
+ allowWorkflowActions?: boolean;
457
+ inEditMode?: boolean;
454
458
  }
455
459
  declare const DfFormInput: React.FC<DfFormInputProps>;
456
460
 
@@ -710,6 +714,8 @@ interface DfFormSectionProps {
710
714
  };
711
715
  onCreateIssue?: (issueData: any, attachments: File[]) => Promise<any>;
712
716
  onUpdateIssue?: (issueId: string, updateData: any) => Promise<void>;
717
+ allowWorkflowActions?: boolean;
718
+ inEditMode?: boolean;
713
719
  }
714
720
  declare const DfFormSection: React.FC<DfFormSectionProps>;
715
721
 
@@ -785,6 +791,8 @@ interface DfFormTableProps {
785
791
  };
786
792
  onCreateIssue?: (issueData: any, attachments: File[]) => Promise<any>;
787
793
  onUpdateIssue?: (issueId: string, updateData: any) => Promise<void>;
794
+ allowWorkflowActions?: boolean;
795
+ inEditMode?: boolean;
788
796
  }
789
797
  declare const DfFormTable: React.FC<DfFormTableProps>;
790
798
 
@@ -810,6 +818,8 @@ interface IComponentActionFeaturesProps {
810
818
  };
811
819
  onCreateIssue?: (issueData: any, attachments: File[]) => Promise<any>;
812
820
  onUpdateIssue?: (issueId: string, updateData: any) => Promise<void>;
821
+ allowWorkflowActions?: boolean;
822
+ inEditMode?: boolean;
813
823
  }
814
824
  declare const ComponentActionFeatures: React.FC<IComponentActionFeaturesProps>;
815
825
 
@@ -834,6 +844,8 @@ interface IThresholdAlertProps {
834
844
  onIssueRaised?: (conditionId: string) => void;
835
845
  isIssueRaised?: boolean;
836
846
  compact?: boolean;
847
+ allowWorkflowActions?: boolean;
848
+ inEditMode?: boolean;
837
849
  }
838
850
  declare const ThresholdAlert: React.FC<IThresholdAlertProps>;
839
851
 
@@ -875,6 +887,7 @@ interface IRaiseIssueModalProps {
875
887
  assetNumber?: string;
876
888
  isStandalone?: boolean;
877
889
  allowWorkflowActions?: boolean;
890
+ inEditMode?: boolean;
878
891
  isEdit?: boolean;
879
892
  }
880
893
  declare const RaiseIssueModal: React.FC<IRaiseIssueModalProps>;
package/dist/index.esm.js CHANGED
@@ -332,10 +332,7 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
332
332
  'Maria Garcia',
333
333
  'John Smith',
334
334
  'Sarah Johnson'
335
- ], workOrderNumber: initialWorkOrderNumber, assetNumber: initialAssetNumber, isStandalone, isEdit }) => {
336
- // Determine if workflow actions should be enabled
337
- // If explicitly provided, use that. Otherwise, default to isEdit (true if editing, false/undefined otherwise).
338
- // Fallback to false if neither is provided.
335
+ ], workOrderNumber: initialWorkOrderNumber, assetNumber: initialAssetNumber, isStandalone, allowWorkflowActions, inEditMode = false, isEdit }) => {
339
336
  const [title, setTitle] = useState('');
340
337
  const [description, setDescription] = useState('');
341
338
  const [workOrderNumber, setWorkOrderNumber] = useState('');
@@ -348,8 +345,14 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
348
345
  // State to hold both File objects and existing attachments
349
346
  const [localAttachments, setLocalAttachments] = useState(attachments || []);
350
347
  const [isDragging, setIsDragging] = useState(false);
348
+ const [isViewMode, setIsViewMode] = useState(!!issue && !inEditMode);
351
349
  const fileInputRef = React.useRef(null);
352
350
  const isEditMode = isEdit !== undefined ? isEdit : !!issue;
351
+ // Determine if workflow actions should be enabled
352
+ // If explicitly provided, use that. Otherwise, default to showing them if we have an existing issue.
353
+ const showWorkflowActions = allowWorkflowActions !== undefined
354
+ ? allowWorkflowActions
355
+ : !!issue;
353
356
  useEffect(() => {
354
357
  if (isOpen) {
355
358
  // In edit mode, prioritize issue attachments from API
@@ -369,6 +372,11 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
369
372
  }
370
373
  }
371
374
  }, [isOpen, attachments, issue, isEditMode]);
375
+ useEffect(() => {
376
+ if (issue) {
377
+ setIsViewMode(!inEditMode);
378
+ }
379
+ }, [issue, inEditMode]);
372
380
  const handleFileChange = (event) => {
373
381
  if (event.target.files && event.target.files.length > 0) {
374
382
  const newFiles = Array.from(event.target.files);
@@ -585,6 +593,7 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
585
593
  await onUpdateIssue(issue._id, updateData);
586
594
  }
587
595
  toastService.showSuccess('Issue updated successfully');
596
+ setIsViewMode(true);
588
597
  if (onSuccess) {
589
598
  onSuccess();
590
599
  }
@@ -666,7 +675,7 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
666
675
  if (!isOpen) {
667
676
  return null;
668
677
  }
669
- const modalContent = (jsx("div", { className: "raise-issue-modal-overlay", onClick: onClose, children: jsxs("div", { className: "raise-issue-modal", onClick: (e) => e.stopPropagation(), children: [jsxs("div", { className: "raise-issue-modal-header", children: [jsxs("div", { className: "raise-issue-modal-header-left", children: [jsx(AlertTriangle, { className: "raise-issue-modal-icon", size: 20 }), jsx("div", { className: "raise-issue-modal-header-text", children: jsx("div", { className: "raise-issue-modal-title-main", children: isEditMode ? 'Issue Details' : 'Create Issue' }) })] }), jsx("button", { className: "raise-issue-modal-close", onClick: onClose, "aria-label": "Close", children: jsx(X$1, { size: 18 }) })] }), jsx("div", { className: "raise-issue-modal-content", children: jsxs("div", { className: "raise-issue-fields-grid", children: [isEditMode && issue?.issueNumber && (jsxs("div", { className: "raise-issue-field", children: [jsx("label", { className: "raise-issue-field-label", children: "Issue ID" }), jsx("input", { type: "text", className: "raise-issue-field-input raise-issue-field-readonly", value: issue.issueNumber, readOnly: true })] })), jsxs("div", { className: "raise-issue-field", children: [jsx("label", { className: "raise-issue-field-label", children: "Task" }), jsx("input", { type: "text", className: "raise-issue-field-input raise-issue-field-readonly", value: isEditMode ? (issue?.component?.basic?.label || '') : (component?.basic?.label || ''), readOnly: true })] }), jsxs("div", { className: "raise-issue-field", children: [jsx("label", { className: "raise-issue-field-label", children: "Task Value" }), jsx("input", { type: "text", className: "raise-issue-field-input raise-issue-field-readonly", value: isEditMode ? (issue?.component?.basic?.value || '') : (component?.basic?.value || ''), readOnly: true })] }), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Title ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("input", { type: "text", className: `raise-issue-field-input ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: title, onChange: (e) => setTitle(e.target.value), placeholder: "Enter issue title", readOnly: isEditMode })] }), !isStandalone && (jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Work Order ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("input", { type: "text", className: `raise-issue-field-input ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: workOrderNumber, onChange: (e) => setWorkOrderNumber(e.target.value), placeholder: "N/A", readOnly: isEditMode })] })), !isStandalone && (jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Asset Number ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("input", { type: "text", className: `raise-issue-field-input ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: assetNumber, onChange: (e) => setAssetNumber(e.target.value), placeholder: "Enter asset number", readOnly: isEditMode })] })), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Raised By ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsxs("div", { className: "raise-issue-field-value-with-icon", children: [jsx(User, { size: 16 }), jsx("span", { children: user ? `${user.firstName || ''} ${user.lastName || ''}`.trim() || 'User' : 'User' })] })] }), jsxs("div", { className: "raise-issue-field", children: [jsx("label", { className: "raise-issue-field-label", children: "Created On" }), jsxs("div", { className: "raise-issue-field-value-with-icon", children: [jsx(Calendar, { size: 16 }), jsx("span", { children: isEditMode && issue?.createdAt
678
+ const modalContent = (jsx("div", { className: "raise-issue-modal-overlay", onClick: onClose, children: jsxs("div", { className: "raise-issue-modal", onClick: (e) => e.stopPropagation(), children: [jsxs("div", { className: "raise-issue-modal-header", children: [jsxs("div", { className: "raise-issue-modal-header-left", children: [jsx(AlertTriangle, { className: "raise-issue-modal-icon", size: 20 }), jsx("div", { className: "raise-issue-modal-header-text", children: jsx("div", { className: "raise-issue-modal-title-main", children: isEditMode ? 'Issue Details' : 'Create Issue' }) })] }), jsx("button", { className: "raise-issue-modal-close", onClick: onClose, "aria-label": "Close", children: jsx(X$1, { size: 18 }) })] }), jsx("div", { className: "raise-issue-modal-content", children: jsxs("div", { className: "raise-issue-fields-grid", children: [isEditMode && issue?.issueNumber && (jsxs("div", { className: "raise-issue-field", children: [jsx("label", { className: "raise-issue-field-label", children: "Issue ID" }), jsx("input", { type: "text", className: "raise-issue-field-input raise-issue-field-readonly", value: issue.issueNumber, readOnly: true })] })), jsxs("div", { className: "raise-issue-field", children: [jsx("label", { className: "raise-issue-field-label", children: "Task" }), jsx("input", { type: "text", className: "raise-issue-field-input raise-issue-field-readonly", value: isEditMode ? (issue?.component?.basic?.label || '') : (component?.basic?.label || ''), readOnly: true })] }), jsxs("div", { className: "raise-issue-field", children: [jsx("label", { className: "raise-issue-field-label", children: "Task Value" }), jsx("input", { type: "text", className: "raise-issue-field-input raise-issue-field-readonly", value: isEditMode ? (issue?.component?.basic?.value || '') : (component?.basic?.value || ''), readOnly: true })] }), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Title ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("input", { type: "text", className: `raise-issue-field-input ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: title, onChange: (e) => setTitle(e.target.value), placeholder: "Enter issue title", readOnly: isEditMode && isViewMode })] }), !isStandalone && (jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Work Order ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("input", { type: "text", className: `raise-issue-field-input ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: workOrderNumber, onChange: (e) => setWorkOrderNumber(e.target.value), placeholder: "N/A", readOnly: isEditMode && isViewMode })] })), !isStandalone && (jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Asset Number ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("input", { type: "text", className: `raise-issue-field-input ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: assetNumber, onChange: (e) => setAssetNumber(e.target.value), placeholder: "Enter asset number", readOnly: isEditMode && isViewMode })] })), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Raised By ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsxs("div", { className: "raise-issue-field-value-with-icon", children: [jsx(User, { size: 16 }), jsx("span", { children: user ? `${user.firstName || ''} ${user.lastName || ''}`.trim() || 'User' : 'User' })] })] }), jsxs("div", { className: "raise-issue-field", children: [jsx("label", { className: "raise-issue-field-label", children: "Created On" }), jsxs("div", { className: "raise-issue-field-value-with-icon", children: [jsx(Calendar, { size: 16 }), jsx("span", { children: isEditMode && issue?.createdAt
670
679
  ? (safeDate(issue.createdAt) || new Date()).toLocaleString('en-US', {
671
680
  year: 'numeric',
672
681
  month: 'short',
@@ -682,12 +691,12 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
682
691
  hour: '2-digit',
683
692
  minute: '2-digit',
684
693
  hour12: true
685
- }) })] })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Description ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("textarea", { className: `raise-issue-field-textarea ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: description, onChange: (e) => setDescription(e.target.value), placeholder: "Enter issue description", rows: 4, readOnly: isEditMode })] }), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Status ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsxs("select", { className: `raise-issue-field-select ${!isEditMode ? 'raise-issue-field-readonly' : ''}`, value: status, onChange: (e) => setStatus(e.target.value), disabled: !isEditMode, children: [jsx("option", { value: EIssueStatus.OPEN, children: EIssueStatus.OPEN }), jsx("option", { value: EIssueStatus.IN_PROGRESS, children: EIssueStatus.IN_PROGRESS }), jsx("option", { value: EIssueStatus.REJECTED, children: EIssueStatus.REJECTED }), jsx("option", { value: EIssueStatus.RESOLVE, children: EIssueStatus.RESOLVE })] })] }), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Assign to ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsxs("select", { className: "raise-issue-field-select", value: assignee, onChange: (e) => setAssignee(e.target.value), children: [jsx("option", { value: "", children: "Unassigned" }), availableUsers.map(userName => (jsx("option", { value: userName, children: userName }, userName)))] })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Priority ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsxs("div", { className: "raise-issue-priority-buttons", children: [jsx("button", { type: "button", className: `priority-button priority-low ${priority === 'Low' ? 'active' : ''}`, onClick: () => setPriority('Low'), children: "Low" }), jsx("button", { type: "button", className: `priority-button priority-medium ${priority === 'Medium' ? 'active' : ''}`, onClick: () => setPriority('Medium'), children: "Medium" }), jsx("button", { type: "button", className: `priority-button priority-high ${priority === 'High' ? 'active' : ''}`, onClick: () => setPriority('High'), children: "High" })] })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label-with-icon", children: [jsx(MessageSquare, { size: 16 }), jsx("span", { children: "Comments" })] }), !comments && (jsx("div", { className: "raise-issue-no-comments", children: "No comments yet" })), jsx("textarea", { className: `raise-issue-field-textarea raise-issue-comments-textarea ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: comments, onChange: (e) => setComments(e.target.value), placeholder: "Add a comment...", rows: 4, readOnly: isEditMode })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", style: { marginTop: '1rem' }, children: [jsx("label", { className: "raise-issue-field-label", children: "Attachments" }), jsxs("div", { className: "raise-issue-attachments-container", children: [!isEditMode && (jsxs("div", { className: `raise-issue-dropzone ${isDragging ? 'dragging' : ''}`, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: () => fileInputRef.current?.click(), children: [jsx("input", { type: "file", ref: fileInputRef, style: { display: 'none' }, onChange: handleFileChange, multiple: true }), jsx("div", { className: "raise-issue-dropzone-icon", children: jsx(UploadCloud, { size: 24 }) }), jsx("div", { className: "raise-issue-dropzone-text", children: "Click to upload or drag and drop" }), jsx("div", { className: "raise-issue-dropzone-hint", children: "PNG, JPG up to 10MB" })] })), localAttachments.length > 0 && (jsx("div", { className: "raise-issue-attachments-list", children: localAttachments.map((file, index) => (jsxs("div", { className: "raise-issue-attachment-item", children: [jsx("div", { className: "raise-issue-attachment-thumbnail", children: getAttachmentPreview(file) ? (jsx("img", { src: getAttachmentPreview(file), alt: "Thumbnail" })) : (jsx(Paperclip, { size: 20, color: "#9ca3af" })) }), jsxs("div", { className: "raise-issue-attachment-info", children: [jsx("span", { className: "attachment-name", title: getAttachmentName(file), children: getAttachmentName(file) }), file instanceof File && (jsxs("span", { className: "attachment-size", children: [(file.size / 1024).toFixed(1), " KB"] }))] }), !isEditMode && (jsx("button", { type: "button", className: "attachment-remove-btn", onClick: () => handleRemoveAttachment(index), title: "Remove", children: jsx(X$1, { size: 12 }) }))] }, index))) }))] })] })] }) }), jsx("div", { className: "raise-issue-modal-actions", children: jsxs("div", { className: "raise-issue-modal-actions-buttons", children: [isEditMode && issue && (jsxs(Fragment, { children: [status === EIssueStatus.OPEN && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-accept", onClick: handleAccept, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Accept' })), status === EIssueStatus.IN_PROGRESS && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-resolve", onClick: handleResolve, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Resolve' })), (status === EIssueStatus.OPEN || status === EIssueStatus.IN_PROGRESS) && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-reject", onClick: handleReject, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Reject' }))] })), !isEditMode && (jsx("button", { className: `raise-issue-modal-button raise-issue-modal-button-save ${!isFormValid ? 'disabled' : ''}`, onClick: handleSubmit, disabled: isSubmitting || !isFormValid, children: isSubmitting ? 'Creating...' : 'Create Issue' }))] }) })] }) }));
694
+ }) })] })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Description ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("textarea", { className: `raise-issue-field-textarea ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: description, onChange: (e) => setDescription(e.target.value), placeholder: "Enter issue description", rows: 4, readOnly: isEditMode && isViewMode })] }), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Status ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("input", { type: "text", className: "raise-issue-field-input raise-issue-field-readonly", value: status, readOnly: true })] }), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Assign to ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsxs("select", { className: "raise-issue-field-select", value: assignee, onChange: (e) => setAssignee(e.target.value), disabled: isEditMode && isViewMode, children: [jsx("option", { value: "", children: "Unassigned" }), availableUsers.map(userName => (jsx("option", { value: userName, children: userName }, userName)))] })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Priority ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsxs("div", { className: "raise-issue-priority-buttons", children: [jsx("button", { type: "button", className: `priority-button priority-low ${priority === 'Low' ? 'active' : ''}`, onClick: () => setPriority('Low'), disabled: isEditMode && isViewMode, children: "Low" }), jsx("button", { type: "button", className: `priority-button priority-medium ${priority === 'Medium' ? 'active' : ''}`, onClick: () => setPriority('Medium'), disabled: isEditMode && isViewMode, children: "Medium" }), jsx("button", { type: "button", className: `priority-button priority-high ${priority === 'High' ? 'active' : ''}`, onClick: () => setPriority('High'), disabled: isEditMode && isViewMode, children: "High" })] })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label-with-icon", children: [jsx(MessageSquare, { size: 16 }), jsx("span", { children: "Comments" })] }), !comments && (jsx("div", { className: "raise-issue-no-comments", children: "No comments yet" })), jsx("textarea", { className: `raise-issue-field-textarea raise-issue-comments-textarea ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: comments, onChange: (e) => setComments(e.target.value), placeholder: "Add a comment...", rows: 4, readOnly: isEditMode })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", style: { marginTop: '1rem' }, children: [jsx("label", { className: "raise-issue-field-label", children: "Attachments" }), jsxs("div", { className: "raise-issue-attachments-container", children: [!isEditMode && (jsxs("div", { className: `raise-issue-dropzone ${isDragging ? 'dragging' : ''}`, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: () => fileInputRef.current?.click(), children: [jsx("input", { type: "file", ref: fileInputRef, style: { display: 'none' }, onChange: handleFileChange, multiple: true }), jsx("div", { className: "raise-issue-dropzone-icon", children: jsx(UploadCloud, { size: 24 }) }), jsx("div", { className: "raise-issue-dropzone-text", children: "Click to upload or drag and drop" }), jsx("div", { className: "raise-issue-dropzone-hint", children: "PNG, JPG up to 10MB" })] })), localAttachments.length > 0 && (jsx("div", { className: "raise-issue-attachments-list", children: localAttachments.map((file, index) => (jsxs("div", { className: "raise-issue-attachment-item", children: [jsx("div", { className: "raise-issue-attachment-thumbnail", children: getAttachmentPreview(file) ? (jsx("img", { src: getAttachmentPreview(file), alt: "Thumbnail" })) : (jsx(Paperclip, { size: 20, color: "#9ca3af" })) }), jsxs("div", { className: "raise-issue-attachment-info", children: [jsx("span", { className: "attachment-name", title: getAttachmentName(file), children: getAttachmentName(file) }), file instanceof File && (jsxs("span", { className: "attachment-size", children: [(file.size / 1024).toFixed(1), " KB"] }))] }), !isEditMode && (jsx("button", { type: "button", className: "attachment-remove-btn", onClick: () => handleRemoveAttachment(index), title: "Remove", children: jsx(X$1, { size: 12 }) }))] }, index))) }))] })] })] }) }), jsx("div", { className: "raise-issue-modal-actions", children: jsxs("div", { className: "raise-issue-modal-actions-buttons", children: [(showWorkflowActions && issue) && (jsxs(Fragment, { children: [status === EIssueStatus.OPEN && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-accept", onClick: handleAccept, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Accept' })), status === EIssueStatus.IN_PROGRESS && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-resolve", onClick: handleResolve, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Resolve' })), (status === EIssueStatus.OPEN) && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-reject", onClick: handleReject, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Reject' }))] })), !isEditMode && (jsx("button", { className: `raise-issue-modal-button raise-issue-modal-button-save ${!isFormValid ? 'disabled' : ''}`, onClick: handleSubmit, disabled: isSubmitting || !isFormValid, children: isSubmitting ? 'Creating...' : 'Create Issue' }))] }) })] }) }));
686
695
  // Render modal using portal to document body for full-page overlay
687
696
  return createPortal(modalContent, document.body);
688
697
  };
689
698
 
690
- const ThresholdAlert = ({ component, condition, currentValue, thresholdValue, formTemplateId, workOrderNumber, assetNumber, user, onIssueRaised, isIssueRaised = false, compact = false }) => {
699
+ const ThresholdAlert = ({ component, condition, currentValue, thresholdValue, formTemplateId, workOrderNumber, assetNumber, user, onIssueRaised, isIssueRaised = false, compact = false, allowWorkflowActions, inEditMode }) => {
691
700
  const [showRaiseIssueModal, setShowRaiseIssueModal] = useState(false);
692
701
  const [issue, setIssue] = useState(null);
693
702
  const [isLoadingIssue, setIsLoadingIssue] = useState(false);
@@ -779,16 +788,16 @@ const ThresholdAlert = ({ component, condition, currentValue, thresholdValue, fo
779
788
  // If issue is raised (either from prop or local state), don't show anything
780
789
  // The ComponentActionFeatures will handle showing the raised issue state
781
790
  if (isIssueRaised || localIssueRaised) {
782
- return (jsx(Fragment, { children: showRaiseIssueModal && (jsx(RaiseIssueModal, { isOpen: showRaiseIssueModal, onClose: handleRaiseIssueClose, onSuccess: handleRaiseIssueSuccess, component: component, formTemplateId: formTemplateId, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, notes: "", attachments: null, issue: issue })) }));
791
+ return (jsx(Fragment, { children: showRaiseIssueModal && (jsx(RaiseIssueModal, { isOpen: showRaiseIssueModal, onClose: handleRaiseIssueClose, onSuccess: handleRaiseIssueSuccess, component: component, formTemplateId: formTemplateId, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, notes: "", attachments: null, issue: issue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode })) }));
783
792
  }
784
793
  // Show compact version for small screens/tables
785
794
  if (compact) {
786
- return (jsxs(Fragment, { children: [jsxs("div", { className: "threshold-alert threshold-alert-unresolved threshold-alert-compact", children: [jsx("div", { className: "threshold-alert-border" }), jsxs("div", { className: "threshold-alert-content-compact", children: [jsx(AlertTriangle, { className: "threshold-alert-icon-compact", size: 14 }), jsx("span", { className: "threshold-alert-message-compact", children: getCompactMessage() }), jsx("button", { type: "button", onClick: handleRaiseIssueClick, className: "threshold-alert-raise-issue-btn-compact", title: "Raise Issue", children: "Raise Issue" })] })] }), showRaiseIssueModal && (jsx(RaiseIssueModal, { isOpen: showRaiseIssueModal, onClose: handleRaiseIssueClose, onSuccess: handleRaiseIssueSuccess, component: component, formTemplateId: formTemplateId, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, notes: "", attachments: null, issue: issue }))] }));
795
+ return (jsxs(Fragment, { children: [jsxs("div", { className: "threshold-alert threshold-alert-unresolved threshold-alert-compact", children: [jsx("div", { className: "threshold-alert-border" }), jsxs("div", { className: "threshold-alert-content-compact", children: [jsx(AlertTriangle, { className: "threshold-alert-icon-compact", size: 14 }), jsx("span", { className: "threshold-alert-message-compact", children: getCompactMessage() }), jsx("button", { type: "button", onClick: handleRaiseIssueClick, className: "threshold-alert-raise-issue-btn-compact", title: "Raise Issue", children: "Raise Issue" })] })] }), showRaiseIssueModal && (jsx(RaiseIssueModal, { isOpen: showRaiseIssueModal, onClose: handleRaiseIssueClose, onSuccess: handleRaiseIssueSuccess, component: component, formTemplateId: formTemplateId, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, notes: "", attachments: null, issue: issue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }))] }));
787
796
  }
788
- return (jsxs(Fragment, { children: [jsxs("div", { className: "threshold-alert threshold-alert-unresolved", children: [jsx("div", { className: "threshold-alert-border" }), jsxs("div", { className: "threshold-alert-content", children: [jsx("div", { className: "threshold-alert-header", children: jsxs("div", { className: "threshold-alert-title-group", children: [jsx(AlertTriangle, { className: "threshold-alert-icon", size: 20 }), jsx("span", { className: "threshold-alert-title", children: "Threshold Condition Met - Action Required" })] }) }), jsxs("div", { className: "threshold-alert-message", children: [getConditionMessage(), jsx("span", { className: "threshold-alert-warning", children: " You must raise an issue before submitting the form." })] }), jsx("div", { className: "threshold-alert-buttons", children: jsx("button", { type: "button", onClick: handleRaiseIssueClick, className: "threshold-alert-raise-issue-btn", children: "Raise Issue Now" }) })] })] }), showRaiseIssueModal && (jsx(RaiseIssueModal, { isOpen: showRaiseIssueModal, onClose: handleRaiseIssueClose, onSuccess: handleRaiseIssueSuccess, component: component, formTemplateId: formTemplateId, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, notes: "", attachments: null, issue: issue }))] }));
797
+ return (jsxs(Fragment, { children: [jsxs("div", { className: "threshold-alert threshold-alert-unresolved", children: [jsx("div", { className: "threshold-alert-border" }), jsxs("div", { className: "threshold-alert-content", children: [jsx("div", { className: "threshold-alert-header", children: jsxs("div", { className: "threshold-alert-title-group", children: [jsx(AlertTriangle, { className: "threshold-alert-icon", size: 20 }), jsx("span", { className: "threshold-alert-title", children: "Threshold Condition Met - Action Required" })] }) }), jsxs("div", { className: "threshold-alert-message", children: [getConditionMessage(), jsx("span", { className: "threshold-alert-warning", children: " You must raise an issue before submitting the form." })] }), jsx("div", { className: "threshold-alert-buttons", children: jsx("button", { type: "button", onClick: handleRaiseIssueClick, className: "threshold-alert-raise-issue-btn", children: "Raise Issue Now" }) })] })] }), showRaiseIssueModal && (jsx(RaiseIssueModal, { isOpen: showRaiseIssueModal, onClose: handleRaiseIssueClose, onSuccess: handleRaiseIssueSuccess, component: component, formTemplateId: formTemplateId, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, notes: "", attachments: null, issue: issue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }))] }));
789
798
  };
790
799
 
791
- const DfFormInput = ({ id, properties, validationErrors = {}, formValue = '', inputType = 'text', readonly = false, disabled = false, touchedFields = {}, formSubmitted = false, mode = 'test', onValueChange, onBlur, onFocus, className = '', hideLabel = false, formTemplateId, onThresholdIssueRaised, raisedThresholdIssues = new Set(), workOrderNumber, assetNumber, user }) => {
800
+ const DfFormInput = ({ id, properties, validationErrors = {}, formValue = '', inputType = 'text', readonly = false, disabled = false, touchedFields = {}, formSubmitted = false, mode = 'test', onValueChange, onBlur, onFocus, className = '', hideLabel = false, formTemplateId, onThresholdIssueRaised, raisedThresholdIssues = new Set(), workOrderNumber, assetNumber, user, allowWorkflowActions, inEditMode }) => {
792
801
  // Ensure formValue is always a string to prevent [object Object] errors
793
802
  const getStringValue = (val) => {
794
803
  if (val === null || val === undefined)
@@ -1152,7 +1161,7 @@ const DfFormInput = ({ id, properties, validationErrors = {}, formValue = '', in
1152
1161
  inputWrapperRef.current?.closest('.datagrid-list-view') !== null ||
1153
1162
  className.includes('table-cell') ||
1154
1163
  className.includes('cell-content');
1155
- return (jsx(ThresholdAlert, { component: properties, condition: activeThresholdCondition, currentValue: value, thresholdValue: activeThresholdCondition.value, formTemplateId: formTemplateId, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onDismiss: () => handleDismissAlert(activeThresholdCondition.id), onIssueRaised: onThresholdIssueRaised, isIssueRaised: issueRaised, compact: isInTable }, `${activeThresholdCondition.id}-${issueRaised}`));
1164
+ return (jsx(ThresholdAlert, { component: properties, condition: activeThresholdCondition, currentValue: value, thresholdValue: activeThresholdCondition.value, formTemplateId: formTemplateId, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onDismiss: () => handleDismissAlert(activeThresholdCondition.id), onIssueRaised: onThresholdIssueRaised, isIssueRaised: issueRaised, compact: isInTable, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }, `${activeThresholdCondition.id}-${issueRaised}`));
1156
1165
  })()] }));
1157
1166
  };
1158
1167
 
@@ -3739,7 +3748,7 @@ const AttachmentThumbnails = ({ attachments, onRemove }) => {
3739
3748
  return (jsx("div", { className: "attachment-thumbnail", children: isImage && objectUrl ? (jsxs(Fragment, { children: [jsx("img", { src: objectUrl, alt: file ? file.name : 'Attachment' }), jsx("button", { type: "button", className: "thumbnail-remove-btn", onClick: () => onRemove(index), title: "Remove attachment", children: jsx(X$1, { size: 14 }) })] })) : (jsxs(Fragment, { children: [jsx("div", { className: "file-icon-placeholder", children: jsx(Paperclip, { size: 20 }) }), jsx("span", { className: "file-name", children: file ? file.name : 'Unknown File' }), jsx("button", { type: "button", className: "thumbnail-remove-btn", onClick: () => onRemove(index), title: "Remove attachment", children: jsx(X$1, { size: 14 }) })] })) }, index));
3740
3749
  }) }));
3741
3750
  };
3742
- const ComponentActionFeatures = ({ component, mode, formTemplateId, formValue, formData, onNotesChange, onAttachmentChange, notes = '', attachments = null, onThresholdActionCompletion, onThresholdIssueRaised, onBasicPropertyActionCompletion, workOrderNumber, assetNumber, isStandalone, user, onCreateIssue, onUpdateIssue }) => {
3751
+ const ComponentActionFeatures = ({ component, mode, formTemplateId, formValue, formData, onNotesChange, onAttachmentChange, notes = '', attachments = null, onThresholdActionCompletion, onThresholdIssueRaised, onBasicPropertyActionCompletion, workOrderNumber, assetNumber, isStandalone, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
3743
3752
  // Determine effective form value (prefer prop, fallback to formData lookup)
3744
3753
  const effectiveFormValue = formValue !== undefined ? formValue : (formData ? formData[component.id] : undefined);
3745
3754
  // Use effectiveFormValue for logic instead of raw formValue
@@ -4017,10 +4026,8 @@ const ComponentActionFeatures = ({ component, mode, formTemplateId, formValue, f
4017
4026
  }, 3000);
4018
4027
  }, [getActiveThresholdConditions, onThresholdActionCompletion, component, onBasicPropertyActionCompletion]);
4019
4028
  const handleRaiseIssueClick = useCallback(() => {
4020
- if (issueRaised)
4021
- return;
4022
4029
  setShowRaiseIssueModal(true);
4023
- }, [issueRaised]);
4030
+ }, []);
4024
4031
  const handleRaiseIssueClose = useCallback(() => {
4025
4032
  setShowRaiseIssueModal(false);
4026
4033
  }, []);
@@ -4227,7 +4234,7 @@ const ComponentActionFeatures = ({ component, mode, formTemplateId, formValue, f
4227
4234
  modalComponent.basic.value = selectedOption.value || effectiveValue;
4228
4235
  }
4229
4236
  return modalComponent;
4230
- })(), formTemplateId: formTemplateId || '', notes: localNotes, attachments: localAttachments, isStandalone: isStandalone, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue }))] }));
4237
+ })(), formTemplateId: formTemplateId || '', notes: localNotes, attachments: localAttachments, isStandalone: isStandalone, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }))] }));
4231
4238
  };
4232
4239
 
4233
4240
  // Attachment Thumbnails Component for Submission View
@@ -4293,7 +4300,7 @@ function ensureStringId$2(id) {
4293
4300
  }
4294
4301
  return String(id);
4295
4302
  }
4296
- const DraggableGridComponent = ({ component, selectedComponent, mode, onComponentSelect, onComponentDelete, onComponentEdit, renderFormComponent, isOverlay = false, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, shouldShowComponent }) => {
4303
+ const DraggableGridComponent = ({ component, selectedComponent, mode, onComponentSelect, onComponentDelete, onComponentEdit, renderFormComponent, isOverlay = false, formData = {}, formTemplateId, onThresholdIssueRaised, onNotesChange, onAttachmentChange, shouldShowComponent }) => {
4297
4304
  const formValue = formData[component.id];
4298
4305
  const isVisible = shouldShowComponent ? shouldShowComponent(component.id) : true;
4299
4306
  // Check if component has notes or attachments for submission view
@@ -4464,8 +4471,7 @@ const GridDropZone = ({ gridComponents, mode, onComponentSelect, onComponentDele
4464
4471
  }, children: isOver ? (jsx("span", { style: { color: '#3b82f6', fontWeight: '500' }, children: "Drop component here to add to grid" })) : (jsx("span", { children: "+ Drop more components here" })) })] })) }));
4465
4472
  };
4466
4473
  // Sub-component for displaying entries (TableView)
4467
- const TableView = ({ templateComponents, dataEntries, renderFormComponent, mode, allowAddRemoveEntries, addAnotherText, removeText, maxEntries, minEntries, displayAsGrid = true, onAddEntry, onRemoveEntry, formData, // Use current formData to render values
4468
- formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, columnView, shouldShowComponent }) => {
4474
+ const TableView = ({ templateComponents, dataEntries, renderFormComponent, mode, allowAddRemoveEntries, addAnotherText, removeText, maxEntries, minEntries, displayAsGrid = true, onAddEntry, onRemoveEntry, formData, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, columnView, shouldShowComponent, allowWorkflowActions, inEditMode }) => {
4469
4475
  const _formData = formData || {};
4470
4476
  const visibleTemplateComponents = React.useMemo(() => {
4471
4477
  if (!shouldShowComponent)
@@ -5132,7 +5138,7 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
5132
5138
  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 })) }))] }));
5133
5139
  };
5134
5140
 
5135
- const DraggableChild = ({ child, selectedChild, mode, onChildSelect, onChildDelete, renderFormComponent, isOverlay = false, isChildrenEditMode = false, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue }) => {
5141
+ const DraggableChild = ({ child, selectedChild, mode, onChildSelect, onChildDelete, renderFormComponent, isOverlay = false, isChildrenEditMode = false, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
5136
5142
  const formValue = formData[child.id];
5137
5143
  // Check if component has notes or attachments for submission view
5138
5144
  const hasSubmissionData = mode === 'preview' && ((child.basic?.notes && child.basic.notes.trim().length > 0) ||
@@ -5150,9 +5156,9 @@ const DraggableChild = ({ child, selectedChild, mode, onChildSelect, onChildDele
5150
5156
  return (jsxs("div", { ref: setNodeRef, style: style, className: `form-component section-child ${selectedChild?.id === child.id ? 'selected' : ''} ${isDragging ? 'dragging' : ''} ${isSorting ? 'sorting' : ''} ${isChildrenEditMode ? 'children-edit-active' : ''}`, onClick: () => !isDragging && onChildSelect(child), role: "button", tabIndex: 0, children: [(mode === 'edit' || isChildrenEditMode) && (jsx("div", { className: "child-drag-handle", ...listeners, ...attributes, onClick: (e) => e.stopPropagation(), onMouseDown: (e) => e.stopPropagation(), children: jsx(GripVertical, { size: 14 }) })), jsxs("div", { className: "form-component-content section-child-content", children: [(mode === 'edit' || isChildrenEditMode) && (jsxs("div", { className: "component-actions child-actions", children: [jsx("button", { className: "btn edit-btn", onClick: (e) => {
5151
5157
  e.stopPropagation();
5152
5158
  onChildSelect(child);
5153
- }, onMouseDown: (e) => e.stopPropagation(), title: "Edit properties", children: jsx(Edit, { size: 12 }) }), jsx("button", { className: "btn delete-btn", onClick: (e) => onChildDelete(child, e), onMouseDown: (e) => e.stopPropagation(), title: "Delete component", children: jsx(Trash2, { size: 12 }) })] })), jsxs("div", { className: "component-preview child-preview", children: [renderFormComponent(child), !['section', 'table', 'heading', 'file', 'instructions', 'signature', 'location', 'datagrid'].includes(child.name) && (jsx(ComponentActionFeatures, { component: child, mode: "test", formTemplateId: formTemplateId, formValue: formValue, formData: formData, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange ? (notes) => onNotesChange(child.id, notes) : undefined, onAttachmentChange: onAttachmentChange ? (attachments) => onAttachmentChange(child.id, attachments) : undefined, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue })), hasSubmissionData && (jsx(ComponentSubmissionActions, { component: child }))] })] })] }));
5159
+ }, onMouseDown: (e) => e.stopPropagation(), title: "Edit properties", children: jsx(Edit, { size: 12 }) }), jsx("button", { className: "btn delete-btn", onClick: (e) => onChildDelete(child, e), onMouseDown: (e) => e.stopPropagation(), title: "Delete component", children: jsx(Trash2, { size: 12 }) })] })), jsxs("div", { className: "component-preview child-preview", children: [renderFormComponent(child), !['section', 'table', 'heading', 'file', 'instructions', 'signature', 'location', 'datagrid'].includes(child.name) && (jsx(ComponentActionFeatures, { component: child, mode: "test", formTemplateId: formTemplateId, formValue: formValue, formData: formData, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange ? (notes) => onNotesChange(child.id, notes) : undefined, onAttachmentChange: onAttachmentChange ? (attachments) => onAttachmentChange(child.id, attachments) : undefined, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode })), hasSubmissionData && (jsx(ComponentSubmissionActions, { component: child }))] })] })] }));
5154
5160
  };
5155
- const DfFormSection = ({ id, properties, mode = 'edit', formData = {}, onValueChange, onSelect, isSelected = false, className = '', onSectionSelect, onChildSelect, onChildDelete, selectedChild, renderFormComponent, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue }) => {
5161
+ const DfFormSection = ({ id, properties, mode = 'edit', formData = {}, onValueChange, onSelect, isSelected = false, className = '', onSectionSelect, onChildSelect, onChildDelete, selectedChild, renderFormComponent, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
5156
5162
  const [isCollapsed, setIsCollapsed] = useState(properties.basic.collapsed);
5157
5163
  const [isEditingTitle, setIsEditingTitle] = useState(false);
5158
5164
  const [isEditingDescription, setIsEditingDescription] = useState(false);
@@ -5365,7 +5371,7 @@ const DfFormSection = ({ id, properties, mode = 'edit', formData = {}, onValueCh
5365
5371
  }, children: isOver ? 'Drop components here' : 'Empty Section' }), jsx("div", { style: {
5366
5372
  fontSize: '12px',
5367
5373
  color: '#9ca3af'
5368
- }, children: "Drag and drop components here to create your section" })] })) : (children.map((child) => (jsx(DraggableChild, { child: child, selectedChild: selectedChild || null, mode: mode, onChildSelect: handleChildSelect, onChildDelete: handleChildDelete, renderFormComponent: renderComponent, isChildrenEditMode: isChildrenEditMode, formData: formData, formTemplateId: formTemplateId, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue }, child.id)))) }) }))] }));
5374
+ }, children: "Drag and drop components here to create your section" })] })) : (children.map((child) => (jsx(DraggableChild, { child: child, selectedChild: selectedChild || null, mode: mode, onChildSelect: handleChildSelect, onChildDelete: handleChildDelete, renderFormComponent: renderComponent, isChildrenEditMode: isChildrenEditMode, formData: formData, formTemplateId: formTemplateId, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }, child.id)))) }) }))] }));
5369
5375
  };
5370
5376
 
5371
5377
  // Dynamic imports to avoid circular dependencies
@@ -5415,7 +5421,7 @@ const normalizeTableRow = (row) => {
5415
5421
  };
5416
5422
  const DfFormPreview = ({ formComponents = [], currentDevice = 'desktop', isPreviewMode = false, initialFormData = [], onSubmit, onFormDataChange, formTitle, formDescription, formTemplateId,
5417
5423
  // Add component management props for edit mode
5418
- onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, selectedComponent, workOrderNumber, assetNumber, isStandalone, user, onCreateIssue, onUpdateIssue }) => {
5424
+ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, selectedComponent, workOrderNumber, assetNumber, isStandalone, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
5419
5425
  // Local copy of formComponents so structure updates (e.g. table cell init) are reflected immediately
5420
5426
  const [localFormComponents, setLocalFormComponents] = useState(formComponents);
5421
5427
  // Sync local state when the prop changes from the parent
@@ -6770,7 +6776,7 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6770
6776
  case 'email-input':
6771
6777
  // Regular text/email/number input
6772
6778
  return (jsx(DfFormInput, { ...commonProps, properties: component, inputType: component.name === 'text-input' ? 'text' :
6773
- component.name === 'number-input' ? 'number' : 'email', formTemplateId: formTemplateId, onThresholdIssueRaised: handleThresholdIssueRaised, raisedThresholdIssues: raisedThresholdIssues, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user }));
6779
+ component.name === 'number-input' ? 'number' : 'email', formTemplateId: formTemplateId, onThresholdIssueRaised: handleThresholdIssueRaised, raisedThresholdIssues: raisedThresholdIssues, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }));
6774
6780
  case 'textarea':
6775
6781
  return jsx(DfFormTextarea, { ...commonProps, properties: component });
6776
6782
  case 'select':
@@ -6836,13 +6842,13 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
6836
6842
  case 'location':
6837
6843
  return jsx(DfFormLocation, { ...commonProps, properties: component });
6838
6844
  case 'section':
6839
- return (jsx(DfFormSection, { ...commonProps, properties: component, formData: formValues, formTemplateId: formTemplateId, onThresholdActionCompletion: handleThresholdActionCompletion, onThresholdIssueRaised: handleThresholdIssueRaised, onNotesChange: handleComponentNotesChange, onAttachmentChange: handleComponentAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, renderFormComponent: (field) => {
6845
+ return (jsx(DfFormSection, { ...commonProps, properties: component, formData: formValues, formTemplateId: formTemplateId, onThresholdActionCompletion: handleThresholdActionCompletion, onThresholdIssueRaised: handleThresholdIssueRaised, onNotesChange: handleComponentNotesChange, onAttachmentChange: handleComponentAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode, renderFormComponent: (field) => {
6840
6846
  // Ensure the nested component gets the proper form value
6841
6847
  // const fieldValue = formValues[field.id] || (field.basic as any)?.value || (field.basic as any)?.defaultValue || ''
6842
6848
  return renderFormComponent(field);
6843
6849
  } }));
6844
6850
  case 'table':
6845
- return (jsx(React.Suspense, { fallback: jsx("div", { children: "Loading table..." }), children: jsx(DfFormTable$1, { ...commonProps, properties: component, formData: formValues, formTemplateId: formTemplateId, mode: commonProps.mode, validationErrors: validationErrors, touchedFields: touchedFields, formSubmitted: formSubmitted, onThresholdActionCompletion: handleThresholdActionCompletion, onThresholdIssueRaised: handleThresholdIssueRaised, workOrderNumber: workOrderNumber, assetNumber: assetNumber, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, renderFormComponent: (field) => {
6851
+ return (jsx(React.Suspense, { fallback: jsx("div", { children: "Loading table..." }), children: jsx(DfFormTable$1, { ...commonProps, properties: component, formData: formValues, formTemplateId: formTemplateId, mode: commonProps.mode, validationErrors: validationErrors, touchedFields: touchedFields, formSubmitted: formSubmitted, onThresholdActionCompletion: handleThresholdActionCompletion, onThresholdIssueRaised: handleThresholdIssueRaised, workOrderNumber: workOrderNumber, assetNumber: assetNumber, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode, renderFormComponent: (field) => {
6846
6852
  return renderFormComponent(field);
6847
6853
  }, onNotesChange: (componentId, notes) => {
6848
6854
  // Handle notes change for table cell components
@@ -7180,7 +7186,7 @@ onComponentSelect, onComponentDelete, onComponentEdit, onComponentUpdate, select
7180
7186
  return comp;
7181
7187
  });
7182
7188
  onFormDataChange?.(updatedComponents);
7183
- }, notes: componentNotes[component.id] !== undefined ? componentNotes[component.id] : (component.basic?.notes || ''), attachments: componentAttachments[component.id] !== undefined ? componentAttachments[component.id] : (component.basic?.attachments || null), workOrderNumber: workOrderNumber, assetNumber: assetNumber, isStandalone: isStandalone, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue })), isPreviewMode && hasSubmissionData && (jsx(ComponentSubmissionActions, { component: component }))] }, component.id));
7189
+ }, notes: componentNotes[component.id] !== undefined ? componentNotes[component.id] : (component.basic?.notes || ''), attachments: componentAttachments[component.id] !== undefined ? componentAttachments[component.id] : (component.basic?.attachments || null), workOrderNumber: workOrderNumber, assetNumber: assetNumber, isStandalone: isStandalone, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode })), isPreviewMode && hasSubmissionData && (jsx(ComponentSubmissionActions, { component: component }))] }, component.id));
7184
7190
  }), !isPreviewMode && (jsxs("div", { className: "form-actions", children: [!formSubmitted && (jsx("button", { type: "button", onClick: () => handleSubmit('Saved'), className: "form-save-button", disabled: formSubmitted && !isFormValid(), children: "Save" })), jsx("button", { type: "button", disabled: !isFormValid() || !thresholdValidationState.isValid, className: "form-submit-button", title: !thresholdValidationState.isValid ? thresholdValidationState.errorMessage : '', onClick: () => handleSubmit('Submitted'), children: "Submit" })] }))] }))] }) }) }));
7185
7191
  };
7186
7192
 
@@ -7275,12 +7281,12 @@ const ensureComponentHasId = (component) => {
7275
7281
  }
7276
7282
  return component;
7277
7283
  };
7278
- const SimpleTableComponent = ({ component, mode, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue }) => {
7284
+ const SimpleTableComponent = ({ component, mode, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
7279
7285
  const formValue = formData[component.id];
7280
7286
  // Check if component has notes or attachments for submission view
7281
7287
  const hasSubmissionData = mode === 'preview' && ((component.basic?.notes && component.basic.notes.trim().length > 0) ||
7282
7288
  (component.basic?.attachments && Array.isArray(component.basic.attachments) && component.basic.attachments.length > 0));
7283
- return (jsxs("div", { className: "simple-table-component", children: [renderFormComponent(component), !['section', 'table', 'heading', 'file', 'instructions', 'signature', 'location', 'datagrid'].includes(component.name) && (jsx(ComponentActionFeatures, { component: component, mode: "test", formTemplateId: formTemplateId, formValue: formValue, formData: formData, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange ? (notes) => onNotesChange(component.id, notes) : undefined, onAttachmentChange: onAttachmentChange ? (attachments) => onAttachmentChange(component.id, attachments) : undefined, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue })), hasSubmissionData && (jsx(ComponentSubmissionActions, { component: component }))] }));
7289
+ return (jsxs("div", { className: "simple-table-component", children: [renderFormComponent(component), !['section', 'table', 'heading', 'file', 'instructions', 'signature', 'location', 'datagrid'].includes(component.name) && (jsx(ComponentActionFeatures, { component: component, mode: "test", formTemplateId: formTemplateId, formValue: formValue, formData: formData, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange ? (notes) => onNotesChange(component.id, notes) : undefined, onAttachmentChange: onAttachmentChange ? (attachments) => onAttachmentChange(component.id, attachments) : undefined, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode })), hasSubmissionData && (jsx(ComponentSubmissionActions, { component: component }))] }));
7284
7290
  };
7285
7291
  const DraggableTableComponent = ({ component, selectedComponent, mode, onComponentSelect, onComponentDelete, onComponentEdit, renderFormComponent, isOverlay = false, }) => {
7286
7292
  const { attributes, listeners, setNodeRef, transform, transition, isDragging, isSorting, } = useSortable({
@@ -7301,7 +7307,7 @@ const DraggableTableComponent = ({ component, selectedComponent, mode, onCompone
7301
7307
  onComponentDelete(component, e);
7302
7308
  }, type: "button", title: "Delete Component", children: jsx(Trash2, { size: 12 }) })] }))] }));
7303
7309
  };
7304
- const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, tableId, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue }) => {
7310
+ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, tableId, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
7305
7311
  const dropZoneId = `table-cell-${tableId}-${cell.row}-${cell.column}`;
7306
7312
  const { setNodeRef, isOver } = useDroppable({
7307
7313
  id: dropZoneId,
@@ -7336,7 +7342,7 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
7336
7342
  cell.components.map((component) => {
7337
7343
  // Only ensure ID if it's truly missing - don't regenerate existing IDs
7338
7344
  const componentWithId = component.id ? component : ensureComponentHasId(component);
7339
- return (jsx(SimpleTableComponent, { component: componentWithId, mode: mode, renderFormComponent: renderFormComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue }, componentWithId.id));
7345
+ return (jsx(SimpleTableComponent, { component: componentWithId, mode: mode, renderFormComponent: renderFormComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }, componentWithId.id));
7340
7346
  }))) : (
7341
7347
  // Only show drop zone content in edit mode
7342
7348
  mode === 'edit' ? (jsx("div", { className: "empty-cell-placeholder", children: jsxs("div", { className: "cell-info", children: [jsx("span", { className: "drop-zone-text", children: "Drag and Drop a form component" }), jsxs("span", { className: "cell-coordinates", children: ["Cell (", cell.row + 1, ", ", cell.column + 1, ")"] })] }) })) : (
@@ -7347,7 +7353,7 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
7347
7353
  visibility: 'hidden' // Hide content but maintain space
7348
7354
  }, children: "\u00A0" }))) }) }));
7349
7355
  };
7350
- const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationErrors = {}, touchedFields = {}, formSubmitted = false, onValueChange, onSelect, isSelected = false, className = '', onTableSelect, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue }) => {
7356
+ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationErrors = {}, touchedFields = {}, formSubmitted = false, onValueChange, onSelect, isSelected = false, className = '', onTableSelect, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
7351
7357
  const [isCollapsed, setIsCollapsed] = useState(false); // Always start expanded to show drop zones
7352
7358
  // CRITICAL: Normalize cells from API format (object with numeric keys) to proper 2D array
7353
7359
  // The API may return cells as [{"0": {cell}, "1": {cell}}, ...] instead of [[cell, cell], ...]
@@ -7585,7 +7591,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
7585
7591
  fontSize: '14px',
7586
7592
  textAlign: 'center'
7587
7593
  }, children: columnName }, `header-${colIndex}`));
7588
- }) }) })), jsx("tbody", { children: cellsWithIds.map((row, rowIndex) => (jsx("tr", { className: "table-row", children: row.map((cell) => (jsx(TableCellComponent, { cell: cell, mode: mode, onComponentSelect: onComponentSelect || (() => { }), onComponentDelete: handleComponentDelete, onComponentEdit: onComponentEdit, selectedComponent: selectedComponent || null, renderFormComponent: renderComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, tableId: id, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue }, cell.id))) }, rowIndex))) })] })] }))] }));
7594
+ }) }) })), jsx("tbody", { children: cellsWithIds.map((row, rowIndex) => (jsx("tr", { className: "table-row", children: row.map((cell) => (jsx(TableCellComponent, { cell: cell, mode: mode, onComponentSelect: onComponentSelect || (() => { }), onComponentDelete: handleComponentDelete, onComponentEdit: onComponentEdit, selectedComponent: selectedComponent || null, renderFormComponent: renderComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, tableId: id, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }, cell.id))) }, rowIndex))) })] })] }))] }));
7589
7595
  };
7590
7596
 
7591
7597
  var dfFormTable = /*#__PURE__*/Object.freeze({