@embedpdf/react 3.0.0-next.1 → 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 (132) hide show
  1. package/dist/AnnotationListSnapshot-C1U3XUxP-6kGwNoxy.d.cts +546 -0
  2. package/dist/AnnotationListSnapshot-C1U3XUxP-6kGwNoxy.d.ts +546 -0
  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/anchored.cjs +89 -0
  10. package/dist/anchored.cjs.map +1 -0
  11. package/dist/anchored.d.cts +45 -0
  12. package/dist/anchored.d.ts +45 -0
  13. package/dist/anchored.js +60 -0
  14. package/dist/anchored.js.map +1 -0
  15. package/dist/{annotation-B6jwfTCh.d.cts → annotation-BCED_p9H.d.cts} +56 -69
  16. package/dist/annotation-anchors-CetwM1g7.js +15 -0
  17. package/dist/annotation-anchors-CetwM1g7.js.map +1 -0
  18. package/dist/annotation-anchors-DuYRBJLl.cjs +26 -0
  19. package/dist/annotation-anchors-DuYRBJLl.cjs.map +1 -0
  20. package/dist/annotation-hooks-BB5ZhPpf.cjs +16 -0
  21. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +1 -0
  22. package/dist/annotation-hooks-Df8EmzDO.js +11 -0
  23. package/dist/annotation-hooks-Df8EmzDO.js.map +1 -0
  24. package/dist/{annotation-nUMefyjw.d.ts → annotation-k38KDlIZ.d.ts} +57 -70
  25. package/dist/annotation-menu.cjs +37 -88
  26. package/dist/annotation-menu.cjs.map +1 -1
  27. package/dist/annotation-menu.d.cts +28 -2
  28. package/dist/annotation-menu.d.ts +28 -2
  29. package/dist/annotation-menu.js +28 -79
  30. package/dist/annotation-menu.js.map +1 -1
  31. package/dist/annotation.cjs +738 -16
  32. package/dist/annotation.cjs.map +1 -0
  33. package/dist/annotation.d.cts +2 -2
  34. package/dist/annotation.d.ts +2 -2
  35. package/dist/annotation.js +723 -3
  36. package/dist/annotation.js.map +1 -0
  37. package/dist/commands.js +1 -0
  38. package/dist/commands.js.map +1 -1
  39. package/dist/form-BwrLFpKN.js +805 -0
  40. package/dist/form-BwrLFpKN.js.map +1 -0
  41. package/dist/form-D-ZSfGmB.cjs +836 -0
  42. package/dist/form-D-ZSfGmB.cjs.map +1 -0
  43. package/dist/form.cjs +8 -551
  44. package/dist/form.d.cts +4 -21
  45. package/dist/form.d.ts +4 -21
  46. package/dist/form.js +3 -544
  47. package/dist/index.cjs +49 -16
  48. package/dist/index.d.cts +17 -10
  49. package/dist/index.d.ts +17 -10
  50. package/dist/index.js +14 -9
  51. package/dist/interaction.cjs +17 -4
  52. package/dist/interaction.cjs.map +1 -1
  53. package/dist/interaction.d.cts +2 -2
  54. package/dist/interaction.d.ts +2 -2
  55. package/dist/interaction.js +7 -5
  56. package/dist/interaction.js.map +1 -1
  57. package/dist/link.cjs +70 -7
  58. package/dist/link.cjs.map +1 -1
  59. package/dist/link.d.cts +12 -3
  60. package/dist/link.d.ts +12 -3
  61. package/dist/link.js +73 -10
  62. package/dist/link.js.map +1 -1
  63. package/dist/metadata.js +1 -0
  64. package/dist/metadata.js.map +1 -1
  65. package/dist/page-edit.js +1 -0
  66. package/dist/page-edit.js.map +1 -1
  67. package/dist/page-view.cjs +62 -38
  68. package/dist/page-view.cjs.map +1 -1
  69. package/dist/page-view.js +59 -37
  70. package/dist/page-view.js.map +1 -1
  71. package/dist/redaction.js +1 -0
  72. package/dist/redaction.js.map +1 -1
  73. package/dist/render.cjs +67 -50
  74. package/dist/render.cjs.map +1 -1
  75. package/dist/render.d.cts +6 -19
  76. package/dist/render.d.ts +6 -19
  77. package/dist/render.js +71 -52
  78. package/dist/render.js.map +1 -1
  79. package/dist/rolldown-runtime-BBjsoOtd.js +27 -0
  80. package/dist/{runtime-CMxIuF2O.d.cts → runtime-DE76hlnl.d.ts} +32 -11
  81. package/dist/{runtime-DV98q7I0.d.ts → runtime-umHA_xHt.d.cts} +32 -11
  82. package/dist/runtime.cjs +25 -5
  83. package/dist/runtime.cjs.map +1 -1
  84. package/dist/runtime.d.cts +2 -2
  85. package/dist/runtime.d.ts +2 -2
  86. package/dist/runtime.js +26 -6
  87. package/dist/runtime.js.map +1 -1
  88. package/dist/scrollbar.cjs +3 -3
  89. package/dist/scrollbar.cjs.map +1 -1
  90. package/dist/scrollbar.d.cts +1 -1
  91. package/dist/scrollbar.d.ts +1 -1
  92. package/dist/scrollbar.js +1 -1
  93. package/dist/scrollbar.js.map +1 -1
  94. package/dist/search.cjs +36 -19
  95. package/dist/search.cjs.map +1 -1
  96. package/dist/search.d.cts +1 -1
  97. package/dist/search.d.ts +1 -1
  98. package/dist/search.js +36 -19
  99. package/dist/search.js.map +1 -1
  100. package/dist/selection.cjs +217 -22
  101. package/dist/selection.cjs.map +1 -1
  102. package/dist/selection.d.cts +60 -2
  103. package/dist/selection.d.ts +60 -2
  104. package/dist/selection.js +214 -27
  105. package/dist/selection.js.map +1 -1
  106. package/dist/shell.js +1 -0
  107. package/dist/shell.js.map +1 -1
  108. package/dist/stage.cjs +49 -148
  109. package/dist/stage.cjs.map +1 -1
  110. package/dist/stage.d.cts +18 -5
  111. package/dist/stage.d.ts +18 -5
  112. package/dist/stage.js +51 -149
  113. package/dist/stage.js.map +1 -1
  114. package/dist/stamp.js +1 -0
  115. package/dist/stamp.js.map +1 -1
  116. package/dist/toolbar.cjs +4 -4
  117. package/dist/toolbar.cjs.map +1 -1
  118. package/dist/toolbar.d.cts +1 -1
  119. package/dist/toolbar.d.ts +1 -1
  120. package/dist/toolbar.js +2 -1
  121. package/dist/toolbar.js.map +1 -1
  122. package/dist/views.js +1 -0
  123. package/dist/views.js.map +1 -1
  124. package/package.json +33 -26
  125. package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.cts +0 -2593
  126. package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.ts +0 -2593
  127. package/dist/annotation-Ct6dFtzJ.cjs +0 -913
  128. package/dist/annotation-Ct6dFtzJ.cjs.map +0 -1
  129. package/dist/annotation-DjGWJljY.js +0 -829
  130. package/dist/annotation-DjGWJljY.js.map +0 -1
  131. package/dist/form.cjs.map +0 -1
  132. 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 { l as useAnnotationSelected } from "./annotation-DjGWJljY.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.pageToContent({
