@epam/ai-dial-react-pdf-highlighter 0.1.3 → 0.1.4
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/dist/ai-dial-react-pdf-highlighter.cjs.js +1 -1
- package/dist/ai-dial-react-pdf-highlighter.es.js +324 -310
- package/dist/index.css +1 -1
- package/dist/src/components/DocumentPreview/DocumentPreview.d.ts +13 -1
- package/dist/src/components/PdfViewer/PdfViewer.d.ts +7 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/models/pdf-viewer.models.d.ts +5 -1
- package/package.json +19 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("@epam/ai-dial-ui-kit"),U=require("@epam/pdf-highlighter-kit"),t=require("react"),z=require("@tabler/icons-react"),Z="auto",A="page-fit",L=[{value:Z,label:"Auto"},{value:A,label:"Page Fit"},{value:"0.5",label:"50%"},{value:"0.75",label:"75%"},{value:"1",label:"100%"},{value:"1.25",label:"125%"},{value:"1.5",label:"150%"},{value:"2",label:"200%"},{value:"3",label:"300%"}],K={maxWidth:104,format:"image/jpeg",quality:.85},$=15,ne="application/pdf",le=".pdf",W=({pdf:s,highlights:a,selectedHighlightId:m,autoFocusFirstHighlight:n=!1,selectedPageNumber:d,zoom:c,containerClassName:p,onTotalPagesChange:x,onViewerReady:y,selectedPages:f})=>{const h=t.useRef(null),r=t.useRef(null),[o,C]=t.useState(!1),[O,v]=t.useState(!1),P=t.useRef(x),E=t.useRef(y);t.useEffect(()=>{P.current=x},[x]),t.useEffect(()=>{E.current=y},[y]);const N=t.useCallback(l=>r.current?.goToHighlight(l),[]);return t.useEffect(()=>{if(!h.current)return;C(!1),v(!1),r.current&&(r.current.destroy(),r.current=null);let l=null,b=!0;return(async()=>{try{if(l=new U.PDFHighlightViewer,await l.init(h.current,{enableTextSelection:!0,enableVirtualScrolling:!0,bboxOrigin:"top-left"}),!b){l.destroy();return}if(await l.loadPDF(s,{selectedPages:f}),!b){l.destroy();return}const g=l.getTotalPages?.();typeof g=="number"&&g>0&&P.current?.(g),b&&(r.current=l,C(!0))}catch(g){if(!b)return;console.error("Error in initViewer:",g)}})(),()=>{b=!1,l&&l.destroy()}},[s,f]),t.useEffect(()=>{!o||!r.current||(r.current.loadHighlights(a),n&&a&&a[0]&&N(a[0].id))},[n,N,a,o]),t.useEffect(()=>{v(!0)},[a]),t.useEffect(()=>{o&&O&&m&&N(m)},[N,o,O,m]),t.useEffect(()=>{if(!(!o||!c))if(c===Z)r.current?.setZoom?.(U.ZoomMode.AUTO);else if(c===A)r.current?.setZoom?.(U.ZoomMode.PAGE_FIT);else{const l=parseFloat(c);!Number.isNaN(l)&&l>0&&r.current?.setZoom?.(l)}},[o,c]),t.useEffect(()=>{o&&d&&r.current?.setPage?.(d)},[o,d]),t.useEffect(()=>{if(!o||!r.current)return;const l=r.current;E.current?.({getThumbnailsDataUrl:(b,I)=>l.getThumbnailsDataUrl(b,I),zoomIn:()=>l.zoomIn(),zoomOut:()=>l.zoomOut(),getZoom:()=>l.getZoom(),navigateToPage:b=>l.setPage?.(b)})},[o]),e.jsx("div",{ref:h,className:i.mergeClasses("grow min-w-0 overflow-auto bg-layer-3",p)})},T="h-4 rounded-[120px] bg-gradient-to-r from-layer-4 via-layer-3 to-layer-4 bg-[length:200%_100%] animate-skeleton-wave",X=({className:s,ariaLabel:a="pdf preview loading"})=>e.jsx("div",{role:"status","aria-label":a,"aria-live":"polite",className:i.mergeClasses("h-full w-full bg-layer-3",s),children:e.jsxs("div",{className:"flex h-full w-full flex-col gap-10 px-[60px] pt-10",children:[e.jsx("div",{className:"mx-auto h-4 w-[208px] max-w-[40%] rounded-[120px] bg-gradient-to-r from-layer-4 via-layer-3 to-layer-4 bg-[length:200%_100%] animate-skeleton-wave"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:T}),e.jsx("div",{className:T}),e.jsx("div",{className:T}),e.jsx("div",{className:T}),e.jsx("div",{className:i.mergeClasses(T,"w-[28%] max-w-[320px]")})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:T}),e.jsx("div",{className:T}),e.jsx("div",{className:T}),e.jsx("div",{className:T}),e.jsx("div",{className:i.mergeClasses(T,"w-[58%] max-w-[520px]")})]})]})}),Y=t.createContext(null),J=()=>t.useContext(Y),S=L.filter(({value:s})=>{const a=Number.parseFloat(s);return!Number.isNaN(a)&&a>0}),oe=[...S].reverse(),Q=(s,a,m)=>{if(S.length===0)return s;const n=Number.parseFloat(s),d=!Number.isNaN(n)&&n>0?n:m,c=typeof d=="number"&&d>0?d:Number.parseFloat(S[0].value);return a===1?(S.find(({value:p})=>Number.parseFloat(p)>c)??S[S.length-1]).value:(oe.find(({value:p})=>Number.parseFloat(p)<c)??S[0]).value};function ee(s,a){const m=(s??"").toLowerCase();return(a??"").toLowerCase()===ne||m.endsWith(le)}const G=L.map(s=>({value:s.value,label:s.label})),te=({fileUrl:s,fileName:a,loadFileCb:m,highlights:n,selectedPageNumber:d,onTotalPagesChange:c,thumbnailPageNumbers:p,onThumbnailsLoaded:x,onViewerReady:y,showLoaderOverlay:f=!1,selectedPages:h})=>{const r=J(),o=t.useRef(null),[C,O]=t.useState(!1),[v,P]=t.useState(0),[E,N]=t.useState(!1),[l,b]=t.useState(null),[I,g]=t.useState(null),[j,k]=t.useState(Z),D=t.useMemo(()=>{let u=a||s;if(!a)try{u=new URL(s).pathname}catch{u=s.split("?")[0].split("#")[0]}return ee(u.toLowerCase())},[a,s]),M=t.useCallback(u=>{P((v+u+n.length)%n.length)},[v,n.length]),F=t.useCallback(u=>{const w=o.current;!w?.getZoom||!u||k(Q(j,u,w.getZoom()))},[j]),V=t.useMemo(()=>{if(!(j===Z||j===A||L.some(w=>w.value===j))){const w=parseFloat(j);if(!Number.isNaN(w)&&w>0)return[...G,{value:j,label:`${Math.round(w*100)}%`}]}return G},[j]);t.useEffect(()=>{let u=!1;if(b(!0),N(!1),g(null),O(!1),o.current=null,!D){N(!0),b(!1);return}return(async()=>{try{const _=await(r?r.getFile(s,()=>m(s)):m(s));u||g(_)}catch{u||(N(!0),g(null))}finally{u||b(!1)}})(),()=>{u=!0}},[s,r,m,D]);const B=t.useCallback(u=>{o.current=u,O(!0),y?.(u)},[y]);return t.useEffect(()=>{const u=p??[],w=o.current?.getThumbnailsDataUrl;if(!u.length||!w||!I||!x||!C)return;let _=!1;return(async()=>{const q=new Map;for(let R=0;R<u.length&&!_;R+=$){const se=u.slice(R,R+$);try{const H=await w(se,K);if(_)break;H.forEach((re,ae)=>q.set(ae,re)),x(new Map(q))}catch(H){console.warn("Thumbnail batch load failed:",H);break}}})(),()=>{_=!0}},[p,I,x,C]),{file:I,isLoading:l,isError:E,isSupportedFile:D,activeHighlightIndex:v,zoom:j,setZoom:k,zoomSelectOptions:V,viewerApiRef:o,showLoader:!E&&(!!l||f),changeIndex:M,handleZoomChange:F,handleViewerReady:B}},ce=({fileUrl:s,fileName:a,errorLabel:m,occurrencesLabel:n,unsupportedLabel:d,highlights:c,loadFileCb:p,showOccurrences:x=!0,selectedPageNumber:y,containerClassName:f,pdfViewerClassName:h,onTotalPagesChange:r,title:o,thumbnailPageNumbers:C,onThumbnailsLoaded:O,onViewerReady:v,showLoaderOverlay:P=!1,selectedPages:E})=>{const{file:N,isError:l,isSupportedFile:b,activeHighlightIndex:I,zoom:g,setZoom:j,zoomSelectOptions:k,showLoader:D,changeIndex:M,handleZoomChange:F,handleViewerReady:V}=te({fileUrl:s,fileName:a,loadFileCb:p,highlights:c,selectedPageNumber:y,onTotalPagesChange:r,thumbnailPageNumbers:C,onThumbnailsLoaded:O,onViewerReady:v,showLoaderOverlay:P,selectedPages:E});return e.jsxs("div",{className:i.mergeClasses("flex flex-col self-center gap-4 py-3 px-6 h-full w-full bg-layer-2",f),children:[a&&e.jsx("div",{className:"shrink-0 min-h-0 w-full",children:e.jsx(i.DialEllipsisTooltip,{className:"dial-tiny-text text-secondary",text:a})}),e.jsxs("div",{className:i.mergeClasses("flex w-full justify-between items-center",x&&o?"gap-2":""),children:[e.jsx("div",{children:x?e.jsxs("div",{className:"flex gap-1 py-0.5 px-1.5 min-h-[26px] items-center bg-layer-4 rounded w-fit",children:[e.jsxs("span",{className:"dial-small-text",children:[n??"Occurrences",":",e.jsx("span",{className:"pl-0.5 min-w-3 inline-block text-right",children:c.length>0?`${I+1}/${c.length}`:"0"})]}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(i.DialButton,{className:"p-0 text-primary !h-6.5",size:i.ElementSize.Small,iconAfter:e.jsx(z.IconChevronDown,{size:16}),"aria-label":"Next occurrence",onClick:()=>M(1)}),e.jsx(i.DialButton,{className:"p-0 text-primary !h-6.5",size:i.ElementSize.Small,iconAfter:e.jsx(z.IconChevronUp,{size:16}),"aria-label":"Previous occurrence",onClick:()=>M(-1)})]})]}):e.jsx("div",{})}),e.jsxs("div",{className:i.mergeClasses("flex flex-1 items-center gap-4 min-w-0",o!=null&&o!==""?"justify-between":"justify-end"),children:[o!=null&&o!==""&&e.jsx(i.DialEllipsisTooltip,{text:o,className:"dial-body-semi-text text-primary min-w-0"}),e.jsxs("div",{className:"flex gap-0.5 items-center shrink-0",children:[e.jsx("div",{className:"h-6",children:e.jsx(i.DialSelect,{size:i.SelectSize.Sm,className:"bg-layer-4 !py-0 h-6 min-h-6 dial-small-text max-h-full border-transparent hover:border-hover rounded",options:k,value:g,onChange:B=>j(B)})}),e.jsx(i.DialButton,{className:"py-0 flex items-center justify-center rounded text-primary bg-layer-4 border border-transparent hover:border-hover",iconAfter:e.jsx(z.IconMinus,{size:16}),"aria-label":"Zoom out",size:i.ElementSize.Small,onClick:()=>F(-1)}),e.jsx(i.DialButton,{className:"py-0 flex items-center justify-center rounded text-primary bg-layer-4 border border-transparent hover:border-hover",iconAfter:e.jsx(z.IconPlus,{size:16}),"aria-label":"Zoom in",size:i.ElementSize.Small,onClick:()=>F(1)})]})]})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[N&&e.jsx(W,{pdf:N,highlights:c,selectedHighlightId:x?c[I]?.id:void 0,selectedPageNumber:y,zoom:g,onTotalPagesChange:r,onViewerReady:V,containerClassName:h,selectedPages:E}),D&&e.jsx(X,{className:"absolute inset-0 z-10"}),l&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-layer-3",children:e.jsxs("div",{className:"flex flex-col items-center gap-6 p-10",children:[e.jsx(z.IconAlertTriangle,{size:60,stroke:2,className:"text-secondary"}),e.jsx("div",{className:"text-center dial-small-text whitespace-pre-wrap",children:!b&&d?d:m??"Failed to load document."})]})})]})]})},ie=1200*1e3,ue=20,me=({children:s,ttlMs:a=ie,maxEntries:m=ue})=>{const n=t.useRef(new Map),d=t.useCallback((f,h)=>{n.current.delete(f),n.current.set(f,h)},[]),c=t.useCallback(()=>{const f=Date.now();for(const[h,r]of n.current.entries())r.file&&f-r.timestamp>a&&n.current.delete(h)},[a]),p=t.useCallback(()=>{for(;n.current.size>m;){const f=n.current.keys().next().value;f&&n.current.delete(f)}},[m]),x=t.useCallback(()=>{n.current.clear()},[]),y=t.useCallback(async(f,h)=>{c();const r=n.current.get(f);if(r){if(d(f,{...r,timestamp:Date.now()}),r.file)return r.file;if(r.promise)return r.promise}const o=Date.now(),C=h().then(v=>{const P={file:v,timestamp:Date.now()};return d(f,P),p(),v}).catch(v=>{throw n.current.delete(f),v});return d(f,{promise:C,timestamp:o}),p(),C},[p,c,d]);return t.useEffect(()=>()=>x(),[x]),e.jsx(Y.Provider,{value:{getFile:y,clearCache:x},children:s})},de=({pageNum:s,onSelectPage:a,isSelected:m,isLoading:n,isMultiselect:d,thumbnailUrl:c,className:p})=>e.jsxs("button",{type:"button","aria-label":`Page ${s}`,"aria-pressed":m,onClick:x=>{d&&x.target.closest("[data-checkbox-wrapper]")||a(s)},className:i.mergeClasses("flex flex-col gap-2 p-2 h-[186px] w-[120px] items-center justify-center cursor-pointer transition-colors hover:bg-layer-4 rounded-sm",m&&(d?"border border-accent-primary bg-accent-primary-alpha":"border border-primary"),p),children:[e.jsxs("div",{className:"relative w-[104px] h-[146px] bg-model-icon rounded-sm overflow-hidden",children:[c?e.jsx("img",{src:c,alt:`Page ${s} thumbnail`,className:"w-full h-full object-cover rounded-sm"}):null,d&&e.jsx("div",{className:"absolute left-1 top-1 z-10","data-checkbox-wrapper":!0,children:e.jsx(i.DialCheckbox,{id:`page-thumbnail-${s}`,checked:m,onChange:()=>a(s),className:"before:border-primary before:bg-model-icon bg-model-icon"})}),n&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-blackout rounded-sm",children:e.jsx(i.DialLoader,{size:24,fullWidth:!1,ariaLabel:`Loading page ${s}`})})]}),e.jsx("span",{className:"dial-tiny-text text-primary",children:s})]});exports.AUTO_ZOOM_ID=Z;exports.DocumentPreview=ce;exports.DocumentPreviewCacheProvider=me;exports.FIT_ZOOM_ID=A;exports.PDFViewer=W;exports.PageThumbnail=de;exports.PdfPreviewLoader=X;exports.THUMBNAIL_BATCH_SIZE=$;exports.THUMBNAIL_IMAGE_OPTIONS=K;exports.ZOOM_OPTIONS=L;exports.getStepZoomOptionValue=Q;exports.isPdfFile=ee;exports.useDocumentPreview=te;exports.useDocumentPreviewCache=J;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("@epam/ai-dial-ui-kit"),F=require("@epam/pdf-highlighter-kit"),t=require("react"),z=require("@tabler/icons-react"),R="auto",L="page-fit",V=[{value:R,label:"Auto"},{value:L,label:"Page Fit"},{value:"0.5",label:"50%"},{value:"0.75",label:"75%"},{value:"1",label:"100%"},{value:"1.25",label:"125%"},{value:"1.5",label:"150%"},{value:"2",label:"200%"},{value:"3",label:"300%"}],X={maxWidth:104,format:"image/jpeg",quality:.85},$=15,le="application/pdf",oe=".pdf",Y=({pdf:s,highlights:r,selectedHighlightId:u,autoFocusFirstHighlight:l=!1,selectedPageNumber:m,zoom:i,containerClassName:h,onTotalPagesChange:v,onViewerReady:N,selectedPages:d,viewerOptions:w})=>{const f=t.useRef(null),n=t.useRef(null),[b,E]=t.useState(!1),[y,D]=t.useState(!1),T=t.useRef(v),O=t.useRef(N),I=t.useRef(w);t.useEffect(()=>{T.current=v},[v]),t.useEffect(()=>{O.current=N},[N]),t.useEffect(()=>{I.current=w},[w]);const j=t.useCallback(a=>n.current?.goToHighlight(a),[]);return t.useEffect(()=>{if(!f.current)return;E(!1),D(!1),n.current&&(n.current.destroy(),n.current=null);let a=null,x=!0;const p=()=>{x&&D(!0)};return(async()=>{try{if(a=new F.PDFHighlightViewer,await a.init(f.current,{enableTextSelection:!0,enableVirtualScrolling:!0,bboxOrigin:"top-left",...I.current}),!x){a.destroy();return}if(a.addEventListener("zoomChanged",p),await a.loadPDF(s,{selectedPages:d}),!x){a.destroy();return}const C=a.getTotalPages?.();typeof C=="number"&&C>0&&T.current?.(C),x&&(n.current=a,E(!0))}catch(C){if(!x)return;console.error("Error in initViewer:",C)}})(),()=>{x=!1,a&&(a.removeEventListener("zoomChanged",p),a.destroy())}},[s,d]),t.useEffect(()=>{!b||!n.current||(n.current.loadHighlights(r),l&&r&&r[0]&&j(r[0].id))},[l,j,r,b]),t.useEffect(()=>{b&&y&&u&&j(u)},[j,b,y,u]),t.useEffect(()=>{if(!(!b||!i))if(i===R)n.current?.setZoom?.(F.ZoomMode.AUTO);else if(i===L)n.current?.setZoom?.(F.ZoomMode.PAGE_FIT);else{const a=parseFloat(i);!Number.isNaN(a)&&a>0&&n.current?.setZoom?.(a)}},[b,i]),t.useEffect(()=>{b&&m&&n.current?.setPage?.(m)},[b,m]),t.useEffect(()=>{if(!b||!n.current)return;const a=n.current;O.current?.({getThumbnailsDataUrl:(x,p)=>a.getThumbnailsDataUrl(x,p),zoomIn:()=>a.zoomIn(),zoomOut:()=>a.zoomOut(),getZoom:()=>a.getZoom(),navigateToPage:x=>a.setPage?.(x),setPageDisplayRotation:(x,p,S)=>a.setPageDisplayRotation(x,p,S),getPageDisplayRotation:x=>a.getPageDisplayRotation(x)})},[b]),e.jsx("div",{ref:f,className:c.mergeClasses("grow min-w-0 overflow-auto bg-layer-3",h)})},P="h-4 rounded-[120px] bg-gradient-to-r from-layer-4 via-layer-3 to-layer-4 bg-[length:200%_100%] animate-skeleton-wave",J=({className:s,ariaLabel:r="pdf preview loading"})=>e.jsx("div",{role:"status","aria-label":r,"aria-live":"polite",className:c.mergeClasses("h-full w-full bg-layer-3",s),children:e.jsxs("div",{className:"flex h-full w-full flex-col gap-10 px-[60px] pt-10",children:[e.jsx("div",{className:"mx-auto h-4 w-[208px] max-w-[40%] rounded-[120px] bg-gradient-to-r from-layer-4 via-layer-3 to-layer-4 bg-[length:200%_100%] animate-skeleton-wave"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:P}),e.jsx("div",{className:P}),e.jsx("div",{className:P}),e.jsx("div",{className:P}),e.jsx("div",{className:c.mergeClasses(P,"w-[28%] max-w-[320px]")})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:P}),e.jsx("div",{className:P}),e.jsx("div",{className:P}),e.jsx("div",{className:P}),e.jsx("div",{className:c.mergeClasses(P,"w-[58%] max-w-[520px]")})]})]})}),Q=t.createContext(null),ee=()=>t.useContext(Q),_=V.filter(({value:s})=>{const r=Number.parseFloat(s);return!Number.isNaN(r)&&r>0}),ie=[..._].reverse(),te=(s,r,u)=>{if(_.length===0)return s;const l=Number.parseFloat(s),m=!Number.isNaN(l)&&l>0?l:u,i=typeof m=="number"&&m>0?m:Number.parseFloat(_[0].value);return r===1?(_.find(({value:h})=>Number.parseFloat(h)>i)??_[_.length-1]).value:(ie.find(({value:h})=>Number.parseFloat(h)<i)??_[0]).value};function q(s,r){const u=(s??"").toLowerCase();return(r??"").toLowerCase()===le||u.endsWith(oe)}const W=V.map(s=>({value:s.value,label:s.label})),se=({fileUrl:s,fileName:r,loadFileCb:u,highlights:l,selectedPageNumber:m,onTotalPagesChange:i,thumbnailPageNumbers:h,onThumbnailsLoaded:v,onViewerReady:N,showLoaderOverlay:d=!1,selectedPages:w})=>{const f=ee(),n=t.useRef(null),[b,E]=t.useState(!1),[y,D]=t.useState(0),[T,O]=t.useState(!1),[I,j]=t.useState(null),[a,x]=t.useState(null),[p,S]=t.useState(R),C=t.useMemo(()=>{if(r)return q(r.toLowerCase());let o;try{o=new URL(s).pathname}catch{o=s.split("?")[0].split("#")[0]}const g=o.split("/").pop()??"";return!g.includes(".")||q(g.toLowerCase())},[r,s]),B=t.useCallback(o=>{D((y+o+l.length)%l.length)},[y,l.length]),U=t.useCallback(o=>{const g=n.current;!g?.getZoom||!o||S(te(p,o,g.getZoom()))},[p]),k=t.useMemo(()=>{if(!(p===R||p===L||V.some(g=>g.value===p))){const g=parseFloat(p);if(!Number.isNaN(g)&&g>0)return[...W,{value:p,label:`${Math.round(g*100)}%`}]}return W},[p]);t.useEffect(()=>{let o=!1;if(j(!0),O(!1),x(null),E(!1),n.current=null,!C){O(!0),j(!1);return}return(async()=>{try{const Z=await(f?f.getFile(s,()=>u(s)):u(s));o||x(Z)}catch{o||(O(!0),x(null))}finally{o||j(!1)}})(),()=>{o=!0}},[s,f,u,C]);const M=t.useCallback(o=>{n.current=o,E(!0),N?.(o)},[N]);return t.useEffect(()=>{const o=h??[],g=n.current?.getThumbnailsDataUrl;if(!o.length||!g||!a||!v||!b)return;let Z=!1;return(async()=>{const K=new Map;for(let A=0;A<o.length&&!Z;A+=$){const ae=o.slice(A,A+$);try{const H=await g(ae,X);if(Z)break;H.forEach((re,ne)=>K.set(ne,re)),v(new Map(K))}catch(H){console.warn("Thumbnail batch load failed:",H);break}}})(),()=>{Z=!0}},[h,a,v,b]),{file:a,isLoading:I,isError:T,isSupportedFile:C,activeHighlightIndex:y,zoom:p,setZoom:S,zoomSelectOptions:k,viewerApiRef:n,showLoader:!T&&(!!I||d),changeIndex:B,handleZoomChange:U,handleViewerReady:M}},ce=({fileUrl:s,fileName:r,errorLabel:u,occurrencesLabel:l,unsupportedLabel:m,highlights:i,loadFileCb:h,showOccurrences:v=!0,selectedPageNumber:N,containerClassName:d,pdfViewerClassName:w,onTotalPagesChange:f,title:n,thumbnailPageNumbers:b,onThumbnailsLoaded:E,onViewerReady:y,showLoaderOverlay:D=!1,selectedPages:T,selectedHighlightId:O,viewerOptions:I})=>{const{file:j,isError:a,isSupportedFile:x,activeHighlightIndex:p,zoom:S,setZoom:C,zoomSelectOptions:B,showLoader:U,changeIndex:k,handleZoomChange:M,handleViewerReady:G}=se({fileUrl:s,fileName:r,loadFileCb:h,highlights:i,selectedPageNumber:N,onTotalPagesChange:f,thumbnailPageNumbers:b,onThumbnailsLoaded:E,onViewerReady:y,showLoaderOverlay:D,selectedPages:T});return e.jsxs("div",{className:c.mergeClasses("flex flex-col self-center gap-4 py-3 px-6 h-full w-full bg-layer-2",d),children:[r&&e.jsx("div",{className:"shrink-0 min-h-0 w-full",children:e.jsx(c.DialEllipsisTooltip,{className:"dial-tiny-text text-secondary",text:r})}),e.jsxs("div",{className:c.mergeClasses("flex w-full justify-between items-center",v&&n?"gap-2":""),children:[e.jsx("div",{children:v?e.jsxs("div",{className:"flex gap-1 py-0.5 px-1.5 min-h-[26px] items-center bg-layer-4 rounded w-fit",children:[e.jsxs("span",{className:"dial-small-text",children:[l??"Occurrences",":",e.jsx("span",{className:"pl-0.5 min-w-3 inline-block text-right",children:i.length>0?`${p+1}/${i.length}`:"0"})]}),i.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(c.DialButton,{className:"p-0 text-primary !h-6.5",size:c.ElementSize.Small,iconAfter:e.jsx(z.IconChevronDown,{size:16}),"aria-label":"Next occurrence",onClick:()=>k(1)}),e.jsx(c.DialButton,{className:"p-0 text-primary !h-6.5",size:c.ElementSize.Small,iconAfter:e.jsx(z.IconChevronUp,{size:16}),"aria-label":"Previous occurrence",onClick:()=>k(-1)})]})]}):e.jsx("div",{})}),e.jsxs("div",{className:c.mergeClasses("flex flex-1 items-center gap-4 min-w-0",n!=null&&n!==""?"justify-between":"justify-end"),children:[n!=null&&n!==""&&e.jsx(c.DialEllipsisTooltip,{text:n,className:"dial-body-semi-text text-primary min-w-0"}),e.jsxs("div",{className:"flex gap-0.5 items-center shrink-0",children:[e.jsx("div",{className:"h-6",children:e.jsx(c.DialSelect,{size:c.SelectSize.Sm,className:"bg-layer-4 !py-0 h-6 min-h-6 dial-small-text max-h-full border-transparent hover:border-hover rounded",options:B,value:S,onChange:o=>C(o)})}),e.jsx(c.DialButton,{className:"py-0 flex items-center justify-center rounded text-primary bg-layer-4 border border-transparent hover:border-hover",iconAfter:e.jsx(z.IconMinus,{size:16}),"aria-label":"Zoom out",size:c.ElementSize.Small,onClick:()=>M(-1)}),e.jsx(c.DialButton,{className:"py-0 flex items-center justify-center rounded text-primary bg-layer-4 border border-transparent hover:border-hover",iconAfter:e.jsx(z.IconPlus,{size:16}),"aria-label":"Zoom in",size:c.ElementSize.Small,onClick:()=>M(1)})]})]})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[j&&e.jsx(Y,{pdf:j,highlights:i,selectedHighlightId:v?i[p]?.id:O,selectedPageNumber:N,zoom:S,onTotalPagesChange:f,onViewerReady:G,containerClassName:w,selectedPages:T,viewerOptions:I}),U&&e.jsx(J,{className:"absolute inset-0 z-10"}),a&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-layer-3",children:e.jsxs("div",{className:"flex flex-col items-center gap-6 p-10",children:[e.jsx(z.IconAlertTriangle,{size:60,stroke:2,className:"text-secondary"}),e.jsx("div",{className:"text-center dial-small-text whitespace-pre-wrap",children:!x&&m?m:u??"Failed to load document."})]})})]})]})},ue=1200*1e3,me=20,de=({children:s,ttlMs:r=ue,maxEntries:u=me})=>{const l=t.useRef(new Map),m=t.useCallback((d,w)=>{l.current.delete(d),l.current.set(d,w)},[]),i=t.useCallback(()=>{const d=Date.now();for(const[w,f]of l.current.entries())f.file&&d-f.timestamp>r&&l.current.delete(w)},[r]),h=t.useCallback(()=>{for(;l.current.size>u;){const d=l.current.keys().next().value;d&&l.current.delete(d)}},[u]),v=t.useCallback(()=>{l.current.clear()},[]),N=t.useCallback(async(d,w)=>{i();const f=l.current.get(d);if(f){if(m(d,{...f,timestamp:Date.now()}),f.file)return f.file;if(f.promise)return f.promise}const n=Date.now(),b=w().then(y=>{const D={file:y,timestamp:Date.now()};return m(d,D),h(),y}).catch(y=>{throw l.current.delete(d),y});return m(d,{promise:b,timestamp:n}),h(),b},[h,i,m]);return t.useEffect(()=>()=>v(),[v]),e.jsx(Q.Provider,{value:{getFile:N,clearCache:v},children:s})},fe=({pageNum:s,onSelectPage:r,isSelected:u,isLoading:l,isMultiselect:m,thumbnailUrl:i,className:h})=>e.jsxs("button",{type:"button","aria-label":`Page ${s}`,"aria-pressed":u,onClick:v=>{m&&v.target.closest("[data-checkbox-wrapper]")||r(s)},className:c.mergeClasses("flex flex-col gap-2 p-2 h-[186px] w-[120px] items-center justify-center cursor-pointer transition-colors hover:bg-layer-4 rounded-sm",u&&(m?"border border-accent-primary bg-accent-primary-alpha":"border border-primary"),h),children:[e.jsxs("div",{className:"relative w-[104px] h-[146px] bg-model-icon rounded-sm overflow-hidden",children:[i?e.jsx("img",{src:i,alt:`Page ${s} thumbnail`,className:"w-full h-full object-cover rounded-sm"}):null,m&&e.jsx("div",{className:"absolute left-1 top-1 z-10","data-checkbox-wrapper":!0,children:e.jsx(c.DialCheckbox,{id:`page-thumbnail-${s}`,checked:u,onChange:()=>r(s),className:"before:border-primary before:bg-model-icon bg-model-icon"})}),l&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-blackout rounded-sm",children:e.jsx(c.DialLoader,{size:24,fullWidth:!1,ariaLabel:`Loading page ${s}`})})]}),e.jsx("span",{className:"dial-tiny-text text-primary",children:s})]});Object.defineProperty(exports,"RotationDirection",{enumerable:!0,get:()=>F.RotationDirection});exports.AUTO_ZOOM_ID=R;exports.DocumentPreview=ce;exports.DocumentPreviewCacheProvider=de;exports.FIT_ZOOM_ID=L;exports.PDFViewer=Y;exports.PageThumbnail=fe;exports.PdfPreviewLoader=J;exports.THUMBNAIL_BATCH_SIZE=$;exports.THUMBNAIL_IMAGE_OPTIONS=X;exports.ZOOM_OPTIONS=V;exports.getStepZoomOptionValue=te;exports.isPdfFile=q;exports.useDocumentPreview=se;exports.useDocumentPreviewCache=ee;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { mergeClasses as
|
|
3
|
-
import { ZoomMode as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as e, jsxs as x, Fragment as se } from "react/jsx-runtime";
|
|
2
|
+
import { mergeClasses as Z, DialEllipsisTooltip as Y, DialButton as j, ElementSize as B, DialSelect as ie, SelectSize as ce, DialCheckbox as ue, DialLoader as me } from "@epam/ai-dial-ui-kit";
|
|
3
|
+
import { ZoomMode as J, PDFHighlightViewer as de } from "@epam/pdf-highlighter-kit";
|
|
4
|
+
import { RotationDirection as Be } from "@epam/pdf-highlighter-kit";
|
|
5
|
+
import { useRef as L, useState as S, useEffect as w, useCallback as D, createContext as fe, useContext as pe, useMemo as Q } from "react";
|
|
6
|
+
import { IconChevronDown as he, IconChevronUp as ve, IconMinus as be, IconPlus as xe, IconAlertTriangle as ge } from "@tabler/icons-react";
|
|
7
|
+
const U = "auto", G = "page-fit", X = [
|
|
8
|
+
{ value: U, label: "Auto" },
|
|
8
9
|
{ value: G, label: "Page Fit" },
|
|
9
10
|
{ value: "0.5", label: "50%" },
|
|
10
11
|
{ value: "0.75", label: "75%" },
|
|
@@ -13,99 +14,106 @@ const H = "auto", G = "page-fit", X = [
|
|
|
13
14
|
{ value: "1.5", label: "150%" },
|
|
14
15
|
{ value: "2", label: "200%" },
|
|
15
16
|
{ value: "3", label: "300%" }
|
|
16
|
-
],
|
|
17
|
+
], ye = {
|
|
17
18
|
maxWidth: 104,
|
|
18
19
|
format: "image/jpeg",
|
|
19
20
|
quality: 0.85
|
|
20
|
-
},
|
|
21
|
+
}, ee = 15, we = "application/pdf", Ne = ".pdf", Ce = ({
|
|
21
22
|
pdf: t,
|
|
22
23
|
highlights: a,
|
|
23
24
|
selectedHighlightId: i,
|
|
24
|
-
autoFocusFirstHighlight:
|
|
25
|
-
selectedPageNumber:
|
|
25
|
+
autoFocusFirstHighlight: o = !1,
|
|
26
|
+
selectedPageNumber: c,
|
|
26
27
|
zoom: s,
|
|
27
|
-
containerClassName:
|
|
28
|
-
onTotalPagesChange:
|
|
29
|
-
onViewerReady:
|
|
30
|
-
selectedPages:
|
|
28
|
+
containerClassName: v,
|
|
29
|
+
onTotalPagesChange: h,
|
|
30
|
+
onViewerReady: N,
|
|
31
|
+
selectedPages: u,
|
|
32
|
+
viewerOptions: y
|
|
31
33
|
}) => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, [
|
|
36
|
-
|
|
37
|
-
}, [
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const m = L(null), n = L(null), [p, I] = S(!1), [g, _] = S(!1), E = L(h), O = L(N), R = L(y);
|
|
35
|
+
w(() => {
|
|
36
|
+
E.current = h;
|
|
37
|
+
}, [h]), w(() => {
|
|
38
|
+
O.current = N;
|
|
39
|
+
}, [N]), w(() => {
|
|
40
|
+
R.current = y;
|
|
41
|
+
}, [y]);
|
|
42
|
+
const C = D(
|
|
43
|
+
(r) => n.current?.goToHighlight(r),
|
|
40
44
|
[]
|
|
41
45
|
);
|
|
42
|
-
return
|
|
43
|
-
if (!
|
|
44
|
-
|
|
45
|
-
let
|
|
46
|
+
return w(() => {
|
|
47
|
+
if (!m.current) return;
|
|
48
|
+
I(!1), _(!1), n.current && (n.current.destroy(), n.current = null);
|
|
49
|
+
let r = null, d = !0;
|
|
50
|
+
const f = () => {
|
|
51
|
+
d && _(!0);
|
|
52
|
+
};
|
|
46
53
|
return (async () => {
|
|
47
54
|
try {
|
|
48
|
-
if (
|
|
55
|
+
if (r = new de(), await r.init(m.current, {
|
|
49
56
|
enableTextSelection: !0,
|
|
50
57
|
enableVirtualScrolling: !0,
|
|
51
|
-
bboxOrigin: "top-left"
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
bboxOrigin: "top-left",
|
|
59
|
+
...R.current
|
|
60
|
+
}), !d) {
|
|
61
|
+
r.destroy();
|
|
54
62
|
return;
|
|
55
63
|
}
|
|
56
|
-
if (await
|
|
57
|
-
|
|
64
|
+
if (r.addEventListener("zoomChanged", f), await r.loadPDF(t, { selectedPages: u }), !d) {
|
|
65
|
+
r.destroy();
|
|
58
66
|
return;
|
|
59
67
|
}
|
|
60
|
-
const
|
|
61
|
-
typeof
|
|
62
|
-
} catch (
|
|
63
|
-
if (!
|
|
68
|
+
const P = r.getTotalPages?.();
|
|
69
|
+
typeof P == "number" && P > 0 && E.current?.(P), d && (n.current = r, I(!0));
|
|
70
|
+
} catch (P) {
|
|
71
|
+
if (!d)
|
|
64
72
|
return;
|
|
65
|
-
console.error("Error in initViewer:",
|
|
73
|
+
console.error("Error in initViewer:", P);
|
|
66
74
|
}
|
|
67
75
|
})(), () => {
|
|
68
|
-
|
|
76
|
+
d = !1, r && (r.removeEventListener("zoomChanged", f), r.destroy());
|
|
69
77
|
};
|
|
70
|
-
}, [t,
|
|
71
|
-
!
|
|
72
|
-
}, [
|
|
73
|
-
|
|
74
|
-
}, [
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (s === H)
|
|
79
|
-
r.current?.setZoom?.(Y.AUTO);
|
|
78
|
+
}, [t, u]), w(() => {
|
|
79
|
+
!p || !n.current || (n.current.loadHighlights(a), o && a && a[0] && C(a[0].id));
|
|
80
|
+
}, [o, C, a, p]), w(() => {
|
|
81
|
+
p && g && i && C(i);
|
|
82
|
+
}, [C, p, g, i]), w(() => {
|
|
83
|
+
if (!(!p || !s))
|
|
84
|
+
if (s === U)
|
|
85
|
+
n.current?.setZoom?.(J.AUTO);
|
|
80
86
|
else if (s === G)
|
|
81
|
-
|
|
87
|
+
n.current?.setZoom?.(J.PAGE_FIT);
|
|
82
88
|
else {
|
|
83
|
-
const
|
|
84
|
-
!Number.isNaN(
|
|
89
|
+
const r = parseFloat(s);
|
|
90
|
+
!Number.isNaN(r) && r > 0 && n.current?.setZoom?.(r);
|
|
85
91
|
}
|
|
86
|
-
}, [
|
|
87
|
-
|
|
88
|
-
}, [
|
|
89
|
-
if (!
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
getThumbnailsDataUrl: (
|
|
93
|
-
zoomIn: () =>
|
|
94
|
-
zoomOut: () =>
|
|
95
|
-
getZoom: () =>
|
|
96
|
-
navigateToPage: (
|
|
92
|
+
}, [p, s]), w(() => {
|
|
93
|
+
p && c && n.current?.setPage?.(c);
|
|
94
|
+
}, [p, c]), w(() => {
|
|
95
|
+
if (!p || !n.current) return;
|
|
96
|
+
const r = n.current;
|
|
97
|
+
O.current?.({
|
|
98
|
+
getThumbnailsDataUrl: (d, f) => r.getThumbnailsDataUrl(d, f),
|
|
99
|
+
zoomIn: () => r.zoomIn(),
|
|
100
|
+
zoomOut: () => r.zoomOut(),
|
|
101
|
+
getZoom: () => r.getZoom(),
|
|
102
|
+
navigateToPage: (d) => r.setPage?.(d),
|
|
103
|
+
setPageDisplayRotation: (d, f, z) => r.setPageDisplayRotation(d, f, z),
|
|
104
|
+
getPageDisplayRotation: (d) => r.getPageDisplayRotation(d)
|
|
97
105
|
});
|
|
98
|
-
}, [
|
|
106
|
+
}, [p]), /* @__PURE__ */ e(
|
|
99
107
|
"div",
|
|
100
108
|
{
|
|
101
|
-
ref:
|
|
102
|
-
className:
|
|
109
|
+
ref: m,
|
|
110
|
+
className: Z(
|
|
103
111
|
"grow min-w-0 overflow-auto bg-layer-3",
|
|
104
|
-
|
|
112
|
+
v
|
|
105
113
|
)
|
|
106
114
|
}
|
|
107
115
|
);
|
|
108
|
-
},
|
|
116
|
+
}, T = "h-4 rounded-[120px] bg-gradient-to-r from-layer-4 via-layer-3 to-layer-4 bg-[length:200%_100%] animate-skeleton-wave", Pe = ({
|
|
109
117
|
className: t,
|
|
110
118
|
ariaLabel: a = "pdf preview loading"
|
|
111
119
|
}) => /* @__PURE__ */ e(
|
|
@@ -114,34 +122,34 @@ const H = "auto", G = "page-fit", X = [
|
|
|
114
122
|
role: "status",
|
|
115
123
|
"aria-label": a,
|
|
116
124
|
"aria-live": "polite",
|
|
117
|
-
className:
|
|
118
|
-
children: /* @__PURE__ */
|
|
125
|
+
className: Z("h-full w-full bg-layer-3", t),
|
|
126
|
+
children: /* @__PURE__ */ x("div", { className: "flex h-full w-full flex-col gap-10 px-[60px] pt-10", children: [
|
|
119
127
|
/* @__PURE__ */ e("div", { className: "mx-auto h-4 w-[208px] max-w-[40%] rounded-[120px] bg-gradient-to-r from-layer-4 via-layer-3 to-layer-4 bg-[length:200%_100%] animate-skeleton-wave" }),
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
/* @__PURE__ */ e("div", { className:
|
|
122
|
-
/* @__PURE__ */ e("div", { className:
|
|
123
|
-
/* @__PURE__ */ e("div", { className:
|
|
124
|
-
/* @__PURE__ */ e("div", { className:
|
|
128
|
+
/* @__PURE__ */ x("div", { className: "flex flex-col gap-4", children: [
|
|
129
|
+
/* @__PURE__ */ e("div", { className: T }),
|
|
130
|
+
/* @__PURE__ */ e("div", { className: T }),
|
|
131
|
+
/* @__PURE__ */ e("div", { className: T }),
|
|
132
|
+
/* @__PURE__ */ e("div", { className: T }),
|
|
125
133
|
/* @__PURE__ */ e(
|
|
126
134
|
"div",
|
|
127
135
|
{
|
|
128
|
-
className:
|
|
129
|
-
|
|
136
|
+
className: Z(
|
|
137
|
+
T,
|
|
130
138
|
"w-[28%] max-w-[320px]"
|
|
131
139
|
)
|
|
132
140
|
}
|
|
133
141
|
)
|
|
134
142
|
] }),
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */ e("div", { className:
|
|
137
|
-
/* @__PURE__ */ e("div", { className:
|
|
138
|
-
/* @__PURE__ */ e("div", { className:
|
|
139
|
-
/* @__PURE__ */ e("div", { className:
|
|
143
|
+
/* @__PURE__ */ x("div", { className: "flex flex-col gap-4", children: [
|
|
144
|
+
/* @__PURE__ */ e("div", { className: T }),
|
|
145
|
+
/* @__PURE__ */ e("div", { className: T }),
|
|
146
|
+
/* @__PURE__ */ e("div", { className: T }),
|
|
147
|
+
/* @__PURE__ */ e("div", { className: T }),
|
|
140
148
|
/* @__PURE__ */ e(
|
|
141
149
|
"div",
|
|
142
150
|
{
|
|
143
|
-
className:
|
|
144
|
-
|
|
151
|
+
className: Z(
|
|
152
|
+
T,
|
|
145
153
|
"w-[58%] max-w-[520px]"
|
|
146
154
|
)
|
|
147
155
|
}
|
|
@@ -149,216 +157,220 @@ const H = "auto", G = "page-fit", X = [
|
|
|
149
157
|
] })
|
|
150
158
|
] })
|
|
151
159
|
}
|
|
152
|
-
),
|
|
160
|
+
), ae = fe(null), Te = () => pe(ae), F = X.filter(({ value: t }) => {
|
|
153
161
|
const a = Number.parseFloat(t);
|
|
154
162
|
return !Number.isNaN(a) && a > 0;
|
|
155
|
-
}),
|
|
156
|
-
if (
|
|
163
|
+
}), De = [...F].reverse(), Ie = (t, a, i) => {
|
|
164
|
+
if (F.length === 0)
|
|
157
165
|
return t;
|
|
158
|
-
const
|
|
159
|
-
return a === 1 ? (
|
|
160
|
-
({ value:
|
|
161
|
-
) ??
|
|
162
|
-
({ value:
|
|
163
|
-
) ??
|
|
166
|
+
const o = Number.parseFloat(t), c = !Number.isNaN(o) && o > 0 ? o : i, s = typeof c == "number" && c > 0 ? c : Number.parseFloat(F[0].value);
|
|
167
|
+
return a === 1 ? (F.find(
|
|
168
|
+
({ value: v }) => Number.parseFloat(v) > s
|
|
169
|
+
) ?? F[F.length - 1]).value : (De.find(
|
|
170
|
+
({ value: v }) => Number.parseFloat(v) < s
|
|
171
|
+
) ?? F[0]).value;
|
|
164
172
|
};
|
|
165
|
-
function
|
|
173
|
+
function te(t, a) {
|
|
166
174
|
const i = (t ?? "").toLowerCase();
|
|
167
|
-
return (a ?? "").toLowerCase() === we || i.endsWith(
|
|
175
|
+
return (a ?? "").toLowerCase() === we || i.endsWith(Ne);
|
|
168
176
|
}
|
|
169
|
-
const
|
|
177
|
+
const re = X.map((t) => ({
|
|
170
178
|
value: t.value,
|
|
171
179
|
label: t.label
|
|
172
|
-
})),
|
|
180
|
+
})), _e = ({
|
|
173
181
|
fileUrl: t,
|
|
174
182
|
fileName: a,
|
|
175
183
|
loadFileCb: i,
|
|
176
|
-
highlights:
|
|
177
|
-
selectedPageNumber:
|
|
184
|
+
highlights: o,
|
|
185
|
+
selectedPageNumber: c,
|
|
178
186
|
onTotalPagesChange: s,
|
|
179
|
-
thumbnailPageNumbers:
|
|
180
|
-
onThumbnailsLoaded:
|
|
181
|
-
onViewerReady:
|
|
182
|
-
showLoaderOverlay:
|
|
183
|
-
selectedPages:
|
|
187
|
+
thumbnailPageNumbers: v,
|
|
188
|
+
onThumbnailsLoaded: h,
|
|
189
|
+
onViewerReady: N,
|
|
190
|
+
showLoaderOverlay: u = !1,
|
|
191
|
+
selectedPages: y
|
|
184
192
|
}) => {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
(
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
const m = Te(), n = L(null), [p, I] = S(!1), [g, _] = S(0), [E, O] = S(!1), [R, C] = S(null), [r, d] = S(null), [f, z] = S(U), P = Q(() => {
|
|
194
|
+
if (a)
|
|
195
|
+
return te(a.toLowerCase());
|
|
196
|
+
let l;
|
|
197
|
+
try {
|
|
198
|
+
l = new URL(t).pathname;
|
|
199
|
+
} catch {
|
|
200
|
+
l = t.split("?")[0].split("#")[0];
|
|
201
|
+
}
|
|
202
|
+
const b = l.split("/").pop() ?? "";
|
|
203
|
+
return !b.includes(".") || te(b.toLowerCase());
|
|
204
|
+
}, [a, t]), $ = D(
|
|
205
|
+
(l) => {
|
|
206
|
+
_(
|
|
207
|
+
(g + l + o.length) % o.length
|
|
198
208
|
);
|
|
199
209
|
},
|
|
200
|
-
[
|
|
201
|
-
),
|
|
202
|
-
(
|
|
203
|
-
const
|
|
204
|
-
!
|
|
210
|
+
[g, o.length]
|
|
211
|
+
), H = D(
|
|
212
|
+
(l) => {
|
|
213
|
+
const b = n.current;
|
|
214
|
+
!b?.getZoom || !l || z(Ie(f, l, b.getZoom()));
|
|
205
215
|
},
|
|
206
|
-
[
|
|
207
|
-
),
|
|
208
|
-
if (!(
|
|
209
|
-
const
|
|
210
|
-
if (!Number.isNaN(
|
|
216
|
+
[f]
|
|
217
|
+
), A = Q(() => {
|
|
218
|
+
if (!(f === U || f === G || X.some((b) => b.value === f))) {
|
|
219
|
+
const b = parseFloat(f);
|
|
220
|
+
if (!Number.isNaN(b) && b > 0)
|
|
211
221
|
return [
|
|
212
|
-
...
|
|
213
|
-
{ value:
|
|
222
|
+
...re,
|
|
223
|
+
{ value: f, label: `${Math.round(b * 100)}%` }
|
|
214
224
|
];
|
|
215
225
|
}
|
|
216
|
-
return
|
|
217
|
-
}, [
|
|
218
|
-
|
|
219
|
-
let
|
|
220
|
-
if (
|
|
221
|
-
|
|
226
|
+
return re;
|
|
227
|
+
}, [f]);
|
|
228
|
+
w(() => {
|
|
229
|
+
let l = !1;
|
|
230
|
+
if (C(!0), O(!1), d(null), I(!1), n.current = null, !P) {
|
|
231
|
+
O(!0), C(!1);
|
|
222
232
|
return;
|
|
223
233
|
}
|
|
224
234
|
return (async () => {
|
|
225
235
|
try {
|
|
226
|
-
const
|
|
227
|
-
|
|
236
|
+
const k = await (m ? m.getFile(t, () => i(t)) : i(t));
|
|
237
|
+
l || d(k);
|
|
228
238
|
} catch {
|
|
229
|
-
|
|
239
|
+
l || (O(!0), d(null));
|
|
230
240
|
} finally {
|
|
231
|
-
|
|
241
|
+
l || C(!1);
|
|
232
242
|
}
|
|
233
243
|
})(), () => {
|
|
234
|
-
|
|
244
|
+
l = !0;
|
|
235
245
|
};
|
|
236
|
-
}, [t,
|
|
237
|
-
const
|
|
238
|
-
(
|
|
239
|
-
|
|
246
|
+
}, [t, m, i, P]);
|
|
247
|
+
const M = D(
|
|
248
|
+
(l) => {
|
|
249
|
+
n.current = l, I(!0), N?.(l);
|
|
240
250
|
},
|
|
241
|
-
[
|
|
251
|
+
[N]
|
|
242
252
|
);
|
|
243
|
-
return
|
|
244
|
-
const
|
|
245
|
-
if (!
|
|
253
|
+
return w(() => {
|
|
254
|
+
const l = v ?? [], b = n.current?.getThumbnailsDataUrl;
|
|
255
|
+
if (!l.length || !b || !r || !h || !p)
|
|
246
256
|
return;
|
|
247
|
-
let
|
|
257
|
+
let k = !1;
|
|
248
258
|
return (async () => {
|
|
249
|
-
const
|
|
250
|
-
for (let V = 0; V <
|
|
251
|
-
const
|
|
259
|
+
const K = /* @__PURE__ */ new Map();
|
|
260
|
+
for (let V = 0; V < l.length && !k; V += ee) {
|
|
261
|
+
const ne = l.slice(V, V + ee);
|
|
252
262
|
try {
|
|
253
|
-
const W = await
|
|
254
|
-
if (
|
|
255
|
-
W.forEach((
|
|
263
|
+
const W = await b(ne, ye);
|
|
264
|
+
if (k) break;
|
|
265
|
+
W.forEach((oe, le) => K.set(le, oe)), h(new Map(K));
|
|
256
266
|
} catch (W) {
|
|
257
267
|
console.warn("Thumbnail batch load failed:", W);
|
|
258
268
|
break;
|
|
259
269
|
}
|
|
260
270
|
}
|
|
261
271
|
})(), () => {
|
|
262
|
-
|
|
272
|
+
k = !0;
|
|
263
273
|
};
|
|
264
|
-
}, [
|
|
265
|
-
file:
|
|
266
|
-
isLoading:
|
|
267
|
-
isError:
|
|
268
|
-
isSupportedFile:
|
|
269
|
-
activeHighlightIndex:
|
|
270
|
-
zoom:
|
|
271
|
-
setZoom:
|
|
272
|
-
zoomSelectOptions:
|
|
273
|
-
viewerApiRef:
|
|
274
|
-
showLoader: !
|
|
275
|
-
changeIndex:
|
|
276
|
-
handleZoomChange:
|
|
277
|
-
handleViewerReady:
|
|
274
|
+
}, [v, r, h, p]), {
|
|
275
|
+
file: r,
|
|
276
|
+
isLoading: R,
|
|
277
|
+
isError: E,
|
|
278
|
+
isSupportedFile: P,
|
|
279
|
+
activeHighlightIndex: g,
|
|
280
|
+
zoom: f,
|
|
281
|
+
setZoom: z,
|
|
282
|
+
zoomSelectOptions: A,
|
|
283
|
+
viewerApiRef: n,
|
|
284
|
+
showLoader: !E && (!!R || u),
|
|
285
|
+
changeIndex: $,
|
|
286
|
+
handleZoomChange: H,
|
|
287
|
+
handleViewerReady: M
|
|
278
288
|
};
|
|
279
|
-
},
|
|
289
|
+
}, ke = ({
|
|
280
290
|
fileUrl: t,
|
|
281
291
|
fileName: a,
|
|
282
292
|
errorLabel: i,
|
|
283
|
-
occurrencesLabel:
|
|
284
|
-
unsupportedLabel:
|
|
293
|
+
occurrencesLabel: o,
|
|
294
|
+
unsupportedLabel: c,
|
|
285
295
|
highlights: s,
|
|
286
|
-
loadFileCb:
|
|
287
|
-
showOccurrences:
|
|
288
|
-
selectedPageNumber:
|
|
289
|
-
containerClassName:
|
|
290
|
-
pdfViewerClassName:
|
|
291
|
-
onTotalPagesChange:
|
|
292
|
-
title:
|
|
293
|
-
thumbnailPageNumbers:
|
|
294
|
-
onThumbnailsLoaded:
|
|
295
|
-
onViewerReady:
|
|
296
|
-
showLoaderOverlay:
|
|
297
|
-
selectedPages:
|
|
296
|
+
loadFileCb: v,
|
|
297
|
+
showOccurrences: h = !0,
|
|
298
|
+
selectedPageNumber: N,
|
|
299
|
+
containerClassName: u,
|
|
300
|
+
pdfViewerClassName: y,
|
|
301
|
+
onTotalPagesChange: m,
|
|
302
|
+
title: n,
|
|
303
|
+
thumbnailPageNumbers: p,
|
|
304
|
+
onThumbnailsLoaded: I,
|
|
305
|
+
onViewerReady: g,
|
|
306
|
+
showLoaderOverlay: _ = !1,
|
|
307
|
+
selectedPages: E,
|
|
308
|
+
selectedHighlightId: O,
|
|
309
|
+
viewerOptions: R
|
|
298
310
|
}) => {
|
|
299
311
|
const {
|
|
300
|
-
file:
|
|
301
|
-
isError:
|
|
302
|
-
isSupportedFile:
|
|
303
|
-
activeHighlightIndex:
|
|
304
|
-
zoom:
|
|
305
|
-
setZoom:
|
|
306
|
-
zoomSelectOptions:
|
|
307
|
-
showLoader:
|
|
308
|
-
changeIndex:
|
|
309
|
-
handleZoomChange:
|
|
310
|
-
handleViewerReady:
|
|
311
|
-
} =
|
|
312
|
+
file: C,
|
|
313
|
+
isError: r,
|
|
314
|
+
isSupportedFile: d,
|
|
315
|
+
activeHighlightIndex: f,
|
|
316
|
+
zoom: z,
|
|
317
|
+
setZoom: P,
|
|
318
|
+
zoomSelectOptions: $,
|
|
319
|
+
showLoader: H,
|
|
320
|
+
changeIndex: A,
|
|
321
|
+
handleZoomChange: M,
|
|
322
|
+
handleViewerReady: q
|
|
323
|
+
} = _e({
|
|
312
324
|
fileUrl: t,
|
|
313
325
|
fileName: a,
|
|
314
|
-
loadFileCb:
|
|
326
|
+
loadFileCb: v,
|
|
315
327
|
highlights: s,
|
|
316
|
-
selectedPageNumber:
|
|
317
|
-
onTotalPagesChange:
|
|
318
|
-
thumbnailPageNumbers:
|
|
319
|
-
onThumbnailsLoaded:
|
|
320
|
-
onViewerReady:
|
|
321
|
-
showLoaderOverlay:
|
|
322
|
-
selectedPages:
|
|
328
|
+
selectedPageNumber: N,
|
|
329
|
+
onTotalPagesChange: m,
|
|
330
|
+
thumbnailPageNumbers: p,
|
|
331
|
+
onThumbnailsLoaded: I,
|
|
332
|
+
onViewerReady: g,
|
|
333
|
+
showLoaderOverlay: _,
|
|
334
|
+
selectedPages: E
|
|
323
335
|
});
|
|
324
|
-
return /* @__PURE__ */
|
|
336
|
+
return /* @__PURE__ */ x(
|
|
325
337
|
"div",
|
|
326
338
|
{
|
|
327
|
-
className:
|
|
339
|
+
className: Z(
|
|
328
340
|
"flex flex-col self-center gap-4 py-3 px-6 h-full w-full bg-layer-2",
|
|
329
|
-
|
|
341
|
+
u
|
|
330
342
|
),
|
|
331
343
|
children: [
|
|
332
344
|
a && /* @__PURE__ */ e("div", { className: "shrink-0 min-h-0 w-full", children: /* @__PURE__ */ e(
|
|
333
|
-
|
|
345
|
+
Y,
|
|
334
346
|
{
|
|
335
347
|
className: "dial-tiny-text text-secondary",
|
|
336
348
|
text: a
|
|
337
349
|
}
|
|
338
350
|
) }),
|
|
339
|
-
/* @__PURE__ */
|
|
351
|
+
/* @__PURE__ */ x(
|
|
340
352
|
"div",
|
|
341
353
|
{
|
|
342
|
-
className:
|
|
354
|
+
className: Z(
|
|
343
355
|
"flex w-full justify-between items-center",
|
|
344
|
-
|
|
356
|
+
h && n ? "gap-2" : ""
|
|
345
357
|
),
|
|
346
358
|
children: [
|
|
347
|
-
/* @__PURE__ */ e("div", { children:
|
|
348
|
-
/* @__PURE__ */
|
|
349
|
-
|
|
359
|
+
/* @__PURE__ */ e("div", { children: h ? /* @__PURE__ */ x("div", { className: "flex gap-1 py-0.5 px-1.5 min-h-[26px] items-center bg-layer-4 rounded w-fit", children: [
|
|
360
|
+
/* @__PURE__ */ x("span", { className: "dial-small-text", children: [
|
|
361
|
+
o ?? "Occurrences",
|
|
350
362
|
":",
|
|
351
|
-
/* @__PURE__ */ e("span", { className: "pl-0.5 min-w-3 inline-block text-right", children: s.length > 0 ? `${
|
|
363
|
+
/* @__PURE__ */ e("span", { className: "pl-0.5 min-w-3 inline-block text-right", children: s.length > 0 ? `${f + 1}/${s.length}` : "0" })
|
|
352
364
|
] }),
|
|
353
|
-
s.length > 0 && /* @__PURE__ */
|
|
365
|
+
s.length > 0 && /* @__PURE__ */ x(se, { children: [
|
|
354
366
|
/* @__PURE__ */ e(
|
|
355
367
|
j,
|
|
356
368
|
{
|
|
357
369
|
className: "p-0 text-primary !h-6.5",
|
|
358
370
|
size: B.Small,
|
|
359
|
-
iconAfter: /* @__PURE__ */ e(
|
|
371
|
+
iconAfter: /* @__PURE__ */ e(he, { size: 16 }),
|
|
360
372
|
"aria-label": "Next occurrence",
|
|
361
|
-
onClick: () =>
|
|
373
|
+
onClick: () => A(1)
|
|
362
374
|
}
|
|
363
375
|
),
|
|
364
376
|
/* @__PURE__ */ e(
|
|
@@ -366,57 +378,57 @@ const ee = X.map((t) => ({
|
|
|
366
378
|
{
|
|
367
379
|
className: "p-0 text-primary !h-6.5",
|
|
368
380
|
size: B.Small,
|
|
369
|
-
iconAfter: /* @__PURE__ */ e(
|
|
381
|
+
iconAfter: /* @__PURE__ */ e(ve, { size: 16 }),
|
|
370
382
|
"aria-label": "Previous occurrence",
|
|
371
|
-
onClick: () =>
|
|
383
|
+
onClick: () => A(-1)
|
|
372
384
|
}
|
|
373
385
|
)
|
|
374
386
|
] })
|
|
375
387
|
] }) : /* @__PURE__ */ e("div", {}) }),
|
|
376
|
-
/* @__PURE__ */
|
|
388
|
+
/* @__PURE__ */ x(
|
|
377
389
|
"div",
|
|
378
390
|
{
|
|
379
|
-
className:
|
|
391
|
+
className: Z(
|
|
380
392
|
"flex flex-1 items-center gap-4 min-w-0",
|
|
381
|
-
|
|
393
|
+
n != null && n !== "" ? "justify-between" : "justify-end"
|
|
382
394
|
),
|
|
383
395
|
children: [
|
|
384
|
-
|
|
385
|
-
|
|
396
|
+
n != null && n !== "" && /* @__PURE__ */ e(
|
|
397
|
+
Y,
|
|
386
398
|
{
|
|
387
|
-
text:
|
|
399
|
+
text: n,
|
|
388
400
|
className: "dial-body-semi-text text-primary min-w-0"
|
|
389
401
|
}
|
|
390
402
|
),
|
|
391
|
-
/* @__PURE__ */
|
|
403
|
+
/* @__PURE__ */ x("div", { className: "flex gap-0.5 items-center shrink-0", children: [
|
|
392
404
|
/* @__PURE__ */ e("div", { className: "h-6", children: /* @__PURE__ */ e(
|
|
393
|
-
|
|
405
|
+
ie,
|
|
394
406
|
{
|
|
395
|
-
size:
|
|
407
|
+
size: ce.Sm,
|
|
396
408
|
className: "bg-layer-4 !py-0 h-6 min-h-6 dial-small-text max-h-full border-transparent hover:border-hover rounded",
|
|
397
|
-
options:
|
|
398
|
-
value:
|
|
399
|
-
onChange: (
|
|
409
|
+
options: $,
|
|
410
|
+
value: z,
|
|
411
|
+
onChange: (l) => P(l)
|
|
400
412
|
}
|
|
401
413
|
) }),
|
|
402
414
|
/* @__PURE__ */ e(
|
|
403
415
|
j,
|
|
404
416
|
{
|
|
405
417
|
className: "py-0 flex items-center justify-center rounded text-primary bg-layer-4 border border-transparent hover:border-hover",
|
|
406
|
-
iconAfter: /* @__PURE__ */ e(
|
|
418
|
+
iconAfter: /* @__PURE__ */ e(be, { size: 16 }),
|
|
407
419
|
"aria-label": "Zoom out",
|
|
408
420
|
size: B.Small,
|
|
409
|
-
onClick: () =>
|
|
421
|
+
onClick: () => M(-1)
|
|
410
422
|
}
|
|
411
423
|
),
|
|
412
424
|
/* @__PURE__ */ e(
|
|
413
425
|
j,
|
|
414
426
|
{
|
|
415
427
|
className: "py-0 flex items-center justify-center rounded text-primary bg-layer-4 border border-transparent hover:border-hover",
|
|
416
|
-
iconAfter: /* @__PURE__ */ e(
|
|
428
|
+
iconAfter: /* @__PURE__ */ e(xe, { size: 16 }),
|
|
417
429
|
"aria-label": "Zoom in",
|
|
418
430
|
size: B.Small,
|
|
419
|
-
onClick: () =>
|
|
431
|
+
onClick: () => M(1)
|
|
420
432
|
}
|
|
421
433
|
)
|
|
422
434
|
] })
|
|
@@ -426,100 +438,101 @@ const ee = X.map((t) => ({
|
|
|
426
438
|
]
|
|
427
439
|
}
|
|
428
440
|
),
|
|
429
|
-
/* @__PURE__ */
|
|
430
|
-
|
|
431
|
-
|
|
441
|
+
/* @__PURE__ */ x("div", { className: "relative flex min-h-0 flex-1", children: [
|
|
442
|
+
C && /* @__PURE__ */ e(
|
|
443
|
+
Ce,
|
|
432
444
|
{
|
|
433
|
-
pdf:
|
|
445
|
+
pdf: C,
|
|
434
446
|
highlights: s,
|
|
435
|
-
selectedHighlightId:
|
|
436
|
-
selectedPageNumber:
|
|
437
|
-
zoom:
|
|
438
|
-
onTotalPagesChange:
|
|
439
|
-
onViewerReady:
|
|
440
|
-
containerClassName:
|
|
441
|
-
selectedPages:
|
|
447
|
+
selectedHighlightId: h ? s[f]?.id : O,
|
|
448
|
+
selectedPageNumber: N,
|
|
449
|
+
zoom: z,
|
|
450
|
+
onTotalPagesChange: m,
|
|
451
|
+
onViewerReady: q,
|
|
452
|
+
containerClassName: y,
|
|
453
|
+
selectedPages: E,
|
|
454
|
+
viewerOptions: R
|
|
442
455
|
}
|
|
443
456
|
),
|
|
444
|
-
|
|
445
|
-
|
|
457
|
+
H && /* @__PURE__ */ e(Pe, { className: "absolute inset-0 z-10" }),
|
|
458
|
+
r && /* @__PURE__ */ e("div", { className: "absolute inset-0 z-20 flex items-center justify-center bg-layer-3", children: /* @__PURE__ */ x("div", { className: "flex flex-col items-center gap-6 p-10", children: [
|
|
446
459
|
/* @__PURE__ */ e(
|
|
447
|
-
|
|
460
|
+
ge,
|
|
448
461
|
{
|
|
449
462
|
size: 60,
|
|
450
463
|
stroke: 2,
|
|
451
464
|
className: "text-secondary"
|
|
452
465
|
}
|
|
453
466
|
),
|
|
454
|
-
/* @__PURE__ */ e("div", { className: "text-center dial-small-text whitespace-pre-wrap", children: !
|
|
467
|
+
/* @__PURE__ */ e("div", { className: "text-center dial-small-text whitespace-pre-wrap", children: !d && c ? c : i ?? "Failed to load document." })
|
|
455
468
|
] }) })
|
|
456
469
|
] })
|
|
457
470
|
]
|
|
458
471
|
}
|
|
459
472
|
);
|
|
460
|
-
},
|
|
473
|
+
}, Ee = 1200 * 1e3, Oe = 20, Ae = ({
|
|
461
474
|
children: t,
|
|
462
|
-
ttlMs: a =
|
|
463
|
-
maxEntries: i =
|
|
475
|
+
ttlMs: a = Ee,
|
|
476
|
+
maxEntries: i = Oe
|
|
464
477
|
}) => {
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
}, []), s =
|
|
468
|
-
const
|
|
469
|
-
for (const [
|
|
470
|
-
|
|
471
|
-
}, [a]),
|
|
472
|
-
for (;
|
|
473
|
-
const
|
|
474
|
-
|
|
478
|
+
const o = L(/* @__PURE__ */ new Map()), c = D((u, y) => {
|
|
479
|
+
o.current.delete(u), o.current.set(u, y);
|
|
480
|
+
}, []), s = D(() => {
|
|
481
|
+
const u = Date.now();
|
|
482
|
+
for (const [y, m] of o.current.entries())
|
|
483
|
+
m.file && u - m.timestamp > a && o.current.delete(y);
|
|
484
|
+
}, [a]), v = D(() => {
|
|
485
|
+
for (; o.current.size > i; ) {
|
|
486
|
+
const u = o.current.keys().next().value;
|
|
487
|
+
u && o.current.delete(u);
|
|
475
488
|
}
|
|
476
|
-
}, [i]),
|
|
477
|
-
|
|
478
|
-
}, []),
|
|
479
|
-
async (
|
|
489
|
+
}, [i]), h = D(() => {
|
|
490
|
+
o.current.clear();
|
|
491
|
+
}, []), N = D(
|
|
492
|
+
async (u, y) => {
|
|
480
493
|
s();
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
483
|
-
if (u
|
|
484
|
-
return
|
|
485
|
-
if (
|
|
486
|
-
return
|
|
494
|
+
const m = o.current.get(u);
|
|
495
|
+
if (m) {
|
|
496
|
+
if (c(u, { ...m, timestamp: Date.now() }), m.file)
|
|
497
|
+
return m.file;
|
|
498
|
+
if (m.promise)
|
|
499
|
+
return m.promise;
|
|
487
500
|
}
|
|
488
|
-
const
|
|
489
|
-
const
|
|
490
|
-
return u
|
|
491
|
-
}).catch((
|
|
492
|
-
throw
|
|
501
|
+
const n = Date.now(), p = y().then((g) => {
|
|
502
|
+
const _ = { file: g, timestamp: Date.now() };
|
|
503
|
+
return c(u, _), v(), g;
|
|
504
|
+
}).catch((g) => {
|
|
505
|
+
throw o.current.delete(u), g;
|
|
493
506
|
});
|
|
494
|
-
return u
|
|
507
|
+
return c(u, { promise: p, timestamp: n }), v(), p;
|
|
495
508
|
},
|
|
496
|
-
[
|
|
509
|
+
[v, s, c]
|
|
497
510
|
);
|
|
498
|
-
return
|
|
499
|
-
},
|
|
511
|
+
return w(() => () => h(), [h]), /* @__PURE__ */ e(ae.Provider, { value: { getFile: N, clearCache: h }, children: t });
|
|
512
|
+
}, Me = ({
|
|
500
513
|
pageNum: t,
|
|
501
514
|
onSelectPage: a,
|
|
502
515
|
isSelected: i,
|
|
503
|
-
isLoading:
|
|
504
|
-
isMultiselect:
|
|
516
|
+
isLoading: o,
|
|
517
|
+
isMultiselect: c,
|
|
505
518
|
thumbnailUrl: s,
|
|
506
|
-
className:
|
|
507
|
-
}) => /* @__PURE__ */
|
|
519
|
+
className: v
|
|
520
|
+
}) => /* @__PURE__ */ x(
|
|
508
521
|
"button",
|
|
509
522
|
{
|
|
510
523
|
type: "button",
|
|
511
524
|
"aria-label": `Page ${t}`,
|
|
512
525
|
"aria-pressed": i,
|
|
513
|
-
onClick: (
|
|
514
|
-
|
|
526
|
+
onClick: (h) => {
|
|
527
|
+
c && h.target.closest("[data-checkbox-wrapper]") || a(t);
|
|
515
528
|
},
|
|
516
|
-
className:
|
|
529
|
+
className: Z(
|
|
517
530
|
"flex flex-col gap-2 p-2 h-[186px] w-[120px] items-center justify-center cursor-pointer transition-colors hover:bg-layer-4 rounded-sm",
|
|
518
|
-
i && (
|
|
519
|
-
|
|
531
|
+
i && (c ? "border border-accent-primary bg-accent-primary-alpha" : "border border-primary"),
|
|
532
|
+
v
|
|
520
533
|
),
|
|
521
534
|
children: [
|
|
522
|
-
/* @__PURE__ */
|
|
535
|
+
/* @__PURE__ */ x("div", { className: "relative w-[104px] h-[146px] bg-model-icon rounded-sm overflow-hidden", children: [
|
|
523
536
|
s ? /* @__PURE__ */ e(
|
|
524
537
|
"img",
|
|
525
538
|
{
|
|
@@ -528,8 +541,8 @@ const ee = X.map((t) => ({
|
|
|
528
541
|
className: "w-full h-full object-cover rounded-sm"
|
|
529
542
|
}
|
|
530
543
|
) : null,
|
|
531
|
-
|
|
532
|
-
|
|
544
|
+
c && /* @__PURE__ */ e("div", { className: "absolute left-1 top-1 z-10", "data-checkbox-wrapper": !0, children: /* @__PURE__ */ e(
|
|
545
|
+
ue,
|
|
533
546
|
{
|
|
534
547
|
id: `page-thumbnail-${t}`,
|
|
535
548
|
checked: i,
|
|
@@ -537,8 +550,8 @@ const ee = X.map((t) => ({
|
|
|
537
550
|
className: "before:border-primary before:bg-model-icon bg-model-icon"
|
|
538
551
|
}
|
|
539
552
|
) }),
|
|
540
|
-
|
|
541
|
-
|
|
553
|
+
o && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-blackout rounded-sm", children: /* @__PURE__ */ e(
|
|
554
|
+
me,
|
|
542
555
|
{
|
|
543
556
|
size: 24,
|
|
544
557
|
fullWidth: !1,
|
|
@@ -551,18 +564,19 @@ const ee = X.map((t) => ({
|
|
|
551
564
|
}
|
|
552
565
|
);
|
|
553
566
|
export {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
567
|
+
U as AUTO_ZOOM_ID,
|
|
568
|
+
ke as DocumentPreview,
|
|
569
|
+
Ae as DocumentPreviewCacheProvider,
|
|
557
570
|
G as FIT_ZOOM_ID,
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
571
|
+
Ce as PDFViewer,
|
|
572
|
+
Me as PageThumbnail,
|
|
573
|
+
Pe as PdfPreviewLoader,
|
|
574
|
+
Be as RotationDirection,
|
|
575
|
+
ee as THUMBNAIL_BATCH_SIZE,
|
|
576
|
+
ye as THUMBNAIL_IMAGE_OPTIONS,
|
|
563
577
|
X as ZOOM_OPTIONS,
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
578
|
+
Ie as getStepZoomOptionValue,
|
|
579
|
+
te as isPdfFile,
|
|
580
|
+
_e as useDocumentPreview,
|
|
581
|
+
Te as useDocumentPreviewCache
|
|
568
582
|
};
|
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.visible{visibility:visible}.static{position:static}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.left-1{left:.25rem}.top-1{top:.25rem}.z-10{z-index:10}.z-20{z-index:20}.mx-auto{margin-left:auto;margin-right:auto}.inline-block{display:inline-block}.flex{display:flex}.hidden{display:none}.h-4{height:1rem}.h-6{height:1.5rem}.h-\[146px\]{height:146px}.h-\[186px\]{height:186px}.h-\[600px\]{height:600px}.h-\[700px\]{height:700px}.h-full{height:100%}.max-h-full{max-height:100%}.min-h-0{min-height:0}.min-h-6{min-height:1.5rem}.min-h-\[26px\]{min-height:26px}.w-\[104px\]{width:104px}.w-\[120px\]{width:120px}.w-\[208px\]{width:208px}.w-\[28\%\]{width:28%}.w-\[500px\]{width:500px}.w-\[58\%\]{width:58%}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.min-w-0{min-width:0}.min-w-3{min-width:.75rem}.max-w-\[320px\]{max-width:320px}.max-w-\[40\%\]{max-width:40%}.max-w-\[520px\]{max-width:520px}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.grow{flex-grow:1}@keyframes skeleton-wave{0%{background-position:200% 0}to{background-position:-200% 0}}.animate-skeleton-wave{animation:skeleton-wave 3.5s ease-in-out infinite}.cursor-pointer{cursor:pointer}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-10{gap:2.5rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.self-center{align-self:center}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.whitespace-pre-wrap{white-space:pre-wrap}.rounded{border-radius:4px}.rounded-\[120px\]{border-radius:120px}.rounded-sm{border-radius:.125rem}.border{border-width:1px}.border-accent-primary{border-color:var(--stroke-accent-primary,#7da4ff)}.border-primary{border-color:var(--stroke-primary,#696e7c)}.border-transparent{border-color:transparent}.bg-accent-primary-alpha{background-color:var(--bg-accent-primary-alpha,#7da4ff26)}.bg-blackout{background-color:var(--bg-blackout,#0c101db3)}.bg-layer-1{background-color:var(--bg-layer-1,#0c101d)}.bg-layer-2{background-color:var(--bg-layer-2,#161b2d)}.bg-layer-3{background-color:var(--bg-layer-3,#1d2439)}.bg-layer-4{background-color:var(--bg-layer-4,#242c42)}.bg-model-icon{background-color:var(--bg-model-icon,#fff)}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-layer-4{--tw-gradient-from:var(--bg-layer-4,#242c42) var(--tw-gradient-from-position);--tw-gradient-to:hsla(0,0%,100%,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.via-layer-3{--tw-gradient-to:hsla(0,0%,100%,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--bg-layer-3,#1d2439) var(--tw-gradient-via-position),var(--tw-gradient-to)}.to-layer-4{--tw-gradient-to:var(--bg-layer-4,#242c42) var(--tw-gradient-to-position)}.bg-\[length\:200\%_100\%\]{background-size:200% 100%}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-10{padding:2.5rem}.p-2{padding:.5rem}.p-4{padding:1rem}.\!py-0{padding-top:0!important;padding-bottom:0!important}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-\[60px\]{padding-left:60px;padding-right:60px}.py-0{padding-top:0;padding-bottom:0}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.pl-0\.5{padding-left:.125rem}.pt-10{padding-top:2.5rem}.text-center{text-align:center}.text-right{text-align:right}.text-xs{font-size:.75rem;line-height:1rem}.text-primary{color:var(--text-primary,#eef1f7)}.text-secondary{color:var(--text-secondary,#9fa6bd)}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.before\:border-primary:before{content:var(--tw-content);border-color:var(--stroke-primary,#696e7c)}.before\:bg-model-icon:before{content:var(--tw-content);background-color:var(--bg-model-icon,#fff)}.hover\:border-hover:hover{border-color:var(--stroke-hover,#eef1f7)}.hover\:bg-layer-4:hover{background-color:var(--bg-layer-4,#242c42)}
|
|
1
|
+
*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.visible{visibility:visible}.static{position:static}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.left-1{left:.25rem}.top-1{top:.25rem}.z-10{z-index:10}.z-20{z-index:20}.mx-auto{margin-left:auto;margin-right:auto}.inline-block{display:inline-block}.flex{display:flex}.table{display:table}.hidden{display:none}.h-4{height:1rem}.h-6{height:1.5rem}.h-\[146px\]{height:146px}.h-\[186px\]{height:186px}.h-\[600px\]{height:600px}.h-\[700px\]{height:700px}.h-full{height:100%}.max-h-full{max-height:100%}.min-h-0{min-height:0}.min-h-6{min-height:1.5rem}.min-h-\[26px\]{min-height:26px}.w-64{width:16rem}.w-\[104px\]{width:104px}.w-\[120px\]{width:120px}.w-\[208px\]{width:208px}.w-\[28\%\]{width:28%}.w-\[500px\]{width:500px}.w-\[58\%\]{width:58%}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.min-w-0{min-width:0}.min-w-3{min-width:.75rem}.max-w-\[320px\]{max-width:320px}.max-w-\[40\%\]{max-width:40%}.max-w-\[520px\]{max-width:520px}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.grow{flex-grow:1}@keyframes skeleton-wave{0%{background-position:200% 0}to{background-position:-200% 0}}.animate-skeleton-wave{animation:skeleton-wave 3.5s ease-in-out infinite}.cursor-pointer{cursor:pointer}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.\!justify-start{justify-content:flex-start!important}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-10{gap:2.5rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.self-center{align-self:center}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.whitespace-pre-wrap{white-space:pre-wrap}.rounded{border-radius:4px}.rounded-\[120px\]{border-radius:120px}.rounded-sm{border-radius:.125rem}.border{border-width:1px}.border-r{border-right-width:1px}.border-accent-primary{border-color:var(--stroke-accent-primary,#7da4ff)}.border-primary{border-color:var(--stroke-primary,#696e7c)}.border-transparent{border-color:transparent}.bg-accent-primary-alpha{background-color:var(--bg-accent-primary-alpha,#7da4ff26)}.bg-blackout{background-color:var(--bg-blackout,#0c101db3)}.bg-layer-1{background-color:var(--bg-layer-1,#0c101d)}.bg-layer-2{background-color:var(--bg-layer-2,#161b2d)}.bg-layer-3{background-color:var(--bg-layer-3,#1d2439)}.bg-layer-4{background-color:var(--bg-layer-4,#242c42)}.bg-model-icon{background-color:var(--bg-model-icon,#fff)}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-layer-4{--tw-gradient-from:var(--bg-layer-4,#242c42) var(--tw-gradient-from-position);--tw-gradient-to:hsla(0,0%,100%,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.via-layer-3{--tw-gradient-to:hsla(0,0%,100%,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--bg-layer-3,#1d2439) var(--tw-gradient-via-position),var(--tw-gradient-to)}.to-layer-4{--tw-gradient-to:var(--bg-layer-4,#242c42) var(--tw-gradient-to-position)}.bg-\[length\:200\%_100\%\]{background-size:200% 100%}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-10{padding:2.5rem}.p-2{padding:.5rem}.p-4{padding:1rem}.\!py-0{padding-top:0!important;padding-bottom:0!important}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-\[60px\]{padding-left:60px;padding-right:60px}.py-0{padding-top:0;padding-bottom:0}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.pl-0\.5{padding-left:.125rem}.pt-10{padding-top:2.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.text-xs{font-size:.75rem;line-height:1rem}.uppercase{text-transform:uppercase}.tracking-wide{letter-spacing:.025em}.text-accent-primary{color:var(--text-accent-primary,#7da4ff)}.text-primary{color:var(--text-primary,#eef1f7)}.text-secondary{color:var(--text-secondary,#9fa6bd)}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.before\:border-primary:before{content:var(--tw-content);border-color:var(--stroke-primary,#696e7c)}.before\:bg-model-icon:before{content:var(--tw-content);background-color:var(--bg-model-icon,#fff)}.hover\:border-hover:hover{border-color:var(--stroke-hover,#eef1f7)}.hover\:bg-layer-4:hover{background-color:var(--bg-layer-4,#242c42)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InputHighlightData } from '@epam/pdf-highlighter-kit';
|
|
1
|
+
import { InputHighlightData, ViewerOptions } from '@epam/pdf-highlighter-kit';
|
|
2
2
|
import { FC, ReactNode } from 'react';
|
|
3
3
|
import { PdfViewerApi } from '../../models/pdf-viewer.models';
|
|
4
4
|
/**
|
|
@@ -47,6 +47,18 @@ export interface DocumentPreviewProps {
|
|
|
47
47
|
showLoaderOverlay?: boolean;
|
|
48
48
|
/** Restricts viewer loading to selected pages only. */
|
|
49
49
|
selectedPages?: number[];
|
|
50
|
+
/**
|
|
51
|
+
* Highlight id to navigate to. When `showOccurrences` is true the internal
|
|
52
|
+
* occurrence counter takes precedence; pass this when `showOccurrences` is
|
|
53
|
+
* false to drive navigation externally (e.g. from a results table).
|
|
54
|
+
*/
|
|
55
|
+
selectedHighlightId?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Override or extend low-level viewer initialization options passed to `PDFViewer`.
|
|
58
|
+
* Values are merged on top of the defaults (`enableTextSelection: true`,
|
|
59
|
+
* `enableVirtualScrolling: true`, `bboxOrigin: 'top-left'`).
|
|
60
|
+
*/
|
|
61
|
+
viewerOptions?: ViewerOptions;
|
|
50
62
|
}
|
|
51
63
|
/**
|
|
52
64
|
* High-level PDF preview component with toolbar, highlight navigation, zoom controls,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PDFSource, InputHighlightData } from '@epam/pdf-highlighter-kit';
|
|
1
|
+
import { PDFSource, ViewerOptions, InputHighlightData } from '@epam/pdf-highlighter-kit';
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
import { PdfViewerApi } from '../../models/pdf-viewer.models';
|
|
4
4
|
/**
|
|
@@ -25,6 +25,12 @@ export interface PdfViewerProps {
|
|
|
25
25
|
onViewerReady?: (api: PdfViewerApi) => void;
|
|
26
26
|
/** Optional list of pages to load instead of the full document. */
|
|
27
27
|
selectedPages?: number[];
|
|
28
|
+
/**
|
|
29
|
+
* Override or extend low-level viewer initialization options.
|
|
30
|
+
* Values are merged on top of the defaults (`enableTextSelection: true`,
|
|
31
|
+
* `enableVirtualScrolling: true`, `bboxOrigin: 'top-left'`).
|
|
32
|
+
*/
|
|
33
|
+
viewerOptions?: ViewerOptions;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
30
36
|
* Low-level PDF viewer wrapper around `PDFHighlightViewer`.
|
package/dist/src/index.d.ts
CHANGED
|
@@ -12,5 +12,8 @@ export { PageThumbnail } from './components/PageThumbnail/PageThumbnail';
|
|
|
12
12
|
export type { PageThumbnailProps } from './components/PageThumbnail/PageThumbnail';
|
|
13
13
|
export type { PdfViewerApi } from './models/pdf-viewer.models';
|
|
14
14
|
export type { ZoomOption } from './models/pdf-viewer.models';
|
|
15
|
+
export type { ViewerOptions } from '@epam/pdf-highlighter-kit';
|
|
16
|
+
export { RotationDirection } from '@epam/pdf-highlighter-kit';
|
|
17
|
+
export type { PageRotationDegrees } from '@epam/pdf-highlighter-kit';
|
|
15
18
|
export { AUTO_ZOOM_ID, FIT_ZOOM_ID, THUMBNAIL_BATCH_SIZE, THUMBNAIL_IMAGE_OPTIONS, ZOOM_OPTIONS, } from './constants/pdf-viewer.constants';
|
|
16
19
|
export { getStepZoomOptionValue, isPdfFile } from './utils/pdf-viewer.utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThumbnailOptions } from '@epam/pdf-highlighter-kit';
|
|
1
|
+
import { PageRotationDegrees, RotationDirection, ThumbnailOptions } from '@epam/pdf-highlighter-kit';
|
|
2
2
|
/**
|
|
3
3
|
* Imperative API exposed by {@link PDFViewer} through the `onViewerReady` callback.
|
|
4
4
|
*/
|
|
@@ -18,6 +18,10 @@ export interface PdfViewerApi {
|
|
|
18
18
|
getZoom: () => number;
|
|
19
19
|
/** Navigates to a specific 1-based page number. */
|
|
20
20
|
navigateToPage: (page: number) => void;
|
|
21
|
+
/** Sets extra clockwise display rotation for a 1-based page (on top of PDF `/Rotate`). */
|
|
22
|
+
setPageDisplayRotation: (pageNumber: number, degrees: PageRotationDegrees, direction?: RotationDirection) => void;
|
|
23
|
+
/** Returns extra clockwise display rotation for a 1-based page. */
|
|
24
|
+
getPageDisplayRotation: (pageNumber: number) => PageRotationDegrees;
|
|
21
25
|
}
|
|
22
26
|
export interface ZoomOption {
|
|
23
27
|
value: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-react-pdf-highlighter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "React components for PDF viewing and highlighting, built on @epam/pdf-highlighter-kit",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"build-storybook": "concurrently \"npm run build-storybook:css\" \"storybook build\"",
|
|
49
49
|
"build-storybook:css": "tailwindcss -m -i ./src/styles/tailwind-entry.scss -o ./src/index.css",
|
|
50
50
|
"prepare": "husky",
|
|
51
|
-
"publish": "node tools/publish-lib.mjs",
|
|
51
|
+
"publish:npm": "node tools/publish-lib.mjs",
|
|
52
52
|
"publish:dry": "node tools/publish-lib.mjs --dry",
|
|
53
53
|
"test": "vitest --coverage"
|
|
54
54
|
},
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@epam/ai-dial-ui-kit": ">=0.
|
|
62
|
-
"@epam/pdf-highlighter-kit": ">=0.0.
|
|
63
|
-
"@tabler/icons-react": "^3.
|
|
61
|
+
"@epam/ai-dial-ui-kit": ">=0.13.0-0",
|
|
62
|
+
"@epam/pdf-highlighter-kit": ">=0.0.18",
|
|
63
|
+
"@tabler/icons-react": "^3.44.0",
|
|
64
64
|
"pdfjs-dist": ">=4.0.0",
|
|
65
65
|
"react": ">=18",
|
|
66
66
|
"react-dom": ">=18"
|
|
@@ -73,21 +73,24 @@
|
|
|
73
73
|
"overrides": {
|
|
74
74
|
"minimatch": ">=3.1.4",
|
|
75
75
|
"picomatch": ">=2.3.2",
|
|
76
|
-
"tar": ">=7.5.11"
|
|
76
|
+
"tar": ">=7.5.11",
|
|
77
|
+
"@eslint/eslintrc": {
|
|
78
|
+
"minimatch": "5.1.6"
|
|
79
|
+
}
|
|
77
80
|
},
|
|
78
81
|
"devDependencies": {
|
|
79
|
-
"@chromatic-com/storybook": "^
|
|
80
|
-
"@epam/ai-dial-ui-kit": "0.
|
|
81
|
-
"@epam/pdf-highlighter-kit": "^0.0.
|
|
82
|
+
"@chromatic-com/storybook": "^5.2.1",
|
|
83
|
+
"@epam/ai-dial-ui-kit": "0.12.0-dev.4",
|
|
84
|
+
"@epam/pdf-highlighter-kit": "^0.0.18",
|
|
82
85
|
"@eslint/compat": "^1.3.1",
|
|
83
86
|
"@eslint/eslintrc": "^3.3.1",
|
|
84
87
|
"@eslint/js": "^9.31.0",
|
|
85
88
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
86
|
-
"@storybook/addon-a11y": "^10.
|
|
87
|
-
"@storybook/addon-docs": "^10.
|
|
88
|
-
"@storybook/addon-vitest": "^10.
|
|
89
|
-
"@storybook/react-vite": "^10.
|
|
90
|
-
"@tabler/icons-react": "^3.
|
|
89
|
+
"@storybook/addon-a11y": "^10.4.6",
|
|
90
|
+
"@storybook/addon-docs": "^10.4.6",
|
|
91
|
+
"@storybook/addon-vitest": "^10.4.6",
|
|
92
|
+
"@storybook/react-vite": "^10.4.6",
|
|
93
|
+
"@tabler/icons-react": "^3.44.0",
|
|
91
94
|
"@testing-library/dom": "^10.4.0",
|
|
92
95
|
"@testing-library/react": "^16.3.0",
|
|
93
96
|
"@types/node": "^22.15.30",
|
|
@@ -104,7 +107,7 @@
|
|
|
104
107
|
"eslint-plugin-react": "7.37.5",
|
|
105
108
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
106
109
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
107
|
-
"eslint-plugin-storybook": "^10.
|
|
110
|
+
"eslint-plugin-storybook": "^10.4.6",
|
|
108
111
|
"globals": "^16.3.0",
|
|
109
112
|
"husky": "^9.1.7",
|
|
110
113
|
"jsdom": "^26.1.0",
|
|
@@ -114,7 +117,7 @@
|
|
|
114
117
|
"postcss-import": "^16.1.1",
|
|
115
118
|
"prettier": "3.6.2",
|
|
116
119
|
"sass": "^1.89.2",
|
|
117
|
-
"storybook": "^10.
|
|
120
|
+
"storybook": "^10.4.6",
|
|
118
121
|
"tailwindcss": "^3.4.17",
|
|
119
122
|
"typescript": "~5.9.3",
|
|
120
123
|
"typescript-eslint": "^8.48.0",
|