@signiphi/pdf-signer 0.2.0-beta.16 → 0.2.0-beta.17
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/components/index.js +37 -13
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +37 -13
- package/dist/components/index.mjs.map +1 -1
- package/dist/hooks/index.js +36 -12
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +37 -13
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.js +37 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -13
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.js +15 -7
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +15 -7
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/components/index.js
CHANGED
|
@@ -903,7 +903,7 @@ async function fillPdfWithSignatures(pdfBytes, signatures, formFieldValues = {},
|
|
|
903
903
|
const fieldInfo = extractedFormFields?.find((f) => f.name === fieldName);
|
|
904
904
|
if (fieldInfo && hasDrawableLabel(fieldInfo)) {
|
|
905
905
|
const labelFont = await pdfDoc.embedFont(StandardFonts.HelveticaBold);
|
|
906
|
-
const labelFontSize = Math.min(
|
|
906
|
+
const labelFontSize = Math.min(10, height * 0.4);
|
|
907
907
|
const labelX = x;
|
|
908
908
|
const labelY = y + height + 5;
|
|
909
909
|
page.drawText(fieldInfo.label, {
|
|
@@ -948,7 +948,7 @@ async function fillPdfWithSignatures(pdfBytes, signatures, formFieldValues = {},
|
|
|
948
948
|
console.log("[FLATTEN] After pattern matching in fieldPageMap:", foundInitialsFields);
|
|
949
949
|
if (extractedFormFields && extractedFormFields.length > 0) {
|
|
950
950
|
foundInitialsFields = foundInitialsFields.filter((fieldName) => {
|
|
951
|
-
const fieldInfo = extractedFormFields.find((f) => f.name === fieldName);
|
|
951
|
+
const fieldInfo = extractedFormFields.find((f) => f.name === fieldName) || extractedFormFields.find((f) => f.name === fieldName.replace(/_initials$/i, "")) || extractedFormFields.find((f) => fieldName.startsWith(f.name));
|
|
952
952
|
if (!fieldInfo) return false;
|
|
953
953
|
const isActualInitialsField = fieldInfo.type === "initials" || fieldName.toLowerCase().includes("initials");
|
|
954
954
|
if (!isActualInitialsField) return false;
|
|
@@ -977,9 +977,9 @@ async function fillPdfWithSignatures(pdfBytes, signatures, formFieldValues = {},
|
|
|
977
977
|
const y = fieldPosition.y;
|
|
978
978
|
const height = Math.max(fieldPosition.height, 20);
|
|
979
979
|
const fontSize = Math.min(height * 0.7, 14);
|
|
980
|
-
const fieldInfo = extractedFormFields?.find((f) => f.name === fieldName);
|
|
980
|
+
const fieldInfo = extractedFormFields?.find((f) => f.name === fieldName) || extractedFormFields?.find((f) => f.name === fieldName.replace(/_initials$/i, "")) || extractedFormFields?.find((f) => fieldName.startsWith(f.name)) || extractedFormFields?.find((f) => f.fieldId && fieldName.includes(f.fieldId)) || extractedFormFields?.find((f) => f.type === "initials" && f.name !== "initials_field_main");
|
|
981
981
|
if (fieldInfo && hasDrawableLabel(fieldInfo)) {
|
|
982
|
-
const labelFontSize = Math.min(
|
|
982
|
+
const labelFontSize = Math.min(10, height * 0.4);
|
|
983
983
|
const labelX = x;
|
|
984
984
|
const labelY = y + height + 5;
|
|
985
985
|
page.drawText(fieldInfo.label, {
|
|
@@ -1060,7 +1060,7 @@ async function fillPdfWithSignatures(pdfBytes, signatures, formFieldValues = {},
|
|
|
1060
1060
|
if (!result) continue;
|
|
1061
1061
|
const { rect, page } = result;
|
|
1062
1062
|
if (fieldInfo && hasDrawableLabel(fieldInfo)) {
|
|
1063
|
-
const labelFontSize = Math.min(
|
|
1063
|
+
const labelFontSize = Math.min(10, rect.height * 0.4);
|
|
1064
1064
|
const labelX = rect.x + rect.width + 5;
|
|
1065
1065
|
const labelY = rect.y + (rect.height - labelFontSize) / 2;
|
|
1066
1066
|
page.drawText(fieldInfo.label, {
|
|
@@ -1174,11 +1174,12 @@ async function fillPdfWithSignatures(pdfBytes, signatures, formFieldValues = {},
|
|
|
1174
1174
|
if (i === 0 && fieldInfo && hasDrawableLabel(fieldInfo)) {
|
|
1175
1175
|
const groupLabelKey = `${pageIndex}-${fieldName}-grouplabel`;
|
|
1176
1176
|
if (!drawnGroupLabels.has(groupLabelKey)) {
|
|
1177
|
+
const labelFontSize = Math.min(10, rect.height * 0.4);
|
|
1177
1178
|
const labelY = rect.y + rect.height + 3;
|
|
1178
1179
|
page.drawText(fieldInfo.label, {
|
|
1179
1180
|
x: rect.x,
|
|
1180
1181
|
y: labelY,
|
|
1181
|
-
size:
|
|
1182
|
+
size: labelFontSize,
|
|
1182
1183
|
font: labelFont,
|
|
1183
1184
|
color: rgb(0, 0, 0)
|
|
1184
1185
|
});
|
|
@@ -1230,7 +1231,7 @@ async function fillPdfWithSignatures(pdfBytes, signatures, formFieldValues = {},
|
|
|
1230
1231
|
if (!result) continue;
|
|
1231
1232
|
const { rect, page } = result;
|
|
1232
1233
|
if (fieldInfo && hasDrawableLabel(fieldInfo)) {
|
|
1233
|
-
const labelFontSize = Math.min(
|
|
1234
|
+
const labelFontSize = Math.min(10, rect.height * 0.4);
|
|
1234
1235
|
const labelX = rect.x;
|
|
1235
1236
|
const labelY = rect.y + rect.height + 5;
|
|
1236
1237
|
page.drawText(fieldInfo.label, {
|
|
@@ -1530,6 +1531,13 @@ async function extractVisibleFormFields(pdfBytes, currentSignerEmail) {
|
|
|
1530
1531
|
logger.warn("Error extracting options for field:", error);
|
|
1531
1532
|
}
|
|
1532
1533
|
}
|
|
1534
|
+
try {
|
|
1535
|
+
const currentValue = extractFieldValue(f, esignField.type);
|
|
1536
|
+
if (currentValue) {
|
|
1537
|
+
esignField.defaultValue = currentValue;
|
|
1538
|
+
}
|
|
1539
|
+
} catch {
|
|
1540
|
+
}
|
|
1533
1541
|
visibleFields.push(esignField);
|
|
1534
1542
|
}
|
|
1535
1543
|
}
|
|
@@ -7349,11 +7357,12 @@ async function drawFieldLabelsOnPdf(pdfDoc, fieldsToLabel, rgb) {
|
|
|
7349
7357
|
if (page) {
|
|
7350
7358
|
const groupLabelKey = `${pageIndex}-${field.name}-grouplabel`;
|
|
7351
7359
|
if (!drawnOnce.has(groupLabelKey)) {
|
|
7360
|
+
const radioLabelFontSize = Math.min(10, firstRect.height * 0.4);
|
|
7352
7361
|
const labelY = firstRect.y + firstRect.height + 5;
|
|
7353
7362
|
page.drawText(field.label, {
|
|
7354
7363
|
x: firstRect.x,
|
|
7355
7364
|
y: labelY,
|
|
7356
|
-
size:
|
|
7365
|
+
size: radioLabelFontSize,
|
|
7357
7366
|
font: labelFont,
|
|
7358
7367
|
color: rgb(0, 0, 0)
|
|
7359
7368
|
});
|
|
@@ -7403,11 +7412,12 @@ async function drawFieldLabelsOnPdf(pdfDoc, fieldsToLabel, rgb) {
|
|
|
7403
7412
|
const key = `${pageIndex}-${field.name}`;
|
|
7404
7413
|
if (!drawnOnce.has(key)) {
|
|
7405
7414
|
if (hasDrawableLabel(field)) {
|
|
7415
|
+
const labelFontSize = Math.min(10, rect.height * 0.4);
|
|
7406
7416
|
if (field.type === "checkbox" /* CHECKBOX */) {
|
|
7407
7417
|
page.drawText(field.label, {
|
|
7408
7418
|
x: rect.x + rect.width + 5,
|
|
7409
|
-
y: rect.y + rect.height
|
|
7410
|
-
size:
|
|
7419
|
+
y: rect.y + (rect.height - labelFontSize) / 2,
|
|
7420
|
+
size: labelFontSize,
|
|
7411
7421
|
font: labelFont,
|
|
7412
7422
|
color: rgb(0, 0, 0)
|
|
7413
7423
|
});
|
|
@@ -7416,9 +7426,9 @@ async function drawFieldLabelsOnPdf(pdfDoc, fieldsToLabel, rgb) {
|
|
|
7416
7426
|
page.drawText(field.label, {
|
|
7417
7427
|
x: rect.x,
|
|
7418
7428
|
y: labelY,
|
|
7419
|
-
size:
|
|
7429
|
+
size: labelFontSize,
|
|
7420
7430
|
font: labelFont,
|
|
7421
|
-
color: rgb(0
|
|
7431
|
+
color: rgb(0, 0, 0)
|
|
7422
7432
|
});
|
|
7423
7433
|
}
|
|
7424
7434
|
drawnOnce.add(key);
|
|
@@ -7736,6 +7746,20 @@ function usePdfViewer(multiSignerContext) {
|
|
|
7736
7746
|
}
|
|
7737
7747
|
function useFormFields(fields = []) {
|
|
7738
7748
|
const [fieldValues, setFieldValues] = React9.useState({});
|
|
7749
|
+
const seededFieldsRef = React9.useRef(/* @__PURE__ */ new Set());
|
|
7750
|
+
React9.useEffect(() => {
|
|
7751
|
+
if (fields.length === 0) return;
|
|
7752
|
+
const defaults = {};
|
|
7753
|
+
for (const field of fields) {
|
|
7754
|
+
if (field.defaultValue && field.defaultValue.trim() && !seededFieldsRef.current.has(field.id)) {
|
|
7755
|
+
defaults[field.id] = field.defaultValue;
|
|
7756
|
+
seededFieldsRef.current.add(field.id);
|
|
7757
|
+
}
|
|
7758
|
+
}
|
|
7759
|
+
if (Object.keys(defaults).length > 0) {
|
|
7760
|
+
setFieldValues((prev) => ({ ...defaults, ...prev }));
|
|
7761
|
+
}
|
|
7762
|
+
}, [fields]);
|
|
7739
7763
|
const [errors, setErrors] = React9.useState([]);
|
|
7740
7764
|
const [touched, setTouched] = React9.useState({});
|
|
7741
7765
|
const updateField = React9.useCallback((fieldId, value) => {
|
|
@@ -8351,7 +8375,7 @@ function SubmissionForm({
|
|
|
8351
8375
|
getFieldError,
|
|
8352
8376
|
isFieldTouched,
|
|
8353
8377
|
clearFields
|
|
8354
|
-
} = useFormFields();
|
|
8378
|
+
} = useFormFields(extractedFields);
|
|
8355
8379
|
const {
|
|
8356
8380
|
signatures,
|
|
8357
8381
|
setSignature: setSignatureOriginal,
|