UNPKG

@afzalimdad9/react-file-preview

Version:

The url previewer is built using native html elements for previewing url of files of the following type

39 lines 2.46 kB
import { jsx as _jsx } from "react/jsx-runtime"; import AudioViewer from './audio-viewer'; import CSVViewer from './csv-viewer'; import DefaultViewer from './default-viewer'; import DocumentViewer from './document-viewer'; import IFrameViewer from './html-viewer'; import ImageViewer from './image-viewer'; import PDFViewer from './pdf-viewer'; import TextViewer from './text-viewer'; import VideoViewer from './video-viewer'; export default function DriverSelector(_a) { var mimeType = _a.mimeType, src = _a.src, onError = _a.onError, onLoad = _a.onLoad, autoPlay = _a.autoPlay; switch (mimeType) { case 'text/csv': return _jsx(CSVViewer, { onLoad: onLoad, onError: function (e) { return onError(e); }, src: src }); case 'text/plain': return _jsx(TextViewer, { onLoad: onLoad, onError: function (e) { return onError(e); }, src: src }); case 'application/pdf': return _jsx(PDFViewer, { onLoad: onLoad, onError: function (e) { return onError(e); }, src: src }); case 'text/html': return _jsx(IFrameViewer, { src: src, onLoad: onLoad, onError: function (e) { return onError(e); } }); case mimeType.startsWith('image/') && mimeType: return _jsx(ImageViewer, { src: src, onLoad: onLoad, onError: function (e) { return onError(e); } }); case mimeType.startsWith('audio/') && mimeType: return (_jsx(AudioViewer, { src: src, onLoad: function () { return onLoad(true); }, onError: function (e) { return onError(e); }, mimeType: mimeType, autoPlay: autoPlay })); case mimeType.startsWith('video/') && mimeType: return (_jsx(VideoViewer, { src: src, onLoad: function () { return onLoad(true); }, onError: function (e) { return onError(e); }, mimeType: mimeType, autoPlay: autoPlay })); case 'application/msword': case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': case 'application/vnd.ms-excel': case 'application/vnd.ms-powerpoint': case 'application/vnd.openxmlformats-officedocument.presentationml.presentation': return _jsx(DocumentViewer, { src: src, onLoad: onLoad }); default: return _jsx(DefaultViewer, { onLoad: onLoad, mimeType: mimeType }); } } //# sourceMappingURL=driver-selector.js.map