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