@embedpdf/plugin-form 3.3.0 → 3.4.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.
- package/dist/contract/host.cjs +1 -1
- package/dist/contract/host.cjs.map +1 -1
- package/dist/contract/host.d.cts +3 -3
- package/dist/contract/host.d.ts +3 -3
- package/dist/contract/host.js +1 -1
- package/dist/contract/host.js.map +1 -1
- package/dist/{contract-Bq_ewUE5.d.cts → contract-B7rB7jYx.d.cts} +201 -21
- package/dist/{contract-DJLVUeAe.d.ts → contract-BkTJQ39E.d.ts} +201 -21
- package/dist/{contract-DO7k0ua0.cjs → contract-CMb6PYbf.cjs} +4 -2
- package/dist/contract-CMb6PYbf.cjs.map +1 -0
- package/dist/{contract-Bu3RA2jA.js → contract-J_QN_Igp.js} +4 -2
- package/dist/contract-J_QN_Igp.js.map +1 -0
- package/dist/contract.cjs +1 -1
- package/dist/contract.d.cts +2 -2
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +1 -1
- package/dist/{host-contract-DI1Gf4fB.d.cts → host-contract-C8HiD6sJ.d.cts} +28 -6
- package/dist/{host-contract-D9NExKAu.d.ts → host-contract-cOcPAwaN.d.ts} +27 -5
- package/dist/index.cjs +504 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -5
- package/dist/index.d.ts +24 -5
- package/dist/index.js +514 -94
- package/dist/index.js.map +1 -1
- package/dist/scripting.d.cts +1 -1
- package/dist/scripting.d.ts +1 -1
- package/package.json +17 -17
- package/dist/contract-Bu3RA2jA.js.map +0 -1
- package/dist/contract-DO7k0ua0.cjs.map +0 -1
package/dist/contract/host.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_contract = require("../contract-
|
|
2
|
+
const require_contract = require("../contract-CMb6PYbf.cjs");
|
|
3
3
|
let _embedpdf_core = require("@embedpdf/core");
|
|
4
4
|
let _embedpdf_engine_core_public = require("@embedpdf/engine-core/public");
|
|
5
5
|
let _embedpdf_engine_core_runtime = require("@embedpdf/engine-core/runtime");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.cjs","names":["PublicFormToken"],"sources":["../../src/host-contract.ts"],"sourcesContent":["/**\n * @embedpdf/plugin-form/contract/host: the host lens, for the framework\n * layers and the actions plugin: loading a page's widgets, the widget event\n * feed, the text being typed, and the actions plugin's executors and sinks.\n * Same runtime token as the public one, typed wider.\n */\nimport { createHostToken } from '@embedpdf/core';\nimport type { TextEditorLayout } from '@embedpdf/core-form';\nimport type {\n AnnotationRef,\n FormEffect,\n FormFieldRef,\n PageRef,\n PdfActionTargetRef,\n} from '@embedpdf/engine-core/runtime';\nimport type {\n ActionContext,\n ActionDiagnostic,\n ActionOrigin,\n ActionSubmitRequest,\n PdfAnnotationEventKind,\n SubmitIntent,\n} from '@embedpdf/plugin-actions/contract';\nimport type { FormCommitSinkResult } from '@embedpdf/plugin-actions/contract/host';\nimport type { FontCss } from '@embedpdf/plugin-fonts/contract';\nimport type { AppearancePicture } from '@embedpdf/plugin-render/contract/host';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"host.cjs","names":["PublicFormToken"],"sources":["../../src/host-contract.ts"],"sourcesContent":["/**\n * @embedpdf/plugin-form/contract/host: the host lens, for the framework\n * layers and the actions plugin: loading a page's widgets, the widget event\n * feed, the text being typed, and the actions plugin's executors and sinks.\n * Same runtime token as the public one, typed wider.\n */\nimport { createHostToken } from '@embedpdf/core';\nimport type { TextEditorLayout } from '@embedpdf/core-form';\nimport type {\n AnnotationRef,\n FormEffect,\n FormFieldRef,\n PageRef,\n PdfActionTargetRef,\n} from '@embedpdf/engine-core/runtime';\nimport type {\n ActionContext,\n ActionDiagnostic,\n ActionOrigin,\n ActionSubmitRequest,\n PdfAnnotationEventKind,\n SubmitIntent,\n} from '@embedpdf/plugin-actions/contract';\nimport type { FormCommitSinkResult } from '@embedpdf/plugin-actions/contract/host';\nimport type { FontCss } from '@embedpdf/plugin-fonts/contract';\nimport type { AppearancePicture } from '@embedpdf/plugin-render/contract/host';\n\nimport type {\n FormCapability,\n FormCommitResult,\n FormSetValueResult,\n FormWidgetAnchor,\n} from './contract';\nimport type { Box, ShownWidget } from './model';\nimport type { WidgetPainting } from './services/looks';\nimport { FormToken as PublicFormToken } from './token';\n\nexport * from './contract';\nexport type { ShownWidget } from './model';\nexport type { WidgetPainting } from './services/looks';\nexport type { TextEditorLayout } from '@embedpdf/core-form';\n\n/**\n * A field box's control, as the host shows it: what the cursor goes into. The form layer lends\n * one for each box on screen (`attachFocusTarget`); in a browser it focuses the control's\n * element without scrolling (`@embedpdf/web`'s `bindFieldFocus`), and the Stage brings the box\n * into view.\n */\nexport interface FormFocusTarget {\n /**\n * Whether the control takes the cursor, asked each time the cursor is about to move. A box\n * that holds nothing to focus says no: a signature field with nothing to sign it, a control\n * of an app's own with no element Tab stops at. `focus()`, `focusNext()` and Tab pass over\n * its field. A target without it takes the cursor.\n */\n takesCursor?(): boolean;\n /**\n * Take the cursor; `select` selects a text box's text, so typing replaces it. `false` when\n * nothing took it after all: the cursor then passes over the box, as over one that says it\n * takes none. A target that answers anything else, or nothing, took it: the return is\n * `unknown`, so one whose `focus` returns a timer or a promise fits too.\n */\n focus(options: { readonly select: boolean }): unknown;\n}\n\n/**\n * The host lens: members for the framework layers and sibling plugins (the\n * widget event feed, the text being typed, and the actions plugin's\n * executors and sinks). Application code uses the public capability.\n */\nexport interface FormHostCapability extends FormCapability {\n /** Load a page's widgets (one annotation read per page), so `listWidgets(page)` has them. */\n ensureLoaded(page: PageRef): Promise<void>;\n /**\n * The widgets a page shows, in the order the page draws them, each with the appearance state it\n * shows and whether its look is `pending` (the view's isn't the confirmed one yet); hidden ones\n * are left out. The form layer paints their pictures from it, and the painter's drawing\n * (`getWidgetPainting`) for a pending one or one whose picture is older than its look. In design\n * mode, while the widgets are lent to the annotation plugin, none: the annotation layer draws\n * them.\n */\n listShownWidgets(page: PageRef): readonly ShownWidget[];\n /**\n * What a page's widget pictures depend on: its widgets at their picture\n * versions (`5@2|6@7`). Load the pictures again when it changes, or when\n * the appearance scale does. A checkbox that only switches its state\n * doesn't move it.\n */\n getAppearanceEpoch(page: PageRef): string;\n /**\n * Every picture of a page's widgets, at rest, in every state, each with the\n * picture version of its widget (`ShownWidget.pictureVersion`), through the\n * render plugin; none without it. The form layer and design mode share them.\n */\n renderAppearances(\n page: PageRef,\n scale: number,\n signal?: AbortSignal,\n ): Promise<readonly AppearancePicture[]>;\n /**\n * What the widget looks like as the view has it, drawn by the painter (`@embedpdf/core-form`): its\n * scene in page space, its text in the engine's own faces (each glyphs node carries the program\n * to mount). The same object while nothing it shows changes; `null` for a widget the painter\n * doesn't draw (a signature).\n */\n getWidgetPainting(widget: AnnotationRef): WidgetPainting | null;\n /**\n * Where a text field's editor shows `text` (what is typed in it), so it sits where the engine\n * will draw it: the face, the size the engine draws at (a fitted size resolved for `text`),\n * the text's box inside the widget's, one line's height and a comb's spacing, in page points.\n * `null` for a widget that isn't a text field's.\n */\n getTextEditorLayout(widget: AnnotationRef, text: string): TextEditorLayout | null;\n /**\n * How a control the painter doesn't draw (a list box's rows) draws the widget's text: its font\n * as CSS, as the engine picks it (the fonts plugin's; without it, the standard font the engine\n * falls back to), with the programs the family list names, to mount. `null` for a widget that\n * isn't there.\n */\n getWidgetFontCss(widget: AnnotationRef): FontCss | null;\n /** The page box in page space, for keeping a placement on the page; `null` for a page that isn't there. */\n getPageBox(page: PageRef): Box | null;\n /**\n * Where UI attaches to one box of a field: its page and where the box stands, following the box\n * as it is moved in design mode. The same object until the box moves; `null` for a box that\n * isn't there, or that shows nowhere.\n */\n getWidgetAnchor(widget: AnnotationRef): FormWidgetAnchor | null;\n /** Whether the cursor is in this box. */\n isWidgetFocused(widget: AnnotationRef): boolean;\n /**\n * Lend the plugin a box's control while it's on screen, so `focus()` and `focusNext()` can put\n * the cursor in it; a box `focus()` asked for before its page came in takes the cursor now.\n * Lend one for a box that holds nothing to focus too, saying so (`takesCursor`): the cursor\n * passes over a box on screen that takes none, and nothing else tells the plugin that a box\n * it hasn't seen can't take it. Returns the call that takes it back.\n */\n attachFocusTarget(widget: AnnotationRef, target: FormFocusTarget): () => void;\n /**\n * The arrow keys in a radio group: move the cursor to the group's next button (the one before,\n * `backward`), going round, and pick it, as a click on it does. `false` for a widget that isn't a\n * radio button the user can pick, or a group of one.\n */\n moveInGroup(widget: AnnotationRef, backward: boolean): boolean;\n /** Send a widget's pointer or focus event to the actions plugin, which runs its `/AA` actions. */\n notifyWidgetEvent(\n field: FormFieldRef,\n widget: AnnotationRef,\n event: PdfAnnotationEventKind,\n ): void;\n /** Run a ResetForm action: reset the fields it names (or all but them), then recalculate. */\n resetFormAction(\n fields: PdfActionTargetRef[] | null,\n exclude: boolean,\n origin?: ActionOrigin,\n ): Promise<FormCommitResult>;\n /** The fields a SubmitForm action sends: the form as the user sees it, once every fill on its way is answered. */\n resolveSubmitDataset(\n intent: SubmitIntent,\n actionContext: ActionContext,\n diagnose: (diagnostic: ActionDiagnostic) => void,\n ): Promise<ActionSubmitRequest>;\n /**\n * Write what a document script changed in the fields, with the calculations a value causes,\n * as one change: shown at once, sent once the script's transaction ends. Never rejects; a\n * change it can't stage reports why, and the engine's refusal comes through the change queue.\n */\n commitScriptFormEffects(effects: FormEffect[]): Promise<FormCommitSinkResult>;\n /**\n * The text someone is typing in a field, before it's written (write/typing.ts): a keystroke\n * calls `draftText`, blur or Enter `commitDraftText` (the field's scripts run then), Escape\n * `discardDraftText`. A download writes a draft first, like Acrobat commits the field being\n * edited before it saves. `commitDraftText` resolves `null` when there's nothing to write.\n */\n draftText(field: FormFieldRef, text: string): void;\n commitDraftText(field: FormFieldRef): Promise<FormSetValueResult | null>;\n discardDraftText(field: FormFieldRef): void;\n}\n\nexport const FormToken = createHostToken<FormHostCapability>(PublicFormToken);\n"],"mappings":";;;;;;;;;;;;AAmLA,MAAa,aAAA,GAAA,eAAA,gBAAA,CAAgDA,iBAAAA,SAAe"}
|
package/dist/contract/host.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { a as WidgetPainting, i as TextEditorLayout, n as FormHostCapability, r as FormToken, t as FormFocusTarget } from "../host-contract-
|
|
3
|
-
export { type Box, FORM_DEFAULTS, FillableFields, type FormBundle, FormCapability, FormCommitResult, FormCommitStatus, FormConfig, FormDuplicateOptions, FormDuplicateResult, FormExportSelection, type FormField, FormFieldCreatedEvent, FormFieldDeletedEvent, type FormFieldDraft, FormFieldFlagSetting, type FormFieldKind, type FormFieldPatch, type FormFieldRef, FormFieldResult, FormFieldSetting, FormFieldSettings, FormFieldUpdatedEvent, type FormFieldValue, FormFilter, FormFocusChangedEvent, FormFocusNextOptions, FormFocusOptions, FormFocusTarget, FormHostCapability, type FormImportDrop, type FormImportDropReason, type FormImportOptions, FormImportResult, type FormKind, FormPlainValue, type FormRepairOptions, type FormRepairResult, FormResetResult, FormResyncedEvent, FormSetValueResult, FormSetValueStatus, FormSettings, type FormSnapshot, FormToken, FormTransfer, FormUiEffect, FormValidation, FormValidationRejectedEvent, FormValueChangedEvent, FormWidgetAddResult, type FormWidgetItem, type FormWidgetLook, type ShownWidget, type TextEditorLayout, WidgetActivationResult, WidgetAddress, type WidgetAnnotation, type WidgetHit, type WidgetPainting, toFieldRef };
|
|
1
|
+
import { $ as WidgetActivationResult, A as FormGroupMoveResult, B as FormResetResult, C as FormFieldUpdatedEvent, D as FormFocusNextOptions, E as FormFocusChangedEvent, F as FormImportResult, G as FormSnapshot, H as FormSetValueResult, I as FormKind, J as FormValidation, K as FormTransfer, L as FormPlainValue, M as FormImportDrop, N as FormImportDropReason, O as FormFocusOptions, P as FormImportOptions, Q as FormWidgetAnchor, R as FormRepairOptions, S as FormFieldSettings, T as FormFilter, U as FormSetValueStatus, V as FormResyncedEvent, W as FormSettings, X as FormValueChangedEvent, Y as FormValidationRejectedEvent, Z as FormWidgetAddResult, _ as FormFieldKind, a as FormCommitResult, at as GroupPosition, b as FormFieldResult, c as FormDesignGroupChangedEvent, d as FormExportSelection, dt as WidgetHit, et as WidgetAddress, f as FormField, ft as WidgetPlace, g as FormFieldFlagSetting, h as FormFieldDraft, i as FormCapability, it as FormWidgetItem, j as FormGroupsChangedEvent, k as FormGroupInput, l as FormDuplicateOptions, lt as FormWidgetLook, m as FormFieldDeletedEvent, n as FillableFields, nt as toFieldRef, o as FormCommitStatus, ot as FormGroup, p as FormFieldCreatedEvent, q as FormUiEffect, r as FormBundle, s as FormConfig, st as Box, t as FORM_DEFAULTS, tt as WidgetAnnotation, u as FormDuplicateResult, ut as ShownWidget, v as FormFieldPatch, w as FormFieldValue, x as FormFieldSetting, y as FormFieldRef, z as FormRepairResult } from "../contract-B7rB7jYx.cjs";
|
|
2
|
+
import { a as WidgetPainting, i as TextEditorLayout, n as FormHostCapability, r as FormToken, t as FormFocusTarget } from "../host-contract-C8HiD6sJ.cjs";
|
|
3
|
+
export { type Box, FORM_DEFAULTS, FillableFields, type FormBundle, FormCapability, FormCommitResult, FormCommitStatus, FormConfig, FormDesignGroupChangedEvent, FormDuplicateOptions, FormDuplicateResult, FormExportSelection, type FormField, FormFieldCreatedEvent, FormFieldDeletedEvent, type FormFieldDraft, FormFieldFlagSetting, type FormFieldKind, type FormFieldPatch, type FormFieldRef, FormFieldResult, FormFieldSetting, FormFieldSettings, FormFieldUpdatedEvent, type FormFieldValue, FormFilter, FormFocusChangedEvent, FormFocusNextOptions, FormFocusOptions, FormFocusTarget, type FormGroup, FormGroupInput, FormGroupMoveResult, FormGroupsChangedEvent, FormHostCapability, type FormImportDrop, type FormImportDropReason, type FormImportOptions, FormImportResult, type FormKind, FormPlainValue, type FormRepairOptions, type FormRepairResult, FormResetResult, FormResyncedEvent, FormSetValueResult, FormSetValueStatus, FormSettings, type FormSnapshot, FormToken, FormTransfer, FormUiEffect, FormValidation, FormValidationRejectedEvent, FormValueChangedEvent, FormWidgetAddResult, FormWidgetAnchor, type FormWidgetItem, type FormWidgetLook, type GroupPosition, type ShownWidget, type TextEditorLayout, WidgetActivationResult, WidgetAddress, type WidgetAnnotation, type WidgetHit, type WidgetPainting, type WidgetPlace, toFieldRef };
|
package/dist/contract/host.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { a as WidgetPainting, i as TextEditorLayout, n as FormHostCapability, r as FormToken, t as FormFocusTarget } from "../host-contract-
|
|
3
|
-
export { type Box, FORM_DEFAULTS, FillableFields, type FormBundle, FormCapability, FormCommitResult, FormCommitStatus, FormConfig, FormDuplicateOptions, FormDuplicateResult, FormExportSelection, type FormField, FormFieldCreatedEvent, FormFieldDeletedEvent, type FormFieldDraft, FormFieldFlagSetting, type FormFieldKind, type FormFieldPatch, type FormFieldRef, FormFieldResult, FormFieldSetting, FormFieldSettings, FormFieldUpdatedEvent, type FormFieldValue, FormFilter, FormFocusChangedEvent, FormFocusNextOptions, FormFocusOptions, FormFocusTarget, FormHostCapability, type FormImportDrop, type FormImportDropReason, type FormImportOptions, FormImportResult, type FormKind, FormPlainValue, type FormRepairOptions, type FormRepairResult, FormResetResult, FormResyncedEvent, FormSetValueResult, FormSetValueStatus, FormSettings, type FormSnapshot, FormToken, FormTransfer, FormUiEffect, FormValidation, FormValidationRejectedEvent, FormValueChangedEvent, FormWidgetAddResult, type FormWidgetItem, type FormWidgetLook, type ShownWidget, type TextEditorLayout, WidgetActivationResult, WidgetAddress, type WidgetAnnotation, type WidgetHit, type WidgetPainting, toFieldRef };
|
|
1
|
+
import { $ as WidgetActivationResult, A as FormGroupMoveResult, B as FormResetResult, C as FormFieldUpdatedEvent, D as FormFocusNextOptions, E as FormFocusChangedEvent, F as FormImportResult, G as FormSnapshot, H as FormSetValueResult, I as FormKind, J as FormValidation, K as FormTransfer, L as FormPlainValue, M as FormImportDrop, N as FormImportDropReason, O as FormFocusOptions, P as FormImportOptions, Q as FormWidgetAnchor, R as FormRepairOptions, S as FormFieldSettings, T as FormFilter, U as FormSetValueStatus, V as FormResyncedEvent, W as FormSettings, X as FormValueChangedEvent, Y as FormValidationRejectedEvent, Z as FormWidgetAddResult, _ as FormFieldKind, a as FormCommitResult, at as GroupPosition, b as FormFieldResult, c as FormDesignGroupChangedEvent, d as FormExportSelection, dt as WidgetHit, et as WidgetAddress, f as FormField, ft as WidgetPlace, g as FormFieldFlagSetting, h as FormFieldDraft, i as FormCapability, it as FormWidgetItem, j as FormGroupsChangedEvent, k as FormGroupInput, l as FormDuplicateOptions, lt as FormWidgetLook, m as FormFieldDeletedEvent, n as FillableFields, nt as toFieldRef, o as FormCommitStatus, ot as FormGroup, p as FormFieldCreatedEvent, q as FormUiEffect, r as FormBundle, s as FormConfig, st as Box, t as FORM_DEFAULTS, tt as WidgetAnnotation, u as FormDuplicateResult, ut as ShownWidget, v as FormFieldPatch, w as FormFieldValue, x as FormFieldSetting, y as FormFieldRef, z as FormRepairResult } from "../contract-BkTJQ39E.js";
|
|
2
|
+
import { a as WidgetPainting, i as TextEditorLayout, n as FormHostCapability, r as FormToken, t as FormFocusTarget } from "../host-contract-cOcPAwaN.js";
|
|
3
|
+
export { type Box, FORM_DEFAULTS, FillableFields, type FormBundle, FormCapability, FormCommitResult, FormCommitStatus, FormConfig, FormDesignGroupChangedEvent, FormDuplicateOptions, FormDuplicateResult, FormExportSelection, type FormField, FormFieldCreatedEvent, FormFieldDeletedEvent, type FormFieldDraft, FormFieldFlagSetting, type FormFieldKind, type FormFieldPatch, type FormFieldRef, FormFieldResult, FormFieldSetting, FormFieldSettings, FormFieldUpdatedEvent, type FormFieldValue, FormFilter, FormFocusChangedEvent, FormFocusNextOptions, FormFocusOptions, FormFocusTarget, type FormGroup, FormGroupInput, FormGroupMoveResult, FormGroupsChangedEvent, FormHostCapability, type FormImportDrop, type FormImportDropReason, type FormImportOptions, FormImportResult, type FormKind, FormPlainValue, type FormRepairOptions, type FormRepairResult, FormResetResult, FormResyncedEvent, FormSetValueResult, FormSetValueStatus, FormSettings, type FormSnapshot, FormToken, FormTransfer, FormUiEffect, FormValidation, FormValidationRejectedEvent, FormValueChangedEvent, FormWidgetAddResult, FormWidgetAnchor, type FormWidgetItem, type FormWidgetLook, type GroupPosition, type ShownWidget, type TextEditorLayout, WidgetActivationResult, WidgetAddress, type WidgetAnnotation, type WidgetHit, type WidgetPainting, type WidgetPlace, toFieldRef };
|
package/dist/contract/host.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as FormToken$1, n as FormTransfer, r as toFieldRef, t as FORM_DEFAULTS } from "../contract-
|
|
1
|
+
import { i as FormToken$1, n as FormTransfer, r as toFieldRef, t as FORM_DEFAULTS } from "../contract-J_QN_Igp.js";
|
|
2
2
|
import { createHostToken } from "@embedpdf/core";
|
|
3
3
|
//#region src/host-contract.ts
|
|
4
4
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","names":["PublicFormToken"],"sources":["../../src/host-contract.ts"],"sourcesContent":["/**\n * @embedpdf/plugin-form/contract/host: the host lens, for the framework\n * layers and the actions plugin: loading a page's widgets, the widget event\n * feed, the text being typed, and the actions plugin's executors and sinks.\n * Same runtime token as the public one, typed wider.\n */\nimport { createHostToken } from '@embedpdf/core';\nimport type { TextEditorLayout } from '@embedpdf/core-form';\nimport type {\n AnnotationRef,\n FormEffect,\n FormFieldRef,\n PageRef,\n PdfActionTargetRef,\n} from '@embedpdf/engine-core/runtime';\nimport type {\n ActionContext,\n ActionDiagnostic,\n ActionOrigin,\n ActionSubmitRequest,\n PdfAnnotationEventKind,\n SubmitIntent,\n} from '@embedpdf/plugin-actions/contract';\nimport type { FormCommitSinkResult } from '@embedpdf/plugin-actions/contract/host';\nimport type { FontCss } from '@embedpdf/plugin-fonts/contract';\nimport type { AppearancePicture } from '@embedpdf/plugin-render/contract/host';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"host.js","names":["PublicFormToken"],"sources":["../../src/host-contract.ts"],"sourcesContent":["/**\n * @embedpdf/plugin-form/contract/host: the host lens, for the framework\n * layers and the actions plugin: loading a page's widgets, the widget event\n * feed, the text being typed, and the actions plugin's executors and sinks.\n * Same runtime token as the public one, typed wider.\n */\nimport { createHostToken } from '@embedpdf/core';\nimport type { TextEditorLayout } from '@embedpdf/core-form';\nimport type {\n AnnotationRef,\n FormEffect,\n FormFieldRef,\n PageRef,\n PdfActionTargetRef,\n} from '@embedpdf/engine-core/runtime';\nimport type {\n ActionContext,\n ActionDiagnostic,\n ActionOrigin,\n ActionSubmitRequest,\n PdfAnnotationEventKind,\n SubmitIntent,\n} from '@embedpdf/plugin-actions/contract';\nimport type { FormCommitSinkResult } from '@embedpdf/plugin-actions/contract/host';\nimport type { FontCss } from '@embedpdf/plugin-fonts/contract';\nimport type { AppearancePicture } from '@embedpdf/plugin-render/contract/host';\n\nimport type {\n FormCapability,\n FormCommitResult,\n FormSetValueResult,\n FormWidgetAnchor,\n} from './contract';\nimport type { Box, ShownWidget } from './model';\nimport type { WidgetPainting } from './services/looks';\nimport { FormToken as PublicFormToken } from './token';\n\nexport * from './contract';\nexport type { ShownWidget } from './model';\nexport type { WidgetPainting } from './services/looks';\nexport type { TextEditorLayout } from '@embedpdf/core-form';\n\n/**\n * A field box's control, as the host shows it: what the cursor goes into. The form layer lends\n * one for each box on screen (`attachFocusTarget`); in a browser it focuses the control's\n * element without scrolling (`@embedpdf/web`'s `bindFieldFocus`), and the Stage brings the box\n * into view.\n */\nexport interface FormFocusTarget {\n /**\n * Whether the control takes the cursor, asked each time the cursor is about to move. A box\n * that holds nothing to focus says no: a signature field with nothing to sign it, a control\n * of an app's own with no element Tab stops at. `focus()`, `focusNext()` and Tab pass over\n * its field. A target without it takes the cursor.\n */\n takesCursor?(): boolean;\n /**\n * Take the cursor; `select` selects a text box's text, so typing replaces it. `false` when\n * nothing took it after all: the cursor then passes over the box, as over one that says it\n * takes none. A target that answers anything else, or nothing, took it: the return is\n * `unknown`, so one whose `focus` returns a timer or a promise fits too.\n */\n focus(options: { readonly select: boolean }): unknown;\n}\n\n/**\n * The host lens: members for the framework layers and sibling plugins (the\n * widget event feed, the text being typed, and the actions plugin's\n * executors and sinks). Application code uses the public capability.\n */\nexport interface FormHostCapability extends FormCapability {\n /** Load a page's widgets (one annotation read per page), so `listWidgets(page)` has them. */\n ensureLoaded(page: PageRef): Promise<void>;\n /**\n * The widgets a page shows, in the order the page draws them, each with the appearance state it\n * shows and whether its look is `pending` (the view's isn't the confirmed one yet); hidden ones\n * are left out. The form layer paints their pictures from it, and the painter's drawing\n * (`getWidgetPainting`) for a pending one or one whose picture is older than its look. In design\n * mode, while the widgets are lent to the annotation plugin, none: the annotation layer draws\n * them.\n */\n listShownWidgets(page: PageRef): readonly ShownWidget[];\n /**\n * What a page's widget pictures depend on: its widgets at their picture\n * versions (`5@2|6@7`). Load the pictures again when it changes, or when\n * the appearance scale does. A checkbox that only switches its state\n * doesn't move it.\n */\n getAppearanceEpoch(page: PageRef): string;\n /**\n * Every picture of a page's widgets, at rest, in every state, each with the\n * picture version of its widget (`ShownWidget.pictureVersion`), through the\n * render plugin; none without it. The form layer and design mode share them.\n */\n renderAppearances(\n page: PageRef,\n scale: number,\n signal?: AbortSignal,\n ): Promise<readonly AppearancePicture[]>;\n /**\n * What the widget looks like as the view has it, drawn by the painter (`@embedpdf/core-form`): its\n * scene in page space, its text in the engine's own faces (each glyphs node carries the program\n * to mount). The same object while nothing it shows changes; `null` for a widget the painter\n * doesn't draw (a signature).\n */\n getWidgetPainting(widget: AnnotationRef): WidgetPainting | null;\n /**\n * Where a text field's editor shows `text` (what is typed in it), so it sits where the engine\n * will draw it: the face, the size the engine draws at (a fitted size resolved for `text`),\n * the text's box inside the widget's, one line's height and a comb's spacing, in page points.\n * `null` for a widget that isn't a text field's.\n */\n getTextEditorLayout(widget: AnnotationRef, text: string): TextEditorLayout | null;\n /**\n * How a control the painter doesn't draw (a list box's rows) draws the widget's text: its font\n * as CSS, as the engine picks it (the fonts plugin's; without it, the standard font the engine\n * falls back to), with the programs the family list names, to mount. `null` for a widget that\n * isn't there.\n */\n getWidgetFontCss(widget: AnnotationRef): FontCss | null;\n /** The page box in page space, for keeping a placement on the page; `null` for a page that isn't there. */\n getPageBox(page: PageRef): Box | null;\n /**\n * Where UI attaches to one box of a field: its page and where the box stands, following the box\n * as it is moved in design mode. The same object until the box moves; `null` for a box that\n * isn't there, or that shows nowhere.\n */\n getWidgetAnchor(widget: AnnotationRef): FormWidgetAnchor | null;\n /** Whether the cursor is in this box. */\n isWidgetFocused(widget: AnnotationRef): boolean;\n /**\n * Lend the plugin a box's control while it's on screen, so `focus()` and `focusNext()` can put\n * the cursor in it; a box `focus()` asked for before its page came in takes the cursor now.\n * Lend one for a box that holds nothing to focus too, saying so (`takesCursor`): the cursor\n * passes over a box on screen that takes none, and nothing else tells the plugin that a box\n * it hasn't seen can't take it. Returns the call that takes it back.\n */\n attachFocusTarget(widget: AnnotationRef, target: FormFocusTarget): () => void;\n /**\n * The arrow keys in a radio group: move the cursor to the group's next button (the one before,\n * `backward`), going round, and pick it, as a click on it does. `false` for a widget that isn't a\n * radio button the user can pick, or a group of one.\n */\n moveInGroup(widget: AnnotationRef, backward: boolean): boolean;\n /** Send a widget's pointer or focus event to the actions plugin, which runs its `/AA` actions. */\n notifyWidgetEvent(\n field: FormFieldRef,\n widget: AnnotationRef,\n event: PdfAnnotationEventKind,\n ): void;\n /** Run a ResetForm action: reset the fields it names (or all but them), then recalculate. */\n resetFormAction(\n fields: PdfActionTargetRef[] | null,\n exclude: boolean,\n origin?: ActionOrigin,\n ): Promise<FormCommitResult>;\n /** The fields a SubmitForm action sends: the form as the user sees it, once every fill on its way is answered. */\n resolveSubmitDataset(\n intent: SubmitIntent,\n actionContext: ActionContext,\n diagnose: (diagnostic: ActionDiagnostic) => void,\n ): Promise<ActionSubmitRequest>;\n /**\n * Write what a document script changed in the fields, with the calculations a value causes,\n * as one change: shown at once, sent once the script's transaction ends. Never rejects; a\n * change it can't stage reports why, and the engine's refusal comes through the change queue.\n */\n commitScriptFormEffects(effects: FormEffect[]): Promise<FormCommitSinkResult>;\n /**\n * The text someone is typing in a field, before it's written (write/typing.ts): a keystroke\n * calls `draftText`, blur or Enter `commitDraftText` (the field's scripts run then), Escape\n * `discardDraftText`. A download writes a draft first, like Acrobat commits the field being\n * edited before it saves. `commitDraftText` resolves `null` when there's nothing to write.\n */\n draftText(field: FormFieldRef, text: string): void;\n commitDraftText(field: FormFieldRef): Promise<FormSetValueResult | null>;\n discardDraftText(field: FormFieldRef): void;\n}\n\nexport const FormToken = createHostToken<FormHostCapability>(PublicFormToken);\n"],"mappings":";;;;;;;;;AAmLA,MAAa,YAAY,gBAAoCA,WAAe"}
|
|
@@ -2,6 +2,7 @@ import { BatchResult, DeepPartial, EventHook, EventOrigin, HistoryOptions, Opera
|
|
|
2
2
|
import { ScriptDiagnostic, ScriptExecutionError, ScriptUiEffect } from "@embedpdf/core-acrojs";
|
|
3
3
|
import { AnnotationRef, FieldPosition, FormBundle, FormBundle as FormBundle$1, FormField, FormField as FormField$1, FormFieldDraft, FormFieldDraft as FormFieldDraft$1, FormFieldKind, FormFieldKind as FormFieldKind$1, FormFieldOption, FormFieldPatch, FormFieldPatch as FormFieldPatch$1, FormFieldRef, FormFieldRef as FormFieldRef$1, FormFieldValue, FormFieldValue as FormFieldValue$1, FormImportDrop, FormImportDrop as FormImportDrop$1, FormImportDropReason, FormImportOptions, FormImportOptions as FormImportOptions$1, FormKind, FormKind as FormKind$1, FormRepairOptions, FormRepairOptions as FormRepairOptions$1, FormRepairResult, FormRepairResult as FormRepairResult$1, FormSnapshot, FormSnapshot as FormSnapshot$1, FormWidget, PageRef, WidgetAnnotation, WidgetAnnotation as WidgetAnnotation$1, WidgetPatch, WidgetPlacement, toFieldRef } from "@embedpdf/engine-core/runtime";
|
|
4
4
|
import { ActionOrigin, ActionTriggerResult } from "@embedpdf/plugin-actions/contract";
|
|
5
|
+
import { RecordAccent } from "@embedpdf/core-annotation";
|
|
5
6
|
import { FormTransfer } from "@embedpdf/engine-core/public";
|
|
6
7
|
//#region src/model.d.ts
|
|
7
8
|
/** A page-space box (top-left origin, y-down, PDF points). */
|
|
@@ -37,11 +38,26 @@ interface FormWidgetLook {
|
|
|
37
38
|
readonly fontSize: number | null;
|
|
38
39
|
readonly textAlign: 'left' | 'center' | 'right';
|
|
39
40
|
}
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Where a widget is on its page, as the engine reads it: the frame its
|
|
43
|
+
* contents are laid out in, its quarter turn, and the rect it stands in. An
|
|
44
|
+
* unturned widget's frame is its rect.
|
|
45
|
+
*/
|
|
46
|
+
interface WidgetPlace {
|
|
47
|
+
/** The frame the widget's contents are laid out in, before its turn. */
|
|
48
|
+
readonly box: Box;
|
|
49
|
+
/** Its turn, degrees clockwise about the middle of `box`: a quarter turn (`/MK /R`), `0` upright. */
|
|
50
|
+
readonly rotation: 0 | 90 | 180 | 270;
|
|
51
|
+
/** Where it stands on its page: `box` turned (its sides swapped at 90 and 270). */
|
|
44
52
|
readonly rect: Box;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A widget a page shows: its address, where it is, the appearance state it
|
|
56
|
+
* shows, and how new its look is. Its picture and the painter's drawing both
|
|
57
|
+
* fill `rect`, where it stands: each holds the widget's turn already.
|
|
58
|
+
*/
|
|
59
|
+
interface ShownWidget extends WidgetPlace {
|
|
60
|
+
readonly ref: AnnotationRef;
|
|
45
61
|
/** The state it shows (`/AS`), or `null` for a widget without states. */
|
|
46
62
|
readonly appearanceState: string | null;
|
|
47
63
|
/**
|
|
@@ -52,25 +68,56 @@ interface ShownWidget {
|
|
|
52
68
|
/** Its confirmed picture version: a picture drawn at another one shows another look. */
|
|
53
69
|
readonly pictureVersion: number;
|
|
54
70
|
}
|
|
55
|
-
/** A widget hit: the annotation under the point
|
|
56
|
-
interface WidgetHit {
|
|
71
|
+
/** A widget hit: the annotation under the point, the field it belongs to, and where it is. */
|
|
72
|
+
interface WidgetHit extends WidgetPlace {
|
|
57
73
|
readonly annotObjectNumber: number;
|
|
58
74
|
readonly field: FormField;
|
|
59
|
-
/** The widget's page-space box. */
|
|
60
|
-
readonly box: Box;
|
|
61
75
|
}
|
|
62
76
|
/** The box the cursor is in: its field and its annotation object number. */
|
|
63
77
|
interface FocusedWidget {
|
|
64
78
|
readonly field: FieldKey;
|
|
65
79
|
readonly widget: number;
|
|
66
80
|
}
|
|
67
|
-
/**
|
|
81
|
+
/** A group as the app named it for this document (`setGroups()`): what it gave, nothing worked out. */
|
|
82
|
+
interface NamedGroup {
|
|
83
|
+
readonly id: string;
|
|
84
|
+
readonly label: string | null;
|
|
85
|
+
readonly color: string | null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The plugin's session state: the box the cursor is in, the group that fields placed with a
|
|
89
|
+
* tool go in, and who the app says this document's groups are. A write in flight shows in the
|
|
90
|
+
* mirror's view.
|
|
91
|
+
*/
|
|
68
92
|
interface FormModel {
|
|
69
93
|
readonly focused: FocusedWidget | null;
|
|
94
|
+
/** The group a field placed with a tool goes in; `null` when it names none. */
|
|
95
|
+
readonly designGroup: string | null;
|
|
96
|
+
/** The groups the app named, in its order, each id once. */
|
|
97
|
+
readonly groups: readonly NamedGroup[];
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/services/groups.d.ts
|
|
101
|
+
/** One of the form's groups, as `listGroups()` gives it. */
|
|
102
|
+
interface FormGroup {
|
|
103
|
+
/** The group: the id its fields carry. */
|
|
104
|
+
readonly id: string;
|
|
105
|
+
/** Who the group is, for people; `null` when the app gives it no label. */
|
|
106
|
+
readonly label: string | null;
|
|
107
|
+
/**
|
|
108
|
+
* The color its fields show in, a CSS color: the one the app gave, else one
|
|
109
|
+
* of {@link GROUP_COLORS} by the group's place in the list.
|
|
110
|
+
*/
|
|
111
|
+
readonly color: string;
|
|
70
112
|
}
|
|
71
113
|
//#endregion
|
|
72
114
|
//#region src/read/fill-items.d.ts
|
|
73
|
-
|
|
115
|
+
/** Where a radio button comes among its group's buttons: `position` from 1, of `size`. */
|
|
116
|
+
interface GroupPosition {
|
|
117
|
+
readonly position: number;
|
|
118
|
+
readonly size: number;
|
|
119
|
+
}
|
|
120
|
+
interface FormWidgetItemBase extends WidgetPlace {
|
|
74
121
|
key: FieldKey;
|
|
75
122
|
/** The field this widget belongs to: what the write verbs take. */
|
|
76
123
|
fieldRef: FormFieldRef;
|
|
@@ -78,13 +125,33 @@ interface FormWidgetItemBase {
|
|
|
78
125
|
annotObjectNumber: number;
|
|
79
126
|
/** The widget's annotation address (null until the engine has placed it). */
|
|
80
127
|
annotationRef: AnnotationRef | null;
|
|
81
|
-
/**
|
|
82
|
-
|
|
128
|
+
/** The box's own address: what `getWidget()` takes, and what UI anchored to the box is given. */
|
|
129
|
+
ref: AnnotationRef;
|
|
130
|
+
/** The group the field is in, or `null`. */
|
|
131
|
+
groupId: string | null;
|
|
132
|
+
/** The session may fill the field in, or sign it for a signature field: its permissions alone. */
|
|
133
|
+
canFill: boolean;
|
|
134
|
+
/** The form asks for a value: the field's Required flag. */
|
|
135
|
+
required: boolean;
|
|
136
|
+
/** The field holds nothing yet, by the rule `validate()` checks a required field with. */
|
|
137
|
+
empty: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* What the box shows its group in: the group's color, a CSS color, and how strongly it shows
|
|
140
|
+
* (the `fields.tint` setting), while the session may fill the field in and the field still
|
|
141
|
+
* takes a value (it isn't a push button, read-only, nor a signed signature). `null`
|
|
142
|
+
* otherwise, for a field in no group, and while the tint is `0`: the box shows as the PDF has
|
|
143
|
+
* it. The same shape a lent field has on the annotation layer.
|
|
144
|
+
*/
|
|
145
|
+
accent: RecordAccent | null;
|
|
83
146
|
/** How the widget looks in the PDF. */
|
|
84
147
|
look: FormWidgetLook;
|
|
85
148
|
/** A read-only field, no permission to fill, filling it turned off (`fillable`), or a write on its way: draw it, don't take input. */
|
|
86
149
|
disabled: boolean;
|
|
87
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* Accessible name: the field's tooltip (`/TU`) when it has one, else its full name. A radio
|
|
152
|
+
* button adds the option it stands for, its export value: `Plan: monthly`. A field of a group
|
|
153
|
+
* the app gives a label says whose it is last: `Plan: monthly, Dana Smith`.
|
|
154
|
+
*/
|
|
88
155
|
label: string;
|
|
89
156
|
}
|
|
90
157
|
/** One widget as a fill control draws it: where, how it looks, its control and its value. */
|
|
@@ -97,10 +164,21 @@ type FormWidgetItem = FormWidgetItemBase & ({
|
|
|
97
164
|
comb: boolean;
|
|
98
165
|
} | {
|
|
99
166
|
control: 'toggle';
|
|
100
|
-
kind: 'checkbox'
|
|
167
|
+
kind: 'checkbox';
|
|
101
168
|
checked: boolean;
|
|
102
169
|
/** The export value that checks this widget. */
|
|
103
170
|
exportValue: string;
|
|
171
|
+
} | {
|
|
172
|
+
control: 'toggle';
|
|
173
|
+
kind: 'radio';
|
|
174
|
+
checked: boolean;
|
|
175
|
+
/** The export value that checks this widget: the option it stands for. */
|
|
176
|
+
exportValue: string;
|
|
177
|
+
/**
|
|
178
|
+
* Where the button comes among its group's buttons, in the order the arrow keys go round
|
|
179
|
+
* (Tab's): for `aria-posinset` and `aria-setsize`. Null while that order isn't known.
|
|
180
|
+
*/
|
|
181
|
+
inGroup: GroupPosition | null;
|
|
104
182
|
} | {
|
|
105
183
|
control: 'choice';
|
|
106
184
|
kind: 'combo' | 'list';
|
|
@@ -132,7 +210,8 @@ declare const FormToken: import("@embedpdf/core").CapabilityToken<FormCapability
|
|
|
132
210
|
* document while the app runs. The colors are what the viewer draws around
|
|
133
211
|
* fields (a field's own colors are in the PDF); each can also come from CSS
|
|
134
212
|
* (`--epdf-form-focus`, `--epdf-form-field-border`,
|
|
135
|
-
* `--epdf-form-field-background`, `--epdf-form-field-color
|
|
213
|
+
* `--epdf-form-field-background`, `--epdf-form-field-color`,
|
|
214
|
+
* `--epdf-form-field-tint`), which wins.
|
|
136
215
|
*/
|
|
137
216
|
interface FormSettings {
|
|
138
217
|
/**
|
|
@@ -152,6 +231,11 @@ interface FormSettings {
|
|
|
152
231
|
readonly background: string;
|
|
153
232
|
/** The text of a field that has no color of its own. */
|
|
154
233
|
readonly color: string;
|
|
234
|
+
/**
|
|
235
|
+
* How strongly a field shows its group's color ({@link FormCapability.listGroups}): from
|
|
236
|
+
* `0`, not at all, to `1`.
|
|
237
|
+
*/
|
|
238
|
+
readonly tint: number;
|
|
155
239
|
};
|
|
156
240
|
/**
|
|
157
241
|
* Which fields people may fill in by hand: `true`, every one; `false`,
|
|
@@ -162,6 +246,19 @@ interface FormSettings {
|
|
|
162
246
|
*/
|
|
163
247
|
readonly fillable: FillableFields;
|
|
164
248
|
}
|
|
249
|
+
/** One of a document's groups, as the app names it with `setGroups()`. */
|
|
250
|
+
interface FormGroupInput {
|
|
251
|
+
/** The group: the id its fields carry, and the one the permissions name. */
|
|
252
|
+
readonly id: string;
|
|
253
|
+
/** Who the group is, for people: a legend shows it, and screen readers read it after a field's name. */
|
|
254
|
+
readonly label?: string;
|
|
255
|
+
/**
|
|
256
|
+
* The color its fields show in: a CSS color, so it can name a variable of
|
|
257
|
+
* the app's (`'var(--signer-1)'`). Left out, the group gets one of eight
|
|
258
|
+
* colors by its place in the list.
|
|
259
|
+
*/
|
|
260
|
+
readonly color?: string;
|
|
261
|
+
}
|
|
165
262
|
/** Which fields people may fill in by hand: all, none, or those of these kinds. */
|
|
166
263
|
type FillableFields = boolean | readonly FormFieldKind[];
|
|
167
264
|
/** What the form settings are when the app registers none. */
|
|
@@ -214,7 +311,10 @@ type FormFieldFlagSetting = 'required' | 'readOnly' | 'noExport' | 'multiline' |
|
|
|
214
311
|
* (`null`). `choice`: one of `options`, or any text when `free`. `choices`:
|
|
215
312
|
* any of `options`. `options`: the field's options, each a label and a value.
|
|
216
313
|
* `options` of a `choice` or `choices` are the field's own values, the
|
|
217
|
-
* document's words, shown as they are.
|
|
314
|
+
* document's words, shown as they are. The `groupId` setting's are the ids of
|
|
315
|
+
* the groups the user may put the field in: show each with its group's label
|
|
316
|
+
* (`listGroups()`), and none of them (`null`) takes the field out of its
|
|
317
|
+
* group. A field has it only while the document has groups.
|
|
218
318
|
*
|
|
219
319
|
* `label` is the English name and `labelKey` its translation key
|
|
220
320
|
* (`form.settings.tooltip`): a panel shows `t(setting.labelKey, { fallback:
|
|
@@ -248,6 +348,13 @@ type FormFieldSetting = {
|
|
|
248
348
|
readonly labelKey: string;
|
|
249
349
|
readonly options: readonly string[];
|
|
250
350
|
readonly free: boolean;
|
|
351
|
+
} | {
|
|
352
|
+
readonly key: 'groupId';
|
|
353
|
+
readonly control: 'choice';
|
|
354
|
+
readonly label: string;
|
|
355
|
+
readonly labelKey: string;
|
|
356
|
+
readonly options: readonly string[];
|
|
357
|
+
readonly free: false;
|
|
251
358
|
} | {
|
|
252
359
|
readonly key: 'defaultValue';
|
|
253
360
|
readonly control: 'choices';
|
|
@@ -269,6 +376,10 @@ interface FormFieldSettings {
|
|
|
269
376
|
readonly properties: readonly FormFieldSetting[];
|
|
270
377
|
readonly values: Readonly<Record<string, unknown>>;
|
|
271
378
|
}
|
|
379
|
+
/** What `moveToGroup()` resolves: the fields as they are now, in the order given. */
|
|
380
|
+
interface FormGroupMoveResult {
|
|
381
|
+
readonly fields: readonly FormField[];
|
|
382
|
+
}
|
|
272
383
|
/** What `create()`, `update()` and `removeWidget()` resolve: the field as it is now. */
|
|
273
384
|
interface FormFieldResult {
|
|
274
385
|
readonly field: FormField;
|
|
@@ -399,12 +510,25 @@ interface FormValidationRejectedEvent {
|
|
|
399
510
|
readonly field: FormField;
|
|
400
511
|
readonly issues: readonly ScriptDiagnostic[];
|
|
401
512
|
}
|
|
513
|
+
/** Where UI attaches to one box of a field: its page and where the box stands on it (page space). */
|
|
514
|
+
interface FormWidgetAnchor {
|
|
515
|
+
readonly page: PageRef;
|
|
516
|
+
readonly bounds: Box;
|
|
517
|
+
}
|
|
402
518
|
/** The cursor moved into a field, to another one, or out of the fields (`field` is then `null`). */
|
|
403
519
|
interface FormFocusChangedEvent {
|
|
404
520
|
readonly field: FormField | null;
|
|
405
521
|
/** The box the cursor is in. */
|
|
406
522
|
readonly widget: AnnotationRef | null;
|
|
407
523
|
}
|
|
524
|
+
/** The group that fields placed with a tool go in changed (`groupId` is `null` when it names none). */
|
|
525
|
+
interface FormDesignGroupChangedEvent {
|
|
526
|
+
readonly groupId: string | null;
|
|
527
|
+
}
|
|
528
|
+
/** `setGroups()` changed who the document's groups are: the groups as `listGroups()` gives them now. */
|
|
529
|
+
interface FormGroupsChangedEvent {
|
|
530
|
+
readonly groups: readonly FormGroup[];
|
|
531
|
+
}
|
|
408
532
|
/** The whole form was read. */
|
|
409
533
|
interface FormResyncedEvent {
|
|
410
534
|
readonly snapshot: FormSnapshot;
|
|
@@ -445,11 +569,13 @@ interface FormCapability extends SettingsApi<FormSettings> {
|
|
|
445
569
|
/**
|
|
446
570
|
* Each widget on a page (its ref or its index), with its place, its look,
|
|
447
571
|
* its control, its value and whether it can be filled: for drawing the
|
|
448
|
-
* fields yourself.
|
|
449
|
-
*
|
|
572
|
+
* fields yourself. Its place is its frame (`box`), its quarter turn
|
|
573
|
+
* (`rotation`) and the rect it stands in (`rect`): a control goes in the
|
|
574
|
+
* frame, turned about its middle. The same array while nothing changes;
|
|
575
|
+
* empty for a page that isn't in the document.
|
|
450
576
|
*/
|
|
451
577
|
listWidgets(page: PageRef | number): readonly FormWidgetItem[];
|
|
452
|
-
/** The widget under a point on a page, with its field, or `null`. */
|
|
578
|
+
/** The widget under a point on a page, with its field and its place, or `null`. */
|
|
453
579
|
getWidgetAt(page: PageRef | number, point: {
|
|
454
580
|
x: number;
|
|
455
581
|
y: number;
|
|
@@ -459,8 +585,26 @@ interface FormCapability extends SettingsApi<FormSettings> {
|
|
|
459
585
|
* field, such as a radio group's buttons. `null` otherwise.
|
|
460
586
|
*/
|
|
461
587
|
getSelectedField(): FormField | null;
|
|
588
|
+
/**
|
|
589
|
+
* Every field with a selected widget (in design mode), in the selection's order, each once.
|
|
590
|
+
* The same array while nothing changes.
|
|
591
|
+
*/
|
|
592
|
+
listSelectedFields(): readonly FormField[];
|
|
462
593
|
/** The field the cursor is in, or `null`. */
|
|
463
594
|
getFocusedField(): FormField | null;
|
|
595
|
+
/**
|
|
596
|
+
* The document's groups: the ones `setGroups()` named, in that order, then
|
|
597
|
+
* the other groups the form's fields are in. Each has its label (`null`
|
|
598
|
+
* where the app gave none) and the color its fields show in: the app's,
|
|
599
|
+
* else one of eight by the group's place in this list. The same array
|
|
600
|
+
* while nothing changes.
|
|
601
|
+
*/
|
|
602
|
+
listGroups(): readonly FormGroup[];
|
|
603
|
+
/**
|
|
604
|
+
* The group that fields placed with a tool go in (in design mode), or
|
|
605
|
+
* `null`, where it starts, when it names none.
|
|
606
|
+
*/
|
|
607
|
+
getDesignGroup(): string | null;
|
|
464
608
|
/**
|
|
465
609
|
* A field's settings, described for a settings panel, which writes them
|
|
466
610
|
* with `update()`; `null` for a field the form doesn't have. Every setting
|
|
@@ -579,6 +723,32 @@ interface FormCapability extends SettingsApi<FormSettings> {
|
|
|
579
723
|
* `not-found` for a widget the form doesn't show.
|
|
580
724
|
*/
|
|
581
725
|
duplicateWidgets(widgets: readonly AnnotationRef[], options?: FormDuplicateOptions & OperationOptions): Promise<FormDuplicateResult>;
|
|
726
|
+
/**
|
|
727
|
+
* Say who this document's groups are, for the people who look at it: the
|
|
728
|
+
* whole list, and an empty one clears it. A field's group is an id in the
|
|
729
|
+
* PDF; its name and its color are the app's, and never written there. The
|
|
730
|
+
* first entry of an id is the group. Fires `onGroupsChanged`; the same
|
|
731
|
+
* list again changes nothing.
|
|
732
|
+
*/
|
|
733
|
+
setGroups(groups: readonly FormGroupInput[]): void;
|
|
734
|
+
/**
|
|
735
|
+
* Say who the next fields are for: a field placed with a tool goes into
|
|
736
|
+
* this group. With `null` it names none, and the field is in no group.
|
|
737
|
+
* Fires `onDesignGroupChanged`. Throws
|
|
738
|
+
* `permission-denied` for a group the user may not put a field in
|
|
739
|
+
* (`canSetGroup`).
|
|
740
|
+
*/
|
|
741
|
+
setDesignGroup(groupId: string | null): void;
|
|
742
|
+
/**
|
|
743
|
+
* Put fields in a group, or with `null` take them out of theirs, in one
|
|
744
|
+
* step to undo: each field not already there gets it as its `groupId`.
|
|
745
|
+
* Fires `onFieldUpdated` for each, and resolves the fields as they are
|
|
746
|
+
* now, in the order given. Rejects `permission-denied` without
|
|
747
|
+
* `doc.forms.modify` or for a group the user may not put a field in
|
|
748
|
+
* (`canSetGroup`; taking a field out of its group needs no more than
|
|
749
|
+
* `doc.forms.modify`), `not-found` for a field the form doesn't have.
|
|
750
|
+
*/
|
|
751
|
+
moveToGroup(fields: readonly FormFieldRef[], groupId: string | null, options?: OperationOptions): Promise<FormGroupMoveResult>;
|
|
582
752
|
/** Change a field's settings: pass only what changes. Fires `onFieldUpdated`. Rejects like `create()`. */
|
|
583
753
|
update(ref: FormFieldRef, patch: FormFieldPatch, options?: OperationOptions): Promise<FormFieldResult>;
|
|
584
754
|
/** Remove a field and every widget it has. Fires `onFieldDeleted`. Rejects `permission-denied` without `doc.forms.modify`, `not-found`. */
|
|
@@ -634,6 +804,12 @@ interface FormCapability extends SettingsApi<FormSettings> {
|
|
|
634
804
|
canFill(field: FormFieldRef): boolean;
|
|
635
805
|
/** Whether adding, changing and removing fields is allowed: `doc.forms.modify`. */
|
|
636
806
|
canDesign(): boolean;
|
|
807
|
+
/**
|
|
808
|
+
* Whether the user may put a field in this group, with `create()`,
|
|
809
|
+
* `update()` or a tool: `doc.forms.modify`, and the group is the user's
|
|
810
|
+
* own or one a `fields:set-group` permission names.
|
|
811
|
+
*/
|
|
812
|
+
canSetGroup(groupId: string): boolean;
|
|
637
813
|
/**
|
|
638
814
|
* Whether an import may restore who created and filled in the fields it
|
|
639
815
|
* brings, instead of naming the importing user: `doc.forms.import`.
|
|
@@ -658,7 +834,11 @@ interface FormCapability extends SettingsApi<FormSettings> {
|
|
|
658
834
|
readonly onResynced: EventHook<FormResyncedEvent>;
|
|
659
835
|
/** The cursor moved into a field, to another one, or out of the fields. */
|
|
660
836
|
readonly onFocusChanged: EventHook<FormFocusChangedEvent>;
|
|
837
|
+
/** The group that fields placed with a tool go in changed. */
|
|
838
|
+
readonly onDesignGroupChanged: EventHook<FormDesignGroupChangedEvent>;
|
|
839
|
+
/** `setGroups()` changed who the document's groups are. */
|
|
840
|
+
readonly onGroupsChanged: EventHook<FormGroupsChangedEvent>;
|
|
661
841
|
}
|
|
662
842
|
//#endregion
|
|
663
|
-
export {
|
|
664
|
-
//# sourceMappingURL=contract-
|
|
843
|
+
export { WidgetActivationResult as $, FormGroupMoveResult as A, FormResetResult as B, FormFieldUpdatedEvent as C, FormFocusNextOptions as D, FormFocusChangedEvent as E, FormImportResult as F, FormSnapshot$1 as G, FormSetValueResult as H, FormKind$1 as I, FormValidation as J, FormTransfer as K, FormPlainValue as L, FormImportDrop$1 as M, FormImportDropReason as N, FormFocusOptions as O, FormImportOptions$1 as P, FormWidgetAnchor as Q, FormRepairOptions$1 as R, FormFieldSettings as S, FormFilter as T, FormSetValueStatus as U, FormResyncedEvent as V, FormSettings as W, FormValueChangedEvent as X, FormValidationRejectedEvent as Y, FormWidgetAddResult as Z, FormFieldKind$1 as _, FormCommitResult as a, GroupPosition as at, FormFieldResult as b, FormDesignGroupChangedEvent as c, FormModel as ct, FormExportSelection as d, WidgetHit as dt, WidgetAddress as et, FormField$1 as f, WidgetPlace as ft, FormFieldFlagSetting as g, FormFieldDraft$1 as h, FormCapability as i, FormWidgetItem as it, FormGroupsChangedEvent as j, FormGroupInput as k, FormDuplicateOptions as l, FormWidgetLook as lt, FormFieldDeletedEvent as m, FillableFields as n, toFieldRef as nt, FormCommitStatus as o, FormGroup as ot, FormFieldCreatedEvent as p, FormUiEffect as q, FormBundle$1 as r, FormToken as rt, FormConfig as s, Box as st, FORM_DEFAULTS as t, WidgetAnnotation$1 as tt, FormDuplicateResult as u, ShownWidget as ut, FormFieldPatch$1 as v, FormFieldValue$1 as w, FormFieldSetting as x, FormFieldRef$1 as y, FormRepairResult$1 as z };
|
|
844
|
+
//# sourceMappingURL=contract-B7rB7jYx.d.cts.map
|