@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
@@ -1 +1 @@
1
- {"version":3,"file":"useFunctionColumnsData.js","names":["useOsdkClient","useEffect","useMemo","useRef","useState","createAsyncCellData","useFunctionColumnsData","objectSet","objects","columnDefinitions","client","data","setData","abortControllerRef","functionColumnConfigs","getFunctionColumnConfigs","stableObjects","useStableObjects","stableObjectSet","JSON","stringify","length","current","abort","abortController","AbortController","initializeFunctionColumnData","queryResult","executeQueriesGenerator","signal","aborted","config","result","error","processQueryResult","configsByApiName","Map","forEach","colDef","locator","type","apiName","queryDefinition","existingConfig","get","columnIds","push","columnId","String","id","getValue","getKey","set","getParams","getFunctionParams","Array","from","values","map","item","$apiName","$primaryKey","sort","a","b","localeCompare","queryPromises","createQueryPromise","pendingPromises","Promise","race","promise","index","then","splice","resolve","params","executeFunction","catch","Error","prev","newData","obj","key","isLoading","columnGetKey","customKey","rawData","cellData"],"sources":["useFunctionColumnsData.ts"],"sourcesContent":["/*\n * Copyright 2026 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 {\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { useOsdkClient } from \"@osdk/react\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n ColumnDefinition,\n ExtractQueryParameters,\n FunctionColumnLocator,\n} from \"../ObjectTableApi.js\";\nimport {\n type AsyncCellData,\n createAsyncCellData,\n} from \"../utils/AsyncCellData.js\";\n\nexport interface FunctionColumnData {\n [columnId: string]: {\n [objectPrimaryKey: string]: AsyncCellData;\n };\n}\n\ntype FunctionColumnConfig<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = {\n queryDefinition: QueryDefinition<any>;\n getParams: (\n objectSet: ObjectSet<Q>,\n ) => ExtractQueryParameters<FunctionColumns[keyof FunctionColumns]>;\n columnIds: Array<{\n columnId: string;\n getValue?: (cellData: unknown) => unknown;\n getKey: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => string;\n }>;\n};\n\ntype QueryResult<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = {\n config: FunctionColumnConfig<Q, RDPs, FunctionColumns>;\n result: Record<string, unknown> | null;\n error: Error | null;\n aborted?: boolean;\n};\n\nexport function useFunctionColumnsData<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n objectSet: ObjectSet<Q, RDPs> | undefined,\n objects:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined,\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>,\n): FunctionColumnData {\n const client = useOsdkClient();\n const [data, setData] = useState<FunctionColumnData>({});\n const abortControllerRef = useRef<AbortController | null>(null);\n\n // Function column configurations grouped by unique query definition\n const functionColumnConfigs = useMemo(\n () => getFunctionColumnConfigs(columnDefinitions),\n [columnDefinitions],\n );\n\n const stableObjects = useStableObjects(objects);\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableObjectSet = useMemo(() => objectSet, [JSON.stringify(objectSet)]);\n\n useEffect(() => {\n if (\n !stableObjects || stableObjects.length === 0\n || functionColumnConfigs.length === 0 || !stableObjectSet\n ) {\n return;\n }\n\n // Cancel previous requests\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n const executeQueries = async () => {\n if (!stableObjectSet) {\n return;\n }\n\n initializeFunctionColumnData(\n functionColumnConfigs,\n stableObjects,\n setData,\n );\n\n // Process query results as they complete\n for await (\n const queryResult of executeQueriesGenerator(\n functionColumnConfigs,\n stableObjectSet as ObjectSet<Q>,\n client,\n abortController.signal,\n )\n ) {\n if (abortController.signal.aborted) {\n break;\n }\n\n const { config, result, error, aborted } = queryResult;\n if (!aborted) {\n processQueryResult(config, result, error, stableObjects, setData);\n }\n }\n };\n\n void executeQueries();\n\n return () => {\n abortController.abort();\n abortControllerRef.current = null;\n };\n }, [functionColumnConfigs, stableObjects, stableObjectSet, client]);\n\n return data;\n}\n\nfunction getFunctionColumnConfigs<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>,\n): Array<FunctionColumnConfig<Q, RDPs, FunctionColumns>> {\n if (!columnDefinitions) return [];\n\n // Group columns by their query definition apiName\n const configsByApiName = new Map<\n string,\n FunctionColumnConfig<Q, RDPs, FunctionColumns>\n >();\n\n columnDefinitions.forEach((colDef) => {\n if (colDef.locator.type === \"function\") {\n const locator = colDef.locator as FunctionColumnLocator<\n Q,\n RDPs,\n FunctionColumns\n >;\n\n const apiName = locator.queryDefinition.apiName;\n const existingConfig = configsByApiName.get(apiName);\n\n if (existingConfig) {\n // Add this column to the existing config\n existingConfig.columnIds.push({\n columnId: String(locator.id),\n getValue: locator.getValue,\n getKey: locator.getKey,\n });\n } else {\n // Create new config\n configsByApiName.set(apiName, {\n queryDefinition: locator.queryDefinition,\n getParams: locator.getFunctionParams,\n columnIds: [{\n columnId: String(locator.id),\n getValue: locator.getValue,\n getKey: locator.getKey,\n }],\n });\n }\n }\n });\n\n return Array.from(configsByApiName.values());\n}\n\nconst useStableObjects = <\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n objects:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined,\n):\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined =>\n{\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => objects, [\n // eslint-disable-next-line react-hooks/exhaustive-deps\n JSON.stringify(\n (objects ?? []).map(item => ({\n $apiName: item.$apiName,\n $primaryKey: item.$primaryKey,\n })).sort((a, b) => {\n if (a.$apiName !== b.$apiName) {\n return a.$apiName.localeCompare(b.$apiName);\n }\n return String(a.$primaryKey).localeCompare(String(b.$primaryKey));\n }),\n ),\n ]);\n};\n\n/**\n * Generator that yields query results as they complete\n */\nasync function* executeQueriesGenerator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n functionColumnConfigs: Array<FunctionColumnConfig<Q, RDPs, FunctionColumns>>,\n objectSet: ObjectSet<Q>,\n client: ReturnType<typeof useOsdkClient>,\n signal?: AbortSignal,\n): AsyncGenerator<QueryResult<Q, RDPs, FunctionColumns>, void, unknown> {\n // Start all queries in parallel\n const queryPromises = functionColumnConfigs.map(config =>\n createQueryPromise(config, objectSet, client, signal)\n ) as Array<Promise<QueryResult<Q, RDPs, FunctionColumns>>>;\n const pendingPromises = [...queryPromises];\n\n // Yield results as they complete using Promise.race\n while (pendingPromises.length > 0) {\n const result = await Promise.race(\n pendingPromises.map((promise, index) =>\n promise.then(result => ({ result, index }))\n ),\n );\n\n yield result.result;\n\n // Remove the completed promise from the pending list\n void pendingPromises.splice(result.index, 1);\n }\n}\n\n/**\n * Create a promise that executes a function column query\n */\nfunction createQueryPromise<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n config: FunctionColumnConfig<Q, RDPs, FunctionColumns>,\n objectSet: ObjectSet<Q>,\n client: ReturnType<typeof useOsdkClient>,\n signal?: AbortSignal,\n): Promise<QueryResult<Q, RDPs, FunctionColumns>> {\n return new Promise((resolve) => {\n if (signal?.aborted) {\n resolve({ config, result: null, error: null, aborted: true });\n return;\n }\n\n const params = config.getParams(objectSet as ObjectSet<Q>);\n\n client(config.queryDefinition)\n .executeFunction(params)\n .then((result: Record<string, unknown>) => {\n // Check if aborted during execution\n if (signal?.aborted) {\n resolve({ config, result: null, error: null, aborted: true });\n } else {\n resolve({ config, result, error: null });\n }\n })\n .catch((error: unknown) => {\n // Check if aborted during error handling\n if (signal?.aborted) {\n resolve({ config, result: null, error: null, aborted: true });\n } else {\n resolve({\n config,\n result: null,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n }\n });\n });\n}\n\n/**\n * Initialize function column data with isLoading state for all columns and objects\n */\nfunction initializeFunctionColumnData<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n functionColumnConfigs: Array<FunctionColumnConfig<Q, RDPs, FunctionColumns>>,\n objects: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[],\n setData: React.Dispatch<React.SetStateAction<FunctionColumnData>>,\n): void {\n setData(prev => {\n const newData = { ...prev };\n\n functionColumnConfigs.forEach(config => {\n config.columnIds.forEach(({ columnId }) => {\n // Initialize column if it doesn't exist\n if (!newData[columnId]) {\n newData[columnId] = {};\n }\n\n objects.forEach(obj => {\n const key = String(obj.$primaryKey);\n // Only set isLoading state if this object's data doesn't already exist\n if (!newData[columnId][key]) {\n newData[columnId][key] = createAsyncCellData({\n isLoading: true,\n });\n }\n });\n });\n });\n\n return newData;\n });\n}\n\nfunction processQueryResult<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n config: FunctionColumnConfig<Q, RDPs, FunctionColumns>,\n result: Record<string, unknown> | null,\n error: Error | null,\n objects: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[],\n setData: React.Dispatch<React.SetStateAction<FunctionColumnData>>,\n): void {\n // Batch all updates into a single setState call\n setData(prev => {\n const newData = { ...prev };\n\n if (error) {\n // Set error for all objects in all columns that use this query\n config.columnIds.forEach(({ columnId }) => {\n if (!newData[columnId]) {\n newData[columnId] = {};\n }\n\n objects.forEach(obj => {\n const key = String(obj.$primaryKey);\n newData[columnId][key] = createAsyncCellData({\n error: error instanceof Error\n ? error\n : new Error(String(error)),\n isLoading: false,\n });\n });\n });\n } else if (result) {\n // Process the FunctionsMap result\n objects.forEach(obj => {\n const key = String(obj.$primaryKey);\n\n // Process each column that uses this query result\n config.columnIds.forEach(\n ({ columnId, getValue, getKey: columnGetKey }) => {\n if (!newData[columnId]) {\n newData[columnId] = {};\n }\n\n const customKey = columnGetKey(obj);\n const rawData = result[customKey];\n const cellData = getValue ? getValue(rawData) : rawData;\n\n newData[columnId][key] = createAsyncCellData({\n data: cellData,\n isLoading: false,\n });\n },\n );\n });\n }\n\n return newData;\n });\n}\n"],"mappings":"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ACA9B,MAAM,CAACc,SAAS,CAACR,OAAO,CACtB,CAAC;UAAEU,QAAQ;UAAEG,QAAQ;UAAEC,MAAM,EAAEkC;QAAa,CAAC,KAAK;UAChD,IAAI,CAACJ,OAAO,CAAClC,QAAQ,CAAC,EAAE;YACtBkC,OAAO,CAAClC,QAAQ,CAAC,GAAG,CAAC,CAAC;UACxB;UAEA,MAAMuC,SAAS,GAAGD,YAAY,CAACH,GAAG,CAAC;UACnC,MAAMK,OAAO,GAAGvD,MAAM,CAACsD,SAAS,CAAC;UACjC,MAAME,QAAQ,GAAGtC,QAAQ,GAAGA,QAAQ,CAACqC,OAAO,CAAC,GAAGA,OAAO;UAEvDN,OAAO,CAAClC,QAAQ,CAAC,CAACoC,GAAG,CAAC,GAAG9E,mBAAmB,CAAC;YAC3CM,IAAI,EAAE6E,QAAQ;YACdJ,SAAS,EAAE;UACb,CAAC,CAAC;QACJ,CACF,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAOH,OAAO;EAChB,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"useFunctionColumnsData.js","names":["useOsdkFunctions","useMemo","createAsyncCellData","useFunctionColumnsData","objectSet","objects","columnDefinitions","functionColumnConfigs","getFunctionColumnConfigs","stableObjects","useStableObjects","stableObjectSet","JSON","stringify","disabled","length","queries","map","config","queryDefinition","options","params","getParams","results","enabled","data","columnData","forEach","result","index","functionsMap","columnIds","columnId","getValue","getKey","columnGetKey","obj","key","String","$primaryKey","isLoading","error","customKey","rawData","cellData","configsByApiName","Map","colDef","locator","type","apiName","existingConfig","get","push","id","set","getFunctionParams","Array","from","values","item","$apiName","sort","a","b","localeCompare"],"sources":["useFunctionColumnsData.ts"],"sourcesContent":["/*\n * Copyright 2026 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 {\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport {\n type FunctionQueryParams,\n useOsdkFunctions,\n} from \"@osdk/react/unstable-do-not-use\";\n\nimport { useMemo } from \"react\";\nimport type {\n ColumnDefinition,\n FunctionColumnLocator,\n} from \"../ObjectTableApi.js\";\nimport {\n type AsyncCellData,\n createAsyncCellData,\n} from \"../utils/AsyncCellData.js\";\n\nexport interface FunctionColumnData {\n [columnId: string]: {\n [objectPrimaryKey: string]: AsyncCellData;\n };\n}\n\ntype FunctionColumnConfig<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> = {\n queryDefinition: QueryDefinition<unknown>;\n getParams: (\n objectSet: ObjectSet<Q, RDPs>,\n ) => unknown;\n columnIds: Array<{\n columnId: string;\n getValue?: (cellData: unknown) => unknown;\n getKey: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => string;\n }>;\n};\n\nexport function useFunctionColumnsData<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n objectSet: ObjectSet<Q, RDPs> | undefined,\n objects:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined,\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>,\n): FunctionColumnData {\n // Function column configurations grouped by unique query definition\n const functionColumnConfigs = useMemo(\n () => getFunctionColumnConfigs(columnDefinitions),\n [columnDefinitions],\n );\n\n const stableObjects = useStableObjects(objects);\n\n // TODO: replace with useDeepEqual when it's added\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableObjectSet = useMemo(() => objectSet, [JSON.stringify(objectSet)]);\n\n const disabled = !stableObjectSet || !stableObjects?.length\n || functionColumnConfigs.length === 0;\n\n // Prepare queries for useOsdkFunctions\n const queries = useMemo(\n () => {\n if (disabled) {\n return [];\n }\n\n return functionColumnConfigs.map(\n (config): FunctionQueryParams<QueryDefinition<unknown>> => ({\n queryDefinition: config.queryDefinition,\n options: {\n params: config.getParams(stableObjectSet),\n } as FunctionQueryParams<QueryDefinition<unknown>>[\"options\"],\n }),\n );\n },\n [disabled, functionColumnConfigs, stableObjectSet],\n );\n\n const results = useOsdkFunctions(\n {\n queries,\n enabled: !disabled,\n },\n );\n\n const data = useMemo(() => {\n const columnData: FunctionColumnData = {};\n\n if (disabled || !stableObjects) return columnData;\n\n results.forEach((result, index) => {\n const config = functionColumnConfigs[index];\n if (!config) return;\n\n const functionsMap = result.data as Record<string, unknown> | undefined;\n\n config.columnIds.forEach(\n ({ columnId, getValue, getKey: columnGetKey }) => {\n if (!columnData[columnId]) {\n columnData[columnId] = {};\n }\n\n stableObjects.forEach(obj => {\n const key = String(obj.$primaryKey);\n\n if (result.isLoading) {\n columnData[columnId][key] = createAsyncCellData({\n isLoading: true,\n });\n } else if (result.error) {\n columnData[columnId][key] = createAsyncCellData({\n error: result.error,\n isLoading: false,\n });\n } else if (functionsMap) {\n const customKey = columnGetKey(obj);\n const rawData = functionsMap[customKey];\n const cellData = getValue ? getValue(rawData) : rawData;\n columnData[columnId][key] = createAsyncCellData({\n data: cellData,\n isLoading: false,\n });\n }\n });\n },\n );\n });\n\n return columnData;\n }, [results, functionColumnConfigs, stableObjects, disabled]);\n\n return data;\n}\n\nfunction getFunctionColumnConfigs<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>,\n): Array<FunctionColumnConfig<Q, RDPs>> {\n if (!columnDefinitions) return [];\n\n // Group columns by their query definition apiName\n const configsByApiName = new Map<\n string,\n FunctionColumnConfig<Q, RDPs>\n >();\n\n columnDefinitions.forEach((colDef) => {\n if (colDef.locator.type === \"function\") {\n const locator = colDef.locator as FunctionColumnLocator<\n Q,\n RDPs,\n FunctionColumns\n >;\n\n const apiName = locator.queryDefinition.apiName;\n const existingConfig = configsByApiName.get(apiName);\n\n if (existingConfig) {\n // Add this column to the existing config\n existingConfig.columnIds.push({\n columnId: String(locator.id),\n getValue: locator.getValue,\n getKey: locator.getKey,\n });\n } else {\n // Create new config\n configsByApiName.set(apiName, {\n queryDefinition: locator.queryDefinition,\n getParams: locator.getFunctionParams,\n columnIds: [{\n columnId: String(locator.id),\n getValue: locator.getValue,\n getKey: locator.getKey,\n }],\n });\n }\n }\n });\n\n return Array.from(configsByApiName.values());\n}\n\nconst useStableObjects = <\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n objects:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined,\n):\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined =>\n{\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => objects, [\n // eslint-disable-next-line react-hooks/exhaustive-deps\n JSON.stringify(\n (objects ?? []).map(item => ({\n $apiName: item.$apiName,\n $primaryKey: item.$primaryKey,\n })).sort((a, b) => {\n if (a.$apiName !== b.$apiName) {\n return a.$apiName.localeCompare(b.$apiName);\n }\n return String(a.$primaryKey).localeCompare(String(b.$primaryKey));\n }),\n ),\n ]);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAEEA,gBAAgB,Q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CAAC,CAAC,CAAC;AAC9C;AAEA,MAAMjD,gBAAgB,GAIpBL,OAEa,IAIf;EACE;EACA,OAAOJ,OAAO,CAAC,MAAMI,OAAO,EAAE;EAC5B;EACAO,IAAI,CAACC,SAAS,CACZ,CAACR,OAAO,IAAI,EAAE,EAAEY,GAAG,CAAC2C,IAAI,KAAK;IAC3BC,QAAQ,EAAED,IAAI,CAACC,QAAQ;IACvBtB,WAAW,EAAEqB,IAAI,CAACrB;EACpB,CAAC,CAAC,CAAC,CAACuB,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK;IACjB,IAAID,CAAC,CAACF,QAAQ,KAAKG,CAAC,CAACH,QAAQ,EAAE;MAC7B,OAAOE,CAAC,CAACF,QAAQ,CAACI,aAAa,CAACD,CAAC,CAACH,QAAQ,CAAC;IAC7C;IACA,OAAOvB,MAAM,CAACyB,CAAC,CAACxB,WAAW,CAAC,CAAC0B,aAAa,CAAC3B,MAAM,CAAC0B,CAAC,CAACzB,WAAW,CAAC,CAAC;EACnE,CAAC,CACH,CAAC,CACF,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -17,21 +17,30 @@
17
17
  import { Error as ErrorIcon, Spin } from "@blueprintjs/icons";
18
18
  import classnames from "classnames";
19
19
  import "pdfjs-dist/web/pdf_viewer.css";
20
- import React from "react";
20
+ import React, { forwardRef, useImperativeHandle } from "react";
21
21
  import { createPortal } from "react-dom";
22
22
  import { PdfViewerAnnotationLayer } from "./components/PdfViewerAnnotationLayer.js";
23
23
  import { PdfViewerOutlineSidebar } from "./components/PdfViewerOutlineSidebar.js";
24
24
  import { PdfViewerSearchBar } from "./components/PdfViewerSearchBar.js";
25
25
  import { PdfViewerSidebar } from "./components/PdfViewerSidebar.js";
26
26
  import { PdfViewerToolbar } from "./components/PdfViewerToolbar.js";
27
- import { EMPTY_ANNOTATION_ARRAY, EMPTY_ANNOTATIONS } from "./constants.js";
27
+ import { EMPTY_ANNOTATION_ARRAY } from "./constants.js";
28
+ import { usePdfAnnotationsByPage } from "./hooks/usePdfAnnotationsByPage.js";
29
+ import { usePdfFormFields } from "./hooks/usePdfFormFields.js";
30
+ import { usePdfHighlightMode } from "./hooks/usePdfHighlightMode.js";
28
31
  import { usePdfViewerState } from "./hooks/usePdfViewerState.js";
29
32
  import styles from "./PdfViewer.module.css.js";
30
- export function BasePdfViewer({
33
+ export const BasePdfViewer = /*#__PURE__*/forwardRef(function ({
31
34
  src,
32
- annotations = EMPTY_ANNOTATIONS,
35
+ annotations = EMPTY_ANNOTATION_ARRAY,
33
36
  onAnnotationClick,
34
37
  onDownload,
38
+ enableHighlight = false,
39
+ onTextHighlight,
40
+ onHighlightDelete,
41
+ formData,
42
+ onFormSubmit,
43
+ onFormChange,
35
44
  initialPage = 1,
36
45
  initialScale = 1.0,
37
46
  initialSidebarOpen = false,
@@ -39,7 +48,7 @@ export function BasePdfViewer({
39
48
  sidebarMode: sidebarModeProp = "thumbnails",
40
49
  outlineIcons,
41
50
  className
42
- }) {
51
+ }, ref) {
43
52
  const viewer = usePdfViewerState({
44
53
  src,
45
54
  initialPage,
@@ -48,6 +57,33 @@ export function BasePdfViewer({
48
57
  sidebarMode: sidebarModeProp,
49
58
  onDownload
50
59
  });
60
+ const {
61
+ highlightModeActive,
62
+ toggleHighlightMode,
63
+ deleteHighlight
64
+ } = usePdfHighlightMode({
65
+ pdfViewerRef: viewer.pdfViewerRef,
66
+ document: viewer.document,
67
+ enabled: enableHighlight,
68
+ onTextHighlight,
69
+ onHighlightDelete
70
+ });
71
+ useImperativeHandle(ref, () => ({
72
+ scrollToPage: viewer.scrollToPage,
73
+ deleteHighlight
74
+ }), [viewer.scrollToPage, deleteHighlight]);
75
+ const {
76
+ hasFormFields,
77
+ submitFormData
78
+ } = usePdfFormFields({
79
+ pdfViewerRef: viewer.pdfViewerRef,
80
+ eventBusRef: viewer.eventBusRef,
81
+ document: viewer.document,
82
+ formData,
83
+ onFormSubmit,
84
+ onFormChange
85
+ });
86
+ const annotationsByPage = usePdfAnnotationsByPage(annotations);
51
87
  const rootClassName = classnames(styles.pdfViewer, className);
52
88
  if (viewer.loading) {
53
89
  return /*#__PURE__*/React.createElement("div", {
@@ -88,7 +124,12 @@ export function BasePdfViewer({
88
124
  onDownload: viewer.download,
89
125
  enableDownload: enableDownload,
90
126
  onRotateLeft: viewer.rotateLeft,
91
- onRotateRight: viewer.rotateRight
127
+ onRotateRight: viewer.rotateRight,
128
+ enableHighlight: enableHighlight,
129
+ highlightModeActive: highlightModeActive,
130
+ onHighlightToggle: toggleHighlightMode,
131
+ enableFormSave: onFormSubmit != null && hasFormFields,
132
+ onFormSave: submitFormData
92
133
  }), viewer.search.isSearchOpen && /*#__PURE__*/React.createElement(PdfViewerSearchBar, {
93
134
  query: viewer.search.query,
94
135
  totalMatches: viewer.search.totalMatches,
@@ -122,7 +163,7 @@ export function BasePdfViewer({
122
163
  ref: viewer.viewerRef,
123
164
  className: "pdfViewer"
124
165
  }), viewer.portalTargets.map(target => {
125
- const pageAnnotations = annotations[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;
166
+ const pageAnnotations = annotationsByPage[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;
126
167
  if (pageAnnotations.length === 0) {
127
168
  return null;
128
169
  }
@@ -134,5 +175,5 @@ export function BasePdfViewer({
134
175
  onAnnotationClick: onAnnotationClick
135
176
  }), target.container);
136
177
  })))));
137
- }
178
+ });
138
179
  //# sourceMappingURL=PdfViewer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PdfViewer.js","names":["Error","ErrorIcon","Spin","classnames","React","createPortal","PdfViewerAnnotationLayer","PdfViewerOutlineSidebar","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","EMPTY_ANNOTATION_ARRAY","EMPTY_ANNOTATIONS","usePdfViewerState","styles","BasePdfViewer","src","annotations","onAnnotationClick","onDownload","initialPage","initialScale","initialSidebarOpen","enableDownload","sidebarMode","sidebarModeProp","outlineIcons","className","viewer","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","document","currentPage","numPages","scale","sidebarOpen","onPageChange","scrollToPage","onScaleChange","setScale","onSearchOpen","search","openSearch","onSidebarToggle","toggleSidebar","download","onRotateLeft","rotateLeft","onRotateRight","rotateRight","isSearchOpen","query","totalMatches","currentMatchIndex","onQueryChange","setQuery","onNext","nextMatch","onPrev","prevMatch","onClose","closeSearch","contentArea","onPageClick","onSidebarModeChange","setSidebarMode","outlineItems","onItemClick","scrollContainerWrapper","ref","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key","pageHeight","container"],"sources":["PdfViewer.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { PdfViewerAnnotationLayer } from \"./components/PdfViewerAnnotationLayer.js\";\nimport { PdfViewerOutlineSidebar } from \"./components/PdfViewerOutlineSidebar.js\";\nimport { PdfViewerSearchBar } from \"./components/PdfViewerSearchBar.js\";\nimport { PdfViewerSidebar } from \"./components/PdfViewerSidebar.js\";\nimport { PdfViewerToolbar } from \"./components/PdfViewerToolbar.js\";\nimport { EMPTY_ANNOTATION_ARRAY, EMPTY_ANNOTATIONS } from \"./constants.js\";\nimport { usePdfViewerState } from \"./hooks/usePdfViewerState.js\";\nimport styles from \"./PdfViewer.module.css\";\nimport type { PdfViewerProps } from \"./types.js\";\n\nexport function BasePdfViewer({\n src,\n annotations = EMPTY_ANNOTATIONS,\n onAnnotationClick,\n onDownload,\n initialPage = 1,\n initialScale = 1.0,\n initialSidebarOpen = false,\n enableDownload = false,\n sidebarMode: sidebarModeProp = \"thumbnails\",\n outlineIcons,\n className,\n}: PdfViewerProps): React.ReactElement {\n const viewer = usePdfViewerState({\n src,\n initialPage,\n initialScale,\n initialSidebarOpen,\n sidebarMode: sidebarModeProp,\n onDownload,\n });\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (viewer.loading) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n </div>\n );\n }\n\n if (viewer.error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {viewer.error.message}\n </div>\n </div>\n );\n }\n\n if (viewer.document == null) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>No document</div>\n </div>\n );\n }\n\n return (\n <div className={rootClassName}>\n <PdfViewerToolbar\n currentPage={viewer.currentPage}\n numPages={viewer.numPages}\n scale={viewer.scale}\n sidebarOpen={viewer.sidebarOpen}\n onPageChange={viewer.scrollToPage}\n onScaleChange={viewer.setScale}\n onSearchOpen={viewer.search.openSearch}\n onSidebarToggle={viewer.toggleSidebar}\n onDownload={viewer.download}\n enableDownload={enableDownload}\n onRotateLeft={viewer.rotateLeft}\n onRotateRight={viewer.rotateRight}\n />\n {viewer.search.isSearchOpen && (\n <PdfViewerSearchBar\n query={viewer.search.query}\n totalMatches={viewer.search.totalMatches}\n currentMatchIndex={viewer.search.currentMatchIndex}\n onQueryChange={viewer.search.setQuery}\n onNext={viewer.search.nextMatch}\n onPrev={viewer.search.prevMatch}\n onClose={viewer.search.closeSearch}\n />\n )}\n <div className={styles.contentArea}>\n {viewer.sidebarOpen && viewer.sidebarMode === \"thumbnails\" && (\n <PdfViewerSidebar\n document={viewer.document}\n numPages={viewer.numPages}\n currentPage={viewer.currentPage}\n onPageClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n />\n )}\n {viewer.sidebarOpen && viewer.sidebarMode === \"outline\" && (\n <PdfViewerOutlineSidebar\n outlineItems={viewer.outlineItems}\n currentPage={viewer.currentPage}\n onItemClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n outlineIcons={outlineIcons}\n />\n )}\n <div className={styles.scrollContainerWrapper}>\n <div ref={viewer.containerRef} className={styles.scrollContainer}>\n <div ref={viewer.viewerRef} className=\"pdfViewer\" />\n {viewer.portalTargets.map((target) => {\n const pageAnnotations = annotations[target.pageNumber]\n ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return createPortal(\n <PdfViewerAnnotationLayer\n key={target.pageNumber}\n annotations={pageAnnotations}\n pageHeight={target.pageHeight}\n scale={target.scale}\n onAnnotationClick={onAnnotationClick}\n />,\n target.container,\n );\n })}\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,IAAIC,SAAS,EAAEC,IAAI,QAAQ,oBAAoB;AAC7D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,wBAAwB,QAAQ,0CAA0C;AACnF,SAASC,uBAAuB,QAAQ,yCAAyC;AACjF,SAASC,kBAAkB,QAAQ,oCAAoC;AACvE,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,sBAAsB,EAAEC,iBAAiB,QAAQ,gBAAgB;AAC1E,SAASC,iBAAi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ACE,UAAU,CAAC,IACjD1E,sBAAsB;IAC3B,IAAIyE,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBAAOjF,YAAY,cACjBD,KAAA,CAAA4B,aAAA,CAAC1B,wBAAwB;MACvBiF,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvBpE,WAAW,EAAEmE,eAAgB;MAC7BI,UAAU,EAAEL,MAAM,CAACK,UAAW;MAC9B9C,KAAK,EAAEyC,MAAM,CAACzC,KAAM;MACpBxB,iBAAiB,EAAEA;IAAkB,CACtC,CAAC,EACFiE,MAAM,CAACM,SACT,CAAC;EACH,CAAC,CACE,CACF,CACF,CACF,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"PdfViewer.js","names":["Error","ErrorIcon","Spin","classnames","React","forwardRef","useImperativeHandle","createPortal","PdfViewerAnnotationLayer","PdfViewerOutlineSidebar","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfHighlightMode","usePdfViewerState","styles","BasePdfViewer","src","annotations","onAnnotationClick","onDownload","enableHighlight","onTextHighlight","onHighlightDelete","formData","onFormSubmit","onFormChange","initialPage","initialScale","initialSidebarOpen","enableDownload","sidebarMode","sidebarModeProp","outlineIcons","className","ref","viewer","highlightModeActive","toggleHighlightMode","deleteHighlight","pdfViewerRef","document","enabled","scrollToPage","hasFormFields","submitFormData","eventBusRef","annotationsByPage","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","currentPage","numPages","scale","sidebarOpen","onPageChange","onScaleChange","setScale","onSearchOpen","search","openSearch","onSidebarToggle","toggleSidebar","download","onRotateLeft","rotateLeft","onRotateRight","rotateRight","onHighlightToggle","enableFormSave","onFormSave","isSearchOpen","query","totalMatches","currentMatchIndex","onQueryChange","setQuery","onNext","nextMatch","onPrev","prevMatch","onClose","closeSearch","contentArea","onPageClick","onSidebarModeChange","setSidebarMode","outlineItems","onItemClick","scrollContainerWrapper","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key","pageHeight","container"],"sources":["PdfViewer.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { forwardRef, useImperativeHandle } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { PdfViewerAnnotationLayer } from \"./components/PdfViewerAnnotationLayer.js\";\nimport { PdfViewerOutlineSidebar } from \"./components/PdfViewerOutlineSidebar.js\";\nimport { PdfViewerSearchBar } from \"./components/PdfViewerSearchBar.js\";\nimport { PdfViewerSidebar } from \"./components/PdfViewerSidebar.js\";\nimport { PdfViewerToolbar } from \"./components/PdfViewerToolbar.js\";\nimport { EMPTY_ANNOTATION_ARRAY } from \"./constants.js\";\nimport { usePdfAnnotationsByPage } from \"./hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"./hooks/usePdfFormFields.js\";\nimport { usePdfHighlightMode } from \"./hooks/usePdfHighlightMode.js\";\nimport { usePdfViewerState } from \"./hooks/usePdfViewerState.js\";\nimport styles from \"./PdfViewer.module.css\";\nimport type { PdfViewerHandle, PdfViewerProps } from \"./types.js\";\n\nexport const BasePdfViewer: React.ForwardRefExoticComponent<\n PdfViewerProps & React.RefAttributes<PdfViewerHandle>\n> = forwardRef<PdfViewerHandle, PdfViewerProps>(\n function BasePdfViewer({\n src,\n annotations = EMPTY_ANNOTATION_ARRAY,\n onAnnotationClick,\n onDownload,\n enableHighlight = false,\n onTextHighlight,\n onHighlightDelete,\n formData,\n onFormSubmit,\n onFormChange,\n initialPage = 1,\n initialScale = 1.0,\n initialSidebarOpen = false,\n enableDownload = false,\n sidebarMode: sidebarModeProp = \"thumbnails\",\n outlineIcons,\n className,\n }, ref) {\n const viewer = usePdfViewerState({\n src,\n initialPage,\n initialScale,\n initialSidebarOpen,\n sidebarMode: sidebarModeProp,\n onDownload,\n });\n\n const { highlightModeActive, toggleHighlightMode, deleteHighlight } =\n usePdfHighlightMode({\n pdfViewerRef: viewer.pdfViewerRef,\n document: viewer.document,\n enabled: enableHighlight,\n onTextHighlight,\n onHighlightDelete,\n });\n\n useImperativeHandle(ref, () => ({\n scrollToPage: viewer.scrollToPage,\n deleteHighlight,\n }), [viewer.scrollToPage, deleteHighlight]);\n\n const { hasFormFields, submitFormData } = usePdfFormFields({\n pdfViewerRef: viewer.pdfViewerRef,\n eventBusRef: viewer.eventBusRef,\n document: viewer.document,\n formData,\n onFormSubmit,\n onFormChange,\n });\n\n const annotationsByPage = usePdfAnnotationsByPage(annotations);\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (viewer.loading) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n </div>\n );\n }\n\n if (viewer.error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {viewer.error.message}\n </div>\n </div>\n );\n }\n\n if (viewer.document == null) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>No document</div>\n </div>\n );\n }\n\n return (\n <div className={rootClassName}>\n <PdfViewerToolbar\n currentPage={viewer.currentPage}\n numPages={viewer.numPages}\n scale={viewer.scale}\n sidebarOpen={viewer.sidebarOpen}\n onPageChange={viewer.scrollToPage}\n onScaleChange={viewer.setScale}\n onSearchOpen={viewer.search.openSearch}\n onSidebarToggle={viewer.toggleSidebar}\n onDownload={viewer.download}\n enableDownload={enableDownload}\n onRotateLeft={viewer.rotateLeft}\n onRotateRight={viewer.rotateRight}\n enableHighlight={enableHighlight}\n highlightModeActive={highlightModeActive}\n onHighlightToggle={toggleHighlightMode}\n enableFormSave={onFormSubmit != null && hasFormFields}\n onFormSave={submitFormData}\n />\n {viewer.search.isSearchOpen && (\n <PdfViewerSearchBar\n query={viewer.search.query}\n totalMatches={viewer.search.totalMatches}\n currentMatchIndex={viewer.search.currentMatchIndex}\n onQueryChange={viewer.search.setQuery}\n onNext={viewer.search.nextMatch}\n onPrev={viewer.search.prevMatch}\n onClose={viewer.search.closeSearch}\n />\n )}\n <div className={styles.contentArea}>\n {viewer.sidebarOpen && viewer.sidebarMode === \"thumbnails\" && (\n <PdfViewerSidebar\n document={viewer.document}\n numPages={viewer.numPages}\n currentPage={viewer.currentPage}\n onPageClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n />\n )}\n {viewer.sidebarOpen && viewer.sidebarMode === \"outline\" && (\n <PdfViewerOutlineSidebar\n outlineItems={viewer.outlineItems}\n currentPage={viewer.currentPage}\n onItemClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n outlineIcons={outlineIcons}\n />\n )}\n <div className={styles.scrollContainerWrapper}>\n <div ref={viewer.containerRef} className={styles.scrollContainer}>\n <div ref={viewer.viewerRef} className=\"pdfViewer\" />\n {viewer.portalTargets.map((target) => {\n const pageAnnotations = annotationsByPage[target.pageNumber]\n ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return createPortal(\n <PdfViewerAnnotationLayer\n key={target.pageNumber}\n annotations={pageAnnotations}\n pageHeight={target.pageHeight}\n scale={target.scale}\n onAnnotationClick={onAnnotationClick}\n />,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AM,CAACL,WAAY;IAChC6D,mBAAmB,EAAExD,MAAM,CAACyD,cAAe;IAC3C5D,YAAY,EAAEA;EAAa,CAC5B,CACF,eACDhC,KAAA,CAAAkD,aAAA;IAAKjB,SAAS,EAAEnB,MAAM,CAACiF;EAAuB,gBAC5C/F,KAAA,CAAAkD,aAAA;IAAKhB,GAAG,EAAEC,MAAM,CAAC6D,YAAa;IAAC/D,SAAS,EAAEnB,MAAM,CAACmF;EAAgB,gBAC/DjG,KAAA,CAAAkD,aAAA;IAAKhB,GAAG,EAAEC,MAAM,CAAC+D,SAAU;IAACjE,SAAS,EAAC;EAAW,CAAE,CAAC,EACnDE,MAAM,CAACgE,aAAa,CAACC,GAAG,CAAEC,MAAM,IAAK;IACpC,MAAMC,eAAe,GAAGxD,iBAAiB,CAACuD,MAAM,CAACE,UAAU,CAAC,IACvD9F,sBAAsB;IAC3B,IAAI6F,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBAAOrG,YAAY,cACjBH,KAAA,CAAAkD,aAAA,CAAC9C,wBAAwB;MACvBqG,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvBtF,WAAW,EAAEqF,eAAgB;MAC7BI,UAAU,EAAEL,MAAM,CAACK,UAAW;MAC9B/C,KAAK,EAAE0C,MAAM,CAAC1C,KAAM;MACpBzC,iBAAiB,EAAEA;IAAkB,CACtC,CAAC,EACFmF,MAAM,CAACM,SACT,CAAC;EACH,CAAC,CACE,CACF,CACF,CACF,CAAC;AAEV,CACF,CAAC","ignoreList":[]}
@@ -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,g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
18
18
  import React, { useCallback, useMemo } from "react";
19
19
  import styles from "./PdfViewerAnnotationLayer.module.css.js";
20
- function AnnotationItem({
21
- annotation,
22
- pageHeight,
23
- scale,
24
- onClick
25
- }) {
20
+ /** Convert a single PDF rect (bottom-left origin) to CSS positioning (top-left origin). */
21
+ function computeRectStyle(rect, pageHeight, scale, color) {
22
+ return {
23
+ left: rect.x * scale,
24
+ top: (pageHeight - rect.y - rect.height) * scale,
25
+ width: rect.width * scale,
26
+ height: rect.height * scale,
27
+ ...(color != null ? {
28
+ "--osdk-pdf-annotation-color": color
29
+ } : {})
30
+ };
31
+ }
32
+ function useAnnotationHandlers(annotation, onClick) {
26
33
  const handleClick = useCallback(() => {
27
34
  onClick?.(annotation);
28
35
  }, [onClick, annotation]);
@@ -32,18 +39,45 @@ function AnnotationItem({
32
39
  onClick?.(annotation);
33
40
  }
34
41
  }, [onClick, annotation]);
35
-
36
- // Convert PDF coordinates (bottom-left origin) to CSS (top-left origin)
37
- const style = useMemo(() => ({
38
- left: annotation.rect.x * scale,
39
- top: (pageHeight - annotation.rect.y - annotation.rect.height) * scale,
40
- width: annotation.rect.width * scale,
41
- height: annotation.rect.height * scale,
42
- ...(annotation.color != null ? {
43
- "--osdk-pdf-annotation-color": annotation.color
44
- } : {})
45
- }), [annotation, pageHeight, scale]);
42
+ return {
43
+ handleClick,
44
+ handleKeyDown
45
+ };
46
+ }
47
+ function AnnotationItem({
48
+ annotation,
49
+ pageHeight,
50
+ scale,
51
+ onClick
52
+ }) {
53
+ const {
54
+ handleClick,
55
+ handleKeyDown
56
+ } = useAnnotationHandlers(annotation, onClick);
46
57
  const className = classnames(styles.annotation, styles[annotation.type]);
58
+ const multiRects = annotation.rects;
59
+ const hasMultipleRects = multiRects != null && multiRects.length > 1;
60
+ const style = useMemo(() => computeRectStyle(annotation.rect, pageHeight, scale, annotation.color), [annotation, pageHeight, scale]);
61
+
62
+ // Multi-rect: render a group wrapper with one div per rect
63
+ if (hasMultipleRects) {
64
+ return /*#__PURE__*/React.createElement("div", {
65
+ className: styles.annotationGroup,
66
+ onClick: handleClick,
67
+ onKeyDown: handleKeyDown,
68
+ role: "button",
69
+ tabIndex: 0,
70
+ title: annotation.label,
71
+ "data-annotation-id": annotation.id
72
+ }, multiRects.map((rect, i) => /*#__PURE__*/React.createElement("div", {
73
+ key: i,
74
+ className: className,
75
+ style: computeRectStyle(rect, pageHeight, scale, annotation.color)
76
+ })));
77
+ }
78
+
79
+ // Single rect: existing behavior
80
+
47
81
  return /*#__PURE__*/React.createElement("div", {
48
82
  className: className,
49
83
  style: style,
@@ -55,6 +89,33 @@ function AnnotationItem({
55
89
  "data-annotation-id": annotation.id
56
90
  });
57
91
  }
92
+ function CustomAnnotationItem({
93
+ annotation,
94
+ pageHeight,
95
+ scale,
96
+ onClick
97
+ }) {
98
+ const {
99
+ handleClick,
100
+ handleKeyDown
101
+ } = useAnnotationHandlers(annotation, onClick);
102
+ const style = useMemo(() => computeRectStyle(annotation.rect, pageHeight, scale, undefined), [annotation, pageHeight, scale]);
103
+ const renderProps = useMemo(() => ({
104
+ annotation,
105
+ scale,
106
+ pageHeight
107
+ }), [annotation, scale, pageHeight]);
108
+ return /*#__PURE__*/React.createElement("div", {
109
+ className: styles.annotation,
110
+ style: style,
111
+ onClick: handleClick,
112
+ onKeyDown: handleKeyDown,
113
+ role: "button",
114
+ tabIndex: 0,
115
+ title: annotation.label,
116
+ "data-annotation-id": annotation.id
117
+ }, annotation.render(renderProps));
118
+ }
58
119
  export function PdfViewerAnnotationLayer({
59
120
  annotations,
60
121
  pageHeight,
@@ -63,7 +124,13 @@ export function PdfViewerAnnotationLayer({
63
124
  }) {
64
125
  return /*#__PURE__*/React.createElement("div", {
65
126
  className: styles.annotationLayer
66
- }, annotations.map(annotation => /*#__PURE__*/React.createElement(AnnotationItem, {
127
+ }, annotations.map(annotation => annotation.type === "custom" ? /*#__PURE__*/React.createElement(CustomAnnotationItem, {
128
+ key: annotation.id,
129
+ annotation: annotation,
130
+ pageHeight: pageHeight,
131
+ scale: scale,
132
+ onClick: onAnnotationClick
133
+ }) : /*#__PURE__*/React.createElement(AnnotationItem, {
67
134
  key: annotation.id,
68
135
  annotation: annotation,
69
136
  pageHeight: pageHeight,
@@ -1 +1 @@
1
- {"version":3,"file":"PdfViewerAnnotationLayer.js","names":["classnames","React","useCallback","useMemo","styles","AnnotationItem","annotation","pageHeight","scale","onClick","handleClick","handleKeyDown","e","key","preventDefault","style","left","rect","x","top","y","height","width","color","className","type","createElement","onKeyDown","role","tabIndex","title","label","id","PdfViewerAnnotationLayer","annotations","onAnnotationClick","annotationLayer","map"],"sources":["PdfViewerAnnotationLayer.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport classnames from \"classnames\";\nimport React, { useCallback, useMemo } from \"react\";\nimport type { PdfAnnotation } from \"../types.js\";\nimport styles from \"./PdfViewerAnnotationLayer.module.css\";\n\nexport interface PdfViewerAnnotationLayerProps {\n annotations: PdfAnnotation[];\n pageHeight: number;\n scale: number;\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n}\n\ninterface AnnotationItemProps {\n annotation: PdfAnnotation;\n pageHeight: number;\n scale: number;\n onClick?: (annotation: PdfAnnotation) => void;\n}\n\nfunction AnnotationItem({\n annotation,\n pageHeight,\n scale,\n onClick,\n}: AnnotationItemProps): React.ReactElement {\n const handleClick = useCallback(() => {\n onClick?.(annotation);\n }, [onClick, annotation]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n onClick?.(annotation);\n }\n },\n [onClick, annotation],\n );\n\n // Convert PDF coordinates (bottom-left origin) to CSS (top-left origin)\n const style = useMemo(\n () => ({\n left: annotation.rect.x * scale,\n top: (pageHeight - annotation.rect.y - annotation.rect.height) * scale,\n width: annotation.rect.width * scale,\n height: annotation.rect.height * scale,\n ...(annotation.color != null\n ? {\n \"--osdk-pdf-annotation-color\": annotation.color,\n } as React.CSSProperties\n : {}),\n }),\n [annotation, pageHeight, scale],\n );\n\n const className = classnames(\n styles.annotation,\n styles[annotation.type],\n );\n\n return (\n <div\n className={className}\n style={style}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n />\n );\n}\n\nexport function PdfViewerAnnotationLayer({\n annotations,\n pageHeight,\n scale,\n onAnnotationClick,\n}: PdfViewerAnnotationLayerProps): React.ReactElement {\n return (\n <div className={styles.annotationLayer}>\n {annotations.map((annotation) => (\n <AnnotationItem\n key={annotation.id}\n annotation={annotation}\n pageHeight={pageHeight}\n scale={scale}\n onClick={onAnnotationClick}\n />\n ))}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAEnD,OAAOC,MAAM,MAAM,uCAAuC;AAgB1D,SAASC,cAAcA,CAAC;EACtBC,UAAU;EACVC,UAAU;EACVC,KAAK;EACLC;AACmB,CAAC,EAAsB;EAC1C,MAAMC,WAAW,GAAGR,WAAW,CAAC,MAAM;IACpCO,OAAO,GAAGH,UAAU,CAAC;EACvB,CAAC,EAAE,CAACG,OAAO,EAAEH,UAAU,CAAC,CAAC;EAEzB,MAAMK,aAAa,GAAGT,WAAW,CAC9BU,CAAsB,IAAK;IAC1B,IAAIA,CAAC,CAACC,GA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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,IA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EAAEA,UAAW;IACvBV,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbU,OAAO,EAAE8B;EAAkB,CAC5B,CAEP,CACG,CAAC;AAEV","ignoreList":[]}
@@ -8,6 +8,24 @@
8
8
  z-index: 3;
9
9
  }
10
10
 
11
+ .annotationGroup {
12
+ position: absolute;
13
+ top: 0;
14
+ left: 0;
15
+ width: 100%;
16
+ height: 100%;
17
+ pointer-events: none;
18
+ }
19
+
20
+ .annotationGroup:focus-visible {
21
+ outline: var(--osdk-focus-outline);
22
+ outline-offset: var(--osdk-focus-visible-outline-offset);
23
+ }
24
+
25
+ .annotationGroup .annotation {
26
+ pointer-events: auto;
27
+ }
28
+
11
29
  .annotation {
12
30
  position: absolute;
13
31
  pointer-events: auto;
@@ -1,6 +1,7 @@
1
1
  // CSS Module proxy for PdfViewerAnnotationLayer.module.css
2
2
  const styles = {
3
3
  "annotationLayer": "PdfViewerAnnotationLayer-module__annotationLayer___mljRfBSQ",
4
+ "annotationGroup": "PdfViewerAnnotationLayer-module__annotationGroup___CiaFrKH5",
4
5
  "annotation": "PdfViewerAnnotationLayer-module__annotation___1dAkVbQ8",
5
6
  "highlight": "PdfViewerAnnotationLayer-module__highlight___uPiyo2kN",
6
7
  "underline": "PdfViewerAnnotationLayer-module__underline___-qCk9Jld",