@topconsultnpm/sdkui-react-beta 6.16.89 → 6.16.91
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/lib/components/features/archive/TMArchive.d.ts +1 -0
- package/lib/components/features/archive/TMArchive.js +2 -2
- package/lib/components/features/documents/TMDcmtForm.d.ts +1 -0
- package/lib/components/features/documents/TMDcmtForm.js +4 -4
- package/lib/components/features/documents/TMDragDropOverlay.d.ts +6 -0
- package/lib/components/features/documents/TMDragDropOverlay.js +95 -0
- package/lib/components/features/documents/TMFileUploader.d.ts +1 -0
- package/lib/components/features/documents/TMFileUploader.js +4 -3
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ interface ITMArchiveProps {
|
|
|
9
9
|
onDcmtTypeSelect?: (tid: number | undefined) => void;
|
|
10
10
|
connectorFileSave?: () => Promise<File>;
|
|
11
11
|
onSavedAsyncCallback?: (tid: number | undefined, did: number | undefined) => Promise<void>;
|
|
12
|
+
enableDragDropOverlay?: boolean;
|
|
12
13
|
}
|
|
13
14
|
declare const TMArchive: React.FunctionComponent<ITMArchiveProps>;
|
|
14
15
|
export default TMArchive;
|
|
@@ -12,7 +12,7 @@ import TMTreeSelector from '../search/TMTreeSelector';
|
|
|
12
12
|
import TMPanel from '../../base/TMPanel';
|
|
13
13
|
import { TMPanelManagerProvider, useTMPanelManagerContext } from '../../layout/panelManager/TMPanelManagerContext';
|
|
14
14
|
import TMPanelManagerContainer from '../../layout/panelManager/TMPanelManagerContainer';
|
|
15
|
-
const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, connectorFileSave = undefined, onSavedAsyncCallback, inputMids = [] }) => {
|
|
15
|
+
const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, connectorFileSave = undefined, onSavedAsyncCallback, inputMids = [], enableDragDropOverlay = false }) => {
|
|
16
16
|
const [currentTID, setCurrentTID] = useState(inputTID ?? 0);
|
|
17
17
|
const [mruTIDs, setMruTIDs] = useState([]);
|
|
18
18
|
const [currentMruTID, setCurrentMruTID] = useState(0);
|
|
@@ -51,7 +51,7 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
|
|
|
51
51
|
setMruTIDs(newMruTIDS);
|
|
52
52
|
} }), [mruTIDs, currentMruTID, deviceType]);
|
|
53
53
|
const tmFormElement = useMemo(() => currentTID ?
|
|
54
|
-
_jsx(TMDcmtForm, { TID: currentTID, DID: undefined, groupId: 'tmForm', layoutMode: LayoutModes.Ark, onClose: deviceType === DeviceType.MOBILE ? () => setCurrentTID(undefined) : undefined, onSaveRecents: (TIDs) => setMruTIDs(TIDs), showDcmtFormSidebar: false, inputFile: inputFile, connectorFileSave: connectorFileSave, onSavedAsyncCallback: onSavedAsyncCallback, inputMids: inputMids })
|
|
54
|
+
_jsx(TMDcmtForm, { TID: currentTID, DID: undefined, groupId: 'tmForm', layoutMode: LayoutModes.Ark, onClose: deviceType === DeviceType.MOBILE ? () => setCurrentTID(undefined) : undefined, onSaveRecents: (TIDs) => setMruTIDs(TIDs), showDcmtFormSidebar: false, inputFile: inputFile, connectorFileSave: connectorFileSave, onSavedAsyncCallback: onSavedAsyncCallback, inputMids: inputMids, enableDragDropOverlay: enableDragDropOverlay })
|
|
55
55
|
:
|
|
56
56
|
_jsx(TMPanel, { title: 'Archiviazione', allowMaximize: false, children: _jsxs(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: [_jsx(StyledToppyTextContainer, { children: _jsx(StyledToppyText, { children: SDKUI_Localizator.DcmtTypeSelect }) }), _jsx(StyledToppyImage, { src: Logo, alt: 'Toppy' })] }) }), [currentTID, deviceType, mruTIDs, inputFile, inputMids]);
|
|
57
57
|
const allInitialPanelVisibility = {
|
|
@@ -40,6 +40,7 @@ interface ITMDcmtFormProps {
|
|
|
40
40
|
}>;
|
|
41
41
|
onOpenS4TViewerRequest?: (dcmtInfo: Array<DcmtInfo>, onRefreshSearchAsync?: (() => Promise<void>)) => void;
|
|
42
42
|
s4TViewerDialogComponent?: React.ReactNode;
|
|
43
|
+
enableDragDropOverlay?: boolean;
|
|
43
44
|
}
|
|
44
45
|
declare const TMDcmtForm: React.FC<ITMDcmtFormProps>;
|
|
45
46
|
export default TMDcmtForm;
|
|
@@ -36,7 +36,7 @@ import TMBlogCommentForm from '../blog/TMBlogCommentForm';
|
|
|
36
36
|
import WFDiagram from '../workflow/diagram/WFDiagram';
|
|
37
37
|
let abortControllerLocal = new AbortController();
|
|
38
38
|
//#endregion
|
|
39
|
-
const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes.Update, onClose, onSavedAsyncCallback, TID, DID, formMode = FormModes.Update, canNext, canPrev, count, itemIndex, onNext, onPrev, allowNavigation = true, allowRelations = true, isClosable = false, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, showDcmtFormSidebar = true, invokedByTodo = false, titleModal, isModal = false, widthModal = "100%", heightModal = "100%", groupId, onWFOperationCompleted, onTaskCompleted, inputFile = null, taskFormDialogComponent, taskMoreInfo, connectorFileSave = undefined, inputMids = [], onOpenS4TViewerRequest, s4TViewerDialogComponent }) => {
|
|
39
|
+
const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes.Update, onClose, onSavedAsyncCallback, TID, DID, formMode = FormModes.Update, canNext, canPrev, count, itemIndex, onNext, onPrev, allowNavigation = true, allowRelations = true, isClosable = false, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, showDcmtFormSidebar = true, invokedByTodo = false, titleModal, isModal = false, widthModal = "100%", heightModal = "100%", groupId, onWFOperationCompleted, onTaskCompleted, inputFile = null, taskFormDialogComponent, taskMoreInfo, connectorFileSave = undefined, inputMids = [], onOpenS4TViewerRequest, s4TViewerDialogComponent, enableDragDropOverlay = false }) => {
|
|
40
40
|
const [id, setID] = useState('');
|
|
41
41
|
const [showWaitPanelLocal, setShowWaitPanelLocal] = useState(false);
|
|
42
42
|
const [waitPanelTitleLocal, setWaitPanelTitleLocal] = useState('');
|
|
@@ -551,7 +551,7 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
|
|
|
551
551
|
const tmSysMetadata = useMemo(() => _jsx(TMMetadataValues, { layoutMode: layoutMode, openChooserBySingleClick: !isOpenDistinctValues, TID: TID, isReadOnly: true, deviceType: deviceType, metadataValues: formData.filter(o => (o.mid != undefined && o.mid <= 100)), metadataValuesOrig: formData.filter(o => (o.mid != undefined && o.mid <= 100)), validationItems: [], inputMids: inputMids }), [TID, layoutMode, formData, deviceType, inputMids]);
|
|
552
552
|
const tmDcmtPreview = useMemo(() => _jsx(TMDcmtPreviewWrapper, { currentDcmt: currentDcmt, dcmtFile: dcmtFile ?? inputFile, deviceType: deviceType, fromDTD: fromDTD, layoutMode: layoutMode, onFileUpload: (setFile) => {
|
|
553
553
|
setDcmtFile(setFile);
|
|
554
|
-
} }), [currentDcmt, dcmtFile, deviceType, fromDTD, layoutMode, inputFile]);
|
|
554
|
+
}, enableDragDropOverlay: enableDragDropOverlay }), [currentDcmt, dcmtFile, deviceType, fromDTD, layoutMode, inputFile, enableDragDropOverlay]);
|
|
555
555
|
const tmWF = useMemo(() => {
|
|
556
556
|
if (isWFDataLoading) {
|
|
557
557
|
return (_jsx("div", { style: {
|
|
@@ -840,10 +840,10 @@ const WfButtonStateHandler = ({ isWFDisabled }) => {
|
|
|
840
840
|
}, [isWFDisabled, setToolbarButtonDisabled]);
|
|
841
841
|
return null; // Non renderizza elementi nel DOM
|
|
842
842
|
};
|
|
843
|
-
const TMDcmtPreviewWrapper = ({ currentDcmt, layoutMode, fromDTD, dcmtFile, deviceType, isVisible, onFileUpload }) => {
|
|
843
|
+
const TMDcmtPreviewWrapper = ({ currentDcmt, layoutMode, fromDTD, dcmtFile, deviceType, isVisible, onFileUpload, enableDragDropOverlay = false }) => {
|
|
844
844
|
const { setPanelVisibilityById, toggleMaximize, isResizingActive, countVisibleLeafPanels, setToolbarButtonDisabled } = useTMPanelManagerContext();
|
|
845
845
|
const isMobile = deviceType === DeviceType.MOBILE;
|
|
846
846
|
return (layoutMode === LayoutModes.Update ?
|
|
847
847
|
_jsx(TMDcmtPreview, { isVisible: isVisible, onClosePanel: (!isMobile && countVisibleLeafPanels() > 1) ? () => setPanelVisibilityById('tmDcmtPreview', false) : undefined, allowMaximize: !isMobile && countVisibleLeafPanels() > 1, onMaximizePanel: (!isMobile && countVisibleLeafPanels() > 1) ? () => toggleMaximize("tmDcmtPreview") : undefined, dcmtData: currentDcmt, isResizingActive: isResizingActive }) :
|
|
848
|
-
_jsx(TMFileUploader, { onFileUpload: onFileUpload, onClose: (!isMobile && countVisibleLeafPanels() > 1) ? () => setPanelVisibilityById('tmDcmtPreview', false) : undefined, isRequired: fromDTD?.archiveConstraint === ArchiveConstraints.ContentCompulsory && dcmtFile === null, defaultBlob: dcmtFile, deviceType: deviceType, isResizingActive: isResizingActive }));
|
|
848
|
+
_jsx(TMFileUploader, { onFileUpload: onFileUpload, onClose: (!isMobile && countVisibleLeafPanels() > 1) ? () => setPanelVisibilityById('tmDcmtPreview', false) : undefined, isRequired: fromDTD?.archiveConstraint === ArchiveConstraints.ContentCompulsory && dcmtFile === null, defaultBlob: dcmtFile, deviceType: deviceType, isResizingActive: isResizingActive, enableDragDropOverlay: enableDragDropOverlay }));
|
|
849
849
|
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import Toppy from '../../../assets/Toppy-generico.png';
|
|
4
|
+
const TMDragDropOverlay = (props) => {
|
|
5
|
+
const { handleFile, refocusAfterFileInput } = props;
|
|
6
|
+
const [dragOver, setDragOver] = useState(false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const handleWindowDragEnter = (e) => {
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
setDragOver(true);
|
|
11
|
+
};
|
|
12
|
+
const handleWindowDragOver = (e) => {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
};
|
|
15
|
+
const handleWindowDragLeave = (e) => {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
if (e.clientX === 0 && e.clientY === 0) {
|
|
18
|
+
setDragOver(false);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const handleWindowDrop = (e) => {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
setDragOver(false);
|
|
24
|
+
const file = e.dataTransfer?.files?.[0];
|
|
25
|
+
if (file)
|
|
26
|
+
handleFile(file);
|
|
27
|
+
refocusAfterFileInput();
|
|
28
|
+
};
|
|
29
|
+
window.addEventListener('dragenter', handleWindowDragEnter);
|
|
30
|
+
window.addEventListener('dragover', handleWindowDragOver);
|
|
31
|
+
window.addEventListener('dragleave', handleWindowDragLeave);
|
|
32
|
+
window.addEventListener('drop', handleWindowDrop);
|
|
33
|
+
return () => {
|
|
34
|
+
window.removeEventListener('dragenter', handleWindowDragEnter);
|
|
35
|
+
window.removeEventListener('dragover', handleWindowDragOver);
|
|
36
|
+
window.removeEventListener('dragleave', handleWindowDragLeave);
|
|
37
|
+
window.removeEventListener('drop', handleWindowDrop);
|
|
38
|
+
};
|
|
39
|
+
}, [handleFile, refocusAfterFileInput]);
|
|
40
|
+
return (_jsxs("div", { style: {
|
|
41
|
+
display: 'flex',
|
|
42
|
+
opacity: dragOver ? 1 : 0,
|
|
43
|
+
pointerEvents: dragOver ? 'auto' : 'none',
|
|
44
|
+
position: 'fixed',
|
|
45
|
+
top: 0,
|
|
46
|
+
left: 0,
|
|
47
|
+
width: '100%',
|
|
48
|
+
height: '100%',
|
|
49
|
+
background: 'rgba(0,0,0,0.5)',
|
|
50
|
+
zIndex: 999999,
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
color: '#fff',
|
|
54
|
+
fontSize: '1.8rem',
|
|
55
|
+
fontWeight: 700,
|
|
56
|
+
borderRadius: 12,
|
|
57
|
+
cursor: 'copy',
|
|
58
|
+
boxShadow: '0 8px 20px rgba(0,0,0,0.3)',
|
|
59
|
+
backdropFilter: 'blur(5px)',
|
|
60
|
+
transition: 'opacity 0.2s, transform 0.2s, background 0.2s',
|
|
61
|
+
}, onDragEnter: (e) => { e.preventDefault(); e.stopPropagation(); setDragOver(true); }, onDragOver: (e) => { e.preventDefault(); e.stopPropagation(); setDragOver(true); }, onDragLeave: (e) => {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
// Solo se il cursore ha lasciato il div principale
|
|
65
|
+
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
66
|
+
setDragOver(false);
|
|
67
|
+
}
|
|
68
|
+
}, onDrop: (e) => {
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
const file = e.dataTransfer.files[0];
|
|
72
|
+
if (file)
|
|
73
|
+
handleFile(file);
|
|
74
|
+
refocusAfterFileInput();
|
|
75
|
+
setDragOver(false);
|
|
76
|
+
}, children: [_jsx("div", { onClick: () => {
|
|
77
|
+
setDragOver(false);
|
|
78
|
+
handleFile(null);
|
|
79
|
+
}, style: {
|
|
80
|
+
position: 'absolute',
|
|
81
|
+
top: 15,
|
|
82
|
+
right: 20,
|
|
83
|
+
cursor: 'pointer',
|
|
84
|
+
fontSize: '1.8rem',
|
|
85
|
+
fontWeight: 700,
|
|
86
|
+
color: '#fff',
|
|
87
|
+
}, children: _jsx("i", { className: 'dx-icon-close', style: { fontSize: 25 } }) }), _jsxs("div", { style: {
|
|
88
|
+
display: 'flex',
|
|
89
|
+
flexDirection: 'column',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
gap: 20,
|
|
92
|
+
textAlign: 'center',
|
|
93
|
+
}, children: [_jsx("img", { src: Toppy, alt: "Toppy", style: { width: 80, height: 'auto' } }), _jsx("div", { style: { fontSize: '1.6rem' }, children: "Rilascia il tuo file qui" })] })] }));
|
|
94
|
+
};
|
|
95
|
+
export default TMDragDropOverlay;
|
|
@@ -10,7 +10,8 @@ import { DeviceType } from '../../base/TMDeviceProvider';
|
|
|
10
10
|
import TMTooltip from '../../base/TMTooltip';
|
|
11
11
|
import { TMFileViewer, StyledHeaderIcon } from './TMDcmtPreview';
|
|
12
12
|
import TMPanel from '../../base/TMPanel';
|
|
13
|
-
|
|
13
|
+
import TMDragDropOverlay from './TMDragDropOverlay';
|
|
14
|
+
const TMFileUploader = ({ deviceType = DeviceType.DESKTOP, onClose, onFileUpload, isRequired = false, defaultBlob = null, isResizingActive, showTMPanel = true, enableDragDropOverlay = false }) => {
|
|
14
15
|
const [dragOver, setDragOver] = useState(false);
|
|
15
16
|
const [uploadedFile, setUploadedFile] = useState(defaultBlob);
|
|
16
17
|
const [fileName, setFileName] = useState('');
|
|
@@ -82,10 +83,10 @@ const TMFileUploader = ({ deviceType = DeviceType.DESKTOP, onClose, onFileUpload
|
|
|
82
83
|
document.getElementById('fileInput')?.click();
|
|
83
84
|
}, []);
|
|
84
85
|
let content = !uploadedFile ?
|
|
85
|
-
_jsx("div", { style: { display: 'flex', gap: 10, width: '100%', height: '100%' }, children: _jsxs(UploadContainer, { ref: uploaderRef, tabIndex: 0, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, style: { backgroundColor: dragOver ? '#76b1e6' : 'white' }, onDoubleClick: browseHandler, "$isRequired": isRequired, children: [_jsx("div", { style: { display: 'flex', gap: '10px', flexDirection: 'column', position: 'absolute', right: 5, top: 5 }, children: _jsx(TMButton, { btnStyle: 'icon', caption: 'Sfoglia', color: isRequired && !uploadedFile ? 'error' : 'primary', onClick: browseHandler, icon: _jsx(IconFolderOpen, { fontSize: 22 }) }) }), _jsx("p", { style: { fontSize: '1.2rem', fontWeight: 'bold' }, children: deviceType === DeviceType.MOBILE ? 'Clicca per sfogliare il tuo file' : 'Trascina il tuo file
|
|
86
|
+
_jsx("div", { style: { display: 'flex', gap: 10, width: '100%', height: '100%' }, children: _jsxs(UploadContainer, { ref: uploaderRef, tabIndex: 0, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, style: { backgroundColor: dragOver ? '#76b1e6' : 'white' }, onDoubleClick: browseHandler, "$isRequired": isRequired, children: [_jsx("div", { style: { display: 'flex', gap: '10px', flexDirection: 'column', position: 'absolute', right: 5, top: 5 }, children: _jsx(TMButton, { btnStyle: 'icon', caption: 'Sfoglia', color: isRequired && !uploadedFile ? 'error' : 'primary', onClick: browseHandler, icon: _jsx(IconFolderOpen, { fontSize: 22 }) }) }), _jsx("p", { style: { fontSize: '1.2rem', fontWeight: 'bold' }, children: deviceType === DeviceType.MOBILE ? 'Clicca per sfogliare il tuo file' : 'Trascina il tuo file o fai doppio click per sfogliarlo' }), isRequired && _jsxs("p", { style: { fontWeight: 'bold' }, children: [" ", SDKUI_Localizator.RequiredField, " "] })] }) }) :
|
|
86
87
|
_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 10, width: '100%', height: '100%' }, children: [_jsxs("div", { style: { backgroundColor: 'white', padding: '5px 10px', borderRadius: 8, display: 'flex', alignItems: 'center', justifyContent: 'space-between', color: TMColors.primaryColor }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 5 }, children: [_jsx("p", { children: "File name:" }), _jsxs("div", { style: { fontWeight: 'bold' }, children: [fileName, " ", _jsxs("span", { children: [" ", ` (${formatBytes(fileSize)})`, " "] })] })] }), uploadedFile && _jsx(TMButton, { btnStyle: 'icon', color: 'error', caption: 'Pulisci', onClick: () => clearFile(true), icon: _jsx(IconClear, { fontSize: 22 }) })] }), extensionHandler(fileExt) === FileExtensionHandler.READY_TO_SHOW ? _jsx(TMFileViewer, { fileBlob: uploadedFile, isResizingActive: isResizingActive }) :
|
|
87
88
|
_jsx("div", { style: { backgroundColor: '#f6dbdb', padding: '5px 10px', borderRadius: 8, display: 'flex', alignItems: 'center', justifyContent: 'space-between', color: TMColors.error }, children: _jsxs("div", { children: [" ", 'Anteprima non disponibile.', fileExt && _jsx("b", { children: ` (*.${fileExt})` })] }) })] });
|
|
88
|
-
const innerContent = (_jsxs("div", { style: { width: '100%', height: '100%', padding: '2px', display: 'flex', flexDirection: 'column', gap: 10 }, children: [_jsx(HiddenInput, { id: "fileInput", type: "file", onChange: handleInputChange }), content] }));
|
|
89
|
+
const innerContent = (_jsxs("div", { style: { width: '100%', height: '100%', padding: '2px', display: 'flex', flexDirection: 'column', gap: 10 }, children: [_jsx(HiddenInput, { id: "fileInput", type: "file", onChange: handleInputChange }), enableDragDropOverlay && _jsx(TMDragDropOverlay, { handleFile: handleFile, refocusAfterFileInput: refocusAfterFileInput }), content] }));
|
|
89
90
|
return showTMPanel ? (_jsx(TMPanel, { ref: fileUploaderPanelRef, panelID: 'file-uploader-panel', title: SDKUI_Localizator.FileUpload, onBack: deviceType === DeviceType.MOBILE ? () => onClose?.() : undefined, toolbar: deviceType !== DeviceType.MOBILE ? (_jsx(StyledHeaderIcon, { onClick: onClose, "$color": 'white', children: _jsx(TMTooltip, { content: SDKUI_Localizator.Close, children: _jsx(IconCloseOutline, {}) }) })) : undefined, children: innerContent })) : (innerContent);
|
|
90
91
|
};
|
|
91
92
|
const UploadContainer = styled.div `
|