@topconsultnpm/sdkui-react-beta 6.14.121 → 6.14.122
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.
|
@@ -163,12 +163,21 @@ export const TMFileViewer = ({ fileBlob, isResizingActive }) => {
|
|
|
163
163
|
const [blobUrl, setBlobUrl] = useState(undefined);
|
|
164
164
|
const [fileType, setFileType] = useState(undefined);
|
|
165
165
|
const [formattedXml, setFormattedXml] = useState(undefined);
|
|
166
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
const checkIsMobile = () => {
|
|
169
|
+
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
|
170
|
+
const isMobileDevice = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent);
|
|
171
|
+
setIsMobile(isMobileDevice);
|
|
172
|
+
};
|
|
173
|
+
checkIsMobile();
|
|
174
|
+
}, []);
|
|
166
175
|
useEffect(() => {
|
|
167
176
|
if (fileBlob) {
|
|
168
177
|
const url = URL.createObjectURL(fileBlob);
|
|
169
178
|
setBlobUrl(url);
|
|
170
179
|
setFileType(fileBlob.type);
|
|
171
|
-
setFormattedXml(undefined);
|
|
180
|
+
setFormattedXml(undefined);
|
|
172
181
|
if (fileBlob.type.includes("xml")) {
|
|
173
182
|
fileBlob.text().then((text) => {
|
|
174
183
|
const parser = new DOMParser();
|
|
@@ -204,33 +213,33 @@ export const TMFileViewer = ({ fileBlob, isResizingActive }) => {
|
|
|
204
213
|
if (fileBlob.type.includes('image')) {
|
|
205
214
|
return (_jsx(ImageViewer, { fileBlob: fileBlob, alt: '' }));
|
|
206
215
|
}
|
|
207
|
-
if (fileType === 'application/pdf') {
|
|
208
|
-
return (
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
216
|
+
if (fileType === 'application/pdf' && isMobile) {
|
|
217
|
+
return (_jsxs("div", { style: {
|
|
218
|
+
padding: '40px',
|
|
219
|
+
textAlign: 'center',
|
|
220
|
+
display: 'flex',
|
|
221
|
+
flexDirection: 'column',
|
|
222
|
+
alignItems: 'center',
|
|
223
|
+
justifyContent: 'center',
|
|
224
|
+
height: '100%',
|
|
225
|
+
gap: '20px'
|
|
226
|
+
}, children: [_jsx(IconPreview, { fontSize: 96 }), _jsxs("div", { children: [_jsx("h3", { children: SDKUI_Localizator.PDFDocument }), _jsx("p", { children: SDKUI_Localizator.PreviewNotAvailableOnDevice })] }), _jsxs("div", { style: { display: 'flex', gap: '10px', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'center' }, children: [_jsx("a", { href: blobUrl, download: "document.pdf", style: {
|
|
227
|
+
minWidth: '180px',
|
|
228
|
+
padding: '12px 24px',
|
|
229
|
+
backgroundColor: TMColors.primaryColor,
|
|
230
|
+
color: 'white',
|
|
231
|
+
textDecoration: 'none',
|
|
232
|
+
borderRadius: '4px',
|
|
233
|
+
display: 'inline-block'
|
|
234
|
+
}, children: SDKUI_Localizator.DownloadFile }), _jsx("a", { href: blobUrl, target: "_blank", rel: "noopener noreferrer", style: {
|
|
235
|
+
minWidth: '180px',
|
|
236
|
+
padding: '12px 24px',
|
|
237
|
+
backgroundColor: TMColors.primaryColor,
|
|
238
|
+
color: 'white',
|
|
239
|
+
textDecoration: 'none',
|
|
240
|
+
borderRadius: '4px',
|
|
241
|
+
display: 'inline-block'
|
|
242
|
+
}, children: SDKUI_Localizator.OpenInNewTab })] })] }));
|
|
234
243
|
}
|
|
235
244
|
return (_jsx("iframe", { srcDoc: fileType?.includes("xml") && formattedXml ? `<html><body>${formattedXml}</body></html>` : undefined, src: !fileType?.includes("xml") || !formattedXml ? blobUrl : undefined, title: "File Viewer", width: "100%", height: "100%", style: { border: 'none', zIndex: 0, pointerEvents: isResizingActive === true ? "none" : "auto" } }));
|
|
236
245
|
};
|