@embedpdf/react 3.0.0-next.10 → 3.0.0-next.11

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 (83) hide show
  1. package/dist/{AnnotationListSnapshot-DDxHpJQU-BG32YXxG.d.ts → AnnotationListSnapshot-C1U3XUxP-6kGwNoxy.d.cts} +223 -24
  2. package/dist/{AnnotationListSnapshot-DDxHpJQU-BG32YXxG.d.cts → AnnotationListSnapshot-C1U3XUxP-6kGwNoxy.d.ts} +223 -24
  3. package/dist/actions.cjs +42 -0
  4. package/dist/actions.cjs.map +1 -0
  5. package/dist/actions.d.cts +18 -0
  6. package/dist/actions.d.ts +18 -0
  7. package/dist/actions.js +34 -0
  8. package/dist/actions.js.map +1 -0
  9. package/dist/annotation-BCED_p9H.d.cts +160 -0
  10. package/dist/annotation-anchors-CetwM1g7.js +15 -0
  11. package/dist/annotation-anchors-CetwM1g7.js.map +1 -0
  12. package/dist/annotation-anchors-DuYRBJLl.cjs +26 -0
  13. package/dist/annotation-anchors-DuYRBJLl.cjs.map +1 -0
  14. package/dist/annotation-hooks-BB5ZhPpf.cjs +16 -0
  15. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +1 -0
  16. package/dist/annotation-hooks-Df8EmzDO.js +11 -0
  17. package/dist/annotation-hooks-Df8EmzDO.js.map +1 -0
  18. package/dist/annotation-k38KDlIZ.d.ts +160 -0
  19. package/dist/annotation-menu.cjs +5 -5
  20. package/dist/annotation-menu.cjs.map +1 -1
  21. package/dist/annotation-menu.js +2 -2
  22. package/dist/annotation-menu.js.map +1 -1
  23. package/dist/annotation.cjs +5 -19
  24. package/dist/annotation.cjs.map +1 -1
  25. package/dist/annotation.d.cts +2 -159
  26. package/dist/annotation.d.ts +2 -159
  27. package/dist/annotation.js +2 -16
  28. package/dist/annotation.js.map +1 -1
  29. package/dist/form-BwrLFpKN.js +805 -0
  30. package/dist/form-BwrLFpKN.js.map +1 -0
  31. package/dist/form-D-ZSfGmB.cjs +836 -0
  32. package/dist/form-D-ZSfGmB.cjs.map +1 -0
  33. package/dist/form.cjs +8 -551
  34. package/dist/form.d.cts +4 -21
  35. package/dist/form.d.ts +4 -21
  36. package/dist/form.js +3 -544
  37. package/dist/index.cjs +15 -11
  38. package/dist/index.d.cts +7 -6
  39. package/dist/index.d.ts +7 -6
  40. package/dist/index.js +8 -5
  41. package/dist/link.cjs +48 -8
  42. package/dist/link.cjs.map +1 -1
  43. package/dist/link.d.cts +2 -2
  44. package/dist/link.d.ts +2 -2
  45. package/dist/link.js +49 -9
  46. package/dist/link.js.map +1 -1
  47. package/dist/{runtime-Cvi0wQ4d.d.cts → runtime-DE76hlnl.d.ts} +13 -5
  48. package/dist/{runtime-DXxr8T4L.d.ts → runtime-umHA_xHt.d.cts} +13 -5
  49. package/dist/runtime.cjs +19 -0
  50. package/dist/runtime.cjs.map +1 -1
  51. package/dist/runtime.d.cts +2 -2
  52. package/dist/runtime.d.ts +2 -2
  53. package/dist/runtime.js +19 -1
  54. package/dist/runtime.js.map +1 -1
  55. package/dist/scrollbar.cjs +3 -3
  56. package/dist/scrollbar.cjs.map +1 -1
  57. package/dist/scrollbar.d.cts +1 -1
  58. package/dist/scrollbar.d.ts +1 -1
  59. package/dist/scrollbar.js +1 -1
  60. package/dist/scrollbar.js.map +1 -1
  61. package/dist/search.d.cts +1 -1
  62. package/dist/search.d.ts +1 -1
  63. package/dist/selection.cjs +2 -2
  64. package/dist/selection.cjs.map +1 -1
  65. package/dist/selection.d.cts +1 -1
  66. package/dist/selection.d.ts +1 -1
  67. package/dist/selection.js +1 -1
  68. package/dist/selection.js.map +1 -1
  69. package/dist/stage.cjs +2 -2
  70. package/dist/stage.cjs.map +1 -1
  71. package/dist/stage.d.cts +1 -1
  72. package/dist/stage.d.ts +1 -1
  73. package/dist/stage.js +1 -1
  74. package/dist/stage.js.map +1 -1
  75. package/dist/toolbar.cjs +4 -4
  76. package/dist/toolbar.cjs.map +1 -1
  77. package/dist/toolbar.d.cts +1 -1
  78. package/dist/toolbar.d.ts +1 -1
  79. package/dist/toolbar.js +1 -1
  80. package/dist/toolbar.js.map +1 -1
  81. package/package.json +29 -23
  82. package/dist/form.cjs.map +0 -1
  83. package/dist/form.js.map +0 -1
