@osdk/react-components 0.2.0-beta.24 → 0.2.0-beta.26

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 (175) hide show
  1. package/AGENTS.md +4 -0
  2. package/CHANGELOG.md +38 -0
  3. package/build/browser/action-form/ActionForm.js +15 -11
  4. package/build/browser/action-form/ActionForm.js.map +1 -1
  5. package/build/browser/action-form/FormFieldApi.js.map +1 -1
  6. package/build/browser/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
  7. package/build/browser/action-form/fields/BaseInput.module.css.js +6 -0
  8. package/build/browser/action-form/fields/CustomField.js +30 -0
  9. package/build/browser/action-form/fields/CustomField.js.map +1 -0
  10. package/build/browser/action-form/fields/FormFieldRenderer.js +26 -16
  11. package/build/browser/action-form/fields/FormFieldRenderer.js.map +1 -1
  12. package/build/browser/action-form/fields/RadioButtonsField.js +57 -0
  13. package/build/browser/action-form/fields/RadioButtonsField.js.map +1 -0
  14. package/build/browser/action-form/fields/RadioButtonsField.module.css +83 -0
  15. package/build/browser/action-form/fields/RadioButtonsField.module.css.js +10 -0
  16. package/build/browser/action-form/fields/TextAreaField.js +50 -0
  17. package/build/browser/action-form/fields/TextAreaField.js.map +1 -0
  18. package/build/browser/action-form/fields/TextInputField.js +3 -3
  19. package/build/browser/action-form/fields/TextInputField.js.map +1 -1
  20. package/build/browser/action-form/utils/getDefaultFieldDefinitions.js +97 -10
  21. package/build/browser/action-form/utils/getDefaultFieldDefinitions.js.map +1 -1
  22. package/build/browser/base-components/dialog/Dialog.js +4 -2
  23. package/build/browser/base-components/dialog/Dialog.js.map +1 -1
  24. package/build/browser/object-table/ObjectTableApi.js.map +1 -1
  25. package/build/browser/object-table/hooks/useFunctionColumnsData.js +57 -192
  26. package/build/browser/object-table/hooks/useFunctionColumnsData.js.map +1 -1
  27. package/build/browser/pdf-viewer/PdfViewer.js +49 -8
  28. package/build/browser/pdf-viewer/PdfViewer.js.map +1 -1
  29. package/build/browser/pdf-viewer/PdfViewerContext.js +108 -0
  30. package/build/browser/pdf-viewer/PdfViewerContext.js.map +1 -0
  31. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
  32. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
  33. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
  34. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css.js +1 -0
  35. package/build/browser/pdf-viewer/components/PdfViewerContent.js +15 -3
  36. package/build/browser/pdf-viewer/components/PdfViewerContent.js.map +1 -1
  37. package/build/browser/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
  38. package/build/browser/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
  39. package/build/browser/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
  40. package/build/browser/pdf-viewer/components/PdfViewerToolbar.js +29 -2
  41. package/build/browser/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
  42. package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
  43. package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css.js +1 -0
  44. package/build/browser/pdf-viewer/constants.js +2 -1
  45. package/build/browser/pdf-viewer/constants.js.map +1 -1
  46. package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
  47. package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
  48. package/build/browser/pdf-viewer/hooks/usePdfFormFields.js +341 -0
  49. package/build/browser/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
  50. package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js +227 -0
  51. package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
  52. package/build/browser/pdf-viewer/hooks/usePdfViewer.js +16 -10
  53. package/build/browser/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
  54. package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js +3 -3
  55. package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
  56. package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js +3 -3
  57. package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -1
  58. package/build/browser/pdf-viewer/hooks/usePdfViewerState.js +3 -3
  59. package/build/browser/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
  60. package/build/browser/pdf-viewer/types.js.map +1 -1
  61. package/build/browser/public/experimental.js +5 -0
  62. package/build/browser/public/experimental.js.map +1 -1
  63. package/build/browser/styles.css +144 -35
  64. package/build/cjs/{chunk-GT6IV6LV.cjs → chunk-MRRRZN44.cjs} +6 -4
  65. package/build/cjs/chunk-MRRRZN44.cjs.map +1 -0
  66. package/build/cjs/public/experimental.cjs +1981 -1314
  67. package/build/cjs/public/experimental.cjs.map +1 -1
  68. package/build/cjs/public/experimental.css +82 -5
  69. package/build/cjs/public/experimental.css.map +1 -1
  70. package/build/cjs/public/experimental.d.cts +267 -26
  71. package/build/cjs/public/primitives.cjs +5 -5
  72. package/build/cjs/public/primitives.d.cts +3 -2
  73. package/build/esm/action-form/ActionForm.js +15 -11
  74. package/build/esm/action-form/ActionForm.js.map +1 -1
  75. package/build/esm/action-form/FormFieldApi.js.map +1 -1
  76. package/build/esm/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
  77. package/build/esm/action-form/fields/CustomField.js +30 -0
  78. package/build/esm/action-form/fields/CustomField.js.map +1 -0
  79. package/build/esm/action-form/fields/FormFieldRenderer.js +26 -16
  80. package/build/esm/action-form/fields/FormFieldRenderer.js.map +1 -1
  81. package/build/esm/action-form/fields/RadioButtonsField.js +57 -0
  82. package/build/esm/action-form/fields/RadioButtonsField.js.map +1 -0
  83. package/build/esm/action-form/fields/RadioButtonsField.module.css +83 -0
  84. package/build/esm/action-form/fields/TextAreaField.js +50 -0
  85. package/build/esm/action-form/fields/TextAreaField.js.map +1 -0
  86. package/build/esm/action-form/fields/TextInputField.js +3 -3
  87. package/build/esm/action-form/fields/TextInputField.js.map +1 -1
  88. package/build/esm/action-form/utils/getDefaultFieldDefinitions.js +97 -10
  89. package/build/esm/action-form/utils/getDefaultFieldDefinitions.js.map +1 -1
  90. package/build/esm/base-components/dialog/Dialog.js +4 -2
  91. package/build/esm/base-components/dialog/Dialog.js.map +1 -1
  92. package/build/esm/object-table/ObjectTableApi.js.map +1 -1
  93. package/build/esm/object-table/hooks/useFunctionColumnsData.js +57 -192
  94. package/build/esm/object-table/hooks/useFunctionColumnsData.js.map +1 -1
  95. package/build/esm/pdf-viewer/PdfViewer.js +49 -8
  96. package/build/esm/pdf-viewer/PdfViewer.js.map +1 -1
  97. package/build/esm/pdf-viewer/PdfViewerContext.js +108 -0
  98. package/build/esm/pdf-viewer/PdfViewerContext.js.map +1 -0
  99. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
  100. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
  101. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
  102. package/build/esm/pdf-viewer/components/PdfViewerContent.js +15 -3
  103. package/build/esm/pdf-viewer/components/PdfViewerContent.js.map +1 -1
  104. package/build/esm/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
  105. package/build/esm/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
  106. package/build/esm/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
  107. package/build/esm/pdf-viewer/components/PdfViewerToolbar.js +29 -2
  108. package/build/esm/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
  109. package/build/esm/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
  110. package/build/esm/pdf-viewer/constants.js +2 -1
  111. package/build/esm/pdf-viewer/constants.js.map +1 -1
  112. package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
  113. package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
  114. package/build/esm/pdf-viewer/hooks/usePdfFormFields.js +341 -0
  115. package/build/esm/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
  116. package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js +227 -0
  117. package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
  118. package/build/esm/pdf-viewer/hooks/usePdfViewer.js +16 -10
  119. package/build/esm/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
  120. package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js +3 -3
  121. package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
  122. package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js +3 -3
  123. package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -1
  124. package/build/esm/pdf-viewer/hooks/usePdfViewerState.js +3 -3
  125. package/build/esm/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
  126. package/build/esm/pdf-viewer/types.js.map +1 -1
  127. package/build/esm/public/experimental.js +5 -0
  128. package/build/esm/public/experimental.js.map +1 -1
  129. package/build/types/action-form/FormFieldApi.d.ts +11 -5
  130. package/build/types/action-form/FormFieldApi.d.ts.map +1 -1
  131. package/build/types/action-form/fields/CustomField.d.ts +9 -0
  132. package/build/types/action-form/fields/CustomField.d.ts.map +1 -0
  133. package/build/types/action-form/fields/FormFieldRenderer.d.ts.map +1 -1
  134. package/build/types/action-form/fields/RadioButtonsField.d.ts +3 -0
  135. package/build/types/action-form/fields/RadioButtonsField.d.ts.map +1 -0
  136. package/build/types/action-form/fields/TextAreaField.d.ts +3 -0
  137. package/build/types/action-form/fields/TextAreaField.d.ts.map +1 -0
  138. package/build/types/action-form/utils/getDefaultFieldDefinitions.d.ts +7 -4
  139. package/build/types/action-form/utils/getDefaultFieldDefinitions.d.ts.map +1 -1
  140. package/build/types/base-components/dialog/Dialog.d.ts +3 -2
  141. package/build/types/base-components/dialog/Dialog.d.ts.map +1 -1
  142. package/build/types/object-table/ObjectTableApi.d.ts +4 -3
  143. package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
  144. package/build/types/object-table/hooks/useFunctionColumnsData.d.ts.map +1 -1
  145. package/build/types/pdf-viewer/PdfViewer.d.ts +2 -2
  146. package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -1
  147. package/build/types/pdf-viewer/PdfViewerContext.d.ts +64 -0
  148. package/build/types/pdf-viewer/PdfViewerContext.d.ts.map +1 -0
  149. package/build/types/pdf-viewer/components/PdfViewerAnnotationLayer.d.ts.map +1 -1
  150. package/build/types/pdf-viewer/components/PdfViewerContent.d.ts +8 -4
  151. package/build/types/pdf-viewer/components/PdfViewerContent.d.ts.map +1 -1
  152. package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts +6 -1
  153. package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts.map +1 -1
  154. package/build/types/pdf-viewer/constants.d.ts +1 -1
  155. package/build/types/pdf-viewer/constants.d.ts.map +1 -1
  156. package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts +5 -0
  157. package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts.map +1 -0
  158. package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts +24 -0
  159. package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts.map +1 -0
  160. package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts +36 -0
  161. package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts.map +1 -0
  162. package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts.map +1 -1
  163. package/build/types/pdf-viewer/types.d.ts +137 -13
  164. package/build/types/pdf-viewer/types.d.ts.map +1 -1
  165. package/build/types/public/experimental.d.ts +6 -1
  166. package/build/types/public/experimental.d.ts.map +1 -1
  167. package/package.json +6 -6
  168. package/build/browser/action-form/fields/TextInputField.module.css.js +0 -6
  169. package/build/browser/action-form/utils/getDefaultFieldComponent.js +0 -56
  170. package/build/browser/action-form/utils/getDefaultFieldComponent.js.map +0 -1
  171. package/build/cjs/chunk-GT6IV6LV.cjs.map +0 -1
  172. package/build/esm/action-form/utils/getDefaultFieldComponent.js +0 -56
  173. package/build/esm/action-form/utils/getDefaultFieldComponent.js.map +0 -1
  174. package/build/types/action-form/utils/getDefaultFieldComponent.d.ts +0 -6
  175. package/build/types/action-form/utils/getDefaultFieldComponent.d.ts.map +0 -1
