@osdk/react-components 0.20.0-main-4e2a115a796e8664c3972548bb02e707baafa912 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -10
- package/build/browser/object-table/ObjectTable.js +2 -1
- package/build/browser/object-table/ObjectTable.js.map +1 -1
- package/build/browser/object-table/ObjectTableApi.js.map +1 -1
- package/build/browser/object-table/hooks/useObjectTableData.js +5 -3
- package/build/browser/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/browser/pdf-viewer/PdfViewer.js +4 -6
- package/build/browser/pdf-viewer/PdfViewer.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfAnnotationOverlay.js +43 -0
- package/build/browser/pdf-viewer/components/PdfAnnotationOverlay.js.map +1 -0
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js +22 -14
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerContent.js +4 -6
- package/build/browser/pdf-viewer/components/PdfViewerContent.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfAnnotationPortals.js +83 -13
- package/build/browser/pdf-viewer/hooks/usePdfAnnotationPortals.js.map +1 -1
- package/build/browser/pdf-viewer/types.js.map +1 -1
- package/build/browser/shared/calendar/DatePickerCommon.module.css +5 -0
- package/build/browser/styles.css +5 -0
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/cjs/chunk-2GAPPUP5.cjs +11 -0
- package/build/cjs/{chunk-BN5MGNSI.cjs.map → chunk-2GAPPUP5.cjs.map} +1 -1
- package/build/cjs/{chunk-QYUADULX.cjs → chunk-4MGATUJ3.cjs} +17 -17
- package/build/cjs/{chunk-QYUADULX.cjs.map → chunk-4MGATUJ3.cjs.map} +1 -1
- package/build/cjs/{chunk-HOPH2463.cjs → chunk-4WDDVYWV.cjs} +3 -3
- package/build/cjs/chunk-4WDDVYWV.cjs.map +1 -0
- package/build/cjs/chunk-5UTN55T6.cjs +11 -0
- package/build/cjs/{chunk-LLGHXDSY.cjs.map → chunk-5UTN55T6.cjs.map} +1 -1
- package/build/cjs/{chunk-YWDLYGD5.cjs → chunk-AICPFRJQ.cjs} +32 -32
- package/build/cjs/{chunk-YWDLYGD5.cjs.map → chunk-AICPFRJQ.cjs.map} +1 -1
- package/build/cjs/{chunk-WYIUQ3FZ.cjs → chunk-DAHWLFFD.cjs} +4 -4
- package/build/cjs/{chunk-WYIUQ3FZ.cjs.map → chunk-DAHWLFFD.cjs.map} +1 -1
- package/build/cjs/{chunk-ETOC4FJE.cjs → chunk-FWZS3WQ4.cjs} +135 -34
- package/build/cjs/chunk-FWZS3WQ4.cjs.map +1 -0
- package/build/cjs/{chunk-67LMSFXM.cjs → chunk-GUBIWML7.cjs} +16 -13
- package/build/cjs/chunk-GUBIWML7.cjs.map +1 -0
- package/build/cjs/chunk-KLL6MAZL.cjs +11 -0
- package/build/cjs/{chunk-YWYFWFUF.cjs.map → chunk-KLL6MAZL.cjs.map} +1 -1
- package/build/cjs/{chunk-7CYKOZFL.cjs → chunk-LIF2LJ2I.cjs} +7 -7
- package/build/cjs/{chunk-7CYKOZFL.cjs.map → chunk-LIF2LJ2I.cjs.map} +1 -1
- package/build/cjs/{chunk-4JJP3RNQ.cjs → chunk-PPQSIR4K.cjs} +4 -4
- package/build/cjs/{chunk-4JJP3RNQ.cjs.map → chunk-PPQSIR4K.cjs.map} +1 -1
- package/build/cjs/{chunk-4V245Z6A.cjs → chunk-PWXV5SBK.cjs} +26 -28
- package/build/cjs/chunk-PWXV5SBK.cjs.map +1 -0
- package/build/cjs/chunk-UJKIIMIE.cjs +11 -0
- package/build/cjs/{chunk-DCRVOHKP.cjs.map → chunk-UJKIIMIE.cjs.map} +1 -1
- package/build/cjs/chunk-VBM5GWFP.cjs +11 -0
- package/build/cjs/{chunk-LGUTBX34.cjs.map → chunk-VBM5GWFP.cjs.map} +1 -1
- package/build/cjs/{chunk-4KC5U44T.cjs → chunk-XA3S7YAO.cjs} +2 -2
- package/build/cjs/chunk-XA3S7YAO.cjs.map +1 -0
- package/build/cjs/{chunk-GN3PIYGH.cjs → chunk-Y6BGC7DP.cjs} +22 -22
- package/build/cjs/{chunk-GN3PIYGH.cjs.map → chunk-Y6BGC7DP.cjs.map} +1 -1
- package/build/cjs/public/experimental/action-form.cjs +6 -6
- package/build/cjs/public/experimental/action-form.css +3 -0
- package/build/cjs/public/experimental/action-form.css.map +1 -1
- package/build/cjs/public/experimental/document-viewer.cjs +5 -5
- package/build/cjs/public/experimental/document-viewer.d.cts +1 -1
- package/build/cjs/public/experimental/email-viewer.cjs +3 -3
- package/build/cjs/public/experimental/excel-viewer.cjs +3 -3
- package/build/cjs/public/experimental/filter-list.cjs +15 -15
- package/build/cjs/public/experimental/filter-list.css +3 -0
- package/build/cjs/public/experimental/filter-list.css.map +1 -1
- package/build/cjs/public/experimental/image-viewer.cjs +3 -3
- package/build/cjs/public/experimental/markdown-renderer.cjs +3 -3
- package/build/cjs/public/experimental/object-table.cjs +10 -10
- package/build/cjs/public/experimental/object-table.css +3 -0
- package/build/cjs/public/experimental/object-table.css.map +1 -1
- package/build/cjs/public/experimental/object-table.d.cts +14 -1
- package/build/cjs/public/experimental/pdf-viewer.cjs +25 -25
- package/build/cjs/public/experimental/pdf-viewer.d.cts +9 -4
- package/build/cjs/public/experimental/tiff-renderer.cjs +3 -3
- package/build/cjs/public/experimental/video-viewer.cjs +3 -3
- package/build/cjs/public/experimental/xml-viewer.cjs +3 -3
- package/build/cjs/public/experimental.cjs +67 -67
- package/build/cjs/public/experimental.css +3 -0
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +1 -1
- package/build/cjs/{types-CbSNeyzw.d.cts → types-Cg_LdKf-.d.cts} +1 -0
- package/build/esm/object-table/ObjectTable.js +2 -1
- package/build/esm/object-table/ObjectTable.js.map +1 -1
- package/build/esm/object-table/ObjectTableApi.js.map +1 -1
- package/build/esm/object-table/hooks/useObjectTableData.js +5 -3
- package/build/esm/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/esm/pdf-viewer/PdfViewer.js +4 -6
- package/build/esm/pdf-viewer/PdfViewer.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfAnnotationOverlay.js +43 -0
- package/build/esm/pdf-viewer/components/PdfAnnotationOverlay.js.map +1 -0
- package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js +22 -14
- package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerContent.js +4 -6
- package/build/esm/pdf-viewer/components/PdfViewerContent.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfAnnotationPortals.js +83 -13
- package/build/esm/pdf-viewer/hooks/usePdfAnnotationPortals.js.map +1 -1
- package/build/esm/pdf-viewer/types.js.map +1 -1
- package/build/esm/shared/calendar/DatePickerCommon.module.css +5 -0
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/types/object-table/ObjectTable.d.ts +1 -1
- package/build/types/object-table/ObjectTable.d.ts.map +1 -1
- package/build/types/object-table/ObjectTableApi.d.ts +13 -0
- package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
- package/build/types/object-table/hooks/useObjectTableData.d.ts +1 -1
- package/build/types/object-table/hooks/useObjectTableData.d.ts.map +1 -1
- package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -1
- package/build/types/pdf-viewer/components/PdfAnnotationOverlay.d.ts +9 -0
- package/build/types/pdf-viewer/components/PdfAnnotationOverlay.d.ts.map +1 -0
- package/build/types/pdf-viewer/components/PdfViewerAnnotationLayer.d.ts +2 -1
- package/build/types/pdf-viewer/components/PdfViewerAnnotationLayer.d.ts.map +1 -1
- package/build/types/pdf-viewer/components/PdfViewerContent.d.ts.map +1 -1
- package/build/types/pdf-viewer/hooks/usePdfAnnotationPortals.d.ts +5 -1
- package/build/types/pdf-viewer/hooks/usePdfAnnotationPortals.d.ts.map +1 -1
- package/build/types/pdf-viewer/types.d.ts +1 -0
- package/build/types/pdf-viewer/types.d.ts.map +1 -1
- package/docs/GettingStarted.md +65 -0
- package/docs/ObjectTable.md +6 -5
- package/docs/Prerequisites.md +1 -2
- package/docs/StylingOverview.md +146 -0
- package/docs/TokenColors.md +130 -0
- package/docs/TokenSpacing.md +73 -0
- package/docs/TokenTypography.md +57 -0
- package/docs/UsageWithOsdk.md +47 -0
- package/docs/Welcome.md +42 -0
- package/package.json +8 -8
- package/build/cjs/chunk-4KC5U44T.cjs.map +0 -1
- package/build/cjs/chunk-4V245Z6A.cjs.map +0 -1
- package/build/cjs/chunk-67LMSFXM.cjs.map +0 -1
- package/build/cjs/chunk-BN5MGNSI.cjs +0 -11
- package/build/cjs/chunk-DCRVOHKP.cjs +0 -11
- package/build/cjs/chunk-ETOC4FJE.cjs.map +0 -1
- package/build/cjs/chunk-HOPH2463.cjs.map +0 -1
- package/build/cjs/chunk-LGUTBX34.cjs +0 -11
- package/build/cjs/chunk-LLGHXDSY.cjs +0 -11
- package/build/cjs/chunk-YWYFWFUF.cjs +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfViewerAnnotationLayer.js","names":["classnames","React","useCallback","useMemo","styles","computeRectStyle","rect","pageHeight","scale","color","left","x","top","y","height","width","useAnnotationHandlers","annotation","onClick","handleClick","handleKeyDown","e","key","preventDefault","AnnotationItem","className","type","multiRects","rects","hasMultipleRects","length","style","createElement","annotationGroup","onKeyDown","role","tabIndex","title","label","id","map","i","CustomAnnotationItem","undefined","renderProps","render","PdfViewerAnnotationLayer","annotations","onAnnotationClick","annotationLayer"],"sources":["PdfViewerAnnotationLayer.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport classnames from \"classnames\";\nimport React, { useCallback, useMemo } from \"react\";\nimport type { PdfAnnotation, PdfCustomAnnotation, PdfRect } from \"../types.js\";\nimport styles from \"./PdfViewerAnnotationLayer.module.css\";\n\nexport interface PdfViewerAnnotationLayerProps {\n annotations: PdfAnnotation[];\n pageHeight: number;\n scale: number;\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n}\n\ninterface AnnotationItemProps {\n annotation: PdfAnnotation;\n pageHeight: number;\n scale: number;\n onClick?: (annotation: PdfAnnotation) => void;\n}\n\n/** Convert a single PDF rect (bottom-left origin) to CSS positioning (top-left origin). */\nfunction computeRectStyle(\n rect: PdfRect,\n pageHeight: number,\n scale: number,\n color: string | undefined,\n): React.CSSProperties {\n return {\n left: rect.x * scale,\n top: (pageHeight - rect.y - rect.height) * scale,\n width: rect.width * scale,\n height: rect.height * scale,\n ...(color != null\n ? { \"--osdk-pdf-annotation-color\": color } as React.CSSProperties\n : {}),\n };\n}\n\nfunction useAnnotationHandlers(\n annotation: PdfAnnotation,\n onClick?: (annotation: PdfAnnotation) => void,\n) {\n const handleClick = useCallback(() => {\n onClick?.(annotation);\n }, [onClick, annotation]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n onClick?.(annotation);\n }\n },\n [onClick, annotation],\n );\n\n return { handleClick, handleKeyDown };\n}\n\nfunction AnnotationItem({\n annotation,\n pageHeight,\n scale,\n onClick,\n}: AnnotationItemProps): React.ReactElement {\n const { handleClick, handleKeyDown } = useAnnotationHandlers(\n annotation,\n onClick,\n );\n\n const className = classnames(\n styles.annotation,\n styles[annotation.type],\n );\n\n const multiRects = annotation.rects;\n const hasMultipleRects = multiRects != null && multiRects.length > 1;\n\n const style = useMemo(\n () =>\n computeRectStyle(annotation.rect, pageHeight, scale, annotation.color),\n [annotation, pageHeight, scale],\n );\n\n // Multi-rect: render a group wrapper with one div per rect\n if (hasMultipleRects) {\n return (\n <div\n className={styles.annotationGroup}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n >\n {multiRects.map((rect, i) => (\n <div\n key={i}\n className={className}\n style={computeRectStyle(\n rect,\n pageHeight,\n scale,\n annotation.color,\n )}\n />\n ))}\n </div>\n );\n }\n\n // Single rect: existing behavior\n\n return (\n <div\n className={className}\n style={style}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n />\n );\n}\n\nfunction CustomAnnotationItem({\n annotation,\n pageHeight,\n scale,\n onClick,\n}: AnnotationItemProps & {\n annotation: PdfCustomAnnotation;\n}): React.ReactElement {\n const { handleClick, handleKeyDown } = useAnnotationHandlers(\n annotation,\n onClick,\n );\n\n const style = useMemo(\n () => computeRectStyle(annotation.rect, pageHeight, scale, undefined),\n [annotation, pageHeight, scale],\n );\n\n const renderProps = useMemo(\n () => ({ annotation, scale, pageHeight }),\n [annotation, scale, pageHeight],\n );\n\n return (\n <div\n className={styles.annotation}\n style={style}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n >\n {annotation.render(renderProps)}\n </div>\n );\n}\n\nexport function PdfViewerAnnotationLayer({\n annotations,\n pageHeight,\n scale,\n onAnnotationClick,\n}: PdfViewerAnnotationLayerProps): React.ReactElement {\n return (\n <div className={styles.annotationLayer}>\n {annotations.map((annotation) =>\n annotation.type === \"custom\"\n ? (\n <CustomAnnotationItem\n key={annotation.id}\n annotation={annotation}\n pageHeight={pageHeight}\n scale={scale}\n onClick={onAnnotationClick}\n />\n )\n : (\n <AnnotationItem\n key={annotation.id}\n annotation={annotation}\n pageHeight={pageHeight}\n scale={scale}\n onClick={onAnnotationClick}\n />\n )\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAEnD,OAAOC,MAAM,MAAM,uCAAuC;AAgB1D;AACA,SAASC,gBAAgBA,CACvBC,IAAa,EACbC,UAAkB,EAClBC,KAAa,EACbC,KAAyB,EACJ;EACrB,OAAO;IACLC,IAAI,EAAEJ,IAAI,CAACK,CAAC,GAAGH,KAAK;IACpBI,GAAG,EAAE,CAACL,UAAU,GAAGD,IAAI,CAACO,CAAC,GAAGP,IAAI,CAACQ,MAAM,IAAIN,KAAK;IAChDO,KAAK,EAAET,IAAI,CAACS,KAAK,GAAGP,KAAK;IACzBM,MAAM,EAAER,IAAI,CAACQ,MAAM,GAAGN,KAAK;IAC3B,IAAIC,KAAK,IAAI,IAAI,GACb;MAAE,6BAA6B,EAAEA;IAAM,CAAC,GACxC,CAAC,CAAC;EACR,CAAC;AACH;AAEA,SAASO,qBAAqBA,CAC5BC,UAAyB,EACzBC,OAA6C,EAC7C;EACA,MAAMC,WAAW,GAAGjB,WAAW,CAAC,MAAM;IACpCgB,OAAO,GAAGD,UAAU,CAAC;EACvB,CAAC,EAAE,CAACC,OAAO,EAAED,UAAU,CAAC,CAAC;EAEzB,MAAMG,aAAa,GAAGlB,WAAW,CAC9BmB,CAAsB,IAAK;IAC1B,IAAIA,CAAC,CAACC,GAAG,KAAK,OAAO,EAAE;MACrBD,CAAC,CAACE,cAAc,CAAC,CAAC;MAClBL,OAAO,GAAGD,UAAU,CAAC;IACvB;EACF,CAAC,EACD,CAACC,OAAO,EAAED,UAAU,CACtB,CAAC;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EACpD,oBACE/C,KAAA,CAAA+B,aAAA;IAAKP,SAAS,EAAErB,MAAM,CAAC6C;EAAgB,GACpCF,WAAW,CAACP,GAAG,CAAEvB,UAAU,IAC1BA,UAAU,CAACS,IAAI,KAAK,QAAQ,gBAExBzB,KAAA,CAAA+B,aAAA,CAACU,oBAAoB;IACnBpB,GAAG,EAAEL,UAAU,CAACsB,EAAG;IACnBtB,UAAU,EAAEA,UAAW;IACvBV,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbU,OAAO,EAAE8B;EAAkB,CAC5B,CAAC,gBAGF/C,KAAA,CAAA+B,aAAA,CAACR,cAAc;IACbF,GAAG,EAAEL,UAAU,CAACsB,EAAG;IACnBtB,UAAU,EAAEA,UAAW;IACvBV,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbU,OAAO,EAAE8B;EAAkB,CAC5B,CAEP,CACG,CAAC;AAEV","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PdfViewerAnnotationLayer.js","names":["classnames","React","useCallback","useMemo","styles","applyTransform","point","m","computeRectStyle","rect","transform","color","x1","y1","x","y","x2","y2","width","height","left","Math","min","top","abs","useAnnotationHandlers","annotation","onClick","handleClick","handleKeyDown","e","key","preventDefault","AnnotationItem","className","type","multiRects","rects","hasMultipleRects","length","style","createElement","annotationGroup","onKeyDown","role","tabIndex","title","label","id","map","i","CustomAnnotationItem","pageHeight","scale","undefined","renderProps","render","PdfViewerAnnotationLayer","annotations","onAnnotationClick","annotationLayer"],"sources":["PdfViewerAnnotationLayer.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport classnames from \"classnames\";\nimport React, { useCallback, useMemo } from \"react\";\nimport type { PdfAnnotation, PdfCustomAnnotation, PdfRect } from \"../types.js\";\nimport styles from \"./PdfViewerAnnotationLayer.module.css\";\n\nexport interface PdfViewerAnnotationLayerProps {\n annotations: PdfAnnotation[];\n pageHeight: number;\n scale: number;\n transform: number[];\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n}\n\ninterface AnnotationItemProps {\n annotation: PdfAnnotation;\n transform: number[];\n onClick?: (annotation: PdfAnnotation) => void;\n}\n\ninterface CustomAnnotationItemProps extends AnnotationItemProps {\n annotation: PdfCustomAnnotation;\n pageHeight: number;\n scale: number;\n}\n\nfunction applyTransform(\n point: readonly [number, number],\n m: readonly number[],\n): [number, number] {\n return [\n m[0] * point[0] + m[2] * point[1] + m[4],\n m[1] * point[0] + m[3] * point[1] + m[5],\n ];\n}\n\n/** Convert a single PDF rect (bottom-left origin) to CSS positioning (top-left origin). */\nfunction computeRectStyle(\n rect: PdfRect,\n transform: readonly number[],\n color: string | undefined,\n): React.CSSProperties {\n const [x1, y1] = applyTransform([rect.x, rect.y], transform);\n const [x2, y2] = applyTransform(\n [rect.x + rect.width, rect.y + rect.height],\n transform,\n );\n return {\n left: Math.min(x1, x2),\n top: Math.min(y1, y2),\n width: Math.abs(x2 - x1),\n height: Math.abs(y2 - y1),\n ...(color != null\n ? { \"--osdk-pdf-annotation-color\": color } as React.CSSProperties\n : {}),\n };\n}\n\nfunction useAnnotationHandlers(\n annotation: PdfAnnotation,\n onClick?: (annotation: PdfAnnotation) => void,\n) {\n const handleClick = useCallback(() => {\n onClick?.(annotation);\n }, [onClick, annotation]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n onClick?.(annotation);\n }\n },\n [onClick, annotation],\n );\n\n return { handleClick, handleKeyDown };\n}\n\nfunction AnnotationItem({\n annotation,\n transform,\n onClick,\n}: AnnotationItemProps): React.ReactElement {\n const { handleClick, handleKeyDown } = useAnnotationHandlers(\n annotation,\n onClick,\n );\n\n const className = classnames(\n styles.annotation,\n styles[annotation.type],\n );\n\n const multiRects = annotation.rects;\n const hasMultipleRects = multiRects != null && multiRects.length > 1;\n\n const style = useMemo(\n () => computeRectStyle(annotation.rect, transform, annotation.color),\n [annotation, transform],\n );\n\n // Multi-rect: render a group wrapper with one div per rect\n if (hasMultipleRects) {\n return (\n <div\n className={styles.annotationGroup}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n >\n {multiRects.map((rect, i) => (\n <div\n key={i}\n className={className}\n style={computeRectStyle(rect, transform, annotation.color)}\n />\n ))}\n </div>\n );\n }\n\n // Single rect: existing behavior\n\n return (\n <div\n className={className}\n style={style}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n />\n );\n}\n\nfunction CustomAnnotationItem({\n annotation,\n pageHeight,\n scale,\n transform,\n onClick,\n}: CustomAnnotationItemProps): React.ReactElement {\n const { handleClick, handleKeyDown } = useAnnotationHandlers(\n annotation,\n onClick,\n );\n\n const style = useMemo(\n () => computeRectStyle(annotation.rect, transform, undefined),\n [annotation, transform],\n );\n\n const renderProps = useMemo(\n () => ({ annotation, scale, pageHeight, transform }),\n [annotation, scale, pageHeight, transform],\n );\n\n return (\n <div\n className={styles.annotation}\n style={style}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n title={annotation.label}\n data-annotation-id={annotation.id}\n >\n {annotation.render(renderProps)}\n </div>\n );\n}\n\nexport function PdfViewerAnnotationLayer({\n annotations,\n pageHeight,\n scale,\n transform,\n onAnnotationClick,\n}: PdfViewerAnnotationLayerProps): React.ReactElement {\n return (\n <div className={styles.annotationLayer}>\n {annotations.map((annotation) =>\n annotation.type === \"custom\"\n ? (\n <CustomAnnotationItem\n key={annotation.id}\n annotation={annotation}\n pageHeight={pageHeight}\n scale={scale}\n transform={transform}\n onClick={onAnnotationClick}\n />\n )\n : (\n <AnnotationItem\n key={annotation.id}\n annotation={annotation}\n transform={transform}\n onClick={onAnnotationClick}\n />\n )\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAEnD,OAAOC,MAAM,MAAM,uCAAuC;AAsB1D,SAASC,cAAcA,CACrBC,KAAgC,EAChCC,CAAoB,EACF;EAClB,OAAO,CACLA,CAAC,CAAC,CAAC,CAAC,GAAGD,KAAK,CAAC,CAAC,CAAC,GAAGC,CAAC,CAAC,CAAC,CAAC,GAAGD,KAAK,CAAC,CAAC,CAAC,GAAGC,CAAC,CAAC,CAAC,CAAC,EACxCA,CAAC,CAAC,CAAC,CAAC,GAAGD,KAAK,CAAC,CAAC,CAAC,GAAGC,CAAC,CAAC,CAAC,CAAC,GAAGD,KAAK,CAAC,CAAC,CAAC,GAAGC,CAAC,CAAC,CAAC,CAAC,CACzC;AACH;;AAEA;AACA,SAASC,gBAAgBA,CACvBC,IAAa,EACbC,SAA4B,EAC5BC,KAAyB,EACJ;EACrB,MAAM,CAACC,EAAE,EAAEC,EAAE,CAAC,GAAGR,cAAc,CAAC,CAACI,IAAI,CAACK,CAAC,EAAEL,IAAI,CAACM,CAAC,CAAC,EAAEL,SAAS,CAAC;EAC5D,MAAM,CAACM,EAAE,EAAEC,EAAE,CAAC,GAAGZ,cAAc,CAC7B,CAACI,IAAI,CAACK,CAAC,GAAGL,IAAI,CAACS,KAAK,EAAET,IAAI,CAACM,CAAC,GAAGN,IAAI,CAACU,MAAM,CAAC,EAC3CT,SACF,C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,gBAGF1D,KAAA,CAAAwC,aAAA,CAACR,cAAc;IACbF,GAAG,EAAEL,UAAU,CAACsB,EAAG;IACnBtB,UAAU,EAAEA,UAAW;IACvBhB,SAAS,EAAEA,SAAU;IACrBiB,OAAO,EAAEgC;EAAkB,CAC5B,CAEP,CACG,CAAC;AAEV","ignoreList":[]}
|
|
@@ -18,13 +18,12 @@ import { Error as ErrorIcon, Spin } from "@blueprintjs/icons";
|
|
|
18
18
|
import classnames from "classnames";
|
|
19
19
|
import "pdfjs-dist/web/pdf_viewer.css";
|
|
20
20
|
import React, { useEffect, useRef } from "react";
|
|
21
|
-
import { createPortal } from "react-dom";
|
|
22
21
|
import { EMPTY_ANNOTATION_ARRAY } from "../constants.js";
|
|
23
22
|
import { usePdfAnnotationsByPage } from "../hooks/usePdfAnnotationsByPage.js";
|
|
24
23
|
import { usePdfFormFields } from "../hooks/usePdfFormFields.js";
|
|
25
24
|
import { usePdfViewerCore } from "../hooks/usePdfViewerCore.js";
|
|
26
25
|
import styles from "../PdfViewer.module.css.js";
|
|
27
|
-
import {
|
|
26
|
+
import { PdfAnnotationOverlay } from "./PdfAnnotationOverlay.js";
|
|
28
27
|
export function PdfViewerContent({
|
|
29
28
|
src,
|
|
30
29
|
annotations = EMPTY_ANNOTATION_ARRAY,
|
|
@@ -113,13 +112,12 @@ export function PdfViewerContent({
|
|
|
113
112
|
if (pageAnnotations.length === 0) {
|
|
114
113
|
return null;
|
|
115
114
|
}
|
|
116
|
-
return /*#__PURE__*/
|
|
115
|
+
return /*#__PURE__*/React.createElement(PdfAnnotationOverlay, {
|
|
117
116
|
key: target.pageNumber,
|
|
117
|
+
target: target,
|
|
118
118
|
annotations: pageAnnotations,
|
|
119
|
-
pageHeight: target.pageHeight,
|
|
120
|
-
scale: target.scale,
|
|
121
119
|
onAnnotationClick: onAnnotationClick
|
|
122
|
-
})
|
|
120
|
+
});
|
|
123
121
|
}))));
|
|
124
122
|
}
|
|
125
123
|
//# sourceMappingURL=PdfViewerContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfViewerContent.js","names":["Error","ErrorIcon","Spin","classnames","React","useEffect","useRef","
|
|
1
|
+
{"version":3,"file":"PdfViewerContent.js","names":["Error","ErrorIcon","Spin","classnames","React","useEffect","useRef","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfViewerCore","styles","PdfAnnotationOverlay","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\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { useEffect, useRef } from \"react\";\nimport { EMPTY_ANNOTATION_ARRAY } from \"../constants.js\";\nimport { usePdfAnnotationsByPage } from \"../hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"../hooks/usePdfFormFields.js\";\nimport { usePdfViewerCore } from \"../hooks/usePdfViewerCore.js\";\nimport styles from \"../PdfViewer.module.css\";\nimport type { PdfAnnotation, PdfFormFieldValue } from \"../types.js\";\nimport { PdfAnnotationOverlay } from \"./PdfAnnotationOverlay.js\";\n\nexport interface PdfViewerContentProps {\n /** PDF source — URL string or ArrayBuffer */\n src: string | ArrayBuffer;\n /** Annotations to overlay on the PDF */\n annotations?: PdfAnnotation[];\n /** Callback fired when an annotation is clicked */\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n /** Initial page number (1-indexed, default 1) */\n initialPage?: number;\n /** Initial zoom scale (default 1.0) */\n initialScale?: number;\n /** Callback fired when the current page changes during scrolling */\n onPageChange?: (page: number) => void;\n /** Callback fired when the zoom scale changes */\n onScaleChange?: (scale: number) => void;\n /** Initial form field values keyed by field name. Applied when the document loads. */\n formData?: Record<string, PdfFormFieldValue>;\n /** Callback fired when any form field value changes. */\n onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;\n /** Additional CSS class name for the root element */\n className?: string;\n}\n\nexport function PdfViewerContent({\n src,\n annotations = EMPTY_ANNOTATION_ARRAY,\n onAnnotationClick,\n initialPage = 1,\n initialScale = 1.0,\n onPageChange: onPageChangeProp,\n onScaleChange: onScaleChangeProp,\n formData,\n onFormChange,\n className,\n}: PdfViewerContentProps): React.ReactElement {\n const viewer = usePdfViewerCore({ src, initialPage, initialScale });\n const annotationsByPage = usePdfAnnotationsByPage(annotations);\n\n usePdfFormFields({\n pdfViewerRef: viewer.pdfViewerRef,\n eventBusRef: viewer.eventBusRef,\n document: viewer.document,\n formData,\n onFormChange,\n });\n\n // Use refs for callbacks to avoid firing on initial mount\n const onPageChangeRef = useRef(onPageChangeProp);\n onPageChangeRef.current = onPageChangeProp;\n const onScaleChangeRef = useRef(onScaleChangeProp);\n onScaleChangeRef.current = onScaleChangeProp;\n const isInitialMountRef = useRef(true);\n\n useEffect(function notifyPageChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onPageChangeRef.current?.(viewer.currentPage);\n }, [viewer.currentPage]);\n\n useEffect(function notifyScaleChange() {\n if (isInitialMountRef.current) {\n return;\n }\n onScaleChangeRef.current?.(viewer.scale);\n }, [viewer.scale]);\n\n useEffect(function clearInitialMount() {\n isInitialMountRef.current = false;\n }, []);\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (viewer.loading) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n </div>\n );\n }\n\n if (viewer.error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {viewer.error.message}\n </div>\n </div>\n );\n }\n\n if (viewer.document == null) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>No document</div>\n </div>\n );\n }\n\n return (\n <div className={rootClassName}>\n <div className={styles.scrollContainerWrapper}>\n <div ref={viewer.containerRef} className={styles.scrollContainer}>\n <div ref={viewer.viewerRef} className=\"pdfViewer\" />\n {viewer.portalTargets.map((target) => {\n const pageAnnotations = annotationsByPage[target.pageNumber]\n ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return (\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;AACnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,sBAAsB,QAAQ,iBAAiB;AACxD,SAASC,uBAAuB,QAAQ,qCAAqC;AAC7E,SAASC,gBAAgB,QAAQ,8BAA8B;AAC/D,SAASC,gBAAgB,QAAQ,8BAA8B;AAC/D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,gBAC5C3C,KAAA,CAAAoC,aAAA;IAAKQ,GAAG,EAAEtB,MAAM,CAACuB,YAAa;IAACxB,SAAS,EAAEd,MAAM,CAACuC;EAAgB,gBAC/D9C,KAAA,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,GAAG5B,iBAAiB,CAAC2B,MAAM,CAACE,UAAU,CAAC,IACvDjD,sBAAsB;IAC3B,IAAIgD,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBACErD,KAAA,CAAAoC,aAAA,CAAC5B,oBAAoB;MACnB8C,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":[]}
|
|
@@ -24,31 +24,101 @@ export function usePdfAnnotationPortals(pdfViewerRef, eventBusRef, document) {
|
|
|
24
24
|
if (eventBus == null || pdfViewer == null) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const pageView = pdfViewer.getPageView(pageIndex);
|
|
27
|
+
const measurePage = (pageNumber, containerRect, scrollContainer) => {
|
|
28
|
+
const pageView = pdfViewer.getPageView(pageNumber - 1);
|
|
30
29
|
if (pageView?.div == null || pageView?.viewport == null) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const div = pageView.div;
|
|
33
|
+
const divRect = div.getBoundingClientRect();
|
|
34
|
+
if (divRect.width <= 0 || divRect.height <= 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
pageNumber,
|
|
39
|
+
// Assumes scrollContainer has zero border/padding; otherwise overlays will be offset.
|
|
40
|
+
left: divRect.left - containerRect.left + scrollContainer.scrollLeft,
|
|
41
|
+
top: divRect.top - containerRect.top + scrollContainer.scrollTop,
|
|
42
|
+
width: divRect.width,
|
|
43
|
+
height: divRect.height,
|
|
44
|
+
// viewBox is [xMin, yMin, width, height] and we need the original height before scaling
|
|
45
|
+
pageHeight: pageView.viewport.viewBox[3],
|
|
46
|
+
scale: pageView.viewport.scale,
|
|
47
|
+
transform: pageView.viewport.transform.slice()
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const readContainer = () => {
|
|
51
|
+
const scrollContainer = pdfViewer.container;
|
|
52
|
+
if (scrollContainer == null) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
rect: scrollContainer.getBoundingClientRect(),
|
|
57
|
+
el: scrollContainer
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const handlePageRendered = evt => {
|
|
61
|
+
const container = readContainer();
|
|
62
|
+
if (container == null) {
|
|
31
63
|
return;
|
|
32
64
|
}
|
|
33
|
-
const
|
|
65
|
+
const next = measurePage(evt.pageNumber, container.rect, container.el);
|
|
34
66
|
setPortalTargets(prev => {
|
|
35
|
-
// Replace existing entry for this page or add new one
|
|
36
67
|
const filtered = prev.filter(t => t.pageNumber !== evt.pageNumber);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// viewBox is [xMin, yMin, width, height] and we need the original height before scaling
|
|
42
|
-
scale: viewport.scale
|
|
43
|
-
}].sort((a, b) => a.pageNumber - b.pageNumber);
|
|
68
|
+
if (next == null) {
|
|
69
|
+
return filtered;
|
|
70
|
+
}
|
|
71
|
+
return [...filtered, next].sort((a, b) => a.pageNumber - b.pageNumber);
|
|
44
72
|
});
|
|
45
73
|
};
|
|
74
|
+
let rafHandle = null;
|
|
75
|
+
const flushRemeasure = () => {
|
|
76
|
+
rafHandle = null;
|
|
77
|
+
setPortalTargets(prev => {
|
|
78
|
+
if (prev.length === 0) {
|
|
79
|
+
return prev;
|
|
80
|
+
}
|
|
81
|
+
const container = readContainer();
|
|
82
|
+
if (container == null) {
|
|
83
|
+
return prev;
|
|
84
|
+
}
|
|
85
|
+
const next = [];
|
|
86
|
+
for (const target of prev) {
|
|
87
|
+
const remeasured = measurePage(target.pageNumber, container.rect, container.el);
|
|
88
|
+
if (remeasured != null) {
|
|
89
|
+
next.push(remeasured);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return next;
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const remeasureAll = () => {
|
|
96
|
+
if (rafHandle != null) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
rafHandle = requestAnimationFrame(flushRemeasure);
|
|
100
|
+
};
|
|
46
101
|
eventBus.on(PAGE_RENDERED_EVENT, handlePageRendered);
|
|
102
|
+
eventBus.on("scalechanging", remeasureAll);
|
|
103
|
+
eventBus.on("rotationchanging", remeasureAll);
|
|
104
|
+
const scrollContainer = pdfViewer.container;
|
|
105
|
+
let containerObserver;
|
|
106
|
+
if (scrollContainer != null && typeof ResizeObserver !== "undefined") {
|
|
107
|
+
containerObserver = new ResizeObserver(remeasureAll);
|
|
108
|
+
containerObserver.observe(scrollContainer);
|
|
109
|
+
}
|
|
47
110
|
return () => {
|
|
48
111
|
eventBus.off(PAGE_RENDERED_EVENT, handlePageRendered);
|
|
112
|
+
eventBus.off("scalechanging", remeasureAll);
|
|
113
|
+
eventBus.off("rotationchanging", remeasureAll);
|
|
114
|
+
containerObserver?.disconnect();
|
|
115
|
+
if (rafHandle != null) {
|
|
116
|
+
cancelAnimationFrame(rafHandle);
|
|
117
|
+
rafHandle = null;
|
|
118
|
+
}
|
|
49
119
|
setPortalTargets([]);
|
|
50
120
|
};
|
|
51
|
-
}, [
|
|
121
|
+
}, [document]);
|
|
52
122
|
return portalTargets;
|
|
53
123
|
}
|
|
54
124
|
//# sourceMappingURL=usePdfAnnotationPortals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePdfAnnotationPortals.js","names":["useEffect","useState","PAGE_RENDERED_EVENT","usePdfAnnotationPortals","pdfViewerRef","eventBusRef","document","portalTargets","setPortalTargets","eventBus","current","pdfViewer","
|
|
1
|
+
{"version":3,"file":"usePdfAnnotationPortals.js","names":["useEffect","useState","PAGE_RENDERED_EVENT","usePdfAnnotationPortals","pdfViewerRef","eventBusRef","document","portalTargets","setPortalTargets","eventBus","current","pdfViewer","measurePage","pageNumber","containerRect","scrollContainer","pageView","getPageView","div","viewport","divRect","getBoundingClientRect","width","height","left","scrollLeft","top","scrollTop","pageHeight","viewBox","scale","transform","slice","readContainer","container","rect","el","handlePageRendered","evt","next","prev","filtered","filter","t","sort","a","b","rafHandle","flushRemeasure","length","target","remeasured","push","remeasureAll","requestAnimationFrame","on","containerObserver","ResizeObserver","observe","off","disconnect","cancelAnimationFrame"],"sources":["usePdfAnnotationPortals.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport type { EventBus, PDFViewer } from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport type { RefObject } from \"react\";\nimport { useEffect, useState } from \"react\";\nimport { PAGE_RENDERED_EVENT } from \"../constants.js\";\n\nexport interface AnnotationPortalTarget {\n pageNumber: number;\n left: number;\n top: number;\n width: number;\n height: number;\n pageHeight: number;\n scale: number;\n transform: number[];\n}\n\nexport function usePdfAnnotationPortals(\n pdfViewerRef: RefObject<PDFViewer | null>,\n eventBusRef: RefObject<EventBus | null>,\n document: PDFDocumentProxy | undefined,\n): AnnotationPortalTarget[] {\n const [portalTargets, setPortalTargets] = useState<AnnotationPortalTarget[]>(\n [],\n );\n\n useEffect(function subscribePageEvents() {\n const eventBus = eventBusRef.current;\n const pdfViewer = pdfViewerRef.current;\n if (eventBus == null || pdfViewer == null) {\n return;\n }\n\n const measurePage = (\n pageNumber: number,\n containerRect: DOMRect,\n scrollContainer: HTMLElement,\n ): AnnotationPortalTarget | null => {\n const pageView = pdfViewer.getPageView(pageNumber - 1);\n if (pageView?.div == null || pageView?.viewport == null) {\n return null;\n }\n const div = pageView.div as HTMLDivElement;\n const divRect = div.getBoundingClientRect();\n if (divRect.width <= 0 || divRect.height <= 0) {\n return null;\n }\n return {\n pageNumber,\n // Assumes scrollContainer has zero border/padding; otherwise overlays will be offset.\n left: divRect.left - containerRect.left + scrollContainer.scrollLeft,\n top: divRect.top - containerRect.top + scrollContainer.scrollTop,\n width: divRect.width,\n height: divRect.height,\n // viewBox is [xMin, yMin, width, height] and we need the original height before scaling\n pageHeight: pageView.viewport.viewBox[3],\n scale: pageView.viewport.scale,\n transform: pageView.viewport.transform.slice(),\n };\n };\n\n const readContainer = (): {\n rect: DOMRect;\n el: HTMLElement;\n } | null => {\n const scrollContainer = pdfViewer.container as HTMLElement | null;\n if (scrollContainer == null) {\n return null;\n }\n return {\n rect: scrollContainer.getBoundingClientRect(),\n el: scrollContainer,\n };\n };\n\n const handlePageRendered = (evt: { pageNumber: number }) => {\n const container = readContainer();\n if (container == null) {\n return;\n }\n const next = measurePage(evt.pageNumber, container.rect, container.el);\n setPortalTargets((prev) => {\n const filtered = prev.filter((t) => t.pageNumber !== evt.pageNumber);\n if (next == null) {\n return filtered;\n }\n return [...filtered, next].sort((a, b) => a.pageNumber - b.pageNumber);\n });\n };\n\n let rafHandle: number | null = null;\n const flushRemeasure = () => {\n rafHandle = null;\n setPortalTargets((prev) => {\n if (prev.length === 0) {\n return prev;\n }\n const container = readContainer();\n if (container == null) {\n return prev;\n }\n const next: AnnotationPortalTarget[] = [];\n for (const target of prev) {\n const remeasured = measurePage(\n target.pageNumber,\n container.rect,\n container.el,\n );\n if (remeasured != null) {\n next.push(remeasured);\n }\n }\n return next;\n });\n };\n const remeasureAll = () => {\n if (rafHandle != null) {\n return;\n }\n rafHandle = requestAnimationFrame(flushRemeasure);\n };\n\n eventBus.on(PAGE_RENDERED_EVENT, handlePageRendered);\n eventBus.on(\"scalechanging\", remeasureAll);\n eventBus.on(\"rotationchanging\", remeasureAll);\n\n const scrollContainer = pdfViewer.container as HTMLElement | null;\n let containerObserver: ResizeObserver | undefined;\n if (scrollContainer != null && typeof ResizeObserver !== \"undefined\") {\n containerObserver = new ResizeObserver(remeasureAll);\n containerObserver.observe(scrollContainer);\n }\n\n return () => {\n eventBus.off(PAGE_RENDERED_EVENT, handlePageRendered);\n eventBus.off(\"scalechanging\", remeasureAll);\n eventBus.off(\"rotationchanging\", remeasureAll);\n containerObserver?.disconnect();\n if (rafHandle != null) {\n cancelAnimationFrame(rafHandle);\n rafHandle = null;\n }\n setPortalTargets([]);\n };\n }, [document]);\n\n return portalTargets;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,mBAAmB,QAAQ,iBAAiB;AAarD,OAAO,SAASC,uBAAuBA,CACrCC,YAAyC,EACzCC,WAAuC,EACvCC,QAAsC,EACZ;EAC1B,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGP,QAAQ,CAChD,EACF,CAAC;EAEDD,SAAS,CAAC,YAA+B;IACvC,MAAMS,QAAQ,GAAGJ,WAAW,CAACK,OAAO;IACpC,MAAMC,SAAS,GAAGP,YAAY,CAACM,OAAO;IACtC,IAAID,QAAQ,IAAI,IAAI,IA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
-
{"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}\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 * 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 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 * 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":[]}
|
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
/* Match the dismiss layer's dialog stack level so the later positioner stays
|
|
35
35
|
clickable above it without escalating z-index values. */
|
|
36
36
|
z-index: var(--osdk-datetime-popover-z-index);
|
|
37
|
+
|
|
38
|
+
/* Hide the popover when its anchor scrolls out of view */
|
|
39
|
+
&[data-anchor-hidden] {
|
|
40
|
+
visibility: hidden;
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
.osdkDatePickerPopover {
|
package/build/browser/styles.css
CHANGED
|
@@ -9955,6 +9955,11 @@
|
|
|
9955
9955
|
/* Match the dismiss layer's dialog stack level so the later positioner stays
|
|
9956
9956
|
clickable above it without escalating z-index values. */
|
|
9957
9957
|
z-index: var(--osdk-datetime-popover-z-index);
|
|
9958
|
+
|
|
9959
|
+
/* Hide the popover when its anchor scrolls out of view */
|
|
9960
|
+
&[data-anchor-hidden] {
|
|
9961
|
+
visibility: hidden;
|
|
9962
|
+
}
|
|
9958
9963
|
}
|
|
9959
9964
|
|
|
9960
9965
|
.DatePickerCommon-module__osdkDatePickerPopover___wlnVaL4Q {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
const PACKAGE_USER_AGENT = `osdk-react-components/${"0.20.0
|
|
17
|
+
const PACKAGE_USER_AGENT = `osdk-react-components/${"0.20.0"}`;
|
|
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 =\n `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,GACtB,
|
|
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 =\n `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,GACtB,mCAAsD;AAExD,OAAO,SAASC,kBAAkBA,CAACC,aAAqB,EAAU;EAChE,OAAO,GAAGF,kBAAkB,IAAIE,aAAa,EAAE;AACjD","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVOROB7KJ_cjs = require('./chunk-VOROB7KJ.cjs');
|
|
4
|
+
var chunk4WDDVYWV_cjs = require('./chunk-4WDDVYWV.cjs');
|
|
5
|
+
|
|
6
|
+
// src/public/experimental/image-viewer.ts
|
|
7
|
+
var ImageViewer2 = chunk4WDDVYWV_cjs.withOsdkMetrics(chunkVOROB7KJ_cjs.ImageViewer, "ImageViewer");
|
|
8
|
+
|
|
9
|
+
exports.ImageViewer = ImageViewer2;
|
|
10
|
+
//# sourceMappingURL=chunk-2GAPPUP5.cjs.map
|
|
11
|
+
//# sourceMappingURL=chunk-2GAPPUP5.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/public/experimental/image-viewer.ts"],"names":["ImageViewer","withOsdkMetrics"],"mappings":";;;;;;AAqBO,IAAMA,YAAAA,GAAcC,iCAAA,CAAgBD,6BAAA,EAAc,aAAa","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../../src/public/experimental/image-viewer.ts"],"names":["ImageViewer","withOsdkMetrics"],"mappings":";;;;;;AAqBO,IAAMA,YAAAA,GAAcC,iCAAA,CAAgBD,6BAAA,EAAc,aAAa","file":"chunk-2GAPPUP5.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// BaseImageViewer\nexport { BaseImageViewer } from \"../../images/image-viewer/BaseImageViewer.js\";\n// ImageViewer (Media wrapper)\nimport { ImageViewer as _ImageViewer } from \"../../images/image-viewer/ImageViewer.js\";\nimport { withOsdkMetrics } from \"../../util/withOsdkMetrics.js\";\nexport const ImageViewer = withOsdkMetrics(_ImageViewer, \"ImageViewer\");"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkJKNARBQW_cjs = require('./chunk-JKNARBQW.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkY6BGC7DP_cjs = require('./chunk-Y6BGC7DP.cjs');
|
|
5
|
+
var chunkXA3S7YAO_cjs = require('./chunk-XA3S7YAO.cjs');
|
|
6
6
|
var chunkHNBSGCSZ_cjs = require('./chunk-HNBSGCSZ.cjs');
|
|
7
7
|
var chunk7LXS66DW_cjs = require('./chunk-7LXS66DW.cjs');
|
|
8
8
|
var chunkMD4KDE44_cjs = require('./chunk-MD4KDE44.cjs');
|
|
9
9
|
var chunkUCTQICPR_cjs = require('./chunk-UCTQICPR.cjs');
|
|
10
|
-
var
|
|
10
|
+
var chunk4WDDVYWV_cjs = require('./chunk-4WDDVYWV.cjs');
|
|
11
11
|
var react = require('@osdk/react');
|
|
12
12
|
var React17 = require('react');
|
|
13
13
|
var icons = require('@blueprintjs/icons');
|
|
@@ -542,7 +542,7 @@ function useInfiniteScroll({
|
|
|
542
542
|
}) {
|
|
543
543
|
const observer = React17.useRef();
|
|
544
544
|
const targetRef = React17.useRef();
|
|
545
|
-
const eventCallback =
|
|
545
|
+
const eventCallback = chunkY6BGC7DP_cjs.useEventCallback(callback);
|
|
546
546
|
const throttledCallback = React17.useCallback(lodashEs.throttle(eventCallback), []);
|
|
547
547
|
const handleObserverUpdate = React17.useCallback(
|
|
548
548
|
(entries) => {
|
|
@@ -593,7 +593,7 @@ function _extends() {
|
|
|
593
593
|
return n;
|
|
594
594
|
}, _extends.apply(null, arguments);
|
|
595
595
|
}
|
|
596
|
-
var AsyncDropdownField =
|
|
596
|
+
var AsyncDropdownField = chunkY6BGC7DP_cjs.typedReactMemo(function AsyncDropdownFieldFn({
|
|
597
597
|
isLoading,
|
|
598
598
|
hasMore,
|
|
599
599
|
isSearching,
|
|
@@ -625,7 +625,7 @@ var AsyncDropdownField = chunkGN3PIYGH_cjs.typedReactMemo(function AsyncDropdown
|
|
|
625
625
|
callback: onFetchMore,
|
|
626
626
|
loadedCount: itemCount
|
|
627
627
|
});
|
|
628
|
-
return /* @__PURE__ */ React17__default.default.createElement(
|
|
628
|
+
return /* @__PURE__ */ React17__default.default.createElement(chunkY6BGC7DP_cjs.DropdownField, _extends({}, dropdownProps, {
|
|
629
629
|
isSearchable: true,
|
|
630
630
|
popupStatus,
|
|
631
631
|
trailingItem: hasMore ? /* @__PURE__ */ React17__default.default.createElement(InfiniteScrollSentinel, {
|
|
@@ -808,7 +808,7 @@ var DEFAULT_OBJECT_ICON = {
|
|
|
808
808
|
};
|
|
809
809
|
var ICON_SIZE = icons.IconSize.STANDARD;
|
|
810
810
|
var DEFAULT_EMPTY_MESSAGE = "Object set is not defined";
|
|
811
|
-
var ObjectSetField =
|
|
811
|
+
var ObjectSetField = chunkY6BGC7DP_cjs.typedReactMemo(function ObjectSetFieldFn({
|
|
812
812
|
value,
|
|
813
813
|
emptyMessage = DEFAULT_EMPTY_MESSAGE,
|
|
814
814
|
disabled
|
|
@@ -898,7 +898,7 @@ function toComponentIcon(apiIcon) {
|
|
|
898
898
|
var RadioButtonsField_default = {};
|
|
899
899
|
|
|
900
900
|
// src/action-form/fields/RadioButtonsField.tsx
|
|
901
|
-
var RadioButtonsField =
|
|
901
|
+
var RadioButtonsField = chunkY6BGC7DP_cjs.typedReactMemo(function RadioButtonsFieldFn({
|
|
902
902
|
id,
|
|
903
903
|
value,
|
|
904
904
|
onChange,
|
|
@@ -1074,7 +1074,7 @@ function renderFieldComponent(fieldDefinition, value, onChange, error, portalCon
|
|
|
1074
1074
|
const disabled = fieldDefinition.disabled === true;
|
|
1075
1075
|
switch (fieldDefinition.fieldComponent) {
|
|
1076
1076
|
case "DATE_RANGE_INPUT":
|
|
1077
|
-
return /* @__PURE__ */ React17__default.default.createElement(
|
|
1077
|
+
return /* @__PURE__ */ React17__default.default.createElement(chunkXA3S7YAO_cjs.DateRangePicker, _extends4({
|
|
1078
1078
|
id: fieldDefinition.fieldKey,
|
|
1079
1079
|
value: coerceToDateRange(value),
|
|
1080
1080
|
onChange,
|
|
@@ -1111,7 +1111,7 @@ function renderFieldComponent(fieldDefinition, value, onChange, error, portalCon
|
|
|
1111
1111
|
disabled
|
|
1112
1112
|
}));
|
|
1113
1113
|
case "DROPDOWN": {
|
|
1114
|
-
return /* @__PURE__ */ React17__default.default.createElement(
|
|
1114
|
+
return /* @__PURE__ */ React17__default.default.createElement(chunkY6BGC7DP_cjs.DropdownField, _extends4({
|
|
1115
1115
|
id: fieldDefinition.fieldKey,
|
|
1116
1116
|
value,
|
|
1117
1117
|
onChange,
|
|
@@ -1124,7 +1124,7 @@ function renderFieldComponent(fieldDefinition, value, onChange, error, portalCon
|
|
|
1124
1124
|
}));
|
|
1125
1125
|
}
|
|
1126
1126
|
case "DATETIME_PICKER":
|
|
1127
|
-
return /* @__PURE__ */ React17__default.default.createElement(
|
|
1127
|
+
return /* @__PURE__ */ React17__default.default.createElement(chunkXA3S7YAO_cjs.DatePicker, _extends4({
|
|
1128
1128
|
id: fieldDefinition.fieldKey,
|
|
1129
1129
|
placeholder: fieldDefinition.placeholder,
|
|
1130
1130
|
value: value instanceof Date ? value : null,
|
|
@@ -1206,10 +1206,10 @@ function resolvePortalContainer(fieldComponentProps, formPortalContainer) {
|
|
|
1206
1206
|
return Object.hasOwn(fieldComponentProps, "portalContainer") ? fieldComponentProps.portalContainer : formPortalContainer;
|
|
1207
1207
|
}
|
|
1208
1208
|
function coerceToDateRange(value) {
|
|
1209
|
-
if (!Array.isArray(value) || value.length !== 2) return
|
|
1209
|
+
if (!Array.isArray(value) || value.length !== 2) return chunkXA3S7YAO_cjs.EMPTY_RANGE;
|
|
1210
1210
|
const start = value[0] instanceof Date ? value[0] : null;
|
|
1211
1211
|
const end = value[1] instanceof Date ? value[1] : null;
|
|
1212
|
-
if (start == null && end == null) return
|
|
1212
|
+
if (start == null && end == null) return chunkXA3S7YAO_cjs.EMPTY_RANGE;
|
|
1213
1213
|
return [start, end];
|
|
1214
1214
|
}
|
|
1215
1215
|
function isFileArray(value) {
|
|
@@ -1747,7 +1747,7 @@ function _extends5() {
|
|
|
1747
1747
|
}
|
|
1748
1748
|
var EMPTY_FIELD_DEFINITIONS = [];
|
|
1749
1749
|
var EMPTY_FORM_CONTENT = [];
|
|
1750
|
-
var ActionForm =
|
|
1750
|
+
var ActionForm = chunkY6BGC7DP_cjs.typedReactMemo(function ActionFormFn({
|
|
1751
1751
|
actionDefinition,
|
|
1752
1752
|
formTitle,
|
|
1753
1753
|
showFormTitle = false,
|
|
@@ -1852,9 +1852,9 @@ var ActionForm = chunkGN3PIYGH_cjs.typedReactMemo(function ActionFormFn({
|
|
|
1852
1852
|
});
|
|
1853
1853
|
|
|
1854
1854
|
// src/public/experimental/action-form.ts
|
|
1855
|
-
var ActionForm2 =
|
|
1855
|
+
var ActionForm2 = chunk4WDDVYWV_cjs.withOsdkMetrics(ActionForm, "ActionForm");
|
|
1856
1856
|
|
|
1857
1857
|
exports.ActionForm = ActionForm2;
|
|
1858
1858
|
exports.BaseForm = BaseForm;
|
|
1859
|
-
//# sourceMappingURL=chunk-
|
|
1860
|
-
//# sourceMappingURL=chunk-
|
|
1859
|
+
//# sourceMappingURL=chunk-4MGATUJ3.cjs.map
|
|
1860
|
+
//# sourceMappingURL=chunk-4MGATUJ3.cjs.map
|