@topconsultnpm/sdkui-react 6.20.0-dev1.7 → 6.20.0-dev1.70

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