@@ -0,0 +1,108 @@
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 React, { createContext, useContext, useMemo } from "react";
18
+ import { EMPTY_ANNOTATION_ARRAY } from "./constants.js";
19
+ import { usePdfAnnotationsByPage } from "./hooks/usePdfAnnotationsByPage.js";
20
+ import { usePdfFormFields } from "./hooks/usePdfFormFields.js";
21
+ import { usePdfHighlightMode } from "./hooks/usePdfHighlightMode.js";
22
+ import { usePdfViewerState } from "./hooks/usePdfViewerState.js";
23
+
24
+ /** The shape of the value provided by {@link PdfViewerProvider}. */
25
+
26
+ const PdfViewerContext = /*#__PURE__*/createContext(null);
27
+ /** Provides {@link PdfViewerContextValue} to descendant components. */
28
+ export function PdfViewerProvider({
29
+ value,
30
+ children
31
+ }) {
32
+ return /*#__PURE__*/React.createElement(PdfViewerContext.Provider, {
33
+ value: value
34
+ }, children);
35
+ }
36
+
37
+ /**
38
+ * Returns the nearest {@link PdfViewerContextValue} from a {@link PdfViewerProvider}.
39
+ * Throws if called outside a provider.
40
+ */
41
+ export function usePdfViewerContext() {
42
+ const ctx = useContext(PdfViewerContext);
43
+ if (ctx == null) {
44
+ throw new Error("usePdfViewerContext must be used within a PdfViewerProvider");
45
+ }
46
+ return ctx;
47
+ }
48
+
49
+ /**
50
+ * Consumer-facing setup hook analogous to react-hook-form's `useForm()`.
51
+ * Accepts viewer options and returns a {@link PdfViewerContextValue} suitable
52
+ * for passing to {@link PdfViewerProvider}.
53
+ */
54
+ export function usePdfViewerInstance(options) {
55
+ const viewer = usePdfViewerState({
56
+ src: options.src,
57
+ initialPage: options.initialPage,
58
+ initialScale: options.initialScale,
59
+ initialSidebarOpen: options.initialSidebarOpen,
60
+ sidebarMode: options.sidebarMode,
61
+ onDownload: options.onDownload
62
+ });
63
+ const {
64
+ highlightModeActive,
65
+ toggleHighlightMode
66
+ } = usePdfHighlightMode({
67
+ pdfViewerRef: viewer.pdfViewerRef,
68
+ document: viewer.document,
69
+ enabled: options.highlightEnabled ?? false,
70
+ onTextHighlight: options.onTextHighlight,
71
+ onHighlightDelete: options.onHighlightDelete
72
+ });
73
+ const {
74
+ hasFormFields,
75
+ submitFormData
76
+ } = usePdfFormFields({
77
+ pdfViewerRef: viewer.pdfViewerRef,
78
+ eventBusRef: viewer.eventBusRef,
79
+ document: viewer.document,
80
+ formData: options.formData,
81
+ onFormSubmit: options.onFormSubmit,
82
+ onFormChange: options.onFormChange
83
+ });
84
+ const annotations = options.annotations ?? EMPTY_ANNOTATION_ARRAY;
85
+ const annotationsByPage = usePdfAnnotationsByPage(annotations);
86
+ const highlightEnabled = options.highlightEnabled ?? false;
87
+ const enableDownload = options.enableDownload ?? false;
88
+ const enableFormSave = options.onFormSubmit != null && hasFormFields;
89
+ const {
90
+ onAnnotationClick,
91
+ outlineIcons
92
+ } = options;
93
+ return useMemo(() => ({
94
+ ...viewer,
95
+ highlightEnabled,
96
+ highlightModeActive,
97
+ toggleHighlightMode,
98
+ hasFormFields,
99
+ submitFormData,
100
+ annotations,
101
+ annotationsByPage,
102
+ onAnnotationClick,
103
+ enableDownload,
104
+ enableFormSave,
105
+ outlineIcons
106
+ }), [viewer, highlightEnabled, highlightModeActive, toggleHighlightMode, hasFormFields, submitFormData, annotations, annotationsByPage, onAnnotationClick, enableDownload, enableFormSave, outlineIcons]);
107
+ }
108
+ //# sourceMappingURL=PdfViewerContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdfViewerContext.js","names":["React","createContext","useContext","useMemo","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfHighlightMode","usePdfViewerState","PdfViewerContext","PdfViewerProvider","value","children","createElement","Provider","usePdfViewerContext","ctx","Error","usePdfViewerInstance","options","viewer","src","initialPage","initialScale","initialSidebarOpen","sidebarMode","onDownload","highlightModeActive","toggleHighlightMode","pdfViewerRef","document","enabled","highlightEnabled","onTextHighlight","onHighlightDelete","hasFormFields","submitFormData","eventBusRef","formData","onFormSubmit","onFormChange","annotations","annotationsByPage","enableDownload","enableFormSave","onAnnotationClick","outlineIcons"],"sources":["PdfViewerContext.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport type {\n EventBus,\n PDFFindController,\n PDFViewer,\n} from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport React, { createContext, useContext, useMemo } from \"react\";\nimport type { RefObject } from \"react\";\nimport { EMPTY_ANNOTATION_ARRAY } from \"./constants.js\";\nimport type {\n AnnotationPortalTarget,\n} from \"./hooks/usePdfAnnotationPortals.js\";\nimport { usePdfAnnotationsByPage } from \"./hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"./hooks/usePdfFormFields.js\";\nimport { usePdfHighlightMode } from \"./hooks/usePdfHighlightMode.js\";\nimport type { UsePdfViewerSearchResult } from \"./hooks/usePdfViewerSearch.js\";\nimport { usePdfViewerState } from \"./hooks/usePdfViewerState.js\";\nimport type {\n OutlineItem,\n PdfAnnotation,\n PdfViewerInstanceOptions,\n SidebarMode,\n} from \"./types.js\";\n\n/** The shape of the value provided by {@link PdfViewerProvider}. */\nexport interface PdfViewerContextValue {\n // From UsePdfViewerStateResult (core + state)\n document: PDFDocumentProxy | undefined;\n numPages: number;\n loading: boolean;\n error: Error | undefined;\n containerRef: RefObject<HTMLDivElement>;\n viewerRef: RefObject<HTMLDivElement>;\n currentPage: number;\n scrollToPage: (page: number) => void;\n scale: number;\n setScale: (scale: number) => void;\n zoomIn: () => void;\n zoomOut: () => void;\n rotation: number;\n rotateLeft: () => void;\n rotateRight: () => void;\n sidebarOpen: boolean;\n sidebarMode: SidebarMode;\n setSidebarMode: (mode: SidebarMode) => void;\n toggleSidebar: () => void;\n search: UsePdfViewerSearchResult;\n outlineItems: OutlineItem[];\n download: (filename?: string) => void;\n portalTargets: AnnotationPortalTarget[];\n\n // From UsePdfHighlightModeResult\n highlightEnabled: boolean;\n highlightModeActive: boolean;\n toggleHighlightMode: () => void;\n\n // From UsePdfFormFieldsResult\n hasFormFields: boolean;\n submitFormData: () => void;\n\n // Annotations\n annotations: PdfAnnotation[];\n annotationsByPage: Record<number, PdfAnnotation[]>;\n onAnnotationClick: ((annotation: PdfAnnotation) => void) | undefined;\n\n // Config props passed through\n enableDownload: boolean;\n enableFormSave: boolean;\n outlineIcons: Partial<Record<number, React.ComponentType>> | undefined;\n\n // Internal refs (for advanced consumers)\n pdfViewerRef: RefObject<PDFViewer | null>;\n eventBusRef: RefObject<EventBus | null>;\n findControllerRef: RefObject<PDFFindController | null>;\n}\n\nconst PdfViewerContext = createContext<PdfViewerContextValue | null>(null);\n\nexport interface PdfViewerProviderProps {\n value: PdfViewerContextValue;\n children: React.ReactNode;\n}\n\n/** Provides {@link PdfViewerContextValue} to descendant components. */\nexport function PdfViewerProvider(\n { value, children }: PdfViewerProviderProps,\n): React.ReactElement {\n return (\n <PdfViewerContext.Provider value={value}>\n {children}\n </PdfViewerContext.Provider>\n );\n}\n\n/**\n * Returns the nearest {@link PdfViewerContextValue} from a {@link PdfViewerProvider}.\n * Throws if called outside a provider.\n */\nexport function usePdfViewerContext(): PdfViewerContextValue {\n const ctx = useContext(PdfViewerContext);\n if (ctx == null) {\n throw new Error(\n \"usePdfViewerContext must be used within a PdfViewerProvider\",\n );\n }\n return ctx;\n}\n\n/**\n * Consumer-facing setup hook analogous to react-hook-form's `useForm()`.\n * Accepts viewer options and returns a {@link PdfViewerContextValue} suitable\n * for passing to {@link PdfViewerProvider}.\n */\nexport function usePdfViewerInstance(\n options: PdfViewerInstanceOptions,\n): PdfViewerContextValue {\n const viewer = usePdfViewerState({\n src: options.src,\n initialPage: options.initialPage,\n initialScale: options.initialScale,\n initialSidebarOpen: options.initialSidebarOpen,\n sidebarMode: options.sidebarMode,\n onDownload: options.onDownload,\n });\n\n const { highlightModeActive, toggleHighlightMode } = usePdfHighlightMode({\n pdfViewerRef: viewer.pdfViewerRef,\n document: viewer.document,\n enabled: options.highlightEnabled ?? false,\n onTextHighlight: options.onTextHighlight,\n onHighlightDelete: options.onHighlightDelete,\n });\n\n const { hasFormFields, submitFormData } = usePdfFormFields({\n pdfViewerRef: viewer.pdfViewerRef,\n eventBusRef: viewer.eventBusRef,\n document: viewer.document,\n formData: options.formData,\n onFormSubmit: options.onFormSubmit,\n onFormChange: options.onFormChange,\n });\n\n const annotations = options.annotations ?? EMPTY_ANNOTATION_ARRAY;\n const annotationsByPage = usePdfAnnotationsByPage(annotations);\n\n const highlightEnabled = options.highlightEnabled ?? false;\n const enableDownload = options.enableDownload ?? false;\n const enableFormSave = options.onFormSubmit != null && hasFormFields;\n const { onAnnotationClick, outlineIcons } = options;\n\n return useMemo(\n () => ({\n ...viewer,\n highlightEnabled,\n highlightModeActive,\n toggleHighlightMode,\n hasFormFields,\n submitFormData,\n annotations,\n annotationsByPage,\n onAnnotationClick,\n enableDownload,\n enableFormSave,\n outlineIcons,\n }),\n [\n viewer,\n highlightEnabled,\n highlightModeActive,\n toggleHighlightMode,\n hasFormFields,\n submitFormData,\n annotations,\n annotationsByPage,\n onAnnotationClick,\n enableDownload,\n enableFormSave,\n outlineIcons,\n ],\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAEjE,SAASC,sBAAsB,QAAQ,gBAAgB;AAIvD,SAASC,uBAAuB,QAAQ,oCAAoC;AAC5E,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,mBAAmB,QAAQ,gCAAgC;AAEpE,SAASC,iBAAiB,QAAQ,8BAA8B;;AAQhE;;AAoDA,MAAMC,gBAAgB,gBAAGR,aAAa,CAA+B,IAAI,CAAC;AAO1E;AACA,OAAO,SAASS,iBAAiBA,CAC/B;EAAEC,KAAK;EAAEC;AAAiC,CAAC,EACvB;EACpB,oBACEZ,KAAA,CAAAa,aAAA,CAACJ,gBAAgB,CAACK,QAAQ;IAACH,KAAK,EAAEA;EAAM,GACrCC,QACwB,CAAC;AAEhC;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,mBAAmBA,CAAA,EAA0B;EAC3D,MAAMC,GAAG,GAAGd,UAAU,CAACO,gBAAgB,CAAC;EACxC,IAAIO,GAAG,IAAI,IAAI,EAAE;IACf,MAAM,IAAIC,KAAK,CACb,6DACF,CAAC;EACH;EACA,OAAOD,GAAG;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,oBAAoBA,CAClCC,OAAiC,EACV;EACvB,MAAMC,MAAM,GAAGZ,iBA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AiB;IAAEC;EAAa,CAAC,GAAG3B,OAAO;EAEnD,OAAOhB,OAAO,CACZ,OAAO;IACL,GAAGiB,MAAM;IACTY,gBAAgB;IAChBL,mBAAmB;IACnBC,mBAAmB;IACnBO,aAAa;IACbC,cAAc;IACdK,WAAW;IACXC,iBAAiB;IACjBG,iBAAiB;IACjBF,cAAc;IACdC,cAAc;IACdE;EACF,CAAC,CAAC,EACF,CACE1B,MAAM,EACNY,gBAAgB,EAChBL,mBAAmB,EACnBC,mBAAmB,EACnBO,aAAa,EACbC,cAAc,EACdK,WAAW,EACXC,iBAAiB,EACjBG,iBAAiB,EACjBF,cAAc,EACdC,cAAc,EACdE,YAAY,CAEhB,CAAC;AACH","ignoreList":[]}
@@ -17,12 +17,19 @@
17
17
  import classnames from "classnames";