package/dist/form.js CHANGED
@@ -1,545 +1,4 @@
1
- import { shallowArray, useCapability, useOptionalCapability, usePage, useSelector } from "./runtime.js";
2
- import { useAnnotationSelected } from "./annotation.js";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import { useEffect, useRef, useState } from "react";
5
- import { StageToken } from "@embedpdf/plugin-stage";
6
- import { InteractionToken } from "@embedpdf/plugin-interaction";
7
- import { FormToken } from "@embedpdf/plugin-form";
1
+ import "./runtime.js";
2
+ import { a as useFormSnapshot, i as useFormField, n as formWidgetRenderer, r as useForm, t as FormLayer } from "./form-BwrLFpKN.js";
8
3
  export * from "@embedpdf/plugin-form";
9
- //#region src/form.tsx
10
- /** Content rect → a view-px box (the page wrapper's own coordinate space). */
11
- function viewBox(r, page) {
12
- const tl = page.transform.toPixels({
13
- x: r.x,
14
- y: r.y
15
- });
16
- const br = page.transform.toPixels({
17
- x: r.x + r.width,
18
- y: r.y + r.height
19
- });
20
- return {
21
- left: tl.x,
22
- top: tl.y,
23
- width: br.x - tl.x,
24
- height: br.y - tl.y
25
- };
26
- }
27
- /**
28
- * Keep the interaction hub out of gestures that begin inside a fill control.
29
- * Native listener (not React's) so it runs during real DOM bubbling, before
30
- * the Stage's own native listener on an ancestor — same trick as FreeText.
31
- */
32
- function useIsolated() {
33
- const ref = useRef(null);
34
- useEffect(() => {
35
- const el = ref.current;
36
- if (!el) return;
37
- const stop = (e) => e.stopPropagation();
38
- el.addEventListener("pointerdown", stop);
39
- return () => el.removeEventListener("pointerdown", stop);
40
- }, []);
41
- return ref;
42
- }
43
- /**
44
- * Fulfil form-script UI requests for the active document. By default alerts use
45
- * the browser dialog, page navigation uses the main Stage, and print delegates
46
- * to the browser. Pass handlers (or one raw provider) to replace that policy.
47
- */
48
- function useFormScriptingProvider(adapter) {
49
- const form = useOptionalCapability(FormToken);
50
- const stage = useOptionalCapability(StageToken);
51
- const adapterRef = useRef(adapter);
52
- adapterRef.current = adapter;
53
- useEffect(() => {
54
- if (!form) return;
55
- const provider = (effect) => {
56
- const current = adapterRef.current;
57
- if (typeof current === "function") {
58
- current(effect);
59
- return;
60
- }
61
- switch (effect.kind) {
62
- case "alert":
63
- if (current?.alert) current.alert(effect.message, effect);
64
- else if (typeof globalThis.alert === "function") globalThis.alert(effect.message);
65
- break;
66
- case "gotoPage":
67
- if (current?.gotoPage) current.gotoPage(effect.page, effect);
68
- else stage?.goToPage(effect.page);
69
- break;
70
- case "print":
71
- if (current?.print) current.print(effect);
72
- else if (typeof globalThis.print === "function") globalThis.print();
73
- break;
74
- }
75
- };
76
- form.setUiEffectProvider(provider);
77
- return () => form.setUiEffectProvider(null);
78
- }, [form, stage]);
79
- }
80
- /** The baked /AP raster, blitted by its OWN box (exactly like BakedImage). */
81
- function Picture({ page, appearance, apBox, frame, hidden }) {
82
- if (!appearance) return null;
83
- const b = viewBox(apBox ?? appearance.box, page);
84
- return /* @__PURE__ */ jsx("img", {
85
- src: appearance.url,
86
- alt: "",
87
- draggable: false,
88
- style: {
89
- position: "absolute",
90
- left: b.left - (frame?.left ?? 0),
91
- top: b.top - (frame?.top ?? 0),
92
- width: b.width,
93
- height: b.height,
94
- maxWidth: "none",
95
- pointerEvents: "none",
96
- visibility: hidden ? "hidden" : "visible"
97
- }
98
- });
99
- }
100
- /**
101
- * Dispatch one engaged widget to its fill control. The FIELD plane (value,
102
- * behavior, disabled) comes from the form plugin's single-widget projection;
103
- * the WIDGET plane (live box, /DA font, baked raster) rides in on the
104
- * renderer props — no geometry is read from the form model here.
105
- */
106
- function FormWidget({ item, page, appearance }) {
107
- const annot = item.ref?.kind === "objectNumber" ? item.ref.annotObjectNumber : 0;
108
- const fill = useSelector(FormToken, (c) => annot > 0 ? c.fillItem(annot) : null);
109
- if (!fill) return /* @__PURE__ */ jsx(Picture, {
110
- page,
111
- appearance,
112
- apBox: item.apBox
113
- });
114
- switch (fill.control) {
115
- case "text": return /* @__PURE__ */ jsx(TextWidget, {
116
- fill,
117
- item,
118
- page,
119
- appearance
120
- });
121
- case "toggle": return /* @__PURE__ */ jsx(ToggleWidget, {
122
- fill,
123
- item,
124
- page,
125
- appearance
126
- });
127
- case "choice": return /* @__PURE__ */ jsx(ChoiceWidget, {
128
- fill,
129
- item,
130
- page,
131
- appearance
132
- });
133
- case "button": return /* @__PURE__ */ jsx(ButtonWidget, {
134
- fill,
135
- item,
136
- page,
137
- appearance
138
- });
139
- }
140
- }
141
- function ButtonWidget({ fill, item, page, appearance }) {
142
- const form = useCapability(FormToken);
143
- const wrap = useIsolated();
144
- const b = viewBox(item.box, page);
145
- return /* @__PURE__ */ jsx("button", {
146
- ref: wrap,
147
- type: "button",
148
- "aria-label": fill.label,
149
- disabled: fill.disabled,
150
- onClick: () => {
151
- if (item.ref) form.activateWidget(fill.key, item.ref);
152
- },
153
- style: {
154
- position: "absolute",
155
- left: b.left,
156
- top: b.top,
157
- width: b.width,
158
- height: b.height,
159
- boxSizing: "border-box",
160
- padding: 0,
161
- border: 0,
162
- background: "transparent",
163
- cursor: fill.disabled ? "default" : "pointer",
164
- pointerEvents: fill.disabled ? "none" : "auto"
165
- },
166
- children: /* @__PURE__ */ jsx(Picture, {
167
- page,
168
- appearance,
169
- apBox: item.apBox,
170
- frame: b
171
- })
172
- });
173
- }
174
- function TextWidget({ fill, item, page, appearance }) {
175
- const form = useCapability(FormToken);
176
- const wrap = useIsolated();
177
- const [focused, setFocused] = useState(false);
178
- const [draft, setDraft] = useState(fill.value);
179
- const cancelled = useRef(false);
180
- useEffect(() => {
181
- if (!focused) setDraft(fill.value);
182
- }, [fill.value, focused]);
183
- const b = viewBox(item.box, page);
184
- const scale = item.box.width > 0 ? b.width / item.box.width : 1;
185
- const fontSize = item.text && item.text.fontSize > 0 ? item.text.fontSize * scale : fill.multiline ? 12 * scale : Math.max(6, b.height * .72);
186
- const editorStyle = {
187
- position: "absolute",
188
- inset: 0,
189
- width: "100%",
190
- height: "100%",
191
- boxSizing: "border-box",
192
- border: "none",
193
- outline: focused ? "2px solid rgba(66, 133, 244, 0.8)" : "none",
194
- outlineOffset: -2,
195
- padding: "0 2px",
196
- margin: 0,
197
- background: item.style.interiorColor ?? "#fff",
198
- color: item.text?.fontColor ?? "#000",
199
- fontFamily: item.text?.fontFamily ?? "Helvetica, Arial, sans-serif",
200
- fontSize,
201
- textAlign: item.text?.textAlign ?? "left",
202
- resize: "none",
203
- cursor: "text",
204
- opacity: focused ? 1 : 0
205
- };
206
- const editorProps = {
207
- value: draft,
208
- maxLength: fill.maxLength ?? void 0,
209
- "aria-label": fill.label,
210
- disabled: fill.disabled,
211
- onFocus: () => setFocused(true),
212
- onChange: (e) => setDraft(e.target.value),
213
- onBlur: () => {
214
- setFocused(false);
215
- if (cancelled.current) {
216
- cancelled.current = false;
217
- setDraft(fill.value);
218
- return;
219
- }
220
- if (draft !== fill.value) form.setText(fill.key, draft);
221
- },
222
- style: editorStyle
223
- };
224
- const onKeys = (e) => {
225
- if (e.key === "Escape") {
226
- cancelled.current = true;
227
- e.currentTarget.blur();
228
- }
229
- if (e.key === "Enter" && !fill.multiline) e.currentTarget.blur();
230
- };
231
- return /* @__PURE__ */ jsxs("div", {
232
- ref: wrap,
233
- style: {
234
- position: "absolute",
235
- left: b.left,
236
- top: b.top,
237
- width: b.width,
238
- height: b.height,
239
- pointerEvents: fill.disabled ? "none" : "auto"
240
- },
241
- children: [/* @__PURE__ */ jsx(Picture, {
242
- page,
243
- appearance,
244
- apBox: item.apBox,
245
- frame: b,
246
- hidden: focused
247
- }), fill.multiline ? /* @__PURE__ */ jsx("textarea", {
248
- ...editorProps,
249
- onKeyDown: onKeys
250
- }) : /* @__PURE__ */ jsx("input", {
251
- ...editorProps,
252
- type: fill.password ? "password" : "text",
253
- onKeyDown: onKeys
254
- })]
255
- });
256
- }
257
- function ToggleWidget({ fill, item, page, appearance }) {
258
- const form = useCapability(FormToken);
259
- const wrap = useIsolated();
260
- const [focused, setFocused] = useState(false);
261
- const b = viewBox(item.box, page);
262
- const toggle = () => {
263
- if (fill.disabled) return;
264
- form.toggle(fill.key, fill.kind === "checkbox" && fill.checked ? null : fill.onState);
265
- };
266
- return /* @__PURE__ */ jsx("div", {
267
- ref: wrap,
268
- role: fill.kind === "checkbox" ? "checkbox" : "radio",
269
- "aria-checked": fill.checked,
270
- "aria-label": fill.label,
271
- tabIndex: fill.disabled ? -1 : 0,
272
- onClick: toggle,
273
- onFocus: () => setFocused(true),
274
- onBlur: () => setFocused(false),
275
- onKeyDown: (e) => {
276
- if (e.key === " " || e.key === "Enter") {
277
- e.preventDefault();
278
- toggle();
279
- }
280
- },
281
- style: {
282
- position: "absolute",
283
- left: b.left,
284
- top: b.top,
285
- width: b.width,
286
- height: b.height,
287
- cursor: fill.disabled ? "default" : "pointer",
288
- pointerEvents: fill.disabled ? "none" : "auto",
289
- outline: focused ? "2px solid rgba(66, 133, 244, 0.8)" : "none",
290
- outlineOffset: -2
291
- },
292
- children: /* @__PURE__ */ jsx(Picture, {
293
- page,
294
- appearance,
295
- apBox: item.apBox,
296
- frame: b
297
- })
298
- });
299
- }
300
- function ChoiceWidget({ fill, item, page, appearance }) {
301
- const form = useCapability(FormToken);
302
- const wrap = useIsolated();
303
- const [focused, setFocused] = useState(false);
304
- const b = viewBox(item.box, page);
305
- const multiple = fill.kind === "list" && fill.multi;
306
- return /* @__PURE__ */ jsxs("div", {
307
- ref: wrap,
308
- style: {
309
- position: "absolute",
310
- left: b.left,
311
- top: b.top,
312
- width: b.width,
313
- height: b.height,
314
- pointerEvents: fill.disabled ? "none" : "auto",
315
- outline: focused ? "2px solid rgba(66, 133, 244, 0.8)" : "none",
316
- outlineOffset: -2
317
- },
318
- children: [/* @__PURE__ */ jsx(Picture, {
319
- page,
320
- appearance,
321
- apBox: item.apBox,
322
- frame: b
323
- }), /* @__PURE__ */ jsx("select", {
324
- multiple,
325
- size: fill.kind === "list" ? Math.max(2, fill.options.length) : void 0,
326
- defaultValue: multiple ? fill.selected : fill.selected[0] ?? "",
327
- "aria-label": fill.label,
328
- disabled: fill.disabled,
329
- onFocus: () => setFocused(true),
330
- onBlur: () => setFocused(false),
331
- onChange: (e) => {
332
- const values = Array.from(e.currentTarget.selectedOptions).map((o) => o.value);
333
- form.choose(fill.key, values);
334
- },
335
- style: {
336
- position: "absolute",
337
- inset: 0,
338
- width: "100%",
339
- height: "100%",
340
- opacity: 0,
341
- cursor: fill.disabled ? "default" : "pointer"
342
- },
343
- children: fill.options.map((o, i) => /* @__PURE__ */ jsx("option", {
344
- value: o.value,
345
- children: o.label
346
- }, i))
347
- }, fill.selected.join("\0"))]
348
- });
349
- }
350
- /**
351
- * The form plugin's renderer entry, ready for
352
- * `<AnnotationLayer renderers={[formWidgetRenderer]} />`. It answers for the
353
- * PLUGIN-registered 'form-widgets' Behavior — the form plugin decides when
354
- * widgets are fill controls vs. editable annotations, never the app.
355
- */
356
- const formWidgetRenderer = {
357
- behavior: "form-widgets",
358
- component: FormWidget
359
- };
360
- const controlBase = {
361
- position: "absolute",
362
- boxSizing: "border-box",
363
- border: "1px solid rgba(56, 88, 233, 0.55)",
364
- background: "rgba(255, 255, 255, 0.92)",
365
- borderRadius: 2,
366
- font: "inherit"
367
- };
368
- const fillBox = (item, page) => viewBox(item.box, page);
369
- /** Text control: keystrokes stay LOCAL (the input is the draft store);
370
- * the engine write happens on blur or Enter. */
371
- function FillText({ item, page }) {
372
- const form = useCapability(FormToken);
373
- const [draft, setDraft] = useState(item.value);
374
- useEffect(() => setDraft(item.value), [item.value]);
375
- const css = fillBox(item, page);
376
- const fontSize = Math.max(9, Math.min(css.height * .62, 24));
377
- const commit = () => {
378
- if (draft !== item.value) form.setText(item.key, draft).catch(() => setDraft(item.value));
379
- };
380
- const shared = {
381
- ...controlBase,
382
- ...css,
383
- fontSize,
384
- padding: "0 3px",
385
- ...item.comb ? { letterSpacing: css.width / Math.max(1, item.maxLength ?? 1) / 2 } : {}
386
- };
387
- return item.multiline ? /* @__PURE__ */ jsx("textarea", {
388
- "aria-label": item.label,
389
- value: draft,
390
- disabled: item.disabled,
391
- onChange: (e) => setDraft(e.target.value),
392
- onBlur: commit,
393
- style: {
394
- ...shared,
395
- resize: "none"
396
- }
397
- }) : /* @__PURE__ */ jsx("input", {
398
- "aria-label": item.label,
399
- type: item.password ? "password" : "text",
400
- value: draft,
401
- maxLength: item.maxLength ?? void 0,
402
- disabled: item.disabled,
403
- onChange: (e) => setDraft(e.target.value),
404
- onBlur: commit,
405
- onKeyDown: (e) => {
406
- if (e.key === "Enter") e.target.blur();
407
- },
408
- style: shared
409
- });
410
- }
411
- function FillToggle({ item, page }) {
412
- const form = useCapability(FormToken);
413
- const css = fillBox(item, page);
414
- const glyphSize = Math.min(css.width, css.height) * .72;
415
- return /* @__PURE__ */ jsx("button", {
416
- role: item.kind,
417
- "aria-checked": item.checked,
418
- "aria-label": item.label,
419
- disabled: item.disabled,
420
- onClick: () => void form.toggle(item.key, item.kind === "checkbox" && item.checked ? null : item.onState),
421
- style: {
422
- ...controlBase,
423
- ...css,
424
- cursor: item.disabled ? "default" : "pointer",
425
- display: "grid",
426
- placeItems: "center",
427
- padding: 0,
428
- borderRadius: item.kind === "radio" ? "50%" : 2,
429
- fontSize: glyphSize,
430
- lineHeight: 1,
431
- color: "#1f2a44"
432
- },
433
- children: item.checked ? item.kind === "radio" ? "●" : "✓" : ""
434
- });
435
- }
436
- function FillChoice({ item, page }) {
437
- const form = useCapability(FormToken);
438
- const css = fillBox(item, page);
439
- return /* @__PURE__ */ jsxs("select", {
440
- "aria-label": item.label,
441
- multiple: item.multi,
442
- disabled: item.disabled,
443
- value: item.multi ? item.selected : item.selected[0] ?? "",
444
- onChange: (e) => {
445
- const values = item.multi ? Array.from(e.target.selectedOptions).map((o) => o.value) : [e.target.value];
446
- form.choose(item.key, values);
447
- },
448
- style: {
449
- ...controlBase,
450
- ...css,
451
- fontSize: Math.max(9, Math.min(css.height * .55, 18))
452
- },
453
- children: [!item.multi && item.selected.length === 0 && /* @__PURE__ */ jsx("option", { value: "" }), item.options.map((o) => /* @__PURE__ */ jsx("option", {
454
- value: o.value,
455
- children: o.label
456
- }, o.value))]
457
- });
458
- }
459
- function FillButton({ item, page }) {
460
- const form = useCapability(FormToken);
461
- const css = fillBox(item, page);
462
- return /* @__PURE__ */ jsx("button", {
463
- type: "button",
464
- "aria-label": item.label,
465
- disabled: item.disabled,
466
- onClick: () => void form.activateWidget(item.key, {
467
- kind: "objectNumber",
468
- pageObjectNumber: page.pon,
469
- annotObjectNumber: item.annotObjectNumber
470
- }),
471
- style: {
472
- ...controlBase,
473
- ...css,
474
- padding: 0,
475
- border: 0,
476
- background: "transparent",
477
- cursor: item.disabled ? "default" : "pointer"
478
- }
479
- });
480
- }
481
- /**
482
- * Fill-mode form controls for one page, positioned from the form model's own
483
- * widget geometry — the ANNOTATION-LESS path (a fill-only viewer whose page
484
- * pixels come from an annotated RenderLayer raster). Active whenever the
485
- * active tool carries the 'form-fill' tag (the built-in pointer/pan tools
486
- * do); any other tool stands the controls down. Do not mount next to an
487
- * AnnotationLayer wired with `formWidgetBehaviors`.
488
- */
489
- function FormLayer() {
490
- const page = usePage();
491
- const form = useCapability(FormToken);
492
- const active = useSelector(InteractionToken, (c) => c.activeTool().enables.has("form-fill"));
493
- useEffect(() => {
494
- if (active) form.ensureGeom(page.pon);
495
- }, [
496
- active,
497
- form,
498
- page.pon
499
- ]);
500
- const items = useSelector(FormToken, (c) => c.fillItems(page.pon), shallowArray);
501
- if (!active) return null;
502
- return /* @__PURE__ */ jsx("div", {
503
- style: {
504
- position: "absolute",
505
- inset: 0
506
- },
507
- children: items.map((item) => item.control === "text" ? /* @__PURE__ */ jsx(FillText, {
508
- item,
509
- page
510
- }, `${item.key}:${item.annotObjectNumber}`) : item.control === "toggle" ? /* @__PURE__ */ jsx(FillToggle, {
511
- item,
512
- page
513
- }, `${item.key}:${item.annotObjectNumber}`) : item.control === "choice" ? /* @__PURE__ */ jsx(FillChoice, {
514
- item,
515
- page
516
- }, `${item.key}:${item.annotObjectNumber}`) : item.control === "button" ? /* @__PURE__ */ jsx(FillButton, {
517
- item,
518
- page
519
- }, `${item.key}:${item.annotObjectNumber}`) : null)
520
- });
521
- }
522
- /** The form capability — values, interchange, design-mode verbs. */
523
- function useForm() {
524
- return useCapability(FormToken);
525
- }
526
- /** The reconciled form snapshot (null until the first load lands),
527
- * re-rendering on every form model change. */
528
- function useFormSnapshot() {
529
- return useSelector(FormToken, (c) => c.snapshot());
530
- }
531
- /**
532
- * The FIELD behind the currently selected widget annotation (single
533
- * selection), or null. The design-mode join: widget selection lives in the
534
- * annotation plane, field properties live here.
535
- */
536
- function useFormField() {
537
- const selected = useAnnotationSelected();
538
- const widget = selected.length === 1 && selected[0].subtype === "widget" ? selected[0] : null;
539
- const objnum = widget && widget.ref.kind === "objectNumber" ? widget.ref.annotObjectNumber : 0;
540
- return useSelector(FormToken, (c) => objnum > 0 ? c.fieldForWidget(objnum) : null);
541
- }
542
- //#endregion
543
- export { FormLayer, formWidgetRenderer, useForm, useFormField, useFormScriptingProvider, useFormSnapshot };
544
-
545
- //# sourceMappingURL=form.js.map
4
+ export { FormLayer, formWidgetRenderer, useForm, useFormField, useFormSnapshot };
package/dist/index.cjs CHANGED
@@ -8,14 +8,17 @@ const require_page_view = require("./page-view.cjs");
8
8
  const require_render = require("./render.cjs");
