@embedpdf/react 3.0.0-next.13 → 3.0.0-next.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.cts +877 -0
  2. package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.ts +877 -0
  3. package/dist/actions.cjs +25 -5
  4. package/dist/actions.cjs.map +1 -1
  5. package/dist/actions.d.cts +18 -5
  6. package/dist/actions.d.ts +18 -5
  7. package/dist/actions.js +22 -6
  8. package/dist/actions.js.map +1 -1
  9. package/dist/anchored-DeX95xSd.d.ts +85 -0
  10. package/dist/anchored-DzN3JywS.d.cts +85 -0
  11. package/dist/anchored.cjs +71 -28
  12. package/dist/anchored.cjs.map +1 -1
  13. package/dist/anchored.d.cts +2 -45
  14. package/dist/anchored.d.ts +2 -45
  15. package/dist/anchored.js +56 -19
  16. package/dist/anchored.js.map +1 -1
  17. package/dist/annotation-B48UT2ln.d.ts +302 -0
  18. package/dist/annotation-C1ttM8Wj.js +708 -0
  19. package/dist/annotation-C1ttM8Wj.js.map +1 -0
  20. package/dist/annotation-C9dVwo9b.d.cts +302 -0
  21. package/dist/annotation-Dex5EBda.cjs +830 -0
  22. package/dist/annotation-Dex5EBda.cjs.map +1 -0
  23. package/dist/annotation.cjs +20 -783
  24. package/dist/annotation.d.cts +2 -2
  25. package/dist/annotation.d.ts +2 -2
  26. package/dist/annotation.js +2 -768
  27. package/dist/commands.cjs +68 -28
  28. package/dist/commands.cjs.map +1 -1
  29. package/dist/commands.d.cts +37 -10
  30. package/dist/commands.d.ts +37 -10
  31. package/dist/commands.js +68 -31
  32. package/dist/commands.js.map +1 -1
  33. package/dist/form-55izw0jS.js +511 -0
  34. package/dist/form-55izw0jS.js.map +1 -0
  35. package/dist/form-BNqQfGGH.cjs +548 -0
  36. package/dist/form-BNqQfGGH.cjs.map +1 -0
  37. package/dist/form.cjs +5 -5
  38. package/dist/form.d.cts +32 -25
  39. package/dist/form.d.ts +32 -25
  40. package/dist/form.js +2 -3
  41. package/dist/history.cjs +38 -0
  42. package/dist/history.cjs.map +1 -0
  43. package/dist/history.d.cts +27 -0
  44. package/dist/history.d.ts +27 -0
  45. package/dist/history.js +27 -0
  46. package/dist/history.js.map +1 -0
  47. package/dist/i18n.cjs +26 -30
  48. package/dist/i18n.cjs.map +1 -1
  49. package/dist/i18n.d.cts +24 -21
  50. package/dist/i18n.d.ts +24 -21
  51. package/dist/i18n.js +24 -31
  52. package/dist/i18n.js.map +1 -1
  53. package/dist/index.cjs +213 -57
  54. package/dist/index.d.cts +32 -31
  55. package/dist/index.d.ts +32 -31
  56. package/dist/index.js +33 -29
  57. package/dist/inert-CmBEbKCn.cjs +19 -0
  58. package/dist/inert-CmBEbKCn.cjs.map +1 -0
  59. package/dist/inert-D8fkennb.js +14 -0
  60. package/dist/inert-D8fkennb.js.map +1 -0
  61. package/dist/interaction.cjs +48 -102
  62. package/dist/interaction.cjs.map +1 -1
  63. package/dist/interaction.d.cts +23 -32
  64. package/dist/interaction.d.ts +23 -32
  65. package/dist/interaction.js +33 -102
  66. package/dist/interaction.js.map +1 -1
  67. package/dist/link.cjs +65 -104
  68. package/dist/link.cjs.map +1 -1
  69. package/dist/link.d.cts +21 -16
  70. package/dist/link.d.ts +22 -17
  71. package/dist/link.js +67 -107
  72. package/dist/link.js.map +1 -1
  73. package/dist/measurement.cjs +56 -0
  74. package/dist/measurement.cjs.map +1 -0
  75. package/dist/measurement.d.cts +38 -0
  76. package/dist/measurement.d.ts +38 -0
  77. package/dist/measurement.js +42 -0
  78. package/dist/measurement.js.map +1 -0
  79. package/dist/metadata.cjs +20 -7
  80. package/dist/metadata.cjs.map +1 -1
  81. package/dist/metadata.d.cts +22 -7
  82. package/dist/metadata.d.ts +22 -7
  83. package/dist/metadata.js +20 -10
  84. package/dist/metadata.js.map +1 -1
  85. package/dist/page-edit.cjs +7 -3
  86. package/dist/page-edit.cjs.map +1 -1
  87. package/dist/page-edit.d.cts +6 -2
  88. package/dist/page-edit.d.ts +6 -2
  89. package/dist/page-edit.js +7 -4
  90. package/dist/page-edit.js.map +1 -1
  91. package/dist/page-layers-Bkaaz8Zf.js +26 -0
  92. package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
  93. package/dist/page-layers-BloZDoOV.cjs +37 -0
  94. package/dist/page-layers-BloZDoOV.cjs.map +1 -0
  95. package/dist/page-view.cjs +89 -82
  96. package/dist/page-view.cjs.map +1 -1
  97. package/dist/page-view.d.cts +14 -7
  98. package/dist/page-view.d.ts +18 -11
  99. package/dist/page-view.js +86 -81
  100. package/dist/page-view.js.map +1 -1
  101. package/dist/redaction.cjs +30 -15
  102. package/dist/redaction.cjs.map +1 -1
  103. package/dist/redaction.d.cts +27 -9
  104. package/dist/redaction.d.ts +27 -9
  105. package/dist/redaction.js +29 -18
  106. package/dist/redaction.js.map +1 -1
  107. package/dist/render.cjs +71 -46
  108. package/dist/render.cjs.map +1 -1
  109. package/dist/render.d.cts +17 -5
  110. package/dist/render.d.ts +17 -5
  111. package/dist/render.js +70 -49
  112. package/dist/render.js.map +1 -1
  113. package/dist/runtime-B6xcPsEb.js +398 -0
  114. package/dist/runtime-B6xcPsEb.js.map +1 -0
  115. package/dist/runtime-DBEBlpQV.d.cts +237 -0
  116. package/dist/runtime-V3MVMb91.d.ts +237 -0
  117. package/dist/runtime-fzpGv78v.cjs +555 -0
  118. package/dist/runtime-fzpGv78v.cjs.map +1 -0
  119. package/dist/runtime.cjs +45 -324
  120. package/dist/runtime.d.cts +2 -2
  121. package/dist/runtime.d.ts +2 -2
  122. package/dist/runtime.js +2 -306
  123. package/dist/search.cjs +81 -50
  124. package/dist/search.cjs.map +1 -1
  125. package/dist/search.d.cts +36 -24
  126. package/dist/search.d.ts +36 -24
  127. package/dist/search.js +81 -53
  128. package/dist/search.js.map +1 -1
  129. package/dist/selection.cjs +105 -108
  130. package/dist/selection.cjs.map +1 -1
  131. package/dist/selection.d.cts +54 -26
  132. package/dist/selection.d.ts +56 -28
  133. package/dist/selection.js +103 -110
  134. package/dist/selection.js.map +1 -1
  135. package/dist/shell.cjs +36 -21
  136. package/dist/shell.cjs.map +1 -1
  137. package/dist/shell.d.cts +32 -17
  138. package/dist/shell.d.ts +32 -17
  139. package/dist/shell.js +36 -24
  140. package/dist/shell.js.map +1 -1
  141. package/dist/signature.cjs +29 -48
  142. package/dist/signature.cjs.map +1 -1
  143. package/dist/signature.d.cts +26 -26
  144. package/dist/signature.d.ts +26 -26
  145. package/dist/signature.js +30 -48
  146. package/dist/signature.js.map +1 -1
  147. package/dist/stage-BIG6aeVd.cjs +369 -0
  148. package/dist/stage-BIG6aeVd.cjs.map +1 -0
  149. package/dist/stage-ByFPD-Fv.d.cts +117 -0
  150. package/dist/stage-DaboaheR.d.ts +117 -0
  151. package/dist/stage-DoVekb83.js +302 -0
  152. package/dist/stage-DoVekb83.js.map +1 -0
  153. package/dist/stage-scope-CQgCuf1w.cjs +46 -0
  154. package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
  155. package/dist/stage-scope-D7ZeNduT.js +23 -0
  156. package/dist/stage-scope-D7ZeNduT.js.map +1 -0
  157. package/dist/stage.cjs +12 -235
  158. package/dist/stage.d.cts +2 -116
  159. package/dist/stage.d.ts +2 -116
  160. package/dist/stage.js +3 -228
  161. package/dist/stamp.cjs +41 -35
  162. package/dist/stamp.cjs.map +1 -1
  163. package/dist/stamp.d.cts +25 -18
  164. package/dist/stamp.d.ts +25 -18
  165. package/dist/stamp.js +40 -37
  166. package/dist/stamp.js.map +1 -1
  167. package/dist/state-0K1I5cM4.d.cts +29 -0
  168. package/dist/state-0K1I5cM4.d.ts +29 -0
  169. package/dist/state-CbgxhwLA.js +62 -0
  170. package/dist/state-CbgxhwLA.js.map +1 -0
  171. package/dist/state-CsfZy_Eq.cjs +73 -0
  172. package/dist/state-CsfZy_Eq.cjs.map +1 -0
  173. package/dist/svg-shapes-Dm1yTR1b.js +40 -0
  174. package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
  175. package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
  176. package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
  177. package/dist/toolbar.cjs +297 -295
  178. package/dist/toolbar.cjs.map +1 -1
  179. package/dist/toolbar.d.cts +58 -68
  180. package/dist/toolbar.d.ts +67 -77
  181. package/dist/toolbar.js +271 -293
  182. package/dist/toolbar.js.map +1 -1
  183. package/dist/view-manager.cjs +34 -0
  184. package/dist/view-manager.cjs.map +1 -0
  185. package/dist/view-manager.d.cts +21 -0
  186. package/dist/view-manager.d.ts +21 -0
  187. package/dist/view-manager.js +23 -0
  188. package/dist/view-manager.js.map +1 -0
  189. package/package.json +41 -38
  190. package/dist/AnnotationListSnapshot-D3mFut1e-C_GMpK25.d.cts +0 -546
  191. package/dist/AnnotationListSnapshot-D3mFut1e-C_GMpK25.d.ts +0 -546
  192. package/dist/annotation-BCED_p9H.d.cts +0 -160
  193. package/dist/annotation-anchors-CetwM1g7.js +0 -15
  194. package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
  195. package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
  196. package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
  197. package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
  198. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
  199. package/dist/annotation-hooks-Df8EmzDO.js +0 -11
  200. package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
  201. package/dist/annotation-k38KDlIZ.d.ts +0 -160
  202. package/dist/annotation-menu.cjs +0 -64
  203. package/dist/annotation-menu.cjs.map +0 -1
  204. package/dist/annotation-menu.d.cts +0 -33
  205. package/dist/annotation-menu.d.ts +0 -33
  206. package/dist/annotation-menu.js +0 -48
  207. package/dist/annotation-menu.js.map +0 -1
  208. package/dist/annotation.cjs.map +0 -1
  209. package/dist/annotation.js.map +0 -1
  210. package/dist/form-BVumS7up.cjs +0 -926
  211. package/dist/form-BVumS7up.cjs.map +0 -1
  212. package/dist/form-CK3mp99m.js +0 -895
  213. package/dist/form-CK3mp99m.js.map +0 -1
  214. package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
  215. package/dist/runtime-DE76hlnl.d.ts +0 -216
  216. package/dist/runtime-umHA_xHt.d.cts +0 -216
  217. package/dist/runtime.cjs.map +0 -1
  218. package/dist/runtime.js.map +0 -1
  219. package/dist/scrollbar.cjs +0 -241
  220. package/dist/scrollbar.cjs.map +0 -1
  221. package/dist/scrollbar.d.cts +0 -42
  222. package/dist/scrollbar.d.ts +0 -42
  223. package/dist/scrollbar.js +0 -213
  224. package/dist/scrollbar.js.map +0 -1
  225. package/dist/stage.cjs.map +0 -1
  226. package/dist/stage.js.map +0 -1
  227. package/dist/views.cjs +0 -35
  228. package/dist/views.cjs.map +0 -1
  229. package/dist/views.d.cts +0 -21
  230. package/dist/views.d.ts +0 -21
  231. package/dist/views.js +0 -27
  232. package/dist/views.js.map +0 -1
