@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.
- package/CHANGELOG.md +18 -0
- package/build/browser/action-form/ActionForm.js +5 -1
- package/build/browser/action-form/ActionForm.js.map +1 -1
- package/build/browser/action-form/BaseForm.js +4 -8
- package/build/browser/action-form/BaseForm.js.map +1 -1
- package/build/browser/action-form/FormFieldApi.js.map +1 -1
- package/build/browser/action-form/fields/DropdownField.js +104 -0
- package/build/browser/action-form/fields/DropdownField.js.map +1 -0
- package/build/browser/action-form/fields/FormFieldRenderer.js +23 -12
- package/build/browser/action-form/fields/FormFieldRenderer.js.map +1 -1
- package/build/browser/action-form/fields/TextInputField.js +8 -9
- package/build/browser/action-form/fields/TextInputField.js.map +1 -1
- package/build/browser/base-components/combobox/Combobox.js +25 -3
- package/build/browser/base-components/combobox/Combobox.js.map +1 -1
- package/build/browser/base-components/combobox/Combobox.module.css +226 -46
- package/build/browser/base-components/combobox/Combobox.module.css.js +1 -0
- package/build/browser/base-components/select/Select.js +7 -1
- package/build/browser/base-components/select/Select.js.map +1 -1
- package/build/browser/base-components/select/Select.module.css +132 -35
- package/build/browser/base-components/select/Select.module.css.js +2 -0
- package/build/browser/base-components/skeleton/SkeletonBar.js +36 -0
- package/build/browser/base-components/skeleton/SkeletonBar.js.map +1 -0
- package/build/browser/base-components/skeleton/SkeletonBar.module.css +39 -0
- package/build/browser/base-components/skeleton/SkeletonBar.module.css.js +7 -0
- package/build/browser/filter-list/FilterList.js +42 -5
- package/build/browser/filter-list/FilterList.js.map +1 -1
- package/build/browser/filter-list/FilterListApi.js.map +1 -1
- package/build/browser/filter-list/base/AddFilterPopover.js +45 -0
- package/build/browser/filter-list/base/AddFilterPopover.js.map +1 -0
- package/build/browser/filter-list/base/AddFilterPopover.module.css +83 -0
- package/build/browser/filter-list/base/AddFilterPopover.module.css.js +9 -0
- package/build/browser/filter-list/base/inputs/CheckboxListInput.js +16 -27
- package/build/browser/filter-list/base/inputs/CheckboxListInput.js.map +1 -1
- package/build/browser/filter-list/base/inputs/CheckboxListInput.module.css +15 -5
- package/build/browser/filter-list/base/inputs/CheckboxListSkeleton.js +46 -0
- package/build/browser/filter-list/base/inputs/CheckboxListSkeleton.js.map +1 -0
- package/build/browser/filter-list/base/inputs/CheckboxListSkeleton.module.css +32 -0
- package/build/browser/filter-list/base/inputs/CheckboxListSkeleton.module.css.js +8 -0
- package/build/browser/filter-list/base/inputs/ListogramInput.js +21 -12
- package/build/browser/filter-list/base/inputs/ListogramInput.js.map +1 -1
- package/build/browser/filter-list/base/inputs/ListogramInput.module.css +13 -1
- package/build/browser/filter-list/base/inputs/ListogramSkeleton.js +45 -0
- package/build/browser/filter-list/base/inputs/ListogramSkeleton.js.map +1 -0
- package/build/browser/filter-list/base/inputs/ListogramSkeleton.module.css +32 -0
- package/build/browser/filter-list/base/inputs/ListogramSkeleton.module.css.js +8 -0
- package/build/browser/filter-list/base/inputs/MultiSelectInput.js +1 -1
- package/build/browser/filter-list/base/inputs/MultiSelectInput.js.map +1 -1
- package/build/browser/filter-list/base/inputs/RangeInput.js +13 -13
- package/build/browser/filter-list/base/inputs/RangeInput.js.map +1 -1
- package/build/browser/filter-list/base/inputs/RangeInput.module.css +23 -0
- package/build/browser/filter-list/base/inputs/TextTagsInput.js +1 -1
- package/build/browser/filter-list/base/inputs/TextTagsInput.js.map +1 -1
- package/build/browser/filter-list/base/inputs/useStaleData.js +29 -0
- package/build/browser/filter-list/base/inputs/useStaleData.js.map +1 -0
- package/build/browser/filter-list/hooks/useFilterVisibility.js +68 -0
- package/build/browser/filter-list/hooks/useFilterVisibility.js.map +1 -0
- package/build/browser/object-table/DefaultCellRenderer.js +13 -3
- package/build/browser/object-table/DefaultCellRenderer.js.map +1 -1
- package/build/browser/object-table/EditableCell.js +7 -6
- package/build/browser/object-table/EditableCell.js.map +1 -1
- package/build/browser/object-table/LoadingCell.js +6 -3
- package/build/browser/object-table/LoadingCell.js.map +1 -1
- package/build/browser/object-table/LoadingRow.js +2 -1
- package/build/browser/object-table/LoadingRow.js.map +1 -1
- package/build/browser/object-table/ObjectTableApi.js.map +1 -1
- package/build/browser/object-table/Table.js.map +1 -1
- package/build/browser/object-table/TableCell.module.css +1 -0
- package/build/browser/object-table/components/AsyncValueCell.js +35 -0
- package/build/browser/object-table/components/AsyncValueCell.js.map +1 -0
- package/build/browser/object-table/hooks/useColumnDefs.js +3 -1
- package/build/browser/object-table/hooks/useColumnDefs.js.map +1 -1
- package/build/browser/object-table/hooks/useFunctionColumnsData.js +270 -0
- package/build/browser/object-table/hooks/useFunctionColumnsData.js.map +1 -0
- package/build/browser/object-table/hooks/useObjectTableData.js +34 -13
- package/build/browser/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/browser/object-table/utils/AsyncCellData.js +30 -0
- package/build/browser/object-table/utils/AsyncCellData.js.map +1 -0
- package/build/browser/object-table/utils/constants.js +1 -0
- package/build/browser/object-table/utils/constants.js.map +1 -1
- package/build/browser/pdf-viewer/PdfRenderer.js +88 -0
- package/build/browser/pdf-viewer/PdfRenderer.js.map +1 -0
- package/build/browser/pdf-viewer/PdfViewer.js +197 -0
- package/build/browser/pdf-viewer/PdfViewer.js.map +1 -0
- package/build/browser/pdf-viewer/PdfViewer.module.css +95 -0
- package/build/browser/pdf-viewer/PdfViewer.module.css.js +16 -0
- package/build/browser/pdf-viewer/PdfViewerAnnotationLayer.js +74 -0
- package/build/browser/pdf-viewer/PdfViewerAnnotationLayer.js.map +1 -0
- package/build/browser/pdf-viewer/PdfViewerAnnotationLayer.module.css +65 -0
- package/build/browser/pdf-viewer/PdfViewerAnnotationLayer.module.css.js +11 -0
- package/build/browser/pdf-viewer/PdfViewerSearchBar.js +84 -0
- package/build/browser/pdf-viewer/PdfViewerSearchBar.js.map +1 -0
- package/build/browser/pdf-viewer/PdfViewerSearchBar.module.css +65 -0
- package/build/browser/pdf-viewer/PdfViewerSearchBar.module.css.js +10 -0
- package/build/browser/pdf-viewer/PdfViewerSidebar.js +74 -0
- package/build/browser/pdf-viewer/PdfViewerSidebar.js.map +1 -0
- package/build/browser/pdf-viewer/PdfViewerSidebar.module.css +46 -0
- package/build/browser/pdf-viewer/PdfViewerSidebar.module.css.js +11 -0
- package/build/browser/pdf-viewer/PdfViewerThumbnail.js +100 -0
- package/build/browser/pdf-viewer/PdfViewerThumbnail.js.map +1 -0
- package/build/browser/pdf-viewer/PdfViewerThumbnail.module.css +26 -0
- package/build/browser/pdf-viewer/PdfViewerThumbnail.module.css.js +8 -0
- package/build/browser/pdf-viewer/PdfViewerToolbar.js +167 -0
- package/build/browser/pdf-viewer/PdfViewerToolbar.js.map +1 -0
- package/build/browser/pdf-viewer/PdfViewerToolbar.module.css +86 -0
- package/build/browser/pdf-viewer/PdfViewerToolbar.module.css.js +12 -0
- package/build/browser/pdf-viewer/constants.js +43 -0
- package/build/browser/pdf-viewer/constants.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfAnnotationPortals.js +54 -0
- package/build/browser/pdf-viewer/hooks/usePdfAnnotationPortals.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfDocument.js +67 -0
- package/build/browser/pdf-viewer/hooks/usePdfDocument.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewer.js +69 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewer.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js +106 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewerSync.js +71 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewerSync.js.map +1 -0
- package/build/browser/pdf-viewer/types.js +2 -0
- package/build/browser/pdf-viewer/types.js.map +1 -0
- package/build/browser/public/experimental.js +4 -0
- package/build/browser/public/experimental.js.map +1 -1
- package/build/browser/styles.css +1008 -87
- package/build/cjs/public/experimental.cjs +2311 -895
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.css +678 -153
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +114 -13
- package/build/esm/action-form/ActionForm.js +5 -1
- package/build/esm/action-form/ActionForm.js.map +1 -1
- package/build/esm/action-form/BaseForm.js +4 -8
- package/build/esm/action-form/BaseForm.js.map +1 -1
- package/build/esm/action-form/FormFieldApi.js.map +1 -1
- package/build/esm/action-form/fields/DropdownField.js +104 -0
- package/build/esm/action-form/fields/DropdownField.js.map +1 -0
- package/build/esm/action-form/fields/FormFieldRenderer.js +23 -12
- package/build/esm/action-form/fields/FormFieldRenderer.js.map +1 -1
- package/build/esm/action-form/fields/TextInputField.js +8 -9
- package/build/esm/action-form/fields/TextInputField.js.map +1 -1
- package/build/esm/base-components/combobox/Combobox.js +25 -3
- package/build/esm/base-components/combobox/Combobox.js.map +1 -1
- package/build/esm/base-components/combobox/Combobox.module.css +226 -46
- package/build/esm/base-components/select/Select.js +7 -1
- package/build/esm/base-components/select/Select.js.map +1 -1
- package/build/esm/base-components/select/Select.module.css +132 -35
- package/build/esm/base-components/skeleton/SkeletonBar.js +36 -0
- package/build/esm/base-components/skeleton/SkeletonBar.js.map +1 -0
- package/build/esm/base-components/skeleton/SkeletonBar.module.css +39 -0
- package/build/esm/filter-list/FilterList.js +42 -5
- package/build/esm/filter-list/FilterList.js.map +1 -1
- package/build/esm/filter-list/FilterListApi.js.map +1 -1
- package/build/esm/filter-list/base/AddFilterPopover.js +45 -0
- package/build/esm/filter-list/base/AddFilterPopover.js.map +1 -0
- package/build/esm/filter-list/base/AddFilterPopover.module.css +83 -0
- package/build/esm/filter-list/base/inputs/CheckboxListInput.js +16 -27
- package/build/esm/filter-list/base/inputs/CheckboxListInput.js.map +1 -1
- package/build/esm/filter-list/base/inputs/CheckboxListInput.module.css +15 -5
- package/build/esm/filter-list/base/inputs/CheckboxListSkeleton.js +46 -0
- package/build/esm/filter-list/base/inputs/CheckboxListSkeleton.js.map +1 -0
- package/build/esm/filter-list/base/inputs/CheckboxListSkeleton.module.css +32 -0
- package/build/esm/filter-list/base/inputs/ListogramInput.js +21 -12
- package/build/esm/filter-list/base/inputs/ListogramInput.js.map +1 -1
- package/build/esm/filter-list/base/inputs/ListogramInput.module.css +13 -1
- package/build/esm/filter-list/base/inputs/ListogramSkeleton.js +45 -0
- package/build/esm/filter-list/base/inputs/ListogramSkeleton.js.map +1 -0
- package/build/esm/filter-list/base/inputs/ListogramSkeleton.module.css +32 -0
- package/build/esm/filter-list/base/inputs/MultiSelectInput.js +1 -1
- package/build/esm/filter-list/base/inputs/MultiSelectInput.js.map +1 -1
- package/build/esm/filter-list/base/inputs/RangeInput.js +13 -13
- package/build/esm/filter-list/base/inputs/RangeInput.js.map +1 -1
- package/build/esm/filter-list/base/inputs/RangeInput.module.css +23 -0
- package/build/esm/filter-list/base/inputs/TextTagsInput.js +1 -1
- package/build/esm/filter-list/base/inputs/TextTagsInput.js.map +1 -1
- package/build/esm/filter-list/base/inputs/useStaleData.js +29 -0
- package/build/esm/filter-list/base/inputs/useStaleData.js.map +1 -0
- package/build/esm/filter-list/hooks/useFilterVisibility.js +68 -0
- package/build/esm/filter-list/hooks/useFilterVisibility.js.map +1 -0
- package/build/esm/object-table/DefaultCellRenderer.js +13 -3
- package/build/esm/object-table/DefaultCellRenderer.js.map +1 -1
- package/build/esm/object-table/EditableCell.js +7 -6
- package/build/esm/object-table/EditableCell.js.map +1 -1
- package/build/esm/object-table/LoadingCell.js +6 -3
- package/build/esm/object-table/LoadingCell.js.map +1 -1
- package/build/esm/object-table/LoadingRow.js +2 -1
- package/build/esm/object-table/LoadingRow.js.map +1 -1
- package/build/esm/object-table/ObjectTableApi.js.map +1 -1
- package/build/esm/object-table/Table.js.map +1 -1
- package/build/esm/object-table/TableCell.module.css +1 -0
- package/build/esm/object-table/components/AsyncValueCell.js +35 -0
- package/build/esm/object-table/components/AsyncValueCell.js.map +1 -0
- package/build/esm/object-table/hooks/useColumnDefs.js +3 -1
- package/build/esm/object-table/hooks/useColumnDefs.js.map +1 -1
- package/build/esm/object-table/hooks/useFunctionColumnsData.js +270 -0
- package/build/esm/object-table/hooks/useFunctionColumnsData.js.map +1 -0
- package/build/esm/object-table/hooks/useObjectTableData.js +34 -13
- package/build/esm/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/esm/object-table/utils/AsyncCellData.js +30 -0
- package/build/esm/object-table/utils/AsyncCellData.js.map +1 -0
- package/build/esm/object-table/utils/constants.js +1 -0
- package/build/esm/object-table/utils/constants.js.map +1 -1
- package/build/esm/pdf-viewer/PdfRenderer.js +88 -0
- package/build/esm/pdf-viewer/PdfRenderer.js.map +1 -0
- package/build/esm/pdf-viewer/PdfViewer.js +197 -0
- package/build/esm/pdf-viewer/PdfViewer.js.map +1 -0
- package/build/esm/pdf-viewer/PdfViewer.module.css +95 -0
- package/build/esm/pdf-viewer/PdfViewerAnnotationLayer.js +74 -0
- package/build/esm/pdf-viewer/PdfViewerAnnotationLayer.js.map +1 -0
- package/build/esm/pdf-viewer/PdfViewerAnnotationLayer.module.css +65 -0
- package/build/esm/pdf-viewer/PdfViewerSearchBar.js +84 -0
- package/build/esm/pdf-viewer/PdfViewerSearchBar.js.map +1 -0
- package/build/esm/pdf-viewer/PdfViewerSearchBar.module.css +65 -0
- package/build/esm/pdf-viewer/PdfViewerSidebar.js +74 -0
- package/build/esm/pdf-viewer/PdfViewerSidebar.js.map +1 -0
- package/build/esm/pdf-viewer/PdfViewerSidebar.module.css +46 -0
- package/build/esm/pdf-viewer/PdfViewerThumbnail.js +100 -0
- package/build/esm/pdf-viewer/PdfViewerThumbnail.js.map +1 -0
- package/build/esm/pdf-viewer/PdfViewerThumbnail.module.css +26 -0
- package/build/esm/pdf-viewer/PdfViewerToolbar.js +167 -0
- package/build/esm/pdf-viewer/PdfViewerToolbar.js.map +1 -0
- package/build/esm/pdf-viewer/PdfViewerToolbar.module.css +86 -0
- package/build/esm/pdf-viewer/constants.js +43 -0
- package/build/esm/pdf-viewer/constants.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfAnnotationPortals.js +54 -0
- package/build/esm/pdf-viewer/hooks/usePdfAnnotationPortals.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfDocument.js +67 -0
- package/build/esm/pdf-viewer/hooks/usePdfDocument.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewer.js +69 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewer.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js +106 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewerSync.js +71 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewerSync.js.map +1 -0
- package/build/esm/pdf-viewer/types.js +2 -0
- package/build/esm/pdf-viewer/types.js.map +1 -0
- package/build/esm/public/experimental.js +4 -0
- package/build/esm/public/experimental.js.map +1 -1
- package/build/types/action-form/FormFieldApi.d.ts +48 -37
- package/build/types/action-form/FormFieldApi.d.ts.map +1 -1
- package/build/types/action-form/fields/DropdownField.d.ts +6 -0
- package/build/types/action-form/fields/DropdownField.d.ts.map +1 -0
- package/build/types/action-form/fields/FormFieldRenderer.d.ts.map +1 -1
- package/build/types/action-form/fields/TextInputField.d.ts +3 -1
- package/build/types/action-form/fields/TextInputField.d.ts.map +1 -1
- package/build/types/base-components/combobox/Combobox.d.ts +9 -1
- package/build/types/base-components/combobox/Combobox.d.ts.map +1 -1
- package/build/types/base-components/select/Select.d.ts +8 -2
- package/build/types/base-components/select/Select.d.ts.map +1 -1
- package/build/types/base-components/skeleton/SkeletonBar.d.ts +9 -0
- package/build/types/base-components/skeleton/SkeletonBar.d.ts.map +1 -0
- package/build/types/filter-list/FilterList.d.ts.map +1 -1
- package/build/types/filter-list/FilterListApi.d.ts +24 -6
- package/build/types/filter-list/FilterListApi.d.ts.map +1 -1
- package/build/types/filter-list/base/AddFilterPopover.d.ts +12 -0
- package/build/types/filter-list/base/AddFilterPopover.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/CheckboxListInput.d.ts +2 -1
- package/build/types/filter-list/base/inputs/CheckboxListInput.d.ts.map +1 -1
- package/build/types/filter-list/base/inputs/CheckboxListSkeleton.d.ts +2 -0
- package/build/types/filter-list/base/inputs/CheckboxListSkeleton.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/ListogramInput.d.ts +2 -1
- package/build/types/filter-list/base/inputs/ListogramInput.d.ts.map +1 -1
- package/build/types/filter-list/base/inputs/ListogramSkeleton.d.ts +2 -0
- package/build/types/filter-list/base/inputs/ListogramSkeleton.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/RangeInput.d.ts.map +1 -1
- package/build/types/filter-list/base/inputs/useStaleData.d.ts +1 -0
- package/build/types/filter-list/base/inputs/useStaleData.d.ts.map +1 -0
- package/build/types/filter-list/hooks/useFilterVisibility.d.ts +8 -0
- package/build/types/filter-list/hooks/useFilterVisibility.d.ts.map +1 -0
- package/build/types/object-table/DefaultCellRenderer.d.ts.map +1 -1
- package/build/types/object-table/EditableCell.d.ts.map +1 -1
- package/build/types/object-table/LoadingCell.d.ts +1 -0
- package/build/types/object-table/LoadingCell.d.ts.map +1 -1
- package/build/types/object-table/LoadingRow.d.ts.map +1 -1
- package/build/types/object-table/ObjectTableApi.d.ts +51 -15
- package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
- package/build/types/object-table/Table.d.ts +1 -0
- package/build/types/object-table/Table.d.ts.map +1 -1
- package/build/types/object-table/components/AsyncValueCell.d.ts +5 -0
- package/build/types/object-table/components/AsyncValueCell.d.ts.map +1 -0
- package/build/types/object-table/hooks/useFunctionColumnsData.d.ts +13 -0
- package/build/types/object-table/hooks/useFunctionColumnsData.d.ts.map +1 -0
- package/build/types/object-table/hooks/useObjectTableData.d.ts +8 -1
- package/build/types/object-table/hooks/useObjectTableData.d.ts.map +1 -1
- package/build/types/object-table/utils/AsyncCellData.d.ts +8 -0
- package/build/types/object-table/utils/AsyncCellData.d.ts.map +1 -0
- package/build/types/object-table/utils/constants.d.ts +1 -0
- package/build/types/object-table/utils/constants.d.ts.map +1 -1
- package/build/types/pdf-viewer/PdfRenderer.d.ts +8 -0
- package/build/types/pdf-viewer/PdfRenderer.d.ts.map +1 -0
- package/build/types/pdf-viewer/PdfViewer.d.ts +4 -0
- package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -0
- package/build/types/pdf-viewer/PdfViewerAnnotationLayer.d.ts +10 -0
- package/build/types/pdf-viewer/PdfViewerAnnotationLayer.d.ts.map +1 -0
- package/build/types/pdf-viewer/PdfViewerSearchBar.d.ts +12 -0
- package/build/types/pdf-viewer/PdfViewerSearchBar.d.ts.map +1 -0
- package/build/types/pdf-viewer/PdfViewerSidebar.d.ts +10 -0
- package/build/types/pdf-viewer/PdfViewerSidebar.d.ts.map +1 -0
- package/build/types/pdf-viewer/PdfViewerThumbnail.d.ts +10 -0
- package/build/types/pdf-viewer/PdfViewerThumbnail.d.ts.map +1 -0
- package/build/types/pdf-viewer/PdfViewerToolbar.d.ts +14 -0
- package/build/types/pdf-viewer/PdfViewerToolbar.d.ts.map +1 -0
- package/build/types/pdf-viewer/constants.d.ts +17 -0
- package/build/types/pdf-viewer/constants.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfAnnotationPortals.d.ts +10 -0
- package/build/types/pdf-viewer/hooks/usePdfAnnotationPortals.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfDocument.d.ts +9 -0
- package/build/types/pdf-viewer/hooks/usePdfDocument.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts +9 -0
- package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfViewerSearch.d.ts +15 -0
- package/build/types/pdf-viewer/hooks/usePdfViewerSearch.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfViewerSync.d.ts +15 -0
- package/build/types/pdf-viewer/hooks/usePdfViewerSync.d.ts.map +1 -0
- package/build/types/pdf-viewer/types.d.ts +44 -0
- package/build/types/pdf-viewer/types.d.ts.map +1 -0
- package/build/types/public/experimental.d.ts +4 -1
- package/build/types/public/experimental.d.ts.map +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,167 @@
|
|
|
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 { Input } from "@base-ui/react/input";
|
|
18
|
+
import { ChevronLeft, ChevronRight, Download, Menu, Minus, Plus, Search } from "@blueprintjs/icons";
|
|
19
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
20
|
+
import { MAX_SCALE, MIN_SCALE, SCALE_STEP } from "./constants.js";
|
|
21
|
+
import styles from "./PdfViewerToolbar.module.css";
|
|
22
|
+
export function PdfViewerToolbar({
|
|
23
|
+
currentPage,
|
|
24
|
+
numPages,
|
|
25
|
+
scale,
|
|
26
|
+
sidebarOpen,
|
|
27
|
+
onPageChange,
|
|
28
|
+
onScaleChange,
|
|
29
|
+
onSearchOpen,
|
|
30
|
+
onSidebarToggle,
|
|
31
|
+
onDownload
|
|
32
|
+
}) {
|
|
33
|
+
const [pageInputValue, setPageInputValue] = useState(String(currentPage));
|
|
34
|
+
|
|
35
|
+
// Sync input display when currentPage changes from scrolling
|
|
36
|
+
useEffect(function () {
|
|
37
|
+
setPageInputValue(String(currentPage));
|
|
38
|
+
}, [currentPage]);
|
|
39
|
+
const handlePrevPage = useCallback(() => {
|
|
40
|
+
if (currentPage > 1) {
|
|
41
|
+
const newPage = currentPage - 1;
|
|
42
|
+
onPageChange(newPage);
|
|
43
|
+
setPageInputValue(String(newPage));
|
|
44
|
+
}
|
|
45
|
+
}, [currentPage, onPageChange]);
|
|
46
|
+
const handleNextPage = useCallback(() => {
|
|
47
|
+
if (currentPage < numPages) {
|
|
48
|
+
const newPage = currentPage + 1;
|
|
49
|
+
onPageChange(newPage);
|
|
50
|
+
setPageInputValue(String(newPage));
|
|
51
|
+
}
|
|
52
|
+
}, [currentPage, numPages, onPageChange]);
|
|
53
|
+
const handlePageInputChange = useCallback(e => {
|
|
54
|
+
setPageInputValue(e.target.value);
|
|
55
|
+
}, []);
|
|
56
|
+
const handlePageInputKeyDown = useCallback(e => {
|
|
57
|
+
if (e.key === "Enter") {
|
|
58
|
+
const page = parseInt(pageInputValue, 10);
|
|
59
|
+
if (!isNaN(page) && page >= 1 && page <= numPages) {
|
|
60
|
+
onPageChange(page);
|
|
61
|
+
} else {
|
|
62
|
+
setPageInputValue(String(currentPage));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, [pageInputValue, numPages, onPageChange, currentPage]);
|
|
66
|
+
const handlePageInputBlur = useCallback(() => {
|
|
67
|
+
setPageInputValue(String(currentPage));
|
|
68
|
+
}, [currentPage]);
|
|
69
|
+
const handleZoomIn = useCallback(() => {
|
|
70
|
+
const newScale = Math.min(scale + SCALE_STEP, MAX_SCALE);
|
|
71
|
+
onScaleChange(newScale);
|
|
72
|
+
}, [scale, onScaleChange]);
|
|
73
|
+
const handleZoomOut = useCallback(() => {
|
|
74
|
+
const newScale = Math.max(scale - SCALE_STEP, MIN_SCALE);
|
|
75
|
+
onScaleChange(newScale);
|
|
76
|
+
}, [scale, onScaleChange]);
|
|
77
|
+
const scalePercent = `${Math.round(scale * 100)}%`;
|
|
78
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
className: styles.toolbar
|
|
80
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
81
|
+
className: styles.toolbarButton,
|
|
82
|
+
onClick: onSidebarToggle,
|
|
83
|
+
"aria-label": sidebarOpen ? "Close sidebar" : "Open sidebar",
|
|
84
|
+
title: sidebarOpen ? "Close sidebar" : "Open sidebar",
|
|
85
|
+
"aria-pressed": sidebarOpen,
|
|
86
|
+
type: "button"
|
|
87
|
+
}, /*#__PURE__*/React.createElement(Menu, {
|
|
88
|
+
size: 16
|
|
89
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: styles.separator
|
|
91
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: styles.toolbarGroup
|
|
93
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
94
|
+
className: styles.toolbarButton,
|
|
95
|
+
onClick: handlePrevPage,
|
|
96
|
+
disabled: currentPage <= 1,
|
|
97
|
+
"aria-label": "Previous page",
|
|
98
|
+
title: "Previous page",
|
|
99
|
+
type: "button"
|
|
100
|
+
}, /*#__PURE__*/React.createElement(ChevronLeft, {
|
|
101
|
+
size: 16
|
|
102
|
+
})), /*#__PURE__*/React.createElement(Input, {
|
|
103
|
+
className: styles.pageInput,
|
|
104
|
+
type: "text",
|
|
105
|
+
value: pageInputValue,
|
|
106
|
+
onChange: handlePageInputChange,
|
|
107
|
+
onKeyDown: handlePageInputKeyDown,
|
|
108
|
+
onBlur: handlePageInputBlur,
|
|
109
|
+
"aria-label": "Page number"
|
|
110
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
111
|
+
className: styles.pageCount
|
|
112
|
+
}, "of ", numPages), /*#__PURE__*/React.createElement("button", {
|
|
113
|
+
className: styles.toolbarButton,
|
|
114
|
+
onClick: handleNextPage,
|
|
115
|
+
disabled: currentPage >= numPages,
|
|
116
|
+
"aria-label": "Next page",
|
|
117
|
+
title: "Next page",
|
|
118
|
+
type: "button"
|
|
119
|
+
}, /*#__PURE__*/React.createElement(ChevronRight, {
|
|
120
|
+
size: 16
|
|
121
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
122
|
+
className: styles.separator
|
|
123
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
124
|
+
className: styles.toolbarGroup
|
|
125
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
126
|
+
className: styles.toolbarButton,
|
|
127
|
+
onClick: handleZoomOut,
|
|
128
|
+
disabled: scale <= MIN_SCALE,
|
|
129
|
+
"aria-label": "Zoom out",
|
|
130
|
+
title: "Zoom out",
|
|
131
|
+
type: "button"
|
|
132
|
+
}, /*#__PURE__*/React.createElement(Minus, {
|
|
133
|
+
size: 16
|
|
134
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
135
|
+
className: styles.scaleDisplay
|
|
136
|
+
}, scalePercent), /*#__PURE__*/React.createElement("button", {
|
|
137
|
+
className: styles.toolbarButton,
|
|
138
|
+
onClick: handleZoomIn,
|
|
139
|
+
disabled: scale >= MAX_SCALE,
|
|
140
|
+
"aria-label": "Zoom in",
|
|
141
|
+
title: "Zoom in",
|
|
142
|
+
type: "button"
|
|
143
|
+
}, /*#__PURE__*/React.createElement(Plus, {
|
|
144
|
+
size: 16
|
|
145
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
className: styles.separator
|
|
147
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
148
|
+
className: styles.toolbarButton,
|
|
149
|
+
onClick: onSearchOpen,
|
|
150
|
+
"aria-label": "Search",
|
|
151
|
+
title: "Search",
|
|
152
|
+
type: "button"
|
|
153
|
+
}, /*#__PURE__*/React.createElement(Search, {
|
|
154
|
+
size: 16
|
|
155
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
156
|
+
className: styles.separator
|
|
157
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
158
|
+
className: styles.toolbarButton,
|
|
159
|
+
onClick: onDownload,
|
|
160
|
+
"aria-label": "Download",
|
|
161
|
+
title: "Download",
|
|
162
|
+
type: "button"
|
|
163
|
+
}, /*#__PURE__*/React.createElement(Download, {
|
|
164
|
+
size: 16
|
|
165
|
+
})));
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=PdfViewerToolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PdfViewerToolbar.js","names":["Input","ChevronLeft","ChevronRight","Download","Menu","Minus","Plus","Search","React","useCallback","useEffect","useState","MAX_SCALE","MIN_SCALE","SCALE_STEP","styles","PdfViewerToolbar","currentPage","numPages","scale","sidebarOpen","onPageChange","onScaleChange","onSearchOpen","onSidebarToggle","onDownload","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"],"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 { Input } from \"@base-ui/react/input\";\nimport {\n ChevronLeft,\n ChevronRight,\n Download,\n Menu,\n Minus,\n Plus,\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\ninterface 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}\n\nexport function PdfViewerToolbar({\n currentPage,\n numPages,\n scale,\n sidebarOpen,\n onPageChange,\n onScaleChange,\n onSearchOpen,\n onSidebarToggle,\n onDownload,\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 <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 <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 </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,sBAAsB;AAC5C,SACEC,WAAW,EACXC,YAAY,EACZC,QAAQ,EACRC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,MAAM,QACD,oBAAoB;AAC3B,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AACjE,OAAOC,MAAM,MAAM,+BAA+B;AAclD,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,WAAW;EACXC,QAAQ;EACRC,KAAK;EACLC,WAAW;EACXC,YAAY;EACZC,aAAa;EACbC,YAAY;EACZC,eAAe;EACfC;AACqB,CAAC,EAAsB;EAC5C,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAGhB,QAAQ,CAACiB,MAAM,CAACX,WAAW,CAAC,CAAC;;EAEzE;EACAP,SAAS,CAAC,YAAyB;IACjCiB,iBAAiB,CAACC,MAAM,CAACX,WAAW,CAAC,CAAC;EACxC,CAAC,EAAE,CAACA,WAAW,CAAC,CAAC;EAEjB,MAAMY,cAAc,GAAGpB,WAAW,CAAC,MAAM;IACvC,IAAIQ,WAAW,GAAG,CAAC,EAAE;MACnB,MAAMa,OAAO,GAAGb,WAAW,GAAG,CAAC;MAC/BI,YAAY,CAACS,OAAO,CAAC;MACrBH,iBAAiB,CAACC,MAAM,CAACE,OAAO,CAAC,CAAC;IACpC;EACF,CAAC,EAAE,CAACb,WAAW,EAAEI,YAAY,CAAC,CAAC;EAE/B,MAAMU,cAAc,GAAGtB,WAAW,CAAC,MAAM;IACvC,IAAIQ,WAAW,GAAGC,QAAQ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AQ,EAAEzC,KAAK,IAAIP,SAAU;IAC7B,cAAW,SAAS;IACpB2C,KAAK,EAAC,SAAS;IACfC,IAAI,EAAC;EAAQ,gBAEbhD,KAAA,CAAA0C,aAAA,CAAC5C,IAAI;IAACmD,IAAI,EAAE;EAAG,CAAE,CACX,CACL,CAAC,eAENjD,KAAA,CAAA0C,aAAA;IAAKC,SAAS,EAAEpC,MAAM,CAAC2C;EAAU,CAAE,CAAC,eAEpClD,KAAA,CAAA0C,aAAA;IACEC,SAAS,EAAEpC,MAAM,CAACsC,aAAc;IAChCC,OAAO,EAAE/B,YAAa;IACtB,cAAW,QAAQ;IACnBgC,KAAK,EAAC,QAAQ;IACdC,IAAI,EAAC;EAAQ,gBAEbhD,KAAA,CAAA0C,aAAA,CAAC3C,MAAM;IAACkD,IAAI,EAAE;EAAG,CAAE,CACb,CAAC,eAETjD,KAAA,CAAA0C,aAAA;IAAKC,SAAS,EAAEpC,MAAM,CAAC2C;EAAU,CAAE,CAAC,eAEpClD,KAAA,CAAA0C,aAAA;IACEC,SAAS,EAAEpC,MAAM,CAACsC,aAAc;IAChCC,OAAO,EAAE7B,UAAW;IACpB,cAAW,UAAU;IACrB8B,KAAK,EAAC,UAAU;IAChBC,IAAI,EAAC;EAAQ,gBAEbhD,KAAA,CAAA0C,aAAA,CAAC/C,QAAQ;IAACsD,IAAI,EAAE;EAAG,CAAE,CACf,CACL,CAAC;AAEV","ignoreList":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
.toolbar {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
gap: var(--osdk-pdf-viewer-toolbar-gap);
|
|
6
|
+
padding: var(--osdk-surface-spacing);
|
|
7
|
+
background-color: var(--osdk-pdf-viewer-toolbar-bg);
|
|
8
|
+
border-bottom: var(--osdk-pdf-viewer-toolbar-border);
|
|
9
|
+
color: var(--osdk-pdf-viewer-toolbar-color);
|
|
10
|
+
font-family: var(--osdk-typography-family-default);
|
|
11
|
+
font-size: var(--osdk-typography-size-body-small);
|
|
12
|
+
flex-shrink: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.toolbarGroup {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
gap: var(--osdk-surface-spacing);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.separator {
|
|
22
|
+
width: 1px;
|
|
23
|
+
height: 20px;
|
|
24
|
+
background-color: var(--osdk-surface-border-color-default);
|
|
25
|
+
margin: 0 var(--osdk-surface-spacing);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.toolbarButton {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
width: 28px;
|
|
33
|
+
height: 28px;
|
|
34
|
+
border: none;
|
|
35
|
+
background: none;
|
|
36
|
+
color: var(--osdk-typography-color-default-rest);
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
border-radius: var(--osdk-surface-border-radius);
|
|
39
|
+
padding: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.toolbarButton:hover {
|
|
43
|
+
background-color: var(--osdk-surface-background-color-default-hover);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.toolbarButton:active {
|
|
47
|
+
background-color: var(--osdk-surface-background-color-default-active);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.toolbarButton:focus-visible {
|
|
51
|
+
outline: var(--osdk-focus-outline);
|
|
52
|
+
outline-offset: var(--osdk-focus-visible-outline-offset);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.toolbarButton:disabled {
|
|
56
|
+
opacity: 0.5;
|
|
57
|
+
cursor: default;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.pageInput {
|
|
61
|
+
width: 48px;
|
|
62
|
+
text-align: center;
|
|
63
|
+
border: var(--osdk-surface-border);
|
|
64
|
+
border-radius: var(--osdk-surface-border-radius);
|
|
65
|
+
padding: calc(0.5 * var(--osdk-surface-spacing)) var(--osdk-surface-spacing);
|
|
66
|
+
font-family: var(--osdk-typography-family-default);
|
|
67
|
+
font-size: var(--osdk-typography-size-body-small);
|
|
68
|
+
color: var(--osdk-typography-color-default-rest);
|
|
69
|
+
background-color: var(--osdk-background-primary);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.pageInput:focus {
|
|
73
|
+
outline: var(--osdk-focus-outline);
|
|
74
|
+
outline-offset: var(--osdk-focus-visible-outline-offset);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.pageCount {
|
|
78
|
+
color: var(--osdk-typography-color-muted);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.scaleDisplay {
|
|
82
|
+
font-size: var(--osdk-typography-size-body-x-small);
|
|
83
|
+
color: var(--osdk-typography-color-muted);
|
|
84
|
+
min-width: 40px;
|
|
85
|
+
text-align: center;
|
|
86
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
// Default empty values (stable references to avoid re-renders)
|
|
18
|
+
export const EMPTY_ANNOTATIONS = {};
|
|
19
|
+
export const EMPTY_ANNOTATION_ARRAY = [];
|
|
20
|
+
export const EMPTY_STRING = "";
|
|
21
|
+
|
|
22
|
+
// Scale and dimension configuration
|
|
23
|
+
export const SCALE_STEP = 0.25;
|
|
24
|
+
export const MIN_SCALE = 0.25;
|
|
25
|
+
export const MAX_SCALE = 5.0;
|
|
26
|
+
export const DEFAULT_PAGE_HEIGHT = 792;
|
|
27
|
+
export const THUMBNAIL_GAP = 12;
|
|
28
|
+
export const THUMBNAIL_SCALE = 0.2;
|
|
29
|
+
export const DEVICE_PIXEL_RATIO = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
30
|
+
|
|
31
|
+
// pdfjs EventBus event names
|
|
32
|
+
export const FIND_EVENT = "find";
|
|
33
|
+
// cspell:disable-next-line -- pdfjs EventBus event name
|
|
34
|
+
export const UPDATE_FIND_CONTROL_STATE_EVENT = "updatefindcontrolstate";
|
|
35
|
+
// cspell:disable-next-line -- pdfjs EventBus event name
|
|
36
|
+
export const UPDATE_FIND_MATCHES_COUNT_EVENT = "updatefindmatchescount";
|
|
37
|
+
// cspell:disable-next-line -- pdfjs EventBus event name
|
|
38
|
+
export const PAGE_CHANGING_EVENT = "pagechanging";
|
|
39
|
+
// cspell:disable-next-line -- pdfjs EventBus event name
|
|
40
|
+
export const SCALE_CHANGING_EVENT = "scalechanging";
|
|
41
|
+
// cspell:disable-next-line -- pdfjs EventBus event name
|
|
42
|
+
export const PAGE_RENDERED_EVENT = "pagerendered";
|
|
43
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +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","FIND_EVENT","UPDATE_FIND_CONTROL_STATE_EVENT","UPDATE_FIND_MATCHES_COUNT_EVENT","PAGE_CHANGING_EVENT","SCALE_CHANGING_EVENT","PAGE_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_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// pdfjs EventBus event names\nexport const FIND_EVENT = \"find\";\n// cspell:disable-next-line -- pdfjs EventBus event name\nexport const UPDATE_FIND_CONTROL_STATE_EVENT = \"updatefindcontrolstate\";\n// cspell:disable-next-line -- pdfjs EventBus event name\nexport const UPDATE_FIND_MATCHES_COUNT_EVENT = \"updatefindmatchescount\";\n// cspell:disable-next-line -- pdfjs EventBus event name\nexport const PAGE_CHANGING_EVENT = \"pagechanging\";\n// cspell:disable-next-line -- pdfjs EventBus event name\nexport const SCALE_CHANGING_EVENT = \"scalechanging\";\n// cspell:disable-next-line -- pdfjs EventBus event name\nexport const PAGE_RENDERED_EVENT = \"pagerendered\";\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,OAAO,MAAMC,UAAU,GAAG,MAAM;AAChC;AACA,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE;AACA,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE;AACA,OAAO,MAAMC,mBAAmB,GAAG,cAAc;AACjD;AACA,OAAO,MAAMC,oBAAoB,GAAG,eAAe;AACnD;AACA,OAAO,MAAMC,mBAAmB,GAAG,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 { useEffect, useState } from "react";
|
|
18
|
+
import { PAGE_RENDERED_EVENT } from "../constants.js";
|
|
19
|
+
export function usePdfAnnotationPortals(pdfViewerRef, eventBusRef, document) {
|
|
20
|
+
const [portalTargets, setPortalTargets] = useState([]);
|
|
21
|
+
useEffect(function () {
|
|
22
|
+
const eventBus = eventBusRef.current;
|
|
23
|
+
const pdfViewer = pdfViewerRef.current;
|
|
24
|
+
if (eventBus == null || pdfViewer == null) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const handlePageRendered = evt => {
|
|
28
|
+
const pageIndex = evt.pageNumber - 1;
|
|
29
|
+
const pageView = pdfViewer.getPageView(pageIndex);
|
|
30
|
+
if (pageView?.div == null || pageView?.viewport == null) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const viewport = pageView.viewport;
|
|
34
|
+
setPortalTargets(prev => {
|
|
35
|
+
// Replace existing entry for this page or add new one
|
|
36
|
+
const filtered = prev.filter(t => t.pageNumber !== evt.pageNumber);
|
|
37
|
+
return [...filtered, {
|
|
38
|
+
pageNumber: evt.pageNumber,
|
|
39
|
+
container: pageView.div,
|
|
40
|
+
pageHeight: viewport.viewBox[3],
|
|
41
|
+
// viewBox is [xMin, yMin, width, height] and we need the original height before scaling
|
|
42
|
+
scale: viewport.scale
|
|
43
|
+
}].sort((a, b) => a.pageNumber - b.pageNumber);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
eventBus.on(PAGE_RENDERED_EVENT, handlePageRendered);
|
|
47
|
+
return () => {
|
|
48
|
+
eventBus.off(PAGE_RENDERED_EVENT, handlePageRendered);
|
|
49
|
+
setPortalTargets([]);
|
|
50
|
+
};
|
|
51
|
+
}, [eventBusRef, pdfViewerRef, document]);
|
|
52
|
+
return portalTargets;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=usePdfAnnotationPortals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePdfAnnotationPortals.js","names":["useEffect","useState","PAGE_RENDERED_EVENT","usePdfAnnotationPortals","pdfViewerRef","eventBusRef","document","portalTargets","setPortalTargets","eventBus","current","pdfViewer","handlePageRendered","evt","pageIndex","pageNumber","pageView","getPageView","div","viewport","prev","filtered","filter","t","container","pageHeight","viewBox","scale","sort","a","b","on","off"],"sources":["usePdfAnnotationPortals.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport type { EventBus, PDFViewer } from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport type { RefObject } from \"react\";\nimport { useEffect, useState } from \"react\";\nimport { PAGE_RENDERED_EVENT } from \"../constants.js\";\n\nexport interface AnnotationPortalTarget {\n pageNumber: number;\n container: HTMLDivElement;\n pageHeight: number;\n scale: number;\n}\n\nexport function usePdfAnnotationPortals(\n pdfViewerRef: RefObject<PDFViewer | null>,\n eventBusRef: RefObject<EventBus | null>,\n document: PDFDocumentProxy | undefined,\n): AnnotationPortalTarget[] {\n const [portalTargets, setPortalTargets] = useState<AnnotationPortalTarget[]>(\n [],\n );\n\n useEffect(function subscribePageRendered() {\n const eventBus = eventBusRef.current;\n const pdfViewer = pdfViewerRef.current;\n if (eventBus == null || pdfViewer == null) {\n return;\n }\n\n const handlePageRendered = (evt: { pageNumber: number }) => {\n const pageIndex = evt.pageNumber - 1;\n const pageView = pdfViewer.getPageView(pageIndex);\n if (pageView?.div == null || pageView?.viewport == null) {\n return;\n }\n\n const viewport = pageView.viewport;\n\n setPortalTargets((prev) => {\n // Replace existing entry for this page or add new one\n const filtered = prev.filter((t) => t.pageNumber !== evt.pageNumber);\n return [...filtered, {\n pageNumber: evt.pageNumber,\n container: pageView.div as HTMLDivElement,\n pageHeight: viewport.viewBox[3], // viewBox is [xMin, yMin, width, height] and we need the original height before scaling\n scale: viewport.scale,\n }].sort((a, b) => a.pageNumber - b.pageNumber);\n });\n };\n\n eventBus.on(PAGE_RENDERED_EVENT, handlePageRendered);\n\n return () => {\n eventBus.off(PAGE_RENDERED_EVENT, handlePageRendered);\n setPortalTargets([]);\n };\n }, [eventBusRef, pdfViewerRef, document]);\n\n return portalTargets;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,mBAAmB,QAAQ,iBAAiB;AASrD,OAAO,SAASC,uBAAuBA,CACrCC,YAAyC,EACzCC,WAAuC,EACvCC,QAAsC,EACZ;EAC1B,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGP,QAAQ,CAChD,EACF,CAAC;EAEDD,SAAS,CAAC,YAAiC;IACzC,MAAMS,QAAQ,GAAGJ,WAAW,CAACK,OAAO;IACpC,MAAMC,SAAS,GAAGP,YAAY,CAACM,OAAO;IACtC,IAAID,QAAQ,IAAI,IAAI,IAAIE,SAAS,IAAI,IAAI,EAAE;MACzC;IACF;IAEA,MAAMC,kBAAkB,GAAIC,GAA2B,IAAK;MAC1D,MAAMC,SAAS,GAAGD,GAAG,CAACE,UAAU,GAAG,CAAC;MACpC,MAAMC,QAAQ,GAAGL,SAAS,CAACM,WAAW,CAACH,SAAS,CAAC;MACjD,IAAIE,QAAQ,EAAEE,GAAG,IAAI,IAAI,IAAIF,QAAQ,EAAEG,QAAQ,IAAI,IAAI,EAAE;QACvD;MACF;MAEA,MAAMA,QAAQ,GAAGH,QAAQ,CAACG,QAAQ;MAElCX,gBAAgB,CAAEY,IAAI,IAAK;QACzB;QACA,MAAMC,QAAQ,GAAGD,IAAI,CAACE,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACR,UAAU,KAAKF,GAAG,CAACE,UAAU,CAAC;QACpE,OAAO,CAAC,GAAGM,QAAQ,EAAE;UACnBN,UAAU,EAAEF,GAAG,CAACE,UAAU;UAC1BS,SAAS,EAAER,QAAQ,CAACE,GAAqB;UACzCO,UAAU,EAAEN,QAAQ,CAACO,OAAO,CAAC,CAAC,CAAC;UAAE;UACjCC,KAAK,EAAER,QAAQ,CAACQ;QAClB,CAAC,CAAC,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACd,UAAU,GAAGe,CAAC,CAACf,UAAU,CAAC;MAChD,CAAC,CAAC;IACJ,CAAC;IAEDN,QAAQ,CAACsB,EAAE,CAAC7B,mBAAmB,EAAEU,kBAAkB,CAAC;IAEpD,OAAO,MAAM;MACXH,QAAQ,CAACuB,GAAG,CAAC9B,mBAAmB,EAAEU,kBAAkB,CAAC;MACrDJ,gBAAgB,CAAC,EAAE,CAAC;IACtB,CAAC;EACH,CAAC,EAAE,CAACH,WAAW,EAAED,YAAY,EAAEE,QAAQ,CAAC,CAAC;EAEzC,OAAOC,aAAa;AACtB","ignoreList":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 { getDocument, GlobalWorkerOptions } from "pdfjs-dist";
|
|
18
|
+
// @ts-expect-error -- Vite ?url import resolves to a string path at build time
|
|
19
|
+
import pdfWorkerUrl from "pdfjs-dist/build/pdf.worker.min.mjs?url";
|
|
20
|
+
import { useEffect, useState } from "react";
|
|
21
|
+
const pdfWorker = {
|
|
22
|
+
workerInitialized: false,
|
|
23
|
+
ensureWorker() {
|
|
24
|
+
GlobalWorkerOptions.workerSrc = pdfWorkerUrl;
|
|
25
|
+
this.workerInitialized = true;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export function usePdfDocument(src) {
|
|
29
|
+
const [document, setDocument] = useState(undefined);
|
|
30
|
+
const [numPages, setNumPages] = useState(0);
|
|
31
|
+
const [loading, setLoading] = useState(true);
|
|
32
|
+
const [error, setError] = useState(undefined);
|
|
33
|
+
useEffect(function () {
|
|
34
|
+
pdfWorker.ensureWorker();
|
|
35
|
+
setLoading(true);
|
|
36
|
+
setError(undefined);
|
|
37
|
+
const loadingTask = getDocument(typeof src === "string" ? {
|
|
38
|
+
url: src
|
|
39
|
+
} : {
|
|
40
|
+
data: src
|
|
41
|
+
});
|
|
42
|
+
let cancelled = false;
|
|
43
|
+
loadingTask.promise.then(pdf => {
|
|
44
|
+
if (!cancelled) {
|
|
45
|
+
setDocument(pdf);
|
|
46
|
+
setNumPages(pdf.numPages);
|
|
47
|
+
setLoading(false);
|
|
48
|
+
}
|
|
49
|
+
}, err => {
|
|
50
|
+
if (!cancelled) {
|
|
51
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
52
|
+
setLoading(false);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return () => {
|
|
56
|
+
cancelled = true;
|
|
57
|
+
void loadingTask.destroy();
|
|
58
|
+
};
|
|
59
|
+
}, [src]);
|
|
60
|
+
return {
|
|
61
|
+
document,
|
|
62
|
+
numPages,
|
|
63
|
+
loading,
|
|
64
|
+
error
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=usePdfDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePdfDocument.js","names":["getDocument","GlobalWorkerOptions","pdfWorkerUrl","useEffect","useState","pdfWorker","workerInitialized","ensureWorker","workerSrc","usePdfDocument","src","document","setDocument","undefined","numPages","setNumPages","loading","setLoading","error","setError","loadingTask","url","data","cancelled","promise","then","pdf","err","Error","String","destroy"],"sources":["usePdfDocument.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport { getDocument, GlobalWorkerOptions } from \"pdfjs-dist\";\n// @ts-expect-error -- Vite ?url import resolves to a string path at build time\nimport pdfWorkerUrl from \"pdfjs-dist/build/pdf.worker.min.mjs?url\";\nimport { useEffect, useState } from \"react\";\n\nconst pdfWorker = {\n workerInitialized: false,\n ensureWorker() {\n GlobalWorkerOptions.workerSrc = pdfWorkerUrl as string;\n this.workerInitialized = true;\n },\n};\n\ninterface UsePdfDocumentResult {\n document: PDFDocumentProxy | undefined;\n numPages: number;\n loading: boolean;\n error: Error | undefined;\n}\n\nexport function usePdfDocument(\n src: string | ArrayBuffer,\n): UsePdfDocumentResult {\n const [document, setDocument] = useState<PDFDocumentProxy | undefined>(\n undefined,\n );\n const [numPages, setNumPages] = useState(0);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n useEffect(function loadPdfDocument() {\n pdfWorker.ensureWorker();\n setLoading(true);\n setError(undefined);\n\n const loadingTask = getDocument(\n typeof src === \"string\" ? { url: src } : { data: src },\n );\n\n let cancelled = false;\n\n loadingTask.promise.then(\n (pdf) => {\n if (!cancelled) {\n setDocument(pdf);\n setNumPages(pdf.numPages);\n setLoading(false);\n }\n },\n (err: unknown) => {\n if (!cancelled) {\n setError(\n err instanceof Error ? err : new Error(String(err)),\n );\n setLoading(false);\n }\n },\n );\n\n return () => {\n cancelled = true;\n void loadingTask.destroy();\n };\n }, [src]);\n\n return { document, numPages, loading, error };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,WAAW,EAAEC,mBAAmB,QAAQ,YAAY;AAC7D;AACA,OAAOC,YAAY,MAAM,yCAAyC;AAClE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,MAAMC,SAAS,GAAG;EAChBC,iBAAiB,EAAE,KAAK;EACxBC,YAAYA,CAAA,EAAG;IACbN,mBAAmB,CAACO,SAAS,GAAGN,YAAsB;IACtD,IAAI,CAACI,iBAAiB,GAAG,IAAI;EAC/B;AACF,CAAC;AASD,OAAO,SAASG,cAAcA,CAC5BC,GAAyB,EACH;EACtB,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGR,QAAQ,CACtCS,SACF,CAAC;EACD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGX,QAAQ,CAAC,CAAC,CAAC;EAC3C,MAAM,CAACY,OAAO,EAAEC,UAAU,CAAC,GAAGb,QAAQ,CAAC,IAAI,CAAC;EAC5C,MAAM,CAACc,KAAK,EAAEC,QAAQ,CAAC,GAAGf,QAAQ,CAAoBS,SAAS,CAAC;EAEhEV,SAAS,CAAC,YAA2B;IACnCE,SAAS,CAACE,YAAY,CAAC,CAAC;IACxBU,UAAU,CAAC,IAAI,CAAC;IAChBE,QAAQ,CAACN,SAAS,CAAC;IAEnB,MAAMO,WAAW,GAAGpB,WAAW,CAC7B,OAAOU,GAAG,KAAK,QAAQ,GAAG;MAAEW,GAAG,EAAEX;IAAI,CAAC,GAAG;MAAEY,IAAI,EAAEZ;IAAI,CACvD,CAAC;IAED,IAAIa,SAAS,GAAG,KAAK;IAErBH,WAAW,CAACI,OAAO,CAACC,IAAI,CACrBC,GAAG,IAAK;MACP,IAAI,CAACH,SAAS,EAAE;QACdX,WAAW,CAACc,GAAG,CAAC;QAChBX,WAAW,CAACW,GAAG,CAACZ,QAAQ,CAAC;QACzBG,UAAU,CAAC,KAAK,CAAC;MACnB;IACF,CAAC,EACAU,GAAY,IAAK;MAChB,IAAI,CAACJ,SAAS,EAAE;QACdJ,QAAQ,CACNQ,GAAG,YAAYC,KAAK,GAAGD,GAAG,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,GAAG,CAAC,CACpD,CAAC;QACDV,UAAU,CAAC,KAAK,CAAC;MACnB;IACF,CACF,CAAC;IAED,OAAO,MAAM;MACXM,SAAS,GAAG,IAAI;MAChB,KAAKH,WAAW,CAACU,OAAO,CAAC,CAAC;IAC5B,CAAC;EACH,CAAC,EAAE,CAACpB,GAAG,CAAC,CAAC;EAET,OAAO;IAAEC,QAAQ;IAAEG,QAAQ;IAAEE,OAAO;IAAEE;EAAM,CAAC;AAC/C","ignoreList":[]}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { EventBus, PDFFindController, PDFLinkService, PDFViewer } from "pdfjs-dist/web/pdf_viewer.mjs";
|
|
18
|
+
import { useEffect, useRef } from "react";
|
|
19
|
+
export function usePdfViewer(containerRef, viewerRef, document, initialScale) {
|
|
20
|
+
const pdfViewerRef = useRef(null);
|
|
21
|
+
const eventBusRef = useRef(null);
|
|
22
|
+
const findControllerRef = useRef(null);
|
|
23
|
+
useEffect(function () {
|
|
24
|
+
const container = containerRef.current;
|
|
25
|
+
const viewer = viewerRef.current;
|
|
26
|
+
if (container == null || viewer == null || document == null) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const eventBus = new EventBus();
|
|
30
|
+
const linkService = new PDFLinkService({
|
|
31
|
+
eventBus
|
|
32
|
+
});
|
|
33
|
+
const findController = new PDFFindController({
|
|
34
|
+
linkService,
|
|
35
|
+
eventBus,
|
|
36
|
+
updateMatchesCountOnProgress: true
|
|
37
|
+
});
|
|
38
|
+
const pdfViewer = new PDFViewer({
|
|
39
|
+
container,
|
|
40
|
+
viewer,
|
|
41
|
+
eventBus,
|
|
42
|
+
linkService,
|
|
43
|
+
findController,
|
|
44
|
+
removePageBorders: true
|
|
45
|
+
});
|
|
46
|
+
linkService.setViewer(pdfViewer);
|
|
47
|
+
linkService.setDocument(document);
|
|
48
|
+
findController.setDocument(document);
|
|
49
|
+
pdfViewer.setDocument(document);
|
|
50
|
+
if (initialScale != null) {
|
|
51
|
+
pdfViewer.currentScale = initialScale;
|
|
52
|
+
}
|
|
53
|
+
eventBusRef.current = eventBus;
|
|
54
|
+
findControllerRef.current = findController;
|
|
55
|
+
pdfViewerRef.current = pdfViewer;
|
|
56
|
+
return () => {
|
|
57
|
+
pdfViewerRef.current = null;
|
|
58
|
+
eventBusRef.current = null;
|
|
59
|
+
findControllerRef.current = null;
|
|
60
|
+
pdfViewer.cleanup();
|
|
61
|
+
};
|
|
62
|
+
}, [containerRef, viewerRef, document]);
|
|
63
|
+
return {
|
|
64
|
+
pdfViewerRef,
|
|
65
|
+
eventBusRef,
|
|
66
|
+
findControllerRef
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=usePdfViewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePdfViewer.js","names":["EventBus","PDFFindController","PDFLinkService","PDFViewer","useEffect","useRef","usePdfViewer","containerRef","viewerRef","document","initialScale","pdfViewerRef","eventBusRef","findControllerRef","container","current","viewer","eventBus","linkService","findController","updateMatchesCountOnProgress","pdfViewer","removePageBorders","setViewer","setDocument","currentScale","cleanup"],"sources":["usePdfViewer.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport {\n EventBus,\n PDFFindController,\n PDFLinkService,\n PDFViewer,\n} from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport type { RefObject } from \"react\";\nimport { useEffect, useRef } from \"react\";\n\nexport interface UsePdfViewerResult {\n pdfViewerRef: RefObject<PDFViewer | null>;\n eventBusRef: RefObject<EventBus | null>;\n findControllerRef: RefObject<PDFFindController | null>;\n}\n\nexport function usePdfViewer(\n containerRef: RefObject<HTMLDivElement | null>,\n viewerRef: RefObject<HTMLDivElement | null>,\n document: PDFDocumentProxy | undefined,\n initialScale?: number,\n): UsePdfViewerResult {\n const pdfViewerRef = useRef<PDFViewer | null>(null);\n const eventBusRef = useRef<EventBus | null>(null);\n const findControllerRef = useRef<PDFFindController | null>(null);\n\n useEffect(function initializePdfViewer() {\n const container = containerRef.current;\n const viewer = viewerRef.current;\n if (container == null || viewer == null || document == null) {\n return;\n }\n\n const eventBus = new EventBus();\n const linkService = new PDFLinkService({ eventBus });\n const findController = new PDFFindController({\n linkService,\n eventBus,\n updateMatchesCountOnProgress: true,\n });\n\n const pdfViewer = new PDFViewer({\n container,\n viewer,\n eventBus,\n linkService,\n findController,\n removePageBorders: true,\n });\n\n linkService.setViewer(pdfViewer);\n linkService.setDocument(document);\n findController.setDocument(document);\n pdfViewer.setDocument(document);\n\n if (initialScale != null) {\n pdfViewer.currentScale = initialScale;\n }\n\n eventBusRef.current = eventBus;\n findControllerRef.current = findController;\n pdfViewerRef.current = pdfViewer;\n\n return () => {\n pdfViewerRef.current = null;\n eventBusRef.current = null;\n findControllerRef.current = null;\n pdfViewer.cleanup();\n };\n }, [containerRef, viewerRef, document]);\n\n return { pdfViewerRef, eventBusRef, findControllerRef };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,QAAQ,EACRC,iBAAiB,EACjBC,cAAc,EACdC,SAAS,QACJ,+BAA+B;AAEtC,SAASC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAQzC,OAAO,SAASC,YAAYA,CAC1BC,YAA8C,EAC9CC,SAA2C,EAC3CC,QAAsC,EACtCC,YAAqB,EACD;EACpB,MAAMC,YAAY,GAAGN,MAAM,CAAmB,IAAI,CAAC;EACnD,MAAMO,WAAW,GAAGP,MAAM,CAAkB,IAAI,CAAC;EACjD,MAAMQ,iBAAiB,GAAGR,MAAM,CAA2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