9
9
  const require_interaction = require("./interaction.cjs");
10
10
  const require_selection = require("./selection.cjs");
11
+ const require_annotation_anchors = require("./annotation-anchors-DuYRBJLl.cjs");
12
+ const require_annotation_hooks = require("./annotation-hooks-BB5ZhPpf.cjs");
11
13
  const require_annotation = require("./annotation.cjs");
12
14
  const require_annotation_menu = require("./annotation-menu.cjs");
13
15
  const require_link = require("./link.cjs");
16
+ const require_actions = require("./actions.cjs");
14
17
  const require_views = require("./views.cjs");
15
18
  const require_page_edit = require("./page-edit.cjs");
16
19
  const require_metadata = require("./metadata.cjs");
17
20
  const require_redaction = require("./redaction.cjs");
18
- const require_form = require("./form.cjs");
21
+ const require_form = require("./form-D-ZSfGmB.cjs");
19
22
  const require_search = require("./search.cjs");
20
23
  const require_stamp = require("./stamp.cjs");
21
24
  const require_i18n = require("./i18n.cjs");
@@ -58,16 +61,18 @@ exports.filePickerProvider = require_annotation.filePickerProvider;
58
61
  exports.isMacPlatform = require_commands.isMacPlatform;
59
62
  exports.makePageContext = require_runtime.makePageContext;
