@unlev/exeq 0.1.10 → 0.1.12

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/index.mjs CHANGED
@@ -1108,7 +1108,7 @@ function DesignerView({
1108
1108
  }
1109
1109
 
1110
1110
  // src/components/pdf-builder/SignerView.tsx
1111
- import { useState as useState3, useCallback as useCallback4, useEffect as useEffect3, useRef as useRef4 } from "react";
1111
+ import { useState as useState4, useCallback as useCallback4, useEffect as useEffect3, useRef as useRef4 } from "react";
1112
1112
 
1113
1113
  // src/utils/pdfFiller.ts
1114
1114
  import { PDFDocument, rgb, StandardFonts } from "pdf-lib";
@@ -1182,14 +1182,20 @@ async function generateFilledPdf(pdfSource, fields) {
1182
1182
  });
1183
1183
  }
1184
1184
  } else {
1185
- const fontSize = Math.min(field.fontSize, h * 0.7);
1185
+ const maxFontSize = Math.min(field.fontSize, h * 0.7);
1186
+ let fontSize = maxFontSize;
1187
+ const padding = 4;
1188
+ while (fontSize > 4) {
1189
+ const textWidth = font.widthOfTextAtSize(field.value, fontSize);
1190
+ if (textWidth <= w - padding) break;
1191
+ fontSize -= 0.5;
1192
+ }
1186
1193
  page.drawText(field.value, {
1187
1194
  x: x + 2,
1188
1195
  y: y + h * 0.3,
1189
1196
  size: fontSize,
1190
1197
  font,
1191
- color: inkColor,
1192
- maxWidth: w - 4
1198
+ color: inkColor
1193
1199
  });
1194
1200
  }
1195
1201
  }
@@ -1215,7 +1221,13 @@ async function postPdfToCallback(bytes, callbackUrl, filename) {
1215
1221
  }
1216
1222
 
1217
1223
  // src/components/pdf-builder/FieldNavigator.tsx
1224
+ import { useState as useState3 } from "react";
1218
1225
  import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1226
