@unlev/exeq 0.4.0 → 0.4.2
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/README.md +1 -0
- package/dist/index.css +13 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +122 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -52
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -25,6 +25,56 @@ var SIGNER_ROLE_COLORS = {
|
|
|
25
25
|
function getSignerColor(role) {
|
|
26
26
|
return SIGNER_ROLE_COLORS[role] || "#888888";
|
|
27
27
|
}
|
|
28
|
+
function isRedactField(f) {
|
|
29
|
+
return f.type === "blackout" || f.type === "whiteout";
|
|
30
|
+
}
|
|
31
|
+
function isSignatureField(f) {
|
|
32
|
+
return f.type === "signature" || f.type === "initials";
|
|
33
|
+
}
|
|
34
|
+
function isTextLikeField(f) {
|
|
35
|
+
return f.type === "text" || f.type === "dropdown" || f.type === "signed-date";
|
|
36
|
+
}
|
|
37
|
+
function getInputType(subtype) {
|
|
38
|
+
switch (subtype) {
|
|
39
|
+
case "email":
|
|
40
|
+
return "email";
|
|
41
|
+
case "number":
|
|
42
|
+
return "number";
|
|
43
|
+
case "phone":
|
|
44
|
+
return "tel";
|
|
45
|
+
case "date":
|
|
46
|
+
return "date";
|
|
47
|
+
default:
|
|
48
|
+
return "text";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
var CSS_FONT_MAP = {
|
|
52
|
+
Courier: '"Courier New", Courier, monospace',
|
|
53
|
+
TimesRoman: '"Times New Roman", Times, serif',
|
|
54
|
+
Helvetica: "Helvetica, Arial, sans-serif"
|
|
55
|
+
};
|
|
56
|
+
function getCssFontFamily(fontFamily) {
|
|
57
|
+
return fontFamily ? CSS_FONT_MAP[fontFamily] : void 0;
|
|
58
|
+
}
|
|
59
|
+
function sortFieldsByPosition(fields) {
|
|
60
|
+
return [...fields].sort((a, b) => {
|
|
61
|
+
if (a.page !== b.page) return a.page - b.page;
|
|
62
|
+
const bandThreshold = 2;
|
|
63
|
+
if (Math.abs(a.y - b.y) > bandThreshold) return a.y - b.y;
|
|
64
|
+
return a.x - b.x;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function preserveFieldValues(oldFields, newFields) {
|
|
68
|
+
const valueMap = new Map(oldFields.filter((f) => f.value).map((f) => [f.id, f.value]));
|
|
69
|
+
return newFields.map((f) => valueMap.has(f.id) ? { ...f, value: valueMap.get(f.id) } : f);
|
|
70
|
+
}
|
|
71
|
+
function getFieldValues(fields) {
|
|
72
|
+
const values = {};
|
|
73
|
+
fields.forEach((f) => {
|
|
74
|
+
if (!isRedactField(f)) values[f.label] = f.value || "";
|
|
75
|
+
});
|
|
76
|
+
return values;
|
|
77
|
+
}
|
|
28
78
|
var FONT_FAMILIES = [
|
|
29
79
|
{ value: "Helvetica", label: "Helvetica" },
|
|
30
80
|
{ value: "Courier", label: "Courier New" },
|
|
@@ -380,7 +430,7 @@ function FieldOverlayItem({
|
|
|
380
430
|
const dragPosRef = useRef({ x: field.x, y: field.y });
|
|
381
431
|
const didDragRef = useRef(false);
|
|
382
432
|
const resizeStartRef = useRef(null);
|
|
383
|
-
const isRedact = field
|
|
433
|
+
const isRedact = isRedactField(field);
|
|
384
434
|
const isEditable = mode === "designer" || mode === "signer" && field.assignee === currentSigner;
|
|
385
435
|
const isInactiveSigner = mode === "signer" && !isRedact && field.assignee !== currentSigner;
|
|
386
436
|
const isFilled = mode === "signer" && isEditable && !isRedact && (field.type === "checkbox" ? true : field.formula ? true : !!field.value);
|
|
@@ -521,9 +571,9 @@ var INK_COLORS = [
|
|
|
521
571
|
];
|
|
522
572
|
function FieldPropertyPanel({ field, signerRoles, onUpdate, onDelete, prefillContent, pageSize }) {
|
|
523
573
|
const color = getSignerColor(field.assignee);
|
|
524
|
-
const
|
|
525
|
-
const
|
|
526
|
-
const showInkColor =
|
|
574
|
+
const isRedact = isRedactField(field);
|
|
575
|
+
const isText = isTextLikeField(field);
|
|
576
|
+
const showInkColor = isText || isSignatureField(field);
|
|
527
577
|
const [newOption, setNewOption] = useState2("");
|
|
528
578
|
return /* @__PURE__ */ jsxs2("div", { className: "field-property-panel", children: [
|
|
529
579
|
/* @__PURE__ */ jsxs2("div", { className: "panel-header", children: [
|
|
@@ -555,7 +605,7 @@ function FieldPropertyPanel({ field, signerRoles, onUpdate, onDelete, prefillCon
|
|
|
555
605
|
/* @__PURE__ */ jsx2("button", { onClick: () => onDelete(field.id), className: "panel-icon-btn panel-icon-btn-danger", title: "Delete", children: /* @__PURE__ */ jsx2("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "currentColor", children: /* @__PURE__ */ jsx2("path", { d: "M5 1h4v1H5V1zM2 3v1h1v8.5A1.5 1.5 0 004.5 14h5a1.5 1.5 0 001.5-1.5V4h1V3H2zm2 1h6v8.5a.5.5 0 01-.5.5h-5a.5.5 0 01-.5-.5V4z" }) }) })
|
|
556
606
|
] })
|
|
557
607
|
] }),
|
|
558
|
-
!
|
|
608
|
+
!isRedact && /* @__PURE__ */ jsxs2("div", { className: "panel-section", children: [
|
|
559
609
|
/* @__PURE__ */ jsx2("div", { className: "panel-section-heading", children: "Assigned To" }),
|
|
560
610
|
/* @__PURE__ */ jsx2(
|
|
561
611
|
"select",
|
|
@@ -570,7 +620,7 @@ function FieldPropertyPanel({ field, signerRoles, onUpdate, onDelete, prefillCon
|
|
|
570
620
|
] }),
|
|
571
621
|
/* @__PURE__ */ jsxs2("div", { className: "panel-section", children: [
|
|
572
622
|
/* @__PURE__ */ jsx2("div", { className: "panel-section-heading", children: "Content" }),
|
|
573
|
-
!
|
|
623
|
+
!isRedact && /* @__PURE__ */ jsxs2("div", { className: "panel-field", children: [
|
|
574
624
|
/* @__PURE__ */ jsx2("label", { children: "Field Type" }),
|
|
575
625
|
/* @__PURE__ */ jsxs2("select", { value: field.type, onChange: (e) => onUpdate(field.id, { type: e.target.value }), children: [
|
|
576
626
|
/* @__PURE__ */ jsx2("option", { value: "text", children: "Text" }),
|
|
@@ -591,15 +641,15 @@ function FieldPropertyPanel({ field, signerRoles, onUpdate, onDelete, prefillCon
|
|
|
591
641
|
/* @__PURE__ */ jsx2("option", { value: "phone", children: "Phone" })
|
|
592
642
|
] })
|
|
593
643
|
] }),
|
|
594
|
-
!
|
|
644
|
+
!isRedact && /* @__PURE__ */ jsxs2("div", { className: "panel-field", children: [
|
|
595
645
|
/* @__PURE__ */ jsx2("label", { children: "Placeholder" }),
|
|
596
646
|
/* @__PURE__ */ jsx2("input", { type: "text", value: field.placeholder, onChange: (e) => onUpdate(field.id, { placeholder: e.target.value }) })
|
|
597
647
|
] }),
|
|
598
|
-
!
|
|
648
|
+
!isRedact && field.type !== "checkbox" && /* @__PURE__ */ jsx2("div", { className: "panel-field", children: /* @__PURE__ */ jsxs2("label", { className: "panel-checkbox-label", children: [
|
|
599
649
|
/* @__PURE__ */ jsx2("input", { type: "checkbox", checked: field.required, onChange: (e) => onUpdate(field.id, { required: e.target.checked }) }),
|
|
600
650
|
"Required"
|
|
601
651
|
] }) }),
|
|
602
|
-
|
|
652
|
+
isText && /* @__PURE__ */ jsxs2("div", { className: "panel-field", children: [
|
|
603
653
|
/* @__PURE__ */ jsx2("label", { children: "Formula" }),
|
|
604
654
|
/* @__PURE__ */ jsx2("input", { type: "text", value: field.formula || "", onChange: (e) => onUpdate(field.id, { formula: e.target.value || void 0 }), placeholder: "e.g. {{Date Field | month}}" }),
|
|
605
655
|
field.formula && /* @__PURE__ */ jsx2("span", { className: "panel-hint", children: "Auto-computed. Signer cannot edit." })
|
|
@@ -614,7 +664,7 @@ function FieldPropertyPanel({ field, signerRoles, onUpdate, onDelete, prefillCon
|
|
|
614
664
|
/* @__PURE__ */ jsx2("input", { type: "number", min: "0", max: "9999", value: field.maxLength || 0, onChange: (e) => onUpdate(field.id, { maxLength: Number(e.target.value) }) })
|
|
615
665
|
] })
|
|
616
666
|
] }),
|
|
617
|
-
|
|
667
|
+
isText && /* @__PURE__ */ jsxs2("div", { className: "panel-field", children: [
|
|
618
668
|
/* @__PURE__ */ jsxs2("label", { className: "panel-checkbox-label", children: [
|
|
619
669
|
/* @__PURE__ */ jsx2("input", { type: "checkbox", checked: field.autoShrink || false, onChange: (e) => onUpdate(field.id, { autoShrink: e.target.checked }) }),
|
|
620
670
|
"Auto-shrink to fit"
|
|
@@ -651,17 +701,17 @@ function FieldPropertyPanel({ field, signerRoles, onUpdate, onDelete, prefillCon
|
|
|
651
701
|
] }),
|
|
652
702
|
prefillContent
|
|
653
703
|
] }),
|
|
654
|
-
(
|
|
704
|
+
(isText || showInkColor) && /* @__PURE__ */ jsxs2("div", { className: "panel-section", children: [
|
|
655
705
|
/* @__PURE__ */ jsx2("div", { className: "panel-section-heading", children: "Style" }),
|
|
656
|
-
|
|
706
|
+
isText && /* @__PURE__ */ jsxs2("div", { className: "panel-field", children: [
|
|
657
707
|
/* @__PURE__ */ jsx2("label", { children: "Font" }),
|
|
658
708
|
/* @__PURE__ */ jsx2("select", { value: field.fontFamily || "Helvetica", onChange: (e) => onUpdate(field.id, { fontFamily: e.target.value }), children: FONT_FAMILIES.map((f) => /* @__PURE__ */ jsx2("option", { value: f.value, children: f.label }, f.value)) })
|
|
659
709
|
] }),
|
|
660
|
-
|
|
710
|
+
isText && /* @__PURE__ */ jsxs2("div", { className: "panel-field", children: [
|
|
661
711
|
/* @__PURE__ */ jsx2("label", { children: "Font Size (pt)" }),
|
|
662
712
|
/* @__PURE__ */ jsx2("input", { type: "number", min: "6", max: "72", value: field.fontSize, onChange: (e) => onUpdate(field.id, { fontSize: Number(e.target.value) }) })
|
|
663
713
|
] }),
|
|
664
|
-
|
|
714
|
+
isText && /* @__PURE__ */ jsxs2("div", { className: "panel-field-row", children: [
|
|
665
715
|
/* @__PURE__ */ jsxs2("div", { className: "panel-field panel-field-half", children: [
|
|
666
716
|
/* @__PURE__ */ jsx2("label", { children: "Letter Spacing" }),
|
|
667
717
|
/* @__PURE__ */ jsx2("input", { type: "number", min: "0", max: "20", step: "0.5", value: field.letterSpacing || 0, onChange: (e) => onUpdate(field.id, { letterSpacing: Number(e.target.value) }) })
|
|
@@ -1138,6 +1188,7 @@ function DesignerView({
|
|
|
1138
1188
|
initialPdfUrl,
|
|
1139
1189
|
initialTemplate,
|
|
1140
1190
|
onSave,
|
|
1191
|
+
onChange,
|
|
1141
1192
|
hideHeader,
|
|
1142
1193
|
headerPortalRef
|
|
1143
1194
|
} = {}) {
|
|
@@ -1172,6 +1223,20 @@ function DesignerView({
|
|
|
1172
1223
|
const dragGhostRef = useRef4(null);
|
|
1173
1224
|
const resizingRef = useRef4(false);
|
|
1174
1225
|
const lastStylesRef = useRef4({});
|
|
1226
|
+
const onChangeMountedRef = useRef4(false);
|
|
1227
|
+
useEffect2(() => {
|
|
1228
|
+
if (!onChange) return;
|
|
1229
|
+
if (!onChangeMountedRef.current) {
|
|
1230
|
+
onChangeMountedRef.current = true;
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
const template = {
|
|
1234
|
+
fields,
|
|
1235
|
+
signerRoles,
|
|
1236
|
+
pdfUrl: typeof pdfSource === "string" ? pdfSource : ""
|
|
1237
|
+
};
|
|
1238
|
+
onChange(template);
|
|
1239
|
+
}, [fields, signerRoles, pdfSource, onChange]);
|
|
1175
1240
|
useEffect2(() => {
|
|
1176
1241
|
const pdfUrl = initialPdfUrl || initialTemplate?.pdfUrl;
|
|
1177
1242
|
if (pdfUrl) {
|
|
@@ -1218,11 +1283,16 @@ function DesignerView({
|
|
|
1218
1283
|
reader.readAsArrayBuffer(file);
|
|
1219
1284
|
}, [loadPdf]);
|
|
1220
1285
|
const handlePageClick = useCallback4((page, x, y) => {
|
|
1286
|
+
const scrollEl = pdfAreaRef.current;
|
|
1287
|
+
const scrollTop = scrollEl?.scrollTop ?? 0;
|
|
1221
1288
|
const field = createField(activeFieldType, activeRole, page, x, y, fields);
|
|
1222
1289
|
const sticky = lastStylesRef.current[activeFieldType];
|
|
1223
1290
|
const styledField = sticky ? { ...field, ...sticky } : field;
|
|
1224
1291
|
setFields((prev) => [...prev, styledField]);
|
|
1225
1292
|
setSelectedFieldIds(/* @__PURE__ */ new Set([styledField.id]));
|
|
1293
|
+
requestAnimationFrame(() => {
|
|
1294
|
+
if (scrollEl) scrollEl.scrollTop = scrollTop;
|
|
1295
|
+
});
|
|
1226
1296
|
setRightTab("properties");
|
|
1227
1297
|
}, [activeFieldType, activeRole, fields]);
|
|
1228
1298
|
const handleFieldMove = useCallback4((id, page, x, y) => {
|
|
@@ -1597,24 +1667,19 @@ function DesignerView({
|
|
|
1597
1667
|
window.addEventListener("mousemove", handleMouseMove);
|
|
1598
1668
|
window.addEventListener("mouseup", handleMouseUp);
|
|
1599
1669
|
}, [panelWidth]);
|
|
1600
|
-
const sortedFields =
|
|
1601
|
-
if (a.page !== b.page) return a.page - b.page;
|
|
1602
|
-
const bandThreshold = 2;
|
|
1603
|
-
if (Math.abs(a.y - b.y) > bandThreshold) return a.y - b.y;
|
|
1604
|
-
return a.x - b.x;
|
|
1605
|
-
});
|
|
1670
|
+
const sortedFields = sortFieldsByPosition(fields);
|
|
1606
1671
|
const selectedField = selectedFieldIds.size === 1 ? fields.find((f) => f.id === Array.from(selectedFieldIds)[0]) || null : null;
|
|
1607
1672
|
const renderFieldContent = useCallback4((field) => {
|
|
1608
|
-
if (field
|
|
1673
|
+
if (isRedactField(field)) {
|
|
1609
1674
|
return null;
|
|
1610
1675
|
}
|
|
1611
|
-
if (field
|
|
1676
|
+
if (isSignatureField(field)) {
|
|
1612
1677
|
if (field.value) {
|
|
1613
1678
|
return /* @__PURE__ */ jsx4("img", { src: field.value, alt: field.label, className: "field-signature-preview" });
|
|
1614
1679
|
}
|
|
1615
1680
|
}
|
|
1616
1681
|
const inkColor = field.inkColor || "#000000";
|
|
1617
|
-
const cssFontFamily = field.fontFamily
|
|
1682
|
+
const cssFontFamily = getCssFontFamily(field.fontFamily);
|
|
1618
1683
|
return /* @__PURE__ */ jsx4(
|
|
1619
1684
|
"div",
|
|
1620
1685
|
{
|
|
@@ -1639,7 +1704,6 @@ function DesignerView({
|
|
|
1639
1704
|
] }) : null;
|
|
1640
1705
|
return /* @__PURE__ */ jsxs4("div", { className: "designer-layout", children: [
|
|
1641
1706
|
headerPortalRef?.current && headerButtons && createPortal(headerButtons, headerPortalRef.current),
|
|
1642
|
-
!hideHeader && !headerPortalRef && /* @__PURE__ */ jsx4("div", { className: "designer-header", children: /* @__PURE__ */ jsx4("div", { className: "designer-header-right", children: headerButtons }) }),
|
|
1643
1707
|
/* @__PURE__ */ jsxs4("div", { className: "designer-body", children: [
|
|
1644
1708
|
pages.length > 0 && /* @__PURE__ */ jsxs4("div", { className: "designer-palette", children: [
|
|
1645
1709
|
/* @__PURE__ */ jsx4("div", { className: "palette-heading", children: "New Field Role" }),
|
|
@@ -1753,6 +1817,7 @@ function DesignerView({
|
|
|
1753
1817
|
pages.length > 0 && /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
1754
1818
|
/* @__PURE__ */ jsx4("div", { className: "panel-resize-handle", onMouseDown: handleResizeStart }),
|
|
1755
1819
|
/* @__PURE__ */ jsxs4("div", { className: "designer-panel", style: { width: panelWidth }, children: [
|
|
1820
|
+
!hideHeader && !headerPortalRef && headerButtons && /* @__PURE__ */ jsx4("div", { className: "designer-panel-actions", children: headerButtons }),
|
|
1756
1821
|
/* @__PURE__ */ jsxs4("div", { className: "designer-panel-header", children: [
|
|
1757
1822
|
/* @__PURE__ */ jsxs4("div", { className: "signer-role-indicator", children: [
|
|
1758
1823
|
/* @__PURE__ */ jsx4("span", { className: "signer-role-indicator-label", children: "Editing as" }),
|
|
@@ -1843,9 +1908,9 @@ function DesignerView({
|
|
|
1843
1908
|
onUpdate: handleFieldUpdate,
|
|
1844
1909
|
onDelete: handleFieldDelete,
|
|
1845
1910
|
pageSize: pages[selectedField.page] ? { width: pages[selectedField.page].pdfWidth, height: pages[selectedField.page].pdfHeight } : void 0,
|
|
1846
|
-
prefillContent: selectedField
|
|
1911
|
+
prefillContent: !isRedactField(selectedField) ? /* @__PURE__ */ jsxs4("div", { className: "prefill-section", children: [
|
|
1847
1912
|
/* @__PURE__ */ jsx4("label", { children: "Pre-fill Value" }),
|
|
1848
|
-
selectedField
|
|
1913
|
+
isSignatureField(selectedField) ? /* @__PURE__ */ jsx4(
|
|
1849
1914
|
SignatureCanvas,
|
|
1850
1915
|
{
|
|
1851
1916
|
width: panelWidth - 40,
|
|
@@ -2129,7 +2194,7 @@ async function renderFieldsOnPages(pages, fields, getFont, getSignature) {
|
|
|
2129
2194
|
const y = pageHeight - field.y / 100 * pageHeight - field.height / 100 * pageHeight;
|
|
2130
2195
|
const w = field.width / 100 * pageWidth;
|
|
2131
2196
|
const h = field.height / 100 * pageHeight;
|
|
2132
|
-
if (field
|
|
2197
|
+
if (isRedactField(field)) {
|
|
2133
2198
|
page.drawRectangle({
|
|
2134
2199
|
x,
|
|
2135
2200
|
y,
|
|
@@ -2158,7 +2223,7 @@ async function renderFieldsOnPages(pages, fields, getFont, getSignature) {
|
|
|
2158
2223
|
color: inkColor
|
|
2159
2224
|
});
|
|
2160
2225
|
}
|
|
2161
|
-
} else if (field
|
|
2226
|
+
} else if (isSignatureField(field)) {
|
|
2162
2227
|
if (field.value.startsWith("data:image/png")) {
|
|
2163
2228
|
const img = await getSignature(field.value);
|
|
2164
2229
|
page.drawImage(img, { x, y, width: w, height: h });
|
|
@@ -2456,7 +2521,7 @@ function SignerView({
|
|
|
2456
2521
|
useEffect3(() => {
|
|
2457
2522
|
if (fields.length === 0 || !isMultiSigner) return;
|
|
2458
2523
|
const signerFields = fields.filter(
|
|
2459
|
-
(f) => f.assignee === signer && f
|
|
2524
|
+
(f) => f.assignee === signer && !isRedactField(f)
|
|
2460
2525
|
);
|
|
2461
2526
|
const allFilled = signerFields.length > 0 && signerFields.every((f) => {
|
|
2462
2527
|
if (!f.required) return true;
|
|
@@ -2550,14 +2615,9 @@ function SignerView({
|
|
|
2550
2615
|
setLoading(false);
|
|
2551
2616
|
}
|
|
2552
2617
|
}, []);
|
|
2553
|
-
const editableFields = fields.filter((f) => f.assignee === signer && f
|
|
2554
|
-
if (a.page !== b.page) return a.page - b.page;
|
|
2555
|
-
const bandThreshold = 2;
|
|
2556
|
-
if (Math.abs(a.y - b.y) > bandThreshold) return a.y - b.y;
|
|
2557
|
-
return a.x - b.x;
|
|
2558
|
-
});
|
|
2618
|
+
const editableFields = sortFieldsByPosition(fields.filter((f) => f.assignee === signer && !isRedactField(f) && !f.formula));
|
|
2559
2619
|
const selectedField = fields.find((f) => f.id === selectedFieldId) || null;
|
|
2560
|
-
const isFieldEditable = selectedField ? selectedField.assignee === signer && selectedField
|
|
2620
|
+
const isFieldEditable = selectedField ? selectedField.assignee === signer && !isRedactField(selectedField) && !selectedField.formula : false;
|
|
2561
2621
|
const handleFieldUpdate = useCallback5((id, value) => {
|
|
2562
2622
|
setFields((prev) => prev.map((f) => f.id === id ? { ...f, value } : f));
|
|
2563
2623
|
}, []);
|
|
@@ -2569,7 +2629,7 @@ function SignerView({
|
|
|
2569
2629
|
if (!onChange) return;
|
|
2570
2630
|
const values = {};
|
|
2571
2631
|
fields.forEach((f) => {
|
|
2572
|
-
if (f
|
|
2632
|
+
if (!isRedactField(f)) values[f.label] = f.value || "";
|
|
2573
2633
|
});
|
|
2574
2634
|
onChange(values);
|
|
2575
2635
|
}, [fieldValuesKey]);
|
|
@@ -2590,18 +2650,12 @@ function SignerView({
|
|
|
2590
2650
|
if (f.minLength && f.value.length < f.minLength) return false;
|
|
2591
2651
|
return true;
|
|
2592
2652
|
});
|
|
2593
|
-
const
|
|
2594
|
-
const values = {};
|
|
2595
|
-
fields.forEach((f) => {
|
|
2596
|
-
if (f.type !== "blackout" && f.type !== "whiteout") values[f.label] = f.value || "";
|
|
2597
|
-
});
|
|
2598
|
-
return values;
|
|
2599
|
-
}, [fields]);
|
|
2653
|
+
const getValues = useCallback5(() => getFieldValues(fields), [fields]);
|
|
2600
2654
|
const handleAdvanceOrSubmit = useCallback5(async () => {
|
|
2601
2655
|
if (!allRequiredFilled) return;
|
|
2602
2656
|
auditLogRef.current.push({ signer, completedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
2603
2657
|
if (onSignerComplete) {
|
|
2604
|
-
onSignerComplete(signer,
|
|
2658
|
+
onSignerComplete(signer, getValues());
|
|
2605
2659
|
}
|
|
2606
2660
|
if (!isLastSigner) {
|
|
2607
2661
|
setCurrentSignerIndex((prev) => prev + 1);
|
|
@@ -2640,7 +2694,7 @@ function SignerView({
|
|
|
2640
2694
|
}
|
|
2641
2695
|
const blob = new Blob([pdfBytes.slice().buffer], { type: "application/pdf" });
|
|
2642
2696
|
if (onExport && exportFormat) {
|
|
2643
|
-
const values =
|
|
2697
|
+
const values = getValues();
|
|
2644
2698
|
if (exportFormat === "json") {
|
|
2645
2699
|
onExport(JSON.stringify(values, null, 2), "json");
|
|
2646
2700
|
} else {
|
|
@@ -2665,9 +2719,9 @@ ${row.join(",")}`, "csv");
|
|
|
2665
2719
|
} finally {
|
|
2666
2720
|
setSubmitting(false);
|
|
2667
2721
|
}
|
|
2668
|
-
}, [pdfSource, fields, callbackUrl, allRequiredFilled, onComplete, isLastSigner, signer, onSignerComplete, includeAuditTrail, exportFormat, onExport,
|
|
2722
|
+
}, [pdfSource, fields, callbackUrl, allRequiredFilled, onComplete, isLastSigner, signer, onSignerComplete, includeAuditTrail, exportFormat, onExport, getValues, transforms]);
|
|
2669
2723
|
const renderFieldContent = useCallback5((field) => {
|
|
2670
|
-
if (field
|
|
2724
|
+
if (isRedactField(field)) {
|
|
2671
2725
|
return null;
|
|
2672
2726
|
}
|
|
2673
2727
|
if (field.formula) {
|
|
@@ -2675,7 +2729,7 @@ ${row.join(",")}`, "csv");
|
|
|
2675
2729
|
}
|
|
2676
2730
|
const editable = field.assignee === signer;
|
|
2677
2731
|
if (!editable) {
|
|
2678
|
-
if (field
|
|
2732
|
+
if (isSignatureField(field)) {
|
|
2679
2733
|
return field.value ? /* @__PURE__ */ jsx6("img", { src: field.value, alt: field.label, className: "field-signature-preview" }) : /* @__PURE__ */ jsx6("div", { className: "field-overlay-placeholder readonly", children: field.placeholder });
|
|
2680
2734
|
}
|
|
2681
2735
|
if (field.type === "checkbox") {
|
|
@@ -2683,7 +2737,7 @@ ${row.join(",")}`, "csv");
|
|
|
2683
2737
|
}
|
|
2684
2738
|
return /* @__PURE__ */ jsx6("div", { className: "field-overlay-placeholder readonly", children: field.value || field.placeholder });
|
|
2685
2739
|
}
|
|
2686
|
-
if (field
|
|
2740
|
+
if (isSignatureField(field)) {
|
|
2687
2741
|
if (field.value) {
|
|
2688
2742
|
return /* @__PURE__ */ jsx6("div", { className: "field-signature-filled", onClick: () => handleFieldUpdate(field.id, ""), children: /* @__PURE__ */ jsx6("img", { src: field.value, alt: field.label, className: "field-signature-preview" }) });
|
|
2689
2743
|
}
|
|
@@ -2709,7 +2763,7 @@ ${row.join(",")}`, "csv");
|
|
|
2709
2763
|
fontSize: `${field.fontSize}pt`,
|
|
2710
2764
|
letterSpacing: field.letterSpacing ? `${field.letterSpacing}pt` : void 0,
|
|
2711
2765
|
lineHeight: field.lineHeight ? `${field.lineHeight}` : void 0,
|
|
2712
|
-
fontFamily: field.fontFamily
|
|
2766
|
+
fontFamily: getCssFontFamily(field.fontFamily)
|
|
2713
2767
|
};
|
|
2714
2768
|
if (field.type === "dropdown" || field.options && field.options.length > 0) {
|
|
2715
2769
|
return /* @__PURE__ */ jsxs6(
|
|
@@ -2794,7 +2848,7 @@ ${row.join(",")}`, "csv");
|
|
|
2794
2848
|
selectedField && isFieldEditable && /* @__PURE__ */ jsxs6("div", { className: "signer-field-input", children: [
|
|
2795
2849
|
/* @__PURE__ */ jsx6("h3", { children: selectedField.label }),
|
|
2796
2850
|
selectedField.required && /* @__PURE__ */ jsx6("span", { className: "required-badge", children: "Required" }),
|
|
2797
|
-
(selectedField
|
|
2851
|
+
isSignatureField(selectedField) && /* @__PURE__ */ jsx6(
|
|
2798
2852
|
SignatureCanvas,
|
|
2799
2853
|
{
|
|
2800
2854
|
width: 280,
|
|
@@ -2980,11 +3034,19 @@ export {
|
|
|
2980
3034
|
downloadPdf,
|
|
2981
3035
|
generateFilledPdf,
|
|
2982
3036
|
generateId,
|
|
3037
|
+
getCssFontFamily,
|
|
3038
|
+
getFieldValues,
|
|
3039
|
+
getInputType,
|
|
2983
3040
|
getSignerColor,
|
|
3041
|
+
isRedactField,
|
|
3042
|
+
isSignatureField,
|
|
3043
|
+
isTextLikeField,
|
|
2984
3044
|
postPdfToCallback,
|
|
3045
|
+
preserveFieldValues,
|
|
2985
3046
|
renderPdfPages,
|
|
2986
3047
|
resolveAllFormulas,
|
|
2987
3048
|
resolveFormula,
|
|
3049
|
+
sortFieldsByPosition,
|
|
2988
3050
|
uniqueLabel
|
|
2989
3051
|
};
|
|
2990
3052
|
//# sourceMappingURL=index.mjs.map
|