@osdk/react-components 0.2.0-beta.24 → 0.2.0-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -0
- package/CHANGELOG.md +38 -0
- package/build/browser/action-form/ActionForm.js +15 -11
- package/build/browser/action-form/ActionForm.js.map +1 -1
- package/build/browser/action-form/FormFieldApi.js.map +1 -1
- package/build/browser/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
- package/build/browser/action-form/fields/BaseInput.module.css.js +6 -0
- package/build/browser/action-form/fields/CustomField.js +30 -0
- package/build/browser/action-form/fields/CustomField.js.map +1 -0
- package/build/browser/action-form/fields/FormFieldRenderer.js +26 -16
- package/build/browser/action-form/fields/FormFieldRenderer.js.map +1 -1
- package/build/browser/action-form/fields/RadioButtonsField.js +57 -0
- package/build/browser/action-form/fields/RadioButtonsField.js.map +1 -0
- package/build/browser/action-form/fields/RadioButtonsField.module.css +83 -0
- package/build/browser/action-form/fields/RadioButtonsField.module.css.js +10 -0
- package/build/browser/action-form/fields/TextAreaField.js +50 -0
- package/build/browser/action-form/fields/TextAreaField.js.map +1 -0
- package/build/browser/action-form/fields/TextInputField.js +3 -3
- package/build/browser/action-form/fields/TextInputField.js.map +1 -1
- package/build/browser/action-form/utils/getDefaultFieldDefinitions.js +97 -10
- package/build/browser/action-form/utils/getDefaultFieldDefinitions.js.map +1 -1
- package/build/browser/base-components/dialog/Dialog.js +4 -2
- package/build/browser/base-components/dialog/Dialog.js.map +1 -1
- package/build/browser/object-table/ObjectTableApi.js.map +1 -1
- package/build/browser/object-table/hooks/useFunctionColumnsData.js +57 -192
- package/build/browser/object-table/hooks/useFunctionColumnsData.js.map +1 -1
- package/build/browser/pdf-viewer/PdfViewer.js +49 -8
- package/build/browser/pdf-viewer/PdfViewer.js.map +1 -1
- package/build/browser/pdf-viewer/PdfViewerContext.js +108 -0
- package/build/browser/pdf-viewer/PdfViewerContext.js.map +1 -0
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css.js +1 -0
- package/build/browser/pdf-viewer/components/PdfViewerContent.js +15 -3
- package/build/browser/pdf-viewer/components/PdfViewerContent.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerToolbar.js +29 -2
- package/build/browser/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
- package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css.js +1 -0
- package/build/browser/pdf-viewer/constants.js +2 -1
- package/build/browser/pdf-viewer/constants.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
- package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfFormFields.js +341 -0
- package/build/browser/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js +227 -0
- package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewer.js +16 -10
- package/build/browser/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js +3 -3
- package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js +3 -3
- package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfViewerState.js +3 -3
- package/build/browser/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
- package/build/browser/pdf-viewer/types.js.map +1 -1
- package/build/browser/public/experimental.js +5 -0
- package/build/browser/public/experimental.js.map +1 -1
- package/build/browser/styles.css +144 -35
- package/build/cjs/{chunk-GT6IV6LV.cjs → chunk-MRRRZN44.cjs} +6 -4
- package/build/cjs/chunk-MRRRZN44.cjs.map +1 -0
- package/build/cjs/public/experimental.cjs +1981 -1314
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.css +82 -5
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +267 -26
- package/build/cjs/public/primitives.cjs +5 -5
- package/build/cjs/public/primitives.d.cts +3 -2
- package/build/esm/action-form/ActionForm.js +15 -11
- package/build/esm/action-form/ActionForm.js.map +1 -1
- package/build/esm/action-form/FormFieldApi.js.map +1 -1
- package/build/esm/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
- package/build/esm/action-form/fields/CustomField.js +30 -0
- package/build/esm/action-form/fields/CustomField.js.map +1 -0
- package/build/esm/action-form/fields/FormFieldRenderer.js +26 -16
- package/build/esm/action-form/fields/FormFieldRenderer.js.map +1 -1
- package/build/esm/action-form/fields/RadioButtonsField.js +57 -0
- package/build/esm/action-form/fields/RadioButtonsField.js.map +1 -0
- package/build/esm/action-form/fields/RadioButtonsField.module.css +83 -0
- package/build/esm/action-form/fields/TextAreaField.js +50 -0
- package/build/esm/action-form/fields/TextAreaField.js.map +1 -0
- package/build/esm/action-form/fields/TextInputField.js +3 -3
- package/build/esm/action-form/fields/TextInputField.js.map +1 -1
- package/build/esm/action-form/utils/getDefaultFieldDefinitions.js +97 -10
- package/build/esm/action-form/utils/getDefaultFieldDefinitions.js.map +1 -1
- package/build/esm/base-components/dialog/Dialog.js +4 -2
- package/build/esm/base-components/dialog/Dialog.js.map +1 -1
- package/build/esm/object-table/ObjectTableApi.js.map +1 -1
- package/build/esm/object-table/hooks/useFunctionColumnsData.js +57 -192
- package/build/esm/object-table/hooks/useFunctionColumnsData.js.map +1 -1
- package/build/esm/pdf-viewer/PdfViewer.js +49 -8
- package/build/esm/pdf-viewer/PdfViewer.js.map +1 -1
- package/build/esm/pdf-viewer/PdfViewerContext.js +108 -0
- package/build/esm/pdf-viewer/PdfViewerContext.js.map +1 -0
- package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
- package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
- package/build/esm/pdf-viewer/components/PdfViewerContent.js +15 -3
- package/build/esm/pdf-viewer/components/PdfViewerContent.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerToolbar.js +29 -2
- package/build/esm/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
- package/build/esm/pdf-viewer/constants.js +2 -1
- package/build/esm/pdf-viewer/constants.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
- package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfFormFields.js +341 -0
- package/build/esm/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js +227 -0
- package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewer.js +16 -10
- package/build/esm/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js +3 -3
- package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js +3 -3
- package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfViewerState.js +3 -3
- package/build/esm/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
- package/build/esm/pdf-viewer/types.js.map +1 -1
- package/build/esm/public/experimental.js +5 -0
- package/build/esm/public/experimental.js.map +1 -1
- package/build/types/action-form/FormFieldApi.d.ts +11 -5
- package/build/types/action-form/FormFieldApi.d.ts.map +1 -1
- package/build/types/action-form/fields/CustomField.d.ts +9 -0
- package/build/types/action-form/fields/CustomField.d.ts.map +1 -0
- package/build/types/action-form/fields/FormFieldRenderer.d.ts.map +1 -1
- package/build/types/action-form/fields/RadioButtonsField.d.ts +3 -0
- package/build/types/action-form/fields/RadioButtonsField.d.ts.map +1 -0
- package/build/types/action-form/fields/TextAreaField.d.ts +3 -0
- package/build/types/action-form/fields/TextAreaField.d.ts.map +1 -0
- package/build/types/action-form/utils/getDefaultFieldDefinitions.d.ts +7 -4
- package/build/types/action-form/utils/getDefaultFieldDefinitions.d.ts.map +1 -1
- package/build/types/base-components/dialog/Dialog.d.ts +3 -2
- package/build/types/base-components/dialog/Dialog.d.ts.map +1 -1
- package/build/types/object-table/ObjectTableApi.d.ts +4 -3
- package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
- package/build/types/object-table/hooks/useFunctionColumnsData.d.ts.map +1 -1
- package/build/types/pdf-viewer/PdfViewer.d.ts +2 -2
- package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -1
- package/build/types/pdf-viewer/PdfViewerContext.d.ts +64 -0
- package/build/types/pdf-viewer/PdfViewerContext.d.ts.map +1 -0
- package/build/types/pdf-viewer/components/PdfViewerAnnotationLayer.d.ts.map +1 -1
- package/build/types/pdf-viewer/components/PdfViewerContent.d.ts +8 -4
- package/build/types/pdf-viewer/components/PdfViewerContent.d.ts.map +1 -1
- package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts +6 -1
- package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts.map +1 -1
- package/build/types/pdf-viewer/constants.d.ts +1 -1
- package/build/types/pdf-viewer/constants.d.ts.map +1 -1
- package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts +5 -0
- package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts +24 -0
- package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts +36 -0
- package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts.map +1 -1
- package/build/types/pdf-viewer/types.d.ts +137 -13
- package/build/types/pdf-viewer/types.d.ts.map +1 -1
- package/build/types/public/experimental.d.ts +6 -1
- package/build/types/public/experimental.d.ts.map +1 -1
- package/package.json +6 -6
- package/build/browser/action-form/fields/TextInputField.module.css.js +0 -6
- package/build/browser/action-form/utils/getDefaultFieldComponent.js +0 -56
- package/build/browser/action-form/utils/getDefaultFieldComponent.js.map +0 -1
- package/build/cjs/chunk-GT6IV6LV.cjs.map +0 -1
- package/build/esm/action-form/utils/getDefaultFieldComponent.js +0 -56
- package/build/esm/action-form/utils/getDefaultFieldComponent.js.map +0 -1
- package/build/types/action-form/utils/getDefaultFieldComponent.d.ts +0 -6
- package/build/types/action-form/utils/getDefaultFieldComponent.d.ts.map +0 -1
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
// Default empty values (stable references to avoid re-renders)
|
|
18
|
-
export const EMPTY_ANNOTATIONS = {};
|
|
19
18
|
export const EMPTY_ANNOTATION_ARRAY = [];
|
|
20
19
|
export const EMPTY_STRING = "";
|
|
21
20
|
|
|
@@ -42,4 +41,6 @@ export const PAGE_CHANGING_EVENT = "pagechanging";
|
|
|
42
41
|
export const SCALE_CHANGING_EVENT = "scalechanging";
|
|
43
42
|
export const PAGE_RENDERED_EVENT = "pagerendered";
|
|
44
43
|
export const PAGES_LOADED_EVENT = "pagesloaded";
|
|
44
|
+
// cspell:disable-next-line -- pdfjs EventBus event name
|
|
45
|
+
export const ANNOTATION_LAYER_RENDERED_EVENT = "annotationlayerrendered";
|
|
45
46
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["
|
|
1
|
+
{"version":3,"file":"constants.js","names":["EMPTY_ANNOTATION_ARRAY","EMPTY_STRING","SCALE_STEP","MIN_SCALE","MAX_SCALE","DEFAULT_PAGE_HEIGHT","THUMBNAIL_GAP","THUMBNAIL_SCALE","DEVICE_PIXEL_RATIO","window","devicePixelRatio","OUTLINE_HEADING_SIZE_RATIO","OUTLINE_MAX_HEADING_LENGTH","FIND_EVENT","UPDATE_FIND_CONTROL_STATE_EVENT","UPDATE_FIND_MATCHES_COUNT_EVENT","PAGE_CHANGING_EVENT","SCALE_CHANGING_EVENT","PAGE_RENDERED_EVENT","PAGES_LOADED_EVENT","ANNOTATION_LAYER_RENDERED_EVENT"],"sources":["constants.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PdfAnnotation } from \"./types.js\";\n\n// Default empty values (stable references to avoid re-renders)\nexport const EMPTY_ANNOTATION_ARRAY: PdfAnnotation[] = [];\nexport const EMPTY_STRING = \"\";\n\n// Scale and dimension configuration\nexport const SCALE_STEP = 0.25;\nexport const MIN_SCALE = 0.25;\nexport const MAX_SCALE = 5.0;\nexport const DEFAULT_PAGE_HEIGHT = 792;\nexport const THUMBNAIL_GAP = 12;\nexport const THUMBNAIL_SCALE = 0.2;\nexport const DEVICE_PIXEL_RATIO: number = typeof window !== \"undefined\"\n ? window.devicePixelRatio || 1\n : 1;\n\n// Outline heading extraction\n/** Text must be at least 15% larger than the most common font size to be considered a heading. */\nexport const OUTLINE_HEADING_SIZE_RATIO = 1.15;\n/** Headings longer than this are likely paragraphs and are filtered out. */\nexport const OUTLINE_MAX_HEADING_LENGTH = 200;\n\n// pdfjs EventBus event names\nexport const FIND_EVENT = \"find\";\nexport const UPDATE_FIND_CONTROL_STATE_EVENT = \"updatefindcontrolstate\";\nexport const UPDATE_FIND_MATCHES_COUNT_EVENT = \"updatefindmatchescount\";\nexport const PAGE_CHANGING_EVENT = \"pagechanging\";\nexport const SCALE_CHANGING_EVENT = \"scalechanging\";\nexport const PAGE_RENDERED_EVENT = \"pagerendered\";\nexport const PAGES_LOADED_EVENT = \"pagesloaded\";\n// cspell:disable-next-line -- pdfjs EventBus event name\nexport const ANNOTATION_LAYER_RENDERED_EVENT = \"annotationlayerrendered\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA,OAAO,MAAMA,sBAAuC,GAAG,EAAE;AACzD,OAAO,MAAMC,YAAY,GAAG,EAAE;;AAE9B;AACA,OAAO,MAAMC,UAAU,GAAG,IAAI;AAC9B,OAAO,MAAMC,SAAS,GAAG,IAAI;AAC7B,OAAO,MAAMC,SAAS,GAAG,GAAG;AAC5B,OAAO,MAAMC,mBAAmB,GAAG,GAAG;AACtC,OAAO,MAAMC,aAAa,GAAG,EAAE;AAC/B,OAAO,MAAMC,eAAe,GAAG,GAAG;AAClC,OAAO,MAAMC,kBAA0B,GAAG,OAAOC,MAAM,KAAK,WAAW,GACnEA,MAAM,CAACC,gBAAgB,IAAI,CAAC,GAC5B,CAAC;;AAEL;AACA;AACA,OAAO,MAAMC,0BAA0B,GAAG,IAAI;AAC9C;AACA,OAAO,MAAMC,0BAA0B,GAAG,GAAG;;AAE7C;AACA,OAAO,MAAMC,UAAU,GAAG,MAAM;AAChC,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,mBAAmB,GAAG,cAAc;AACjD,OAAO,MAAMC,oBAAoB,GAAG,eAAe;AACnD,OAAO,MAAMC,mBAAmB,GAAG,cAAc;AACjD,OAAO,MAAMC,kBAAkB,GAAG,aAAa;AAC/C;AACA,OAAO,MAAMC,+BAA+B,GAAG,yBAAyB","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { useMemo } from "react";
|
|
18
|
+
/**
|
|
19
|
+
* Groups a flat array of annotations by page number for efficient per-page lookup.
|
|
20
|
+
*/
|
|
21
|
+
export function usePdfAnnotationsByPage(annotations) {
|
|
22
|
+
return useMemo(() => {
|
|
23
|
+
const result = {};
|
|
24
|
+
for (const ann of annotations) {
|
|
25
|
+
(result[ann.page] ??= []).push(ann);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}, [annotations]);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=usePdfAnnotationsByPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePdfAnnotationsByPage.js","names":["useMemo","usePdfAnnotationsByPage","annotations","result","ann","page","push"],"sources":["usePdfAnnotationsByPage.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 { useMemo } from \"react\";\nimport type { PdfAnnotation } from \"../types.js\";\n\n/**\n * Groups a flat array of annotations by page number for efficient per-page lookup.\n */\nexport function usePdfAnnotationsByPage(\n annotations: PdfAnnotation[],\n): Record<number, PdfAnnotation[]> {\n return useMemo(() => {\n const result: Record<number, PdfAnnotation[]> = {};\n for (const ann of annotations) {\n (result[ann.page] ??= []).push(ann);\n }\n return result;\n }, [annotations]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,OAAO;AAG/B;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CACrCC,WAA4B,EACK;EACjC,OAAOF,OAAO,CAAC,MAAM;IACnB,MAAMG,MAAuC,GAAG,CAAC,CAAC;IAClD,KAAK,MAAMC,GAAG,IAAIF,WAAW,EAAE;MAC7B,CAACC,MAAM,CAACC,GAAG,CAACC,IAAI,CAAC,KAAK,EAAE,EAAEC,IAAI,CAACF,GAAG,CAAC;IACrC;IACA,OAAOD,MAAM;EACf,CAAC,EAAE,CAACD,WAAW,CAAC,CAAC;AACnB","ignoreList":[]}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
18
|
+
import { ANNOTATION_LAYER_RENDERED_EVENT } from "../constants.js";
|
|
19
|
+
/** Get the viewer's container element (typed loosely by pdf.js). */
|
|
20
|
+
function getViewerContainer(viewer) {
|
|
21
|
+
return viewer.container;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Internal metadata for a single form field annotation. */
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Normalizes a pdf.js field object type string to a simplified form type.
|
|
28
|
+
* @internal Exported for testing.
|
|
29
|
+
*/
|
|
30
|
+
export function normalizeFieldType(type) {
|
|
31
|
+
switch (type) {
|
|
32
|
+
case "checkbox":
|
|
33
|
+
case "radiobutton":
|
|
34
|
+
case "combobox":
|
|
35
|
+
case "listbox":
|
|
36
|
+
return type;
|
|
37
|
+
default:
|
|
38
|
+
return "text";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Converts a pdf.js annotationStorage value to a consumer-friendly PdfFormFieldValue.
|
|
44
|
+
* @internal Exported for testing.
|
|
45
|
+
*/
|
|
46
|
+
export function toFormFieldValue(storageValue, fieldType) {
|
|
47
|
+
if (fieldType === "checkbox") {
|
|
48
|
+
if (typeof storageValue === "boolean") {
|
|
49
|
+
return storageValue;
|
|
50
|
+
}
|
|
51
|
+
// pdf.js stores checkbox as the export value when checked, "Off" when unchecked
|
|
52
|
+
return storageValue !== "Off" && storageValue !== false;
|
|
53
|
+
}
|
|
54
|
+
if (fieldType === "radiobutton") {
|
|
55
|
+
return typeof storageValue === "string" ? storageValue : "";
|
|
56
|
+
}
|
|
57
|
+
if (typeof storageValue === "string") {
|
|
58
|
+
return storageValue;
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(storageValue)) {
|
|
61
|
+
return storageValue.map(String);
|
|
62
|
+
}
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Converts a consumer PdfFormFieldValue to a pdf.js annotationStorage value.
|
|
68
|
+
* @internal Exported for testing.
|
|
69
|
+
*/
|
|
70
|
+
export function toStorageValue(formValue, fieldType) {
|
|
71
|
+
if (fieldType === "checkbox") {
|
|
72
|
+
if (typeof formValue === "boolean") {
|
|
73
|
+
return formValue;
|
|
74
|
+
}
|
|
75
|
+
return formValue !== "Off" && formValue !== "";
|
|
76
|
+
}
|
|
77
|
+
return formValue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Hook that manages interactive PDF form fields.
|
|
82
|
+
* Builds a field metadata map, pre-populates initial values,
|
|
83
|
+
* listens for field changes, and collects values on submit.
|
|
84
|
+
*/
|
|
85
|
+
export function usePdfFormFields({
|
|
86
|
+
pdfViewerRef,
|
|
87
|
+
eventBusRef,
|
|
88
|
+
document,
|
|
89
|
+
formData,
|
|
90
|
+
onFormSubmit,
|
|
91
|
+
onFormChange
|
|
92
|
+
}) {
|
|
93
|
+
const [hasFormFields, setHasFormFields] = useState(false);
|
|
94
|
+
|
|
95
|
+
// Stable refs for callbacks
|
|
96
|
+
const onFormSubmitRef = useRef(onFormSubmit);
|
|
97
|
+
const onFormChangeRef = useRef(onFormChange);
|
|
98
|
+
const formDataRef = useRef(formData);
|
|
99
|
+
useEffect(function () {
|
|
100
|
+
onFormSubmitRef.current = onFormSubmit;
|
|
101
|
+
onFormChangeRef.current = onFormChange;
|
|
102
|
+
formDataRef.current = formData;
|
|
103
|
+
}, [onFormSubmit, onFormChange, formData]);
|
|
104
|
+
|
|
105
|
+
// Map from annotation ID -> field metadata
|
|
106
|
+
const fieldMapRef = useRef(new Map());
|
|
107
|
+
// Reverse map from field name -> annotation IDs
|
|
108
|
+
const nameToIdsRef = useRef(new Map());
|
|
109
|
+
|
|
110
|
+
// Effect 1: Build field metadata map when document loads
|
|
111
|
+
useEffect(function () {
|
|
112
|
+
const doc = document;
|
|
113
|
+
if (doc == null) {
|
|
114
|
+
fieldMapRef.current.clear();
|
|
115
|
+
nameToIdsRef.current.clear();
|
|
116
|
+
setHasFormFields(false);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
let cancelled = false;
|
|
120
|
+
void doc.getFieldObjects().then(fieldObjects => {
|
|
121
|
+
if (cancelled || fieldObjects == null) {
|
|
122
|
+
setHasFormFields(false);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const fieldMap = new Map();
|
|
126
|
+
const nameToIds = new Map();
|
|
127
|
+
for (const [fieldName, objects] of Object.entries(fieldObjects)) {
|
|
128
|
+
const ids = [];
|
|
129
|
+
for (const obj of objects) {
|
|
130
|
+
const typedObj = obj;
|
|
131
|
+
if (typedObj.id == null) continue;
|
|
132
|
+
const fieldType = normalizeFieldType(typedObj.type ?? "text");
|
|
133
|
+
fieldMap.set(typedObj.id, {
|
|
134
|
+
fieldName,
|
|
135
|
+
fieldType,
|
|
136
|
+
exportValues: typedObj.exportValues,
|
|
137
|
+
page: typedObj.page ?? 0
|
|
138
|
+
});
|
|
139
|
+
ids.push(typedObj.id);
|
|
140
|
+
}
|
|
141
|
+
if (ids.length > 0) {
|
|
142
|
+
nameToIds.set(fieldName, ids);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
fieldMapRef.current = fieldMap;
|
|
146
|
+
nameToIdsRef.current = nameToIds;
|
|
147
|
+
setHasFormFields(fieldMap.size > 0);
|
|
148
|
+
});
|
|
149
|
+
return () => {
|
|
150
|
+
cancelled = true;
|
|
151
|
+
};
|
|
152
|
+
}, [document]);
|
|
153
|
+
|
|
154
|
+
// Populates form fields from formData into both annotation storage and DOM elements.
|
|
155
|
+
// Scoped to the viewer container to avoid conflicts with multiple viewer instances.
|
|
156
|
+
const populateFields = useCallback(() => {
|
|
157
|
+
const data = formDataRef.current;
|
|
158
|
+
const doc = document;
|
|
159
|
+
const pdfViewer = pdfViewerRef.current;
|
|
160
|
+
if (data == null || doc == null || pdfViewer == null) return;
|
|
161
|
+
if (fieldMapRef.current.size === 0) return;
|
|
162
|
+
const storage = doc.annotationStorage;
|
|
163
|
+
const container = getViewerContainer(pdfViewer);
|
|
164
|
+
for (const [fieldName, value] of Object.entries(data)) {
|
|
165
|
+
const ids = nameToIdsRef.current.get(fieldName);
|
|
166
|
+
if (ids == null) continue;
|
|
167
|
+
for (const id of ids) {
|
|
168
|
+
const entry = fieldMapRef.current.get(id);
|
|
169
|
+
if (entry == null) continue;
|
|
170
|
+
|
|
171
|
+
// Also update the DOM element directly (scoped to viewer container)
|
|
172
|
+
const el = container?.querySelector(`[data-element-id="${CSS.escape(id)}"]`);
|
|
173
|
+
if (entry.fieldType === "radiobutton") {
|
|
174
|
+
// Radio buttons: each ID is a separate option. Check the one
|
|
175
|
+
// whose export value matches, uncheck the others.
|
|
176
|
+
// Use exportValues if defined, otherwise fall back to the DOM
|
|
177
|
+
// element's value attribute (mirrors handleFieldChange logic).
|
|
178
|
+
const optionValue = entry.exportValues ?? (el instanceof HTMLInputElement ? el.value : undefined);
|
|
179
|
+
const isSelected = optionValue === String(value);
|
|
180
|
+
storage.setValue(id, {
|
|
181
|
+
value: isSelected ? entry.exportValues ?? String(value) : "Off"
|
|
182
|
+
});
|
|
183
|
+
if (el instanceof HTMLInputElement) {
|
|
184
|
+
el.checked = isSelected;
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
const storageVal = toStorageValue(value, entry.fieldType);
|
|
188
|
+
storage.setValue(id, {
|
|
189
|
+
value: storageVal
|
|
190
|
+
});
|
|
191
|
+
if (el == null) continue;
|
|
192
|
+
if (entry.fieldType === "checkbox" && el instanceof HTMLInputElement) {
|
|
193
|
+
el.checked = typeof storageVal === "boolean" ? storageVal : storageVal !== "Off";
|
|
194
|
+
} else if (el instanceof HTMLSelectElement) {
|
|
195
|
+
el.value = String(value);
|
|
196
|
+
} else if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
197
|
+
el.value = String(value);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}, [document, pdfViewerRef]);
|
|
203
|
+
|
|
204
|
+
// Effect 2: Populate initial form data when annotation layers render
|
|
205
|
+
useEffect(function () {
|
|
206
|
+
const eventBus = eventBusRef.current;
|
|
207
|
+
if (eventBus == null || document == null || formDataRef.current == null) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Attempt population immediately in case the field map was built
|
|
212
|
+
// after the annotation layer already rendered (race condition fix).
|
|
213
|
+
populateFields();
|
|
214
|
+
const onAnnotationLayerRendered = () => {
|
|
215
|
+
populateFields();
|
|
216
|
+
};
|
|
217
|
+
eventBus.on(ANNOTATION_LAYER_RENDERED_EVENT, onAnnotationLayerRendered);
|
|
218
|
+
return () => {
|
|
219
|
+
eventBus.off(ANNOTATION_LAYER_RENDERED_EVENT, onAnnotationLayerRendered);
|
|
220
|
+
};
|
|
221
|
+
}, [eventBusRef, document, hasFormFields, populateFields]);
|
|
222
|
+
|
|
223
|
+
// Effect 3: Listen for field changes via MutationObserver + event listeners
|
|
224
|
+
useEffect(function () {
|
|
225
|
+
const pdfViewer = pdfViewerRef.current;
|
|
226
|
+
if (pdfViewer == null || document == null) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Get the viewer's container element
|
|
231
|
+
const container = getViewerContainer(pdfViewer);
|
|
232
|
+
if (container == null) return;
|
|
233
|
+
const listeners = new Map();
|
|
234
|
+
function handleFieldChange(el) {
|
|
235
|
+
const id = el.getAttribute("data-element-id");
|
|
236
|
+
if (id == null) return;
|
|
237
|
+
const entry = fieldMapRef.current.get(id);
|
|
238
|
+
if (entry == null) return;
|
|
239
|
+
let value;
|
|
240
|
+
if (entry.fieldType === "checkbox" && el instanceof HTMLInputElement) {
|
|
241
|
+
value = el.checked;
|
|
242
|
+
} else if (entry.fieldType === "radiobutton" && el instanceof HTMLInputElement) {
|
|
243
|
+
// For radio buttons, the value is the button's export value when selected
|
|
244
|
+
value = el.checked ? entry.exportValues ?? el.value : "";
|
|
245
|
+
} else {
|
|
246
|
+
value = el.value;
|
|
247
|
+
}
|
|
248
|
+
onFormChangeRef.current?.(entry.fieldName, value);
|
|
249
|
+
}
|
|
250
|
+
function attachListeners(root) {
|
|
251
|
+
const elements = root.querySelectorAll?.(".annotationLayer input, .annotationLayer select, .annotationLayer textarea");
|
|
252
|
+
if (elements == null) return;
|
|
253
|
+
for (const el of elements) {
|
|
254
|
+
if (listeners.has(el)) continue;
|
|
255
|
+
const handler = () => {
|
|
256
|
+
handleFieldChange(el);
|
|
257
|
+
};
|
|
258
|
+
el.addEventListener("input", handler);
|
|
259
|
+
el.addEventListener("change", handler);
|
|
260
|
+
listeners.set(el, handler);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Attach to any elements already in the DOM
|
|
265
|
+
attachListeners(container);
|
|
266
|
+
|
|
267
|
+
// Watch for new form elements being added (pages render lazily)
|
|
268
|
+
const observer = new MutationObserver(mutations => {
|
|
269
|
+
for (const mutation of mutations) {
|
|
270
|
+
for (const node of mutation.addedNodes) {
|
|
271
|
+
if (node instanceof Element) {
|
|
272
|
+
attachListeners(node);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
observer.observe(container, {
|
|
278
|
+
childList: true,
|
|
279
|
+
subtree: true
|
|
280
|
+
});
|
|
281
|
+
return () => {
|
|
282
|
+
observer.disconnect();
|
|
283
|
+
for (const [el, handler] of listeners) {
|
|
284
|
+
el.removeEventListener("input", handler);
|
|
285
|
+
el.removeEventListener("change", handler);
|
|
286
|
+
}
|
|
287
|
+
listeners.clear();
|
|
288
|
+
};
|
|
289
|
+
}, [pdfViewerRef, document]);
|
|
290
|
+
|
|
291
|
+
// Callback: collect all form data and invoke onFormSubmit
|
|
292
|
+
const submitFormData = useCallback(() => {
|
|
293
|
+
const doc = document;
|
|
294
|
+
if (doc == null) return;
|
|
295
|
+
const storage = doc.annotationStorage;
|
|
296
|
+
const allValues = storage.getAll();
|
|
297
|
+
const result = {};
|
|
298
|
+
|
|
299
|
+
// Track which radio group has been resolved
|
|
300
|
+
const resolvedRadios = new Set();
|
|
301
|
+
for (const [id, entry] of fieldMapRef.current) {
|
|
302
|
+
const {
|
|
303
|
+
fieldName,
|
|
304
|
+
fieldType
|
|
305
|
+
} = entry;
|
|
306
|
+
|
|
307
|
+
// For radio buttons, only process each group once
|
|
308
|
+
if (fieldType === "radiobutton") {
|
|
309
|
+
if (resolvedRadios.has(fieldName)) continue;
|
|
310
|
+
resolvedRadios.add(fieldName);
|
|
311
|
+
|
|
312
|
+
// Find the selected radio in the group
|
|
313
|
+
const groupIds = nameToIdsRef.current.get(fieldName) ?? [];
|
|
314
|
+
let selectedValue = "";
|
|
315
|
+
for (const radioId of groupIds) {
|
|
316
|
+
const stored = allValues?.[radioId];
|
|
317
|
+
const val = stored != null && typeof stored === "object" && "value" in stored ? stored.value : stored;
|
|
318
|
+
if (val === true || typeof val === "string" && val !== "Off") {
|
|
319
|
+
const radioEntry = fieldMapRef.current.get(radioId);
|
|
320
|
+
selectedValue = radioEntry?.exportValues ?? String(val);
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
result[fieldName] = selectedValue;
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
const stored = allValues?.[id];
|
|
328
|
+
const rawValue = stored != null && typeof stored === "object" && "value" in stored ? stored.value : stored;
|
|
329
|
+
|
|
330
|
+
// Skip if we already have a value for this field name (e.g. duplicate IDs)
|
|
331
|
+
if (fieldName in result) continue;
|
|
332
|
+
result[fieldName] = toFormFieldValue(rawValue, fieldType);
|
|
333
|
+
}
|
|
334
|
+
onFormSubmitRef.current?.(result);
|
|
335
|
+
}, [document]);
|
|
336
|
+
return {
|
|
337
|
+
hasFormFields,
|
|
338
|
+
submitFormData
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=usePdfFormFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePdfFormFields.js","names":["useCallback","useEffect","useRef","useState","ANNOTATION_LAYER_RENDERED_EVENT","getViewerContainer","viewer","container","normalizeFieldType","type","toFormFieldValue","storageValue","fieldType","Array","isArray","map","String","toStorageValue","formValue","usePdfFormFields","pdfViewerRef","eventBusRef","document","formData","onFormSubmit","onFormChange","hasFormFields","setHasFormFields","onFormSubmitRef","onFormChangeRef","formDataRef","current","fieldMapRef","Map","nameToIdsRef","doc","clear","cancelled","getFieldObjects","then","fieldObjects","fieldMap","nameToIds","fieldName","objects","Object","entries","ids","obj","typedObj","id","set","exportValues","page","push","length","size","populateFields","data","pdfViewer","storage","annotationStorage","value","get","entry","el","querySelector","CSS","escape","optionValue","HTMLInputElement","undefined","isSelected","setValue","checked","storageVal","HTMLSelectElement","HTMLTextAreaElement","eventBus","onAnnotationLayerRendered","on","off","listeners","handleFieldChange","getAttribute","attachListeners","root","elements","querySelectorAll","has","handler","addEventListener","observer","MutationObserver","mutations","mutation","node","addedNodes","Element","observe","childList","subtree","disconnect","removeEventListener","submitFormData","allValues","getAll","result","resolvedRadios","Set","add","groupIds","selectedValue","radioId","stored","val","radioEntry","rawValue"],"sources":["usePdfFormFields.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 { useCallback, useEffect, useRef, useState } from \"react\";\nimport { ANNOTATION_LAYER_RENDERED_EVENT } from \"../constants.js\";\nimport type { PdfFormFieldValue } from \"../types.js\";\n\n/** Get the viewer's container element (typed loosely by pdf.js). */\nfunction getViewerContainer(viewer: PDFViewer): HTMLElement | undefined {\n return (viewer as { container?: HTMLElement }).container;\n}\n\n/** Internal metadata for a single form field annotation. */\ninterface FieldEntry {\n fieldName: string;\n fieldType: \"text\" | \"checkbox\" | \"radiobutton\" | \"combobox\" | \"listbox\";\n exportValues: string | undefined;\n page: number;\n}\n\nexport interface UsePdfFormFieldsOptions {\n pdfViewerRef: RefObject<PDFViewer | null>;\n eventBusRef: RefObject<EventBus | null>;\n document: PDFDocumentProxy | undefined;\n formData?: Record<string, PdfFormFieldValue>;\n onFormSubmit?: (data: Record<string, PdfFormFieldValue>) => void;\n onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;\n}\n\nexport interface UsePdfFormFieldsResult {\n /** Whether the loaded PDF contains interactive form fields. */\n hasFormFields: boolean;\n /** Collect all current form field values and invoke onFormSubmit. */\n submitFormData: () => void;\n}\n\n/**\n * Normalizes a pdf.js field object type string to a simplified form type.\n * @internal Exported for testing.\n */\nexport function normalizeFieldType(\n type: string,\n): \"text\" | \"checkbox\" | \"radiobutton\" | \"combobox\" | \"listbox\" {\n switch (type) {\n case \"checkbox\":\n case \"radiobutton\":\n case \"combobox\":\n case \"listbox\":\n return type;\n default:\n return \"text\";\n }\n}\n\n/**\n * Converts a pdf.js annotationStorage value to a consumer-friendly PdfFormFieldValue.\n * @internal Exported for testing.\n */\nexport function toFormFieldValue(\n storageValue: unknown,\n fieldType: \"text\" | \"checkbox\" | \"radiobutton\" | \"combobox\" | \"listbox\",\n): PdfFormFieldValue {\n if (fieldType === \"checkbox\") {\n if (typeof storageValue === \"boolean\") {\n return storageValue;\n }\n // pdf.js stores checkbox as the export value when checked, \"Off\" when unchecked\n return storageValue !== \"Off\" && storageValue !== false;\n }\n if (fieldType === \"radiobutton\") {\n return typeof storageValue === \"string\" ? storageValue : \"\";\n }\n if (typeof storageValue === \"string\") {\n return storageValue;\n }\n if (Array.isArray(storageValue)) {\n return storageValue.map(String);\n }\n return \"\";\n}\n\n/**\n * Converts a consumer PdfFormFieldValue to a pdf.js annotationStorage value.\n * @internal Exported for testing.\n */\nexport function toStorageValue(\n formValue: PdfFormFieldValue,\n fieldType: \"text\" | \"checkbox\" | \"radiobutton\" | \"combobox\" | \"listbox\",\n): unknown {\n if (fieldType === \"checkbox\") {\n if (typeof formValue === \"boolean\") {\n return formValue;\n }\n return formValue !== \"Off\" && formValue !== \"\";\n }\n return formValue;\n}\n\n/**\n * Hook that manages interactive PDF form fields.\n * Builds a field metadata map, pre-populates initial values,\n * listens for field changes, and collects values on submit.\n */\nexport function usePdfFormFields({\n pdfViewerRef,\n eventBusRef,\n document,\n formData,\n onFormSubmit,\n onFormChange,\n}: UsePdfFormFieldsOptions): UsePdfFormFieldsResult {\n const [hasFormFields, setHasFormFields] = useState(false);\n\n // Stable refs for callbacks\n const onFormSubmitRef = useRef(onFormSubmit);\n const onFormChangeRef = useRef(onFormChange);\n const formDataRef = useRef(formData);\n\n useEffect(function syncCallbackRefs() {\n onFormSubmitRef.current = onFormSubmit;\n onFormChangeRef.current = onFormChange;\n formDataRef.current = formData;\n }, [onFormSubmit, onFormChange, formData]);\n\n // Map from annotation ID -> field metadata\n const fieldMapRef = useRef<Map<string, FieldEntry>>(new Map());\n // Reverse map from field name -> annotation IDs\n const nameToIdsRef = useRef<Map<string, string[]>>(new Map());\n\n // Effect 1: Build field metadata map when document loads\n useEffect(function buildFieldMap() {\n const doc = document;\n if (doc == null) {\n fieldMapRef.current.clear();\n nameToIdsRef.current.clear();\n setHasFormFields(false);\n return;\n }\n\n let cancelled = false;\n\n void doc.getFieldObjects().then((fieldObjects) => {\n if (cancelled || fieldObjects == null) {\n setHasFormFields(false);\n return;\n }\n\n const fieldMap = new Map<string, FieldEntry>();\n const nameToIds = new Map<string, string[]>();\n\n for (const [fieldName, objects] of Object.entries(fieldObjects)) {\n const ids: string[] = [];\n for (const obj of objects) {\n const typedObj = obj as {\n id?: string;\n type?: string;\n exportValues?: string;\n page?: number;\n };\n if (typedObj.id == null) continue;\n\n const fieldType = normalizeFieldType(typedObj.type ?? \"text\");\n fieldMap.set(typedObj.id, {\n fieldName,\n fieldType,\n exportValues: typedObj.exportValues,\n page: typedObj.page ?? 0,\n });\n ids.push(typedObj.id);\n }\n if (ids.length > 0) {\n nameToIds.set(fieldName, ids);\n }\n }\n\n fieldMapRef.current = fieldMap;\n nameToIdsRef.current = nameToIds;\n setHasFormFields(fieldMap.size > 0);\n });\n\n return () => {\n cancelled = true;\n };\n }, [document]);\n\n // Populates form fields from formData into both annotation storage and DOM elements.\n // Scoped to the viewer container to avoid conflicts with multiple viewer instances.\n const populateFields = useCallback(() => {\n const data = formDataRef.current;\n const doc = document;\n const pdfViewer = pdfViewerRef.current;\n if (data == null || doc == null || pdfViewer == null) return;\n if (fieldMapRef.current.size === 0) return;\n\n const storage = doc.annotationStorage;\n const container = getViewerContainer(pdfViewer);\n\n for (const [fieldName, value] of Object.entries(data)) {\n const ids = nameToIdsRef.current.get(fieldName);\n if (ids == null) continue;\n\n for (const id of ids) {\n const entry = fieldMapRef.current.get(id);\n if (entry == null) continue;\n\n // Also update the DOM element directly (scoped to viewer container)\n const el = container?.querySelector(\n `[data-element-id=\"${CSS.escape(id)}\"]`,\n );\n\n if (entry.fieldType === \"radiobutton\") {\n // Radio buttons: each ID is a separate option. Check the one\n // whose export value matches, uncheck the others.\n // Use exportValues if defined, otherwise fall back to the DOM\n // element's value attribute (mirrors handleFieldChange logic).\n const optionValue = entry.exportValues\n ?? (el instanceof HTMLInputElement ? el.value : undefined);\n const isSelected = optionValue === String(value);\n storage.setValue(id, {\n value: isSelected ? (entry.exportValues ?? String(value)) : \"Off\",\n });\n if (el instanceof HTMLInputElement) {\n el.checked = isSelected;\n }\n } else {\n const storageVal = toStorageValue(value, entry.fieldType);\n storage.setValue(id, { value: storageVal });\n\n if (el == null) continue;\n\n if (\n entry.fieldType === \"checkbox\" && el instanceof HTMLInputElement\n ) {\n el.checked = typeof storageVal === \"boolean\"\n ? storageVal\n : storageVal !== \"Off\";\n } else if (el instanceof HTMLSelectElement) {\n el.value = String(value);\n } else if (\n el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement\n ) {\n el.value = String(value);\n }\n }\n }\n }\n }, [document, pdfViewerRef]);\n\n // Effect 2: Populate initial form data when annotation layers render\n useEffect(function populateFormData() {\n const eventBus = eventBusRef.current;\n if (eventBus == null || document == null || formDataRef.current == null) {\n return;\n }\n\n // Attempt population immediately in case the field map was built\n // after the annotation layer already rendered (race condition fix).\n populateFields();\n\n const onAnnotationLayerRendered = () => {\n populateFields();\n };\n\n eventBus.on(ANNOTATION_LAYER_RENDERED_EVENT, onAnnotationLayerRendered);\n\n return () => {\n eventBus.off(ANNOTATION_LAYER_RENDERED_EVENT, onAnnotationLayerRendered);\n };\n }, [eventBusRef, document, hasFormFields, populateFields]);\n\n // Effect 3: Listen for field changes via MutationObserver + event listeners\n useEffect(function listenForFieldChanges() {\n const pdfViewer = pdfViewerRef.current;\n if (pdfViewer == null || document == null) {\n return;\n }\n\n // Get the viewer's container element\n const container = getViewerContainer(pdfViewer);\n if (container == null) return;\n\n const listeners = new Map<Element, () => void>();\n\n function handleFieldChange(\n el: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement,\n ) {\n const id = el.getAttribute(\"data-element-id\");\n if (id == null) return;\n\n const entry = fieldMapRef.current.get(id);\n if (entry == null) return;\n\n let value: PdfFormFieldValue;\n if (entry.fieldType === \"checkbox\" && el instanceof HTMLInputElement) {\n value = el.checked;\n } else if (\n entry.fieldType === \"radiobutton\" && el instanceof HTMLInputElement\n ) {\n // For radio buttons, the value is the button's export value when selected\n value = el.checked ? (entry.exportValues ?? el.value) : \"\";\n } else {\n value = el.value;\n }\n\n onFormChangeRef.current?.(entry.fieldName, value);\n }\n\n function attachListeners(root: Node) {\n const elements = (root as Element).querySelectorAll?.(\n \".annotationLayer input, .annotationLayer select, .annotationLayer textarea\",\n );\n if (elements == null) return;\n\n for (const el of elements) {\n if (listeners.has(el)) continue;\n\n const handler = () => {\n handleFieldChange(\n el as HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement,\n );\n };\n el.addEventListener(\"input\", handler);\n el.addEventListener(\"change\", handler);\n listeners.set(el, handler);\n }\n }\n\n // Attach to any elements already in the DOM\n attachListeners(container);\n\n // Watch for new form elements being added (pages render lazily)\n const observer = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n for (const node of mutation.addedNodes) {\n if (node instanceof Element) {\n attachListeners(node);\n }\n }\n }\n });\n\n observer.observe(container, { childList: true, subtree: true });\n\n return () => {\n observer.disconnect();\n for (const [el, handler] of listeners) {\n el.removeEventListener(\"input\", handler);\n el.removeEventListener(\"change\", handler);\n }\n listeners.clear();\n };\n }, [pdfViewerRef, document]);\n\n // Callback: collect all form data and invoke onFormSubmit\n const submitFormData = useCallback(() => {\n const doc = document;\n if (doc == null) return;\n\n const storage = doc.annotationStorage;\n const allValues = storage.getAll() as Record<string, unknown> | null;\n const result: Record<string, PdfFormFieldValue> = {};\n\n // Track which radio group has been resolved\n const resolvedRadios = new Set<string>();\n\n for (const [id, entry] of fieldMapRef.current) {\n const { fieldName, fieldType } = entry;\n\n // For radio buttons, only process each group once\n if (fieldType === \"radiobutton\") {\n if (resolvedRadios.has(fieldName)) continue;\n resolvedRadios.add(fieldName);\n\n // Find the selected radio in the group\n const groupIds = nameToIdsRef.current.get(fieldName) ?? [];\n let selectedValue = \"\";\n for (const radioId of groupIds) {\n const stored = allValues?.[radioId];\n const val =\n stored != null && typeof stored === \"object\" && \"value\" in stored\n ? (stored as { value: unknown }).value\n : stored;\n if (val === true || (typeof val === \"string\" && val !== \"Off\")) {\n const radioEntry = fieldMapRef.current.get(radioId);\n selectedValue = radioEntry?.exportValues ?? String(val);\n break;\n }\n }\n result[fieldName] = selectedValue;\n continue;\n }\n\n const stored = allValues?.[id];\n const rawValue =\n stored != null && typeof stored === \"object\" && \"value\" in stored\n ? (stored as { value: unknown }).value\n : stored;\n\n // Skip if we already have a value for this field name (e.g. duplicate IDs)\n if (fieldName in result) continue;\n\n result[fieldName] = toFormFieldValue(rawValue, fieldType);\n }\n\n onFormSubmitRef.current?.(result);\n }, [document]);\n\n return {\n hasFormFields,\n submitFormData,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAChE,SAASC,+BAA+B,QAAQ,iBAAiB;AAGjE;AACA,SAASC,kBAAkBA,CAACC,MAAiB,EAA2B;EACtE,OAAQA,MAAM,CAAiCC,SAAS;AAC1D;;AAEA;;AAwBA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAk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