epochs-pdf 0.1.2 → 0.1.3

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.
@@ -490,7 +490,7 @@ function Qi({
490
490
  onRemoveText: ue,
491
491
  selectedTextId: be = null,
492
492
  onSelectText: J,
493
- textFields: Ee = [],
493
+ textFields: Be = [],
494
494
  selectedTextFieldId: Ye = null,
495
495
  onSelectTextField: Pe,
496
496
  hasFixedTextFields: Oe = !1,
@@ -657,8 +657,8 @@ function Qi({
657
657
  le - g.startY,
658
658
  ne,
659
659
  n
660
- ) : { dx: 0, dy: 0 }, $e = Ne.width - de.x, Ge = Ne.height - de.y, Se = Math.min($e, Math.max(40, g.startW + pe)), lt = Math.min(Ge, Math.max(20, g.startH + me));
661
- $(g.id, { width: Se, height: lt });
660
+ ) : { dx: 0, dy: 0 }, $e = Ne.width - de.x, Ge = Ne.height - de.y, Ee = Math.min($e, Math.max(40, g.startW + pe)), lt = Math.min(Ge, Math.max(20, g.startH + me));
661
+ $(g.id, { width: Ee, height: lt });
662
662
  }, L = (H, le) => {
663
663
  var xt;
664
664
  if (g.kind !== "signature" || !$ || oe) return;
@@ -679,12 +679,12 @@ function Qi({
679
679
  ne.getAttribute("data-page-number") || String(de.pageNumber),
680
680
  10
681
681
  ), me = Pt(H, le, Ne, n), $e = yt(Ne, n);
682
- let Ge = me.x - g.offsetX, Se = me.y - g.offsetY;
682
+ let Ge = me.x - g.offsetX, Ee = me.y - g.offsetY;
683
683
  const lt = Math.max(0, $e.width - de.width), Xe = Math.max(0, $e.height - de.height);
684
- Ge = Math.min(Math.max(0, Ge), lt), Se = Math.min(Math.max(0, Se), Xe), $(g.id, {
684
+ Ge = Math.min(Math.max(0, Ge), lt), Ee = Math.min(Math.max(0, Ee), Xe), $(g.id, {
685
685
  pageNumber: pe,
686
686
  x: Ge,
687
- y: Se
687
+ y: Ee
688
688
  });
689
689
  }, O = () => {
690
690
  if (o = 0, !k) return;
@@ -735,7 +735,7 @@ function Qi({
735
735
  }, [ve]);
736
736
  const re = (o) => {
737
737
  fe.current = o, r == null || r(o);
738
- }, Ce = y.filter((o) => o.pageNumber === t), ce = v.filter((o) => o.pageNumber === t), Be = V.filter((o) => o.pageNumber === t), Ae = Q.filter((o) => o.pageNumber === t), Ue = (o, w) => {
738
+ }, Ce = y.filter((o) => o.pageNumber === t), ce = v.filter((o) => o.pageNumber === t), He = V.filter((o) => o.pageNumber === t), Ae = Q.filter((o) => o.pageNumber === t), Ue = (o, w) => {
739
739
  const _ = w.trim();
740
740
  if (!_) {
741
741
  ue == null || ue(o.id), B == null || B(null);
@@ -762,7 +762,7 @@ function Qi({
762
762
  const W = Di(
763
763
  P.x,
764
764
  P.y,
765
- Ee,
765
+ Be,
766
766
  t
767
767
  );
768
768
  if (!W) return;
@@ -969,7 +969,7 @@ function Qi({
969
969
  ))
970
970
  ) }),
971
971
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__signature-layer", children: [
972
- Be.map((o) => {
972
+ He.map((o) => {
973
973
  const w = ce.some((_) => _.fieldId === o.id);
974
974
  return /* @__PURE__ */ a(
975
975
  "button",
@@ -1437,7 +1437,7 @@ function lr({
1437
1437
  showFieldTypeTabs: r = !1,
1438
1438
  textPlaceholder: s
1439
1439
  }) {
1440
- const c = _e(null), l = _e(!1), y = _e(null), f = _e([]), x = _e([]), v = i ?? "sign", [m, M] = U(v), [$, G] = U(""), [S, z] = U(""), [E, I] = U("draw"), [V, te] = U(""), [X, oe] = U(""), [ke, ye] = U(!1), [D, ae] = U("signature"), [C, F] = U("#111827"), [Q, Me] = U("dancing-script"), [Ie, ue] = U(!1), be = It.find((u) => u.id === Q) ?? It[0], J = D === "initials" ? X.trim() : V.trim(), Ee = J || (D === "initials" ? "AB" : "Signature");
1440
+ const c = _e(null), l = _e(!1), y = _e(null), f = _e([]), x = _e([]), v = i ?? "sign", [m, M] = U(v), [$, G] = U(""), [S, z] = U(""), [E, I] = U("draw"), [V, te] = U(""), [X, oe] = U(""), [ke, ye] = U(!1), [D, ae] = U("signature"), [C, F] = U("#111827"), [Q, Me] = U("dancing-script"), [Ie, ue] = U(!1), be = It.find((u) => u.id === Q) ?? It[0], J = D === "initials" ? X.trim() : V.trim(), Be = J || (D === "initials" ? "AB" : "Signature");
1441
1441
  if (xe(() => {
1442
1442
  e && (M(v), G((/* @__PURE__ */ new Date()).toISOString().slice(0, 10)), z(""));
1443
1443
  }, [e, v]), xe(() => {
@@ -1506,17 +1506,17 @@ function lr({
1506
1506
  Le.x < g && (g = Le.x), Le.y < j && (j = Le.y), Le.x > Y && (Y = Le.x), Le.y > se && (se = Le.y);
1507
1507
  const re = 8;
1508
1508
  g = Math.max(0, g - re), j = Math.max(0, j - re), Y += re, se += re;
1509
- const Ce = Y - g, ce = se - j, Be = u.map((Ke) => "M" + Ke.map((We) => ({ x: We.x - g, y: We.y - j })).map((We) => `${We.x.toFixed(1)},${We.y.toFixed(1)}`).join("L")).join(" "), Ae = `<svg xmlns="http://www.w3.org/2000/svg" width="${Ce.toFixed(0)}" height="${ce.toFixed(0)}" viewBox="0 0 ${Ce.toFixed(0)} ${ce.toFixed(0)}"><path d="${Be}" fill="none" stroke="${C}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`, Ue = `data:image/svg+xml;base64,${btoa(Ae)}`;
1509
+ const Ce = Y - g, ce = se - j, He = u.map((Ke) => "M" + Ke.map((We) => ({ x: We.x - g, y: We.y - j })).map((We) => `${We.x.toFixed(1)},${We.y.toFixed(1)}`).join("L")).join(" "), Ae = `<svg xmlns="http://www.w3.org/2000/svg" width="${Ce.toFixed(0)}" height="${ce.toFixed(0)}" viewBox="0 0 ${Ce.toFixed(0)} ${ce.toFixed(0)}"><path d="${He}" fill="none" stroke="${C}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`, Ue = `data:image/svg+xml;base64,${btoa(Ae)}`;
1510
1510
  n(Ue, Ce, ce);
1511
1511
  } else {
1512
1512
  if (!J) return;
1513
1513
  const u = 3, g = D === "initials" ? 72 : be.family === "Great Vibes" || be.family === "Allura" ? 56 : be.family === "Pacifico" ? 44 : 48, Y = document.createElement("canvas").getContext("2d");
1514
1514
  Y.font = `${g * u}px "${be.family}", cursive`;
1515
- const se = Y.measureText(J), re = 12 * u, Ce = Math.ceil(se.width) + re * 2, ce = g * u + re * 2, Be = document.createElement("canvas");
1516
- Be.width = Ce, Be.height = ce;
1517
- const Ae = Be.getContext("2d");
1515
+ const se = Y.measureText(J), re = 12 * u, Ce = Math.ceil(se.width) + re * 2, ce = g * u + re * 2, He = document.createElement("canvas");
1516
+ He.width = Ce, He.height = ce;
1517
+ const Ae = He.getContext("2d");
1518
1518
  Ae.clearRect(0, 0, Ce, ce), Ae.font = `${g * u}px "${be.family}", cursive`, Ae.fillStyle = C, Ae.textBaseline = "middle", Ae.fillText(J, re, ce / 2);
1519
- const Ue = Be.toDataURL("image/png");
1519
+ const Ue = He.toDataURL("image/png");
1520
1520
  n(Ue, Ce / u, ce / u);
1521
1521
  }
1522
1522
  }, ie = () => {
@@ -1606,7 +1606,7 @@ function lr({
1606
1606
  style: { fontFamily: `"${u.family}", cursive` },
1607
1607
  onClick: () => Me(u.id),
1608
1608
  title: u.label,
1609
- children: Ee
1609
+ children: Be
1610
1610
  },
1611
1611
  u.id
1612
1612
  ))
@@ -2248,11 +2248,11 @@ function Hr({
2248
2248
  onSubmit: be,
2249
2249
  submitLabel: J = "Submit"
2250
2250
  }) {
2251
- const Ee = _e(null), Ye = _e(null), Pe = _e(/* @__PURE__ */ new Map()), Oe = _e(!1), ve = Mt(() => e && typeof e != "string" ? e : null, [e]), B = Mt(() => ve ? "" : nr(typeof e == "string" ? e : void 0, t, n), [ve, e, t, n]), [fe, je] = U("idle"), [ie, ge] = U(null), [he, u] = U(0), [g, j] = U(1), [Y, se] = U(c), [re, Ce] = U(0), [ce, Be] = U(null), [Ae, Ue] = U(!1), [Ke, Le] = U(!1), [We, vt] = U(!1), [o, w] = U("none"), [_, k] = U([]), [P, N] = U([]), [L, O] = U([]), [Z, W] = U(!1), [H, le] = U(void 0), [de, ne] = U(null), [Ne, pe] = U(
2251
+ const Be = _e(null), Ye = _e(null), Pe = _e(/* @__PURE__ */ new Map()), Oe = _e(!1), ve = Mt(() => e && typeof e != "string" ? e : null, [e]), B = Mt(() => ve ? "" : nr(typeof e == "string" ? e : void 0, t, n), [ve, e, t, n]), [fe, je] = U("idle"), [ie, ge] = U(null), [he, u] = U(0), [g, j] = U(1), [Y, se] = U(c), [re, Ce] = U(0), [ce, He] = U(null), [Ae, Ue] = U(!1), [Ke, Le] = U(!1), [We, vt] = U(!1), [o, w] = U("none"), [_, k] = U([]), [P, N] = U([]), [L, O] = U([]), [Z, W] = U(!1), [H, le] = U(void 0), [de, ne] = U(null), [Ne, pe] = U(
2252
2252
  null
2253
2253
  ), [me, $e] = U(
2254
2254
  null
2255
- ), [Ge, Se] = U(null), [lt, Xe] = U(null), [xt, Ze] = U(null), [Lt, Je] = U(null), [Kt, On] = U(gn), [Zt, Un] = U(xi), He = C.length > 0, dt = F.length > 0, [it, Wn] = U({});
2255
+ ), [Ge, Ee] = U(null), [lt, Xe] = U(null), [xt, Ze] = U(null), [Lt, Je] = U(null), [Kt, On] = U(gn), [Zt, Un] = U(xi), Se = C.length > 0, dt = F.length > 0, [it, Wn] = U({});
2256
2256
  xe(() => {
2257
2257
  Ie && W(!0);
2258
2258
  }, [Ie]);
@@ -2301,14 +2301,14 @@ function Hr({
2301
2301
  };
2302
2302
  return d(), p.addEventListener("change", d), () => p.removeEventListener("change", d);
2303
2303
  }, [tt, l]);
2304
- const Vt = !He && tt.has("highlight"), Qt = !He && tt.has("underline"), Rt = tt.has("signature"), Jt = tt.has("text") || dt, en = !He && tt.has("erase"), ht = q(() => {
2304
+ const Vt = !Se && tt.has("highlight"), Qt = !Se && tt.has("underline"), Rt = tt.has("signature") || Se, Jt = tt.has("text") || dt, en = !Se && tt.has("erase"), ht = q(() => {
2305
2305
  Ye.current && (URL.revokeObjectURL(Ye.current), Ye.current = null);
2306
2306
  }, []), Dt = q(async () => {
2307
2307
  if (!(!ve && !B)) {
2308
- tr(v), je("loading"), ge(null), u(0), j(1), k([]), N([]), O([]), ne(null), pe(null), $e(null), Se(null), Xe(null), Ze(null), Je(null), w("none");
2308
+ tr(v), je("loading"), ge(null), u(0), j(1), k([]), N([]), O([]), ne(null), pe(null), $e(null), Ee(null), Xe(null), Ze(null), Je(null), w("none");
2309
2309
  try {
2310
2310
  const h = ve ? await an(ve, i) : await an(B, i), p = new Blob([h], { type: "application/pdf" }), d = URL.createObjectURL(p);
2311
- ht(), Ye.current = d, Be(d);
2311
+ ht(), Ye.current = d, He(d);
2312
2312
  const A = await ct.getDocument({
2313
2313
  data: h,
2314
2314
  cMapUrl: `https://unpkg.com/pdfjs-dist@${ct.version}/cmaps/`,
@@ -2329,7 +2329,7 @@ function Hr({
2329
2329
  ]);
2330
2330
  xe(() => {
2331
2331
  if (!ve && !B) {
2332
- je("idle"), ge(null), u(0), Be(null), ht();
2332
+ je("idle"), ge(null), u(0), He(null), ht();
2333
2333
  return;
2334
2334
  }
2335
2335
  return Dt(), () => {
@@ -2356,7 +2356,7 @@ function Hr({
2356
2356
  p && (Oe.current = !0, j(h.pageNumber));
2357
2357
  const d = () => {
2358
2358
  var A;
2359
- const b = (A = Ee.current) == null ? void 0 : A.querySelector(
2359
+ const b = (A = Be.current) == null ? void 0 : A.querySelector(
2360
2360
  `[data-signature-field-id="${CSS.escape(h.id)}"]`
2361
2361
  );
2362
2362
  b ? b.scrollIntoView({ behavior: "smooth", block: "center" }) : p && p.scrollIntoView({ behavior: "smooth", block: "start" }), window.setTimeout(() => {
@@ -2370,8 +2370,8 @@ function Hr({
2370
2370
  []
2371
2371
  );
2372
2372
  xe(() => {
2373
- if (fe !== "ready" || !Ee.current || !he) return;
2374
- const h = Ee.current, p = new IntersectionObserver(
2373
+ if (fe !== "ready" || !Be.current || !he) return;
2374
+ const h = Be.current, p = new IntersectionObserver(
2375
2375
  (d) => {
2376
2376
  if (Oe.current) return;
2377
2377
  let b = null;
@@ -2407,11 +2407,11 @@ function Hr({
2407
2407
  }, []), Kn = q(() => {
2408
2408
  se((h) => Math.min(5, Math.round((h + 0.1) * 100) / 100));
2409
2409
  }, []), St = q(async () => {
2410
- if (!(!ie || !Ee.current))
2410
+ if (!(!ie || !Be.current))
2411
2411
  try {
2412
2412
  const p = (await ie.getPage(g)).getViewport({ scale: 1, rotation: re }), b = window.matchMedia("(max-width: 720px)").matches ? 16 : 24, R = Math.max(
2413
2413
  0,
2414
- Ee.current.clientWidth - b
2414
+ Be.current.clientWidth - b
2415
2415
  ) / p.width;
2416
2416
  se(Math.max(0.25, Math.min(5, Math.round(R * 100) / 100)));
2417
2417
  } catch {
@@ -2424,7 +2424,7 @@ function Hr({
2424
2424
  h || St();
2425
2425
  };
2426
2426
  p();
2427
- const d = Ee.current, b = typeof ResizeObserver < "u" && d ? new ResizeObserver(() => p()) : null;
2427
+ const d = Be.current, b = typeof ResizeObserver < "u" && d ? new ResizeObserver(() => p()) : null;
2428
2428
  b == null || b.observe(d);
2429
2429
  const A = window.matchMedia("(max-width: 720px)"), R = () => {
2430
2430
  A.matches && p();
@@ -2585,10 +2585,10 @@ function Hr({
2585
2585
  height: De.fieldId ? De.height : b.height
2586
2586
  } : De
2587
2587
  )
2588
- ), ne(null), w("none"), W(!1), Se(null);
2588
+ ), ne(null), w("none"), W(!1), Ee(null);
2589
2589
  return;
2590
2590
  }
2591
- if (He) {
2591
+ if (Se) {
2592
2592
  const ee = C.find(
2593
2593
  (we) => we.id === me && !P.some((nt) => nt.fieldId === we.id)
2594
2594
  ) ?? C.find(
@@ -2611,7 +2611,7 @@ function Hr({
2611
2611
  N((we) => [
2612
2612
  ...we.filter((nt) => nt.fieldId !== ee.id),
2613
2613
  De
2614
- ]), Q == null || Q(ee.id, De), ne(null), w("none"), W(!1), Se(null);
2614
+ ]), Q == null || Q(ee.id, De), ne(null), w("none"), W(!1), Ee(null);
2615
2615
  const Ve = new Set(
2616
2616
  P.filter((we) => we.fieldId && we.fieldId !== ee.id).map((we) => we.fieldId)
2617
2617
  );
@@ -2649,11 +2649,11 @@ function Hr({
2649
2649
  height: b.height,
2650
2650
  imageDataUrl: h
2651
2651
  };
2652
- N((ee) => [...ee, qe]), Q == null || Q(void 0, qe), pe(qe.id), ne(null), w("none"), W(!1), Se(null);
2652
+ N((ee) => [...ee, qe]), Q == null || Q(void 0, qe), pe(qe.id), ne(null), w("none"), W(!1), Ee(null);
2653
2653
  },
2654
2654
  [
2655
2655
  Ge,
2656
- He,
2656
+ Se,
2657
2657
  g,
2658
2658
  Y,
2659
2659
  ot,
@@ -2700,7 +2700,7 @@ function Hr({
2700
2700
  N((qe) => [...qe, Re]), pe(Re.id), ne(null), w("none");
2701
2701
  }, [Y, st, P]), hi = q((h) => {
2702
2702
  const p = h ?? (st == null ? void 0 : st.id);
2703
- p && (pe(p), Se(p), W(!0));
2703
+ p && (pe(p), Ee(p), W(!0));
2704
2704
  }, [st]), pi = q((h) => {
2705
2705
  O((p) => h.fieldId ? [...p.filter((d) => d.fieldId !== h.fieldId), h] : [...p, h]), Xe(h.id), h.fieldId && Ze(h.fieldId);
2706
2706
  }, []), ui = q(
@@ -2780,7 +2780,7 @@ function Hr({
2780
2780
  handleRotate: qn,
2781
2781
  markupTool: o,
2782
2782
  toggleMarkupTool: (h) => Qn(h),
2783
- hasFixedSignatureFields: He,
2783
+ hasFixedSignatureFields: Se,
2784
2784
  hasFixedTextFields: dt,
2785
2785
  pendingSignature: de,
2786
2786
  setMarkupTool: w,
@@ -2801,7 +2801,7 @@ function Hr({
2801
2801
  resolvedUrl: B,
2802
2802
  handleDownload: Vn,
2803
2803
  isDownloading: We
2804
- }, mi = (h) => h.filter((p) => !(He && (p === "highlight" || p === "underline" || p === "erase"))), Et = me ? C.findIndex((h) => h.id === me) : 0, wi = C.filter((h) => {
2804
+ }, mi = (h) => h.filter((p) => !(Se && (p === "highlight" || p === "underline" || p === "erase"))), Et = me ? C.findIndex((h) => h.id === me) : 0, wi = C.filter((h) => {
2805
2805
  var d;
2806
2806
  const p = h.type ?? "sign";
2807
2807
  return p === "date" || p === "text" ? !!((d = it[h.id]) != null && d.trim()) : P.some((b) => b.fieldId === h.id);
@@ -2838,16 +2838,16 @@ function Hr({
2838
2838
  rn(et.left),
2839
2839
  rn(et.right, !0)
2840
2840
  ] }) : null,
2841
- Rt || Ie ? /* @__PURE__ */ a(
2841
+ Rt || Ie || Se ? /* @__PURE__ */ a(
2842
2842
  lr,
2843
2843
  {
2844
2844
  open: Z,
2845
2845
  onClose: () => {
2846
- W(!1), Se(null), ue == null || ue();
2846
+ W(!1), Ee(null), ue == null || ue();
2847
2847
  },
2848
2848
  onSave: si,
2849
2849
  fieldType: H,
2850
- showFieldTypeTabs: !He
2850
+ showFieldTypeTabs: !Se
2851
2851
  }
2852
2852
  ) : null,
2853
2853
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__content", children: [
@@ -2886,7 +2886,7 @@ function Hr({
2886
2886
  ] }) : /* @__PURE__ */ a("div", { className: "epochs-pdf-viewer__muted", children: "Thumbnails" })
2887
2887
  }
2888
2888
  ) : null,
2889
- /* @__PURE__ */ T("div", { ref: Ee, className: "epochs-pdf-viewer__body", children: [
2889
+ /* @__PURE__ */ T("div", { ref: Be, className: "epochs-pdf-viewer__body", children: [
2890
2890
  fe === "loading" ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__overlay epochs-pdf-viewer__muted", children: [
2891
2891
  "Loading PDF…",
2892
2892
  /* @__PURE__ */ a("span", { className: "epochs-pdf-viewer__spinner" })
@@ -2930,7 +2930,7 @@ function Hr({
2930
2930
  signatureFields: C,
2931
2931
  selectedSignatureFieldId: me,
2932
2932
  onSelectSignatureField: $e,
2933
- hasFixedSignatureFields: He,
2933
+ hasFixedSignatureFields: Se,
2934
2934
  onOpenSignaturePad: ii,
2935
2935
  fieldValues: it,
2936
2936
  onFieldValueChange: ri,
@@ -2956,8 +2956,8 @@ function Hr({
2956
2956
  }) }) : null
2957
2957
  ] })
2958
2958
  ] }),
2959
- He || be ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer", role: "navigation", "aria-label": "Viewer actions", children: [
2960
- He ? /* @__PURE__ */ T(bt, { children: [
2959
+ Se || be ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer", role: "navigation", "aria-label": "Viewer actions", children: [
2960
+ Se ? /* @__PURE__ */ T(bt, { children: [
2961
2961
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer-nav", children: [
2962
2962
  /* @__PURE__ */ a(
2963
2963
  "button",