+ function isFieldFilled(f) {
1227
+ if (!f.required) return true;
1228
+ if (f.type === "checkbox") return true;
1229
+ return !!f.value;
1230
+ }
1219
1231
  function FieldNavigator({
1220
1232
  fields,
1221
1233
  currentFieldId,
@@ -1224,6 +1236,7 @@ function FieldNavigator({
1224
1236
  onComplete,
1225
1237
  completeLabel = "Complete"
1226
1238
  }) {
1239
+ const [showIncomplete, setShowIncomplete] = useState3(false);
1227
1240
  const currentIndex = fields.findIndex((f) => f.id === currentFieldId);
1228
1241
  const hasPrev = currentIndex > 0;
1229
1242
  const hasNext = currentIndex < fields.length - 1;
@@ -1237,18 +1250,36 @@ function FieldNavigator({
1237
1250
  onNavigate(fields[currentIndex + 1].id);
1238
1251
  }
1239
1252
  };
1240
- const filledCount = fields.filter((f) => {
1241
- if (!f.required) return true;
1242
- if (f.type === "checkbox") return true;
1243
- return !!f.value;
1244
- }).length;
1253
+ const filledCount = fields.filter(isFieldFilled).length;
1254
+ const incompleteFields = fields.filter((f) => !isFieldFilled(f));
1255
+ const showCompleteAsNext = !hasNext && allRequiredFilled;
1245
1256
  return /* @__PURE__ */ jsxs5("div", { className: "field-navigator", children: [
1246
- /* @__PURE__ */ jsxs5("div", { className: "field-navigator-progress", children: [
1247
- filledCount,
1248
- " of ",
1249
- fields.length,
1250
- " fields completed"
1251
- ] }),
1257
+ /* @__PURE__ */ jsxs5(
1258
+ "div",
1259
+ {
1260
+ className: `field-navigator-progress ${incompleteFields.length > 0 ? "clickable" : ""}`,
1261
+ onClick: () => incompleteFields.length > 0 && setShowIncomplete(!showIncomplete),
1262
+ children: [
1263
+ filledCount,
1264
+ " of ",
1265
+ fields.length,
1266
+ " fields completed",
1267
+ incompleteFields.length > 0 && /* @__PURE__ */ jsx5("span", { className: "field-navigator-toggle", children: showIncomplete ? "\u25B2" : "\u25BC" })
1268
+ ]
1269
+ }
1270
+ ),
1271
+ showIncomplete && incompleteFields.length > 0 && /* @__PURE__ */ jsx5("div", { className: "incomplete-fields-list", children: incompleteFields.map((f) => /* @__PURE__ */ jsx5(
1272
+ "button",
1273
+ {
1274
+ className: "incomplete-field-item",
1275
+ onClick: () => {
1276
+ onNavigate(f.id);
1277
+ setShowIncomplete(false);
1278
+ },
1279
+ children: f.label
1280
+ },
1281
+ f.id
1282
+ )) }),
1252
1283
  /* @__PURE__ */ jsxs5("div", { className: "field-navigator-controls", children: [
1253
1284
  /* @__PURE__ */ jsx5(
1254
1285
  "button",
@@ -1260,7 +1291,14 @@ function FieldNavigator({
1260
1291
  }
1261
1292
  ),
1262
1293
  /* @__PURE__ */ jsx5("span", { className: "field-navigator-position", children: currentIndex >= 0 ? `${currentIndex + 1} / ${fields.length}` : "-" }),
1263
- /* @__PURE__ */ jsx5(
1294
+ showCompleteAsNext ? /* @__PURE__ */ jsx5(
1295
+ "button",
1296
+ {
1297
+ onClick: onComplete,
1298
+ className: "nav-btn nav-btn-complete",
1299
+ children: completeLabel
1300
+ }
1301
+ ) : /* @__PURE__ */ jsx5(
1264
1302
  "button",
1265
1303
  {
1266
1304
  onClick: handleNext,
@@ -1269,21 +1307,12 @@ function FieldNavigator({
1269
1307
  children: "Next"
1270
1308
  }
1271
1309
  )
1272
- ] }),
1273
- /* @__PURE__ */ jsx5(
1274
- "button",
1275
- {
1276
- onClick: onComplete,
1277
- disabled: !allRequiredFilled,
1278
- className: "complete-btn",
1279
- children: completeLabel
1280
- }
1281
- )
1310
+ ] })
1282
1311
  ] });
1283
1312
  }
1284
1313
 
1285
1314
  // src/components/pdf-builder/SignerView.tsx
1286
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1315
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1287
1316
  function SignerView({
1288
1317
  apiKey,
1289
1318
  initialPdfUrl,
@@ -1305,11 +1334,11 @@ function SignerView({
1305
1334
  ] })
1306
1335
  ] }) });
1307
1336
  }
