@osdk/react-components 0.2.0-beta.19 → 0.2.0-beta.20

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 (316) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/browser/action-form/ActionForm.js +5 -1
  3. package/build/browser/action-form/ActionForm.js.map +1 -1
  4. package/build/browser/action-form/BaseForm.js +4 -8
  5. package/build/browser/action-form/BaseForm.js.map +1 -1
  6. package/build/browser/action-form/FormFieldApi.js.map +1 -1
  7. package/build/browser/action-form/fields/DropdownField.js +104 -0
  8. package/build/browser/action-form/fields/DropdownField.js.map +1 -0
  9. package/build/browser/action-form/fields/FormFieldRenderer.js +23 -12
  10. package/build/browser/action-form/fields/FormFieldRenderer.js.map +1 -1
  11. package/build/browser/action-form/fields/TextInputField.js +8 -9
  12. package/build/browser/action-form/fields/TextInputField.js.map +1 -1
  13. package/build/browser/base-components/combobox/Combobox.js +25 -3
  14. package/build/browser/base-components/combobox/Combobox.js.map +1 -1
  15. package/build/browser/base-components/combobox/Combobox.module.css +226 -46
  16. package/build/browser/base-components/combobox/Combobox.module.css.js +1 -0
  17. package/build/browser/base-components/select/Select.js +7 -1
  18. package/build/browser/base-components/select/Select.js.map +1 -1
  19. package/build/browser/base-components/select/Select.module.css +132 -35
  20. package/build/browser/base-components/select/Select.module.css.js +2 -0
  21. package/build/browser/base-components/skeleton/SkeletonBar.js +36 -0
  22. package/build/browser/base-components/skeleton/SkeletonBar.js.map +1 -0
  23. package/build/browser/base-components/skeleton/SkeletonBar.module.css +39 -0
  24. package/build/browser/base-components/skeleton/SkeletonBar.module.css.js +7 -0
  25. package/build/browser/filter-list/FilterList.js +42 -5
  26. package/build/browser/filter-list/FilterList.js.map +1 -1
  27. package/build/browser/filter-list/FilterListApi.js.map +1 -1
  28. package/build/browser/filter-list/base/AddFilterPopover.js +45 -0
  29. package/build/browser/filter-list/base/AddFilterPopover.js.map +1 -0
  30. package/build/browser/filter-list/base/AddFilterPopover.module.css +83 -0
  31. package/build/browser/filter-list/base/AddFilterPopover.module.css.js +9 -0
  32. package/build/browser/filter-list/base/inputs/CheckboxListInput.js +16 -27
  33. package/build/browser/filter-list/base/inputs/CheckboxListInput.js.map +1 -1
  34. package/build/browser/filter-list/base/inputs/CheckboxListInput.module.css +15 -5
  35. package/build/browser/filter-list/base/inputs/CheckboxListSkeleton.js +46 -0
  36. package/build/browser/filter-list/base/inputs/CheckboxListSkeleton.js.map +1 -0
  37. package/build/browser/filter-list/base/inputs/CheckboxListSkeleton.module.css +32 -0
  38. package/build/browser/filter-list/base/inputs/CheckboxListSkeleton.module.css.js +8 -0
  39. package/build/browser/filter-list/base/inputs/ListogramInput.js +21 -12
  40. package/build/browser/filter-list/base/inputs/ListogramInput.js.map +1 -1
  41. package/build/browser/filter-list/base/inputs/ListogramInput.module.css +13 -1
  42. package/build/browser/filter-list/base/inputs/ListogramSkeleton.js +45 -0
  43. package/build/browser/filter-list/base/inputs/ListogramSkeleton.js.map +1 -0
  44. package/build/browser/filter-list/base/inputs/ListogramSkeleton.module.css +32 -0
  45. package/build/browser/filter-list/base/inputs/ListogramSkeleton.module.css.js +8 -0
  46. package/build/browser/filter-list/base/inputs/MultiSelectInput.js +1 -1
  47. package/build/browser/filter-list/base/inputs/MultiSelectInput.js.map +1 -1
  48. package/build/browser/filter-list/base/inputs/RangeInput.js +13 -13
  49. package/build/browser/filter-list/base/inputs/RangeInput.js.map +1 -1
  50. package/build/browser/filter-list/base/inputs/RangeInput.module.css +23 -0
  51. package/build/browser/filter-list/base/inputs/TextTagsInput.js +1 -1
  52. package/build/browser/filter-list/base/inputs/TextTagsInput.js.map +1 -1
  53. package/build/browser/filter-list/base/inputs/useStaleData.js +29 -0
  54. package/build/browser/filter-list/base/inputs/useStaleData.js.map +1 -0
  55. package/build/browser/filter-list/hooks/useFilterVisibility.js +68 -0
  56. package/build/browser/filter-list/hooks/useFilterVisibility.js.map +1 -0
  57. package/build/browser/object-table/DefaultCellRenderer.js +13 -3
  58. package/build/browser/object-table/DefaultCellRenderer.js.map +1 -1
  59. package/build/browser/object-table/EditableCell.js +7 -6
  60. package/build/browser/object-table/EditableCell.js.map +1 -1
  61. package/build/browser/object-table/LoadingCell.js +6 -3
  62. package/build/browser/object-table/LoadingCell.js.map +1 -1
  63. package/build/browser/object-table/LoadingRow.js +2 -1
  64. package/build/browser/object-table/LoadingRow.js.map +1 -1
  65. package/build/browser/object-table/ObjectTableApi.js.map +1 -1
  66. package/build/browser/object-table/Table.js.map +1 -1
  67. package/build/browser/object-table/TableCell.module.css +1 -0
  68. package/build/browser/object-table/components/AsyncValueCell.js +35 -0
  69. package/build/browser/object-table/components/AsyncValueCell.js.map +1 -0
  70. package/build/browser/object-table/hooks/useColumnDefs.js +3 -1
  71. package/build/browser/object-table/hooks/useColumnDefs.js.map +1 -1
  72. package/build/browser/object-table/hooks/useFunctionColumnsData.js +270 -0
  73. package/build/browser/object-table/hooks/useFunctionColumnsData.js.map +1 -0
  74. package/build/browser/object-table/hooks/useObjectTableData.js +34 -13
  75. package/build/browser/object-table/hooks/useObjectTableData.js.map +1 -1
  76. package/build/browser/object-table/utils/AsyncCellData.js +30 -0
  77. package/build/browser/object-table/utils/AsyncCellData.js.map +1 -0
  78. package/build/browser/object-table/utils/constants.js +1 -0
  79. package/build/browser/object-table/utils/constants.js.map +1 -1
  80. package/build/browser/pdf-viewer/PdfRenderer.js +88 -0
  81. package/build/browser/pdf-viewer/PdfRenderer.js.map +1 -0
  82. package/build/browser/pdf-viewer/PdfViewer.js +197 -0
  83. package/build/browser/pdf-viewer/PdfViewer.js.map +1 -0
  84. package/build/browser/pdf-viewer/PdfViewer.module.css +95 -0
  85. package/build/browser/pdf-viewer/PdfViewer.module.css.js +16 -0
  86. package/build/browser/pdf-viewer/PdfViewerAnnotationLayer.js +74 -0
  87. package/build/browser/pdf-viewer/PdfViewerAnnotationLayer.js.map +1 -0
  88. package/build/browser/pdf-viewer/PdfViewerAnnotationLayer.module.css +65 -0
  89. package/build/browser/pdf-viewer/PdfViewerAnnotationLayer.module.css.js +11 -0
  90. package/build/browser/pdf-viewer/PdfViewerSearchBar.js +84 -0
  91. package/build/browser/pdf-viewer/PdfViewerSearchBar.js.map +1 -0
  92. package/build/browser/pdf-viewer/PdfViewerSearchBar.module.css +65 -0
  93. package/build/browser/pdf-viewer/PdfViewerSearchBar.module.css.js +10 -0
  94. package/build/browser/pdf-viewer/PdfViewerSidebar.js +74 -0
  95. package/build/browser/pdf-viewer/PdfViewerSidebar.js.map +1 -0
  96. package/build/browser/pdf-viewer/PdfViewerSidebar.module.css +46 -0
  97. package/build/browser/pdf-viewer/PdfViewerSidebar.module.css.js +11 -0
  98. package/build/browser/pdf-viewer/PdfViewerThumbnail.js +100 -0
  99. package/build/browser/pdf-viewer/PdfViewerThumbnail.js.map +1 -0
  100. package/build/browser/pdf-viewer/PdfViewerThumbnail.module.css +26 -0
  101. package/build/browser/pdf-viewer/PdfViewerThumbnail.module.css.js +8 -0
  102. package/build/browser/pdf-viewer/PdfViewerToolbar.js +167 -0
  103. package/build/browser/pdf-viewer/PdfViewerToolbar.js.map +1 -0
  104. package/build/browser/pdf-viewer/PdfViewerToolbar.module.css +86 -0
  105. package/build/browser/pdf-viewer/PdfViewerToolbar.module.css.js +12 -0
  106. package/build/browser/pdf-viewer/constants.js +43 -0
  107. package/build/browser/pdf-viewer/constants.js.map +1 -0
  108. package/build/browser/pdf-viewer/hooks/usePdfAnnotationPortals.js +54 -0
  109. package/build/browser/pdf-viewer/hooks/usePdfAnnotationPortals.js.map +1 -0
  110. package/build/browser/pdf-viewer/hooks/usePdfDocument.js +67 -0
  111. package/build/browser/pdf-viewer/hooks/usePdfDocument.js.map +1 -0
  112. package/build/browser/pdf-viewer/hooks/usePdfViewer.js +69 -0
  113. package/build/browser/pdf-viewer/hooks/usePdfViewer.js.map +1 -0
  114. package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js +106 -0
  115. package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -0
  116. package/build/browser/pdf-viewer/hooks/usePdfViewerSync.js +71 -0
  117. package/build/browser/pdf-viewer/hooks/usePdfViewerSync.js.map +1 -0
  118. package/build/browser/pdf-viewer/types.js +2 -0
  119. package/build/browser/pdf-viewer/types.js.map +1 -0
  120. package/build/browser/public/experimental.js +4 -0
  121. package/build/browser/public/experimental.js.map +1 -1
  122. package/build/browser/styles.css +1008 -87
  123. package/build/cjs/public/experimental.cjs +2311 -895
  124. package/build/cjs/public/experimental.cjs.map +1 -1
  125. package/build/cjs/public/experimental.css +678 -153
  126. package/build/cjs/public/experimental.css.map +1 -1
  127. package/build/cjs/public/experimental.d.cts +114 -13
  128. package/build/esm/action-form/ActionForm.js +5 -1
  129. package/build/esm/action-form/ActionForm.js.map +1 -1
  130. package/build/esm/action-form/BaseForm.js +4 -8
  131. package/build/esm/action-form/BaseForm.js.map +1 -1
  132. package/build/esm/action-form/FormFieldApi.js.map +1 -1
  133. package/build/esm/action-form/fields/DropdownField.js +104 -0
  134. package/build/esm/action-form/fields/DropdownField.js.map +1 -0
  135. package/build/esm/action-form/fields/FormFieldRenderer.js +23 -12
  136. package/build/esm/action-form/fields/FormFieldRenderer.js.map +1 -1
  137. package/build/esm/action-form/fields/TextInputField.js +8 -9
  138. package/build/esm/action-form/fields/TextInputField.js.map +1 -1
  139. package/build/esm/base-components/combobox/Combobox.js +25 -3
  140. package/build/esm/base-components/combobox/Combobox.js.map +1 -1
  141. package/build/esm/base-components/combobox/Combobox.module.css +226 -46
  142. package/build/esm/base-components/select/Select.js +7 -1
  143. package/build/esm/base-components/select/Select.js.map +1 -1
  144. package/build/esm/base-components/select/Select.module.css +132 -35
  145. package/build/esm/base-components/skeleton/SkeletonBar.js +36 -0
  146. package/build/esm/base-components/skeleton/SkeletonBar.js.map +1 -0
  147. package/build/esm/base-components/skeleton/SkeletonBar.module.css +39 -0
  148. package/build/esm/filter-list/FilterList.js +42 -5
  149. package/build/esm/filter-list/FilterList.js.map +1 -1
  150. package/build/esm/filter-list/FilterListApi.js.map +1 -1
  151. package/build/esm/filter-list/base/AddFilterPopover.js +45 -0
  152. package/build/esm/filter-list/base/AddFilterPopover.js.map +1 -0
  153. package/build/esm/filter-list/base/AddFilterPopover.module.css +83 -0
  154. package/build/esm/filter-list/base/inputs/CheckboxListInput.js +16 -27
  155. package/build/esm/filter-list/base/inputs/CheckboxListInput.js.map +1 -1
  156. package/build/esm/filter-list/base/inputs/CheckboxListInput.module.css +15 -5
  157. package/build/esm/filter-list/base/inputs/CheckboxListSkeleton.js +46 -0
  158. package/build/esm/filter-list/base/inputs/CheckboxListSkeleton.js.map +1 -0
  159. package/build/esm/filter-list/base/inputs/CheckboxListSkeleton.module.css +32 -0
  160. package/build/esm/filter-list/base/inputs/ListogramInput.js +21 -12
  161. package/build/esm/filter-list/base/inputs/ListogramInput.js.map +1 -1
  162. package/build/esm/filter-list/base/inputs/ListogramInput.module.css +13 -1
  163. package/build/esm/filter-list/base/inputs/ListogramSkeleton.js +45 -0
  164. package/build/esm/filter-list/base/inputs/ListogramSkeleton.js.map +1 -0
  165. package/build/esm/filter-list/base/inputs/ListogramSkeleton.module.css +32 -0
  166. package/build/esm/filter-list/base/inputs/MultiSelectInput.js +1 -1
  167. package/build/esm/filter-list/base/inputs/MultiSelectInput.js.map +1 -1
  168. package/build/esm/filter-list/base/inputs/RangeInput.js +13 -13
  169. package/build/esm/filter-list/base/inputs/RangeInput.js.map +1 -1
  170. package/build/esm/filter-list/base/inputs/RangeInput.module.css +23 -0
  171. package/build/esm/filter-list/base/inputs/TextTagsInput.js +1 -1
  172. package/build/esm/filter-list/base/inputs/TextTagsInput.js.map +1 -1
  173. package/build/esm/filter-list/base/inputs/useStaleData.js +29 -0
  174. package/build/esm/filter-list/base/inputs/useStaleData.js.map +1 -0
  175. package/build/esm/filter-list/hooks/useFilterVisibility.js +68 -0
  176. package/build/esm/filter-list/hooks/useFilterVisibility.js.map +1 -0
  177. package/build/esm/object-table/DefaultCellRenderer.js +13 -3
  178. package/build/esm/object-table/DefaultCellRenderer.js.map +1 -1
  179. package/build/esm/object-table/EditableCell.js +7 -6
  180. package/build/esm/object-table/EditableCell.js.map +1 -1
  181. package/build/esm/object-table/LoadingCell.js +6 -3
  182. package/build/esm/object-table/LoadingCell.js.map +1 -1
  183. package/build/esm/object-table/LoadingRow.js +2 -1
  184. package/build/esm/object-table/LoadingRow.js.map +1 -1
  185. package/build/esm/object-table/ObjectTableApi.js.map +1 -1
  186. package/build/esm/object-table/Table.js.map +1 -1
  187. package/build/esm/object-table/TableCell.module.css +1 -0
  188. package/build/esm/object-table/components/AsyncValueCell.js +35 -0
  189. package/build/esm/object-table/components/AsyncValueCell.js.map +1 -0
  190. package/build/esm/object-table/hooks/useColumnDefs.js +3 -1
  191. package/build/esm/object-table/hooks/useColumnDefs.js.map +1 -1
  192. package/build/esm/object-table/hooks/useFunctionColumnsData.js +270 -0
  193. package/build/esm/object-table/hooks/useFunctionColumnsData.js.map +1 -0
  194. package/build/esm/object-table/hooks/useObjectTableData.js +34 -13
  195. package/build/esm/object-table/hooks/useObjectTableData.js.map +1 -1
  196. package/build/esm/object-table/utils/AsyncCellData.js +30 -0
  197. package/build/esm/object-table/utils/AsyncCellData.js.map +1 -0
  198. package/build/esm/object-table/utils/constants.js +1 -0
  199. package/build/esm/object-table/utils/constants.js.map +1 -1
  200. package/build/esm/pdf-viewer/PdfRenderer.js +88 -0
  201. package/build/esm/pdf-viewer/PdfRenderer.js.map +1 -0
  202. package/build/esm/pdf-viewer/PdfViewer.js +197 -0
  203. package/build/esm/pdf-viewer/PdfViewer.js.map +1 -0
  204. package/build/esm/pdf-viewer/PdfViewer.module.css +95 -0
  205. package/build/esm/pdf-viewer/PdfViewerAnnotationLayer.js +74 -0
  206. package/build/esm/pdf-viewer/PdfViewerAnnotationLayer.js.map +1 -0
  207. package/build/esm/pdf-viewer/PdfViewerAnnotationLayer.module.css +65 -0
  208. package/build/esm/pdf-viewer/PdfViewerSearchBar.js +84 -0
  209. package/build/esm/pdf-viewer/PdfViewerSearchBar.js.map +1 -0
  210. package/build/esm/pdf-viewer/PdfViewerSearchBar.module.css +65 -0
  211. package/build/esm/pdf-viewer/PdfViewerSidebar.js +74 -0
  212. package/build/esm/pdf-viewer/PdfViewerSidebar.js.map +1 -0
  213. package/build/esm/pdf-viewer/PdfViewerSidebar.module.css +46 -0
  214. package/build/esm/pdf-viewer/PdfViewerThumbnail.js +100 -0
  215. package/build/esm/pdf-viewer/PdfViewerThumbnail.js.map +1 -0
  216. package/build/esm/pdf-viewer/PdfViewerThumbnail.module.css +26 -0
  217. package/build/esm/pdf-viewer/PdfViewerToolbar.js +167 -0
  218. package/build/esm/pdf-viewer/PdfViewerToolbar.js.map +1 -0
  219. package/build/esm/pdf-viewer/PdfViewerToolbar.module.css +86 -0
  220. package/build/esm/pdf-viewer/constants.js +43 -0
  221. package/build/esm/pdf-viewer/constants.js.map +1 -0
  222. package/build/esm/pdf-viewer/hooks/usePdfAnnotationPortals.js +54 -0
  223. package/build/esm/pdf-viewer/hooks/usePdfAnnotationPortals.js.map +1 -0
  224. package/build/esm/pdf-viewer/hooks/usePdfDocument.js +67 -0
  225. package/build/esm/pdf-viewer/hooks/usePdfDocument.js.map +1 -0
  226. package/build/esm/pdf-viewer/hooks/usePdfViewer.js +69 -0
  227. package/build/esm/pdf-viewer/hooks/usePdfViewer.js.map +1 -0
  228. package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js +106 -0
  229. package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -0
  230. package/build/esm/pdf-viewer/hooks/usePdfViewerSync.js +71 -0
  231. package/build/esm/pdf-viewer/hooks/usePdfViewerSync.js.map +1 -0
  232. package/build/esm/pdf-viewer/types.js +2 -0
  233. package/build/esm/pdf-viewer/types.js.map +1 -0
  234. package/build/esm/public/experimental.js +4 -0
  235. package/build/esm/public/experimental.js.map +1 -1
  236. package/build/types/action-form/FormFieldApi.d.ts +48 -37
  237. package/build/types/action-form/FormFieldApi.d.ts.map +1 -1
  238. package/build/types/action-form/fields/DropdownField.d.ts +6 -0
  239. package/build/types/action-form/fields/DropdownField.d.ts.map +1 -0
  240. package/build/types/action-form/fields/FormFieldRenderer.d.ts.map +1 -1
  241. package/build/types/action-form/fields/TextInputField.d.ts +3 -1
  242. package/build/types/action-form/fields/TextInputField.d.ts.map +1 -1
  243. package/build/types/base-components/combobox/Combobox.d.ts +9 -1
  244. package/build/types/base-components/combobox/Combobox.d.ts.map +1 -1
  245. package/build/types/base-components/select/Select.d.ts +8 -2
  246. package/build/types/base-components/select/Select.d.ts.map +1 -1
  247. package/build/types/base-components/skeleton/SkeletonBar.d.ts +9 -0
  248. package/build/types/base-components/skeleton/SkeletonBar.d.ts.map +1 -0
  249. package/build/types/filter-list/FilterList.d.ts.map +1 -1
  250. package/build/types/filter-list/FilterListApi.d.ts +24 -6
  251. package/build/types/filter-list/FilterListApi.d.ts.map +1 -1
  252. package/build/types/filter-list/base/AddFilterPopover.d.ts +12 -0
  253. package/build/types/filter-list/base/AddFilterPopover.d.ts.map +1 -0
  254. package/build/types/filter-list/base/inputs/CheckboxListInput.d.ts +2 -1
  255. package/build/types/filter-list/base/inputs/CheckboxListInput.d.ts.map +1 -1
  256. package/build/types/filter-list/base/inputs/CheckboxListSkeleton.d.ts +2 -0
  257. package/build/types/filter-list/base/inputs/CheckboxListSkeleton.d.ts.map +1 -0
  258. package/build/types/filter-list/base/inputs/ListogramInput.d.ts +2 -1
  259. package/build/types/filter-list/base/inputs/ListogramInput.d.ts.map +1 -1
  260. package/build/types/filter-list/base/inputs/ListogramSkeleton.d.ts +2 -0
  261. package/build/types/filter-list/base/inputs/ListogramSkeleton.d.ts.map +1 -0
  262. package/build/types/filter-list/base/inputs/RangeInput.d.ts.map +1 -1
  263. package/build/types/filter-list/base/inputs/useStaleData.d.ts +1 -0
  264. package/build/types/filter-list/base/inputs/useStaleData.d.ts.map +1 -0
  265. package/build/types/filter-list/hooks/useFilterVisibility.d.ts +8 -0
  266. package/build/types/filter-list/hooks/useFilterVisibility.d.ts.map +1 -0
  267. package/build/types/object-table/DefaultCellRenderer.d.ts.map +1 -1
  268. package/build/types/object-table/EditableCell.d.ts.map +1 -1
  269. package/build/types/object-table/LoadingCell.d.ts +1 -0
  270. package/build/types/object-table/LoadingCell.d.ts.map +1 -1
  271. package/build/types/object-table/LoadingRow.d.ts.map +1 -1
  272. package/build/types/object-table/ObjectTableApi.d.ts +51 -15
  273. package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
  274. package/build/types/object-table/Table.d.ts +1 -0
  275. package/build/types/object-table/Table.d.ts.map +1 -1
  276. package/build/types/object-table/components/AsyncValueCell.d.ts +5 -0
  277. package/build/types/object-table/components/AsyncValueCell.d.ts.map +1 -0
  278. package/build/types/object-table/hooks/useFunctionColumnsData.d.ts +13 -0
  279. package/build/types/object-table/hooks/useFunctionColumnsData.d.ts.map +1 -0
  280. package/build/types/object-table/hooks/useObjectTableData.d.ts +8 -1
  281. package/build/types/object-table/hooks/useObjectTableData.d.ts.map +1 -1
  282. package/build/types/object-table/utils/AsyncCellData.d.ts +8 -0
  283. package/build/types/object-table/utils/AsyncCellData.d.ts.map +1 -0
  284. package/build/types/object-table/utils/constants.d.ts +1 -0
  285. package/build/types/object-table/utils/constants.d.ts.map +1 -1
  286. package/build/types/pdf-viewer/PdfRenderer.d.ts +8 -0
  287. package/build/types/pdf-viewer/PdfRenderer.d.ts.map +1 -0
  288. package/build/types/pdf-viewer/PdfViewer.d.ts +4 -0
  289. package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -0
  290. package/build/types/pdf-viewer/PdfViewerAnnotationLayer.d.ts +10 -0
  291. package/build/types/pdf-viewer/PdfViewerAnnotationLayer.d.ts.map +1 -0
  292. package/build/types/pdf-viewer/PdfViewerSearchBar.d.ts +12 -0
  293. package/build/types/pdf-viewer/PdfViewerSearchBar.d.ts.map +1 -0
  294. package/build/types/pdf-viewer/PdfViewerSidebar.d.ts +10 -0
  295. package/build/types/pdf-viewer/PdfViewerSidebar.d.ts.map +1 -0
  296. package/build/types/pdf-viewer/PdfViewerThumbnail.d.ts +10 -0
  297. package/build/types/pdf-viewer/PdfViewerThumbnail.d.ts.map +1 -0
  298. package/build/types/pdf-viewer/PdfViewerToolbar.d.ts +14 -0
  299. package/build/types/pdf-viewer/PdfViewerToolbar.d.ts.map +1 -0
  300. package/build/types/pdf-viewer/constants.d.ts +17 -0
  301. package/build/types/pdf-viewer/constants.d.ts.map +1 -0
  302. package/build/types/pdf-viewer/hooks/usePdfAnnotationPortals.d.ts +10 -0
  303. package/build/types/pdf-viewer/hooks/usePdfAnnotationPortals.d.ts.map +1 -0
  304. package/build/types/pdf-viewer/hooks/usePdfDocument.d.ts +9 -0
  305. package/build/types/pdf-viewer/hooks/usePdfDocument.d.ts.map +1 -0
  306. package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts +9 -0
  307. package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts.map +1 -0
  308. package/build/types/pdf-viewer/hooks/usePdfViewerSearch.d.ts +15 -0
  309. package/build/types/pdf-viewer/hooks/usePdfViewerSearch.d.ts.map +1 -0
  310. package/build/types/pdf-viewer/hooks/usePdfViewerSync.d.ts +15 -0
  311. package/build/types/pdf-viewer/hooks/usePdfViewerSync.d.ts.map +1 -0
  312. package/build/types/pdf-viewer/types.d.ts +44 -0
  313. package/build/types/pdf-viewer/types.d.ts.map +1 -0
  314. package/build/types/public/experimental.d.ts +4 -1
  315. package/build/types/public/experimental.d.ts.map +1 -1
  316. package/package.json +5 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdfRenderer.js","names":["Error","ErrorIcon","Spin","classnames","React","useEffect","useState","BasePdfViewer","styles","fetchMediaContents","media","result","fetchContents","arrayBuffer","PdfRenderer","className","pdfViewerProps","src","setSrc","undefined","loading","setLoading","error","setError","cancelled","then","buffer","catch","err","String","rootClassName","pdfViewer","createElement","loadingContainer","spinnerIcon","errorContainer","errorIcon","message","_extends"],"sources":["PdfRenderer.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 type { Media } from \"@osdk/api\";\nimport classnames from \"classnames\";\nimport React, { useEffect, useState } from \"react\";\nimport { BasePdfViewer } from \"./PdfViewer.js\";\nimport styles from \"./PdfViewer.module.css\";\nimport type { PdfViewerProps } from \"./types.js\";\n\nasync function fetchMediaContents(media: Media): Promise<ArrayBuffer> {\n const result = await media.fetchContents();\n return result.arrayBuffer();\n}\n\nexport interface PdfRendererProps extends Omit<PdfViewerProps, \"src\"> {\n /** The Media object to fetch PDF contents from */\n media: Media;\n}\n\nexport function PdfRenderer({\n media,\n className,\n ...pdfViewerProps\n}: PdfRendererProps): React.ReactElement {\n const [src, setSrc] = useState<ArrayBuffer | undefined>(undefined);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n // This is required until we either support React 19+ or a data fetching hook\n useEffect(function fetchMediaSource() {\n let cancelled = false;\n setLoading(true);\n setError(undefined);\n setSrc(undefined);\n\n fetchMediaContents(media)\n .then((buffer) => {\n if (!cancelled) {\n setSrc(buffer);\n setLoading(false);\n }\n })\n .catch((err: unknown) => {\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setLoading(false);\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [media]);\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (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 (error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {error.message}\n </div>\n </div>\n );\n }\n\n if (src == null) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>No document</div>\n </div>\n );\n }\n\n return <BasePdfViewer src={src} className={className} {...pdfViewerProps} />;\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;AAE7D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,OAAOC,MAAM,MAAM,wBAAwB;AAG3C,eAAeC,kBAAkBA,CAACC,KAAY,EAAwB;EACpE,MAAMC,MAAM,GAAG,MAAMD,KAAK,CAACE,aAAa,CAAC,CAAC;EAC1C,OAAOD,MAAM,CAACE,WAAW,CAAC,CAAC;AAC7B;AAOA,OAAO,SAASC,WAAWA,CAAC;EAC1BJ,KAAK;EACLK,SAAS;EACT,GAAGC;AACa,CAAC,EAAsB;EACvC,MAAM,CAACC,GAAG,EAAEC,MAAM,CAAC,GAAGZ,QAAQ,CAA0Ba,SAAS,CAAC;EAClE,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGf,QAAQ,CAAC,IAAI,CAAC;EAC5C,MAAM,CAACgB,KAAK,EAAEC,QAAQ,CAAC,GAAGjB,QAAQ,CAAoBa,SAAS,CAAC;;EAEhE;EACAd,SAAS,CAAC,YAA4B;IACpC,IAAImB,SAAS,GAAG,KAAK;IACrBH,UAAU,CAAC,IAAI,CAAC;IAChBE,QAAQ,CAACJ,SAAS,CAAC;IACnBD,MAAM,CAACC,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I,IAAI,EAAE;IACf,oBACEb,KAAA,CAAA4B,aAAA;MAAKjB,SAAS,EAAEe;IAAc,gBAC5B1B,KAAA,CAAA4B,aAAA;MAAKjB,SAAS,EAAEP,MAAM,CAACyB;IAAiB,GAAC,aAAgB,CACtD,CAAC;EAEV;EAEA,oBAAO7B,KAAA,CAAA4B,aAAA,CAACzB,aAAa,EAAA+B,QAAA;IAACrB,GAAG,EAAEA,GAAI;IAACF,SAAS,EAAEA;EAAU,GAAKC,cAAc,CAAG,CAAC;AAC9E","ignoreList":[]}
