@verbb/formie-browser 1.0.7 → 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.
- package/CHANGELOG.md +12 -0
- package/dist/chunks/_survey-presentations-CFsgToRT.js +4 -0
- package/dist/chunks/{api-DztsCJ4r.js → api-C8wyLC-s.js} +184 -150
- package/dist/chunks/{bpoint-2qDxlKD9.js → bpoint-CwSw_p7A.js} +1 -1
- package/dist/chunks/{eway-CImXrB4g.js → eway-B30BMlDp.js} +1 -1
- package/dist/chunks/{go-cardless-Bz7HHtH0.js → go-cardless-BiF3iLel.js} +1 -1
- package/dist/chunks/{mollie-BtnB3KGh.js → mollie-D__SwtcH.js} +1 -1
- package/dist/chunks/{moneris-Bd4vUk8b.js → moneris-KJS1BKx7.js} +1 -1
- package/dist/chunks/{opayo-B-eRIXo-.js → opayo-A_LIkc-v.js} +1 -1
- package/dist/chunks/{paddle-BUFeEU4d.js → paddle-BjbOOb0m.js} +1 -1
- package/dist/chunks/{paypal-8Euw7Hrn.js → paypal-CyjHIV8v.js} +1 -1
- package/dist/chunks/{payway-dV0SzJxy.js → payway-a_cyrr3j.js} +1 -1
- package/dist/chunks/{square-reyJukb7.js → square-Bga6WXHV.js} +1 -1
- package/dist/chunks/{stripe-BC-2PBvY.js → stripe-BlqVocl3.js} +1 -1
- package/dist/chunks/{summary-D3AjxpYN.js → summary-Dks0gXS3.js} +42 -38
- package/dist/chunks/survey-likert-DmJ3klhP.js +20 -0
- package/dist/chunks/survey-rank-DeUenftw.js +127 -0
- package/dist/chunks/survey-rating-BPUYDgBJ.js +88 -0
- package/dist/css/formie-theme.css +1 -0
- package/dist/css/theme/fields/_survey-presentations.css +396 -0
- package/dist/index.js +469 -465
- package/dist/js/contracts/schema.d.ts +5 -0
- package/dist/js/contracts/schema.d.ts.map +1 -1
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/page-client-event.d.ts +8 -4
- package/dist/js/core/page-client-event.d.ts.map +1 -1
- package/dist/js/core/submit-result-state.d.ts.map +1 -1
- package/dist/js/modules/fields/index.d.ts.map +1 -1
- package/dist/js/modules/fields/summary.d.ts.map +1 -1
- package/dist/js/modules/fields/survey-likert.d.ts +3 -0
- package/dist/js/modules/fields/survey-likert.d.ts.map +1 -0
- package/dist/js/modules/fields/survey-rank.d.ts +3 -0
- package/dist/js/modules/fields/survey-rank.d.ts.map +1 -0
- package/dist/js/modules/fields/survey-rating.d.ts +3 -0
- package/dist/js/modules/fields/survey-rating.d.ts.map +1 -0
- package/dist/js/transport/forms-api.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/css/formie-theme.css +1 -0
- package/src/css/theme/fields/_survey-presentations.css +396 -0
- package/src/js/contracts/schema.ts +6 -0
- package/src/js/core/create-formie-client.ts +14 -1
- package/src/js/core/page-client-event.ts +86 -18
- package/src/js/core/submit-result-state.ts +6 -2
- package/src/js/modules/fields/index.ts +3 -0
- package/src/js/modules/fields/summary.ts +17 -3
- package/src/js/modules/fields/survey-likert.ts +50 -0
- package/src/js/modules/fields/survey-rank.ts +385 -0
- package/src/js/modules/fields/survey-rating.ts +182 -0
- package/src/js/transport/forms-api.ts +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as e } from "./event-names-BCI2FLD8.js";
|
|
2
|
-
import { t } from "./api-
|
|
2
|
+
import { t } from "./api-C8wyLC-s.js";
|
|
3
3
|
import { t as n } from "./debug-BV0DvdHx.js";
|
|
4
4
|
import { r } from "./scripts-CbQ7agX3.js";
|
|
5
5
|
//#region src/js/modules/payments/opayo.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as e } from "./event-names-BCI2FLD8.js";
|
|
2
|
-
import { t } from "./api-
|
|
2
|
+
import { t } from "./api-C8wyLC-s.js";
|
|
3
3
|
import { r as n } from "./scripts-CbQ7agX3.js";
|
|
4
4
|
//#region src/js/modules/payments/paddle.ts
|
|
5
5
|
var r = "FORMIE_PADDLE_SCRIPT", i = e("paddle", "initialize"), a = t({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as e } from "./event-names-BCI2FLD8.js";
|
|
2
|
-
import { t } from "./api-
|
|
2
|
+
import { t } from "./api-C8wyLC-s.js";
|
|
3
3
|
import { r as n, t as r } from "./theme-classes-Tv7q7ToE.js";
|
|
4
4
|
import { r as i } from "./scripts-CbQ7agX3.js";
|
|
5
5
|
import { t as a } from "./styles-BfoIZwJp.js";
|
|
@@ -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 = "
|
|
9
|
-
i(
|
|
10
|
-
function
|
|
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
|
|
15
|
-
return {
|
|
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
|
|
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(
|
|
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
|
|
31
|
+
function v(e, n) {
|
|
28
32
|
let i = e.closest("form");
|
|
29
|
-
if (!(i instanceof HTMLFormElement)) return
|
|
30
|
-
let a = !1, s = !0, u = !1,
|
|
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(!!
|
|
50
|
+
b(!!g(e, i).accessToken);
|
|
47
51
|
let x = () => {
|
|
48
|
-
!u || a && !s || (
|
|
52
|
+
!u || a && !s || (m.log("Queueing fetch."), S());
|
|
49
53
|
}, S = r(async () => {
|
|
50
|
-
let t =
|
|
54
|
+
let t = g(e, i);
|
|
51
55
|
if (!v() || !t.accessToken) {
|
|
52
|
-
|
|
56
|
+
m.warn("Missing state for fetch.", t), b(!1);
|
|
53
57
|
return;
|
|
54
58
|
}
|
|
55
|
-
|
|
56
|
-
let n =
|
|
57
|
-
|
|
59
|
+
f += 1;
|
|
60
|
+
let n = f, r = d;
|
|
61
|
+
h?.abort(), h = new AbortController(), b(!0);
|
|
58
62
|
try {
|
|
59
|
-
let c = await
|
|
60
|
-
if (n !==
|
|
61
|
-
let u = y(),
|
|
62
|
-
|
|
63
|
-
let v =
|
|
64
|
-
u && v instanceof HTMLElement ? u.replaceWith(v) : u && (u.innerHTML = c), a = !0, s =
|
|
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:
|
|
70
|
+
dirtyVersion: d,
|
|
67
71
|
requestVersion: n
|
|
68
|
-
}), o(e,
|
|
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
|
-
|
|
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 ===
|
|
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,
|
|
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,
|
|
91
|
+
s = !0, m.log("Submit result received; refreshing."), x();
|
|
88
92
|
}, E = () => {
|
|
89
|
-
s = !0,
|
|
93
|
+
s = !0, m.log("Page navigation received; refreshing."), x();
|
|
90
94
|
}, D = new IntersectionObserver((t) => {
|
|
91
|
-
u = !!t[0]?.isIntersecting, u && (
|
|
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
|
-
|
|
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:
|
|
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) =>
|
|
106
|
-
return
|
|
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
|
-
}),
|
|
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 {
|
|
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 };
|
|
@@ -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";
|