1308
- const [pages, setPages] = useState3([]);
1309
- const [fields, setFields] = useState3([]);
1310
- const [selectedFieldId, setSelectedFieldId] = useState3(null);
1311
- const [signerRoles, setSignerRoles] = useState3([]);
1312
- const [currentSignerIndex, setCurrentSignerIndex] = useState3(() => {
1337
+ const [pages, setPages] = useState4([]);
1338
+ const [fields, setFields] = useState4([]);
1339
+ const [selectedFieldId, setSelectedFieldId] = useState4(null);
1340
+ const [signerRoles, setSignerRoles] = useState4([]);
1341
+ const [currentSignerIndex, setCurrentSignerIndex] = useState4(() => {
1313
1342
  if (initialSigner && signerOrderProp) {
1314
1343
  const idx = signerOrderProp.indexOf(initialSigner);
1315
1344
  return idx >= 0 ? idx : 0;
@@ -1317,10 +1346,10 @@ function SignerView({
1317
1346
  return 0;
1318
1347
  });
1319
1348
  const initializedRef = useRef4(false);
1320
- const [loading, setLoading] = useState3(false);
1321
- const [submitting, setSubmitting] = useState3(false);
1322
- const [pdfSource, setPdfSource] = useState3(null);
1323
- const [callbackUrl, setCallbackUrl] = useState3(initialCallbackUrl || "");
1349
+ const [loading, setLoading] = useState4(false);
1350
+ const [submitting, setSubmitting] = useState4(false);
1351
+ const [pdfSource, setPdfSource] = useState4(null);
1352
+ const [callbackUrl, setCallbackUrl] = useState4(initialCallbackUrl || "");
1324
1353
  const containerRef = useRef4(null);
1325
1354
  const signerOrder = signerOrderProp || (signerRoles.length > 0 ? [...signerRoles.filter((r) => r !== "Sender"), ...signerRoles.filter((r) => r === "Sender")] : [initialSigner || "Signer 1"]);
1326
1355
  const signer = signerOrder[currentSignerIndex] || signerOrder[0] || "Signer 1";
@@ -1419,6 +1448,9 @@ function SignerView({
1419
1448
  const handleFieldUpdate = useCallback4((id, value) => {
1420
1449
  setFields((prev) => prev.map((f) => f.id === id ? { ...f, value } : f));
1421
1450
  }, []);
1451
+ const handleFieldPropertyUpdate = useCallback4((id, updates) => {
1452
+ setFields((prev) => prev.map((f) => f.id === id ? { ...f, ...updates } : f));
1453
+ }, []);
1422
1454
  const handleNavigate = useCallback4((fieldId) => {
1423
1455
  setSelectedFieldId(fieldId);
1424
1456
  const field = fields.find((f) => f.id === fieldId);
@@ -1569,16 +1601,32 @@ function SignerView({
1569
1601
  initialValue: selectedField.value
1570
1602
  }
1571
1603
  ),
1572
- selectedField.type === "text" && /* @__PURE__ */ jsx6(
1573
- "input",
1574
- {
1575
- type: selectedField.textSubtype === "email" ? "email" : selectedField.textSubtype === "number" ? "number" : selectedField.textSubtype === "phone" ? "tel" : selectedField.textSubtype === "date" ? "date" : "text",
1576
- value: selectedField.value,
1577
- onChange: (e) => handleFieldUpdate(selectedField.id, e.target.value),
1578
- placeholder: selectedField.placeholder,
1579
- className: "signer-text-input"
1580
- }
1581
- ),
1604
+ selectedField.type === "text" && /* @__PURE__ */ jsxs6(Fragment2, { children: [
1605
+ /* @__PURE__ */ jsx6(
1606
+ "input",
1607
+ {
1608
+ type: selectedField.textSubtype === "email" ? "email" : selectedField.textSubtype === "number" ? "number" : selectedField.textSubtype === "phone" ? "tel" : selectedField.textSubtype === "date" ? "date" : "text",
1609
+ value: selectedField.value,
1610
+ onChange: (e) => handleFieldUpdate(selectedField.id, e.target.value),
1611
+ placeholder: selectedField.placeholder,
1612
+ className: "signer-text-input"
1613
+ }
1614
+ ),
1615
+ /* @__PURE__ */ jsxs6("div", { className: "signer-font-size", children: [
1616
+ /* @__PURE__ */ jsx6("label", { children: "Font Size" }),
1617
+ /* @__PURE__ */ jsx6(
1618
+ "input",
1619
+ {
1620
+ type: "number",
1621
+ min: "6",
1622
+ max: "72",
1623
+ value: selectedField.fontSize,
1624
+ onChange: (e) => handleFieldPropertyUpdate(selectedField.id, { fontSize: Number(e.target.value) })
1625
+ }
1626
+ ),
1627
+ /* @__PURE__ */ jsx6("span", { children: "pt" })
1628
+ ] })
1629
+ ] }),
1582
1630
  selectedField.type === "checkbox" && /* @__PURE__ */ jsxs6("label", { className: "signer-checkbox-label", children: [
1583
1631
  /* @__PURE__ */ jsx6(
1584
1632
  "input",
@@ -1622,7 +1670,7 @@ function SignerView({
1622
1670
  }
1623
1671
 
1624
1672
  // src/components/pdf-builder/SignerRoleSelector.tsx
1625
- import { useState as useState4 } from "react";
1673
+ import { useState as useState5 } from "react";
1626
1674
  import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1627
1675
  function SignerRoleSelector({
1628
1676
  roles,
@@ -1631,8 +1679,8 @@ function SignerRoleSelector({
1631
1679
  onAddRole,
1632
1680
  onRemoveRole
1633
1681
  }) {
1634
- const [isAdding, setIsAdding] = useState4(false);
1635
- const [newRoleName, setNewRoleName] = useState4("");
1682
+ const [isAdding, setIsAdding] = useState5(false);
1683
+ const [newRoleName, setNewRoleName] = useState5("");
1636
1684
  const handleAdd = () => {
1637
1685
  if (newRoleName.trim()) {
1638
1686
  onAddRole(newRoleName.trim());