@unlev/exeq 0.1.9 → 0.1.11

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
@@ -1221,8 +1221,8 @@ function FieldNavigator({
1221
1221
  currentFieldId,
1222
1222
  onNavigate,
1223
1223
  allRequiredFilled,
1224
- onSubmit,
1225
- submitLabel = "Complete"
1224
+ onComplete,
1225
+ completeLabel = "Complete"
1226
1226
  }) {
1227
1227
  const currentIndex = fields.findIndex((f) => f.id === currentFieldId);
1228
1228
  const hasPrev = currentIndex > 0;
@@ -1242,6 +1242,7 @@ function FieldNavigator({
1242
1242
  if (f.type === "checkbox") return true;
1243
1243
  return !!f.value;
1244
1244
  }).length;
1245
+ const showCompleteAsNext = !hasNext && allRequiredFilled;
1245
1246
  return /* @__PURE__ */ jsxs5("div", { className: "field-navigator", children: [
1246
1247
  /* @__PURE__ */ jsxs5("div", { className: "field-navigator-progress", children: [
1247
1248
  filledCount,
@@ -1260,7 +1261,14 @@ function FieldNavigator({
1260
1261
  }
1261
1262
  ),
1262
1263
  /* @__PURE__ */ jsx5("span", { className: "field-navigator-position", children: currentIndex >= 0 ? `${currentIndex + 1} / ${fields.length}` : "-" }),
1263
- /* @__PURE__ */ jsx5(
1264
+ showCompleteAsNext ? /* @__PURE__ */ jsx5(
1265
+ "button",
1266
+ {
1267
+ onClick: onComplete,
1268
+ className: "nav-btn nav-btn-complete",
1269
+ children: completeLabel
1270
+ }
1271
+ ) : /* @__PURE__ */ jsx5(
1264
1272
  "button",
1265
1273
  {
1266
1274
  onClick: handleNext,
@@ -1269,21 +1277,12 @@ function FieldNavigator({
1269
1277
  children: "Next"
1270
1278
  }
1271
1279
  )
1272
- ] }),
1273
- /* @__PURE__ */ jsx5(
1274
- "button",
1275
- {
1276
- onClick: onSubmit,
1277
- disabled: !allRequiredFilled,
1278
- className: "submit-btn",
1279
- children: submitLabel
1280
- }
1281
- )
1280
+ ] })
1282
1281
  ] });
1283
1282
  }
1284
1283
 
1285
1284
  // src/components/pdf-builder/SignerView.tsx
