@cyber-harbour/ui 3.0.0-next-gen.55 → 3.0.0-next-gen.57
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/PdfDriver-HHUZBFHA.mjs +2 -0
- package/dist/{PdfDriver-P5ADXPSY.mjs.map → PdfDriver-HHUZBFHA.mjs.map} +1 -1
- package/dist/PdfDriver-Q3PWPXQQ.js +2 -0
- package/dist/{PdfDriver-TMPVSYW4.js.map → PdfDriver-Q3PWPXQQ.js.map} +1 -1
- package/dist/chunk-47XRQ3QA.mjs +2 -0
- package/dist/chunk-47XRQ3QA.mjs.map +1 -0
- package/dist/chunk-AUAUMCWH.js +2 -0
- package/dist/chunk-AUAUMCWH.js.map +1 -0
- package/dist/index.d.mts +10 -66
- package/dist/index.d.ts +10 -66
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/styles/design-tokens.css +609 -0
- package/dist/styles/legacy-token-aliases.css +66 -0
- package/dist/styles/tailwind.css +57 -167
- package/package.json +6 -9
- package/dist/PdfDriver-P5ADXPSY.mjs +0 -2
- package/dist/PdfDriver-TMPVSYW4.js +0 -2
- package/dist/chunk-3UCQYQQT.js +0 -2
- package/dist/chunk-3UCQYQQT.js.map +0 -1
- package/dist/chunk-RYHWWDCM.mjs +0 -2
- package/dist/chunk-RYHWWDCM.mjs.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$1,b,e,d as d$1,c}from'./chunk-47XRQ3QA.mjs';import {e as e$1,d,b as b$1,c as c$1,a as a$2}from'./chunk-EKYQRECJ.mjs';import'./chunk-7LHQWEWV.mjs';import {a}from'./chunk-QWPVIX2T.mjs';import {useState,useRef,useCallback,useMemo,useEffect}from'react';import G from'lodash.debounce';import {pdfjs,Document,Page}from'react-pdf';import'react-pdf/dist/Page/AnnotationLayer.css';import'react-pdf/dist/Page/TextLayer.css';import {Virtuoso}from'react-virtuoso';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var f="/pdfjs";typeof window<"u"&&typeof document<"u"&&(pdfjs.GlobalWorkerOptions.workerSrc=`${f}/pdf.worker.min.js`);var ue=1e3,me=400,fe=150,ge=70,pe=1.414,P=400,Le=a(({url:$,filename:I,onDownload:F})=>{let[s,j]=useState(0),[i,h]=useState(1),[z,y]=useState(true),[R,V]=useState(null),[b$2,W]=useState(P),[K,Y]=useState(P),[c$2,E]=useState(1),[v,q]=useState(P),[A,J]=useState(pe),d$2=useRef(null),L=useRef(null),x=useRef(false),u=useRef(null),w=useRef(false),g=useCallback((e,o=true)=>{e<1||e>s||(x.current=true,L.current?.scrollToIndex({index:e-1,align:"start",behavior:o?"smooth":"auto"}),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{w.current&&(x.current=false);},ue));},[s]),C=useMemo(()=>G((e,o=false)=>{g(e,o);},me),[g]),Q=useCallback(()=>{E(e=>Math.min(e+.25,4));},[]),X=useCallback(()=>{E(e=>Math.max(e-.25,.25));},[]);useEffect(()=>{if(!d$2.current)return;let e=G(()=>{d$2.current&&(W(d$2.current.offsetWidth-ge),Y(d$2.current.clientHeight));},fe);e();let o=new ResizeObserver(e);return o.observe(d$2.current),()=>{o.disconnect(),e.cancel();}},[]);let ee=useMemo(()=>({cMapPacked:true,cMapUrl:`${f}/cmaps/`,standardFontDataUrl:`${f}/standard_fonts/`,wasmUrl:`${f}/wasm/`,iccUrl:`${f}/icc/`}),[]),te=useCallback(({numPages:e})=>{j(e),y(false);},[]),oe=useCallback(e=>{V(`Failed to load PDF: ${e.message}`),y(false);},[]),p=useCallback(e=>{let o=i+e;h(o),g(o);},[i,g]),ne=useCallback(()=>{p(-1);},[p]),re=useCallback(()=>{p(1);},[p]),ae=useCallback(e=>{if(x.current)return;let o=e.startIndex+1;o!==i&&h(o);},[i]);return useEffect(()=>(w.current=true,()=>{w.current=false,C.cancel(),u.current&&clearTimeout(u.current);}),[C]),useEffect(()=>{q(b$2*c$2*A);},[b$2,c$2,A]),R?jsx("div",{className:"flex items-center justify-center h-full w-full px-8.5",children:jsx("div",{className:"text-red-500 text-center",children:jsx("p",{children:R})})}):jsxs("div",{className:"relative h-full w-full flex flex-col overflow-hidden bg-background-page",children:[z&&jsx("div",{className:"flex items-center justify-center h-full px-8.5",children:jsx("div",{className:"text-text-secondary",children:"Loading PDF..."})}),jsxs("div",{ref:d$2,className:"relative flex-1 overflow-hidden min-h-0",children:[jsx(Document,{options:ee,file:$,onLoadSuccess:te,onLoadError:oe,loading:jsx("div",{className:"flex items-center justify-center",style:{height:v},children:jsx("div",{className:"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent"})}),children:jsx(Virtuoso,{ref:L,style:{height:K||"calc(100dvh - 120px)",width:"100%",scrollbarGutter:"stable both-edges"},totalCount:s,rangeChanged:ae,defaultItemHeight:v,itemContent:e=>jsx("div",{className:"mx-auto w-fit mb-4 border border-gray-100",children:jsx(Page,{pageNumber:e+1,renderTextLayer:true,renderAnnotationLayer:true,width:b$2*c$2,onLoadSuccess:o=>{if(e===0){let se=o.height/o.width;J(se);}},loading:jsx("div",{className:"flex items-center justify-center",style:{height:v},children:jsx("div",{className:"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent"})}),className:"h-auto w-full transition-[width] duration-[600ms] ease-in-out"})})})}),s>0&&jsxs(a$1,{"aria-label":"PDF controls",children:[jsxs(b,{children:[jsx(e,{"aria-label":"Zoom out",onClick:X,disabled:c$2<=.25,children:jsx(e$1,{width:16,height:16})}),jsxs(e,{"aria-label":"Current zoom",children:[Math.round(c$2*100),"%"]}),jsx(e,{"aria-label":"Zoom in",onClick:Q,disabled:c$2>=4,children:jsx(d,{width:16,height:16})})]}),jsx(d$1,{}),jsxs(c,{children:[jsx(e,{"aria-label":"Previous page",onClick:ne,disabled:i<=1,className:"px-3!",children:jsx(b$1,{width:12,height:12})}),jsxs("span",{className:"font-plex text-sm leading-4 tracking-[0.16px] text-text-body flex items-center",children:[jsx("input",{type:"number",min:1,max:s,value:i,onChange:e=>{let o=parseInt(e.target.value,10);o>=1&&o<=s&&(h(o),C(o,false));},className:"w-8 text-center bg-transparent outline-none font-plex text-sm leading-4 tracking-[0.16px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),jsxs("span",{children:["/",s]})]}),jsx(e,{"aria-label":"Next page",onClick:re,disabled:i>=s,className:"px-3!",children:jsx(c$1,{width:12,height:12})})]}),F&&jsxs(Fragment,{children:[jsx(d$1,{}),jsx(e,{"aria-label":I?`Download ${I}`:"Download",onClick:F,children:jsx(a$2,{width:16,height:16})})]})]})]})]})},"PdfDriver");export{Le as PdfDriver};//# sourceMappingURL=PdfDriver-HHUZBFHA.mjs.map
|
|
2
|
+
//# sourceMappingURL=PdfDriver-HHUZBFHA.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/FileViewer/drivers/PdfDriver/PdfDriver.tsx"],"names":["BASE_DIR","pdfjs","SCROLL_ANIMATION_DURATION","INPUT_DEBOUNCE_DELAY","RESIZE_DEBOUNCE_DELAY","CONTAINER_PADDING","DEFAULT_RATIO_A4","DEFAULT_MIN_SIZE","PdfDriver","__name","url","filename","onDownload","numPages","setNumPages","useState","pageNumber","setPageNumber","loading","setLoading","error","setError","width","setWidth","height","setHeight","scale","setScale","defaultPageHeight","setDefaultPageHeight","pageAspectRatio","setPageAspectRatio","containerRef","useRef","virtuosoRef","isUserScrollingRef","scrollTimeoutRef","isMountedRef","scrollToPage","useCallback","page","smooth","debouncedScroll","useMemo","debounce","handleZoomIn","prev","handleZoomOut","useEffect","updateSize","observer","options","onDocumentLoadSuccess","onDocumentLoadError","changePage","offset","newPage","previousPage","nextPage","handleRangeChanged","range","visiblePage","jsx","jsxs","Document","Virtuoso","index","Page","ratio","FloatingControls","FloatingControlsGroup","FloatingControlsButton","ZoomOutIcon","ZoomInIcon","FloatingControl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A,CAACiB,IAAA,CAAa,KAAA,CAAO,EAAA,CAAI,MAAA,CAAQ,EAAA,CAAI,CAAA,CACvC,GACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAEJ,CAAA,CApRmD,WAAA","file":"PdfDriver-P5ADXPSY.mjs","sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport debounce from 'lodash.debounce';\nimport { Document, Page, pdfjs } from 'react-pdf';\nimport 'react-pdf/dist/Page/AnnotationLayer.css';\nimport 'react-pdf/dist/Page/TextLayer.css';\nimport { Virtuoso, VirtuosoHandle } from 'react-virtuoso';\nimport { DownloadIcon } from '../../../Icons2/DownloadIcon';\nimport { KeyboardArrowLeftIcon } from '../../../Icons2/KeyboardArrowLeftIcon';\nimport { KeyboardArrowRightIcon } from '../../../Icons2/KeyboardArrowRightIcon';\nimport { ZoomInIcon } from '../../../Icons2/ZoomInIcon';\nimport { ZoomOutIcon } from '../../../Icons2/ZoomOutIcon';\nimport {\n FloatingControls,\n FloatingControlsBoxedGroup,\n FloatingControlsButton,\n FloatingControlsDivider,\n FloatingControlsGroup,\n} from '../_shared';\n\nconst BASE_DIR = '/pdfjs';\n\n// Set up the worker - self-hosted configuration (client-side only)\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n pdfjs.GlobalWorkerOptions.workerSrc = `${BASE_DIR}/pdf.worker.min.js`;\n}\n\ninterface PdfDriverProps {\n url: string;\n filename?: string;\n onDownload?: () => void;\n}\nconst SCROLL_ANIMATION_DURATION = 1000;\nconst INPUT_DEBOUNCE_DELAY = 400;\nconst RESIZE_DEBOUNCE_DELAY = 150;\nconst CONTAINER_PADDING = 70;\nconst DEFAULT_RATIO_A4 = 1.414;\nconst DEFAULT_MIN_SIZE = 400;\n\nexport const PdfDriver: React.FC<PdfDriverProps> = ({ url, filename, onDownload }) => {\n const [numPages, setNumPages] = useState<number>(0);\n const [pageNumber, setPageNumber] = useState<number>(1);\n const [loading, setLoading] = useState<boolean>(true);\n const [error, setError] = useState<string | null>(null);\n const [width, setWidth] = useState<number>(DEFAULT_MIN_SIZE);\n const [height, setHeight] = useState<number>(DEFAULT_MIN_SIZE);\n const [scale, setScale] = useState(1);\n const [defaultPageHeight, setDefaultPageHeight] = useState(DEFAULT_MIN_SIZE);\n const [pageAspectRatio, setPageAspectRatio] = useState(DEFAULT_RATIO_A4);\n\n const containerRef = useRef<HTMLDivElement>(null);\n const virtuosoRef = useRef<VirtuosoHandle>(null);\n const isUserScrollingRef = useRef<boolean>(false);\n const scrollTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isMountedRef = useRef(false);\n\n const scrollToPage = useCallback(\n (page: number, smooth = true) => {\n if (page < 1 || page > numPages) return;\n\n isUserScrollingRef.current = true;\n virtuosoRef.current?.scrollToIndex({\n index: page - 1,\n align: 'start',\n behavior: smooth ? 'smooth' : 'auto',\n });\n\n if (scrollTimeoutRef.current) {\n clearTimeout(scrollTimeoutRef.current);\n }\n\n scrollTimeoutRef.current = setTimeout(() => {\n if (isMountedRef.current) isUserScrollingRef.current = false;\n }, SCROLL_ANIMATION_DURATION);\n },\n [numPages]\n );\n\n const debouncedScroll = useMemo(() => {\n return debounce((page: number, smooth = false) => {\n scrollToPage(page, smooth);\n }, INPUT_DEBOUNCE_DELAY);\n }, [scrollToPage]);\n\n const handleZoomIn = useCallback(() => {\n setScale((prev) => Math.min(prev + 0.25, 4));\n }, []);\n\n const handleZoomOut = useCallback(() => {\n setScale((prev) => Math.max(prev - 0.25, 0.25));\n }, []);\n\n useEffect(() => {\n if (!containerRef.current) return;\n const updateSize = debounce(() => {\n if (containerRef.current) {\n setWidth(containerRef.current.offsetWidth - CONTAINER_PADDING);\n setHeight(containerRef.current.clientHeight);\n }\n }, RESIZE_DEBOUNCE_DELAY);\n updateSize();\n const observer = new ResizeObserver(updateSize);\n observer.observe(containerRef.current);\n return () => {\n observer.disconnect();\n updateSize.cancel();\n };\n }, []);\n\n const options = useMemo(\n () => ({\n cMapPacked: true,\n cMapUrl: `${BASE_DIR}/cmaps/`,\n standardFontDataUrl: `${BASE_DIR}/standard_fonts/`,\n wasmUrl: `${BASE_DIR}/wasm/`,\n iccUrl: `${BASE_DIR}/icc/`,\n }),\n []\n );\n\n const onDocumentLoadSuccess = useCallback(({ numPages }: { numPages: number }): void => {\n setNumPages(numPages);\n setLoading(false);\n }, []);\n\n const onDocumentLoadError = useCallback((error: Error): void => {\n setError(`Failed to load PDF: ${error.message}`);\n setLoading(false);\n }, []);\n\n const changePage = useCallback(\n (offset: number): void => {\n const newPage = pageNumber + offset;\n setPageNumber(newPage);\n scrollToPage(newPage);\n },\n [pageNumber, scrollToPage]\n );\n\n const previousPage = useCallback((): void => {\n changePage(-1);\n }, [changePage]);\n\n const nextPage = useCallback((): void => {\n changePage(1);\n }, [changePage]);\n\n const handleRangeChanged = useCallback(\n (range: { startIndex: number; endIndex: number }) => {\n if (isUserScrollingRef.current) {\n return;\n }\n const visiblePage = range.startIndex + 1;\n if (visiblePage !== pageNumber) {\n setPageNumber(visiblePage);\n }\n },\n [pageNumber]\n );\n\n useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n debouncedScroll.cancel();\n if (scrollTimeoutRef.current) {\n clearTimeout(scrollTimeoutRef.current);\n }\n };\n }, [debouncedScroll]);\n\n useEffect(() => {\n setDefaultPageHeight(width * scale * pageAspectRatio);\n }, [width, scale, pageAspectRatio]);\n\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full w-full px-8.5\">\n <div className=\"text-red-500 text-center\">\n <p>{error}</p>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"relative h-full w-full flex flex-col overflow-hidden bg-radar-drawer-bg\">\n {loading && (\n <div className=\"flex items-center justify-center h-full px-8.5\">\n <div className=\"text-radar-text-secondary\">Loading PDF...</div>\n </div>\n )}\n <div ref={containerRef} className=\"relative flex-1 overflow-hidden min-h-0\">\n <Document\n options={options}\n file={url}\n onLoadSuccess={onDocumentLoadSuccess}\n onLoadError={onDocumentLoadError}\n loading={\n <div className=\"flex items-center justify-center\" style={{ height: defaultPageHeight }}>\n <div className=\"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent\" />\n </div>\n }\n >\n <Virtuoso\n ref={virtuosoRef}\n style={{\n height: height || 'calc(100dvh - 120px)',\n width: '100%',\n scrollbarGutter: 'stable both-edges',\n }}\n totalCount={numPages}\n rangeChanged={handleRangeChanged}\n defaultItemHeight={defaultPageHeight}\n itemContent={(index) => (\n <div className=\"mx-auto w-fit mb-4 border border-gray-100\">\n <Page\n pageNumber={index + 1}\n renderTextLayer\n renderAnnotationLayer\n width={width * scale}\n onLoadSuccess={(page) => {\n if (index === 0) {\n const ratio = page.height / page.width;\n setPageAspectRatio(ratio);\n }\n }}\n loading={\n <div className=\"flex items-center justify-center\" style={{ height: defaultPageHeight }}>\n <div className=\"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent\" />\n </div>\n }\n className=\"h-auto w-full transition-[width] duration-[600ms] ease-in-out\"\n />\n </div>\n )}\n />\n </Document>\n\n {numPages > 0 && (\n <FloatingControls aria-label=\"PDF controls\">\n <FloatingControlsGroup>\n <FloatingControlsButton\n aria-label=\"Zoom out\"\n onClick={handleZoomOut}\n disabled={scale <= 0.25}\n >\n <ZoomOutIcon width={16} height={16} />\n </FloatingControlsButton>\n <FloatingControlsButton aria-label=\"Current zoom\">\n {Math.round(scale * 100)}%\n </FloatingControlsButton>\n <FloatingControlsButton\n aria-label=\"Zoom in\"\n onClick={handleZoomIn}\n disabled={scale >= 4}\n >\n <ZoomInIcon width={16} height={16} />\n </FloatingControlsButton>\n </FloatingControlsGroup>\n\n <FloatingControlsDivider />\n\n <FloatingControlsBoxedGroup>\n <FloatingControlsButton\n aria-label=\"Previous page\"\n onClick={previousPage}\n disabled={pageNumber <= 1}\n className=\"px-3!\"\n >\n <KeyboardArrowLeftIcon width={12} height={12} />\n </FloatingControlsButton>\n <span className=\"font-plex text-sm leading-4 tracking-[0.16px] text-radar-text-primary flex items-center\">\n <input\n type=\"number\"\n min={1}\n max={numPages}\n value={pageNumber}\n onChange={(e) => {\n const page = parseInt(e.target.value, 10);\n if (page >= 1 && page <= numPages) {\n setPageNumber(page);\n debouncedScroll(page, false);\n }\n }}\n className=\"w-8 text-center bg-transparent outline-none font-plex text-sm leading-4 tracking-[0.16px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none\"\n />\n <span>/{numPages}</span>\n </span>\n <FloatingControlsButton\n aria-label=\"Next page\"\n onClick={nextPage}\n disabled={pageNumber >= numPages}\n className=\"px-3!\"\n >\n <KeyboardArrowRightIcon width={12} height={12} />\n </FloatingControlsButton>\n </FloatingControlsBoxedGroup>\n\n {onDownload && (\n <>\n <FloatingControlsDivider />\n <FloatingControlsButton\n aria-label={filename ? `Download ${filename}` : 'Download'}\n onClick={onDownload}\n >\n <DownloadIcon width={16} height={16} />\n </FloatingControlsButton>\n </>\n )}\n </FloatingControls>\n )}\n </div>\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/FileViewer/drivers/PdfDriver/PdfDriver.tsx"],"names":["BASE_DIR","pdfjs","SCROLL_ANIMATION_DURATION","INPUT_DEBOUNCE_DELAY","RESIZE_DEBOUNCE_DELAY","CONTAINER_PADDING","DEFAULT_RATIO_A4","DEFAULT_MIN_SIZE","PdfDriver","__name","url","filename","onDownload","numPages","setNumPages","useState","pageNumber","setPageNumber","loading","setLoading","error","setError","width","setWidth","height","setHeight","scale","setScale","defaultPageHeight","setDefaultPageHeight","pageAspectRatio","setPageAspectRatio","containerRef","useRef","virtuosoRef","isUserScrollingRef","scrollTimeoutRef","isMountedRef","scrollToPage","useCallback","page","smooth","debouncedScroll","useMemo","debounce","handleZoomIn","prev","handleZoomOut","useEffect","updateSize","observer","options","onDocumentLoadSuccess","onDocumentLoadError","changePage","offset","newPage","previousPage","nextPage","handleRangeChanged","range","visiblePage","jsx","jsxs","Document","Virtuoso","index","Page","ratio","FloatingControls","FloatingControlsGroup","FloatingControlsButton","ZoomOutIcon","ZoomInIcon","FloatingControlsDivider","FloatingControlsBoxedGroup","KeyboardArrowLeftIcon","KeyboardArrowRightIcon","Fragment","DownloadIcon"],"mappings":"qgBAmBA,IAAMA,CAAAA,CAAW,QAAA,CAGb,OAAO,MAAA,CAAW,GAAA,EAAe,OAAO,QAAA,CAAa,GAAA,GACvDC,KAAAA,CAAM,mBAAA,CAAoB,SAAA,CAAY,CAAA,EAAGD,CAAQ,CAAA,kBAAA,CAAA,CAAA,CAQnD,IAAME,GAA4B,GAAA,CAC5BC,EAAAA,CAAuB,IACvBC,EAAAA,CAAwB,GAAA,CACxBC,EAAAA,CAAoB,EAAA,CACpBC,EAAAA,CAAmB,KAAA,CACnBC,EAAmB,GAAA,CAEZC,EAAAA,CAAsCC,EAAA,CAAC,CAAE,IAAAC,CAAAA,CAAK,QAAA,CAAAC,CAAAA,CAAU,UAAA,CAAAC,CAAW,CAAA,GAAM,CACpF,GAAM,CAACC,EAAUC,CAAW,CAAA,CAAIC,SAAiB,CAAC,CAAA,CAC5C,CAACC,CAAAA,CAAYC,CAAa,CAAA,CAAIF,SAAiB,CAAC,CAAA,CAChD,CAACG,CAAAA,CAASC,CAAU,CAAA,CAAIJ,SAAkB,IAAI,CAAA,CAC9C,CAACK,CAAAA,CAAOC,CAAQ,CAAA,CAAIN,SAAwB,IAAI,CAAA,CAChD,CAACO,GAAAA,CAAOC,CAAQ,EAAIR,QAAAA,CAAiBR,CAAgB,CAAA,CACrD,CAACiB,CAAAA,CAAQC,CAAS,EAAIV,QAAAA,CAAiBR,CAAgB,EACvD,CAACmB,GAAAA,CAAOC,CAAQ,CAAA,CAAIZ,QAAAA,CAAS,CAAC,CAAA,CAC9B,CAACa,CAAAA,CAAmBC,CAAoB,CAAA,CAAId,QAAAA,CAASR,CAAgB,CAAA,CACrE,CAACuB,EAAiBC,CAAkB,CAAA,CAAIh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,CAAA,SAAA,EAAYA,CAAQ,CAAA,CAAA,CAAK,UAAA,CAChD,OAAA,CAASC,CAAAA,CAET,QAAA,CAAAkD,GAAAA,CAACiB,IAAA,CAAa,KAAA,CAAO,EAAA,CAAI,MAAA,CAAQ,EAAA,CAAI,CAAA,CACvC,GACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAEJ,CAAA,CApRmD,WAAA","file":"PdfDriver-HHUZBFHA.mjs","sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport debounce from 'lodash.debounce';\nimport { Document, Page, pdfjs } from 'react-pdf';\nimport 'react-pdf/dist/Page/AnnotationLayer.css';\nimport 'react-pdf/dist/Page/TextLayer.css';\nimport { Virtuoso, VirtuosoHandle } from 'react-virtuoso';\nimport { DownloadIcon } from '../../../Icons2/DownloadIcon';\nimport { KeyboardArrowLeftIcon } from '../../../Icons2/KeyboardArrowLeftIcon';\nimport { KeyboardArrowRightIcon } from '../../../Icons2/KeyboardArrowRightIcon';\nimport { ZoomInIcon } from '../../../Icons2/ZoomInIcon';\nimport { ZoomOutIcon } from '../../../Icons2/ZoomOutIcon';\nimport {\n FloatingControls,\n FloatingControlsBoxedGroup,\n FloatingControlsButton,\n FloatingControlsDivider,\n FloatingControlsGroup,\n} from '../_shared';\n\nconst BASE_DIR = '/pdfjs';\n\n// Set up the worker - self-hosted configuration (client-side only)\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n pdfjs.GlobalWorkerOptions.workerSrc = `${BASE_DIR}/pdf.worker.min.js`;\n}\n\ninterface PdfDriverProps {\n url: string;\n filename?: string;\n onDownload?: () => void;\n}\nconst SCROLL_ANIMATION_DURATION = 1000;\nconst INPUT_DEBOUNCE_DELAY = 400;\nconst RESIZE_DEBOUNCE_DELAY = 150;\nconst CONTAINER_PADDING = 70;\nconst DEFAULT_RATIO_A4 = 1.414;\nconst DEFAULT_MIN_SIZE = 400;\n\nexport const PdfDriver: React.FC<PdfDriverProps> = ({ url, filename, onDownload }) => {\n const [numPages, setNumPages] = useState<number>(0);\n const [pageNumber, setPageNumber] = useState<number>(1);\n const [loading, setLoading] = useState<boolean>(true);\n const [error, setError] = useState<string | null>(null);\n const [width, setWidth] = useState<number>(DEFAULT_MIN_SIZE);\n const [height, setHeight] = useState<number>(DEFAULT_MIN_SIZE);\n const [scale, setScale] = useState(1);\n const [defaultPageHeight, setDefaultPageHeight] = useState(DEFAULT_MIN_SIZE);\n const [pageAspectRatio, setPageAspectRatio] = useState(DEFAULT_RATIO_A4);\n\n const containerRef = useRef<HTMLDivElement>(null);\n const virtuosoRef = useRef<VirtuosoHandle>(null);\n const isUserScrollingRef = useRef<boolean>(false);\n const scrollTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isMountedRef = useRef(false);\n\n const scrollToPage = useCallback(\n (page: number, smooth = true) => {\n if (page < 1 || page > numPages) return;\n\n isUserScrollingRef.current = true;\n virtuosoRef.current?.scrollToIndex({\n index: page - 1,\n align: 'start',\n behavior: smooth ? 'smooth' : 'auto',\n });\n\n if (scrollTimeoutRef.current) {\n clearTimeout(scrollTimeoutRef.current);\n }\n\n scrollTimeoutRef.current = setTimeout(() => {\n if (isMountedRef.current) isUserScrollingRef.current = false;\n }, SCROLL_ANIMATION_DURATION);\n },\n [numPages]\n );\n\n const debouncedScroll = useMemo(() => {\n return debounce((page: number, smooth = false) => {\n scrollToPage(page, smooth);\n }, INPUT_DEBOUNCE_DELAY);\n }, [scrollToPage]);\n\n const handleZoomIn = useCallback(() => {\n setScale((prev) => Math.min(prev + 0.25, 4));\n }, []);\n\n const handleZoomOut = useCallback(() => {\n setScale((prev) => Math.max(prev - 0.25, 0.25));\n }, []);\n\n useEffect(() => {\n if (!containerRef.current) return;\n const updateSize = debounce(() => {\n if (containerRef.current) {\n setWidth(containerRef.current.offsetWidth - CONTAINER_PADDING);\n setHeight(containerRef.current.clientHeight);\n }\n }, RESIZE_DEBOUNCE_DELAY);\n updateSize();\n const observer = new ResizeObserver(updateSize);\n observer.observe(containerRef.current);\n return () => {\n observer.disconnect();\n updateSize.cancel();\n };\n }, []);\n\n const options = useMemo(\n () => ({\n cMapPacked: true,\n cMapUrl: `${BASE_DIR}/cmaps/`,\n standardFontDataUrl: `${BASE_DIR}/standard_fonts/`,\n wasmUrl: `${BASE_DIR}/wasm/`,\n iccUrl: `${BASE_DIR}/icc/`,\n }),\n []\n );\n\n const onDocumentLoadSuccess = useCallback(({ numPages }: { numPages: number }): void => {\n setNumPages(numPages);\n setLoading(false);\n }, []);\n\n const onDocumentLoadError = useCallback((error: Error): void => {\n setError(`Failed to load PDF: ${error.message}`);\n setLoading(false);\n }, []);\n\n const changePage = useCallback(\n (offset: number): void => {\n const newPage = pageNumber + offset;\n setPageNumber(newPage);\n scrollToPage(newPage);\n },\n [pageNumber, scrollToPage]\n );\n\n const previousPage = useCallback((): void => {\n changePage(-1);\n }, [changePage]);\n\n const nextPage = useCallback((): void => {\n changePage(1);\n }, [changePage]);\n\n const handleRangeChanged = useCallback(\n (range: { startIndex: number; endIndex: number }) => {\n if (isUserScrollingRef.current) {\n return;\n }\n const visiblePage = range.startIndex + 1;\n if (visiblePage !== pageNumber) {\n setPageNumber(visiblePage);\n }\n },\n [pageNumber]\n );\n\n useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n debouncedScroll.cancel();\n if (scrollTimeoutRef.current) {\n clearTimeout(scrollTimeoutRef.current);\n }\n };\n }, [debouncedScroll]);\n\n useEffect(() => {\n setDefaultPageHeight(width * scale * pageAspectRatio);\n }, [width, scale, pageAspectRatio]);\n\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full w-full px-8.5\">\n <div className=\"text-red-500 text-center\">\n <p>{error}</p>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"relative h-full w-full flex flex-col overflow-hidden bg-background-page\">\n {loading && (\n <div className=\"flex items-center justify-center h-full px-8.5\">\n <div className=\"text-text-secondary\">Loading PDF...</div>\n </div>\n )}\n <div ref={containerRef} className=\"relative flex-1 overflow-hidden min-h-0\">\n <Document\n options={options}\n file={url}\n onLoadSuccess={onDocumentLoadSuccess}\n onLoadError={onDocumentLoadError}\n loading={\n <div className=\"flex items-center justify-center\" style={{ height: defaultPageHeight }}>\n <div className=\"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent\" />\n </div>\n }\n >\n <Virtuoso\n ref={virtuosoRef}\n style={{\n height: height || 'calc(100dvh - 120px)',\n width: '100%',\n scrollbarGutter: 'stable both-edges',\n }}\n totalCount={numPages}\n rangeChanged={handleRangeChanged}\n defaultItemHeight={defaultPageHeight}\n itemContent={(index) => (\n <div className=\"mx-auto w-fit mb-4 border border-gray-100\">\n <Page\n pageNumber={index + 1}\n renderTextLayer\n renderAnnotationLayer\n width={width * scale}\n onLoadSuccess={(page) => {\n if (index === 0) {\n const ratio = page.height / page.width;\n setPageAspectRatio(ratio);\n }\n }}\n loading={\n <div className=\"flex items-center justify-center\" style={{ height: defaultPageHeight }}>\n <div className=\"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent\" />\n </div>\n }\n className=\"h-auto w-full transition-[width] duration-[600ms] ease-in-out\"\n />\n </div>\n )}\n />\n </Document>\n\n {numPages > 0 && (\n <FloatingControls aria-label=\"PDF controls\">\n <FloatingControlsGroup>\n <FloatingControlsButton\n aria-label=\"Zoom out\"\n onClick={handleZoomOut}\n disabled={scale <= 0.25}\n >\n <ZoomOutIcon width={16} height={16} />\n </FloatingControlsButton>\n <FloatingControlsButton aria-label=\"Current zoom\">\n {Math.round(scale * 100)}%\n </FloatingControlsButton>\n <FloatingControlsButton\n aria-label=\"Zoom in\"\n onClick={handleZoomIn}\n disabled={scale >= 4}\n >\n <ZoomInIcon width={16} height={16} />\n </FloatingControlsButton>\n </FloatingControlsGroup>\n\n <FloatingControlsDivider />\n\n <FloatingControlsBoxedGroup>\n <FloatingControlsButton\n aria-label=\"Previous page\"\n onClick={previousPage}\n disabled={pageNumber <= 1}\n className=\"px-3!\"\n >\n <KeyboardArrowLeftIcon width={12} height={12} />\n </FloatingControlsButton>\n <span className=\"font-plex text-sm leading-4 tracking-[0.16px] text-text-body flex items-center\">\n <input\n type=\"number\"\n min={1}\n max={numPages}\n value={pageNumber}\n onChange={(e) => {\n const page = parseInt(e.target.value, 10);\n if (page >= 1 && page <= numPages) {\n setPageNumber(page);\n debouncedScroll(page, false);\n }\n }}\n className=\"w-8 text-center bg-transparent outline-none font-plex text-sm leading-4 tracking-[0.16px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none\"\n />\n <span>/{numPages}</span>\n </span>\n <FloatingControlsButton\n aria-label=\"Next page\"\n onClick={nextPage}\n disabled={pageNumber >= numPages}\n className=\"px-3!\"\n >\n <KeyboardArrowRightIcon width={12} height={12} />\n </FloatingControlsButton>\n </FloatingControlsBoxedGroup>\n\n {onDownload && (\n <>\n <FloatingControlsDivider />\n <FloatingControlsButton\n aria-label={filename ? `Download ${filename}` : 'Download'}\n onClick={onDownload}\n >\n <DownloadIcon width={16} height={16} />\n </FloatingControlsButton>\n </>\n )}\n </FloatingControls>\n )}\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkAUAUMCWH_js=require('./chunk-AUAUMCWH.js'),chunk6YUK4MG2_js=require('./chunk-6YUK4MG2.js');require('./chunk-NQZUCXJV.js');var chunkAYDF3IFZ_js=require('./chunk-AYDF3IFZ.js'),react=require('react'),G=require('lodash.debounce'),reactPdf=require('react-pdf');require('react-pdf/dist/Page/AnnotationLayer.css'),require('react-pdf/dist/Page/TextLayer.css');var reactVirtuoso=require('react-virtuoso'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var G__default=/*#__PURE__*/_interopDefault(G);var f="/pdfjs";typeof window<"u"&&typeof document<"u"&&(reactPdf.pdfjs.GlobalWorkerOptions.workerSrc=`${f}/pdf.worker.min.js`);var ue=1e3,me=400,fe=150,ge=70,pe=1.414,P=400,Te=chunkAYDF3IFZ_js.a(({url:$,filename:I,onDownload:F})=>{let[s,j]=react.useState(0),[i,h]=react.useState(1),[z,y]=react.useState(true),[R,V]=react.useState(null),[b,W]=react.useState(P),[K,Y]=react.useState(P),[c,E]=react.useState(1),[v,q]=react.useState(P),[A,J]=react.useState(pe),d=react.useRef(null),L=react.useRef(null),x=react.useRef(false),u=react.useRef(null),w=react.useRef(false),g=react.useCallback((e,o=true)=>{e<1||e>s||(x.current=true,L.current?.scrollToIndex({index:e-1,align:"start",behavior:o?"smooth":"auto"}),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{w.current&&(x.current=false);},ue));},[s]),C=react.useMemo(()=>G__default.default((e,o=false)=>{g(e,o);},me),[g]),Q=react.useCallback(()=>{E(e=>Math.min(e+.25,4));},[]),X=react.useCallback(()=>{E(e=>Math.max(e-.25,.25));},[]);react.useEffect(()=>{if(!d.current)return;let e=G__default.default(()=>{d.current&&(W(d.current.offsetWidth-ge),Y(d.current.clientHeight));},fe);e();let o=new ResizeObserver(e);return o.observe(d.current),()=>{o.disconnect(),e.cancel();}},[]);let ee=react.useMemo(()=>({cMapPacked:true,cMapUrl:`${f}/cmaps/`,standardFontDataUrl:`${f}/standard_fonts/`,wasmUrl:`${f}/wasm/`,iccUrl:`${f}/icc/`}),[]),te=react.useCallback(({numPages:e})=>{j(e),y(false);},[]),oe=react.useCallback(e=>{V(`Failed to load PDF: ${e.message}`),y(false);},[]),p=react.useCallback(e=>{let o=i+e;h(o),g(o);},[i,g]),ne=react.useCallback(()=>{p(-1);},[p]),re=react.useCallback(()=>{p(1);},[p]),ae=react.useCallback(e=>{if(x.current)return;let o=e.startIndex+1;o!==i&&h(o);},[i]);return react.useEffect(()=>(w.current=true,()=>{w.current=false,C.cancel(),u.current&&clearTimeout(u.current);}),[C]),react.useEffect(()=>{q(b*c*A);},[b,c,A]),R?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full w-full px-8.5",children:jsxRuntime.jsx("div",{className:"text-red-500 text-center",children:jsxRuntime.jsx("p",{children:R})})}):jsxRuntime.jsxs("div",{className:"relative h-full w-full flex flex-col overflow-hidden bg-background-page",children:[z&&jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full px-8.5",children:jsxRuntime.jsx("div",{className:"text-text-secondary",children:"Loading PDF..."})}),jsxRuntime.jsxs("div",{ref:d,className:"relative flex-1 overflow-hidden min-h-0",children:[jsxRuntime.jsx(reactPdf.Document,{options:ee,file:$,onLoadSuccess:te,onLoadError:oe,loading:jsxRuntime.jsx("div",{className:"flex items-center justify-center",style:{height:v},children:jsxRuntime.jsx("div",{className:"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent"})}),children:jsxRuntime.jsx(reactVirtuoso.Virtuoso,{ref:L,style:{height:K||"calc(100dvh - 120px)",width:"100%",scrollbarGutter:"stable both-edges"},totalCount:s,rangeChanged:ae,defaultItemHeight:v,itemContent:e=>jsxRuntime.jsx("div",{className:"mx-auto w-fit mb-4 border border-gray-100",children:jsxRuntime.jsx(reactPdf.Page,{pageNumber:e+1,renderTextLayer:true,renderAnnotationLayer:true,width:b*c,onLoadSuccess:o=>{if(e===0){let se=o.height/o.width;J(se);}},loading:jsxRuntime.jsx("div",{className:"flex items-center justify-center",style:{height:v},children:jsxRuntime.jsx("div",{className:"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent"})}),className:"h-auto w-full transition-[width] duration-[600ms] ease-in-out"})})})}),s>0&&jsxRuntime.jsxs(chunkAUAUMCWH_js.a,{"aria-label":"PDF controls",children:[jsxRuntime.jsxs(chunkAUAUMCWH_js.b,{children:[jsxRuntime.jsx(chunkAUAUMCWH_js.e,{"aria-label":"Zoom out",onClick:X,disabled:c<=.25,children:jsxRuntime.jsx(chunk6YUK4MG2_js.e,{width:16,height:16})}),jsxRuntime.jsxs(chunkAUAUMCWH_js.e,{"aria-label":"Current zoom",children:[Math.round(c*100),"%"]}),jsxRuntime.jsx(chunkAUAUMCWH_js.e,{"aria-label":"Zoom in",onClick:Q,disabled:c>=4,children:jsxRuntime.jsx(chunk6YUK4MG2_js.d,{width:16,height:16})})]}),jsxRuntime.jsx(chunkAUAUMCWH_js.d,{}),jsxRuntime.jsxs(chunkAUAUMCWH_js.c,{children:[jsxRuntime.jsx(chunkAUAUMCWH_js.e,{"aria-label":"Previous page",onClick:ne,disabled:i<=1,className:"px-3!",children:jsxRuntime.jsx(chunk6YUK4MG2_js.b,{width:12,height:12})}),jsxRuntime.jsxs("span",{className:"font-plex text-sm leading-4 tracking-[0.16px] text-text-body flex items-center",children:[jsxRuntime.jsx("input",{type:"number",min:1,max:s,value:i,onChange:e=>{let o=parseInt(e.target.value,10);o>=1&&o<=s&&(h(o),C(o,false));},className:"w-8 text-center bg-transparent outline-none font-plex text-sm leading-4 tracking-[0.16px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),jsxRuntime.jsxs("span",{children:["/",s]})]}),jsxRuntime.jsx(chunkAUAUMCWH_js.e,{"aria-label":"Next page",onClick:re,disabled:i>=s,className:"px-3!",children:jsxRuntime.jsx(chunk6YUK4MG2_js.c,{width:12,height:12})})]}),F&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(chunkAUAUMCWH_js.d,{}),jsxRuntime.jsx(chunkAUAUMCWH_js.e,{"aria-label":I?`Download ${I}`:"Download",onClick:F,children:jsxRuntime.jsx(chunk6YUK4MG2_js.a,{width:16,height:16})})]})]})]})]})},"PdfDriver");exports.PdfDriver=Te;//# sourceMappingURL=PdfDriver-Q3PWPXQQ.js.map
|
|
2
|
+
//# sourceMappingURL=PdfDriver-Q3PWPXQQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/FileViewer/drivers/PdfDriver/PdfDriver.tsx"],"names":["BASE_DIR","pdfjs","SCROLL_ANIMATION_DURATION","INPUT_DEBOUNCE_DELAY","RESIZE_DEBOUNCE_DELAY","CONTAINER_PADDING","DEFAULT_RATIO_A4","DEFAULT_MIN_SIZE","PdfDriver","__name","url","filename","onDownload","numPages","setNumPages","useState","pageNumber","setPageNumber","loading","setLoading","error","setError","width","setWidth","height","setHeight","scale","setScale","defaultPageHeight","setDefaultPageHeight","pageAspectRatio","setPageAspectRatio","containerRef","useRef","virtuosoRef","isUserScrollingRef","scrollTimeoutRef","isMountedRef","scrollToPage","useCallback","page","smooth","debouncedScroll","useMemo","debounce","handleZoomIn","prev","handleZoomOut","useEffect","updateSize","observer","options","onDocumentLoadSuccess","onDocumentLoadError","changePage","offset","newPage","previousPage","nextPage","handleRangeChanged","range","visiblePage","jsx","jsxs","Document","Virtuoso","index","Page","ratio","FloatingControls","FloatingControlsGroup","FloatingControlsButton","ZoomOutIcon","ZoomInIcon","FloatingControlsDivider","FloatingControlsBoxedGroup","KeyboardArrowLeftIcon","KeyboardArrowRightIcon","Fragment","DownloadIcon"],"mappings":"0jBAmBA,IAAMA,CAAAA,CAAW,QAAA,CAGb,OAAO,MAAA,CAAW,GAAA,EAAe,OAAO,QAAA,CAAa,GAAA,GACvDC,cAAAA,CAAM,mBAAA,CAAoB,SAAA,CAAY,CAAA,EAAGD,CAAQ,CAAA,kBAAA,CAAA,CAAA,CAQnD,IAAME,GAA4B,GAAA,CAC5BC,EAAAA,CAAuB,IACvBC,EAAAA,CAAwB,GAAA,CACxBC,EAAAA,CAAoB,EAAA,CACpBC,EAAAA,CAAmB,KAAA,CACnBC,EAAmB,GAAA,CAEZC,EAAAA,CAAsCC,mBAAA,CAAC,CAAE,IAAAC,CAAAA,CAAK,QAAA,CAAAC,CAAAA,CAAU,UAAA,CAAAC,CAAW,CAAA,GAAM,CACpF,GAAM,CAACC,EAAUC,CAAW,CAAA,CAAIC,eAAiB,CAAC,CAAA,CAC5C,CAACC,CAAAA,CAAYC,CAAa,CAAA,CAAIF,eAAiB,CAAC,CA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AAA,CAAK,QAAA,CAAA,CAAA,GAAA,CAAElD,CAAAA,CAAAA,CAAS,GACnB,CAAA,CACAiD,cAAAA,CAACS,kBAAAA,CAAA,CACC,YAAA,CAAW,WAAA,CACX,QAASb,EAAAA,CACT,QAAA,CAAU1C,GAAcH,CAAAA,CACxB,SAAA,CAAU,QAEV,QAAA,CAAAiD,cAAAA,CAACe,kBAAAA,CAAA,CAAuB,KAAA,CAAO,EAAA,CAAI,OAAQ,EAAA,CAAI,CAAA,CACjD,CAAA,CAAA,CACF,CAAA,CAECjE,CAAAA,EACCmD,eAAAA,CAAAe,oBAAA,CACE,QAAA,CAAA,CAAAhB,cAAAA,CAACY,kBAAAA,CAAA,EAAwB,CAAA,CACzBZ,eAACS,kBAAAA,CAAA,CACC,aAAY5D,CAAAA,CAAW,CAAA,SAAA,EAAYA,CAAQ,CAAA,CAAA,CAAK,UAAA,CAChD,OAAA,CAASC,CAAAA,CAET,QAAA,CAAAkD,cAAAA,CAACiB,mBAAA,CAAa,KAAA,CAAO,EAAA,CAAI,MAAA,CAAQ,EAAA,CAAI,CAAA,CACvC,GACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAEJ,CAAA,CApRmD,WAAA","file":"PdfDriver-TMPVSYW4.js","sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport debounce from 'lodash.debounce';\nimport { Document, Page, pdfjs } from 'react-pdf';\nimport 'react-pdf/dist/Page/AnnotationLayer.css';\nimport 'react-pdf/dist/Page/TextLayer.css';\nimport { Virtuoso, VirtuosoHandle } from 'react-virtuoso';\nimport { DownloadIcon } from '../../../Icons2/DownloadIcon';\nimport { KeyboardArrowLeftIcon } from '../../../Icons2/KeyboardArrowLeftIcon';\nimport { KeyboardArrowRightIcon } from '../../../Icons2/KeyboardArrowRightIcon';\nimport { ZoomInIcon } from '../../../Icons2/ZoomInIcon';\nimport { ZoomOutIcon } from '../../../Icons2/ZoomOutIcon';\nimport {\n FloatingControls,\n FloatingControlsBoxedGroup,\n FloatingControlsButton,\n FloatingControlsDivider,\n FloatingControlsGroup,\n} from '../_shared';\n\nconst BASE_DIR = '/pdfjs';\n\n// Set up the worker - self-hosted configuration (client-side only)\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n pdfjs.GlobalWorkerOptions.workerSrc = `${BASE_DIR}/pdf.worker.min.js`;\n}\n\ninterface PdfDriverProps {\n url: string;\n filename?: string;\n onDownload?: () => void;\n}\nconst SCROLL_ANIMATION_DURATION = 1000;\nconst INPUT_DEBOUNCE_DELAY = 400;\nconst RESIZE_DEBOUNCE_DELAY = 150;\nconst CONTAINER_PADDING = 70;\nconst DEFAULT_RATIO_A4 = 1.414;\nconst DEFAULT_MIN_SIZE = 400;\n\nexport const PdfDriver: React.FC<PdfDriverProps> = ({ url, filename, onDownload }) => {\n const [numPages, setNumPages] = useState<number>(0);\n const [pageNumber, setPageNumber] = useState<number>(1);\n const [loading, setLoading] = useState<boolean>(true);\n const [error, setError] = useState<string | null>(null);\n const [width, setWidth] = useState<number>(DEFAULT_MIN_SIZE);\n const [height, setHeight] = useState<number>(DEFAULT_MIN_SIZE);\n const [scale, setScale] = useState(1);\n const [defaultPageHeight, setDefaultPageHeight] = useState(DEFAULT_MIN_SIZE);\n const [pageAspectRatio, setPageAspectRatio] = useState(DEFAULT_RATIO_A4);\n\n const containerRef = useRef<HTMLDivElement>(null);\n const virtuosoRef = useRef<VirtuosoHandle>(null);\n const isUserScrollingRef = useRef<boolean>(false);\n const scrollTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isMountedRef = useRef(false);\n\n const scrollToPage = useCallback(\n (page: number, smooth = true) => {\n if (page < 1 || page > numPages) return;\n\n isUserScrollingRef.current = true;\n virtuosoRef.current?.scrollToIndex({\n index: page - 1,\n align: 'start',\n behavior: smooth ? 'smooth' : 'auto',\n });\n\n if (scrollTimeoutRef.current) {\n clearTimeout(scrollTimeoutRef.current);\n }\n\n scrollTimeoutRef.current = setTimeout(() => {\n if (isMountedRef.current) isUserScrollingRef.current = false;\n }, SCROLL_ANIMATION_DURATION);\n },\n [numPages]\n );\n\n const debouncedScroll = useMemo(() => {\n return debounce((page: number, smooth = false) => {\n scrollToPage(page, smooth);\n }, INPUT_DEBOUNCE_DELAY);\n }, [scrollToPage]);\n\n const handleZoomIn = useCallback(() => {\n setScale((prev) => Math.min(prev + 0.25, 4));\n }, []);\n\n const handleZoomOut = useCallback(() => {\n setScale((prev) => Math.max(prev - 0.25, 0.25));\n }, []);\n\n useEffect(() => {\n if (!containerRef.current) return;\n const updateSize = debounce(() => {\n if (containerRef.current) {\n setWidth(containerRef.current.offsetWidth - CONTAINER_PADDING);\n setHeight(containerRef.current.clientHeight);\n }\n }, RESIZE_DEBOUNCE_DELAY);\n updateSize();\n const observer = new ResizeObserver(updateSize);\n observer.observe(containerRef.current);\n return () => {\n observer.disconnect();\n updateSize.cancel();\n };\n }, []);\n\n const options = useMemo(\n () => ({\n cMapPacked: true,\n cMapUrl: `${BASE_DIR}/cmaps/`,\n standardFontDataUrl: `${BASE_DIR}/standard_fonts/`,\n wasmUrl: `${BASE_DIR}/wasm/`,\n iccUrl: `${BASE_DIR}/icc/`,\n }),\n []\n );\n\n const onDocumentLoadSuccess = useCallback(({ numPages }: { numPages: number }): void => {\n setNumPages(numPages);\n setLoading(false);\n }, []);\n\n const onDocumentLoadError = useCallback((error: Error): void => {\n setError(`Failed to load PDF: ${error.message}`);\n setLoading(false);\n }, []);\n\n const changePage = useCallback(\n (offset: number): void => {\n const newPage = pageNumber + offset;\n setPageNumber(newPage);\n scrollToPage(newPage);\n },\n [pageNumber, scrollToPage]\n );\n\n const previousPage = useCallback((): void => {\n changePage(-1);\n }, [changePage]);\n\n const nextPage = useCallback((): void => {\n changePage(1);\n }, [changePage]);\n\n const handleRangeChanged = useCallback(\n (range: { startIndex: number; endIndex: number }) => {\n if (isUserScrollingRef.current) {\n return;\n }\n const visiblePage = range.startIndex + 1;\n if (visiblePage !== pageNumber) {\n setPageNumber(visiblePage);\n }\n },\n [pageNumber]\n );\n\n useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n debouncedScroll.cancel();\n if (scrollTimeoutRef.current) {\n clearTimeout(scrollTimeoutRef.current);\n }\n };\n }, [debouncedScroll]);\n\n useEffect(() => {\n setDefaultPageHeight(width * scale * pageAspectRatio);\n }, [width, scale, pageAspectRatio]);\n\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full w-full px-8.5\">\n <div className=\"text-red-500 text-center\">\n <p>{error}</p>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"relative h-full w-full flex flex-col overflow-hidden bg-radar-drawer-bg\">\n {loading && (\n <div className=\"flex items-center justify-center h-full px-8.5\">\n <div className=\"text-radar-text-secondary\">Loading PDF...</div>\n </div>\n )}\n <div ref={containerRef} className=\"relative flex-1 overflow-hidden min-h-0\">\n <Document\n options={options}\n file={url}\n onLoadSuccess={onDocumentLoadSuccess}\n onLoadError={onDocumentLoadError}\n loading={\n <div className=\"flex items-center justify-center\" style={{ height: defaultPageHeight }}>\n <div className=\"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent\" />\n </div>\n }\n >\n <Virtuoso\n ref={virtuosoRef}\n style={{\n height: height || 'calc(100dvh - 120px)',\n width: '100%',\n scrollbarGutter: 'stable both-edges',\n }}\n totalCount={numPages}\n rangeChanged={handleRangeChanged}\n defaultItemHeight={defaultPageHeight}\n itemContent={(index) => (\n <div className=\"mx-auto w-fit mb-4 border border-gray-100\">\n <Page\n pageNumber={index + 1}\n renderTextLayer\n renderAnnotationLayer\n width={width * scale}\n onLoadSuccess={(page) => {\n if (index === 0) {\n const ratio = page.height / page.width;\n setPageAspectRatio(ratio);\n }\n }}\n loading={\n <div className=\"flex items-center justify-center\" style={{ height: defaultPageHeight }}>\n <div className=\"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent\" />\n </div>\n }\n className=\"h-auto w-full transition-[width] duration-[600ms] ease-in-out\"\n />\n </div>\n )}\n />\n </Document>\n\n {numPages > 0 && (\n <FloatingControls aria-label=\"PDF controls\">\n <FloatingControlsGroup>\n <FloatingControlsButton\n aria-label=\"Zoom out\"\n onClick={handleZoomOut}\n disabled={scale <= 0.25}\n >\n <ZoomOutIcon width={16} height={16} />\n </FloatingControlsButton>\n <FloatingControlsButton aria-label=\"Current zoom\">\n {Math.round(scale * 100)}%\n </FloatingControlsButton>\n <FloatingControlsButton\n aria-label=\"Zoom in\"\n onClick={handleZoomIn}\n disabled={scale >= 4}\n >\n <ZoomInIcon width={16} height={16} />\n </FloatingControlsButton>\n </FloatingControlsGroup>\n\n <FloatingControlsDivider />\n\n <FloatingControlsBoxedGroup>\n <FloatingControlsButton\n aria-label=\"Previous page\"\n onClick={previousPage}\n disabled={pageNumber <= 1}\n className=\"px-3!\"\n >\n <KeyboardArrowLeftIcon width={12} height={12} />\n </FloatingControlsButton>\n <span className=\"font-plex text-sm leading-4 tracking-[0.16px] text-radar-text-primary flex items-center\">\n <input\n type=\"number\"\n min={1}\n max={numPages}\n value={pageNumber}\n onChange={(e) => {\n const page = parseInt(e.target.value, 10);\n if (page >= 1 && page <= numPages) {\n setPageNumber(page);\n debouncedScroll(page, false);\n }\n }}\n className=\"w-8 text-center bg-transparent outline-none font-plex text-sm leading-4 tracking-[0.16px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none\"\n />\n <span>/{numPages}</span>\n </span>\n <FloatingControlsButton\n aria-label=\"Next page\"\n onClick={nextPage}\n disabled={pageNumber >= numPages}\n className=\"px-3!\"\n >\n <KeyboardArrowRightIcon width={12} height={12} />\n </FloatingControlsButton>\n </FloatingControlsBoxedGroup>\n\n {onDownload && (\n <>\n <FloatingControlsDivider />\n <FloatingControlsButton\n aria-label={filename ? `Download ${filename}` : 'Download'}\n onClick={onDownload}\n >\n <DownloadIcon width={16} height={16} />\n </FloatingControlsButton>\n </>\n )}\n </FloatingControls>\n )}\n </div>\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/FileViewer/drivers/PdfDriver/PdfDriver.tsx"],"names":["BASE_DIR","pdfjs","SCROLL_ANIMATION_DURATION","INPUT_DEBOUNCE_DELAY","RESIZE_DEBOUNCE_DELAY","CONTAINER_PADDING","DEFAULT_RATIO_A4","DEFAULT_MIN_SIZE","PdfDriver","__name","url","filename","onDownload","numPages","setNumPages","useState","pageNumber","setPageNumber","loading","setLoading","error","setError","width","setWidth","height","setHeight","scale","setScale","defaultPageHeight","setDefaultPageHeight","pageAspectRatio","setPageAspectRatio","containerRef","useRef","virtuosoRef","isUserScrollingRef","scrollTimeoutRef","isMountedRef","scrollToPage","useCallback","page","smooth","debouncedScroll","useMemo","debounce","handleZoomIn","prev","handleZoomOut","useEffect","updateSize","observer","options","onDocumentLoadSuccess","onDocumentLoadError","changePage","offset","newPage","previousPage","nextPage","handleRangeChanged","range","visiblePage","jsx","jsxs","Document","Virtuoso","index","Page","ratio","FloatingControls","FloatingControlsGroup","FloatingControlsButton","ZoomOutIcon","ZoomInIcon","FloatingControlsDivider","FloatingControlsBoxedGroup","KeyboardArrowLeftIcon","KeyboardArrowRightIcon","Fragment","DownloadIcon"],"mappings":"0jBAmBA,IAAMA,CAAAA,CAAW,QAAA,CAGb,OAAO,MAAA,CAAW,GAAA,EAAe,OAAO,QAAA,CAAa,GAAA,GACvDC,cAAAA,CAAM,mBAAA,CAAoB,SAAA,CAAY,CAAA,EAAGD,CAAQ,CAAA,kBAAA,CAAA,CAAA,CAQnD,IAAME,GAA4B,GAAA,CAC5BC,EAAAA,CAAuB,IACvBC,EAAAA,CAAwB,GAAA,CACxBC,EAAAA,CAAoB,EAAA,CACpBC,EAAAA,CAAmB,KAAA,CACnBC,EAAmB,GAAA,CAEZC,EAAAA,CAAsCC,mBAAA,CAAC,CAAE,IAAAC,CAAAA,CAAK,QAAA,CAAAC,CAAAA,CAAU,UAAA,CAAAC,CAA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CAAcuB,CAAI,CAAA,CAClBE,CAAAA,CAAgBF,CAAAA,CAAM,KAAK,CAAA,EAE/B,CAAA,CACA,UAAU,gNAAA,CACZ,CAAA,CACAuB,eAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,CAAA,GAAA,CAAElD,CAAAA,CAAAA,CAAS,GACnB,CAAA,CACAiD,cAAAA,CAACS,kBAAAA,CAAA,CACC,YAAA,CAAW,WAAA,CACX,QAASb,EAAAA,CACT,QAAA,CAAU1C,GAAcH,CAAAA,CACxB,SAAA,CAAU,QAEV,QAAA,CAAAiD,cAAAA,CAACe,kBAAAA,CAAA,CAAuB,KAAA,CAAO,EAAA,CAAI,OAAQ,EAAA,CAAI,CAAA,CACjD,CAAA,CAAA,CACF,CAAA,CAECjE,CAAAA,EACCmD,eAAAA,CAAAe,oBAAA,CACE,QAAA,CAAA,CAAAhB,cAAAA,CAACY,kBAAAA,CAAA,EAAwB,CAAA,CACzBZ,eAACS,kBAAAA,CAAA,CACC,aAAY5D,CAAAA,CAAW,CAAA,SAAA,EAAYA,CAAQ,CAAA,CAAA,CAAK,UAAA,CAChD,OAAA,CAASC,CAAAA,CAET,QAAA,CAAAkD,cAAAA,CAACiB,mBAAA,CAAa,KAAA,CAAO,EAAA,CAAI,MAAA,CAAQ,EAAA,CAAI,CAAA,CACvC,GACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAEJ,CAAA,CApRmD,WAAA","file":"PdfDriver-Q3PWPXQQ.js","sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport debounce from 'lodash.debounce';\nimport { Document, Page, pdfjs } from 'react-pdf';\nimport 'react-pdf/dist/Page/AnnotationLayer.css';\nimport 'react-pdf/dist/Page/TextLayer.css';\nimport { Virtuoso, VirtuosoHandle } from 'react-virtuoso';\nimport { DownloadIcon } from '../../../Icons2/DownloadIcon';\nimport { KeyboardArrowLeftIcon } from '../../../Icons2/KeyboardArrowLeftIcon';\nimport { KeyboardArrowRightIcon } from '../../../Icons2/KeyboardArrowRightIcon';\nimport { ZoomInIcon } from '../../../Icons2/ZoomInIcon';\nimport { ZoomOutIcon } from '../../../Icons2/ZoomOutIcon';\nimport {\n FloatingControls,\n FloatingControlsBoxedGroup,\n FloatingControlsButton,\n FloatingControlsDivider,\n FloatingControlsGroup,\n} from '../_shared';\n\nconst BASE_DIR = '/pdfjs';\n\n// Set up the worker - self-hosted configuration (client-side only)\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n pdfjs.GlobalWorkerOptions.workerSrc = `${BASE_DIR}/pdf.worker.min.js`;\n}\n\ninterface PdfDriverProps {\n url: string;\n filename?: string;\n onDownload?: () => void;\n}\nconst SCROLL_ANIMATION_DURATION = 1000;\nconst INPUT_DEBOUNCE_DELAY = 400;\nconst RESIZE_DEBOUNCE_DELAY = 150;\nconst CONTAINER_PADDING = 70;\nconst DEFAULT_RATIO_A4 = 1.414;\nconst DEFAULT_MIN_SIZE = 400;\n\nexport const PdfDriver: React.FC<PdfDriverProps> = ({ url, filename, onDownload }) => {\n const [numPages, setNumPages] = useState<number>(0);\n const [pageNumber, setPageNumber] = useState<number>(1);\n const [loading, setLoading] = useState<boolean>(true);\n const [error, setError] = useState<string | null>(null);\n const [width, setWidth] = useState<number>(DEFAULT_MIN_SIZE);\n const [height, setHeight] = useState<number>(DEFAULT_MIN_SIZE);\n const [scale, setScale] = useState(1);\n const [defaultPageHeight, setDefaultPageHeight] = useState(DEFAULT_MIN_SIZE);\n const [pageAspectRatio, setPageAspectRatio] = useState(DEFAULT_RATIO_A4);\n\n const containerRef = useRef<HTMLDivElement>(null);\n const virtuosoRef = useRef<VirtuosoHandle>(null);\n const isUserScrollingRef = useRef<boolean>(false);\n const scrollTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isMountedRef = useRef(false);\n\n const scrollToPage = useCallback(\n (page: number, smooth = true) => {\n if (page < 1 || page > numPages) return;\n\n isUserScrollingRef.current = true;\n virtuosoRef.current?.scrollToIndex({\n index: page - 1,\n align: 'start',\n behavior: smooth ? 'smooth' : 'auto',\n });\n\n if (scrollTimeoutRef.current) {\n clearTimeout(scrollTimeoutRef.current);\n }\n\n scrollTimeoutRef.current = setTimeout(() => {\n if (isMountedRef.current) isUserScrollingRef.current = false;\n }, SCROLL_ANIMATION_DURATION);\n },\n [numPages]\n );\n\n const debouncedScroll = useMemo(() => {\n return debounce((page: number, smooth = false) => {\n scrollToPage(page, smooth);\n }, INPUT_DEBOUNCE_DELAY);\n }, [scrollToPage]);\n\n const handleZoomIn = useCallback(() => {\n setScale((prev) => Math.min(prev + 0.25, 4));\n }, []);\n\n const handleZoomOut = useCallback(() => {\n setScale((prev) => Math.max(prev - 0.25, 0.25));\n }, []);\n\n useEffect(() => {\n if (!containerRef.current) return;\n const updateSize = debounce(() => {\n if (containerRef.current) {\n setWidth(containerRef.current.offsetWidth - CONTAINER_PADDING);\n setHeight(containerRef.current.clientHeight);\n }\n }, RESIZE_DEBOUNCE_DELAY);\n updateSize();\n const observer = new ResizeObserver(updateSize);\n observer.observe(containerRef.current);\n return () => {\n observer.disconnect();\n updateSize.cancel();\n };\n }, []);\n\n const options = useMemo(\n () => ({\n cMapPacked: true,\n cMapUrl: `${BASE_DIR}/cmaps/`,\n standardFontDataUrl: `${BASE_DIR}/standard_fonts/`,\n wasmUrl: `${BASE_DIR}/wasm/`,\n iccUrl: `${BASE_DIR}/icc/`,\n }),\n []\n );\n\n const onDocumentLoadSuccess = useCallback(({ numPages }: { numPages: number }): void => {\n setNumPages(numPages);\n setLoading(false);\n }, []);\n\n const onDocumentLoadError = useCallback((error: Error): void => {\n setError(`Failed to load PDF: ${error.message}`);\n setLoading(false);\n }, []);\n\n const changePage = useCallback(\n (offset: number): void => {\n const newPage = pageNumber + offset;\n setPageNumber(newPage);\n scrollToPage(newPage);\n },\n [pageNumber, scrollToPage]\n );\n\n const previousPage = useCallback((): void => {\n changePage(-1);\n }, [changePage]);\n\n const nextPage = useCallback((): void => {\n changePage(1);\n }, [changePage]);\n\n const handleRangeChanged = useCallback(\n (range: { startIndex: number; endIndex: number }) => {\n if (isUserScrollingRef.current) {\n return;\n }\n const visiblePage = range.startIndex + 1;\n if (visiblePage !== pageNumber) {\n setPageNumber(visiblePage);\n }\n },\n [pageNumber]\n );\n\n useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n debouncedScroll.cancel();\n if (scrollTimeoutRef.current) {\n clearTimeout(scrollTimeoutRef.current);\n }\n };\n }, [debouncedScroll]);\n\n useEffect(() => {\n setDefaultPageHeight(width * scale * pageAspectRatio);\n }, [width, scale, pageAspectRatio]);\n\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full w-full px-8.5\">\n <div className=\"text-red-500 text-center\">\n <p>{error}</p>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"relative h-full w-full flex flex-col overflow-hidden bg-background-page\">\n {loading && (\n <div className=\"flex items-center justify-center h-full px-8.5\">\n <div className=\"text-text-secondary\">Loading PDF...</div>\n </div>\n )}\n <div ref={containerRef} className=\"relative flex-1 overflow-hidden min-h-0\">\n <Document\n options={options}\n file={url}\n onLoadSuccess={onDocumentLoadSuccess}\n onLoadError={onDocumentLoadError}\n loading={\n <div className=\"flex items-center justify-center\" style={{ height: defaultPageHeight }}>\n <div className=\"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent\" />\n </div>\n }\n >\n <Virtuoso\n ref={virtuosoRef}\n style={{\n height: height || 'calc(100dvh - 120px)',\n width: '100%',\n scrollbarGutter: 'stable both-edges',\n }}\n totalCount={numPages}\n rangeChanged={handleRangeChanged}\n defaultItemHeight={defaultPageHeight}\n itemContent={(index) => (\n <div className=\"mx-auto w-fit mb-4 border border-gray-100\">\n <Page\n pageNumber={index + 1}\n renderTextLayer\n renderAnnotationLayer\n width={width * scale}\n onLoadSuccess={(page) => {\n if (index === 0) {\n const ratio = page.height / page.width;\n setPageAspectRatio(ratio);\n }\n }}\n loading={\n <div className=\"flex items-center justify-center\" style={{ height: defaultPageHeight }}>\n <div className=\"h-10 w-10 rounded-full border-2 border-gray-200 animate-spin border-s-transparent\" />\n </div>\n }\n className=\"h-auto w-full transition-[width] duration-[600ms] ease-in-out\"\n />\n </div>\n )}\n />\n </Document>\n\n {numPages > 0 && (\n <FloatingControls aria-label=\"PDF controls\">\n <FloatingControlsGroup>\n <FloatingControlsButton\n aria-label=\"Zoom out\"\n onClick={handleZoomOut}\n disabled={scale <= 0.25}\n >\n <ZoomOutIcon width={16} height={16} />\n </FloatingControlsButton>\n <FloatingControlsButton aria-label=\"Current zoom\">\n {Math.round(scale * 100)}%\n </FloatingControlsButton>\n <FloatingControlsButton\n aria-label=\"Zoom in\"\n onClick={handleZoomIn}\n disabled={scale >= 4}\n >\n <ZoomInIcon width={16} height={16} />\n </FloatingControlsButton>\n </FloatingControlsGroup>\n\n <FloatingControlsDivider />\n\n <FloatingControlsBoxedGroup>\n <FloatingControlsButton\n aria-label=\"Previous page\"\n onClick={previousPage}\n disabled={pageNumber <= 1}\n className=\"px-3!\"\n >\n <KeyboardArrowLeftIcon width={12} height={12} />\n </FloatingControlsButton>\n <span className=\"font-plex text-sm leading-4 tracking-[0.16px] text-text-body flex items-center\">\n <input\n type=\"number\"\n min={1}\n max={numPages}\n value={pageNumber}\n onChange={(e) => {\n const page = parseInt(e.target.value, 10);\n if (page >= 1 && page <= numPages) {\n setPageNumber(page);\n debouncedScroll(page, false);\n }\n }}\n className=\"w-8 text-center bg-transparent outline-none font-plex text-sm leading-4 tracking-[0.16px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none\"\n />\n <span>/{numPages}</span>\n </span>\n <FloatingControlsButton\n aria-label=\"Next page\"\n onClick={nextPage}\n disabled={pageNumber >= numPages}\n className=\"px-3!\"\n >\n <KeyboardArrowRightIcon width={12} height={12} />\n </FloatingControlsButton>\n </FloatingControlsBoxedGroup>\n\n {onDownload && (\n <>\n <FloatingControlsDivider />\n <FloatingControlsButton\n aria-label={filename ? `Download ${filename}` : 'Download'}\n onClick={onDownload}\n >\n <DownloadIcon width={16} height={16} />\n </FloatingControlsButton>\n </>\n )}\n </FloatingControls>\n )}\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-7LHQWEWV.mjs';import {a}from'./chunk-QWPVIX2T.mjs';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var d=forwardRef(a(function({className:o,children:t,...r},e){return jsx("div",{ref:e,role:"toolbar",className:a$1("absolute left-1/2 -translate-x-1/2 bottom-4 z-10","flex items-center justify-center gap-2 p-2","bg-white border border-border-subtle shadow-radar-overlay",o),...r,children:t})},"FloatingControls")),g=forwardRef(a(function({className:o,children:t,...r},e){return jsx("div",{ref:e,className:a$1("flex items-center gap-1",o),...r,children:t})},"FloatingControlsGroup")),c=forwardRef(a(function({className:o,children:t,...r},e){return jsx("div",{ref:e,className:a$1("flex items-center border border-border-subtle",o),...r,children:t})},"FloatingControlsBoxedGroup")),b=a(()=>jsx("span",{"aria-hidden":true,className:"self-stretch w-px bg-border-subtle"}),"FloatingControlsDivider"),x=forwardRef(a(function({active:o,className:t,children:r,type:e,...p},u){return jsx("button",{ref:u,type:e??"button",className:a$1("inline-flex items-center justify-center px-2 py-[7px]","font-plex text-sm leading-4 tracking-[0.16px] text-text-body","hover:bg-background-surface-secondary","disabled:opacity-40 disabled:pointer-events-none",o&&"bg-background-surface-secondary",t),...p,children:r})},"FloatingControlsButton"));export{d as a,g as b,c,b as d,x as e};//# sourceMappingURL=chunk-47XRQ3QA.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-47XRQ3QA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/FileViewer/drivers/_shared/FloatingControls.tsx"],"names":["FloatingControls","forwardRef","__name","className","children","rest","ref","jsx","cn","FloatingControlsGroup","FloatingControlsBoxed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AA,CAAA,CAQ1BK,EAAyBX,UAAAA,CACpCC,CAAAA,CAAA,SAAgC,CAAE,OAAAW,CAAAA,CAAQ,SAAA,CAAAV,CAAAA,CAAW,QAAA,CAAAC,EAAU,IAAA,CAAAU,CAAAA,CAAM,GAAGT,CAAK,EAAGC,CAAAA,CAAK,CACnF,OACEC,GAAAA,CAAC,UACC,GAAA,CAAKD,CAAAA,CACL,IAAA,CAAMQ,CAAAA,EAAQ,SACd,SAAA,CAAWN,GAAAA,CACT,uDAAA,CACA,8DAAA,CACA,wCACA,kDAAA,CACAK,CAAAA,EAAU,iCAAA,CACVV,CACF,EACC,GAAGE,CAAAA,CAEH,SAAAD,CAAAA,CACH,CAEJ,EAlBA,wBAAA,CAmBF","file":"chunk-47XRQ3QA.mjs","sourcesContent":["import {\n forwardRef,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { cn } from '../../../lib/cn';\n\n// Tokens follow Figma \"Document toolbar/Variants\" (Radar-Components 458:22503):\n// - container/buttons/groups have NO rounded corners,\n// - text uses IBM Plex Sans (font-plex) 14px / leading-4 / tracking-[0.16px],\n// - icon-only buttons are 30px tall (px-[8px] py-[7px] + 16px icon),\n// - text-only buttons (e.g. \"100%\") use px-[8px] py-[7px] without an icon spacer.\n\nexport type FloatingControlsProps = HTMLAttributes<HTMLDivElement> & {\n children: ReactNode;\n};\n\nexport const FloatingControls = forwardRef<HTMLDivElement, FloatingControlsProps>(\n function FloatingControls({ className, children, ...rest }, ref) {\n return (\n <div\n ref={ref}\n role=\"toolbar\"\n className={cn(\n 'absolute left-1/2 -translate-x-1/2 bottom-4 z-10',\n 'flex items-center justify-center gap-2 p-2',\n 'bg-white border border-border-subtle shadow-radar-overlay',\n className\n )}\n {...rest}\n >\n {children}\n </div>\n );\n }\n);\n\nexport type FloatingControlsGroupProps = HTMLAttributes<HTMLDivElement>;\n\nexport const FloatingControlsGroup = forwardRef<HTMLDivElement, FloatingControlsGroupProps>(\n function FloatingControlsGroup({ className, children, ...rest }, ref) {\n return (\n <div ref={ref} className={cn('flex items-center gap-1', className)} {...rest}>\n {children}\n </div>\n );\n }\n);\n\nexport type FloatingControlsBoxedGroupProps = HTMLAttributes<HTMLDivElement>;\n\nexport const FloatingControlsBoxedGroup = forwardRef<HTMLDivElement, FloatingControlsBoxedGroupProps>(\n function FloatingControlsBoxedGroup({ className, children, ...rest }, ref) {\n return (\n <div\n ref={ref}\n className={cn('flex items-center border border-border-subtle', className)}\n {...rest}\n >\n {children}\n </div>\n );\n }\n);\n\nexport const FloatingControlsDivider = () => (\n <span aria-hidden className=\"self-stretch w-px bg-border-subtle\" />\n);\n\nexport type FloatingControlsButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n active?: boolean;\n};\n\nexport const FloatingControlsButton = forwardRef<HTMLButtonElement, FloatingControlsButtonProps>(\n function FloatingControlsButton({ active, className, children, type, ...rest }, ref) {\n return (\n <button\n ref={ref}\n type={type ?? 'button'}\n className={cn(\n 'inline-flex items-center justify-center px-2 py-[7px]',\n 'font-plex text-sm leading-4 tracking-[0.16px] text-text-body',\n 'hover:bg-background-surface-secondary',\n 'disabled:opacity-40 disabled:pointer-events-none',\n active && 'bg-background-surface-secondary',\n className\n )}\n {...rest}\n >\n {children}\n </button>\n );\n }\n);\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkNQZUCXJV_js=require('./chunk-NQZUCXJV.js'),chunkAYDF3IFZ_js=require('./chunk-AYDF3IFZ.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var g=react.forwardRef(chunkAYDF3IFZ_js.a(function({className:o,children:t,...r},e){return jsxRuntime.jsx("div",{ref:e,role:"toolbar",className:chunkNQZUCXJV_js.a("absolute left-1/2 -translate-x-1/2 bottom-4 z-10","flex items-center justify-center gap-2 p-2","bg-white border border-border-subtle shadow-radar-overlay",o),...r,children:t})},"FloatingControls")),c=react.forwardRef(chunkAYDF3IFZ_js.a(function({className:o,children:t,...r},e){return jsxRuntime.jsx("div",{ref:e,className:chunkNQZUCXJV_js.a("flex items-center gap-1",o),...r,children:t})},"FloatingControlsGroup")),b=react.forwardRef(chunkAYDF3IFZ_js.a(function({className:o,children:t,...r},e){return jsxRuntime.jsx("div",{ref:e,className:chunkNQZUCXJV_js.a("flex items-center border border-border-subtle",o),...r,children:t})},"FloatingControlsBoxedGroup")),x=chunkAYDF3IFZ_js.a(()=>jsxRuntime.jsx("span",{"aria-hidden":true,className:"self-stretch w-px bg-border-subtle"}),"FloatingControlsDivider"),C=react.forwardRef(chunkAYDF3IFZ_js.a(function({active:o,className:t,children:r,type:e,...p},u){return jsxRuntime.jsx("button",{ref:u,type:e??"button",className:chunkNQZUCXJV_js.a("inline-flex items-center justify-center px-2 py-[7px]","font-plex text-sm leading-4 tracking-[0.16px] text-text-body","hover:bg-background-surface-secondary","disabled:opacity-40 disabled:pointer-events-none",o&&"bg-background-surface-secondary",t),...p,children:r})},"FloatingControlsButton"));exports.a=g;exports.b=c;exports.c=b;exports.d=x;exports.e=C;//# sourceMappingURL=chunk-AUAUMCWH.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-AUAUMCWH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/FileViewer/drivers/_shared/FloatingControls.tsx"],"names":["FloatingControls","forwardRef","__name","className","children","rest","ref","jsx","cn","FloatingControlsGroup","FloatingControlsBoxedGroup","FloatingControlsDivider","FloatingControlsButton","active","type"],"mappings":"gLAkBO,IAAMA,CAAAA,CAAmBC,gBAAAA,CAC9BC,kBAAAA,CAAA,SAA0B,CAAE,SAAA,CAAAC,CAAAA,CAAW,QAAA,CAAAC,EAAU,GAAGC,CAAK,CAAA,CAAGC,CAAAA,CAAK,CAC/D,OACEC,cAAAA,CAAC,KAAA,CAAA,CACC,GAAA,CAAKD,EACL,IAAA,CAAK,SAAA,CACL,SAAA,CAAWE,kBAAAA,CACT,mDACA,4CAAA,CACA,2DAAA,CACAL,C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A,wCACA,kDAAA,CACAK,CAAAA,EAAU,iCAAA,CACVV,CACF,EACC,GAAGE,CAAAA,CAEH,SAAAD,CAAAA,CACH,CAEJ,EAlBA,wBAAA,CAmBF","file":"chunk-AUAUMCWH.js","sourcesContent":["import {\n forwardRef,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { cn } from '../../../lib/cn';\n\n// Tokens follow Figma \"Document toolbar/Variants\" (Radar-Components 458:22503):\n// - container/buttons/groups have NO rounded corners,\n// - text uses IBM Plex Sans (font-plex) 14px / leading-4 / tracking-[0.16px],\n// - icon-only buttons are 30px tall (px-[8px] py-[7px] + 16px icon),\n// - text-only buttons (e.g. \"100%\") use px-[8px] py-[7px] without an icon spacer.\n\nexport type FloatingControlsProps = HTMLAttributes<HTMLDivElement> & {\n children: ReactNode;\n};\n\nexport const FloatingControls = forwardRef<HTMLDivElement, FloatingControlsProps>(\n function FloatingControls({ className, children, ...rest }, ref) {\n return (\n <div\n ref={ref}\n role=\"toolbar\"\n className={cn(\n 'absolute left-1/2 -translate-x-1/2 bottom-4 z-10',\n 'flex items-center justify-center gap-2 p-2',\n 'bg-white border border-border-subtle shadow-radar-overlay',\n className\n )}\n {...rest}\n >\n {children}\n </div>\n );\n }\n);\n\nexport type FloatingControlsGroupProps = HTMLAttributes<HTMLDivElement>;\n\nexport const FloatingControlsGroup = forwardRef<HTMLDivElement, FloatingControlsGroupProps>(\n function FloatingControlsGroup({ className, children, ...rest }, ref) {\n return (\n <div ref={ref} className={cn('flex items-center gap-1', className)} {...rest}>\n {children}\n </div>\n );\n }\n);\n\nexport type FloatingControlsBoxedGroupProps = HTMLAttributes<HTMLDivElement>;\n\nexport const FloatingControlsBoxedGroup = forwardRef<HTMLDivElement, FloatingControlsBoxedGroupProps>(\n function FloatingControlsBoxedGroup({ className, children, ...rest }, ref) {\n return (\n <div\n ref={ref}\n className={cn('flex items-center border border-border-subtle', className)}\n {...rest}\n >\n {children}\n </div>\n );\n }\n);\n\nexport const FloatingControlsDivider = () => (\n <span aria-hidden className=\"self-stretch w-px bg-border-subtle\" />\n);\n\nexport type FloatingControlsButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n active?: boolean;\n};\n\nexport const FloatingControlsButton = forwardRef<HTMLButtonElement, FloatingControlsButtonProps>(\n function FloatingControlsButton({ active, className, children, type, ...rest }, ref) {\n return (\n <button\n ref={ref}\n type={type ?? 'button'}\n className={cn(\n 'inline-flex items-center justify-center px-2 py-[7px]',\n 'font-plex text-sm leading-4 tracking-[0.16px] text-text-body',\n 'hover:bg-background-surface-secondary',\n 'disabled:opacity-40 disabled:pointer-events-none',\n active && 'bg-background-surface-secondary',\n className\n )}\n {...rest}\n >\n {children}\n </button>\n );\n }\n);\n"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -417,17 +417,19 @@ declare const SearchInput2: React__default.ForwardRefExoticComponent<Omit<React_
|
|
|
417
417
|
rootClassName?: string;
|
|
418
418
|
} & React__default.RefAttributes<SearchInput2Element>>;
|
|
419
419
|
|
|
420
|
-
type
|
|
421
|
-
type
|
|
422
|
-
type?:
|
|
420
|
+
type VerticalNavigationButtonType = 'default' | 'treeview' | 'isLeaf';
|
|
421
|
+
type BaseVerticalNavigationButtonProps = {
|
|
422
|
+
type?: VerticalNavigationButtonType;
|
|
423
423
|
count?: number | string;
|
|
424
424
|
countLoading?: boolean;
|
|
425
|
+
/** Cap a numeric count at 99 → "99+". Defaults to true. */
|
|
426
|
+
capCount?: boolean;
|
|
425
427
|
selected?: boolean;
|
|
426
428
|
expanded?: boolean;
|
|
427
429
|
children?: React__default.ReactNode;
|
|
428
430
|
};
|
|
429
|
-
type
|
|
430
|
-
declare const
|
|
431
|
+
type VerticalNavigationButtonProps = Omit<React__default.ButtonHTMLAttributes<HTMLButtonElement>, keyof BaseVerticalNavigationButtonProps> & BaseVerticalNavigationButtonProps;
|
|
432
|
+
declare const VerticalNavigationButton: React__default.ForwardRefExoticComponent<Omit<React__default.ButtonHTMLAttributes<HTMLButtonElement>, keyof BaseVerticalNavigationButtonProps> & BaseVerticalNavigationButtonProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
431
433
|
|
|
432
434
|
interface BoneProps {
|
|
433
435
|
width?: number | string;
|
|
@@ -1209,6 +1211,8 @@ type BaseVerticalNavigationProps = {
|
|
|
1209
1211
|
defaultExpandedIds?: string[];
|
|
1210
1212
|
onExpandedChange?: (ids: string[]) => void;
|
|
1211
1213
|
collapsible?: boolean;
|
|
1214
|
+
/** Cap numeric item counts at 99 → "99+". Defaults to true. */
|
|
1215
|
+
capCount?: boolean;
|
|
1212
1216
|
};
|
|
1213
1217
|
type VerticalNavigationProps = Omit<React__default.HTMLAttributes<HTMLDivElement>, keyof BaseVerticalNavigationProps> & BaseVerticalNavigationProps;
|
|
1214
1218
|
declare const VerticalNavigation: React__default.ForwardRefExoticComponent<Omit<React__default.HTMLAttributes<HTMLDivElement>, keyof BaseVerticalNavigationProps> & BaseVerticalNavigationProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
@@ -1265,34 +1269,6 @@ interface TableProps {
|
|
|
1265
1269
|
}
|
|
1266
1270
|
declare const Table: ({ columns, rowCount, renderCell, renderHeaderCell, rowIds, hasHeader, hasBorder, cellPadding, className, columnWidths, onColumnResizeStart, activeResizeCol, }: TableProps) => react_jsx_runtime.JSX.Element;
|
|
1267
1271
|
|
|
1268
|
-
type Table2SortDirection = 'asc' | 'desc';
|
|
1269
|
-
type Table2SortState = {
|
|
1270
|
-
key: string;
|
|
1271
|
-
direction: Table2SortDirection;
|
|
1272
|
-
} | null;
|
|
1273
|
-
type Table2Column<T> = {
|
|
1274
|
-
key: string;
|
|
1275
|
-
header: React__default.ReactNode;
|
|
1276
|
-
accessor?: keyof T | ((row: T) => React__default.ReactNode);
|
|
1277
|
-
sortable?: boolean;
|
|
1278
|
-
width?: number | string;
|
|
1279
|
-
align?: 'left' | 'center' | 'right';
|
|
1280
|
-
className?: string;
|
|
1281
|
-
headerClassName?: string;
|
|
1282
|
-
};
|
|
1283
|
-
type BaseTable2Props<T> = {
|
|
1284
|
-
columns: Table2Column<T>[];
|
|
1285
|
-
data: T[];
|
|
1286
|
-
rowKey: (row: T, index: number) => React__default.Key;
|
|
1287
|
-
zebra?: boolean;
|
|
1288
|
-
sort?: Table2SortState;
|
|
1289
|
-
onSortChange?: (sort: Table2SortState) => void;
|
|
1290
|
-
onRowClick?: (row: T, index: number) => void;
|
|
1291
|
-
emptyMessage?: React__default.ReactNode;
|
|
1292
|
-
};
|
|
1293
|
-
type Table2Props<T> = Omit<React__default.TableHTMLAttributes<HTMLTableElement>, keyof BaseTable2Props<T>> & BaseTable2Props<T>;
|
|
1294
|
-
declare function Table2<T>({ columns, data, rowKey, zebra, sort, onSortChange, onRowClick, emptyMessage, className, ...rest }: Table2Props<T>): react_jsx_runtime.JSX.Element;
|
|
1295
|
-
|
|
1296
1272
|
type DataGridSortDirection = 'asc' | 'desc';
|
|
1297
1273
|
type DataGridSortState = {
|
|
1298
1274
|
key: string;
|
|
@@ -1630,38 +1606,6 @@ interface ContextMenuDelimiterProps {
|
|
|
1630
1606
|
}
|
|
1631
1607
|
declare const ContextMenuDelimiter: ({ className }: ContextMenuDelimiterProps) => react_jsx_runtime.JSX.Element;
|
|
1632
1608
|
|
|
1633
|
-
interface ListMenuProps {
|
|
1634
|
-
children: any;
|
|
1635
|
-
width?: number;
|
|
1636
|
-
className?: string;
|
|
1637
|
-
}
|
|
1638
|
-
declare const ListMenu: ({ children, className, width }: ListMenuProps) => react_jsx_runtime.JSX.Element;
|
|
1639
|
-
|
|
1640
|
-
type ListMenuItemBase = {
|
|
1641
|
-
active?: boolean;
|
|
1642
|
-
label?: string;
|
|
1643
|
-
count?: number;
|
|
1644
|
-
component?: React.ElementType;
|
|
1645
|
-
};
|
|
1646
|
-
type ListMenuItemAnchorProps = {
|
|
1647
|
-
href: string;
|
|
1648
|
-
onClick?: (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void;
|
|
1649
|
-
target?: '_blank' | '_self' | '_parent' | '_top';
|
|
1650
|
-
};
|
|
1651
|
-
type ListMenuItemButtonProps = {
|
|
1652
|
-
type?: 'button' | 'reset' | 'submit';
|
|
1653
|
-
onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
1654
|
-
};
|
|
1655
|
-
type ListMenuItemProps = ListMenuItemBase & (ListMenuItemAnchorProps | ListMenuItemButtonProps);
|
|
1656
|
-
declare const ListMenuItem: ({ component, active, label, count, ...props }: ListMenuItemProps) => react_jsx_runtime.JSX.Element;
|
|
1657
|
-
|
|
1658
|
-
interface ListMenuSectionProps {
|
|
1659
|
-
items: any;
|
|
1660
|
-
title?: string;
|
|
1661
|
-
className?: string;
|
|
1662
|
-
}
|
|
1663
|
-
declare const ListMenuSection: ({ title, items, className }: ListMenuSectionProps) => react_jsx_runtime.JSX.Element;
|
|
1664
|
-
|
|
1665
1609
|
interface EmptyDataProps {
|
|
1666
1610
|
children?: any;
|
|
1667
1611
|
title?: string;
|
|
@@ -2042,4 +1986,4 @@ interface ThemeProviderProps {
|
|
|
2042
1986
|
declare function ThemeProvider({ children, defaultTheme, storageKey, root, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
2043
1987
|
declare function useTheme(): ThemeContextValue;
|
|
2044
1988
|
|
|
2045
|
-
export { Alert, type BaseInputProps, Bone, type BoneProps, Box, Button, Button2, type Button2Props, type ButtonProps, type ButtonSize, type ButtonType, Checkbox, Checkbox2, type Checkbox2Props, type ColorToastVariant, type ColumnTable, Container, ContentLoader, type ContentLoaderProps, ContextMenu, ContextMenuChevron, ContextMenuDelimiter, CopyButton, type CopyButtonProps, Counter, type CounterProps, CounterTag, type CounterTagLevel, type CounterTagProps, DataGrid, type DataGridColumn, type DataGridProps, type DataGridSortDirection, type DataGridSortState, DatePicker, DatePicker2, DatePicker2Calendar, type DatePicker2Props, DatePickerCalendar, Drawer, Drawer2, Drawer2Body, type Drawer2BodyProps, Drawer2Close, type Drawer2CloseProps, Drawer2Footer, type Drawer2FooterProps, Drawer2Header, type Drawer2HeaderProps, type Drawer2Props, DrawerBody, DrawerHeader, DropdownMenu2, DropdownMenu2Item, type DropdownMenu2ItemProps, type DropdownMenu2ItemSize, DropdownMenu2List, type DropdownMenu2ListProps, type DropdownMenu2Props, EmptyData, type EmptyDataProps, FileField, type FileFieldProps, FileViewer, FullscreenCard, GlobalDropZone, Graph2D, type Graph2DProps, type Graph2DRef, type GraphData, type GraphState, Header, HeaderDelimeter, HeaderSection, IconButton2, type IconButton2Props, type IconButtonSize, type IconButtonType, Input, type InputElementProps, type InputProps, Label, Line, LinerProgress, Link, type LinkObject, type LinkProps,
|
|
1989
|
+
export { Alert, type BaseInputProps, Bone, type BoneProps, Box, Button, Button2, type Button2Props, type ButtonProps, type ButtonSize, type ButtonType, Checkbox, Checkbox2, type Checkbox2Props, type ColorToastVariant, type ColumnTable, Container, ContentLoader, type ContentLoaderProps, ContextMenu, ContextMenuChevron, ContextMenuDelimiter, CopyButton, type CopyButtonProps, Counter, type CounterProps, CounterTag, type CounterTagLevel, type CounterTagProps, DataGrid, type DataGridColumn, type DataGridProps, type DataGridSortDirection, type DataGridSortState, DatePicker, DatePicker2, DatePicker2Calendar, type DatePicker2Props, DatePickerCalendar, Drawer, Drawer2, Drawer2Body, type Drawer2BodyProps, Drawer2Close, type Drawer2CloseProps, Drawer2Footer, type Drawer2FooterProps, Drawer2Header, type Drawer2HeaderProps, type Drawer2Props, DrawerBody, DrawerHeader, DropdownMenu2, DropdownMenu2Item, type DropdownMenu2ItemProps, type DropdownMenu2ItemSize, DropdownMenu2List, type DropdownMenu2ListProps, type DropdownMenu2Props, EmptyData, type EmptyDataProps, FileField, type FileFieldProps, FileViewer, FullscreenCard, GlobalDropZone, Graph2D, type Graph2DProps, type Graph2DRef, type GraphData, type GraphState, Header, HeaderDelimeter, HeaderSection, IconButton2, type IconButton2Props, type IconButtonSize, type IconButtonType, Input, type InputElementProps, type InputProps, Label, Line, LinerProgress, Link, type LinkObject, type LinkProps, Masonry, type MasonryProps, Modal, Modal2, Modal2Body, type Modal2BodyProps, Modal2Close, type Modal2CloseProps, Modal2Footer, type Modal2FooterProps, Modal2Header, type Modal2HeaderProps, type Modal2Props, ModalBody, ModalFooter, ModalHeader, MultiSelect, MultiSelect2, type MultiSelect2AllOption, type MultiSelect2Props, type MultiSelectProps, type NodeButton, type NodeObject, Notification2, type Notification2Props, type Notification2Type, Overlay, Overlay2, type Overlay2Props, type OverlayProps, PageContent, PageLayout, Pagination, type PaginationProps, PhoneNumber2, type PhoneNumber2Meta, type PhoneNumber2Props, type PinSide, ProgressLoader, type RenderCellProps, type RenderHeaderCellProps, SearchInput2, type SearchInput2Props, Select, Select2, type Select2Group, type Select2Option, type Select2Props, type Select2RenderOption, type Select2RenderOptionContext, type Select2Value, Sidebar, Sidebar2, Sidebar2Context, type Sidebar2ContextValue, Sidebar2Divider, type Sidebar2DividerProps, Sidebar2Item, type Sidebar2ItemProps, type Sidebar2Props, Sidebar2Section, type Sidebar2SectionProps, SidebarContext, SidebarDelimeter, SidebarItem, type SidebarItemProps, type SidebarProps, SidebarSection, type SidebarSectionProps, SkeletonAvatar, type SkeletonAvatarProps, SkeletonRow, type SkeletonRowProps, SkeletonTextBlock, type SkeletonTextBlockProps, SourcesButton, type SourcesButtonProps, SpinnerLoader, type SpinnerLoaderProps, SplitterLayout, SubNav, type SupportedFileExtension, Switch, Table, Tabs2, Tabs2List, type Tabs2ListProps, Tabs2Panel, type Tabs2PanelProps, Tabs2Panels, type Tabs2PanelsProps, type Tabs2Props, Tabs2Tab, type Tabs2TabProps, Tag, Tag2, type Tag2Color, type Tag2Props, type Tag2Shape, type Tag2Wrap, TextArea2, type TextArea2Props, type TextAreaElementProps, TextInput2, type TextInput2Props, type Theme, ThemeProvider, type Toast, type ToastVariant, ToastsList, Tooltip, Tooltip2, type Tooltip2Props, type TooltipProps, Typewriter, VerticalNavigation, VerticalNavigationButton, type VerticalNavigationButtonProps, type VerticalNavigationItem, type VerticalNavigationProps, buttonVariants, useCopyToClipboard, useTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -417,17 +417,19 @@ declare const SearchInput2: React__default.ForwardRefExoticComponent<Omit<React_
|
|
|
417
417
|
rootClassName?: string;
|
|
418
418
|
} & React__default.RefAttributes<SearchInput2Element>>;
|
|
419
419
|
|
|
420
|
-
type
|
|
421
|
-
type
|
|
422
|
-
type?:
|
|
420
|
+
type VerticalNavigationButtonType = 'default' | 'treeview' | 'isLeaf';
|
|
421
|
+
type BaseVerticalNavigationButtonProps = {
|
|
422
|
+
type?: VerticalNavigationButtonType;
|
|
423
423
|
count?: number | string;
|
|
424
424
|
countLoading?: boolean;
|
|
425
|
+
/** Cap a numeric count at 99 → "99+". Defaults to true. */
|
|
426
|
+
capCount?: boolean;
|
|
425
427
|
selected?: boolean;
|
|
426
428
|
expanded?: boolean;
|
|
427
429
|
children?: React__default.ReactNode;
|
|
428
430
|
};
|
|
429
|
-
type
|
|
430
|
-
declare const
|
|
431
|
+
type VerticalNavigationButtonProps = Omit<React__default.ButtonHTMLAttributes<HTMLButtonElement>, keyof BaseVerticalNavigationButtonProps> & BaseVerticalNavigationButtonProps;
|
|
432
|
+
declare const VerticalNavigationButton: React__default.ForwardRefExoticComponent<Omit<React__default.ButtonHTMLAttributes<HTMLButtonElement>, keyof BaseVerticalNavigationButtonProps> & BaseVerticalNavigationButtonProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
431
433
|
|
|
432
434
|
interface BoneProps {
|
|
433
435
|
width?: number | string;
|
|
@@ -1209,6 +1211,8 @@ type BaseVerticalNavigationProps = {
|
|
|
1209
1211
|
defaultExpandedIds?: string[];
|
|
1210
1212
|
onExpandedChange?: (ids: string[]) => void;
|
|
1211
1213
|
collapsible?: boolean;
|
|
1214
|
+
/** Cap numeric item counts at 99 → "99+". Defaults to true. */
|
|
1215
|
+
capCount?: boolean;
|
|
1212
1216
|
};
|
|
1213
1217
|
type VerticalNavigationProps = Omit<React__default.HTMLAttributes<HTMLDivElement>, keyof BaseVerticalNavigationProps> & BaseVerticalNavigationProps;
|
|
1214
1218
|
declare const VerticalNavigation: React__default.ForwardRefExoticComponent<Omit<React__default.HTMLAttributes<HTMLDivElement>, keyof BaseVerticalNavigationProps> & BaseVerticalNavigationProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
@@ -1265,34 +1269,6 @@ interface TableProps {
|
|
|
1265
1269
|
}
|
|
1266
1270
|
declare const Table: ({ columns, rowCount, renderCell, renderHeaderCell, rowIds, hasHeader, hasBorder, cellPadding, className, columnWidths, onColumnResizeStart, activeResizeCol, }: TableProps) => react_jsx_runtime.JSX.Element;
|
|
1267
1271
|
|
|
1268
|
-
type Table2SortDirection = 'asc' | 'desc';
|
|
1269
|
-
type Table2SortState = {
|
|
1270
|
-
key: string;
|
|
1271
|
-
direction: Table2SortDirection;
|
|
1272
|
-
} | null;
|
|
1273
|
-
type Table2Column<T> = {
|
|
1274
|
-
key: string;
|
|
1275
|
-
header: React__default.ReactNode;
|
|
1276
|
-
accessor?: keyof T | ((row: T) => React__default.ReactNode);
|
|
1277
|
-
sortable?: boolean;
|
|
1278
|
-
width?: number | string;
|
|
1279
|
-
align?: 'left' | 'center' | 'right';
|
|
1280
|
-
className?: string;
|
|
1281
|
-
headerClassName?: string;
|
|
1282
|
-
};
|
|
1283
|
-
type BaseTable2Props<T> = {
|
|
1284
|
-
columns: Table2Column<T>[];
|
|
1285
|
-
data: T[];
|
|
1286
|
-
rowKey: (row: T, index: number) => React__default.Key;
|
|
1287
|
-
zebra?: boolean;
|
|
1288
|
-
sort?: Table2SortState;
|
|
1289
|
-
onSortChange?: (sort: Table2SortState) => void;
|
|
1290
|
-
onRowClick?: (row: T, index: number) => void;
|
|
1291
|
-
emptyMessage?: React__default.ReactNode;
|
|
1292
|
-
};
|
|
1293
|
-
type Table2Props<T> = Omit<React__default.TableHTMLAttributes<HTMLTableElement>, keyof BaseTable2Props<T>> & BaseTable2Props<T>;
|
|
1294
|
-
declare function Table2<T>({ columns, data, rowKey, zebra, sort, onSortChange, onRowClick, emptyMessage, className, ...rest }: Table2Props<T>): react_jsx_runtime.JSX.Element;
|
|
1295
|
-
|
|
1296
1272
|
type DataGridSortDirection = 'asc' | 'desc';
|
|
1297
1273
|
type DataGridSortState = {
|
|
1298
1274
|
key: string;
|
|
@@ -1630,38 +1606,6 @@ interface ContextMenuDelimiterProps {
|
|
|
1630
1606
|
}
|
|
1631
1607
|
declare const ContextMenuDelimiter: ({ className }: ContextMenuDelimiterProps) => react_jsx_runtime.JSX.Element;
|
|
1632
1608
|
|
|
1633
|
-
interface ListMenuProps {
|
|
1634
|
-
children: any;
|
|
1635
|
-
width?: number;
|
|
1636
|
-
className?: string;
|
|
1637
|
-
}
|
|
1638
|
-
declare const ListMenu: ({ children, className, width }: ListMenuProps) => react_jsx_runtime.JSX.Element;
|
|
1639
|
-
|
|
1640
|
-
type ListMenuItemBase = {
|
|
1641
|
-
active?: boolean;
|
|
1642
|
-
label?: string;
|
|
1643
|
-
count?: number;
|
|
1644
|
-
component?: React.ElementType;
|
|
1645
|
-
};
|
|
1646
|
-
type ListMenuItemAnchorProps = {
|
|
1647
|
-
href: string;
|
|
1648
|
-
onClick?: (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void;
|
|
1649
|
-
target?: '_blank' | '_self' | '_parent' | '_top';
|
|
1650
|
-
};
|
|
1651
|
-
type ListMenuItemButtonProps = {
|
|
1652
|
-
type?: 'button' | 'reset' | 'submit';
|
|
1653
|
-
onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
1654
|
-
};
|
|
1655
|
-
type ListMenuItemProps = ListMenuItemBase & (ListMenuItemAnchorProps | ListMenuItemButtonProps);
|
|
1656
|
-
declare const ListMenuItem: ({ component, active, label, count, ...props }: ListMenuItemProps) => react_jsx_runtime.JSX.Element;
|
|
1657
|
-
|
|
1658
|
-
interface ListMenuSectionProps {
|
|
1659
|
-
items: any;
|
|
1660
|
-
title?: string;
|
|
1661
|
-
className?: string;
|
|
1662
|
-
}
|
|
1663
|
-
declare const ListMenuSection: ({ title, items, className }: ListMenuSectionProps) => react_jsx_runtime.JSX.Element;
|
|
1664
|
-
|
|
1665
1609
|
interface EmptyDataProps {
|
|
1666
1610
|
children?: any;
|
|
1667
1611
|
title?: string;
|
|
@@ -2042,4 +1986,4 @@ interface ThemeProviderProps {
|
|
|
2042
1986
|
declare function ThemeProvider({ children, defaultTheme, storageKey, root, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
2043
1987
|
declare function useTheme(): ThemeContextValue;
|
|
2044
1988
|
|
|
2045
|
-
export { Alert, type BaseInputProps, Bone, type BoneProps, Box, Button, Button2, type Button2Props, type ButtonProps, type ButtonSize, type ButtonType, Checkbox, Checkbox2, type Checkbox2Props, type ColorToastVariant, type ColumnTable, Container, ContentLoader, type ContentLoaderProps, ContextMenu, ContextMenuChevron, ContextMenuDelimiter, CopyButton, type CopyButtonProps, Counter, type CounterProps, CounterTag, type CounterTagLevel, type CounterTagProps, DataGrid, type DataGridColumn, type DataGridProps, type DataGridSortDirection, type DataGridSortState, DatePicker, DatePicker2, DatePicker2Calendar, type DatePicker2Props, DatePickerCalendar, Drawer, Drawer2, Drawer2Body, type Drawer2BodyProps, Drawer2Close, type Drawer2CloseProps, Drawer2Footer, type Drawer2FooterProps, Drawer2Header, type Drawer2HeaderProps, type Drawer2Props, DrawerBody, DrawerHeader, DropdownMenu2, DropdownMenu2Item, type DropdownMenu2ItemProps, type DropdownMenu2ItemSize, DropdownMenu2List, type DropdownMenu2ListProps, type DropdownMenu2Props, EmptyData, type EmptyDataProps, FileField, type FileFieldProps, FileViewer, FullscreenCard, GlobalDropZone, Graph2D, type Graph2DProps, type Graph2DRef, type GraphData, type GraphState, Header, HeaderDelimeter, HeaderSection, IconButton2, type IconButton2Props, type IconButtonSize, type IconButtonType, Input, type InputElementProps, type InputProps, Label, Line, LinerProgress, Link, type LinkObject, type LinkProps,
|
|
1989
|
+
export { Alert, type BaseInputProps, Bone, type BoneProps, Box, Button, Button2, type Button2Props, type ButtonProps, type ButtonSize, type ButtonType, Checkbox, Checkbox2, type Checkbox2Props, type ColorToastVariant, type ColumnTable, Container, ContentLoader, type ContentLoaderProps, ContextMenu, ContextMenuChevron, ContextMenuDelimiter, CopyButton, type CopyButtonProps, Counter, type CounterProps, CounterTag, type CounterTagLevel, type CounterTagProps, DataGrid, type DataGridColumn, type DataGridProps, type DataGridSortDirection, type DataGridSortState, DatePicker, DatePicker2, DatePicker2Calendar, type DatePicker2Props, DatePickerCalendar, Drawer, Drawer2, Drawer2Body, type Drawer2BodyProps, Drawer2Close, type Drawer2CloseProps, Drawer2Footer, type Drawer2FooterProps, Drawer2Header, type Drawer2HeaderProps, type Drawer2Props, DrawerBody, DrawerHeader, DropdownMenu2, DropdownMenu2Item, type DropdownMenu2ItemProps, type DropdownMenu2ItemSize, DropdownMenu2List, type DropdownMenu2ListProps, type DropdownMenu2Props, EmptyData, type EmptyDataProps, FileField, type FileFieldProps, FileViewer, FullscreenCard, GlobalDropZone, Graph2D, type Graph2DProps, type Graph2DRef, type GraphData, type GraphState, Header, HeaderDelimeter, HeaderSection, IconButton2, type IconButton2Props, type IconButtonSize, type IconButtonType, Input, type InputElementProps, type InputProps, Label, Line, LinerProgress, Link, type LinkObject, type LinkProps, Masonry, type MasonryProps, Modal, Modal2, Modal2Body, type Modal2BodyProps, Modal2Close, type Modal2CloseProps, Modal2Footer, type Modal2FooterProps, Modal2Header, type Modal2HeaderProps, type Modal2Props, ModalBody, ModalFooter, ModalHeader, MultiSelect, MultiSelect2, type MultiSelect2AllOption, type MultiSelect2Props, type MultiSelectProps, type NodeButton, type NodeObject, Notification2, type Notification2Props, type Notification2Type, Overlay, Overlay2, type Overlay2Props, type OverlayProps, PageContent, PageLayout, Pagination, type PaginationProps, PhoneNumber2, type PhoneNumber2Meta, type PhoneNumber2Props, type PinSide, ProgressLoader, type RenderCellProps, type RenderHeaderCellProps, SearchInput2, type SearchInput2Props, Select, Select2, type Select2Group, type Select2Option, type Select2Props, type Select2RenderOption, type Select2RenderOptionContext, type Select2Value, Sidebar, Sidebar2, Sidebar2Context, type Sidebar2ContextValue, Sidebar2Divider, type Sidebar2DividerProps, Sidebar2Item, type Sidebar2ItemProps, type Sidebar2Props, Sidebar2Section, type Sidebar2SectionProps, SidebarContext, SidebarDelimeter, SidebarItem, type SidebarItemProps, type SidebarProps, SidebarSection, type SidebarSectionProps, SkeletonAvatar, type SkeletonAvatarProps, SkeletonRow, type SkeletonRowProps, SkeletonTextBlock, type SkeletonTextBlockProps, SourcesButton, type SourcesButtonProps, SpinnerLoader, type SpinnerLoaderProps, SplitterLayout, SubNav, type SupportedFileExtension, Switch, Table, Tabs2, Tabs2List, type Tabs2ListProps, Tabs2Panel, type Tabs2PanelProps, Tabs2Panels, type Tabs2PanelsProps, type Tabs2Props, Tabs2Tab, type Tabs2TabProps, Tag, Tag2, type Tag2Color, type Tag2Props, type Tag2Shape, type Tag2Wrap, TextArea2, type TextArea2Props, type TextAreaElementProps, TextInput2, type TextInput2Props, type Theme, ThemeProvider, type Toast, type ToastVariant, ToastsList, Tooltip, Tooltip2, type Tooltip2Props, type TooltipProps, Typewriter, VerticalNavigation, VerticalNavigationButton, type VerticalNavigationButtonProps, type VerticalNavigationItem, type VerticalNavigationProps, buttonVariants, useCopyToClipboard, useTheme };
|