@osdk/react-components 0.2.0-beta.23 → 0.2.0-beta.25

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.
Files changed (115) hide show
  1. package/AGENTS.md +3 -0
  2. package/CHANGELOG.md +29 -0
  3. package/build/browser/action-form/FormFieldApi.js.map +1 -1
  4. package/build/browser/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
  5. package/build/browser/action-form/fields/BaseInput.module.css.js +6 -0
  6. package/build/browser/action-form/fields/FormFieldRenderer.js +26 -8
  7. package/build/browser/action-form/fields/FormFieldRenderer.js.map +1 -1
  8. package/build/browser/action-form/fields/RadioButtonsField.js +57 -0
  9. package/build/browser/action-form/fields/RadioButtonsField.js.map +1 -0
  10. package/build/browser/action-form/fields/RadioButtonsField.module.css +83 -0
  11. package/build/browser/action-form/fields/RadioButtonsField.module.css.js +10 -0
  12. package/build/browser/action-form/fields/TextAreaField.js +50 -0
  13. package/build/browser/action-form/fields/TextAreaField.js.map +1 -0
  14. package/build/browser/action-form/fields/TextInputField.js +3 -3
  15. package/build/browser/action-form/fields/TextInputField.js.map +1 -1
  16. package/build/browser/pdf-viewer/PdfViewer.js +40 -4
  17. package/build/browser/pdf-viewer/PdfViewer.js.map +1 -1
  18. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
  19. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
  20. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
  21. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css.js +1 -0
  22. package/build/browser/pdf-viewer/components/PdfViewerContent.js +15 -3
  23. package/build/browser/pdf-viewer/components/PdfViewerContent.js.map +1 -1
  24. package/build/browser/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
  25. package/build/browser/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
  26. package/build/browser/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
  27. package/build/browser/pdf-viewer/components/PdfViewerToolbar.js +29 -2
  28. package/build/browser/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
  29. package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
  30. package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css.js +1 -0
  31. package/build/browser/pdf-viewer/constants.js +2 -1
  32. package/build/browser/pdf-viewer/constants.js.map +1 -1
  33. package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
  34. package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
  35. package/build/browser/pdf-viewer/hooks/usePdfFormFields.js +326 -0
  36. package/build/browser/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
  37. package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js +199 -0
  38. package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
  39. package/build/browser/pdf-viewer/hooks/usePdfViewer.js +16 -10
  40. package/build/browser/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
  41. package/build/browser/pdf-viewer/types.js.map +1 -1
  42. package/build/browser/public/experimental.js +3 -0
  43. package/build/browser/public/experimental.js.map +1 -1
  44. package/build/browser/styles.css +144 -35
  45. package/build/cjs/public/experimental.cjs +1735 -1109
  46. package/build/cjs/public/experimental.cjs.map +1 -1
  47. package/build/cjs/public/experimental.css +82 -5
  48. package/build/cjs/public/experimental.css.map +1 -1
  49. package/build/cjs/public/experimental.d.cts +154 -20
  50. package/build/esm/action-form/FormFieldApi.js.map +1 -1
  51. package/build/esm/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
  52. package/build/esm/action-form/fields/FormFieldRenderer.js +26 -8
  53. package/build/esm/action-form/fields/FormFieldRenderer.js.map +1 -1
  54. package/build/esm/action-form/fields/RadioButtonsField.js +57 -0
  55. package/build/esm/action-form/fields/RadioButtonsField.js.map +1 -0
  56. package/build/esm/action-form/fields/RadioButtonsField.module.css +83 -0
  57. package/build/esm/action-form/fields/TextAreaField.js +50 -0
  58. package/build/esm/action-form/fields/TextAreaField.js.map +1 -0
  59. package/build/esm/action-form/fields/TextInputField.js +3 -3
  60. package/build/esm/action-form/fields/TextInputField.js.map +1 -1
  61. package/build/esm/pdf-viewer/PdfViewer.js +40 -4
  62. package/build/esm/pdf-viewer/PdfViewer.js.map +1 -1
  63. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
  64. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
  65. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
  66. package/build/esm/pdf-viewer/components/PdfViewerContent.js +15 -3
  67. package/build/esm/pdf-viewer/components/PdfViewerContent.js.map +1 -1
  68. package/build/esm/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
  69. package/build/esm/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
  70. package/build/esm/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
  71. package/build/esm/pdf-viewer/components/PdfViewerToolbar.js +29 -2
  72. package/build/esm/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
  73. package/build/esm/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
  74. package/build/esm/pdf-viewer/constants.js +2 -1
  75. package/build/esm/pdf-viewer/constants.js.map +1 -1
  76. package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
  77. package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
  78. package/build/esm/pdf-viewer/hooks/usePdfFormFields.js +326 -0
  79. package/build/esm/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
  80. package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js +199 -0
  81. package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
  82. package/build/esm/pdf-viewer/hooks/usePdfViewer.js +16 -10
  83. package/build/esm/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
  84. package/build/esm/pdf-viewer/types.js.map +1 -1
  85. package/build/esm/public/experimental.js +3 -0
  86. package/build/esm/public/experimental.js.map +1 -1
  87. package/build/types/action-form/FormFieldApi.d.ts +8 -2
  88. package/build/types/action-form/FormFieldApi.d.ts.map +1 -1
  89. package/build/types/action-form/fields/FormFieldRenderer.d.ts.map +1 -1
  90. package/build/types/action-form/fields/RadioButtonsField.d.ts +3 -0
  91. package/build/types/action-form/fields/RadioButtonsField.d.ts.map +1 -0
  92. package/build/types/action-form/fields/TextAreaField.d.ts +3 -0
  93. package/build/types/action-form/fields/TextAreaField.d.ts.map +1 -0
  94. package/build/types/pdf-viewer/PdfViewer.d.ts +1 -1
  95. package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -1
  96. package/build/types/pdf-viewer/components/PdfViewerAnnotationLayer.d.ts.map +1 -1
  97. package/build/types/pdf-viewer/components/PdfViewerContent.d.ts +8 -4
  98. package/build/types/pdf-viewer/components/PdfViewerContent.d.ts.map +1 -1
  99. package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts +6 -1
  100. package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts.map +1 -1
  101. package/build/types/pdf-viewer/constants.d.ts +1 -1
  102. package/build/types/pdf-viewer/constants.d.ts.map +1 -1
  103. package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts +5 -0
  104. package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts.map +1 -0
  105. package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts +24 -0
  106. package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts.map +1 -0
  107. package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts +35 -0
  108. package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts.map +1 -0
  109. package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts.map +1 -1
  110. package/build/types/pdf-viewer/types.d.ts +90 -13
  111. package/build/types/pdf-viewer/types.d.ts.map +1 -1
  112. package/build/types/public/experimental.d.ts +4 -1
  113. package/build/types/public/experimental.d.ts.map +1 -1
  114. package/package.json +5 -5
  115. package/build/browser/action-form/fields/TextInputField.module.css.js +0 -6
