@verbb/formie-browser 1.0.6 → 1.0.8

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/chunks/_survey-presentations-CFsgToRT.js +4 -0
  3. package/dist/chunks/{address-finder-yXU5yMjG.js → address-finder-k7_BXaRe.js} +1 -1
  4. package/dist/chunks/{api-DMK8NSUI.js → api-BUb6P-xu.js} +57 -51
  5. package/dist/chunks/{api-CmwLRq_n.js → api-C8wyLC-s.js} +235 -193
  6. package/dist/chunks/{bpoint-DSjqRv63.js → bpoint-CwSw_p7A.js} +1 -1
  7. package/dist/chunks/{captcha-eu-CWJb64_j.js → captcha-eu-CGm8Lbrj.js} +2 -2
  8. package/dist/chunks/{conditions-DjZOtHfS.js → conditions-B6_nzpeE.js} +95 -83
  9. package/dist/chunks/{eway-D3ctTbEk.js → eway-B30BMlDp.js} +2 -2
  10. package/dist/chunks/{friendly-captcha-v1-ByXzENYZ.js → friendly-captcha-v1-C_2reOXr.js} +1 -1
  11. package/dist/chunks/{friendly-captcha-v2-BPdlmhQu.js → friendly-captcha-v2-CLSAbkqx.js} +1 -1
  12. package/dist/chunks/{go-cardless-BwASSYSK.js → go-cardless-BiF3iLel.js} +1 -1
  13. package/dist/chunks/{google-address-OhKilPWE.js → google-address-BH3Zhi06.js} +1 -1
  14. package/dist/chunks/{hcaptcha-CdCd9oEi.js → hcaptcha-CGLAmgjO.js} +2 -2
  15. package/dist/chunks/{loqate-Cp2zvwpE.js → loqate-CJPzBmSm.js} +1 -1
  16. package/dist/chunks/{mollie-COG-ko2D.js → mollie-D__SwtcH.js} +1 -1
  17. package/dist/chunks/{moneris-CMH8PlRc.js → moneris-KJS1BKx7.js} +1 -1
  18. package/dist/chunks/{opayo-D2jsR5vh.js → opayo-A_LIkc-v.js} +4 -4
  19. package/dist/chunks/{paddle-DxF88RfC.js → paddle-BjbOOb0m.js} +2 -2
  20. package/dist/chunks/{paypal-b5pnwrA2.js → paypal-CyjHIV8v.js} +2 -2
  21. package/dist/chunks/{payway-BJYu9DIR.js → payway-a_cyrr3j.js} +2 -2
  22. package/dist/chunks/{recaptcha-enterprise-BSwi8IVX.js → recaptcha-enterprise-XPId5-bS.js} +19 -20
  23. package/dist/chunks/{recaptcha-shared-B4zAescW.js → recaptcha-shared-CLYJvojk.js} +15 -3
  24. package/dist/chunks/{recaptcha-v2-checkbox-CnDQmsKa.js → recaptcha-v2-checkbox-Cy-0PEPc.js} +2 -2
  25. package/dist/chunks/{recaptcha-v2-invisible-Cz5uIlp-.js → recaptcha-v2-invisible-BwRH540O.js} +2 -2
  26. package/dist/chunks/recaptcha-v3-No4Ykrhk.js +28 -0
  27. package/dist/chunks/scripts-CbQ7agX3.js +30 -0
  28. package/dist/chunks/{snaptcha-vz1RnZ15.js → snaptcha-DKx98oon.js} +1 -1
  29. package/dist/chunks/{square-BP8RWAKB.js → square-Bga6WXHV.js} +2 -2
  30. package/dist/chunks/{stripe-MihN63uC.js → stripe-BlqVocl3.js} +2 -2
  31. package/dist/chunks/{summary-D3AjxpYN.js → summary-Dks0gXS3.js} +42 -38
  32. package/dist/chunks/survey-likert-DmJ3klhP.js +20 -0
  33. package/dist/chunks/survey-rank-DeUenftw.js +127 -0
  34. package/dist/chunks/survey-rating-BPUYDgBJ.js +88 -0
  35. package/dist/chunks/{turnstile-D_Pi1CKM.js → turnstile-DJakPzQD.js} +3 -3
  36. package/dist/css/formie-theme.css +1 -0
  37. package/dist/css/theme/fields/_survey-presentations.css +396 -0
  38. package/dist/index.js +651 -597
  39. package/dist/js/contracts/schema.d.ts +5 -0
  40. package/dist/js/contracts/schema.d.ts.map +1 -1
  41. package/dist/js/core/create-formie-client.d.ts.map +1 -1
  42. package/dist/js/core/error-aria-live.d.ts +6 -0
  43. package/dist/js/core/error-aria-live.d.ts.map +1 -0
  44. package/dist/js/core/page-client-event.d.ts +8 -4
  45. package/dist/js/core/page-client-event.d.ts.map +1 -1
  46. package/dist/js/core/submit-result-state.d.ts.map +1 -1
  47. package/dist/js/core/submit-result-ui.d.ts.map +1 -1
  48. package/dist/js/modules/captchas/factories.d.ts.map +1 -1
  49. package/dist/js/modules/captchas/host.d.ts +1 -0
  50. package/dist/js/modules/captchas/host.d.ts.map +1 -1
  51. package/dist/js/modules/captchas/recaptcha-enterprise.d.ts.map +1 -1
  52. package/dist/js/modules/captchas/recaptcha-shared.d.ts +1 -0
  53. package/dist/js/modules/captchas/recaptcha-shared.d.ts.map +1 -1
  54. package/dist/js/modules/captchas/recaptcha-v3.d.ts.map +1 -1
  55. package/dist/js/modules/captchas/turnstile.d.ts.map +1 -1
  56. package/dist/js/modules/fields/conditions/effects.d.ts.map +1 -1
  57. package/dist/js/modules/fields/index.d.ts.map +1 -1
  58. package/dist/js/modules/fields/summary.d.ts.map +1 -1
  59. package/dist/js/modules/fields/survey-likert.d.ts +3 -0
  60. package/dist/js/modules/fields/survey-likert.d.ts.map +1 -0
  61. package/dist/js/modules/fields/survey-rank.d.ts +3 -0
  62. package/dist/js/modules/fields/survey-rank.d.ts.map +1 -0
  63. package/dist/js/modules/fields/survey-rating.d.ts +3 -0
  64. package/dist/js/modules/fields/survey-rating.d.ts.map +1 -0
  65. package/dist/js/transport/forms-api.d.ts.map +1 -1
  66. package/dist/js/utils/form-started-at.d.ts +2 -0
  67. package/dist/js/utils/form-started-at.d.ts.map +1 -0
  68. package/dist/js/utils/scripts.d.ts.map +1 -1
  69. package/dist/js/utils/unload-warning.d.ts.map +1 -1
  70. package/dist/js/validation/enter-key-guard.d.ts +2 -0
  71. package/dist/js/validation/enter-key-guard.d.ts.map +1 -0
  72. package/dist/js/validation/types.d.ts +1 -0
  73. package/dist/js/validation/types.d.ts.map +1 -1
  74. package/dist/js/validation/validator.d.ts.map +1 -1
  75. package/package.json +2 -2
  76. package/src/css/formie-theme.css +1 -0
  77. package/src/css/theme/fields/_survey-presentations.css +396 -0
  78. package/src/js/contracts/schema.ts +6 -0
  79. package/src/js/core/create-formie-client.ts +21 -1
  80. package/src/js/core/error-aria-live.ts +45 -0
  81. package/src/js/core/page-client-event.ts +86 -18
  82. package/src/js/core/submit-result-state.ts +10 -2
  83. package/src/js/core/submit-result-ui.ts +8 -4
  84. package/src/js/modules/captchas/factories.ts +4 -0
  85. package/src/js/modules/captchas/host.ts +14 -2
  86. package/src/js/modules/captchas/recaptcha-enterprise.ts +14 -11
  87. package/src/js/modules/captchas/recaptcha-shared.ts +14 -0
  88. package/src/js/modules/captchas/recaptcha-v3.ts +7 -4
  89. package/src/js/modules/captchas/turnstile.ts +9 -3
  90. package/src/js/modules/fields/conditions/effects.ts +42 -0
  91. package/src/js/modules/fields/index.ts +3 -0
  92. package/src/js/modules/fields/summary.ts +17 -3
  93. package/src/js/modules/fields/survey-likert.ts +50 -0
  94. package/src/js/modules/fields/survey-rank.ts +385 -0
  95. package/src/js/modules/fields/survey-rating.ts +182 -0
  96. package/src/js/transport/forms-api.ts +1 -0
  97. package/src/js/utils/form-started-at.ts +25 -0
  98. package/src/js/utils/scripts.ts +16 -0
  99. package/src/js/utils/unload-warning.ts +1 -0
  100. package/src/js/validation/enter-key-guard.ts +63 -0
  101. package/src/js/validation/types.ts +1 -0
  102. package/src/js/validation/validator.ts +14 -5
  103. package/dist/chunks/recaptcha-v3-BtbbP111.js +0 -27
  104. package/dist/chunks/scripts-6CYSUGKQ.js +0 -24
