@epam/ai-dial-react-pdf-highlighter 0.1.2 → 0.2.0-dev.1
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 +305 -297
- 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 +1 -0
- package/package.json +1 -1
|
@@ -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(i.DialEllipsisTooltip,{className:"dial-tiny-text text-secondary !flex-none",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"),i=require("@epam/ai-dial-ui-kit"),U=require("@epam/pdf-highlighter-kit"),t=require("react"),z=require("@tabler/icons-react"),k="auto",F="page-fit",L=[{value:k,label:"Auto"},{value:F,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%"}],W={maxWidth:104,format:"image/jpeg",quality:.85},$=15,le="application/pdf",oe=".pdf",X=({pdf:s,highlights:a,selectedHighlightId:u,autoFocusFirstHighlight:l=!1,selectedPageNumber:m,zoom:c,containerClassName:b,onTotalPagesChange:p,onViewerReady:N,selectedPages:d,viewerOptions:w})=>{const f=t.useRef(null),n=t.useRef(null),[x,T]=t.useState(!1),[g,P]=t.useState(!1),O=t.useRef(p),I=t.useRef(N),S=t.useRef(w);t.useEffect(()=>{O.current=p},[p]),t.useEffect(()=>{I.current=N},[N]),t.useEffect(()=>{S.current=w},[w]);const j=t.useCallback(r=>n.current?.goToHighlight(r),[]);return t.useEffect(()=>{if(!f.current)return;T(!1),P(!1),n.current&&(n.current.destroy(),n.current=null);let r=null,h=!0;const v=()=>{h&&P(!0)};return(async()=>{try{if(r=new U.PDFHighlightViewer,await r.init(f.current,{enableTextSelection:!0,enableVirtualScrolling:!0,bboxOrigin:"top-left",...S.current}),!h){r.destroy();return}if(r.addEventListener("zoomChanged",v),await r.loadPDF(s,{selectedPages:d}),!h){r.destroy();return}const C=r.getTotalPages?.();typeof C=="number"&&C>0&&O.current?.(C),h&&(n.current=r,T(!0))}catch(C){if(!h)return;console.error("Error in initViewer:",C)}})(),()=>{h=!1,r&&(r.removeEventListener("zoomChanged",v),r.destroy())}},[s,d]),t.useEffect(()=>{!x||!n.current||(n.current.loadHighlights(a),l&&a&&a[0]&&j(a[0].id))},[l,j,a,x]),t.useEffect(()=>{x&&g&&u&&j(u)},[j,x,g,u]),t.useEffect(()=>{if(!(!x||!c))if(c===k)n.current?.setZoom?.(U.ZoomMode.AUTO);else if(c===F)n.current?.setZoom?.(U.ZoomMode.PAGE_FIT);else{const r=parseFloat(c);!Number.isNaN(r)&&r>0&&n.current?.setZoom?.(r)}},[x,c]),t.useEffect(()=>{x&&m&&n.current?.setPage?.(m)},[x,m]),t.useEffect(()=>{if(!x||!n.current)return;const r=n.current;I.current?.({getThumbnailsDataUrl:(h,v)=>r.getThumbnailsDataUrl(h,v),zoomIn:()=>r.zoomIn(),zoomOut:()=>r.zoomOut(),getZoom:()=>r.getZoom(),navigateToPage:h=>r.setPage?.(h)})},[x]),e.jsx("div",{ref:f,className:i.mergeClasses("grow min-w-0 overflow-auto bg-layer-3",b)})},E="h-4 rounded-[120px] bg-gradient-to-r from-layer-4 via-layer-3 to-layer-4 bg-[length:200%_100%] animate-skeleton-wave",Y=({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:E}),e.jsx("div",{className:E}),e.jsx("div",{className:E}),e.jsx("div",{className:E}),e.jsx("div",{className:i.mergeClasses(E,"w-[28%] max-w-[320px]")})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:E}),e.jsx("div",{className:E}),e.jsx("div",{className:E}),e.jsx("div",{className:E}),e.jsx("div",{className:i.mergeClasses(E,"w-[58%] max-w-[520px]")})]})]})}),J=t.createContext(null),Q=()=>t.useContext(J),D=L.filter(({value:s})=>{const a=Number.parseFloat(s);return!Number.isNaN(a)&&a>0}),ce=[...D].reverse(),ee=(s,a,u)=>{if(D.length===0)return s;const l=Number.parseFloat(s),m=!Number.isNaN(l)&&l>0?l:u,c=typeof m=="number"&&m>0?m:Number.parseFloat(D[0].value);return a===1?(D.find(({value:b})=>Number.parseFloat(b)>c)??D[D.length-1]).value:(ce.find(({value:b})=>Number.parseFloat(b)<c)??D[0]).value};function te(s,a){const u=(s??"").toLowerCase();return(a??"").toLowerCase()===le||u.endsWith(oe)}const K=L.map(s=>({value:s.value,label:s.label})),se=({fileUrl:s,fileName:a,loadFileCb:u,highlights:l,selectedPageNumber:m,onTotalPagesChange:c,thumbnailPageNumbers:b,onThumbnailsLoaded:p,onViewerReady:N,showLoaderOverlay:d=!1,selectedPages:w})=>{const f=Q(),n=t.useRef(null),[x,T]=t.useState(!1),[g,P]=t.useState(0),[O,I]=t.useState(!1),[S,j]=t.useState(null),[r,h]=t.useState(null),[v,_]=t.useState(k),C=t.useMemo(()=>{let o=a||s;if(!a)try{o=new URL(s).pathname}catch{o=s.split("?")[0].split("#")[0]}return te(o.toLowerCase())},[a,s]),V=t.useCallback(o=>{P((g+o+l.length)%l.length)},[g,l.length]),B=t.useCallback(o=>{const y=n.current;!y?.getZoom||!o||_(ee(v,o,y.getZoom()))},[v]),M=t.useMemo(()=>{if(!(v===k||v===F||L.some(y=>y.value===v))){const y=parseFloat(v);if(!Number.isNaN(y)&&y>0)return[...K,{value:v,label:`${Math.round(y*100)}%`}]}return K},[v]);t.useEffect(()=>{let o=!1;if(j(!0),I(!1),h(null),T(!1),n.current=null,!C){I(!0),j(!1);return}return(async()=>{try{const Z=await(f?f.getFile(s,()=>u(s)):u(s));o||h(Z)}catch{o||(I(!0),h(null))}finally{o||j(!1)}})(),()=>{o=!0}},[s,f,u,C]);const R=t.useCallback(o=>{n.current=o,T(!0),N?.(o)},[N]);return t.useEffect(()=>{const o=b??[],y=n.current?.getThumbnailsDataUrl;if(!o.length||!y||!r||!p||!x)return;let Z=!1;return(async()=>{const G=new Map;for(let A=0;A<o.length&&!Z;A+=$){const re=o.slice(A,A+$);try{const H=await y(re,W);if(Z)break;H.forEach((ae,ne)=>G.set(ne,ae)),p(new Map(G))}catch(H){console.warn("Thumbnail batch load failed:",H);break}}})(),()=>{Z=!0}},[b,r,p,x]),{file:r,isLoading:S,isError:O,isSupportedFile:C,activeHighlightIndex:g,zoom:v,setZoom:_,zoomSelectOptions:M,viewerApiRef:n,showLoader:!O&&(!!S||d),changeIndex:V,handleZoomChange:B,handleViewerReady:R}},ie=({fileUrl:s,fileName:a,errorLabel:u,occurrencesLabel:l,unsupportedLabel:m,highlights:c,loadFileCb:b,showOccurrences:p=!0,selectedPageNumber:N,containerClassName:d,pdfViewerClassName:w,onTotalPagesChange:f,title:n,thumbnailPageNumbers:x,onThumbnailsLoaded:T,onViewerReady:g,showLoaderOverlay:P=!1,selectedPages:O,selectedHighlightId:I,viewerOptions:S})=>{const{file:j,isError:r,isSupportedFile:h,activeHighlightIndex:v,zoom:_,setZoom:C,zoomSelectOptions:V,showLoader:B,changeIndex:M,handleZoomChange:R,handleViewerReady:q}=se({fileUrl:s,fileName:a,loadFileCb:b,highlights:c,selectedPageNumber:N,onTotalPagesChange:f,thumbnailPageNumbers:x,onThumbnailsLoaded:T,onViewerReady:g,showLoaderOverlay:P,selectedPages:O});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",d),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",p&&n?"gap-2":""),children:[e.jsx("div",{children:p?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:c.length>0?`${v+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",n!=null&&n!==""?"justify-between":"justify-end"),children:[n!=null&&n!==""&&e.jsx(i.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(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:V,value:_,onChange:o=>C(o)})}),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:()=>R(-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:()=>R(1)})]})]})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[j&&e.jsx(X,{pdf:j,highlights:c,selectedHighlightId:p?c[v]?.id:I,selectedPageNumber:N,zoom:_,onTotalPagesChange:f,onViewerReady:q,containerClassName:w,selectedPages:O,viewerOptions:S}),B&&e.jsx(Y,{className:"absolute inset-0 z-10"}),r&&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:!h&&m?m:u??"Failed to load document."})]})})]})]})},ue=1200*1e3,me=20,de=({children:s,ttlMs:a=ue,maxEntries:u=me})=>{const l=t.useRef(new Map),m=t.useCallback((d,w)=>{l.current.delete(d),l.current.set(d,w)},[]),c=t.useCallback(()=>{const d=Date.now();for(const[w,f]of l.current.entries())f.file&&d-f.timestamp>a&&l.current.delete(w)},[a]),b=t.useCallback(()=>{for(;l.current.size>u;){const d=l.current.keys().next().value;d&&l.current.delete(d)}},[u]),p=t.useCallback(()=>{l.current.clear()},[]),N=t.useCallback(async(d,w)=>{c();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(),x=w().then(g=>{const P={file:g,timestamp:Date.now()};return m(d,P),b(),g}).catch(g=>{throw l.current.delete(d),g});return m(d,{promise:x,timestamp:n}),b(),x},[b,c,m]);return t.useEffect(()=>()=>p(),[p]),e.jsx(J.Provider,{value:{getFile:N,clearCache:p},children:s})},fe=({pageNum:s,onSelectPage:a,isSelected:u,isLoading:l,isMultiselect:m,thumbnailUrl:c,className:b})=>e.jsxs("button",{type:"button","aria-label":`Page ${s}`,"aria-pressed":u,onClick:p=>{m&&p.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",u&&(m?"border border-accent-primary bg-accent-primary-alpha":"border border-primary"),b),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,m&&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:u,onChange:()=>a(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(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=k;exports.DocumentPreview=ie;exports.DocumentPreviewCacheProvider=de;exports.FIT_ZOOM_ID=F;exports.PDFViewer=X;exports.PageThumbnail=fe;exports.PdfPreviewLoader=Y;exports.THUMBNAIL_BATCH_SIZE=$;exports.THUMBNAIL_IMAGE_OPTIONS=W;exports.ZOOM_OPTIONS=L;exports.getStepZoomOptionValue=ee;exports.isPdfFile=te;exports.useDocumentPreview=se;exports.useDocumentPreviewCache=Q;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { mergeClasses as
|
|
3
|
-
import { ZoomMode as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { IconChevronDown as
|
|
6
|
-
const
|
|
7
|
-
{ value:
|
|
1
|
+
import { jsx as e, jsxs as b, Fragment as oe } from "react/jsx-runtime";
|
|
2
|
+
import { mergeClasses as Z, DialEllipsisTooltip as Y, DialButton as j, ElementSize as B, DialSelect as se, SelectSize as ce, DialCheckbox as ie, DialLoader as ue } from "@epam/ai-dial-ui-kit";
|
|
3
|
+
import { ZoomMode as J, PDFHighlightViewer as me } from "@epam/pdf-highlighter-kit";
|
|
4
|
+
import { useRef as k, useState as E, useEffect as g, useCallback as P, createContext as de, useContext as fe, useMemo as Q } from "react";
|
|
5
|
+
import { IconChevronDown as pe, IconChevronUp as ve, IconMinus as he, IconPlus as be, IconAlertTriangle as xe } from "@tabler/icons-react";
|
|
6
|
+
const $ = "auto", G = "page-fit", X = [
|
|
7
|
+
{ value: $, label: "Auto" },
|
|
8
8
|
{ value: G, label: "Page Fit" },
|
|
9
9
|
{ value: "0.5", label: "50%" },
|
|
10
10
|
{ value: "0.75", label: "75%" },
|
|
@@ -13,99 +13,104 @@ const H = "auto", G = "page-fit", X = [
|
|
|
13
13
|
{ value: "1.5", label: "150%" },
|
|
14
14
|
{ value: "2", label: "200%" },
|
|
15
15
|
{ value: "3", label: "300%" }
|
|
16
|
-
],
|
|
16
|
+
], ye = {
|
|
17
17
|
maxWidth: 104,
|
|
18
18
|
format: "image/jpeg",
|
|
19
19
|
quality: 0.85
|
|
20
|
-
},
|
|
20
|
+
}, ee = 15, we = "application/pdf", ge = ".pdf", Ne = ({
|
|
21
21
|
pdf: t,
|
|
22
22
|
highlights: a,
|
|
23
|
-
selectedHighlightId:
|
|
24
|
-
autoFocusFirstHighlight:
|
|
25
|
-
selectedPageNumber:
|
|
23
|
+
selectedHighlightId: c,
|
|
24
|
+
autoFocusFirstHighlight: l = !1,
|
|
25
|
+
selectedPageNumber: i,
|
|
26
26
|
zoom: s,
|
|
27
|
-
containerClassName:
|
|
28
|
-
onTotalPagesChange:
|
|
29
|
-
onViewerReady:
|
|
30
|
-
selectedPages:
|
|
27
|
+
containerClassName: v,
|
|
28
|
+
onTotalPagesChange: f,
|
|
29
|
+
onViewerReady: N,
|
|
30
|
+
selectedPages: u,
|
|
31
|
+
viewerOptions: y
|
|
31
32
|
}) => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, [
|
|
36
|
-
|
|
37
|
-
}, [
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
const m = k(null), n = k(null), [d, _] = E(!1), [x, O] = E(!1), z = k(f), D = k(N), S = k(y);
|
|
34
|
+
g(() => {
|
|
35
|
+
z.current = f;
|
|
36
|
+
}, [f]), g(() => {
|
|
37
|
+
D.current = N;
|
|
38
|
+
}, [N]), g(() => {
|
|
39
|
+
S.current = y;
|
|
40
|
+
}, [y]);
|
|
41
|
+
const C = P(
|
|
42
|
+
(r) => n.current?.goToHighlight(r),
|
|
40
43
|
[]
|
|
41
44
|
);
|
|
42
|
-
return
|
|
43
|
-
if (!
|
|
44
|
-
|
|
45
|
-
let
|
|
45
|
+
return g(() => {
|
|
46
|
+
if (!m.current) return;
|
|
47
|
+
_(!1), O(!1), n.current && (n.current.destroy(), n.current = null);
|
|
48
|
+
let r = null, h = !0;
|
|
49
|
+
const p = () => {
|
|
50
|
+
h && O(!0);
|
|
51
|
+
};
|
|
46
52
|
return (async () => {
|
|
47
53
|
try {
|
|
48
|
-
if (
|
|
54
|
+
if (r = new me(), await r.init(m.current, {
|
|
49
55
|
enableTextSelection: !0,
|
|
50
56
|
enableVirtualScrolling: !0,
|
|
51
|
-
bboxOrigin: "top-left"
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
bboxOrigin: "top-left",
|
|
58
|
+
...S.current
|
|
59
|
+
}), !h) {
|
|
60
|
+
r.destroy();
|
|
54
61
|
return;
|
|
55
62
|
}
|
|
56
|
-
if (await
|
|
57
|
-
|
|
63
|
+
if (r.addEventListener("zoomChanged", p), await r.loadPDF(t, { selectedPages: u }), !h) {
|
|
64
|
+
r.destroy();
|
|
58
65
|
return;
|
|
59
66
|
}
|
|
60
|
-
const
|
|
61
|
-
typeof
|
|
62
|
-
} catch (
|
|
63
|
-
if (!
|
|
67
|
+
const T = r.getTotalPages?.();
|
|
68
|
+
typeof T == "number" && T > 0 && z.current?.(T), h && (n.current = r, _(!0));
|
|
69
|
+
} catch (T) {
|
|
70
|
+
if (!h)
|
|
64
71
|
return;
|
|
65
|
-
console.error("Error in initViewer:",
|
|
72
|
+
console.error("Error in initViewer:", T);
|
|
66
73
|
}
|
|
67
74
|
})(), () => {
|
|
68
|
-
|
|
75
|
+
h = !1, r && (r.removeEventListener("zoomChanged", p), r.destroy());
|
|
69
76
|
};
|
|
70
|
-
}, [t,
|
|
71
|
-
!
|
|
72
|
-
}, [
|
|
73
|
-
|
|
74
|
-
}, [
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (s === H)
|
|
79
|
-
r.current?.setZoom?.(Y.AUTO);
|
|
77
|
+
}, [t, u]), g(() => {
|
|
78
|
+
!d || !n.current || (n.current.loadHighlights(a), l && a && a[0] && C(a[0].id));
|
|
79
|
+
}, [l, C, a, d]), g(() => {
|
|
80
|
+
d && x && c && C(c);
|
|
81
|
+
}, [C, d, x, c]), g(() => {
|
|
82
|
+
if (!(!d || !s))
|
|
83
|
+
if (s === $)
|
|
84
|
+
n.current?.setZoom?.(J.AUTO);
|
|
80
85
|
else if (s === G)
|
|
81
|
-
|
|
86
|
+
n.current?.setZoom?.(J.PAGE_FIT);
|
|
82
87
|
else {
|
|
83
|
-
const
|
|
84
|
-
!Number.isNaN(
|
|
88
|
+
const r = parseFloat(s);
|
|
89
|
+
!Number.isNaN(r) && r > 0 && n.current?.setZoom?.(r);
|
|
85
90
|
}
|
|
86
|
-
}, [
|
|
87
|
-
|
|
88
|
-
}, [
|
|
89
|
-
if (!
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
getThumbnailsDataUrl: (
|
|
93
|
-
zoomIn: () =>
|
|
94
|
-
zoomOut: () =>
|
|
95
|
-
getZoom: () =>
|
|
96
|
-
navigateToPage: (
|
|
91
|
+
}, [d, s]), g(() => {
|
|
92
|
+
d && i && n.current?.setPage?.(i);
|
|
93
|
+
}, [d, i]), g(() => {
|
|
94
|
+
if (!d || !n.current) return;
|
|
95
|
+
const r = n.current;
|
|
96
|
+
D.current?.({
|
|
97
|
+
getThumbnailsDataUrl: (h, p) => r.getThumbnailsDataUrl(h, p),
|
|
98
|
+
zoomIn: () => r.zoomIn(),
|
|
99
|
+
zoomOut: () => r.zoomOut(),
|
|
100
|
+
getZoom: () => r.getZoom(),
|
|
101
|
+
navigateToPage: (h) => r.setPage?.(h)
|
|
97
102
|
});
|
|
98
|
-
}, [
|
|
103
|
+
}, [d]), /* @__PURE__ */ e(
|
|
99
104
|
"div",
|
|
100
105
|
{
|
|
101
|
-
ref:
|
|
102
|
-
className:
|
|
106
|
+
ref: m,
|
|
107
|
+
className: Z(
|
|
103
108
|
"grow min-w-0 overflow-auto bg-layer-3",
|
|
104
|
-
|
|
109
|
+
v
|
|
105
110
|
)
|
|
106
111
|
}
|
|
107
112
|
);
|
|
108
|
-
},
|
|
113
|
+
}, I = "h-4 rounded-[120px] bg-gradient-to-r from-layer-4 via-layer-3 to-layer-4 bg-[length:200%_100%] animate-skeleton-wave", Ce = ({
|
|
109
114
|
className: t,
|
|
110
115
|
ariaLabel: a = "pdf preview loading"
|
|
111
116
|
}) => /* @__PURE__ */ e(
|
|
@@ -114,34 +119,34 @@ const H = "auto", G = "page-fit", X = [
|
|
|
114
119
|
role: "status",
|
|
115
120
|
"aria-label": a,
|
|
116
121
|
"aria-live": "polite",
|
|
117
|
-
className:
|
|
118
|
-
children: /* @__PURE__ */
|
|
122
|
+
className: Z("h-full w-full bg-layer-3", t),
|
|
123
|
+
children: /* @__PURE__ */ b("div", { className: "flex h-full w-full flex-col gap-10 px-[60px] pt-10", children: [
|
|
119
124
|
/* @__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:
|
|
125
|
+
/* @__PURE__ */ b("div", { className: "flex flex-col gap-4", children: [
|
|
126
|
+
/* @__PURE__ */ e("div", { className: I }),
|
|
127
|
+
/* @__PURE__ */ e("div", { className: I }),
|
|
128
|
+
/* @__PURE__ */ e("div", { className: I }),
|
|
129
|
+
/* @__PURE__ */ e("div", { className: I }),
|
|
125
130
|
/* @__PURE__ */ e(
|
|
126
131
|
"div",
|
|
127
132
|
{
|
|
128
|
-
className:
|
|
129
|
-
|
|
133
|
+
className: Z(
|
|
134
|
+
I,
|
|
130
135
|
"w-[28%] max-w-[320px]"
|
|
131
136
|
)
|
|
132
137
|
}
|
|
133
138
|
)
|
|
134
139
|
] }),
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */ e("div", { className:
|
|
137
|
-
/* @__PURE__ */ e("div", { className:
|
|
138
|
-
/* @__PURE__ */ e("div", { className:
|
|
139
|
-
/* @__PURE__ */ e("div", { className:
|
|
140
|
+
/* @__PURE__ */ b("div", { className: "flex flex-col gap-4", children: [
|
|
141
|
+
/* @__PURE__ */ e("div", { className: I }),
|
|
142
|
+
/* @__PURE__ */ e("div", { className: I }),
|
|
143
|
+
/* @__PURE__ */ e("div", { className: I }),
|
|
144
|
+
/* @__PURE__ */ e("div", { className: I }),
|
|
140
145
|
/* @__PURE__ */ e(
|
|
141
146
|
"div",
|
|
142
147
|
{
|
|
143
|
-
className:
|
|
144
|
-
|
|
148
|
+
className: Z(
|
|
149
|
+
I,
|
|
145
150
|
"w-[58%] max-w-[520px]"
|
|
146
151
|
)
|
|
147
152
|
}
|
|
@@ -149,214 +154,216 @@ const H = "auto", G = "page-fit", X = [
|
|
|
149
154
|
] })
|
|
150
155
|
] })
|
|
151
156
|
}
|
|
152
|
-
),
|
|
157
|
+
), re = de(null), Te = () => fe(re), F = X.filter(({ value: t }) => {
|
|
153
158
|
const a = Number.parseFloat(t);
|
|
154
159
|
return !Number.isNaN(a) && a > 0;
|
|
155
|
-
}),
|
|
156
|
-
if (
|
|
160
|
+
}), Ie = [...F].reverse(), Pe = (t, a, c) => {
|
|
161
|
+
if (F.length === 0)
|
|
157
162
|
return t;
|
|
158
|
-
const
|
|
159
|
-
return a === 1 ? (
|
|
160
|
-
({ value:
|
|
161
|
-
) ??
|
|
162
|
-
({ value:
|
|
163
|
-
) ??
|
|
163
|
+
const l = Number.parseFloat(t), i = !Number.isNaN(l) && l > 0 ? l : c, s = typeof i == "number" && i > 0 ? i : Number.parseFloat(F[0].value);
|
|
164
|
+
return a === 1 ? (F.find(
|
|
165
|
+
({ value: v }) => Number.parseFloat(v) > s
|
|
166
|
+
) ?? F[F.length - 1]).value : (Ie.find(
|
|
167
|
+
({ value: v }) => Number.parseFloat(v) < s
|
|
168
|
+
) ?? F[0]).value;
|
|
164
169
|
};
|
|
165
|
-
function
|
|
166
|
-
const
|
|
167
|
-
return (a ?? "").toLowerCase() ===
|
|
170
|
+
function _e(t, a) {
|
|
171
|
+
const c = (t ?? "").toLowerCase();
|
|
172
|
+
return (a ?? "").toLowerCase() === we || c.endsWith(ge);
|
|
168
173
|
}
|
|
169
|
-
const
|
|
174
|
+
const te = X.map((t) => ({
|
|
170
175
|
value: t.value,
|
|
171
176
|
label: t.label
|
|
172
177
|
})), Oe = ({
|
|
173
178
|
fileUrl: t,
|
|
174
179
|
fileName: a,
|
|
175
|
-
loadFileCb:
|
|
176
|
-
highlights:
|
|
177
|
-
selectedPageNumber:
|
|
180
|
+
loadFileCb: c,
|
|
181
|
+
highlights: l,
|
|
182
|
+
selectedPageNumber: i,
|
|
178
183
|
onTotalPagesChange: s,
|
|
179
|
-
thumbnailPageNumbers:
|
|
180
|
-
onThumbnailsLoaded:
|
|
181
|
-
onViewerReady:
|
|
182
|
-
showLoaderOverlay:
|
|
183
|
-
selectedPages:
|
|
184
|
+
thumbnailPageNumbers: v,
|
|
185
|
+
onThumbnailsLoaded: f,
|
|
186
|
+
onViewerReady: N,
|
|
187
|
+
showLoaderOverlay: u = !1,
|
|
188
|
+
selectedPages: y
|
|
184
189
|
}) => {
|
|
185
|
-
const
|
|
186
|
-
let
|
|
190
|
+
const m = Te(), n = k(null), [d, _] = E(!1), [x, O] = E(0), [z, D] = E(!1), [S, C] = E(null), [r, h] = E(null), [p, L] = E($), T = Q(() => {
|
|
191
|
+
let o = a || t;
|
|
187
192
|
if (!a)
|
|
188
193
|
try {
|
|
189
|
-
|
|
194
|
+
o = new URL(t).pathname;
|
|
190
195
|
} catch {
|
|
191
|
-
|
|
196
|
+
o = t.split("?")[0].split("#")[0];
|
|
192
197
|
}
|
|
193
|
-
return
|
|
194
|
-
}, [a, t]),
|
|
195
|
-
(
|
|
196
|
-
|
|
197
|
-
(
|
|
198
|
+
return _e(o.toLowerCase());
|
|
199
|
+
}, [a, t]), H = P(
|
|
200
|
+
(o) => {
|
|
201
|
+
O(
|
|
202
|
+
(x + o + l.length) % l.length
|
|
198
203
|
);
|
|
199
204
|
},
|
|
200
|
-
[
|
|
201
|
-
),
|
|
202
|
-
(
|
|
203
|
-
const
|
|
204
|
-
!
|
|
205
|
+
[x, l.length]
|
|
206
|
+
), U = P(
|
|
207
|
+
(o) => {
|
|
208
|
+
const w = n.current;
|
|
209
|
+
!w?.getZoom || !o || L(Pe(p, o, w.getZoom()));
|
|
205
210
|
},
|
|
206
|
-
[
|
|
207
|
-
),
|
|
208
|
-
if (!(
|
|
209
|
-
const
|
|
210
|
-
if (!Number.isNaN(
|
|
211
|
+
[p]
|
|
212
|
+
), M = Q(() => {
|
|
213
|
+
if (!(p === $ || p === G || X.some((w) => w.value === p))) {
|
|
214
|
+
const w = parseFloat(p);
|
|
215
|
+
if (!Number.isNaN(w) && w > 0)
|
|
211
216
|
return [
|
|
212
|
-
...
|
|
213
|
-
{ value:
|
|
217
|
+
...te,
|
|
218
|
+
{ value: p, label: `${Math.round(w * 100)}%` }
|
|
214
219
|
];
|
|
215
220
|
}
|
|
216
|
-
return
|
|
217
|
-
}, [
|
|
218
|
-
|
|
219
|
-
let
|
|
220
|
-
if (
|
|
221
|
-
|
|
221
|
+
return te;
|
|
222
|
+
}, [p]);
|
|
223
|
+
g(() => {
|
|
224
|
+
let o = !1;
|
|
225
|
+
if (C(!0), D(!1), h(null), _(!1), n.current = null, !T) {
|
|
226
|
+
D(!0), C(!1);
|
|
222
227
|
return;
|
|
223
228
|
}
|
|
224
229
|
return (async () => {
|
|
225
230
|
try {
|
|
226
|
-
const
|
|
227
|
-
|
|
231
|
+
const A = await (m ? m.getFile(t, () => c(t)) : c(t));
|
|
232
|
+
o || h(A);
|
|
228
233
|
} catch {
|
|
229
|
-
|
|
234
|
+
o || (D(!0), h(null));
|
|
230
235
|
} finally {
|
|
231
|
-
|
|
236
|
+
o || C(!1);
|
|
232
237
|
}
|
|
233
238
|
})(), () => {
|
|
234
|
-
|
|
239
|
+
o = !0;
|
|
235
240
|
};
|
|
236
|
-
}, [t,
|
|
237
|
-
const
|
|
238
|
-
(
|
|
239
|
-
|
|
241
|
+
}, [t, m, c, T]);
|
|
242
|
+
const R = P(
|
|
243
|
+
(o) => {
|
|
244
|
+
n.current = o, _(!0), N?.(o);
|
|
240
245
|
},
|
|
241
|
-
[
|
|
246
|
+
[N]
|
|
242
247
|
);
|
|
243
|
-
return
|
|
244
|
-
const
|
|
245
|
-
if (!
|
|
248
|
+
return g(() => {
|
|
249
|
+
const o = v ?? [], w = n.current?.getThumbnailsDataUrl;
|
|
250
|
+
if (!o.length || !w || !r || !f || !d)
|
|
246
251
|
return;
|
|
247
|
-
let
|
|
252
|
+
let A = !1;
|
|
248
253
|
return (async () => {
|
|
249
|
-
const
|
|
250
|
-
for (let V = 0; V <
|
|
251
|
-
const
|
|
254
|
+
const K = /* @__PURE__ */ new Map();
|
|
255
|
+
for (let V = 0; V < o.length && !A; V += ee) {
|
|
256
|
+
const ae = o.slice(V, V + ee);
|
|
252
257
|
try {
|
|
253
|
-
const W = await
|
|
254
|
-
if (
|
|
255
|
-
W.forEach((
|
|
258
|
+
const W = await w(ae, ye);
|
|
259
|
+
if (A) break;
|
|
260
|
+
W.forEach((ne, le) => K.set(le, ne)), f(new Map(K));
|
|
256
261
|
} catch (W) {
|
|
257
262
|
console.warn("Thumbnail batch load failed:", W);
|
|
258
263
|
break;
|
|
259
264
|
}
|
|
260
265
|
}
|
|
261
266
|
})(), () => {
|
|
262
|
-
|
|
267
|
+
A = !0;
|
|
263
268
|
};
|
|
264
|
-
}, [
|
|
265
|
-
file:
|
|
266
|
-
isLoading:
|
|
269
|
+
}, [v, r, f, d]), {
|
|
270
|
+
file: r,
|
|
271
|
+
isLoading: S,
|
|
267
272
|
isError: z,
|
|
268
|
-
isSupportedFile:
|
|
269
|
-
activeHighlightIndex:
|
|
270
|
-
zoom:
|
|
271
|
-
setZoom:
|
|
272
|
-
zoomSelectOptions:
|
|
273
|
-
viewerApiRef:
|
|
274
|
-
showLoader: !z && (!!
|
|
275
|
-
changeIndex:
|
|
276
|
-
handleZoomChange:
|
|
277
|
-
handleViewerReady:
|
|
273
|
+
isSupportedFile: T,
|
|
274
|
+
activeHighlightIndex: x,
|
|
275
|
+
zoom: p,
|
|
276
|
+
setZoom: L,
|
|
277
|
+
zoomSelectOptions: M,
|
|
278
|
+
viewerApiRef: n,
|
|
279
|
+
showLoader: !z && (!!S || u),
|
|
280
|
+
changeIndex: H,
|
|
281
|
+
handleZoomChange: U,
|
|
282
|
+
handleViewerReady: R
|
|
278
283
|
};
|
|
279
284
|
}, Ae = ({
|
|
280
285
|
fileUrl: t,
|
|
281
286
|
fileName: a,
|
|
282
|
-
errorLabel:
|
|
283
|
-
occurrencesLabel:
|
|
284
|
-
unsupportedLabel:
|
|
287
|
+
errorLabel: c,
|
|
288
|
+
occurrencesLabel: l,
|
|
289
|
+
unsupportedLabel: i,
|
|
285
290
|
highlights: s,
|
|
286
|
-
loadFileCb:
|
|
287
|
-
showOccurrences:
|
|
288
|
-
selectedPageNumber:
|
|
289
|
-
containerClassName:
|
|
290
|
-
pdfViewerClassName:
|
|
291
|
-
onTotalPagesChange:
|
|
292
|
-
title:
|
|
293
|
-
thumbnailPageNumbers:
|
|
291
|
+
loadFileCb: v,
|
|
292
|
+
showOccurrences: f = !0,
|
|
293
|
+
selectedPageNumber: N,
|
|
294
|
+
containerClassName: u,
|
|
295
|
+
pdfViewerClassName: y,
|
|
296
|
+
onTotalPagesChange: m,
|
|
297
|
+
title: n,
|
|
298
|
+
thumbnailPageNumbers: d,
|
|
294
299
|
onThumbnailsLoaded: _,
|
|
295
|
-
onViewerReady:
|
|
296
|
-
showLoaderOverlay:
|
|
297
|
-
selectedPages: z
|
|
300
|
+
onViewerReady: x,
|
|
301
|
+
showLoaderOverlay: O = !1,
|
|
302
|
+
selectedPages: z,
|
|
303
|
+
selectedHighlightId: D,
|
|
304
|
+
viewerOptions: S
|
|
298
305
|
}) => {
|
|
299
306
|
const {
|
|
300
|
-
file:
|
|
301
|
-
isError:
|
|
302
|
-
isSupportedFile:
|
|
303
|
-
activeHighlightIndex:
|
|
304
|
-
zoom:
|
|
305
|
-
setZoom:
|
|
306
|
-
zoomSelectOptions:
|
|
307
|
-
showLoader:
|
|
307
|
+
file: C,
|
|
308
|
+
isError: r,
|
|
309
|
+
isSupportedFile: h,
|
|
310
|
+
activeHighlightIndex: p,
|
|
311
|
+
zoom: L,
|
|
312
|
+
setZoom: T,
|
|
313
|
+
zoomSelectOptions: H,
|
|
314
|
+
showLoader: U,
|
|
308
315
|
changeIndex: M,
|
|
309
316
|
handleZoomChange: R,
|
|
310
|
-
handleViewerReady:
|
|
317
|
+
handleViewerReady: q
|
|
311
318
|
} = Oe({
|
|
312
319
|
fileUrl: t,
|
|
313
320
|
fileName: a,
|
|
314
|
-
loadFileCb:
|
|
321
|
+
loadFileCb: v,
|
|
315
322
|
highlights: s,
|
|
316
|
-
selectedPageNumber:
|
|
317
|
-
onTotalPagesChange:
|
|
318
|
-
thumbnailPageNumbers:
|
|
323
|
+
selectedPageNumber: N,
|
|
324
|
+
onTotalPagesChange: m,
|
|
325
|
+
thumbnailPageNumbers: d,
|
|
319
326
|
onThumbnailsLoaded: _,
|
|
320
|
-
onViewerReady:
|
|
321
|
-
showLoaderOverlay:
|
|
327
|
+
onViewerReady: x,
|
|
328
|
+
showLoaderOverlay: O,
|
|
322
329
|
selectedPages: z
|
|
323
330
|
});
|
|
324
|
-
return /* @__PURE__ */
|
|
331
|
+
return /* @__PURE__ */ b(
|
|
325
332
|
"div",
|
|
326
333
|
{
|
|
327
|
-
className:
|
|
334
|
+
className: Z(
|
|
328
335
|
"flex flex-col self-center gap-4 py-3 px-6 h-full w-full bg-layer-2",
|
|
329
|
-
|
|
336
|
+
u
|
|
330
337
|
),
|
|
331
338
|
children: [
|
|
332
|
-
a && /* @__PURE__ */ e(
|
|
333
|
-
|
|
339
|
+
a && /* @__PURE__ */ e("div", { className: "shrink-0 min-h-0 w-full", children: /* @__PURE__ */ e(
|
|
340
|
+
Y,
|
|
334
341
|
{
|
|
335
|
-
className: "dial-tiny-text text-secondary
|
|
342
|
+
className: "dial-tiny-text text-secondary",
|
|
336
343
|
text: a
|
|
337
344
|
}
|
|
338
|
-
),
|
|
339
|
-
/* @__PURE__ */
|
|
345
|
+
) }),
|
|
346
|
+
/* @__PURE__ */ b(
|
|
340
347
|
"div",
|
|
341
348
|
{
|
|
342
|
-
className:
|
|
349
|
+
className: Z(
|
|
343
350
|
"flex w-full justify-between items-center",
|
|
344
|
-
|
|
351
|
+
f && n ? "gap-2" : ""
|
|
345
352
|
),
|
|
346
353
|
children: [
|
|
347
|
-
/* @__PURE__ */ e("div", { children:
|
|
348
|
-
/* @__PURE__ */
|
|
349
|
-
|
|
354
|
+
/* @__PURE__ */ e("div", { children: f ? /* @__PURE__ */ b("div", { className: "flex gap-1 py-0.5 px-1.5 min-h-[26px] items-center bg-layer-4 rounded w-fit", children: [
|
|
355
|
+
/* @__PURE__ */ b("span", { className: "dial-small-text", children: [
|
|
356
|
+
l ?? "Occurrences",
|
|
350
357
|
":",
|
|
351
|
-
/* @__PURE__ */ e("span", { className: "pl-0.5 min-w-3 inline-block text-right", children: s.length > 0 ? `${
|
|
358
|
+
/* @__PURE__ */ e("span", { className: "pl-0.5 min-w-3 inline-block text-right", children: s.length > 0 ? `${p + 1}/${s.length}` : "0" })
|
|
352
359
|
] }),
|
|
353
|
-
s.length > 0 && /* @__PURE__ */
|
|
360
|
+
s.length > 0 && /* @__PURE__ */ b(oe, { children: [
|
|
354
361
|
/* @__PURE__ */ e(
|
|
355
362
|
j,
|
|
356
363
|
{
|
|
357
364
|
className: "p-0 text-primary !h-6.5",
|
|
358
365
|
size: B.Small,
|
|
359
|
-
iconAfter: /* @__PURE__ */ e(
|
|
366
|
+
iconAfter: /* @__PURE__ */ e(pe, { size: 16 }),
|
|
360
367
|
"aria-label": "Next occurrence",
|
|
361
368
|
onClick: () => M(1)
|
|
362
369
|
}
|
|
@@ -366,44 +373,44 @@ const ee = X.map((t) => ({
|
|
|
366
373
|
{
|
|
367
374
|
className: "p-0 text-primary !h-6.5",
|
|
368
375
|
size: B.Small,
|
|
369
|
-
iconAfter: /* @__PURE__ */ e(
|
|
376
|
+
iconAfter: /* @__PURE__ */ e(ve, { size: 16 }),
|
|
370
377
|
"aria-label": "Previous occurrence",
|
|
371
378
|
onClick: () => M(-1)
|
|
372
379
|
}
|
|
373
380
|
)
|
|
374
381
|
] })
|
|
375
382
|
] }) : /* @__PURE__ */ e("div", {}) }),
|
|
376
|
-
/* @__PURE__ */
|
|
383
|
+
/* @__PURE__ */ b(
|
|
377
384
|
"div",
|
|
378
385
|
{
|
|
379
|
-
className:
|
|
386
|
+
className: Z(
|
|
380
387
|
"flex flex-1 items-center gap-4 min-w-0",
|
|
381
|
-
|
|
388
|
+
n != null && n !== "" ? "justify-between" : "justify-end"
|
|
382
389
|
),
|
|
383
390
|
children: [
|
|
384
|
-
|
|
385
|
-
|
|
391
|
+
n != null && n !== "" && /* @__PURE__ */ e(
|
|
392
|
+
Y,
|
|
386
393
|
{
|
|
387
|
-
text:
|
|
394
|
+
text: n,
|
|
388
395
|
className: "dial-body-semi-text text-primary min-w-0"
|
|
389
396
|
}
|
|
390
397
|
),
|
|
391
|
-
/* @__PURE__ */
|
|
398
|
+
/* @__PURE__ */ b("div", { className: "flex gap-0.5 items-center shrink-0", children: [
|
|
392
399
|
/* @__PURE__ */ e("div", { className: "h-6", children: /* @__PURE__ */ e(
|
|
393
|
-
|
|
400
|
+
se,
|
|
394
401
|
{
|
|
395
|
-
size:
|
|
402
|
+
size: ce.Sm,
|
|
396
403
|
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: (
|
|
404
|
+
options: H,
|
|
405
|
+
value: L,
|
|
406
|
+
onChange: (o) => T(o)
|
|
400
407
|
}
|
|
401
408
|
) }),
|
|
402
409
|
/* @__PURE__ */ e(
|
|
403
410
|
j,
|
|
404
411
|
{
|
|
405
412
|
className: "py-0 flex items-center justify-center rounded text-primary bg-layer-4 border border-transparent hover:border-hover",
|
|
406
|
-
iconAfter: /* @__PURE__ */ e(
|
|
413
|
+
iconAfter: /* @__PURE__ */ e(he, { size: 16 }),
|
|
407
414
|
"aria-label": "Zoom out",
|
|
408
415
|
size: B.Small,
|
|
409
416
|
onClick: () => R(-1)
|
|
@@ -426,100 +433,101 @@ const ee = X.map((t) => ({
|
|
|
426
433
|
]
|
|
427
434
|
}
|
|
428
435
|
),
|
|
429
|
-
/* @__PURE__ */
|
|
430
|
-
|
|
431
|
-
|
|
436
|
+
/* @__PURE__ */ b("div", { className: "relative flex min-h-0 flex-1", children: [
|
|
437
|
+
C && /* @__PURE__ */ e(
|
|
438
|
+
Ne,
|
|
432
439
|
{
|
|
433
|
-
pdf:
|
|
440
|
+
pdf: C,
|
|
434
441
|
highlights: s,
|
|
435
|
-
selectedHighlightId:
|
|
436
|
-
selectedPageNumber:
|
|
437
|
-
zoom:
|
|
438
|
-
onTotalPagesChange:
|
|
439
|
-
onViewerReady:
|
|
440
|
-
containerClassName:
|
|
441
|
-
selectedPages: z
|
|
442
|
+
selectedHighlightId: f ? s[p]?.id : D,
|
|
443
|
+
selectedPageNumber: N,
|
|
444
|
+
zoom: L,
|
|
445
|
+
onTotalPagesChange: m,
|
|
446
|
+
onViewerReady: q,
|
|
447
|
+
containerClassName: y,
|
|
448
|
+
selectedPages: z,
|
|
449
|
+
viewerOptions: S
|
|
442
450
|
}
|
|
443
451
|
),
|
|
444
|
-
|
|
445
|
-
|
|
452
|
+
U && /* @__PURE__ */ e(Ce, { className: "absolute inset-0 z-10" }),
|
|
453
|
+
r && /* @__PURE__ */ e("div", { className: "absolute inset-0 z-20 flex items-center justify-center bg-layer-3", children: /* @__PURE__ */ b("div", { className: "flex flex-col items-center gap-6 p-10", children: [
|
|
446
454
|
/* @__PURE__ */ e(
|
|
447
|
-
|
|
455
|
+
xe,
|
|
448
456
|
{
|
|
449
457
|
size: 60,
|
|
450
458
|
stroke: 2,
|
|
451
459
|
className: "text-secondary"
|
|
452
460
|
}
|
|
453
461
|
),
|
|
454
|
-
/* @__PURE__ */ e("div", { className: "text-center dial-small-text whitespace-pre-wrap", children: !
|
|
462
|
+
/* @__PURE__ */ e("div", { className: "text-center dial-small-text whitespace-pre-wrap", children: !h && i ? i : c ?? "Failed to load document." })
|
|
455
463
|
] }) })
|
|
456
464
|
] })
|
|
457
465
|
]
|
|
458
466
|
}
|
|
459
467
|
);
|
|
460
|
-
},
|
|
468
|
+
}, ze = 1200 * 1e3, De = 20, Me = ({
|
|
461
469
|
children: t,
|
|
462
|
-
ttlMs: a =
|
|
463
|
-
maxEntries:
|
|
470
|
+
ttlMs: a = ze,
|
|
471
|
+
maxEntries: c = De
|
|
464
472
|
}) => {
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
}, []), s =
|
|
468
|
-
const
|
|
469
|
-
for (const [
|
|
470
|
-
|
|
471
|
-
}, [a]),
|
|
472
|
-
for (;
|
|
473
|
-
const
|
|
474
|
-
|
|
473
|
+
const l = k(/* @__PURE__ */ new Map()), i = P((u, y) => {
|
|
474
|
+
l.current.delete(u), l.current.set(u, y);
|
|
475
|
+
}, []), s = P(() => {
|
|
476
|
+
const u = Date.now();
|
|
477
|
+
for (const [y, m] of l.current.entries())
|
|
478
|
+
m.file && u - m.timestamp > a && l.current.delete(y);
|
|
479
|
+
}, [a]), v = P(() => {
|
|
480
|
+
for (; l.current.size > c; ) {
|
|
481
|
+
const u = l.current.keys().next().value;
|
|
482
|
+
u && l.current.delete(u);
|
|
475
483
|
}
|
|
476
|
-
}, [
|
|
477
|
-
|
|
478
|
-
}, []),
|
|
479
|
-
async (
|
|
484
|
+
}, [c]), f = P(() => {
|
|
485
|
+
l.current.clear();
|
|
486
|
+
}, []), N = P(
|
|
487
|
+
async (u, y) => {
|
|
480
488
|
s();
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
483
|
-
if (u
|
|
484
|
-
return
|
|
485
|
-
if (
|
|
486
|
-
return
|
|
489
|
+
const m = l.current.get(u);
|
|
490
|
+
if (m) {
|
|
491
|
+
if (i(u, { ...m, timestamp: Date.now() }), m.file)
|
|
492
|
+
return m.file;
|
|
493
|
+
if (m.promise)
|
|
494
|
+
return m.promise;
|
|
487
495
|
}
|
|
488
|
-
const
|
|
489
|
-
const
|
|
490
|
-
return u
|
|
491
|
-
}).catch((
|
|
492
|
-
throw
|
|
496
|
+
const n = Date.now(), d = y().then((x) => {
|
|
497
|
+
const O = { file: x, timestamp: Date.now() };
|
|
498
|
+
return i(u, O), v(), x;
|
|
499
|
+
}).catch((x) => {
|
|
500
|
+
throw l.current.delete(u), x;
|
|
493
501
|
});
|
|
494
|
-
return u
|
|
502
|
+
return i(u, { promise: d, timestamp: n }), v(), d;
|
|
495
503
|
},
|
|
496
|
-
[
|
|
504
|
+
[v, s, i]
|
|
497
505
|
);
|
|
498
|
-
return
|
|
506
|
+
return g(() => () => f(), [f]), /* @__PURE__ */ e(re.Provider, { value: { getFile: N, clearCache: f }, children: t });
|
|
499
507
|
}, Re = ({
|
|
500
508
|
pageNum: t,
|
|
501
509
|
onSelectPage: a,
|
|
502
|
-
isSelected:
|
|
503
|
-
isLoading:
|
|
504
|
-
isMultiselect:
|
|
510
|
+
isSelected: c,
|
|
511
|
+
isLoading: l,
|
|
512
|
+
isMultiselect: i,
|
|
505
513
|
thumbnailUrl: s,
|
|
506
|
-
className:
|
|
507
|
-
}) => /* @__PURE__ */
|
|
514
|
+
className: v
|
|
515
|
+
}) => /* @__PURE__ */ b(
|
|
508
516
|
"button",
|
|
509
517
|
{
|
|
510
518
|
type: "button",
|
|
511
519
|
"aria-label": `Page ${t}`,
|
|
512
|
-
"aria-pressed":
|
|
513
|
-
onClick: (
|
|
514
|
-
|
|
520
|
+
"aria-pressed": c,
|
|
521
|
+
onClick: (f) => {
|
|
522
|
+
i && f.target.closest("[data-checkbox-wrapper]") || a(t);
|
|
515
523
|
},
|
|
516
|
-
className:
|
|
524
|
+
className: Z(
|
|
517
525
|
"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
|
-
|
|
519
|
-
|
|
526
|
+
c && (i ? "border border-accent-primary bg-accent-primary-alpha" : "border border-primary"),
|
|
527
|
+
v
|
|
520
528
|
),
|
|
521
529
|
children: [
|
|
522
|
-
/* @__PURE__ */
|
|
530
|
+
/* @__PURE__ */ b("div", { className: "relative w-[104px] h-[146px] bg-model-icon rounded-sm overflow-hidden", children: [
|
|
523
531
|
s ? /* @__PURE__ */ e(
|
|
524
532
|
"img",
|
|
525
533
|
{
|
|
@@ -528,17 +536,17 @@ const ee = X.map((t) => ({
|
|
|
528
536
|
className: "w-full h-full object-cover rounded-sm"
|
|
529
537
|
}
|
|
530
538
|
) : null,
|
|
531
|
-
|
|
532
|
-
|
|
539
|
+
i && /* @__PURE__ */ e("div", { className: "absolute left-1 top-1 z-10", "data-checkbox-wrapper": !0, children: /* @__PURE__ */ e(
|
|
540
|
+
ie,
|
|
533
541
|
{
|
|
534
542
|
id: `page-thumbnail-${t}`,
|
|
535
|
-
checked:
|
|
543
|
+
checked: c,
|
|
536
544
|
onChange: () => a(t),
|
|
537
545
|
className: "before:border-primary before:bg-model-icon bg-model-icon"
|
|
538
546
|
}
|
|
539
547
|
) }),
|
|
540
|
-
|
|
541
|
-
|
|
548
|
+
l && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-blackout rounded-sm", children: /* @__PURE__ */ e(
|
|
549
|
+
ue,
|
|
542
550
|
{
|
|
543
551
|
size: 24,
|
|
544
552
|
fullWidth: !1,
|
|
@@ -551,18 +559,18 @@ const ee = X.map((t) => ({
|
|
|
551
559
|
}
|
|
552
560
|
);
|
|
553
561
|
export {
|
|
554
|
-
|
|
562
|
+
$ as AUTO_ZOOM_ID,
|
|
555
563
|
Ae as DocumentPreview,
|
|
556
564
|
Me as DocumentPreviewCacheProvider,
|
|
557
565
|
G as FIT_ZOOM_ID,
|
|
558
|
-
|
|
566
|
+
Ne as PDFViewer,
|
|
559
567
|
Re as PageThumbnail,
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
568
|
+
Ce as PdfPreviewLoader,
|
|
569
|
+
ee as THUMBNAIL_BATCH_SIZE,
|
|
570
|
+
ye as THUMBNAIL_IMAGE_OPTIONS,
|
|
563
571
|
X as ZOOM_OPTIONS,
|
|
564
|
-
|
|
565
|
-
|
|
572
|
+
Pe as getStepZoomOptionValue,
|
|
573
|
+
_e as isPdfFile,
|
|
566
574
|
Oe as useDocumentPreview,
|
|
567
|
-
|
|
575
|
+
Te as useDocumentPreviewCache
|
|
568
576
|
};
|
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}
|
|
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,6 @@ 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';
|
|
15
16
|
export { AUTO_ZOOM_ID, FIT_ZOOM_ID, THUMBNAIL_BATCH_SIZE, THUMBNAIL_IMAGE_OPTIONS, ZOOM_OPTIONS, } from './constants/pdf-viewer.constants';
|
|
16
17
|
export { getStepZoomOptionValue, isPdfFile } from './utils/pdf-viewer.utils';
|
package/package.json
CHANGED