@embedpdf/plugin-form 3.0.0-next.9 → 3.0.0

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.
@@ -0,0 +1,119 @@
1
+ import { I as FormSetValueResult, Q as Box, a as FormCommitResult, i as FormCapability, tt as ShownWidget } from "./contract-Djti7ew8.cjs";
2
+ import "@embedpdf/core";
3
+ import { AnnotationRef, FormEffect, FormField, FormFieldRef, PageRef, PdfActionTargetRef, WidgetAnnotation } from "@embedpdf/engine-core/runtime";
4
+ import { ActionContext, ActionDiagnostic, ActionOrigin, ActionSubmitRequest, PdfAnnotationEventKind, SubmitIntent } from "@embedpdf/plugin-actions/contract";
5
+ import { TextEditorLayout, TextEditorLayout as TextEditorLayout$1 } from "@embedpdf/core-form";
6
+ import { FormCommitSinkResult } from "@embedpdf/plugin-actions/contract/host";
7
+ import { FontCss } from "@embedpdf/plugin-fonts/contract";
8
+ import { AppearancePicture } from "@embedpdf/plugin-render/contract/host";
9
+ import { SceneNode } from "@embedpdf/core-annotation";
10
+ //#region src/services/looks.d.ts
11
+ /** A widget as the painter draws it: its scene on the page (its text carries the faces it needs). */
12
+ interface WidgetPainting {
13
+ readonly scene: readonly SceneNode[];
14
+ }
15
+ //#endregion
16
+ //#region src/host-contract.d.ts
17
+ /**
18
+ * A field box's control, as the host shows it: what the cursor goes into. The form layer lends
19
+ * one for each box on screen (`attachFocusTarget`); in a browser it focuses the control's
20
+ * element without scrolling (`@embedpdf/web`'s `bindFieldFocus`), and the Stage brings the box
21
+ * into view.
22
+ */
23
+ interface FormFocusTarget {
24
+ /** Take the cursor; `select` selects a text box's text, so typing replaces it. */
25
+ focus(options: {
26
+ readonly select: boolean;
27
+ }): void;
28
+ }
29
+ /**
30
+ * The host lens: members for the framework layers and sibling plugins (the
31
+ * widget event feed, the text being typed, and the actions plugin's
32
+ * executors and sinks). Application code uses the public capability.
33
+ */
34
+ interface FormHostCapability extends FormCapability {
35
+ /** Load a page's widgets (one annotation read per page), so `listWidgets(page)` has them. */
36
+ ensureLoaded(page: PageRef): Promise<void>;
37
+ /**
38
+ * The widgets a page shows, in the order the page draws them, each with the appearance state it
39
+ * shows and whether its look is `pending` (the view's isn't the confirmed one yet); hidden ones
40
+ * are left out. The form layer paints their pictures from it, and the painter's drawing
41
+ * (`getWidgetPainting`) for a pending one or one whose picture is older than its look. In design
42
+ * mode, while the widgets are lent to the annotation plugin, none: the annotation layer draws
43
+ * them.
44
+ */
45
+ listShownWidgets(page: PageRef): readonly ShownWidget[];
46
+ /**
47
+ * What a page's widget pictures depend on: its widgets at their picture
48
+ * versions (`5@2|6@7`). Load the pictures again when it changes, or when
49
+ * the appearance scale does. A checkbox that only switches its state
50
+ * doesn't move it.
51
+ */
52
+ getAppearanceEpoch(page: PageRef): string;
53
+ /**
54
+ * Every picture of a page's widgets, at rest, in every state, each with the
55
+ * picture version of its widget (`ShownWidget.pictureVersion`), through the
56
+ * render plugin; none without it. The form layer and design mode share them.
57
+ */
58
+ renderAppearances(page: PageRef, scale: number, signal?: AbortSignal): Promise<readonly AppearancePicture[]>;
59
+ /**
60
+ * What the widget looks like as the view has it, drawn by the painter (`@embedpdf/core-form`): its
61
+ * scene in page space, its text in the engine's own faces (each glyphs node carries the program
62
+ * to mount). The same object while nothing it shows changes; `null` for a widget the painter
63
+ * doesn't draw (a signature).
64
+ */
65
+ getWidgetPainting(widget: AnnotationRef): WidgetPainting | null;
66
+ /**
67
+ * Where a text field's editor shows `text` (what is typed in it), so it sits where the engine
68
+ * will draw it: the face, the size the engine draws at (a fitted size resolved for `text`),
69
+ * the text's box inside the widget's, one line's height and a comb's spacing, in page points.
70
+ * `null` for a widget that isn't a text field's.
71
+ */
72
+ getTextEditorLayout(widget: AnnotationRef, text: string): TextEditorLayout | null;
73
+ /**
74
+ * How a control the painter doesn't draw (a list box's rows) draws the widget's text: its font
75
+ * as CSS, as the engine picks it (the fonts plugin's; without it, the standard font the engine
76
+ * falls back to), with the programs the family list names, to mount. `null` for a widget that
77
+ * isn't there.
78
+ */
79
+ getWidgetFontCss(widget: AnnotationRef): FontCss | null;
80
+ /** The page box in page space, for keeping a placement on the page; `null` for a page that isn't there. */
81
+ getPageBox(page: PageRef): Box | null;
82
+ /**
83
+ * Lend the plugin a box's control while it's on screen, so `focus()` and `focusNext()` can put
84
+ * the cursor in it; a box `focus()` asked for before its page came in takes the cursor now.
85
+ * Returns the call that takes it back.
86
+ */
87
+ attachFocusTarget(widget: AnnotationRef, target: FormFocusTarget): () => void;
88
+ /**
89
+ * The arrow keys in a radio group: move the cursor to the group's next button (the one before,
90
+ * `backward`), going round, and pick it, as a click on it does. `false` for a widget that isn't a
91
+ * radio button the user can pick, or a group of one.
92
+ */
93
+ moveInGroup(widget: AnnotationRef, backward: boolean): boolean;
94
+ /** Send a widget's pointer or focus event to the actions plugin, which runs its `/AA` actions. */
95
+ notifyWidgetEvent(field: FormFieldRef, widget: AnnotationRef, event: PdfAnnotationEventKind): void;
96
+ /** Run a ResetForm action: reset the fields it names (or all but them), then recalculate. */
97
+ resetFormAction(fields: PdfActionTargetRef[] | null, exclude: boolean, origin?: ActionOrigin): Promise<FormCommitResult>;
98
+ /** The fields a SubmitForm action sends: the form as the user sees it, once every fill on its way is answered. */
99
+ resolveSubmitDataset(intent: SubmitIntent, actionContext: ActionContext, diagnose: (diagnostic: ActionDiagnostic) => void): Promise<ActionSubmitRequest>;
100
+ /**
101
+ * Write what a document script changed in the fields, with the calculations a value causes,
102
+ * as one change: shown at once, sent once the script's transaction ends. Never rejects; a
103
+ * change it can't stage reports why, and the engine's refusal comes through the change queue.
104
+ */
105
+ commitScriptFormEffects(effects: FormEffect[]): Promise<FormCommitSinkResult>;
106
+ /**
107
+ * The text someone is typing in a field, before it's written (write/typing.ts): a keystroke
108
+ * calls `draftText`, blur or Enter `commitDraftText` (the field's scripts run then), Escape
109
+ * `discardDraftText`. A download writes a draft first, like Acrobat commits the field being
110
+ * edited before it saves. `commitDraftText` resolves `null` when there's nothing to write.
111
+ */
112
+ draftText(field: FormFieldRef, text: string): void;
113
+ commitDraftText(field: FormFieldRef): Promise<FormSetValueResult | null>;
114
+ discardDraftText(field: FormFieldRef): void;
115
+ }
116
+ declare const FormToken: import("@embedpdf/core").CapabilityToken<FormHostCapability>;
117
+ //#endregion
118
+ export { WidgetPainting as a, TextEditorLayout$1 as i, FormHostCapability as n, FormToken as r, FormFocusTarget as t };
119
+ //# sourceMappingURL=host-contract-DO9xsBoD.d.cts.map
@@ -0,0 +1,119 @@
1
+ import { I as FormSetValueResult, Q as Box, a as FormCommitResult, i as FormCapability, tt as ShownWidget } from "./contract-6YEsObRl.js";
2
+ import "@embedpdf/core";
3
+ import { ActionContext, ActionDiagnostic, ActionOrigin, ActionSubmitRequest, PdfAnnotationEventKind, SubmitIntent } from "@embedpdf/plugin-actions/contract";
4
+ import { FontCss } from "@embedpdf/plugin-fonts/contract";
5
+ import { AnnotationRef, FormEffect, FormField, FormFieldRef, PageRef, PdfActionTargetRef, WidgetAnnotation } from "@embedpdf/engine-core/runtime";
6
+ import { FormCommitSinkResult } from "@embedpdf/plugin-actions/contract/host";
7
+ import { SceneNode } from "@embedpdf/core-annotation";
8
+ import { TextEditorLayout, TextEditorLayout as TextEditorLayout$1 } from "@embedpdf/core-form";
9
+ import { AppearancePicture } from "@embedpdf/plugin-render/contract/host";
10
+ //#region src/services/looks.d.ts
11
+ /** A widget as the painter draws it: its scene on the page (its text carries the faces it needs). */
12
+ interface WidgetPainting {
13
+ readonly scene: readonly SceneNode[];
14
+ }
15
+ //#endregion
16
+ //#region src/host-contract.d.ts
17
+ /**
18
+ * A field box's control, as the host shows it: what the cursor goes into. The form layer lends
19
+ * one for each box on screen (`attachFocusTarget`); in a browser it focuses the control's
20
+ * element without scrolling (`@embedpdf/web`'s `bindFieldFocus`), and the Stage brings the box
21
+ * into view.
22
+ */
23
+ interface FormFocusTarget {
24
+ /** Take the cursor; `select` selects a text box's text, so typing replaces it. */
25
+ focus(options: {
26
+ readonly select: boolean;
27
+ }): void;
28
+ }
29
+ /**
30
+ * The host lens: members for the framework layers and sibling plugins (the
31
+ * widget event feed, the text being typed, and the actions plugin's
32
+ * executors and sinks). Application code uses the public capability.
33
+ */
34
+ interface FormHostCapability extends FormCapability {
35
+ /** Load a page's widgets (one annotation read per page), so `listWidgets(page)` has them. */
36
+ ensureLoaded(page: PageRef): Promise<void>;
37
+ /**
38
+ * The widgets a page shows, in the order the page draws them, each with the appearance state it
39
+ * shows and whether its look is `pending` (the view's isn't the confirmed one yet); hidden ones
40
+ * are left out. The form layer paints their pictures from it, and the painter's drawing
41
+ * (`getWidgetPainting`) for a pending one or one whose picture is older than its look. In design
42
+ * mode, while the widgets are lent to the annotation plugin, none: the annotation layer draws
43
+ * them.
44
+ */
45
+ listShownWidgets(page: PageRef): readonly ShownWidget[];
46
+ /**
47
+ * What a page's widget pictures depend on: its widgets at their picture
48
+ * versions (`5@2|6@7`). Load the pictures again when it changes, or when
49
+ * the appearance scale does. A checkbox that only switches its state
50
+ * doesn't move it.
51
+ */
52
+ getAppearanceEpoch(page: PageRef): string;
53
+ /**
54
+ * Every picture of a page's widgets, at rest, in every state, each with the
55
+ * picture version of its widget (`ShownWidget.pictureVersion`), through the
56
+ * render plugin; none without it. The form layer and design mode share them.
57
+ */
58
+ renderAppearances(page: PageRef, scale: number, signal?: AbortSignal): Promise<readonly AppearancePicture[]>;
59
+ /**
60
+ * What the widget looks like as the view has it, drawn by the painter (`@embedpdf/core-form`): its
61
+ * scene in page space, its text in the engine's own faces (each glyphs node carries the program
62
+ * to mount). The same object while nothing it shows changes; `null` for a widget the painter
63
+ * doesn't draw (a signature).
64
+ */
65
+ getWidgetPainting(widget: AnnotationRef): WidgetPainting | null;
66
+ /**
67
+ * Where a text field's editor shows `text` (what is typed in it), so it sits where the engine
68
+ * will draw it: the face, the size the engine draws at (a fitted size resolved for `text`),
69
+ * the text's box inside the widget's, one line's height and a comb's spacing, in page points.
70
+ * `null` for a widget that isn't a text field's.
71
+ */
72
+ getTextEditorLayout(widget: AnnotationRef, text: string): TextEditorLayout | null;
73
+ /**
74
+ * How a control the painter doesn't draw (a list box's rows) draws the widget's text: its font
75
+ * as CSS, as the engine picks it (the fonts plugin's; without it, the standard font the engine
76
+ * falls back to), with the programs the family list names, to mount. `null` for a widget that
77
+ * isn't there.
78
+ */
79
+ getWidgetFontCss(widget: AnnotationRef): FontCss | null;
80
+ /** The page box in page space, for keeping a placement on the page; `null` for a page that isn't there. */
81
+ getPageBox(page: PageRef): Box | null;
82
+ /**
83
+ * Lend the plugin a box's control while it's on screen, so `focus()` and `focusNext()` can put
84
+ * the cursor in it; a box `focus()` asked for before its page came in takes the cursor now.
85
+ * Returns the call that takes it back.
86
+ */
87
+ attachFocusTarget(widget: AnnotationRef, target: FormFocusTarget): () => void;
88
+ /**
89
+ * The arrow keys in a radio group: move the cursor to the group's next button (the one before,
90
+ * `backward`), going round, and pick it, as a click on it does. `false` for a widget that isn't a
91
+ * radio button the user can pick, or a group of one.
92
+ */
93
+ moveInGroup(widget: AnnotationRef, backward: boolean): boolean;
94
+ /** Send a widget's pointer or focus event to the actions plugin, which runs its `/AA` actions. */
95
+ notifyWidgetEvent(field: FormFieldRef, widget: AnnotationRef, event: PdfAnnotationEventKind): void;
96
+ /** Run a ResetForm action: reset the fields it names (or all but them), then recalculate. */
97
+ resetFormAction(fields: PdfActionTargetRef[] | null, exclude: boolean, origin?: ActionOrigin): Promise<FormCommitResult>;
98
+ /** The fields a SubmitForm action sends: the form as the user sees it, once every fill on its way is answered. */
99
+ resolveSubmitDataset(intent: SubmitIntent, actionContext: ActionContext, diagnose: (diagnostic: ActionDiagnostic) => void): Promise<ActionSubmitRequest>;
100
+ /**
101
+ * Write what a document script changed in the fields, with the calculations a value causes,
102
+ * as one change: shown at once, sent once the script's transaction ends. Never rejects; a
103
+ * change it can't stage reports why, and the engine's refusal comes through the change queue.
104
+ */
105
+ commitScriptFormEffects(effects: FormEffect[]): Promise<FormCommitSinkResult>;
106
+ /**
107
+ * The text someone is typing in a field, before it's written (write/typing.ts): a keystroke
108
+ * calls `draftText`, blur or Enter `commitDraftText` (the field's scripts run then), Escape
109
+ * `discardDraftText`. A download writes a draft first, like Acrobat commits the field being
110
+ * edited before it saves. `commitDraftText` resolves `null` when there's nothing to write.
111
+ */
112
+ draftText(field: FormFieldRef, text: string): void;
113
+ commitDraftText(field: FormFieldRef): Promise<FormSetValueResult | null>;
114
+ discardDraftText(field: FormFieldRef): void;
115
+ }
116
+ declare const FormToken: import("@embedpdf/core").CapabilityToken<FormHostCapability>;
117
+ //#endregion
118
+ export { WidgetPainting as a, TextEditorLayout$1 as i, FormHostCapability as n, FormToken as r, FormFocusTarget as t };
119
+ //# sourceMappingURL=host-contract-XqkfFuoy.d.ts.map