@embedpdf/plugin-form 3.0.0-next.22 → 3.0.0-next.23
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.d.cts +3 -3
- package/dist/contract/host.d.ts +3 -3
- package/dist/{contract-D_9fiTkd.d.ts → contract-6YEsObRl.d.ts} +32 -32
- package/dist/contract-BdEaLXUK.js.map +1 -1
- package/dist/contract-CU0jrI_D.cjs.map +1 -1
- package/dist/{contract-c_wuhKk1.d.cts → contract-Djti7ew8.d.cts} +32 -32
- package/dist/contract.d.cts +2 -2
- package/dist/contract.d.ts +2 -2
- package/dist/{controller-Sr5M_8G8.js → controller-BbC8XWpY.js} +7 -7
- package/dist/controller-BbC8XWpY.js.map +1 -0
- package/dist/{controller-CS6tV2m1.cjs → controller-BwbadmLW.cjs} +7 -7
- package/dist/controller-BwbadmLW.cjs.map +1 -0
- package/dist/{host-contract-DdOsYM83.d.ts → host-contract-DO9xsBoD.d.cts} +6 -6
- package/dist/{host-contract-DaauiYfw.d.cts → host-contract-XqkfFuoy.d.ts} +6 -6
- package/dist/index.cjs +64 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.js +64 -65
- package/dist/index.js.map +1 -1
- package/dist/scripting.cjs +1 -1
- package/dist/scripting.d.cts +3 -3
- package/dist/scripting.d.ts +3 -3
- package/dist/scripting.js +1 -1
- package/package.json +17 -17
- package/dist/controller-CS6tV2m1.cjs.map +0 -1
- package/dist/controller-Sr5M_8G8.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_contract = require("./contract-CU0jrI_D.cjs");
|
|
3
|
-
const require_controller = require("./controller-
|
|
3
|
+
const require_controller = require("./controller-BwbadmLW.cjs");
|
|
4
4
|
const require_contract_host = require("./contract/host.cjs");
|
|
5
5
|
let _embedpdf_core = require("@embedpdf/core");
|
|
6
6
|
let _embedpdf_plugin_actions_contract = require("@embedpdf/plugin-actions/contract");
|
|
@@ -28,7 +28,7 @@ const FIELD_CHROME = {
|
|
|
28
28
|
const FORM_TOOLS = [
|
|
29
29
|
{
|
|
30
30
|
id: "form-text",
|
|
31
|
-
|
|
31
|
+
fieldKind: "text",
|
|
32
32
|
visualKind: "widget-text",
|
|
33
33
|
clickCreate: {
|
|
34
34
|
width: 160,
|
|
@@ -42,7 +42,7 @@ const FORM_TOOLS = [
|
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
id: "form-checkbox",
|
|
45
|
-
|
|
45
|
+
fieldKind: "checkbox",
|
|
46
46
|
visualKind: "widget-toggle",
|
|
47
47
|
clickCreate: {
|
|
48
48
|
width: 18,
|
|
@@ -53,7 +53,7 @@ const FORM_TOOLS = [
|
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
id: "form-radio",
|
|
56
|
-
|
|
56
|
+
fieldKind: "radio",
|
|
57
57
|
visualKind: "widget-radio",
|
|
58
58
|
clickCreate: {
|
|
59
59
|
width: 18,
|
|
@@ -64,7 +64,7 @@ const FORM_TOOLS = [
|
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
id: "form-combobox",
|
|
67
|
-
|
|
67
|
+
fieldKind: "combobox",
|
|
68
68
|
visualKind: "widget-choice",
|
|
69
69
|
clickCreate: {
|
|
70
70
|
width: 140,
|
|
@@ -78,7 +78,7 @@ const FORM_TOOLS = [
|
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
id: "form-listbox",
|
|
81
|
-
|
|
81
|
+
fieldKind: "listbox",
|
|
82
82
|
visualKind: "widget-choice",
|
|
83
83
|
clickCreate: {
|
|
84
84
|
width: 140,
|
|
@@ -92,7 +92,7 @@ const FORM_TOOLS = [
|
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
94
|
id: "form-button",
|
|
95
|
-
|
|
95
|
+
fieldKind: "pushbutton",
|
|
96
96
|
visualKind: "widget-button",
|
|
97
97
|
clickCreate: {
|
|
98
98
|
width: 100,
|
|
@@ -107,7 +107,7 @@ const FORM_TOOLS = [
|
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
109
|
id: "form-signature",
|
|
110
|
-
|
|
110
|
+
fieldKind: "signature",
|
|
111
111
|
visualKind: "widget-box",
|
|
112
112
|
clickCreate: {
|
|
113
113
|
width: 160,
|
|
@@ -145,9 +145,9 @@ function clampToPage(box, page) {
|
|
|
145
145
|
* settings panel.
|
|
146
146
|
*/
|
|
147
147
|
function toolDraft(tool, name, widget) {
|
|
148
|
-
switch (tool.
|
|
148
|
+
switch (tool.fieldKind) {
|
|
149
149
|
case "radio": return {
|
|
150
|
-
|
|
150
|
+
kind: "radio",
|
|
151
151
|
name,
|
|
152
152
|
widgets: [{
|
|
153
153
|
...widget,
|
|
@@ -156,7 +156,7 @@ function toolDraft(tool, name, widget) {
|
|
|
156
156
|
};
|
|
157
157
|
case "combobox":
|
|
158
158
|
case "listbox": return {
|
|
159
|
-
|
|
159
|
+
kind: tool.fieldKind,
|
|
160
160
|
name,
|
|
161
161
|
widgets: [widget],
|
|
162
162
|
options: [{
|
|
@@ -168,7 +168,7 @@ function toolDraft(tool, name, widget) {
|
|
|
168
168
|
}]
|
|
169
169
|
};
|
|
170
170
|
case "pushbutton": return {
|
|
171
|
-
|
|
171
|
+
kind: "pushbutton",
|
|
172
172
|
name,
|
|
173
173
|
widgets: [{
|
|
174
174
|
...widget,
|
|
@@ -176,7 +176,7 @@ function toolDraft(tool, name, widget) {
|
|
|
176
176
|
}]
|
|
177
177
|
};
|
|
178
178
|
default: return {
|
|
179
|
-
|
|
179
|
+
kind: tool.fieldKind,
|
|
180
180
|
name,
|
|
181
181
|
widgets: [widget]
|
|
182
182
|
};
|
|
@@ -215,7 +215,7 @@ function createPlaceHandler(form, interaction, annotation) {
|
|
|
215
215
|
const rect = pageBox ? clampToPage(box, pageBox) : null;
|
|
216
216
|
if (!rect) return;
|
|
217
217
|
const look = (0, _embedpdf_core_annotation.widgetAppearanceOf)(annotation ? annotation.tools.getDefaults(tool.id) : tool.defaults);
|
|
218
|
-
const name = nextFieldName(tool.
|
|
218
|
+
const name = nextFieldName(tool.fieldKind, new Set(form.list().map((field) => field.name)));
|
|
219
219
|
const created = form.create(toolDraft(tool, name, {
|
|
220
220
|
page,
|
|
221
221
|
rect,
|
|
@@ -228,7 +228,7 @@ function createPlaceHandler(form, interaction, annotation) {
|
|
|
228
228
|
if (!annotation || interaction.getActiveToolId() !== tool.id) return;
|
|
229
229
|
const policy = annotation.getSettings().afterCreate;
|
|
230
230
|
const widget = field.widgets.find((candidate) => candidate.page?.objectNumber === page.objectNumber);
|
|
231
|
-
if (policy.select && widget?.ref) annotation.selection.
|
|
231
|
+
if (policy.select && widget?.ref) annotation.selection.select([widget.ref]);
|
|
232
232
|
if (policy.tool === "default") interaction.activateTool("form-edit");
|
|
233
233
|
await created;
|
|
234
234
|
};
|
|
@@ -242,7 +242,7 @@ function createPlaceHandler(form, interaction, annotation) {
|
|
|
242
242
|
if (sample.page && FORM_TOOL_BY_ID.has(toolId) && form.canDesign() && !interaction.hasCursorClaim()) annotation.hoverGhostAt(toolId, sample.page.ref, sample.page.point, sample.page.rotation, sample.page.zoom);
|
|
243
243
|
else annotation.clearGhost();
|
|
244
244
|
},
|
|
245
|
-
|
|
245
|
+
onPointerDown: (sample) => {
|
|
246
246
|
if (!sample.page || !FORM_TOOL_BY_ID.has(interaction.getActiveToolId())) return false;
|
|
247
247
|
if (!form.canDesign()) return false;
|
|
248
248
|
origin = {
|
|
@@ -252,14 +252,14 @@ function createPlaceHandler(form, interaction, annotation) {
|
|
|
252
252
|
};
|
|
253
253
|
return true;
|
|
254
254
|
},
|
|
255
|
-
|
|
255
|
+
onPointerMove: (sample) => {
|
|
256
256
|
if (!origin) return;
|
|
257
257
|
const point = (0, _embedpdf_plugin_interaction_contract_host.samplePointOn)(sample, origin.page);
|
|
258
258
|
if (!point) return;
|
|
259
259
|
origin.last = point;
|
|
260
260
|
annotation?.previewPlacement(interaction.getActiveToolId(), origin.page, origin.start, point);
|
|
261
261
|
},
|
|
262
|
-
|
|
262
|
+
onPointerUp: (sample) => {
|
|
263
263
|
if (!origin) return;
|
|
264
264
|
const gesture = origin;
|
|
265
265
|
endGesture();
|
|
@@ -272,7 +272,7 @@ function createPlaceHandler(form, interaction, annotation) {
|
|
|
272
272
|
globalThis.console?.error("[form] placing the field failed:", error);
|
|
273
273
|
});
|
|
274
274
|
},
|
|
275
|
-
|
|
275
|
+
onPointerCancel: endGesture
|
|
276
276
|
};
|
|
277
277
|
}
|
|
278
278
|
//#endregion
|
|
@@ -664,7 +664,7 @@ const widgetObjectOf = (widget) => "kind" in widget ? widget.kind === "objectNum
|
|
|
664
664
|
function valueOf$1(field) {
|
|
665
665
|
const entry = field.valueEntry;
|
|
666
666
|
if (entry.kind === "none" || entry.kind === "unsupported") return null;
|
|
667
|
-
switch (field.
|
|
667
|
+
switch (field.kind) {
|
|
668
668
|
case "text": return { value: field.value };
|
|
669
669
|
case "checkbox": return { checked: field.checked };
|
|
670
670
|
case "radio": return { value: field.value === "Off" ? null : field.value };
|
|
@@ -682,11 +682,11 @@ function plainValueOf(field) {
|
|
|
682
682
|
return value.value;
|
|
683
683
|
}
|
|
684
684
|
/**
|
|
685
|
-
* The write a plain value makes for a field of this
|
|
686
|
-
*
|
|
685
|
+
* The write a plain value makes for a field of this kind, or null when the
|
|
686
|
+
* kind can't take it (a list given `true`, a value for a push button).
|
|
687
687
|
*/
|
|
688
688
|
function writeOfPlainValue(field, value) {
|
|
689
|
-
switch (field.
|
|
689
|
+
switch (field.kind) {
|
|
690
690
|
case "checkbox":
|
|
691
691
|
if (typeof value === "boolean") return { checked: value };
|
|
692
692
|
return typeof value === "string" || value === null ? { value } : null;
|
|
@@ -702,7 +702,7 @@ function writeOfPlainValue(field, value) {
|
|
|
702
702
|
}
|
|
703
703
|
/** Whether a field holds nothing a required check would accept. */
|
|
704
704
|
function isEmpty(field) {
|
|
705
|
-
switch (field.
|
|
705
|
+
switch (field.kind) {
|
|
706
706
|
case "text":
|
|
707
707
|
case "combobox": return field.value === "";
|
|
708
708
|
case "checkbox": return !field.checked;
|
|
@@ -718,7 +718,7 @@ function createFieldReads(ctx, { fields, rights, siblings }) {
|
|
|
718
718
|
if (!filter) return all();
|
|
719
719
|
const page = filter.page === void 0 ? void 0 : ctx.getPage(filter.page)?.ref;
|
|
720
720
|
if (filter.page !== void 0 && !page) return NO_FIELDS$1;
|
|
721
|
-
return all().filter((field) => (!filter.
|
|
721
|
+
return all().filter((field) => (!filter.kind || field.kind === filter.kind) && (filter.name === void 0 || field.name === filter.name) && (!page || field.widgets.some((widget) => widget.page && (0, _embedpdf_engine_core_runtime.pageRefsEqual)(widget.page, page))));
|
|
722
722
|
};
|
|
723
723
|
const valueByKey = (0, _embedpdf_core.memoByKey)((key) => {
|
|
724
724
|
const field = fieldByKey(fields.view(), key);
|
|
@@ -760,7 +760,7 @@ function createFieldReads(ctx, { fields, rights, siblings }) {
|
|
|
760
760
|
missing
|
|
761
761
|
};
|
|
762
762
|
});
|
|
763
|
-
const getSelectedField = (0, _embedpdf_core.memo)(() => [fields.view(), siblings.annotation()?.selection.
|
|
763
|
+
const getSelectedField = (0, _embedpdf_core.memo)(() => [fields.view(), siblings.annotation()?.selection.getSelected() ?? NOTHING_SELECTED], (index, selected) => {
|
|
764
764
|
const [annotation] = selected;
|
|
765
765
|
if (selected.length !== 1 || !annotation?.subtype.startsWith("widget")) return null;
|
|
766
766
|
return fieldForWidget(index, widgetObjectOf(annotation.ref));
|
|
@@ -785,7 +785,7 @@ function createFieldReads(ctx, { fields, rights, siblings }) {
|
|
|
785
785
|
//#region src/read/settings.ts
|
|
786
786
|
/**
|
|
787
787
|
* A field's settings, described for a settings panel the way an annotation
|
|
788
|
-
* kind describes its look: which settings the field's
|
|
788
|
+
* kind describes its look: which settings the field's kind has, how each is
|
|
789
789
|
* edited, and its value. `update()` writes them.
|
|
790
790
|
*/
|
|
791
791
|
/** What every field has. */
|
|
@@ -831,9 +831,9 @@ const OPTIONS = {
|
|
|
831
831
|
label: "Options",
|
|
832
832
|
labelKey: "form.settings.options"
|
|
833
833
|
};
|
|
834
|
-
/** What each
|
|
834
|
+
/** What each kind adds. */
|
|
835
835
|
function familySettings(field) {
|
|
836
|
-
switch (field.
|
|
836
|
+
switch (field.kind) {
|
|
837
837
|
case "text": return [
|
|
838
838
|
{
|
|
839
839
|
key: "defaultValue",
|
|
@@ -935,7 +935,7 @@ function createFieldSettings({ fields }) {
|
|
|
935
935
|
//#region src/read/fill-items.ts
|
|
936
936
|
/**
|
|
937
937
|
* Project one widget of a field into a fill control; `fillable`: the user may
|
|
938
|
-
* fill the field in (a signature field: sign it). Null for
|
|
938
|
+
* fill the field in (a signature field: sign it). Null for kinds with no
|
|
939
939
|
* fill control.
|
|
940
940
|
*/
|
|
941
941
|
function projectWidget(field, annotObjectNumber, widget, fillable) {
|
|
@@ -949,7 +949,7 @@ function projectWidget(field, annotObjectNumber, widget, fillable) {
|
|
|
949
949
|
disabled: field.readOnly || !fillable,
|
|
950
950
|
label: field.alternateName ?? field.name
|
|
951
951
|
};
|
|
952
|
-
switch (field.
|
|
952
|
+
switch (field.kind) {
|
|
953
953
|
case "text": return {
|
|
954
954
|
...base,
|
|
955
955
|
control: "text",
|
|
@@ -1106,7 +1106,7 @@ function withFields(index, parts) {
|
|
|
1106
1106
|
return upsertWidgets(upsertFields(index, parts.map((part) => part.field)), parts.flatMap((part) => part.widgets));
|
|
1107
1107
|
}
|
|
1108
1108
|
/** The fields a reset of the whole form puts back: the ones that hold a value. */
|
|
1109
|
-
const resetTargets = (index) => (index.snapshot?.fields ?? []).filter((field) => RESET_FAMILIES.has(field.
|
|
1109
|
+
const resetTargets = (index) => (index.snapshot?.fields ?? []).filter((field) => RESET_FAMILIES.has(field.kind));
|
|
1110
1110
|
const RESET_FAMILIES = /* @__PURE__ */ new Set([
|
|
1111
1111
|
"text",
|
|
1112
1112
|
"checkbox",
|
|
@@ -1336,7 +1336,7 @@ function createFieldsMirror(ctx, events) {
|
|
|
1336
1336
|
load: async (doc) => ({ value: indexLoadedFields(fields.get(), await doc.forms.list()) }),
|
|
1337
1337
|
fold: foldFormEvent,
|
|
1338
1338
|
predict: predictFormOp,
|
|
1339
|
-
|
|
1339
|
+
onChanged: ({ cause, event, next }) => {
|
|
1340
1340
|
if (cause === "load") {
|
|
1341
1341
|
if (next.snapshot) events.resynced.emit({ snapshot: next.snapshot });
|
|
1342
1342
|
return;
|
|
@@ -1500,12 +1500,12 @@ function createEvents(ctx) {
|
|
|
1500
1500
|
* write. A field's group decides: a `fields:fill` (`fields:sign`) permission
|
|
1501
1501
|
* for its group, or `doc.forms.fill` (`doc.sign`) for every field.
|
|
1502
1502
|
*/
|
|
1503
|
-
/** Whether the `fillable` setting lets people fill in a field of this
|
|
1504
|
-
const isFillableByHand = (fillable,
|
|
1503
|
+
/** Whether the `fillable` setting lets people fill in a field of this kind by hand. */
|
|
1504
|
+
const isFillableByHand = (fillable, kind) => typeof fillable === "boolean" ? fillable : fillable.includes(kind);
|
|
1505
1505
|
function createFillRights(ctx, fields) {
|
|
1506
1506
|
const mayFill = (field) => ctx.allowsField("fill", field);
|
|
1507
1507
|
const maySign = (field) => ctx.allowsField("sign", field);
|
|
1508
|
-
const mayFillByHand = (field) => isFillableByHand(ctx.settings().get().fillable, field.
|
|
1508
|
+
const mayFillByHand = (field) => isFillableByHand(ctx.settings().get().fillable, field.kind) && (field.kind === "signature" ? maySign(field) : mayFill(field));
|
|
1509
1509
|
/** The form's groups, `null` (no group) among them. */
|
|
1510
1510
|
const groups = (0, _embedpdf_core.memo)(() => [fields.view()], (index) => [...new Set((index.snapshot?.fields ?? []).map((field) => field.groupId))]);
|
|
1511
1511
|
return {
|
|
@@ -1521,7 +1521,7 @@ function createFillRights(ctx, fields) {
|
|
|
1521
1521
|
//#region src/services/formatted.ts
|
|
1522
1522
|
/** The values remembered per field: enough for an undo or two. */
|
|
1523
1523
|
const KEPT_PER_FIELD = 8;
|
|
1524
|
-
const valueOf = (field) => field.
|
|
1524
|
+
const valueOf = (field) => field.kind === "text" || field.kind === "combobox" ? field.value : null;
|
|
1525
1525
|
function createFormattedTexts(ctx, fields) {
|
|
1526
1526
|
const texts = /* @__PURE__ */ new Map();
|
|
1527
1527
|
let version = 0;
|
|
@@ -1577,7 +1577,7 @@ function createWidgetLooks({ fields, formatted, design, fonts }) {
|
|
|
1577
1577
|
const lookKeyOf = (row, field) => {
|
|
1578
1578
|
const box = row.box ?? row.rect;
|
|
1579
1579
|
const content = (() => {
|
|
1580
|
-
switch (field?.
|
|
1580
|
+
switch (field?.kind) {
|
|
1581
1581
|
case "text": return [
|
|
1582
1582
|
formatted.textOf(field) ?? field.value,
|
|
1583
1583
|
field.multiline,
|
|
@@ -1587,7 +1587,7 @@ function createWidgetLooks({ fields, formatted, design, fonts }) {
|
|
|
1587
1587
|
];
|
|
1588
1588
|
case "combobox": return [formatted.textOf(field) ?? field.value];
|
|
1589
1589
|
case "listbox": return [field.topIndex, field.options.map((option) => [option.label, option.selected])];
|
|
1590
|
-
default: return [field?.
|
|
1590
|
+
default: return [field?.kind ?? null];
|
|
1591
1591
|
}
|
|
1592
1592
|
})();
|
|
1593
1593
|
return JSON.stringify([
|
|
@@ -1694,11 +1694,11 @@ function createWidgetLooks({ fields, formatted, design, fonts }) {
|
|
|
1694
1694
|
},
|
|
1695
1695
|
/**
|
|
1696
1696
|
* How the painter draws a widget row live, upright in a box (where a gesture has it); `null`
|
|
1697
|
-
* for one whose field it doesn't draw
|
|
1697
|
+
* for one whose field it doesn't draw, or with a mark in it, which only its picture shows.
|
|
1698
1698
|
*/
|
|
1699
1699
|
painterOf: (row) => {
|
|
1700
1700
|
const field = fieldForWidget(fields.view(), numberOf(row.ref));
|
|
1701
|
-
return field && (0, _embedpdf_core_form.paints)(field) ? (box) => paint(row, box, 0, true) ?? [] : null;
|
|
1701
|
+
return field && (0, _embedpdf_core_form.paints)(field) && !row.hasMark ? (box) => paint(row, box, 0, true) ?? [] : null;
|
|
1702
1702
|
},
|
|
1703
1703
|
getTextEditorLayout: (ref, text) => {
|
|
1704
1704
|
const view = fields.view();
|
|
@@ -1761,7 +1761,7 @@ function createScriptingSeam(ctx, siblings) {
|
|
|
1761
1761
|
transaction: realm.transaction.bind(realm),
|
|
1762
1762
|
budget: realm.budget
|
|
1763
1763
|
});
|
|
1764
|
-
ctx.cleanup(() => made.
|
|
1764
|
+
ctx.cleanup(() => made.destroy());
|
|
1765
1765
|
pipeline = made;
|
|
1766
1766
|
return made;
|
|
1767
1767
|
};
|
|
@@ -1913,18 +1913,18 @@ function createActivation(ctx, services, { fill }) {
|
|
|
1913
1913
|
const actions = ctx.tryGet(_embedpdf_plugin_actions_contract.ActionsToken);
|
|
1914
1914
|
if (actions) {
|
|
1915
1915
|
const result = await ctx.cancellable(options?.signal, actions.dispatch({
|
|
1916
|
-
|
|
1917
|
-
|
|
1916
|
+
type: "activate",
|
|
1917
|
+
annotation: annotationRef,
|
|
1918
1918
|
page: annotationRef.page,
|
|
1919
1919
|
source: widgetSource(field.ref, annotationRef)
|
|
1920
1920
|
}));
|
|
1921
1921
|
if (!(result.status === "inert" && result.steps.length === 0 && result.diagnostics.length === 0)) return {
|
|
1922
|
-
|
|
1922
|
+
status: "dispatched",
|
|
1923
1923
|
result
|
|
1924
1924
|
};
|
|
1925
1925
|
}
|
|
1926
1926
|
return {
|
|
1927
|
-
|
|
1927
|
+
status: "form",
|
|
1928
1928
|
result: await activateThroughScripts(field.ref, annotationRef, options)
|
|
1929
1929
|
};
|
|
1930
1930
|
},
|
|
@@ -1950,9 +1950,9 @@ function createActivation(ctx, services, { fill }) {
|
|
|
1950
1950
|
}
|
|
1951
1951
|
if (event === "focus") scripting.warm(fields.view());
|
|
1952
1952
|
actions.dispatch({
|
|
1953
|
-
|
|
1953
|
+
type: "annotation",
|
|
1954
1954
|
event,
|
|
1955
|
-
|
|
1955
|
+
annotation: annotationRef,
|
|
1956
1956
|
page: annotationRef.page,
|
|
1957
1957
|
source
|
|
1958
1958
|
});
|
|
@@ -2082,11 +2082,11 @@ const lookOf = (widget) => {
|
|
|
2082
2082
|
/**
|
|
2083
2083
|
* The export value a field's new widget gets when none is given: a radio group's next free
|
|
2084
2084
|
* `Choice<n>` (the radio tool names its first button `Choice1`), a checkbox's own value, so
|
|
2085
|
-
* the boxes check together. Other
|
|
2085
|
+
* the boxes check together. Other kinds take none.
|
|
2086
2086
|
*/
|
|
2087
2087
|
function exportValueFor(field) {
|
|
2088
|
-
if (field.
|
|
2089
|
-
if (field.
|
|
2088
|
+
if (field.kind === "checkbox") return field.exportValue;
|
|
2089
|
+
if (field.kind !== "radio") return void 0;
|
|
2090
2090
|
const taken = new Set(field.widgets.map((widget) => widget.exportValue));
|
|
2091
2091
|
let n = field.widgets.length + 1;
|
|
2092
2092
|
while (taken.has(`Choice${n}`)) n += 1;
|
|
@@ -2516,7 +2516,7 @@ function failedFill(result) {
|
|
|
2516
2516
|
* (`services/cursor.ts`) brings the box into view and hands it to its control.
|
|
2517
2517
|
*/
|
|
2518
2518
|
/** A radio button as its field lists it: whether it's the checked one, and the value it picks. */
|
|
2519
|
-
const radioButtonOf = (field, widget) => field.
|
|
2519
|
+
const radioButtonOf = (field, widget) => field.kind === "radio" ? field.widgets.find((candidate) => candidate.objectNumber === widget) ?? null : null;
|
|
2520
2520
|
function createFocus(ctx, { fields, rights, events, cursor }, fill) {
|
|
2521
2521
|
/** Every box that shows, in Tab's order, and the ones Tab stops at. */
|
|
2522
2522
|
const order = (0, _embedpdf_core.memo)(() => [
|
|
@@ -2534,7 +2534,7 @@ function createFocus(ctx, { fields, rights, events, cursor }, fill) {
|
|
|
2534
2534
|
position.set(widget, at);
|
|
2535
2535
|
const field = fieldForWidget(index, widget);
|
|
2536
2536
|
if (!field || !rights.takesInput(field)) return;
|
|
2537
|
-
if (field.
|
|
2537
|
+
if (field.kind === "radio") {
|
|
2538
2538
|
const group = `${fieldKeyOf(field)}@${row.page.objectNumber}`;
|
|
2539
2539
|
if (groups.has(group)) return;
|
|
2540
2540
|
groups.add(group);
|
|
@@ -2558,7 +2558,7 @@ function createFocus(ctx, { fields, rights, events, cursor }, fill) {
|
|
|
2558
2558
|
* its first, or its last when Shift+Tab comes to it from after it.
|
|
2559
2559
|
*/
|
|
2560
2560
|
const boxAt = (stop, backward) => {
|
|
2561
|
-
if (stop.field.
|
|
2561
|
+
if (stop.field.kind !== "radio") return stop.row;
|
|
2562
2562
|
const buttons = buttonsOf(stop.field, stop.row.page.objectNumber);
|
|
2563
2563
|
return buttons.find((button) => radioButtonOf(stop.field, widgetObjectOf(button.ref))?.checked) ?? (backward ? buttons.at(-1) ?? stop.row : stop.row);
|
|
2564
2564
|
};
|
|
@@ -2586,7 +2586,7 @@ function createFocus(ctx, { fields, rights, events, cursor }, fill) {
|
|
|
2586
2586
|
const at = from === null ? null : position.get(from) ?? null;
|
|
2587
2587
|
const field = from === null ? null : fieldForWidget(index, from);
|
|
2588
2588
|
const page = from === null ? null : widgetRowOf(index, from)?.page.objectNumber;
|
|
2589
|
-
const candidates = stops.filter((stop) => (!options.empty || isEmpty(stop.field)) && !(stop.field === field && field.
|
|
2589
|
+
const candidates = stops.filter((stop) => (!options.empty || isEmpty(stop.field)) && !(stop.field === field && field.kind === "radio" && stop.row.page.objectNumber === page));
|
|
2590
2590
|
const ahead = candidates.filter((stop) => at === null ? true : backward ? stop.at < at : stop.at > at);
|
|
2591
2591
|
const next = (backward ? ahead.at(-1) : ahead[0]) ?? (options.wrap ? backward ? candidates.at(-1) : candidates[0] : void 0);
|
|
2592
2592
|
return next ? cursor.goTo(boxAt(next, backward), true) : false;
|
|
@@ -2594,7 +2594,7 @@ function createFocus(ctx, { fields, rights, events, cursor }, fill) {
|
|
|
2594
2594
|
const moveInGroup = (ref, backward) => {
|
|
2595
2595
|
const widget = widgetObjectOf(ref);
|
|
2596
2596
|
const field = fieldForWidget(fields.view(), widget);
|
|
2597
|
-
if (!field || field.
|
|
2597
|
+
if (!field || field.kind !== "radio" || !rights.takesInput(field)) return false;
|
|
2598
2598
|
const buttons = buttonsOf(field);
|
|
2599
2599
|
const here = buttons.findIndex((row) => widgetObjectOf(row.ref) === widget);
|
|
2600
2600
|
if (here < 0 || buttons.length < 2) return false;
|
|
@@ -2736,17 +2736,17 @@ function createWidgetLender(ctx, { fields, design, pictures, looks }) {
|
|
|
2736
2736
|
widgets: [...refs],
|
|
2737
2737
|
position
|
|
2738
2738
|
}],
|
|
2739
|
-
|
|
2739
|
+
getAuthority: () => {
|
|
2740
2740
|
const may = ctx.allows("doc.forms.modify");
|
|
2741
2741
|
return {
|
|
2742
2742
|
update: may,
|
|
2743
2743
|
delete: may
|
|
2744
2744
|
};
|
|
2745
2745
|
},
|
|
2746
|
-
|
|
2747
|
-
|
|
2746
|
+
getPictureEpoch: pictures.epoch,
|
|
2747
|
+
getPictureVersion: pictures.versionOf,
|
|
2748
2748
|
renderAppearances: pictures.render,
|
|
2749
|
-
|
|
2749
|
+
isPending: looks.isPending,
|
|
2750
2750
|
painter: (record) => record.subtype === "widget" ? looks.painterOf(record) : null
|
|
2751
2751
|
};
|
|
2752
2752
|
}
|
|
@@ -2805,10 +2805,10 @@ const buildSubmitEntries = (fields, intent, diagnose) => {
|
|
|
2805
2805
|
const entries = [];
|
|
2806
2806
|
for (const field of selected) {
|
|
2807
2807
|
const explicit = explicitInclude && listed(field);
|
|
2808
|
-
if (field.
|
|
2808
|
+
if (field.kind === "pushbutton" || field.kind === "signature") {
|
|
2809
2809
|
if (explicit) diagnose({
|
|
2810
2810
|
code: "submit-entry-unsupported",
|
|
2811
|
-
message: `submit: '${field.name}' (${field.
|
|
2811
|
+
message: `submit: '${field.name}' (${field.kind}) has no representable submission value in v1 — skipped`
|
|
2812
2812
|
});
|
|
2813
2813
|
continue;
|
|
2814
2814
|
}
|
|
@@ -2863,7 +2863,7 @@ function createResetWrites(_ctx, services, { fill }) {
|
|
|
2863
2863
|
* Whether a reset puts this field back: the engine refuses push button and
|
|
2864
2864
|
* signature refs, and another signer's fields are theirs.
|
|
2865
2865
|
*/
|
|
2866
|
-
const resettable = (field) => field.
|
|
2866
|
+
const resettable = (field) => field.kind !== "pushbutton" && field.kind !== "signature" && rights.mayFill(field);
|
|
2867
2867
|
/**
|
|
2868
2868
|
* Reset the selected fields, then recalculate, as one change. `origin` is carried through to
|
|
2869
2869
|
* the surfaced recalculation results, so a ResetForm run by a page or hover trigger never
|
|
@@ -2934,7 +2934,6 @@ function createScriptEffects(ctx, { fields, rights, enqueue }, { fillSoon }) {
|
|
|
2934
2934
|
url: intent.url,
|
|
2935
2935
|
method: intent.method,
|
|
2936
2936
|
format: intent.format,
|
|
2937
|
-
flagsRaw: intent.flagsRaw,
|
|
2938
2937
|
...intent.charSet === void 0 ? {} : { charSet: intent.charSet },
|
|
2939
2938
|
entries: buildSubmitEntries(fields.view().snapshot?.fields ?? [], intent, diagnose),
|
|
2940
2939
|
origin: actionContext.origin,
|
|
@@ -3135,7 +3134,7 @@ function createValueWrites(_ctx, services, { fill }) {
|
|
|
3135
3134
|
if (!value) {
|
|
3136
3135
|
skipped.push({
|
|
3137
3136
|
ref: name,
|
|
3138
|
-
reason: `a ${field.
|
|
3137
|
+
reason: `a ${field.kind} field can't take this value`
|
|
3139
3138
|
});
|
|
3140
3139
|
continue;
|
|
3141
3140
|
}
|