@osdk/react-components 0.56.0 → 0.57.0-main-9c5a7b17bd0a71c88bf2d3ed29847e6f87975bbf
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/AGENTS.md +19 -14
- package/CHANGELOG.md +55 -0
- package/README.md +3 -3
- package/action-form.d.ts +17 -0
- package/build/browser/pdf-viewer/BasePdfViewer.js +12 -8
- package/build/browser/pdf-viewer/BasePdfViewer.js.map +1 -1
- package/build/browser/pdf-viewer/PdfViewerApi.js.map +1 -1
- package/build/browser/pdf-viewer/PdfViewerContext.js +4 -0
- package/build/browser/pdf-viewer/PdfViewerContext.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerContent.js +6 -2
- package/build/browser/pdf-viewer/components/PdfViewerContent.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js +10 -4
- package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfViewerState.js +9 -1
- package/build/browser/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
- package/build/browser/public/action-form.js +21 -0
- package/build/browser/public/action-form.js.map +1 -0
- package/build/browser/public/document-viewer.js +22 -0
- package/build/browser/public/document-viewer.js.map +1 -0
- package/build/browser/public/email-viewer.js +23 -0
- package/build/browser/public/email-viewer.js.map +1 -0
- package/build/browser/public/experimental/action-form.js +60 -5
- package/build/browser/public/experimental/action-form.js.map +1 -1
- package/build/browser/public/experimental/document-viewer.js +11 -5
- package/build/browser/public/experimental/document-viewer.js.map +1 -1
- package/build/browser/public/experimental/email-viewer.js +15 -6
- package/build/browser/public/experimental/email-viewer.js.map +1 -1
- package/build/browser/public/experimental/filter-list.js +71 -14
- package/build/browser/public/experimental/filter-list.js.map +1 -1
- package/build/browser/public/experimental/image-viewer.js +11 -6
- package/build/browser/public/experimental/image-viewer.js.map +1 -1
- package/build/browser/public/experimental/markdown-renderer.js +11 -17
- package/build/browser/public/experimental/markdown-renderer.js.map +1 -1
- package/build/browser/public/experimental/object-table.js +152 -37
- package/build/browser/public/experimental/object-table.js.map +1 -1
- package/build/browser/public/experimental/pdf-viewer.js +134 -34
- package/build/browser/public/experimental/pdf-viewer.js.map +1 -1
- package/build/browser/public/experimental/spreadsheet-viewer.js +15 -6
- package/build/browser/public/experimental/spreadsheet-viewer.js.map +1 -1
- package/build/browser/public/experimental/tiff-renderer.js +11 -17
- package/build/browser/public/experimental/tiff-renderer.js.map +1 -1
- package/build/browser/public/experimental/video-viewer.js +11 -6
- package/build/browser/public/experimental/video-viewer.js.map +1 -1
- package/build/browser/public/experimental/xml-viewer.js +11 -6
- package/build/browser/public/experimental/xml-viewer.js.map +1 -1
- package/build/browser/public/filter-list.js +30 -0
- package/build/browser/public/filter-list.js.map +1 -0
- package/build/browser/public/image-viewer.js +23 -0
- package/build/browser/public/image-viewer.js.map +1 -0
- package/build/browser/public/markdown-viewer.js +24 -0
- package/build/browser/public/markdown-viewer.js.map +1 -0
- package/build/browser/public/object-table.js +65 -0
- package/build/browser/public/object-table.js.map +1 -0
- package/build/browser/public/pdf-viewer.js +50 -0
- package/build/browser/public/pdf-viewer.js.map +1 -0
- package/build/browser/public/spreadsheet-viewer.js +23 -0
- package/build/browser/public/spreadsheet-viewer.js.map +1 -0
- package/build/browser/public/tiff-viewer.js +24 -0
- package/build/browser/public/tiff-viewer.js.map +1 -0
- package/build/browser/public/video-viewer.js +23 -0
- package/build/browser/public/video-viewer.js.map +1 -0
- package/build/browser/public/xml-viewer.js +23 -0
- package/build/browser/public/xml-viewer.js.map +1 -0
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/cjs/{PdfViewerApi-CQJlwPUl.d.cts → PdfViewerApi-CIpvxxUo.d.cts} +9 -1
- package/build/cjs/action-form-4OvVNZ6i.d.cts +791 -0
- package/build/cjs/chunk-36QJAKOY.cjs +13 -0
- package/build/cjs/chunk-36QJAKOY.cjs.map +1 -0
- package/build/cjs/{chunk-HVJTECCC.cjs → chunk-4KHF42ZL.cjs} +34 -15
- package/build/cjs/chunk-4KHF42ZL.cjs.map +1 -0
- package/build/cjs/chunk-5KVF4DSH.cjs +53 -0
- package/build/cjs/chunk-5KVF4DSH.cjs.map +1 -0
- package/build/cjs/{chunk-L2FCT7HW.cjs → chunk-6YNO7HDC.cjs} +4 -4
- package/build/cjs/{chunk-L2FCT7HW.cjs.map → chunk-6YNO7HDC.cjs.map} +1 -1
- package/build/cjs/{chunk-JHKAQXRZ.cjs → chunk-7IP4YOC6.cjs} +5 -5
- package/build/cjs/chunk-7IP4YOC6.cjs.map +1 -0
- package/build/cjs/chunk-A3GEXM7R.cjs +48 -0
- package/build/cjs/chunk-A3GEXM7R.cjs.map +1 -0
- package/build/cjs/chunk-AWSDHTVF.cjs +11 -0
- package/build/cjs/chunk-AWSDHTVF.cjs.map +1 -0
- package/build/cjs/chunk-BPRRM7TQ.cjs +12 -0
- package/build/cjs/chunk-BPRRM7TQ.cjs.map +1 -0
- package/build/cjs/chunk-DZLFOD3V.cjs +12 -0
- package/build/cjs/chunk-DZLFOD3V.cjs.map +1 -0
- package/build/cjs/{chunk-DJNKQI5C.cjs → chunk-GCAQEFD6.cjs} +35 -27
- package/build/cjs/chunk-GCAQEFD6.cjs.map +1 -0
- package/build/cjs/chunk-IBDBFMEQ.cjs +13 -0
- package/build/cjs/chunk-IBDBFMEQ.cjs.map +1 -0
- package/build/cjs/chunk-IFBNWYYC.cjs +11 -0
- package/build/cjs/chunk-IFBNWYYC.cjs.map +1 -0
- package/build/cjs/chunk-JCCZWVY3.cjs +13 -0
- package/build/cjs/chunk-JCCZWVY3.cjs.map +1 -0
- package/build/cjs/{chunk-BBXX42YT.cjs → chunk-L4PLQPV2.cjs} +12 -12
- package/build/cjs/chunk-L4PLQPV2.cjs.map +1 -0
- package/build/cjs/chunk-MDVEVGFJ.cjs +11 -0
- package/build/cjs/chunk-MDVEVGFJ.cjs.map +1 -0
- package/build/cjs/chunk-OJTBEZKG.cjs +11 -0
- package/build/cjs/chunk-OJTBEZKG.cjs.map +1 -0
- package/build/cjs/{chunk-ABT6IGXN.cjs → chunk-RPEXVMQG.cjs} +7 -7
- package/build/cjs/chunk-RPEXVMQG.cjs.map +1 -0
- package/build/cjs/{chunk-RDJK72SG.cjs → chunk-RZOLA2GI.cjs} +10 -10
- package/build/cjs/chunk-RZOLA2GI.cjs.map +1 -0
- package/build/cjs/{chunk-6RCVPIW5.cjs → chunk-U7FYMS5T.cjs} +3 -3
- package/build/cjs/chunk-U7FYMS5T.cjs.map +1 -0
- package/build/cjs/chunk-UAKUGVQW.cjs +17 -0
- package/build/cjs/chunk-UAKUGVQW.cjs.map +1 -0
- package/build/cjs/chunk-UQGEGHHQ.cjs +34 -0
- package/build/cjs/chunk-UQGEGHHQ.cjs.map +1 -0
- package/build/cjs/chunk-VLADVYGE.cjs +13 -0
- package/build/cjs/chunk-VLADVYGE.cjs.map +1 -0
- package/build/cjs/chunk-VYLMJUGV.cjs +17 -0
- package/build/cjs/chunk-VYLMJUGV.cjs.map +1 -0
- package/build/cjs/chunk-VZ2OSX6A.cjs +11 -0
- package/build/cjs/chunk-VZ2OSX6A.cjs.map +1 -0
- package/build/cjs/chunk-XE7JD6LH.cjs +13 -0
- package/build/cjs/chunk-XE7JD6LH.cjs.map +1 -0
- package/build/cjs/chunk-XQHT3TQO.cjs +11 -0
- package/build/cjs/chunk-XQHT3TQO.cjs.map +1 -0
- package/build/cjs/chunk-YE6XEEAZ.cjs +11 -0
- package/build/cjs/chunk-YE6XEEAZ.cjs.map +1 -0
- package/build/cjs/filter-list-CraygbR8.d.cts +976 -0
- package/build/cjs/public/action-form.cjs +27 -0
- package/build/cjs/public/action-form.cjs.map +1 -0
- package/build/cjs/public/action-form.css +1668 -0
- package/build/cjs/public/action-form.css.map +1 -0
- package/build/cjs/public/action-form.d.cts +3 -0
- package/build/cjs/public/document-viewer.cjs +28 -0
- package/build/cjs/public/document-viewer.cjs.map +1 -0
- package/build/cjs/public/document-viewer.css +914 -0
- package/build/cjs/public/document-viewer.css.map +1 -0
- package/build/cjs/public/document-viewer.d.cts +57 -0
- package/build/cjs/public/email-viewer.cjs +20 -0
- package/build/cjs/public/email-viewer.cjs.map +1 -0
- package/build/cjs/public/email-viewer.css +81 -0
- package/build/cjs/public/email-viewer.css.map +1 -0
- package/build/cjs/public/email-viewer.d.cts +37 -0
- package/build/cjs/public/experimental/action-form.cjs +7 -6
- package/build/cjs/public/experimental/action-form.d.cts +58 -787
- package/build/cjs/public/experimental/cbac-picker.cjs +12 -12
- package/build/cjs/public/experimental/document-viewer.cjs +10 -9
- package/build/cjs/public/experimental/document-viewer.d.cts +14 -53
- package/build/cjs/public/experimental/email-viewer.cjs +8 -7
- package/build/cjs/public/experimental/email-viewer.d.cts +14 -33
- package/build/cjs/public/experimental/filter-list.cjs +17 -16
- package/build/cjs/public/experimental/filter-list.d.cts +59 -973
- package/build/cjs/public/experimental/image-viewer.cjs +8 -7
- package/build/cjs/public/experimental/image-viewer.d.cts +11 -7
- package/build/cjs/public/experimental/markdown-renderer.cjs +11 -10
- package/build/cjs/public/experimental/markdown-renderer.d.cts +13 -20
- package/build/cjs/public/experimental/object-table.cjs +28 -27
- package/build/cjs/public/experimental/object-table.d.cts +148 -1228
- package/build/cjs/public/experimental/pdf-viewer.cjs +38 -37
- package/build/cjs/public/experimental/pdf-viewer.d.cts +115 -344
- package/build/cjs/public/experimental/spreadsheet-viewer.cjs +8 -7
- package/build/cjs/public/experimental/spreadsheet-viewer.d.cts +14 -30
- package/build/cjs/public/experimental/tiff-renderer.cjs +11 -10
- package/build/cjs/public/experimental/tiff-renderer.d.cts +14 -10
- package/build/cjs/public/experimental/video-viewer.cjs +8 -7
- package/build/cjs/public/experimental/video-viewer.d.cts +11 -7
- package/build/cjs/public/experimental/xml-viewer.cjs +8 -7
- package/build/cjs/public/experimental/xml-viewer.d.cts +11 -19
- package/build/cjs/public/experimental.cjs +221 -209
- package/build/cjs/public/experimental.d.cts +21 -9
- package/build/cjs/public/filter-list.cjs +71 -0
- package/build/cjs/public/filter-list.cjs.map +1 -0
- package/build/cjs/public/filter-list.css +2414 -0
- package/build/cjs/public/filter-list.css.map +1 -0
- package/build/cjs/public/filter-list.d.cts +3 -0
- package/build/cjs/public/image-viewer.cjs +20 -0
- package/build/cjs/public/image-viewer.cjs.map +1 -0
- package/build/cjs/public/image-viewer.css +30 -0
- package/build/cjs/public/image-viewer.css.map +1 -0
- package/build/cjs/public/image-viewer.d.cts +11 -0
- package/build/cjs/public/markdown-viewer.cjs +20 -0
- package/build/cjs/public/markdown-viewer.cjs.map +1 -0
- package/build/cjs/public/markdown-viewer.css +117 -0
- package/build/cjs/public/markdown-viewer.css.map +1 -0
- package/build/cjs/public/markdown-viewer.d.cts +21 -0
- package/build/cjs/public/object-table.cjs +101 -0
- package/build/cjs/public/object-table.cjs.map +1 -0
- package/build/cjs/public/object-table.css +2201 -0
- package/build/cjs/public/object-table.css.map +1 -0
- package/build/cjs/public/object-table.d.cts +1231 -0
- package/build/cjs/public/pdf-viewer.cjs +99 -0
- package/build/cjs/public/pdf-viewer.cjs.map +1 -0
- package/build/cjs/public/pdf-viewer.css +442 -0
- package/build/cjs/public/pdf-viewer.css.map +1 -0
- package/build/cjs/public/pdf-viewer.d.cts +360 -0
- package/build/cjs/public/primitives.cjs +1 -1
- package/build/cjs/public/spreadsheet-viewer.cjs +20 -0
- package/build/cjs/public/spreadsheet-viewer.cjs.map +1 -0
- package/build/cjs/public/spreadsheet-viewer.css +122 -0
- package/build/cjs/public/spreadsheet-viewer.css.map +1 -0
- package/build/cjs/public/spreadsheet-viewer.d.cts +34 -0
- package/build/cjs/public/tiff-viewer.cjs +20 -0
- package/build/cjs/public/tiff-viewer.cjs.map +1 -0
- package/build/cjs/public/tiff-viewer.css +23 -0
- package/build/cjs/public/tiff-viewer.css.map +1 -0
- package/build/cjs/public/tiff-viewer.d.cts +11 -0
- package/build/cjs/public/video-viewer.cjs +20 -0
- package/build/cjs/public/video-viewer.cjs.map +1 -0
- package/build/cjs/public/video-viewer.css +29 -0
- package/build/cjs/public/video-viewer.css.map +1 -0
- package/build/cjs/public/video-viewer.d.cts +11 -0
- package/build/cjs/public/xml-viewer.cjs +20 -0
- package/build/cjs/public/xml-viewer.cjs.map +1 -0
- package/build/cjs/public/xml-viewer.css +38 -0
- package/build/cjs/public/xml-viewer.css.map +1 -0
- package/build/cjs/public/xml-viewer.d.cts +22 -0
- package/build/esm/pdf-viewer/BasePdfViewer.js +12 -8
- package/build/esm/pdf-viewer/BasePdfViewer.js.map +1 -1
- package/build/esm/pdf-viewer/PdfViewerApi.js.map +1 -1
- package/build/esm/pdf-viewer/PdfViewerContext.js +4 -0
- package/build/esm/pdf-viewer/PdfViewerContext.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerContent.js +6 -2
- package/build/esm/pdf-viewer/components/PdfViewerContent.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js +10 -4
- package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfViewerState.js +9 -1
- package/build/esm/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
- package/build/esm/public/action-form.js +21 -0
- package/build/esm/public/action-form.js.map +1 -0
- package/build/esm/public/document-viewer.js +22 -0
- package/build/esm/public/document-viewer.js.map +1 -0
- package/build/esm/public/email-viewer.js +23 -0
- package/build/esm/public/email-viewer.js.map +1 -0
- package/build/esm/public/experimental/action-form.js +60 -5
- package/build/esm/public/experimental/action-form.js.map +1 -1
- package/build/esm/public/experimental/document-viewer.js +11 -5
- package/build/esm/public/experimental/document-viewer.js.map +1 -1
- package/build/esm/public/experimental/email-viewer.js +15 -6
- package/build/esm/public/experimental/email-viewer.js.map +1 -1
- package/build/esm/public/experimental/filter-list.js +71 -14
- package/build/esm/public/experimental/filter-list.js.map +1 -1
- package/build/esm/public/experimental/image-viewer.js +11 -6
- package/build/esm/public/experimental/image-viewer.js.map +1 -1
- package/build/esm/public/experimental/markdown-renderer.js +11 -17
- package/build/esm/public/experimental/markdown-renderer.js.map +1 -1
- package/build/esm/public/experimental/object-table.js +152 -37
- package/build/esm/public/experimental/object-table.js.map +1 -1
- package/build/esm/public/experimental/pdf-viewer.js +134 -34
- package/build/esm/public/experimental/pdf-viewer.js.map +1 -1
- package/build/esm/public/experimental/spreadsheet-viewer.js +15 -6
- package/build/esm/public/experimental/spreadsheet-viewer.js.map +1 -1
- package/build/esm/public/experimental/tiff-renderer.js +11 -17
- package/build/esm/public/experimental/tiff-renderer.js.map +1 -1
- package/build/esm/public/experimental/video-viewer.js +11 -6
- package/build/esm/public/experimental/video-viewer.js.map +1 -1
- package/build/esm/public/experimental/xml-viewer.js +11 -6
- package/build/esm/public/experimental/xml-viewer.js.map +1 -1
- package/build/esm/public/filter-list.js +30 -0
- package/build/esm/public/filter-list.js.map +1 -0
- package/build/esm/public/image-viewer.js +23 -0
- package/build/esm/public/image-viewer.js.map +1 -0
- package/build/esm/public/markdown-viewer.js +24 -0
- package/build/esm/public/markdown-viewer.js.map +1 -0
- package/build/esm/public/object-table.js +65 -0
- package/build/esm/public/object-table.js.map +1 -0
- package/build/esm/public/pdf-viewer.js +50 -0
- package/build/esm/public/pdf-viewer.js.map +1 -0
- package/build/esm/public/spreadsheet-viewer.js +23 -0
- package/build/esm/public/spreadsheet-viewer.js.map +1 -0
- package/build/esm/public/tiff-viewer.js +24 -0
- package/build/esm/public/tiff-viewer.js.map +1 -0
- package/build/esm/public/video-viewer.js +23 -0
- package/build/esm/public/video-viewer.js.map +1 -0
- package/build/esm/public/xml-viewer.js +23 -0
- package/build/esm/public/xml-viewer.js.map +1 -0
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/types/pdf-viewer/PdfViewerApi.d.ts +9 -1
- package/build/types/pdf-viewer/PdfViewerApi.d.ts.map +1 -1
- package/build/types/pdf-viewer/components/PdfViewerContent.d.ts +5 -1
- package/build/types/pdf-viewer/components/PdfViewerContent.d.ts.map +1 -1
- package/build/types/pdf-viewer/hooks/usePdfViewerCore.d.ts +7 -1
- package/build/types/pdf-viewer/hooks/usePdfViewerCore.d.ts.map +1 -1
- package/build/types/pdf-viewer/hooks/usePdfViewerState.d.ts +3 -1
- package/build/types/pdf-viewer/hooks/usePdfViewerState.d.ts.map +1 -1
- package/build/types/public/action-form.d.ts +5 -0
- package/build/types/public/action-form.d.ts.map +1 -0
- package/build/types/public/document-viewer.d.ts +4 -0
- package/build/types/public/document-viewer.d.ts.map +1 -0
- package/build/types/public/email-viewer.d.ts +4 -0
- package/build/types/public/email-viewer.d.ts.map +1 -0
- package/build/types/public/experimental/action-form.d.ts +68 -5
- package/build/types/public/experimental/action-form.d.ts.map +1 -1
- package/build/types/public/experimental/document-viewer.d.ts +9 -4
- package/build/types/public/experimental/document-viewer.d.ts.map +1 -1
- package/build/types/public/experimental/email-viewer.d.ts +13 -4
- package/build/types/public/experimental/email-viewer.d.ts.map +1 -1
- package/build/types/public/experimental/filter-list.d.ts +63 -19
- package/build/types/public/experimental/filter-list.d.ts.map +1 -1
- package/build/types/public/experimental/image-viewer.d.ts +9 -4
- package/build/types/public/experimental/image-viewer.d.ts.map +1 -1
- package/build/types/public/experimental/markdown-renderer.d.ts +12 -9
- package/build/types/public/experimental/markdown-renderer.d.ts.map +1 -1
- package/build/types/public/experimental/object-table.d.ts +235 -29
- package/build/types/public/experimental/object-table.d.ts.map +1 -1
- package/build/types/public/experimental/pdf-viewer.d.ts +111 -25
- package/build/types/public/experimental/pdf-viewer.d.ts.map +1 -1
- package/build/types/public/experimental/spreadsheet-viewer.d.ts +13 -4
- package/build/types/public/experimental/spreadsheet-viewer.d.ts.map +1 -1
- package/build/types/public/experimental/tiff-renderer.d.ts +12 -9
- package/build/types/public/experimental/tiff-renderer.d.ts.map +1 -1
- package/build/types/public/experimental/video-viewer.d.ts +9 -4
- package/build/types/public/experimental/video-viewer.d.ts.map +1 -1
- package/build/types/public/experimental/xml-viewer.d.ts +9 -4
- package/build/types/public/experimental/xml-viewer.d.ts.map +1 -1
- package/build/types/public/filter-list.d.ts +19 -0
- package/build/types/public/filter-list.d.ts.map +1 -0
- package/build/types/public/image-viewer.d.ts +4 -0
- package/build/types/public/image-viewer.d.ts.map +1 -0
- package/build/types/public/markdown-viewer.d.ts +4 -0
- package/build/types/public/markdown-viewer.d.ts.map +1 -0
- package/build/types/public/object-table.d.ts +29 -0
- package/build/types/public/object-table.d.ts.map +1 -0
- package/build/types/public/pdf-viewer.d.ts +25 -0
- package/build/types/public/pdf-viewer.d.ts.map +1 -0
- package/build/types/public/spreadsheet-viewer.d.ts +4 -0
- package/build/types/public/spreadsheet-viewer.d.ts.map +1 -0
- package/build/types/public/tiff-viewer.d.ts +4 -0
- package/build/types/public/tiff-viewer.d.ts.map +1 -0
- package/build/types/public/video-viewer.d.ts +4 -0
- package/build/types/public/video-viewer.d.ts.map +1 -0
- package/build/types/public/xml-viewer.d.ts +4 -0
- package/build/types/public/xml-viewer.d.ts.map +1 -0
- package/docs/ActionForm.md +3 -3
- package/docs/ActionFormOverview.md +3 -3
- package/docs/DocumentViewer.md +3 -3
- package/docs/DocumentViewerOverview.md +8 -8
- package/docs/EmailViewer.md +3 -3
- package/docs/FilterList.md +6 -6
- package/docs/FilterListOverview.md +3 -3
- package/docs/GettingStarted.md +1 -1
- package/docs/ImageViewer.md +3 -3
- package/docs/MarkdownViewer.md +3 -3
- package/docs/ObjectTable.md +23 -23
- package/docs/ObjectTableOverview.md +3 -3
- package/docs/PdfViewer.md +16 -19
- package/docs/SpreadsheetViewer.md +3 -3
- package/docs/TiffViewer.md +3 -6
- package/docs/VideoViewer.md +3 -3
- package/docs/Welcome.md +2 -2
- package/docs/XmlViewer.md +3 -6
- package/document-viewer.d.ts +17 -0
- package/email-viewer.d.ts +17 -0
- package/filter-list.d.ts +17 -0
- package/image-viewer.d.ts +17 -0
- package/markdown-viewer.d.ts +17 -0
- package/object-table.d.ts +17 -0
- package/package.json +116 -8
- package/pdf-viewer.d.ts +17 -0
- package/spreadsheet-viewer.d.ts +17 -0
- package/tiff-viewer.d.ts +17 -0
- package/video-viewer.d.ts +17 -0
- package/xml-viewer.d.ts +17 -0
- package/build/cjs/chunk-2UJNMXVL.cjs +0 -15
- package/build/cjs/chunk-2UJNMXVL.cjs.map +0 -1
- package/build/cjs/chunk-4F5VJN66.cjs +0 -11
- package/build/cjs/chunk-4F5VJN66.cjs.map +0 -1
- package/build/cjs/chunk-6RCVPIW5.cjs.map +0 -1
- package/build/cjs/chunk-A5ZKDZH4.cjs +0 -11
- package/build/cjs/chunk-A5ZKDZH4.cjs.map +0 -1
- package/build/cjs/chunk-ABT6IGXN.cjs.map +0 -1
- package/build/cjs/chunk-BBXX42YT.cjs.map +0 -1
- package/build/cjs/chunk-CR5S7BJM.cjs +0 -11
- package/build/cjs/chunk-CR5S7BJM.cjs.map +0 -1
- package/build/cjs/chunk-DJNKQI5C.cjs.map +0 -1
- package/build/cjs/chunk-HVJTECCC.cjs.map +0 -1
- package/build/cjs/chunk-JDKKKXMF.cjs +0 -15
- package/build/cjs/chunk-JDKKKXMF.cjs.map +0 -1
- package/build/cjs/chunk-JHKAQXRZ.cjs.map +0 -1
- package/build/cjs/chunk-RDJK72SG.cjs.map +0 -1
- package/build/cjs/chunk-S4DLEUUJ.cjs +0 -11
- package/build/cjs/chunk-S4DLEUUJ.cjs.map +0 -1
- package/build/cjs/chunk-ULVTAKJF.cjs +0 -11
- package/build/cjs/chunk-ULVTAKJF.cjs.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -36,21 +36,26 @@ See `@osdk/react`'s `AGENTS.md` for optional peers (`@osdk/foundry.admin`, `@osd
|
|
|
36
36
|
|
|
37
37
|
## Components
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
- `@osdk/react-components/
|
|
42
|
-
- `@osdk/react-components/
|
|
43
|
-
- `@osdk/react-components/
|
|
44
|
-
- `@osdk/react-components/
|
|
45
|
-
- `@osdk/react-components/
|
|
46
|
-
- `@osdk/react-components/
|
|
39
|
+
Promoted components are imported from stable individual entry points:
|
|
40
|
+
|
|
41
|
+
- `@osdk/react-components/object-table` — ObjectTable, BaseTable, ColumnConfigDialog
|
|
42
|
+
- `@osdk/react-components/filter-list` — FilterList, BaseFilterList
|
|
43
|
+
- `@osdk/react-components/action-form` — ActionForm, BaseForm, and form field definitions
|
|
44
|
+
- `@osdk/react-components/pdf-viewer` — PdfViewer, BasePdfViewer, and building blocks/hooks
|
|
45
|
+
- `@osdk/react-components/tiff-viewer` — TiffViewer, BaseTiffViewer
|
|
46
|
+
- `@osdk/react-components/markdown-viewer` — MarkdownViewer, BaseMarkdownViewer
|
|
47
|
+
- `@osdk/react-components/document-viewer` — DocumentViewer
|
|
48
|
+
- `@osdk/react-components/email-viewer` — EmailViewer, BaseEmailViewer
|
|
49
|
+
- `@osdk/react-components/spreadsheet-viewer` — SpreadsheetViewer, BaseSpreadsheetViewer
|
|
50
|
+
- `@osdk/react-components/image-viewer` — ImageViewer, BaseImageViewer
|
|
51
|
+
- `@osdk/react-components/video-viewer` — VideoViewer, BaseVideoViewer
|
|
52
|
+
- `@osdk/react-components/xml-viewer` — XmlViewer, BaseXmlViewer
|
|
53
|
+
|
|
54
|
+
Components not yet promoted remain under `experimental/`:
|
|
55
|
+
|
|
47
56
|
- `@osdk/react-components/experimental/aip-agent-chat` — AipAgentChat, BaseAipAgentChat
|
|
48
|
-
- `@osdk/react-components/experimental/
|
|
49
|
-
- `@osdk/react-components/experimental/
|
|
50
|
-
- `@osdk/react-components/experimental/spreadsheet-viewer` — SpreadsheetViewer, BaseSpreadsheetViewer
|
|
51
|
-
- `@osdk/react-components/experimental/image-viewer` — ImageViewer, BaseImageViewer
|
|
52
|
-
- `@osdk/react-components/experimental/video-viewer` — VideoViewer, BaseVideoViewer
|
|
53
|
-
- `@osdk/react-components/experimental/xml-viewer` — XmlViewer, BaseXmlViewer
|
|
57
|
+
- `@osdk/react-components/experimental/cbac-picker` — CbacPicker
|
|
58
|
+
- `@osdk/react-components/experimental/theme` — OsdkThemeProvider
|
|
54
59
|
|
|
55
60
|
| Component | Description |
|
|
56
61
|
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @osdk/react-components
|
|
2
2
|
|
|
3
|
+
## 0.57.0-main-9c5a7b17bd0a71c88bf2d3ed29847e6f87975bbf
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9c5a7b1: Add stable export paths for ObjectTable, FilterList, ActionForm, DocumentViewer, and every viewer used by DocumentViewer.
|
|
8
|
+
|
|
9
|
+
The previous `experimental` export paths are deprecated but remain available for compatibility. Migrate imports as follows:
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
- import { ObjectTable } from "@osdk/react-components/experimental/object-table";
|
|
13
|
+
+ import { ObjectTable } from "@osdk/react-components/object-table";
|
|
14
|
+
|
|
15
|
+
- import { FilterList } from "@osdk/react-components/experimental/filter-list";
|
|
16
|
+
+ import { FilterList } from "@osdk/react-components/filter-list";
|
|
17
|
+
|
|
18
|
+
- import { ActionForm } from "@osdk/react-components/experimental/action-form";
|
|
19
|
+
+ import { ActionForm } from "@osdk/react-components/action-form";
|
|
20
|
+
|
|
21
|
+
- import { DocumentViewer } from "@osdk/react-components/experimental/document-viewer";
|
|
22
|
+
+ import { DocumentViewer } from "@osdk/react-components/document-viewer";
|
|
23
|
+
|
|
24
|
+
- import { EmailViewer } from "@osdk/react-components/experimental/email-viewer";
|
|
25
|
+
+ import { EmailViewer } from "@osdk/react-components/email-viewer";
|
|
26
|
+
|
|
27
|
+
- import { ImageViewer } from "@osdk/react-components/experimental/image-viewer";
|
|
28
|
+
+ import { ImageViewer } from "@osdk/react-components/image-viewer";
|
|
29
|
+
|
|
30
|
+
- import { MarkdownViewer } from "@osdk/react-components/experimental/markdown-renderer";
|
|
31
|
+
+ import { MarkdownViewer } from "@osdk/react-components/markdown-viewer";
|
|
32
|
+
|
|
33
|
+
- import { PdfViewer } from "@osdk/react-components/experimental/pdf-viewer";
|
|
34
|
+
+ import { PdfViewer } from "@osdk/react-components/pdf-viewer";
|
|
35
|
+
|
|
36
|
+
- import { SpreadsheetViewer } from "@osdk/react-components/experimental/spreadsheet-viewer";
|
|
37
|
+
+ import { SpreadsheetViewer } from "@osdk/react-components/spreadsheet-viewer";
|
|
38
|
+
|
|
39
|
+
- import { TiffViewer } from "@osdk/react-components/experimental/tiff-renderer";
|
|
40
|
+
+ import { TiffViewer } from "@osdk/react-components/tiff-viewer";
|
|
41
|
+
|
|
42
|
+
- import { VideoViewer } from "@osdk/react-components/experimental/video-viewer";
|
|
43
|
+
+ import { VideoViewer } from "@osdk/react-components/video-viewer";
|
|
44
|
+
|
|
45
|
+
- import { XmlViewer } from "@osdk/react-components/experimental/xml-viewer";
|
|
46
|
+
+ import { XmlViewer } from "@osdk/react-components/xml-viewer";
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- e5dd4c9: Add `defaultPage`, `defaultScale`, `defaultAutoSize`, and `defaultSidebarOpen` to the PDF viewer APIs. The corresponding `initial*` props remain supported as deprecated aliases.
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [b1bb84a]
|
|
54
|
+
- @osdk/client@2.64.1-main-9c5a7b17bd0a71c88bf2d3ed29847e6f87975bbf
|
|
55
|
+
- @osdk/api@2.64.1-main-9c5a7b17bd0a71c88bf2d3ed29847e6f87975bbf
|
|
56
|
+
- @osdk/react@2.64.1-main-9c5a7b17bd0a71c88bf2d3ed29847e6f87975bbf
|
|
57
|
+
|
|
3
58
|
## 0.56.0
|
|
4
59
|
|
|
5
60
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -236,7 +236,7 @@ src/
|
|
|
236
236
|
|
|
237
237
|
### Export Strategy
|
|
238
238
|
|
|
239
|
-
- **OSDK Components**: Exported through individual entry points
|
|
239
|
+
- **OSDK Components**: Exported through individual entry points (e.g., `object-table`, `filter-list`); components not yet promoted remain under `experimental/`
|
|
240
240
|
- **Base Components**: Select base components are exported for advanced use cases (e.g., `BaseTable`, `BaseFilterList`)
|
|
241
241
|
- **UI Primitives**: The `base-components/` folder contains internal UI primitives that are **NOT exported**
|
|
242
242
|
|
|
@@ -253,7 +253,7 @@ This package focuses on complex, Ontology-aware components with built-in data fe
|
|
|
253
253
|
|
|
254
254
|
Every OSDK component (the outermost data-fetching layer, **not** the Base component) must register a user agent string so that network requests include a `Fetch-User-Agent` header identifying which component initiated them. This enables usage tracking and debugging.
|
|
255
255
|
|
|
256
|
-
This is handled automatically by the `withOsdkMetrics` HOC. Wrap your component at
|
|
256
|
+
This is handled automatically by the `withOsdkMetrics` HOC. Wrap your component at its canonical **export barrel** (`public/experimental/*.ts` before promotion, or `public/*.ts` after promotion), not inside the component body:
|
|
257
257
|
|
|
258
258
|
```ts
|
|
259
259
|
// public/experimental/my-component.ts
|
|
@@ -283,7 +283,7 @@ See the [CSS Variables Reference](https://github.com/palantir/osdk-ts/blob/main/
|
|
|
283
283
|
### Object Table
|
|
284
284
|
|
|
285
285
|
```ts
|
|
286
|
-
import { ObjectTable } from "@osdk/react-components/
|
|
286
|
+
import { ObjectTable } from "@osdk/react-components/object-table";
|
|
287
287
|
import { Employee } from "@your-osdk-package";
|
|
288
288
|
|
|
289
289
|
function EmployeeDirectory() {
|
package/action-form.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export * from "./build/types/public/action-form.js";
|
|
@@ -40,10 +40,14 @@ export const BasePdfViewer = /*#__PURE__*/forwardRef(function ({
|
|
|
40
40
|
formData,
|
|
41
41
|
onFormSubmit,
|
|
42
42
|
onFormChange,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
defaultPage,
|
|
44
|
+
initialPage,
|
|
45
|
+
defaultScale,
|
|
46
|
+
initialScale,
|
|
47
|
+
defaultAutoSize,
|
|
48
|
+
initialAutoSize,
|
|
49
|
+
defaultSidebarOpen,
|
|
50
|
+
initialSidebarOpen,
|
|
47
51
|
enableDownload = false,
|
|
48
52
|
downloadFileName,
|
|
49
53
|
sidebarMode: sidebarModeProp = "thumbnails",
|
|
@@ -52,10 +56,10 @@ export const BasePdfViewer = /*#__PURE__*/forwardRef(function ({
|
|
|
52
56
|
}, ref) {
|
|
53
57
|
const viewer = usePdfViewerState({
|
|
54
58
|
src,
|
|
55
|
-
initialPage,
|
|
56
|
-
initialScale,
|
|
57
|
-
initialAutoSize,
|
|
58
|
-
initialSidebarOpen,
|
|
59
|
+
defaultPage: defaultPage ?? initialPage,
|
|
60
|
+
defaultScale: defaultScale ?? initialScale,
|
|
61
|
+
defaultAutoSize: defaultAutoSize ?? initialAutoSize,
|
|
62
|
+
defaultSidebarOpen: defaultSidebarOpen ?? initialSidebarOpen,
|
|
59
63
|
sidebarMode: sidebarModeProp,
|
|
60
64
|
onDownload
|
|
61
65
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasePdfViewer.js","names":["Error","ErrorIcon","Spin","classnames","React","forwardRef","useCallback","useImperativeHandle","PdfAnnotationOverlay","PdfViewerOutlineSidebar","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfHighlightMode","usePdfViewerState","styles","BasePdfViewer","src","annotations","onAnnotationClick","onDownload","enableHighlight","onTextHighlight","onHighlightDelete","formData","onFormSubmit","onFormChange","initialPage","initialScale","initialAutoSize","initialSidebarOpen","enableDownload","downloadFileName","sidebarMode","sidebarModeProp","outlineIcons","className","ref","viewer","highlightModeActive","toggleHighlightMode","deleteHighlight","pdfViewerRef","document","enabled","scrollToPage","hasFormFields","submitFormData","eventBusRef","annotationsByPage","handleDownload","download","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","currentPage","numPages","scale","autoSize","sidebarOpen","onPageChange","onZoomIn","zoomIn","onZoomOut","zoomOut","onAutoSizeToggle","toggleAutoSize","onSearchOpen","search","openSearch","onSidebarToggle","toggleSidebar","onRotateLeft","rotateLeft","onRotateRight","rotateRight","onHighlightToggle","enableFormSave","onFormSave","isSearchOpen","query","totalMatches","currentMatchIndex","onQueryChange","setQuery","onNext","nextMatch","onPrev","prevMatch","onClose","closeSearch","contentArea","onPageClick","onSidebarModeChange","setSidebarMode","outlineItems","onItemClick","scrollContainerWrapper","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key"],"sources":["BasePdfViewer.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\n\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { forwardRef, useCallback, useImperativeHandle } from \"react\";\n\nimport { PdfAnnotationOverlay } from \"./components/PdfAnnotationOverlay.js\";\nimport { PdfViewerOutlineSidebar } from \"./components/PdfViewerOutlineSidebar.js\";\nimport { PdfViewerSearchBar } from \"./components/PdfViewerSearchBar.js\";\nimport { PdfViewerSidebar } from \"./components/PdfViewerSidebar.js\";\nimport { PdfViewerToolbar } from \"./components/PdfViewerToolbar.js\";\nimport { EMPTY_ANNOTATION_ARRAY } from \"./constants.js\";\nimport { usePdfAnnotationsByPage } from \"./hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"./hooks/usePdfFormFields.js\";\nimport { usePdfHighlightMode } from \"./hooks/usePdfHighlightMode.js\";\nimport { usePdfViewerState } from \"./hooks/usePdfViewerState.js\";\nimport type { BasePdfViewerProps, PdfViewerHandle } from \"./PdfViewerApi.js\";\n\nimport styles from \"./BasePdfViewer.module.css\";\n\nexport const BasePdfViewer: React.ForwardRefExoticComponent<\n BasePdfViewerProps & React.RefAttributes<PdfViewerHandle>\n> = forwardRef<PdfViewerHandle, BasePdfViewerProps>(function BasePdfViewer(\n {\n src,\n annotations = EMPTY_ANNOTATION_ARRAY,\n onAnnotationClick,\n onDownload,\n enableHighlight = false,\n onTextHighlight,\n onHighlightDelete,\n formData,\n onFormSubmit,\n onFormChange,\n initialPage = 1,\n initialScale = 1.0,\n initialAutoSize = false,\n initialSidebarOpen = false,\n enableDownload = false,\n downloadFileName,\n sidebarMode: sidebarModeProp = \"thumbnails\",\n outlineIcons,\n className,\n },\n ref,\n) {\n const viewer = usePdfViewerState({\n src,\n initialPage,\n initialScale,\n initialAutoSize,\n initialSidebarOpen,\n sidebarMode: sidebarModeProp,\n onDownload,\n });\n\n const { highlightModeActive, toggleHighlightMode, deleteHighlight } =\n usePdfHighlightMode({\n pdfViewerRef: viewer.pdfViewerRef,\n document: viewer.document,\n enabled: enableHighlight,\n onTextHighlight,\n onHighlightDelete,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n scrollToPage: viewer.scrollToPage,\n deleteHighlight,\n }),\n [viewer.scrollToPage, deleteHighlight],\n );\n\n const { hasFormFields, submitFormData } = usePdfFormFields({\n pdfViewerRef: viewer.pdfViewerRef,\n eventBusRef: viewer.eventBusRef,\n document: viewer.document,\n formData,\n onFormSubmit,\n onFormChange,\n });\n\n const annotationsByPage = usePdfAnnotationsByPage(annotations);\n\n const handleDownload = useCallback(() => {\n viewer.download(downloadFileName);\n }, [viewer, downloadFileName]);\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (viewer.loading) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n </div>\n );\n }\n\n if (viewer.error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {viewer.error.message}\n </div>\n </div>\n );\n }\n\n if (viewer.document == null) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>No document</div>\n </div>\n );\n }\n\n return (\n <div className={rootClassName}>\n <PdfViewerToolbar\n currentPage={viewer.currentPage}\n numPages={viewer.numPages}\n scale={viewer.scale}\n autoSize={viewer.autoSize}\n sidebarOpen={viewer.sidebarOpen}\n onPageChange={viewer.scrollToPage}\n onZoomIn={viewer.zoomIn}\n onZoomOut={viewer.zoomOut}\n onAutoSizeToggle={viewer.toggleAutoSize}\n onSearchOpen={viewer.search.openSearch}\n onSidebarToggle={viewer.toggleSidebar}\n onDownload={handleDownload}\n enableDownload={enableDownload}\n onRotateLeft={viewer.rotateLeft}\n onRotateRight={viewer.rotateRight}\n enableHighlight={enableHighlight}\n highlightModeActive={highlightModeActive}\n onHighlightToggle={toggleHighlightMode}\n enableFormSave={onFormSubmit != null && hasFormFields}\n onFormSave={submitFormData}\n />\n {viewer.search.isSearchOpen && (\n <PdfViewerSearchBar\n query={viewer.search.query}\n totalMatches={viewer.search.totalMatches}\n currentMatchIndex={viewer.search.currentMatchIndex}\n onQueryChange={viewer.search.setQuery}\n onNext={viewer.search.nextMatch}\n onPrev={viewer.search.prevMatch}\n onClose={viewer.search.closeSearch}\n />\n )}\n <div className={styles.contentArea}>\n {viewer.sidebarOpen && viewer.sidebarMode === \"thumbnails\" && (\n <PdfViewerSidebar\n document={viewer.document}\n numPages={viewer.numPages}\n currentPage={viewer.currentPage}\n onPageClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n />\n )}\n {viewer.sidebarOpen && viewer.sidebarMode === \"outline\" && (\n <PdfViewerOutlineSidebar\n outlineItems={viewer.outlineItems}\n currentPage={viewer.currentPage}\n onItemClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n outlineIcons={outlineIcons}\n />\n )}\n <div className={styles.scrollContainerWrapper}>\n <div ref={viewer.containerRef} className={styles.scrollContainer}>\n <div ref={viewer.viewerRef} className=\"pdfViewer\" />\n {viewer.portalTargets.map((target) => {\n const pageAnnotations =\n annotationsByPage[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return (\n <PdfAnnotationOverlay\n key={target.pageNumber}\n target={target}\n annotations={pageAnnotations}\n onAnnotationClick={onAnnotationClick}\n />\n );\n })}\n </div>\n </div>\n </div>\n </div>\n );\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,IAAIC,SAAS,EAAEC,IAAI,QAAQ,oBAAoB;AAC7D,OAAOC,UAAU,MAAM,YAAY;AAEnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,IAAIC,UAAU,EAA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W,EAAEK,MAAM,CAACL,WAAY;IAChCmE,mBAAmB,EAAE9D,MAAM,CAAC+D,cAAe;IAC3ClE,YAAY,EAAEA;EAAa,CAC5B,CACF,eACDlC,KAAA,CAAAsD,aAAA;IAAKnB,SAAS,EAAErB,MAAM,CAACyF;EAAuB,gBAC5CvG,KAAA,CAAAsD,aAAA;IAAKlB,GAAG,EAAEC,MAAM,CAACmE,YAAa;IAACrE,SAAS,EAAErB,MAAM,CAAC2F;EAAgB,gBAC/DzG,KAAA,CAAAsD,aAAA;IAAKlB,GAAG,EAAEC,MAAM,CAACqE,SAAU;IAACvE,SAAS,EAAC;EAAW,CAAE,CAAC,EACnDE,MAAM,CAACsE,aAAa,CAACC,GAAG,CAAEC,MAAM,IAAK;IACpC,MAAMC,eAAe,GACnB9D,iBAAiB,CAAC6D,MAAM,CAACE,UAAU,CAAC,IAAItG,sBAAsB;IAChE,IAAIqG,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBACEhH,KAAA,CAAAsD,aAAA,CAAClD,oBAAoB;MACnB6G,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvBF,MAAM,EAAEA,MAAO;MACf5F,WAAW,EAAE6F,eAAgB;MAC7B5F,iBAAiB,EAAEA;IAAkB,CACtC,CAAC;EAEN,CAAC,CACE,CACF,CACF,CACF,CAAC;AAEV,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"BasePdfViewer.js","names":["Error","ErrorIcon","Spin","classnames","React","forwardRef","useCallback","useImperativeHandle","PdfAnnotationOverlay","PdfViewerOutlineSidebar","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfHighlightMode","usePdfViewerState","styles","BasePdfViewer","src","annotations","onAnnotationClick","onDownload","enableHighlight","onTextHighlight","onHighlightDelete","formData","onFormSubmit","onFormChange","defaultPage","initialPage","defaultScale","initialScale","defaultAutoSize","initialAutoSize","defaultSidebarOpen","initialSidebarOpen","enableDownload","downloadFileName","sidebarMode","sidebarModeProp","outlineIcons","className","ref","viewer","highlightModeActive","toggleHighlightMode","deleteHighlight","pdfViewerRef","document","enabled","scrollToPage","hasFormFields","submitFormData","eventBusRef","annotationsByPage","handleDownload","download","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","currentPage","numPages","scale","autoSize","sidebarOpen","onPageChange","onZoomIn","zoomIn","onZoomOut","zoomOut","onAutoSizeToggle","toggleAutoSize","onSearchOpen","search","openSearch","onSidebarToggle","toggleSidebar","onRotateLeft","rotateLeft","onRotateRight","rotateRight","onHighlightToggle","enableFormSave","onFormSave","isSearchOpen","query","totalMatches","currentMatchIndex","onQueryChange","setQuery","onNext","nextMatch","onPrev","prevMatch","onClose","closeSearch","contentArea","onPageClick","onSidebarModeChange","setSidebarMode","outlineItems","onItemClick","scrollContainerWrapper","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key"],"sources":["BasePdfViewer.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\n\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { forwardRef, useCallback, useImperativeHandle } from \"react\";\n\nimport { PdfAnnotationOverlay } from \"./components/PdfAnnotationOverlay.js\";\nimport { PdfViewerOutlineSidebar } from \"./components/PdfViewerOutlineSidebar.js\";\nimport { PdfViewerSearchBar } from \"./components/PdfViewerSearchBar.js\";\nimport { PdfViewerSidebar } from \"./components/PdfViewerSidebar.js\";\nimport { PdfViewerToolbar } from \"./components/PdfViewerToolbar.js\";\nimport { EMPTY_ANNOTATION_ARRAY } from \"./constants.js\";\nimport { usePdfAnnotationsByPage } from \"./hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"./hooks/usePdfFormFields.js\";\nimport { usePdfHighlightMode } from \"./hooks/usePdfHighlightMode.js\";\nimport { usePdfViewerState } from \"./hooks/usePdfViewerState.js\";\nimport type { BasePdfViewerProps, PdfViewerHandle } from \"./PdfViewerApi.js\";\n\nimport styles from \"./BasePdfViewer.module.css\";\n\nexport const BasePdfViewer: React.ForwardRefExoticComponent<\n BasePdfViewerProps & React.RefAttributes<PdfViewerHandle>\n> = forwardRef<PdfViewerHandle, BasePdfViewerProps>(function BasePdfViewer(\n {\n src,\n annotations = EMPTY_ANNOTATION_ARRAY,\n onAnnotationClick,\n onDownload,\n enableHighlight = false,\n onTextHighlight,\n onHighlightDelete,\n formData,\n onFormSubmit,\n onFormChange,\n defaultPage,\n initialPage,\n defaultScale,\n initialScale,\n defaultAutoSize,\n initialAutoSize,\n defaultSidebarOpen,\n initialSidebarOpen,\n enableDownload = false,\n downloadFileName,\n sidebarMode: sidebarModeProp = \"thumbnails\",\n outlineIcons,\n className,\n },\n ref,\n) {\n const viewer = usePdfViewerState({\n src,\n defaultPage: defaultPage ?? initialPage,\n defaultScale: defaultScale ?? initialScale,\n defaultAutoSize: defaultAutoSize ?? initialAutoSize,\n defaultSidebarOpen: defaultSidebarOpen ?? initialSidebarOpen,\n sidebarMode: sidebarModeProp,\n onDownload,\n });\n\n const { highlightModeActive, toggleHighlightMode, deleteHighlight } =\n usePdfHighlightMode({\n pdfViewerRef: viewer.pdfViewerRef,\n document: viewer.document,\n enabled: enableHighlight,\n onTextHighlight,\n onHighlightDelete,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n scrollToPage: viewer.scrollToPage,\n deleteHighlight,\n }),\n [viewer.scrollToPage, deleteHighlight],\n );\n\n const { hasFormFields, submitFormData } = usePdfFormFields({\n pdfViewerRef: viewer.pdfViewerRef,\n eventBusRef: viewer.eventBusRef,\n document: viewer.document,\n formData,\n onFormSubmit,\n onFormChange,\n });\n\n const annotationsByPage = usePdfAnnotationsByPage(annotations);\n\n const handleDownload = useCallback(() => {\n viewer.download(downloadFileName);\n }, [viewer, downloadFileName]);\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (viewer.loading) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n </div>\n );\n }\n\n if (viewer.error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {viewer.error.message}\n </div>\n </div>\n );\n }\n\n if (viewer.document == null) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>No document</div>\n </div>\n );\n }\n\n return (\n <div className={rootClassName}>\n <PdfViewerToolbar\n currentPage={viewer.currentPage}\n numPages={viewer.numPages}\n scale={viewer.scale}\n autoSize={viewer.autoSize}\n sidebarOpen={viewer.sidebarOpen}\n onPageChange={viewer.scrollToPage}\n onZoomIn={viewer.zoomIn}\n onZoomOut={viewer.zoomOut}\n onAutoSizeToggle={viewer.toggleAutoSize}\n onSearchOpen={viewer.search.openSearch}\n onSidebarToggle={viewer.toggleSidebar}\n onDownload={handleDownload}\n enableDownload={enableDownload}\n onRotateLeft={viewer.rotateLeft}\n onRotateRight={viewer.rotateRight}\n enableHighlight={enableHighlight}\n highlightModeActive={highlightModeActive}\n onHighlightToggle={toggleHighlightMode}\n enableFormSave={onFormSubmit != null && hasFormFields}\n onFormSave={submitFormData}\n />\n {viewer.search.isSearchOpen && (\n <PdfViewerSearchBar\n query={viewer.search.query}\n totalMatches={viewer.search.totalMatches}\n currentMatchIndex={viewer.search.currentMatchIndex}\n onQueryChange={viewer.search.setQuery}\n onNext={viewer.search.nextMatch}\n onPrev={viewer.search.prevMatch}\n onClose={viewer.search.closeSearch}\n />\n )}\n <div className={styles.contentArea}>\n {viewer.sidebarOpen && viewer.sidebarMode === \"thumbnails\" && (\n <PdfViewerSidebar\n document={viewer.document}\n numPages={viewer.numPages}\n currentPage={viewer.currentPage}\n onPageClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n />\n )}\n {viewer.sidebarOpen && viewer.sidebarMode === \"outline\" && (\n <PdfViewerOutlineSidebar\n outlineItems={viewer.outlineItems}\n currentPage={viewer.currentPage}\n onItemClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n outlineIcons={outlineIcons}\n />\n )}\n <div className={styles.scrollContainerWrapper}>\n <div ref={viewer.containerRef} className={styles.scrollContainer}>\n <div ref={viewer.viewerRef} className=\"pdfViewer\" />\n {viewer.portalTargets.map((target) => {\n const pageAnnotations =\n annotationsByPage[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return (\n <PdfAnnotationOverlay\n key={target.pageNumber}\n target={target}\n annotations={pageAnnotations}\n onAnnotationClick={onAnnotationClick}\n />\n );\n })}\n </div>\n </div>\n </div>\n </div>\n );\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,IAAIC,SAAS,EAAEC,IAAI,QAAQ,oBAAoB;AAC7D,OAAOC,UAAU,MAAM,YAAY;AAEnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,mBAAmB,QAAQ,OAAO;AAE3E,SAASC,oBAAoB,QAAQ,sCAAsC;AAC3E,SAASC,uBAAuB,QAAQ,yCAAyC;AACjF,SAASC,kBAAkB,Q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K,MAAM,CAACL,WAAY;IAChCmE,mBAAmB,EAAE9D,MAAM,CAAC+D,cAAe;IAC3ClE,YAAY,EAAEA;EAAa,CAC5B,CACF,eACDtC,KAAA,CAAA0D,aAAA;IAAKnB,SAAS,EAAEzB,MAAM,CAAC6F;EAAuB,gBAC5C3G,KAAA,CAAA0D,aAAA;IAAKlB,GAAG,EAAEC,MAAM,CAACmE,YAAa;IAACrE,SAAS,EAAEzB,MAAM,CAAC+F;EAAgB,gBAC/D7G,KAAA,CAAA0D,aAAA;IAAKlB,GAAG,EAAEC,MAAM,CAACqE,SAAU;IAACvE,SAAS,EAAC;EAAW,CAAE,CAAC,EACnDE,MAAM,CAACsE,aAAa,CAACC,GAAG,CAAEC,MAAM,IAAK;IACpC,MAAMC,eAAe,GACnB9D,iBAAiB,CAAC6D,MAAM,CAACE,UAAU,CAAC,IAAI1G,sBAAsB;IAChE,IAAIyG,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBACEpH,KAAA,CAAA0D,aAAA,CAACtD,oBAAoB;MACnBiH,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvBF,MAAM,EAAEA,MAAO;MACfhG,WAAW,EAAEiG,eAAgB;MAC7BhG,iBAAiB,EAAEA;IAAkB,CACtC,CAAC;EAEN,CAAC,CACE,CACF,CACF,CACF,CAAC;AAEV,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfViewerApi.js","names":[],"sources":["PdfViewerApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Media } from \"@osdk/api\";\nimport type React from \"react\";\n\n/** Which sidebar panel to display when the sidebar is open. */\nexport type SidebarMode = \"thumbnails\" | \"outline\";\n\n/** A single item in the PDF document outline (table of contents). */\nexport interface OutlineItem {\n title: string;\n depth: number;\n pageNumber: number;\n bold: boolean;\n italic: boolean;\n}\n\n/** The visual style of an annotation rendered on the PDF. */\nexport type AnnotationType =\n | \"highlight\"\n | \"underline\"\n | \"comment\"\n | \"pin\"\n | \"custom\";\n\n/** A rectangle in PDF coordinate space (origin: bottom-left of page). */\nexport interface PdfRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Props passed to a custom annotation renderer. */\nexport interface PdfAnnotationRenderProps {\n annotation: PdfAnnotation;\n scale: number;\n pageHeight: number;\n transform: number[];\n}\n\n/** Common fields shared by all annotation types. */\ninterface PdfAnnotationBase {\n /** Unique identifier for this annotation */\n id: string;\n /** Page number (1-indexed) */\n page: number;\n /** Coordinates in PDF points (origin: bottom-left of page) */\n rect: PdfRect;\n /** Additional rects for multi-line text highlights. When present, all rects are rendered. */\n rects?: PdfRect[];\n /** Optional label or tooltip text */\n label?: string;\n /** Optional color override (CSS color string) */\n color?: string;\n}\n\n/** A built-in annotation type (highlight, underline, comment, pin). */\ninterface PdfStandardAnnotation extends PdfAnnotationBase {\n /** The type of annotation to render */\n type: \"highlight\" | \"underline\" | \"comment\" | \"pin\";\n}\n\n/** A custom annotation with a user-provided renderer. */\nexport interface PdfCustomAnnotation extends PdfAnnotationBase {\n /** Must be \"custom\" for custom-rendered annotations */\n type: \"custom\";\n /** Render function for the custom annotation content (required for custom type) */\n render: (props: PdfAnnotationRenderProps) => React.ReactNode;\n}\n\n/** A single annotation positioned on a specific page of the PDF. */\nexport type PdfAnnotation = PdfStandardAnnotation | PdfCustomAnnotation;\n\n/** Result passed to the {@link BasePdfViewerProps.onDownload} callback. */\nexport type PdfDownloadResult =\n | { success: true; filename: string }\n | { success: false; error: Error };\n\n/** Possible values for a PDF form field. */\nexport type PdfFormFieldValue = string | boolean | string[];\n\n/** Data emitted when the user creates a text highlight via the highlight editor. */\nexport interface PdfTextHighlightEvent {\n /** Internal PDF.js editor ID. Use with `deleteHighlight` to programmatically remove. */\n editorId: string;\n /** Page number (1-indexed) */\n page: number;\n /** Bounding rects in PDF coordinate space (bottom-left origin) */\n rects: PdfRect[];\n /** The selected text content */\n selectedText: string;\n /** Highlight color as CSS color string */\n color: string;\n}\n\n/** Imperative handle for programmatic control of a {@link PdfViewer} or {@link BasePdfViewer}. */\nexport interface PdfViewerHandle {\n /** Scroll the viewer to the given page number (1-indexed). */\n scrollToPage: (page: number) => void;\n /** Programmatically delete a highlight by its `editorId` (from {@link PdfTextHighlightEvent}). */\n deleteHighlight: (editorId: string) => void;\n}\n\n/**\n * Options for {@link usePdfViewerInstance}.\n *\n * Derived from {@link BasePdfViewerProps} rather than restated, so the two\n * cannot drift. `className` is excluded as a rendering concern, and\n * `downloadFileName` because the hooks tier does not render the toolbar that\n * would use it.\n */\nexport type PdfViewerInstanceOptions = Omit<\n BasePdfViewerProps,\n \"className\" | \"downloadFileName\"\n> & {\n /**\n * Whether the highlight toggle button is shown in the toolbar.\n * @deprecated Use `enableHighlight` instead, which matches\n * {@link BasePdfViewerProps}. Ignored when `enableHighlight` is set.\n */\n highlightEnabled?: boolean;\n};\n\n/**\n * PDF source input.\n *\n * - `string` — a URL the PDF is fetched from\n * - `ArrayBuffer` / `Uint8Array` — raw PDF bytes already in memory (a Node\n * `Buffer` satisfies `Uint8Array` and is accepted as-is)\n * - `Blob` — read into an `ArrayBuffer` before rendering\n */\nexport type PdfSource = string | ArrayBuffer | Uint8Array | Blob;\n\n/** Props for the {@link BasePdfViewer} component. */\nexport interface BasePdfViewerProps {\n /** PDF source — URL string, ArrayBuffer, Uint8Array, or Blob */\n src: PdfSource;\n /** Annotations to overlay on the PDF */\n annotations?: PdfAnnotation[];\n /**\n * Callback fired when an annotation is clicked.\n *\n * @param annotation - The annotation that was clicked\n * @returns void\n */\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n /**\n * Callback fired when a download completes or fails.\n *\n * @param result - The download result indicating success with the filename, or failure with an error\n * @returns void\n */\n onDownload?: (result: PdfDownloadResult) => void;\n /**\n * Whether the highlight toggle button is shown in the toolbar.\n * @default false\n */\n enableHighlight?: boolean;\n /**\n * Callback fired when the user creates a text highlight.\n * Only fires when highlight mode is active.\n *\n * @param event - The highlight event with page, rects, text, and color\n * @returns void\n */\n onTextHighlight?: (event: PdfTextHighlightEvent) => void;\n /**\n * Callback fired when the user deletes a highlight via the PDF.js editor UI.\n *\n * @param event - The highlight event that was deleted\n * @returns void\n */\n onHighlightDelete?: (event: PdfTextHighlightEvent) => void;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /**\n * Whether auto-size (fit to width) is initially enabled.\n * When enabled, the PDF scales to fit the container width and\n * re-fits automatically on resize. Manual zoom disables auto-size.\n * Takes precedence over {@link
|
|
1
|
+
{"version":3,"file":"PdfViewerApi.js","names":[],"sources":["PdfViewerApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Media } from \"@osdk/api\";\nimport type React from \"react\";\n\n/** Which sidebar panel to display when the sidebar is open. */\nexport type SidebarMode = \"thumbnails\" | \"outline\";\n\n/** A single item in the PDF document outline (table of contents). */\nexport interface OutlineItem {\n title: string;\n depth: number;\n pageNumber: number;\n bold: boolean;\n italic: boolean;\n}\n\n/** The visual style of an annotation rendered on the PDF. */\nexport type AnnotationType =\n | \"highlight\"\n | \"underline\"\n | \"comment\"\n | \"pin\"\n | \"custom\";\n\n/** A rectangle in PDF coordinate space (origin: bottom-left of page). */\nexport interface PdfRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Props passed to a custom annotation renderer. */\nexport interface PdfAnnotationRenderProps {\n annotation: PdfAnnotation;\n scale: number;\n pageHeight: number;\n transform: number[];\n}\n\n/** Common fields shared by all annotation types. */\ninterface PdfAnnotationBase {\n /** Unique identifier for this annotation */\n id: string;\n /** Page number (1-indexed) */\n page: number;\n /** Coordinates in PDF points (origin: bottom-left of page) */\n rect: PdfRect;\n /** Additional rects for multi-line text highlights. When present, all rects are rendered. */\n rects?: PdfRect[];\n /** Optional label or tooltip text */\n label?: string;\n /** Optional color override (CSS color string) */\n color?: string;\n}\n\n/** A built-in annotation type (highlight, underline, comment, pin). */\ninterface PdfStandardAnnotation extends PdfAnnotationBase {\n /** The type of annotation to render */\n type: \"highlight\" | \"underline\" | \"comment\" | \"pin\";\n}\n\n/** A custom annotation with a user-provided renderer. */\nexport interface PdfCustomAnnotation extends PdfAnnotationBase {\n /** Must be \"custom\" for custom-rendered annotations */\n type: \"custom\";\n /** Render function for the custom annotation content (required for custom type) */\n render: (props: PdfAnnotationRenderProps) => React.ReactNode;\n}\n\n/** A single annotation positioned on a specific page of the PDF. */\nexport type PdfAnnotation = PdfStandardAnnotation | PdfCustomAnnotation;\n\n/** Result passed to the {@link BasePdfViewerProps.onDownload} callback. */\nexport type PdfDownloadResult =\n | { success: true; filename: string }\n | { success: false; error: Error };\n\n/** Possible values for a PDF form field. */\nexport type PdfFormFieldValue = string | boolean | string[];\n\n/** Data emitted when the user creates a text highlight via the highlight editor. */\nexport interface PdfTextHighlightEvent {\n /** Internal PDF.js editor ID. Use with `deleteHighlight` to programmatically remove. */\n editorId: string;\n /** Page number (1-indexed) */\n page: number;\n /** Bounding rects in PDF coordinate space (bottom-left origin) */\n rects: PdfRect[];\n /** The selected text content */\n selectedText: string;\n /** Highlight color as CSS color string */\n color: string;\n}\n\n/** Imperative handle for programmatic control of a {@link PdfViewer} or {@link BasePdfViewer}. */\nexport interface PdfViewerHandle {\n /** Scroll the viewer to the given page number (1-indexed). */\n scrollToPage: (page: number) => void;\n /** Programmatically delete a highlight by its `editorId` (from {@link PdfTextHighlightEvent}). */\n deleteHighlight: (editorId: string) => void;\n}\n\n/**\n * Options for {@link usePdfViewerInstance}.\n *\n * Derived from {@link BasePdfViewerProps} rather than restated, so the two\n * cannot drift. `className` is excluded as a rendering concern, and\n * `downloadFileName` because the hooks tier does not render the toolbar that\n * would use it.\n */\nexport type PdfViewerInstanceOptions = Omit<\n BasePdfViewerProps,\n \"className\" | \"downloadFileName\"\n> & {\n /**\n * Whether the highlight toggle button is shown in the toolbar.\n * @deprecated Use `enableHighlight` instead, which matches\n * {@link BasePdfViewerProps}. Ignored when `enableHighlight` is set.\n */\n highlightEnabled?: boolean;\n};\n\n/**\n * PDF source input.\n *\n * - `string` — a URL the PDF is fetched from\n * - `ArrayBuffer` / `Uint8Array` — raw PDF bytes already in memory (a Node\n * `Buffer` satisfies `Uint8Array` and is accepted as-is)\n * - `Blob` — read into an `ArrayBuffer` before rendering\n */\nexport type PdfSource = string | ArrayBuffer | Uint8Array | Blob;\n\n/** Props for the {@link BasePdfViewer} component. */\nexport interface BasePdfViewerProps {\n /** PDF source — URL string, ArrayBuffer, Uint8Array, or Blob */\n src: PdfSource;\n /** Annotations to overlay on the PDF */\n annotations?: PdfAnnotation[];\n /**\n * Callback fired when an annotation is clicked.\n *\n * @param annotation - The annotation that was clicked\n * @returns void\n */\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n /**\n * Callback fired when a download completes or fails.\n *\n * @param result - The download result indicating success with the filename, or failure with an error\n * @returns void\n */\n onDownload?: (result: PdfDownloadResult) => void;\n /**\n * Whether the highlight toggle button is shown in the toolbar.\n * @default false\n */\n enableHighlight?: boolean;\n /**\n * Callback fired when the user creates a text highlight.\n * Only fires when highlight mode is active.\n *\n * @param event - The highlight event with page, rects, text, and color\n * @returns void\n */\n onTextHighlight?: (event: PdfTextHighlightEvent) => void;\n /**\n * Callback fired when the user deletes a highlight via the PDF.js editor UI.\n *\n * @param event - The highlight event that was deleted\n * @returns void\n */\n onHighlightDelete?: (event: PdfTextHighlightEvent) => void;\n /** Initial page number (1-indexed, default 1) */\n defaultPage?: number;\n /** @deprecated Rename to `defaultPage`. */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n defaultScale?: number;\n /** @deprecated Rename to `defaultScale`. */\n initialScale?: number;\n /**\n * Whether auto-size (fit to width) is initially enabled.\n * When enabled, the PDF scales to fit the container width and\n * re-fits automatically on resize. Manual zoom disables auto-size.\n * Takes precedence over {@link defaultScale} when enabled.\n * @default false\n */\n defaultAutoSize?: boolean;\n /** @deprecated Rename to `defaultAutoSize`. */\n initialAutoSize?: boolean;\n /** Whether the sidebar is initially open (default false) */\n defaultSidebarOpen?: boolean;\n /** @deprecated Rename to `defaultSidebarOpen`. */\n initialSidebarOpen?: boolean;\n /**\n * Whether the download button is shown in the toolbar.\n * @default false\n */\n enableDownload?: boolean;\n /**\n * Filename used when the user downloads the PDF via the toolbar button.\n * If omitted, the name is derived from the `src` URL, falling back to \"document.pdf\".\n */\n downloadFileName?: string;\n /**\n * Which sidebar panel to show: thumbnails or document outline.\n * @default \"thumbnails\"\n */\n sidebarMode?: SidebarMode;\n /**\n * Custom icon components for each outline depth level (0-indexed).\n * Key 0 = top-level items, 1 = first nesting level, etc.\n * If omitted, no icons are rendered.\n */\n outlineIcons?: Partial<Record<number, React.ComponentType>>;\n /**\n * Initial form field values keyed by field name. Applied when the document loads.\n * Use this to pre-populate form fields when resuming a previously edited PDF.\n */\n formData?: Record<string, PdfFormFieldValue>;\n /**\n * Callback fired when the user clicks the save button in the toolbar.\n * Receives all current form field values keyed by field name.\n *\n * @param data - All form field values keyed by field name\n * @returns void\n */\n onFormSubmit?: (data: Record<string, PdfFormFieldValue>) => void;\n /**\n * Callback fired when any form field value changes.\n *\n * @param fieldName - The name of the field that changed\n * @param value - The new value\n * @returns void\n */\n onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;\n /** Additional CSS class name for the root element */\n className?: string;\n}\n\n/** Props for the {@link PdfViewer} component. */\nexport interface PdfViewerProps extends Omit<BasePdfViewerProps, \"src\"> {\n /** The Media object to fetch PDF contents from */\n media: Media;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -54,9 +54,13 @@ export function usePdfViewerContext() {
|
|
|
54
54
|
export function usePdfViewerInstance(options) {
|
|
55
55
|
const viewer = usePdfViewerState({
|
|
56
56
|
src: options.src,
|
|
57
|
+
defaultPage: options.defaultPage,
|
|
57
58
|
initialPage: options.initialPage,
|
|
59
|
+
defaultScale: options.defaultScale,
|
|
58
60
|
initialScale: options.initialScale,
|
|
61
|
+
defaultAutoSize: options.defaultAutoSize,
|
|
59
62
|
initialAutoSize: options.initialAutoSize,
|
|
63
|
+
defaultSidebarOpen: options.defaultSidebarOpen,
|
|
60
64
|
initialSidebarOpen: options.initialSidebarOpen,
|
|
61
65
|
sidebarMode: options.sidebarMode,
|
|
62
66
|
onDownload: options.onDownload
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfViewerContext.js","names":["React","createContext","useContext","useMemo","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfHighlightMode","usePdfViewerState","PdfViewerContext","PdfViewerProvider","value","children","createElement","Provider","usePdfViewerContext","ctx","Error","usePdfViewerInstance","options","viewer","src","initialPage","initialScale","initialAutoSize","initialSidebarOpen","sidebarMode","onDownload","highlightModeActive","toggleHighlightMode","pdfViewerRef","document","enabled","enableHighlight","highlightEnabled","onTextHighlight","onHighlightDelete","hasFormFields","submitFormData","eventBusRef","formData","onFormSubmit","onFormChange","annotations","annotationsByPage","enableDownload","enableFormSave","onAnnotationClick","outlineIcons"],"sources":["PdfViewerContext.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport type {\n EventBus,\n PDFFindController,\n PDFViewer,\n} from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport React, { createContext, useContext, useMemo } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { EMPTY_ANNOTATION_ARRAY } from \"./constants.js\";\nimport type { AnnotationPortalTarget } from \"./hooks/usePdfAnnotationPortals.js\";\nimport { usePdfAnnotationsByPage } from \"./hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"./hooks/usePdfFormFields.js\";\nimport { usePdfHighlightMode } from \"./hooks/usePdfHighlightMode.js\";\nimport type { UsePdfViewerSearchResult } from \"./hooks/usePdfViewerSearch.js\";\nimport { usePdfViewerState } from \"./hooks/usePdfViewerState.js\";\nimport type {\n OutlineItem,\n PdfAnnotation,\n PdfViewerInstanceOptions,\n SidebarMode,\n} from \"./PdfViewerApi.js\";\n\n/** The shape of the value provided by {@link PdfViewerProvider}. */\nexport interface PdfViewerContextValue {\n // From UsePdfViewerStateResult (core + state)\n document: PDFDocumentProxy | undefined;\n numPages: number;\n loading: boolean;\n error: Error | undefined;\n containerRef: RefObject<HTMLDivElement>;\n viewerRef: RefObject<HTMLDivElement>;\n currentPage: number;\n scrollToPage: (page: number) => void;\n scale: number;\n setScale: (scale: number) => void;\n autoSize: boolean;\n setAutoSize: (autoSize: boolean) => void;\n zoomIn: () => void;\n zoomOut: () => void;\n toggleAutoSize: () => void;\n rotation: number;\n rotateLeft: () => void;\n rotateRight: () => void;\n sidebarOpen: boolean;\n sidebarMode: SidebarMode;\n setSidebarMode: (mode: SidebarMode) => void;\n toggleSidebar: () => void;\n search: UsePdfViewerSearchResult;\n outlineItems: OutlineItem[];\n download: (filename?: string) => void;\n portalTargets: AnnotationPortalTarget[];\n\n // From UsePdfHighlightModeResult\n highlightEnabled: boolean;\n highlightModeActive: boolean;\n toggleHighlightMode: () => void;\n\n // From UsePdfFormFieldsResult\n hasFormFields: boolean;\n submitFormData: () => void;\n\n // Annotations\n annotations: PdfAnnotation[];\n annotationsByPage: Record<number, PdfAnnotation[]>;\n onAnnotationClick: ((annotation: PdfAnnotation) => void) | undefined;\n\n // Config props passed through\n enableDownload: boolean;\n enableFormSave: boolean;\n outlineIcons: Partial<Record<number, React.ComponentType>> | undefined;\n\n // Internal refs (for advanced consumers)\n pdfViewerRef: RefObject<PDFViewer | null>;\n eventBusRef: RefObject<EventBus | null>;\n findControllerRef: RefObject<PDFFindController | null>;\n}\n\nconst PdfViewerContext = createContext<PdfViewerContextValue | null>(null);\n\nexport interface PdfViewerProviderProps {\n value: PdfViewerContextValue;\n children: React.ReactNode;\n}\n\n/** Provides {@link PdfViewerContextValue} to descendant components. */\nexport function PdfViewerProvider({\n value,\n children,\n}: PdfViewerProviderProps): React.ReactElement {\n return (\n <PdfViewerContext.Provider value={value}>\n {children}\n </PdfViewerContext.Provider>\n );\n}\n\n/**\n * Returns the nearest {@link PdfViewerContextValue} from a {@link PdfViewerProvider}.\n * Throws if called outside a provider.\n */\nexport function usePdfViewerContext(): PdfViewerContextValue {\n const ctx = useContext(PdfViewerContext);\n if (ctx == null) {\n throw new Error(\n \"usePdfViewerContext must be used within a PdfViewerProvider\",\n );\n }\n return ctx;\n}\n\n/**\n * Consumer-facing setup hook analogous to react-hook-form's `useForm()`.\n * Accepts viewer options and returns a {@link PdfViewerContextValue} suitable\n * for passing to {@link PdfViewerProvider}.\n */\nexport function usePdfViewerInstance(\n options: PdfViewerInstanceOptions,\n): PdfViewerContextValue {\n const viewer = usePdfViewerState({\n src: options.src,\n initialPage: options.initialPage,\n initialScale: options.initialScale,\n initialAutoSize: options.initialAutoSize,\n initialSidebarOpen: options.initialSidebarOpen,\n sidebarMode: options.sidebarMode,\n onDownload: options.onDownload,\n });\n\n const { highlightModeActive, toggleHighlightMode } = usePdfHighlightMode({\n pdfViewerRef: viewer.pdfViewerRef,\n document: viewer.document,\n enabled: options.enableHighlight ?? options.highlightEnabled ?? false,\n onTextHighlight: options.onTextHighlight,\n onHighlightDelete: options.onHighlightDelete,\n });\n\n const { hasFormFields, submitFormData } = usePdfFormFields({\n pdfViewerRef: viewer.pdfViewerRef,\n eventBusRef: viewer.eventBusRef,\n document: viewer.document,\n formData: options.formData,\n onFormSubmit: options.onFormSubmit,\n onFormChange: options.onFormChange,\n });\n\n const annotations = options.annotations ?? EMPTY_ANNOTATION_ARRAY;\n const annotationsByPage = usePdfAnnotationsByPage(annotations);\n\n // `highlightEnabled` is the deprecated spelling of `enableHighlight`.\n const highlightEnabled =\n options.enableHighlight ?? options.highlightEnabled ?? false;\n const enableDownload = options.enableDownload ?? false;\n const enableFormSave = options.onFormSubmit != null && hasFormFields;\n const { onAnnotationClick, outlineIcons } = options;\n\n return useMemo(\n () => ({\n ...viewer,\n highlightEnabled,\n highlightModeActive,\n toggleHighlightMode,\n hasFormFields,\n submitFormData,\n annotations,\n annotationsByPage,\n onAnnotationClick,\n enableDownload,\n enableFormSave,\n outlineIcons,\n }),\n [\n viewer,\n highlightEnabled,\n highlightModeActive,\n toggleHighlightMode,\n hasFormFields,\n submitFormData,\n annotations,\n annotationsByPage,\n onAnnotationClick,\n enableDownload,\n enableFormSave,\n outlineIcons,\n ],\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,EA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AAc,EACdK,WAAW,EACXC,iBAAiB,EACjBG,iBAAiB,EACjBF,cAAc,EACdC,cAAc,EACdE,YAAY,CAEhB,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PdfViewerContext.js","names":["React","createContext","useContext","useMemo","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfHighlightMode","usePdfViewerState","PdfViewerContext","PdfViewerProvider","value","children","createElement","Provider","usePdfViewerContext","ctx","Error","usePdfViewerInstance","options","viewer","src","defaultPage","initialPage","defaultScale","initialScale","defaultAutoSize","initialAutoSize","defaultSidebarOpen","initialSidebarOpen","sidebarMode","onDownload","highlightModeActive","toggleHighlightMode","pdfViewerRef","document","enabled","enableHighlight","highlightEnabled","onTextHighlight","onHighlightDelete","hasFormFields","submitFormData","eventBusRef","formData","onFormSubmit","onFormChange","annotations","annotationsByPage","enableDownload","enableFormSave","onAnnotationClick","outlineIcons"],"sources":["PdfViewerContext.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport type {\n EventBus,\n PDFFindController,\n PDFViewer,\n} from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport React, { createContext, useContext, useMemo } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { EMPTY_ANNOTATION_ARRAY } from \"./constants.js\";\nimport type { AnnotationPortalTarget } from \"./hooks/usePdfAnnotationPortals.js\";\nimport { usePdfAnnotationsByPage } from \"./hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"./hooks/usePdfFormFields.js\";\nimport { usePdfHighlightMode } from \"./hooks/usePdfHighlightMode.js\";\nimport type { UsePdfViewerSearchResult } from \"./hooks/usePdfViewerSearch.js\";\nimport { usePdfViewerState } from \"./hooks/usePdfViewerState.js\";\nimport type {\n OutlineItem,\n PdfAnnotation,\n PdfViewerInstanceOptions,\n SidebarMode,\n} from \"./PdfViewerApi.js\";\n\n/** The shape of the value provided by {@link PdfViewerProvider}. */\nexport interface PdfViewerContextValue {\n // From UsePdfViewerStateResult (core + state)\n document: PDFDocumentProxy | undefined;\n numPages: number;\n loading: boolean;\n error: Error | undefined;\n containerRef: RefObject<HTMLDivElement>;\n viewerRef: RefObject<HTMLDivElement>;\n currentPage: number;\n scrollToPage: (page: number) => void;\n scale: number;\n setScale: (scale: number) => void;\n autoSize: boolean;\n setAutoSize: (autoSize: boolean) => void;\n zoomIn: () => void;\n zoomOut: () => void;\n toggleAutoSize: () => void;\n rotation: number;\n rotateLeft: () => void;\n rotateRight: () => void;\n sidebarOpen: boolean;\n sidebarMode: SidebarMode;\n setSidebarMode: (mode: SidebarMode) => void;\n toggleSidebar: () => void;\n search: UsePdfViewerSearchResult;\n outlineItems: OutlineItem[];\n download: (filename?: string) => void;\n portalTargets: AnnotationPortalTarget[];\n\n // From UsePdfHighlightModeResult\n highlightEnabled: boolean;\n highlightModeActive: boolean;\n toggleHighlightMode: () => void;\n\n // From UsePdfFormFieldsResult\n hasFormFields: boolean;\n submitFormData: () => void;\n\n // Annotations\n annotations: PdfAnnotation[];\n annotationsByPage: Record<number, PdfAnnotation[]>;\n onAnnotationClick: ((annotation: PdfAnnotation) => void) | undefined;\n\n // Config props passed through\n enableDownload: boolean;\n enableFormSave: boolean;\n outlineIcons: Partial<Record<number, React.ComponentType>> | undefined;\n\n // Internal refs (for advanced consumers)\n pdfViewerRef: RefObject<PDFViewer | null>;\n eventBusRef: RefObject<EventBus | null>;\n findControllerRef: RefObject<PDFFindController | null>;\n}\n\nconst PdfViewerContext = createContext<PdfViewerContextValue | null>(null);\n\nexport interface PdfViewerProviderProps {\n value: PdfViewerContextValue;\n children: React.ReactNode;\n}\n\n/** Provides {@link PdfViewerContextValue} to descendant components. */\nexport function PdfViewerProvider({\n value,\n children,\n}: PdfViewerProviderProps): React.ReactElement {\n return (\n <PdfViewerContext.Provider value={value}>\n {children}\n </PdfViewerContext.Provider>\n );\n}\n\n/**\n * Returns the nearest {@link PdfViewerContextValue} from a {@link PdfViewerProvider}.\n * Throws if called outside a provider.\n */\nexport function usePdfViewerContext(): PdfViewerContextValue {\n const ctx = useContext(PdfViewerContext);\n if (ctx == null) {\n throw new Error(\n \"usePdfViewerContext must be used within a PdfViewerProvider\",\n );\n }\n return ctx;\n}\n\n/**\n * Consumer-facing setup hook analogous to react-hook-form's `useForm()`.\n * Accepts viewer options and returns a {@link PdfViewerContextValue} suitable\n * for passing to {@link PdfViewerProvider}.\n */\nexport function usePdfViewerInstance(\n options: PdfViewerInstanceOptions,\n): PdfViewerContextValue {\n const viewer = usePdfViewerState({\n src: options.src,\n defaultPage: options.defaultPage,\n initialPage: options.initialPage,\n defaultScale: options.defaultScale,\n initialScale: options.initialScale,\n defaultAutoSize: options.defaultAutoSize,\n initialAutoSize: options.initialAutoSize,\n defaultSidebarOpen: options.defaultSidebarOpen,\n initialSidebarOpen: options.initialSidebarOpen,\n sidebarMode: options.sidebarMode,\n onDownload: options.onDownload,\n });\n\n const { highlightModeActive, toggleHighlightMode } = usePdfHighlightMode({\n pdfViewerRef: viewer.pdfViewerRef,\n document: viewer.document,\n enabled: options.enableHighlight ?? options.highlightEnabled ?? false,\n onTextHighlight: options.onTextHighlight,\n onHighlightDelete: options.onHighlightDelete,\n });\n\n const { hasFormFields, submitFormData } = usePdfFormFields({\n pdfViewerRef: viewer.pdfViewerRef,\n eventBusRef: viewer.eventBusRef,\n document: viewer.document,\n formData: options.formData,\n onFormSubmit: options.onFormSubmit,\n onFormChange: options.onFormChange,\n });\n\n const annotations = options.annotations ?? EMPTY_ANNOTATION_ARRAY;\n const annotationsByPage = usePdfAnnotationsByPage(annotations);\n\n // `highlightEnabled` is the deprecated spelling of `enableHighlight`.\n const highlightEnabled =\n options.enableHighlight ?? options.highlightEnabled ?? false;\n const enableDownload = options.enableDownload ?? false;\n const enableFormSave = options.onFormSubmit != null && hasFormFields;\n const { onAnnotationClick, outlineIcons } = options;\n\n return useMemo(\n () => ({\n ...viewer,\n highlightEnabled,\n highlightModeActive,\n toggleHighlightMode,\n hasFormFields,\n submitFormData,\n annotations,\n annotationsByPage,\n onAnnotationClick,\n enableDownload,\n enableFormSave,\n outlineIcons,\n }),\n [\n viewer,\n highlightEnabled,\n highlightModeActive,\n toggleHighlightMode,\n hasFormFields,\n submitFormData,\n annotations,\n annotationsByPage,\n onAnnotationClick,\n enableDownload,\n enableFormSave,\n outlineIcons,\n ],\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAGjE,SAASC,sBAAsB,QAAQ,gBAAgB;AAEvD,SAASC,uBAAuB,QAAQ,oCAAoC;AAC5E,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,mBAAmB,QAAQ,gCAAgC;AAEpE,SAASC,iBAAiB,QAAQ,8BAA8B;;AAQhE;;AAuDA,MAAMC,gBAAgB,gBAAGR,aAAa,CAA+B,IAAI,CAAC;AAO1E;AACA,OAAO,SAASS,iBAAiBA,CAAC;EAChCC,KAAK;EACLC;AACsB,CAAC,EAAsB;EAC7C,oBACEZ,KAAA,CAAAa,aAAA,CAACJ,gBAAgB,CAACK,QAAQ;IAACH,KAAK,EAAEA;EAAM,GACrCC,QACwB,CAAC;AAEhC;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,mBAAmBA,CAAA,EAA0B;EAC3D,MAAMC,GAA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zBS,QAAQ,EAAEzB,OAAO,CAACyB,QAAQ;IAC1BC,YAAY,EAAE1B,OAAO,CAAC0B,YAAY;IAClCC,YAAY,EAAE3B,OAAO,CAAC2B;EACxB,CAAC,CAAC;EAEF,MAAMC,WAAW,GAAG5B,OAAO,CAAC4B,WAAW,IAAI3C,sBAAsB;EACjE,MAAM4C,iBAAiB,GAAG3C,uBAAuB,CAAC0C,WAAW,CAAC;;EAE9D;EACA,MAAMT,gBAAgB,GACpBnB,OAAO,CAACkB,eAAe,IAAIlB,OAAO,CAACmB,gBAAgB,IAAI,KAAK;EAC9D,MAAMW,cAAc,GAAG9B,OAAO,CAAC8B,cAAc,IAAI,KAAK;EACtD,MAAMC,cAAc,GAAG/B,OAAO,CAAC0B,YAAY,IAAI,IAAI,IAAIJ,aAAa;EACpE,MAAM;IAAEU,iBAAiB;IAAEC;EAAa,CAAC,GAAGjC,OAAO;EAEnD,OAAOhB,OAAO,CACZ,OAAO;IACL,GAAGiB,MAAM;IACTkB,gBAAgB;IAChBN,mBAAmB;IACnBC,mBAAmB;IACnBQ,aAAa;IACbC,cAAc;IACdK,WAAW;IACXC,iBAAiB;IACjBG,iBAAiB;IACjBF,cAAc;IACdC,cAAc;IACdE;EACF,CAAC,CAAC,EACF,CACEhC,MAAM,EACNkB,gBAAgB,EAChBN,mBAAmB,EACnBC,mBAAmB,EACnBQ,aAAa,EACbC,cAAc,EACdK,WAAW,EACXC,iBAAiB,EACjBG,iBAAiB,EACjBF,cAAc,EACdC,cAAc,EACdE,YAAY,CAEhB,CAAC;AACH","ignoreList":[]}
|
|
@@ -28,8 +28,10 @@ export function PdfViewerContent({
|
|
|
28
28
|
src,
|
|
29
29
|
annotations = EMPTY_ANNOTATION_ARRAY,
|
|
30
30
|
onAnnotationClick,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
defaultPage,
|
|
32
|
+
initialPage,
|
|
33
|
+
defaultScale,
|
|
34
|
+
initialScale,
|
|
33
35
|
onPageChange: onPageChangeProp,
|
|
34
36
|
onScaleChange: onScaleChangeProp,
|
|
35
37
|
formData,
|
|
@@ -38,7 +40,9 @@ export function PdfViewerContent({
|
|
|
38
40
|
}) {
|
|
39
41
|
const viewer = usePdfViewerCore({
|
|
40
42
|
src,
|
|
43
|
+
defaultPage,
|
|
41
44
|
initialPage,
|
|
45
|
+
defaultScale,
|
|
42
46
|
initialScale
|
|
43
47
|
});
|
|
44
48
|
const annotationsByPage = usePdfAnnotationsByPage(annotations);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfViewerContent.js","names":["Error","ErrorIcon","Spin","classnames","React","useEffect","useRef","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfViewerCore","PdfAnnotationOverlay","styles","PdfViewerContent","src","annotations","onAnnotationClick","initialPage","initialScale","onPageChange","onPageChangeProp","onScaleChange","onScaleChangeProp","formData","onFormChange","className","viewer","annotationsByPage","pdfViewerRef","eventBusRef","document","onPageChangeRef","current","onScaleChangeRef","isInitialMountRef","currentPage","scale","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","scrollContainerWrapper","ref","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key"],"sources":["PdfViewerContent.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\n\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { useEffect, useRef } from \"react\";\n\nimport { EMPTY_ANNOTATION_ARRAY } from \"../constants.js\";\nimport { usePdfAnnotationsByPage } from \"../hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"../hooks/usePdfFormFields.js\";\nimport { usePdfViewerCore } from \"../hooks/usePdfViewerCore.js\";\nimport type {\n PdfAnnotation,\n PdfFormFieldValue,\n PdfSource,\n} from \"../PdfViewerApi.js\";\nimport { PdfAnnotationOverlay } from \"./PdfAnnotationOverlay.js\";\n\nimport styles from \"../BasePdfViewer.module.css\";\n\nexport interface PdfViewerContentProps {\n /** PDF source — URL string, ArrayBuffer, Uint8Array, or Blob */\n src: PdfSource;\n /** Annotations to overlay on the PDF */\n annotations?: PdfAnnotation[];\n /** Callback fired when an annotation is clicked */\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /** Callback fired when the current page changes during scrolling */\n onPageChange?: (page: number) => void;\n /** Callback fired when the zoom scale changes */\n onScaleChange?: (scale: number) => void;\n /** Initial form field values keyed by field name. Applied when the document loads. */\n formData?: Record<string, PdfFormFieldValue>;\n /** Callback fired when any form field value changes. */\n onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;\n /** Additional CSS class name for the root element */\n className?: string;\n}\n\nexport function PdfViewerContent({\n src,\n annotations = EMPTY_ANNOTATION_ARRAY,\n onAnnotationClick,\n initialPage
|
|
1
|
+
{"version":3,"file":"PdfViewerContent.js","names":["Error","ErrorIcon","Spin","classnames","React","useEffect","useRef","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfViewerCore","PdfAnnotationOverlay","styles","PdfViewerContent","src","annotations","onAnnotationClick","defaultPage","initialPage","defaultScale","initialScale","onPageChange","onPageChangeProp","onScaleChange","onScaleChangeProp","formData","onFormChange","className","viewer","annotationsByPage","pdfViewerRef","eventBusRef","document","onPageChangeRef","current","onScaleChangeRef","isInitialMountRef","currentPage","scale","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","scrollContainerWrapper","ref","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key"],"sources":["PdfViewerContent.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\n\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { useEffect, useRef } from \"react\";\n\nimport { EMPTY_ANNOTATION_ARRAY } from \"../constants.js\";\nimport { usePdfAnnotationsByPage } from \"../hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"../hooks/usePdfFormFields.js\";\nimport { usePdfViewerCore } from \"../hooks/usePdfViewerCore.js\";\nimport type {\n PdfAnnotation,\n PdfFormFieldValue,\n PdfSource,\n} from \"../PdfViewerApi.js\";\nimport { PdfAnnotationOverlay } from \"./PdfAnnotationOverlay.js\";\n\nimport styles from \"../BasePdfViewer.module.css\";\n\nexport interface PdfViewerContentProps {\n /** PDF source — URL string, ArrayBuffer, Uint8Array, or Blob */\n src: PdfSource;\n /** Annotations to overlay on the PDF */\n annotations?: PdfAnnotation[];\n /** Callback fired when an annotation is clicked */\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n /** Initial page number (1-indexed, default 1) */\n defaultPage?: number;\n /** @deprecated Rename to `defaultPage`. */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n defaultScale?: number;\n /** @deprecated Rename to `defaultScale`. */\n initialScale?: number;\n /** Callback fired when the current page changes during scrolling */\n onPageChange?: (page: number) => void;\n /** Callback fired when the zoom scale changes */\n onScaleChange?: (scale: number) => void;\n /** Initial form field values keyed by field name. Applied when the document loads. */\n formData?: Record<string, PdfFormFieldValue>;\n /** Callback fired when any form field value changes. */\n onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;\n /** Additional CSS class name for the root element */\n className?: string;\n}\n\nexport function PdfViewerContent({\n src,\n annotations = EMPTY_ANNOTATION_ARRAY,\n onAnnotationClick,\n defaultPage,\n initialPage,\n defaultScale,\n initialScale,\n onPageChange: onPageChangeProp,\n onScaleChange: onScaleChangeProp,\n formData,\n onFormChange,\n className,\n}: PdfViewerContentProps): React.ReactElement {\n const viewer = usePdfViewerCore({\n src,\n defaultPage,\n initialPage,\n defaultScale,\n initialScale,\n });\n const annotationsByPage = usePdfAnnotationsByPage(annotations);\n\n usePdfFormFields({\n pdfViewerRef: viewer.pdfViewerRef,\n eventBusRef: viewer.eventBusRef,\n document: viewer.document,\n formData,\n onFormChange,\n });\n\n // Use refs for callbacks to avoid firing on initial mount\n const onPageChangeRef = useRef(onPageChangeProp);\n onPageChangeRef.current = onPageChangeProp;\n const onScaleChangeRef = useRef(onScaleChangeProp);\n onScaleChangeRef.current = onScaleChangeProp;\n const isInitialMountRef = useRef(true);\n\n useEffect(\n function notifyPageChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onPageChangeRef.current?.(viewer.currentPage);\n },\n [viewer.currentPage],\n );\n\n useEffect(\n function notifyScaleChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onScaleChangeRef.current?.(viewer.scale);\n },\n [viewer.scale],\n );\n\n useEffect(function clearInitialMount() {\n isInitialMountRef.current = false;\n }, []);\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (viewer.loading) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n </div>\n );\n }\n\n if (viewer.error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {viewer.error.message}\n </div>\n </div>\n );\n }\n\n if (viewer.document == null) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>No document</div>\n </div>\n );\n }\n\n return (\n <div className={rootClassName}>\n <div className={styles.scrollContainerWrapper}>\n <div ref={viewer.containerRef} className={styles.scrollContainer}>\n <div ref={viewer.viewerRef} className=\"pdfViewer\" />\n {viewer.portalTargets.map((target) => {\n const pageAnnotations =\n annotationsByPage[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return (\n <PdfAnnotationOverlay\n key={target.pageNumber}\n target={target}\n annotations={pageAnnotations}\n onAnnotationClick={onAnnotationClick}\n />\n );\n })}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,IAAIC,SAAS,EAAEC,IAAI,QAAQ,oBAAoB;AAC7D,OAAOC,UAAU,MAAM,YAAY;AAEnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEhD,SAASC,sBAAsB,QAAQ,iBAAiB;AACxD,SAASC,uBAAuB,QAAQ,qCAAqC;AAC7E,SAASC,gBAAgB,QAAQ,8BAA8B;AAC/D,SAASC,gBAAgB,QAAQ,8BAA8B;AAM/D,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE,OAAOC,MAAM,MAAM,6BAA6B;AA6BhD,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,GAAG;EACHC,WAAW,GAAGR,sBAAsB;EACpCS,iBAAiB;EACjBC,WAAW;EACXC,WAAW;EACXC,YAAY;EACZC,YAAY;EACZC,YAAY,EAAEC,gBAAgB;E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AAC,EACnDC,MAAM,CAAC0B,aAAa,CAACC,GAAG,CAAEC,MAAM,IAAK;IACpC,MAAMC,eAAe,GACnB5B,iBAAiB,CAAC2B,MAAM,CAACE,UAAU,CAAC,IAAInD,sBAAsB;IAChE,IAAIkD,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBACEvD,KAAA,CAAAsC,aAAA,CAAC/B,oBAAoB;MACnBiD,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvBF,MAAM,EAAEA,MAAO;MACfzC,WAAW,EAAE0C,eAAgB;MAC7BzC,iBAAiB,EAAEA;IAAkB,CACtC,CAAC;EAEN,CAAC,CACE,CACF,CACF,CAAC;AAEV","ignoreList":[]}
|
|
@@ -21,26 +21,32 @@ import { usePdfViewer } from "./usePdfViewer.js";
|
|
|
21
21
|
import { usePdfViewerSync } from "./usePdfViewerSync.js";
|
|
22
22
|
export function usePdfViewerCore({
|
|
23
23
|
src,
|
|
24
|
+
defaultPage,
|
|
25
|
+
// TODO: Move these defaults to the default* props when the initial* aliases are removed.
|
|
24
26
|
initialPage = 1,
|
|
27
|
+
defaultScale,
|
|
25
28
|
initialScale = 1.0,
|
|
29
|
+
defaultAutoSize,
|
|
26
30
|
initialAutoSize = false
|
|
27
31
|
}) {
|
|
32
|
+
const seededPage = defaultPage ?? initialPage;
|
|
33
|
+
const seededScale = defaultScale ?? initialScale;
|
|
28
34
|
const {
|
|
29
35
|
document,
|
|
30
36
|
numPages,
|
|
31
37
|
loading,
|
|
32
38
|
error
|
|
33
39
|
} = usePdfDocument(src);
|
|
34
|
-
const [scale, setScale] = useState(
|
|
35
|
-
const [currentPage, setCurrentPage] = useState(
|
|
36
|
-
const [autoSize, setAutoSize] = useState(initialAutoSize);
|
|
40
|
+
const [scale, setScale] = useState(seededScale);
|
|
41
|
+
const [currentPage, setCurrentPage] = useState(seededPage);
|
|
42
|
+
const [autoSize, setAutoSize] = useState(defaultAutoSize ?? initialAutoSize);
|
|
37
43
|
const containerRef = useRef(null);
|
|
38
44
|
const viewerRef = useRef(null);
|
|
39
45
|
const {
|
|
40
46
|
pdfViewerRef,
|
|
41
47
|
eventBusRef,
|
|
42
48
|
findControllerRef
|
|
43
|
-
} = usePdfViewer(containerRef, viewerRef, document,
|
|
49
|
+
} = usePdfViewer(containerRef, viewerRef, document, seededScale, seededPage);
|
|
44
50
|
const handleScaleChange = useCallback(newScale => {
|
|
45
51
|
setScale(newScale);
|
|
46
52
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePdfViewerCore.js","names":["useCallback","useMemo","useRef","useState","usePdfAnnotationPortals","usePdfDocument","usePdfViewer","usePdfViewerSync","usePdfViewerCore","src","initialPage","initialScale","initialAutoSize","document","numPages","loading","error","scale","setScale","currentPage","setCurrentPage","autoSize","setAutoSize","containerRef","viewerRef","pdfViewerRef","eventBusRef","findControllerRef","handleScaleChange","newScale","handlePageChange","page","scrollToPage","syncScrollToPage","onScaleChange","onPageChange","portalTargets"],"sources":["usePdfViewerCore.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport type {\n EventBus,\n PDFFindController,\n PDFViewer,\n} from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport type { RefObject } from \"react\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\n\nimport type { PdfSource } from \"../PdfViewerApi.js\";\nimport type { AnnotationPortalTarget } from \"./usePdfAnnotationPortals.js\";\nimport { usePdfAnnotationPortals } from \"./usePdfAnnotationPortals.js\";\nimport { usePdfDocument } from \"./usePdfDocument.js\";\nimport { usePdfViewer } from \"./usePdfViewer.js\";\nimport { usePdfViewerSync } from \"./usePdfViewerSync.js\";\n\nexport interface UsePdfViewerCoreOptions {\n /** PDF source — URL string, ArrayBuffer, Uint8Array, or Blob */\n src: PdfSource;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /** Whether auto-size (fit to width) is initially enabled (default false) */\n initialAutoSize?: boolean;\n}\n\nexport interface UsePdfViewerCoreResult {\n /** The loaded PDF document, or undefined while loading */\n document: PDFDocumentProxy | undefined;\n /** Total number of pages in the document */\n numPages: number;\n /** Whether the document is currently loading */\n loading: boolean;\n /** Error encountered while loading the document */\n error: Error | undefined;\n\n /** Ref to attach to the scroll-container div */\n containerRef: RefObject<HTMLDivElement>;\n /** Ref to attach to the inner viewer div (className=\"pdfViewer\") */\n viewerRef: RefObject<HTMLDivElement>;\n\n /** Current page number (1-indexed) */\n currentPage: number;\n /** Navigate to a specific page (updates state and scrolls the viewer) */\n scrollToPage: (page: number) => void;\n\n /** Current zoom scale */\n scale: number;\n /** Set the zoom scale directly */\n setScale: (scale: number) => void;\n\n /** Whether auto-size (fit to width) is active */\n autoSize: boolean;\n /** Enable or disable auto-size */\n setAutoSize: (autoSize: boolean) => void;\n\n /** Portal targets for rendering annotation overlays on each page */\n portalTargets: AnnotationPortalTarget[];\n\n /** Ref to the internal pdfjs PDFViewer instance */\n pdfViewerRef: RefObject<PDFViewer | null>;\n /** Ref to the internal pdfjs EventBus instance */\n eventBusRef: RefObject<EventBus | null>;\n /** Ref to the internal pdfjs PDFFindController instance */\n findControllerRef: RefObject<PDFFindController | null>;\n}\n\nexport function usePdfViewerCore({\n src,\n initialPage = 1,\n initialScale = 1.0,\n initialAutoSize = false,\n}: UsePdfViewerCoreOptions): UsePdfViewerCoreResult {\n const { document, numPages, loading, error } = usePdfDocument(src);\n const [scale, setScale] = useState(
|
|
1
|
+
{"version":3,"file":"usePdfViewerCore.js","names":["useCallback","useMemo","useRef","useState","usePdfAnnotationPortals","usePdfDocument","usePdfViewer","usePdfViewerSync","usePdfViewerCore","src","defaultPage","initialPage","defaultScale","initialScale","defaultAutoSize","initialAutoSize","seededPage","seededScale","document","numPages","loading","error","scale","setScale","currentPage","setCurrentPage","autoSize","setAutoSize","containerRef","viewerRef","pdfViewerRef","eventBusRef","findControllerRef","handleScaleChange","newScale","handlePageChange","page","scrollToPage","syncScrollToPage","onScaleChange","onPageChange","portalTargets"],"sources":["usePdfViewerCore.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport type {\n EventBus,\n PDFFindController,\n PDFViewer,\n} from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport type { RefObject } from \"react\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\n\nimport type { PdfSource } from \"../PdfViewerApi.js\";\nimport type { AnnotationPortalTarget } from \"./usePdfAnnotationPortals.js\";\nimport { usePdfAnnotationPortals } from \"./usePdfAnnotationPortals.js\";\nimport { usePdfDocument } from \"./usePdfDocument.js\";\nimport { usePdfViewer } from \"./usePdfViewer.js\";\nimport { usePdfViewerSync } from \"./usePdfViewerSync.js\";\n\nexport interface UsePdfViewerCoreOptions {\n /** PDF source — URL string, ArrayBuffer, Uint8Array, or Blob */\n src: PdfSource;\n /** Initial page number (1-indexed, default 1) */\n defaultPage?: number;\n /** @deprecated Rename to `defaultPage`. */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n defaultScale?: number;\n /** @deprecated Rename to `defaultScale`. */\n initialScale?: number;\n /** Whether auto-size (fit to width) is initially enabled (default false) */\n defaultAutoSize?: boolean;\n /** @deprecated Rename to `defaultAutoSize`. */\n initialAutoSize?: boolean;\n}\n\nexport interface UsePdfViewerCoreResult {\n /** The loaded PDF document, or undefined while loading */\n document: PDFDocumentProxy | undefined;\n /** Total number of pages in the document */\n numPages: number;\n /** Whether the document is currently loading */\n loading: boolean;\n /** Error encountered while loading the document */\n error: Error | undefined;\n\n /** Ref to attach to the scroll-container div */\n containerRef: RefObject<HTMLDivElement>;\n /** Ref to attach to the inner viewer div (className=\"pdfViewer\") */\n viewerRef: RefObject<HTMLDivElement>;\n\n /** Current page number (1-indexed) */\n currentPage: number;\n /** Navigate to a specific page (updates state and scrolls the viewer) */\n scrollToPage: (page: number) => void;\n\n /** Current zoom scale */\n scale: number;\n /** Set the zoom scale directly */\n setScale: (scale: number) => void;\n\n /** Whether auto-size (fit to width) is active */\n autoSize: boolean;\n /** Enable or disable auto-size */\n setAutoSize: (autoSize: boolean) => void;\n\n /** Portal targets for rendering annotation overlays on each page */\n portalTargets: AnnotationPortalTarget[];\n\n /** Ref to the internal pdfjs PDFViewer instance */\n pdfViewerRef: RefObject<PDFViewer | null>;\n /** Ref to the internal pdfjs EventBus instance */\n eventBusRef: RefObject<EventBus | null>;\n /** Ref to the internal pdfjs PDFFindController instance */\n findControllerRef: RefObject<PDFFindController | null>;\n}\n\nexport function usePdfViewerCore({\n src,\n defaultPage,\n // TODO: Move these defaults to the default* props when the initial* aliases are removed.\n initialPage = 1,\n defaultScale,\n initialScale = 1.0,\n defaultAutoSize,\n initialAutoSize = false,\n}: UsePdfViewerCoreOptions): UsePdfViewerCoreResult {\n const seededPage = defaultPage ?? initialPage;\n const seededScale = defaultScale ?? initialScale;\n const seededAutoSize = defaultAutoSize ?? initialAutoSize;\n const { document, numPages, loading, error } = usePdfDocument(src);\n const [scale, setScale] = useState(seededScale);\n const [currentPage, setCurrentPage] = useState(seededPage);\n const [autoSize, setAutoSize] = useState(seededAutoSize);\n const containerRef = useRef<HTMLDivElement>(null);\n const viewerRef = useRef<HTMLDivElement>(null);\n\n const { pdfViewerRef, eventBusRef, findControllerRef } = usePdfViewer(\n containerRef,\n viewerRef,\n document,\n seededScale,\n seededPage,\n );\n\n const handleScaleChange = useCallback((newScale: number) => {\n setScale(newScale);\n }, []);\n\n const handlePageChange = useCallback((page: number) => {\n setCurrentPage(page);\n }, []);\n\n const { scrollToPage: syncScrollToPage } = usePdfViewerSync({\n pdfViewerRef,\n eventBusRef,\n containerRef,\n document,\n scale,\n autoSize,\n onScaleChange: handleScaleChange,\n onPageChange: handlePageChange,\n });\n\n const scrollToPage = useCallback(\n (page: number) => {\n setCurrentPage(page);\n syncScrollToPage(page);\n },\n [syncScrollToPage],\n );\n\n const portalTargets = usePdfAnnotationPortals(\n pdfViewerRef,\n eventBusRef,\n document,\n );\n\n return useMemo(\n (): UsePdfViewerCoreResult => ({\n document,\n numPages,\n loading,\n error,\n containerRef,\n viewerRef,\n currentPage,\n scrollToPage,\n scale,\n setScale,\n autoSize,\n setAutoSize,\n portalTargets,\n pdfViewerRef,\n eventBusRef,\n findControllerRef,\n }),\n [\n document,\n numPages,\n loading,\n error,\n currentPage,\n scrollToPage,\n scale,\n setScale,\n autoSize,\n setAutoSize,\n portalTargets,\n ],\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,WAAW,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAI9D,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,gBAAgB,QAAQ,uBAAuB;AA4DxD,OAAO,SAASC,gBAAgBA,CA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;IACRa,aAAa,EAAEN,iBAAiB;IAChCO,YAAY,EAAEL;EAChB,CAAC,CAAC;EAEF,MAAME,YAAY,GAAGrC,WAAW,CAC7BoC,IAAY,IAAK;IAChBX,cAAc,CAACW,IAAI,CAAC;IACpBE,gBAAgB,CAACF,IAAI,CAAC;EACxB,CAAC,EACD,CAACE,gBAAgB,CACnB,CAAC;EAED,MAAMG,aAAa,GAAGrC,uBAAuB,CAC3C0B,YAAY,EACZC,WAAW,EACXb,QACF,CAAC;EAED,OAAOjB,OAAO,CACZ,OAA+B;IAC7BiB,QAAQ;IACRC,QAAQ;IACRC,OAAO;IACPC,KAAK;IACLO,YAAY;IACZC,SAAS;IACTL,WAAW;IACXa,YAAY;IACZf,KAAK;IACLC,QAAQ;IACRG,QAAQ;IACRC,WAAW;IACXc,aAAa;IACbX,YAAY;IACZC,WAAW;IACXC;EACF,CAAC,CAAC,EACF,CACEd,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACPC,KAAK,EACLG,WAAW,EACXa,YAAY,EACZf,KAAK,EACLC,QAAQ,EACRG,QAAQ,EACRC,WAAW,EACXc,aAAa,CAEjB,CAAC;AACH","ignoreList":[]}
|
|
@@ -21,21 +21,29 @@ import { usePdfViewerCore } from "./usePdfViewerCore.js";
|
|
|
21
21
|
import { usePdfViewerSearch } from "./usePdfViewerSearch.js";
|
|
22
22
|
export function usePdfViewerState({
|
|
23
23
|
src,
|
|
24
|
+
defaultPage,
|
|
24
25
|
initialPage,
|
|
26
|
+
defaultScale,
|
|
25
27
|
initialScale,
|
|
28
|
+
defaultAutoSize,
|
|
26
29
|
initialAutoSize,
|
|
30
|
+
defaultSidebarOpen,
|
|
31
|
+
// TODO: Move this default to defaultSidebarOpen when initialSidebarOpen is removed.
|
|
27
32
|
initialSidebarOpen = false,
|
|
28
33
|
sidebarMode: sidebarModeProp = "thumbnails",
|
|
29
34
|
onDownload
|
|
30
35
|
}) {
|
|
31
36
|
const core = usePdfViewerCore({
|
|
32
37
|
src,
|
|
38
|
+
defaultPage,
|
|
33
39
|
initialPage,
|
|
40
|
+
defaultScale,
|
|
34
41
|
initialScale,
|
|
42
|
+
defaultAutoSize,
|
|
35
43
|
initialAutoSize
|
|
36
44
|
});
|
|
37
45
|
const [rotation, setRotation] = useState(0);
|
|
38
|
-
const [sidebarOpen, setSidebarOpen] = useState(initialSidebarOpen);
|
|
46
|
+
const [sidebarOpen, setSidebarOpen] = useState(defaultSidebarOpen ?? initialSidebarOpen);
|
|
39
47
|
const [sidebarMode, setSidebarMode] = useState(sidebarModeProp);
|
|
40
48
|
const search = usePdfViewerSearch(core.eventBusRef, core.findControllerRef, core.document);
|
|
41
49
|
const outlineItems = usePdfOutline(core.document);
|