@osdk/react-components 0.37.0 → 0.38.0-main-1b33456f25e1ced9c8ce17587cdd559d4337a247

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 (106) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/build/browser/markdown-renderer/MarkdownViewerMedia.js +2 -0
  3. package/build/browser/markdown-renderer/MarkdownViewerMedia.js.map +1 -1
  4. package/build/browser/object-table/hooks/useEditableTable.js +3 -0
  5. package/build/browser/object-table/hooks/useEditableTable.js.map +1 -1
  6. package/build/browser/pdf-viewer/components/PdfViewerContent.js.map +1 -1
  7. package/build/browser/pdf-viewer/hooks/usePdfDocument.js +39 -12
  8. package/build/browser/pdf-viewer/hooks/usePdfDocument.js.map +1 -1
  9. package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
  10. package/build/browser/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
  11. package/build/browser/pdf-viewer/types.js.map +1 -1
  12. package/build/browser/public/experimental/pdf-viewer.js.map +1 -1
  13. package/build/browser/util/UserAgent.js +1 -1
  14. package/build/browser/util/UserAgent.js.map +1 -1
  15. package/build/browser/xml-viewer/XmlViewer.js +3 -0
  16. package/build/browser/xml-viewer/XmlViewer.js.map +1 -1
  17. package/build/cjs/chunk-6KC2X46P.cjs +11 -0
  18. package/build/cjs/{chunk-XRI2RLG7.cjs.map → chunk-6KC2X46P.cjs.map} +1 -1
  19. package/build/cjs/{chunk-2TBIJGID.cjs → chunk-6MS4BCHK.cjs} +4 -4
  20. package/build/cjs/{chunk-2TBIJGID.cjs.map → chunk-6MS4BCHK.cjs.map} +1 -1
  21. package/build/cjs/chunk-73AY42MF.cjs +11 -0
  22. package/build/cjs/{chunk-YJX6FHRF.cjs.map → chunk-73AY42MF.cjs.map} +1 -1
  23. package/build/cjs/{chunk-BE226IHU.cjs → chunk-7EGCPMTN.cjs} +34 -14
  24. package/build/cjs/chunk-7EGCPMTN.cjs.map +1 -0
  25. package/build/cjs/{chunk-MVUTL2YO.cjs → chunk-BCIH6LUS.cjs} +3 -3
  26. package/build/cjs/chunk-BCIH6LUS.cjs.map +1 -0
  27. package/build/cjs/chunk-BCO5AJMH.cjs +11 -0
  28. package/build/cjs/{chunk-JHBFHACA.cjs.map → chunk-BCO5AJMH.cjs.map} +1 -1
  29. package/build/cjs/chunk-BMAZ4WZH.cjs +11 -0
  30. package/build/cjs/{chunk-R5FIVXEF.cjs.map → chunk-BMAZ4WZH.cjs.map} +1 -1
  31. package/build/cjs/{chunk-W2F62KMQ.cjs → chunk-EPBPOFKU.cjs} +4 -4
  32. package/build/cjs/{chunk-W2F62KMQ.cjs.map → chunk-EPBPOFKU.cjs.map} +1 -1
  33. package/build/cjs/{chunk-3SLAC2Z5.cjs → chunk-GOOED4XT.cjs} +4 -4
  34. package/build/cjs/{chunk-3SLAC2Z5.cjs.map → chunk-GOOED4XT.cjs.map} +1 -1
  35. package/build/cjs/{chunk-4R4NE4YK.cjs → chunk-IYUG6BG3.cjs} +4 -4
  36. package/build/cjs/{chunk-4R4NE4YK.cjs.map → chunk-IYUG6BG3.cjs.map} +1 -1
  37. package/build/cjs/{chunk-L5EO3NSA.cjs → chunk-NQ4K4PFQ.cjs} +4 -4
  38. package/build/cjs/{chunk-L5EO3NSA.cjs.map → chunk-NQ4K4PFQ.cjs.map} +1 -1
  39. package/build/cjs/{chunk-G4SRFNQ3.cjs → chunk-O2QJUEG2.cjs} +24 -24
  40. package/build/cjs/{chunk-G4SRFNQ3.cjs.map → chunk-O2QJUEG2.cjs.map} +1 -1
  41. package/build/cjs/{chunk-IYJOHKJE.cjs → chunk-P55Q2MCT.cjs} +2 -2
  42. package/build/cjs/{chunk-IYJOHKJE.cjs.map → chunk-P55Q2MCT.cjs.map} +1 -1
  43. package/build/cjs/chunk-R3RLWZKE.cjs +11 -0
  44. package/build/cjs/{chunk-INRJWUVA.cjs.map → chunk-R3RLWZKE.cjs.map} +1 -1
  45. package/build/cjs/{chunk-GYTR4A74.cjs → chunk-RUU6HGBK.cjs} +11 -11
  46. package/build/cjs/{chunk-GYTR4A74.cjs.map → chunk-RUU6HGBK.cjs.map} +1 -1
  47. package/build/cjs/{chunk-OUJQJQ7N.cjs → chunk-RVZE7LPI.cjs} +2 -2
  48. package/build/cjs/{chunk-OUJQJQ7N.cjs.map → chunk-RVZE7LPI.cjs.map} +1 -1
  49. package/build/cjs/chunk-X2TAMNMH.cjs +11 -0
  50. package/build/cjs/{chunk-VIOZG6Z7.cjs.map → chunk-X2TAMNMH.cjs.map} +1 -1
  51. package/build/cjs/public/experimental/action-form.cjs +4 -4
  52. package/build/cjs/public/experimental/cbac-picker.cjs +11 -11
  53. package/build/cjs/public/experimental/document-viewer.cjs +7 -7
  54. package/build/cjs/public/experimental/document-viewer.d.cts +1 -1
  55. package/build/cjs/public/experimental/email-viewer.cjs +3 -3
  56. package/build/cjs/public/experimental/excel-viewer.cjs +3 -3
  57. package/build/cjs/public/experimental/filter-list.cjs +15 -15
  58. package/build/cjs/public/experimental/image-viewer.cjs +3 -3
  59. package/build/cjs/public/experimental/markdown-renderer.cjs +5 -5
  60. package/build/cjs/public/experimental/object-table.cjs +8 -8
  61. package/build/cjs/public/experimental/pdf-viewer.cjs +25 -25
  62. package/build/cjs/public/experimental/pdf-viewer.d.cts +8 -8
  63. package/build/cjs/public/experimental/tiff-renderer.cjs +3 -3
  64. package/build/cjs/public/experimental/video-viewer.cjs +3 -3
  65. package/build/cjs/public/experimental/xml-viewer.cjs +5 -5
  66. package/build/cjs/public/experimental.cjs +80 -80
  67. package/build/cjs/public/experimental.d.cts +1 -1
  68. package/build/cjs/{types-cSnAM4mt.d.cts → types-DDeX79uW.d.cts} +14 -5
  69. package/build/esm/markdown-renderer/MarkdownViewerMedia.js +2 -0
  70. package/build/esm/markdown-renderer/MarkdownViewerMedia.js.map +1 -1
  71. package/build/esm/object-table/hooks/useEditableTable.js +3 -0
  72. package/build/esm/object-table/hooks/useEditableTable.js.map +1 -1
  73. package/build/esm/pdf-viewer/components/PdfViewerContent.js.map +1 -1
  74. package/build/esm/pdf-viewer/hooks/usePdfDocument.js +39 -12
  75. package/build/esm/pdf-viewer/hooks/usePdfDocument.js.map +1 -1
  76. package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
  77. package/build/esm/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
  78. package/build/esm/pdf-viewer/types.js.map +1 -1
  79. package/build/esm/public/experimental/pdf-viewer.js.map +1 -1
  80. package/build/esm/util/UserAgent.js +1 -1
  81. package/build/esm/util/UserAgent.js.map +1 -1
  82. package/build/esm/xml-viewer/XmlViewer.js +3 -0
  83. package/build/esm/xml-viewer/XmlViewer.js.map +1 -1
  84. package/build/types/markdown-renderer/MarkdownViewerMedia.d.ts.map +1 -1
  85. package/build/types/pdf-viewer/components/PdfViewerContent.d.ts +3 -3
  86. package/build/types/pdf-viewer/components/PdfViewerContent.d.ts.map +1 -1
  87. package/build/types/pdf-viewer/hooks/usePdfDocument.d.ts +2 -1
  88. package/build/types/pdf-viewer/hooks/usePdfDocument.d.ts.map +1 -1
  89. package/build/types/pdf-viewer/hooks/usePdfViewerCore.d.ts +3 -2
  90. package/build/types/pdf-viewer/hooks/usePdfViewerCore.d.ts.map +1 -1
  91. package/build/types/pdf-viewer/hooks/usePdfViewerState.d.ts.map +1 -1
  92. package/build/types/pdf-viewer/types.d.ts +13 -4
  93. package/build/types/pdf-viewer/types.d.ts.map +1 -1
  94. package/build/types/public/experimental/pdf-viewer.d.ts +1 -1
  95. package/build/types/public/experimental/pdf-viewer.d.ts.map +1 -1
  96. package/build/types/xml-viewer/XmlViewer.d.ts.map +1 -1
  97. package/docs/PdfViewer.md +15 -12
  98. package/package.json +8 -8
  99. package/build/cjs/chunk-BE226IHU.cjs.map +0 -1
  100. package/build/cjs/chunk-INRJWUVA.cjs +0 -11
  101. package/build/cjs/chunk-JHBFHACA.cjs +0 -11
  102. package/build/cjs/chunk-MVUTL2YO.cjs.map +0 -1
  103. package/build/cjs/chunk-R5FIVXEF.cjs +0 -11
  104. package/build/cjs/chunk-VIOZG6Z7.cjs +0 -11
  105. package/build/cjs/chunk-XRI2RLG7.cjs +0 -11
  106. package/build/cjs/chunk-YJX6FHRF.cjs +0 -11
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @osdk/react-components
2
2
 
3
+ ## 0.38.0-main-1b33456f25e1ced9c8ce17587cdd559d4337a247
4
+
5
+ ### Minor Changes
6
+
7
+ - cb30380: BasePdfViewer now accepts a Uint8Array or Blob as its `src`, in addition to the existing URL string and ArrayBuffer inputs.
8
+
9
+ ### Patch Changes
10
+
11
+ - 1b33456: Enable the require-await lint rule: drop the redundant `async` keyword from test callbacks that never await, and keep intentionally-async (Promise-returning) functions as-is
12
+ - Updated dependencies [1b33456]
13
+ - @osdk/aip-core@0.8.1-main-1b33456f25e1ced9c8ce17587cdd559d4337a247
14
+ - @osdk/client@2.43.1-main-1b33456f25e1ced9c8ce17587cdd559d4337a247
15
+ - @osdk/react@2.43.1-main-1b33456f25e1ced9c8ce17587cdd559d4337a247
16
+ - @osdk/api@2.43.1-main-1b33456f25e1ced9c8ce17587cdd559d4337a247
17
+
3
18
  ## 0.37.0
4
19
 
5
20
  ### Minor Changes
@@ -21,6 +21,8 @@ import React from "react";
21
21
  import { useMediaContents } from "../shared/hooks/useMediaContents.js";
22
22
  import { MarkdownRenderer } from "./MarkdownRenderer.js";
23
23
  import styles from "./MarkdownRenderer.module.css.js";
24
+ // TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.
25
+ // oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed
24
26
  const transformToText = async response => {
25
27
  return response.text();
26
28
  };
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownViewerMedia.js","names":["Error","ErrorIcon","Spin","classnames","React","useMediaContents","MarkdownRenderer","styles","transformToText","response","text","MarkdownViewerMedia","media","markdownRendererProps","data","content","loading","error","rootClassName","container","className","createElement","loadingContainer","spinnerIcon","errorContainer","errorIcon","message","_extends"],"sources":["MarkdownViewerMedia.tsx"],"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 { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport type { Media } from \"@osdk/api\";\nimport classnames from \"classnames\";\nimport React from \"react\";\n\nimport { useMediaContents } from \"../shared/hooks/useMediaContents.js\";\nimport { MarkdownRenderer } from \"./MarkdownRenderer.js\";\nimport type { MarkdownRendererProps } from \"./MarkdownRenderer.js\";\n\nimport styles from \"./MarkdownRenderer.module.css\";\n\nexport interface MarkdownViewerMediaProps extends Omit<\n MarkdownRendererProps,\n \"content\"\n> {\n /** The Media object to fetch markdown contents from */\n media: Media;\n}\n\nconst transformToText = async (response: Response): Promise<string> => {\n return response.text();\n};\n\nexport function MarkdownViewerMedia({\n media,\n ...markdownRendererProps\n}: MarkdownViewerMediaProps): React.ReactElement {\n const {\n data: content,\n loading,\n error,\n } = useMediaContents(media, transformToText);\n\n const rootClassName = classnames(\n styles.container,\n markdownRendererProps.className\n );\n\n return (\n <div className={rootClassName}>\n {loading && (\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n )}\n {error != null && (\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load document: {error.message}\n </div>\n )}\n {content != null && (\n <MarkdownRenderer content={content} {...markdownRendererProps} />\n )}\n </div>\n );\n}\n"],"mappings":";AA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AgB,EAAAqB,QAAA;IAACZ,OAAO,EAAEA;EAAQ,GAAKF,qBAAqB,CAAG,CAE/D,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"MarkdownViewerMedia.js","names":["Error","ErrorIcon","Spin","classnames","React","useMediaContents","MarkdownRenderer","styles","transformToText","response","text","MarkdownViewerMedia","media","markdownRendererProps","data","content","loading","error","rootClassName","container","className","createElement","loadingContainer","spinnerIcon","errorContainer","errorIcon","message","_extends"],"sources":["MarkdownViewerMedia.tsx"],"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 { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport type { Media } from \"@osdk/api\";\nimport classnames from \"classnames\";\nimport React from \"react\";\n\nimport { useMediaContents } from \"../shared/hooks/useMediaContents.js\";\nimport { MarkdownRenderer } from \"./MarkdownRenderer.js\";\nimport type { MarkdownRendererProps } from \"./MarkdownRenderer.js\";\n\nimport styles from \"./MarkdownRenderer.module.css\";\n\nexport interface MarkdownViewerMediaProps extends Omit<\n MarkdownRendererProps,\n \"content\"\n> {\n /** The Media object to fetch markdown contents from */\n media: Media;\n}\n\n// TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.\n// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\nconst transformToText = async (response: Response): Promise<string> => {\n return response.text();\n};\n\nexport function MarkdownViewerMedia({\n media,\n ...markdownRendererProps\n}: MarkdownViewerMediaProps): React.ReactElement {\n const {\n data: content,\n loading,\n error,\n } = useMediaContents(media, transformToText);\n\n const rootClassName = classnames(\n styles.container,\n markdownRendererProps.className\n );\n\n return (\n <div className={rootClassName}>\n {loading && (\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n )}\n {error != null && (\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load document: {error.message}\n </div>\n )}\n {content != null && (\n <MarkdownRenderer content={content} {...markdownRendererProps} />\n )}\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;AAE7D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,gBAAgB,QAAQ,qCAAqC;AACtE,SAASC,gBAAgB,QAAQ,uBAAuB;AAGxD,OAAOC,MAAM,MAAM,+BAA+B;AAUlD;AACA;AACA,MAAMC,eAAe,GAAG,MAAOC,QAAkB,IAAsB;EACrE,OAAOA,QAAQ,CAACC,IAAI,CAAC,CAAC;AACxB,CAAC;AAED,OAAO,SAASC,mBAAmBA,CAAC;EAClCC,KAAK;EACL,GAAGC;AACqB,CAAC,EAAsB;EAC/C,MAAM;IACJC,IAAI,EAAEC,OAAO;IACbC,OAAO;IACPC;EACF,CAAC,GAAGZ,gBAAgB,CAACO,KAAK,EAAEJ,eAAe,CAAC;EAE5C,MAAMU,aAAa,GAAGf,UAAU,CAC9BI,MAAM,CAACY,SAAS,EAChBN,qBAAqB,CAACO,SACxB,CAAC;EAED,oBACEhB,KAAA,CAAAiB,aAAA;IAAKD,SAAS,EAAEF;EAAc,GAC3BF,OAAO,iBACNZ,KAAA,CAAAiB,aAAA;IAAKD,SAAS,EAAEb,MAAM,CAACe;EAAiB,gBACtClB,KAAA,CAAAiB,aAAA,CAACnB,IAAI;IAACkB,SAAS,EAAEb,MAAM,CAACgB;EAAY,CAAE,CAAC,iBAEpC,CACN,EACAN,KAAK,IAAI,IAAI,iBACZb,KAAA,CAAAiB,aAAA;IAAKD,SAAS,EAAEb,MAAM,CAACiB;EAAe,gBACpCpB,KAAA,CAAAiB,aAAA,CAACpB,SAAS;IAACmB,SAAS,EAAEb,MAAM,CAACkB;EAAU,CAAE,CAAC,6BACjB,EAACR,KAAK,CAACS,OAC7B,CACN,EACAX,OAAO,IAAI,IAAI,iBACdX,KAAA,CAAAiB,aAAA,CAACf,gBAAgB,EAAAqB,QAAA;IAACZ,OAAO,EAAEA;EAAQ,GAAKF,qBAAqB,CAAG,CAE/D,CAAC;AAEV","ignoreList":[]}
@@ -56,6 +56,9 @@ export function useEditableTable({
56
56
  setCellEdits({});
57
57
  setValidationErrors(new Map());
58
58
  }, []);