60
63
  exports.openLinkTarget = require_link.openLinkTarget;
61
- exports.sameAnchor = require_annotation.sameAnchor;
62
- exports.sameCreationDraftAnchor = require_annotation.sameCreationDraftAnchor;
64
+ exports.sameAnchor = require_annotation_anchors.sameAnchor;
65
+ exports.sameCreationDraftAnchor = require_annotation_anchors.sameCreationDraftAnchor;
63
66
  exports.shallowArray = require_runtime.shallowArray;
67
+ exports.useActionsUiAdapter = require_actions.useActionsUiAdapter;
64
68
  exports.useActiveDocumentId = require_runtime.useActiveDocumentId;
65
69
  exports.useAnnotation = require_annotation.useAnnotation;
66
70
  exports.useAnnotationDefaults = require_annotation.useAnnotationDefaults;
67
- exports.useAnnotationSelected = require_annotation.useAnnotationSelected;
71
+ exports.useAnnotationSelected = require_annotation_hooks.useAnnotationSelected;
68
72
  exports.useAnnotationSelection = require_annotation.useAnnotationSelection;
69
73
  exports.useArmStampAsset = require_stamp.useArmStampAsset;
70
74
  exports.useCapability = require_runtime.useCapability;
75
+ exports.useCapabilityEvent = require_runtime.useCapabilityEvent;
71
76
  exports.useCommand = require_commands.useCommand;
