@topconsultnpm/sdkui-react 6.20.0-dev1.23 → 6.20.0-dev1.25

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.
@@ -1,12 +1,24 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState, useRef, useCallback } from "react";
3
- import { pdfjs, Document, Page } from 'react-pdf';
4
3
  import styled from "styled-components";
5
4
  import { LoadIndicator } from 'devextreme-react/load-indicator';
6
5
  import { IconCloseOutline } from "./TMIcons";
7
6
  import { SDKUI_Localizator } from "./SDKUI_Localizator";
8
7
  import { TMColors } from "../utils/theme";
9
- pdfjs.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url).toString();
8
+ // Dynamic imports for optional dependencies
9
+ let pdfjs;
10
+ let Document;
11
+ let Page;
12
+ try {
13
+ const reactPdf = require('react-pdf');
14
+ pdfjs = reactPdf.pdfjs;
15
+ Document = reactPdf.Document;
16
+ Page = reactPdf.Page;
17
+ }
18
+ catch (error) {
19
+ // react-pdf not available
20
+ console.warn('react-pdf is not installed. TMPdfViewer will use iframe fallback for all devices.');
21
+ }
10
22
  const PDFViewerContainer = styled.div `
11
23
  width: 100%;
12
24
  height: 100%;
@@ -64,6 +76,16 @@ const TMPdfViewer = (props) => {
64
76
  (window.matchMedia?.('(hover: none) and (pointer: coarse)').matches ?? false) ||
65
77
  // Touch-capable devices excluding desktop OS
66
78
  (navigator.maxTouchPoints > 1 && !/Win|Mac|Linux x86_64/i.test(userAgent));
79
+ // Configura il worker PDF.js solo per mobile (react-pdf)
80
+ if (isMobileDevice && !pdfjs.GlobalWorkerOptions.workerSrc) {
81
+ try {
82
+ pdfjs.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url).toString();
83
+ }
84
+ catch (error) {
85
+ console.warn('Worker PDF.js locale non disponibile, uso CDN fallback');
86
+ pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.min.js`;
87
+ }
88
+ }
67
89
  setIsMobile(isMobileDevice);
68
90
  };
69
91
  checkIsMobile();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.20.0-dev1.23",
3
+ "version": "6.20.0-dev1.25",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -45,7 +45,7 @@
45
45
  "devextreme-react": "25.1.7",
46
46
  "exceljs": "^4.4.0",
47
47
  "htmlparser2": "^10.0.0",
48
- "pdfjs-dist": "^5.4.530",
48
+ "pdfjs-dist": "5.4.296",
49
49
  "react-pdf": "^10.3.0",
50
50
  "react-router-dom": "^6.15.0",
51
51
  "styled-components": "^6.1.1"