@cyber-harbour/ui 2.0.22 → 2.0.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cyber-harbour/ui",
3
- "version": "2.0.22",
3
+ "version": "2.0.24",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "bin": {
16
16
  "switch-ui-lib": "./bin/switch-ui-lib.js",
17
- "copy-pdf-worker": "./bin/copy-pdf-worker.js"
17
+ "copy-pdfjs": "./bin/copy-pdfjs.js"
18
18
  },
19
19
  "files": [
20
20
  "dist",
@@ -51,9 +51,9 @@
51
51
  "@types/react-dom": "^19.1.8",
52
52
  "@types/react-syntax-highlighter": "^15.5.13",
53
53
  "d3": ">=7.9",
54
+ "docx-preview": "^0.3.6",
54
55
  "dotenv": "^16.6.1",
55
56
  "lodash.clonedeep": "^4.5.0",
56
- "mammoth": "^1.10.0",
57
57
  "postcss": "^8.5.6",
58
58
  "prompts": "^2.4.2",
59
59
  "react-content-loader": "^7.0.2",
@@ -1,92 +0,0 @@
1
- #!/usr/bin/env node
2
- const fs = require('fs');
3
- const path = require('path');
4
-
5
- // Find the current working directory (the project using the UI library)
6
- const projectRoot = process.cwd();
7
-
8
- // Allow custom target directory via command line argument
9
- const targetDirName = process.env.UI_LIBRARY_WORKERS_DIR || 'public/workers';
10
-
11
- // Try multiple possible locations for pdfjs-dist worker
12
- const possiblePaths = [
13
- // In project's own node_modules
14
- path.resolve(projectRoot, 'node_modules/pdfjs-dist/build/pdf.worker.min.mjs'),
15
- // In the UI library's node_modules (when installed as dependency)
16
- path.resolve(projectRoot, 'node_modules/@cyber-harbour/ui/node_modules/pdfjs-dist/build/pdf.worker.min.mjs'),
17
- // In nested node_modules structure
18
- path.resolve(__dirname, '../node_modules/pdfjs-dist/build/pdf.worker.min.mjs'),
19
- // Alternative path structure
20
- path.resolve(projectRoot, 'node_modules/pdfjs-dist/build/pdf.worker.mjs'),
21
- ];
22
-
23
- // Try to resolve through require mechanism
24
- try {
25
- const pdfjsPath = require.resolve('pdfjs-dist/package.json', { paths: [projectRoot] });
26
- const pdfjsDir = path.dirname(pdfjsPath);
27
- const resolvedWorkerPath = path.join(pdfjsDir, 'build/pdf.worker.min.mjs');
28
- if (!possiblePaths.includes(resolvedWorkerPath)) {
29
- possiblePaths.unshift(resolvedWorkerPath);
30
- }
31
- } catch (err) {
32
- // pdfjs-dist not found via require.resolve, continue with predefined paths
33
- }
34
-
35
- // Find the first existing source path
36
- let sourcePath = null;
37
- for (const possiblePath of possiblePaths) {
38
- if (fs.existsSync(possiblePath)) {
39
- sourcePath = possiblePath;
40
- break;
41
- }
42
- }
43
-
44
- // Target directory (customizable)
45
- const targetDir = path.resolve(projectRoot, targetDirName);
46
- const targetPath = path.join(targetDir, 'pdf.worker.min.js');
47
-
48
- // Create target directory if it doesn't exist
49
- if (!fs.existsSync(targetDir)) {
50
- fs.mkdirSync(targetDir, { recursive: true });
51
- console.log(`šŸ“ Created ${targetDirName} directory`);
52
- }
53
-
54
- // Copy the worker file
55
- try {
56
- if (!sourcePath) {
57
- console.error('āŒ Failed to copy PDF worker: PDF worker not found in any of the following locations:');
58
- possiblePaths.forEach((path, index) => {
59
- console.error(` ${index + 1}. ${path}`);
60
- });
61
- throw new Error('Make sure pdfjs-dist is installed either in your project or as a peer dependency.');
62
- }
63
-
64
- console.log(`šŸ“„ Found PDF worker at: ${sourcePath}`);
65
- fs.copyFileSync(sourcePath, targetPath);
66
- console.log(`āœ… PDF worker copied successfully to ${targetDirName}/pdf.worker.min.js`);
67
- console.log(
68
- `šŸ’” Make sure to configure your app to load the worker from /${targetDirName.replace(
69
- /^public\//,
70
- ''
71
- )}/pdf.worker.min.js`
72
- );
73
-
74
- // Additional info for different frameworks
75
- console.log('\nšŸ“‹ Integration examples:');
76
- console.log('React/Next.js: Configure worker URL in your PDF component');
77
- console.log('Vite: Worker will be available at /workers/pdf.worker.min.js');
78
- console.log('Custom: Use the path specified above');
79
- } catch (error) {
80
- console.error('āŒ Failed to copy PDF worker:', error.message);
81
- console.error('\nšŸ”§ Troubleshooting:');
82
- console.error('1. Make sure pdfjs-dist is installed in your project: npm install pdfjs-dist');
83
- console.error('2. Or make sure @cyber-harbour/ui has pdfjs-dist as dependency');
84
- console.error('3. Run this command from your project root directory');
85
- console.error('4. Check that you have write permissions in the target directory');
86
- console.error('\nšŸ“ Checked locations:');
87
- possiblePaths.forEach((path, index) => {
88
- const exists = fs.existsSync(path);
89
- console.error(` ${exists ? 'āœ…' : 'āŒ'} ${path}`);
90
- });
91
- process.exit(1);
92
- }
@@ -1,3 +0,0 @@
1
- import {a,z}from'./chunk-GLKANQJX.mjs';import {useState}from'react';import {pdfjs,Document,Page}from'react-pdf';import'react-pdf/dist/Page/AnnotationLayer.css';import'react-pdf/dist/Page/TextLayer.css';import {jsx,jsxs}from'react/jsx-runtime';if(typeof window<"u"&&typeof document<"u"){let i="/workers";pdfjs.GlobalWorkerOptions.workerSrc=`${i}/pdf.worker.min.js`;}var B=a(({url:i})=>{let[t,p]=useState(0),[a$1,d]=useState(1),[v,c]=useState(true),[f,g]=useState(null);function x({numPages:r}){p(r),c(false);}a(x,"onDocumentLoadSuccess");function w(r){g(`Failed to load PDF: ${r.message}`),c(false);}a(w,"onDocumentLoadError");function m(r){d(n=>n+r);}a(m,"changePage");function b(){m(-1);}a(b,"previousPage");function k(){m(1);}return a(k,"nextPage"),f?jsx("div",{className:"flex items-center justify-center h-full w-full",children:jsx("div",{className:"text-red-500 text-center",children:jsx("p",{children:f})})}):jsxs("div",{className:"h-full w-full flex flex-col",children:[v&&jsx("div",{className:"flex items-center justify-center h-full",children:jsx("div",{className:"text-gray-500",children:"Loading PDF..."})}),t>0&&jsxs("div",{className:"flex items-center justify-center gap-4 p-4",children:[jsx(z,{variant:"outlined","aria-label":"previous page",color:"secondary",size:"small",type:"button",disabled:a$1<=1,onClick:b,icon:jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m15 18-6-6 6-6"})})}),jsxs("span",{className:"flex items-center gap-2",children:[jsx("input",{type:"number",min:1,max:t,value:a$1,onChange:r=>{let n=parseInt(r.target.value,10);n>=1&&n<=t&&d(n);},className:"w-16 px-2 py-1 border rounded text-center"}),"/ ",t]}),jsx(z,{variant:"outlined","aria-label":"next page",color:"secondary",size:"small",type:"button",disabled:a$1>=t,onClick:k,icon:jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m9 18 6-6-6-6"})})})]}),jsx("div",{className:"flex-1 flex justify-center overflow-auto",children:jsx(Document,{file:i,onLoadSuccess:x,onLoadError:w,loading:"",children:jsx(Page,{pageNumber:a$1,renderTextLayer:true,renderAnnotationLayer:true,className:"max-w-full max-h-full"})})})]})},"PdfDriver");
2
- export{B as PdfDriver};//# sourceMappingURL=PdfDriver-3OY5MHRK.mjs.map
3
- //# sourceMappingURL=PdfDriver-3OY5MHRK.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/FileViewer/drivers/PdfDriver/PdfDriver.tsx"],"names":["workerDir","pdfjs","PdfDriver","__name","url","numPages","setNumPages","useState","pageNumber","setPageNumber","loading","setLoading","error","setError","onDocumentLoadSuccess","onDocumentLoadError","changePage","offset","prevPageNumber","previousPage","nextPage","jsx","jsxs","Button","e","page","Document","Page"],"mappings":"mPAOA,GAAI,OAAO,MAAW,CAAA,GAAA,EAAe,OAAO,QAAa,CAAA,GAAA,CAAa,CACpE,IAAMA,CAAAA,CAAY,UAClBC,CAAAA,KAAAA,CAAM,oBAAoB,SAAY,CAAA,CAAA,EAAG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CAAAA,GAAAA,CAACE,CAAA,CAAA,CACC,QAAQ,UACR,CAAA,YAAA,CAAW,YACX,KAAM,CAAA,WAAA,CACN,KAAK,OACL,CAAA,IAAA,CAAK,QACL,CAAA,QAAA,CAAUf,KAAcH,CACxB,CAAA,OAAA,CAASe,EACT,IACEC,CAAAA,GAAAA,CAAC,OACC,KAAM,CAAA,4BAAA,CACN,OAAQ,CAAA,WAAA,CACR,KAAK,MACL,CAAA,MAAA,CAAO,eACP,WAAY,CAAA,GAAA,CACZ,cAAc,OACd,CAAA,cAAA,CAAe,OAEf,CAAA,QAAA,CAAAA,IAAC,MAAK,CAAA,CAAA,CAAA,CAAE,gBAAgB,CAC1B,CAAA,CAAA,CAEJ,GACF,CAEFA,CAAAA,GAAAA,CAAC,KAAI,CAAA,CAAA,SAAA,CAAU,2CACb,QAAAA,CAAAA,GAAAA,CAACK,SAAA,CAAS,IAAA,CAAMtB,EAAK,aAAeU,CAAAA,CAAAA,CAAuB,WAAaC,CAAAA,CAAAA,CAAqB,QAAQ,EACnG,CAAA,QAAA,CAAAM,IAACM,IAAA,CAAA,CACC,WAAYnB,GACZ,CAAA,eAAA,CAAiB,IACjB,CAAA,qBAAA,CAAuB,KACvB,SAAU,CAAA,uBAAA,CACZ,EACF,CACF,CAAA,CAAA,CAAA,CACF,CAEJ,CA5HmD,CAAA,WAAA","file":"PdfDriver-3OY5MHRK.mjs","sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Document, Page, pdfjs } from 'react-pdf';\nimport 'react-pdf/dist/Page/AnnotationLayer.css';\nimport 'react-pdf/dist/Page/TextLayer.css';\nimport { Button } from '../../../Core';\n\n// Set up the worker - self-hosted configuration (client-side only)\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n const workerDir = '/workers';\n pdfjs.GlobalWorkerOptions.workerSrc = `${workerDir}/pdf.worker.min.js`;\n}\n\ninterface PdfDriverProps {\n url: string;\n}\n\nexport const PdfDriver: React.FC<PdfDriverProps> = ({ url }) => {\n const [numPages, setNumPages] = useState<number>(0);\n const [pageNumber, setPageNumber] = useState<number>(1);\n const [loading, setLoading] = useState<boolean>(true);\n const [error, setError] = useState<string | null>(null);\n\n //TODO: add fix 100px problem;\n\n function onDocumentLoadSuccess({ numPages }: { numPages: number }): void {\n setNumPages(numPages);\n setLoading(false);\n }\n\n function onDocumentLoadError(error: Error): void {\n setError(`Failed to load PDF: ${error.message}`);\n setLoading(false);\n }\n\n function changePage(offset: number): void {\n setPageNumber((prevPageNumber) => prevPageNumber + offset);\n }\n\n function previousPage(): void {\n changePage(-1);\n }\n\n function nextPage(): void {\n changePage(1);\n }\n\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full w-full\">\n <div className=\"text-red-500 text-center\">\n <p>{error}</p>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"h-full w-full flex flex-col\">\n {loading && (\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"text-gray-500\">Loading PDF...</div>\n </div>\n )}\n {numPages > 0 && (\n <div className=\"flex items-center justify-center gap-4 p-4\">\n <Button\n variant=\"outlined\"\n aria-label=\"previous page\"\n color=\"secondary\"\n size=\"small\"\n type=\"button\"\n disabled={pageNumber <= 1}\n onClick={previousPage}\n icon={\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n }\n />\n\n <span className=\"flex items-center gap-2\">\n <input\n type=\"number\"\n min={1}\n max={numPages}\n value={pageNumber}\n onChange={(e) => {\n const page = parseInt(e.target.value, 10);\n if (page >= 1 && page <= numPages) {\n setPageNumber(page);\n }\n }}\n className=\"w-16 px-2 py-1 border rounded text-center\"\n />\n / {numPages}\n </span>\n <Button\n variant=\"outlined\"\n aria-label=\"next page\"\n color=\"secondary\"\n size=\"small\"\n type=\"button\"\n disabled={pageNumber >= numPages}\n onClick={nextPage}\n icon={\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n }\n />\n </div>\n )}\n <div className=\"flex-1 flex justify-center overflow-auto\">\n <Document file={url} onLoadSuccess={onDocumentLoadSuccess} onLoadError={onDocumentLoadError} loading=\"\">\n <Page\n pageNumber={pageNumber}\n renderTextLayer={true}\n renderAnnotationLayer={true}\n className=\"max-w-full max-h-full\"\n />\n </Document>\n </div>\n </div>\n );\n};\n"]}
@@ -1,3 +0,0 @@
1
- 'use strict';var chunkVMUGTG7N_js=require('./chunk-VMUGTG7N.js'),react=require('react'),reactPdf=require('react-pdf');require('react-pdf/dist/Page/AnnotationLayer.css'),require('react-pdf/dist/Page/TextLayer.css');var jsxRuntime=require('react/jsx-runtime');if(typeof window<"u"&&typeof document<"u"){let i="/workers";reactPdf.pdfjs.GlobalWorkerOptions.workerSrc=`${i}/pdf.worker.min.js`;}var R=chunkVMUGTG7N_js.a(({url:i})=>{let[t,p]=react.useState(0),[a,d]=react.useState(1),[v,c]=react.useState(true),[f,g]=react.useState(null);function x({numPages:r}){p(r),c(false);}chunkVMUGTG7N_js.a(x,"onDocumentLoadSuccess");function w(r){g(`Failed to load PDF: ${r.message}`),c(false);}chunkVMUGTG7N_js.a(w,"onDocumentLoadError");function m(r){d(n=>n+r);}chunkVMUGTG7N_js.a(m,"changePage");function b(){m(-1);}chunkVMUGTG7N_js.a(b,"previousPage");function k(){m(1);}return chunkVMUGTG7N_js.a(k,"nextPage"),f?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full w-full",children:jsxRuntime.jsx("div",{className:"text-red-500 text-center",children:jsxRuntime.jsx("p",{children:f})})}):jsxRuntime.jsxs("div",{className:"h-full w-full flex flex-col",children:[v&&jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full",children:jsxRuntime.jsx("div",{className:"text-gray-500",children:"Loading PDF..."})}),t>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-4 p-4",children:[jsxRuntime.jsx(chunkVMUGTG7N_js.z,{variant:"outlined","aria-label":"previous page",color:"secondary",size:"small",type:"button",disabled:a<=1,onClick:b,icon:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m15 18-6-6 6-6"})})}),jsxRuntime.jsxs("span",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"number",min:1,max:t,value:a,onChange:r=>{let n=parseInt(r.target.value,10);n>=1&&n<=t&&d(n);},className:"w-16 px-2 py-1 border rounded text-center"}),"/ ",t]}),jsxRuntime.jsx(chunkVMUGTG7N_js.z,{variant:"outlined","aria-label":"next page",color:"secondary",size:"small",type:"button",disabled:a>=t,onClick:k,icon:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m9 18 6-6-6-6"})})})]}),jsxRuntime.jsx("div",{className:"flex-1 flex justify-center overflow-auto",children:jsxRuntime.jsx(reactPdf.Document,{file:i,onLoadSuccess:x,onLoadError:w,loading:"",children:jsxRuntime.jsx(reactPdf.Page,{pageNumber:a,renderTextLayer:true,renderAnnotationLayer:true,className:"max-w-full max-h-full"})})})]})},"PdfDriver");
2
- exports.PdfDriver=R;//# sourceMappingURL=PdfDriver-QWYK2IMO.js.map
3
- //# sourceMappingURL=PdfDriver-QWYK2IMO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/FileViewer/drivers/PdfDriver/PdfDriver.tsx"],"names":["workerDir","pdfjs","PdfDriver","__name","url","numPages","setNumPages","useState","pageNumber","setPageNumber","loading","setLoading","error","setError","onDocumentLoadSuccess","onDocumentLoadError","changePage","offset","prevPageNumber","previousPage","nextPage","jsx","jsxs","Button","e","page","Document","Page"],"mappings":"kQAOA,GAAI,OAAO,MAAW,CAAA,GAAA,EAAe,OAAO,QAAa,CAAA,GAAA,CAAa,CACpE,IAAMA,CAAAA,CAAY,UAClBC,CAAAA,cAAAA,CAAM,oBAAoB,SAAY,CAAA,CAAA,EAAGD,CAAS,CACpD,kBAAA,EAAA,KAMaE,CAAsCC,CAAAA,kBAAAA,CAAA,CAAC,CAAE,IAAAC,CAAI,CAAA,GAAM,CAC9D,GAAM,CAACC,EAAUC,CAAW,CAAA,CAAIC,cAAiB,CAAA,CAAC,EAC5C,CAACC,CAAAA,CAAYC,CAAa,CAAIF,CAAAA,cAAAA,CAAiB,CAAC,CAChD,CAAA,CAACG,CAASC,CAAAA,CAAU,EAAIJ,cAAkB,CAAA,IAAI,EAC9C,CAACK,CAAAA,CAAOC,CAAQ,CAAIN,CAAAA,cAAAA,CAAwB,IAAI,CAAA,CAItD,SAASO,CAAsB,CAAA,CAAE,SAAAT,CAAS,CAAA,CAA+B,CACvEC,CAAYD,CAAAA,CAAQ,CACpBM,CAAAA,CAAAA,CAAW,KAAK,EAClB,CAHSR,mBAAAW,CAAA,CAAA,uBAAA,CAAA,CAKT,SAASC,CAAoBH,CAAAA,CAAAA,CAAoB,CAC/CC,CAAAA,CAAS,uBAAuBD,CAAM,CAAA,OAAO,EAAE,CAC/CD,CAAAA,CAAAA,CAAW,KAAK,EAClB,CAHSR,kBAAAY,CAAAA,CAAAA,CAAA,uBAKT,SAASC,CAAAA,CAAWC,EAAsB,CACxCR,CAAAA,CAAeS,GAAmBA,CAAiBD,CAAAA,CAAM,EAC3D,CAFSd,mBAAAa,CAAA,CAAA,YAAA,CAAA,CAIT,SAASG,CAAqB,EAAA,CAC5BH,EAAW,EAAE,EACf,CAFSb,kBAAAA,CAAAgB,EAAA,cA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EACL,GAAKhB,CAAAA,CAAAA,CACL,MAAOG,CACP,CAAA,QAAA,CAAWgB,GAAM,CACf,IAAMC,CAAO,CAAA,QAAA,CAASD,EAAE,MAAO,CAAA,KAAA,CAAO,EAAE,CACpCC,CAAAA,CAAAA,EAAQ,GAAKA,CAAQpB,EAAAA,CAAAA,EACvBI,CAAcgB,CAAAA,CAAI,EAEtB,CACA,CAAA,SAAA,CAAU,4CACZ,CAAE,CAAA,IAAA,CACCpB,GACL,CACAgB,CAAAA,cAAAA,CAACE,kBAAA,CAAA,CACC,QAAQ,UACR,CAAA,YAAA,CAAW,YACX,KAAM,CAAA,WAAA,CACN,KAAK,OACL,CAAA,IAAA,CAAK,QACL,CAAA,QAAA,CAAUf,GAAcH,CACxB,CAAA,OAAA,CAASe,EACT,IACEC,CAAAA,cAAAA,CAAC,OACC,KAAM,CAAA,4BAAA,CACN,OAAQ,CAAA,WAAA,CACR,KAAK,MACL,CAAA,MAAA,CAAO,eACP,WAAY,CAAA,GAAA,CACZ,cAAc,OACd,CAAA,cAAA,CAAe,OAEf,CAAA,QAAA,CAAAA,eAAC,MAAK,CAAA,CAAA,CAAA,CAAE,gBAAgB,CAC1B,CAAA,CAAA,CAEJ,GACF,CAEFA,CAAAA,cAAAA,CAAC,KAAI,CAAA,CAAA,SAAA,CAAU,2CACb,QAAAA,CAAAA,cAAAA,CAACK,kBAAA,CAAS,IAAA,CAAMtB,EAAK,aAAeU,CAAAA,CAAAA,CAAuB,WAAaC,CAAAA,CAAAA,CAAqB,QAAQ,EACnG,CAAA,QAAA,CAAAM,eAACM,aAAA,CAAA,CACC,WAAYnB,CACZ,CAAA,eAAA,CAAiB,IACjB,CAAA,qBAAA,CAAuB,KACvB,SAAU,CAAA,uBAAA,CACZ,EACF,CACF,CAAA,CAAA,CAAA,CACF,CAEJ,CA5HmD,CAAA,WAAA","file":"PdfDriver-QWYK2IMO.js","sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Document, Page, pdfjs } from 'react-pdf';\nimport 'react-pdf/dist/Page/AnnotationLayer.css';\nimport 'react-pdf/dist/Page/TextLayer.css';\nimport { Button } from '../../../Core';\n\n// Set up the worker - self-hosted configuration (client-side only)\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n const workerDir = '/workers';\n pdfjs.GlobalWorkerOptions.workerSrc = `${workerDir}/pdf.worker.min.js`;\n}\n\ninterface PdfDriverProps {\n url: string;\n}\n\nexport const PdfDriver: React.FC<PdfDriverProps> = ({ url }) => {\n const [numPages, setNumPages] = useState<number>(0);\n const [pageNumber, setPageNumber] = useState<number>(1);\n const [loading, setLoading] = useState<boolean>(true);\n const [error, setError] = useState<string | null>(null);\n\n //TODO: add fix 100px problem;\n\n function onDocumentLoadSuccess({ numPages }: { numPages: number }): void {\n setNumPages(numPages);\n setLoading(false);\n }\n\n function onDocumentLoadError(error: Error): void {\n setError(`Failed to load PDF: ${error.message}`);\n setLoading(false);\n }\n\n function changePage(offset: number): void {\n setPageNumber((prevPageNumber) => prevPageNumber + offset);\n }\n\n function previousPage(): void {\n changePage(-1);\n }\n\n function nextPage(): void {\n changePage(1);\n }\n\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full w-full\">\n <div className=\"text-red-500 text-center\">\n <p>{error}</p>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"h-full w-full flex flex-col\">\n {loading && (\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"text-gray-500\">Loading PDF...</div>\n </div>\n )}\n {numPages > 0 && (\n <div className=\"flex items-center justify-center gap-4 p-4\">\n <Button\n variant=\"outlined\"\n aria-label=\"previous page\"\n color=\"secondary\"\n size=\"small\"\n type=\"button\"\n disabled={pageNumber <= 1}\n onClick={previousPage}\n icon={\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n }\n />\n\n <span className=\"flex items-center gap-2\">\n <input\n type=\"number\"\n min={1}\n max={numPages}\n value={pageNumber}\n onChange={(e) => {\n const page = parseInt(e.target.value, 10);\n if (page >= 1 && page <= numPages) {\n setPageNumber(page);\n }\n }}\n className=\"w-16 px-2 py-1 border rounded text-center\"\n />\n / {numPages}\n </span>\n <Button\n variant=\"outlined\"\n aria-label=\"next page\"\n color=\"secondary\"\n size=\"small\"\n type=\"button\"\n disabled={pageNumber >= numPages}\n onClick={nextPage}\n icon={\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n }\n />\n </div>\n )}\n <div className=\"flex-1 flex justify-center overflow-auto\">\n <Document file={url} onLoadSuccess={onDocumentLoadSuccess} onLoadError={onDocumentLoadError} loading=\"\">\n <Page\n pageNumber={pageNumber}\n renderTextLayer={true}\n renderAnnotationLayer={true}\n className=\"max-w-full max-h-full\"\n />\n </Document>\n </div>\n </div>\n );\n};\n"]}