@topconsultnpm/sdkui-react 6.20.0-dev1.6 → 6.20.0-dev1.60
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/NewComponents/ContextMenu/TMContextMenu.d.ts +4 -0
- package/lib/components/NewComponents/ContextMenu/TMContextMenu.js +416 -0
- package/lib/components/NewComponents/ContextMenu/hooks.d.ts +13 -0
- package/lib/components/NewComponents/ContextMenu/hooks.js +61 -0
- package/lib/components/NewComponents/ContextMenu/index.d.ts +5 -0
- package/lib/components/NewComponents/ContextMenu/index.js +3 -0
- package/lib/components/NewComponents/ContextMenu/styles.d.ts +31 -0
- package/lib/components/NewComponents/ContextMenu/styles.js +336 -0
- package/lib/components/NewComponents/ContextMenu/types.d.ts +39 -0
- package/lib/components/NewComponents/ContextMenu/types.js +1 -0
- package/lib/components/NewComponents/ContextMenu/useLongPress.d.ts +21 -0
- package/lib/components/NewComponents/ContextMenu/useLongPress.js +112 -0
- package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.d.ts +4 -0
- package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.js +745 -0
- package/lib/components/NewComponents/FloatingMenuBar/index.d.ts +2 -0
- package/lib/components/NewComponents/FloatingMenuBar/index.js +2 -0
- package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +51 -0
- package/lib/components/NewComponents/FloatingMenuBar/styles.js +385 -0
- package/lib/components/NewComponents/FloatingMenuBar/types.d.ts +29 -0
- package/lib/components/NewComponents/FloatingMenuBar/types.js +1 -0
- package/lib/components/base/TMAccordionNew.js +35 -14
- package/lib/components/base/TMCustomButton.js +61 -17
- package/lib/components/base/TMDataGrid.d.ts +7 -4
- package/lib/components/base/TMDataGrid.js +142 -11
- package/lib/components/choosers/TMMetadataChooser.js +8 -1
- package/lib/components/editors/TMMetadataValues.js +23 -5
- package/lib/components/editors/TMTextBox.js +6 -3
- package/lib/components/features/documents/TMDcmtForm.d.ts +13 -1
- package/lib/components/features/documents/TMDcmtForm.js +386 -194
- package/lib/components/features/documents/TMDcmtPreview.js +40 -69
- package/lib/components/features/documents/TMMasterDetailDcmts.js +37 -52
- package/lib/components/features/search/TMDcmtCheckoutInfoForm.d.ts +8 -0
- package/lib/components/features/search/{TMSearchResultCheckoutInfoForm.js → TMDcmtCheckoutInfoForm.js} +5 -10
- package/lib/components/features/search/TMSavedQuerySelector.js +72 -67
- package/lib/components/features/search/TMSearch.js +30 -5
- package/lib/components/features/search/TMSearchQueryPanel.js +13 -12
- package/lib/components/features/search/TMSearchResult.js +57 -216
- package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +3 -3
- package/lib/components/features/search/TMSearchResultsMenuItems.js +205 -169
- package/lib/components/features/search/TMSignSettingsForm.js +1 -1
- package/lib/components/features/search/TMSignatureInfoContent.d.ts +6 -0
- package/lib/components/features/search/TMSignatureInfoContent.js +140 -0
- package/lib/components/features/search/TMViewHistoryDcmt.js +1 -1
- package/lib/components/features/tasks/TMTaskForm.js +20 -1
- package/lib/components/features/tasks/TMTasksUtils.d.ts +2 -2
- package/lib/components/features/tasks/TMTasksUtils.js +62 -52
- package/lib/components/features/tasks/TMTasksView.js +6 -6
- package/lib/components/features/workflow/TMWorkflowPopup.d.ts +32 -2
- package/lib/components/features/workflow/TMWorkflowPopup.js +112 -14
- package/lib/components/features/workflow/diagram/WFDiagram.js +2 -2
- package/lib/components/forms/Login/LoginValidatorService.d.ts +2 -0
- package/lib/components/forms/Login/LoginValidatorService.js +7 -2
- package/lib/components/forms/Login/TMLoginForm.js +34 -6
- package/lib/components/forms/TMChooserForm.js +1 -1
- package/lib/components/grids/TMBlogsPost.js +55 -30
- package/lib/components/index.d.ts +2 -0
- package/lib/components/index.js +2 -0
- package/lib/components/viewers/TMDataListItemViewer.d.ts +2 -1
- package/lib/components/viewers/TMDataListItemViewer.js +12 -11
- package/lib/css/tm-sdkui.css +1 -1
- package/lib/helper/SDKUI_Globals.d.ts +17 -0
- package/lib/helper/SDKUI_Globals.js +9 -0
- package/lib/helper/SDKUI_Localizator.d.ts +9 -1
- package/lib/helper/SDKUI_Localizator.js +87 -1
- package/lib/helper/TMIcons.d.ts +2 -0
- package/lib/helper/TMIcons.js +6 -0
- package/lib/helper/TMPdfViewer.d.ts +8 -0
- package/lib/helper/TMPdfViewer.js +368 -0
- package/lib/helper/checkinCheckoutManager.d.ts +32 -2
- package/lib/helper/checkinCheckoutManager.js +115 -38
- package/lib/helper/devextremeCustomMessages.d.ts +30 -0
- package/lib/helper/devextremeCustomMessages.js +30 -0
- package/lib/helper/helpers.d.ts +2 -1
- package/lib/helper/helpers.js +14 -3
- package/lib/helper/index.d.ts +1 -0
- package/lib/helper/index.js +1 -0
- package/lib/helper/queryHelper.js +29 -0
- package/lib/hooks/useCheckInOutOperations.d.ts +28 -0
- package/lib/hooks/useCheckInOutOperations.js +223 -0
- package/lib/hooks/useWorkflowApprove.d.ts +4 -0
- package/lib/hooks/useWorkflowApprove.js +14 -1
- package/lib/ts/types.d.ts +56 -1
- package/package.json +5 -2
- package/lib/components/features/search/TMSearchResultCheckoutInfoForm.d.ts +0 -8
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState, useRef, useCallback } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { LoadIndicator } from 'devextreme-react/load-indicator';
|
|
5
|
+
import { IconCloseOutline } from "./TMIcons";
|
|
6
|
+
import { SDKUI_Localizator } from "./SDKUI_Localizator";
|
|
7
|
+
import { TMColors } from "../utils/theme";
|
|
8
|
+
import { TMMessageBoxManager, ButtonNames } from "../components/base/TMPopUp";
|
|
9
|
+
// Dynamic imports for optional dependencies
|
|
10
|
+
let pdfjs;
|
|
11
|
+
let Document;
|
|
12
|
+
let Page;
|
|
13
|
+
let isReactPdfAvailable = false;
|
|
14
|
+
try {
|
|
15
|
+
const reactPdf = require('react-pdf');
|
|
16
|
+
pdfjs = reactPdf.pdfjs;
|
|
17
|
+
Document = reactPdf.Document;
|
|
18
|
+
Page = reactPdf.Page;
|
|
19
|
+
// Configura il worker PDF.js PRIMA del rendering
|
|
20
|
+
pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`;
|
|
21
|
+
isReactPdfAvailable = true;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
// react-pdf not available - will use iframe fallback
|
|
25
|
+
// console.warn('react-pdf is not installed. TMPdfViewer will use iframe fallback.');
|
|
26
|
+
}
|
|
27
|
+
const PDFViewerContainer = styled.div `
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
overflow-y: auto;
|
|
31
|
+
overflow-x: hidden;
|
|
32
|
+
background-color: #f5f5f5;
|
|
33
|
+
position: relative;
|
|
34
|
+
|
|
35
|
+
.react-pdf__Document {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
align-items: center;
|
|
39
|
+
gap: 10px;
|
|
40
|
+
padding: 10px 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.react-pdf__Page {
|
|
44
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
45
|
+
margin: 0 auto;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.react-pdf__Page__canvas {
|
|
49
|
+
max-width: 100%;
|
|
50
|
+
height: auto !important;
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
const LoadingOverlay = styled.div `
|
|
54
|
+
position: absolute;
|
|
55
|
+
top: 0;
|
|
56
|
+
left: 0;
|
|
57
|
+
width: 100%;
|
|
58
|
+
height: 100%;
|
|
59
|
+
background-color: rgba(245, 245, 245, 0.95);
|
|
60
|
+
display: flex;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
align-items: center;
|
|
63
|
+
z-index: 1000;
|
|
64
|
+
`;
|
|
65
|
+
const TMPdfViewer = (props) => {
|
|
66
|
+
const { pdfBlob, title = "Anteprima PDF", isResizingActive, enableFitToWidth = false } = props;
|
|
67
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
68
|
+
const [totalPagesNumber, setTotalPagesNumber] = useState(0);
|
|
69
|
+
const [loadedPagesNumber, setLoadedPagesNumber] = useState(0);
|
|
70
|
+
const [visiblePages, setVisiblePages] = useState(new Set([1]));
|
|
71
|
+
const [pdfUrl, setPdfUrl] = useState("");
|
|
72
|
+
const [hasUnsafeContent, setHasUnsafeContent] = useState(false);
|
|
73
|
+
const [isCheckingPdf, setIsCheckingPdf] = useState(true);
|
|
74
|
+
const [jsMatches, setJsMatches] = useState([]);
|
|
75
|
+
const observerRef = useRef(null);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
const checkIsMobile = () => {
|
|
78
|
+
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
|
79
|
+
// Detect actual mobile/tablet devices
|
|
80
|
+
const isMobileDevice =
|
|
81
|
+
// User agent detection (phones and tablets)
|
|
82
|
+
/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent) ||
|
|
83
|
+
// Media query for touch devices with coarse pointer (more reliable than screen width)
|
|
84
|
+
(window.matchMedia?.('(hover: none) and (pointer: coarse)').matches ?? false) ||
|
|
85
|
+
// Touch-capable devices excluding desktop OS
|
|
86
|
+
(navigator.maxTouchPoints > 1 && !/Win|Mac|Linux x86_64/i.test(userAgent));
|
|
87
|
+
setIsMobile(isMobileDevice);
|
|
88
|
+
};
|
|
89
|
+
const checkPdfForJavaScript = async () => {
|
|
90
|
+
setIsCheckingPdf(true);
|
|
91
|
+
try {
|
|
92
|
+
// Legge il PDF come testo per cercare pattern di JavaScript
|
|
93
|
+
const arrayBuffer = await pdfBlob.arrayBuffer();
|
|
94
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
|
95
|
+
const text = new TextDecoder('latin1').decode(uint8Array);
|
|
96
|
+
// Pattern specifici per rilevare JavaScript effettivo nelle strutture PDF
|
|
97
|
+
const jsPatterns = [
|
|
98
|
+
// Esempio: /JavaScript [ (app.alert('Hello');) ]
|
|
99
|
+
{ name: 'JavaScript Dictionary Entry', pattern: /\/JavaScript\s*[(\[<][\s\S]*?[)\]>]/i },
|
|
100
|
+
// Esempio: /JS 15 0 R (riferimento a un oggetto JavaScript)
|
|
101
|
+
{ name: 'JavaScript Object Reference', pattern: /\/JS\s+\d+\s+\d+\s+R/i },
|
|
102
|
+
// Esempio: /JS (app.alert('Click');) o /JS <hexstring>
|
|
103
|
+
{ name: 'Inline JavaScript Code', pattern: /\/JS\s*[(<][\s\S]*?[)>]/i },
|
|
104
|
+
// Esempio: /AA << /O << /S /JavaScript /JS (app.alert('Open');) >> >>
|
|
105
|
+
{ name: 'Additional Actions (AA) with JavaScript', pattern: /\/AA\s*<<[\s\S]*?\/JS[\s\S]*?>>/is },
|
|
106
|
+
// Esempio: /OpenAction << /S /JavaScript /JS (this.print();) >>
|
|
107
|
+
{ name: 'Document Open Action with JavaScript', pattern: /\/OpenAction\s*<<[\s\S]*?\/JS[\s\S]*?>>/is },
|
|
108
|
+
// Esempio: /Names << /JavaScript [ (MyScript) 12 0 R ] >>
|
|
109
|
+
{ name: 'Named JavaScript Functions', pattern: /\/Names\s*<<[\s\S]*?\/JavaScript[\s\S]*?>>/is },
|
|
110
|
+
];
|
|
111
|
+
let foundJS = false;
|
|
112
|
+
const matches = [];
|
|
113
|
+
jsPatterns.forEach(({ name, pattern }) => {
|
|
114
|
+
const match = text.match(pattern);
|
|
115
|
+
if (match) {
|
|
116
|
+
foundJS = true;
|
|
117
|
+
const matchIndex = match.index || 0;
|
|
118
|
+
const contextStart = Math.max(0, matchIndex - 50);
|
|
119
|
+
const contextEnd = Math.min(text.length, matchIndex + match[0].length + 50);
|
|
120
|
+
const context = text.substring(contextStart, contextEnd);
|
|
121
|
+
matches.push({
|
|
122
|
+
name,
|
|
123
|
+
pattern: pattern.toString(),
|
|
124
|
+
match: match[0],
|
|
125
|
+
context: context.replace(/[\r\n]+/g, ' ').trim()
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
setHasUnsafeContent(foundJS);
|
|
130
|
+
setJsMatches(matches);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
// console.error('Errore nella validazione del PDF:', error);
|
|
134
|
+
// In caso di errore, permetti la visualizzazione
|
|
135
|
+
setHasUnsafeContent(false);
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
setIsCheckingPdf(false);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
checkIsMobile();
|
|
142
|
+
checkPdfForJavaScript();
|
|
143
|
+
// Create URL for iframe
|
|
144
|
+
const url = URL.createObjectURL(pdfBlob);
|
|
145
|
+
setPdfUrl(url);
|
|
146
|
+
return () => {
|
|
147
|
+
if (url) {
|
|
148
|
+
URL.revokeObjectURL(url);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}, [pdfBlob]);
|
|
152
|
+
/**
|
|
153
|
+
* Callback per l'Intersection Observer che gestisce il lazy loading delle pagine PDF.
|
|
154
|
+
* Viene chiamato ogni volta che una pagina entra o esce dal viewport (area visibile).
|
|
155
|
+
*
|
|
156
|
+
* - Monitora quando gli elementi (pagine) diventano visibili
|
|
157
|
+
* - Aggiunge il numero di pagina al Set delle pagine visibili quando entra nel viewport
|
|
158
|
+
* - Il rootMargin di 500px carica le pagine prima che siano effettivamente visibili (preloading)
|
|
159
|
+
*/
|
|
160
|
+
const pageObserverCallback = useCallback((entries) => {
|
|
161
|
+
entries.forEach(entry => {
|
|
162
|
+
const pageNum = parseInt(entry.target.getAttribute('data-page-number') || '0');
|
|
163
|
+
if (entry.isIntersecting) {
|
|
164
|
+
// Aggiunge la pagina al Set di quelle da renderizzare
|
|
165
|
+
setVisiblePages(prev => new Set([...prev, pageNum]));
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}, []);
|
|
169
|
+
/**
|
|
170
|
+
* Crea e configura l'Intersection Observer per il lazy loading.
|
|
171
|
+
*
|
|
172
|
+
* Configurazione:
|
|
173
|
+
* - root: null → osserva rispetto al viewport del browser
|
|
174
|
+
* - rootMargin: '500px' → inizia il caricamento 500px prima che la pagina sia visibile (buffer)
|
|
175
|
+
* - threshold: 0.01 → trigger quando anche solo l'1% dell'elemento è visibile
|
|
176
|
+
*
|
|
177
|
+
* Benefici:
|
|
178
|
+
* - Non blocca l'UI durante il rendering
|
|
179
|
+
* - Carica solo le pagine necessarie
|
|
180
|
+
* - Migliora le performance su PDF con molte pagine
|
|
181
|
+
*/
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
observerRef.current = new IntersectionObserver(pageObserverCallback, {
|
|
184
|
+
root: null,
|
|
185
|
+
rootMargin: '500px',
|
|
186
|
+
threshold: 0.01
|
|
187
|
+
});
|
|
188
|
+
return () => {
|
|
189
|
+
// Cleanup: disconnette l'observer quando il componente viene smontato
|
|
190
|
+
observerRef.current?.disconnect();
|
|
191
|
+
};
|
|
192
|
+
}, [pageObserverCallback]);
|
|
193
|
+
const showMatchDetails = () => {
|
|
194
|
+
const highlightMatch = (context, matchText) => {
|
|
195
|
+
const matchIndex = context.indexOf(matchText);
|
|
196
|
+
if (matchIndex === -1) {
|
|
197
|
+
// Se non trova il match esatto, prova con una versione normalizzata
|
|
198
|
+
const normalizedContext = context.replace(/\s+/g, ' ');
|
|
199
|
+
const normalizedMatch = matchText.replace(/\s+/g, ' ');
|
|
200
|
+
const normalizedIndex = normalizedContext.indexOf(normalizedMatch);
|
|
201
|
+
if (normalizedIndex === -1) {
|
|
202
|
+
// Se ancora non trova, mostra tutto in grassetto rosso
|
|
203
|
+
return _jsx("strong", { style: { color: '#d32f2f', fontWeight: 'bold' }, children: context });
|
|
204
|
+
}
|
|
205
|
+
return (_jsxs(_Fragment, { children: [normalizedContext.substring(0, normalizedIndex), _jsx("strong", { style: { color: '#d32f2f', fontWeight: 'bold', background: '#ffebee' }, children: normalizedContext.substring(normalizedIndex, normalizedIndex + normalizedMatch.length) }), normalizedContext.substring(normalizedIndex + normalizedMatch.length)] }));
|
|
206
|
+
}
|
|
207
|
+
return (_jsxs(_Fragment, { children: [context.substring(0, matchIndex), _jsx("strong", { style: { color: '#d32f2f', fontWeight: 'bold', background: '#ffebee' }, children: context.substring(matchIndex, matchIndex + matchText.length) }), context.substring(matchIndex + matchText.length)] }));
|
|
208
|
+
};
|
|
209
|
+
TMMessageBoxManager.show({
|
|
210
|
+
title: `${SDKUI_Localizator.Attention}: ${SDKUI_Localizator.PotentiallyUnsafeContent}`,
|
|
211
|
+
buttons: [ButtonNames.OK],
|
|
212
|
+
showToppy: false,
|
|
213
|
+
resizable: true,
|
|
214
|
+
initialWidth: !isMobile ? '800px' : undefined,
|
|
215
|
+
message: (_jsxs("div", { style: { maxHeight: '500px', overflowY: 'auto', padding: '10px', lineHeight: '1.6' }, children: [_jsxs("div", { style: {
|
|
216
|
+
marginBottom: '20px',
|
|
217
|
+
padding: '12px',
|
|
218
|
+
background: '#fff3cd',
|
|
219
|
+
border: '1px solid #ffc107',
|
|
220
|
+
borderRadius: '6px',
|
|
221
|
+
fontSize: '14px',
|
|
222
|
+
wordBreak: 'normal',
|
|
223
|
+
hyphens: 'none'
|
|
224
|
+
}, children: [_jsxs("strong", { children: [SDKUI_Localizator.Attention, ":"] }), " ", SDKUI_Localizator.PotentiallyUnsafeCodePatternsDetected.replaceParams(jsMatches.length.toString())] }), jsMatches.length > 0 ? (jsMatches.map((match, index) => (_jsxs("div", { style: {
|
|
225
|
+
marginBottom: '16px',
|
|
226
|
+
padding: '16px',
|
|
227
|
+
border: '1px solid #ffcdd2',
|
|
228
|
+
borderRadius: '8px',
|
|
229
|
+
background: '#fff',
|
|
230
|
+
boxShadow: '0 1px 3px rgba(0,0,0,0.1)'
|
|
231
|
+
}, children: [_jsx("div", { style: {
|
|
232
|
+
marginBottom: '12px',
|
|
233
|
+
paddingBottom: '8px',
|
|
234
|
+
borderBottom: '2px solid #f44336'
|
|
235
|
+
}, children: _jsxs("strong", { style: {
|
|
236
|
+
color: '#d32f2f',
|
|
237
|
+
fontSize: '15px',
|
|
238
|
+
display: 'flex',
|
|
239
|
+
alignItems: 'center',
|
|
240
|
+
gap: '8px'
|
|
241
|
+
}, children: [_jsx("span", { style: {
|
|
242
|
+
background: '#f44336',
|
|
243
|
+
color: '#fff',
|
|
244
|
+
borderRadius: '50%',
|
|
245
|
+
width: '24px',
|
|
246
|
+
height: '24px',
|
|
247
|
+
display: 'inline-flex',
|
|
248
|
+
alignItems: 'center',
|
|
249
|
+
justifyContent: 'center',
|
|
250
|
+
fontSize: '13px',
|
|
251
|
+
fontWeight: 'bold'
|
|
252
|
+
}, children: index + 1 }), match.name] }) }), _jsx("div", { style: { fontSize: '13px' }, children: _jsx("div", { style: {
|
|
253
|
+
background: '#f5f5f5',
|
|
254
|
+
padding: '10px',
|
|
255
|
+
borderRadius: '4px',
|
|
256
|
+
borderLeft: '3px solid #f44336',
|
|
257
|
+
fontFamily: 'Consolas, Monaco, monospace',
|
|
258
|
+
fontSize: '12px',
|
|
259
|
+
wordBreak: 'break-all',
|
|
260
|
+
color: '#333',
|
|
261
|
+
maxHeight: '200px',
|
|
262
|
+
overflowY: 'auto',
|
|
263
|
+
userSelect: 'text'
|
|
264
|
+
}, children: highlightMatch(match.context, match.match) }) })] }, index)))) : (_jsx("div", { style: { textAlign: 'center', padding: '20px', color: '#999' }, children: "Nessun dettaglio disponibile" }))] }))
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
// Mostra loading durante la validazione
|
|
268
|
+
if (isCheckingPdf) {
|
|
269
|
+
return (_jsx(PDFViewerContainer, { children: _jsxs("div", { style: {
|
|
270
|
+
display: 'flex',
|
|
271
|
+
justifyContent: 'center',
|
|
272
|
+
alignItems: 'center',
|
|
273
|
+
height: '100%',
|
|
274
|
+
flexDirection: 'column',
|
|
275
|
+
gap: '10px'
|
|
276
|
+
}, children: [_jsx(LoadIndicator, { height: 60, width: 60 }), _jsx("div", { children: "Validazione PDF in corso..." })] }) }));
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Usa <iframe> nei seguenti casi:
|
|
280
|
+
* 1. react-pdf non è disponibile (libreria non installata)
|
|
281
|
+
* 2. Desktop E nessun contenuto JavaScript rilevato (visualizzazione nativa del browser più performante)
|
|
282
|
+
*
|
|
283
|
+
* L'iframe sfrutta il visualizzatore PDF nativo del browser, ma non può prevenire
|
|
284
|
+
* l'esecuzione di JavaScript embedded nel PDF.
|
|
285
|
+
*/
|
|
286
|
+
if (!isReactPdfAvailable || (!isMobile && !hasUnsafeContent && pdfUrl)) {
|
|
287
|
+
return (_jsx(PDFViewerContainer, { children: _jsx("iframe", { src: `${pdfUrl}#${enableFitToWidth ? 'view=FitH&' : ''}scrollbar=1`, title: title, style: {
|
|
288
|
+
width: '100%',
|
|
289
|
+
height: '100%',
|
|
290
|
+
border: 'none',
|
|
291
|
+
zIndex: 0,
|
|
292
|
+
pointerEvents: isResizingActive === true ? "none" : "auto"
|
|
293
|
+
} }, pdfUrl) }));
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Usa react-pdf nei seguenti casi:
|
|
297
|
+
* 1. Dispositivo mobile (migliore esperienza utente con lazy loading)
|
|
298
|
+
* 2. Desktop con contenuto JavaScript rilevato (rendering sicuro senza esecuzione di script)
|
|
299
|
+
*
|
|
300
|
+
* react-pdf renderizza il PDF come canvas, prevenendo l'esecuzione di JavaScript embedded,
|
|
301
|
+
* ma è meno performante dell'iframe nativo su desktop.
|
|
302
|
+
*/
|
|
303
|
+
return _jsxs(PDFViewerContainer, { style: { display: 'flex', flexDirection: 'column' }, children: [loadedPagesNumber === 0 && totalPagesNumber > 0 && _jsx(LoadingOverlay, { children: _jsxs("div", { style: {
|
|
304
|
+
display: 'flex',
|
|
305
|
+
justifyContent: 'center',
|
|
306
|
+
alignItems: 'center',
|
|
307
|
+
flexDirection: 'column',
|
|
308
|
+
gap: '10px'
|
|
309
|
+
}, children: [_jsx(LoadIndicator, { height: 60, width: 60 }), _jsxs("div", { children: [SDKUI_Localizator.Loading, "..."] })] }) }), _jsx("div", { style: {
|
|
310
|
+
display: loadedPagesNumber > 0 && totalPagesNumber > 0 ? 'block' : 'none',
|
|
311
|
+
flex: 1,
|
|
312
|
+
overflow: 'auto'
|
|
313
|
+
}, children: _jsx(Document, { file: pdfBlob, onLoadSuccess: ({ numPages }) => {
|
|
314
|
+
setTotalPagesNumber(numPages);
|
|
315
|
+
setLoadedPagesNumber(0);
|
|
316
|
+
}, loading: _jsxs("div", { style: {
|
|
317
|
+
display: 'flex',
|
|
318
|
+
justifyContent: 'center',
|
|
319
|
+
alignItems: 'center',
|
|
320
|
+
height: '100%',
|
|
321
|
+
flexDirection: 'column',
|
|
322
|
+
gap: '10px'
|
|
323
|
+
}, children: [_jsx(LoadIndicator, { height: 60, width: 60 }), _jsxs("div", { children: [SDKUI_Localizator.Loading, "..."] })] }), error: _jsxs("div", { style: {
|
|
324
|
+
display: 'flex',
|
|
325
|
+
justifyContent: 'center',
|
|
326
|
+
alignItems: 'center',
|
|
327
|
+
height: '100%',
|
|
328
|
+
flexDirection: 'column',
|
|
329
|
+
gap: '10px'
|
|
330
|
+
}, children: [_jsx(IconCloseOutline, { fontSize: 64, color: TMColors.error }), _jsx("div", { children: "Errore nel caricamento del PDF" })] }), children: Array.from(new Array(totalPagesNumber), (el, index) => {
|
|
331
|
+
const pageNumber = index + 1;
|
|
332
|
+
const shouldRender = visiblePages.has(pageNumber);
|
|
333
|
+
return (_jsx("div", { "data-page-number": pageNumber, ref: (el) => {
|
|
334
|
+
if (el && observerRef.current) {
|
|
335
|
+
observerRef.current.observe(el);
|
|
336
|
+
}
|
|
337
|
+
}, style: {
|
|
338
|
+
minHeight: shouldRender ? 'auto' : '1000px',
|
|
339
|
+
display: 'flex',
|
|
340
|
+
justifyContent: 'center',
|
|
341
|
+
alignItems: 'center'
|
|
342
|
+
}, children: shouldRender && (_jsx(Page, { pageNumber: pageNumber, renderTextLayer: false, renderAnnotationLayer: false, width: Math.min(window.innerWidth - 40, 1200), loading: _jsx("div", { style: { padding: '20px' }, children: _jsx(LoadIndicator, { height: 40, width: 40 }) }), onLoadSuccess: () => {
|
|
343
|
+
setLoadedPagesNumber(prev => prev + 1);
|
|
344
|
+
} })) }, `page_${pageNumber}`));
|
|
345
|
+
}) }) }), hasUnsafeContent && (_jsxs("div", { style: {
|
|
346
|
+
display: 'flex',
|
|
347
|
+
justifyContent: 'center',
|
|
348
|
+
alignItems: 'center',
|
|
349
|
+
padding: '12px 20px',
|
|
350
|
+
background: '#fff3cd',
|
|
351
|
+
borderTop: '2px solid #ffc107',
|
|
352
|
+
gap: '8px',
|
|
353
|
+
flexShrink: 0
|
|
354
|
+
}, children: [_jsxs("span", { style: {
|
|
355
|
+
color: '#856404',
|
|
356
|
+
whiteSpace: 'nowrap',
|
|
357
|
+
overflow: 'hidden',
|
|
358
|
+
textOverflow: 'ellipsis',
|
|
359
|
+
flex: 1
|
|
360
|
+
}, children: [_jsx("strong", { children: "Attenzione:" }), " Questo documento contiene contenuti potenzialmente non sicuri."] }), jsMatches.length > 0 && (_jsx("span", { className: "dx-icon-info", style: {
|
|
361
|
+
fontSize: '20px',
|
|
362
|
+
color: '#d32f2f',
|
|
363
|
+
cursor: 'pointer',
|
|
364
|
+
transition: 'color 0.2s',
|
|
365
|
+
marginLeft: '4px'
|
|
366
|
+
}, onClick: showMatchDetails, title: "Clicca per vedere i dettagli", onMouseEnter: (e) => e.currentTarget.style.color = '#b71c1c', onMouseLeave: (e) => e.currentTarget.style.color = '#d32f2f' }))] }))] });
|
|
367
|
+
};
|
|
368
|
+
export default TMPdfViewer;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { DcmtTypeDescriptor, FileDescriptor, UserDescriptor } from "@topconsultnpm/sdk-ts";
|
|
2
|
+
import { AccessLevels, DcmtTypeDescriptor, FileDescriptor, UserDescriptor } from "@topconsultnpm/sdk-ts";
|
|
3
3
|
import { DcmtInfo, DownloadModes, DownloadTypes } from "../ts/types";
|
|
4
4
|
import { FileItem } from "../components";
|
|
5
5
|
/**
|
|
6
6
|
* Check-in/Check-out Manager
|
|
7
7
|
* Questo modulo gestisce tutte le operazioni di check-in e check-out
|
|
8
8
|
* dei documenti e delle bozze dei gruppi di lavoro.
|
|
9
|
+
*
|
|
10
|
+
* Operazioni gestite:
|
|
11
|
+
* - Generazione nomi file per download e checkout con timestamp e identificatori univoci
|
|
12
|
+
* - Download di documenti in modalità checkout
|
|
13
|
+
* - Gestione dello storage locale delle informazioni di checkout (aggiunta, aggiornamento, rimozione)
|
|
14
|
+
* - Validazione dei nomi file secondo le convenzioni di naming CICO
|
|
15
|
+
* - Rendering dell'interfaccia utente per conferma check-in con visualizzazione anomalie
|
|
16
|
+
* - Determinazione dello stato di check-out dei documenti (editMode/lockMode)
|
|
17
|
+
* - Verifica permessi e abilitazione funzionalità CICO per tipo documento
|
|
9
18
|
*/
|
|
10
19
|
export interface CheckoutInfo {
|
|
11
20
|
DID: string;
|
|
@@ -18,6 +27,7 @@ interface CheckoutStatusResult {
|
|
|
18
27
|
mode: 'editMode' | 'lockMode' | '';
|
|
19
28
|
version: number;
|
|
20
29
|
icon: React.ReactNode | null;
|
|
30
|
+
editLockTooltipText: React.ReactNode | null;
|
|
21
31
|
}
|
|
22
32
|
export type DownloadSource = {
|
|
23
33
|
type: 'fileItem';
|
|
@@ -29,7 +39,7 @@ export type DownloadSource = {
|
|
|
29
39
|
};
|
|
30
40
|
export declare const getCicoDownloadFileName: (source: DownloadSource, checkout: boolean, withTimestampAndExt: boolean) => string;
|
|
31
41
|
export declare const cicoDownloadFilesCallback: (sources: Array<DownloadSource>, checkout: boolean, downloadDcmtsAsync: (inputDcmts: Array<DcmtInfo> | undefined, downloadType?: DownloadTypes, downloadMode?: DownloadModes, onFileDownloaded?: (dcmtFile: File) => void, confirmAttachments?: (list: FileDescriptor[]) => Promise<string[] | undefined>, skipConfirmation?: boolean) => Promise<void>) => Promise<void>;
|
|
32
|
-
export declare const
|
|
42
|
+
export declare const updateCicoCheckoutStorageItem: (item: CheckoutInfo, type: "fileItem" | "dcmtInfo", action?: "addOrUpdate" | "remove") => void;
|
|
33
43
|
export declare const validateCicoFileName: (source: DownloadSource, fileName: string) => FileNameValidation;
|
|
34
44
|
type ValidationResult = {
|
|
35
45
|
expected: string | number | undefined;
|
|
@@ -48,6 +58,26 @@ type FileNameValidation = {
|
|
|
48
58
|
validationResults?: FileNameValidationItems;
|
|
49
59
|
};
|
|
50
60
|
export declare const renderCicoCheckInContent: (source: DownloadSource, selectedFilename: File, isValid: boolean, validationItems: FileNameValidationItems | undefined, color?: string) => React.ReactNode;
|
|
61
|
+
interface CheckInCheckOutDcmtInfo {
|
|
62
|
+
CICO: number;
|
|
63
|
+
CanCICO: AccessLevels;
|
|
64
|
+
CanDelChronology: AccessLevels;
|
|
65
|
+
UserID_MID: number;
|
|
66
|
+
Date_MID: number;
|
|
67
|
+
Ver_MID: number;
|
|
68
|
+
UserID_CanViewOrUpdate: AccessLevels;
|
|
69
|
+
Date_CanViewOrUpdate: AccessLevels;
|
|
70
|
+
Ver_CanViewOrUpdate: AccessLevels;
|
|
71
|
+
}
|
|
72
|
+
export declare const getDcmtCicoInfo: (dtd: DcmtTypeDescriptor | undefined) => CheckInCheckOutDcmtInfo;
|
|
73
|
+
/**
|
|
74
|
+
* Determina lo stato di check-in/check-out di un documento
|
|
75
|
+
*
|
|
76
|
+
* @param dcmt - Il documento in formato array (MetadataValueDescriptorEx[]) o oggetto piatto
|
|
77
|
+
* @param allUsers - Lista di tutti gli utenti per risolvere i nomi
|
|
78
|
+
* @param dtd - Descrittore del tipo documento contenente le definizioni dei metadati CICO
|
|
79
|
+
* @returns Oggetto con cicoEnabled (se CICO è abilitato) e checkoutStatus (dettagli dello stato)
|
|
80
|
+
*/
|
|
51
81
|
export declare const getDcmtCicoStatus: (dcmt: any, allUsers: Array<UserDescriptor>, dtd: DcmtTypeDescriptor | undefined) => {
|
|
52
82
|
cicoEnabled: boolean;
|
|
53
83
|
checkoutStatus: CheckoutStatusResult;
|