13
- x: r.x,
14
- y: r.y
15
- });
16
- const br = page.transform.pageToContent({
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
@@ -1,26 +1,32 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("./rolldown-runtime-DDXJien1.cjs");
3
3
  const require_runtime = require("./runtime.cjs");
4
- const require_interaction = require("./interaction.cjs");
4
+ const require_anchored = require("./anchored.cjs");
5
5
  const require_stage = require("./stage.cjs");
6
6
  const require_scrollbar = require("./scrollbar.cjs");
7
7
  const require_page_view = require("./page-view.cjs");
8
8
  const require_render = require("./render.cjs");
9
+ const require_interaction = require("./interaction.cjs");
9
10
  const require_selection = require("./selection.cjs");
10
- const require_annotation = require("./annotation-Ct6dFtzJ.cjs");
11
+ const require_annotation_anchors = require("./annotation-anchors-DuYRBJLl.cjs");
12
+ const require_annotation_hooks = require("./annotation-hooks-BB5ZhPpf.cjs");
13
+ const require_annotation = require("./annotation.cjs");
11
14
  const require_annotation_menu = require("./annotation-menu.cjs");
12
15
  const require_link = require("./link.cjs");
16
+ const require_actions = require("./actions.cjs");
13
17
  const require_views = require("./views.cjs");
14
18
  const require_page_edit = require("./page-edit.cjs");
15
19
  const require_metadata = require("./metadata.cjs");
16
20
  const require_redaction = require("./redaction.cjs");
17
- const require_form = require("./form.cjs");
21
+ const require_form = require("./form-D-ZSfGmB.cjs");
18
22
  const require_search = require("./search.cjs");
19
23
  const require_stamp = require("./stamp.cjs");
20
24
  const require_i18n = require("./i18n.cjs");
21
25
  const require_commands = require("./commands.cjs");
22
26
  const require_shell = require("./shell.cjs");
23
27
  const require_toolbar = require("./toolbar.cjs");
28
+ let _embedpdf_web = require("@embedpdf/web");
29
+ exports.Anchored = require_anchored.Anchored;
24
30
  exports.AnnotationDraftMenu = require_annotation_menu.AnnotationDraftMenu;
25
31
  exports.AnnotationLayer = require_annotation.AnnotationLayer;
26
32
  exports.AnnotationMenu = require_annotation_menu.AnnotationMenu;
@@ -29,43 +35,57 @@ exports.DocumentScope = require_runtime.DocumentScope;
29
35
  exports.EmbedPDF = require_runtime.EmbedPDF;
30
36
  exports.FormLayer = require_form.FormLayer;
31
37
  exports.LinkLayer = require_link.LinkLayer;
32
- exports.PageAnnotationDraftMenu = require_annotation.PageAnnotationDraftMenu;
33
- exports.PageAnnotationMenu = require_annotation.PageAnnotationMenu;
34
38
  exports.PagePointerSource = require_interaction.PagePointerSource;
35
39
  exports.PageProvider = require_runtime.PageProvider;
36
40
  exports.PageView = require_page_view.PageView;
41
+ exports.ProjectorProvider = require_anchored.ProjectorProvider;
37
42
  exports.RenderLayer = require_render.RenderLayer;
38
43
  exports.Scrollbar = require_scrollbar.Scrollbar;
39
44
  exports.SearchLayer = require_search.SearchLayer;
45
+ exports.SelectionClipboard = require_selection.SelectionClipboard;
46
+ exports.SelectionHandles = require_selection.SelectionHandles;
40
47
  exports.SelectionLayer = require_selection.SelectionLayer;
48
+ exports.SelectionMenu = require_selection.SelectionMenu;
41
49
  exports.Stage = require_stage.Stage;
42
- exports.TileLayer = require_render.TileLayer;
43
50
  exports.Toolbar = require_toolbar.Toolbar;
44
51
  exports.Viewer = require_runtime.Viewer;
52
+ Object.defineProperty(exports, "copySelection", {
53
+ enumerable: true,
54
+ get: function() {
55
+ return _embedpdf_web.copySelection;
56
+ }
57
+ });
45
58
  exports.createClickCounter = require_interaction.createClickCounter;
59
+ exports.enrichCommentThreads = require_annotation.enrichCommentThreads;
46
60
  exports.filePickerProvider = require_annotation.filePickerProvider;
47
61
  exports.isMacPlatform = require_commands.isMacPlatform;
48
62
  exports.makePageContext = require_runtime.makePageContext;
49
- exports.sameAnchor = require_annotation.sameAnchor;
50
- exports.sameCreationDraftAnchor = require_annotation.sameCreationDraftAnchor;
63
+ exports.openLinkTarget = require_link.openLinkTarget;
64
+ exports.sameAnchor = require_annotation_anchors.sameAnchor;
65
+ exports.sameCreationDraftAnchor = require_annotation_anchors.sameCreationDraftAnchor;
51
66
  exports.shallowArray = require_runtime.shallowArray;
67
+ exports.useActionsUiAdapter = require_actions.useActionsUiAdapter;
52
68
  exports.useActiveDocumentId = require_runtime.useActiveDocumentId;
53
69
  exports.useAnnotation = require_annotation.useAnnotation;
54
70
  exports.useAnnotationDefaults = require_annotation.useAnnotationDefaults;
55
- exports.useAnnotationSelected = require_annotation.useAnnotationSelected;
71
+ exports.useAnnotationSelected = require_annotation_hooks.useAnnotationSelected;
56
72
  exports.useAnnotationSelection = require_annotation.useAnnotationSelection;
57
73
  exports.useArmStampAsset = require_stamp.useArmStampAsset;
58
74
  exports.useCapability = require_runtime.useCapability;
75
+ exports.useCapabilityEvent = require_runtime.useCapabilityEvent;
59
76
  exports.useCommand = require_commands.useCommand;
60
77
  exports.useCommandShortcuts = require_commands.useCommandShortcuts;
61
78
  exports.useCommands = require_commands.useCommands;
79
+ exports.useCommentThread = require_annotation.useCommentThread;
80
+ exports.useCommentThreads = require_annotation.useCommentThreads;
81
+ exports.useComments = require_annotation.useComments;
82
+ exports.useCommentsHydration = require_annotation.useCommentsHydration;
62
83
  exports.useDocumentId = require_runtime.useDocumentId;
63
84
  exports.useDocumentStatus = require_runtime.useDocumentStatus;
64
85
  exports.useDocuments = require_runtime.useDocuments;
65
86
  exports.useFilePickerProvider = require_annotation.useFilePickerProvider;
66
87
  exports.useForm = require_form.useForm;
67
88
  exports.useFormField = require_form.useFormField;
68
- exports.useFormScriptingProvider = require_form.useFormScriptingProvider;
69
89
  exports.useI18n = require_i18n.useI18n;
70
90
  exports.useKernel = require_runtime.useKernel;
71
91
  exports.useKernelValue = require_runtime.useKernelValue;
@@ -81,6 +101,7 @@ exports.usePageEditor = require_page_edit.usePageEditor;
81
101
  exports.usePageList = require_stage.usePageList;
82
102
  exports.usePages = require_stage.usePages;
83
103
  exports.usePendingRedactions = require_redaction.usePendingRedactions;
104
+ exports.useProjectorBinding = require_anchored.useProjectorBinding;
84
105
  exports.useRedaction = require_redaction.useRedaction;
85
106
  exports.useScrollMetrics = require_scrollbar.useScrollMetrics;
86
107
  exports.useSearch = require_search.useSearch;
@@ -103,6 +124,18 @@ exports.useTool = require_interaction.useTool;
103
124
  exports.useToolCursor = require_interaction.useToolCursor;
104
125
  exports.useViews = require_views.useViews;
105
126
  exports.useZoom = require_stage.useZoom;
127
+ Object.defineProperty(exports, "vibrationFeedback", {
128
+ enumerable: true,
129
+ get: function() {
130
+ return _embedpdf_web.vibrationFeedback;
131
+ }
132
+ });
133
+ Object.defineProperty(exports, "wkFeedback", {
134
+ enumerable: true,
135
+ get: function() {
136
+ return _embedpdf_web.wkFeedback;
137
+ }
138
+ });
106
139
  var _embedpdf_core = require("@embedpdf/core");
107
140
  Object.keys(_embedpdf_core).forEach(function(k) {
108
141
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
@@ -121,21 +154,21 @@ Object.keys(_embedpdf_plugin_stage).forEach(function(k) {
121
154
  }
122
155
  });
123
156
  });
124
- var _embedpdf_plugin_interaction = require("@embedpdf/plugin-interaction");
125
- 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) {
126
159
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
127
160
  enumerable: true,
128
161
  get: function() {
129
- return _embedpdf_plugin_interaction[k];
162
+ return _embedpdf_plugin_render[k];
130
163
  }
131
164
  });
132
165
  });
133
- var _embedpdf_plugin_render = require("@embedpdf/plugin-render");
134
- 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) {
135
168
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
136
169
  enumerable: true,
137
170
  get: function() {
138
- return _embedpdf_plugin_render[k];
171
+ return _embedpdf_plugin_interaction[k];
139
172
  }
140
173
  });
141
174
  });