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