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