@embedpdf/react 3.0.0-next.14 → 3.0.0-next.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AnnotationList-DcyhF2kU-CiBFOq1z.d.cts +878 -0
- package/dist/AnnotationList-DcyhF2kU-CiBFOq1z.d.ts +878 -0
- package/dist/actions.cjs +25 -5
- package/dist/actions.cjs.map +1 -1
- package/dist/actions.d.cts +18 -5
- package/dist/actions.d.ts +18 -5
- package/dist/actions.js +22 -6
- package/dist/actions.js.map +1 -1
- package/dist/anchored-DeX95xSd.d.ts +85 -0
- package/dist/anchored-DzN3JywS.d.cts +85 -0
- package/dist/anchored.cjs +71 -28
- package/dist/anchored.cjs.map +1 -1
- package/dist/anchored.d.cts +2 -45
- package/dist/anchored.d.ts +2 -45
- package/dist/anchored.js +56 -19
- package/dist/anchored.js.map +1 -1
- package/dist/annotation-3UvABfJm.d.cts +305 -0
- package/dist/annotation-BNHQpMKv.cjs +806 -0
- package/dist/annotation-BNHQpMKv.cjs.map +1 -0
- package/dist/annotation-CDI8CFb3.js +684 -0
- package/dist/annotation-CDI8CFb3.js.map +1 -0
- package/dist/annotation-DhEfs0pH.d.ts +305 -0
- package/dist/annotation.cjs +20 -784
- package/dist/annotation.d.cts +2 -2
- package/dist/annotation.d.ts +2 -2
- package/dist/annotation.js +2 -769
- package/dist/attachment.cjs +39 -0
- package/dist/attachment.cjs.map +1 -0
- package/dist/attachment.d.cts +29 -0
- package/dist/attachment.d.ts +29 -0
- package/dist/attachment.js +28 -0
- package/dist/attachment.js.map +1 -0
- package/dist/commands.cjs +68 -28
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +37 -10
- package/dist/commands.d.ts +37 -10
- package/dist/commands.js +68 -31
- package/dist/commands.js.map +1 -1
- package/dist/form-BSGvjA5D.js +511 -0
- package/dist/form-BSGvjA5D.js.map +1 -0
- package/dist/form-BgztZyOK.cjs +548 -0
- package/dist/form-BgztZyOK.cjs.map +1 -0
- package/dist/form.cjs +5 -5
- package/dist/form.d.cts +41 -2
- package/dist/form.d.ts +41 -2
- package/dist/form.js +2 -3
- package/dist/history.cjs +38 -0
- package/dist/history.cjs.map +1 -0
- package/dist/history.d.cts +27 -0
- package/dist/history.d.ts +27 -0
- package/dist/history.js +27 -0
- package/dist/history.js.map +1 -0
- package/dist/i18n.cjs +26 -30
- package/dist/i18n.cjs.map +1 -1
- package/dist/i18n.d.cts +24 -21
- package/dist/i18n.d.ts +24 -21
- package/dist/i18n.js +24 -31
- package/dist/i18n.js.map +1 -1
- package/dist/index.cjs +227 -57
- package/dist/index.d.cts +35 -32
- package/dist/index.d.ts +35 -32
- package/dist/index.js +36 -30
- package/dist/inert-CmBEbKCn.cjs +19 -0
- package/dist/inert-CmBEbKCn.cjs.map +1 -0
- package/dist/inert-D8fkennb.js +14 -0
- package/dist/inert-D8fkennb.js.map +1 -0
- package/dist/interaction.cjs +48 -102
- package/dist/interaction.cjs.map +1 -1
- package/dist/interaction.d.cts +23 -32
- package/dist/interaction.d.ts +23 -32
- package/dist/interaction.js +33 -102
- package/dist/interaction.js.map +1 -1
- package/dist/link.cjs +65 -104
- package/dist/link.cjs.map +1 -1
- package/dist/link.d.cts +21 -16
- package/dist/link.d.ts +22 -17
- package/dist/link.js +67 -107
- package/dist/link.js.map +1 -1
- package/dist/measurement.cjs +36 -11
- package/dist/measurement.cjs.map +1 -1
- package/dist/measurement.d.cts +33 -7
- package/dist/measurement.d.ts +33 -7
- package/dist/measurement.js +35 -14
- package/dist/measurement.js.map +1 -1
- package/dist/metadata.cjs +20 -7
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +22 -7
- package/dist/metadata.d.ts +22 -7
- package/dist/metadata.js +20 -10
- package/dist/metadata.js.map +1 -1
- package/dist/outline.cjs +39 -0
- package/dist/outline.cjs.map +1 -0
- package/dist/outline.d.cts +31 -0
- package/dist/outline.d.ts +31 -0
- package/dist/outline.js +28 -0
- package/dist/outline.js.map +1 -0
- package/dist/page-edit.cjs +15 -3
- package/dist/page-edit.cjs.map +1 -1
- package/dist/page-edit.d.cts +17 -2
- package/dist/page-edit.d.ts +17 -2
- package/dist/page-edit.js +15 -5
- package/dist/page-edit.js.map +1 -1
- package/dist/page-layers-Bkaaz8Zf.js +26 -0
- package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
- package/dist/page-layers-BloZDoOV.cjs +37 -0
- package/dist/page-layers-BloZDoOV.cjs.map +1 -0
- package/dist/page-view.cjs +89 -82
- package/dist/page-view.cjs.map +1 -1
- package/dist/page-view.d.cts +14 -7
- package/dist/page-view.d.ts +18 -11
- package/dist/page-view.js +86 -81
- package/dist/page-view.js.map +1 -1
- package/dist/redaction.cjs +30 -15
- package/dist/redaction.cjs.map +1 -1
- package/dist/redaction.d.cts +27 -9
- package/dist/redaction.d.ts +27 -9
- package/dist/redaction.js +29 -18
- package/dist/redaction.js.map +1 -1
- package/dist/render.cjs +71 -46
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +17 -5
- package/dist/render.d.ts +17 -5
- package/dist/render.js +70 -49
- package/dist/render.js.map +1 -1
- package/dist/runtime-BfnpyfY0.cjs +556 -0
- package/dist/runtime-BfnpyfY0.cjs.map +1 -0
- package/dist/runtime-DBEBlpQV.d.cts +237 -0
- package/dist/runtime-V3MVMb91.d.ts +237 -0
- package/dist/runtime-tD5iJU83.js +399 -0
- package/dist/runtime-tD5iJU83.js.map +1 -0
- package/dist/runtime.cjs +45 -324
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +2 -306
- package/dist/search.cjs +81 -50
- package/dist/search.cjs.map +1 -1
- package/dist/search.d.cts +37 -24
- package/dist/search.d.ts +37 -24
- package/dist/search.js +81 -53
- package/dist/search.js.map +1 -1
- package/dist/selection.cjs +105 -108
- package/dist/selection.cjs.map +1 -1
- package/dist/selection.d.cts +54 -26
- package/dist/selection.d.ts +56 -28
- package/dist/selection.js +103 -110
- package/dist/selection.js.map +1 -1
- package/dist/shell.cjs +36 -21
- package/dist/shell.cjs.map +1 -1
- package/dist/shell.d.cts +32 -17
- package/dist/shell.d.ts +32 -17
- package/dist/shell.js +36 -24
- package/dist/shell.js.map +1 -1
- package/dist/signature.cjs +29 -48
- package/dist/signature.cjs.map +1 -1
- package/dist/signature.d.cts +26 -26
- package/dist/signature.d.ts +26 -26
- package/dist/signature.js +30 -48
- package/dist/signature.js.map +1 -1
- package/dist/stage-B7BG2e8Q.cjs +369 -0
- package/dist/stage-B7BG2e8Q.cjs.map +1 -0
- package/dist/stage-BqfBjDu6.js +302 -0
- package/dist/stage-BqfBjDu6.js.map +1 -0
- package/dist/stage-ByFPD-Fv.d.cts +117 -0
- package/dist/stage-DaboaheR.d.ts +117 -0
- package/dist/stage-scope-CQgCuf1w.cjs +46 -0
- package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
- package/dist/stage-scope-D7ZeNduT.js +23 -0
- package/dist/stage-scope-D7ZeNduT.js.map +1 -0
- package/dist/stage.cjs +12 -235
- package/dist/stage.d.cts +2 -116
- package/dist/stage.d.ts +2 -116
- package/dist/stage.js +3 -228
- package/dist/stamp.cjs +41 -35
- package/dist/stamp.cjs.map +1 -1
- package/dist/stamp.d.cts +25 -18
- package/dist/stamp.d.ts +25 -18
- package/dist/stamp.js +40 -37
- package/dist/stamp.js.map +1 -1
- package/dist/state-0K1I5cM4.d.cts +29 -0
- package/dist/state-0K1I5cM4.d.ts +29 -0
- package/dist/state-CzI2KlZb.js +62 -0
- package/dist/state-CzI2KlZb.js.map +1 -0
- package/dist/state-Dtf8HAue.cjs +73 -0
- package/dist/state-Dtf8HAue.cjs.map +1 -0
- package/dist/svg-shapes-Dm1yTR1b.js +40 -0
- package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
- package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
- package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
- package/dist/toolbar.cjs +297 -295
- package/dist/toolbar.cjs.map +1 -1
- package/dist/toolbar.d.cts +58 -68
- package/dist/toolbar.d.ts +67 -77
- package/dist/toolbar.js +271 -293
- package/dist/toolbar.js.map +1 -1
- package/dist/view-manager.cjs +34 -0
- package/dist/view-manager.cjs.map +1 -0
- package/dist/view-manager.d.cts +21 -0
- package/dist/view-manager.d.ts +21 -0
- package/dist/view-manager.js +23 -0
- package/dist/view-manager.js.map +1 -0
- package/package.json +47 -39
- package/dist/annotation-BCED_p9H.d.cts +0 -160
- package/dist/annotation-anchors-CetwM1g7.js +0 -15
- package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
- package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
- package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
- package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
- package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
- package/dist/annotation-hooks-Df8EmzDO.js +0 -11
- package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
- package/dist/annotation-k38KDlIZ.d.ts +0 -160
- package/dist/annotation-menu.cjs +0 -64
- package/dist/annotation-menu.cjs.map +0 -1
- package/dist/annotation-menu.d.cts +0 -33
- package/dist/annotation-menu.d.ts +0 -33
- package/dist/annotation-menu.js +0 -48
- package/dist/annotation-menu.js.map +0 -1
- package/dist/annotation.cjs.map +0 -1
- package/dist/annotation.js.map +0 -1
- package/dist/form-BVumS7up.cjs +0 -926
- package/dist/form-BVumS7up.cjs.map +0 -1
- package/dist/form-Bdjk0Z3T.d.cts +0 -537
- package/dist/form-CK3mp99m.js +0 -895
- package/dist/form-CK3mp99m.js.map +0 -1
- package/dist/form-CYRYgthn.d.ts +0 -537
- package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
- package/dist/runtime-DE76hlnl.d.ts +0 -216
- package/dist/runtime-umHA_xHt.d.cts +0 -216
- package/dist/runtime.cjs.map +0 -1
- package/dist/runtime.js.map +0 -1
- package/dist/scrollbar.cjs +0 -241
- package/dist/scrollbar.cjs.map +0 -1
- package/dist/scrollbar.d.cts +0 -42
- package/dist/scrollbar.d.ts +0 -42
- package/dist/scrollbar.js +0 -213
- package/dist/scrollbar.js.map +0 -1
- package/dist/stage.cjs.map +0 -1
- package/dist/stage.js.map +0 -1
- package/dist/views.cjs +0 -35
- package/dist/views.cjs.map +0 -1
- package/dist/views.d.cts +0 -21
- package/dist/views.d.ts +0 -21
- package/dist/views.js +0 -27
- package/dist/views.js.map +0 -1
package/dist/shell.d.ts
CHANGED
|
@@ -1,27 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as StateHook } from "./state-0K1I5cM4.js";
|
|
2
|
+
import { EventHook } from "@embedpdf/core";
|
|
3
|
+
import { SurfaceFocusOptions } from "@embedpdf/web";
|
|
4
|
+
import { RefObject } from "react";
|
|
5
|
+
import { OpenSurfaceOptions, ShellCapability, SurfaceProps } from "@embedpdf/plugin-shell";
|
|
2
6
|
export * from "@embedpdf/plugin-shell";
|
|
3
7
|
//#region src/shell.d.ts
|
|
4
|
-
/** The
|
|
8
|
+
/** The shell capability: open and close panels, dialogs and menus. Without a document its methods throw `not-ready`. */
|
|
5
9
|
declare function useShell(): ShellCapability;
|
|
10
|
+
/** Subscribe to one shell event for the mounted lifetime: `useShellEvent((shell) => shell.onSurfaceOpened, handler)`. */
|
|
11
|
+
declare function useShellEvent<T>(select: (shell: ShellCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
12
|
+
/**
|
|
13
|
+
* Which panels, dialogs and menus are open (the page's State table, declared
|
|
14
|
+
* once in `shellState`). Takes a selector, and re-renders only when what it
|
|
15
|
+
* returns changes. Without a document nothing is open.
|
|
16
|
+
*/
|
|
17
|
+
declare const useShellState: StateHook<{
|
|
18
|
+
openSurfaces: readonly import("@embedpdf/plugin-shell").SurfaceState[];
|
|
19
|
+
openMenus: readonly string[];
|
|
20
|
+
}>;
|
|
6
21
|
interface SurfaceHandle {
|
|
7
22
|
readonly isOpen: boolean;
|
|
8
|
-
|
|
9
|
-
|
|
23
|
+
/** The props the surface was opened with, or updated to; empty when it has none. */
|
|
24
|
+
readonly props: SurfaceProps;
|
|
25
|
+
open(options?: OpenSurfaceOptions): void;
|
|
10
26
|
close(): void;
|
|
11
|
-
toggle(
|
|
27
|
+
toggle(options?: OpenSurfaceOptions): void;
|
|
12
28
|
}
|
|
13
|
-
/** One named surface (panel
|
|
14
|
-
* document. Reads as closed — and intents no-op — while no document is open. */
|
|
29
|
+
/** One named surface (panel, dialog, overlay) of this subtree's document. Reads as closed, and its verbs do nothing, while no document is open. */
|
|
15
30
|
declare function useSurface(id: string): SurfaceHandle;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
declare function
|
|
31
|
+
/**
|
|
32
|
+
* Put the cursor in `ref`'s element when the surface `id` asks for it: on every
|
|
33
|
+
* `open(id, { focus: true })`, a command whose panel says `focus` among them, and
|
|
34
|
+
* when the element mounts while the request is up (the panel opened, or its code
|
|
35
|
+
* loaded, because of it). A plain open never moves it. `select` selects an input's
|
|
36
|
+
* text, so typing replaces it. Reads the surface of this subtree's document; use
|
|
37
|
+
* it in the component that renders the element.
|
|
38
|
+
*/
|
|
39
|
+
declare function useSurfaceFocus(id: string, ref: RefObject<HTMLElement | null>, options?: SurfaceFocusOptions): void;
|
|
25
40
|
//#endregion
|
|
26
|
-
export {
|
|
41
|
+
export { type SurfaceFocusOptions, SurfaceHandle, useShell, useShellEvent, useShellState, useSurface, useSurfaceFocus };
|
|
27
42
|
//# sourceMappingURL=shell.d.ts.map
|
package/dist/shell.js
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { C as useOptionalSelector, S as useOptionalCapability, f as useCapability, p as useCapabilityEvent } from "./runtime-tD5iJU83.js";
|
|
2
|
+
import { n as stateHook } from "./state-CzI2KlZb.js";
|
|
3
|
+
import { createSurfaceFocusFollower } from "@embedpdf/web";
|
|
4
|
+
import { useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { ShellToken, shellState } from "@embedpdf/plugin-shell";
|
|
5
6
|
export * from "@embedpdf/plugin-shell";
|
|
6
7
|
//#region src/shell.ts
|
|
7
|
-
/** The
|
|
8
|
+
/** The shell capability: open and close panels, dialogs and menus. Without a document its methods throw `not-ready`. */
|
|
8
9
|
function useShell() {
|
|
9
10
|
return useCapability(ShellToken);
|
|
10
11
|
}
|
|
11
|
-
/**
|
|
12
|
-
|
|
12
|
+
/** Subscribe to one shell event for the mounted lifetime: `useShellEvent((shell) => shell.onSurfaceOpened, handler)`. */
|
|
13
|
+
function useShellEvent(select, handler) {
|
|
14
|
+
useCapabilityEvent(ShellToken, select, handler);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Which panels, dialogs and menus are open (the page's State table, declared
|
|
18
|
+
* once in `shellState`). Takes a selector, and re-renders only when what it
|
|
19
|
+
* returns changes. Without a document nothing is open.
|
|
20
|
+
*/
|
|
21
|
+
const useShellState = stateHook(shellState);
|
|
22
|
+
const NO_PROPS = Object.freeze({});
|
|
23
|
+
/** One named surface (panel, dialog, overlay) of this subtree's document. Reads as closed, and its verbs do nothing, while no document is open. */
|
|
13
24
|
function useSurface(id) {
|
|
14
25
|
const shell = useOptionalCapability(ShellToken);
|
|
15
|
-
const isOpen = useOptionalSelector(ShellToken, (
|
|
16
|
-
const props = useOptionalSelector(ShellToken, (
|
|
26
|
+
const isOpen = useOptionalSelector(ShellToken, (shell) => shell.isOpen(id), false);
|
|
27
|
+
const props = useOptionalSelector(ShellToken, (shell) => shell.getSurface(id)?.props ?? NO_PROPS, NO_PROPS);
|
|
17
28
|
return useMemo(() => ({
|
|
18
29
|
isOpen,
|
|
19
30
|
props,
|
|
20
|
-
open: (
|
|
31
|
+
open: (options) => shell?.open(id, options),
|
|
21
32
|
close: () => shell?.close(id),
|
|
22
|
-
toggle: (
|
|
33
|
+
toggle: (options) => shell?.toggle(id, options)
|
|
23
34
|
}), [
|
|
24
35
|
shell,
|
|
25
36
|
id,
|
|
@@ -27,21 +38,22 @@ function useSurface(id) {
|
|
|
27
38
|
props
|
|
28
39
|
]);
|
|
29
40
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Put the cursor in `ref`'s element when the surface `id` asks for it: on every
|
|
43
|
+
* `open(id, { focus: true })`, a command whose panel says `focus` among them, and
|
|
44
|
+
* when the element mounts while the request is up (the panel opened, or its code
|
|
45
|
+
* loaded, because of it). A plain open never moves it. `select` selects an input's
|
|
46
|
+
* text, so typing replaces it. Reads the surface of this subtree's document; use
|
|
47
|
+
* it in the component that renders the element.
|
|
48
|
+
*/
|
|
49
|
+
function useSurfaceFocus(id, ref, options = {}) {
|
|
34
50
|
const shell = useOptionalCapability(ShellToken);
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
toggle: (id) => shell?.toggleMenu(id),
|
|
40
|
-
close: (id) => shell?.closeMenu(id),
|
|
41
|
-
closeAll: () => shell?.closeAllMenus()
|
|
42
|
-
}), [shell, open]);
|
|
51
|
+
const request = useOptionalSelector(ShellToken, (current) => current.getSurface(id)?.focusRequest ?? 0, 0);
|
|
52
|
+
const [follower] = useState(createSurfaceFocusFollower);
|
|
53
|
+
const select = options.select ?? false;
|
|
54
|
+
useEffect(() => follower.follow(ref.current, shell, request, { select }));
|
|
43
55
|
}
|
|
44
56
|
//#endregion
|
|
45
|
-
export {
|
|
57
|
+
export { useShell, useShellEvent, useShellState, useSurface, useSurfaceFocus };
|
|
46
58
|
|
|
47
59
|
//# sourceMappingURL=shell.js.map
|
package/dist/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","names":[],"sources":["../src/shell.ts"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-shell. The app owns every\n * surface's DOM; these hooks bind its open/closed state to the kernel so\n * commands can drive it and applications can restore it.\n *\n *
|
|
1
|
+
{"version":3,"file":"shell.js","names":[],"sources":["../src/shell.ts"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-shell. The app owns every\n * surface's DOM; these hooks bind its open/closed state to the kernel so\n * commands can drive it and applications can restore it.\n *\n * The state hooks work without a document: shell state is document-scoped,\n * and chrome that uses it (panel buttons, menu anchors) stays mounted across\n * the empty workspace. With no document every surface reads as closed, no menu\n * as open, and `useSurface`'s verbs do nothing. `useShell()` then returns the\n * stand-in, whose methods throw `not-ready`.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-shell';\nimport { useEffect, useMemo, useState, type RefObject } from 'react';\nimport { ShellToken, shellState } from '@embedpdf/plugin-shell';\nimport type { OpenSurfaceOptions, ShellCapability, SurfaceProps } from '@embedpdf/plugin-shell';\nimport type { EventHook } from '@embedpdf/core';\nimport { createSurfaceFocusFollower, type SurfaceFocusOptions } from '@embedpdf/web';\nimport {\n useCapability,\n useCapabilityEvent,\n useOptionalCapability,\n useOptionalSelector,\n} from './runtime';\nimport { stateHook } from './state';\n\n/** The shell capability: open and close panels, dialogs and menus. Without a document its methods throw `not-ready`. */\nexport function useShell(): ShellCapability {\n return useCapability(ShellToken);\n}\n\n/** Subscribe to one shell event for the mounted lifetime: `useShellEvent((shell) => shell.onSurfaceOpened, handler)`. */\nexport function useShellEvent<T>(\n select: (shell: ShellCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(ShellToken, select, handler);\n}\n\n/**\n * Which panels, dialogs and menus are open (the page's State table, declared\n * once in `shellState`). Takes a selector, and re-renders only when what it\n * returns changes. Without a document nothing is open.\n */\nexport const useShellState = stateHook(shellState);\n\nexport interface SurfaceHandle {\n readonly isOpen: boolean;\n /** The props the surface was opened with, or updated to; empty when it has none. */\n readonly props: SurfaceProps;\n open(options?: OpenSurfaceOptions): void;\n close(): void;\n toggle(options?: OpenSurfaceOptions): void;\n}\n\nconst NO_PROPS: SurfaceProps = Object.freeze({});\n\n/** One named surface (panel, dialog, overlay) of this subtree's document. Reads as closed, and its verbs do nothing, while no document is open. */\nexport function useSurface(id: string): SurfaceHandle {\n const shell = useOptionalCapability(ShellToken);\n const isOpen = useOptionalSelector(ShellToken, (shell) => shell.isOpen(id), false);\n const props = useOptionalSelector(\n ShellToken,\n (shell) => shell.getSurface(id)?.props ?? NO_PROPS,\n NO_PROPS,\n );\n return useMemo(\n () => ({\n isOpen,\n props,\n open: (options?: OpenSurfaceOptions) => shell?.open(id, options),\n close: () => shell?.close(id),\n toggle: (options?: OpenSurfaceOptions) => shell?.toggle(id, options),\n }),\n [shell, id, isOpen, props],\n );\n}\n\nexport type { SurfaceFocusOptions };\n\n/**\n * Put the cursor in `ref`'s element when the surface `id` asks for it: on every\n * `open(id, { focus: true })`, a command whose panel says `focus` among them, and\n * when the element mounts while the request is up (the panel opened, or its code\n * loaded, because of it). A plain open never moves it. `select` selects an input's\n * text, so typing replaces it. Reads the surface of this subtree's document; use\n * it in the component that renders the element.\n */\nexport function useSurfaceFocus(\n id: string,\n ref: RefObject<HTMLElement | null>,\n options: SurfaceFocusOptions = {},\n): void {\n const shell = useOptionalCapability(ShellToken);\n const request = useOptionalSelector(\n ShellToken,\n (current) => current.getSurface(id)?.focusRequest ?? 0,\n 0,\n );\n const [follower] = useState(createSurfaceFocusFollower);\n const select = options.select ?? false;\n // After every render, so an element that has just appeared is seen, and after the layout\n // effects, so a panel's frame has placed and shown it (a sheet's layer is hidden until then).\n useEffect(() => follower.follow(ref.current, shell, request, { select }));\n}\n"],"mappings":";;;;;;;;AA4BA,SAAgB,WAA4B;CAC1C,OAAO,cAAc,UAAU;AACjC;;AAGA,SAAgB,cACd,QACA,SACM;CACN,mBAAmB,YAAY,QAAQ,OAAO;AAChD;;;;;;AAOA,MAAa,gBAAgB,UAAU,UAAU;AAWjD,MAAM,WAAyB,OAAO,OAAO,CAAC,CAAC;;AAG/C,SAAgB,WAAW,IAA2B;CACpD,MAAM,QAAQ,sBAAsB,UAAU;CAC9C,MAAM,SAAS,oBAAoB,aAAa,UAAU,MAAM,OAAO,EAAE,GAAG,KAAK;CACjF,MAAM,QAAQ,oBACZ,aACC,UAAU,MAAM,WAAW,EAAE,CAAC,EAAE,SAAS,UAC1C,QACF;CACA,OAAO,eACE;EACL;EACA;EACA,OAAO,YAAiC,OAAO,KAAK,IAAI,OAAO;EAC/D,aAAa,OAAO,MAAM,EAAE;EAC5B,SAAS,YAAiC,OAAO,OAAO,IAAI,OAAO;CACrE,IACA;EAAC;EAAO;EAAI;EAAQ;CAAK,CAC3B;AACF;;;;;;;;;AAYA,SAAgB,gBACd,IACA,KACA,UAA+B,CAAC,GAC1B;CACN,MAAM,QAAQ,sBAAsB,UAAU;CAC9C,MAAM,UAAU,oBACd,aACC,YAAY,QAAQ,WAAW,EAAE,CAAC,EAAE,gBAAgB,GACrD,CACF;CACA,MAAM,CAAC,YAAY,SAAS,0BAA0B;CACtD,MAAM,SAAS,QAAQ,UAAU;CAGjC,gBAAgB,SAAS,OAAO,IAAI,SAAS,OAAO,SAAS,EAAE,OAAO,CAAC,CAAC;AAC1E"}
|
package/dist/signature.cjs
CHANGED
|
@@ -1,73 +1,54 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("./rolldown-runtime-DDXJien1.cjs");
|
|
3
|
-
const require_runtime = require("./runtime.cjs");
|
|
3
|
+
const require_runtime = require("./runtime-BfnpyfY0.cjs");
|
|
4
|
+
const require_state = require("./state-Dtf8HAue.cjs");
|
|
4
5
|
const require_stamp = require("./stamp.cjs");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
let _embedpdf_plugin_signature = require("@embedpdf/plugin-signature");
|
|
7
|
-
let _embedpdf_plugin_stamp_contract = require("@embedpdf/plugin-stamp/contract");
|
|
8
8
|
//#region src/signature.tsx
|
|
9
9
|
/**
|
|
10
|
-
* The React view of @embedpdf/plugin-signature:
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* the people (libraries of kind `signatures`) with
|
|
10
|
+
* The React view of @embedpdf/plugin-signature: signing for the surrounding
|
|
11
|
+
* document, its state (the signatures with their verdicts, what they allow,
|
|
12
|
+
* the target, a two-step signing in progress), and the one derivation a
|
|
13
|
+
* signatures panel needs: the people (libraries of kind `signatures`) with
|
|
14
|
+
* their marks.
|
|
14
15
|
*
|
|
15
16
|
* const signature = useSignature();
|
|
16
|
-
* await signature.placeMark({ assetId }, { field: target });
|
|
17
|
+
* await signature.placeMark({ assetId }, { field: target }); // sign, fill or ask, by mode
|
|
17
18
|
*/
|
|
18
|
-
/** The signature
|
|
19
|
+
/** The signature API for the surrounding document. */
|
|
19
20
|
function useSignature() {
|
|
20
21
|
return require_runtime.useCapability(_embedpdf_plugin_signature.SignatureToken);
|
|
21
22
|
}
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
function useSignatureTarget() {
|
|
36
|
-
return {
|
|
37
|
-
target: require_runtime.useSelector(_embedpdf_plugin_signature.SignatureToken, (c) => c.target()),
|
|
38
|
-
busy: require_runtime.useSelector(_embedpdf_plugin_signature.SignatureToken, (c) => c.busy())
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/** Subscribe to the plugin's change events (signed / filled / ask / inspect / target / validated …). */
|
|
42
|
-
function useSignatureEvent(handler) {
|
|
43
|
-
require_runtime.useCapabilityEvent(_embedpdf_plugin_signature.SignatureToken, (c) => c.onChanged, handler);
|
|
23
|
+
/**
|
|
24
|
+
* The signatures' state: the signed fields with their verdicts, what they
|
|
25
|
+
* allow, the target, whether a signing runs, a two-step signing in progress,
|
|
26
|
+
* and whether they're read (the page's State table, declared once in
|
|
27
|
+
* `signatureState`). Takes a selector, and re-renders only when what it
|
|
28
|
+
* returns changes.
|
|
29
|
+
*/
|
|
30
|
+
const useSignatureState = require_state.stateHook(_embedpdf_plugin_signature.signatureState);
|
|
31
|
+
/** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */
|
|
32
|
+
const useSignatureSettings = require_state.settingsHook(_embedpdf_plugin_signature.SignatureToken);
|
|
33
|
+
/** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */
|
|
34
|
+
function useSignatureEvent(select, handler) {
|
|
35
|
+
require_runtime.useCapabilityEvent(_embedpdf_plugin_signature.SignatureToken, select, handler);
|
|
44
36
|
}
|
|
45
37
|
/**
|
|
46
|
-
* The people whose marks this browser holds
|
|
47
|
-
* `signatures
|
|
48
|
-
* export are the library verbs; nothing is stored beyond the file.
|
|
38
|
+
* The people whose marks this browser holds, one row per library of kind
|
|
39
|
+
* `signatures`, for a picker. Derived from the stamp plugin: rename, delete
|
|
40
|
+
* and export are the library verbs; nothing is stored beyond the file.
|
|
49
41
|
*/
|
|
50
42
|
function useSignerRows() {
|
|
51
43
|
const libraries = require_stamp.useStampLibraries({ kind: _embedpdf_plugin_signature.SIGNATURES_LIBRARY_KIND });
|
|
52
|
-
const assets =
|
|
53
|
-
return (0, react.useMemo)(() =>
|
|
54
|
-
const own = assets.filter((asset) => asset.libraryId === library.id);
|
|
55
|
-
return {
|
|
56
|
-
libraryId: library.id,
|
|
57
|
-
name: library.name,
|
|
58
|
-
library,
|
|
59
|
-
signatures: own.filter((asset) => (0, _embedpdf_plugin_signature.markRoleOf)(asset) === "signature"),
|
|
60
|
-
initials: own.find((asset) => (0, _embedpdf_plugin_signature.markRoleOf)(asset) === "initials") ?? null
|
|
61
|
-
};
|
|
62
|
-
}), [libraries, assets]);
|
|
44
|
+
const assets = require_stamp.useStampAssets();
|
|
45
|
+
return (0, react.useMemo)(() => (0, _embedpdf_plugin_signature.signerRowsOf)(libraries, assets), [libraries, assets]);
|
|
63
46
|
}
|
|
64
47
|
//#endregion
|
|
65
|
-
exports.useDocumentProtection = useDocumentProtection;
|
|
66
48
|
exports.useSignature = useSignature;
|
|
67
49
|
exports.useSignatureEvent = useSignatureEvent;
|
|
68
|
-
exports.
|
|
69
|
-
exports.
|
|
70
|
-
exports.useSignatureVerdicts = useSignatureVerdicts;
|
|
50
|
+
exports.useSignatureSettings = useSignatureSettings;
|
|
51
|
+
exports.useSignatureState = useSignatureState;
|
|
71
52
|
exports.useSignerRows = useSignerRows;
|
|
72
53
|
Object.keys(_embedpdf_plugin_signature).forEach(function(k) {
|
|
73
54
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
package/dist/signature.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.cjs","names":["useCapability","SignatureToken","
|
|
1
|
+
{"version":3,"file":"signature.cjs","names":["useCapability","SignatureToken","stateHook","signatureState","settingsHook","useStampLibraries","SIGNATURES_LIBRARY_KIND","useStampAssets"],"sources":["../src/signature.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-signature: signing for the surrounding\n * document, its state (the signatures with their verdicts, what they allow,\n * the target, a two-step signing in progress), and the one derivation a\n * signatures panel needs: the people (libraries of kind `signatures`) with\n * their marks.\n *\n * const signature = useSignature();\n * await signature.placeMark({ assetId }, { field: target }); // sign, fill or ask, by mode\n */\nimport { useMemo } from 'react';\nimport type { EventHook } from '@embedpdf/core';\nimport {\n signatureState,\n signerRowsOf,\n SIGNATURES_LIBRARY_KIND,\n SignatureToken,\n type SignatureCapability,\n type SignerRow,\n} from '@embedpdf/plugin-signature';\n\nimport { useCapability, useCapabilityEvent } from './runtime';\nimport { useStampAssets, useStampLibraries } from './stamp';\nimport { settingsHook, stateHook } from './state';\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-signature';\n\n/** The signature API for the surrounding document. */\nexport function useSignature(): SignatureCapability {\n return useCapability(SignatureToken);\n}\n\n/**\n * The signatures' state: the signed fields with their verdicts, what they\n * allow, the target, whether a signing runs, a two-step signing in progress,\n * and whether they're read (the page's State table, declared once in\n * `signatureState`). Takes a selector, and re-renders only when what it\n * returns changes.\n */\nexport const useSignatureState = stateHook(signatureState);\n\n/** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */\nexport const useSignatureSettings = settingsHook(SignatureToken);\n\n/** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */\nexport function useSignatureEvent<T>(\n select: (signature: SignatureCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(SignatureToken, select, handler);\n}\n\n/**\n * The people whose marks this browser holds, one row per library of kind\n * `signatures`, for a picker. Derived from the stamp plugin: rename, delete\n * and export are the library verbs; nothing is stored beyond the file.\n */\nexport function useSignerRows(): SignerRow[] {\n const libraries = useStampLibraries({ kind: SIGNATURES_LIBRARY_KIND });\n const assets = useStampAssets();\n return useMemo(() => signerRowsOf(libraries, assets), [libraries, assets]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,eAAoC;CAClD,OAAOA,gBAAAA,cAAcC,2BAAAA,cAAc;AACrC;;;;;;;;AASA,MAAa,oBAAoBC,cAAAA,UAAUC,2BAAAA,cAAc;;AAGzD,MAAa,uBAAuBC,cAAAA,aAAaH,2BAAAA,cAAc;;AAG/D,SAAgB,kBACd,QACA,SACM;CACN,gBAAA,mBAAmBA,2BAAAA,gBAAgB,QAAQ,OAAO;AACpD;;;;;;AAOA,SAAgB,gBAA6B;CAC3C,MAAM,YAAYI,cAAAA,kBAAkB,EAAE,MAAMC,2BAAAA,wBAAwB,CAAC;CACrE,MAAM,SAASC,cAAAA,eAAe;CAC9B,QAAA,GAAA,MAAA,QAAA,QAAA,GAAA,2BAAA,aAAA,CAAkC,WAAW,MAAM,GAAG,CAAC,WAAW,MAAM,CAAC;AAC3E"}
|
package/dist/signature.d.cts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as StateHook, t as SettingsHook } from "./state-0K1I5cM4.cjs";
|
|
2
|
+
import { r as FormFieldRef, t as DocumentProtection } from "./AnnotationList-DcyhF2kU-CiBFOq1z.cjs";
|
|
3
|
+
import { EventHook } from "@embedpdf/core";
|
|
4
|
+
import { SignatureCapability, SignerRow } from "@embedpdf/plugin-signature";
|
|
3
5
|
export * from "@embedpdf/plugin-signature";
|
|
4
6
|
//#region src/signature.d.ts
|
|
5
|
-
/** The signature
|
|
7
|
+
/** The signature API for the surrounding document. */
|
|
6
8
|
declare function useSignature(): SignatureCapability;
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
declare
|
|
9
|
+
/**
|
|
10
|
+
* The signatures' state: the signed fields with their verdicts, what they
|
|
11
|
+
* allow, the target, whether a signing runs, a two-step signing in progress,
|
|
12
|
+
* and whether they're read (the page's State table, declared once in
|
|
13
|
+
* `signatureState`). Takes a selector, and re-renders only when what it
|
|
14
|
+
* returns changes.
|
|
15
|
+
*/
|
|
16
|
+
declare const useSignatureState: StateHook<{
|
|
17
|
+
signatures: readonly import("@embedpdf/plugin-signature").SignatureInfo[];
|
|
18
|
+
protection: DocumentProtection | null;
|
|
15
19
|
target: FormFieldRef | null;
|
|
16
20
|
busy: boolean;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
library: StampLibrary;
|
|
25
|
-
signatures: StampAsset[];
|
|
26
|
-
initials: StampAsset | null;
|
|
27
|
-
}
|
|
21
|
+
pending: import("@embedpdf/plugin-signature").SignaturePending | null;
|
|
22
|
+
status: import("@embedpdf/core").ResourceStatus;
|
|
23
|
+
}>;
|
|
24
|
+
/** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */
|
|
25
|
+
declare const useSignatureSettings: SettingsHook<import("@embedpdf/plugin-signature").SignatureSettings>;
|
|
26
|
+
/** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */
|
|
27
|
+
declare function useSignatureEvent<T>(select: (signature: SignatureCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
28
28
|
/**
|
|
29
|
-
* The people whose marks this browser holds
|
|
30
|
-
* `signatures
|
|
31
|
-
* export are the library verbs; nothing is stored beyond the file.
|
|
29
|
+
* The people whose marks this browser holds, one row per library of kind
|
|
30
|
+
* `signatures`, for a picker. Derived from the stamp plugin: rename, delete
|
|
31
|
+
* and export are the library verbs; nothing is stored beyond the file.
|
|
32
32
|
*/
|
|
33
33
|
declare function useSignerRows(): SignerRow[];
|
|
34
34
|
//#endregion
|
|
35
|
-
export {
|
|
35
|
+
export { useSignature, useSignatureEvent, useSignatureSettings, useSignatureState, useSignerRows };
|
|
36
36
|
//# sourceMappingURL=signature.d.cts.map
|
package/dist/signature.d.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as StateHook, t as SettingsHook } from "./state-0K1I5cM4.js";
|
|
2
|
+
import { r as FormFieldRef, t as DocumentProtection } from "./AnnotationList-DcyhF2kU-CiBFOq1z.js";
|
|
3
|
+
import { EventHook } from "@embedpdf/core";
|
|
4
|
+
import { SignatureCapability, SignerRow } from "@embedpdf/plugin-signature";
|
|
3
5
|
export * from "@embedpdf/plugin-signature";
|
|
4
6
|
//#region src/signature.d.ts
|
|
5
|
-
/** The signature
|
|
7
|
+
/** The signature API for the surrounding document. */
|
|
6
8
|
declare function useSignature(): SignatureCapability;
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
declare
|
|
9
|
+
/**
|
|
10
|
+
* The signatures' state: the signed fields with their verdicts, what they
|
|
11
|
+
* allow, the target, whether a signing runs, a two-step signing in progress,
|
|
12
|
+
* and whether they're read (the page's State table, declared once in
|
|
13
|
+
* `signatureState`). Takes a selector, and re-renders only when what it
|
|
14
|
+
* returns changes.
|
|
15
|
+
*/
|
|
16
|
+
declare const useSignatureState: StateHook<{
|
|
17
|
+
signatures: readonly import("@embedpdf/plugin-signature").SignatureInfo[];
|
|
18
|
+
protection: DocumentProtection | null;
|
|
15
19
|
target: FormFieldRef | null;
|
|
16
20
|
busy: boolean;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
library: StampLibrary;
|
|
25
|
-
signatures: StampAsset[];
|
|
26
|
-
initials: StampAsset | null;
|
|
27
|
-
}
|
|
21
|
+
pending: import("@embedpdf/plugin-signature").SignaturePending | null;
|
|
22
|
+
status: import("@embedpdf/core").ResourceStatus;
|
|
23
|
+
}>;
|
|
24
|
+
/** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */
|
|
25
|
+
declare const useSignatureSettings: SettingsHook<import("@embedpdf/plugin-signature").SignatureSettings>;
|
|
26
|
+
/** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */
|
|
27
|
+
declare function useSignatureEvent<T>(select: (signature: SignatureCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
28
28
|
/**
|
|
29
|
-
* The people whose marks this browser holds
|
|
30
|
-
* `signatures
|
|
31
|
-
* export are the library verbs; nothing is stored beyond the file.
|
|
29
|
+
* The people whose marks this browser holds, one row per library of kind
|
|
30
|
+
* `signatures`, for a picker. Derived from the stamp plugin: rename, delete
|
|
31
|
+
* and export are the library verbs; nothing is stored beyond the file.
|
|
32
32
|
*/
|
|
33
33
|
declare function useSignerRows(): SignerRow[];
|
|
34
34
|
//#endregion
|
|
35
|
-
export {
|
|
35
|
+
export { useSignature, useSignatureEvent, useSignatureSettings, useSignatureState, useSignerRows };
|
|
36
36
|
//# sourceMappingURL=signature.d.ts.map
|
package/dist/signature.js
CHANGED
|
@@ -1,67 +1,49 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import {
|
|
3
|
-
import { useStampLibraries } from "./stamp.js";
|
|
1
|
+
import { f as useCapability, p as useCapabilityEvent } from "./runtime-tD5iJU83.js";
|
|
2
|
+
import { n as stateHook, t as settingsHook } from "./state-CzI2KlZb.js";
|
|
3
|
+
import { useStampAssets, useStampLibraries } from "./stamp.js";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import { SIGNATURES_LIBRARY_KIND, SignatureToken,
|
|
6
|
-
import { StampToken } from "@embedpdf/plugin-stamp/contract";
|
|
5
|
+
import { SIGNATURES_LIBRARY_KIND, SignatureToken, signatureState, signerRowsOf } from "@embedpdf/plugin-signature";
|
|
7
6
|
export * from "@embedpdf/plugin-signature";
|
|
8
7
|
//#region src/signature.tsx
|
|
9
8
|
/**
|
|
10
|
-
* The React view of @embedpdf/plugin-signature:
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* the people (libraries of kind `signatures`) with
|
|
9
|
+
* The React view of @embedpdf/plugin-signature: signing for the surrounding
|
|
10
|
+
* document, its state (the signatures with their verdicts, what they allow,
|
|
11
|
+
* the target, a two-step signing in progress), and the one derivation a
|
|
12
|
+
* signatures panel needs: the people (libraries of kind `signatures`) with
|
|
13
|
+
* their marks.
|
|
14
14
|
*
|
|
15
15
|
* const signature = useSignature();
|
|
16
|
-
* await signature.placeMark({ assetId }, { field: target });
|
|
16
|
+
* await signature.placeMark({ assetId }, { field: target }); // sign, fill or ask, by mode
|
|
17
17
|
*/
|
|
18
|
-
/** The signature
|
|
18
|
+
/** The signature API for the surrounding document. */
|
|
19
19
|
function useSignature() {
|
|
20
20
|
return useCapability(SignatureToken);
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
function useSignatureTarget() {
|
|
36
|
-
return {
|
|
37
|
-
target: useSelector(SignatureToken, (c) => c.target()),
|
|
38
|
-
busy: useSelector(SignatureToken, (c) => c.busy())
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/** Subscribe to the plugin's change events (signed / filled / ask / inspect / target / validated …). */
|
|
42
|
-
function useSignatureEvent(handler) {
|
|
43
|
-
useCapabilityEvent(SignatureToken, (c) => c.onChanged, handler);
|
|
22
|
+
/**
|
|
23
|
+
* The signatures' state: the signed fields with their verdicts, what they
|
|
24
|
+
* allow, the target, whether a signing runs, a two-step signing in progress,
|
|
25
|
+
* and whether they're read (the page's State table, declared once in
|
|
26
|
+
* `signatureState`). Takes a selector, and re-renders only when what it
|
|
27
|
+
* returns changes.
|
|
28
|
+
*/
|
|
29
|
+
const useSignatureState = stateHook(signatureState);
|
|
30
|
+
/** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */
|
|
31
|
+
const useSignatureSettings = settingsHook(SignatureToken);
|
|
32
|
+
/** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */
|
|
33
|
+
function useSignatureEvent(select, handler) {
|
|
34
|
+
useCapabilityEvent(SignatureToken, select, handler);
|
|
44
35
|
}
|
|
45
36
|
/**
|
|
46
|
-
* The people whose marks this browser holds
|
|
47
|
-
* `signatures
|
|
48
|
-
* export are the library verbs; nothing is stored beyond the file.
|
|
37
|
+
* The people whose marks this browser holds, one row per library of kind
|
|
38
|
+
* `signatures`, for a picker. Derived from the stamp plugin: rename, delete
|
|
39
|
+
* and export are the library verbs; nothing is stored beyond the file.
|
|
49
40
|
*/
|
|
50
41
|
function useSignerRows() {
|
|
51
42
|
const libraries = useStampLibraries({ kind: SIGNATURES_LIBRARY_KIND });
|
|
52
|
-
const assets =
|
|
53
|
-
return useMemo(() => libraries
|
|
54
|
-
const own = assets.filter((asset) => asset.libraryId === library.id);
|
|
55
|
-
return {
|
|
56
|
-
libraryId: library.id,
|
|
57
|
-
name: library.name,
|
|
58
|
-
library,
|
|
59
|
-
signatures: own.filter((asset) => markRoleOf(asset) === "signature"),
|
|
60
|
-
initials: own.find((asset) => markRoleOf(asset) === "initials") ?? null
|
|
61
|
-
};
|
|
62
|
-
}), [libraries, assets]);
|
|
43
|
+
const assets = useStampAssets();
|
|
44
|
+
return useMemo(() => signerRowsOf(libraries, assets), [libraries, assets]);
|
|
63
45
|
}
|
|
64
46
|
//#endregion
|
|
65
|
-
export {
|
|
47
|
+
export { useSignature, useSignatureEvent, useSignatureSettings, useSignatureState, useSignerRows };
|
|
66
48
|
|
|
67
49
|
//# sourceMappingURL=signature.js.map
|
package/dist/signature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.js","names":[],"sources":["../src/signature.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-signature:
|
|
1
|
+
{"version":3,"file":"signature.js","names":[],"sources":["../src/signature.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-signature: signing for the surrounding\n * document, its state (the signatures with their verdicts, what they allow,\n * the target, a two-step signing in progress), and the one derivation a\n * signatures panel needs: the people (libraries of kind `signatures`) with\n * their marks.\n *\n * const signature = useSignature();\n * await signature.placeMark({ assetId }, { field: target }); // sign, fill or ask, by mode\n */\nimport { useMemo } from 'react';\nimport type { EventHook } from '@embedpdf/core';\nimport {\n signatureState,\n signerRowsOf,\n SIGNATURES_LIBRARY_KIND,\n SignatureToken,\n type SignatureCapability,\n type SignerRow,\n} from '@embedpdf/plugin-signature';\n\nimport { useCapability, useCapabilityEvent } from './runtime';\nimport { useStampAssets, useStampLibraries } from './stamp';\nimport { settingsHook, stateHook } from './state';\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-signature';\n\n/** The signature API for the surrounding document. */\nexport function useSignature(): SignatureCapability {\n return useCapability(SignatureToken);\n}\n\n/**\n * The signatures' state: the signed fields with their verdicts, what they\n * allow, the target, whether a signing runs, a two-step signing in progress,\n * and whether they're read (the page's State table, declared once in\n * `signatureState`). Takes a selector, and re-renders only when what it\n * returns changes.\n */\nexport const useSignatureState = stateHook(signatureState);\n\n/** The signature settings (`key`, `mode`, `trust`, `allowCertify`), with or without a document. Takes a selector. */\nexport const useSignatureSettings = settingsHook(SignatureToken);\n\n/** Subscribe to one of the plugin's events while mounted: `useSignatureEvent((signature) => signature.onSigned, handler)`. */\nexport function useSignatureEvent<T>(\n select: (signature: SignatureCapability) => EventHook<T>,\n handler: (event: T) => void,\n): void {\n useCapabilityEvent(SignatureToken, select, handler);\n}\n\n/**\n * The people whose marks this browser holds, one row per library of kind\n * `signatures`, for a picker. Derived from the stamp plugin: rename, delete\n * and export are the library verbs; nothing is stored beyond the file.\n */\nexport function useSignerRows(): SignerRow[] {\n const libraries = useStampLibraries({ kind: SIGNATURES_LIBRARY_KIND });\n const assets = useStampAssets();\n return useMemo(() => signerRowsOf(libraries, assets), [libraries, assets]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAAgB,eAAoC;CAClD,OAAO,cAAc,cAAc;AACrC;;;;;;;;AASA,MAAa,oBAAoB,UAAU,cAAc;;AAGzD,MAAa,uBAAuB,aAAa,cAAc;;AAG/D,SAAgB,kBACd,QACA,SACM;CACN,mBAAmB,gBAAgB,QAAQ,OAAO;AACpD;;;;;;AAOA,SAAgB,gBAA6B;CAC3C,MAAM,YAAY,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;CACrE,MAAM,SAAS,eAAe;CAC9B,OAAO,cAAc,aAAa,WAAW,MAAM,GAAG,CAAC,WAAW,MAAM,CAAC;AAC3E"}
|