@@ -0,0 +1,197 @@
1
+ /*
2
+ * Copyright 2025 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
+ import { Error as ErrorIcon, Spin } from "@blueprintjs/icons";
18
+ import classnames from "classnames";
19
+ import "pdfjs-dist/web/pdf_viewer.css";
20
+ import React, { useCallback, useEffect, useRef, useState } from "react";
21
+ import { createPortal } from "react-dom";
22
+ import { EMPTY_ANNOTATION_ARRAY, EMPTY_ANNOTATIONS } from "./constants.js";
23
+ import { usePdfAnnotationPortals } from "./hooks/usePdfAnnotationPortals.js";
24
+ import { usePdfDocument } from "./hooks/usePdfDocument.js";
25
+ import { usePdfViewer } from "./hooks/usePdfViewer.js";
26
+ import { usePdfViewerSearch } from "./hooks/usePdfViewerSearch.js";
27
+ import { usePdfViewerSync } from "./hooks/usePdfViewerSync.js";
28
+ import styles from "./PdfViewer.module.css.js";
29
+ import { PdfViewerAnnotationLayer } from "./PdfViewerAnnotationLayer.js";
30
+ import { PdfViewerSearchBar } from "./PdfViewerSearchBar.js";
31
+ import { PdfViewerSidebar } from "./PdfViewerSidebar.js";
32
+ import { PdfViewerToolbar } from "./PdfViewerToolbar.js";
33
+ export function BasePdfViewer({
34
+ src,
35
+ annotations = EMPTY_ANNOTATIONS,
36
+ onAnnotationClick,
37
+ initialPage = 1,
38
+ initialScale = 1.0,
39
+ initialSidebarOpen = false,
40
+ className
41
+ }) {
42
+ const {
43
+ document,
44
+ numPages,
45
+ loading,
46
+ error
47
+ } = usePdfDocument(src);
48
+ const [scale, setScale] = useState(initialScale);
49
+ const [sidebarOpen, setSidebarOpen] = useState(initialSidebarOpen);
50
+ const [currentPage, setCurrentPage] = useState(initialPage);
51
+ const containerRef = useRef(null);
52
+ const viewerRef = useRef(null);
53
+ const {
54
+ pdfViewerRef,
55
+ eventBusRef,
56
+ findControllerRef
57
+ } = usePdfViewer(containerRef, viewerRef, document, initialScale);
58
+ const search = usePdfViewerSearch(eventBusRef, findControllerRef, document);
59
+ const handleScaleChange = useCallback(newScale => {
60
+ setScale(newScale);
61
+ }, []);
62
+ const handlePageChange = useCallback(page => {
63
+ setCurrentPage(page);
64
+ }, []);
65
+ const {
66
+ scrollToPage
67
+ } = usePdfViewerSync({
68
+ pdfViewerRef,
69
+ eventBusRef,
70
+ document,
71
+ scale,
72
+ onScaleChange: handleScaleChange,
73
+ onPageChange: handlePageChange
74
+ });
75
+ const portalTargets = usePdfAnnotationPortals(pdfViewerRef, eventBusRef, document);
76
+
77
+ // Set initial page after viewer is ready
78
+ useEffect(function () {
79
+ if (pdfViewerRef.current != null && initialPage > 1) {
80
+ pdfViewerRef.current.currentPageNumber = initialPage;
81
+ }
82
+ }, [pdfViewerRef, initialPage]);
83
+
84
+ // Ctrl+F handler
85
+ useEffect(function () {
86
+ const handleKeyDown = e => {
87
+ if ((e.ctrlKey || e.metaKey) && e.key === "f") {
88
+ e.preventDefault();
89
+ search.openSearch();
90
+ }
91
+ };
92
+ window.addEventListener("keydown", handleKeyDown);
93
+ return () => {
94
+ window.removeEventListener("keydown", handleKeyDown);
95
+ };
96
+ }, [search.openSearch]);
97
+ const handleDownload = useCallback(() => {
98
+ if (document == null) {
99
+ return;
100
+ }
101
+ void document.getData().then(data => {
102
+ const blob = new Blob([data.buffer], {
103
+ type: "application/pdf"
104
+ });
105
+ const url = URL.createObjectURL(blob);
106
+ // Extract filename from URL by taking the last path segment and stripping query params
107
+ const filename = typeof src === "string" ? src.split("/").pop()?.split("?")[0] || "document.pdf" : "document.pdf";
108
+ const a = globalThis.document.createElement("a");
109
+ a.href = url;
110
+ a.download = filename;
111
+ a.click();
112
+ URL.revokeObjectURL(url);
113
+ });
114
+ }, [document, src]);
115
+ const handleSidebarToggle = useCallback(() => {
116
+ setSidebarOpen(prev => !prev);
117
+ }, []);
118
+ const handleToolbarPageChange = useCallback(page => {
119
+ setCurrentPage(page);
120
+ scrollToPage(page);
121
+ }, [scrollToPage]);
122
+ const rootClassName = classnames(styles.pdfViewer, className);
123
+ if (loading) {
124
+ return /*#__PURE__*/React.createElement("div", {
125
+ className: rootClassName
126
+ }, /*#__PURE__*/React.createElement("div", {
127
+ className: styles.loadingContainer
128
+ }, /*#__PURE__*/React.createElement(Spin, {
129
+ className: styles.spinnerIcon
130
+ }), "Loading\u2026"));
131
+ }
132
+ if (error != null) {
133
+ return /*#__PURE__*/React.createElement("div", {
134
+ className: rootClassName
135
+ }, /*#__PURE__*/React.createElement("div", {
136
+ className: styles.errorContainer
137
+ }, /*#__PURE__*/React.createElement(ErrorIcon, {
138
+ className: styles.errorIcon
139
+ }), "Failed to load PDF: ", error.message));
140
+ }
141
+ if (document == null) {
142
+ return /*#__PURE__*/React.createElement("div", {
143
+ className: rootClassName
144
+ }, /*#__PURE__*/React.createElement("div", {
145
+ className: styles.loadingContainer
146
+ }, "No document"));
147
+ }
148
+ return /*#__PURE__*/React.createElement("div", {
149
+ className: rootClassName
150
+ }, /*#__PURE__*/React.createElement(PdfViewerToolbar, {
151
+ currentPage: currentPage,
152
+ numPages: numPages,
153
+ scale: scale,
154
+ sidebarOpen: sidebarOpen,
155
+ onPageChange: handleToolbarPageChange,
156
+ onScaleChange: setScale,
157
+ onSearchOpen: search.openSearch,
158
+ onSidebarToggle: handleSidebarToggle,
159
+ onDownload: handleDownload
160
+ }), search.isSearchOpen && /*#__PURE__*/React.createElement(PdfViewerSearchBar, {
161
+ query: search.query,
162
+ totalMatches: search.totalMatches,
163
+ currentMatchIndex: search.currentMatchIndex,
164
+ onQueryChange: search.setQuery,
165
+ onNext: search.nextMatch,
166
+ onPrev: search.prevMatch,
167
+ onClose: search.closeSearch
168
+ }), /*#__PURE__*/React.createElement("div", {
169
+ className: styles.contentArea
170
+ }, sidebarOpen && /*#__PURE__*/React.createElement(PdfViewerSidebar, {
171
+ document: document,
172
+ numPages: numPages,
173
+ currentPage: currentPage,
174
+ onPageClick: handleToolbarPageChange
175
+ }), /*#__PURE__*/React.createElement("div", {
176
+ className: styles.scrollContainerWrapper
177
+ }, /*#__PURE__*/React.createElement("div", {
178
+ ref: containerRef,
179
+ className: styles.scrollContainer
180
+ }, /*#__PURE__*/React.createElement("div", {
181
+ ref: viewerRef,
182
+ className: "pdfViewer"
183
+ }), portalTargets.map(target => {
184
+ const pageAnnotations = annotations[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;
185
+ if (pageAnnotations.length === 0) {
186
+ return null;
187
+ }
188
+ return /*#__PURE__*/createPortal(/*#__PURE__*/React.createElement(PdfViewerAnnotationLayer, {
189
+ key: target.pageNumber,
190
+ annotations: pageAnnotations,
191
+ pageHeight: target.pageHeight,
192
+ scale: target.scale,
193
+ onAnnotationClick: onAnnotationClick
194
+ }), target.container);
195
+ })))));
196
+ }
197
+ //# sourceMappingURL=PdfViewer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdfViewer.js","names":["Error","ErrorIcon","Spin","classnames","React","useCallback","useEffect","useRef","useState","createPortal","EMPTY_ANNOTATION_ARRAY","EMPTY_ANNOTATIONS","usePdfAnnotationPortals","usePdfDocument","usePdfViewer","usePdfViewerSearch","usePdfViewerSync","styles","PdfViewerAnnotationLayer","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","BasePdfViewer","src","annotations","onAnnotationClick","initialPage","initialScale","initialSidebarOpen","className","document","numPages","loading","error","scale","setScale","sidebarOpen","setSidebarOpen","currentPage","setCurrentPage","containerRef","viewerRef","pdfViewerRef","eventBusRef","findControllerRef","search","handleScaleChange","newScale","handlePageChange","page","scrollToPage","onScaleChange","onPageChange","portalTargets","current","currentPageNumber","handleKeyDown","e","ctrlKey","metaKey","key","preventDefault","openSearch","window","addEventListener","removeEventListener","handleDownload","getData","then","data","blob","Blob","buffer","type","url","URL","createObjectURL","filename","split","pop","a","globalThis","createElement","href","download","click","revokeObjectURL","handleSidebarToggle","prev","handleToolbarPageChange","rootClassName","pdfViewer","loadingContainer","spinnerIcon","errorContainer","errorIcon","message","onSearchOpen","onSidebarToggle","onDownload","isSearchOpen","query","totalMatches","currentMatchIndex","onQueryChange","setQuery","onNext","nextMatch","onPrev","prevMatch","onClose","closeSearch","contentArea","onPageClick","scrollContainerWrapper","ref","scrollContainer","map","target","pageAnnotations","pageNumber","length","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, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { EMPTY_ANNOTATION_ARRAY, EMPTY_ANNOTATIONS } from \"./constants.js\";\nimport { usePdfAnnotationPortals } from \"./hooks/usePdfAnnotationPortals.js\";\nimport { usePdfDocument } from \"./hooks/usePdfDocument.js\";\nimport { usePdfViewer } from \"./hooks/usePdfViewer.js\";\nimport { usePdfViewerSearch } from \"./hooks/usePdfViewerSearch.js\";\nimport { usePdfViewerSync } from \"./hooks/usePdfViewerSync.js\";\nimport styles from \"./PdfViewer.module.css\";\nimport { PdfViewerAnnotationLayer } from \"./PdfViewerAnnotationLayer.js\";\nimport { PdfViewerSearchBar } from \"./PdfViewerSearchBar.js\";\nimport { PdfViewerSidebar } from \"./PdfViewerSidebar.js\";\nimport { PdfViewerToolbar } from \"./PdfViewerToolbar.js\";\nimport type { PdfViewerProps } from \"./types.js\";\n\nexport function BasePdfViewer({\n src,\n annotations = EMPTY_ANNOTATIONS,\n onAnnotationClick,\n initialPage = 1,\n initialScale = 1.0,\n initialSidebarOpen = false,\n className,\n}: PdfViewerProps): React.ReactElement {\n const { document, numPages, loading, error } = usePdfDocument(src);\n const [scale, setScale] = useState(initialScale);\n const [sidebarOpen, setSidebarOpen] = useState(initialSidebarOpen);\n const [currentPage, setCurrentPage] = useState(initialPage);\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 initialScale,\n );\n\n const search = usePdfViewerSearch(eventBusRef, findControllerRef, document);\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 } = usePdfViewerSync({\n pdfViewerRef,\n eventBusRef,\n document,\n scale,\n onScaleChange: handleScaleChange,\n onPageChange: handlePageChange,\n });\n\n const portalTargets = usePdfAnnotationPortals(\n pdfViewerRef,\n eventBusRef,\n document,\n );\n\n // Set initial page after viewer is ready\n useEffect(function setInitialPage() {\n if (pdfViewerRef.current != null && initialPage > 1) {\n pdfViewerRef.current.currentPageNumber = initialPage;\n }\n }, [pdfViewerRef, initialPage]);\n\n // Ctrl+F handler\n useEffect(function registerSearchShortcut() {\n const handleKeyDown = (e: KeyboardEvent) => {\n if ((e.ctrlKey || e.metaKey) && e.key === \"f\") {\n e.preventDefault();\n search.openSearch();\n }\n };\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [search.openSearch]);\n\n const handleDownload = useCallback(() => {\n if (document == null) {\n return;\n }\n void document.getData().then((data) => {\n const blob = new Blob([data.buffer as ArrayBuffer], {\n type: \"application/pdf\",\n });\n const url = URL.createObjectURL(blob);\n // Extract filename from URL by taking the last path segment and stripping query params\n const filename = typeof src === \"string\"\n ? src.split(\"/\").pop()?.split(\"?\")[0] || \"document.pdf\"\n : \"document.pdf\";\n const a = globalThis.document.createElement(\"a\");\n a.href = url;\n a.download = filename;\n a.click();\n URL.revokeObjectURL(url);\n });\n }, [document, src]);\n\n const handleSidebarToggle = useCallback(() => {\n setSidebarOpen((prev) => !prev);\n }, []);\n\n const handleToolbarPageChange = useCallback(\n (page: number) => {\n setCurrentPage(page);\n scrollToPage(page);\n },\n [scrollToPage],\n );\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (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 (error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {error.message}\n </div>\n </div>\n );\n }\n\n if (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={currentPage}\n numPages={numPages}\n scale={scale}\n sidebarOpen={sidebarOpen}\n onPageChange={handleToolbarPageChange}\n onScaleChange={setScale}\n onSearchOpen={search.openSearch}\n onSidebarToggle={handleSidebarToggle}\n onDownload={handleDownload}\n />\n {search.isSearchOpen && (\n <PdfViewerSearchBar\n query={search.query}\n totalMatches={search.totalMatches}\n currentMatchIndex={search.currentMatchIndex}\n onQueryChange={search.setQuery}\n onNext={search.nextMatch}\n onPrev={search.prevMatch}\n onClose={search.closeSearch}\n />\n )}\n <div className={styles.contentArea}>\n {sidebarOpen && (\n <PdfViewerSidebar\n document={document}\n numPages={numPages}\n currentPage={currentPage}\n onPageClick={handleToolbarPageChange}\n />\n )}\n <div className={styles.scrollContainerWrapper}>\n <div ref={containerRef} className={styles.scrollContainer}>\n <div ref={viewerRef} className=\"pdfViewer\" />\n {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;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,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACvE,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,sBAAsB,EAAEC,iBAAiB,QAAQ,gBAAgB;AAC1E,SAASC,uBAAuB,QAAQ,oCAAoC;AAC5E,SAASC,cAAc,QAAQ,2BAA2B;AAC1D,SAASC,YAAY,QAAQ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ACF6F,MAAM,CAACK,SACT,CAAC;EACH,CAAC,CACE,CACF,CACF,CACF,CAAC;AAEV","ignoreList":[]}
@@ -0,0 +1,95 @@
1
+ .pdfViewer {
2
+ display: flex;
3
+ flex-direction: column;
4
+ width: 100%;
5
+ height: 100%;
6
+ background-color: var(--osdk-pdf-viewer-bg);
7
+ border: var(--osdk-pdf-viewer-border);
8
+ border-radius: var(--osdk-surface-border-radius);
9
+ overflow: hidden;
10
+ position: relative;
11
+ }
12
+
13
+ .contentArea {
14
+ display: flex;
15
+ flex: 1;
16
+ overflow: hidden;
17
+ position: relative;
18
+ }
19
+
20
+ .scrollContainerWrapper {
21
+ flex: 1;
22
+ position: relative;
23
+ overflow: hidden;
24
+ }
25
+
26
+ .scrollContainer {
27
+ overflow: auto;
28
+ position: absolute;
29
+ top: 0;
30
+ left: 0;
31
+ right: 0;
32
+ bottom: 0;
33
+ }
34
+
35
+ .loadingContainer {
36
+ display: flex;
37
+ flex-direction: column;
38
+ align-items: center;
39
+ justify-content: center;
40
+ gap: calc(var(--osdk-surface-spacing) * 2);
41
+ height: 100%;
42
+ font-family: var(--osdk-typography-family-default);
43
+ font-size: var(--osdk-typography-size-body-medium);
44
+ color: var(--osdk-typography-color-muted);
45
+ }
46
+
47
+ .errorContainer {
48
+ display: flex;
49
+ align-items: center;
50
+ justify-content: center;
51
+ gap: var(--osdk-surface-spacing);
52
+ height: 100%;
53
+ font-family: var(--osdk-typography-family-default);
54
+ font-size: var(--osdk-typography-size-body-medium);
55
+ color: var(--osdk-typography-color-danger-rest);
56
+ }
57
+
58
+ @keyframes spin {
59
+ from {
60
+ transform: rotate(0deg);
61
+ }
62
+ to {
63
+ transform: rotate(360deg);
64
+ }
65
+ }
66
+
67
+ .spinnerIcon {
68
+ animation: spin 1s linear infinite;
69
+ color: var(--osdk-typography-color-muted);
70
+ }
71
+
72
+ .errorIcon {
73
+ flex-shrink: 0;
74
+ }
75
+
76
+ /* PDFViewer page overrides */
77
+ :global(.pdfViewer .page) {
78
+ box-shadow: var(--osdk-pdf-viewer-page-shadow);
79
+ background-color: var(--osdk-palette-white);
80
+ margin: 0 auto var(--osdk-pdf-viewer-page-gap);
81
+ }
82
+
83
+ /* Search highlight overrides — match pdf.js FindController CSS classes */
84
+ :global(.textLayer) .highlight {
85
+ background-color: var(--osdk-pdf-viewer-search-highlight);
86
+ border-radius: 1px;
87
+ }
88
+
89
+ :global(.textLayer) .highlight.selected {
90
+ background-color: var(--osdk-pdf-viewer-search-active);
91
+ }
92
+
93
+ :global(.textLayer)::selection {
94
+ background: var(--osdk-intent-primary-rest);
95
+ }
@@ -0,0 +1,16 @@
1
+ // CSS Module proxy for PdfViewer.module.css
2
+ const styles = {
3
+ "pdfViewer": "PdfViewer-module__pdfViewer___7nCJQUHY",
4
+ "contentArea": "PdfViewer-module__contentArea___4QVW9oJR",
5
+ "scrollContainerWrapper": "PdfViewer-module__scrollContainerWrapper___MGUf2Bdn",
6
+ "scrollContainer": "PdfViewer-module__scrollContainer___H-KtV92S",
7
+ "loadingContainer": "PdfViewer-module__loadingContainer___jMm-fGVB",
8
+ "errorContainer": "PdfViewer-module__errorContainer___Vs2aAf-H",
9
+ "spinnerIcon": "PdfViewer-module__spinnerIcon___ToPhzHJn",
10
+ "spin": "PdfViewer-module__spin___RtvIp8OH",
11
+ "errorIcon": "PdfViewer-module__errorIcon___xdB0USZw",
12
+ "highlight": "PdfViewer-module__highlight___TS0k-Fyu",
13
+ "selected": "PdfViewer-module__selected___cQuODZ69"
14
+ };
15
+
16
+ export default styles;
@@ -0,0 +1,74 @@
1
+ /*
2
+ * Copyright 2025 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
+ import classnames from "classnames";
18
+ import React, { useCallback, useMemo } from "react";
19
+ import styles from "./PdfViewerAnnotationLayer.module.css.js";
20
+ function AnnotationItem({
21
+ annotation,
22
+ pageHeight,
23
+ scale,
24
+ onClick
25
+ }) {
26
+ const handleClick = useCallback(() => {
27
+ onClick?.(annotation);
28
+ }, [onClick, annotation]);
29
+ const handleKeyDown = useCallback(e => {
30
+ if (e.key === "Enter") {
31
+ e.preventDefault();
32
+ onClick?.(annotation);
33
+ }
34
+ }, [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]);
46
+ const className = classnames(styles.annotation, styles[annotation.type]);
47
+ return /*#__PURE__*/React.createElement("div", {
48
+ className: className,
49
+ style: style,
50
+ onClick: handleClick,
51
+ onKeyDown: handleKeyDown,
52
+ role: "button",
53
+ tabIndex: 0,
54
+ title: annotation.label,
55
+ "data-annotation-id": annotation.id
56
+ });
57
+ }
58
+ export function PdfViewerAnnotationLayer({
59
+ annotations,
60
+ pageHeight,
61
+ scale,
62
+ onAnnotationClick
63
+ }) {
64
+ return /*#__PURE__*/React.createElement("div", {
65
+ className: styles.annotationLayer
66
+ }, annotations.map(annotation => /*#__PURE__*/React.createElement(AnnotationItem, {
67
+ key: annotation.id,
68
+ annotation: annotation,
69
+ pageHeight: pageHeight,
70
+ scale: scale,
71
+ onClick: onAnnotationClick
72
+ })));
73
+ }
74
+ //# sourceMappingURL=PdfViewerAnnotationLayer.js.map
@@ -0,0 +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 styles from \"./PdfViewerAnnotationLayer.module.css\";\nimport type { PdfAnnotation } from \"./types.js\";\n\ninterface 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;AACnD,OAAOC,MAAM,MAAM,uCAAuC;AAiB1D,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;;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CAAC0B,EAAG;IACnB1B,UAAU,EAAEA,UAAW;IACvBC,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbC,OAAO,EAAE0B;EAAkB,CAC5B,CACF,CACE,CAAC;AAEV","ignoreList":[]}
@@ -0,0 +1,65 @@
1
+ .annotationLayer {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ width: 100%;
6
+ height: 100%;
7
+ pointer-events: none;
8
+ z-index: 3;
9
+ }
10
+
11
+ .annotation {
12
+ position: absolute;
13
+ pointer-events: auto;
14
+ cursor: pointer;
15
+ box-sizing: border-box;
16
+ transition: opacity var(--osdk-emphasis-transition-duration)
17
+ var(--osdk-emphasis-ease-default);
18
+ }
19
+
20
+ .annotation:hover {
21
+ opacity: 0.8;
22
+ }
23
+
24
+ .annotation:focus-visible {
25
+ outline: var(--osdk-focus-outline);
26
+ outline-offset: var(--osdk-focus-visible-outline-offset);
27
+ }
28
+
29
+ .highlight {
30
+ background-color: var(
31
+ --osdk-pdf-annotation-color,
32
+ var(--osdk-pdf-viewer-annotation-highlight)
33
+ );
34
+ border-radius: 2px;
35
+ }
36
+
37
+ .underline {
38
+ background-color: transparent;
39
+ border-bottom: 2px solid
40
+ var(
41
+ --osdk-pdf-annotation-color,
42
+ var(--osdk-pdf-viewer-annotation-underline)
43
+ );
44
+ }
45
+
46
+ .comment {
47
+ background-color: var(
48
+ --osdk-pdf-annotation-color,
49
+ var(--osdk-pdf-viewer-annotation-comment)
50
+ );
51
+ border-radius: 50%;
52
+ width: 16px !important;
53
+ height: 16px !important;
54
+ }
55
+
56
+ .pin {
57
+ background-color: var(
58
+ --osdk-pdf-annotation-color,
59
+ var(--osdk-pdf-viewer-annotation-pin)
60
+ );
61
+ border-radius: 50% 50% 50% 0;
62
+ width: 16px !important;
63
+ height: 16px !important;
64
+ transform: rotate(-45deg);
65
+ }
@@ -0,0 +1,11 @@
1
+ // CSS Module proxy for PdfViewerAnnotationLayer.module.css
2
+ const styles = {
3
+ "annotationLayer": "PdfViewerAnnotationLayer-module__annotationLayer___9qNMaJ-S",
4
+ "annotation": "PdfViewerAnnotationLayer-module__annotation___5hTAzm8w",
5
+ "highlight": "PdfViewerAnnotationLayer-module__highlight___hu-LZv1e",
6
+ "underline": "PdfViewerAnnotationLayer-module__underline___SjTKjwwv",
7
+ "comment": "PdfViewerAnnotationLayer-module__comment___darli8TU",
8
+ "pin": "PdfViewerAnnotationLayer-module__pin___VeZrPTVU"
9
+ };
10
+
11
+ export default styles;
@@ -0,0 +1,84 @@
1
+ /*
2
+ * Copyright 2025 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
+ import { ChevronDown, ChevronUp, Cross } from "@blueprintjs/icons";
18
+ import React, { useCallback } from "react";
19
+ import styles from "./PdfViewerSearchBar.module.css.js";
20
+ export function PdfViewerSearchBar({
21
+ query,
22
+ totalMatches,
23
+ currentMatchIndex,
24
+ onQueryChange,
25
+ onNext,
26
+ onPrev,
27
+ onClose
28
+ }) {
29
+ const handleInputChange = useCallback(e => {
30
+ onQueryChange(e.target.value);
31
+ }, [onQueryChange]);
32
+ const handleKeyDown = useCallback(e => {
33
+ if (e.key === "Enter") {
34
+ e.preventDefault();
35
+ if (e.shiftKey) {
36
+ onPrev();
37
+ } else {
38
+ onNext();
39
+ }
40
+ } else if (e.key === "Escape") {
41
+ e.preventDefault();
42
+ onClose();
43
+ }
44
+ }, [onNext, onPrev, onClose]);
45
+ const matchDisplay = totalMatches > 0 ? `${currentMatchIndex + 1} of ${totalMatches}` : query.length > 0 ? "No results" : "";
46
+ return /*#__PURE__*/React.createElement("div", {
47
+ className: styles.searchBar
48
+ }, /*#__PURE__*/React.createElement("input", {
49
+ autoFocus: true,
50
+ className: styles.searchInput,
51
+ type: "text",
52
+ value: query,
53
+ onChange: handleInputChange,
54
+ onKeyDown: handleKeyDown,
55
+ placeholder: "Find in document...",
56
+ "aria-label": "Search in PDF"
57
+ }), matchDisplay.length > 0 && /*#__PURE__*/React.createElement("span", {
58
+ className: styles.matchCount
59
+ }, matchDisplay), /*#__PURE__*/React.createElement("button", {
60
+ className: styles.navButton,
61
+ onClick: onPrev,
62
+ disabled: totalMatches === 0,
63
+ "aria-label": "Previous match",
64
+ type: "button"
65
+ }, /*#__PURE__*/React.createElement(ChevronUp, {
66
+ size: 16
67
+ })), /*#__PURE__*/React.createElement("button", {
68
+ className: styles.navButton,
69
+ onClick: onNext,
70
+ disabled: totalMatches === 0,
71
+ "aria-label": "Next match",
72
+ type: "button"
73
+ }, /*#__PURE__*/React.createElement(ChevronDown, {
74
+ size: 16
75
+ })), /*#__PURE__*/React.createElement("button", {
76
+ className: styles.closeButton,
77
+ onClick: onClose,
78
+ "aria-label": "Close search",
79
+ type: "button"
80
+ }, /*#__PURE__*/React.createElement(Cross, {
81
+ size: 16
82
+ })));
83
+ }
84
+ //# sourceMappingURL=PdfViewerSearchBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdfViewerSearchBar.js","names":["ChevronDown","ChevronUp","Cross","React","useCallback","styles","PdfViewerSearchBar","query","totalMatches","currentMatchIndex","onQueryChange","onNext","onPrev","onClose","handleInputChange","e","target","value","handleKeyDown","key","preventDefault","shiftKey","matchDisplay","length","createElement","className","searchBar","autoFocus","searchInput","type","onChange","onKeyDown","placeholder","matchCount","navButton","onClick","disabled","size","closeButton"],"sources":["PdfViewerSearchBar.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 { ChevronDown, ChevronUp, Cross } from \"@blueprintjs/icons\";\nimport React, { useCallback } from \"react\";\nimport styles from \"./PdfViewerSearchBar.module.css\";\n\ninterface PdfViewerSearchBarProps {\n query: string;\n totalMatches: number;\n currentMatchIndex: number;\n onQueryChange: (query: string) => void;\n onNext: () => void;\n onPrev: () => void;\n onClose: () => void;\n}\n\nexport function PdfViewerSearchBar({\n query,\n totalMatches,\n currentMatchIndex,\n onQueryChange,\n onNext,\n onPrev,\n onClose,\n}: PdfViewerSearchBarProps): React.ReactElement {\n const handleInputChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n onQueryChange(e.target.value);\n },\n [onQueryChange],\n );\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n if (e.shiftKey) {\n onPrev();\n } else {\n onNext();\n }\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n onClose();\n }\n },\n [onNext, onPrev, onClose],\n );\n\n const matchDisplay = totalMatches > 0\n ? `${currentMatchIndex + 1} of ${totalMatches}`\n : query.length > 0\n ? \"No results\"\n : \"\";\n\n return (\n <div className={styles.searchBar}>\n <input\n autoFocus\n className={styles.searchInput}\n type=\"text\"\n value={query}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n placeholder=\"Find in document...\"\n aria-label=\"Search in PDF\"\n />\n {matchDisplay.length > 0 && (\n <span className={styles.matchCount}>{matchDisplay}</span>\n )}\n <button\n className={styles.navButton}\n onClick={onPrev}\n disabled={totalMatches === 0}\n aria-label=\"Previous match\"\n type=\"button\"\n >\n <ChevronUp size={16} />\n </button>\n <button\n className={styles.navButton}\n onClick={onNext}\n disabled={totalMatches === 0}\n aria-label=\"Next match\"\n type=\"button\"\n >\n <ChevronDown size={16} />\n </button>\n <button\n className={styles.closeButton}\n onClick={onClose}\n aria-label=\"Close search\"\n type=\"button\"\n >\n <Cross size={16} />\n </button>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,KAAK,QAAQ,oBAAoB;AAClE,OAAOC,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,OAAOC,MAAM,MAAM,iCAAiC;AAYpD,OAAO,SAASC,kBAAkBA,CAAC;EACjCC,KAAK;EACLC,YAAY;EACZC,iBAAiB;EACjBC,aAAa;EACbC,MAAM;EACNC,MAAM;EACNC;AACuB,CAAC,EAAsB;EAC9C,MAAMC,iBAAiB,GAAGV,WAAW,CAClCW,CAAsC,IAAK;IAC1CL,aAAa,CAACK,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC;EAC/B,CAAC,EACD,CAACP,aAAa,CAChB,CAAC;EAED,MAAMQ,aAAa,GAAGd,WAAW,CAC9BW,CAAsB,IAAK;IAC1B,IAAIA,CAAC,CAACI,GAAG,KAAK,OAAO,EAAE;MACrBJ,CAAC,CAACK,cAAc,CAAC,CAAC;MAClB,IAAIL,CAAC,CAACM,QAAQ,EAAE;QACdT,MAAM,CAAC,CAAC;MACV,CAAC,MAAM;QACLD,MAAM,CAAC,CAAC;MACV;IACF,CAAC,MAAM,IAAII,CAAC,CAACI,GAAG,KAAK,QAAQ,EAAE;MAC7BJ,CAAC,CAACK,cAAc,CAAC,CAAC;MAClBP,OAAO,CAAC,CAAC;IACX;EACF,CAAC,EACD,CAACF,MAAM,EAAEC,MAAM,EAAEC,OAAO,CAC1B,CAAC;EAED,MAAMS,YAAY,GAAGd,YAAY,GAAG,CAAC,GACjC,GAAG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