@verbb/formie-browser 1.0.12 → 1.0.13

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.0.13 - 2026-07-09
6
+
7
+ ### Fixed
8
+ - Fix Signature field canvas height preserving the stored PNG aspect ratio when restoring values or resizing, so signatures are not vertically stretched.
9
+ - Fix Date/Time calendar fields not using an existing input value as the Flatpickr default date on init.
10
+ - Fix false unload warnings after front-end form init by resetting dirty state once captcha/token hydration and field modules have settled.
11
+
5
12
  ## 1.0.12 - 2026-07-02
6
13
 
7
14
  ### Added
@@ -2,7 +2,7 @@ import { t as e } from "./debug-BV0DvdHx.js";
2
2
  import { r as t, t as n } from "./field-references.keys-58ZSTrCW.js";
3
3
  import { n as r, r as i } from "./field-references.resolver-CHwn0G0L.js";
4
4
  import { r as a, t as o } from "./shared-Bx9s0i0P.js";
5
- import { c as s, i as c, r as l, s as u, t as d } from "./dist-BdUy8m_p.js";
5
+ import { c as s, i as c, r as l, s as u, t as d } from "./dist-D6i-VNgM.js";
6
6
  //#region src/js/utils/field-references.row-scope.ts
7
7
  var f = new Set([
8
8
  "first",
@@ -1,7 +1,7 @@
1
1
  import { t as e } from "./debug-BV0DvdHx.js";
2
2
  import { t } from "./field-references.keys-58ZSTrCW.js";
3
3
  import { n } from "./shared-Bx9s0i0P.js";
4
- import { a as r, o as i } from "./dist-BdUy8m_p.js";
4
+ import { a as r, o as i } from "./dist-D6i-VNgM.js";
5
5
  //#region src/js/modules/fields/conditions/config.ts
6
6
  var a = "[data-formie-conditions]";
7
7
  function o(e) {
@@ -5269,6 +5269,9 @@ function H(e, t) {
5269
5269
  s.mode = "range";
5270
5270
  let e = i instanceof HTMLInputElement && i.value ? V(i.value) : null, t = o instanceof HTMLInputElement && o.value ? V(o.value) : null;
5271
5271
  e && (s.defaultDate = t ? [e, t] : [e]);
5272
+ } else if (e.value) {
5273
+ let t = V(e.value);
5274
+ t && (s.defaultDate = t);
5272
5275
  }
5273
5276
  let l = {
5274
5277
  ...s,
@@ -1,4 +1,4 @@
1
- //#region ../formie-core/dist/index.js
1
+ //#region node_modules/@verbb/formie-core/dist/index.js
2
2
  var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
3
3
  if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
4
  get: ((e) => i[e]).bind(null, d),
@@ -1,5 +1,5 @@
1
1
  import { c as e, i as t, l as n } from "./shared-Bx9s0i0P.js";
2
- import { n as r } from "./dist-BdUy8m_p.js";
2
+ import { n as r } from "./dist-D6i-VNgM.js";
3
3
  //#region src/js/modules/fields/password-validation.ts
4
4
  var i = "input[data-formie-password-input]", a = [
5
5
  "passwordMinLength",
@@ -386,7 +386,7 @@ var s = class e extends a {
386
386
  a.setAttribute("r", s.toString()), a.setAttribute("cx", e.x.toString()), a.setAttribute("cy", e.y.toString()), a.setAttribute("fill", t), o.appendChild(a);
387
387
  }), o.outerHTML;
388
388
  }
389
- }, c = "@layer formie-theme{[data-formie-field-type=signature] .formie-field-control{transition:border-color .15s,box-shadow .15s,background-color .15s;position:relative}[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{border-color:var(--formie-focus-ring-border-color);box-shadow:var(--formie-shadow-focus)}.formie-field-has-error[data-formie-field-type=signature] .formie-signature-canvas{border-color:var(--formie-color-danger)}.formie-field-has-error[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{box-shadow:var(--formie-shadow-danger-focus)}[data-formie-field-type=signature] .formie-signature-canvas{width:var(--formie-signature-width);height:var(--formie-signature-height);border:var(--formie-signature-border);background:var(--formie-signature-background);border-radius:var(--formie-signature-border-radius);touch-action:none;transition:border-color .15s,box-shadow .15s,background-color .15s;display:block}[data-formie-field-type=signature] .formie-signature-remove-button{top:var(--formie-signature-remove-button-top);right:var(--formie-signature-remove-button-right);transform:var(--formie-signature-remove-button-transform);font-size:0;line-height:0;position:absolute}[data-formie-field-type=signature] .formie-signature-pad{position:relative}[data-formie-field-type=signature] .formie-signature-message{padding:var(--formie-space-3);border:var(--formie-signature-border);border-radius:var(--formie-signature-border-radius);background:var(--formie-signature-background);color:var(--formie-color-text-muted);font-size:var(--formie-font-size-sm);line-height:var(--formie-line-height-base);margin:0}[data-formie-field-type=signature].formie-signature-has-message .formie-signature-canvas{display:none}}", l = "input[data-formie-signature-input]", u = "canvas[data-formie-signature-canvas]", d = "[data-formie-signature-clear]", f = "[data-formie-signature-message]", p = "signature", m = 20, h = 100, g = [
389
+ }, c = "@layer formie-theme{[data-formie-field-type=signature] .formie-field-control{transition:border-color .15s,box-shadow .15s,background-color .15s;position:relative}[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{border-color:var(--formie-focus-ring-border-color);box-shadow:var(--formie-shadow-focus)}.formie-field-has-error[data-formie-field-type=signature] .formie-signature-canvas{border-color:var(--formie-color-danger)}.formie-field-has-error[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{box-shadow:var(--formie-shadow-danger-focus)}[data-formie-field-type=signature] .formie-signature-canvas{width:var(--formie-signature-width);min-height:var(--formie-signature-height);border:var(--formie-signature-border);background:var(--formie-signature-background);border-radius:var(--formie-signature-border-radius);touch-action:none;height:auto;transition:border-color .15s,box-shadow .15s,background-color .15s;display:block}[data-formie-field-type=signature] .formie-signature-remove-button{top:var(--formie-signature-remove-button-top);right:var(--formie-signature-remove-button-right);transform:var(--formie-signature-remove-button-transform);font-size:0;line-height:0;position:absolute}[data-formie-field-type=signature] .formie-signature-pad{position:relative}[data-formie-field-type=signature] .formie-signature-message{padding:var(--formie-space-3);border:var(--formie-signature-border);border-radius:var(--formie-signature-border-radius);background:var(--formie-signature-background);color:var(--formie-color-text-muted);font-size:var(--formie-font-size-sm);line-height:var(--formie-line-height-base);margin:0}[data-formie-field-type=signature].formie-signature-has-message .formie-signature-canvas{display:none}}", l = "input[data-formie-signature-input]", u = "canvas[data-formie-signature-canvas]", d = "[data-formie-signature-clear]", f = "[data-formie-signature-message]", p = "signature", m = 20, h = 100, g = [
390
390
  "hidden",
391
391
  "data-formie-conditionally-hidden",
392
392
  "data-formie-page-hidden",
@@ -436,85 +436,107 @@ function C(e, t) {
436
436
  r && r.drawImage(n, 0, 0, e.width / t, e.height / t);
437
437
  };
438
438
  }
439
- async function w(e, t, n) {
440
- if (n) try {
441
- await e.fromDataURL(n);
442
- } catch {
443
- C(t, n);
439
+ function w(e) {
440
+ return new Promise((t) => {
441
+ let n = new Image();
442
+ n.onload = () => {
443
+ t({
444
+ width: n.naturalWidth,
445
+ height: n.naturalHeight
446
+ });
447
+ }, n.onerror = () => t(null), n.src = e;
448
+ });
449
+ }
450
+ async function T(e, t) {
451
+ let n = await w(t);
452
+ if (!n?.width || !n?.height) return;
453
+ let { width: r } = _(e);
454
+ if (!(r > 0)) return;
455
+ let i = Math.max(1, Math.round(r * (n.height / n.width)));
456
+ e.style.height = `${i}px`;
457
+ }
458
+ async function E(e, t, n) {
459
+ if (n) {
460
+ await T(t, n);
461
+ try {
462
+ await e.fromDataURL(n);
463
+ } catch {
464
+ C(t, n);
465
+ }
444
466
  }
445
467
  }
446
- function T(e, t, r, i, a, o) {
468
+ function D(e, t, r, i, a, o) {
447
469
  let c = b(t);
448
470
  if (!v()) return x(t, i, c.noCanvas), () => {};
449
- let l = parseFloat(o.penWeight || "2") || 2, u = i.parentElement instanceof HTMLElement ? i.parentElement : t, d = 0, f = null, y = !1, C = !1, T = new s(i, {
471
+ let l = parseFloat(o.penWeight || "2") || 2, u = i.parentElement instanceof HTMLElement ? i.parentElement : t, d = 0, f = null, y = !1, C = !1, w = new s(i, {
450
472
  backgroundColor: o.backgroundColor || "rgba(255, 255, 255, 0)",
451
473
  penColor: o.penColor || "#000000",
452
474
  dotSize: l,
453
475
  minWidth: l,
454
476
  maxWidth: l
455
- }), E = () => {
477
+ }), D = () => {
456
478
  f !== null && (window.clearTimeout(f), f = null);
457
- }, D = () => {
458
- y || (y = !0, C = !1, x(t, i, null), n(t, p, "init", { signature: T }));
459
479
  }, O = () => {
480
+ y || (y = !0, C = !1, x(t, i, null), n(t, p, "init", { signature: w }));
481
+ }, k = () => {
460
482
  y || C || (C = !0, x(t, i, c.initFailed));
461
- }, k = async () => {
462
- let { width: e, height: t } = _(i);
463
- if (!(e > 0) || !(t > 0)) return !1;
464
- let n = Math.max(window.devicePixelRatio || 1, 1), a = i.getContext("2d");
465
- if (!a) return !1;
466
- let o = r.value || (T.isEmpty() ? "" : T.toDataURL());
467
- return i.width = e * n, i.height = t * n, a.setTransform(1, 0, 0, 1, 0, 0), a.scale(n, n), T.clear(), await w(T, i, o), D(), !0;
468
- }, A = () => {
483
+ }, A = async () => {
484
+ let e = r.value || (w.isEmpty() ? "" : w.toDataURL());
485
+ e && await T(i, e);
486
+ let { width: t, height: n } = _(i);
487
+ if (!(t > 0) || !(n > 0)) return !1;
488
+ let a = Math.max(window.devicePixelRatio || 1, 1), o = i.getContext("2d");
489
+ return o ? (i.width = t * a, i.height = n * a, o.setTransform(1, 0, 0, 1, 0, 0), o.scale(a, a), w.clear(), await E(w, i, e), O(), !0) : !1;
490
+ }, j = () => {
469
491
  if (!(y || C)) {
470
492
  if (d >= m) {
471
- O();
493
+ k();
472
494
  return;
473
495
  }
474
- E(), f = window.setTimeout(() => {
475
- f = null, d += 1, j();
496
+ D(), f = window.setTimeout(() => {
497
+ f = null, d += 1, M();
476
498
  }, h);
477
499
  }
478
- }, j = async () => {
479
- if (!await k()) {
480
- A();
500
+ }, M = async () => {
501
+ if (!await A()) {
502
+ j();
481
503
  return;
482
504
  }
483
- E(), d = 0;
484
- }, M = (e = 0) => {
505
+ D(), d = 0;
506
+ }, N = (e = 0) => {
485
507
  window.setTimeout(() => {
486
508
  window.requestAnimationFrame(() => {
487
- j();
509
+ M();
488
510
  });
489
511
  }, e);
490
- }, N = () => {
491
- S(t) && !y && (C = !1), M();
492
512
  }, P = () => {
493
- N();
513
+ S(t) && !y && (C = !1), N();
494
514
  }, F = () => {
495
- S(t) && (d = 0, C = !1, M(100));
515
+ P();
496
516
  }, I = () => {
497
- S(t) && (d = 0, C = !1, N());
498
- }, L = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
499
- N();
500
- }), R = new MutationObserver(() => {
501
- I();
502
- }), z = (e) => {
517
+ S(t) && (d = 0, C = !1, N(100));
518
+ }, L = () => {
519
+ S(t) && (d = 0, C = !1, P());
520
+ }, R = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
521
+ P();
522
+ }), z = new MutationObserver(() => {
523
+ L();
524
+ }), B = (e) => {
503
525
  let t = r.value !== e;
504
526
  r.value = e, t && (r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })));
505
- }, B = () => {
506
- z(T.isEmpty() ? "" : T.toDataURL());
507
527
  }, V = () => {
508
- T.clear(), z("");
528
+ B(w.isEmpty() ? "" : w.toDataURL());
529
+ }, H = () => {
530
+ w.clear(), B("");
509
531
  };
510
- return T.addEventListener("endStroke", B), window.addEventListener("resize", P), e.addEventListener("formie:page:navigate:after", F), L?.observe(u), R.observe(t, {
532
+ return w.addEventListener("endStroke", V), window.addEventListener("resize", F), e.addEventListener("formie:page:navigate:after", I), R?.observe(u), z.observe(t, {
511
533
  attributes: !0,
512
534
  attributeFilter: [...g]
513
- }), M(), a && a.addEventListener("click", V), () => {
514
- E(), T.removeEventListener("endStroke", B), window.removeEventListener("resize", P), e.removeEventListener("formie:page:navigate:after", F), L?.disconnect(), R.disconnect(), a && a.removeEventListener("click", V), T.clear();
535
+ }), N(), a && a.addEventListener("click", H), () => {
536
+ D(), w.removeEventListener("endStroke", V), window.removeEventListener("resize", F), e.removeEventListener("formie:page:navigate:after", I), R?.disconnect(), z.disconnect(), a && a.removeEventListener("click", H), w.clear();
515
537
  };
516
538
  }
517
- var E = {
539
+ var O = {
518
540
  id: p,
519
541
  kind: "field",
520
542
  match: (e) => !!e.target.querySelector(u),
@@ -523,7 +545,7 @@ var E = {
523
545
  if (!r) return;
524
546
  let i = t(e).map((e) => {
525
547
  let t = e.querySelector(l), i = e.querySelector(u), a = e.querySelector(d);
526
- return !(t instanceof HTMLInputElement) || !(i instanceof HTMLCanvasElement) ? () => {} : T(r, e, t, i, a instanceof HTMLElement ? a : null, n);
548
+ return !(t instanceof HTMLInputElement) || !(i instanceof HTMLCanvasElement) ? () => {} : D(r, e, t, i, a instanceof HTMLElement ? a : null, n);
527
549
  });
528
550
  return await e.emit("formie:module:signature:init", { count: i.length }), { destroy: () => {
529
551
  i.forEach((e) => {
@@ -533,4 +555,4 @@ var E = {
533
555
  }
534
556
  };
535
557
  //#endregion
536
- export { E as signatureModule };
558
+ export { O as signatureModule };
@@ -1,7 +1,7 @@
1
1
  import { i as e } from "./i18n-BY1ds1BL.js";
2
2
  import { t } from "./styles-BfoIZwJp.js";
3
3
  import { c as n, i as r, l as i } from "./shared-Bx9s0i0P.js";
4
- import { n as a } from "./dist-BdUy8m_p.js";
4
+ import { n as a } from "./dist-D6i-VNgM.js";
5
5
  //#region src/css/theme/fields/_text-limit.css?inline
6
6
  var o = "@layer formie-theme{.formie-limit-number{font-weight:var(--formie-font-weight-semibold);color:var(--formie-color-text)}.formie-limit-number-error{color:var(--formie-color-danger)}}", s = "input[data-formie-single-line-text-input], textarea[data-formie-multi-line-text-input]", c = [
7
7
  "textMinCharacterLimit",
@@ -20,7 +20,8 @@
20
20
  [data-formie-field-type="signature"] .formie-signature-canvas {
21
21
  display: block;
22
22
  width: var(--formie-signature-width);
23
- height: var(--formie-signature-height);
23
+ min-height: var(--formie-signature-height);
24
+ height: auto;
24
25
  border: var(--formie-signature-border);
25
26
  background: var(--formie-signature-background);
26
27
  border-radius: var(--formie-signature-border-radius);
package/dist/index.js CHANGED
@@ -1382,30 +1382,30 @@ var L = class {
1382
1382
  snaptcha: () => import("./chunks/snaptcha-DKx98oon.js").then((e) => e.snaptchaModule),
1383
1383
  turnstile: () => import("./chunks/turnstile-DJakPzQD.js").then((e) => e.turnstileModule)
1384
1384
  }, Xt = {
1385
- calculations: () => import("./chunks/calculations-DERi2xaC.js").then((e) => e.calculationsModule),
1385
+ calculations: () => import("./chunks/calculations-Dv3hYb8_.js").then((e) => e.calculationsModule),
1386
1386
  "checkbox-radio": () => import("./chunks/checkbox-radio-BY2aTCOG.js").then((e) => e.checkboxRadioModule),
1387
1387
  combobox: () => import("./chunks/combobox-C0EuExSI.js").then((e) => e.comboboxModule),
1388
- conditions: () => import("./chunks/conditions-65kBcFWW.js").then((e) => e.conditionsModule),
1388
+ conditions: () => import("./chunks/conditions-CPH1snCx.js").then((e) => e.conditionsModule),
1389
1389
  "custom-google-maps": () => import("./chunks/custom-google-maps-BsaSirEZ.js").then((e) => e.customGoogleMapsModule),
1390
1390
  "custom-link": () => import("./chunks/custom-link-CJ1-FjEM.js").then((e) => e.customLinkModule),
1391
1391
  "custom-maps": () => import("./chunks/custom-maps-DYW_pBid.js").then((e) => e.customMapsModule),
1392
- "date-picker": () => import("./chunks/date-picker-5CA_-zGb.js").then((e) => e.datePickerModule),
1392
+ "date-picker": () => import("./chunks/date-picker-F9BUBDSW.js").then((e) => e.datePickerModule),
1393
1393
  "file-upload": () => import("./chunks/file-upload-rqfZNqlH.js").then((e) => e.fileUploadModule),
1394
1394
  "upload-manager": () => import("./chunks/upload-manager-W-QDgxKD.js").then((e) => e.uploadManagerModule),
1395
1395
  hidden: () => import("./chunks/hidden-D7_Ch-QN.js").then((e) => e.hiddenModule),
1396
1396
  "phone-country": () => import("./chunks/phone-country-D3ayr60L.js").then((e) => e.phoneCountryModule),
1397
- "password-validation": () => import("./chunks/password-validation-T0vDQPCr.js").then((e) => e.passwordValidationModule),
1397
+ "password-validation": () => import("./chunks/password-validation-D06uH9va.js").then((e) => e.passwordValidationModule),
1398
1398
  "address-country": () => import("./chunks/address-country-Rx6GQTND.js").then((e) => e.addressCountryModule),
1399
1399
  "address-state": () => import("./chunks/address-state-BwE01m2_.js").then((e) => e.addressStateModule),
1400
1400
  repeater: () => import("./chunks/repeater-BVnPUqTj.js").then((e) => e.repeaterModule),
1401
1401
  "rich-text": () => import("./chunks/rich-text-Bg_--4TG.js").then((e) => e.richTextModule),
1402
- signature: () => import("./chunks/signature-xz4QO7CR.js").then((e) => e.signatureModule),
1402
+ signature: () => import("./chunks/signature-IOhuicje.js").then((e) => e.signatureModule),
1403
1403
  summary: () => import("./chunks/summary-Dks0gXS3.js").then((e) => e.summaryModule),
1404
1404
  "survey-likert": () => import("./chunks/survey-likert-DkE6bR7B.js").then((e) => e.surveyLikertModule),
1405
1405
  "survey-rank": () => import("./chunks/survey-rank-DN6x4IZM.js").then((e) => e.surveyRankModule),
1406
1406
  "survey-rating": () => import("./chunks/survey-rating-BnsNL9U5.js").then((e) => e.surveyRatingModule),
1407
1407
  table: () => import("./chunks/table-CAjCJHrL.js").then((e) => e.tableModule),
1408
- "text-limit": () => import("./chunks/text-limit-Bn18WrPU.js").then((e) => e.textLimitModule)
1408
+ "text-limit": () => import("./chunks/text-limit-BGaY0jhI.js").then((e) => e.textLimitModule)
1409
1409
  }, Zt = {
1410
1410
  bpoint: () => import("./chunks/bpoint-Dlq34XH1.js").then((e) => e.bpointModule),
1411
1411
  eway: () => import("./chunks/eway-D9_m8ooj.js").then((e) => e.ewayModule),
@@ -2231,7 +2231,9 @@ function sr() {
2231
2231
  instance: D,
2232
2232
  options: g,
2233
2233
  unbinds: d
2234
- })), b && (ar(r, b, m, l, T, d), T && (d.push(_(b, T, r)), d.push(bn(b))), await or(r, m, b)), i.forEach((e) => {
2234
+ })), b && (ar(r, b, m, l, T, d), T && (d.push(_(b, T, r)), d.push(bn(b))), await or(r, m, b), b.dispatchEvent(new CustomEvent("formie:state:reset")), window.setTimeout(() => {
2235
+ b.dispatchEvent(new CustomEvent("formie:state:reset"));
2236
+ }, 350)), i.forEach((e) => {
2235
2237
  let t = l.on(`formie:stage:${e}:before`, async (t) => {
2236
2238
  h(r, `formie:stage:${e}:before`, t);
2237
2239
  }), n = l.on(`formie:stage:${e}:before`, async (e) => {
@@ -1 +1 @@
1
- {"version":3,"file":"create-formie-client.d.ts","sourceRoot":"","sources":["../../../src/js/core/create-formie-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,YAAY,EAGf,MAAM,mBAAmB,CAAC;AA81B3B,wBAAgB,kBAAkB,IAAI,YAAY,CAysBjD"}
1
+ {"version":3,"file":"create-formie-client.d.ts","sourceRoot":"","sources":["../../../src/js/core/create-formie-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,YAAY,EAGf,MAAM,mBAAmB,CAAC;AA81B3B,wBAAgB,kBAAkB,IAAI,YAAY,CAgtBjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/date-picker.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAgUjE,eAAO,MAAM,gBAAgB,EAAE,sBAwC9B,CAAC"}
1
+ {"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/date-picker.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAsUjE,eAAO,MAAM,gBAAgB,EAAE,sBAwC9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/signature.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAmVjE,eAAO,MAAM,eAAe,EAAE,sBA2C7B,CAAC"}
1
+ {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../../src/js/modules/fields/signature.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAyXjE,eAAO,MAAM,eAAe,EAAE,sBA2C7B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbb/formie-browser",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -70,7 +70,7 @@
70
70
  "@placekit/autocomplete-js": "^2.2.1",
71
71
  "@uppy/core": "^5.2.0",
72
72
  "@uppy/xhr-upload": "^5.2.0",
73
- "@verbb/formie-core": "1.0.12",
73
+ "@verbb/formie-core": "1.0.13",
74
74
  "expression-language": "^2.5.4",
75
75
  "flatpickr": "^4.6.13",
76
76
  "friendly-challenge": "^0.9.19",
@@ -20,7 +20,8 @@
20
20
  [data-formie-field-type="signature"] .formie-signature-canvas {
21
21
  display: block;
22
22
  width: var(--formie-signature-width);
23
- height: var(--formie-signature-height);
23
+ min-height: var(--formie-signature-height);
24
+ height: auto;
24
25
  border: var(--formie-signature-border);
25
26
  background: var(--formie-signature-background);
26
27
  border-radius: var(--formie-signature-border-radius);
@@ -1192,6 +1192,13 @@ export function createFormieClient(): FormieClient {
1192
1192
  }
1193
1193
 
1194
1194
  await refreshTokensIfNeeded(target, normalizedOptions, form);
1195
+
1196
+ // Recapture after captcha/token hydration and field-module init settle so
1197
+ // programmatic post-mount value changes do not leave a false dirty state.
1198
+ form.dispatchEvent(new CustomEvent('formie:state:reset'));
1199
+ window.setTimeout(() => {
1200
+ form.dispatchEvent(new CustomEvent('formie:state:reset'));
1201
+ }, 350);
1195
1202
  }
1196
1203
 
1197
1204
  stageNames.forEach((stageName) => {
@@ -285,6 +285,12 @@ function initDatePicker(input: FlatpickrInput, options: DatePickerOptions): () =
285
285
  if (startDate) {
286
286
  defaultOptions.defaultDate = endDate ? [startDate, endDate] : [startDate];
287
287
  }
288
+ } else if (input.value) {
289
+ const defaultDate = parseSubmissionDate(input.value);
290
+
291
+ if (defaultDate) {
292
+ defaultOptions.defaultDate = defaultDate;
293
+ }
288
294
  }
289
295
 
290
296
  const mergedOptions = {
@@ -111,11 +111,45 @@ function drawValueOnCanvas(canvas: HTMLCanvasElement, value: string): void {
111
111
  };
112
112
  }
113
113
 
114
+ function getImageDimensions(dataUrl: string): Promise<{ width: number; height: number } | null> {
115
+ return new Promise((resolve) => {
116
+ const image = new Image();
117
+ image.onload = () => {
118
+ resolve({
119
+ width: image.naturalWidth,
120
+ height: image.naturalHeight,
121
+ });
122
+ };
123
+ image.onerror = () => resolve(null);
124
+ image.src = dataUrl;
125
+ });
126
+ }
127
+
128
+ async function syncCanvasHeightToSignatureValue(canvas: HTMLCanvasElement, value: string): Promise<void> {
129
+ const dimensions = await getImageDimensions(value);
130
+
131
+ if (!dimensions?.width || !dimensions?.height) {
132
+ return;
133
+ }
134
+
135
+ const { width: containerWidth } = getCanvasSize(canvas);
136
+
137
+ if (!(containerWidth > 0)) {
138
+ return;
139
+ }
140
+
141
+ // Match the stored PNG aspect ratio so restored signatures are not vertically stretched.
142
+ const aspectHeight = Math.max(1, Math.round(containerWidth * (dimensions.height / dimensions.width)));
143
+ canvas.style.height = `${aspectHeight}px`;
144
+ }
145
+
114
146
  async function restoreSignatureValue(signaturePad: SignaturePad, canvas: HTMLCanvasElement, value: string): Promise<void> {
115
147
  if (!value) {
116
148
  return;
117
149
  }
118
150
 
151
+ await syncCanvasHeightToSignatureValue(canvas, value);
152
+
119
153
  try {
120
154
  await signaturePad.fromDataURL(value);
121
155
  } catch {
@@ -184,6 +218,12 @@ function initSignatureField(
184
218
  };
185
219
 
186
220
  const resizeCanvas = async(): Promise<boolean> => {
221
+ const existingValue = input.value || (signaturePad.isEmpty() ? '' : signaturePad.toDataURL());
222
+
223
+ if (existingValue) {
224
+ await syncCanvasHeightToSignatureValue(canvas, existingValue);
225
+ }
226
+
187
227
  const { width, height } = getCanvasSize(canvas);
188
228
 
189
229
  if (!(width > 0) || !(height > 0)) {
@@ -196,8 +236,6 @@ function initSignatureField(
196
236
  return false;
197
237
  }
198
238
 
199
- const existingValue = input.value || (signaturePad.isEmpty() ? '' : signaturePad.toDataURL());
200
-
201
239
  canvas.width = width * ratio;
202
240
  canvas.height = height * ratio;
203
241
  context.setTransform(1, 0, 0, 1, 0, 0);