72
77
  exports.useCommandShortcuts = require_commands.useCommandShortcuts;
73
78
  exports.useCommands = require_commands.useCommands;
@@ -81,7 +86,6 @@ exports.useDocuments = require_runtime.useDocuments;
81
86
  exports.useFilePickerProvider = require_annotation.useFilePickerProvider;
82
87
  exports.useForm = require_form.useForm;
83
88
  exports.useFormField = require_form.useFormField;
84
- exports.useFormScriptingProvider = require_form.useFormScriptingProvider;
85
89
  exports.useI18n = require_i18n.useI18n;
86
90
  exports.useKernel = require_runtime.useKernel;
87
91
  exports.useKernelValue = require_runtime.useKernelValue;
@@ -150,21 +154,21 @@ Object.keys(_embedpdf_plugin_stage).forEach(function(k) {
150
154
  }
151
155
  });
152
156
  });
153
- var _embedpdf_plugin_interaction = require("@embedpdf/plugin-interaction");
154
- Object.keys(_embedpdf_plugin_interaction).forEach(function(k) {
157
+ var _embedpdf_plugin_render = require("@embedpdf/plugin-render");
158
+ Object.keys(_embedpdf_plugin_render).forEach(function(k) {
155
159
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
156
160
  enumerable: true,
157
161
  get: function() {
158
- return _embedpdf_plugin_interaction[k];
162
+ return _embedpdf_plugin_render[k];
159
163
  }
160
164
  });
161
165
  });