18
18
  import React, { useCallback, useMemo } from "react";
19
19
  import styles from "./PdfViewerAnnotationLayer.module.css";
20
- function AnnotationItem({
21
- annotation,
22
- pageHeight,
23
- scale,
24
- onClick
25
- }) {
20
+ /** Convert a single PDF rect (bottom-left origin) to CSS positioning (top-left origin). */
21
+ function computeRectStyle(rect, pageHeight, scale, color) {
22
+ return {
23
+ left: rect.x * scale,
24
+ top: (pageHeight - rect.y - rect.height) * scale,
25
+ width: rect.width * scale,
26
+ height: rect.height * scale,
27
+ ...(color != null ? {
28
+ "--osdk-pdf-annotation-color": color
29
+ } : {})
30
+ };
31
+ }
32
+ function useAnnotationHandlers(annotation, onClick) {
26
33
  const handleClick = useCallback(() => {
27
34
  onClick?.(annotation);
28
35
  }, [onClick, annotation]);
@@ -32,18 +39,45 @@ function AnnotationItem({
32
39
  onClick?.(annotation);
33
40
  }
34
41
  }, [onClick, annotation]);
35
-
36
- // Convert PDF coordinates (bottom-left origin) to CSS (top-left origin)
37
- const style = useMemo(() => ({
38
- left: annotation.rect.x * scale,
39
- top: (pageHeight - annotation.rect.y - annotation.rect.height) * scale,
40
- width: annotation.rect.width * scale,
41
- height: annotation.rect.height * scale,
42
- ...(annotation.color != null ? {
43
- "--osdk-pdf-annotation-color": annotation.color
44
- } : {})
45
- }), [annotation, pageHeight, scale]);
42
+ return {
43
+ handleClick,
44
+ handleKeyDown
45
+ };
46
+ }
47
+ function AnnotationItem({
48
+ annotation,
49
+ pageHeight,
50
+ scale,
51
+ onClick
52
+ }) {
53
+ const {
54
+ handleClick,
55
+ handleKeyDown
56
+ } = useAnnotationHandlers(annotation, onClick);
46
57
  const className = classnames(styles.annotation, styles[annotation.type]);
58
+ const multiRects = annotation.rects;
59
+ const hasMultipleRects = multiRects != null && multiRects.length > 1;
60
+ const style = useMemo(() => computeRectStyle(annotation.rect, pageHeight, scale, annotation.color), [annotation, pageHeight, scale]);
61
+
62
+ // Multi-rect: render a group wrapper with one div per rect
63
+ if (hasMultipleRects) {
64
+ return /*#__PURE__*/React.createElement("div", {
65
+ className: styles.annotationGroup,
66
+ onClick: handleClick,
67
+ onKeyDown: handleKeyDown,
68
+ role: "button",
69
+ tabIndex: 0,
70
+ title: annotation.label,
71
+ "data-annotation-id": annotation.id
72
+ }, multiRects.map((rect, i) => /*#__PURE__*/React.createElement("div", {
73
+ key: i,
74
+ className: className,
75
+ style: computeRectStyle(rect, pageHeight, scale, annotation.color)
76
+ })));
77
+ }
78
+
79
+ // Single rect: existing behavior
80
+
47
81
  return /*#__PURE__*/React.createElement("div", {
48
82
  className: className,
49
83
  style: style,
@@ -55,6 +89,33 @@ function AnnotationItem({
55
89
  "data-annotation-id": annotation.id
56
90
  });
57
91
  }
92
+ function CustomAnnotationItem({
93
+ annotation,
94
+ pageHeight,
95
+ scale,
96
+ onClick
97
+ }) {
98
+ const {
99
+ handleClick,
100
+ handleKeyDown
101
+ } = useAnnotationHandlers(annotation, onClick);
102
+ const style = useMemo(() => computeRectStyle(annotation.rect, pageHeight, scale, undefined), [annotation, pageHeight, scale]);
103
+ const renderProps = useMemo(() => ({
104
+ annotation,
105
+ scale,
106
+ pageHeight
107
+ }), [annotation, scale, pageHeight]);
108
+ return /*#__PURE__*/React.createElement("div", {
109
+ className: styles.annotation,
110
+ style: style,
111
+ onClick: handleClick,
112
+ onKeyDown: handleKeyDown,
113
+ role: "button",
114
+ tabIndex: 0,
115
+ title: annotation.label,
116
+ "data-annotation-id": annotation.id
117
+ }, annotation.render(renderProps));
118
+ }
58
119
  export function PdfViewerAnnotationLayer({
59
120
  annotations,
60
121
  pageHeight,
@@ -63,7 +124,13 @@ export function PdfViewerAnnotationLayer({
63
124
  }) {
64
125
  return /*#__PURE__*/React.createElement("div", {
65
126
  className: styles.annotationLayer
66
- }, annotations.map(annotation => /*#__PURE__*/React.createElement(AnnotationItem, {
127
+ }, annotations.map(annotation => annotation.type === "custom" ? /*#__PURE__*/React.createElement(CustomAnnotationItem, {
128
+ key: annotation.id,
129
+ annotation: annotation,
130
+ pageHeight: pageHeight,
131
+ scale: scale,
132
+ onClick: onAnnotationClick
133
+ }) : /*#__PURE__*/React.createElement(AnnotationItem, {
67
134
  key: annotation.id,
68
135
  annotation: annotation,
69
136
  pageHeight: pageHeight,
@@ -1 +1 @@
1
- {"version":3,"file":"PdfViewerAnnotationLayer.js","names":["classnames","React","useCallback","useMemo","styles","AnnotationItem","annotation","pageHeight","scale","onClick","handleClick","handleKeyDown","e","key","preventDefault","style","left","rect","x","top","y","height","width","color","className","type","createElement","onKeyDown","role","tabIndex","title","label","id","PdfViewerAnnotationLayer","annotations","onAnnotationClick","annotationLayer","map"],"sources":["PdfViewerAnnotationLayer.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport classnames from \"classnames\";\nimport React, { useCallback, useMemo } from \"react\";\nimport type { PdfAnnotation } from \"../types.js\";\nimport styles from \"./PdfViewerAnnotationLayer.module.css\";\n\nexport interface PdfViewerAnnotationLayerProps {\n annotations: PdfAnnotation[];\n pageHeight: number;\n scale: number;\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n}\n\ninterface AnnotationItemProps {\n annotation: PdfAnnotation;\n pageHeight: number;\n scale: number;\n onClick?: (annotation: PdfAnnotation) => void;\n}\n\nfunction AnnotationItem({\n annotation,\n pageHeight,\n scale,\n onClick,\n}: AnnotationItemProps): React.ReactElement {\n const handleClick = useCallback(() => {\n onClick?.(annotation);\n }, [onClick, annotation]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n onClick?.(annotation);\n }\n },\n [onClick, annotation],\n );\n\n // Convert PDF coordinates (bottom-left origin) to CSS (top-left origin)\n const style = useMemo(\n () => ({\n left: annotation.rect.x * scale,\n top: (pageHeight - annotation.rect.y - annotation.rect.height) * scale,\n width: annotation.rect.width * scale,\n height: annotation.rect.height * scale,\n ...(annotation.color != null\n ? {\n \"--osdk-pdf-annotation-color\": annotation.color,\n } as React.CSSProperties\n : {}),\n }),\n [annotation, pageHeight, scale],\n );\n\n const className = classnames(\n styles.annotation,\n styles[annotation.type],\n );\n\n return (\n <div\n className={className}\n style={style}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n />\n );\n}\n\nexport function PdfViewerAnnotationLayer({\n annotations,\n pageHeight,\n scale,\n onAnnotationClick,\n}: PdfViewerAnnotationLayerProps): React.ReactElement {\n return (\n <div className={styles.annotationLayer}>\n {annotations.map((annotation) => (\n <AnnotationItem\n key={annotation.id}\n annotation={annotation}\n pageHeight={pageHeight}\n scale={scale}\n onClick={onAnnotationClick}\n />\n ))}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;A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AAM,CAACE,UAAU,EACjBF,MAAM,CAACE,UAAU,CAACmB,IAAI,CACxB,CAAC;EAED,oBACExB,KAAA,CAAAyB,aAAA;IACEF,SAAS,EAAEA,SAAU;IACrBT,KAAK,EAAEA,KAAM;IACbN,OAAO,EAAEC,WAAY;IACrBiB,SAAS,EAAEhB,aAAc;IACzBiB,IAAI,EAAC,QAAQ;IACbC,QAAQ,EAAE,CAAE;IACZC,KAAK,EAAExB,UAAU,CAACyB,KAAM;IACxB,sBAAoBzB,UAAU,CAAC0B;EAAG,CACnC,CAAC;AAEN;AAEA,OAAO,SAASC,wBAAwBA,CAAC;EACvCC,WAAW;EACX3B,UAAU;EACVC,KAAK;EACL2B;AAC6B,CAAC,EAAsB;EACpD,oBACElC,KAAA,CAAAyB,aAAA;IAAKF,SAAS,EAAEpB,MAAM,CAACgC;EAAgB,GACpCF,WAAW,CAACG,GAAG,CAAE/B,UAAU,iBAC1BL,KAAA,CAAAyB,aAAA,CAACrB,cAAc;IACbQ,GAAG,EAAEP,UAAU,CAAC0B,EAAG;IACnB1B,UAAU,EAAEA,UAAW;IACvBC,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbC,OAAO,EAAE0B;EAAkB,CAC5B,CACF,CACE,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"PdfViewerAnnotationLayer.js","names":["classnames","React","useCallback","useMemo","styles","computeRectStyle","rect","pageHeight","scale","color","left","x","top","y","height","width","useAnnotationHandlers","annotation","onClick","handleClick","handleKeyDown","e","key","preventDefault","AnnotationItem","className","type","multiRects","rects","hasMultipleRects","length","style","createElement","annotationGroup","onKeyDown","role","tabIndex","title","label","id","map","i","CustomAnnotationItem","undefined","renderProps","render","PdfViewerAnnotationLayer","annotations","onAnnotationClick","annotationLayer"],"sources":["PdfViewerAnnotationLayer.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport classnames from \"classnames\";\nimport React, { useCallback, useMemo } from \"react\";\nimport type { PdfAnnotation, PdfCustomAnnotation, PdfRect } from \"../types.js\";\nimport styles from \"./PdfViewerAnnotationLayer.module.css\";\n\nexport interface PdfViewerAnnotationLayerProps {\n annotations: PdfAnnotation[];\n pageHeight: number;\n scale: number;\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n}\n\ninterface AnnotationItemProps {\n annotation: PdfAnnotation;\n pageHeight: number;\n scale: number;\n onClick?: (annotation: PdfAnnotation) => void;\n}\n\n/** Convert a single PDF rect (bottom-left origin) to CSS positioning (top-left origin). */\nfunction computeRectStyle(\n rect: PdfRect,\n pageHeight: number,\n scale: number,\n color: string | undefined,\n): React.CSSProperties {\n return {\n left: rect.x * scale,\n top: (pageHeight - rect.y - rect.height) * scale,\n width: rect.width * scale,\n height: rect.height * scale,\n ...(color != null\n ? { \"--osdk-pdf-annotation-color\": color } as React.CSSProperties\n : {}),\n };\n}\n\nfunction useAnnotationHandlers(\n annotation: PdfAnnotation,\n onClick?: (annotation: PdfAnnotation) => void,\n) {\n const handleClick = useCallback(() => {\n onClick?.(annotation);\n }, [onClick, annotation]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n onClick?.(annotation);\n }\n },\n [onClick, annotation],\n );\n\n return { handleClick, handleKeyDown };\n}\n\nfunction AnnotationItem({\n annotation,\n pageHeight,\n scale,\n onClick,\n}: AnnotationItemProps): React.ReactElement {\n const { handleClick, handleKeyDown } = useAnnotationHandlers(\n annotation,\n onClick,\n );\n\n const className = classnames(\n styles.annotation,\n styles[annotation.type],\n );\n\n const multiRects = annotation.rects;\n const hasMultipleRects = multiRects != null && multiRects.length > 1;\n\n const style = useMemo(\n () =>\n computeRectStyle(annotation.rect, pageHeight, scale, annotation.color),\n [annotation, pageHeight, scale],\n );\n\n // Multi-rect: render a group wrapper with one div per rect\n if (hasMultipleRects) {\n return (\n <div\n className={styles.annotationGroup}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n >\n {multiRects.map((rect, i) => (\n <div\n key={i}\n className={className}\n style={computeRectStyle(\n rect,\n pageHeight,\n scale,\n annotation.color,\n )}\n />\n ))}\n </div>\n );\n }\n\n // Single rect: existing behavior\n\n return (\n <div\n className={className}\n style={style}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n />\n );\n}\n\nfunction CustomAnnotationItem({\n annotation,\n pageHeight,\n scale,\n onClick,\n}: AnnotationItemProps & {\n annotation: PdfCustomAnnotation;\n}): React.ReactElement {\n const { handleClick, handleKeyDown } = useAnnotationHandlers(\n annotation,\n onClick,\n );\n\n const style = useMemo(\n () => computeRectStyle(annotation.rect, pageHeight, scale, undefined),\n [annotation, pageHeight, scale],\n );\n\n const renderProps = useMemo(\n () => ({ annotation, scale, pageHeight }),\n [annotation, scale, pageHeight],\n );\n\n return (\n <div\n className={styles.annotation}\n style={style}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n >\n {annotation.render(renderProps)}\n </div>\n );\n}\n\nexport function PdfViewerAnnotationLayer({\n annotations,\n pageHeight,\n scale,\n onAnnotationClick,\n}: PdfViewerAnnotationLayerProps): React.ReactElement {\n return (\n <div className={styles.annotationLayer}>\n {annotations.map((annotation) =>\n annotation.type === \"custom\"\n ? (\n <CustomAnnotationItem\n key={annotation.id}\n annotation={annotation}\n pageHeight={pageHeight}\n scale={scale}\n onClick={onAnnotationClick}\n />\n )\n : (\n <AnnotationItem\n key={annotation.id}\n annotation={annotation}\n pageHeight={pageHeight}\n scale={scale}\n onClick={onAnnotationClick}\n />\n )\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAEnD,OAAOC,MAAM,MAAM,uCAAuC;AAgB1D;AACA,SAASC,gBAAgBA,CACvBC,IAAa,EACbC,UAAkB,EAClBC,KAAa,EACbC,KAAyB,EACJ;EACrB,OAAO;IACLC,IAAI,EAAEJ,IAAI,CAACK,CAAC,GAAGH,KAAK;IACpBI,GAAG,EAAE,CAACL,UAAU,GAAGD,IAAI,CAACO,CAAC,GAAGP,IAAI,CAACQ,MAAM,IAAIN,KAAK;IAChDO,KAAK,EAAET,IAAI,CAACS,KAAK,GAAGP,KAAK;IACzBM,MAAM,EAAER,IAAI,CAACQ,MAAM,GAAGN,KAAK;IAC3B,IAAIC,KAAK,IAAI,IAAI,GACb;MAAE,6BAA6B,EAAEA;IAAM,CAAC,GACxC,CAAC,CAAC;EACR,CAAC;AACH;AAEA,SAASO,qBAAqBA,CAC5BC,UAAyB,EACzBC,OAA6C,EAC7C;EACA,MAAMC,WAAW,GAAGjB,WAAW,CAAC,MAAM;IACpCgB,OAAO,GAAGD,UAAU,CAAC;EACvB,CAAC,EAAE,CAACC,OAAO,EAAED,UAAU,CAAC,CAAC;EAEzB,MAAMG,aAAa,GAAGlB,WAAW,CAC9BmB,CAAsB,IAAK;IAC1B,IAAIA,CAAC,CAACC,GAAG,KAAK,OAAO,EAAE;MACrBD,CAAC,CAACE,cAAc,CAAC,CAAC;MAClBL,OAAO,GAAGD,UAAU,CAAC;IACvB;EACF,CAAC,EACD,CAACC,OA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EACLwC;AAC6B,CAAC,EAAsB;EACpD,oBACE/C,KAAA,CAAA+B,aAAA;IAAKP,SAAS,EAAErB,MAAM,CAAC6C;EAAgB,GACpCF,WAAW,CAACP,GAAG,CAAEvB,UAAU,IAC1BA,UAAU,CAACS,IAAI,KAAK,QAAQ,gBAExBzB,KAAA,CAAA+B,aAAA,CAACU,oBAAoB;IACnBpB,GAAG,EAAEL,UAAU,CAACsB,EAAG;IACnBtB,UAAU,EAAEA,UAAW;IACvBV,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbU,OAAO,EAAE8B;EAAkB,CAC5B,CAAC,gBAGF/C,KAAA,CAAA+B,aAAA,CAACR,cAAc;IACbF,GAAG,EAAEL,UAAU,CAACsB,EAAG;IACnBtB,UAAU,EAAEA,UAAW;IACvBV,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbU,OAAO,EAAE8B;EAAkB,CAC5B,CAEP,CACG,CAAC;AAEV","ignoreList":[]}
@@ -8,6 +8,24 @@
8
8
  z-index: 3;
9
9
  }
10
10
 
11
+ .annotationGroup {
12
+ position: absolute;
13
+ top: 0;
14
+ left: 0;
15
+ width: 100%;
16
+ height: 100%;
17
+ pointer-events: none;
18
+ }
19
+
20
+ .annotationGroup:focus-visible {
21
+ outline: var(--osdk-focus-outline);
22
+ outline-offset: var(--osdk-focus-visible-outline-offset);
23
+ }
24
+
25
+ .annotationGroup .annotation {
26
+ pointer-events: auto;
27
+ }
28
+
11
29
  .annotation {
12
30
  position: absolute;
13
31
  pointer-events: auto;
@@ -19,18 +19,22 @@ import classnames from "classnames";
19
19
  import "pdfjs-dist/web/pdf_viewer.css";
20
20
  import React, { useEffect, useRef } from "react";
21
21
  import { createPortal } from "react-dom";
22
- import { EMPTY_ANNOTATION_ARRAY, EMPTY_ANNOTATIONS } from "../constants.js";
22
+ import { EMPTY_ANNOTATION_ARRAY } from "../constants.js";
23
+ import { usePdfAnnotationsByPage } from "../hooks/usePdfAnnotationsByPage.js";
24
+ import { usePdfFormFields } from "../hooks/usePdfFormFields.js";
23
25
  import { usePdfViewerCore } from "../hooks/usePdfViewerCore.js";
24
26
  import styles from "../PdfViewer.module.css";
25
27
  import { PdfViewerAnnotationLayer } from "./PdfViewerAnnotationLayer.js";
26
28
  export function PdfViewerContent({
27
29
  src,
28
- annotations = EMPTY_ANNOTATIONS,
30
+ annotations = EMPTY_ANNOTATION_ARRAY,
29
31
  onAnnotationClick,
30
32
  initialPage = 1,
31
33
  initialScale = 1.0,
32
34
  onPageChange: onPageChangeProp,
33
35
  onScaleChange: onScaleChangeProp,
36
+ formData,
37
+ onFormChange,
34
38
  className
35
39
  }) {
36
40
  const viewer = usePdfViewerCore({
@@ -38,6 +42,14 @@ export function PdfViewerContent({
38
42
  initialPage,
39
43
  initialScale
40
44
  });
45
+ const annotationsByPage = usePdfAnnotationsByPage(annotations);
46
+ usePdfFormFields({
47
+ pdfViewerRef: viewer.pdfViewerRef,
48
+ eventBusRef: viewer.eventBusRef,
49
+ document: viewer.document,
50
+ formData,
51
+ onFormChange
52
+ });
41
53
 
42
54
  // Use refs for callbacks to avoid firing on initial mount
43
55
  const onPageChangeRef = useRef(onPageChangeProp);
@@ -97,7 +109,7 @@ export function PdfViewerContent({
97
109
  ref: viewer.viewerRef,
98
110
  className: "pdfViewer"
99
111
  }), viewer.portalTargets.map(target => {
100
- const pageAnnotations = annotations[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;
112
+ const pageAnnotations = annotationsByPage[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;
101
113
  if (pageAnnotations.length === 0) {
102
114
  return null;
103
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PdfViewerContent.js","names":["Error","ErrorIcon","Spin","classnames","React","useEffect","useRef","createPortal","EMPTY_ANNOTATION_ARRAY","EMPTY_ANNOTATIONS","usePdfViewerCore","styles","PdfViewerAnnotationLayer","PdfViewerContent","src","annotations","onAnnotationClick","initialPage","initialScale","onPageChange","onPageChangeProp","onScaleChange","onScaleChangeProp","className","viewer","onPageChangeRef","current","onScaleChangeRef","isInitialMountRef","currentPage","scale","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","document","scrollContainerWrapper","ref","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key","pageHeight","container"],"sources":["PdfViewerContent.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { useEffect, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { EMPTY_ANNOTATION_ARRAY, EMPTY_ANNOTATIONS } from \"../constants.js\";\nimport { usePdfViewerCore } from \"../hooks/usePdfViewerCore.js\";\nimport styles from \"../PdfViewer.module.css\";\nimport type { PdfAnnotation } from \"../types.js\";\nimport { PdfViewerAnnotationLayer } from \"./PdfViewerAnnotationLayer.js\";\n\nexport interface PdfViewerContentProps {\n /** PDF source — URL string or ArrayBuffer */\n src: string | ArrayBuffer;\n /** Annotations to overlay on the PDF, keyed by page number (1-indexed) */\n annotations?: Record<number, PdfAnnotation[]>;\n /** Callback fired when an annotation is clicked */\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /** Callback fired when the current page changes during scrolling */\n onPageChange?: (page: number) => void;\n /** Callback fired when the zoom scale changes */\n onScaleChange?: (scale: number) => void;\n /** Additional CSS class name for the root element */\n className?: string;\n}\n\nexport function PdfViewerContent({\n src,\n annotations = EMPTY_ANNOTATIONS,\n onAnnotationClick,\n initialPage = 1,\n initialScale = 1.0,\n onPageChange: onPageChangeProp,\n onScaleChange: onScaleChangeProp,\n className,\n}: PdfViewerContentProps): React.ReactElement {\n const viewer = usePdfViewerCore({ src, initialPage, initialScale });\n\n // Use refs for callbacks to avoid firing on initial mount\n const onPageChangeRef = useRef(onPageChangeProp);\n onPageChangeRef.current = onPageChangeProp;\n const onScaleChangeRef = useRef(onScaleChangeProp);\n onScaleChangeRef.current = onScaleChangeProp;\n const isInitialMountRef = useRef(true);\n\n useEffect(function notifyPageChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onPageChangeRef.current?.(viewer.currentPage);\n }, [viewer.currentPage]);\n\n useEffect(function notifyScaleChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onScaleChangeRef.current?.(viewer.scale);\n }, [viewer.scale]);\n\n useEffect(function clearInitialMount() {\n isInitialMountRef.current = false;\n }, []);\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (viewer.loading) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n </div>\n );\n }\n\n if (viewer.error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {viewer.error.message}\n </div>\n </div>\n );\n }\n\n if (viewer.document == null) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>No document</div>\n </div>\n );\n }\n\n return (\n <div className={rootClassName}>\n <div className={styles.scrollContainerWrapper}>\n <div ref={viewer.containerRef} className={styles.scrollContainer}>\n <div ref={viewer.viewerRef} className=\"pdfViewer\" />\n {viewer.portalTargets.map((target) => {\n const pageAnnotations = annotations[target.pageNumber]\n ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return createPortal(\n <PdfViewerAnnotationLayer\n key={target.pageNumber}\n annotations={pageAnnotations}\n pageHeight={target.pageHeight}\n scale={target.scale}\n onAnnotationClick={onAnnotationClick}\n />,\n target.container,\n );\n })}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,IAAIC,SAAS,EAAEC,IAAI,QAAQ,oBAAoB;AAC7D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,sBAAsB,EAAEC,iBAAiB,QAAQ,iBAAiB;AAC3E,SAASC,gBAAgB,QAAQ,8BAA8B;AAC/D,OAAOC,MAAM,MAAM,yBAAyB;AAE5C,SAASC,wBAAwB,QAAQ,+BAA+B;AAqBxE,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,GAAG;EACHC,WAAW,GAAGN,iBAAiB;EAC/BO,iBAAiB;EACjBC,WAAW,GAAG,CAAC;EACfC,YAAY,GAAG,GAAG;EAClBC,YAAY,EAAEC,gBAAgB;EAC9BC,aAAa,EAAEC,iBAAiB;EAChCC;AACqB,CAAC,EAAsB;EAC5C,MAAMC,MAAM,GAAGd,gBAAgB,CAAC;IAAEI,GAAG;IAAEG,WAAW;IAAEC;EAAa,CAAC,CAAC;;EAEnE;EACA,MAAMO,eAAe,GAAGnB,MAAM,CAACc,gBAAgB,CAAC;EAChDK,eAAe,CAACC,OAAO,GAAGN,gBAAgB;EAC1C,MAAMO,gBAAgB,GAAGrB,MAAM,CAACgB,iBAAiB,CAAC;EAClDK,gBAAgB,CAACD,OAAO,GAAGJ,iBAAiB;EAC5C,MAAMM,iBAAiB,GAAGtB,MAAM,CAAC,IAAI,CAA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QAAQ,IAAI,IAAI,EAAE;IAC3B,oBACErC,KAAA,CAAA8B,aAAA;MAAKX,SAAS,EAAEQ;IAAc,gBAC5B3B,KAAA,CAAA8B,aAAA;MAAKX,SAAS,EAAEZ,MAAM,CAACwB;IAAiB,GAAC,aAAgB,CACtD,CAAC;EAEV;EAEA,oBACE/B,KAAA,CAAA8B,aAAA;IAAKX,SAAS,EAAEQ;EAAc,gBAC5B3B,KAAA,CAAA8B,aAAA;IAAKX,SAAS,EAAEZ,MAAM,CAAC+B;EAAuB,gBAC5CtC,KAAA,CAAA8B,aAAA;IAAKS,GAAG,EAAEnB,MAAM,CAACoB,YAAa;IAACrB,SAAS,EAAEZ,MAAM,CAACkC;EAAgB,gBAC/DzC,KAAA,CAAA8B,aAAA;IAAKS,GAAG,EAAEnB,MAAM,CAACsB,SAAU;IAACvB,SAAS,EAAC;EAAW,CAAE,CAAC,EACnDC,MAAM,CAACuB,aAAa,CAACC,GAAG,CAAEC,MAAM,IAAK;IACpC,MAAMC,eAAe,GAAGnC,WAAW,CAACkC,MAAM,CAACE,UAAU,CAAC,IACjD3C,sBAAsB;IAC3B,IAAI0C,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBAAO7C,YAAY,cACjBH,KAAA,CAAA8B,aAAA,CAACtB,wBAAwB;MACvByC,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvBpC,WAAW,EAAEmC,eAAgB;MAC7BI,UAAU,EAAEL,MAAM,CAACK,UAAW;MAC9BxB,KAAK,EAAEmB,MAAM,CAACnB,KAAM;MACpBd,iBAAiB,EAAEA;IAAkB,CACtC,CAAC,EACFiC,MAAM,CAACM,SACT,CAAC;EACH,CAAC,CACE,CACF,CACF,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"PdfViewerContent.js","names":["Error","ErrorIcon","Spin","classnames","React","useEffect","useRef","createPortal","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfViewerCore","styles","PdfViewerAnnotationLayer","PdfViewerContent","src","annotations","onAnnotationClick","initialPage","initialScale","onPageChange","onPageChangeProp","onScaleChange","onScaleChangeProp","formData","onFormChange","className","viewer","annotationsByPage","pdfViewerRef","eventBusRef","document","onPageChangeRef","current","onScaleChangeRef","isInitialMountRef","currentPage","scale","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","scrollContainerWrapper","ref","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key","pageHeight","container"],"sources":["PdfViewerContent.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { useEffect, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { EMPTY_ANNOTATION_ARRAY } from \"../constants.js\";\nimport { usePdfAnnotationsByPage } from \"../hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"../hooks/usePdfFormFields.js\";\nimport { usePdfViewerCore } from \"../hooks/usePdfViewerCore.js\";\nimport styles from \"../PdfViewer.module.css\";\nimport type { PdfAnnotation, PdfFormFieldValue } from \"../types.js\";\nimport { PdfViewerAnnotationLayer } from \"./PdfViewerAnnotationLayer.js\";\n\nexport interface PdfViewerContentProps {\n /** PDF source — URL string or ArrayBuffer */\n src: string | ArrayBuffer;\n /** Annotations to overlay on the PDF */\n annotations?: PdfAnnotation[];\n /** Callback fired when an annotation is clicked */\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /** Callback fired when the current page changes during scrolling */\n onPageChange?: (page: number) => void;\n /** Callback fired when the zoom scale changes */\n onScaleChange?: (scale: number) => void;\n /** Initial form field values keyed by field name. Applied when the document loads. */\n formData?: Record<string, PdfFormFieldValue>;\n /** Callback fired when any form field value changes. */\n onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;\n /** Additional CSS class name for the root element */\n className?: string;\n}\n\nexport function PdfViewerContent({\n src,\n annotations = EMPTY_ANNOTATION_ARRAY,\n onAnnotationClick,\n initialPage = 1,\n initialScale = 1.0,\n onPageChange: onPageChangeProp,\n onScaleChange: onScaleChangeProp,\n formData,\n onFormChange,\n className,\n}: PdfViewerContentProps): React.ReactElement {\n const viewer = usePdfViewerCore({ src, initialPage, initialScale });\n const annotationsByPage = usePdfAnnotationsByPage(annotations);\n\n usePdfFormFields({\n pdfViewerRef: viewer.pdfViewerRef,\n eventBusRef: viewer.eventBusRef,\n document: viewer.document,\n formData,\n onFormChange,\n });\n\n // Use refs for callbacks to avoid firing on initial mount\n const onPageChangeRef = useRef(onPageChangeProp);\n onPageChangeRef.current = onPageChangeProp;\n const onScaleChangeRef = useRef(onScaleChangeProp);\n onScaleChangeRef.current = onScaleChangeProp;\n const isInitialMountRef = useRef(true);\n\n useEffect(function notifyPageChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onPageChangeRef.current?.(viewer.currentPage);\n }, [viewer.currentPage]);\n\n useEffect(function notifyScaleChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onScaleChangeRef.current?.(viewer.scale);\n }, [viewer.scale]);\n\n useEffect(function clearInitialMount() {\n isInitialMountRef.current = false;\n }, []);\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (viewer.loading) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n </div>\n );\n }\n\n if (viewer.error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {viewer.error.message}\n </div>\n </div>\n );\n }\n\n if (viewer.document == null) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>No document</div>\n </div>\n );\n }\n\n return (\n <div className={rootClassName}>\n <div className={styles.scrollContainerWrapper}>\n <div ref={viewer.containerRef} className={styles.scrollContainer}>\n <div ref={viewer.viewerRef} className=\"pdfViewer\" />\n {viewer.portalTargets.map((target) => {\n const pageAnnotations = annotationsByPage[target.pageNumber]\n ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return createPortal(\n <PdfViewerAnnotationLayer\n key={target.pageNumber}\n annotations={pageAnnotations}\n pageHeight={target.pageHeight}\n scale={target.scale}\n onAnnotationClick={onAnnotationClick}\n />,\n target.container,\n );\n })}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,IAAIC,SAAS,EAAEC,IAAI,QAAQ,oBAAoB;AAC7D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,sBAAsB,QAAQ,iBAAiB;AACxD,SAASC,uBAAuB,QAAQ,qCAAqC;AAC7E,SAASC,gBAAgB,QAAQ,8BAA8B;AAC/D,SAASC,gBAAgB,QAAQ,8BAA8B;AAC/D,OAAOC,MAAM,MAAM,yBAAyB;AAE5C,SAASC,wBAAwB,QAAQ,+BAA+B;AAyBxE,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,GAAG;EACHC,WA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KAAA,CAAAqC,aAAA;IAAKQ,GAAG,EAAEtB,MAAM,CAACyB,SAAU;IAAC1B,SAAS,EAAC;EAAW,CAAE,CAAC,EACnDC,MAAM,CAAC0B,aAAa,CAACC,GAAG,CAAEC,MAAM,IAAK;IACpC,MAAMC,eAAe,GAAG5B,iBAAiB,CAAC2B,MAAM,CAACE,UAAU,CAAC,IACvDjD,sBAAsB;IAC3B,IAAIgD,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBAAOnD,YAAY,cACjBH,KAAA,CAAAqC,aAAA,CAAC5B,wBAAwB;MACvB8C,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvBzC,WAAW,EAAEwC,eAAgB;MAC7BI,UAAU,EAAEL,MAAM,CAACK,UAAW;MAC9BvB,KAAK,EAAEkB,MAAM,CAAClB,KAAM;MACpBpB,iBAAiB,EAAEA;IAAkB,CACtC,CAAC,EACFsC,MAAM,CAACM,SACT,CAAC;EACH,CAAC,CACE,CACF,CACF,CAAC;AAEV","ignoreList":[]}
@@ -4,7 +4,7 @@
4
4
  display: flex;
5
5
  flex-direction: column;
6
6
  background-color: var(--osdk-pdf-viewer-sidebar-bg);
7
- border-right: 1px solid var(--osdk-pdf-viewer-sidebar-border);
7
+ border-right: var(--osdk-pdf-viewer-sidebar-border);
8
8
  overflow: hidden;
9
9
  }
10
10
 
@@ -4,7 +4,7 @@
4
4
  display: flex;
5
5
  flex-direction: column;
6
6
  background-color: var(--osdk-pdf-viewer-sidebar-bg);
7
- border-right: 1px solid var(--osdk-pdf-viewer-sidebar-border);
7
+ border-right: var(--osdk-pdf-viewer-sidebar-border);
8
8
  overflow: hidden;
9
9
  }
10
10
 
@@ -28,7 +28,7 @@
28
28
  align-items: center;
29
29
  gap: var(--osdk-spacing-2xs, 2px);
30
30
  padding: var(--osdk-spacing-2xs, 2px);
31
- border: 1px solid var(--osdk-surface-border-color, rgba(0, 0, 0, 0.15));
31
+ border: none;
32
32
  border-radius: var(--osdk-surface-border-radius);
33
33
  background-color: var(--osdk-surface-background-color, transparent);
34
34
  }
@@ -16,7 +16,8 @@
16
16
 
17
17
  import { Button } from "@base-ui/react/button";
18
18
  import { Input } from "@base-ui/react/input";
19
- import { ChevronLeft, ChevronRight, Download, Menu, Minus, Plus, RotatePage, Search } from "@blueprintjs/icons";
19
+ import { ChevronLeft, ChevronRight, Download, FloppyDisk, Highlight, Menu, Minus, Plus, RotatePage, Search } from "@blueprintjs/icons";
20
+ import classnames from "classnames";
20
21
  import React, { useCallback, useEffect, useState } from "react";
21
22
  import { MAX_SCALE, MIN_SCALE, SCALE_STEP } from "../constants.js";
22
23
  import styles from "./PdfViewerToolbar.module.css";
@@ -32,7 +33,12 @@ export function PdfViewerToolbar({
32
33
  onDownload,
33
34
  enableDownload,
34
35
  onRotateLeft,
35
- onRotateRight
36
+ onRotateRight,
37
+ enableHighlight,
38
+ highlightModeActive,
39
+ onHighlightToggle,
40
+ enableFormSave = false,
41
+ onFormSave
36
42
  }) {
37
43
  const [pageInputValue, setPageInputValue] = useState(String(currentPage));
38
44
 
@@ -169,6 +175,17 @@ export function PdfViewerToolbar({
169
175
  style: {
170
176
  transform: "scaleX(-1)"
171
177
  }
178
+ }))), enableHighlight && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
179
+ className: styles.separator
180
+ }), /*#__PURE__*/React.createElement(Button, {
181
+ className: classnames(styles.toolbarButton, highlightModeActive && styles.toolbarButtonActive),
182
+ onClick: onHighlightToggle,
183
+ "aria-label": highlightModeActive ? "Disable highlight mode" : "Enable highlight mode",
184
+ title: highlightModeActive ? "Disable highlight mode" : "Enable highlight mode",
185
+ "aria-pressed": highlightModeActive,
186
+ type: "button"
187
+ }, /*#__PURE__*/React.createElement(Highlight, {
188
+ size: 16
172
189
  }))), /*#__PURE__*/React.createElement("div", {
173
190
  className: styles.separator
174
191
  }), /*#__PURE__*/React.createElement(Button, {
@@ -189,6 +206,16 @@ export function PdfViewerToolbar({
189
206
  type: "button"
190
207
  }, /*#__PURE__*/React.createElement(Download, {
191
208
  size: 16
209
+ }))), enableFormSave && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
210
+ className: styles.separator
211
+ }), /*#__PURE__*/React.createElement(Button, {
212
+ className: styles.toolbarButton,
213
+ onClick: onFormSave,
214
+ "aria-label": "Save form",
215
+ title: "Save form",
216
+ type: "button"
217
+ }, /*#__PURE__*/React.createElement(FloppyDisk, {
218
+ size: 16
192
219
  }))));
193
220
  }
194
221
  //# sourceMappingURL=PdfViewerToolbar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PdfViewerToolbar.js","names":["Button","Input","ChevronLeft","ChevronRight","Download","Menu","Minus","Plus","RotatePage","Search","React","useCallback","useEffect","useState","MAX_SCALE","MIN_SCALE","SCALE_STEP","styles","PdfViewerToolbar","currentPage","numPages","scale","sidebarOpen","onPageChange","onScaleChange","onSearchOpen","onSidebarToggle","onDownload","enableDownload","onRotateLeft","onRotateRight","pageInputValue","setPageInputValue","String","handlePrevPage","newPage","handleNextPage","handlePageInputChange","e","target","value","handlePageInputKeyDown","key","page","parseInt","isNaN","handlePageInputBlur","handleZoomIn","newScale","Math","min","handleZoomOut","max","scalePercent","round","createElement","className","toolbar","toolbarButton","onClick","title","type","size","separator","toolbarGroup","disabled","pageInput","onChange","onKeyDown","onBlur","pageCount","scaleDisplay","style","transform","Fragment"],"sources":["PdfViewerToolbar.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Button } from \"@base-ui/react/button\";\nimport { Input } from \"@base-ui/react/input\";\nimport {\n ChevronLeft,\n ChevronRight,\n Download,\n Menu,\n Minus,\n Plus,\n RotatePage,\n Search,\n} from \"@blueprintjs/icons\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport { MAX_SCALE, MIN_SCALE, SCALE_STEP } from \"../constants.js\";\nimport styles from \"./PdfViewerToolbar.module.css\";\n\nexport interface PdfViewerToolbarProps {\n currentPage: number;\n numPages: number;\n scale: number;\n sidebarOpen: boolean;\n onPageChange: (page: number) => void;\n onScaleChange: (scale: number) => void;\n onSearchOpen: () => void;\n onSidebarToggle: () => void;\n onDownload: () => void;\n enableDownload: boolean;\n onRotateLeft: () => void;\n onRotateRight: () => void;\n}\n\nexport function PdfViewerToolbar({\n currentPage,\n numPages,\n scale,\n sidebarOpen,\n onPageChange,\n onScaleChange,\n onSearchOpen,\n onSidebarToggle,\n onDownload,\n enableDownload,\n onRotateLeft,\n onRotateRight,\n}: PdfViewerToolbarProps): React.ReactElement {\n const [pageInputValue, setPageInputValue] = useState(String(currentPage));\n\n // Sync input display when currentPage changes from scrolling\n useEffect(function syncPageInput() {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handlePrevPage = useCallback(() => {\n if (currentPage > 1) {\n const newPage = currentPage - 1;\n onPageChange(newPage);\n setPageInputValue(String(newPage));\n }\n }, [currentPage, onPageChange]);\n\n const handleNextPage = useCallback(() => {\n if (currentPage < numPages) {\n const newPage = currentPage + 1;\n onPageChange(newPage);\n setPageInputValue(String(newPage));\n }\n }, [currentPage, numPages, onPageChange]);\n\n const handlePageInputChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setPageInputValue(e.target.value);\n },\n [],\n );\n\n const handlePageInputKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\") {\n const page = parseInt(pageInputValue, 10);\n if (!isNaN(page) && page >= 1 && page <= numPages) {\n onPageChange(page);\n } else {\n setPageInputValue(String(currentPage));\n }\n }\n },\n [pageInputValue, numPages, onPageChange, currentPage],\n );\n\n const handlePageInputBlur = useCallback(() => {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handleZoomIn = useCallback(() => {\n const newScale = Math.min(scale + SCALE_STEP, MAX_SCALE);\n onScaleChange(newScale);\n }, [scale, onScaleChange]);\n\n const handleZoomOut = useCallback(() => {\n const newScale = Math.max(scale - SCALE_STEP, MIN_SCALE);\n onScaleChange(newScale);\n }, [scale, onScaleChange]);\n\n const scalePercent = `${Math.round(scale * 100)}%`;\n\n return (\n <div className={styles.toolbar}>\n <Button\n className={styles.toolbarButton}\n onClick={onSidebarToggle}\n aria-label={sidebarOpen ? \"Close sidebar\" : \"Open sidebar\"}\n title={sidebarOpen ? \"Close sidebar\" : \"Open sidebar\"}\n aria-pressed={sidebarOpen}\n type=\"button\"\n >\n <Menu size={16} />\n </Button>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={handlePrevPage}\n disabled={currentPage <= 1}\n aria-label=\"Previous page\"\n title=\"Previous page\"\n type=\"button\"\n >\n <ChevronLeft size={16} />\n </Button>\n <Input\n className={styles.pageInput}\n type=\"text\"\n value={pageInputValue}\n onChange={handlePageInputChange}\n onKeyDown={handlePageInputKeyDown}\n onBlur={handlePageInputBlur}\n aria-label=\"Page number\"\n />\n <span className={styles.pageCount}>of {numPages}</span>\n <Button\n className={styles.toolbarButton}\n onClick={handleNextPage}\n disabled={currentPage >= numPages}\n aria-label=\"Next page\"\n title=\"Next page\"\n type=\"button\"\n >\n <ChevronRight size={16} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={handleZoomOut}\n disabled={scale <= MIN_SCALE}\n aria-label=\"Zoom out\"\n title=\"Zoom out\"\n type=\"button\"\n >\n <Minus size={16} />\n </Button>\n <span className={styles.scaleDisplay}>{scalePercent}</span>\n <Button\n className={styles.toolbarButton}\n onClick={handleZoomIn}\n disabled={scale >= MAX_SCALE}\n aria-label=\"Zoom in\"\n title=\"Zoom in\"\n type=\"button\"\n >\n <Plus size={16} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={onRotateLeft}\n aria-label=\"Rotate left\"\n title=\"Rotate left\"\n type=\"button\"\n >\n <RotatePage size={16} />\n </Button>\n <Button\n className={styles.toolbarButton}\n onClick={onRotateRight}\n aria-label=\"Rotate right\"\n title=\"Rotate right\"\n type=\"button\"\n >\n <RotatePage size={16} style={{ transform: \"scaleX(-1)\" }} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onSearchOpen}\n aria-label=\"Search\"\n title=\"Search\"\n type=\"button\"\n >\n <Search size={16} />\n </Button>\n\n {enableDownload && (\n <>\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onDownload}\n aria-label=\"Download\"\n title=\"Download\"\n type=\"button\"\n >\n <Download size={16} />\n </Button>\n </>\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,KAAK,QAAQ,sBAAsB;AAC5C,SACEC,WAAW,EACXC,YAAY,EACZC,QAAQ,EACRC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,UAAU,EACVC,MAAM,QACD,oBAAoB;AAC3B,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,QAAQ,iBAAiB;AAClE,OAAOC,MAAM,MAAM,+BAA+B;AAiBlD,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,WAAW;EACXC,QAAQ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D,QAAQ;IAAC0D,IAAI,EAAE;EAAG,CAAE,CACf,CACR,CAED,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"PdfViewerToolbar.js","names":["Button","Input","ChevronLeft","ChevronRight","Download","FloppyDisk","Highlight","Menu","Minus","Plus","RotatePage","Search","classnames","React","useCallback","useEffect","useState","MAX_SCALE","MIN_SCALE","SCALE_STEP","styles","PdfViewerToolbar","currentPage","numPages","scale","sidebarOpen","onPageChange","onScaleChange","onSearchOpen","onSidebarToggle","onDownload","enableDownload","onRotateLeft","onRotateRight","enableHighlight","highlightModeActive","onHighlightToggle","enableFormSave","onFormSave","pageInputValue","setPageInputValue","String","handlePrevPage","newPage","handleNextPage","handlePageInputChange","e","target","value","handlePageInputKeyDown","key","page","parseInt","isNaN","handlePageInputBlur","handleZoomIn","newScale","Math","min","handleZoomOut","max","scalePercent","round","createElement","className","toolbar","toolbarButton","onClick","title","type","size","separator","toolbarGroup","disabled","pageInput","onChange","onKeyDown","onBlur","pageCount","scaleDisplay","style","transform","Fragment","toolbarButtonActive"],"sources":["PdfViewerToolbar.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Button } from \"@base-ui/react/button\";\nimport { Input } from \"@base-ui/react/input\";\nimport {\n ChevronLeft,\n ChevronRight,\n Download,\n FloppyDisk,\n Highlight,\n Menu,\n Minus,\n Plus,\n RotatePage,\n Search,\n} from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport { MAX_SCALE, MIN_SCALE, SCALE_STEP } from \"../constants.js\";\nimport styles from \"./PdfViewerToolbar.module.css\";\n\nexport interface PdfViewerToolbarProps {\n currentPage: number;\n numPages: number;\n scale: number;\n sidebarOpen: boolean;\n onPageChange: (page: number) => void;\n onScaleChange: (scale: number) => void;\n onSearchOpen: () => void;\n onSidebarToggle: () => void;\n onDownload: () => void;\n enableDownload: boolean;\n onRotateLeft: () => void;\n onRotateRight: () => void;\n enableHighlight: boolean;\n highlightModeActive: boolean;\n onHighlightToggle: () => void;\n enableFormSave?: boolean;\n onFormSave?: () => void;\n}\n\nexport function PdfViewerToolbar({\n currentPage,\n numPages,\n scale,\n sidebarOpen,\n onPageChange,\n onScaleChange,\n onSearchOpen,\n onSidebarToggle,\n onDownload,\n enableDownload,\n onRotateLeft,\n onRotateRight,\n enableHighlight,\n highlightModeActive,\n onHighlightToggle,\n enableFormSave = false,\n onFormSave,\n}: PdfViewerToolbarProps): React.ReactElement {\n const [pageInputValue, setPageInputValue] = useState(String(currentPage));\n\n // Sync input display when currentPage changes from scrolling\n useEffect(function syncPageInput() {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handlePrevPage = useCallback(() => {\n if (currentPage > 1) {\n const newPage = currentPage - 1;\n onPageChange(newPage);\n setPageInputValue(String(newPage));\n }\n }, [currentPage, onPageChange]);\n\n const handleNextPage = useCallback(() => {\n if (currentPage < numPages) {\n const newPage = currentPage + 1;\n onPageChange(newPage);\n setPageInputValue(String(newPage));\n }\n }, [currentPage, numPages, onPageChange]);\n\n const handlePageInputChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setPageInputValue(e.target.value);\n },\n [],\n );\n\n const handlePageInputKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\") {\n const page = parseInt(pageInputValue, 10);\n if (!isNaN(page) && page >= 1 && page <= numPages) {\n onPageChange(page);\n } else {\n setPageInputValue(String(currentPage));\n }\n }\n },\n [pageInputValue, numPages, onPageChange, currentPage],\n );\n\n const handlePageInputBlur = useCallback(() => {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handleZoomIn = useCallback(() => {\n const newScale = Math.min(scale + SCALE_STEP, MAX_SCALE);\n onScaleChange(newScale);\n }, [scale, onScaleChange]);\n\n const handleZoomOut = useCallback(() => {\n const newScale = Math.max(scale - SCALE_STEP, MIN_SCALE);\n onScaleChange(newScale);\n }, [scale, onScaleChange]);\n\n const scalePercent = `${Math.round(scale * 100)}%`;\n\n return (\n <div className={styles.toolbar}>\n <Button\n className={styles.toolbarButton}\n onClick={onSidebarToggle}\n aria-label={sidebarOpen ? \"Close sidebar\" : \"Open sidebar\"}\n title={sidebarOpen ? \"Close sidebar\" : \"Open sidebar\"}\n aria-pressed={sidebarOpen}\n type=\"button\"\n >\n <Menu size={16} />\n </Button>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={handlePrevPage}\n disabled={currentPage <= 1}\n aria-label=\"Previous page\"\n title=\"Previous page\"\n type=\"button\"\n >\n <ChevronLeft size={16} />\n </Button>\n <Input\n className={styles.pageInput}\n type=\"text\"\n value={pageInputValue}\n onChange={handlePageInputChange}\n onKeyDown={handlePageInputKeyDown}\n onBlur={handlePageInputBlur}\n aria-label=\"Page number\"\n />\n <span className={styles.pageCount}>of {numPages}</span>\n <Button\n className={styles.toolbarButton}\n onClick={handleNextPage}\n disabled={currentPage >= numPages}\n aria-label=\"Next page\"\n title=\"Next page\"\n type=\"button\"\n >\n <ChevronRight size={16} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={handleZoomOut}\n disabled={scale <= MIN_SCALE}\n aria-label=\"Zoom out\"\n title=\"Zoom out\"\n type=\"button\"\n >\n <Minus size={16} />\n </Button>\n <span className={styles.scaleDisplay}>{scalePercent}</span>\n <Button\n className={styles.toolbarButton}\n onClick={handleZoomIn}\n disabled={scale >= MAX_SCALE}\n aria-label=\"Zoom in\"\n title=\"Zoom in\"\n type=\"button\"\n >\n <Plus size={16} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={onRotateLeft}\n aria-label=\"Rotate left\"\n title=\"Rotate left\"\n type=\"button\"\n >\n <RotatePage size={16} />\n </Button>\n <Button\n className={styles.toolbarButton}\n onClick={onRotateRight}\n aria-label=\"Rotate right\"\n title=\"Rotate right\"\n type=\"button\"\n >\n <RotatePage size={16} style={{ transform: \"scaleX(-1)\" }} />\n </Button>\n </div>\n\n {enableHighlight && (\n <>\n <div className={styles.separator} />\n\n <Button\n className={classnames(\n styles.toolbarButton,\n highlightModeActive && styles.toolbarButtonActive,\n )}\n onClick={onHighlightToggle}\n aria-label={highlightModeActive\n ? \"Disable highlight mode\"\n : \"Enable highlight mode\"}\n title={highlightModeActive\n ? \"Disable highlight mode\"\n : \"Enable highlight mode\"}\n aria-pressed={highlightModeActive}\n type=\"button\"\n >\n <Highlight size={16} />\n </Button>\n </>\n )}\n\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onSearchOpen}\n aria-label=\"Search\"\n title=\"Search\"\n type=\"button\"\n >\n <Search size={16} />\n </Button>\n\n {enableDownload && (\n <>\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onDownload}\n aria-label=\"Download\"\n title=\"Download\"\n type=\"button\"\n >\n <Download size={16} />\n </Button>\n </>\n )}\n\n {enableFormSave && (\n <>\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onFormSave}\n aria-label=\"Save form\"\n title=\"Save form\"\n type=\"button\"\n >\n <FloppyDisk size={16} />\n </Button>\n </>\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,u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AA,CAAAkD,aAAA,CAAAlD,KAAA,CAAAqE,QAAA,qBACErE,KAAA,CAAAkD,aAAA;IAAKC,SAAS,EAAE5C,MAAM,CAACmD;EAAU,CAAE,CAAC,eAEpC1D,KAAA,CAAAkD,aAAA,CAAC/D,MAAM;IACLgE,SAAS,EAAE5C,MAAM,CAAC8C,aAAc;IAChCC,OAAO,EAAE7B,UAAW;IACpB,cAAW,WAAW;IACtB8B,KAAK,EAAC,WAAW;IACjBC,IAAI,EAAC;EAAQ,gBAEbxD,KAAA,CAAAkD,aAAA,CAAC1D,UAAU;IAACiE,IAAI,EAAE;EAAG,CAAE,CACjB,CACR,CAED,CAAC;AAEV","ignoreList":[]}
@@ -57,6 +57,11 @@
57
57
  cursor: default;
58
58
  }
59
59
 
60
+ .toolbarButtonActive {
61
+ background-color: var(--osdk-surface-background-color-default-active);
62
+ color: var(--osdk-typography-color-default-rest);
63
+ }
64
+
60
65
  .pageInput {
61
66
  width: 48px;
62
67
  text-align: center;