1286
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1285
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1287
1286
  function SignerView({
1288
1287
  apiKey,
1289
1288
  initialPdfUrl,
@@ -1419,6 +1418,9 @@ function SignerView({
1419
1418
  const handleFieldUpdate = useCallback4((id, value) => {
1420
1419
  setFields((prev) => prev.map((f) => f.id === id ? { ...f, value } : f));
1421
1420
  }, []);
1421
+ const handleFieldPropertyUpdate = useCallback4((id, updates) => {
1422
+ setFields((prev) => prev.map((f) => f.id === id ? { ...f, ...updates } : f));
1423
+ }, []);
1422
1424
  const handleNavigate = useCallback4((fieldId) => {
1423
1425
  setSelectedFieldId(fieldId);
1424
1426
  const field = fields.find((f) => f.id === fieldId);
@@ -1528,20 +1530,8 @@ function SignerView({
1528
1530
  }));
1529
1531
  }
1530
1532
  }, [fields.filter((f) => f.type === "signature" && f.value).length]);
1531
- const stepLabel = isLastSigner ? submitLabel || "Complete" : `Next: ${signerOrder[currentSignerIndex + 1]}`;
1532
1533
  return /* @__PURE__ */ jsxs6("div", { className: "signer-layout", ref: containerRef, children: [
1533
1534
  loading && /* @__PURE__ */ jsx6("div", { className: "loading-indicator", children: "Loading document..." }),
1534
- isMultiSigner && /* @__PURE__ */ jsx6("div", { className: "signer-progress-bar", children: signerOrder.map((role, i) => /* @__PURE__ */ jsxs6(
1535
- "div",
1536
- {
1537
- className: `signer-progress-step ${i < currentSignerIndex ? "completed" : ""} ${i === currentSignerIndex ? "active" : ""} ${i > currentSignerIndex ? "upcoming" : ""}`,
1538
- children: [
1539
- /* @__PURE__ */ jsx6("div", { className: "signer-progress-dot", children: i < currentSignerIndex ? "\u2713" : i + 1 }),
1540
- /* @__PURE__ */ jsx6("span", { className: "signer-progress-label", children: role })
1541
- ]
1542
- },
1543
- role
1544
- )) }),
1545
1535
  /* @__PURE__ */ jsxs6("div", { className: "signer-content", children: [
1546
1536
  /* @__PURE__ */ jsx6("div", { className: "signer-pdf-area", children: pages.length > 0 && /* @__PURE__ */ jsx6(
1547
1537
  PdfViewer,
@@ -1556,65 +1546,93 @@ function SignerView({
1556
1546
  }
1557
1547
  ) }),
1558
1548
  /* @__PURE__ */ jsxs6("div", { className: "signer-panel", children: [
1559
- /* @__PURE__ */ jsxs6("div", { className: "signer-role-indicator", children: [
1560
- /* @__PURE__ */ jsx6("span", { className: "signer-role-indicator-label", children: "Signing as" }),
1561
- /* @__PURE__ */ jsx6("strong", { children: signer })
1549
+ /* @__PURE__ */ jsxs6("div", { className: "signer-panel-header", children: [
1550
+ /* @__PURE__ */ jsxs6("div", { className: "signer-role-indicator", children: [
1551
+ /* @__PURE__ */ jsx6("span", { className: "signer-role-indicator-label", children: "Signing as" }),
1552
+ /* @__PURE__ */ jsx6("strong", { children: signer })
1553
+ ] }),
1554
+ isMultiSigner && /* @__PURE__ */ jsxs6("div", { className: "signer-step-badge", children: [
1555
+ "Step ",
1556
+ currentSignerIndex + 1,
1557
+ " of ",
1558
+ signerOrder.length
1559
+ ] })
1562
1560
  ] }),
1563
- selectedField && isFieldEditable && /* @__PURE__ */ jsxs6("div", { className: "signer-field-input", children: [
1564
- /* @__PURE__ */ jsx6("h3", { children: selectedField.label }),
1565
- selectedField.required && /* @__PURE__ */ jsx6("span", { className: "required-badge", children: "Required" }),
1566
- (selectedField.type === "signature" || selectedField.type === "initials") && /* @__PURE__ */ jsx6(
1567
- SignatureCanvas,
1568
- {
1569
- width: 280,
1570
- height: selectedField.type === "initials" ? 80 : 120,
1571
- onSign: (dataUrl) => handleFieldUpdate(selectedField.id, dataUrl),
1572
- initialValue: selectedField.value
1573
- }
1574
- ),
1575
- selectedField.type === "text" && /* @__PURE__ */ jsx6(
1576
- "input",
1577
- {
1578
- type: selectedField.textSubtype === "email" ? "email" : selectedField.textSubtype === "number" ? "number" : selectedField.textSubtype === "phone" ? "tel" : selectedField.textSubtype === "date" ? "date" : "text",
1579
- value: selectedField.value,
1580
- onChange: (e) => handleFieldUpdate(selectedField.id, e.target.value),
1581
- placeholder: selectedField.placeholder,
1582
- className: "signer-text-input"
1583
- }
1584
- ),
1585
- selectedField.type === "checkbox" && /* @__PURE__ */ jsxs6("label", { className: "signer-checkbox-label", children: [
1586
- /* @__PURE__ */ jsx6(
1587
- "input",
1561
+ /* @__PURE__ */ jsxs6("div", { className: "signer-panel-body", children: [
1562
+ selectedField && isFieldEditable && /* @__PURE__ */ jsxs6("div", { className: "signer-field-input", children: [
1563
+ /* @__PURE__ */ jsx6("h3", { children: selectedField.label }),
1564
+ selectedField.required && /* @__PURE__ */ jsx6("span", { className: "required-badge", children: "Required" }),
1565
+ (selectedField.type === "signature" || selectedField.type === "initials") && /* @__PURE__ */ jsx6(
1566
+ SignatureCanvas,
1588
1567
  {
1589
- type: "checkbox",
1590
- checked: selectedField.value === "true",
1591
- onChange: (e) => handleFieldUpdate(selectedField.id, e.target.checked ? "true" : "")
1568
+ width: 280,
1569
+ height: selectedField.type === "initials" ? 80 : 120,
1570
+ onSign: (dataUrl) => handleFieldUpdate(selectedField.id, dataUrl),
1571
+ initialValue: selectedField.value
1592
1572
  }
1593
1573
  ),
1594
- selectedField.placeholder || "Check this box"
1574
+ selectedField.type === "text" && /* @__PURE__ */ jsxs6(Fragment2, { children: [
1575
+ /* @__PURE__ */ jsx6(
1576
+ "input",
1577
+ {
1578
+ type: selectedField.textSubtype === "email" ? "email" : selectedField.textSubtype === "number" ? "number" : selectedField.textSubtype === "phone" ? "tel" : selectedField.textSubtype === "date" ? "date" : "text",
1579
+ value: selectedField.value,
1580
+ onChange: (e) => handleFieldUpdate(selectedField.id, e.target.value),
1581
+ placeholder: selectedField.placeholder,
1582
+ className: "signer-text-input"
1583
+ }
1584
+ ),
1585
+ /* @__PURE__ */ jsxs6("div", { className: "signer-font-size", children: [
1586
+ /* @__PURE__ */ jsx6("label", { children: "Font Size" }),
1587
+ /* @__PURE__ */ jsx6(
1588
+ "input",
1589
+ {
1590
+ type: "number",
1591
+ min: "6",
1592
+ max: "72",
1593
+ value: selectedField.fontSize,
1594
+ onChange: (e) => handleFieldPropertyUpdate(selectedField.id, { fontSize: Number(e.target.value) })
1595
+ }
1596
+ ),
1597
+ /* @__PURE__ */ jsx6("span", { children: "pt" })
1598
+ ] })
1599
+ ] }),
1600
+ selectedField.type === "checkbox" && /* @__PURE__ */ jsxs6("label", { className: "signer-checkbox-label", children: [
1601
+ /* @__PURE__ */ jsx6(
1602
+ "input",
1603
+ {
1604
+ type: "checkbox",
1605
+ checked: selectedField.value === "true",
1606
+ onChange: (e) => handleFieldUpdate(selectedField.id, e.target.checked ? "true" : "")
1607
+ }
1608
+ ),
1609
+ selectedField.placeholder || "Check this box"
1610
+ ] }),
1611
+ selectedField.type === "signed-date" && /* @__PURE__ */ jsx6("div", { className: "signer-date-display", children: selectedField.value || "Will auto-fill when you sign" })
1595
1612
  ] }),
1596
- selectedField.type === "signed-date" && /* @__PURE__ */ jsx6("div", { className: "signer-date-display", children: selectedField.value || "Will auto-fill when you sign" })
1597
- ] }),
1598
- selectedField && !isFieldEditable && /* @__PURE__ */ jsxs6("div", { className: "signer-field-readonly", children: [
1599
- /* @__PURE__ */ jsx6("h3", { children: selectedField.label }),
1600
- /* @__PURE__ */ jsx6("p", { children: "This field belongs to another signer." })
1613
+ selectedField && !isFieldEditable && /* @__PURE__ */ jsxs6("div", { className: "signer-field-readonly", children: [
1614
+ /* @__PURE__ */ jsx6("h3", { children: selectedField.label }),
1615
+ /* @__PURE__ */ jsx6("p", { children: "This field belongs to another signer." })
1616
+ ] }),
1617
+ !selectedField && editableFields.length > 0 && /* @__PURE__ */ jsx6("div", { className: "panel-empty", children: "Select a field to fill it in, or use the navigation below." })
1601
1618
  ] }),
1602
- !selectedField && editableFields.length > 0 && /* @__PURE__ */ jsx6("div", { className: "panel-empty", children: "Select a field to fill it in, or use the navigation below." }),
1603
- /* @__PURE__ */ jsx6(
1604
- FieldNavigator,
1605
- {
1606
- fields: editableFields,
1607
- currentFieldId: selectedFieldId,
1608
- onNavigate: handleNavigate,
1609
- allRequiredFilled,
1610
- onSubmit: handleAdvanceOrSubmit,
1611
- submitLabel: stepLabel
1612
- }
1613
- ),
1614
- submitting && /* @__PURE__ */ jsx6("div", { className: "loading-indicator", children: "Generating PDF..." }),
1615
- /* @__PURE__ */ jsxs6("div", { className: "powered-by", children: [
1616
- "Powered by ",
1617
- /* @__PURE__ */ jsx6("a", { href: "https://exeq.org", target: "_blank", rel: "noopener noreferrer", children: "Exeq.org" })
1619
+ /* @__PURE__ */ jsxs6("div", { className: "signer-panel-footer", children: [
1620
+ /* @__PURE__ */ jsx6(
1621
+ FieldNavigator,
1622
+ {
1623
+ fields: editableFields,
1624
+ currentFieldId: selectedFieldId,
1625
+ onNavigate: handleNavigate,
1626
+ allRequiredFilled,
1627
+ onComplete: handleAdvanceOrSubmit,
1628
+ completeLabel: isLastSigner ? submitLabel || "Complete" : `Next: ${signerOrder[currentSignerIndex + 1]}`
1629
+ }
1630
+ ),
1631
+ submitting && /* @__PURE__ */ jsx6("div", { className: "loading-indicator", children: "Generating PDF..." }),
1632
+ /* @__PURE__ */ jsxs6("div", { className: "powered-by", children: [
1633
+ "Powered by ",
1634
+ /* @__PURE__ */ jsx6("a", { href: "https://exeq.org", target: "_blank", rel: "noopener noreferrer", children: "Exeq.org" })
1635
+ ] })
1618
1636
  ] })
1619
1637
  ] })
1620
1638
  ] })