162
- var _embedpdf_plugin_render = require("@embedpdf/plugin-render");
163
- Object.keys(_embedpdf_plugin_render).forEach(function(k) {
166
+ var _embedpdf_plugin_interaction = require("@embedpdf/plugin-interaction");
167
+ Object.keys(_embedpdf_plugin_interaction).forEach(function(k) {
164
168
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
165
169
  enumerable: true,
166
170
  get: function() {
167
- return _embedpdf_plugin_render[k];
171
+ return _embedpdf_plugin_interaction[k];
168
172
  }
169
173
  });
170
174
  });
package/dist/index.d.cts CHANGED
@@ -1,9 +1,10 @@
1
+ import { ActionsUiHandlers, useActionsUiAdapter } from "./actions.cjs";
1
2
  import { AnchorTarget, Anchored, AnchoredPlacement, AnchoredProps, ProjectorBinding, ProjectorProvider, ViewProjector, useProjectorBinding } from "./anchored.cjs";
2
3
  import { AnnotationDraftMenu, AnnotationDraftMenuProps, AnnotationMenu, AnnotationMenuProps } from "./annotation-menu.cjs";
3
- import { C as useSelector, S as usePage, _ as useDocuments, a as EmbedPDF, b as useOptionalCapability, c as Viewer, d as runtime_d_exports, f as shallowArray, g as useDocumentStatus, h as useDocumentId, i as DocumentScopeProps, l as ViewerProps, m as useCapability, n as DocumentGateProps, o as PageContextValue, p as useActiveDocumentId, r as DocumentScope, s as PageProvider, t as DocumentGate, u as makePageContext, v as useKernel, x as useOptionalSelector, y as useKernelValue } from "./runtime-Cvi0wQ4d.cjs";
4
- import { AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationProps, AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, Border, CommentThreadView, CreationDraftAnchor, Geom, LineEnding, LineEndings, PropKey, PropSpec, RenderItem, SelectionAnchor, SelectionFlags, SelectionProps, Style, TextAlign, TextStyle, enrichCommentThreads, filePickerProvider, sameAnchor, sameCreationDraftAnchor, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useFilePickerProvider, useSelectionFlags, useSelectionProps } from "./annotation.cjs";
4
+ import { C as usePage, S as useOptionalSelector, _ as useDocumentStatus, a as EmbedPDF, b as useKernelValue, c as Viewer, d as runtime_d_exports, f as shallowArray, g as useDocumentId, h as useCapabilityEvent, i as DocumentScopeProps, l as ViewerProps, m as useCapability, n as DocumentGateProps, o as PageContextValue, p as useActiveDocumentId, r as DocumentScope, s as PageProvider, t as DocumentGate, u as makePageContext, v as useDocuments, w as useSelector, x as useOptionalCapability, y as useKernel } from "./runtime-umHA_xHt.cjs";
5
+ import { A as useCommentsHydration, C as filePickerProvider, D as useCommentThread, E as useAnnotationSelection, F as SelectionAnchor, I as sameAnchor, L as sameCreationDraftAnchor, M as useSelectionFlags, N as useSelectionProps, O as useCommentThreads, P as useAnnotationSelected, S as enrichCommentThreads, T as useAnnotationDefaults, _ as SelectionFlags, a as AnnotationPropsPatch, b as TextAlign, c as Border, d as Geom, f as LineEnding, g as RenderItem, h as PropSpec, i as AnnotationProps, j as useFilePickerProvider, k as useComments, l as CommentThreadView, m as PropKey, n as AnnotationLayer, o as AnnotationRenderer, p as LineEndings, r as AnnotationLayerProps, s as AnnotationRendererProps, t as AnnotationFlags, u as CreationDraftAnchor, v as SelectionProps, w as useAnnotation, x as TextStyle, y as Style } from "./annotation-BCED_p9H.cjs";
5
6
  import { isMacPlatform, useCommand, useCommandShortcuts, useCommands } from "./commands.cjs";