@@ -1 +1 @@
1
- {"version":3,"file":"PdfViewer.js","names":["Error","ErrorIcon","Spin","classnames","React","createPortal","PdfViewerAnnotationLayer","PdfViewerOutlineSidebar","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","EMPTY_ANNOTATION_ARRAY","EMPTY_ANNOTATIONS","usePdfViewerState","styles","BasePdfViewer","src","annotations","onAnnotationClick","onDownload","initialPage","initialScale","initialSidebarOpen","enableDownload","sidebarMode","sidebarModeProp","outlineIcons","className","viewer","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","document","currentPage","numPages","scale","sidebarOpen","onPageChange","scrollToPage","onScaleChange","setScale","onSearchOpen","search","openSearch","onSidebarToggle","toggleSidebar","download","onRotateLeft","rotateLeft","onRotateRight","rotateRight","isSearchOpen","query","totalMatches","currentMatchIndex","onQueryChange","setQuery","onNext","nextMatch","onPrev","prevMatch","onClose","closeSearch","contentArea","onPageClick","onSidebarModeChange","setSidebarMode","outlineItems","onItemClick","scrollContainerWrapper","ref","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key","pageHeight","container"],"sources":["PdfViewer.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\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { PdfViewerAnnotationLayer } from \"./components/PdfViewerAnnotationLayer.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, EMPTY_ANNOTATIONS } from \"./constants.js\";\nimport { usePdfViewerState } from \"./hooks/usePdfViewerState.js\";\nimport styles from \"./PdfViewer.module.css\";\nimport type { PdfViewerProps } from \"./types.js\";\n\nexport function BasePdfViewer({\n src,\n annotations = EMPTY_ANNOTATIONS,\n onAnnotationClick,\n onDownload,\n initialPage = 1,\n initialScale = 1.0,\n initialSidebarOpen = false,\n enableDownload = false,\n sidebarMode: sidebarModeProp = \"thumbnails\",\n outlineIcons,\n className,\n}: PdfViewerProps): React.ReactElement {\n const viewer = usePdfViewerState({\n src,\n initialPage,\n initialScale,\n initialSidebarOpen,\n sidebarMode: sidebarModeProp,\n onDownload,\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 <PdfViewerToolbar\n currentPage={viewer.currentPage}\n numPages={viewer.numPages}\n scale={viewer.scale}\n sidebarOpen={viewer.sidebarOpen}\n onPageChange={viewer.scrollToPage}\n onScaleChange={viewer.setScale}\n onSearchOpen={viewer.search.openSearch}\n onSidebarToggle={viewer.toggleSidebar}\n onDownload={viewer.download}\n enableDownload={enableDownload}\n onRotateLeft={viewer.rotateLeft}\n onRotateRight={viewer.rotateRight}\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 = annotations[target.pageNumber]\n ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return createPortal(\n <PdfViewerAnnotationLayer\n key={target.pageNumber}\n annotations={pageAnnotations}\n pageHeight={target.pageHeight}\n scale={target.scale}\n onAnnotationClick={onAnnotationClick}\n />,\n target.container,\n );\n })}\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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,cAAe;IAC3C/C,YAAY,EAAEA;EAAa,CAC5B,CACF,eACDtB,KAAA,CAAA4B,aAAA;IAAKL,SAAS,EAAEb,MAAM,CAAC8D;EAAuB,gBAC5CxE,KAAA,CAAA4B,aAAA;IAAK6C,GAAG,EAAEjD,MAAM,CAACkD,YAAa;IAACnD,SAAS,EAAEb,MAAM,CAACiE;EAAgB,gBAC/D3E,KAAA,CAAA4B,aAAA;IAAK6C,GAAG,EAAEjD,MAAM,CAACoD,SAAU;IAACrD,SAAS,EAAC;EAAW,CAAE,CAAC,EACnDC,MAAM,CAACqD,aAAa,CAACC,GAAG,CAAEC,MAAM,IAAK;IACpC,MAAMC,eAAe,GAAGnE,WAAW,CAACkE,MAAM,CAACE,UAAU,CAAC,IACjD1E,sBAAsB;IAC3B,IAAIyE,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBAAOjF,YAAY,cACjBD,KAAA,CAAA4B,aAAA,CAAC1B,wBAAwB;MACvBiF,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvBpE,WAAW,EAAEmE,eAAgB;MAC7BI,UAAU,EAAEL,MAAM,CAACK,UAAW;MAC9B9C,KAAK,EAAEyC,MAAM,CAACzC,KAAM;MACpBxB,iBAAiB,EAAEA;IAAkB,CACtC,CAAC,EACFiE,MAAM,CAACM,SACT,CAAC;EACH,CAAC,CACE,CACF,CACF,CACF,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"PdfViewer.js","names":["Error","ErrorIcon","Spin","classnames","React","createPortal","PdfViewerAnnotationLayer","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","initialSidebarOpen","enableDownload","sidebarMode","sidebarModeProp","outlineIcons","className","viewer","highlightModeActive","toggleHighlightMode","pdfViewerRef","document","enabled","hasFormFields","submitFormData","eventBusRef","annotationsByPage","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","currentPage","numPages","scale","sidebarOpen","onPageChange","scrollToPage","onScaleChange","setScale","onSearchOpen","search","openSearch","onSidebarToggle","toggleSidebar","download","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","ref","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key","pageHeight","container"],"sources":["PdfViewer.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\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { PdfViewerAnnotationLayer } from \"./components/PdfViewerAnnotationLayer.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 styles from \"./PdfViewer.module.css\";\nimport type { PdfViewerProps } from \"./types.js\";\n\nexport function BasePdfViewer({\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 initialSidebarOpen = false,\n enableDownload = false,\n sidebarMode: sidebarModeProp = \"thumbnails\",\n outlineIcons,\n className,\n}: PdfViewerProps): React.ReactElement {\n const viewer = usePdfViewerState({\n src,\n initialPage,\n initialScale,\n initialSidebarOpen,\n sidebarMode: sidebarModeProp,\n onDownload,\n });\n\n const { highlightModeActive, toggleHighlightMode } = usePdfHighlightMode({\n pdfViewerRef: viewer.pdfViewerRef,\n document: viewer.document,\n enabled: enableHighlight,\n onTextHighlight,\n onHighlightDelete,\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 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 sidebarOpen={viewer.sidebarOpen}\n onPageChange={viewer.scrollToPage}\n onScaleChange={viewer.setScale}\n onSearchOpen={viewer.search.openSearch}\n onSidebarToggle={viewer.toggleSidebar}\n onDownload={viewer.download}\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 = annotationsByPage[target.pageNumber]\n ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return createPortal(\n <PdfViewerAnnotationLayer\n key={target.pageNumber}\n annotations={pageAnnotations}\n pageHeight={target.pageHeight}\n scale={target.scale}\n onAnnotationClick={onAnnotationClick}\n />,\n target.container,\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;AACnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,wBAAwB,QAAQ,0CAA0C;AACnF,SAASC,uBAAuB,QAAQ,yCAAyC;AACjF,SAASC,kBAAkB,QAAQ,oCAAoC;AACvE,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,SAASC,uBAAuB,QAAQ,oCAAoC;AAC5E,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,iBAAiB,QAAQ,8BAA8B;AAChE,OAAOC,MAAM,MAAM,wBAAwB;AAG3C,OAAO,SAASC,aAAaA,CAAC;EAC5BC,GAAG;EACHC,WAAW,GAAGR,sBAAsB;EACpCS,iBAAiB;EACjBC,UAAU;EACVC,eAAe,GAAG,KAAK;EACvBC,eAAe;EACfC,iBAAiB;EACjBC,QAAQ;EACRC,YAAY;EACZC,YAAY;EACZC,WAAW,GAAG,CAAC;EACfC,YAAY,GAAG,GAAG;EAClBC,kBAAkB,GAAG,KAAK;EAC1BC,cAAc,GAAG,KAAK;EACtBC,WAAW,EAAEC,eAAe,GAAG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D,cAAe;IAC3C1D,YAAY,EAAEA;EAAa,CAC5B,CACF,eACD9B,KAAA,CAAA6C,aAAA;IAAKd,SAAS,EAAEnB,MAAM,CAAC+E;EAAuB,gBAC5C3F,KAAA,CAAA6C,aAAA;IAAK+C,GAAG,EAAE5D,MAAM,CAAC6D,YAAa;IAAC9D,SAAS,EAAEnB,MAAM,CAACkF;EAAgB,gBAC/D9F,KAAA,CAAA6C,aAAA;IAAK+C,GAAG,EAAE5D,MAAM,CAAC+D,SAAU;IAAChE,SAAS,EAAC;EAAW,CAAE,CAAC,EACnDC,MAAM,CAACgE,aAAa,CAACC,GAAG,CAAEC,MAAM,IAAK;IACpC,MAAMC,eAAe,GAAG1D,iBAAiB,CAACyD,MAAM,CAACE,UAAU,CAAC,IACvD7F,sBAAsB;IAC3B,IAAI4F,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBAAOpG,YAAY,cACjBD,KAAA,CAAA6C,aAAA,CAAC3C,wBAAwB;MACvBoG,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvBrF,WAAW,EAAEoF,eAAgB;MAC7BI,UAAU,EAAEL,MAAM,CAACK,UAAW;MAC9BjD,KAAK,EAAE4C,MAAM,CAAC5C,KAAM;MACpBtC,iBAAiB,EAAEA;IAAkB,CACtC,CAAC,EACFkF,MAAM,CAACM,SACT,CAAC;EACH,CAAC,CACE,CACF,CACF,CACF,CAAC;AAEV","ignoreList":[]}
@@ -17,12 +17,19 @@
17
17
  import classnames from "classnames";
18
18
  import React, { useCallback, useMemo } from "react";
19
19
  import styles from "./PdfViewerAnnotationLayer.module.css.js";
20
- function AnnotationItem({
21
- annotation,
22
- pageHeight,
23
- scale,
24
- onClick
25
- }) {
20
+ /** Convert a single PDF rect (bottom-left origin) to CSS positioning (top-left origin). */
21
+ function computeRectStyle(rect, pageHeight, scale, color) {
22
+ return {
23
+ left: rect.x * scale,
24
+ top: (pageHeight - rect.y - rect.height) * scale,
25
+ width: rect.width * scale,
26
+ height: rect.height * scale,
27
+ ...(color != null ? {
28
+ "--osdk-pdf-annotation-color": color
29
+ } : {})
30
+ };
31
+ }
32
+ function useAnnotationHandlers(annotation, onClick) {
26
33
  const handleClick = useCallback(() => {
27
34
  onClick?.(annotation);
28
35
  }, [onClick, annotation]);
@@ -32,18 +39,45 @@ function AnnotationItem({
32
39
  onClick?.(annotation);
33
40
  }
34
41
  }, [onClick, annotation]);
35
-
36
- // Convert PDF coordinates (bottom-left origin) to CSS (top-left origin)
37
- const style = useMemo(() => ({
38
- left: annotation.rect.x * scale,
39
- top: (pageHeight - annotation.rect.y - annotation.rect.height) * scale,
40
- width: annotation.rect.width * scale,
41
- height: annotation.rect.height * scale,
42
- ...(annotation.color != null ? {
43
- "--osdk-pdf-annotation-color": annotation.color
44
- } : {})
45
- }), [annotation, pageHeight, scale]);
42
+ return {
43
+ handleClick,
44
+ handleKeyDown
45
+ };
46
+ }
47
+ function AnnotationItem({
48
+ annotation,
49
+ pageHeight,
50
+ scale,
51
+ onClick
52
+ }) {
53
+ const {
54
+ handleClick,
55
+ handleKeyDown
56
+ } = useAnnotationHandlers(annotation, onClick);
46
57
  const className = classnames(styles.annotation, styles[annotation.type]);
58
+ const multiRects = annotation.rects;
59
+ const hasMultipleRects = multiRects != null && multiRects.length > 1;
60
+ const style = useMemo(() => computeRectStyle(annotation.rect, pageHeight, scale, annotation.color), [annotation, pageHeight, scale]);
61
+
62
+ // Multi-rect: render a group wrapper with one div per rect
63
+ if (hasMultipleRects) {
64
+ return /*#__PURE__*/React.createElement("div", {
65
+ className: styles.annotationGroup,
66
+ onClick: handleClick,
67
+ onKeyDown: handleKeyDown,
68
+ role: "button",
69
+ tabIndex: 0,
70
+ title: annotation.label,
71
+ "data-annotation-id": annotation.id
72
+ }, multiRects.map((rect, i) => /*#__PURE__*/React.createElement("div", {
73
+ key: i,
74
+ className: className,
75
+ style: computeRectStyle(rect, pageHeight, scale, annotation.color)
76
+ })));
77
+ }
78
+
79
+ // Single rect: existing behavior
80
+
47
81
  return /*#__PURE__*/React.createElement("div", {
48
82
  className: className,
49
83
  style: style,
@@ -55,6 +89,33 @@ function AnnotationItem({
55
89
  "data-annotation-id": annotation.id
56
90
  });
57
91
  }
92
+ function CustomAnnotationItem({
93
+ annotation,
94
+ pageHeight,
95
+ scale,
96
+ onClick
97
+ }) {
98
+ const {
99
+ handleClick,
100
+ handleKeyDown
101
+ } = useAnnotationHandlers(annotation, onClick);
102
+ const style = useMemo(() => computeRectStyle(annotation.rect, pageHeight, scale, undefined), [annotation, pageHeight, scale]);
103
+ const renderProps = useMemo(() => ({
104
+ annotation,
105
+ scale,
106
+ pageHeight
107
+ }), [annotation, scale, pageHeight]);
108
+ return /*#__PURE__*/React.createElement("div", {
109
+ className: styles.annotation,
110
+ style: style,
111
+ onClick: handleClick,
112
+ onKeyDown: handleKeyDown,
113
+ role: "button",
114
+ tabIndex: 0,
115
+ title: annotation.label,
116
+ "data-annotation-id": annotation.id
117
+ }, annotation.render(renderProps));
118
+ }
58
119
  export function PdfViewerAnnotationLayer({
59
120
  annotations,
60
121
  pageHeight,
@@ -63,7 +124,13 @@ export function PdfViewerAnnotationLayer({
63
124
  }) {
64
125
  return /*#__PURE__*/React.createElement("div", {
65
126
  className: styles.annotationLayer
66
- }, annotations.map(annotation => /*#__PURE__*/React.createElement(AnnotationItem, {
127
+ }, annotations.map(annotation => annotation.type === "custom" ? /*#__PURE__*/React.createElement(CustomAnnotationItem, {
128
+ key: annotation.id,
129
+ annotation: annotation,
130
+ pageHeight: pageHeight,
131
+ scale: scale,
132
+ onClick: onAnnotationClick
133
+ }) : /*#__PURE__*/React.createElement(AnnotationItem, {
67
134
  key: annotation.id,
68
135
  annotation: annotation,
69
136
  pageHeight: pageHeight,
@@ -1 +1 @@
1
- {"version":3,"file":"PdfViewerAnnotationLayer.js","names":["classnames","React","useCallback","useMemo","styles","AnnotationItem","annotation","pageHeight","scale","onClick","handleClick","handleKeyDown","e","key","preventDefault","style","left","rect","x","top","y","height","width","color","className","type","createElement","onKeyDown","role","tabIndex","title","label","id","PdfViewerAnnotationLayer","annotations","onAnnotationClick","annotationLayer","map"],"sources":["PdfViewerAnnotationLayer.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 classnames from \"classnames\";\nimport React, { useCallback, useMemo } from \"react\";\nimport type { PdfAnnotation } from \"../types.js\";\nimport styles from \"./PdfViewerAnnotationLayer.module.css\";\n\nexport interface PdfViewerAnnotationLayerProps {\n annotations: PdfAnnotation[];\n pageHeight: number;\n scale: number;\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n}\n\ninterface AnnotationItemProps {\n annotation: PdfAnnotation;\n pageHeight: number;\n scale: number;\n onClick?: (annotation: PdfAnnotation) => void;\n}\n\nfunction AnnotationItem({\n annotation,\n pageHeight,\n scale,\n onClick,\n}: AnnotationItemProps): React.ReactElement {\n const handleClick = useCallback(() => {\n onClick?.(annotation);\n }, [onClick, annotation]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n onClick?.(annotation);\n }\n },\n [onClick, annotation],\n );\n\n // Convert PDF coordinates (bottom-left origin) to CSS (top-left origin)\n const style = useMemo(\n () => ({\n left: annotation.rect.x * scale,\n top: (pageHeight - annotation.rect.y - annotation.rect.height) * scale,\n width: annotation.rect.width * scale,\n height: annotation.rect.height * scale,\n ...(annotation.color != null\n ? {\n \"--osdk-pdf-annotation-color\": annotation.color,\n } as React.CSSProperties\n : {}),\n }),\n [annotation, pageHeight, scale],\n );\n\n const className = classnames(\n styles.annotation,\n styles[annotation.type],\n );\n\n return (\n <div\n className={className}\n style={style}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n />\n );\n}\n\nexport function PdfViewerAnnotationLayer({\n annotations,\n pageHeight,\n scale,\n onAnnotationClick,\n}: PdfViewerAnnotationLayerProps): React.ReactElement {\n return (\n <div className={styles.annotationLayer}>\n {annotations.map((annotation) => (\n <AnnotationItem\n key={annotation.id}\n annotation={annotation}\n pageHeight={pageHeight}\n scale={scale}\n onClick={onAnnotationClick}\n />\n ))}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAEnD,OAAOC,MAAM,MAAM,uCAAuC;AAgB1D,SAASC,cAAcA,CAAC;EACtBC,UAAU;EACVC,UAAU;EACVC,KAAK;EACLC;AACmB,CAAC,EAAsB;EAC1C,MAAMC,WAAW,GAAGR,WAAW,CAAC,MAAM;IACpCO,OAAO,GAAGH,UAAU,CAAC;EACvB,CAAC,EAAE,CAACG,OAAO,EAAEH,UAAU,CAAC,CAAC;EAEzB,MAAMK,aAAa,GAAGT,WAAW,CAC9BU,CAAsB,IAAK;IAC1B,IAAIA,CAAC,CAACC,GAAG,KAAK,OAAO,EAAE;MACrBD,CAAC,CAACE,cAAc,CAAC,CAAC;MAClBL,OAAO,GAAGH,UAAU,CAAC;IACvB;EACF,CAAC,EACD,CAACG,OAAO,EAAEH,UAAU,CACtB,CAAC;;EAED;EACA,MAAMS,KAAK,GAAGZ,OAAO,CACnB,OAAO;IACLa,IAAI,EAAEV,UAAU,CAACW,IAAI,CAACC,CAAC,GAAGV,KAAK;IAC/BW,GAAG,EA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,CACF,CACE,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"PdfViewerAnnotationLayer.js","names":["classnames","React","useCallback","useMemo","styles","computeRectStyle","rect","pageHeight","scale","color","left","x","top","y","height","width","useAnnotationHandlers","annotation","onClick","handleClick","handleKeyDown","e","key","preventDefault","AnnotationItem","className","type","multiRects","rects","hasMultipleRects","length","style","createElement","annotationGroup","onKeyDown","role","tabIndex","title","label","id","map","i","CustomAnnotationItem","undefined","renderProps","render","PdfViewerAnnotationLayer","annotations","onAnnotationClick","annotationLayer"],"sources":["PdfViewerAnnotationLayer.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 classnames from \"classnames\";\nimport React, { useCallback, useMemo } from \"react\";\nimport type { PdfAnnotation, PdfCustomAnnotation, PdfRect } from \"../types.js\";\nimport styles from \"./PdfViewerAnnotationLayer.module.css\";\n\nexport interface PdfViewerAnnotationLayerProps {\n annotations: PdfAnnotation[];\n pageHeight: number;\n scale: number;\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n}\n\ninterface AnnotationItemProps {\n annotation: PdfAnnotation;\n pageHeight: number;\n scale: number;\n onClick?: (annotation: PdfAnnotation) => void;\n}\n\n/** Convert a single PDF rect (bottom-left origin) to CSS positioning (top-left origin). */\nfunction computeRectStyle(\n rect: PdfRect,\n pageHeight: number,\n scale: number,\n color: string | undefined,\n): React.CSSProperties {\n return {\n left: rect.x * scale,\n top: (pageHeight - rect.y - rect.height) * scale,\n width: rect.width * scale,\n height: rect.height * scale,\n ...(color != null\n ? { \"--osdk-pdf-annotation-color\": color } as React.CSSProperties\n : {}),\n };\n}\n\nfunction useAnnotationHandlers(\n annotation: PdfAnnotation,\n onClick?: (annotation: PdfAnnotation) => void,\n) {\n const handleClick = useCallback(() => {\n onClick?.(annotation);\n }, [onClick, annotation]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n onClick?.(annotation);\n }\n },\n [onClick, annotation],\n );\n\n return { handleClick, handleKeyDown };\n}\n\nfunction AnnotationItem({\n annotation,\n pageHeight,\n scale,\n onClick,\n}: AnnotationItemProps): React.ReactElement {\n const { handleClick, handleKeyDown } = useAnnotationHandlers(\n annotation,\n onClick,\n );\n\n const className = classnames(\n styles.annotation,\n styles[annotation.type],\n );\n\n const multiRects = annotation.rects;\n const hasMultipleRects = multiRects != null && multiRects.length > 1;\n\n const style = useMemo(\n () =>\n computeRectStyle(annotation.rect, pageHeight, scale, annotation.color),\n [annotation, pageHeight, scale],\n );\n\n // Multi-rect: render a group wrapper with one div per rect\n if (hasMultipleRects) {\n return (\n <div\n className={styles.annotationGroup}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n >\n {multiRects.map((rect, i) => (\n <div\n key={i}\n className={className}\n style={computeRectStyle(\n rect,\n pageHeight,\n scale,\n annotation.color,\n )}\n />\n ))}\n </div>\n );\n }\n\n // Single rect: existing behavior\n\n return (\n <div\n className={className}\n style={style}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n />\n );\n}\n\nfunction CustomAnnotationItem({\n annotation,\n pageHeight,\n scale,\n onClick,\n}: AnnotationItemProps & {\n annotation: PdfCustomAnnotation;\n}): React.ReactElement {\n const { handleClick, handleKeyDown } = useAnnotationHandlers(\n annotation,\n onClick,\n );\n\n const style = useMemo(\n () => computeRectStyle(annotation.rect, pageHeight, scale, undefined),\n [annotation, pageHeight, scale],\n );\n\n const renderProps = useMemo(\n () => ({ annotation, scale, pageHeight }),\n [annotation, scale, pageHeight],\n );\n\n return (\n <div\n className={styles.annotation}\n style={style}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n >\n {annotation.render(renderProps)}\n </div>\n );\n}\n\nexport function PdfViewerAnnotationLayer({\n annotations,\n pageHeight,\n scale,\n onAnnotationClick,\n}: PdfViewerAnnotationLayerProps): React.ReactElement {\n return (\n <div className={styles.annotationLayer}>\n {annotations.map((annotation) =>\n annotation.type === \"custom\"\n ? (\n <CustomAnnotationItem\n key={annotation.id}\n annotation={annotation}\n pageHeight={pageHeight}\n scale={scale}\n onClick={onAnnotationClick}\n />\n )\n : (\n <AnnotationItem\n key={annotation.id}\n annotation={annotation}\n pageHeight={pageHeight}\n scale={scale}\n onClick={onAnnotationClick}\n />\n )\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAEnD,OAAOC,MAAM,MAAM,uCAAuC;AAgB1D;AACA,SAASC,gBAAgBA,CACvBC,IAAa,EACbC,UAAkB,EAClBC,KAAa,EACbC,KAAyB,EACJ;EACrB,OAAO;IACLC,IAAI,EAAEJ,IAAI,CAACK,CAAC,GAAGH,KAAK;IACpBI,GAAG,EAAE,CAACL,UAAU,GAAGD,IAAI,CAACO,CAAC,GAAGP,IAAI,CAACQ,MAAM,IAAIN,KAAK;IAChDO,KAAK,EAAET,IAAI,CAACS,KAAK,GAAGP,KAAK;IACzBM,MAAM,EAAER,IAAI,CAACQ,MAAM,GAAGN,KAAK;IAC3B,IAAIC,KAAK,IAAI,IAAI,GACb;M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EACzC,CAACU,UAAU,EAAET,KAAK,EAAED,UAAU,CAChC,CAAC;EAED,oBACEN,KAAA,CAAA+B,aAAA;IACEP,SAAS,EAAErB,MAAM,CAACa,UAAW;IAC7Bc,KAAK,EAAEA,KAAM;IACbb,OAAO,EAAEC,WAAY;IACrBe,SAAS,EAAEd,aAAc;IACzBe,IAAI,EAAC,QAAQ;IACbC,QAAQ,EAAE,CAAE;IACZC,KAAK,EAAEpB,UAAU,CAACqB,KAAM;IACxB,sBAAoBrB,UAAU,CAACsB;EAAG,GAEjCtB,UAAU,CAAC4B,MAAM,CAACD,WAAW,CAC3B,CAAC;AAEV;AAEA,OAAO,SAASE,wBAAwBA,CAAC;EACvCC,WAAW;EACXxC,UAAU;EACVC,KAAK;EACLwC;AAC6B,CAAC,EAAsB;EACpD,oBACE/C,KAAA,CAAA+B,aAAA;IAAKP,SAAS,EAAErB,MAAM,CAAC6C;EAAgB,GACpCF,WAAW,CAACP,GAAG,CAAEvB,UAAU,IAC1BA,UAAU,CAACS,IAAI,KAAK,QAAQ,gBAExBzB,KAAA,CAAA+B,aAAA,CAACU,oBAAoB;IACnBpB,GAAG,EAAEL,UAAU,CAACsB,EAAG;IACnBtB,UAAU,EAAEA,UAAW;IACvBV,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbU,OAAO,EAAE8B;EAAkB,CAC5B,CAAC,gBAGF/C,KAAA,CAAA+B,aAAA,CAACR,cAAc;IACbF,GAAG,EAAEL,UAAU,CAACsB,EAAG;IACnBtB,UAAU,EAAEA,UAAW;IACvBV,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbU,OAAO,EAAE8B;EAAkB,CAC5B,CAEP,CACG,CAAC;AAEV","ignoreList":[]}
@@ -8,6 +8,24 @@
8
8
  z-index: 3;
9
9
  }
10
10
 
11
+ .annotationGroup {
12
+ position: absolute;
13
+ top: 0;
14
+ left: 0;
15
+ width: 100%;
16
+ height: 100%;
17
+ pointer-events: none;
18
+ }
19
+
20
+ .annotationGroup:focus-visible {
21
+ outline: var(--osdk-focus-outline);
22
+ outline-offset: var(--osdk-focus-visible-outline-offset);
23
+ }
24
+
25
+ .annotationGroup .annotation {
26
+ pointer-events: auto;
27
+ }
28
+
11
29
  .annotation {
12
30
  position: absolute;
13
31
  pointer-events: auto;
@@ -1,6 +1,7 @@
1
1
  // CSS Module proxy for PdfViewerAnnotationLayer.module.css
2
2
  const styles = {
3
3
  "annotationLayer": "PdfViewerAnnotationLayer-module__annotationLayer___mljRfBSQ",
4
+ "annotationGroup": "PdfViewerAnnotationLayer-module__annotationGroup___CiaFrKH5",
4
5
  "annotation": "PdfViewerAnnotationLayer-module__annotation___1dAkVbQ8",
5
6
  "highlight": "PdfViewerAnnotationLayer-module__highlight___uPiyo2kN",
6
7
  "underline": "PdfViewerAnnotationLayer-module__underline___-qCk9Jld",
@@ -19,18 +19,22 @@ import classnames from "classnames";
19
19
  import "pdfjs-dist/web/pdf_viewer.css";
20
20
  import React, { useEffect, useRef } from "react";
21
21
  import { createPortal } from "react-dom";
22
- import { EMPTY_ANNOTATION_ARRAY, EMPTY_ANNOTATIONS } from "../constants.js";
22
+ import { EMPTY_ANNOTATION_ARRAY } from "../constants.js";
23
+ import { usePdfAnnotationsByPage } from "../hooks/usePdfAnnotationsByPage.js";
24
+ import { usePdfFormFields } from "../hooks/usePdfFormFields.js";
23
25
  import { usePdfViewerCore } from "../hooks/usePdfViewerCore.js";
24
26
  import styles from "../PdfViewer.module.css.js";
25
27
  import { PdfViewerAnnotationLayer } from "./PdfViewerAnnotationLayer.js";
26
28
  export function PdfViewerContent({
27
29
  src,
28
- annotations = EMPTY_ANNOTATIONS,
30
+ annotations = EMPTY_ANNOTATION_ARRAY,
29
31
  onAnnotationClick,
30
32
  initialPage = 1,
31
33
  initialScale = 1.0,
32
34
  onPageChange: onPageChangeProp,
33
35
  onScaleChange: onScaleChangeProp,
36
+ formData,
37
+ onFormChange,
34
38
  className
35
39
  }) {
36
40
  const viewer = usePdfViewerCore({
@@ -38,6 +42,14 @@ export function PdfViewerContent({
38
42
  initialPage,
39
43
  initialScale
40
44
  });
45
+ const annotationsByPage = usePdfAnnotationsByPage(annotations);
46
+ usePdfFormFields({
47
+ pdfViewerRef: viewer.pdfViewerRef,
48
+ eventBusRef: viewer.eventBusRef,
49
+ document: viewer.document,
50
+ formData,
51
+ onFormChange
52
+ });
41
53
 
42
54
  // Use refs for callbacks to avoid firing on initial mount
43
55
  const onPageChangeRef = useRef(onPageChangeProp);
@@ -97,7 +109,7 @@ export function PdfViewerContent({
97
109
  ref: viewer.viewerRef,
98
110
  className: "pdfViewer"
99
111
  }), viewer.portalTargets.map(target => {
100
- const pageAnnotations = annotations[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;
112
+ const pageAnnotations = annotationsByPage[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;
101
113
  if (pageAnnotations.length === 0) {
102
114
  return null;
103
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PdfViewerContent.js","names":["Error","ErrorIcon","Spin","classnames","React","useEffect","useRef","createPortal","EMPTY_ANNOTATION_ARRAY","EMPTY_ANNOTATIONS","usePdfViewerCore","styles","PdfViewerAnnotationLayer","PdfViewerContent","src","annotations","onAnnotationClick","initialPage","initialScale","onPageChange","onPageChangeProp","onScaleChange","onScaleChangeProp","className","viewer","onPageChangeRef","current","onScaleChangeRef","isInitialMountRef","currentPage","scale","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","document","scrollContainerWrapper","ref","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key","pageHeight","container"],"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\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { useEffect, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { EMPTY_ANNOTATION_ARRAY, EMPTY_ANNOTATIONS } from \"../constants.js\";\nimport { usePdfViewerCore } from \"../hooks/usePdfViewerCore.js\";\nimport styles from \"../PdfViewer.module.css\";\nimport type { PdfAnnotation } from \"../types.js\";\nimport { PdfViewerAnnotationLayer } from \"./PdfViewerAnnotationLayer.js\";\n\nexport interface PdfViewerContentProps {\n /** PDF source — URL string or ArrayBuffer */\n src: string | ArrayBuffer;\n /** Annotations to overlay on the PDF, keyed by page number (1-indexed) */\n annotations?: Record<number, 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 /** Additional CSS class name for the root element */\n className?: string;\n}\n\nexport function PdfViewerContent({\n src,\n annotations = EMPTY_ANNOTATIONS,\n onAnnotationClick,\n initialPage = 1,\n initialScale = 1.0,\n onPageChange: onPageChangeProp,\n onScaleChange: onScaleChangeProp,\n className,\n}: PdfViewerContentProps): React.ReactElement {\n const viewer = usePdfViewerCore({ src, initialPage, initialScale });\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(function notifyPageChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onPageChangeRef.current?.(viewer.currentPage);\n }, [viewer.currentPage]);\n\n useEffect(function notifyScaleChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onScaleChangeRef.current?.(viewer.scale);\n }, [viewer.scale]);\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 = annotations[target.pageNumber]\n ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return createPortal(\n <PdfViewerAnnotationLayer\n key={target.pageNumber}\n annotations={pageAnnotations}\n pageHeight={target.pageHeight}\n scale={target.scale}\n onAnnotationClick={onAnnotationClick}\n />,\n target.container,\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;AACnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,IAAIC,S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AM,CAACkC;EAAgB,gBAC/DzC,KAAA,CAAA8B,aAAA;IAAKS,GAAG,EAAEnB,MAAM,CAACsB,SAAU;IAACvB,SAAS,EAAC;EAAW,CAAE,CAAC,EACnDC,MAAM,CAACuB,aAAa,CAACC,GAAG,CAAEC,MAAM,IAAK;IACpC,MAAMC,eAAe,GAAGnC,WAAW,CAACkC,MAAM,CAACE,UAAU,CAAC,IACjD3C,sBAAsB;IAC3B,IAAI0C,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBAAO7C,YAAY,cACjBH,KAAA,CAAA8B,aAAA,CAACtB,wBAAwB;MACvByC,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvBpC,WAAW,EAAEmC,eAAgB;MAC7BI,UAAU,EAAEL,MAAM,CAACK,UAAW;MAC9BxB,KAAK,EAAEmB,MAAM,CAACnB,KAAM;MACpBd,iBAAiB,EAAEA;IAAkB,CACtC,CAAC,EACFiC,MAAM,CAACM,SACT,CAAC;EACH,CAAC,CACE,CACF,CACF,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"PdfViewerContent.js","names":["Error","ErrorIcon","Spin","classnames","React","useEffect","useRef","createPortal","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfViewerCore","styles","PdfViewerAnnotationLayer","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","pageHeight","container"],"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\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { useEffect, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\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 styles from \"../PdfViewer.module.css\";\nimport type { PdfAnnotation, PdfFormFieldValue } from \"../types.js\";\nimport { PdfViewerAnnotationLayer } from \"./PdfViewerAnnotationLayer.js\";\n\nexport interface PdfViewerContentProps {\n /** PDF source — URL string or ArrayBuffer */\n src: string | ArrayBuffer;\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,\n initialScale = 1.0,\n onPageChange: onPageChangeProp,\n onScaleChange: onScaleChangeProp,\n formData,\n onFormChange,\n className,\n}: PdfViewerContentProps): React.ReactElement {\n const viewer = usePdfViewerCore({ src, initialPage, initialScale });\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(function notifyPageChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onPageChangeRef.current?.(viewer.currentPage);\n }, [viewer.currentPage]);\n\n useEffect(function notifyScaleChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onScaleChangeRef.current?.(viewer.scale);\n }, [viewer.scale]);\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 = annotationsByPage[target.pageNumber]\n ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return createPortal(\n <PdfViewerAnnotationLayer\n key={target.pageNumber}\n annotations={pageAnnotations}\n pageHeight={target.pageHeight}\n scale={target.scale}\n onAnnotationClick={onAnnotationClick}\n />,\n target.container,\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;AACnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,sBAAsB,QAAQ,iBAAiB;AACxD,SAASC,uBAAuB,QAAQ,qCAAqC;AAC7E,SAASC,gBAAgB,QAAQ,8BAA8B;AAC/D,SAASC,gBAAgB,QAAQ,8BAA8B;AAC/D,OAAOC,MAAM,MAAM,yBAAyB;AAE5C,SAASC,wBAAwB,QAAQ,+BAA+B;AAyBxE,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,GAAG;EACHC,WAAW,GAAGR,sBAAsB;EACpCS,iBAAiB;EACjBC,WAAW,GAAG,CAAC;EACfC,YAAY,GAAG,GAAG;EAClBC,YAAY,EAAEC,gBAAgB;EAC9BC,aAAa,EAAEC,iBAAiB;EAChCC,QAAQ;EACRC,YAAY;EACZC;AACqB,CAAC,EAAsB;EAC5C,MAAMC,MAAM,GAAGhB,gBAAgB,CAAC;IAAEI,GAAG;IAAEG,WAAW;IAAEC;EAAa,CAAC,CAAC;EACnE,MAAMS,iBAAiB,GAAGnB,uBAAuB,CAACO,WAAW,CAAC;EAE9DN,gBAAgB,CAAC;IACfmB,YAAY,EAAEF,MAAM,CAACE,YAAY;IACjCC,WAAW,EAAE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MACvBzC,WAAW,EAAEwC,eAAgB;MAC7BI,UAAU,EAAEL,MAAM,CAACK,UAAW;MAC9BvB,KAAK,EAAEkB,MAAM,CAAClB,KAAM;MACpBpB,iBAAiB,EAAEA;IAAkB,CACtC,CAAC,EACFsC,MAAM,CAACM,SACT,CAAC;EACH,CAAC,CACE,CACF,CACF,CAAC;AAEV","ignoreList":[]}
@@ -4,7 +4,7 @@
4
4
  display: flex;
5
5
  flex-direction: column;
6
6
  background-color: var(--osdk-pdf-viewer-sidebar-bg);
7
- border-right: 1px solid var(--osdk-pdf-viewer-sidebar-border);
7
+ border-right: var(--osdk-pdf-viewer-sidebar-border);
8
8
  overflow: hidden;
9
9
  }
10
10
 
@@ -4,7 +4,7 @@
4
4
  display: flex;
5
5
  flex-direction: column;
6
6
  background-color: var(--osdk-pdf-viewer-sidebar-bg);
7
- border-right: 1px solid var(--osdk-pdf-viewer-sidebar-border);
7
+ border-right: var(--osdk-pdf-viewer-sidebar-border);
8
8
  overflow: hidden;
9
9
  }
10
10
 
@@ -28,7 +28,7 @@
28
28
  align-items: center;
29
29
  gap: var(--osdk-spacing-2xs, 2px);
30
30
  padding: var(--osdk-spacing-2xs, 2px);
31
- border: 1px solid var(--osdk-surface-border-color, rgba(0, 0, 0, 0.15));
31
+ border: none;
32
32
  border-radius: var(--osdk-surface-border-radius);
33
33
  background-color: var(--osdk-surface-background-color, transparent);
34
34
  }
@@ -16,7 +16,8 @@
16
16
 
17
17
  import { Button } from "@base-ui/react/button";
18
18
  import { Input } from "@base-ui/react/input";
19
- import { ChevronLeft, ChevronRight, Download, Menu, Minus, Plus, RotatePage, Search } from "@blueprintjs/icons";
19
+ import { ChevronLeft, ChevronRight, Download, FloppyDisk, Highlight, Menu, Minus, Plus, RotatePage, Search } from "@blueprintjs/icons";
20
+ import classnames from "classnames";
20
21
  import React, { useCallback, useEffect, useState } from "react";
21
22
  import { MAX_SCALE, MIN_SCALE, SCALE_STEP } from "../constants.js";
22
23
  import styles from "./PdfViewerToolbar.module.css.js";
@@ -32,7 +33,12 @@ export function PdfViewerToolbar({
32
33
  onDownload,
33
34
  enableDownload,
34
35
  onRotateLeft,
35
- onRotateRight
36
+ onRotateRight,
37
+ enableHighlight,
38
+ highlightModeActive,
39
+ onHighlightToggle,
40
+ enableFormSave = false,
41
+ onFormSave
36
42
  }) {
37
43
  const [pageInputValue, setPageInputValue] = useState(String(currentPage));
38
44
 
@@ -169,6 +175,17 @@ export function PdfViewerToolbar({
169
175
  style: {
170
176
  transform: "scaleX(-1)"
171
177
  }
178
+ }))), enableHighlight && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
179
+ className: styles.separator
180
+ }), /*#__PURE__*/React.createElement(Button, {
181
+ className: classnames(styles.toolbarButton, highlightModeActive && styles.toolbarButtonActive),
182
+ onClick: onHighlightToggle,
183
+ "aria-label": highlightModeActive ? "Disable highlight mode" : "Enable highlight mode",
184
+ title: highlightModeActive ? "Disable highlight mode" : "Enable highlight mode",
185
+ "aria-pressed": highlightModeActive,
186
+ type: "button"
187
+ }, /*#__PURE__*/React.createElement(Highlight, {
188
+ size: 16
172
189
  }))), /*#__PURE__*/React.createElement("div", {
173
190
  className: styles.separator
174
191
  }), /*#__PURE__*/React.createElement(Button, {
@@ -189,6 +206,16 @@ export function PdfViewerToolbar({
189
206
  type: "button"
190
207
  }, /*#__PURE__*/React.createElement(Download, {
191
208
  size: 16
209
+ }))), enableFormSave && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
210
+ className: styles.separator
211
+ }), /*#__PURE__*/React.createElement(Button, {
212
+ className: styles.toolbarButton,
213
+ onClick: onFormSave,
214
+ "aria-label": "Save form",
215
+ title: "Save form",
216
+ type: "button"
217
+ }, /*#__PURE__*/React.createElement(FloppyDisk, {
218
+ size: 16
192
219
  }))));
193
220
  }
194
221
  //# sourceMappingURL=PdfViewerToolbar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PdfViewerToolbar.js","names":["Button","Input","ChevronLeft","ChevronRight","Download","Menu","Minus","Plus","RotatePage","Search","React","useCallback","useEffect","useState","MAX_SCALE","MIN_SCALE","SCALE_STEP","styles","PdfViewerToolbar","currentPage","numPages","scale","sidebarOpen","onPageChange","onScaleChange","onSearchOpen","onSidebarToggle","onDownload","enableDownload","onRotateLeft","onRotateRight","pageInputValue","setPageInputValue","String","handlePrevPage","newPage","handleNextPage","handlePageInputChange","e","target","value","handlePageInputKeyDown","key","page","parseInt","isNaN","handlePageInputBlur","handleZoomIn","newScale","Math","min","handleZoomOut","max","scalePercent","round","createElement","className","toolbar","toolbarButton","onClick","title","type","size","separator","toolbarGroup","disabled","pageInput","onChange","onKeyDown","onBlur","pageCount","scaleDisplay","style","transform","Fragment"],"sources":["PdfViewerToolbar.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 { Button } from \"@base-ui/react/button\";\nimport { Input } from \"@base-ui/react/input\";\nimport {\n ChevronLeft,\n ChevronRight,\n Download,\n Menu,\n Minus,\n Plus,\n RotatePage,\n Search,\n} from \"@blueprintjs/icons\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport { MAX_SCALE, MIN_SCALE, SCALE_STEP } from \"../constants.js\";\nimport styles from \"./PdfViewerToolbar.module.css\";\n\nexport interface PdfViewerToolbarProps {\n currentPage: number;\n numPages: number;\n scale: number;\n sidebarOpen: boolean;\n onPageChange: (page: number) => void;\n onScaleChange: (scale: number) => void;\n onSearchOpen: () => void;\n onSidebarToggle: () => void;\n onDownload: () => void;\n enableDownload: boolean;\n onRotateLeft: () => void;\n onRotateRight: () => void;\n}\n\nexport function PdfViewerToolbar({\n currentPage,\n numPages,\n scale,\n sidebarOpen,\n onPageChange,\n onScaleChange,\n onSearchOpen,\n onSidebarToggle,\n onDownload,\n enableDownload,\n onRotateLeft,\n onRotateRight,\n}: PdfViewerToolbarProps): React.ReactElement {\n const [pageInputValue, setPageInputValue] = useState(String(currentPage));\n\n // Sync input display when currentPage changes from scrolling\n useEffect(function syncPageInput() {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handlePrevPage = useCallback(() => {\n if (currentPage > 1) {\n const newPage = currentPage - 1;\n onPageChange(newPage);\n setPageInputValue(String(newPage));\n }\n }, [currentPage, onPageChange]);\n\n const handleNextPage = useCallback(() => {\n if (currentPage < numPages) {\n const newPage = currentPage + 1;\n onPageChange(newPage);\n setPageInputValue(String(newPage));\n }\n }, [currentPage, numPages, onPageChange]);\n\n const handlePageInputChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setPageInputValue(e.target.value);\n },\n [],\n );\n\n const handlePageInputKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\") {\n const page = parseInt(pageInputValue, 10);\n if (!isNaN(page) && page >= 1 && page <= numPages) {\n onPageChange(page);\n } else {\n setPageInputValue(String(currentPage));\n }\n }\n },\n [pageInputValue, numPages, onPageChange, currentPage],\n );\n\n const handlePageInputBlur = useCallback(() => {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handleZoomIn = useCallback(() => {\n const newScale = Math.min(scale + SCALE_STEP, MAX_SCALE);\n onScaleChange(newScale);\n }, [scale, onScaleChange]);\n\n const handleZoomOut = useCallback(() => {\n const newScale = Math.max(scale - SCALE_STEP, MIN_SCALE);\n onScaleChange(newScale);\n }, [scale, onScaleChange]);\n\n const scalePercent = `${Math.round(scale * 100)}%`;\n\n return (\n <div className={styles.toolbar}>\n <Button\n className={styles.toolbarButton}\n onClick={onSidebarToggle}\n aria-label={sidebarOpen ? \"Close sidebar\" : \"Open sidebar\"}\n title={sidebarOpen ? \"Close sidebar\" : \"Open sidebar\"}\n aria-pressed={sidebarOpen}\n type=\"button\"\n >\n <Menu size={16} />\n </Button>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={handlePrevPage}\n disabled={currentPage <= 1}\n aria-label=\"Previous page\"\n title=\"Previous page\"\n type=\"button\"\n >\n <ChevronLeft size={16} />\n </Button>\n <Input\n className={styles.pageInput}\n type=\"text\"\n value={pageInputValue}\n onChange={handlePageInputChange}\n onKeyDown={handlePageInputKeyDown}\n onBlur={handlePageInputBlur}\n aria-label=\"Page number\"\n />\n <span className={styles.pageCount}>of {numPages}</span>\n <Button\n className={styles.toolbarButton}\n onClick={handleNextPage}\n disabled={currentPage >= numPages}\n aria-label=\"Next page\"\n title=\"Next page\"\n type=\"button\"\n >\n <ChevronRight size={16} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={handleZoomOut}\n disabled={scale <= MIN_SCALE}\n aria-label=\"Zoom out\"\n title=\"Zoom out\"\n type=\"button\"\n >\n <Minus size={16} />\n </Button>\n <span className={styles.scaleDisplay}>{scalePercent}</span>\n <Button\n className={styles.toolbarButton}\n onClick={handleZoomIn}\n disabled={scale >= MAX_SCALE}\n aria-label=\"Zoom in\"\n title=\"Zoom in\"\n type=\"button\"\n >\n <Plus size={16} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={onRotateLeft}\n aria-label=\"Rotate left\"\n title=\"Rotate left\"\n type=\"button\"\n >\n <RotatePage size={16} />\n </Button>\n <Button\n className={styles.toolbarButton}\n onClick={onRotateRight}\n aria-label=\"Rotate right\"\n title=\"Rotate right\"\n type=\"button\"\n >\n <RotatePage size={16} style={{ transform: \"scaleX(-1)\" }} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onSearchOpen}\n aria-label=\"Search\"\n title=\"Search\"\n type=\"button\"\n >\n <Search size={16} />\n </Button>\n\n {enableDownload && (\n <>\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onDownload}\n aria-label=\"Download\"\n title=\"Download\"\n type=\"button\"\n >\n <Download size={16} />\n </Button>\n </>\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,KAAK,QAAQ,sBAAsB;AAC5C,SACEC,WAAW,EACXC,YAAY,EACZC,QAAQ,EACRC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,UAAU,EACVC,MAAM,QACD,oBAAoB;AAC3B,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,QAAQ,iBAAiB;AAClE,OAAOC,MAAM,MAAM,+BAA+B;AAiBlD,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,WAAW;EACXC,QAAQ;EACRC,KAAK;EACLC,WAAW;EACXC,YAAY;EACZC,aAAa;EACbC,YAAY;EACZC,eAAe;EACfC,UAAU;EACVC,cAAc;EACdC,YAAY;EACZC;AACqB,CAAC,EAAsB;EAC5C,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAGnB,QAAQ,CAACoB,MAAM,CAACd,WAAW,CAAC,CAAC;;EAEzE;EACAP,SAAS,CAAC,YAAyB;IACjCoB,iBAAiB,CAACC,MAAM,CAACd,WAAW,CAAC,CAAC;EACxC,CAAC,EAAE,CAACA,WAAW,CAAC,CAAC;EAEjB,MAAMe,cAAc,GAAGvB,WAAW,CAAC,MAAM;IACvC,IAAIQ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,EAAE,EAAG;IAACU,KAAK,EAAE;MAAEC,SAAS,EAAE;IAAa;EAAE,CAAE,CACrD,CACL,CAAC,eAEN/D,KAAA,CAAA6C,aAAA;IAAKC,SAAS,EAAEvC,MAAM,CAAC8C;EAAU,CAAE,CAAC,eAEpCrD,KAAA,CAAA6C,aAAA,CAACvD,MAAM;IACLwD,SAAS,EAAEvC,MAAM,CAACyC,aAAc;IAChCC,OAAO,EAAElC,YAAa;IACtB,cAAW,QAAQ;IACnBmC,KAAK,EAAC,QAAQ;IACdC,IAAI,EAAC;EAAQ,gBAEbnD,KAAA,CAAA6C,aAAA,CAAC9C,MAAM;IAACqD,IAAI,EAAE;EAAG,CAAE,CACb,CAAC,EAERlC,cAAc,iBACblB,KAAA,CAAA6C,aAAA,CAAA7C,KAAA,CAAAgE,QAAA,qBACEhE,KAAA,CAAA6C,aAAA;IAAKC,SAAS,EAAEvC,MAAM,CAAC8C;EAAU,CAAE,CAAC,eAEpCrD,KAAA,CAAA6C,aAAA,CAACvD,MAAM;IACLwD,SAAS,EAAEvC,MAAM,CAACyC,aAAc;IAChCC,OAAO,EAAEhC,UAAW;IACpB,cAAW,UAAU;IACrBiC,KAAK,EAAC,UAAU;IAChBC,IAAI,EAAC;EAAQ,gBAEbnD,KAAA,CAAA6C,aAAA,CAACnD,QAAQ;IAAC0D,IAAI,EAAE;EAAG,CAAE,CACf,CACR,CAED,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"PdfViewerToolbar.js","names":["Button","Input","ChevronLeft","ChevronRight","Download","FloppyDisk","Highlight","Menu","Minus","Plus","RotatePage","Search","classnames","React","useCallback","useEffect","useState","MAX_SCALE","MIN_SCALE","SCALE_STEP","styles","PdfViewerToolbar","currentPage","numPages","scale","sidebarOpen","onPageChange","onScaleChange","onSearchOpen","onSidebarToggle","onDownload","enableDownload","onRotateLeft","onRotateRight","enableHighlight","highlightModeActive","onHighlightToggle","enableFormSave","onFormSave","pageInputValue","setPageInputValue","String","handlePrevPage","newPage","handleNextPage","handlePageInputChange","e","target","value","handlePageInputKeyDown","key","page","parseInt","isNaN","handlePageInputBlur","handleZoomIn","newScale","Math","min","handleZoomOut","max","scalePercent","round","createElement","className","toolbar","toolbarButton","onClick","title","type","size","separator","toolbarGroup","disabled","pageInput","onChange","onKeyDown","onBlur","pageCount","scaleDisplay","style","transform","Fragment","toolbarButtonActive"],"sources":["PdfViewerToolbar.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 { Button } from \"@base-ui/react/button\";\nimport { Input } from \"@base-ui/react/input\";\nimport {\n ChevronLeft,\n ChevronRight,\n Download,\n FloppyDisk,\n Highlight,\n Menu,\n Minus,\n Plus,\n RotatePage,\n Search,\n} from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport { MAX_SCALE, MIN_SCALE, SCALE_STEP } from \"../constants.js\";\nimport styles from \"./PdfViewerToolbar.module.css\";\n\nexport interface PdfViewerToolbarProps {\n currentPage: number;\n numPages: number;\n scale: number;\n sidebarOpen: boolean;\n onPageChange: (page: number) => void;\n onScaleChange: (scale: number) => void;\n onSearchOpen: () => void;\n onSidebarToggle: () => void;\n onDownload: () => void;\n enableDownload: boolean;\n onRotateLeft: () => void;\n onRotateRight: () => void;\n enableHighlight: boolean;\n highlightModeActive: boolean;\n onHighlightToggle: () => void;\n enableFormSave?: boolean;\n onFormSave?: () => void;\n}\n\nexport function PdfViewerToolbar({\n currentPage,\n numPages,\n scale,\n sidebarOpen,\n onPageChange,\n onScaleChange,\n onSearchOpen,\n onSidebarToggle,\n onDownload,\n enableDownload,\n onRotateLeft,\n onRotateRight,\n enableHighlight,\n highlightModeActive,\n onHighlightToggle,\n enableFormSave = false,\n onFormSave,\n}: PdfViewerToolbarProps): React.ReactElement {\n const [pageInputValue, setPageInputValue] = useState(String(currentPage));\n\n // Sync input display when currentPage changes from scrolling\n useEffect(function syncPageInput() {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handlePrevPage = useCallback(() => {\n if (currentPage > 1) {\n const newPage = currentPage - 1;\n onPageChange(newPage);\n setPageInputValue(String(newPage));\n }\n }, [currentPage, onPageChange]);\n\n const handleNextPage = useCallback(() => {\n if (currentPage < numPages) {\n const newPage = currentPage + 1;\n onPageChange(newPage);\n setPageInputValue(String(newPage));\n }\n }, [currentPage, numPages, onPageChange]);\n\n const handlePageInputChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setPageInputValue(e.target.value);\n },\n [],\n );\n\n const handlePageInputKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\") {\n const page = parseInt(pageInputValue, 10);\n if (!isNaN(page) && page >= 1 && page <= numPages) {\n onPageChange(page);\n } else {\n setPageInputValue(String(currentPage));\n }\n }\n },\n [pageInputValue, numPages, onPageChange, currentPage],\n );\n\n const handlePageInputBlur = useCallback(() => {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handleZoomIn = useCallback(() => {\n const newScale = Math.min(scale + SCALE_STEP, MAX_SCALE);\n onScaleChange(newScale);\n }, [scale, onScaleChange]);\n\n const handleZoomOut = useCallback(() => {\n const newScale = Math.max(scale - SCALE_STEP, MIN_SCALE);\n onScaleChange(newScale);\n }, [scale, onScaleChange]);\n\n const scalePercent = `${Math.round(scale * 100)}%`;\n\n return (\n <div className={styles.toolbar}>\n <Button\n className={styles.toolbarButton}\n onClick={onSidebarToggle}\n aria-label={sidebarOpen ? \"Close sidebar\" : \"Open sidebar\"}\n title={sidebarOpen ? \"Close sidebar\" : \"Open sidebar\"}\n aria-pressed={sidebarOpen}\n type=\"button\"\n >\n <Menu size={16} />\n </Button>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={handlePrevPage}\n disabled={currentPage <= 1}\n aria-label=\"Previous page\"\n title=\"Previous page\"\n type=\"button\"\n >\n <ChevronLeft size={16} />\n </Button>\n <Input\n className={styles.pageInput}\n type=\"text\"\n value={pageInputValue}\n onChange={handlePageInputChange}\n onKeyDown={handlePageInputKeyDown}\n onBlur={handlePageInputBlur}\n aria-label=\"Page number\"\n />\n <span className={styles.pageCount}>of {numPages}</span>\n <Button\n className={styles.toolbarButton}\n onClick={handleNextPage}\n disabled={currentPage >= numPages}\n aria-label=\"Next page\"\n title=\"Next page\"\n type=\"button\"\n >\n <ChevronRight size={16} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={handleZoomOut}\n disabled={scale <= MIN_SCALE}\n aria-label=\"Zoom out\"\n title=\"Zoom out\"\n type=\"button\"\n >\n <Minus size={16} />\n </Button>\n <span className={styles.scaleDisplay}>{scalePercent}</span>\n <Button\n className={styles.toolbarButton}\n onClick={handleZoomIn}\n disabled={scale >= MAX_SCALE}\n aria-label=\"Zoom in\"\n title=\"Zoom in\"\n type=\"button\"\n >\n <Plus size={16} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={onRotateLeft}\n aria-label=\"Rotate left\"\n title=\"Rotate left\"\n type=\"button\"\n >\n <RotatePage size={16} />\n </Button>\n <Button\n className={styles.toolbarButton}\n onClick={onRotateRight}\n aria-label=\"Rotate right\"\n title=\"Rotate right\"\n type=\"button\"\n >\n <RotatePage size={16} style={{ transform: \"scaleX(-1)\" }} />\n </Button>\n </div>\n\n {enableHighlight && (\n <>\n <div className={styles.separator} />\n\n <Button\n className={classnames(\n styles.toolbarButton,\n highlightModeActive && styles.toolbarButtonActive,\n )}\n onClick={onHighlightToggle}\n aria-label={highlightModeActive\n ? \"Disable highlight mode\"\n : \"Enable highlight mode\"}\n title={highlightModeActive\n ? \"Disable highlight mode\"\n : \"Enable highlight mode\"}\n aria-pressed={highlightModeActive}\n type=\"button\"\n >\n <Highlight size={16} />\n </Button>\n </>\n )}\n\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onSearchOpen}\n aria-label=\"Search\"\n title=\"Search\"\n type=\"button\"\n >\n <Search size={16} />\n </Button>\n\n {enableDownload && (\n <>\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onDownload}\n aria-label=\"Download\"\n title=\"Download\"\n type=\"button\"\n >\n <Download size={16} />\n </Button>\n </>\n )}\n\n {enableFormSave && (\n <>\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onFormSave}\n aria-label=\"Save form\"\n title=\"Save form\"\n type=\"button\"\n >\n <FloppyDisk size={16} />\n </Button>\n </>\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,KAAK,QAAQ,sBAAsB;AAC5C,SACEC,WAAW,EACXC,YAAY,EACZC,QAAQ,EACRC,UAAU,EACVC,SAAS,EACTC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,UAAU,EACVC,MAAM,QACD,oBAAoB;AAC3B,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,QAAQ,iBAAiB;AAClE,OAAOC,MAAM,MAAM,+BAA+B;AAsBlD,OAAO,SAASC,gBAAgBA,CAAC;EA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[]}
@@ -57,6 +57,11 @@
57
57
  cursor: default;
58
58
  }
59
59
 
60
+ .toolbarButtonActive {
61
+ background-color: var(--osdk-surface-background-color-default-active);
62
+ color: var(--osdk-typography-color-default-rest);
63
+ }
64
+
60
65
  .pageInput {
61
66
  width: 48px;
62
67
  text-align: center;
@@ -4,6 +4,7 @@ const styles = {
4
4
  "toolbarGroup": "PdfViewerToolbar-module__toolbarGroup___yCBnXifk",
5
5
  "separator": "PdfViewerToolbar-module__separator___DyiMoFkd",
6
6
  "toolbarButton": "PdfViewerToolbar-module__toolbarButton___BHinMZYh",
7
+ "toolbarButtonActive": "PdfViewerToolbar-module__toolbarButtonActive___lek074gm",
7
8
  "pageInput": "PdfViewerToolbar-module__pageInput___eZDF8KUp",
8
9
  "pageCount": "PdfViewerToolbar-module__pageCount___ChLj67yf",
9
10
  "scaleDisplay": "PdfViewerToolbar-module__scaleDisplay___X3peUnEF"
@@ -15,7 +15,6 @@
15
15
  */
16
16
 
17
17
  // Default empty values (stable references to avoid re-renders)
18
- export const EMPTY_ANNOTATIONS = {};
19
18
  export const EMPTY_ANNOTATION_ARRAY = [];
20
19
  export const EMPTY_STRING = "";
21
20
 
@@ -42,4 +41,6 @@ export const PAGE_CHANGING_EVENT = "pagechanging";
42
41
  export const SCALE_CHANGING_EVENT = "scalechanging";
43
42
  export const PAGE_RENDERED_EVENT = "pagerendered";
44
43
  export const PAGES_LOADED_EVENT = "pagesloaded";
44
+ // cspell:disable-next-line -- pdfjs EventBus event name
45
+ export const ANNOTATION_LAYER_RENDERED_EVENT = "annotationlayerrendered";
45
46
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["EMPTY_ANNOTATIONS","EMPTY_ANNOTATION_ARRAY","EMPTY_STRING","SCALE_STEP","MIN_SCALE","MAX_SCALE","DEFAULT_PAGE_HEIGHT","THUMBNAIL_GAP","THUMBNAIL_SCALE","DEVICE_PIXEL_RATIO","window","devicePixelRatio","OUTLINE_HEADING_SIZE_RATIO","OUTLINE_MAX_HEADING_LENGTH","FIND_EVENT","UPDATE_FIND_CONTROL_STATE_EVENT","UPDATE_FIND_MATCHES_COUNT_EVENT","PAGE_CHANGING_EVENT","SCALE_CHANGING_EVENT","PAGE_RENDERED_EVENT","PAGES_LOADED_EVENT"],"sources":["constants.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 { PdfAnnotation } from \"./types.js\";\n\n// Default empty values (stable references to avoid re-renders)\nexport const EMPTY_ANNOTATIONS: Record<number, PdfAnnotation[]> = {};\nexport const EMPTY_ANNOTATION_ARRAY: PdfAnnotation[] = [];\nexport const EMPTY_STRING = \"\";\n\n// Scale and dimension configuration\nexport const SCALE_STEP = 0.25;\nexport const MIN_SCALE = 0.25;\nexport const MAX_SCALE = 5.0;\nexport const DEFAULT_PAGE_HEIGHT = 792;\nexport const THUMBNAIL_GAP = 12;\nexport const THUMBNAIL_SCALE = 0.2;\nexport const DEVICE_PIXEL_RATIO: number = typeof window !== \"undefined\"\n ? window.devicePixelRatio || 1\n : 1;\n\n// Outline heading extraction\n/** Text must be at least 15% larger than the most common font size to be considered a heading. */\nexport const OUTLINE_HEADING_SIZE_RATIO = 1.15;\n/** Headings longer than this are likely paragraphs and are filtered out. */\nexport const OUTLINE_MAX_HEADING_LENGTH = 200;\n\n// pdfjs EventBus event names\nexport const FIND_EVENT = \"find\";\nexport const UPDATE_FIND_CONTROL_STATE_EVENT = \"updatefindcontrolstate\";\nexport const UPDATE_FIND_MATCHES_COUNT_EVENT = \"updatefindmatchescount\";\nexport const PAGE_CHANGING_EVENT = \"pagechanging\";\nexport const SCALE_CHANGING_EVENT = \"scalechanging\";\nexport const PAGE_RENDERED_EVENT = \"pagerendered\";\nexport const PAGES_LOADED_EVENT = \"pagesloaded\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA,OAAO,MAAMA,iBAAkD,GAAG,CAAC,CAAC;AACpE,OAAO,MAAMC,sBAAuC,GAAG,EAAE;AACzD,OAAO,MAAMC,YAAY,GAAG,EAAE;;AAE9B;AACA,OAAO,MAAMC,UAAU,GAAG,IAAI;AAC9B,OAAO,MAAMC,SAAS,GAAG,IAAI;AAC7B,OAAO,MAAMC,SAAS,GAAG,GAAG;AAC5B,OAAO,MAAMC,mBAAmB,GAAG,GAAG;AACtC,OAAO,MAAMC,aAAa,GAAG,EAAE;AAC/B,OAAO,MAAMC,eAAe,GAAG,GAAG;AAClC,OAAO,MAAMC,kBAA0B,GAAG,OAAOC,MAAM,KAAK,WAAW,GACnEA,MAAM,CAACC,gBAAgB,IAAI,CAAC,GAC5B,CAAC;;AAEL;AACA;AACA,OAAO,MAAMC,0BAA0B,GAAG,IAAI;AAC9C;AACA,OAAO,MAAMC,0BAA0B,GAAG,GAAG;;AAE7C;AACA,OAAO,MAAMC,UAAU,GAAG,MAAM;AAChC,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,mBAAmB,GAAG,cAAc;AACjD,OAAO,MAAMC,oBAAoB,GAAG,eAAe;AACnD,OAAO,MAAMC,mBAAmB,GAAG,cAAc;AACjD,OAAO,MAAMC,kBAAkB,GAAG,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"constants.js","names":["EMPTY_ANNOTATION_ARRAY","EMPTY_STRING","SCALE_STEP","MIN_SCALE","MAX_SCALE","DEFAULT_PAGE_HEIGHT","THUMBNAIL_GAP","THUMBNAIL_SCALE","DEVICE_PIXEL_RATIO","window","devicePixelRatio","OUTLINE_HEADING_SIZE_RATIO","OUTLINE_MAX_HEADING_LENGTH","FIND_EVENT","UPDATE_FIND_CONTROL_STATE_EVENT","UPDATE_FIND_MATCHES_COUNT_EVENT","PAGE_CHANGING_EVENT","SCALE_CHANGING_EVENT","PAGE_RENDERED_EVENT","PAGES_LOADED_EVENT","ANNOTATION_LAYER_RENDERED_EVENT"],"sources":["constants.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 { PdfAnnotation } from \"./types.js\";\n\n// Default empty values (stable references to avoid re-renders)\nexport const EMPTY_ANNOTATION_ARRAY: PdfAnnotation[] = [];\nexport const EMPTY_STRING = \"\";\n\n// Scale and dimension configuration\nexport const SCALE_STEP = 0.25;\nexport const MIN_SCALE = 0.25;\nexport const MAX_SCALE = 5.0;\nexport const DEFAULT_PAGE_HEIGHT = 792;\nexport const THUMBNAIL_GAP = 12;\nexport const THUMBNAIL_SCALE = 0.2;\nexport const DEVICE_PIXEL_RATIO: number = typeof window !== \"undefined\"\n ? window.devicePixelRatio || 1\n : 1;\n\n// Outline heading extraction\n/** Text must be at least 15% larger than the most common font size to be considered a heading. */\nexport const OUTLINE_HEADING_SIZE_RATIO = 1.15;\n/** Headings longer than this are likely paragraphs and are filtered out. */\nexport const OUTLINE_MAX_HEADING_LENGTH = 200;\n\n// pdfjs EventBus event names\nexport const FIND_EVENT = \"find\";\nexport const UPDATE_FIND_CONTROL_STATE_EVENT = \"updatefindcontrolstate\";\nexport const UPDATE_FIND_MATCHES_COUNT_EVENT = \"updatefindmatchescount\";\nexport const PAGE_CHANGING_EVENT = \"pagechanging\";\nexport const SCALE_CHANGING_EVENT = \"scalechanging\";\nexport const PAGE_RENDERED_EVENT = \"pagerendered\";\nexport const PAGES_LOADED_EVENT = \"pagesloaded\";\n// cspell:disable-next-line -- pdfjs EventBus event name\nexport const ANNOTATION_LAYER_RENDERED_EVENT = \"annotationlayerrendered\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA,OAAO,MAAMA,sBAAuC,GAAG,EAAE;AACzD,OAAO,MAAMC,YAAY,GAAG,EAAE;;AAE9B;AACA,OAAO,MAAMC,UAAU,GAAG,IAAI;AAC9B,OAAO,MAAMC,SAAS,GAAG,IAAI;AAC7B,OAAO,MAAMC,SAAS,GAAG,GAAG;AAC5B,OAAO,MAAMC,mBAAmB,GAAG,GAAG;AACtC,OAAO,MAAMC,aAAa,GAAG,EAAE;AAC/B,OAAO,MAAMC,eAAe,GAAG,GAAG;AAClC,OAAO,MAAMC,kBAA0B,GAAG,OAAOC,MAAM,KAAK,WAAW,GACnEA,MAAM,CAACC,gBAAgB,IAAI,CAAC,GAC5B,CAAC;;AAEL;AACA;AACA,OAAO,MAAMC,0BAA0B,GAAG,IAAI;AAC9C;AACA,OAAO,MAAMC,0BAA0B,GAAG,GAAG;;AAE7C;AACA,OAAO,MAAMC,UAAU,GAAG,MAAM;AAChC,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,mBAAmB,GAAG,cAAc;AACjD,OAAO,MAAMC,oBAAoB,GAAG,eAAe;AACnD,OAAO,MAAMC,mBAAmB,GAAG,cAAc;AACjD,OAAO,MAAMC,kBAAkB,GAAG,aAAa;AAC/C;AACA,OAAO,MAAMC,+BAA+B,GAAG,yBAAyB","ignoreList":[]}