@@ -0,0 +1,511 @@
1
+ import { C as useOptionalSelector, D as useViewerSettings, E as useSelector, S as useOptionalCapability, f as useCapability, g as useDocumentScope, p as useCapabilityEvent, u as shallowArray, w as usePage, x as useKernelValue } from "./runtime-B6xcPsEb.js";
2
+ import { n as stateHook, t as settingsHook } from "./state-CbgxhwLA.js";
3
+ import { n as usePaintsPagePart } from "./page-layers-Bkaaz8Zf.js";
4
+ import { n as useFontMounts, t as SvgShapes } from "./svg-shapes-Dm1yTR1b.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { annotationKey } from "@embedpdf/core";
7
+ import { FORM_CONTROL_FILL, createOptimisticSelection, createShownUrls, createTextFieldEditor, formColorsOf, formFocusRingStyleOf, isolatePointerDown, isolateWheel, listBoxControlStyleOf, loadAppearanceUrls, pictureOrPainting, pressToggle, rectInPixels, shownAppearance, svgShapesOf, textFieldEditorStyleOf, widgetBoxStyleOf } from "@embedpdf/web";
8
+ import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
9
+ import { InteractionToken } from "@embedpdf/plugin-interaction/contract/host";
10
+ import { RenderToken } from "@embedpdf/plugin-render/contract/host";
11
+ import { MITER_LIMIT } from "@embedpdf/core-annotation";
12
+ import { FormToken, formState } from "@embedpdf/plugin-form";
13
+ import { FormToken as FormToken$1 } from "@embedpdf/plugin-form/contract/host";
14
+ import { SignatureToken } from "@embedpdf/plugin-signature/contract";
15
+ //#region src/form-listbox.tsx
16
+ /**
17
+ * A PDF list box needs one owner for pixels, hit-testing, and scrolling. A
18
+ * baked /AP picture with an invisible native select cannot provide that: the
19
+ * browser and PDF each keep an independent top-visible row. This visible
20
+ * native control keeps a local optimistic selection while the engine write is
21
+ * pending and synchronizes when engine truth changes (`@embedpdf/web`'s
22
+ * `createOptimisticSelection`), without remounting the DOM node or resetting
23
+ * its scroll position.
24
+ */
25
+ function NativeListBox({ ariaLabel, disabled, multi, options, selected, onSelect, onFocus, onBlur, style }) {
26
+ const [selection] = useState(() => createOptimisticSelection(selected));
27
+ const draft = useSyncExternalStore(selection.subscribe, selection.get, selection.get);
28
+ const controlRef = useRef(null);
29
+ useEffect(() => controlRef.current ? isolateWheel(controlRef.current) : void 0, []);
30
+ useEffect(() => selection.setConfirmed(selected), [selection, selected]);
31
+ return /* @__PURE__ */ jsx("select", {
32
+ ref: controlRef,
33
+ "aria-label": ariaLabel,
34
+ multiple: multi,
35
+ size: Math.max(2, options.length),
36
+ disabled,
37
+ value: multi ? draft : draft[0] ?? "",
38
+ onFocus,
39
+ onBlur,
40
+ onChange: (event) => selection.choose(Array.from(event.currentTarget.selectedOptions).map((option) => option.value), onSelect),
41
+ style,
42
+ children: options.map((option, index) => /* @__PURE__ */ jsx("option", {
43
+ value: option.value,
44
+ children: option.label
45
+ }, index))
46
+ });
47
+ }
48
+ //#endregion
49
+ //#region src/form-focus-ring.tsx
50
+ /**
51
+ * Paint the focus ring above the field's picture and see-through native
52
+ * controls. An inset outline on the box itself would sit under an opaque
53
+ * child, so rectangular checkboxes and dropdowns would look unfocused while
54
+ * they are active in the native Tab order.
55
+ */
56
+ function FormFocusRing({ visible, color }) {
57
+ if (!visible) return null;
58
+ return /* @__PURE__ */ jsx("span", {
59
+ "aria-hidden": "true",
60
+ "data-embedpdf-form-focus-ring": "",
61
+ style: formFocusRingStyleOf(color)
62
+ });
63
+ }
64
+ //#endregion
65
+ //#region src/form.tsx
66
+ /** The colors the viewer draws fields with: the form settings over the viewer's accent. */
67
+ function useFormColors() {
68
+ const accent = useViewerSettings((settings) => settings.accent);
69
+ const focus = useFormSettings((settings) => settings.focus);
70
+ const fields = useFormSettings((settings) => settings.fields);
71
+ return useMemo(() => formColorsOf({
72
+ focus,
73
+ fields
74
+ }, accent), [
75
+ accent,
76
+ focus,
77
+ fields
78
+ ]);
79
+ }
80
+ /**
81
+ * Keep the interaction hub out of gestures that begin inside a control. A
82
+ * native listener, not React's, so it runs during real DOM bubbling, before
83
+ * the Stage's own native listener on an ancestor. The press stops there, so
84
+ * React's own `onPointerDown` never sees it: whoever needs the press passes
85
+ * `onPress`, which the native listener calls.
86
+ */
87
+ function useIsolated(onPress) {
88
+ const ref = useRef(null);
89
+ const press = useRef(onPress);
90
+ press.current = onPress;
91
+ useEffect(() => ref.current ? isolatePointerDown(ref.current, () => press.current?.()) : void 0, []);
92
+ return ref;
93
+ }
94
+ /**
95
+ * The widget's pointer and focus events, sent to the actions plugin, which
96
+ * runs the widget's `/AA` actions (enter, exit, down, up, focus, blur). They
97
+ * live on the always-active box, never the inner control: "may edit this
98
+ * field" and "may receive PDF action events" are different rights, and a
99
+ * session that may not fill must still see hover tooltips.
100
+ */
101
+ function useWidgetEvents(fieldRef, annotationRef) {
102
+ const form = useCapability(FormToken$1);
103
+ const refBox = useRef(annotationRef);
104
+ refBox.current = annotationRef;
105
+ return useMemo(() => {
106
+ const notify = (event) => {
107
+ const target = refBox.current;
108
+ if (target) form.notifyWidgetEvent(fieldRef, target, event);
109
+ };
110
+ return {
111
+ onPointerEnter: () => notify("cursorEnter"),
112
+ onPointerLeave: () => notify("cursorExit"),
113
+ onPress: () => notify("mouseDown"),
114
+ onPointerUp: () => notify("mouseUp"),
115
+ onFocus: () => notify("focus"),
116
+ onBlur: () => notify("blur")
117
+ };
118
+ }, [form, fieldRef]);
119
+ }
120
+ /**
121
+ * A click on a widget runs its `/A` action. ISO 32000 puts the activate
122
+ * action on the widget, whatever its field, and many forms ship "buttons" as
123
+ * read-only text fields with an `/A` that Acrobat runs; a widget without one
124
+ * is inert.
125
+ */
126
+ function useWidgetActivation(annotationRef) {
127
+ const form = useCapability(FormToken$1);
128
+ const refBox = useRef(annotationRef);
129
+ refBox.current = annotationRef;
130
+ return useCallback(() => {
131
+ const target = refBox.current;
132
+ if (target) form.activateWidget(target);
133
+ }, [form]);
134
+ }
135
+ /**
136
+ * The positioned box every control sits in: the widget's event surface, and
137
+ * the edge a field without a border of its own gets, so people see where to
138
+ * fill in.
139
+ */
140
+ function WidgetBox({ item, page, colors, edge = true, onClick, children, ...rest }) {
141
+ const { onPress, ...events } = useWidgetEvents(item.fieldRef, item.annotationRef);
142
+ const wrap = useIsolated(onPress);
143
+ const frame = rectInPixels(item.box, page.transform);
144
+ return /* @__PURE__ */ jsx("div", {
145
+ ref: wrap,
146
+ ...events,
147
+ ...rest,
148
+ onFocus: (event) => {
149
+ events.onFocus?.(event);
150
+ rest.onFocus?.(event);
151
+ },
152
+ onBlur: (event) => {
153
+ events.onBlur?.(event);
154
+ rest.onBlur?.(event);
155
+ },
156
+ onClick,
157
+ style: {
158
+ ...widgetBoxStyleOf(item, frame, colors, { edge }),
159
+ ...rest.style
160
+ },
161
+ children
162
+ });
163
+ }
164
+ /** A text box: the picture at rest, an editor in the field's own font while focused. */
165
+ function TextControl({ item, page, colors }) {
166
+ const form = useCapability(FormToken$1);
167
+ const activate = useWidgetActivation(item.annotationRef);
168
+ const editor = useMemo(() => createTextFieldEditor(form, item.fieldRef, item.value), [form, item.key]);
169
+ const { focused, draft } = useSyncExternalStore(editor.subscribe, editor.getState, editor.getState);
170
+ useEffect(() => editor.setValue(item.value), [editor, item.value]);
171
+ const frame = rectInPixels(item.box, page.transform);
172
+ const layout = item.annotationRef ? form.getTextEditorLayout(item.annotationRef, draft) : null;
173
+ useFontMounts(layout ? [layout.program] : NO_PROGRAMS);
174
+ const editorProps = {
175
+ value: draft,
176
+ maxLength: item.maxLength ?? void 0,
177
+ "aria-label": item.label,
178
+ disabled: item.disabled,
179
+ onFocus: editor.focus,
180
+ onChange: (event) => editor.input(event.target.value),
181
+ onBlur: editor.blur,
182
+ onKeyDown: (event) => {
183
+ if (editor.keyDown(event.key, item.multiline)) event.currentTarget.blur();
184
+ },
185
+ style: textFieldEditorStyleOf(item, frame, colors, focused, layout)
186
+ };
187
+ return /* @__PURE__ */ jsx(WidgetBox, {
188
+ item,
189
+ page,
190
+ colors,
191
+ onClick: activate,
192
+ children: item.multiline ? /* @__PURE__ */ jsx("textarea", { ...editorProps }) : /* @__PURE__ */ jsx("input", {
193
+ ...editorProps,
194
+ type: item.password ? "password" : "text"
195
+ })
196
+ });
197
+ }
198
+ /** A checkbox or a radio button: the picture is the control, a click writes the toggled value. */
199
+ function ToggleControl({ item, page, colors }) {
200
+ const form = useCapability(FormToken$1);
201
+ const activate = useWidgetActivation(item.annotationRef);
202
+ const [focused, setFocused] = useState(false);
203
+ const press = () => pressToggle(form, item, activate);
204
+ return /* @__PURE__ */ jsx(WidgetBox, {
205
+ item,
206
+ page,
207
+ colors,
208
+ role: item.kind === "checkbox" ? "checkbox" : "radio",
209
+ "aria-checked": item.checked,
210
+ "aria-label": item.label,
211
+ tabIndex: item.disabled ? -1 : 0,
212
+ onClick: press,
213
+ onFocus: () => setFocused(true),
214
+ onBlur: () => setFocused(false),
215
+ onKeyDown: (event) => {
216
+ if (event.key === " " || event.key === "Enter") {
217
+ event.preventDefault();
218
+ press();
219
+ }
220
+ },
221
+ style: {
222
+ cursor: item.disabled ? "default" : "pointer",
223
+ outline: "none"
224
+ },
225
+ children: /* @__PURE__ */ jsx(FormFocusRing, {
226
+ visible: focused,
227
+ color: colors.focus
228
+ })
229
+ });
230
+ }
231
+ /** A dropdown: an invisible native select over the field's picture. */
232
+ function ComboControl({ item, page, colors }) {
233
+ const form = useCapability(FormToken$1);
234
+ const activate = useWidgetActivation(item.annotationRef);
235
+ const [focused, setFocused] = useState(false);
236
+ return /* @__PURE__ */ jsxs(WidgetBox, {
237
+ item,
238
+ page,
239
+ colors,
240
+ onClick: activate,
241
+ children: [/* @__PURE__ */ jsxs("select", {
242
+ defaultValue: item.selected[0] ?? "",
243
+ "aria-label": item.label,
244
+ disabled: item.disabled,
245
+ onFocus: () => setFocused(true),
246
+ onBlur: () => setFocused(false),
247
+ onChange: (event) => void form.setValue(item.fieldRef, { value: event.currentTarget.value || null }),
248
+ style: {
249
+ ...FORM_CONTROL_FILL,
250
+ opacity: 0,
251
+ cursor: item.disabled ? "default" : "pointer",
252
+ ...item.disabled ? { pointerEvents: "none" } : {}
253
+ },
254
+ children: [item.selected.length === 0 && /* @__PURE__ */ jsx("option", { value: "" }), item.options.map((option, index) => /* @__PURE__ */ jsx("option", {
255
+ value: option.value,
256
+ children: option.label
257
+ }, index))]
258
+ }, item.selected.join("\0")), /* @__PURE__ */ jsx(FormFocusRing, {
259
+ visible: focused,
260
+ color: colors.focus
261
+ })]
262
+ });
263
+ }
264
+ /** A list: a visible native select in the field's own look, the settings where it has none. */
265
+ function ListControl({ item, page, colors }) {
266
+ const form = useCapability(FormToken$1);
267
+ const activate = useWidgetActivation(item.annotationRef);
268
+ const [focused, setFocused] = useState(false);
269
+ const frame = rectInPixels(item.box, page.transform);
270
+ return /* @__PURE__ */ jsxs(WidgetBox, {
271
+ item,
272
+ page,
273
+ colors,
274
+ edge: false,
275
+ onClick: activate,
276
+ children: [/* @__PURE__ */ jsx(NativeListBox, {
277
+ ariaLabel: item.label,
278
+ disabled: item.disabled,
279
+ multi: item.multi,
280
+ options: item.options,
281
+ selected: item.selected,
282
+ onFocus: () => setFocused(true),
283
+ onBlur: () => setFocused(false),
284
+ onSelect: async (values) => {
285
+ await form.setValue(item.fieldRef, { selectedValues: values });
286
+ },
287
+ style: listBoxControlStyleOf(item, frame, colors)
288
+ }), /* @__PURE__ */ jsx(FormFocusRing, {
289
+ visible: focused,
290
+ color: colors.focus
291
+ })]
292
+ });
293
+ }
294
+ /** A push button: a native click target over its picture that runs its action. */
295
+ function ButtonControl({ item, page, colors }) {
296
+ const activate = useWidgetActivation(item.annotationRef);
297
+ return /* @__PURE__ */ jsx(WidgetBox, {
298
+ item,
299
+ page,
300
+ colors,
301
+ edge: false,
302
+ style: { cursor: item.disabled ? "default" : "pointer" },
303
+ children: /* @__PURE__ */ jsx("button", {
304
+ type: "button",
305
+ "aria-label": item.label,
306
+ disabled: item.disabled,
307
+ onClick: activate,
308
+ style: {
309
+ ...FORM_CONTROL_FILL,
310
+ padding: 0,
311
+ border: 0,
312
+ background: "transparent",
313
+ cursor: "inherit",
314
+ pointerEvents: item.disabled ? "none" : "auto"
315
+ }
316
+ })
317
+ });
318
+ }
319
+ /**
320
+ * A signature field: with the signature plugin, an empty field is "sign
321
+ * here" (it becomes the target the next mark goes to), and a signed one asks
322
+ * your UI to show its details. Without it, the field is only its picture.
323
+ */
324
+ function SignatureControl({ item, page, colors }) {
325
+ const signature = useOptionalCapability(SignatureToken);
326
+ const ref = item.fieldRef;
327
+ const signed = useOptionalSelector(SignatureToken, (capability) => capability.getSignature(ref)?.signed ?? item.signed, item.signed);
328
+ const actionable = signature !== null && (signed || !item.disabled);
329
+ return /* @__PURE__ */ jsx(WidgetBox, {
330
+ item,
331
+ page,
332
+ colors,
333
+ style: { cursor: actionable ? "pointer" : "default" },
334
+ children: actionable ? /* @__PURE__ */ jsx("button", {
335
+ type: "button",
336
+ "aria-label": item.label,
337
+ "data-signed": signed ? "" : void 0,
338
+ onClick: () => signed ? signature.requestInspection(ref) : signature.setTarget(ref),
339
+ style: {
340
+ ...FORM_CONTROL_FILL,
341
+ padding: 0,
342
+ border: 0,
343
+ background: "transparent",
344
+ cursor: "inherit"
345
+ }
346
+ }) : null
347
+ });
348
+ }
349
+ /**
350
+ * The form's fields on one page: their pictures, and the controls people fill
351
+ * them in with. Put it above the page's picture (`<RenderLayer>`, and
352
+ * `<AnnotationLayer>` when the annotation plugin is registered); while it's
353
+ * there, the render layer leaves the fields out of the page's picture. The
354
+ * controls show while the active tool fills forms (the `pointer` and `pan`
355
+ * tools do), and stand down in design mode, where fields are boxes you
356
+ * select and move.
357
+ */
358
+ function FormLayer() {
359
+ const page = usePage();
360
+ const form = useCapability(FormToken$1);
361
+ const colors = useFormColors();
362
+ const active = useSelector(InteractionToken, (interaction) => interaction.activeToolEnables("form-fill"));
363
+ usePaintsPagePart(page.ref, "formFields");
364
+ useEffect(() => {
365
+ form.ensureLoaded(page.ref);
366
+ }, [form, page.ref]);
367
+ const items = useSelector(FormToken$1, (capability) => capability.listWidgets(page.ref), shallowArray);
368
+ return /* @__PURE__ */ jsxs("div", {
369
+ style: {
370
+ position: "absolute",
371
+ inset: 0,
372
+ pointerEvents: "none"
373
+ },
374
+ children: [/* @__PURE__ */ jsx(FieldPictures, { page }), (active ? items : []).map((item) => {
375
+ const key = `${item.key}:${item.annotObjectNumber}`;
376
+ switch (item.control) {
377
+ case "text": return /* @__PURE__ */ jsx(TextControl, {
378
+ item,
379
+ page,
380
+ colors
381
+ }, key);
382
+ case "toggle": return /* @__PURE__ */ jsx(ToggleControl, {
383
+ item,
384
+ page,
385
+ colors
386
+ }, key);
387
+ case "choice": return item.kind === "list" ? /* @__PURE__ */ jsx(ListControl, {
388
+ item,
389
+ page,
390
+ colors
391
+ }, key) : /* @__PURE__ */ jsx(ComboControl, {
392
+ item,
393
+ page,
394
+ colors
395
+ }, key);
396
+ case "button": return /* @__PURE__ */ jsx(ButtonControl, {
397
+ item,
398
+ page,
399
+ colors
400
+ }, key);
401
+ case "signature": return /* @__PURE__ */ jsx(SignatureControl, {
402
+ item,
403
+ page,
404
+ colors
405
+ }, key);
406
+ }
407
+ })]
408
+ });
409
+ }
410
+ /**
411
+ * The page's fields as they look now. Each widget shows its picture, as the
412
+ * engine draws it (the form plugin's, every state loaded, so a check box
413
+ * shows its new state at once), or the painter's drawing while its look is
414
+ * pending or its picture is of an older version (`pictureOrPainting`): a
415
+ * value, a calculation, a restyle shows at once. Hidden widgets aren't drawn.
416
+ */
417
+ function FieldPictures({ page }) {
418
+ const form = useCapability(FormToken$1);
419
+ const widgets = useSelector(FormToken$1, (form) => form.listShownWidgets(page.ref), shallowArray);
420
+ const epoch = useSelector(FormToken$1, (form) => form.getAppearanceEpoch(page.ref));
421
+ const scale = useOptionalSelector(RenderToken, (render) => render.getAppearanceScale(page.transform.renderScale), 0);
422
+ const [urls, setUrls] = useState(null);
423
+ const [shown] = useState(createShownUrls);
424
+ useEffect(() => () => shown.release(), [shown]);
425
+ useEffect(() => {
426
+ if (!scale) return;
427
+ return loadAppearanceUrls(shown, (signal) => form.renderAppearances(page.ref, scale, signal), annotationKey, setUrls);
428
+ }, [
429
+ shown,
430
+ form,
431
+ page.ref,
432
+ scale,
433
+ epoch
434
+ ]);
435
+ const looks = widgets.map((widget) => pictureOrPainting({
436
+ pending: widget.pending,
437
+ picture: urls && shownAppearance(urls, annotationKey(widget.ref), widget.appearanceState),
438
+ version: widget.pictureVersion,
439
+ loaded: urls !== null,
440
+ paint: () => form.getWidgetPainting(widget.ref)
441
+ }));
442
+ return /* @__PURE__ */ jsx(Fragment, { children: widgets.map((widget, index) => {
443
+ const look = looks[index];
444
+ if (!look) return null;
445
+ const key = annotationKey(widget.ref);
446
+ if (look.kind === "painting") {
447
+ const { x, y, width, height } = widget.rect;
448
+ const frame = rectInPixels(widget.rect, page.transform);
449
+ return /* @__PURE__ */ jsx("svg", {
450
+ viewBox: `${x} ${y} ${width} ${height}`,
451
+ style: {
452
+ position: "absolute",
453
+ left: frame.left,
454
+ top: frame.top,
455
+ width: frame.width,
456
+ height: frame.height,
457
+ overflow: "visible",
458
+ pointerEvents: "none"
459
+ },
460
+ children: /* @__PURE__ */ jsx(SvgShapes, { shapes: svgShapesOf(look.painting.scene, { miterLimit: MITER_LIMIT }) })
461
+ }, key);
462
+ }
463
+ const frame = rectInPixels(look.picture.box, page.transform);
464
+ return /* @__PURE__ */ jsx("img", {
465
+ src: look.picture.url,
466
+ alt: "",
467
+ draggable: false,
468
+ style: {
469
+ position: "absolute",
470
+ left: frame.left,
471
+ top: frame.top,
472
+ width: frame.width,
473
+ height: frame.height,
474
+ maxWidth: "none",
475
+ maxHeight: "none",
476
+ pointerEvents: "none"
477
+ }
478
+ }, key);
479
+ }) });
480
+ }
481
+ const NO_PROGRAMS = Object.freeze([]);
482
+ /** The form API for the surrounding document: reading, filling, form data and building. */
483
+ function useForm() {
484
+ return useCapability(FormToken);
485
+ }
486
+ /** Subscribe to one form event while mounted: `useFormEvent((form) => form.onValueChanged, handler)`. */
487
+ function useFormEvent(select, handler) {
488
+ useCapabilityEvent(FormToken, select, handler);
489
+ }
490
+ /**
491
+ * The form's state: every field, whether it's read, what kind of form the
492
+ * document has, and the field of the selected widget (the page's State
493
+ * table, declared once in `formState`). Takes a selector, and re-renders only
494
+ * when what it returns changes.
495
+ */
496
+ const useFormState = stateHook(formState);
497
+ /** The form settings (`validation`, `focus`, `fields`), with or without a document. Takes a selector. */
498
+ const useFormSettings = settingsHook(FormToken);
499
+ /**
500
+ * One field's value, in the shape `setValue()` takes, or `null`: re-renders
501
+ * only when that field's value changes. Empty without a document.
502
+ */
503
+ function useFormValue(ref) {
504
+ const scoped = useDocumentScope();
505
+ const stable = useMemo(() => ref, [ref.kind === "fqn" ? `n:${ref.name}` : `o:${ref.objectNumber}`]);
506
+ return useKernelValue((kernel) => kernel.tryCapability(FormToken, scoped ?? void 0)?.getValue(stable) ?? null);
507
+ }
508
+ //#endregion
509
+ export { useFormState as a, useFormSettings as i, useForm as n, useFormValue as o, useFormEvent as r, FormLayer as t };
510
+
511
+ //# sourceMappingURL=form-55izw0jS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-55izw0jS.js","names":["FormHostToken"],"sources":["../src/form-listbox.tsx","../src/form-focus-ring.tsx","../src/form.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useEffect, useRef, useState, useSyncExternalStore } from 'react';\nimport { createOptimisticSelection, isolateWheel } from '@embedpdf/web';\n\nexport interface NativeListBoxOption {\n label: string;\n value: string;\n}\n\nexport interface NativeListBoxProps {\n ariaLabel: string;\n disabled: boolean;\n multi: boolean;\n options: NativeListBoxOption[];\n selected: string[];\n onSelect(values: string[]): void | Promise<void>;\n onFocus?: React.FocusEventHandler<HTMLSelectElement>;\n onBlur?: React.FocusEventHandler<HTMLSelectElement>;\n style?: React.CSSProperties;\n}\n\n/**\n * A PDF list box needs one owner for pixels, hit-testing, and scrolling. A\n * baked /AP picture with an invisible native select cannot provide that: the\n * browser and PDF each keep an independent top-visible row. This visible\n * native control keeps a local optimistic selection while the engine write is\n * pending and synchronizes when engine truth changes (`@embedpdf/web`'s\n * `createOptimisticSelection`), without remounting the DOM node or resetting\n * its scroll position.\n */\nexport function NativeListBox({\n ariaLabel,\n disabled,\n multi,\n options,\n selected,\n onSelect,\n onFocus,\n onBlur,\n style,\n}: NativeListBoxProps) {\n const [selection] = useState(() => createOptimisticSelection(selected));\n const draft = useSyncExternalStore(selection.subscribe, selection.get, selection.get);\n const controlRef = useRef<HTMLSelectElement>(null);\n\n // The Stage's ambient wheel handler lives on an ancestor and\n // preventDefault()s to pan/zoom the page. Stop at the list box so the\n // browser can apply the same wheel event to this control's own scroll box.\n useEffect(() => (controlRef.current ? isolateWheel(controlRef.current) : undefined), []);\n\n useEffect(() => selection.setConfirmed(selected), [selection, selected]);\n\n return (\n <select\n ref={controlRef}\n aria-label={ariaLabel}\n multiple={multi}\n size={Math.max(2, options.length)}\n disabled={disabled}\n value={multi ? draft : (draft[0] ?? '')}\n onFocus={onFocus}\n onBlur={onBlur}\n onChange={(event) =>\n selection.choose(\n Array.from(event.currentTarget.selectedOptions).map((option) => option.value),\n onSelect,\n )\n }\n style={style}\n >\n {options.map((option, index) => (\n <option key={index} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n );\n}\n","import * as React from 'react';\nimport { formFocusRingStyleOf } from '@embedpdf/web';\n\nexport interface FormFocusRingProps {\n visible: boolean;\n /** The ring's CSS color: the form's `focus.color` setting, through its CSS variable. */\n color: string;\n}\n\n/**\n * Paint the focus ring above the field's picture and see-through native\n * controls. An inset outline on the box itself would sit under an opaque\n * child, so rectangular checkboxes and dropdowns would look unfocused while\n * they are active in the native Tab order.\n */\nexport function FormFocusRing({ visible, color }: FormFocusRingProps) {\n if (!visible) return null;\n return (\n <span aria-hidden=\"true\" data-embedpdf-form-focus-ring=\"\" style={formFocusRingStyleOf(color)} />\n );\n}\n","/**\n * The React view of @embedpdf/plugin-form.\n *\n * `<FormLayer />` paints the fields of its page as the engine draws them\n * (their values, borders and fonts) and puts a real HTML control over each\n * field box, with or without the annotation plugin. While it's on the page,\n * the `<RenderLayer>` leaves the fields out of the page's picture. The\n * controls add what people interact with on top of the pictures:\n *\n * text → the picture at rest; focus shows an editor in the field's font\n * (the plugin keeps what is typed, so a download writes it);\n * blur or Enter commits, Escape puts the value back.\n * toggle → the picture is the control; a click writes the toggled value.\n * combo → an invisible native <select> over the picture: the browser\n * owns the dropdown, the engine the resting pixels.\n * list → a visible native <select>: one surface owns the rows, the\n * keyboard and the scrolling.\n * button → a native click target over the picture; activation runs the\n * widget's action.\n *\n * What the viewer draws itself (the focus ring, the edge of a field without a\n * border, the editor) takes its colors from the form settings, which the\n * `--epdf-form-*` CSS variables override.\n *\n * Every control keeps its pointerdown from the interaction hub with a native\n * listener (`isolatePointerDown`): the Stage listens natively on an ancestor,\n * so React's synthetic events would run too late. The colors, the field\n * looks, the boxes' and controls' styles, and the toggle, text-field and\n * list-box policies are `@embedpdf/web`'s, the same for every framework.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-form';\nimport * as React from 'react';\nimport { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport { annotationKey, type EventHook } from '@embedpdf/core';\nimport { MITER_LIMIT } from '@embedpdf/core-annotation';\nimport type { PdfAnnotationEventKind } from '@embedpdf/plugin-actions/contract';\nimport type { AnnotationRef } from '@embedpdf/plugin-annotation/contract';\nimport {\n FormToken,\n formState,\n type FormCapability,\n type FormFieldRef,\n type FormFieldValue,\n type FormWidgetItem,\n} from '@embedpdf/plugin-form';\nimport { FormToken as FormHostToken } from '@embedpdf/plugin-form/contract/host';\nimport { InteractionToken } from '@embedpdf/plugin-interaction/contract/host';\nimport { RenderToken } from '@embedpdf/plugin-render/contract/host';\nimport { SignatureToken } from '@embedpdf/plugin-signature/contract';\nimport {\n createShownUrls,\n createTextFieldEditor,\n FORM_CONTROL_FILL,\n formColorsOf,\n isolatePointerDown,\n listBoxControlStyleOf,\n loadAppearanceUrls,\n pictureOrPainting,\n pressToggle,\n rectInPixels,\n shownAppearance,\n svgShapesOf,\n textFieldEditorStyleOf,\n widgetBoxStyleOf,\n type AppearanceUrl,\n type FormColors,\n type MountableFontProgram,\n} from '@embedpdf/web';\n\nimport { NativeListBox } from './form-listbox';\nimport { FormFocusRing } from './form-focus-ring';\nimport { usePaintsPagePart } from './page-layers';\nimport {\n shallowArray,\n useCapability,\n useCapabilityEvent,\n useDocumentScope,\n useKernelValue,\n useOptionalCapability,\n useOptionalSelector,\n usePage,\n useSelector,\n useViewerSettings,\n} from './runtime';\nimport type { PageContextValue } from './runtime';\nimport { settingsHook, stateHook } from './state';\nimport { useFontMounts } from './font-mounts';\nimport { SvgShapes } from './svg-shapes';\n\n// ── what every control shares ──────────────────────────────────────────────\n\n/** The colors the viewer draws fields with: the form settings over the viewer's accent. */\nfunction useFormColors(): FormColors {\n const accent = useViewerSettings((settings) => settings.accent);\n const focus = useFormSettings((settings) => settings.focus);\n const fields = useFormSettings((settings) => settings.fields);\n return useMemo(() => formColorsOf({ focus, fields }, accent), [accent, focus, fields]);\n}\n\n/**\n * Keep the interaction hub out of gestures that begin inside a control. A\n * native listener, not React's, so it runs during real DOM bubbling, before\n * the Stage's own native listener on an ancestor. The press stops there, so\n * React's own `onPointerDown` never sees it: whoever needs the press passes\n * `onPress`, which the native listener calls.\n */\nfunction useIsolated<T extends HTMLElement>(onPress?: () => void) {\n const ref = useRef<T>(null);\n const press = useRef(onPress);\n press.current = onPress;\n useEffect(\n () => (ref.current ? isolatePointerDown(ref.current, () => press.current?.()) : undefined),\n [],\n );\n return ref;\n}\n\n/**\n * The widget's pointer and focus events, sent to the actions plugin, which\n * runs the widget's `/AA` actions (enter, exit, down, up, focus, blur). They\n * live on the always-active box, never the inner control: \"may edit this\n * field\" and \"may receive PDF action events\" are different rights, and a\n * session that may not fill must still see hover tooltips.\n */\nfunction useWidgetEvents(\n fieldRef: FormFieldRef,\n annotationRef: AnnotationRef | null,\n): Pick<\n React.DOMAttributes<HTMLElement>,\n 'onPointerEnter' | 'onPointerLeave' | 'onPointerUp' | 'onFocus' | 'onBlur'\n> & { onPress: () => void } {\n const form = useCapability(FormHostToken);\n const refBox = useRef(annotationRef);\n refBox.current = annotationRef;\n return useMemo(() => {\n const notify = (event: PdfAnnotationEventKind) => {\n const target = refBox.current;\n if (target) form.notifyWidgetEvent(fieldRef, target, event);\n };\n return {\n onPointerEnter: () => notify('cursorEnter'),\n onPointerLeave: () => notify('cursorExit'),\n // The press, from the box's native listener (`useIsolated`).\n onPress: () => notify('mouseDown'),\n onPointerUp: () => notify('mouseUp'),\n // React focus and blur bubble, so the inner control's focus reaches the\n // box; blur fires after the control's own commit, so a blur script\n // always sees the committed value.\n onFocus: () => notify('focus'),\n onBlur: () => notify('blur'),\n };\n }, [form, fieldRef]);\n}\n\n/**\n * A click on a widget runs its `/A` action. ISO 32000 puts the activate\n * action on the widget, whatever its field, and many forms ship \"buttons\" as\n * read-only text fields with an `/A` that Acrobat runs; a widget without one\n * is inert.\n */\nfunction useWidgetActivation(annotationRef: AnnotationRef | null): () => void {\n const form = useCapability(FormHostToken);\n const refBox = useRef(annotationRef);\n refBox.current = annotationRef;\n return useCallback(() => {\n const target = refBox.current;\n if (target) void form.activateWidget(target);\n }, [form]);\n}\n\ninterface ControlProps<C extends FormWidgetItem['control']> {\n item: Extract<FormWidgetItem, { control: C }>;\n page: PageContextValue;\n colors: FormColors;\n}\n\n/**\n * The positioned box every control sits in: the widget's event surface, and\n * the edge a field without a border of its own gets, so people see where to\n * fill in.\n */\nfunction WidgetBox({\n item,\n page,\n colors,\n edge = true,\n onClick,\n children,\n ...rest\n}: {\n item: FormWidgetItem;\n page: PageContextValue;\n colors: FormColors;\n edge?: boolean;\n onClick?: () => void;\n children?: React.ReactNode;\n} & Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick' | 'children'>) {\n const { onPress, ...events } = useWidgetEvents(item.fieldRef, item.annotationRef);\n const wrap = useIsolated<HTMLDivElement>(onPress);\n const frame = rectInPixels(item.box, page.transform);\n return (\n <div\n ref={wrap}\n {...events}\n {...rest}\n onFocus={(event) => {\n events.onFocus?.(event);\n rest.onFocus?.(event);\n }}\n onBlur={(event) => {\n events.onBlur?.(event);\n rest.onBlur?.(event);\n }}\n onClick={onClick}\n style={{ ...widgetBoxStyleOf(item, frame, colors, { edge }), ...rest.style }}\n >\n {children}\n </div>\n );\n}\n\n// ── the controls ───────────────────────────────────────────────────────────\n\n/** A text box: the picture at rest, an editor in the field's own font while focused. */\nfunction TextControl({ item, page, colors }: ControlProps<'text'>) {\n const form = useCapability(FormHostToken);\n const activate = useWidgetActivation(item.annotationRef);\n // The editor is always mounted, see-through at rest and shown while\n // focused: the DOM is the focus manager, so Tab reaches every field. Typing\n // drafts, blur or Enter commits, Escape puts the value back. One editing\n // policy per field (by its key) and form.\n const editor = useMemo(\n () => createTextFieldEditor(form, item.fieldRef, item.value),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [form, item.key],\n );\n const { focused, draft } = useSyncExternalStore(\n editor.subscribe,\n editor.getState,\n editor.getState,\n );\n // Take the field's value whenever it changes under us, but never mid-edit.\n useEffect(() => editor.setValue(item.value), [editor, item.value]);\n\n const frame = rectInPixels(item.box, page.transform);\n // The text being typed, where the engine will draw it, in its face.\n const layout = item.annotationRef ? form.getTextEditorLayout(item.annotationRef, draft) : null;\n useFontMounts(layout ? [layout.program] : NO_PROGRAMS);\n const editorProps = {\n value: draft,\n maxLength: item.maxLength ?? undefined,\n 'aria-label': item.label,\n disabled: item.disabled,\n onFocus: editor.focus,\n onChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>\n editor.input(event.target.value),\n onBlur: editor.blur,\n onKeyDown: (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (editor.keyDown(event.key, item.multiline)) event.currentTarget.blur();\n },\n style: textFieldEditorStyleOf(item, frame, colors, focused, layout),\n };\n return (\n // A click runs the widget's action too, as in Acrobat: the editor's\n // focus click bubbles here, a read-only field's lands here directly.\n <WidgetBox item={item} page={page} colors={colors} onClick={activate}>\n {item.multiline ? (\n <textarea {...editorProps} />\n ) : (\n <input {...editorProps} type={item.password ? 'password' : 'text'} />\n )}\n </WidgetBox>\n );\n}\n\n/** A checkbox or a radio button: the picture is the control, a click writes the toggled value. */\nfunction ToggleControl({ item, page, colors }: ControlProps<'toggle'>) {\n const form = useCapability(FormHostToken);\n const activate = useWidgetActivation(item.annotationRef);\n const [focused, setFocused] = useState(false);\n // The value first, then the widget's action (Acrobat's order).\n const press = () => pressToggle(form, item, activate);\n return (\n <WidgetBox\n item={item}\n page={page}\n colors={colors}\n role={item.kind === 'checkbox' ? 'checkbox' : 'radio'}\n aria-checked={item.checked}\n aria-label={item.label}\n tabIndex={item.disabled ? -1 : 0}\n onClick={press}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n onKeyDown={(event) => {\n if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n press();\n }\n }}\n style={{ cursor: item.disabled ? 'default' : 'pointer', outline: 'none' }}\n >\n <FormFocusRing visible={focused} color={colors.focus} />\n </WidgetBox>\n );\n}\n\n/** A dropdown: an invisible native select over the field's picture. */\nfunction ComboControl({ item, page, colors }: ControlProps<'choice'>) {\n const form = useCapability(FormHostToken);\n const activate = useWidgetActivation(item.annotationRef);\n const [focused, setFocused] = useState(false);\n return (\n <WidgetBox item={item} page={page} colors={colors} onClick={activate}>\n <select\n key={item.selected.join('\\0')}\n defaultValue={item.selected[0] ?? ''}\n aria-label={item.label}\n disabled={item.disabled}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n onChange={(event) =>\n void form.setValue(item.fieldRef, { value: event.currentTarget.value || null })\n }\n style={{\n ...FORM_CONTROL_FILL,\n opacity: 0,\n cursor: item.disabled ? 'default' : 'pointer',\n ...(item.disabled ? { pointerEvents: 'none' as const } : {}),\n }}\n >\n {item.selected.length === 0 && <option value=\"\" />}\n {item.options.map((option, index) => (\n <option key={index} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n <FormFocusRing visible={focused} color={colors.focus} />\n </WidgetBox>\n );\n}\n\n/** A list: a visible native select in the field's own look, the settings where it has none. */\nfunction ListControl({ item, page, colors }: ControlProps<'choice'>) {\n const form = useCapability(FormHostToken);\n const activate = useWidgetActivation(item.annotationRef);\n const [focused, setFocused] = useState(false);\n const frame = rectInPixels(item.box, page.transform);\n return (\n <WidgetBox item={item} page={page} colors={colors} edge={false} onClick={activate}>\n <NativeListBox\n ariaLabel={item.label}\n disabled={item.disabled}\n multi={item.multi}\n options={item.options}\n selected={item.selected}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n onSelect={async (values) => {\n await form.setValue(item.fieldRef, { selectedValues: values });\n }}\n style={listBoxControlStyleOf(item, frame, colors)}\n />\n <FormFocusRing visible={focused} color={colors.focus} />\n </WidgetBox>\n );\n}\n\n/** A push button: a native click target over its picture that runs its action. */\nfunction ButtonControl({ item, page, colors }: ControlProps<'button'>) {\n const activate = useWidgetActivation(item.annotationRef);\n return (\n <WidgetBox\n item={item}\n page={page}\n colors={colors}\n edge={false}\n style={{ cursor: item.disabled ? 'default' : 'pointer' }}\n >\n <button\n type=\"button\"\n aria-label={item.label}\n disabled={item.disabled}\n onClick={activate}\n style={{\n ...FORM_CONTROL_FILL,\n padding: 0,\n border: 0,\n background: 'transparent',\n cursor: 'inherit',\n // The box is the event surface; a disabled button must not swallow the pointer.\n pointerEvents: item.disabled ? 'none' : 'auto',\n }}\n />\n </WidgetBox>\n );\n}\n\n/**\n * A signature field: with the signature plugin, an empty field is \"sign\n * here\" (it becomes the target the next mark goes to), and a signed one asks\n * your UI to show its details. Without it, the field is only its picture.\n */\nfunction SignatureControl({ item, page, colors }: ControlProps<'signature'>) {\n const signature = useOptionalCapability(SignatureToken);\n const ref = item.fieldRef;\n // The signature plugin knows best whether it's signed (it reads again after\n // every new version); the field's own value is the fallback.\n const signed = useOptionalSelector(\n SignatureToken,\n (capability) => capability.getSignature(ref)?.signed ?? item.signed,\n item.signed,\n );\n const actionable = signature !== null && (signed || !item.disabled);\n return (\n <WidgetBox\n item={item}\n page={page}\n colors={colors}\n style={{ cursor: actionable ? 'pointer' : 'default' }}\n >\n {actionable ? (\n <button\n type=\"button\"\n aria-label={item.label}\n data-signed={signed ? '' : undefined}\n onClick={() => (signed ? signature.requestInspection(ref) : signature.setTarget(ref))}\n style={{\n ...FORM_CONTROL_FILL,\n padding: 0,\n border: 0,\n background: 'transparent',\n cursor: 'inherit',\n }}\n />\n ) : null}\n </WidgetBox>\n );\n}\n\n/**\n * The form's fields on one page: their pictures, and the controls people fill\n * them in with. Put it above the page's picture (`<RenderLayer>`, and\n * `<AnnotationLayer>` when the annotation plugin is registered); while it's\n * there, the render layer leaves the fields out of the page's picture. The\n * controls show while the active tool fills forms (the `pointer` and `pan`\n * tools do), and stand down in design mode, where fields are boxes you\n * select and move.\n */\nexport function FormLayer() {\n const page = usePage();\n const form = useCapability(FormHostToken);\n const colors = useFormColors();\n const active = useSelector(InteractionToken, (interaction) =>\n interaction.activeToolEnables('form-fill'),\n );\n usePaintsPagePart(page.ref, 'formFields');\n\n useEffect(() => {\n void form.ensureLoaded(page.ref);\n }, [form, page.ref]);\n\n const items = useSelector(\n FormHostToken,\n (capability) => capability.listWidgets(page.ref),\n shallowArray,\n );\n\n return (\n <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>\n <FieldPictures page={page} />\n {(active ? items : []).map((item) => {\n const key = `${item.key}:${item.annotObjectNumber}`;\n switch (item.control) {\n case 'text':\n return <TextControl key={key} item={item} page={page} colors={colors} />;\n case 'toggle':\n return <ToggleControl key={key} item={item} page={page} colors={colors} />;\n case 'choice':\n return item.kind === 'list' ? (\n <ListControl key={key} item={item} page={page} colors={colors} />\n ) : (\n <ComboControl key={key} item={item} page={page} colors={colors} />\n );\n case 'button':\n return <ButtonControl key={key} item={item} page={page} colors={colors} />;\n case 'signature':\n return <SignatureControl key={key} item={item} page={page} colors={colors} />;\n }\n })}\n </div>\n );\n}\n\n/**\n * The page's fields as they look now. Each widget shows its picture, as the\n * engine draws it (the form plugin's, every state loaded, so a check box\n * shows its new state at once), or the painter's drawing while its look is\n * pending or its picture is of an older version (`pictureOrPainting`): a\n * value, a calculation, a restyle shows at once. Hidden widgets aren't drawn.\n */\nfunction FieldPictures({ page }: { page: PageContextValue }) {\n const form = useCapability(FormHostToken);\n const widgets = useSelector(\n FormHostToken,\n (form) => form.listShownWidgets(page.ref),\n shallowArray,\n );\n // Loaded again when one of the page's widgets is drawn again, and at appearance-scale crossings.\n const epoch = useSelector(FormHostToken, (form) => form.getAppearanceEpoch(page.ref));\n const scale = useOptionalSelector(\n RenderToken,\n (render) => render.getAppearanceScale(page.transform.renderScale),\n 0,\n );\n // `null` until the page's first pictures arrive.\n const [urls, setUrls] = useState<Record<string, AppearanceUrl> | null>(null);\n // The pictures shown stay valid until the next ones are shown.\n const [shown] = useState(createShownUrls);\n useEffect(() => () => shown.release(), [shown]);\n\n useEffect(() => {\n if (!scale) return;\n return loadAppearanceUrls(\n shown,\n (signal) => form.renderAppearances(page.ref, scale, signal),\n annotationKey,\n setUrls,\n );\n }, [shown, form, page.ref, scale, epoch]);\n\n const looks = widgets.map((widget) =>\n pictureOrPainting({\n pending: widget.pending,\n picture: urls && shownAppearance(urls, annotationKey(widget.ref), widget.appearanceState),\n version: widget.pictureVersion,\n loaded: urls !== null,\n paint: () => form.getWidgetPainting(widget.ref),\n }),\n );\n\n return (\n <>\n {widgets.map((widget, index) => {\n const look = looks[index];\n if (!look) return null;\n const key = annotationKey(widget.ref);\n if (look.kind === 'painting') {\n const { x, y, width, height } = widget.rect;\n const frame = rectInPixels(widget.rect, page.transform);\n return (\n <svg\n key={key}\n viewBox={`${x} ${y} ${width} ${height}`}\n style={{\n position: 'absolute',\n left: frame.left,\n top: frame.top,\n width: frame.width,\n height: frame.height,\n overflow: 'visible',\n pointerEvents: 'none',\n }}\n >\n <SvgShapes shapes={svgShapesOf(look.painting.scene, { miterLimit: MITER_LIMIT })} />\n </svg>\n );\n }\n const frame = rectInPixels(look.picture.box, page.transform);\n return (\n <img\n key={key}\n src={look.picture.url}\n alt=\"\"\n draggable={false}\n style={{\n position: 'absolute',\n left: frame.left,\n top: frame.top,\n width: frame.width,\n height: frame.height,\n // A global `img { max-width: 100% }` reset would clamp it.\n maxWidth: 'none',\n maxHeight: 'none',\n pointerEvents: 'none',\n }}\n />\n );\n })}\n </>\n );\n}\n\nconst NO_PROGRAMS: readonly MountableFontProgram[] = Object.freeze([]);\n\n// ── hooks ──────────────────────────────────────────────────────────────────\n\n/** The form API for the surrounding document: reading, filling, form data and building. */\nexport function useForm(): FormCapability {\n return useCapability(FormToken);\n}\n\n/** Subscribe to one form event while mounted: `useFormEvent((form) => form.onValueChanged, handler)`. */\nexport function useFormEvent<T>(\n select: (form: FormCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(FormToken, select, handler);\n}\n\n/**\n * The form's state: every field, whether it's read, what kind of form the\n * document has, and the field of the selected widget (the page's State\n * table, declared once in `formState`). Takes a selector, and re-renders only\n * when what it returns changes.\n */\nexport const useFormState = stateHook(formState);\n\n/** The form settings (`validation`, `focus`, `fields`), with or without a document. Takes a selector. */\nexport const useFormSettings = settingsHook(FormToken);\n\n/**\n * One field's value, in the shape `setValue()` takes, or `null`: re-renders\n * only when that field's value changes. Empty without a document.\n */\nexport function useFormValue(ref: FormFieldRef): FormFieldValue | null {\n const scoped = useDocumentScope();\n const key = ref.kind === 'fqn' ? `n:${ref.name}` : `o:${ref.objectNumber}`;\n // Keyed by value, so an inline `toFieldRef('total')` never subscribes again.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stable = useMemo(() => ref, [key]);\n return useKernelValue(\n (kernel) => kernel.tryCapability(FormToken, scoped ?? undefined)?.getValue(stable) ?? null,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,cAAc,EAC5B,WACA,UACA,OACA,SACA,UACA,UACA,SACA,QACA,SACqB;CACrB,MAAM,CAAC,aAAa,eAAe,0BAA0B,QAAQ,CAAC;CACtE,MAAM,QAAQ,qBAAqB,UAAU,WAAW,UAAU,KAAK,UAAU,GAAG;CACpF,MAAM,aAAa,OAA0B,IAAI;CAKjD,gBAAiB,WAAW,UAAU,aAAa,WAAW,OAAO,IAAI,KAAA,GAAY,CAAC,CAAC;CAEvF,gBAAgB,UAAU,aAAa,QAAQ,GAAG,CAAC,WAAW,QAAQ,CAAC;CAEvE,OACE,oBAAC,UAAD;EACE,KAAK;EACL,cAAY;EACZ,UAAU;EACV,MAAM,KAAK,IAAI,GAAG,QAAQ,MAAM;EACtB;EACV,OAAO,QAAQ,QAAS,MAAM,MAAM;EAC3B;EACD;EACR,WAAW,UACT,UAAU,OACR,MAAM,KAAK,MAAM,cAAc,eAAe,CAAC,CAAC,KAAK,WAAW,OAAO,KAAK,GAC5E,QACF;EAEK;EAEN,UAAA,QAAQ,KAAK,Q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