@unlev/exeq 0.1.11 → 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,19 +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));
1245
1255
  const showCompleteAsNext = !hasNext && allRequiredFilled;
1246
1256
  return /* @__PURE__ */ jsxs5("div", { className: "field-navigator", children: [
1247
- /* @__PURE__ */ jsxs5("div", { className: "field-navigator-progress", children: [
1248
- filledCount,
1249
- " of ",
1250
- fields.length,
1251
- " fields completed"
1252
- ] }),
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
+ )) }),
1253
1283
  /* @__PURE__ */ jsxs5("div", { className: "field-navigator-controls", children: [
1254
1284
  /* @__PURE__ */ jsx5(
1255
1285
  "button",
@@ -1304,11 +1334,11 @@ function SignerView({
1304
1334
  ] })
1305
1335
  ] }) });
1306
1336
  }
1307
- const [pages, setPages] = useState3([]);
1308
- const [fields, setFields] = useState3([]);
1309
- const [selectedFieldId, setSelectedFieldId] = useState3(null);
1310
- const [signerRoles, setSignerRoles] = useState3([]);
1311
- 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(() => {
1312
1342
  if (initialSigner && signerOrderProp) {
1313
1343
  const idx = signerOrderProp.indexOf(initialSigner);
1314
1344
  return idx >= 0 ? idx : 0;
@@ -1316,10 +1346,10 @@ function SignerView({
1316
1346
  return 0;
1317
1347
  });
1318
1348
  const initializedRef = useRef4(false);
1319
- const [loading, setLoading] = useState3(false);
1320
- const [submitting, setSubmitting] = useState3(false);
1321
- const [pdfSource, setPdfSource] = useState3(null);
1322
- 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 || "");
1323
1353
  const containerRef = useRef4(null);
1324
1354
  const signerOrder = signerOrderProp || (signerRoles.length > 0 ? [...signerRoles.filter((r) => r !== "Sender"), ...signerRoles.filter((r) => r === "Sender")] : [initialSigner || "Signer 1"]);
1325
1355
  const signer = signerOrder[currentSignerIndex] || signerOrder[0] || "Signer 1";
@@ -1640,7 +1670,7 @@ function SignerView({
1640
1670
  }
1641
1671
 
1642
1672
  // src/components/pdf-builder/SignerRoleSelector.tsx
1643
- import { useState as useState4 } from "react";
1673
+ import { useState as useState5 } from "react";
1644
1674
  import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1645
1675
  function SignerRoleSelector({
1646
1676
  roles,
@@ -1649,8 +1679,8 @@ function SignerRoleSelector({
1649
1679
  onAddRole,
1650
1680
  onRemoveRole
1651
1681
  }) {
1652
- const [isAdding, setIsAdding] = useState4(false);
1653
- const [newRoleName, setNewRoleName] = useState4("");
1682
+ const [isAdding, setIsAdding] = useState5(false);
1683
+ const [newRoleName, setNewRoleName] = useState5("");
1654
1684
  const handleAdd = () => {
1655
1685
  if (newRoleName.trim()) {
1656
1686
  onAddRole(newRoleName.trim());