@@ -0,0 +1,28 @@
1
+ import { t as e } from "./api-BUb6P-xu.js";
2
+ import { n as t, t as n } from "./recaptcha-shared-CLYJvojk.js";
3
+ //#region src/js/modules/captchas/recaptcha-v3.ts
4
+ var r = e({
5
+ id: "recaptcha-v3",
6
+ defaultPlaceholderSelector: "[data-recaptcha-placeholder]",
7
+ defaultTokenFieldNames: ["g-recaptcha-response"],
8
+ load: ({ options: e }) => n(e.provider, !1, e.provider.siteKey || void 0),
9
+ mount: ({ api: e, provider: t }) => new Promise((n) => {
10
+ e.ready(() => {
11
+ n(t.siteKey || "recaptcha-v3");
12
+ });
13
+ }),
14
+ screen: async ({ api: e, provider: n, placeholder: r, services: i, stageCtx: a }) => {
15
+ if (!i.tokens.has() && (await t(e, async () => {
16
+ let t = await e.execute(n.siteKey || "", { action: n.action || "submit" });
17
+ typeof t == "string" && t.trim() !== "" && i.tokens.write(t.trim());
18
+ }), !await i.tokens.wait(12e4))) {
19
+ let e = i.errors.getDefaultMessage();
20
+ i.errors.show(e, r), a.abort(e);
21
+ }
22
+ },
23
+ unmount: ({ services: e }) => {
24
+ e.tokens.clear();
25
+ }
26
+ });
27
+ //#endregion
28
+ export { r as recaptchaV3Module };
@@ -0,0 +1,30 @@
1
+ import { r as e } from "./async-nPFRNQ06.js";
2
+ //#region src/js/utils/scripts.ts
3
+ var t = /* @__PURE__ */ new Map();
4
+ function n() {
5
+ let e = document.querySelector("meta[property=\"csp-nonce\"], meta[name=\"csp-nonce\"]");
6
+ return e && (e.nonce || e.getAttribute("nonce") || e.getAttribute("content")) || null;
7
+ }
8
+ async function r(t, n = 5e3) {
9
+ return e(() => window[t] ?? null, {
10
+ timeoutMs: n,
11
+ intervalMs: 30
12
+ });
13
+ }
14
+ async function i({ id: e, src: r, async: i = !0, defer: a = !0 }) {
15
+ return document.getElementById(e) || (t.has(e) || t.set(e, new Promise((o, s) => {
16
+ let c = document.createElement("script");
17
+ c.id = e, c.src = r, c.async = i, c.defer = a;
18
+ let l = n();
19
+ l && c.setAttribute("nonce", l), c.onload = () => {
20
+ o(c);
21
+ }, c.onerror = () => {
22
+ t.delete(e), s(/* @__PURE__ */ Error(`Failed to load external script: ${r}`));
23
+ }, document.body.appendChild(c);
24
+ })), t.get(e));
25
+ }
26
+ async function a(e, t) {
27
+ return window[e] ?? (await i(t), r(e, t.timeoutMs));
28
+ }
29
+ //#endregion
30
+ export { i as n, a as r, r as t };
@@ -1,4 +1,4 @@
1
- import { n as e } from "./api-DMK8NSUI.js";
1
+ import { n as e } from "./api-BUb6P-xu.js";
2
2
  //#region src/js/modules/captchas/snaptcha.ts