6
- import { FormLayer, FormScriptingUiHandlers, useForm, useFormField, useFormScriptingProvider } from "./form.cjs";
7
+ import { FormLayer, useForm, useFormField } from "./form.cjs";
7
8
  import { useI18n, useLocale, useT } from "./i18n.cjs";
8
9
  import { Stage, StageProps, StageTokenProp, useLayout, usePageList, usePages, useStage, useStageSettings, useZoom } from "./stage.cjs";
9
10
  import { Scrollbar, ScrollbarAxis, ScrollbarProps, useScrollMetrics } from "./scrollbar.cjs";
@@ -22,9 +23,9 @@ import { MenusHandle, SurfaceHandle, useMenus, useShell, useSurface } from "./sh
22
23
  import { CollapsedGroupView, CustomSlotCtx, GroupDisclosureView, OverflowMenuView, StripView, StripViewGroup, Toolbar, ToolbarProps, useStripView } from "./toolbar.cjs";
23
24
  export * from "@embedpdf/plugin-annotation";
24
25
  export * from "@embedpdf/core";
25
- export * from "@embedpdf/plugin-render";
26
26
  export * from "@embedpdf/plugin-commands";
27
27
  export * from "@embedpdf/plugin-stage";
28
+ export * from "@embedpdf/plugin-render";
28
29
  export * from "@embedpdf/plugin-interaction";
29
30
  export * from "@embedpdf/plugin-selection";
30
31
  export * from "@embedpdf/plugin-link";
@@ -36,8 +37,8 @@ export * from "@embedpdf/plugin-stamp";
36
37
  export * from "@embedpdf/plugin-shell";
37
38
  export * from "@embedpdf/core-ui";
38
39
  declare namespace index_d_exports {
39
- export { AnchorTarget, Anchored, AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, AnnotationProps, AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, Border, CollapsedGroupView, CommentThreadView, CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, FormScriptingUiHandlers, Geom, GroupDisclosureView, LineEnding, LineEndings, LinkLayer, LinkLayerProps, MenusHandle, OverflowMenuView, PageContextValue, PagePointerSource, PageProvider, PageView, PageViewProps, ProjectorBinding, ProjectorProvider, PropKey, PropSpec, RenderItem, RenderLayer, RenderLayerProps, Scrollbar, ScrollbarAxis, ScrollbarProps, SearchLayer, SelectionAnchor, SelectionClipboard, SelectionClipboardProps, SelectionFlags, SelectionHandles, SelectionHandlesProps, SelectionLayer, SelectionLayerProps, SelectionMenu, SelectionMenuProps, SelectionProps, Stage, StageProps, StageTokenProp, StripView, StripViewGroup, Style, SurfaceHandle, TextAlign, TextStyle, ToolCursorImage, ToolCursorSpec, Toolbar, ToolbarProps, UseViews, ViewProjector, Viewer, ViewerProps, copySelection, createClickCounter, enrichCommentThreads, filePickerProvider, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useFormScriptingProvider, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useProjectorBinding, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom, vibrationFeedback, wkFeedback };
40
+ export { ActionsUiHandlers, AnchorTarget, Anchored, AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, AnnotationProps, AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, Border, CollapsedGroupView, CommentThreadView, CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, Geom, GroupDisclosureView, LineEnding, LineEndings, LinkLayer, LinkLayerProps, MenusHandle, OverflowMenuView, PageContextValue, PagePointerSource, PageProvider, PageView, PageViewProps, ProjectorBinding, ProjectorProvider, PropKey, PropSpec, RenderItem, RenderLayer, RenderLayerProps, Scrollbar, ScrollbarAxis, ScrollbarProps, SearchLayer, SelectionAnchor, SelectionClipboard, SelectionClipboardProps, SelectionFlags, SelectionHandles, SelectionHandlesProps, SelectionLayer, SelectionLayerProps, SelectionMenu, SelectionMenuProps, SelectionProps, Stage, StageProps, StageTokenProp, StripView, StripViewGroup, Style, SurfaceHandle, TextAlign, TextStyle, ToolCursorImage, ToolCursorSpec, Toolbar, ToolbarProps, UseViews, ViewProjector, Viewer, ViewerProps, copySelection, createClickCounter, enrichCommentThreads, filePickerProvider, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActionsUiAdapter, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCapabilityEvent, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useProjectorBinding, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom, vibrationFeedback, wkFeedback };
40
41
  }