59
+
60
+ // TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.
61
+ // oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed
59
62
  const handleSubmitEdits = useCallback(async () => {
60
63
  const edits = Object.values(cellEdits);
61
64
  return onSubmitEdits ? onSubmitEdits(edits) : false;
@@ -1 +1 @@
1
- {"version":3,"file":"useEditableTable.js","names":["useCallback","useState","cellValuesEqual","useEditableTable","editMode","onCellValueChanged","onSubmitEdits","isActive","setActive","cellEdits","setCellEdits","validationErrors","setValidationErrors","Map","clearCellValidationError","cellId","prev","newErrors","delete","handleCellEdit","info","newValue","oldValue","_","rest","clearEdits","handleSubmitEdits","edits","Object","values","onCellValidationError","error","set","editModeState","type","onCellEdit","undefined"],"sources":["useEditableTable.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { useCallback, useState } from \"react\";\n\nimport type { ObjectTableProps } from \"../ObjectTableApi.js\";\nimport { cellValuesEqual } from \"../utils/editableUtils.js\";\nimport type {\n CellEditInfo,\n EditableConfig,\n EditModeState,\n} from \"../utils/types.js\";\n\nexport interface UseEditableTableProps<\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 editMode?: \"always\" | \"manual\";\n\n onCellValueChanged?: ObjectTableProps<\n Q,\n RDPs,\n FunctionColumns\n >[\"onCellValueChanged\"];\n\n onSubmitEdits?: ObjectTableProps<Q, RDPs, FunctionColumns>[\"onSubmitEdits\"];\n}\n\nexport function useEditableTable<\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 editMode = \"manual\",\n onCellValueChanged,\n onSubmitEdits,\n}: UseEditableTableProps<Q, RDPs, FunctionColumns>): EditableConfig<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n> {\n const [isActive, setActive] = useState<boolean>(editMode === \"always\");\n const [cellEdits, setCellEdits] = useState<\n Record<\n string,\n CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >\n >\n >({});\n const [validationErrors, setValidationErrors] = useState<Map<string, string>>(\n new Map()\n );\n\n const clearCellValidationError = useCallback((cellId: string) => {\n setValidationErrors((prev) => {\n const newErrors = new Map(prev);\n newErrors.delete(cellId);\n return newErrors;\n });\n }, []);\n\n const handleCellEdit = useCallback(\n (\n cellId: string,\n info: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >\n ) => {\n // If value is changed back to original, remove it from edits. null\n // and undefined are treated as the same empty state so clearing a\n // never-set cell doesn't leave a phantom \"edited\" indicator. \"\" stays\n // a distinct value.\n if (cellValuesEqual(info.newValue, info.oldValue)) {\n setCellEdits((prev) => {\n const { [cellId]: _, ...rest } = prev;\n return rest;\n });\n } else {\n setCellEdits((prev) => ({\n ...prev,\n [cellId]: info,\n }));\n }\n\n onCellValueChanged?.(info);\n },\n [onCellValueChanged]\n );\n\n const clearEdits = useCallback(() => {\n setCellEdits({});\n setValidationErrors(new Map());\n }, []);\n\n const handleSubmitEdits = useCallback(async () => {\n const edits = Object.values(cellEdits);\n return onSubmitEdits ? onSubmitEdits(edits) : false;\n }, [cellEdits, onSubmitEdits]);\n\n const onCellValidationError = useCallback((cellId: string, error: string) => {\n setValidationErrors((prev) => {\n const newErrors = new Map(prev);\n newErrors.set(cellId, error);\n return newErrors;\n });\n }, []);\n\n const editModeState: EditModeState =\n editMode === \"always\"\n ? { type: \"always\", isActive: true }\n : { type: \"manual\", isActive, setActive };\n\n return {\n cellEdits,\n onCellEdit: handleCellEdit,\n onSubmitEdits: onSubmitEdits ? handleSubmitEdits : undefined,\n clearEdits,\n editModeState,\n onCellValidationError,\n validationErrors,\n clearCellValidationError,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAG7C,SAASC,eAAe,QAAQ,2BAA2B;AA0B3D,OAAO,SAASC,gBAAgBA,CAO9B;EACAC,QAAQ,GAAG,QAAQ;EACnBC,kBAAkB;EAClBC;AAC+C,CAAC,EAGhD;EACA,M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AAiB,GAAG1B,WAAW,CAAC,YAAY;IAChD,MAAM2B,KAAK,GAAGC,MAAM,CAACC,MAAM,CAACpB,SAAS,CAAC;IACtC,OAAOH,aAAa,GAAGA,aAAa,CAACqB,KAAK,CAAC,GAAG,KAAK;EACrD,CAAC,EAAE,CAAClB,SAAS,EAAEH,aAAa,CAAC,CAAC;EAE9B,MAAMwB,qBAAqB,GAAG9B,WAAW,CAAC,CAACe,MAAc,EAAEgB,KAAa,KAAK;IAC3EnB,mBAAmB,CAAEI,IAAI,IAAK;MAC5B,MAAMC,SAAS,GAAG,IAAIJ,GAAG,CAACG,IAAI,CAAC;MAC/BC,SAAS,CAACe,GAAG,CAACjB,MAAM,EAAEgB,KAAK,CAAC;MAC5B,OAAOd,SAAS;IAClB,CAAC,CAAC;EACJ,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMgB,aAA4B,GAChC7B,QAAQ,KAAK,QAAQ,GACjB;IAAE8B,IAAI,EAAE,QAAQ;IAAE3B,QAAQ,EAAE;EAAK,CAAC,GAClC;IAAE2B,IAAI,EAAE,QAAQ;IAAE3B,QAAQ;IAAEC;EAAU,CAAC;EAE7C,OAAO;IACLC,SAAS;IACT0B,UAAU,EAAEhB,cAAc;IAC1Bb,aAAa,EAAEA,aAAa,GAAGoB,iBAAiB,GAAGU,SAAS;IAC5DX,UAAU;IACVQ,aAAa;IACbH,qBAAqB;IACrBnB,gBAAgB;IAChBG;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useEditableTable.js","names":["useCallback","useState","cellValuesEqual","useEditableTable","editMode","onCellValueChanged","onSubmitEdits","isActive","setActive","cellEdits","setCellEdits","validationErrors","setValidationErrors","Map","clearCellValidationError","cellId","prev","newErrors","delete","handleCellEdit","info","newValue","oldValue","_","rest","clearEdits","handleSubmitEdits","edits","Object","values","onCellValidationError","error","set","editModeState","type","onCellEdit","undefined"],"sources":["useEditableTable.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { useCallback, useState } from \"react\";\n\nimport type { ObjectTableProps } from \"../ObjectTableApi.js\";\nimport { cellValuesEqual } from \"../utils/editableUtils.js\";\nimport type {\n CellEditInfo,\n EditableConfig,\n EditModeState,\n} from \"../utils/types.js\";\n\nexport interface UseEditableTableProps<\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 editMode?: \"always\" | \"manual\";\n\n onCellValueChanged?: ObjectTableProps<\n Q,\n RDPs,\n FunctionColumns\n >[\"onCellValueChanged\"];\n\n onSubmitEdits?: ObjectTableProps<Q, RDPs, FunctionColumns>[\"onSubmitEdits\"];\n}\n\nexport function useEditableTable<\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 editMode = \"manual\",\n onCellValueChanged,\n onSubmitEdits,\n}: UseEditableTableProps<Q, RDPs, FunctionColumns>): EditableConfig<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n> {\n const [isActive, setActive] = useState<boolean>(editMode === \"always\");\n const [cellEdits, setCellEdits] = useState<\n Record<\n string,\n CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >\n >\n >({});\n const [validationErrors, setValidationErrors] = useState<Map<string, string>>(\n new Map()\n );\n\n const clearCellValidationError = useCallback((cellId: string) => {\n setValidationErrors((prev) => {\n const newErrors = new Map(prev);\n newErrors.delete(cellId);\n return newErrors;\n });\n }, []);\n\n const handleCellEdit = useCallback(\n (\n cellId: string,\n info: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >\n ) => {\n // If value is changed back to original, remove it from edits. null\n // and undefined are treated as the same empty state so clearing a\n // never-set cell doesn't leave a phantom \"edited\" indicator. \"\" stays\n // a distinct value.\n if (cellValuesEqual(info.newValue, info.oldValue)) {\n setCellEdits((prev) => {\n const { [cellId]: _, ...rest } = prev;\n return rest;\n });\n } else {\n setCellEdits((prev) => ({\n ...prev,\n [cellId]: info,\n }));\n }\n\n onCellValueChanged?.(info);\n },\n [onCellValueChanged]\n );\n\n const clearEdits = useCallback(() => {\n setCellEdits({});\n setValidationErrors(new Map());\n }, []);\n\n // TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.\n // oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\n const handleSubmitEdits = useCallback(async () => {\n const edits = Object.values(cellEdits);\n return onSubmitEdits ? onSubmitEdits(edits) : false;\n }, [cellEdits, onSubmitEdits]);\n\n const onCellValidationError = useCallback((cellId: string, error: string) => {\n setValidationErrors((prev) => {\n const newErrors = new Map(prev);\n newErrors.set(cellId, error);\n return newErrors;\n });\n }, []);\n\n const editModeState: EditModeState =\n editMode === \"always\"\n ? { type: \"always\", isActive: true }\n : { type: \"manual\", isActive, setActive };\n\n return {\n cellEdits,\n onCellEdit: handleCellEdit,\n onSubmitEdits: onSubmitEdits ? handleSubmitEdits : undefined,\n clearEdits,\n editModeState,\n onCellValidationError,\n validationErrors,\n clearCellValidationError,\n };\n}\n"],"mappings":"AA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":["Error","ErrorIcon","Spin","classnames","React","useEffect","useRef","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfViewerCore","PdfAnnotationOverlay","styles","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"],"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\";\n\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { useEffect, useRef } from \"react\";\n\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 type { PdfAnnotation, PdfFormFieldValue } from \"../types.js\";\nimport { PdfAnnotationOverlay } from \"./PdfAnnotationOverlay.js\";\n\nimport styles from \"../PdfViewer.module.css\";\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(\n function notifyPageChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onPageChangeRef.current?.(viewer.currentPage);\n },\n [viewer.currentPage]\n );\n\n useEffect(\n function notifyScaleChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onScaleChangeRef.current?.(viewer.scale);\n },\n [viewer.scale]\n );\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 =\n annotationsByPage[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return (\n <PdfAnnotationOverlay\n key={target.pageNumber}\n target={target}\n annotations={pageAnnotations}\n onAnnotationClick={onAnnotationClick}\n />\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;AAEnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEhD,SAASC,sBAAsB,QAAQ,iBAAiB;AACxD,SAASC,uBAAuB,QAAQ,qCAAqC;AAC7E,SAASC,gBAAgB,QAAQ,8BAA8B;AAC/D,SAASC,gBAAgB,QAAQ,8BAA8B;AAE/D,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE,OAAOC,MAAM,MAAM,yBAAyB;AAyB5C,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,GAAG;EACHC,WA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CAAAoC,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,GACnB5B,iBAAiB,CAAC2B,MAAM,CAACE,UAAU,CAAC,IAAIjD,sBAAsB;IAChE,IAAIgD,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBACErD,KAAA,CAAAoC,aAAA,CAAC7B,oBAAoB;MACnB+C,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvBF,MAAM,EAAEA,MAAO;MACfvC,WAAW,EAAEwC,eAAgB;MAC7BvC,iBAAiB,EAAEA;IAAkB,CACtC,CAAC;EAEN,CAAC,CACE,CACF,CACF,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"PdfViewerContent.js","names":["Error","ErrorIcon","Spin","classnames","React","useEffect","useRef","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfViewerCore","PdfAnnotationOverlay","styles","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"],"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\";\n\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { useEffect, useRef } from \"react\";\n\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 type { PdfAnnotation, PdfFormFieldValue, PdfSource } from \"../types.js\";\nimport { PdfAnnotationOverlay } from \"./PdfAnnotationOverlay.js\";\n\nimport styles from \"../PdfViewer.module.css\";\n\nexport interface PdfViewerContentProps {\n /** PDF source — URL string, ArrayBuffer, Uint8Array, or Blob */\n src: PdfSource;\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(\n function notifyPageChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onPageChangeRef.current?.(viewer.currentPage);\n },\n [viewer.currentPage]\n );\n\n useEffect(\n function notifyScaleChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onScaleChangeRef.current?.(viewer.scale);\n },\n [viewer.scale]\n );\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 =\n annotationsByPage[target.pageNumber] ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return (\n <PdfAnnotationOverlay\n key={target.pageNumber}\n target={target}\n annotations={pageAnnotations}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Url = new URL("pdfjs-dist/build/pdf.worker.min.mjs", import.meta.url);
19
19
  import { useEffect, useState } from "react";
20
+ /**
21
+ * Resolve a {@link PdfSource} to pdfjs `getDocument` parameters.
22
+ *
23
+ * A Blob is read into an ArrayBuffer first; URLs and in-memory bytes
24
+ * (ArrayBuffer/Uint8Array) resolve immediately. Always returns a promise so
25
+ * callers have a single code path regardless of source type.
26
+ */
27
+ function toDocumentParams(src) {
28
+ if (src instanceof Blob) {
29
+ return src.arrayBuffer().then(data => ({
30
+ data
31
+ }));
32
+ }
33
+ return Promise.resolve(typeof src === "string" ? {
34
+ url: src
35
+ } : {
36
+ data: src
37
+ });
38
+ }
20
39
  const pdfWorker = {
21
40
  workerInitialized: false,
22
41
  ensureWorker() {
@@ -33,19 +52,27 @@ export function usePdfDocument(src) {
33
52
  pdfWorker.ensureWorker();
34
53
  setLoading(true);
35
54
  setError(undefined);
36
- const loadingTask = getDocument(typeof src === "string" ? {
37
- url: src
38
- } : {
39
- data: src
40
- });
41
55
  let cancelled = false;
42
- loadingTask.promise.then(pdf => {
43
- if (!cancelled) {
44
- setDocument(pdf);
45
- setNumPages(pdf.numPages);
46
- setLoading(false);
56
+ let loadingTask;
57
+ const startLoad = params => {
58
+ if (cancelled) {
59
+ return;
47
60
  }
48
- }, err => {
61
+ loadingTask = getDocument(params);
62
+ loadingTask.promise.then(pdf => {
63
+ if (!cancelled) {
64
+ setDocument(pdf);
65
+ setNumPages(pdf.numPages);
66
+ setLoading(false);
67
+ }
68
+ }, err => {
69
+ if (!cancelled) {
70
+ setError(err instanceof Error ? err : new Error(String(err)));
71
+ setLoading(false);
72
+ }
73
+ });
74
+ };
75
+ toDocumentParams(src).then(startLoad, err => {
49
76
  if (!cancelled) {
50
77
  setError(err instanceof Error ? err : new Error(String(err)));
51
78
  setLoading(false);
@@ -53,7 +80,7 @@ export function usePdfDocument(src) {
53
80
  });
54
81
  return () => {
55
82
  cancelled = true;
56
- void loadingTask.destroy();
83
+ void loadingTask?.destroy();
57
84
  };
58
85
  }, [src]);
59
86
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"usePdfDocument.js","names":["getDocument","GlobalWorkerOptions","pdfWorkerUrl","URL","import","meta","url","useEffect","useState","pdfWorker","workerInitialized","ensureWorker","workerSrc","href","usePdfDocument","src","document","setDocument","undefined","numPages","setNumPages","loading","setLoading","error","setError","loadingTask","data","cancelled","promise","then","pdf","err","Error","String","destroy"],"sources":["usePdfDocument.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport { getDocument, GlobalWorkerOptions } from \"pdfjs-dist\";\nconst pdfWorkerUrl = new URL(\n \"pdfjs-dist/build/pdf.worker.min.mjs\",\n import.meta.url\n);\nimport { useEffect, useState } from \"react\";\n\nconst pdfWorker = {\n workerInitialized: false,\n ensureWorker() {\n GlobalWorkerOptions.workerSrc = pdfWorkerUrl.href;\n this.workerInitialized = true;\n },\n};\n\ninterface UsePdfDocumentResult {\n document: PDFDocumentProxy | undefined;\n numPages: number;\n loading: boolean;\n error: Error | undefined;\n}\n\nexport function usePdfDocument(\n src: string | ArrayBuffer\n): UsePdfDocumentResult {\n const [document, setDocument] = useState<PDFDocumentProxy | undefined>(\n undefined\n );\n const [numPages, setNumPages] = useState(0);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n useEffect(\n function loadPdfDocument() {\n pdfWorker.ensureWorker();\n setLoading(true);\n setError(undefined);\n\n const loadingTask = getDocument(\n typeof src === \"string\" ? { url: src } : { data: src }\n );\n\n let cancelled = false;\n\n loadingTask.promise.then(\n (pdf) => {\n if (!cancelled) {\n setDocument(pdf);\n setNumPages(pdf.numPages);\n setLoading(false);\n }\n },\n (err: unknown) => {\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setLoading(false);\n }\n }\n );\n\n return () => {\n cancelled = true;\n void loadingTask.destroy();\n };\n },\n [src]\n );\n\n return { document, numPages, loading, error };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,WAAW,EAAEC,mBAAmB,QAAQ,YAAY;AAC7D,MAAMC,YAAY,GAAG,IAAIC,GAAG,CAC1B,qCAAqC,EACrCC,MAAM,CAACC,IAAI,CAACC,GACd,CAAC;AACD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,MAAMC,SAAS,GAAG;EAChBC,iBAAiB,EAAE,KAAK;EACxBC,YAAYA,CAAA,EAAG;IACbV,mBAAmB,CAACW,SAAS,GAAGV,YAAY,CAACW,IAAI;IACjD,IAAI,CAACH,iBAAiB,GAAG,IAAI;EAC/B;AACF,CAAC;AASD,OAAO,SAASI,cAAcA,CAC5BC,GAAyB,EACH;EACtB,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGT,QAAQ,CACtCU,SACF,CAAC;EACD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGZ,QAAQ,CAAC,CAAC,CAAC;EAC3C,MAAM,CAACa,OAAO,EAAEC,UAAU,CAAC,GAAGd,QAAQ,CAAC,IAAI,CAAC;EAC5C,MAAM,CAACe,KAAK,EAAEC,QAAQ,CAAC,GAAGhB,QAAQ,CAAoBU,SAAS,CAAC;EAEhEX,SAAS,CACP,YAA2B;IACzBE,SAAS,CAACE,YAAY,CAAC,CAAC;IACxBW,UAAU,CAAC,IAAI,CAAC;IAChBE,QAAQ,CAACN,SAAS,CAAC;IAEnB,MAAMO,WAAW,GAAGzB,WAAW,CAC7B,OAAOe,GAAG,KAAK,QAAQ,GAAG;MAAET,GAAG,EAAES;IAAI,CAAC,GAAG;MAAEW,IAAI,EAAEX;IAAI,CACvD,CAAC;IAED,IAAIY,SAAS,GAAG,KAAK;IAErBF,WAAW,CAACG,OAAO,CAACC,IAAI,CACrBC,GAAG,IAAK;MACP,IAAI,CAACH,SAAS,EAAE;QACdV,WAAW,CAACa,GAAG,CAAC;QAChBV,WAAW,CAACU,GAAG,CAACX,QAAQ,CAAC;QACzBG,UAAU,CAAC,KAAK,CAAC;MACnB;IACF,CAAC,EACAS,GAAY,IAAK;MAChB,IAAI,CAACJ,SAAS,EAAE;QACdH,QAAQ,CAACO,GAAG,YAAYC,KAAK,GAAGD,GAAG,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,GAAG,CAAC,CAAC,CAAC;QAC7DT,UAAU,CAAC,KAAK,CAAC;MACnB;IACF,CACF,CAAC;IAED,OAAO,MAAM;MACXK,SAAS,GAAG,IAAI;MAChB,KAAKF,WAAW,CAACS,OAAO,CAAC,CAAC;IAC5B,CAAC;EACH,CAAC,EACD,CAACnB,GAAG,CACN,CAAC;EAED,OAAO;IAAEC,QAAQ;IAAEG,QAAQ;IAAEE,OAAO;IAAEE;EAAM,CAAC;AAC/C","ignoreList":[]}
1
+ {"version":3,"file":"usePdfDocument.js","names":["getDocument","GlobalWorkerOptions","pdfWorkerUrl","URL","import","meta","url","useEffect","useState","toDocumentParams","src","Blob","arrayBuffer","then","data","Promise","resolve","pdfWorker","workerInitialized","ensureWorker","workerSrc","href","usePdfDocument","document","setDocument","undefined","numPages","setNumPages","loading","setLoading","error","setError","cancelled","loadingTask","startLoad","params","promise","pdf","err","Error","String","destroy"],"sources":["usePdfDocument.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport { getDocument, GlobalWorkerOptions } from \"pdfjs-dist\";\nconst pdfWorkerUrl = new URL(\n \"pdfjs-dist/build/pdf.worker.min.mjs\",\n import.meta.url\n);\nimport { useEffect, useState } from \"react\";\n\nimport type { PdfSource } from \"../types.js\";\n\ntype GetDocumentParams = Parameters<typeof getDocument>[0];\n\n/**\n * Resolve a {@link PdfSource} to pdfjs `getDocument` parameters.\n *\n * A Blob is read into an ArrayBuffer first; URLs and in-memory bytes\n * (ArrayBuffer/Uint8Array) resolve immediately. Always returns a promise so\n * callers have a single code path regardless of source type.\n */\nfunction toDocumentParams(src: PdfSource): Promise<GetDocumentParams> {\n if (src instanceof Blob) {\n return src.arrayBuffer().then((data) => ({ data }));\n }\n return Promise.resolve(\n typeof src === \"string\" ? { url: src } : { data: src }\n );\n}\n\nconst pdfWorker = {\n workerInitialized: false,\n ensureWorker() {\n GlobalWorkerOptions.workerSrc = pdfWorkerUrl.href;\n this.workerInitialized = true;\n },\n};\n\ninterface UsePdfDocumentResult {\n document: PDFDocumentProxy | undefined;\n numPages: number;\n loading: boolean;\n error: Error | undefined;\n}\n\nexport function usePdfDocument(src: PdfSource): UsePdfDocumentResult {\n const [document, setDocument] = useState<PDFDocumentProxy | undefined>(\n undefined\n );\n const [numPages, setNumPages] = useState(0);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n useEffect(\n function loadPdfDocument() {\n pdfWorker.ensureWorker();\n setLoading(true);\n setError(undefined);\n\n let cancelled = false;\n let loadingTask: ReturnType<typeof getDocument> | undefined;\n\n const startLoad = (params: GetDocumentParams) => {\n if (cancelled) {\n return;\n }\n loadingTask = getDocument(params);\n loadingTask.promise.then(\n (pdf) => {\n if (!cancelled) {\n setDocument(pdf);\n setNumPages(pdf.numPages);\n setLoading(false);\n }\n },\n (err: unknown) => {\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setLoading(false);\n }\n }\n );\n };\n\n toDocumentParams(src).then(startLoad, (err: unknown) => {\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setLoading(false);\n }\n });\n\n return () => {\n cancelled = true;\n void loadingTask?.destroy();\n };\n },\n [src]\n );\n\n return { document, numPages, loading, error };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,WAAW,EAAEC,mBAAmB,QAAQ,YAAY;AAC7D,MAAMC,YAAY,GAAG,IAAIC,GAAG,CAC1B,qCAAqC,EACrCC,MAAM,CAACC,IAAI,CAACC,GACd,CAAC;AACD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAM3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAACC,GAAc,EAA8B;EACpE,IAAIA,GAAG,YAAYC,IAAI,EAAE;IACvB,OAAOD,GAAG,CAACE,WAAW,CAAC,CAAC,CAACC,IAAI,CAAEC,IAAI,KAAM;MAAEA;IAAK,CAAC,CAAC,CAAC;EACrD;EACA,OAAOC,OAAO,CAACC,OAAO,CACpB,OAAON,GAAG,KAAK,QAAQ,GAAG;IAAEJ,GAAG,EAAEI;EAAI,CAAC,GAAG;IAAEI,IAAI,EAAEJ;EAAI,CACvD,CAAC;AACH;AAEA,MAAMO,SAAS,GAAG;EAChBC,iBAAiB,EAAE,KAAK;EACxBC,YAAYA,CAAA,EAAG;IACblB,mBAAmB,CAACmB,SAAS,GAAGlB,YAAY,CAACmB,IAAI;IACjD,IAAI,CAACH,iBAAiB,GAAG,IAAI;EAC/B;AACF,CAAC;AASD,OAA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AAYC,KAAK,GAAGD,GAAG,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,GAAG,CAAC,CAAC,CAAC;QAC7DT,UAAU,CAAC,KAAK,CAAC;MACnB;IACF,CAAC,CAAC;IAEF,OAAO,MAAM;MACXG,SAAS,GAAG,IAAI;MAChB,KAAKC,WAAW,EAAEQ,OAAO,CAAC,CAAC;IAC7B,CAAC;EACH,CAAC,EACD,CAAC/B,GAAG,CACN,CAAC;EAED,OAAO;IAAEa,QAAQ;IAAEG,QAAQ;IAAEE,OAAO;IAAEE;EAAM,CAAC;AAC/C","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"usePdfViewerCore.js","names":["useCallback","useMemo","useRef","useState","usePdfAnnotationPortals","usePdfDocument","usePdfViewer","usePdfViewerSync","usePdfViewerCore","src","initialPage","initialScale","initialAutoSize","document","numPages","loading","error","scale","setScale","currentPage","setCurrentPage","autoSize","setAutoSize","containerRef","viewerRef","pdfViewerRef","eventBusRef","findControllerRef","handleScaleChange","newScale","handlePageChange","page","scrollToPage","syncScrollToPage","onScaleChange","onPageChange","portalTargets"],"sources":["usePdfViewerCore.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport type {\n EventBus,\n PDFFindController,\n PDFViewer,\n} from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport type { RefObject } from \"react\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\n\nimport type { AnnotationPortalTarget } from \"./usePdfAnnotationPortals.js\";\nimport { usePdfAnnotationPortals } from \"./usePdfAnnotationPortals.js\";\nimport { usePdfDocument } from \"./usePdfDocument.js\";\nimport { usePdfViewer } from \"./usePdfViewer.js\";\nimport { usePdfViewerSync } from \"./usePdfViewerSync.js\";\n\nexport interface UsePdfViewerCoreOptions {\n /** PDF source — URL string or ArrayBuffer */\n src: string | ArrayBuffer;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /** Whether auto-size (fit to width) is initially enabled (default false) */\n initialAutoSize?: boolean;\n}\n\nexport interface UsePdfViewerCoreResult {\n /** The loaded PDF document, or undefined while loading */\n document: PDFDocumentProxy | undefined;\n /** Total number of pages in the document */\n numPages: number;\n /** Whether the document is currently loading */\n loading: boolean;\n /** Error encountered while loading the document */\n error: Error | undefined;\n\n /** Ref to attach to the scroll-container div */\n containerRef: RefObject<HTMLDivElement>;\n /** Ref to attach to the inner viewer div (className=\"pdfViewer\") */\n viewerRef: RefObject<HTMLDivElement>;\n\n /** Current page number (1-indexed) */\n currentPage: number;\n /** Navigate to a specific page (updates state and scrolls the viewer) */\n scrollToPage: (page: number) => void;\n\n /** Current zoom scale */\n scale: number;\n /** Set the zoom scale directly */\n setScale: (scale: number) => void;\n\n /** Whether auto-size (fit to width) is active */\n autoSize: boolean;\n /** Enable or disable auto-size */\n setAutoSize: (autoSize: boolean) => void;\n\n /** Portal targets for rendering annotation overlays on each page */\n portalTargets: AnnotationPortalTarget[];\n\n /** Ref to the internal pdfjs PDFViewer instance */\n pdfViewerRef: RefObject<PDFViewer | null>;\n /** Ref to the internal pdfjs EventBus instance */\n eventBusRef: RefObject<EventBus | null>;\n /** Ref to the internal pdfjs PDFFindController instance */\n findControllerRef: RefObject<PDFFindController | null>;\n}\n\nexport function usePdfViewerCore({\n src,\n initialPage = 1,\n initialScale = 1.0,\n initialAutoSize = false,\n}: UsePdfViewerCoreOptions): UsePdfViewerCoreResult {\n const { document, numPages, loading, error } = usePdfDocument(src);\n const [scale, setScale] = useState(initialScale);\n const [currentPage, setCurrentPage] = useState(initialPage);\n const [autoSize, setAutoSize] = useState(initialAutoSize);\n const containerRef = useRef<HTMLDivElement>(null);\n const viewerRef = useRef<HTMLDivElement>(null);\n\n const { pdfViewerRef, eventBusRef, findControllerRef } = usePdfViewer(\n containerRef,\n viewerRef,\n document,\n initialScale,\n initialPage\n );\n\n const handleScaleChange = useCallback((newScale: number) => {\n setScale(newScale);\n }, []);\n\n const handlePageChange = useCallback((page: number) => {\n setCurrentPage(page);\n }, []);\n\n const { scrollToPage: syncScrollToPage } = usePdfViewerSync({\n pdfViewerRef,\n eventBusRef,\n containerRef,\n document,\n scale,\n autoSize,\n onScaleChange: handleScaleChange,\n onPageChange: handlePageChange,\n });\n\n const scrollToPage = useCallback(\n (page: number) => {\n setCurrentPage(page);\n syncScrollToPage(page);\n },\n [syncScrollToPage]\n );\n\n const portalTargets = usePdfAnnotationPortals(\n pdfViewerRef,\n eventBusRef,\n document\n );\n\n return useMemo(\n (): UsePdfViewerCoreResult => ({\n document,\n numPages,\n loading,\n error,\n containerRef,\n viewerRef,\n currentPage,\n scrollToPage,\n scale,\n setScale,\n autoSize,\n setAutoSize,\n portalTargets,\n pdfViewerRef,\n eventBusRef,\n findControllerRef,\n }),\n [\n document,\n numPages,\n loading,\n error,\n currentPage,\n scrollToPage,\n scale,\n setScale,\n autoSize,\n setAutoSize,\n portalTargets,\n ]\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,WAAW,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAG9D,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,gBAAgB,QAAQ,uBAAuB;AAsDxD,OAAO,SAASC,gBAAgBA,CAAC;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IACpBE,gBAAgB,CAACF,IAAI,CAAC;EACxB,CAAC,EACD,CAACE,gBAAgB,CACnB,CAAC;EAED,MAAMG,aAAa,GAAGhC,uBAAuB,CAC3CqB,YAAY,EACZC,WAAW,EACXb,QACF,CAAC;EAED,OAAOZ,OAAO,CACZ,OAA+B;IAC7BY,QAAQ;IACRC,QAAQ;IACRC,OAAO;IACPC,KAAK;IACLO,YAAY;IACZC,SAAS;IACTL,WAAW;IACXa,YAAY;IACZf,KAAK;IACLC,QAAQ;IACRG,QAAQ;IACRC,WAAW;IACXc,aAAa;IACbX,YAAY;IACZC,WAAW;IACXC;EACF,CAAC,CAAC,EACF,CACEd,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACPC,KAAK,EACLG,WAAW,EACXa,YAAY,EACZf,KAAK,EACLC,QAAQ,EACRG,QAAQ,EACRC,WAAW,EACXc,aAAa,CAEjB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"usePdfViewerCore.js","names":["useCallback","useMemo","useRef","useState","usePdfAnnotationPortals","usePdfDocument","usePdfViewer","usePdfViewerSync","usePdfViewerCore","src","initialPage","initialScale","initialAutoSize","document","numPages","loading","error","scale","setScale","currentPage","setCurrentPage","autoSize","setAutoSize","containerRef","viewerRef","pdfViewerRef","eventBusRef","findControllerRef","handleScaleChange","newScale","handlePageChange","page","scrollToPage","syncScrollToPage","onScaleChange","onPageChange","portalTargets"],"sources":["usePdfViewerCore.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport type {\n EventBus,\n PDFFindController,\n PDFViewer,\n} from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport type { RefObject } from \"react\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\n\nimport type { PdfSource } from \"../types.js\";\nimport type { AnnotationPortalTarget } from \"./usePdfAnnotationPortals.js\";\nimport { usePdfAnnotationPortals } from \"./usePdfAnnotationPortals.js\";\nimport { usePdfDocument } from \"./usePdfDocument.js\";\nimport { usePdfViewer } from \"./usePdfViewer.js\";\nimport { usePdfViewerSync } from \"./usePdfViewerSync.js\";\n\nexport interface UsePdfViewerCoreOptions {\n /** PDF source — URL string, ArrayBuffer, Uint8Array, or Blob */\n src: PdfSource;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /** Whether auto-size (fit to width) is initially enabled (default false) */\n initialAutoSize?: boolean;\n}\n\nexport interface UsePdfViewerCoreResult {\n /** The loaded PDF document, or undefined while loading */\n document: PDFDocumentProxy | undefined;\n /** Total number of pages in the document */\n numPages: number;\n /** Whether the document is currently loading */\n loading: boolean;\n /** Error encountered while loading the document */\n error: Error | undefined;\n\n /** Ref to attach to the scroll-container div */\n containerRef: RefObject<HTMLDivElement>;\n /** Ref to attach to the inner viewer div (className=\"pdfViewer\") */\n viewerRef: RefObject<HTMLDivElement>;\n\n /** Current page number (1-indexed) */\n currentPage: number;\n /** Navigate to a specific page (updates state and scrolls the viewer) */\n scrollToPage: (page: number) => void;\n\n /** Current zoom scale */\n scale: number;\n /** Set the zoom scale directly */\n setScale: (scale: number) => void;\n\n /** Whether auto-size (fit to width) is active */\n autoSize: boolean;\n /** Enable or disable auto-size */\n setAutoSize: (autoSize: boolean) => void;\n\n /** Portal targets for rendering annotation overlays on each page */\n portalTargets: AnnotationPortalTarget[];\n\n /** Ref to the internal pdfjs PDFViewer instance */\n pdfViewerRef: RefObject<PDFViewer | null>;\n /** Ref to the internal pdfjs EventBus instance */\n eventBusRef: RefObject<EventBus | null>;\n /** Ref to the internal pdfjs PDFFindController instance */\n findControllerRef: RefObject<PDFFindController | null>;\n}\n\nexport function usePdfViewerCore({\n src,\n initialPage = 1,\n initialScale = 1.0,\n initialAutoSize = false,\n}: UsePdfViewerCoreOptions): UsePdfViewerCoreResult {\n const { document, numPages, loading, error } = usePdfDocument(src);\n const [scale, setScale] = useState(initialScale);\n const [currentPage, setCurrentPage] = useState(initialPage);\n const [autoSize, setAutoSize] = useState(initialAutoSize);\n const containerRef = useRef<HTMLDivElement>(null);\n const viewerRef = useRef<HTMLDivElement>(null);\n\n const { pdfViewerRef, eventBusRef, findControllerRef } = usePdfViewer(\n containerRef,\n viewerRef,\n document,\n initialScale,\n initialPage\n );\n\n const handleScaleChange = useCallback((newScale: number) => {\n setScale(newScale);\n }, []);\n\n const handlePageChange = useCallback((page: number) => {\n setCurrentPage(page);\n }, []);\n\n const { scrollToPage: syncScrollToPage } = usePdfViewerSync({\n pdfViewerRef,\n eventBusRef,\n containerRef,\n document,\n scale,\n autoSize,\n onScaleChange: handleScaleChange,\n onPageChange: handlePageChange,\n });\n\n const scrollToPage = useCallback(\n (page: number) => {\n setCurrentPage(page);\n syncScrollToPage(page);\n },\n [syncScrollToPage]\n );\n\n const portalTargets = usePdfAnnotationPortals(\n pdfViewerRef,\n eventBusRef,\n document\n );\n\n return useMemo(\n (): UsePdfViewerCoreResult => ({\n document,\n numPages,\n loading,\n error,\n containerRef,\n viewerRef,\n currentPage,\n scrollToPage,\n scale,\n setScale,\n autoSize,\n setAutoSize,\n portalTargets,\n pdfViewerRef,\n eventBusRef,\n findControllerRef,\n }),\n [\n document,\n numPages,\n loading,\n error,\n currentPage,\n scrollToPage,\n scale,\n setScale,\n autoSize,\n setAutoSize,\n portalTargets,\n ]\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,WAAW,EAAEC,OAAO,E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Y;IACZC,WAAW;IACXH,YAAY;IACZV,QAAQ;IACRI,KAAK;IACLI,QAAQ;IACRa,aAAa,EAAEN,iBAAiB;IAChCO,YAAY,EAAEL;EAChB,CAAC,CAAC;EAEF,MAAME,YAAY,GAAGhC,WAAW,CAC7B+B,IAAY,IAAK;IAChBX,cAAc,CAACW,IAAI,CAAC;IACpBE,gBAAgB,CAACF,IAAI,CAAC;EACxB,CAAC,EACD,CAACE,gBAAgB,CACnB,CAAC;EAED,MAAMG,aAAa,GAAGhC,uBAAuB,CAC3CqB,YAAY,EACZC,WAAW,EACXb,QACF,CAAC;EAED,OAAOZ,OAAO,CACZ,OAA+B;IAC7BY,QAAQ;IACRC,QAAQ;IACRC,OAAO;IACPC,KAAK;IACLO,YAAY;IACZC,SAAS;IACTL,WAAW;IACXa,YAAY;IACZf,KAAK;IACLC,QAAQ;IACRG,QAAQ;IACRC,WAAW;IACXc,aAAa;IACbX,YAAY;IACZC,WAAW;IACXC;EACF,CAAC,CAAC,EACF,CACEd,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACPC,KAAK,EACLG,WAAW,EACXa,YAAY,EACZf,KAAK,EACLC,QAAQ,EACRG,QAAQ,EACRC,WAAW,EACXc,aAAa,CAEjB,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"usePdfViewerState.js","names":["useCallback","useEffect","useMemo","useRef","useState","MAX_SCALE","MIN_SCALE","PAGE_WIDTH_SCALE_VALUE","SCALE_STEP","usePdfOutline","usePdfViewerCore","usePdfViewerSearch","usePdfViewerState","src","initialPage","initialScale","initialAutoSize","initialSidebarOpen","sidebarMode","sidebarModeProp","onDownload","core","rotation","setRotation","sidebarOpen","setSidebarOpen","setSidebarMode","search","eventBusRef","findControllerRef","document","outlineItems","pdfViewer","pdfViewerRef","current","pagesRotation","prevRotationRef","autoSize","currentScaleValue","handleKeyDown","e","ctrlKey","metaKey","key","preventDefault","openSearch","window","addEventListener","removeEventListener","zoomIn","setAutoSize","setScale","Math","min","scale","zoomOut","max","toggleAutoSize","rotateLeft","prev","rotateRight","toggleSidebar","download","filename","getData","then","data","blob","Blob","buffer","type","url","URL","createObjectURL","resolvedFilename","resolveDownloadFilename","a","globalThis","createElement","href","click","revokeObjectURL","success","catch","err","error","Error","split","pop"],"sources":["usePdfViewerState.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport {\n MAX_SCALE,\n MIN_SCALE,\n PAGE_WIDTH_SCALE_VALUE,\n SCALE_STEP,\n} from \"../constants.js\";\nimport type { PdfDownloadResult, SidebarMode } from \"../types.js\";\nimport { usePdfOutline } from \"./usePdfOutline.js\";\nimport type {\n UsePdfViewerCoreOptions,\n UsePdfViewerCoreResult,\n} from \"./usePdfViewerCore.js\";\nimport { usePdfViewerCore } from \"./usePdfViewerCore.js\";\nimport type { UsePdfViewerSearchResult } from \"./usePdfViewerSearch.js\";\nimport { usePdfViewerSearch } from \"./usePdfViewerSearch.js\";\n\nexport interface UsePdfViewerStateOptions extends UsePdfViewerCoreOptions {\n /** Whether the sidebar is initially open (default false) */\n initialSidebarOpen?: boolean;\n /** Which sidebar panel to show (default \"thumbnails\") */\n sidebarMode?: SidebarMode;\n /** Callback fired when a download completes or fails */\n onDownload?: (result: PdfDownloadResult) => void;\n}\n\nexport interface UsePdfViewerStateResult extends UsePdfViewerCoreResult {\n /** Zoom in by one step (disables auto-size) */\n zoomIn: () => void;\n /** Zoom out by one step (disables auto-size) */\n zoomOut: () => void;\n /** Toggle auto-size (fit to width) on or off */\n toggleAutoSize: () => void;\n\n /** Current rotation in degrees (0, 90, 180, 270) */\n rotation: number;\n /** Rotate 90 degrees counter-clockwise */\n rotateLeft: () => void;\n /** Rotate 90 degrees clockwise */\n rotateRight: () => void;\n\n /** Whether the sidebar panel is open */\n sidebarOpen: boolean;\n /** Which sidebar panel is active */\n sidebarMode: SidebarMode;\n /** Change the active sidebar panel */\n setSidebarMode: (mode: SidebarMode) => void;\n /** Toggle sidebar open/closed */\n toggleSidebar: () => void;\n\n /** Search state and actions */\n search: UsePdfViewerSearchResult;\n\n /** Document outline items (from bookmarks or text extraction) */\n outlineItems: ReturnType<typeof usePdfOutline>;\n\n /** Download the PDF as a file */\n download: (filename?: string) => void;\n}\n\nexport function usePdfViewerState({\n src,\n initialPage,\n initialScale,\n initialAutoSize,\n initialSidebarOpen = false,\n sidebarMode: sidebarModeProp = \"thumbnails\",\n onDownload,\n}: UsePdfViewerStateOptions): UsePdfViewerStateResult {\n const core = usePdfViewerCore({\n src,\n initialPage,\n initialScale,\n initialAutoSize,\n });\n\n const [rotation, setRotation] = useState(0);\n const [sidebarOpen, setSidebarOpen] = useState(initialSidebarOpen);\n const [sidebarMode, setSidebarMode] = useState<SidebarMode>(sidebarModeProp);\n\n const search = usePdfViewerSearch(\n core.eventBusRef,\n core.findControllerRef,\n core.document\n );\n\n const outlineItems = usePdfOutline(core.document);\n\n // Sync sidebarMode prop changes to state\n useEffect(\n function syncSidebarMode() {\n setSidebarMode(sidebarModeProp);\n },\n [sidebarModeProp]\n );\n\n // Sync rotation → PDFViewer\n useEffect(\n function syncRotationToViewer() {\n const pdfViewer = core.pdfViewerRef.current;\n if (pdfViewer != null) {\n pdfViewer.pagesRotation = rotation;\n }\n },\n [core.pdfViewerRef, rotation]\n );\n\n // Re-apply page-width after rotation changes while auto-size is active.\n // Rotation changes the effective page width, so auto-size must re-fit.\n const prevRotationRef = useRef(rotation);\n useEffect(\n function reapplyAutoSizeAfterRotation() {\n if (prevRotationRef.current === rotation) {\n return;\n }\n prevRotationRef.current = rotation;\n const pdfViewer = core.pdfViewerRef.current;\n if (pdfViewer == null || !core.autoSize) {\n return;\n }\n pdfViewer.currentScaleValue = PAGE_WIDTH_SCALE_VALUE;\n },\n [core.pdfViewerRef, core.autoSize, rotation]\n );\n\n // Ctrl+F keyboard shortcut\n useEffect(\n function registerSearchShortcut() {\n const handleKeyDown = (e: KeyboardEvent) => {\n if ((e.ctrlKey || e.metaKey) && e.key === \"f\") {\n e.preventDefault();\n search.openSearch();\n }\n };\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n };\n },\n [search.openSearch]\n );\n\n const zoomIn = useCallback(() => {\n core.setAutoSize(false);\n core.setScale(Math.min(core.scale + SCALE_STEP, MAX_SCALE));\n }, [core.scale, core.setScale, core.setAutoSize]);\n\n const zoomOut = useCallback(() => {\n core.setAutoSize(false);\n core.setScale(Math.max(core.scale - SCALE_STEP, MIN_SCALE));\n }, [core.scale, core.setScale, core.setAutoSize]);\n\n const toggleAutoSize = useCallback(() => {\n core.setAutoSize(!core.autoSize);\n }, [core.autoSize, core.setAutoSize]);\n\n const rotateLeft = useCallback(() => {\n setRotation((prev) => (prev - 90 + 360) % 360);\n }, []);\n\n const rotateRight = useCallback(() => {\n setRotation((prev) => (prev + 90) % 360);\n }, []);\n\n const toggleSidebar = useCallback(() => {\n setSidebarOpen((prev) => !prev);\n }, []);\n\n const download = useCallback(\n (filename?: string) => {\n if (core.document == null) {\n return;\n }\n void core.document\n .getData()\n .then((data) => {\n const blob = new Blob([data.buffer as ArrayBuffer], {\n type: \"application/pdf\",\n });\n const url = URL.createObjectURL(blob);\n const resolvedFilename = resolveDownloadFilename(src, filename);\n const a = globalThis.document.createElement(\"a\");\n a.href = url;\n a.download = resolvedFilename;\n a.click();\n URL.revokeObjectURL(url);\n onDownload?.({ success: true, filename: resolvedFilename });\n })\n .catch((err: unknown) => {\n onDownload?.({\n success: false,\n error:\n err instanceof Error ? err : new Error(\"Failed to download PDF\"),\n });\n });\n },\n [core.document, src, onDownload]\n );\n\n return useMemo(\n (): UsePdfViewerStateResult => ({\n ...core,\n zoomIn,\n zoomOut,\n toggleAutoSize,\n rotation,\n rotateLeft,\n rotateRight,\n sidebarOpen,\n sidebarMode,\n setSidebarMode,\n toggleSidebar,\n search,\n outlineItems,\n download,\n }),\n [\n core,\n zoomIn,\n zoomOut,\n toggleAutoSize,\n rotation,\n rotateLeft,\n rotateRight,\n sidebarOpen,\n sidebarMode,\n setSidebarMode,\n toggleSidebar,\n search,\n outlineItems,\n download,\n ]\n );\n}\n\n/** Derive a download filename from an explicit name, the src URL, or a fallback. */\nfunction resolveDownloadFilename(\n src: string | ArrayBuffer,\n filename: string | undefined\n): string {\n if (filename != null) {\n return filename;\n }\n if (typeof src === \"string\") {\n return src.split(\"/\").pop()?.split(\"?\")[0] || \"document.pdf\";\n }\n return \"document.pdf\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEzE,SACEC,SAAS,EACTC,SAAS,EACTC,sBAAsB,EACtBC,UAAU,QACL,iBAAiB;AAExB,SAASC,aAAa,QAAQ,oBAAoB;AAKlD,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,SAASC,kBAAkB,QAAQ,yBAAyB;AA6C5D,OAAO,SAASC,iBAAiBA,CAAC;EAChCC,GAAG;EACHC,WAAW;EACXC,YAAY;EACZC,eAAe;EACfC,kBAAkB,GAAG,KAAK;EAC1BC,WAAW,EAAEC,eAAe,GAAG,YAAY;EAC3CC;AACwB,CAAC,EAA2B;EACpD,MAAMC,IAAI,GAAGX,gBAAgB,CAAC;IAC5BG,GAAG;IACHC,WAAW;IACXC,YAAY;IACZC;EACF,CAAC,CAAC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erState.js","names":["useCallback","useEffect","useMemo","useRef","useState","MAX_SCALE","MIN_SCALE","PAGE_WIDTH_SCALE_VALUE","SCALE_STEP","usePdfOutline","usePdfViewerCore","usePdfViewerSearch","usePdfViewerState","src","initialPage","initialScale","initialAutoSize","initialSidebarOpen","sidebarMode","sidebarModeProp","onDownload","core","rotation","setRotation","sidebarOpen","setSidebarOpen","setSidebarMode","search","eventBusRef","findControllerRef","document","outlineItems","pdfViewer","pdfViewerRef","current","pagesRotation","prevRotationRef","autoSize","currentScaleValue","handleKeyDown","e","ctrlKey","metaKey","key","preventDefault","openSearch","window","addEventListener","removeEventListener","zoomIn","setAutoSize","setScale","Math","min","scale","zoomOut","max","toggleAutoSize","rotateLeft","prev","rotateRight","toggleSidebar","download","filename","getData","then","data","blob","Blob","buffer","type","url","URL","createObjectURL","resolvedFilename","resolveDownloadFilename","a","globalThis","createElement","href","click","revokeObjectURL","success","catch","err","error","Error","split","pop"],"sources":["usePdfViewerState.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport {\n MAX_SCALE,\n MIN_SCALE,\n PAGE_WIDTH_SCALE_VALUE,\n SCALE_STEP,\n} from \"../constants.js\";\nimport type { PdfDownloadResult, PdfSource, SidebarMode } from \"../types.js\";\nimport { usePdfOutline } from \"./usePdfOutline.js\";\nimport type {\n UsePdfViewerCoreOptions,\n UsePdfViewerCoreResult,\n} from \"./usePdfViewerCore.js\";\nimport { usePdfViewerCore } from \"./usePdfViewerCore.js\";\nimport type { UsePdfViewerSearchResult } from \"./usePdfViewerSearch.js\";\nimport { usePdfViewerSearch } from \"./usePdfViewerSearch.js\";\n\nexport interface UsePdfViewerStateOptions extends UsePdfViewerCoreOptions {\n /** Whether the sidebar is initially open (default false) */\n initialSidebarOpen?: boolean;\n /** Which sidebar panel to show (default \"thumbnails\") */\n sidebarMode?: SidebarMode;\n /** Callback fired when a download completes or fails */\n onDownload?: (result: PdfDownloadResult) => void;\n}\n\nexport interface UsePdfViewerStateResult extends UsePdfViewerCoreResult {\n /** Zoom in by one step (disables auto-size) */\n zoomIn: () => void;\n /** Zoom out by one step (disables auto-size) */\n zoomOut: () => void;\n /** Toggle auto-size (fit to width) on or off */\n toggleAutoSize: () => void;\n\n /** Current rotation in degrees (0, 90, 180, 270) */\n rotation: number;\n /** Rotate 90 degrees counter-clockwise */\n rotateLeft: () => void;\n /** Rotate 90 degrees clockwise */\n rotateRight: () => void;\n\n /** Whether the sidebar panel is open */\n sidebarOpen: boolean;\n /** Which sidebar panel is active */\n sidebarMode: SidebarMode;\n /** Change the active sidebar panel */\n setSidebarMode: (mode: SidebarMode) => void;\n /** Toggle sidebar open/closed */\n toggleSidebar: () => void;\n\n /** Search state and actions */\n search: UsePdfViewerSearchResult;\n\n /** Document outline items (from bookmarks or text extraction) */\n outlineItems: ReturnType<typeof usePdfOutline>;\n\n /** Download the PDF as a file */\n download: (filename?: string) => void;\n}\n\nexport function usePdfViewerState({\n src,\n initialPage,\n initialScale,\n initialAutoSize,\n initialSidebarOpen = false,\n sidebarMode: sidebarModeProp = \"thumbnails\",\n onDownload,\n}: UsePdfViewerStateOptions): UsePdfViewerStateResult {\n const core = usePdfViewerCore({\n src,\n initialPage,\n initialScale,\n initialAutoSize,\n });\n\n const [rotation, setRotation] = useState(0);\n const [sidebarOpen, setSidebarOpen] = useState(initialSidebarOpen);\n const [sidebarMode, setSidebarMode] = useState<SidebarMode>(sidebarModeProp);\n\n const search = usePdfViewerSearch(\n core.eventBusRef,\n core.findControllerRef,\n core.document\n );\n\n const outlineItems = usePdfOutline(core.document);\n\n // Sync sidebarMode prop changes to state\n useEffect(\n function syncSidebarMode() {\n setSidebarMode(sidebarModeProp);\n },\n [sidebarModeProp]\n );\n\n // Sync rotation → PDFViewer\n useEffect(\n function syncRotationToViewer() {\n const pdfViewer = core.pdfViewerRef.current;\n if (pdfViewer != null) {\n pdfViewer.pagesRotation = rotation;\n }\n },\n [core.pdfViewerRef, rotation]\n );\n\n // Re-apply page-width after rotation changes while auto-size is active.\n // Rotation changes the effective page width, so auto-size must re-fit.\n const prevRotationRef = useRef(rotation);\n useEffect(\n function reapplyAutoSizeAfterRotation() {\n if (prevRotationRef.current === rotation) {\n return;\n }\n prevRotationRef.current = rotation;\n const pdfViewer = core.pdfViewerRef.current;\n if (pdfViewer == null || !core.autoSize) {\n return;\n }\n pdfViewer.currentScaleValue = PAGE_WIDTH_SCALE_VALUE;\n },\n [core.pdfViewerRef, core.autoSize, rotation]\n );\n\n // Ctrl+F keyboard shortcut\n useEffect(\n function registerSearchShortcut() {\n const handleKeyDown = (e: KeyboardEvent) => {\n if ((e.ctrlKey || e.metaKey) && e.key === \"f\") {\n e.preventDefault();\n search.openSearch();\n }\n };\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n };\n },\n [search.openSearch]\n );\n\n const zoomIn = useCallback(() => {\n core.setAutoSize(false);\n core.setScale(Math.min(core.scale + SCALE_STEP, MAX_SCALE));\n }, [core.scale, core.setScale, core.setAutoSize]);\n\n const zoomOut = useCallback(() => {\n core.setAutoSize(false);\n core.setScale(Math.max(core.scale - SCALE_STEP, MIN_SCALE));\n }, [core.scale, core.setScale, core.setAutoSize]);\n\n const toggleAutoSize = useCallback(() => {\n core.setAutoSize(!core.autoSize);\n }, [core.autoSize, core.setAutoSize]);\n\n const rotateLeft = useCallback(() => {\n setRotation((prev) => (prev - 90 + 360) % 360);\n }, []);\n\n const rotateRight = useCallback(() => {\n setRotation((prev) => (prev + 90) % 360);\n }, []);\n\n const toggleSidebar = useCallback(() => {\n setSidebarOpen((prev) => !prev);\n }, []);\n\n const download = useCallback(\n (filename?: string) => {\n if (core.document == null) {\n return;\n }\n void core.document\n .getData()\n .then((data) => {\n const blob = new Blob([data.buffer as ArrayBuffer], {\n type: \"application/pdf\",\n });\n const url = URL.createObjectURL(blob);\n const resolvedFilename = resolveDownloadFilename(src, filename);\n const a = globalThis.document.createElement(\"a\");\n a.href = url;\n a.download = resolvedFilename;\n a.click();\n URL.revokeObjectURL(url);\n onDownload?.({ success: true, filename: resolvedFilename });\n })\n .catch((err: unknown) => {\n onDownload?.({\n success: false,\n error:\n err instanceof Error ? err : new Error(\"Failed to download PDF\"),\n });\n });\n },\n [core.document, src, onDownload]\n );\n\n return useMemo(\n (): UsePdfViewerStateResult => ({\n ...core,\n zoomIn,\n zoomOut,\n toggleAutoSize,\n rotation,\n rotateLeft,\n rotateRight,\n sidebarOpen,\n sidebarMode,\n setSidebarMode,\n toggleSidebar,\n search,\n outlineItems,\n download,\n }),\n [\n core,\n zoomIn,\n zoomOut,\n toggleAutoSize,\n rotation,\n rotateLeft,\n rotateRight,\n sidebarOpen,\n sidebarMode,\n setSidebarMode,\n toggleSidebar,\n search,\n outlineItems,\n download,\n ]\n );\n}\n\n/** Derive a download filename from an explicit name, the src URL, or a fallback. */\nfunction resolveDownloadFilename(\n src: PdfSource,\n filename: string | undefined\n): string {\n if (filename != null) {\n return filename;\n }\n if (typeof src === \"string\") {\n return src.split(\"/\").pop()?.split(\"?\")[0] || \"document.pdf\";\n }\n return \"document.pdf\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEzE,SACEC,SAAS,EACTC,SAAS,EACTC,sBAAsB,EACtBC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+B,QAAQ,CAEZ,CAAC;AACH;;AAEA;AACA,SAASa,uBAAuBA,CAC9B9D,GAAc,EACdkD,QAA4B,EACpB;EACR,IAAIA,QAAQ,IAAI,IAAI,EAAE;IACpB,OAAOA,QAAQ;EACjB;EACA,IAAI,OAAOlD,GAAG,KAAK,QAAQ,EAAE;IAC3B,OAAOA,GAAG,CAAC0E,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,EAAED,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc;EAC9D;EACA,OAAO,cAAc;AACvB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["types.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type React from \"react\";\n\n/** Which sidebar panel to display when the sidebar is open. */\nexport type SidebarMode = \"thumbnails\" | \"outline\";\n\n/** A single item in the PDF document outline (table of contents). */\nexport interface OutlineItem {\n title: string;\n depth: number;\n pageNumber: number;\n bold: boolean;\n italic: boolean;\n}\n\n/** The visual style of an annotation rendered on the PDF. */\nexport type AnnotationType =\n | \"highlight\"\n | \"underline\"\n | \"comment\"\n | \"pin\"\n | \"custom\";\n\n/** A rectangle in PDF coordinate space (origin: bottom-left of page). */\nexport interface PdfRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Props passed to a custom annotation renderer. */\nexport interface PdfAnnotationRenderProps {\n annotation: PdfAnnotation;\n scale: number;\n pageHeight: number;\n transform: number[];\n}\n\n/** Common fields shared by all annotation types. */\ninterface PdfAnnotationBase {\n /** Unique identifier for this annotation */\n id: string;\n /** Page number (1-indexed) */\n page: number;\n /** Coordinates in PDF points (origin: bottom-left of page) */\n rect: PdfRect;\n /** Additional rects for multi-line text highlights. When present, all rects are rendered. */\n rects?: PdfRect[];\n /** Optional label or tooltip text */\n label?: string;\n /** Optional color override (CSS color string) */\n color?: string;\n}\n\n/** A built-in annotation type (highlight, underline, comment, pin). */\ninterface PdfStandardAnnotation extends PdfAnnotationBase {\n /** The type of annotation to render */\n type: \"highlight\" | \"underline\" | \"comment\" | \"pin\";\n}\n\n/** A custom annotation with a user-provided renderer. */\nexport interface PdfCustomAnnotation extends PdfAnnotationBase {\n /** Must be \"custom\" for custom-rendered annotations */\n type: \"custom\";\n /** Render function for the custom annotation content (required for custom type) */\n render: (props: PdfAnnotationRenderProps) => React.ReactNode;\n}\n\n/** A single annotation positioned on a specific page of the PDF. */\nexport type PdfAnnotation = PdfStandardAnnotation | PdfCustomAnnotation;\n\n/** Result passed to the {@link PdfViewerProps.onDownload} callback. */\nexport type PdfDownloadResult =\n | { success: true; filename: string }\n | { success: false; error: Error };\n\n/** Possible values for a PDF form field. */\nexport type PdfFormFieldValue = string | boolean | string[];\n\n/** Data emitted when the user creates a text highlight via the highlight editor. */\nexport interface PdfTextHighlightEvent {\n /** Internal PDF.js editor ID. Use with `deleteHighlight` to programmatically remove. */\n editorId: string;\n /** Page number (1-indexed) */\n page: number;\n /** Bounding rects in PDF coordinate space (bottom-left origin) */\n rects: PdfRect[];\n /** The selected text content */\n selectedText: string;\n /** Highlight color as CSS color string */\n color: string;\n}\n\n/** Imperative handle for programmatic control of a {@link PdfViewer} or {@link BasePdfViewer}. */\nexport interface PdfViewerHandle {\n /** Scroll the viewer to the given page number (1-indexed). */\n scrollToPage: (page: number) => void;\n /** Programmatically delete a highlight by its `editorId` (from {@link PdfTextHighlightEvent}). */\n deleteHighlight: (editorId: string) => void;\n}\n\n/**\n * Options for {@link usePdfViewerInstance}.\n * Equivalent to {@link PdfViewerProps} minus the `className` rendering concern.\n */\nexport interface PdfViewerInstanceOptions {\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 /** Callback fired when a download completes or fails */\n onDownload?: (result: PdfDownloadResult) => void;\n /** Whether the highlight toggle button is shown in the toolbar */\n highlightEnabled?: boolean;\n /** Callback fired when the user creates a text highlight */\n onTextHighlight?: (event: PdfTextHighlightEvent) => void;\n /** Callback fired when the user deletes a highlight */\n onHighlightDelete?: (event: PdfTextHighlightEvent) => void;\n /** Initial form field values keyed by field name */\n formData?: Record<string, PdfFormFieldValue>;\n /** Callback fired when the user clicks the save button */\n onFormSubmit?: (data: Record<string, PdfFormFieldValue>) => void;\n /** Callback fired when any form field value changes */\n onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /**\n * Whether auto-size (fit to width) is initially enabled.\n * When enabled, the PDF scales to fit the container width and\n * re-fits automatically on resize. Manual zoom disables auto-size.\n * Takes precedence over {@link initialScale} when enabled.\n * @default false\n */\n initialAutoSize?: boolean;\n /** Whether the sidebar is initially open (default false) */\n initialSidebarOpen?: boolean;\n /** Whether the download button is shown in the toolbar */\n enableDownload?: boolean;\n /** Which sidebar panel to show: thumbnails or document outline */\n sidebarMode?: SidebarMode;\n /** Custom icon components for each outline depth level (0-indexed) */\n outlineIcons?: Partial<Record<number, React.ComponentType>>;\n}\n\n/** Props for the {@link PdfViewer} component. */\nexport interface PdfViewerProps {\n /** PDF source — URL string or ArrayBuffer */\n src: string | ArrayBuffer;\n /** Annotations to overlay on the PDF */\n annotations?: PdfAnnotation[];\n /**\n * Callback fired when an annotation is clicked.\n *\n * @param annotation - The annotation that was clicked\n * @returns void\n */\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n /**\n * Callback fired when a download completes or fails.\n *\n * @param result - The download result indicating success with the filename, or failure with an error\n * @returns void\n */\n onDownload?: (result: PdfDownloadResult) => void;\n /**\n * Whether the highlight toggle button is shown in the toolbar.\n * @default false\n */\n enableHighlight?: boolean;\n /**\n * Callback fired when the user creates a text highlight.\n * Only fires when highlight mode is active.\n *\n * @param event - The highlight event with page, rects, text, and color\n * @returns void\n */\n onTextHighlight?: (event: PdfTextHighlightEvent) => void;\n /**\n * Callback fired when the user deletes a highlight via the PDF.js editor UI.\n *\n * @param event - The highlight event that was deleted\n * @returns void\n */\n onHighlightDelete?: (event: PdfTextHighlightEvent) => void;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /**\n * Whether auto-size (fit to width) is initially enabled.\n * When enabled, the PDF scales to fit the container width and\n * re-fits automatically on resize. Manual zoom disables auto-size.\n * Takes precedence over {@link initialScale} when enabled.\n * @default false\n */\n initialAutoSize?: boolean;\n /** Whether the sidebar is initially open (default false) */\n initialSidebarOpen?: boolean;\n /**\n * Whether the download button is shown in the toolbar.\n * @default false\n */\n enableDownload?: boolean;\n /**\n * Filename used when the user downloads the PDF via the toolbar button.\n * If omitted, the name is derived from the `src` URL, falling back to \"document.pdf\".\n */\n downloadFileName?: string;\n /**\n * Which sidebar panel to show: thumbnails or document outline.\n * @default \"thumbnails\"\n */\n sidebarMode?: SidebarMode;\n /**\n * Custom icon components for each outline depth level (0-indexed).\n * Key 0 = top-level items, 1 = first nesting level, etc.\n * If omitted, no icons are rendered.\n */\n outlineIcons?: Partial<Record<number, React.ComponentType>>;\n /**\n * Initial form field values keyed by field name. Applied when the document loads.\n * Use this to pre-populate form fields when resuming a previously edited PDF.\n */\n formData?: Record<string, PdfFormFieldValue>;\n /**\n * Callback fired when the user clicks the save button in the toolbar.\n * Receives all current form field values keyed by field name.\n *\n * @param data - All form field values keyed by field name\n * @returns void\n */\n onFormSubmit?: (data: Record<string, PdfFormFieldValue>) => void;\n /**\n * Callback fired when any form field value changes.\n *\n * @param fieldName - The name of the field that changed\n * @param value - The new value\n * @returns void\n */\n onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;\n /** Additional CSS class name for the root element */\n className?: string;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["types.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type React from \"react\";\n\n/** Which sidebar panel to display when the sidebar is open. */\nexport type SidebarMode = \"thumbnails\" | \"outline\";\n\n/** A single item in the PDF document outline (table of contents). */\nexport interface OutlineItem {\n title: string;\n depth: number;\n pageNumber: number;\n bold: boolean;\n italic: boolean;\n}\n\n/** The visual style of an annotation rendered on the PDF. */\nexport type AnnotationType =\n | \"highlight\"\n | \"underline\"\n | \"comment\"\n | \"pin\"\n | \"custom\";\n\n/** A rectangle in PDF coordinate space (origin: bottom-left of page). */\nexport interface PdfRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Props passed to a custom annotation renderer. */\nexport interface PdfAnnotationRenderProps {\n annotation: PdfAnnotation;\n scale: number;\n pageHeight: number;\n transform: number[];\n}\n\n/** Common fields shared by all annotation types. */\ninterface PdfAnnotationBase {\n /** Unique identifier for this annotation */\n id: string;\n /** Page number (1-indexed) */\n page: number;\n /** Coordinates in PDF points (origin: bottom-left of page) */\n rect: PdfRect;\n /** Additional rects for multi-line text highlights. When present, all rects are rendered. */\n rects?: PdfRect[];\n /** Optional label or tooltip text */\n label?: string;\n /** Optional color override (CSS color string) */\n color?: string;\n}\n\n/** A built-in annotation type (highlight, underline, comment, pin). */\ninterface PdfStandardAnnotation extends PdfAnnotationBase {\n /** The type of annotation to render */\n type: \"highlight\" | \"underline\" | \"comment\" | \"pin\";\n}\n\n/** A custom annotation with a user-provided renderer. */\nexport interface PdfCustomAnnotation extends PdfAnnotationBase {\n /** Must be \"custom\" for custom-rendered annotations */\n type: \"custom\";\n /** Render function for the custom annotation content (required for custom type) */\n render: (props: PdfAnnotationRenderProps) => React.ReactNode;\n}\n\n/** A single annotation positioned on a specific page of the PDF. */\nexport type PdfAnnotation = PdfStandardAnnotation | PdfCustomAnnotation;\n\n/** Result passed to the {@link PdfViewerProps.onDownload} callback. */\nexport type PdfDownloadResult =\n | { success: true; filename: string }\n | { success: false; error: Error };\n\n/** Possible values for a PDF form field. */\nexport type PdfFormFieldValue = string | boolean | string[];\n\n/** Data emitted when the user creates a text highlight via the highlight editor. */\nexport interface PdfTextHighlightEvent {\n /** Internal PDF.js editor ID. Use with `deleteHighlight` to programmatically remove. */\n editorId: string;\n /** Page number (1-indexed) */\n page: number;\n /** Bounding rects in PDF coordinate space (bottom-left origin) */\n rects: PdfRect[];\n /** The selected text content */\n selectedText: string;\n /** Highlight color as CSS color string */\n color: string;\n}\n\n/** Imperative handle for programmatic control of a {@link PdfViewer} or {@link BasePdfViewer}. */\nexport interface PdfViewerHandle {\n /** Scroll the viewer to the given page number (1-indexed). */\n scrollToPage: (page: number) => void;\n /** Programmatically delete a highlight by its `editorId` (from {@link PdfTextHighlightEvent}). */\n deleteHighlight: (editorId: string) => void;\n}\n\n/**\n * Options for {@link usePdfViewerInstance}.\n * Equivalent to {@link PdfViewerProps} minus the `className` rendering concern.\n */\nexport interface PdfViewerInstanceOptions {\n /** PDF source — URL string, ArrayBuffer, Uint8Array, or Blob */\n src: PdfSource;\n /** Annotations to overlay on the PDF */\n annotations?: PdfAnnotation[];\n /** Callback fired when an annotation is clicked */\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n /** Callback fired when a download completes or fails */\n onDownload?: (result: PdfDownloadResult) => void;\n /** Whether the highlight toggle button is shown in the toolbar */\n highlightEnabled?: boolean;\n /** Callback fired when the user creates a text highlight */\n onTextHighlight?: (event: PdfTextHighlightEvent) => void;\n /** Callback fired when the user deletes a highlight */\n onHighlightDelete?: (event: PdfTextHighlightEvent) => void;\n /** Initial form field values keyed by field name */\n formData?: Record<string, PdfFormFieldValue>;\n /** Callback fired when the user clicks the save button */\n onFormSubmit?: (data: Record<string, PdfFormFieldValue>) => void;\n /** Callback fired when any form field value changes */\n onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /**\n * Whether auto-size (fit to width) is initially enabled.\n * When enabled, the PDF scales to fit the container width and\n * re-fits automatically on resize. Manual zoom disables auto-size.\n * Takes precedence over {@link initialScale} when enabled.\n * @default false\n */\n initialAutoSize?: boolean;\n /** Whether the sidebar is initially open (default false) */\n initialSidebarOpen?: boolean;\n /** Whether the download button is shown in the toolbar */\n enableDownload?: boolean;\n /** Which sidebar panel to show: thumbnails or document outline */\n sidebarMode?: SidebarMode;\n /** Custom icon components for each outline depth level (0-indexed) */\n outlineIcons?: Partial<Record<number, React.ComponentType>>;\n}\n\n/**\n * PDF source input.\n *\n * - `string` — a URL the PDF is fetched from\n * - `ArrayBuffer` / `Uint8Array` — raw PDF bytes already in memory (a Node\n * `Buffer` satisfies `Uint8Array` and is accepted as-is)\n * - `Blob` — read into an `ArrayBuffer` before rendering\n */\nexport type PdfSource = string | ArrayBuffer | Uint8Array | Blob;\n\n/** Props for the {@link PdfViewer} component. */\nexport interface PdfViewerProps {\n /** PDF source — URL string, ArrayBuffer, Uint8Array, or Blob */\n src: PdfSource;\n /** Annotations to overlay on the PDF */\n annotations?: PdfAnnotation[];\n /**\n * Callback fired when an annotation is clicked.\n *\n * @param annotation - The annotation that was clicked\n * @returns void\n */\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n /**\n * Callback fired when a download completes or fails.\n *\n * @param result - The download result indicating success with the filename, or failure with an error\n * @returns void\n */\n onDownload?: (result: PdfDownloadResult) => void;\n /**\n * Whether the highlight toggle button is shown in the toolbar.\n * @default false\n */\n enableHighlight?: boolean;\n /**\n * Callback fired when the user creates a text highlight.\n * Only fires when highlight mode is active.\n *\n * @param event - The highlight event with page, rects, text, and color\n * @returns void\n */\n onTextHighlight?: (event: PdfTextHighlightEvent) => void;\n /**\n * Callback fired when the user deletes a highlight via the PDF.js editor UI.\n *\n * @param event - The highlight event that was deleted\n * @returns void\n */\n onHighlightDelete?: (event: PdfTextHighlightEvent) => void;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /**\n * Whether auto-size (fit to width) is initially enabled.\n * When enabled, the PDF scales to fit the container width and\n * re-fits automatically on resize. Manual zoom disables auto-size.\n * Takes precedence over {@link initialScale} when enabled.\n * @default false\n */\n initialAutoSize?: boolean;\n /** Whether the sidebar is initially open (default false) */\n initialSidebarOpen?: boolean;\n /**\n * Whether the download button is shown in the toolbar.\n * @default false\n */\n enableDownload?: boolean;\n /**\n * Filename used when the user downloads the PDF via the toolbar button.\n * If omitted, the name is derived from the `src` URL, falling back to \"document.pdf\".\n */\n downloadFileName?: string;\n /**\n * Which sidebar panel to show: thumbnails or document outline.\n * @default \"thumbnails\"\n */\n sidebarMode?: SidebarMode;\n /**\n * Custom icon components for each outline depth level (0-indexed).\n * Key 0 = top-level items, 1 = first nesting level, etc.\n * If omitted, no icons are rendered.\n */\n outlineIcons?: Partial<Record<number, React.ComponentType>>;\n /**\n * Initial form field values keyed by field name. Applied when the document loads.\n * Use this to pre-populate form fields when resuming a previously edited PDF.\n */\n formData?: Record<string, PdfFormFieldValue>;\n /**\n * Callback fired when the user clicks the save button in the toolbar.\n * Receives all current form field values keyed by field name.\n *\n * @param data - All form field values keyed by field name\n * @returns void\n */\n onFormSubmit?: (data: Record<string, PdfFormFieldValue>) => void;\n /**\n * Callback fired when any form field value changes.\n *\n * @param fieldName - The name of the field that changed\n * @param value - The new value\n * @returns void\n */\n onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;\n /** Additional CSS class name for the root element */\n className?: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"pdf-viewer.js","names":["BasePdfViewer","PdfViewerAnnotationLayer","PdfViewerContent","PdfViewerOutlineSidebar","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","usePdfAnnotationPortals","usePdfAnnotationsByPage","usePdfDocument","usePdfFormFields","usePdfHighlightMode","usePdfOutline","usePdfViewer","usePdfViewerSearch","usePdfViewerSync","PdfViewerProvider","usePdfViewerContext","usePdfViewerInstance","usePdfViewerCore","usePdfViewerState","PdfViewer","_PdfViewer","withOsdkMetrics"],"sources":["pdf-viewer.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// PdfViewer\nexport { BasePdfViewer } from \"../../pdf-viewer/PdfViewer.js\";\nexport type {\n AnnotationType,\n PdfAnnotation,\n PdfAnnotationRenderProps,\n PdfCustomAnnotation,\n PdfDownloadResult,\n PdfFormFieldValue,\n PdfRect,\n PdfTextHighlightEvent,\n PdfViewerProps,\n SidebarMode,\n} from \"../../pdf-viewer/types.js\";\n\n// PdfViewer building blocks\nexport {\n PdfViewerAnnotationLayer,\n type PdfViewerAnnotationLayerProps,\n} from \"../../pdf-viewer/components/PdfViewerAnnotationLayer.js\";\nexport {\n PdfViewerContent,\n type PdfViewerContentProps,\n} from \"../../pdf-viewer/components/PdfViewerContent.js\";\nexport {\n PdfViewerOutlineSidebar,\n type PdfViewerOutlineSidebarProps,\n} from \"../../pdf-viewer/components/PdfViewerOutlineSidebar.js\";\nexport {\n PdfViewerSearchBar,\n type PdfViewerSearchBarProps,\n} from \"../../pdf-viewer/components/PdfViewerSearchBar.js\";\nexport {\n PdfViewerSidebar,\n type PdfViewerSidebarProps,\n} from \"../../pdf-viewer/components/PdfViewerSidebar.js\";\nexport {\n PdfViewerToolbar,\n type PdfViewerToolbarProps,\n} from \"../../pdf-viewer/components/PdfViewerToolbar.js\";\n\n// PdfViewer hooks — primitive\nexport {\n type AnnotationPortalTarget,\n usePdfAnnotationPortals,\n} from \"../../pdf-viewer/hooks/usePdfAnnotationPortals.js\";\nexport { usePdfAnnotationsByPage } from \"../../pdf-viewer/hooks/usePdfAnnotationsByPage.js\";\nexport { usePdfDocument } from \"../../pdf-viewer/hooks/usePdfDocument.js\";\nexport {\n usePdfFormFields,\n type UsePdfFormFieldsOptions,\n type UsePdfFormFieldsResult,\n} from \"../../pdf-viewer/hooks/usePdfFormFields.js\";\nexport {\n usePdfHighlightMode,\n type UsePdfHighlightModeOptions,\n type UsePdfHighlightModeResult,\n} from \"../../pdf-viewer/hooks/usePdfHighlightMode.js\";\nexport { usePdfOutline } from \"../../pdf-viewer/hooks/usePdfOutline.js\";\nexport {\n usePdfViewer,\n type UsePdfViewerResult,\n} from \"../../pdf-viewer/hooks/usePdfViewer.js\";\nexport {\n usePdfViewerSearch,\n type UsePdfViewerSearchResult,\n} from \"../../pdf-viewer/hooks/usePdfViewerSearch.js\";\nexport { usePdfViewerSync } from \"../../pdf-viewer/hooks/usePdfViewerSync.js\";\nexport { type OutlineItem } from \"../../pdf-viewer/types.js\";\n\n// PdfViewer context\nexport {\n type PdfViewerContextValue,\n PdfViewerProvider,\n usePdfViewerContext,\n usePdfViewerInstance,\n} from \"../../pdf-viewer/PdfViewerContext.js\";\nexport type {\n PdfViewerHandle,\n PdfViewerInstanceOptions,\n} from \"../../pdf-viewer/types.js\";\n\n// PdfViewer hooks — composition\nexport {\n usePdfViewerCore,\n type UsePdfViewerCoreOptions,\n type UsePdfViewerCoreResult,\n} from \"../../pdf-viewer/hooks/usePdfViewerCore.js\";\nexport {\n usePdfViewerState,\n type UsePdfViewerStateOptions,\n type UsePdfViewerStateResult,\n} from \"../../pdf-viewer/hooks/usePdfViewerState.js\";\n\n// PdfViewer (Media wrapper)\nimport { PdfViewer as _PdfViewer } from \"../../pdf-viewer/PdfRenderer.js\";\nimport { withOsdkMetrics } from \"../../util/withOsdkMetrics.js\";\nexport const PdfViewer: typeof _PdfViewer = withOsdkMetrics(\n _PdfViewer,\n \"PdfViewer\"\n);\nexport type { PdfViewerMediaProps } from \"../../pdf-viewer/PdfRenderer.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASA,aAAa,QAAQ,+BAA+B;AAc7D;AACA,SACEC,wBAAwB,QAEnB,yDAAyD;AAChE,SACEC,gBAAgB,QAEX,iDAAiD;AACxD,SACEC,uBAAuB,QAElB,wDAAwD;AAC/D,SACEC,kBAAkB,QAEb,mDAAmD;AAC1D,SACEC,gBAAgB,QAEX,iDAAiD;AACxD,SACEC,gBAAgB,QAEX,iDAAiD;;AAExD;AACA,SAEEC,uBAAuB,QAClB,mDAAmD;AAC1D,SAASC,uBAAuB,QAAQ,mDAAmD;AAC3F,SAASC,cAAc,QAAQ,0CAA0C;AACzE,SACEC,gBAAgB,QAGX,4CAA4C;AACnD,SACEC,mBAAmB,QAGd,+CAA+C;AACtD,SAASC,aAAa,QAAQ,yCAAyC;AACvE,SACEC,YAAY,QAEP,wCAAwC;AAC/C,SACEC,kBAAkB,QAEb,8CAA8C;AACrD,SAASC,gBAAgB,QAAQ,4CAA4C;AAG7E;AACA,SAEEC,iBAAiB,EACjBC,mBAAmB,EACnBC,oBAAoB,QACf,sCAAsC;AAM7C;AACA,SACEC,gBAAgB,QAGX,4CAA4C;AACnD,SACEC,iBAAiB,QAGZ,6CAA6C;;AAEpD;AACA,SAASC,SAAS,IAAIC,UAAU,QAAQ,iCAAiC;AACzE,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,OAAO,MAAMF,SAA4B,GAAGE,eAAe,CACzDD,UAAU,EACV,WACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"pdf-viewer.js","names":["BasePdfViewer","PdfViewerAnnotationLayer","PdfViewerContent","PdfViewerOutlineSidebar","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","usePdfAnnotationPortals","usePdfAnnotationsByPage","usePdfDocument","usePdfFormFields","usePdfHighlightMode","usePdfOutline","usePdfViewer","usePdfViewerSearch","usePdfViewerSync","PdfViewerProvider","usePdfViewerContext","usePdfViewerInstance","usePdfViewerCore","usePdfViewerState","PdfViewer","_PdfViewer","withOsdkMetrics"],"sources":["pdf-viewer.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// PdfViewer\nexport { BasePdfViewer } from \"../../pdf-viewer/PdfViewer.js\";\nexport type {\n AnnotationType,\n PdfAnnotation,\n PdfAnnotationRenderProps,\n PdfCustomAnnotation,\n PdfDownloadResult,\n PdfFormFieldValue,\n PdfRect,\n PdfSource,\n PdfTextHighlightEvent,\n PdfViewerProps,\n SidebarMode,\n} from \"../../pdf-viewer/types.js\";\n\n// PdfViewer building blocks\nexport {\n PdfViewerAnnotationLayer,\n type PdfViewerAnnotationLayerProps,\n} from \"../../pdf-viewer/components/PdfViewerAnnotationLayer.js\";\nexport {\n PdfViewerContent,\n type PdfViewerContentProps,\n} from \"../../pdf-viewer/components/PdfViewerContent.js\";\nexport {\n PdfViewerOutlineSidebar,\n type PdfViewerOutlineSidebarProps,\n} from \"../../pdf-viewer/components/PdfViewerOutlineSidebar.js\";\nexport {\n PdfViewerSearchBar,\n type PdfViewerSearchBarProps,\n} from \"../../pdf-viewer/components/PdfViewerSearchBar.js\";\nexport {\n PdfViewerSidebar,\n type PdfViewerSidebarProps,\n} from \"../../pdf-viewer/components/PdfViewerSidebar.js\";\nexport {\n PdfViewerToolbar,\n type PdfViewerToolbarProps,\n} from \"../../pdf-viewer/components/PdfViewerToolbar.js\";\n\n// PdfViewer hooks — primitive\nexport {\n type AnnotationPortalTarget,\n usePdfAnnotationPortals,\n} from \"../../pdf-viewer/hooks/usePdfAnnotationPortals.js\";\nexport { usePdfAnnotationsByPage } from \"../../pdf-viewer/hooks/usePdfAnnotationsByPage.js\";\nexport { usePdfDocument } from \"../../pdf-viewer/hooks/usePdfDocument.js\";\nexport {\n usePdfFormFields,\n type UsePdfFormFieldsOptions,\n type UsePdfFormFieldsResult,\n} from \"../../pdf-viewer/hooks/usePdfFormFields.js\";\nexport {\n usePdfHighlightMode,\n type UsePdfHighlightModeOptions,\n type UsePdfHighlightModeResult,\n} from \"../../pdf-viewer/hooks/usePdfHighlightMode.js\";\nexport { usePdfOutline } from \"../../pdf-viewer/hooks/usePdfOutline.js\";\nexport {\n usePdfViewer,\n type UsePdfViewerResult,\n} from \"../../pdf-viewer/hooks/usePdfViewer.js\";\nexport {\n usePdfViewerSearch,\n type UsePdfViewerSearchResult,\n} from \"../../pdf-viewer/hooks/usePdfViewerSearch.js\";\nexport { usePdfViewerSync } from \"../../pdf-viewer/hooks/usePdfViewerSync.js\";\nexport { type OutlineItem } from \"../../pdf-viewer/types.js\";\n\n// PdfViewer context\nexport {\n type PdfViewerContextValue,\n PdfViewerProvider,\n usePdfViewerContext,\n usePdfViewerInstance,\n} from \"../../pdf-viewer/PdfViewerContext.js\";\nexport type {\n PdfViewerHandle,\n PdfViewerInstanceOptions,\n} from \"../../pdf-viewer/types.js\";\n\n// PdfViewer hooks — composition\nexport {\n usePdfViewerCore,\n type UsePdfViewerCoreOptions,\n type UsePdfViewerCoreResult,\n} from \"../../pdf-viewer/hooks/usePdfViewerCore.js\";\nexport {\n usePdfViewerState,\n type UsePdfViewerStateOptions,\n type UsePdfViewerStateResult,\n} from \"../../pdf-viewer/hooks/usePdfViewerState.js\";\n\n// PdfViewer (Media wrapper)\nimport { PdfViewer as _PdfViewer } from \"../../pdf-viewer/PdfRenderer.js\";\nimport { withOsdkMetrics } from \"../../util/withOsdkMetrics.js\";\nexport const PdfViewer: typeof _PdfViewer = withOsdkMetrics(\n _PdfViewer,\n \"PdfViewer\"\n);\nexport type { PdfViewerMediaProps } from \"../../pdf-viewer/PdfRenderer.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASA,aAAa,QAAQ,+BAA+B;AAe7D;AACA,SACEC,wBAAwB,QAEnB,yDAAyD;AAChE,SACEC,gBAAgB,QAEX,iDAAiD;AACxD,SACEC,uBAAuB,QAElB,wDAAwD;AAC/D,SACEC,kBAAkB,QAEb,mDAAmD;AAC1D,SACEC,gBAAgB,QAEX,iDAAiD;AACxD,SACEC,gBAAgB,QAEX,iDAAiD;;AAExD;AACA,SAEEC,uBAAuB,QAClB,mDAAmD;AAC1D,SAASC,uBAAuB,QAAQ,mDAAmD;AAC3F,SAASC,cAAc,QAAQ,0CAA0C;AACzE,SACEC,gBAAgB,QAGX,4CAA4C;AACnD,SACEC,mBAAmB,QAGd,+CAA+C;AACtD,SAASC,aAAa,QAAQ,yCAAyC;AACvE,SACEC,YAAY,QAEP,wCAAwC;AAC/C,SACEC,kBAAkB,QAEb,8CAA8C;AACrD,SAASC,gBAAgB,QAAQ,4CAA4C;AAG7E;AACA,SAEEC,iBAAiB,EACjBC,mBAAmB,EACnBC,oBAAoB,QACf,sCAAsC;AAM7C;AACA,SACEC,gBAAgB,QAGX,4CAA4C;AACnD,SACEC,iBAAiB,QAGZ,6CAA6C;;AAEpD;AACA,SAASC,SAAS,IAAIC,UAAU,QAAQ,iCAAiC;AACzE,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,OAAO,MAAMF,SAA4B,GAAGE,eAAe,CACzDD,UAAU,EACV,WACF,CAAC","ignoreList":[]}
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- const PACKAGE_USER_AGENT = `osdk-react-components/${"0.37.0"}`;
17
+ const PACKAGE_USER_AGENT = `osdk-react-components/${"0.38.0-main-1b33456f25e1ced9c8ce17587cdd559d4337a247"}`;
18
18
  export function componentUserAgent(componentName) {
19
19
  return `${PACKAGE_USER_AGENT}/${componentName}`;
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UserAgent.js","names":["PACKAGE_USER_AGENT","componentUserAgent","componentName"],"sources":["UserAgent.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst PACKAGE_USER_AGENT = `osdk-react-components/${process.env.PACKAGE_VERSION}`;\n\nexport function componentUserAgent(componentName: string): string {\n return `${PACKAGE_USER_AGENT}/${componentName}`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,kBAAkB,GAAG,mCAAsD;AAEjF,OAAO,SAASC,kBAAkBA,CAACC,aAAqB,EAAU;EAChE,OAAO,GAAGF,kBAAkB,IAAIE,aAAa,EAAE;AACjD","ignoreList":[]}
1
+ {"version":3,"file":"UserAgent.js","names":["PACKAGE_USER_AGENT","componentUserAgent","componentName"],"sources":["UserAgent.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst PACKAGE_USER_AGENT = `osdk-react-components/${process.env.PACKAGE_VERSION}`;\n\nexport function componentUserAgent(componentName: string): string {\n return `${PACKAGE_USER_AGENT}/${componentName}`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,kBAAkB,GAAG,iFAAsD;AAEjF,OAAO,SAASC,kBAAkBA,CAACC,aAAqB,EAAU;EAChE,OAAO,GAAGF,kBAAkB,IAAIE,aAAa,EAAE;AACjD","ignoreList":[]}
@@ -21,6 +21,9 @@ import React from "react";
21
21
  import { useMediaContents } from "../shared/hooks/useMediaContents.js";
22
22
  import { BaseXmlViewer } from "./BaseXmlViewer.js";
23
23
  import styles from "./BaseXmlViewer.module.css.js";
24
+
25
+ // TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.
26
+ // oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed
24
27
  const transformToText = async response => {
25
28
  return response.text();
26
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"XmlViewer.js","names":["Error","ErrorIcon","Spin","classnames","React","useMediaContents","BaseXmlViewer","styles","transformToText","response","text","XmlViewer","media","className","xmlViewerProps","data","content","loading","error","rootClassName","container","createElement","loadingContainer","spinnerIcon","errorContainer","errorIcon","message","_extends"],"sources":["XmlViewer.tsx"],"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 { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport React from \"react\";\n\nimport { useMediaContents } from \"../shared/hooks/useMediaContents.js\";\nimport { BaseXmlViewer } from \"./BaseXmlViewer.js\";\nimport type { XmlViewerMediaProps } from \"./XmlViewerApi.js\";\n\nimport styles from \"./BaseXmlViewer.module.css\";\n\nconst transformToText = async (response: Response): Promise<string> => {\n return response.text();\n};\n\nexport function XmlViewer({\n media,\n className,\n ...xmlViewerProps\n}: XmlViewerMediaProps): React.ReactElement {\n const {\n data: content,\n loading,\n error,\n } = useMediaContents(media, transformToText);\n\n const rootClassName = classnames(styles.container, className);\n\n return (\n <div className={rootClassName}>\n {loading && (\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n )}\n {error != null && (\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load XML: {error.message}\n </div>\n )}\n {content != null && (\n <BaseXmlViewer content={content} {...xmlViewerProps} />\n )}\n </div>\n );\n}\n"],"mappings":";AAAA;AACA;AACA;AAC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EAAEA;EAAQ,GAAKF,cAAc,CAAG,CAErD,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"XmlViewer.js","names":["Error","ErrorIcon","Spin","classnames","React","useMediaContents","BaseXmlViewer","styles","transformToText","response","text","XmlViewer","media","className","xmlViewerProps","data","content","loading","error","rootClassName","container","createElement","loadingContainer","spinnerIcon","errorContainer","errorIcon","message","_extends"],"sources":["XmlViewer.tsx"],"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 { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport React from \"react\";\n\nimport { useMediaContents } from \"../shared/hooks/useMediaContents.js\";\nimport { BaseXmlViewer } from \"./BaseXmlViewer.js\";\nimport type { XmlViewerMediaProps } from \"./XmlViewerApi.js\";\n\nimport styles from \"./BaseXmlViewer.module.css\";\n\n// TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.\n// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\nconst transformToText = async (response: Response): Promise<string> => {\n return response.text();\n};\n\nexport function XmlViewer({\n media,\n className,\n ...xmlViewerProps\n}: XmlViewerMediaProps): React.ReactElement {\n const {\n data: content,\n loading,\n error,\n } = useMediaContents(media, transformToText);\n\n const rootClassName = classnames(styles.container, className);\n\n return (\n <div className={rootClassName}>\n {loading && (\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n )}\n {error != null && (\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load XML: {error.message}\n </div>\n )}\n {content != null && (\n <BaseXmlViewer content={content} {...xmlViewerProps} />\n )}\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,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,gBAAgB,QAAQ,qCAAqC;AACtE,SAASC,aAAa,QAAQ,oBAAoB;AAGlD,OAAOC,MAAM,MAAM,4BAA4B;;AAE/C;AACA;AACA,MAAMC,eAAe,GAAG,MAAOC,QAAkB,IAAsB;EACrE,OAAOA,QAAQ,CAACC,IAAI,CAAC,CAAC;AACxB,CAAC;AAED,OAAO,SAASC,SAASA,CAAC;EACxBC,KAAK;EACLC,SAAS;EACT,GAAGC;AACgB,CAAC,EAAsB;EAC1C,MAAM;IACJC,IAAI,EAAEC,OAAO;IACbC,OAAO;IACPC;EACF,CAAC,GAAGb,gBAAgB,CAACO,KAAK,EAAEJ,eAAe,CAAC;EAE5C,MAAMW,aAAa,GAAGhB,UAAU,CAACI,MAAM,CAACa,SAAS,EAAEP,SAAS,CAAC;EAE7D,oBACET,KAAA,CAAAiB,aAAA;IAAKR,SAAS,EAAEM;EAAc,GAC3BF,OAAO,iBACNb,KAAA,CAAAiB,aAAA;IAAKR,SAAS,EAAEN,MAAM,CAACe;EAAiB,gBACtClB,KAAA,CAAAiB,aAAA,CAACnB,IAAI;IAACW,SAAS,EAAEN,MAAM,CAACgB;EAAY,CAAE,CAAC,iBAEpC,CACN,EACAL,KAAK,IAAI,IAAI,iBACZd,KAAA,CAAAiB,aAAA;IAAKR,SAAS,EAAEN,MAAM,CAACiB;EAAe,gBACpCpB,KAAA,CAAAiB,aAAA,CAACpB,SAAS;IAACY,SAAS,EAAEN,MAAM,CAACkB;EAAU,CAAE,CAAC,wBACtB,EAACP,KAAK,CAACQ,OACxB,CACN,EACAV,OAAO,IAAI,IAAI,iBACdZ,KAAA,CAAAiB,aAAA,CAACf,aAAa,EAAAqB,QAAA;IAACX,OAAO,EAAEA;EAAQ,GAAKF,cAAc,CAAG,CAErD,CAAC;AAEV","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var chunkOISZU73V_cjs = require('./chunk-OISZU73V.cjs');
4
+ var chunkBCIH6LUS_cjs = require('./chunk-BCIH6LUS.cjs');
5
+
6
+ // src/public/experimental/email-viewer.ts
7
+ var EmailViewer2 = chunkBCIH6LUS_cjs.withOsdkMetrics(chunkOISZU73V_cjs.EmailViewer, "EmailViewer");
8
+
9
+ exports.EmailViewer = EmailViewer2;
10
+ //# sourceMappingURL=chunk-6KC2X46P.cjs.map
11
+ //# sourceMappingURL=chunk-6KC2X46P.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/public/experimental/email-viewer.ts"],"names":["EmailViewer","withOsdkMetrics"],"mappings":";;;;;;AAqBO,IAAMA,YAAAA,GAAcC,iCAAA,CAAgBD,6BAAA,EAAc,aAAa","file":"chunk-XRI2RLG7.cjs","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\n// BaseEmailViewer\nexport { BaseEmailViewer } from \"../../email-viewer/BaseEmailViewer.js\";\n// EmailViewer (Media wrapper)\nimport { EmailViewer as _EmailViewer } from \"../../email-viewer/EmailViewer.js\";\nimport { withOsdkMetrics } from \"../../util/withOsdkMetrics.js\";\nexport const EmailViewer = withOsdkMetrics(_EmailViewer, \"EmailViewer\");"]}
1
+ {"version":3,"sources":["../../src/public/experimental/email-viewer.ts"],"names":["EmailViewer","withOsdkMetrics"],"mappings":";;;;;;AAqBO,IAAMA,YAAAA,GAAcC,iCAAA,CAAgBD,6BAAA,EAAc,aAAa","file":"chunk-6KC2X46P.cjs","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\n// BaseEmailViewer\nexport { BaseEmailViewer } from \"../../email-viewer/BaseEmailViewer.js\";\n// EmailViewer (Media wrapper)\nimport { EmailViewer as _EmailViewer } from \"../../email-viewer/EmailViewer.js\";\nimport { withOsdkMetrics } from \"../../util/withOsdkMetrics.js\";\nexport const EmailViewer = withOsdkMetrics(_EmailViewer, \"EmailViewer\");"]}
@@ -6,7 +6,7 @@ var chunkNME4K4OR_cjs = require('./chunk-NME4K4OR.cjs');
6
6
  var chunkFVTTRDL6_cjs = require('./chunk-FVTTRDL6.cjs');
7
7
  var chunk7LXS66DW_cjs = require('./chunk-7LXS66DW.cjs');
8
8
  var chunkUCTQICPR_cjs = require('./chunk-UCTQICPR.cjs');
9
- var chunkMVUTL2YO_cjs = require('./chunk-MVUTL2YO.cjs');
9
+ var chunkBCIH6LUS_cjs = require('./chunk-BCIH6LUS.cjs');
10
10
  var button = require('@base-ui/react/button');
11
11
  var classnames3 = require('classnames');
12
12
  var React15 = require('react');
@@ -5576,7 +5576,7 @@ function summarizeFilterValue(definition, state) {
5576
5576
  }
5577
5577
 
5578
5578
  // src/public/experimental/filter-list.ts
5579
- var FilterList2 = chunkMVUTL2YO_cjs.withOsdkMetrics(FilterList, "FilterList");
5579
+ var FilterList2 = chunkBCIH6LUS_cjs.withOsdkMetrics(FilterList, "FilterList");
5580
5580
 
5581
5581
  exports.BaseFilterList = BaseFilterList;
5582
5582
  exports.FilterInput = FilterInput;
@@ -5591,5 +5591,5 @@ exports.narrowObjectSet = narrowObjectSet;
5591
5591
  exports.serializeFilterStates = serializeFilterStates;
5592
5592
  exports.summarizeFilterValue = summarizeFilterValue;
5593
5593
  exports.useFilterListState = useFilterListState;
5594
- //# sourceMappingURL=chunk-2TBIJGID.cjs.map
5595
- //# sourceMappingURL=chunk-2TBIJGID.cjs.map
5594
+ //# sourceMappingURL=chunk-6MS4BCHK.cjs.map
5595
+ //# sourceMappingURL=chunk-6MS4BCHK.cjs.map