3
3
  var t = e({
4
4
  id: "snaptcha",
@@ -1,5 +1,5 @@
1
- import { t as e } from "./api-CmwLRq_n.js";
2
- import { r as t } from "./scripts-6CYSUGKQ.js";
1
+ import { t as e } from "./api-C8wyLC-s.js";
2
+ import { r as t } from "./scripts-CbQ7agX3.js";
3
3
  //#region src/js/modules/payments/square.ts
4
4
  var n = "FORMIE_SQUARE_SCRIPT", r = e({
5
5
  id: "square",
@@ -1,7 +1,7 @@
1
1
  import { s as e } from "./event-names-BCI2FLD8.js";
2
- import { t } from "./api-CmwLRq_n.js";
2
+ import { t } from "./api-C8wyLC-s.js";
3
3
  import { r as n, t as r } from "./theme-classes-Tv7q7ToE.js";
4
- import { r as i } from "./scripts-6CYSUGKQ.js";
4
+ import { r as i } from "./scripts-CbQ7agX3.js";
5
5
  import { t as a } from "./styles-BfoIZwJp.js";
6
6
  //#endregion
7
7
  //#region src/js/modules/payments/stripe.ts
@@ -5,29 +5,33 @@ import { t as r } from "./async-nPFRNQ06.js";
5
5
  import { t as i } from "./styles-BfoIZwJp.js";
6
6
  import { r as a, t as o } from "./shared-Bx9s0i0P.js";
7
7
  //#region src/css/theme/fields/_summary.css?inline
8
- var s = "@layer formie-theme{.formie-summary-container{padding:var(--formie-summary-padding);border:var(--formie-border-width) solid var(--formie-color-border);border-radius:var(--formie-radius-sm)}.formie-summary-heading{color:var(--formie-color-heading)}.formie-summary-blocks{gap:var(--formie-gap-summary);display:grid}.formie-summary-blocks[data-formie-loading=true]{min-height:calc(var(--formie-loading-size) + var(--formie-space-4));position:relative}.formie-summary-blocks[data-formie-loading=true]>*{opacity:0;pointer-events:none}.formie-summary-blocks[data-formie-loading=true]:before{content:\"\";background:var(--formie-color-bg);border-radius:inherit;z-index:1;display:block;position:absolute;inset:0}.formie-summary-blocks[data-formie-loading=true]:after{width:var(--formie-loading-size);height:var(--formie-loading-size);content:\"\";border:var(--formie-loading-border-width) solid var(--formie-loading-color);border-radius:var(--formie-radius-full);z-index:2;animation:formie-loading-spin var(--formie-loading-speed) linear infinite;border-top-color:#0000;border-right-color:#0000;display:block;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}}", c = "[data-formie-summary-blocks]", l = "[data-formie-summary-container]", u = "formie/fields/get-summary-html", d = "summary", f = e("fields", "summary");
9
- i(d, [s]);
10
- function p() {
8
+ var s = "@layer formie-theme{.formie-summary-container{padding:var(--formie-summary-padding);border:var(--formie-border-width) solid var(--formie-color-border);border-radius:var(--formie-radius-sm)}.formie-summary-heading{color:var(--formie-color-heading)}.formie-summary-blocks{gap:var(--formie-gap-summary);display:grid}.formie-summary-blocks[data-formie-loading=true]{min-height:calc(var(--formie-loading-size) + var(--formie-space-4));position:relative}.formie-summary-blocks[data-formie-loading=true]>*{opacity:0;pointer-events:none}.formie-summary-blocks[data-formie-loading=true]:before{content:\"\";background:var(--formie-color-bg);border-radius:inherit;z-index:1;display:block;position:absolute;inset:0}.formie-summary-blocks[data-formie-loading=true]:after{width:var(--formie-loading-size);height:var(--formie-loading-size);content:\"\";border:var(--formie-loading-border-width) solid var(--formie-loading-color);border-radius:var(--formie-radius-full);z-index:2;animation:formie-loading-spin var(--formie-loading-speed) linear infinite;border-top-color:#0000;border-right-color:#0000;display:block;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}}", c = "[data-formie-summary-blocks]", l = "[data-formie-summary-container]", u = "formie/fields/get-summary-html", d = "data-formie-theme-config", f = "data-formie-frontend-theme", p = "summary", m = e("fields", "summary");
9
+ i(p, [s]);
10
+ function h() {
11
11
  let e = new URL(window.location.href);
12
12
  return e.hash = "", e.toString();
13
13
  }
14
- function m(e) {
15
- return { accessToken: e.querySelector("[data-formie-summary-token]")?.value?.trim() || null };
14
+ function g(e, t) {
15
+ return {
16
+ accessToken: e.querySelector("[data-formie-summary-token]")?.value?.trim() || null,
17
+ themeConfig: t.getAttribute(d)?.trim() || null,
18
+ frontendTheme: t.getAttribute(f)?.trim() || null
19
+ };
16
20
  }
17
- async function h(e, t, r) {
21
+ async function _(e, t, r) {
18
22
  if (!t.accessToken) throw Error("Summary field requires an access token.");
19
23
  let i = new FormData(e);
20
- return i.set("action", u), i.set("accessToken", t.accessToken), n(p(), {
24
+ return i.set("action", u), i.set("accessToken", t.accessToken), t.themeConfig && i.set("themeConfig", t.themeConfig), t.frontendTheme && i.set("frontendTheme", t.frontendTheme), n(h(), {
21
25
  method: "POST",
22
26
  body: i,
23
27
  signal: r,
24
28
  headers: { Accept: "text/html" }
25
29
  });
26
30
  }
27
- function g(e, n) {
31
+ function v(e, n) {
28
32
  let i = e.closest("form");
29
- if (!(i instanceof HTMLFormElement)) return f.warn("Missing form ancestor; skipping field."), () => {};
30
- let a = !1, s = !0, u = !1, p = 0, g = 0, _ = null, v = () => {
33
+ if (!(i instanceof HTMLFormElement)) return m.warn("Missing form ancestor; skipping field."), () => {};
34
+ let a = !1, s = !0, u = !1, d = 0, f = 0, h = null, v = () => {
31
35
  let t = e.querySelector(c);
32
36
  return t instanceof HTMLElement ? t : null;
33
37
  }, y = () => {
@@ -43,72 +47,72 @@ function g(e, n) {
43
47
  n.removeAttribute("data-formie-loading"), n.removeAttribute("aria-busy"), t(n, i, "loading", !1);
44
48
  }
45
49
  };
46
- b(!!m(e).accessToken);
50
+ b(!!g(e, i).accessToken);
47
51
  let x = () => {
48
- !u || a && !s || (f.log("Queueing fetch."), S());
52
+ !u || a && !s || (m.log("Queueing fetch."), S());
49
53
  }, S = r(async () => {
50
- let t = m(e);
54
+ let t = g(e, i);
51
55
  if (!v() || !t.accessToken) {
52
- f.warn("Missing state for fetch.", t), b(!1);
56
+ m.warn("Missing state for fetch.", t), b(!1);
53
57
  return;
54
58
  }
55
- g += 1;
56
- let n = g, r = p;
57
- _?.abort(), _ = new AbortController(), b(!0);
59
+ f += 1;
60
+ let n = f, r = d;
61
+ h?.abort(), h = new AbortController(), b(!0);
58
62
  try {
59
- let c = await h(i, t, _.signal);
60
- if (n !== g) return;
61
- let u = y(), m = document.createElement("template");
62
- m.innerHTML = c.trim();
63
- let v = m.content.querySelector(l);
64
- u && v instanceof HTMLElement ? u.replaceWith(v) : u && (u.innerHTML = c), a = !0, s = p !== r, f.log("Fetch complete.", {
63
+ let c = await _(i, t, h.signal);
64
+ if (n !== f) return;
65
+ let u = y(), g = document.createElement("template");
66
+ g.innerHTML = c.trim();
67
+ let v = g.content.querySelector(l);
68
+ u && v instanceof HTMLElement ? u.replaceWith(v) : u && (u.innerHTML = c), a = !0, s = d !== r, m.log("Fetch complete.", {
65
69
  isDirty: s,
66
- dirtyVersion: p,
70
+ dirtyVersion: d,
67
71
  requestVersion: n
68
- }), o(e, d, "fetch-summary", {
72
+ }), o(e, p, "fetch-summary", {
69
73
  summary: e,
70
74
  html: c
71
75
  });
72
76
  } catch (e) {
73
77
  if (e instanceof DOMException && e.name === "AbortError") {
74
- f.log("Fetch aborted.");
78
+ m.log("Fetch aborted.");
75
79
  return;
76
80
  }
77
81
  console.error("[formie] Failed to load summary field HTML.", e);
78
82
  } finally {
79
- n === g && (b(!1), _ = null, s && x());
83
+ n === f && (b(!1), h = null, s && x());
80
84
  }
81
85
  }, 300), C = (t) => {
82
86
  let n = t?.target;
83
- n instanceof Node && e.contains(n) || (s = !0, p += 1, f.log("Marked dirty.", { dirtyVersion: p }));
87
+ n instanceof Node && e.contains(n) || (s = !0, d += 1, m.log("Marked dirty.", { dirtyVersion: d }));
84
88
  }, w = (e) => {
85
89
  C(e), x();
86
90
  }, T = () => {
87
- s = !0, f.log("Submit result received; refreshing."), x();
91
+ s = !0, m.log("Submit result received; refreshing."), x();
88
92
  }, E = () => {
89
- s = !0, f.log("Page navigation received; refreshing."), x();
93
+ s = !0, m.log("Page navigation received; refreshing."), x();
90
94
  }, D = new IntersectionObserver((t) => {
91
- u = !!t[0]?.isIntersecting, u && (f.log("Field became visible."), o(e, d, "field-visible", { summary: e }), x());
95
+ u = !!t[0]?.isIntersecting, u && (m.log("Field became visible."), o(e, p, "field-visible", { summary: e }), x());
92
96
  }, {
93
97
  root: i,
94
98
  rootMargin: "50px"
95
99
  });
96
100
  return D.observe(e), i.addEventListener("input", w), i.addEventListener("change", w), n.addEventListener("formie:page:navigate:after", E), n.addEventListener("formie:submit:result", T), () => {
97
- _?.abort(), D.disconnect(), i.removeEventListener("input", w), i.removeEventListener("change", w), n.removeEventListener("formie:page:navigate:after", E), n.removeEventListener("formie:submit:result", T), f.log("Field destroyed.");
101
+ h?.abort(), D.disconnect(), i.removeEventListener("input", w), i.removeEventListener("change", w), n.removeEventListener("formie:page:navigate:after", E), n.removeEventListener("formie:submit:result", T), m.log("Field destroyed.");
98
102
  };
99
103
  }
100
- var _ = {
101
- id: d,
104
+ var y = {
105
+ id: p,
102
106
  kind: "field",
103
107
  match: (e) => !!e.target.querySelector(c),
104
108
  setup: async (e) => {
105
- let t = a(e).map((t) => g(t, e.root));
106
- return f.log("Module setup.", { fieldCount: t.length }), await e.emit("formie:module:summary:init", { count: t.length }), { destroy: () => {
109
+ let t = a(e).map((t) => v(t, e.root));
110
+ return m.log("Module setup.", { fieldCount: t.length }), await e.emit("formie:module:summary:init", { count: t.length }), { destroy: () => {
107
111
  t.forEach((e) => {
108
112
  e();
109
- }), f.log("Module destroy.", { fieldCount: t.length }), e.emit("formie:module:summary:destroy", {});
113
+ }), m.log("Module destroy.", { fieldCount: t.length }), e.emit("formie:module:summary:destroy", {});
110
114
  } };
111
115
  }
112
116
  };
113
117
  //#endregion
114
- export { _ as summaryModule };
118
+ export { y as summaryModule };
@@ -0,0 +1,20 @@
1
+ import { t as e } from "./debug-BV0DvdHx.js";
2
+ import { t } from "./styles-BfoIZwJp.js";
3
+ import { t as n } from "./_survey-presentations-CFsgToRT.js";
4
+ //#region src/js/modules/fields/survey-likert.ts
5
+ var r = "[data-formie-likert-field-layout]", i = "survey-likert", a = e("fields", "survey-likert");
6
+ t(i, [n]);
7
+ var o = {
8
+ id: i,
9
+ kind: "field",
10
+ match: (e) => e.target instanceof HTMLElement && (e.target.matches(r) || !!e.target.querySelector(r)),
11
+ setup: async (e) => {
12
+ if (!(e.target instanceof HTMLElement)) return;
13
+ let t = e.target.matches(r) ? [e.target] : Array.from(e.target.querySelectorAll(r)).filter((e) => e instanceof HTMLElement);
14
+ return a.log("Module setup.", { fieldCount: t.length }), await e.emit("formie:module:survey-likert:init", { count: t.length }), { destroy: () => {
15
+ a.log("Module destroy.", { fieldCount: t.length }), e.emit("formie:module:survey-likert:destroy", {});
16
+ } };
17
+ }
18
+ };
19
+ //#endregion
20
+ export { o as surveyLikertModule };
@@ -0,0 +1,127 @@
1
+ import { t as e } from "./debug-BV0DvdHx.js";
2
+ import { t } from "./styles-BfoIZwJp.js";
3
+ import { t as n } from "./shared-Bx9s0i0P.js";
4
+ import { t as r } from "./_survey-presentations-CFsgToRT.js";
5
+ //#region src/js/modules/fields/survey-rank.ts
6
+ var i = "[data-formie-survey-rank]", a = "[data-formie-survey-rank-list]", o = "[data-formie-survey-rank-item]", s = "[data-formie-rank-handle]", c = "formie-rank-placeholder", l = .42, u = "survey-rank", d = e("fields", "survey-rank");
7
+ t(u, [r]);
8
+ function f(e) {
9
+ e.querySelectorAll(o).forEach((e, t) => {
10
+ e instanceof HTMLElement && e.querySelectorAll("input[data-formie-rank-input]").forEach((e) => {
11
+ e instanceof HTMLInputElement && (e.dataset.formieRankOrder = String(t));
12
+ });
13
+ });
14
+ }
15
+ function p(e) {
16
+ return Array.from(e.querySelectorAll(o)).filter((e) => e instanceof HTMLElement);
17
+ }
18
+ function m(e, t) {
19
+ return Array.from(e.children).indexOf(t);
20
+ }
21
+ function h(e, t, n) {
22
+ return Array.from(e.children).filter((e) => e instanceof HTMLElement && e !== t && e !== n);
23
+ }
24
+ function g(e, t) {
25
+ return Math.max(0, Math.min(e.bottom, t.bottom) - Math.max(e.top, t.top));
26
+ }
27
+ function _(e) {
28
+ let t = e.getBoundingClientRect();
29
+ return t.top + t.height / 2;
30
+ }
31
+ function v(e, t, n, r) {
32
+ let i = e.getBoundingClientRect(), a = _(e), o = h(t, n, e);
33
+ for (let e = 0; e < o.length; e += 1) {
34
+ let t = o[e].getBoundingClientRect(), n = t.top + t.height * l;
35
+ if (g(i, t) / t.height >= l) return r ? Math.min(e + 1, o.length) : e;
36
+ if (a < n) return e;
37
+ }
38
+ return o.length;
39
+ }
40
+ function y(e, t, n, r) {
41
+ let i = h(e, t, n)[r] ?? null;
42
+ if (i) {
43
+ e.insertBefore(t, i);
44
+ return;
45
+ }
46
+ e.appendChild(t);
47
+ }
48
+ function b(e, t) {
49
+ let n = document.createElement("li");
50
+ return n.className = c, n.setAttribute("data-formie-rank-placeholder", "true"), n.setAttribute("aria-hidden", "true"), n.style.height = `${t.offsetHeight}px`, e.insertBefore(n, t), n;
51
+ }
52
+ function x(e) {
53
+ return {
54
+ position: e.style.position,
55
+ left: e.style.left,
56
+ top: e.style.top,
57
+ width: e.style.width,
58
+ zIndex: e.style.zIndex,
59
+ pointerEvents: e.style.pointerEvents,
60
+ margin: e.style.margin
61
+ };
62
+ }
63
+ function S(e, t) {
64
+ e.style.position = "fixed", e.style.left = `${t.left}px`, e.style.top = `${t.top}px`, e.style.width = `${t.width}px`, e.style.zIndex = "1000", e.style.pointerEvents = "none", e.style.margin = "0";
65
+ }
66
+ function C(e, t, n) {
67
+ e.style.left = `${t.clientX - n.x}px`, e.style.top = `${t.clientY - n.y}px`;
68
+ }
69
+ function w(e, t) {
70
+ e.style.position = t.position, e.style.left = t.left, e.style.top = t.top, e.style.width = t.width, e.style.zIndex = t.zIndex, e.style.pointerEvents = t.pointerEvents, e.style.margin = t.margin;
71
+ }
72
+ function T(e) {
73
+ let t = e.querySelector(a);
74
+ if (!(t instanceof HTMLElement)) return d.warn("Missing rank list; skipping field."), () => {};
75
+ let r = null, i = null, o = null, c = null, l = null, h = null, g = null, T = null, E = null, D = !1, O = [], k = () => {
76
+ if (r && i ? (t.insertBefore(r, i), i.remove()) : i && i.remove(), r && o && (w(r, o), r.removeAttribute("data-formie-rank-dragging")), l && h !== null) try {
77
+ l.releasePointerCapture(h);
78
+ } catch {}
79
+ r = null, i = null, o = null, c = null, l = null, h = null, g = null, T = null, E = null, t.removeAttribute("data-formie-rank-sorting"), D && (f(t), n(e, u, "reorder", { rankField: e })), D = !1;
80
+ }, A = (e) => {
81
+ if (!r || !i || !c || e.pointerId !== h) return;
82
+ e.preventDefault(), C(r, e, c);
83
+ let n = _(r), a = E === null || n >= E;
84
+ E = n;
85
+ let o = v(r, t, i, a);
86
+ o !== g && (g = o, y(t, i, r, o));
87
+ }, j = (e) => {
88
+ e.pointerId === h && (document.removeEventListener("pointermove", A), document.removeEventListener("pointerup", j), document.removeEventListener("pointercancel", j), i && T !== null && (D = m(t, i) !== T), k());
89
+ };
90
+ return p(t).forEach((e) => {
91
+ if (!e.querySelector(s)) return;
92
+ let n = (n) => {
93
+ if (n.button !== 0 || n.target instanceof HTMLInputElement) return;
94
+ n.preventDefault();
95
+ let a = e.getBoundingClientRect();
96
+ r = e, l = e, h = n.pointerId, c = {
97
+ x: n.clientX - a.left,
98
+ y: n.clientY - a.top
99
+ }, o = x(e), i = b(t, e), T = m(t, i), D = !1, S(e, a), e.setAttribute("data-formie-rank-dragging", "true"), t.setAttribute("data-formie-rank-sorting", "true"), e.setPointerCapture(n.pointerId), E = _(e), g = v(e, t, i, !0), document.addEventListener("pointermove", A), document.addEventListener("pointerup", j), document.addEventListener("pointercancel", j);
100
+ };
101
+ e.addEventListener("pointerdown", n), O.push(() => {
102
+ e.removeEventListener("pointerdown", n);
103
+ });
104
+ }), f(t), () => {
105
+ document.removeEventListener("pointermove", A), document.removeEventListener("pointerup", j), document.removeEventListener("pointercancel", j), O.forEach((e) => {
106
+ e();
107
+ }), k();
108
+ };
109
+ }
110
+ var E = {
111
+ id: u,
112
+ kind: "field",
113
+ match: (e) => e.target instanceof HTMLElement && (e.target.matches(i) || !!e.target.querySelector(i)),
114
+ setup: async (e) => {
115
+ if (!(e.target instanceof HTMLElement)) return;
116
+ let t = e.target.matches(i) ? [e.target] : Array.from(e.target.querySelectorAll(i)).filter((e) => e instanceof HTMLElement);
117
+ d.log("Module setup.", { fieldCount: t.length });
118
+ let n = t.map((e) => T(e));
119
+ return await e.emit("formie:module:survey-rank:init", { count: t.length }), { destroy: () => {
120
+ n.forEach((e) => {
121
+ e();
122
+ }), d.log("Module destroy.", { fieldCount: t.length }), e.emit("formie:module:survey-rank:destroy", {});
123
+ } };
124
+ }
125
+ };
126
+ //#endregion
127
+ export { E as surveyRankModule };
@@ -0,0 +1,88 @@
1
+ import { t as e } from "./debug-BV0DvdHx.js";
2
+ import { t } from "./styles-BfoIZwJp.js";
3
+ import { t as n } from "./shared-Bx9s0i0P.js";
4
+ import { t as r } from "./_survey-presentations-CFsgToRT.js";
5
+ //#region src/js/modules/fields/survey-rating.ts
6
+ var i = "[data-formie-survey-rating]", a = "[data-formie-survey-rating-stars]", o = "[data-formie-rating-option]", s = "input[data-formie-rating-input]", c = "data-formie-rating-pressed-while-checked", l = "survey-rating", u = e("fields", "survey-rating");
7
+ t(l, [r]);
8
+ function d(e) {
9
+ return Array.from(e.querySelectorAll(s)).filter((e) => e instanceof HTMLInputElement);
10
+ }
11
+ function f(e) {
12
+ let t = d(e).findIndex((e) => e.checked);
13
+ if (t >= 0) {
14
+ e.setAttribute("data-formie-rating-value", String(t + 1));
15
+ return;
16
+ }
17
+ e.removeAttribute("data-formie-rating-value");
18
+ }
19
+ function p(e) {
20
+ let t = e.querySelector(a);
21
+ if (!(t instanceof HTMLElement)) return u.warn("Missing rating stars container; skipping field."), () => {};
22
+ let r = [], i = () => {
23
+ t.removeAttribute("data-formie-rating-hover");
24
+ }, p = (e) => {
25
+ let n = Array.from(t.querySelectorAll(o)).indexOf(e);
26
+ n >= 0 && t.setAttribute("data-formie-rating-hover", String(n + 1));
27
+ };
28
+ return t.querySelectorAll(o).forEach((e) => {
29
+ if (!(e instanceof HTMLElement)) return;
30
+ let t = e.querySelector(s), n = () => {
31
+ if (t instanceof HTMLInputElement) {
32
+ if (t.checked) {
33
+ t.setAttribute(c, "true");
34
+ return;
35
+ }
36
+ t.removeAttribute(c);
37
+ }
38
+ }, i = () => {
39
+ p(e);
40
+ };
41
+ e.addEventListener("pointerdown", n), e.addEventListener("mouseenter", i), r.push(() => {
42
+ e.removeEventListener("pointerdown", n), e.removeEventListener("mouseenter", i);
43
+ });
44
+ }), t.addEventListener("mouseleave", i), r.push(() => {
45
+ t.removeEventListener("mouseleave", i);
46
+ }), d(t).forEach((i) => {
47
+ let a = (r) => {
48
+ if (i.getAttribute(c) !== "true") {
49
+ f(t), n(e, l, "change", {
50
+ ratingField: e,
51
+ value: i.checked ? i.value : ""
52
+ });
53
+ return;
54
+ }
55
+ r.preventDefault(), d(t).forEach((e) => {
56
+ e.checked = !1, e.removeAttribute(c);
57
+ }), f(t), n(e, l, "change", {
58
+ ratingField: e,
59
+ value: ""
60
+ });
61
+ };
62
+ i.addEventListener("click", a), r.push(() => {
63
+ i.removeEventListener("click", a), i.removeAttribute(c);
64
+ });
65
+ }), f(t), () => {
66
+ r.forEach((e) => {
67
+ e();
68
+ }), i(), t.removeAttribute("data-formie-rating-value");
69
+ };
70
+ }
71
+ var m = {
72
+ id: l,
73
+ kind: "field",
74
+ match: (e) => e.target instanceof HTMLElement && (e.target.matches(i) || !!e.target.querySelector(i)),
75
+ setup: async (e) => {
76
+ if (!(e.target instanceof HTMLElement)) return;
77
+ let t = e.target.matches(i) ? [e.target] : Array.from(e.target.querySelectorAll(i)).filter((e) => e instanceof HTMLElement);
78
+ u.log("Module setup.", { fieldCount: t.length });
79
+ let n = t.map((e) => p(e));
80
+ return await e.emit("formie:module:survey-rating:init", { count: t.length }), { destroy: () => {
81
+ n.forEach((e) => {
82
+ e();
83
+ }), u.log("Module destroy.", { fieldCount: t.length }), e.emit("formie:module:survey-rating:destroy", {});
84
+ } };
85
+ }
86
+ };
87
+ //#endregion
88
+ export { m as surveyRatingModule };
@@ -1,5 +1,5 @@
1
- import { a as e, i as t, o as n, r, t as i } from "./api-DMK8NSUI.js";
2
- import { r as a } from "./scripts-6CYSUGKQ.js";
1
+ import { a as e, i as t, o as n, r, t as i } from "./api-BUb6P-xu.js";
2
+ import { r as a } from "./scripts-CbQ7agX3.js";
3
3
  //#region src/js/modules/captchas/turnstile.ts
4
4
  function o(e) {
5
5
  let r = e.appearance || "always";
@@ -51,7 +51,7 @@ var c = i({
51
51
  });
52
52
  },
53
53
  unmount: ({ api: e, widget: t, services: n }) => {
54
- e.reset(t), n.tokens.clear();
54
+ typeof e.remove == "function" ? e.remove(t) : e.reset(t), n.tokens.clear();
55
55
  }
56
56
  });
57
57
  //#endregion
@@ -15,6 +15,7 @@
15
15
  @import "./theme/fields/_select.css";
16
16
  @import "./theme/fields/_combobox.css";
17
17
  @import "./theme/fields/_check-radio.css";
18
+ @import "./theme/fields/_survey-presentations.css";
18
19
  @import "./theme/fields/_address.css";
19
20
  @import "./theme/fields/_address-state.css";
20
21
  @import "./theme/integrations/_payment-modal.css";