41
42
  //#endregion
42
- export { type AnchorTarget, Anchored, type AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, type AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, type AnnotationProps, type AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, type Border, CollapsedGroupView, CommentThreadView, type CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, type FormScriptingUiHandlers, type Geom, GroupDisclosureView, type LineEnding, type LineEndings, LinkLayer, LinkLayerProps, MenusHandle, OverflowMenuView, PageContextValue, PagePointerSource, PageProvider, PageView, PageViewProps, ProjectorBinding, ProjectorProvider, type PropKey, type PropSpec, type RenderItem, RenderLayer, RenderLayerProps, Scrollbar, ScrollbarAxis, ScrollbarProps, SearchLayer, SelectionAnchor, SelectionClipboard, SelectionClipboardProps, type SelectionFlags, SelectionHandles, SelectionHandlesProps, SelectionLayer, SelectionLayerProps, SelectionMenu, SelectionMenuProps, type SelectionProps, Stage, StageProps, StageTokenProp, StripView, StripViewGroup, type Style, SurfaceHandle, type TextAlign, type TextStyle, ToolCursorImage, ToolCursorSpec, Toolbar, ToolbarProps, UseViews, type ViewProjector, Viewer, ViewerProps, copySelection, createClickCounter, enrichCommentThreads, filePickerProvider, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useFormScriptingProvider, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useProjectorBinding, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom, vibrationFeedback, wkFeedback };
43
+ export { type ActionsUiHandlers, type AnchorTarget, Anchored, type AnchoredPlacement, AnchoredProps, AnnotationDraftMenu, AnnotationDraftMenuProps, type AnnotationFlags, AnnotationLayer, AnnotationLayerProps, AnnotationMenu, AnnotationMenuProps, type AnnotationProps, type AnnotationPropsPatch, AnnotationRenderer, AnnotationRendererProps, type Border, CollapsedGroupView, CommentThreadView, type CreationDraftAnchor, CustomSlotCtx, DocumentGate, DocumentGateProps, DocumentScope, DocumentScopeProps, EmbedPDF, FormLayer, type Geom, GroupDisclosureView, type LineEnding, type LineEndings, LinkLayer, LinkLayerProps, MenusHandle, OverflowMenuView, PageContextValue, PagePointerSource, PageProvider, PageView, PageViewProps, ProjectorBinding, ProjectorProvider, type PropKey, type PropSpec, type RenderItem, RenderLayer, RenderLayerProps, Scrollbar, ScrollbarAxis, ScrollbarProps, SearchLayer, type SelectionAnchor, SelectionClipboard, SelectionClipboardProps, type SelectionFlags, SelectionHandles, SelectionHandlesProps, SelectionLayer, SelectionLayerProps, SelectionMenu, SelectionMenuProps, type SelectionProps, Stage, StageProps, StageTokenProp, StripView, StripViewGroup, type Style, SurfaceHandle, type TextAlign, type TextStyle, ToolCursorImage, ToolCursorSpec, Toolbar, ToolbarProps, UseViews, type ViewProjector, Viewer, ViewerProps, copySelection, createClickCounter, enrichCommentThreads, filePickerProvider, isMacPlatform, makePageContext, openLinkTarget, sameAnchor, sameCreationDraftAnchor, shallowArray, useActionsUiAdapter, useActiveDocumentId, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useArmStampAsset, useCapability, useCapabilityEvent, useCommand, useCommandShortcuts, useCommands, useCommentThread, useCommentThreads, useComments, useCommentsHydration, useDocumentId, useDocumentStatus, useDocuments, useFilePickerProvider, useForm, useFormField, useI18n, useKernel, useKernelValue, useLayout, useLink, useLocale, useMenus, useMetadata, useOptionalCapability, useOptionalSelector, usePage, usePageEditor, usePageList, usePages, usePendingRedactions, useProjectorBinding, useRedaction, useScrollMetrics, useSearch, useSearchState, useSelection, useSelectionFlags, useSelectionProps, useSelector, useShell, useStage, useStageSettings, useStamp, useStampAssetPreviewUrl, useStampAssets, useStampLibraries, useStripView, useSurface, useT, useTool, useToolCursor, useViews, useZoom, vibrationFeedback, wkFeedback };
43
44
  //# sourceMappingURL=index.d.cts.map