@osdk/react-components 0.2.0-beta.23 → 0.2.0-beta.25
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 +3 -0
- package/CHANGELOG.md +29 -0
- 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/FormFieldRenderer.js +26 -8
- 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/pdf-viewer/PdfViewer.js +40 -4
- package/build/browser/pdf-viewer/PdfViewer.js.map +1 -1
- 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 +326 -0
- package/build/browser/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js +199 -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/types.js.map +1 -1
- package/build/browser/public/experimental.js +3 -0
- package/build/browser/public/experimental.js.map +1 -1
- package/build/browser/styles.css +144 -35
- package/build/cjs/public/experimental.cjs +1735 -1109
- 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 +154 -20
- 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/FormFieldRenderer.js +26 -8
- 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/pdf-viewer/PdfViewer.js +40 -4
- package/build/esm/pdf-viewer/PdfViewer.js.map +1 -1
- 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 +326 -0
- package/build/esm/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js +199 -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/types.js.map +1 -1
- package/build/esm/public/experimental.js +3 -0
- package/build/esm/public/experimental.js.map +1 -1
- package/build/types/action-form/FormFieldApi.d.ts +8 -2
- package/build/types/action-form/FormFieldApi.d.ts.map +1 -1
- 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/pdf-viewer/PdfViewer.d.ts +1 -1
- package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -1
- 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 +35 -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 +90 -13
- package/build/types/pdf-viewer/types.d.ts.map +1 -1
- package/build/types/public/experimental.d.ts +4 -1
- package/build/types/public/experimental.d.ts.map +1 -1
- package/package.json +5 -5
- package/build/browser/action-form/fields/TextInputField.module.css.js +0 -6
|
@@ -0,0 +1,199 @@
|
|
|
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 { AnnotationEditorType } from "pdfjs-dist";
|
|
18
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
19
|
+
/**
|
|
20
|
+
* Converts an RGB array (0.0–1.0 per channel) to a CSS hex color string.
|
|
21
|
+
*/
|
|
22
|
+
export function rgbArrayToHex(color) {
|
|
23
|
+
const r = Math.round(color[0] * 255);
|
|
24
|
+
const g = Math.round(color[1] * 255);
|
|
25
|
+
const b = Math.round(color[2] * 255);
|
|
26
|
+
return `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Converts quadPoints (PDF spec format) back to PdfRect[].
|
|
31
|
+
* QuadPoints are 8 values per quad: [x1,y1, x2,y2, x3,y3, x4,y4]
|
|
32
|
+
* representing the four corners of each highlight rect.
|
|
33
|
+
*
|
|
34
|
+
* PDF.js highlight editor produces axis-aligned quads with ordering:
|
|
35
|
+
* (x1,y1)=top-left, (x2,y2)=top-right, (x3,y3)=bottom-left, (x4,y4)=bottom-right
|
|
36
|
+
* We derive the bounding rect from x1, y1 (top), x2 (right edge), y3 (bottom).
|
|
37
|
+
*/
|
|
38
|
+
export function quadPointsToRects(quadPoints) {
|
|
39
|
+
const rects = [];
|
|
40
|
+
for (let i = 0; i < quadPoints.length; i += 8) {
|
|
41
|
+
const x1 = quadPoints[i];
|
|
42
|
+
const y1 = quadPoints[i + 1];
|
|
43
|
+
const x2 = quadPoints[i + 2];
|
|
44
|
+
const y3 = quadPoints[i + 5];
|
|
45
|
+
const x = Math.min(x1, x2);
|
|
46
|
+
const y = Math.min(y1, y3);
|
|
47
|
+
const width = Math.abs(x2 - x1);
|
|
48
|
+
const height = Math.abs(y1 - y3);
|
|
49
|
+
rects.push({
|
|
50
|
+
x,
|
|
51
|
+
y,
|
|
52
|
+
width,
|
|
53
|
+
height
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return rects;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Hook that manages the PDF.js built-in highlight annotation editor mode.
|
|
61
|
+
* When active, users can select text to create highlights.
|
|
62
|
+
* A callback fires with the annotation details for persistence.
|
|
63
|
+
*/
|
|
64
|
+
export function usePdfHighlightMode({
|
|
65
|
+
pdfViewerRef,
|
|
66
|
+
document,
|
|
67
|
+
enabled,
|
|
68
|
+
onTextHighlight,
|
|
69
|
+
onHighlightDelete
|
|
70
|
+
}) {
|
|
71
|
+
const [highlightModeActive, setHighlightModeActive] = useState(false);
|
|
72
|
+
const onTextHighlightRef = useRef(onTextHighlight);
|
|
73
|
+
const onHighlightDeleteRef = useRef(onHighlightDelete);
|
|
74
|
+
const knownEditorIdsRef = useRef(new Set());
|
|
75
|
+
const editorEventsRef = useRef(new Map());
|
|
76
|
+
|
|
77
|
+
// Keep callback refs in sync
|
|
78
|
+
useEffect(function () {
|
|
79
|
+
onTextHighlightRef.current = onTextHighlight;
|
|
80
|
+
onHighlightDeleteRef.current = onHighlightDelete;
|
|
81
|
+
}, [onTextHighlight, onHighlightDelete]);
|
|
82
|
+
|
|
83
|
+
// Toggle the PDF.js annotation editor mode
|
|
84
|
+
useEffect(function () {
|
|
85
|
+
const pdfViewer = pdfViewerRef.current;
|
|
86
|
+
if (pdfViewer == null || document == null) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
if (highlightModeActive && enabled) {
|
|
91
|
+
pdfViewer.annotationEditorMode = {
|
|
92
|
+
mode: AnnotationEditorType.HIGHLIGHT
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
pdfViewer.annotationEditorMode = {
|
|
96
|
+
mode: AnnotationEditorType.NONE
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
} catch {
|
|
100
|
+
// AnnotationEditorUIManager may not be initialized yet
|
|
101
|
+
}
|
|
102
|
+
}, [pdfViewerRef, document, highlightModeActive, enabled]);
|
|
103
|
+
|
|
104
|
+
// Deactivate highlight mode when the feature is disabled
|
|
105
|
+
useEffect(function () {
|
|
106
|
+
if (!enabled) {
|
|
107
|
+
setHighlightModeActive(false);
|
|
108
|
+
}
|
|
109
|
+
}, [enabled]);
|
|
110
|
+
|
|
111
|
+
// Clear tracked editors when the document changes (but not on highlight toggle)
|
|
112
|
+
const prevDocumentRef = useRef(undefined);
|
|
113
|
+
useEffect(function () {
|
|
114
|
+
if (document !== prevDocumentRef.current) {
|
|
115
|
+
knownEditorIdsRef.current.clear();
|
|
116
|
+
editorEventsRef.current.clear();
|
|
117
|
+
prevDocumentRef.current = document;
|
|
118
|
+
}
|
|
119
|
+
}, [document]);
|
|
120
|
+
|
|
121
|
+
// Listen for new highlights being added to annotation storage
|
|
122
|
+
useEffect(function () {
|
|
123
|
+
if (document == null || !highlightModeActive || !enabled) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const storage = document.annotationStorage;
|
|
127
|
+
const previousOnAnnotationEditor = storage.onAnnotationEditor;
|
|
128
|
+
|
|
129
|
+
// Monkey-patch storage.remove to detect highlight deletions.
|
|
130
|
+
// This is fragile but necessary because PDF.js does not emit events
|
|
131
|
+
// when editors are removed. Restore the original on cleanup.
|
|
132
|
+
const originalRemove = storage.remove.bind(storage);
|
|
133
|
+
storage.remove = key => {
|
|
134
|
+
const savedEvent = editorEventsRef.current.get(key);
|
|
135
|
+
if (savedEvent != null) {
|
|
136
|
+
editorEventsRef.current.delete(key);
|
|
137
|
+
knownEditorIdsRef.current.delete(key);
|
|
138
|
+
onHighlightDeleteRef.current?.(savedEvent);
|
|
139
|
+
}
|
|
140
|
+
originalRemove(key);
|
|
141
|
+
};
|
|
142
|
+
storage.onAnnotationEditor = type => {
|
|
143
|
+
// onAnnotationEditor fires with the editor's static _type (string "highlight")
|
|
144
|
+
if (type !== "highlight") {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Find new editors in storage
|
|
149
|
+
const allEntries = storage.getAll();
|
|
150
|
+
if (allEntries == null) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
for (const [id, entry] of Object.entries(allEntries)) {
|
|
154
|
+
if (knownEditorIdsRef.current.has(id)) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Check if this is a highlight editor with serializable data
|
|
159
|
+
if (typeof entry === "object" && entry != null && "serialize" in entry && typeof entry.serialize === "function") {
|
|
160
|
+
knownEditorIdsRef.current.add(id);
|
|
161
|
+
const serialized = entry.serialize(false);
|
|
162
|
+
if (serialized == null || serialized.annotationType !== AnnotationEditorType.HIGHLIGHT) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const rects = serialized.quadPoints != null ? quadPointsToRects(serialized.quadPoints) : [];
|
|
166
|
+
if (rects.length === 0) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const color = Array.isArray(serialized.color) ? rgbArrayToHex(serialized.color) : "#fff066";
|
|
170
|
+
|
|
171
|
+
// Extract text from the editor's aria-label (stores selected text)
|
|
172
|
+
const selectedText = typeof entry.div?.getAttribute === "function" ? entry.div.getAttribute("aria-label") ?? "" : "";
|
|
173
|
+
const event = {
|
|
174
|
+
page: serialized.pageIndex + 1,
|
|
175
|
+
rects,
|
|
176
|
+
selectedText,
|
|
177
|
+
color
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// Store the event so we can provide it back on delete
|
|
181
|
+
editorEventsRef.current.set(id, event);
|
|
182
|
+
onTextHighlightRef.current?.(event);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
return () => {
|
|
187
|
+
storage.onAnnotationEditor = previousOnAnnotationEditor;
|
|
188
|
+
storage.remove = originalRemove;
|
|
189
|
+
};
|
|
190
|
+
}, [document, highlightModeActive, enabled]);
|
|
191
|
+
const toggleHighlightMode = useCallback(() => {
|
|
192
|
+
setHighlightModeActive(prev => !prev);
|
|
193
|
+
}, []);
|
|
194
|
+
return {
|
|
195
|
+
highlightModeActive,
|
|
196
|
+
toggleHighlightMode
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=usePdfHighlightMode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePdfHighlightMode.js","names":["AnnotationEditorType","useCallback","useEffect","useRef","useState","rgbArrayToHex","color","r","Math","round","g","b","toString","padStart","quadPointsToRects","quadPoints","rects","i","length","x1","y1","x2","y3","x","min","y","width","abs","height","push","usePdfHighlightMode","pdfViewerRef","document","enabled","onTextHighlight","onHighlightDelete","highlightModeActive","setHighlightModeActive","onTextHighlightRef","onHighlightDeleteRef","knownEditorIdsRef","Set","editorEventsRef","Map","current","pdfViewer","annotationEditorMode","mode","HIGHLIGHT","NONE","prevDocumentRef","undefined","clear","storage","annotationStorage","previousOnAnnotationEditor","onAnnotationEditor","originalRemove","remove","bind","key","savedEvent","get","delete","type","allEntries","getAll","id","entry","Object","entries","has","serialize","add","serialized","annotationType","Array","isArray","selectedText","div","getAttribute","event","page","pageIndex","set","toggleHighlightMode","prev"],"sources":["usePdfHighlightMode.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 { AnnotationEditorType } from \"pdfjs-dist\";\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport type { PDFViewer } from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport type { RefObject } from \"react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { PdfRect, PdfTextHighlightEvent } from \"../types.js\";\n\nexport interface UsePdfHighlightModeOptions {\n pdfViewerRef: RefObject<PDFViewer | null>;\n document: PDFDocumentProxy | undefined;\n enabled: boolean;\n onTextHighlight?: (event: PdfTextHighlightEvent) => void;\n onHighlightDelete?: (event: PdfTextHighlightEvent) => void;\n}\n\nexport interface UsePdfHighlightModeResult {\n highlightModeActive: boolean;\n toggleHighlightMode: () => void;\n}\n\n/**\n * Converts an RGB array (0.0–1.0 per channel) to a CSS hex color string.\n */\nexport function rgbArrayToHex(color: number[]): string {\n const r = Math.round(color[0] * 255);\n const g = Math.round(color[1] * 255);\n const b = Math.round(color[2] * 255);\n return `#${r.toString(16).padStart(2, \"0\")}${\n g.toString(16).padStart(2, \"0\")\n }${b.toString(16).padStart(2, \"0\")}`;\n}\n\n/**\n * Converts quadPoints (PDF spec format) back to PdfRect[].\n * QuadPoints are 8 values per quad: [x1,y1, x2,y2, x3,y3, x4,y4]\n * representing the four corners of each highlight rect.\n *\n * PDF.js highlight editor produces axis-aligned quads with ordering:\n * (x1,y1)=top-left, (x2,y2)=top-right, (x3,y3)=bottom-left, (x4,y4)=bottom-right\n * We derive the bounding rect from x1, y1 (top), x2 (right edge), y3 (bottom).\n */\nexport function quadPointsToRects(\n quadPoints: Float32Array,\n): PdfRect[] {\n const rects: PdfRect[] = [];\n for (let i = 0; i < quadPoints.length; i += 8) {\n const x1 = quadPoints[i];\n const y1 = quadPoints[i + 1];\n const x2 = quadPoints[i + 2];\n const y3 = quadPoints[i + 5];\n\n const x = Math.min(x1, x2);\n const y = Math.min(y1, y3);\n const width = Math.abs(x2 - x1);\n const height = Math.abs(y1 - y3);\n\n rects.push({ x, y, width, height });\n }\n return rects;\n}\n\n/**\n * Hook that manages the PDF.js built-in highlight annotation editor mode.\n * When active, users can select text to create highlights.\n * A callback fires with the annotation details for persistence.\n */\nexport function usePdfHighlightMode({\n pdfViewerRef,\n document,\n enabled,\n onTextHighlight,\n onHighlightDelete,\n}: UsePdfHighlightModeOptions): UsePdfHighlightModeResult {\n const [highlightModeActive, setHighlightModeActive] = useState(false);\n const onTextHighlightRef = useRef(onTextHighlight);\n const onHighlightDeleteRef = useRef(onHighlightDelete);\n const knownEditorIdsRef = useRef<Set<string>>(new Set());\n const editorEventsRef = useRef<Map<string, PdfTextHighlightEvent>>(new Map());\n\n // Keep callback refs in sync\n useEffect(function syncCallbackRef() {\n onTextHighlightRef.current = onTextHighlight;\n onHighlightDeleteRef.current = onHighlightDelete;\n }, [onTextHighlight, onHighlightDelete]);\n\n // Toggle the PDF.js annotation editor mode\n useEffect(function syncHighlightMode() {\n const pdfViewer = pdfViewerRef.current;\n if (pdfViewer == null || document == null) {\n return;\n }\n\n try {\n if (highlightModeActive && enabled) {\n pdfViewer.annotationEditorMode = {\n mode: AnnotationEditorType.HIGHLIGHT,\n };\n } else {\n pdfViewer.annotationEditorMode = {\n mode: AnnotationEditorType.NONE,\n };\n }\n } catch {\n // AnnotationEditorUIManager may not be initialized yet\n }\n }, [pdfViewerRef, document, highlightModeActive, enabled]);\n\n // Deactivate highlight mode when the feature is disabled\n useEffect(function deactivateOnDisable() {\n if (!enabled) {\n setHighlightModeActive(false);\n }\n }, [enabled]);\n\n // Clear tracked editors when the document changes (but not on highlight toggle)\n const prevDocumentRef = useRef<PDFDocumentProxy | undefined>(undefined);\n useEffect(function clearOnDocumentChange() {\n if (document !== prevDocumentRef.current) {\n knownEditorIdsRef.current.clear();\n editorEventsRef.current.clear();\n prevDocumentRef.current = document;\n }\n }, [document]);\n\n // Listen for new highlights being added to annotation storage\n useEffect(function listenForHighlights() {\n if (document == null || !highlightModeActive || !enabled) {\n return;\n }\n\n const storage = document.annotationStorage;\n const previousOnAnnotationEditor = storage.onAnnotationEditor;\n\n // Monkey-patch storage.remove to detect highlight deletions.\n // This is fragile but necessary because PDF.js does not emit events\n // when editors are removed. Restore the original on cleanup.\n const originalRemove = storage.remove.bind(storage);\n storage.remove = (key: string) => {\n const savedEvent = editorEventsRef.current.get(key);\n if (savedEvent != null) {\n editorEventsRef.current.delete(key);\n knownEditorIdsRef.current.delete(key);\n onHighlightDeleteRef.current?.(savedEvent);\n }\n originalRemove(key);\n };\n\n storage.onAnnotationEditor = (type: string | number | null) => {\n // onAnnotationEditor fires with the editor's static _type (string \"highlight\")\n if (type !== \"highlight\") {\n return;\n }\n\n // Find new editors in storage\n const allEntries = storage.getAll();\n if (allEntries == null) {\n return;\n }\n\n for (const [id, entry] of Object.entries(allEntries)) {\n if (knownEditorIdsRef.current.has(id)) {\n continue;\n }\n\n // Check if this is a highlight editor with serializable data\n if (\n typeof entry === \"object\" && entry != null\n && \"serialize\" in entry\n && typeof entry.serialize === \"function\"\n ) {\n knownEditorIdsRef.current.add(id);\n const serialized = entry.serialize(false);\n if (\n serialized == null\n || serialized.annotationType !== AnnotationEditorType.HIGHLIGHT\n ) {\n continue;\n }\n\n const rects = serialized.quadPoints != null\n ? quadPointsToRects(serialized.quadPoints)\n : [];\n\n if (rects.length === 0) {\n continue;\n }\n\n const color = Array.isArray(serialized.color)\n ? rgbArrayToHex(serialized.color)\n : \"#fff066\";\n\n // Extract text from the editor's aria-label (stores selected text)\n const selectedText = typeof entry.div?.getAttribute === \"function\"\n ? entry.div.getAttribute(\"aria-label\") ?? \"\"\n : \"\";\n\n const event: PdfTextHighlightEvent = {\n page: serialized.pageIndex + 1,\n rects,\n selectedText,\n color,\n };\n\n // Store the event so we can provide it back on delete\n editorEventsRef.current.set(id, event);\n\n onTextHighlightRef.current?.(event);\n }\n }\n };\n\n return () => {\n storage.onAnnotationEditor = previousOnAnnotationEditor;\n storage.remove = originalRemove;\n };\n }, [document, highlightModeActive, enabled]);\n\n const toggleHighlightMode = useCallback(() => {\n setHighlightModeActive((prev) => !prev);\n }, []);\n\n return {\n highlightModeActive,\n toggleHighlightMode,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoB,QAAQ,YAAY;AAIjD,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAgBhE;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,KAAe,EAAU;EACrD,MAAMC,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACH,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;EACpC,MAAMI,CAAC,GAAGF,IAAI,CAACC,KAAK,CAACH,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;EACpC,MAAMK,CAAC,GAAGH,IAAI,CAACC,KAAK,CAACH,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;EACpC,OAAO,IAAIC,CAAC,CAACK,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GACxCH,CAAC,CAACE,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAC9BF,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAC/BC,UAAwB,EACb;EACX,MAAMC,KAAgB,GAAG,EAAE;EAC3B,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG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E,EAAE,CAAC;EAEN,OAAO;IACLlD,mBAAmB;IACnBiD;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { AnnotationEditorType } from "pdfjs-dist";
|
|
17
18
|
import { EventBus, PDFFindController, PDFLinkService, PDFViewer } from "pdfjs-dist/web/pdf_viewer.mjs";
|
|
18
19
|
import { useEffect, useRef } from "react";
|
|
19
20
|
import { PAGES_LOADED_EVENT } from "../constants.js";
|
|
@@ -42,25 +43,30 @@ export function usePdfViewer(containerRef, viewerRef, document, initialScale, in
|
|
|
42
43
|
eventBus,
|
|
43
44
|
linkService,
|
|
44
45
|
findController,
|
|
45
|
-
removePageBorders: true
|
|
46
|
+
removePageBorders: true,
|
|
47
|
+
annotationEditorMode: AnnotationEditorType.NONE,
|
|
48
|
+
annotationEditorHighlightColors: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F"
|
|
46
49
|
});
|
|
47
50
|
linkService.setViewer(pdfViewer);
|
|
48
51
|
linkService.setDocument(document);
|
|
49
52
|
findController.setDocument(document);
|
|
50
53
|
pdfViewer.setDocument(document);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
|
|
55
|
+
// Apply initial scale and page after pages are loaded to avoid
|
|
56
|
+
// "scrollPageIntoView: not a valid pageNumber" console errors.
|
|
57
|
+
const onPagesLoaded = () => {
|
|
58
|
+
if (initialScale != null) {
|
|
59
|
+
pdfViewer.currentScale = initialScale;
|
|
60
|
+
}
|
|
61
|
+
if (initialPage != null && initialPage > 1) {
|
|
56
62
|
pdfViewer.currentPageNumber = initialPage;
|
|
57
63
|
pdfViewer.scrollPageIntoView({
|
|
58
64
|
pageNumber: initialPage
|
|
59
65
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
}
|
|
67
|
+
eventBus.off(PAGES_LOADED_EVENT, onPagesLoaded);
|
|
68
|
+
};
|
|
69
|
+
eventBus.on(PAGES_LOADED_EVENT, onPagesLoaded);
|
|
64
70
|
eventBusRef.current = eventBus;
|
|
65
71
|
findControllerRef.current = findController;
|
|
66
72
|
pdfViewerRef.current = pdfViewer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePdfViewer.js","names":["EventBus","PDFFindController","PDFLinkService","PDFViewer","useEffect","useRef","PAGES_LOADED_EVENT","usePdfViewer","containerRef","viewerRef","document","initialScale","initialPage","pdfViewerRef","eventBusRef","findControllerRef","container","current","viewer","eventBus","linkService","findController","updateMatchesCountOnProgress","pdfViewer","removePageBorders","setViewer","setDocument","
|
|
1
|
+
{"version":3,"file":"usePdfViewer.js","names":["AnnotationEditorType","EventBus","PDFFindController","PDFLinkService","PDFViewer","useEffect","useRef","PAGES_LOADED_EVENT","usePdfViewer","containerRef","viewerRef","document","initialScale","initialPage","pdfViewerRef","eventBusRef","findControllerRef","container","current","viewer","eventBus","linkService","findController","updateMatchesCountOnProgress","pdfViewer","removePageBorders","annotationEditorMode","NONE","annotationEditorHighlightColors","setViewer","setDocument","onPagesLoaded","currentScale","currentPageNumber","scrollPageIntoView","pageNumber","off","on","cleanup"],"sources":["usePdfViewer.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 { AnnotationEditorType } from \"pdfjs-dist\";\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport {\n EventBus,\n PDFFindController,\n PDFLinkService,\n PDFViewer,\n} from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport type { RefObject } from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { PAGES_LOADED_EVENT } from \"../constants.js\";\n\nexport interface UsePdfViewerResult {\n pdfViewerRef: RefObject<PDFViewer | null>;\n eventBusRef: RefObject<EventBus | null>;\n findControllerRef: RefObject<PDFFindController | null>;\n}\n\nexport function usePdfViewer(\n containerRef: RefObject<HTMLDivElement | null>,\n viewerRef: RefObject<HTMLDivElement | null>,\n document: PDFDocumentProxy | undefined,\n initialScale?: number,\n initialPage?: number,\n): UsePdfViewerResult {\n const pdfViewerRef = useRef<PDFViewer | null>(null);\n const eventBusRef = useRef<EventBus | null>(null);\n const findControllerRef = useRef<PDFFindController | null>(null);\n\n useEffect(function initializePdfViewer() {\n const container = containerRef.current;\n const viewer = viewerRef.current;\n if (container == null || viewer == null || document == null) {\n return;\n }\n\n const eventBus = new EventBus();\n const linkService = new PDFLinkService({ eventBus });\n const findController = new PDFFindController({\n linkService,\n eventBus,\n updateMatchesCountOnProgress: true,\n });\n\n const pdfViewer = new PDFViewer({\n container,\n viewer,\n eventBus,\n linkService,\n findController,\n removePageBorders: true,\n annotationEditorMode: AnnotationEditorType.NONE,\n annotationEditorHighlightColors:\n \"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F\",\n });\n\n linkService.setViewer(pdfViewer);\n linkService.setDocument(document);\n findController.setDocument(document);\n pdfViewer.setDocument(document);\n\n // Apply initial scale and page after pages are loaded to avoid\n // \"scrollPageIntoView: not a valid pageNumber\" console errors.\n const onPagesLoaded = () => {\n if (initialScale != null) {\n pdfViewer.currentScale = initialScale;\n }\n if (initialPage != null && initialPage > 1) {\n pdfViewer.currentPageNumber = initialPage;\n pdfViewer.scrollPageIntoView({ pageNumber: initialPage });\n }\n eventBus.off(PAGES_LOADED_EVENT, onPagesLoaded);\n };\n eventBus.on(PAGES_LOADED_EVENT, onPagesLoaded);\n\n eventBusRef.current = eventBus;\n findControllerRef.current = findController;\n pdfViewerRef.current = pdfViewer;\n\n return () => {\n pdfViewerRef.current = null;\n eventBusRef.current = null;\n findControllerRef.current = null;\n pdfViewer.cleanup();\n };\n }, [containerRef, viewerRef, document]);\n\n return { pdfViewerRef, eventBusRef, findControllerRef };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoB,QAAQ,YAAY;AAEjD,SACEC,QAAQ,EACRC,iBAAiB,EACjBC,cAAc,EACdC,SAAS,QACJ,+BAA+B;AAEtC,SAASC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,kBAAkB,QAAQ,iBAAiB;AAQpD,OAAO,SAASC,YAAYA,CAC1BC,YAA8C,EAC9CC,SAA2C,EAC3CC,QAAsC,EACtCC,YAAqB,EACrBC,WAAoB,EACA;EACpB,MAAMC,YAAY,GAAGR,MAAM,CAAmB,IAAI,CAAC;EACnD,MAAMS,WAAW,GAAGT,MAAM,CAAkB,IAAI,CAAC;EACjD,MAAMU,iBAAiB,GAAGV,MAAM,CAA2B,IAAI,CAAC;EAEhED,SAAS,CAAC,YAA+B;IACvC,MAAMY,SAAS,GAAGR,YAAY,CAACS,OAAO;IACtC,MAAMC,MAAM,GAAGT,SAAS,CAACQ,OAAO;IAChC,IAAID,SAAS,IAAI,IAAI,IAAIE,MAAM,IAAI,IAAI,IAAIR,QAAQ,IAAI,IAAI,EAAE;MAC3D;IACF;IAEA,MAAMS,QAAQ,GAAG,IAAInB,QAAQ,CAAC,CAAC;IAC/B,MAAMoB,WAAW,GAAG,IAAIlB,cAAc,CAAC;MAAEiB;IAAS,CAAC,CAAC;IACpD,MAAME,cAAc,GAAG,IAAIpB,iBAAiB,CAAC;MAC3CmB,WAAW;MACXD,QAAQ;MACRG,4BAA4B,EAAE;IAChC,CAAC,CAAC;IAEF,MAAMC,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CAAC;EAEvC,OAAO;IAAEG,YAAY;IAAEC,WAAW;IAAEC;EAAkB,CAAC;AACzD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["types.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type React from \"react\";\n\n/** Which sidebar panel to display when the sidebar is open. */\nexport type SidebarMode = \"thumbnails\" | \"outline\";\n\n/** A single item in the PDF document outline (table of contents). */\nexport interface OutlineItem {\n title: string;\n depth: number;\n pageNumber: number;\n bold: boolean;\n italic: boolean;\n}\n\n/** The visual style of an annotation rendered on the PDF. */\nexport type AnnotationType
|
|
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}\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 /** 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/** 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 /** 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":[]}
|
|
@@ -37,7 +37,10 @@ export { PdfViewerToolbar } from "../pdf-viewer/components/PdfViewerToolbar.js";
|
|
|
37
37
|
|
|
38
38
|
// PdfViewer hooks — primitive
|
|
39
39
|
export { usePdfAnnotationPortals } from "../pdf-viewer/hooks/usePdfAnnotationPortals.js";
|
|
40
|
+
export { usePdfAnnotationsByPage } from "../pdf-viewer/hooks/usePdfAnnotationsByPage.js";
|
|
40
41
|
export { usePdfDocument } from "../pdf-viewer/hooks/usePdfDocument.js";
|
|
42
|
+
export { usePdfFormFields } from "../pdf-viewer/hooks/usePdfFormFields.js";
|
|
43
|
+
export { usePdfHighlightMode } from "../pdf-viewer/hooks/usePdfHighlightMode.js";
|
|
41
44
|
export { usePdfOutline } from "../pdf-viewer/hooks/usePdfOutline.js";
|
|
42
45
|
export { usePdfViewer } from "../pdf-viewer/hooks/usePdfViewer.js";
|
|
43
46
|
export { usePdfViewerSearch } from "../pdf-viewer/hooks/usePdfViewerSearch.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","names":["BaseFilterList","FilterList","deserializeFilterStates","serializeFilterStates","ObjectTable","BaseTable","ColumnConfigDialog","BasePdfViewer","PdfViewerAnnotationLayer","PdfViewerContent","PdfViewerOutlineSidebar","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","usePdfAnnotationPortals","usePdfDocument","usePdfOutline","usePdfViewer","usePdfViewerSearch","usePdfViewerSync","usePdfViewerCore","usePdfViewerState","PdfViewer","ActionForm","BaseForm"],"sources":["experimental.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\nexport { BaseFilterList } from \"../filter-list/base/BaseFilterList.js\";\nexport type {\n BaseFilterListProps,\n RenderFilterInput,\n} from \"../filter-list/base/BaseFilterListApi.js\";\nexport { FilterList } from \"../filter-list/FilterList.js\";\n\nexport type {\n FilterDefinitionUnion,\n FilterListProps,\n} from \"../filter-list/FilterListApi.js\";\nexport type {\n FilterComponentType,\n FilterListItemProps,\n FilterState,\n PropertyFilterDefinition,\n} from \"../filter-list/FilterListItemApi.js\";\nexport {\n deserializeFilterStates,\n serializeFilterStates,\n} from \"../filter-list/utils/filterStateSerialization.js\";\n\n// ObjectTable that loads and displays data for a given objectSet\nexport { ObjectTable } from \"../object-table/ObjectTable.js\";\nexport type {\n ColumnDefinition,\n ColumnDefinitionLocator,\n CustomColumnLocator,\n FunctionColumnLocator,\n ObjectTableProps,\n PropertyColumnLocator,\n RdpColumnLocator,\n} from \"../object-table/ObjectTableApi.js\";\nexport type { CellEditInfo } from \"../object-table/utils/types.js\";\n\n// BaseTable that does not handle data fetching\nexport type { BaseTableProps } from \"../object-table/Table.js\";\nexport { BaseTable } from \"../object-table/Table.js\";\n\nexport { ColumnConfigDialog } from \"../object-table/ColumnConfigDialog.js\";\nexport type {\n ColumnConfigDialogProps,\n ColumnConfigOptions,\n} from \"../object-table/ColumnConfigDialog.js\";\n\n// PdfViewer\nexport { BasePdfViewer } from \"../pdf-viewer/PdfViewer.js\";\nexport type {\n AnnotationType,\n PdfAnnotation,\n PdfDownloadResult,\n PdfViewerProps,\n SidebarMode,\n} from \"../pdf-viewer/types.js\";\n\n// PdfViewer building blocks\nexport {\n PdfViewerAnnotationLayer,\n type PdfViewerAnnotationLayerProps,\n} from \"../pdf-viewer/components/PdfViewerAnnotationLayer.js\";\nexport {\n PdfViewerContent,\n type PdfViewerContentProps,\n} from \"../pdf-viewer/components/PdfViewerContent.js\";\nexport {\n PdfViewerOutlineSidebar,\n type PdfViewerOutlineSidebarProps,\n} from \"../pdf-viewer/components/PdfViewerOutlineSidebar.js\";\nexport {\n PdfViewerSearchBar,\n type PdfViewerSearchBarProps,\n} from \"../pdf-viewer/components/PdfViewerSearchBar.js\";\nexport {\n PdfViewerSidebar,\n type PdfViewerSidebarProps,\n} from \"../pdf-viewer/components/PdfViewerSidebar.js\";\nexport {\n PdfViewerToolbar,\n type PdfViewerToolbarProps,\n} from \"../pdf-viewer/components/PdfViewerToolbar.js\";\n\n// PdfViewer hooks — primitive\nexport {\n type AnnotationPortalTarget,\n usePdfAnnotationPortals,\n} from \"../pdf-viewer/hooks/usePdfAnnotationPortals.js\";\nexport { usePdfDocument } from \"../pdf-viewer/hooks/usePdfDocument.js\";\nexport { usePdfOutline } from \"../pdf-viewer/hooks/usePdfOutline.js\";\nexport {\n usePdfViewer,\n type UsePdfViewerResult,\n} from \"../pdf-viewer/hooks/usePdfViewer.js\";\nexport {\n usePdfViewerSearch,\n type UsePdfViewerSearchResult,\n} from \"../pdf-viewer/hooks/usePdfViewerSearch.js\";\nexport { usePdfViewerSync } from \"../pdf-viewer/hooks/usePdfViewerSync.js\";\nexport { type OutlineItem } from \"../pdf-viewer/types.js\";\n\n// PdfViewer hooks — composition\nexport {\n usePdfViewerCore,\n type UsePdfViewerCoreOptions,\n type UsePdfViewerCoreResult,\n} from \"../pdf-viewer/hooks/usePdfViewerCore.js\";\nexport {\n usePdfViewerState,\n type UsePdfViewerStateOptions,\n type UsePdfViewerStateResult,\n} from \"../pdf-viewer/hooks/usePdfViewerState.js\";\n\n// PdfViewer (Media wrapper)\nexport {\n PdfViewer,\n type PdfViewerMediaProps,\n} from \"../pdf-viewer/PdfRenderer.js\";\n\nexport { ActionForm } from \"../action-form/ActionForm.js\";\nexport type {\n ActionFormProps,\n BaseFormProps,\n FormError,\n FormState,\n} from \"../action-form/ActionFormApi.js\";\nexport { BaseForm } from \"../action-form/BaseForm.js\";\nexport type {\n ActionParameters,\n BaseFormFieldProps,\n CustomFieldProps,\n DatetimePickerFieldProps,\n DropdownFieldProps,\n FieldComponent,\n FieldValueType,\n FilePickerProps,\n FormFieldDefinition,\n FormFieldPropsByType,\n NumberInputFieldProps,\n ObjectSetFieldProps,\n Option,\n RadioButtonsFieldProps,\n RendererFieldDefinition,\n TextAreaFieldProps,\n TextInputFieldProps,\n} from \"../action-form/FormFieldApi.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,uCAAuC;AAKtE,SAASC,UAAU,QAAQ,8BAA8B;AAYzD,SACEC,uBAAuB,EACvBC,qBAAqB,QAChB,kDAAkD;;AAEzD;AACA,SAASC,WAAW,QAAQ,gCAAgC;;AAY5D;;AAEA,SAASC,SAAS,QAAQ,0BAA0B;AAEpD,SAASC,kBAAkB,QAAQ,uCAAuC;AAM1E;AACA,SAASC,aAAa,QAAQ,4BAA4B;
|
|
1
|
+
{"version":3,"file":"experimental.js","names":["BaseFilterList","FilterList","deserializeFilterStates","serializeFilterStates","ObjectTable","BaseTable","ColumnConfigDialog","BasePdfViewer","PdfViewerAnnotationLayer","PdfViewerContent","PdfViewerOutlineSidebar","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","usePdfAnnotationPortals","usePdfAnnotationsByPage","usePdfDocument","usePdfFormFields","usePdfHighlightMode","usePdfOutline","usePdfViewer","usePdfViewerSearch","usePdfViewerSync","usePdfViewerCore","usePdfViewerState","PdfViewer","ActionForm","BaseForm"],"sources":["experimental.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\nexport { BaseFilterList } from \"../filter-list/base/BaseFilterList.js\";\nexport type {\n BaseFilterListProps,\n RenderFilterInput,\n} from \"../filter-list/base/BaseFilterListApi.js\";\nexport { FilterList } from \"../filter-list/FilterList.js\";\n\nexport type {\n FilterDefinitionUnion,\n FilterListProps,\n} from \"../filter-list/FilterListApi.js\";\nexport type {\n FilterComponentType,\n FilterListItemProps,\n FilterState,\n PropertyFilterDefinition,\n} from \"../filter-list/FilterListItemApi.js\";\nexport {\n deserializeFilterStates,\n serializeFilterStates,\n} from \"../filter-list/utils/filterStateSerialization.js\";\n\n// ObjectTable that loads and displays data for a given objectSet\nexport { ObjectTable } from \"../object-table/ObjectTable.js\";\nexport type {\n ColumnDefinition,\n ColumnDefinitionLocator,\n CustomColumnLocator,\n FunctionColumnLocator,\n ObjectTableProps,\n PropertyColumnLocator,\n RdpColumnLocator,\n} from \"../object-table/ObjectTableApi.js\";\nexport type { CellEditInfo } from \"../object-table/utils/types.js\";\n\n// BaseTable that does not handle data fetching\nexport type { BaseTableProps } from \"../object-table/Table.js\";\nexport { BaseTable } from \"../object-table/Table.js\";\n\nexport { ColumnConfigDialog } from \"../object-table/ColumnConfigDialog.js\";\nexport type {\n ColumnConfigDialogProps,\n ColumnConfigOptions,\n} from \"../object-table/ColumnConfigDialog.js\";\n\n// PdfViewer\nexport { BasePdfViewer } from \"../pdf-viewer/PdfViewer.js\";\nexport type {\n AnnotationType,\n PdfAnnotation,\n PdfAnnotationRenderProps,\n PdfCustomAnnotation,\n PdfDownloadResult,\n PdfFormFieldValue,\n PdfRect,\n PdfTextHighlightEvent,\n PdfViewerProps,\n SidebarMode,\n} from \"../pdf-viewer/types.js\";\n\n// PdfViewer building blocks\nexport {\n PdfViewerAnnotationLayer,\n type PdfViewerAnnotationLayerProps,\n} from \"../pdf-viewer/components/PdfViewerAnnotationLayer.js\";\nexport {\n PdfViewerContent,\n type PdfViewerContentProps,\n} from \"../pdf-viewer/components/PdfViewerContent.js\";\nexport {\n PdfViewerOutlineSidebar,\n type PdfViewerOutlineSidebarProps,\n} from \"../pdf-viewer/components/PdfViewerOutlineSidebar.js\";\nexport {\n PdfViewerSearchBar,\n type PdfViewerSearchBarProps,\n} from \"../pdf-viewer/components/PdfViewerSearchBar.js\";\nexport {\n PdfViewerSidebar,\n type PdfViewerSidebarProps,\n} from \"../pdf-viewer/components/PdfViewerSidebar.js\";\nexport {\n PdfViewerToolbar,\n type PdfViewerToolbarProps,\n} from \"../pdf-viewer/components/PdfViewerToolbar.js\";\n\n// PdfViewer hooks — primitive\nexport {\n type AnnotationPortalTarget,\n usePdfAnnotationPortals,\n} from \"../pdf-viewer/hooks/usePdfAnnotationPortals.js\";\nexport { usePdfAnnotationsByPage } from \"../pdf-viewer/hooks/usePdfAnnotationsByPage.js\";\nexport { usePdfDocument } from \"../pdf-viewer/hooks/usePdfDocument.js\";\nexport {\n usePdfFormFields,\n type UsePdfFormFieldsOptions,\n type UsePdfFormFieldsResult,\n} from \"../pdf-viewer/hooks/usePdfFormFields.js\";\nexport {\n usePdfHighlightMode,\n type UsePdfHighlightModeOptions,\n type UsePdfHighlightModeResult,\n} from \"../pdf-viewer/hooks/usePdfHighlightMode.js\";\nexport { usePdfOutline } from \"../pdf-viewer/hooks/usePdfOutline.js\";\nexport {\n usePdfViewer,\n type UsePdfViewerResult,\n} from \"../pdf-viewer/hooks/usePdfViewer.js\";\nexport {\n usePdfViewerSearch,\n type UsePdfViewerSearchResult,\n} from \"../pdf-viewer/hooks/usePdfViewerSearch.js\";\nexport { usePdfViewerSync } from \"../pdf-viewer/hooks/usePdfViewerSync.js\";\nexport { type OutlineItem } from \"../pdf-viewer/types.js\";\n\n// PdfViewer hooks — composition\nexport {\n usePdfViewerCore,\n type UsePdfViewerCoreOptions,\n type UsePdfViewerCoreResult,\n} from \"../pdf-viewer/hooks/usePdfViewerCore.js\";\nexport {\n usePdfViewerState,\n type UsePdfViewerStateOptions,\n type UsePdfViewerStateResult,\n} from \"../pdf-viewer/hooks/usePdfViewerState.js\";\n\n// PdfViewer (Media wrapper)\nexport {\n PdfViewer,\n type PdfViewerMediaProps,\n} from \"../pdf-viewer/PdfRenderer.js\";\n\nexport { ActionForm } from \"../action-form/ActionForm.js\";\nexport type {\n ActionFormProps,\n BaseFormProps,\n FormError,\n FormState,\n} from \"../action-form/ActionFormApi.js\";\nexport { BaseForm } from \"../action-form/BaseForm.js\";\nexport type {\n ActionParameters,\n BaseFormFieldProps,\n CustomFieldProps,\n DatetimePickerFieldProps,\n DropdownFieldProps,\n FieldComponent,\n FieldValueType,\n FilePickerProps,\n FormFieldDefinition,\n FormFieldPropsByType,\n NumberInputFieldProps,\n ObjectSetFieldProps,\n Option,\n RadioButtonsFieldProps,\n RendererFieldDefinition,\n TextAreaFieldProps,\n TextInputFieldProps,\n} from \"../action-form/FormFieldApi.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,uCAAuC;AAKtE,SAASC,UAAU,QAAQ,8BAA8B;AAYzD,SACEC,uBAAuB,EACvBC,qBAAqB,QAChB,kDAAkD;;AAEzD;AACA,SAASC,WAAW,QAAQ,gCAAgC;;AAY5D;;AAEA,SAASC,SAAS,QAAQ,0BAA0B;AAEpD,SAASC,kBAAkB,QAAQ,uCAAuC;AAM1E;AACA,SAASC,aAAa,QAAQ,4BAA4B;AAc1D;AACA,SACEC,wBAAwB,QAEnB,sDAAsD;AAC7D,SACEC,gBAAgB,QAEX,8CAA8C;AACrD,SACEC,uBAAuB,QAElB,qDAAqD;AAC5D,SACEC,kBAAkB,QAEb,gDAAgD;AACvD,SACEC,gBAAgB,QAEX,8CAA8C;AACrD,SACEC,gBAAgB,QAEX,8CAA8C;;AAErD;AACA,SAEEC,uBAAuB,QAClB,gDAAgD;AACvD,SAASC,uBAAuB,QAAQ,gDAAgD;AACxF,SAASC,cAAc,QAAQ,uCAAuC;AACtE,SACEC,gBAAgB,QAGX,yCAAyC;AAChD,SACEC,mBAAmB,QAGd,4CAA4C;AACnD,SAASC,aAAa,QAAQ,sCAAsC;AACpE,SACEC,YAAY,QAEP,qCAAqC;AAC5C,SACEC,kBAAkB,QAEb,2CAA2C;AAClD,SAASC,gBAAgB,QAAQ,yCAAyC;AAG1E;AACA,SACEC,gBAAgB,QAGX,yCAAyC;AAChD,SACEC,iBAAiB,QAGZ,0CAA0C;;AAEjD;AACA,SACEC,SAAS,QAEJ,8BAA8B;AAErC,SAASC,UAAU,QAAQ,8BAA8B;AAOzD,SAASC,QAAQ,QAAQ,4BAA4B","ignoreList":[]}
|
|
@@ -175,7 +175,9 @@ export interface FilePickerProps extends BaseFormFieldProps<File | File[]> {
|
|
|
175
175
|
/**
|
|
176
176
|
* Text area field props
|
|
177
177
|
*/
|
|
178
|
-
export interface TextAreaFieldProps extends BaseFormFieldProps<string>, Pick<React.TextareaHTMLAttributes<HTMLTextAreaElement>, "rows" | "wrap" | "minLength" | "maxLength"> {
|
|
178
|
+
export interface TextAreaFieldProps extends BaseFormFieldProps<string>, Pick<React.TextareaHTMLAttributes<HTMLTextAreaElement>, "rows" | "wrap" | "minLength" | "maxLength"> {
|
|
179
|
+
placeholder?: string;
|
|
180
|
+
}
|
|
179
181
|
export interface TextInputFieldProps extends BaseFormFieldProps<string>, Pick<React.InputHTMLAttributes<HTMLInputElement>, "minLength" | "maxLength"> {
|
|
180
182
|
placeholder?: string;
|
|
181
183
|
}
|
|
@@ -188,7 +190,11 @@ export interface NumberInputFieldProps extends BaseFormFieldProps<number>, Pick<
|
|
|
188
190
|
*/
|
|
189
191
|
export interface RadioButtonsFieldProps<V> extends BaseFormFieldProps<V> {
|
|
190
192
|
/**
|
|
191
|
-
* Available options for radio buttons
|
|
193
|
+
* Available options for radio buttons.
|
|
194
|
+
*
|
|
195
|
+
* Values are compared by reference equality (`===`). When options contain
|
|
196
|
+
* non-primitive values, pass the same object references for `value` and
|
|
197
|
+
* the corresponding option entry.
|
|
192
198
|
*/
|
|
193
199
|
options: Option<V>[];
|
|
194
200
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cACE,kBACA,gBACA,aACA,qBACA,uBACA,WACA,4BACK,WAAY;AACnB,YAAY,WAAW,OAAQ;;;;AAK/B,iBAAiB;CACf,UAAU;CACV,UAAU,SAAS,KAAK,SAAS;EACjC;;;;CAIA,UAAU;;;;;CAMV;;;;CAKA,eAAe,eAAe,GAAG;;;;CAKjC,gBAAgB,8BAA8B,oBAAoB,GAAG;;;;CAKrE;;;;CAKA;;;;;CAMA;;;;;;CAOA,sBAAsB,WAAW;;;;CAKjC;;;;;;;CAQA,qBAAqBA,OAAO;;;;;;;CAQ5B,YAAYC,OAAO,eAAe,GAAG,OAAO;;;;;CAM5C,sBAAsB,KACpB,qBACE,8BACE,oBAAoB,GAAG,MAG3B,QAAQ;AAEX;KAEI,kBAAkB;CAAE,MAAM;CAAgB;AAAe;KAEzD,iBACD,aACA,QACA,QACA,cACA,cACA,YACA;;;;AAKJ,iBAAiB,qBAAqB;CACpC,iBAAiB;CACjB,UAAU;CACV,aAAa;CACb,cAAc;CACd,YAAY,oBAAoB;CAChC,eAAe;CACf,WAAW;CACX,YAAY;CACZ,QAAQ;AACT;;;;;;AAOD,iBAAiB,iCAAiC,mBAAmB,MAAM;;;;;CAKzE,MAAM;;;;;CAMN,MAAM;;;;CAKN;;;;;CAMA;;;;CAKA;;CAGA,cAAcC,MAAM;AACrB;;;;AAKD,iBAAiB;CAAmB;CAAG,2BAA2B;UACxD,mBAAmB,iBAAiB,OAAO,MAAM,GAC3D;;;;CAIE,OAAO;;;;CAKP,qBAAqBC,MA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sBAAsB,wBAC3C,sBAAsB,iBAAiB,GAAG,GAAG;;;;AAMnD,YAAY;CACV,UAAU,4BAA4B;CACtC,gBAAgB,iBAAiB,WAAW,iBAAiB;IAC3D,iBAAiB,GAAG,GAAG;;;;AAK3B,YAAY,iBACR,oBACA,aACA,gBACA,iBACA,kBACA,eACA,cACA,eACA;;;;;AAMJ,YAAY,YACR,YACA,WACA,YACA,SACA,WACA,aACA,cACA,eACA,YACA,mBACA,eACA,aACA,YACA;CAAE,MAAM;CAAU;AAAgB,IAClC;CAAE,MAAM;CAAa;AAAmB,IACxC;CAAE,MAAM;CAAa;AAAmB,IACxC;CAAE,MAAM;CAAU,QAAQ;AAAwB;;;;;;;;;AAUtD,YAAY,6BACT,KAAK,kBAAiB;CACrB;CACA,gBAAgB;CAChB,YAAY;CACZ;CACA;CACA;CACA;CACA;CACA,sBAAsB,WAAW;CACjC,sBAAsB,KAAK,qBAAqB,IAAI,UAAU;AAC/D,IACD;;;;AAKF,YAAY,8BAA8B,UAAU,uBAClD,UAAU,cAAc,eACpB,UAAU,WAAW,aACrB,UAAU,mBAAmB,eAAe,gBAC5C,UAAU,YAAY,kBAAkB,aACxC,UAAU,WAAW,eAAe,cACpC,UAAU,aAAa,cAAc,oBACrC,UACE,WACA,YACA,SACA,UACA,UACA,SACA,YAAY","names":["error: ValidationError","value: FieldValueType<Q, K>","date: Date","item: V","a: V","b: V","props: BaseFormFieldProps<V>","value: V | null"],"sources":["../../../src/action-form/FormFieldApi.ts"],"version":3,"file":"FormFieldApi.d.ts"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,OAAO,WAAqB,OAAQ;AAEpC,
|
|
1
|
+
{"mappings":"AAgBA,OAAO,WAAqB,OAAQ;AAEpC,cAAsB,+BAA+B,oBAAqB;AAU1E,iBAAiB,uBAAuB;CACtC,iBAAiB;CACjB;CACA,qBAAqBA;AACtB;AAED,OAAO,cAAMC,mBAAmB,MAAM,GAAG","names":["value: unknown","FormFieldRenderer: React.FC<FormFieldRendererProps>"],"sources":["../../../../src/action-form/fields/FormFieldRenderer.tsx"],"version":3,"file":"FormFieldRenderer.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAkBA,cAAoB,oBAA0C,OAAQ;AAEtE,cAAsB,8BAA8B,oBAAqB;AAGzE,OAAO,cAAMA,oBAAoB,GAC/BC,OAAO,uBAAuB,OAC3B","names":["RadioButtonsField: <V>(\n props: RadioButtonsFieldProps<V>,\n) => ReactElement","props: RadioButtonsFieldProps<V>"],"sources":["../../../../src/action-form/fields/RadioButtonsField.tsx"],"version":3,"file":"RadioButtonsField.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAiBA,OAAO,WAA4B,OAAQ;AAC3C,cAAc,0BAA0B,oBAAqB;AAK7D,OAAO,iBAAS,cAAc,EAC5B,IACA,OACA,UACA,aACA,MACA,MACA,WACA,WACmB,EAAlB,qBAAqB,MAAM","names":[],"sources":["../../../../src/action-form/fields/TextAreaField.tsx"],"version":3,"file":"TextAreaField.d.ts"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "pdfjs-dist/web/pdf_viewer.css";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { PdfViewerProps } from "./types.js";
|
|
4
|
-
export declare function BasePdfViewer({ src, annotations, onAnnotationClick, onDownload, initialPage, initialScale, initialSidebarOpen, enableDownload, sidebarMode: sidebarModeProp, outlineIcons, className }: PdfViewerProps): React.ReactElement;
|
|
4
|
+
export declare function BasePdfViewer({ src, annotations, onAnnotationClick, onDownload, enableHighlight, onTextHighlight, onHighlightDelete, formData, onFormSubmit, onFormChange, initialPage, initialScale, initialSidebarOpen, enableDownload, sidebarMode: sidebarModeProp, outlineIcons, className }: PdfViewerProps): React.ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAkBA,OAAO,+BAAgC;AACvC,OAAO,WAAW,OAAQ;
|
|
1
|
+
{"mappings":"AAkBA,OAAO,+BAAgC;AACvC,OAAO,WAAW,OAAQ;AAa1B,cAAc,sBAAsB,YAAa;AAEjD,OAAO,iBAAS,cAAc,EAC5B,KACA,aACA,mBACA,YACA,iBACA,iBACA,mBACA,UACA,cACA,cACA,aACA,cACA,oBACA,gBACA,aAAa,iBACb,cACA,WACe,EAAd,iBAAiB,MAAM","names":[],"sources":["../../../src/pdf-viewer/PdfViewer.tsx"],"version":3,"file":"PdfViewer.d.ts"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAiBA,OAAO,WAAqC,OAAQ;AACpD,cAAc,
|
|
1
|
+
{"mappings":"AAiBA,OAAO,WAAqC,OAAQ;AACpD,cAAc,qBAAmD,aAAc;AAG/E,iBAAiB,8BAA8B;CAC7C,aAAa;CACb;CACA;CACA,qBAAqBA,YAAY;AAClC;AA4JD,OAAO,iBAAS,yBAAyB,EACvC,aACA,YACA,OACA,mBAC8B,EAA7B,gCAAgC,MAAM","names":["annotation: PdfAnnotation"],"sources":["../../../../src/pdf-viewer/components/PdfViewerAnnotationLayer.tsx"],"version":3,"file":"PdfViewerAnnotationLayer.d.ts"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "pdfjs-dist/web/pdf_viewer.css";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import type { PdfAnnotation } from "../types.js";
|
|
3
|
+
import type { PdfAnnotation, PdfFormFieldValue } from "../types.js";
|
|
4
4
|
export interface PdfViewerContentProps {
|
|
5
5
|
/** PDF source — URL string or ArrayBuffer */
|
|
6
6
|
src: string | ArrayBuffer;
|
|
7
|
-
/** Annotations to overlay on the PDF
|
|
8
|
-
annotations?:
|
|
7
|
+
/** Annotations to overlay on the PDF */
|
|
8
|
+
annotations?: PdfAnnotation[];
|
|
9
9
|
/** Callback fired when an annotation is clicked */
|
|
10
10
|
onAnnotationClick?: (annotation: PdfAnnotation) => void;
|
|
11
11
|
/** Initial page number (1-indexed, default 1) */
|
|
@@ -16,7 +16,11 @@ export interface PdfViewerContentProps {
|
|
|
16
16
|
onPageChange?: (page: number) => void;
|
|
17
17
|
/** Callback fired when the zoom scale changes */
|
|
18
18
|
onScaleChange?: (scale: number) => void;
|
|
19
|
+
/** Initial form field values keyed by field name. Applied when the document loads. */
|
|
20
|
+
formData?: Record<string, PdfFormFieldValue>;
|
|
21
|
+
/** Callback fired when any form field value changes. */
|
|
22
|
+
onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;
|
|
19
23
|
/** Additional CSS class name for the root element */
|
|
20
24
|
className?: string;
|
|
21
25
|
}
|
|
22
|
-
export declare function PdfViewerContent({ src, annotations, onAnnotationClick, initialPage, initialScale, onPageChange: onPageChangeProp, onScaleChange: onScaleChangeProp, className }: PdfViewerContentProps): React.ReactElement;
|
|
26
|
+
export declare function PdfViewerContent({ src, annotations, onAnnotationClick, initialPage, initialScale, onPageChange: onPageChangeProp, onScaleChange: onScaleChangeProp, formData, onFormChange, className }: PdfViewerContentProps): React.ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAkBA,OAAO,+BAAgC;AACvC,OAAO,WAAkC,OAAQ;
|
|
1
|
+
{"mappings":"AAkBA,OAAO,+BAAgC;AACvC,OAAO,WAAkC,OAAQ;AAOjD,cAAc,eAAe,yBAAyB,aAAc;AAGpE,iBAAiB,sBAAsB;;CAErC,cAAc;;CAEd,cAAc;;CAEd,qBAAqBA,YAAY;;CAEjC;;CAEA;;CAEA,gBAAgBC;;CAEhB,iBAAiBC;;CAEjB,WAAW,eAAe;;CAE1B,gBAAgBC,mBAAmBC,OAAO;;CAE1C;AACD;AAED,OAAO,iBAAS,iBAAiB,EAC/B,KACA,aACA,mBACA,aACA,cACA,cAAc,kBACd,eAAe,mBACf,UACA,cACA,WACsB,EAArB,wBAAwB,MAAM","names":["annotation: PdfAnnotation","page: number","scale: number","fieldName: string","value: PdfFormFieldValue"],"sources":["../../../../src/pdf-viewer/components/PdfViewerContent.tsx"],"version":3,"file":"PdfViewerContent.d.ts"}
|
|
@@ -12,5 +12,10 @@ export interface PdfViewerToolbarProps {
|
|
|
12
12
|
enableDownload: boolean;
|
|
13
13
|
onRotateLeft: () => void;
|
|
14
14
|
onRotateRight: () => void;
|
|
15
|
+
enableHighlight: boolean;
|
|
16
|
+
highlightModeActive: boolean;
|
|
17
|
+
onHighlightToggle: () => void;
|
|
18
|
+
enableFormSave?: boolean;
|
|
19
|
+
onFormSave?: () => void;
|
|
15
20
|
}
|
|
16
|
-
export declare function PdfViewerToolbar({ currentPage, numPages, scale, sidebarOpen, onPageChange, onScaleChange, onSearchOpen, onSidebarToggle, onDownload, enableDownload, onRotateLeft, onRotateRight }: PdfViewerToolbarProps): React.ReactElement;
|
|
21
|
+
export declare function PdfViewerToolbar({ currentPage, numPages, scale, sidebarOpen, onPageChange, onScaleChange, onSearchOpen, onSidebarToggle, onDownload, enableDownload, onRotateLeft, onRotateRight, enableHighlight, highlightModeActive, onHighlightToggle, enableFormSave, onFormSave }: PdfViewerToolbarProps): React.ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":"AA+BA,OAAO,WAAiD,OAAQ;AAIhE,iBAAiB,sBAAsB;CACrC;CACA;CACA;CACA;CACA,eAAeA;CACf,gBAAgBC;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAED,OAAO,iBAAS,iBAAiB,EAC/B,aACA,UACA,OACA,aACA,cACA,eACA,cACA,iBACA,YACA,gBACA,cACA,eACA,iBACA,qBACA,mBACA,gBACA,YACsB,EAArB,wBAAwB,MAAM","names":["page: number","scale: number"],"sources":["../../../../src/pdf-viewer/components/PdfViewerToolbar.tsx"],"version":3,"file":"PdfViewerToolbar.d.ts"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { PdfAnnotation } from "./types.js";
|
|
2
|
-
export declare const EMPTY_ANNOTATIONS: Record<number, PdfAnnotation[]>;
|
|
3
2
|
export declare const EMPTY_ANNOTATION_ARRAY: PdfAnnotation[];
|
|
4
3
|
export declare const EMPTY_STRING = "";
|
|
5
4
|
export declare const SCALE_STEP = .25;
|
|
@@ -20,3 +19,4 @@ export declare const PAGE_CHANGING_EVENT = "pagechanging";
|
|
|
20
19
|
export declare const SCALE_CHANGING_EVENT = "scalechanging";
|
|
21
20
|
export declare const PAGE_RENDERED_EVENT = "pagerendered";
|
|
22
21
|
export declare const PAGES_LOADED_EVENT = "pagesloaded";
|
|
22
|
+
export declare const ANNOTATION_LAYER_RENDERED_EVENT = "annotationlayerrendered";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAAc,qBAAqB,YAAa;AAGhD,OAAO,cAAMA,
|
|
1
|
+
{"mappings":"AAgBA,cAAc,qBAAqB,YAAa;AAGhD,OAAO,cAAMA,wBAAwB;AACrC,OAAO,cAAM,eAAe;AAG5B,OAAO,cAAM,aAAa;AAC1B,OAAO,cAAM,YAAY;AACzB,OAAO,cAAM,YAAY;AACzB,OAAO,cAAM,sBAAsB;AACnC,OAAO,cAAM,gBAAgB;AAC7B,OAAO,cAAM,kBAAkB;AAC/B,OAAO,cAAMC;;AAMb,OAAO,cAAM,6BAA6B;;AAE1C,OAAO,cAAM,6BAA6B;AAG1C,OAAO,cAAM,aAAa;AAC1B,OAAO,cAAM,kCAAkC;AAC/C,OAAO,cAAM,kCAAkC;AAC/C,OAAO,cAAM,sBAAsB;AACnC,OAAO,cAAM,uBAAuB;AACpC,OAAO,cAAM,sBAAsB;AACnC,OAAO,cAAM,qBAAqB;AAElC,OAAO,cAAM,kCAAkC","names":["EMPTY_ANNOTATION_ARRAY: PdfAnnotation[]","DEVICE_PIXEL_RATIO: number"],"sources":["../../../src/pdf-viewer/constants.ts"],"version":3,"file":"constants.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAiBA,cAAc,qBAAqB,aAAc;;;;AAKjD,OAAO,iBAAS,wBACdA,aAAa,kBACZ,eAAe","names":["annotations: PdfAnnotation[]"],"sources":["../../../../src/pdf-viewer/hooks/usePdfAnnotationsByPage.ts"],"version":3,"file":"usePdfAnnotationsByPage.d.ts"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PDFDocumentProxy } from "pdfjs-dist";
|
|
2
|
+
import type { EventBus, PDFViewer } from "pdfjs-dist/web/pdf_viewer.mjs";
|
|
3
|
+
import type { RefObject } from "react";
|
|
4
|
+
import type { PdfFormFieldValue } from "../types.js";
|
|
5
|
+
export interface UsePdfFormFieldsOptions {
|
|
6
|
+
pdfViewerRef: RefObject<PDFViewer | null>;
|
|
7
|
+
eventBusRef: RefObject<EventBus | null>;
|
|
8
|
+
document: PDFDocumentProxy | undefined;
|
|
9
|
+
formData?: Record<string, PdfFormFieldValue>;
|
|
10
|
+
onFormSubmit?: (data: Record<string, PdfFormFieldValue>) => void;
|
|
11
|
+
onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface UsePdfFormFieldsResult {
|
|
14
|
+
/** Whether the loaded PDF contains interactive form fields. */
|
|
15
|
+
hasFormFields: boolean;
|
|
16
|
+
/** Collect all current form field values and invoke onFormSubmit. */
|
|
17
|
+
submitFormData: () => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Hook that manages interactive PDF form fields.
|
|
21
|
+
* Builds a field metadata map, pre-populates initial values,
|
|
22
|
+
* listens for field changes, and collects values on submit.
|
|
23
|
+
*/
|
|
24
|
+
export declare function usePdfFormFields({ pdfViewerRef, eventBusRef, document, formData, onFormSubmit, onFormChange }: UsePdfFormFieldsOptions): UsePdfFormFieldsResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,wBAAwB,YAAa;AACnD,cAAc,UAAU,iBAAiB,+BAAgC;AACzE,cAAc,iBAAiB,OAAQ;AAGvC,cAAc,yBAAyB,aAAc;AAerD,iBAAiB,wBAAwB;CACvC,cAAc,UAAU;CACxB,aAAa,UAAU;CACvB,UAAU;CACV,WAAW,eAAe;CAC1B,gBAAgBA,MAAM,eAAe;CACrC,gBAAgBC,mBAAmBC,OAAO;AAC3C;AAED,iBAAiB,uBAAuB;;CAEtC;;CAEA;AACD;;;;;;AAqED,OAAO,iBAAS,iBAAiB,EAC/B,cACA,aACA,UACA,UACA,cACA,cACwB,EAAvB,0BAA0B","names":["data: Record<string, PdfFormFieldValue>","fieldName: string","value: PdfFormFieldValue"],"sources":["../../../../src/pdf-viewer/hooks/usePdfFormFields.ts"],"version":3,"file":"usePdfFormFields.d.ts"}
|