@sprig-technologies/sprig-browser 2.39.3 → 2.39.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/conversational-ui-loLw6bPe.cjs +1 -0
- package/dist/conversational-ui-sHjWeSW0.js +589 -0
- package/dist/core-BAdMqSxY.js +982 -0
- package/dist/core-DGzfRh0z.cjs +12 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +16 -0
- package/dist/core.js +2 -2
- package/dist/{getAttributedUrl-CKXj5eVU.js → getAttributedUrl-5g_EQiGQ.js} +306 -297
- package/dist/{getAttributedUrl-Wrb2IVbi.cjs → getAttributedUrl-DmbhGoBX.cjs} +5 -5
- package/dist/index-DmjRxajT.cjs +1 -0
- package/dist/index-hWjFkOYS.js +688 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/index.js +2 -2
- package/dist/{metricsReporter-1Oozsgva.js → metricsReporter-Chz3rKxD.js} +1 -1
- package/dist/{metricsReporter-CXdAqZlB.cjs → metricsReporter-DOjBAl52.cjs} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +1 -1
- package/dist/view-BE-QqXV6.cjs +1 -0
- package/dist/{view-BTPuuKmm.js → view-CKY1RqAy.js} +490 -480
- package/package.json +1 -1
- package/dist/conversational-ui-BBEwlRyA.js +0 -586
- package/dist/conversational-ui-p-aTqz70.cjs +0 -1
- package/dist/core-D7GY8Q1p.cjs +0 -12
- package/dist/core-fXpU4mUJ.js +0 -963
- package/dist/index-2SxBb1Na.cjs +0 -1
- package/dist/index-C4JVn6IQ.js +0 -678
- package/dist/view-DrHm3QYY.cjs +0 -1
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
import { a as G, h as V, u as e, c as B, d as ue, g as X, f as De, F as be, e as me, _ as ee, T as Ie, A as nr, p as ne, i as ir, l as sr, q as ar, M as oe, m as lr, n as or, o as dr, r as cr, j as ur, k as pr } from "./view-CKY1RqAy.js";
|
|
2
|
+
import { t as se } from "./metricsReporter-Chz3rKxD.js";
|
|
3
|
+
import { a as Ne, D as Re, g as He, A as mr } from "./core-BAdMqSxY.js";
|
|
4
|
+
import { c as re, a as ie, H as Se, M as pe, O as ve, B as z, Q as ce, L as ye, b as xe, S as gr, u as hr, g as br, P as vr, p as fr, v as yr, R as J, d as Sr, s as kr } from "./getAttributedUrl-5g_EQiGQ.js";
|
|
5
|
+
const xr = ({ className: i, message: s, next: c, properties: r, questionId: t, type: l }) => {
|
|
6
|
+
const { useMobileStyling: h, border: v, isLongFormSurvey: o, focusedQuestionId: b } = G((p) => ({ useMobileStyling: p.useMobileStyling, border: p.border, isLongFormSurvey: se(p.studyType), focusedQuestionId: p.focusedQuestionId })), [a, m] = V(!1), [u, f] = V(""), [d, g] = V(!1), k = o && b === t, D = r == null ? void 0 : r.collectName, C = (r == null ? void 0 : r.nameLabelText) || "Full Name", L = (r == null ? void 0 : r.consentText) || "I agree to the stated conditions", P = (r == null ? void 0 : r.submitButtonText) || "Submit", I = !!u.trim(), M = a && (!D || I), q = (p, y = !1) => {
|
|
7
|
+
p.preventDefault(), p.stopPropagation();
|
|
8
|
+
let N = null;
|
|
9
|
+
if (!y) {
|
|
10
|
+
if (!M) return void g(!0);
|
|
11
|
+
N = { submitted: !0 }, D && (N.name = u);
|
|
12
|
+
}
|
|
13
|
+
c({ value: N, questionId: t, type: l }, M);
|
|
14
|
+
}, x = (p) => {
|
|
15
|
+
p.preventDefault(), p.stopPropagation(), f(p.currentTarget.value);
|
|
16
|
+
}, _ = (p) => {
|
|
17
|
+
p.currentTarget.style.borderColor = d && !I ? Ne : v;
|
|
18
|
+
}, E = (p) => {
|
|
19
|
+
p.currentTarget.style.borderColor = d && !I ? Ne : Re;
|
|
20
|
+
}, n = () => e(ce, { children: [e("div", { className: "sprig-stretch", children: [e(ve, { allowTextEntry: !1, border: v, error: d && !a, id: "consent", isRadio: !1, isSelected: a, label: L, onUserInputChanged: ({ selected: p }) => {
|
|
21
|
+
p !== a && m(!a);
|
|
22
|
+
}, useMobileStyling: h }), D && e("input", { "aria-label": C, "aria-placeholder": C, className: B(X("ul-consent-legal__name-input", h)), "data-gramm": "false", maxLength: 250, name: "name", onBlur: E, onFocus: _, onInput: x, placeholder: C, style: d && !I ? { borderColor: Ne } : {}, tabIndex: 0, value: u })] }), e("div", { className: "ul-card__button-wrapper ul-card-vertical__button-wrapper", children: [e(z, { className: M ? "" : "sprig-button-disabled", onClick: q, children: P }), r.required === !1 && !o && e("button", { className: "ul-card-skip__button", onClick: (p) => q(p, !0), children: De(r) })] })] });
|
|
23
|
+
return e("div", { className: B(i, o && !k && "ul-card--unfocused", "ul-card__consent-legal", "fade-in-transition"), children: [e(re, { isRequired: o && (r == null ? void 0 : r.required), message: s, properties: { questionHtml: r.questionHtml } }), e(ue, { children: [r != null && r.richTextBody ? e(ie, { children: e(Se, { className: "ul-rich-text-body", html: r.richTextBody, id: "ul-card__consent-legal-body-container" }) }) : null, e(pe, { properties: r, defaultBody: n, embeddedType: "pdf" })] })] }, t);
|
|
24
|
+
}, Ir = ({ activeValue: i, border: s, icon: c, isPressed: r, onSubmit: t, range: l, scaleLabelType: h, selectedValue: v, setSelectedValue: o, setActiveValue: b, setIsPressed: a, useMobileStyling: m, value: u, viewDocument: f }) => {
|
|
25
|
+
const { isLongFormSurvey: d, enableCspTrustedTypes: g } = G((_) => ({ isLongFormSurvey: se(_.studyType), enableCspTrustedTypes: _.enableCspTrustedTypes })), k = `option-${u}`, D = h === "number", C = h === "star", L = h === "smiley", P = D && u === i || u === v, [I, M] = (() => {
|
|
26
|
+
const _ = C && v !== null && u <= v;
|
|
27
|
+
return C && u <= i || L && u === i || _ || u === i || u === v ? [s, r || _ || u === v ? 1 : 0.3] : ["", 1];
|
|
28
|
+
})(), q = be(() => {
|
|
29
|
+
const _ = { borderColor: P ? I : "", fillOpacity: P ? "" : M, zIndex: P ? 3 : "auto", color: v === u ? "#fff" : "" };
|
|
30
|
+
return D ? { ..._, backgroundColor: v === u ? I : "" } : { ..._, color: C || L || v === u ? I : "" };
|
|
31
|
+
}, [P, I, M, v, u, D, C, L]), x = be(() => He((({ icon: _, scaleLabelType: E, value: n, selectedValue: p }) => {
|
|
32
|
+
if (E === "smiley" && n === p) {
|
|
33
|
+
let y = 0;
|
|
34
|
+
return _.replace(/black/g, () => ++y == 1 ? "black" : "white");
|
|
35
|
+
}
|
|
36
|
+
return _;
|
|
37
|
+
})({ icon: c, scaleLabelType: h, value: u, selectedValue: v }), g), [g, c, h, v, u]);
|
|
38
|
+
return e("button", { "aria-label": D ? void 0 : String(u), className: (() => {
|
|
39
|
+
switch (h) {
|
|
40
|
+
case "star":
|
|
41
|
+
return B(X("likert-star", m), X(`likert-star-${u}`, m));
|
|
42
|
+
case "smiley":
|
|
43
|
+
return B(X("likert-smiley", m), X(`likert-smiley-${u}`, m));
|
|
44
|
+
default:
|
|
45
|
+
return u === l ? B(X("likert-number", m), X(`likert-number-${u}`, m), X("likert-last-option", m)) : B(X("likert-number", m), X(`likert-number-${u}`, m));
|
|
46
|
+
}
|
|
47
|
+
})(), dangerouslySetInnerHTML: { __html: x }, id: k, onClick: (_) => {
|
|
48
|
+
d && (_.preventDefault(), _.stopPropagation(), o(u)), t();
|
|
49
|
+
}, onKeyDown: (_) => {
|
|
50
|
+
var p, y;
|
|
51
|
+
const E = f.querySelectorAll(`.likert-${h ?? "number"}`), n = u - 1;
|
|
52
|
+
_.key === "ArrowRight" ? (p = E[n + 1]) == null || p.focus() : _.key === "ArrowLeft" ? (y = E[n - 1]) == null || y.focus() : _.key !== "Enter" && _.key !== " " || (d && (_.preventDefault(), _.stopPropagation(), o(u)), t());
|
|
53
|
+
}, onPointerDown: () => a(!0), onPointerEnter: () => b(u), onPointerLeave: () => {
|
|
54
|
+
b(-1), a(!1);
|
|
55
|
+
}, style: q, tabIndex: 0 });
|
|
56
|
+
}, _r = ({ className: i, labels: s, message: c, next: r, properties: t, questionId: l, type: h }) => {
|
|
57
|
+
const { border: v, useMobileStyling: o, viewDocument: b, isLongFormSurvey: a, focusedQuestionId: m } = G((y) => ({ border: y.border, useMobileStyling: y.useMobileStyling, viewDocument: y.viewDocument, isLongFormSurvey: se(y.studyType), focusedQuestionId: y.focusedQuestionId })), [u, f] = V(-1), [d, g] = V(!1), [k, D] = V(null), C = a && m === l, L = s && s.left, P = s && s.right;
|
|
58
|
+
let I;
|
|
59
|
+
const { range: M, scaleLabelType: q, ratingIcons: x } = t;
|
|
60
|
+
M && (I = Number(M));
|
|
61
|
+
const _ = I || 5, E = (y) => {
|
|
62
|
+
var N, U;
|
|
63
|
+
switch (q) {
|
|
64
|
+
case "star":
|
|
65
|
+
return (N = x[0]) == null ? void 0 : N.svg;
|
|
66
|
+
case "smiley":
|
|
67
|
+
return (U = x[y]) == null ? void 0 : U.svg;
|
|
68
|
+
default:
|
|
69
|
+
return String(y + 1);
|
|
70
|
+
}
|
|
71
|
+
}, n = [...Array(_)].map((y, N) => {
|
|
72
|
+
const U = N + 1;
|
|
73
|
+
return e(Ir, { activeValue: u, border: v, icon: E(N), isPressed: d, onSubmit: () => r({ value: U, questionId: l, type: h }, !0), range: _, scaleLabelType: q, selectedValue: k, setActiveValue: f, setIsPressed: g, setSelectedValue: D, useMobileStyling: o, value: U, viewDocument: b }, N);
|
|
74
|
+
}), p = (y) => {
|
|
75
|
+
y.preventDefault(), y.stopPropagation(), r({ value: null, questionId: l, type: h }, !0);
|
|
76
|
+
};
|
|
77
|
+
return e("form", { className: B(i, "ul-card--likert", "fade-in-transition", a && !C && "ul-card--unfocused"), children: [e(re, { isRequired: a && (t == null ? void 0 : t.required), message: c, properties: t }), e(pe, { properties: t, defaultBody: () => e(ue, { children: [e(ie, { children: [e("div", { "aria-label": `Rating (1 - ${_})`, className: "ul-card--likert__numbers", role: "radiogroup", children: n }), e("div", { className: "ul-card--likert__labels", children: [e("span", { children: L }), e("span", { children: P })] })] }), !t.required && !a && e(ce, { children: e("div", { className: "ul-vertical-centered-container", children: e(z, { onClick: p, children: me(t) }) }) })] }) })] }, l);
|
|
78
|
+
}, Ge = (i) => i && (i.scrollHeight > i.offsetHeight ? i : Ge(i.parentElement)), Tr = (i) => {
|
|
79
|
+
if (!i || !((c) => c instanceof HTMLElement)(i)) return 0;
|
|
80
|
+
const s = getComputedStyle(i);
|
|
81
|
+
return parseFloat(s.marginTop) + parseFloat(s.marginBottom) + (parseFloat(s.borderTopWidth) + parseFloat(s.borderBottomWidth));
|
|
82
|
+
}, Cr = ({ columns: i, onSelect: s, options: c, selectedOptions: r }) => {
|
|
83
|
+
const t = ee([]), { border: l, useMobileStyling: h } = G((u) => ({ border: u.border, useMobileStyling: u.useMobileStyling })), v = c.findIndex((u) => r[u.id] === null), [o, b] = V(v), a = Ie((u, f) => {
|
|
84
|
+
s(u, f);
|
|
85
|
+
const d = o + 1, g = c[d];
|
|
86
|
+
if (g && r[g.id] === null) {
|
|
87
|
+
b(d);
|
|
88
|
+
const k = t.current[o];
|
|
89
|
+
if (k != null && k.firstElementChild) {
|
|
90
|
+
const D = Ge(k), C = k.firstElementChild, L = Tr(k) + C.clientHeight;
|
|
91
|
+
D == null || D.scrollTo(0, k.offsetTop + L);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, [s, c, r, o]), m = Ie((u, f) => {
|
|
95
|
+
const d = o === u;
|
|
96
|
+
return e(nr, { animate: !0, header: f.label, isOpen: d, onClick: () => {
|
|
97
|
+
var g;
|
|
98
|
+
return b(d && !((g = window.UserLeap) != null && g.isMobileSDK) ? -1 : u);
|
|
99
|
+
}, ref: (g) => {
|
|
100
|
+
g && (t.current[u] = g);
|
|
101
|
+
}, showHeaderCheck: r[f.id] !== null, children: e("div", { style: { paddingTop: "12px" }, children: i.map((g) => e(ve, { allowTextEntry: !1, ariaLabel: `${f.label}-${g.label}`, border: l, error: !1, id: `${f.id}-${g.value}`, isRadio: !0, isSelected: r[f.id] === g.value, label: g.label, onUserInputChanged: () => a(f.id, g.value), useMobileStyling: h }, g.label)) }) }, f.id);
|
|
102
|
+
}, [l, i, o, a, r, h]);
|
|
103
|
+
return e("div", { children: c.map((u, f) => m(f, u)) });
|
|
104
|
+
}, Nr = ({ columns: i, onSelect: s, options: c, selectedOptions: r }) => {
|
|
105
|
+
const { border: t, useMobileStyling: l, isLongFormSurvey: h } = G((d) => ({ border: d.border, useMobileStyling: d.useMobileStyling, isLongFormSurvey: se(d.studyType) })), v = c.length, o = i.length, b = ee(null), [a, m] = V(!1), [u, f] = V(!1);
|
|
106
|
+
return ne(() => {
|
|
107
|
+
const d = b.current, g = new ResizeObserver((k) => {
|
|
108
|
+
window.requestAnimationFrame(() => {
|
|
109
|
+
d && (m(Math.round(k[0].contentRect.width) < d.scrollWidth), f(Math.round(k[0].contentRect.width) < d.scrollWidth));
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
return d && g.observe(d), () => {
|
|
113
|
+
d && g.unobserve(d);
|
|
114
|
+
};
|
|
115
|
+
}, []), e("div", { className: "ul-card--matrix_question_container", children: [e("div", { className: B("ul-card--matrix_container", a && "ul-matrix-scroll-gradient"), onScroll: () => {
|
|
116
|
+
(() => {
|
|
117
|
+
const d = b.current;
|
|
118
|
+
d && m(d.clientWidth + Math.abs(d.scrollLeft) < d.scrollWidth);
|
|
119
|
+
})();
|
|
120
|
+
}, ref: b, children: e("div", { className: B(h && "ul-card--matrix_grid_longform", "ul-card--matrix_grid"), style: `--numColumns: ${o}; --numRows: ${v + 1};`, children: [e("div", {}), " ", i.map((d) => e("div", { className: "ul-matrix-column-label", children: d.label }, d.label)), c.map((d) => e(ue, { children: [e("div", { "aria-label": d.label, className: "ul-matrix-row-label", children: d.label }, d.label), e("div", { className: "ul-matrix-row-options", role: "radiogroup", children: i.map((g, k) => e("div", { className: B("ul-matrix-option-wrapper", k === o - 1 && "ul-matrix-last-option"), children: e(ve, { allowTextEntry: !1, ariaLabel: `${d.label}-${g.label}`, border: t, choiceStyle: { background: "transparent", border: "none", marginBottom: "0", padding: "0" }, error: !1, id: `${d.id}-${g.value}`, isRadio: !0, isSelected: r[d.id] === g.value, onUserInputChanged: () => s(d.id, g.value), useMobileStyling: l }) }, g.value)) })] }))] }) }), (a || u) && e("button", { className: u && !a ? "ul-matrix-scroll-arrow left" : "ul-matrix-scroll-arrow", onClick: u && !a ? (d) => {
|
|
121
|
+
d.preventDefault();
|
|
122
|
+
const g = b.current;
|
|
123
|
+
if (g) {
|
|
124
|
+
const k = getComputedStyle(g).direction === "rtl";
|
|
125
|
+
g.scrollTo({ left: k ? g.scrollWidth - g.clientWidth : 0, behavior: "smooth" });
|
|
126
|
+
}
|
|
127
|
+
} : (d) => {
|
|
128
|
+
d.preventDefault();
|
|
129
|
+
const g = b.current;
|
|
130
|
+
if (g) {
|
|
131
|
+
const k = getComputedStyle(g).direction === "rtl";
|
|
132
|
+
g.scrollTo({ left: k ? g.clientWidth - g.scrollWidth : g.scrollWidth, behavior: "smooth" });
|
|
133
|
+
}
|
|
134
|
+
}, children: e(u && !a ? wr : qr, {}) })] });
|
|
135
|
+
}, wr = () => e("svg", { fill: "currentColor", height: "32", transform: "matrix(-1,0,0,1,0,0)", version: "1.1", viewBox: "0 0 256 256", width: "32", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" }) }), qr = () => e("svg", { fill: "currentColor", height: "32", viewBox: "0 0 256 256", width: "32", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" }) }), Lr = ({ className: i, message: s, next: c, options: r, properties: t, questionId: l, type: h, showIndividualSubmit: v = !1, onSubmitButtonClick: o }) => {
|
|
136
|
+
const { useMobileStyling: b, isLongFormSurvey: a, focusedQuestionId: m, setFocusedQuestionId: u } = G((q) => ({ useMobileStyling: q.useMobileStyling, isLongFormSurvey: se(q.studyType), focusedQuestionId: q.focusedQuestionId, setFocusedQuestionId: q.setFocusedQuestionId })), f = t.matrixColumn, d = t.required, g = a && m === l, k = (q) => {
|
|
137
|
+
q.preventDefault(), q.stopPropagation(), c({ value: C, questionId: l, type: h }, !0), o && o();
|
|
138
|
+
}, D = r.reduce((q, x) => (q[x.id] = null, q), {}), [C, L] = V(D), P = (q) => d && Object.values(q).every((x) => x == null), I = (q, x) => {
|
|
139
|
+
a && c({ value: { ...C, [q]: x }, questionId: l, type: h }, !P({ ...C, [q]: x })), L((_) => ({ ..._, [q]: x }));
|
|
140
|
+
}, M = t.displayMatrixAsAccordion || b;
|
|
141
|
+
return e("form", { className: B(i, !a && "ul-card__matrix", "fade-in-transition", a && !g && "ul-card--unfocused"), id: "text-form", onClick: () => {
|
|
142
|
+
g && u(l);
|
|
143
|
+
}, onSubmit: k, children: [e(re, { message: s, properties: t, isRequired: a && (t == null ? void 0 : t.required) }), e(pe, { properties: t, defaultBody: () => e(ue, { children: [e(ie, { children: [e(M ? Cr : Nr, { columns: f, onSelect: I, options: r, selectedOptions: C }), v && e(ye, { handleSubmit: k, isSubmitDisabled: P(C) })] }), !a && e(ce, { children: e("div", { className: "ul-card__button-wrapper", children: e(z, { disabled: P(C), children: me(t) }) }) })] }) })] }, l);
|
|
144
|
+
}, Ve = ({ className: i, message: s, onSubmit: c, options: r = [], properties: t, questionId: l, type: h, showIndividualSubmit: v = !1, onSubmitButtonClick: o }) => {
|
|
145
|
+
const { border: b, useMobileStyling: a, isLongFormSurvey: m, focusedQuestionId: u, setFocusedQuestionId: f } = G((S) => ({ border: S.border, useMobileStyling: S.useMobileStyling, isLongFormSurvey: se(S.studyType), focusedQuestionId: S.focusedQuestionId, setFocusedQuestionId: S.setFocusedQuestionId })), d = m && u === l, g = r.reduce((S, w) => (S[w.id] = { isSelected: !1 }, S), {}), [k, D] = V(g), C = h === "multiplechoice", L = t.required, P = r.find((S) => {
|
|
146
|
+
var w;
|
|
147
|
+
return (w = S.optionProperties) == null ? void 0 : w.noneOfTheAbove;
|
|
148
|
+
}), I = (S) => Object.entries(S).some(([w, F]) => {
|
|
149
|
+
var W;
|
|
150
|
+
const j = r.find((Y) => `${Y.id}` === w), $ = F.userText === void 0 || F.userText.trim() === "";
|
|
151
|
+
return ((W = j == null ? void 0 : j.optionProperties) == null ? void 0 : W.allowsTextEntry) && $ && F.isSelected;
|
|
152
|
+
}), M = (S) => Object.values(S).filter((w) => w.isSelected).length, q = t.minSelect && t.minSelect > 0 && t.maxSelectMode === xe.Range && M(k) < t.minSelect && (L || M(k) > 0), x = (S) => I(S) || L && !M(S) || !((w) => {
|
|
153
|
+
const { minSelect: F = 0, maxSelect: j = 1 / 0, maxSelectMode: $ } = t, W = M(w);
|
|
154
|
+
switch ($) {
|
|
155
|
+
case xe.Maximum:
|
|
156
|
+
return W <= j;
|
|
157
|
+
case xe.Range:
|
|
158
|
+
return W === 0 || W >= F;
|
|
159
|
+
default:
|
|
160
|
+
return !0;
|
|
161
|
+
}
|
|
162
|
+
})(S), _ = Object.entries(k).some(([S, w]) => {
|
|
163
|
+
var F, j;
|
|
164
|
+
return w.isSelected && ((j = (F = r.find(($) => `${$.id}` === S)) == null ? void 0 : F.optionProperties) == null ? void 0 : j.allowsTextEntry);
|
|
165
|
+
}), E = v && (!C || _), n = (S) => {
|
|
166
|
+
U(S.id, S.selected, S.userText, S.noneOfTheAbove), S.selected && m && !C && !d && f(l);
|
|
167
|
+
}, p = (S) => {
|
|
168
|
+
var w;
|
|
169
|
+
return (t == null ? void 0 : t.maxSelectMode) !== xe.Unlimited && M(k) === (t == null ? void 0 : t.maxSelect) && !((w = k[S]) != null && w.isSelected);
|
|
170
|
+
}, y = r.map(({ id: S, label: w, value: F, optionProperties: j }) => {
|
|
171
|
+
var te, le;
|
|
172
|
+
const $ = `${S}`, { allowsTextEntry: W, noneOfTheAbove: Y } = { allowsTextEntry: !1, noneOfTheAbove: !1, ...j };
|
|
173
|
+
return e(ve, { allowTextEntry: W, border: b, disabled: p($), error: (K = k, I(K)), id: $, isRadio: C, isSelected: !!((te = k[$]) != null && te.isSelected), label: w, noneOfTheAbove: Y, onUserInputChanged: n, promptText: "Please specify", text: (le = k[S]) == null ? void 0 : le.userText, useMobileStyling: a, value: F }, $);
|
|
174
|
+
var K;
|
|
175
|
+
}), N = (S) => {
|
|
176
|
+
S.preventDefault(), S.stopPropagation(), c(k, !0), o && o();
|
|
177
|
+
}, U = (S, w, F, j) => {
|
|
178
|
+
const $ = Object.assign({}, k);
|
|
179
|
+
if ((C || j) && w) for (const K of Object.values($)) K.isSelected = !1, delete K.userText;
|
|
180
|
+
else P && !j && k[P.id].isSelected && ($[P.id].isSelected = !1);
|
|
181
|
+
$[S] = { isSelected: w, userText: F };
|
|
182
|
+
const W = C && Object.entries($).some(([K, te]) => {
|
|
183
|
+
var le, fe;
|
|
184
|
+
return te.isSelected && ((fe = (le = r.find((ke) => `${ke.id}` === K)) == null ? void 0 : le.optionProperties) == null ? void 0 : fe.allowsTextEntry);
|
|
185
|
+
}), Y = !x($);
|
|
186
|
+
m && (c($, Y), C && !W && Y && o && o()), D($);
|
|
187
|
+
};
|
|
188
|
+
return e("form", { className: B(i, "ul-card--multiple", "fade-in-transition", m && !d && "ul-card--unfocused"), id: "text-form", onClick: h === "multipleselect" ? () => {
|
|
189
|
+
m && u !== l && h === "multipleselect" && f(l);
|
|
190
|
+
} : void 0, onSubmit: N, children: [e(re, { isRequired: m && (t == null ? void 0 : t.required), message: s, properties: t }), e(pe, { properties: t, defaultBody: () => e(ue, { children: [e(ie, { children: [t.isDropdown ? e(gr, { disabledOptions: r.filter((S) => p(S.id)), dropdownFooter: q ? e("div", { className: "ul-card__min-select-counter", style: { marginLeft: "16px" }, children: [M(k), "/", t.minSelect] }) : void 0, isMultiSelect: !C, multiselectText: t.dropdownMultiselectedText ?? "choices selected", onChange: (S) => {
|
|
191
|
+
const w = { ...k };
|
|
192
|
+
for (const F of r) S.includes(F) ? w[F.id].isSelected = !0 : w[F.id].isSelected = !1;
|
|
193
|
+
m && c(w, !x(w)), D(w);
|
|
194
|
+
}, options: r, placeholderText: t.dropdownPlaceholderText ?? (C ? "Select choice" : "Select choice(s)"), value: r.filter((S) => k[S.id].isSelected) }) : e("div", { className: B(X("ul-card__choices", a)), role: C ? "radiogroup" : "group", children: [y, !!q && e("div", { className: "ul-card__min-select-counter", children: [M(k), "/", t.minSelect] })] }), E && e(ye, { handleSubmit: N, isSubmitDisabled: x(k) })] }), !m && e(ce, { children: e("div", { className: "ul-card__button-wrapper", children: e(z, { disabled: x(k), onClick: N, children: me(t) }) }) })] }) })] }, l);
|
|
195
|
+
}, Pr = (i) => {
|
|
196
|
+
const { questionId: s, type: c, next: r, options: t } = i, { setFocusedQuestionId: l } = G((h) => ({ setFocusedQuestionId: h.setFocusedQuestionId }));
|
|
197
|
+
return e(Ve, { ...i, onSubmit: (h, v) => {
|
|
198
|
+
var f;
|
|
199
|
+
const o = Object.entries(h).find(([, d]) => d.isSelected) || [void 0, void 0], [b, a] = o, m = t.find((d) => `${d.id}` === b);
|
|
200
|
+
!((f = m == null ? void 0 : m.optionProperties) != null && f.allowsTextEntry) || a != null && a.userText && a.userText.trim() !== "" || l(s);
|
|
201
|
+
const u = a != null && a.userText ? { [b]: { userText: a.userText } } : null;
|
|
202
|
+
r({ value: m && b ? { [b]: m.value } : {}, secondaryValue: u, questionId: s, type: c }, v);
|
|
203
|
+
} });
|
|
204
|
+
}, Dr = (i) => {
|
|
205
|
+
const { questionId: s, type: c, next: r } = i;
|
|
206
|
+
return e(Ve, { ...i, onSubmit: (t, l) => {
|
|
207
|
+
const h = Object.entries(t).reduce((o, [b, a]) => (o[b] = a.isSelected, o), {}), v = Object.entries(t).reduce((o, [b, a]) => {
|
|
208
|
+
if (!a.userText) return o;
|
|
209
|
+
const m = o || {};
|
|
210
|
+
return m[b] = { userText: a.userText }, m;
|
|
211
|
+
}, null);
|
|
212
|
+
r({ value: h, secondaryValue: v, questionId: s, type: c }, l);
|
|
213
|
+
} });
|
|
214
|
+
}, Rr = ({ className: i, labels: s, message: c, properties: r, next: t, questionId: l, type: h }) => {
|
|
215
|
+
const [v, o] = V(null), { border: b, useMobileStyling: a, viewDocument: m, isLongFormSurvey: u, focusedQuestionId: f } = G((L) => ({ border: L.border, useMobileStyling: L.useMobileStyling, viewDocument: L.viewDocument, isLongFormSurvey: se(L.studyType), focusedQuestionId: L.focusedQuestionId })), d = u && f === l, g = s && s.left, k = s && s.right, D = [...Array(11)].map((L, P) => e("button", { className: B(X("nps-number", a), X(`nps-number-${P}`, a)), id: `option-${P}`, onClick: (I) => {
|
|
216
|
+
u && (I.preventDefault(), I.stopPropagation(), o(P)), t({ value: P, questionId: l, type: h }, !0);
|
|
217
|
+
}, onKeyDown: (I) => {
|
|
218
|
+
var q, x;
|
|
219
|
+
const M = m.querySelectorAll("button.nps-number");
|
|
220
|
+
I.key === "ArrowRight" ? (q = M[P + 1]) == null || q.focus() : I.key === "ArrowLeft" ? (x = M[P - 1]) == null || x.focus() : I.key !== "Enter" && I.key !== " " || (u && (I.preventDefault(), I.stopPropagation(), o(P)), t({ value: P, questionId: l, type: h }, !0));
|
|
221
|
+
}, onPointerDown: (I) => {
|
|
222
|
+
I.currentTarget.style.zIndex = "2", I.currentTarget.style.borderColor = b;
|
|
223
|
+
}, onPointerLeave: (I) => {
|
|
224
|
+
I.currentTarget.style.zIndex = "auto", I.currentTarget.style.borderColor = Re;
|
|
225
|
+
}, style: v === P ? { backgroundColor: b, color: "#fff" } : void 0, tabIndex: 0, children: P }, P)), C = (L) => {
|
|
226
|
+
L.preventDefault(), L.stopPropagation(), t({ value: null, questionId: l, type: h }, !0);
|
|
227
|
+
};
|
|
228
|
+
return e("form", { className: B(i, "ul-card--nps", "fade-in-transition", u && !d && "ul-card--unfocused"), children: [e(re, { isRequired: u && (r == null ? void 0 : r.required), message: c, properties: r }), e(pe, { properties: r, defaultBody: () => e(ue, { children: [e(ie, { children: [e("div", { className: "ul-card--nps__numbers", children: D }), e("div", { className: "ul-card--nps__labels", children: [e("span", { children: g }), e("span", { children: k })] })] }), !r.required && !u && e(ce, { children: e("div", { className: "ul-vertical-centered-container", children: e(z, { onClick: C, children: me(r) }) }) })] }) })] }, l);
|
|
229
|
+
}, Mr = ({ className: i, message: s, next: c, properties: r, questionId: t, type: l, showIndividualSubmit: h = !1, onSubmitButtonClick: v }) => {
|
|
230
|
+
const { border: o, useMobileStyling: b, update: a, isLongFormSurvey: m, focusedQuestionId: u, setFocusedQuestionId: f, isPreview: d } = G((n) => ({ border: n.border, useMobileStyling: n.useMobileStyling, update: n.update, isLongFormSurvey: se(n.studyType), focusedQuestionId: n.focusedQuestionId, setFocusedQuestionId: n.setFocusedQuestionId, isPreview: n.isPreview })), [g, k] = V(""), D = ee(null), C = m && u === t;
|
|
231
|
+
ne(() => {
|
|
232
|
+
var n, p;
|
|
233
|
+
m && !d && (C ? (n = D.current) == null || n.focus() : (p = D.current) == null || p.blur());
|
|
234
|
+
}, [m, C, d]);
|
|
235
|
+
const L = g.trim(), P = r.required === !0 && !L, I = hr(D, () => a()), M = (n) => {
|
|
236
|
+
const { value: p } = n.currentTarget;
|
|
237
|
+
if (I(), n.preventDefault(), n.stopPropagation(), k(p), m) {
|
|
238
|
+
const y = p.trim().length > 0;
|
|
239
|
+
c({ value: p, questionId: t, type: l }, y);
|
|
240
|
+
}
|
|
241
|
+
}, q = (n) => {
|
|
242
|
+
n.preventDefault(), n.stopPropagation(), c({ value: g, questionId: t, type: l }, !r.required || L.length > 0), v && v();
|
|
243
|
+
}, x = r && r.openTextPlaceholder ? r.openTextPlaceholder : "", _ = (n) => {
|
|
244
|
+
n.currentTarget.style.borderColor = o, f(t);
|
|
245
|
+
}, E = (n) => {
|
|
246
|
+
n.currentTarget.style.borderColor = Re;
|
|
247
|
+
};
|
|
248
|
+
return e("form", { className: B(i, "ul-card-text", "fade-in-transition", m && !C && "ul-card--unfocused"), id: "text-form", onClick: () => {
|
|
249
|
+
m && u !== t && f(t);
|
|
250
|
+
}, children: [e(re, { isRequired: m && (r == null ? void 0 : r.required), message: s, properties: r }), e(pe, { defaultBody: () => e("div", { className: "ul-card-text", children: e(ie, { children: [e("div", { className: "ul-card-text__container", children: e("textarea", { "aria-describedby": "ul-caption", "aria-labelledby": "ul-question", "aria-multiline": "true", "aria-placeholder": x, className: B(X("ul-card-text__input", b)), "data-gramm": "false", maxLength: 5e3, name: "text", onBlur: E, onChange: M, onFocus: _, placeholder: x, ref: D, role: "textbox", tabIndex: 0 }) }), r.footerHtml && e(Se, { className: "footer", html: r.footerHtml }), h && e(ye, { handleSubmit: q, isSubmitDisabled: P }), e(ce, { children: !m && e(z, { disabled: P, onClick: q, children: me(r) }) })] }) }), properties: r })] }, t);
|
|
251
|
+
}, qe = 1, je = 2, Ze = 3, _e = (i) => i.type === "av_permission", Be = (i) => i.type === "screen_permission", We = (i, s) => i === void 0 ? qe : i ? ((c, r) => !(_e(r) ? r.permissionDescriptors : []).includes("camera") || c.getVideoTracks().length > 0)(i, s) ? Ze : qe : je, Fe = { avStream: null, currentPage: null, mediaRecordingUids: null, nextQuestion: () => {
|
|
252
|
+
}, passthroughData: void 0, recordingMediaTypes: void 0, screenPermissionRequested: !1, type: void 0 }, de = ir((i) => ({ ...Fe, reset: () => {
|
|
253
|
+
i(Fe);
|
|
254
|
+
}, updatePage: (s) => {
|
|
255
|
+
i(s);
|
|
256
|
+
} }));
|
|
257
|
+
function Le({ currentPage: i, pages: s }) {
|
|
258
|
+
const { avStream: c, recordingMediaTypes: r, updatePage: t } = de.getState(), { recorderEventEmitter: l } = G.getState();
|
|
259
|
+
l.emit("av.permission", { "permission.descriptors": i.permissionDescriptors, "stream.ready": (h, v) => {
|
|
260
|
+
if (c === h) return;
|
|
261
|
+
let o = i;
|
|
262
|
+
if (h && !i.permissionDescriptors.includes("camera")) {
|
|
263
|
+
const b = s.indexOf(i), a = v != null && v.active ? b + 2 : b + 1;
|
|
264
|
+
v != null && v.active && r && l.emit("begin.recording", { "recording.media.types": r, "start.recording.callback": (m) => t({ mediaRecordingUids: m }) }), o = s[a];
|
|
265
|
+
}
|
|
266
|
+
t({ currentPage: o, avStream: h });
|
|
267
|
+
} });
|
|
268
|
+
}
|
|
269
|
+
function Pe({ status: i }) {
|
|
270
|
+
const { nextQuestion: s, passthroughData: c, mediaRecordingUids: r, reset: t } = de.getState(), { recorderEventEmitter: l, handleUploadUpdate: h, index: v } = G.getState(), o = { value: { taskStatus: i }, type: "recordedtask", questionId: (c == null ? void 0 : c.questionId) || 1 };
|
|
271
|
+
c && l.emit("finish.task", { "begin.callback": (b) => {
|
|
272
|
+
h({ mediaRecordingUid: b, isSubmitted: !0, progressPct: 0, isComplete: !1 });
|
|
273
|
+
}, "progress.callback": (b, a) => {
|
|
274
|
+
h({ mediaRecordingUid: b, progressPct: a.detail, isSubmitted: !1, isComplete: !1 });
|
|
275
|
+
}, "upload.callback": (b) => {
|
|
276
|
+
b && h({ mediaRecordingUid: b, isComplete: !0, isSubmitted: !0, progressPct: 100 });
|
|
277
|
+
}, "passthrough.data": c, "current.index": v, "task.response": o, "task.complete.callback": (b) => {
|
|
278
|
+
o.value.taskDurationMillisecond = b, r && (o.value.mediaRecordingUids = r), t(), s(o);
|
|
279
|
+
} });
|
|
280
|
+
}
|
|
281
|
+
function Me({ pages: i, setIsRequestingPermission: s }) {
|
|
282
|
+
const { recorderEventEmitter: c, eventEmitFn: r } = G.getState(), { updatePage: t, currentPage: l, recordingMediaTypes: h, screenPermissionRequested: v } = de.getState();
|
|
283
|
+
if (!l) return;
|
|
284
|
+
const o = i.indexOf(l);
|
|
285
|
+
switch (l.type) {
|
|
286
|
+
case "av_permission": {
|
|
287
|
+
const b = v ? o + 2 : o + 1;
|
|
288
|
+
return v && h && c.emit("begin.recording", { "recording.media.types": h, "start.recording.callback": (a) => {
|
|
289
|
+
t({ mediaRecordingUids: a });
|
|
290
|
+
} }), void t({ currentPage: i[b] });
|
|
291
|
+
}
|
|
292
|
+
case "screen_permission":
|
|
293
|
+
return void c.emit("screen.permission", { "screen.permission.requested": s, "stream.ready.callback": (b, a) => {
|
|
294
|
+
const m = a ? i[o + 1] : l;
|
|
295
|
+
a && h && c.emit("begin.recording", { "recording.media.types": h, "start.recording.callback": (u) => {
|
|
296
|
+
t({ captureStream: a, mediaRecordingUids: u });
|
|
297
|
+
} }), t({ currentPage: m, screenPermissionRequested: !0, captureStream: a });
|
|
298
|
+
} });
|
|
299
|
+
case "start_task":
|
|
300
|
+
return r("recorded.task.start"), c.emit("recorded.task.start"), c.emit("start.task"), void t({ currentPage: i[o + 1], screenPermissionRequested: !0 });
|
|
301
|
+
case "complete_task":
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const ze = "ul-permission-graphics-container", Ye = "ul-permission-body", Ke = B(ze, "ul_recorded-task-inset-spacing"), Te = B("ul-horizontal-button-container", "ul-horizontal-button-container-left"), Xe = ({ richTextBody: i }) => e(Se, { className: "ul-rich-text-body", html: i, id: "ul-task-detail-container" }), Ce = ({ required: i, skipButtonText: s, bottom: c = !1 }) => i ? null : e(z, { className: B(c && "ul-skip-button-below", "ul-button-inactive"), onClick: Pe.bind(null, { status: "abandoned" }), children: s || "Skip" }), Ee = (i) => {
|
|
306
|
+
const { avStream: s, captureStream: c, recordingMediaTypes: r, updatePage: t } = de.getState(), l = (r == null ? void 0 : r.includes("audio")) || (r == null ? void 0 : r.includes("video"));
|
|
307
|
+
ne(() => {
|
|
308
|
+
const h = setInterval(() => {
|
|
309
|
+
l && s && !s.active ? t({ avStream: null, currentPage: i[0] }) : c && c.active || t({ captureStream: void 0, currentPage: i[l ? 1 : 0] });
|
|
310
|
+
}, 1e3);
|
|
311
|
+
return () => clearInterval(h);
|
|
312
|
+
}, [s, c, l, i, r, t]);
|
|
313
|
+
}, Er = ({ content: i, pages: s, required: c }) => {
|
|
314
|
+
const { buttonText: r, skipButtonText: t, taskDetail: l } = i;
|
|
315
|
+
return Ee(s), e("div", { className: "ul-task-page", children: [l && e(Xe, { richTextBody: l }), e("div", { className: Te, children: [e(z, { onClick: Me.bind(null, { pages: s }), children: r }), e(Ce, { required: c, skipButtonText: t })] })] }, "start-task");
|
|
316
|
+
}, Ur = ({ content: i, pages: s, properties: c }) => {
|
|
317
|
+
const { buttonText: r, skipButtonText: t } = i;
|
|
318
|
+
Ee(s);
|
|
319
|
+
const l = e(pe, { properties: c, defaultBody: () => e("div", { className: Te, children: [e(z, { className: "ul-complete-task-button", onClick: Pe.bind(null, { status: "completed" }), children: r }), e(z, { className: B("ul-button-inactive"), onClick: Pe.bind(null, { status: "given.up" }), children: t })] }) });
|
|
320
|
+
return e("div", { className: "ul-task-page", children: [i.taskDetail && e(Xe, { richTextBody: i.taskDetail }), l] }, "complete-task");
|
|
321
|
+
}, Br = ({ content: i, pages: s, required: c }) => {
|
|
322
|
+
const { buttonText: r, skipButtonText: t } = i, [l] = G((o) => [o.tabTitle]), [h, v] = V(!1);
|
|
323
|
+
return e("div", { children: [e("div", { className: Ke, children: [e("p", { style: { marginTop: "auto" }, children: i.selectTabText }), e("div", { className: "ul-select-tab-container", children: e("p", { className: Ye, children: l }) })] }), e("div", { className: c ? "" : Te, children: [e(z, { disabled: h, onClick: Me.bind(null, { pages: s, setIsRequestingPermission: v }), children: r }), e(Ce, { required: c, skipButtonText: t })] })] });
|
|
324
|
+
}, Fr = ({ content: i }) => e(Se, { className: B(ze, "ul_permission_svg_container", "ul_recorded-task-inset-spacing", "ul-center-horizontally"), html: i.svg }, "ul-permission-request-graphic"), Or = ({ content: i, pages: s, required: c }) => {
|
|
325
|
+
const { permissionDeniedHeadline: r, permissionDeniedBody: t, skipButtonText: l, tryAgainButtonText: h } = i, v = _e(s[0]) ? s[0] : null;
|
|
326
|
+
return ne(() => {
|
|
327
|
+
const o = setInterval(() => {
|
|
328
|
+
v !== null && Le({ currentPage: v, pages: s });
|
|
329
|
+
}, 1e3);
|
|
330
|
+
return () => clearInterval(o);
|
|
331
|
+
}, [v, s]), v ? e("div", { children: [e("div", { className: Ke, children: e("p", { className: "ul-av-permission-denied-paragraph", children: [e("span", { className: "ul-av-permission-denied-headline", children: r }), e("span", { className: Ye, children: t })] }) }), e("div", { className: Te, children: [e(z, { onClick: Le.bind(null, { currentPage: v, pages: s }), children: h }), e(Ce, { required: c, skipButtonText: l })] })] }) : null;
|
|
332
|
+
}, Qr = ({ stream: i }) => e("video", { autoPlay: !0, className: B("ul_recorded-task-inset-spacing"), id: "ul-record-task-video-preview", muted: !0, ref: (s) => {
|
|
333
|
+
s && (s.srcObject = i || null);
|
|
334
|
+
} }), $r = ({ content: i, pages: s, required: c }) => {
|
|
335
|
+
const { skipButtonText: r } = i, { avStream: t } = de.getState();
|
|
336
|
+
return Ee(s), e("div", { children: [e(Qr, { stream: t }), e("div", { className: "ul-vertical-button-container-center", children: [e(z, { onClick: Me.bind(null, { pages: s }), children: i.buttonText }), e(Ce, { bottom: !0, required: c, skipButtonText: r })] })] });
|
|
337
|
+
}, Ar = ({ properties: i }) => {
|
|
338
|
+
const { pages: s, required: c } = i, { avStream: r, currentPage: t } = de.getState();
|
|
339
|
+
if (t === void 0) return null;
|
|
340
|
+
switch (t == null ? void 0 : t.type) {
|
|
341
|
+
case "av_permission": {
|
|
342
|
+
const l = We(r, t);
|
|
343
|
+
return l === qe ? e(Fr, { content: t }) : e(l === je ? Or : $r, { content: t, pages: s, required: c });
|
|
344
|
+
}
|
|
345
|
+
case "screen_permission":
|
|
346
|
+
return e(Br, { content: t, pages: s, required: c });
|
|
347
|
+
case "start_task":
|
|
348
|
+
return e(Er, { content: t, pages: s, required: c });
|
|
349
|
+
case "complete_task":
|
|
350
|
+
return e(Ur, { content: t, pages: s, properties: i });
|
|
351
|
+
default:
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
}, Hr = ({ className: i, properties: s, next: c, questionId: r }) => {
|
|
355
|
+
const t = G(), { surveyId: l, responseGroupUid: h, userId: v } = t, o = de(), { screenPermissionRequested: b } = o, a = de((g) => g.avStream);
|
|
356
|
+
let m = de((g) => g.currentPage);
|
|
357
|
+
m || (m = function({ pages: g, userId: k, responseGroupUid: D, surveyId: C, questionId: L, next: P }) {
|
|
358
|
+
const { updatePage: I } = de.getState(), { eventEmitFn: M, recorderEventEmitter: q } = G.getState(), x = { questionId: L, surveyId: C, visitorId: k, responseGroupUid: D };
|
|
359
|
+
let _ = 0;
|
|
360
|
+
q.emit("recorded.task.permission.screen"), M("recorded.task.permission.screen"), q.emit("permission.status", { "permission.status.callback": (n, p, y, N) => {
|
|
361
|
+
const U = g[_], { type: S } = U, w = ["screen"];
|
|
362
|
+
if (_e(U)) {
|
|
363
|
+
const { permissionDescriptors: F } = U, j = F == null ? void 0 : F.includes("microphone"), $ = F == null ? void 0 : F.includes("camera");
|
|
364
|
+
j && w.push("audio"), $ && w.push("video"), (n != null && n.active && !$ || n != null && n.active && p) && _++;
|
|
365
|
+
}
|
|
366
|
+
Be(g[_]) && y && (_++, q.emit("begin.recording", { "recording.media.types": w, "start.recording.callback": (F) => I({ mediaRecordingUids: F }) })), I({ currentPage: g[_], avStream: n, screenPermissionRequested: y, nextQuestion: P, type: S, passthroughData: x, recordingMediaTypes: w, captureStream: N });
|
|
367
|
+
} });
|
|
368
|
+
const E = g[_];
|
|
369
|
+
return E.type === "av_permission" && Le({ currentPage: E, pages: g }), E;
|
|
370
|
+
}({ questionId: r, surveyId: l, next: (g) => {
|
|
371
|
+
c(g, !0);
|
|
372
|
+
}, pages: s.pages, responseGroupUid: h, userId: v }));
|
|
373
|
+
let u = m.headline, f = m.captionText;
|
|
374
|
+
const d = We(a, m);
|
|
375
|
+
return Be(m) && b && (u = m.permissionDeniedHeadline, f = m.permissionDeniedCaptionText), _e(m) && d === Ze && (u = m.permissionGrantedHeadline, f = m.permissionGrantedCaptionText), e("div", { className: B(i, "ul-center-horizontally", "fade-in-transition"), children: [e(re, { isRequired: s == null ? void 0 : s.required, message: u, properties: { captionText: f } }), e(ie, { children: e(Ar, { properties: s }) })] });
|
|
376
|
+
}, Gr = ({ className: i, message: s, next: c, properties: r, questionId: t, type: l }) => {
|
|
377
|
+
const { visitorAttributes: h, isLongFormSurvey: v } = G((d) => ({ visitorAttributes: d.visitorAttributes, isLongFormSurvey: se(d.studyType) })), o = (d, g = !1) => {
|
|
378
|
+
c({ value: g ? { skipped: !0 } : void 0, questionId: t, type: l }, !0);
|
|
379
|
+
}, b = (d) => {
|
|
380
|
+
d.key !== "Enter" && d.key !== " " || c({ value: void 0, questionId: t, type: l }, !0);
|
|
381
|
+
}, a = br(r && r.buttonUrl, h), m = v && r.promptActionType === vr.NO_BUTTON ? () => e(ue, {}) : () => e(ce, { children: e("div", { className: "ul-card-button-group", children: [e("a", { className: "ul-card-text__button ul-card__text-url-prompt-button", href: a, id: "ul-card-text__button", onClick: o, onKeyPress: b, rel: "noreferrer", role: a ? "link" : "button", tabIndex: 0, target: "_blank", children: me(r) }), r.required === !1 && e("button", { className: "ul-card-skip__button", onClick: (d) => o(0, !0), children: De(r) })] }) });
|
|
382
|
+
return e("div", { className: B(i, "ul-card__text-url-prompt", "fade-in-transition"), children: [e(re, { isRequired: v && (r == null ? void 0 : r.required), message: s, properties: { questionHtml: r.questionHtml } }), e(ie, { children: (u = r == null ? void 0 : r.richTextBody, f = r == null ? void 0 : r.body, u ? e(Se, { className: "ul-rich-text-body", html: u, id: "ul-card__text-url-body-container" }) : f ? e("div", { className: "ul-rich-text-body", id: "ul-card__text-url-body-container", children: (f ? f.split(/\n\s*\n/g) : []).map((d, g) => e("p", { children: d }, g)) }) : null) }), e(pe, { defaultBody: m, properties: r })] }, t);
|
|
383
|
+
var u, f;
|
|
384
|
+
}, Vr = ({ className: i, questionId: s }) => {
|
|
385
|
+
const { border: c, destroy: r, endCard: t, forceBrandedLogo: l } = G((o) => ({ border: o.border, destroy: o.destroy, endCard: o.endCard, forceBrandedLogo: o.forceBrandedLogo }));
|
|
386
|
+
ne(() => {
|
|
387
|
+
setTimeout(() => {
|
|
388
|
+
r(mr);
|
|
389
|
+
}, l ? 4e3 : 2e3);
|
|
390
|
+
}, [r, l]);
|
|
391
|
+
const h = t && t.subheader ? e("p", { className: "ul-caption", children: t.subheader }) : null, v = t && t.headline ? t.headline : "";
|
|
392
|
+
return e("div", { className: B(i, "ul-card--thanks", "fade-in-transition"), children: e("div", { children: e("div", { className: "ul-card--thanks-content", children: [e("div", { className: "ul-thanks-check", children: e("svg", { "aria-labelledby": "title", fill: "none", height: "99", viewBox: "0 0 81 99", width: "81", xmlns: "http://www.w3.org/2000/svg", children: [e("path", { clipRule: "evenodd", d: "M40.5 77C60.9345 77 77.5 60.4345 77.5 40C77.5 19.5655 60.9345 3 40.5 3C20.0655 3 3.5 19.5655 3.5 40C3.5 60.4345 20.0655 77 40.5 77ZM80.5 40C80.5 62.0914 62.5914 80 40.5 80C18.4086 80 0.5 62.0914 0.5 40C0.5 17.9086 18.4086 0 40.5 0C62.5914 0 80.5 17.9086 80.5 40Z", fill: c, fillRule: "evenodd" }), e("path", { clipRule: "evenodd", d: "M55.025 22.9046C55.6299 23.4705 55.6616 24.4198 55.0956 25.0247C54.8724 25.2634 54.6109 25.5285 54.3157 25.8277C52.2547 27.9168 48.5549 31.667 44.8135 39.6658C43.2818 42.9406 42.0864 45.8386 41.0823 48.2729C40.6539 49.3116 40.2603 50.2659 39.8902 51.129C39.287 52.5359 38.7248 53.7508 38.1744 54.625C37.8997 55.0613 37.5806 55.4905 37.2017 55.8245C36.8201 56.1607 36.2613 56.5 35.5457 56.5C34.6742 56.5 34.0892 55.9692 33.7774 55.6083C33.4502 55.2296 33.1752 54.7511 32.9396 54.301C32.7305 53.9013 32.5088 53.4367 32.2797 52.9565C32.2429 52.8794 32.2059 52.8019 32.1688 52.7243C31.8942 52.1499 31.5959 51.534 31.2537 50.8868C29.8886 48.305 27.8539 45.2878 24.2343 43.1382C23.522 42.7152 23.2875 41.7949 23.7105 41.0826C24.1335 40.3703 25.0539 40.1358 25.7662 40.5588C30.0556 43.1062 32.4149 46.6647 33.9058 49.4845C34.2776 50.1876 34.5973 50.8487 34.8753 51.4302C34.9147 51.5124 34.9529 51.5926 34.9902 51.6707C35.2222 52.1567 35.4164 52.5637 35.5978 52.9102C35.6151 52.9434 35.6321 52.9754 35.6485 53.0061C36.0565 52.3531 36.5341 51.3434 37.133 49.9468C37.4781 49.1418 37.8572 48.2229 38.2761 47.2074C39.2886 44.7532 40.5339 41.7347 42.0961 38.3948C46.0591 29.9221 50.0641 25.8648 52.1535 23.7482C52.4423 23.4556 52.6944 23.2002 52.9048 22.9753C53.4708 22.3703 54.42 22.3387 55.025 22.9046ZM35.1994 53.5892C35.1994 53.5892 35.2 53.5888 35.2012 53.5879C35.2 53.5889 35.1994 53.5893 35.1994 53.5892ZM36.0666 53.6682C36.0732 53.674 36.0765 53.6775 36.0765 53.6777C36.0765 53.678 36.0732 53.6751 36.0666 53.6682Z", fill: c, fillRule: "evenodd" }), e("path", { d: "M69.5 97C69.5 98.1046 56.2924 99 40 99C23.7076 99 10.5 98.1046 10.5 97C10.5 95.8954 23.7076 95 40 95C56.2924 95 69.5 95.8954 69.5 97Z", fill: "black", fillOpacity: "0.2" })] }) }), e(re, { message: v }), h] }) }) }, s);
|
|
393
|
+
}, ge = "ul-card-video__player_recorder", Oe = "ul-video-btn", we = 0, Qe = 1, jr = ({ className: i, message: s, next: c, properties: r, questionId: t, type: l }) => {
|
|
394
|
+
const { apiURL: h, envId: v, handleUploadUpdate: o, headers: b, responseGroupUid: a, surveyId: m, update: u, viewDocument: f, visitorId: d } = G((n) => ({ apiURL: n.apiURL, envId: n.envId, handleUploadUpdate: n.handleUploadUpdate, headers: n.headers, responseGroupUid: n.responseGroupUid, surveyId: n.surveyId, update: n.update, viewDocument: n.viewDocument, visitorId: n.userId })), [g, k] = V(!1), [D, C] = V(null), [L, P] = V(null), [I, M] = V(we), q = ee(null), x = r && r.videoUrl;
|
|
395
|
+
ne(() => {
|
|
396
|
+
const n = q.current, p = new ResizeObserver(() => {
|
|
397
|
+
u();
|
|
398
|
+
});
|
|
399
|
+
return n && p.observe(n), () => {
|
|
400
|
+
n && p.unobserve(n);
|
|
401
|
+
};
|
|
402
|
+
}, [u]);
|
|
403
|
+
const _ = (n, p) => {
|
|
404
|
+
n === J.UPLOAD_STARTED ? (C(p[J.UPLOAD_ID]), P(p[J.MEDIA_RECORDING_UID]), k(!0)) : n === J.DELETE ? (C(null), P(null), k(!1)) : n === J.UPLOAD_PROGRESS ? isNaN(p[J.UPLOAD_PROGRESS_PCT]) ? o({ mediaRecordingUid: p[J.MEDIA_RECORDING_UID], isComplete: !0 }) : o({ mediaRecordingUid: p[J.MEDIA_RECORDING_UID], progressPct: p[J.UPLOAD_PROGRESS_PCT] }) : n === J.UPLOAD_FINISHED && o({ mediaRecordingUid: p[J.MEDIA_RECORDING_UID], isComplete: !0 });
|
|
405
|
+
}, E = (n) => {
|
|
406
|
+
n.preventDefault(), n.stopPropagation(), document.getElementById(ge) && kr(ge), D && L ? (o({ mediaRecordingUid: L, isSubmitted: !0 }), c({ value: { mediaRecordingUid: L }, questionId: t, type: l }, !0)) : c({ value: null, questionId: t, type: l }, !0);
|
|
407
|
+
};
|
|
408
|
+
return e("form", { className: B(i, "ul-card--video", "fade-in-transition"), id: "ul-video-interview-form", children: [e(re, { isRequired: r == null ? void 0 : r.required, message: s, properties: r }), e(ie, { children: [e("div", { id: "ul-question-player-container", ref: q, style: { display: I === we ? "" : "none" }, children: [e("div", { id: ge, ref: (n) => {
|
|
409
|
+
if (n && n.children.length === 0 && !r.hideRecordedPrompt) {
|
|
410
|
+
const p = yr(ge, { src: x, type: "application/x-mpegURL" }, void 0, r.mediaType === J.MEDIA_TYPE_AUDIO, h, f);
|
|
411
|
+
n.appendChild(p);
|
|
412
|
+
}
|
|
413
|
+
} }), e(pe, { defaultBody: () => e("button", { className: `${Oe} ul-record-response-btn`, onClick: (n) => {
|
|
414
|
+
n.preventDefault(), n.stopPropagation(), document.getElementById(ge) && fr(ge), M(Qe);
|
|
415
|
+
} }), properties: r })] }), e("div", { style: { display: I === Qe ? "block" : "none" }, children: [e("button", { className: `${Oe} ul-back-question-btn`, onClick: (n) => {
|
|
416
|
+
n.preventDefault(), n.stopPropagation(), M(we);
|
|
417
|
+
}, style: { display: r.hideRecordedPrompt ? "none" : "block" } }), e("div", { id: "ul-recorder-player-container", ref: (n) => {
|
|
418
|
+
if (n && n.children.length === 0) {
|
|
419
|
+
const p = Sr(ge, { surveyId: m, responseGroupUid: a, questionId: t, visitorId: d, envId: v }, h, _, void 0, { ...b, "x-ul-video-recorder-origin": "sdk" }, r.mediaType === J.MEDIA_TYPE_AUDIO, f);
|
|
420
|
+
n.appendChild(p);
|
|
421
|
+
}
|
|
422
|
+
} })] })] }), e(ce, { children: [e(z, { disabled: !g, onClick: E, children: me(r) }), e("button", { className: "ul-card-text__button ul-button-inactive ul-card-skip__button", id: "ul-card-video__skip_button", onClick: E, style: { display: r.required ? "none" : "block", ...g ? { display: "none" } : {} }, children: De(r) })] })] });
|
|
423
|
+
}, Zr = ({ className: i }) => {
|
|
424
|
+
const { uploadProgress: s } = G((l) => ({ uploadProgress: l.uploadProgress }));
|
|
425
|
+
let c, r;
|
|
426
|
+
Object.values(s).filter((l) => l.isSubmitted).length > 1 ? (c = "Your responses are processing", r = "Please keep this tab open until your responses are fully processed.") : (c = "Your response is processing", r = "Please keep this tab open until your response is fully processed.");
|
|
427
|
+
const t = Math.round(Math.min(99, ...Object.values(s).filter((l) => l.isSubmitted).map((l) => l.progressPct || 0)));
|
|
428
|
+
return e("div", { className: B(i, "ul-card--uploading", "fade-in-transition"), children: [e("div", { "aria-busy": "true", "aria-label": "Processing...", "aria-live": "polite", className: "ul-loading-spinner-container", role: "progressbar", children: e("div", { className: "ul-loading-spinner", children: [e("div", { className: "first" }), e("div", { className: "second" }), e("div", { className: "third" }), e("div", { className: "fourth" })] }) }), e(re, { message: `${c} (${t}% complete)` }), e("p", { className: "ul-caption", children: r })] });
|
|
429
|
+
}, Je = sr(void 0), Wr = ({ value: i, children: s }) => e(Je.Provider, { value: i, children: s }), zr = ({ isRightLabel: i, isLeftLabel: s }) => i ? oe.RIGHT : s ? oe.LEFT : null, Yr = "Best", Kr = "Worst", Xr = ({ className: i, labels: s, message: c, properties: r, options: t, questionId: l, type: h, next: v }) => {
|
|
430
|
+
var P, I, M, q;
|
|
431
|
+
const [o, b] = V(t.map((x, _) => ({ ...x, label: x.label === "" ? `Item ${_ + 1}` : x.label, isRightLabel: !1, isLeftLabel: !1 }))), a = (() => {
|
|
432
|
+
const x = ar(Je);
|
|
433
|
+
if (x === void 0) throw new Error("usePreviousResponses must be used within a PreviousResponsesProvider");
|
|
434
|
+
return x;
|
|
435
|
+
})(), m = { padding: "24px", display: "flex", cursor: "pointer", width: "auto" }, [u, f] = V(!1);
|
|
436
|
+
ne(() => {
|
|
437
|
+
const x = o.findIndex((S) => S.isRightLabel), _ = o.findIndex((S) => S.isLeftLabel), E = x !== -1 && _ !== -1;
|
|
438
|
+
f(E);
|
|
439
|
+
const n = !r.required || r.required && E, p = o.map((S) => ({ id: S.id, option: S.label, selected: zr(S) })), y = Math.floor(l), N = Object.keys(a).filter((S) => S.startsWith(y.toString())).map(Number).sort((S, w) => S - w).at(-1), U = [];
|
|
440
|
+
if (typeof N == "number") {
|
|
441
|
+
const S = a[N], w = JSON.parse(S);
|
|
442
|
+
U.push(...w);
|
|
443
|
+
}
|
|
444
|
+
U.push(p), setTimeout(() => {
|
|
445
|
+
v({ value: U, questionId: l, type: h }, n, E), f(!1);
|
|
446
|
+
}, E ? 500 : 0);
|
|
447
|
+
}, [o]);
|
|
448
|
+
const { border: d, useMobileStyling: g, enableCspTrustedTypes: k } = G((x) => ({ border: x.border, useMobileStyling: x.useMobileStyling, enableCspTrustedTypes: x.enableCspTrustedTypes })), D = (x, _) => () => {
|
|
449
|
+
u || b((E) => ((n, p, y) => n.map((N) => N.id === p ? { ...N, isRightLabel: y === oe.RIGHT, isLeftLabel: y === oe.LEFT } : y === oe.RIGHT && N.isRightLabel || y === oe.LEFT && N.isLeftLabel ? { ...N, isRightLabel: !1, isLeftLabel: !1 } : N))(E, x, _));
|
|
450
|
+
}, C = (P = r.ratingIcons) == null ? void 0 : P[0].svg, L = (I = r.ratingIcons) == null ? void 0 : I[1].svg;
|
|
451
|
+
return e("form", { className: B(i, "ul-card-maxdiff", "fade-in-transition"), children: [e(re, { isRequired: r == null ? void 0 : r.required, message: c, properties: r }), e(ie, { children: e("div", { className: "ul-card--maxdiff__question-inner-container", children: [e("div", { className: "ul-card-maxdiff__label", children: (s == null ? void 0 : s.left) || ((M = r == null ? void 0 : r.labels) == null ? void 0 : M.left) || Yr }), e("div", { children: " " }), e("div", { className: "ul-card-maxdiff__label", children: (s == null ? void 0 : s.right) || ((q = r == null ? void 0 : r.labels) == null ? void 0 : q.right) || Kr }), o.map(({ id: x, label: _, isLeftLabel: E, isRightLabel: n }) => e(ue, { children: [e("div", { className: "ul-card-maxdiff__option-control " + (L ? "smiley" : ""), children: L ? e($e, { ariaPressed: E, className: E ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected good" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: k, html: L, id: `smiley-good-${x}`, onClick: D(x, oe.LEFT) }) : e(ve, { allowTextEntry: !1, ariaLabel: `bestLabel-${_}`, border: d, choiceStyle: m, error: !1, id: `${x}`, isRadio: !0, isSelected: E, onUserInputChanged: D(x, oe.LEFT), useMobileStyling: g }) }), e("div", { className: "ul-card-maxdiff__option-label", children: _ }), e("div", { className: "ul-card-maxdiff__option-control " + (C ? "smiley" : ""), children: C ? e($e, { ariaPressed: n, className: n ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected bad" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: k, html: C, id: `smiley-bad-${x}`, onClick: D(x, oe.RIGHT) }) : e(ve, { allowTextEntry: !1, ariaLabel: `worstLabel-${_}`, border: d, choiceStyle: m, error: !1, id: `${x}`, isRadio: !0, isSelected: n, onUserInputChanged: D(x, oe.RIGHT), useMobileStyling: g }) })] }))] }) })] }, l);
|
|
452
|
+
}, $e = ({ enableCspTrustedTypes: i, ariaPressed: s, className: c, html: r, id: t, onClick: l }) => {
|
|
453
|
+
const h = be(() => He(r, i), [i, r]);
|
|
454
|
+
return e("span", { "aria-pressed": s, className: c, dangerouslySetInnerHTML: { __html: h }, id: t, onClick: l, tabIndex: 0, type: "button" });
|
|
455
|
+
}, Jr = ({ className: i, labels: s, message: c, next: r, properties: t, questionId: l, type: h, onSubmitButtonClick: v, options: o, showIndividualSubmit: b = !1 }) => {
|
|
456
|
+
const a = ee(null), m = ee(0), u = ee(0), f = ee(null), d = ee(!1), g = ee([]), [k, D] = V(() => (t == null ? void 0 : t.required) === !0), [C, L] = V(() => o.map((T) => ({ ...T, rank: null }))), P = be(() => Array.from({ length: o.length }, (T, O) => O + 1), [o.length]), { isLongFormSurvey: I, focusedQuestionId: M, setFocusedQuestionId: q, useMobileStyling: x, isPreview: _, headers: E } = G((T) => ({ useMobileStyling: T.useMobileStyling, isLongFormSurvey: se(T.studyType), focusedQuestionId: T.focusedQuestionId, setFocusedQuestionId: T.setFocusedQuestionId, isPreview: T.isPreview, headers: T.headers })), n = (E == null ? void 0 : E["userleap-platform"]) === "android", p = x && !_ && !n, y = !p && !n, N = I && M === l, U = (T) => {
|
|
457
|
+
T.preventDefault(), K(C), v && v();
|
|
458
|
+
}, S = (T, O) => {
|
|
459
|
+
L((Q) => {
|
|
460
|
+
const R = parseInt(O), A = Q.map((H) => ({ ...H }));
|
|
461
|
+
A.some((H) => H.rank == null) && A.forEach((H, he) => H.rank = he + 1);
|
|
462
|
+
const ae = A.findIndex((H) => H.id === T);
|
|
463
|
+
if (ae === -1) return Q;
|
|
464
|
+
const Z = A[ae].rank;
|
|
465
|
+
return R < Z ? A.forEach((H) => {
|
|
466
|
+
H.id !== T && H.rank >= R && H.rank < Z && (H.rank = H.rank + 1);
|
|
467
|
+
}) : R > Z && A.forEach((H) => {
|
|
468
|
+
H.id !== T && H.rank > Z && H.rank <= R && (H.rank = H.rank - 1);
|
|
469
|
+
}), A[ae].rank = R, A.sort((H, he) => H.rank - he.rank), te(A), A;
|
|
470
|
+
});
|
|
471
|
+
}, w = (T, O) => {
|
|
472
|
+
for (let Q = 0; Q < g.current.length; Q++) {
|
|
473
|
+
const R = g.current[Q];
|
|
474
|
+
if (!R || R === f.current) continue;
|
|
475
|
+
const A = R.getBoundingClientRect();
|
|
476
|
+
if (T >= A.left && T <= A.right && O >= A.top && O <= A.bottom) return { element: R, index: Q };
|
|
477
|
+
}
|
|
478
|
+
return null;
|
|
479
|
+
}, F = (T) => (O) => {
|
|
480
|
+
if (!p) return;
|
|
481
|
+
O.preventDefault(), O.stopPropagation(), d.current = !0, a.current = T;
|
|
482
|
+
const Q = O.touches[0];
|
|
483
|
+
m.current = Q.clientY, u.current = Q.clientY;
|
|
484
|
+
const R = O.currentTarget.closest(".ul-card-rank__option");
|
|
485
|
+
R && (f.current = R, R.classList.add("is-dragging"));
|
|
486
|
+
}, j = (T) => {
|
|
487
|
+
if (!p || !d.current || a.current === null) return;
|
|
488
|
+
T.preventDefault(), T.stopPropagation();
|
|
489
|
+
const O = T.touches[0];
|
|
490
|
+
u.current = O.clientY;
|
|
491
|
+
const Q = u.current - m.current;
|
|
492
|
+
f.current && (f.current.style.transform = `translateY(${Q}px)`, f.current.style.zIndex = "1000"), g.current.forEach((A) => {
|
|
493
|
+
A && A !== f.current && A.classList.remove("is-drop-target");
|
|
494
|
+
});
|
|
495
|
+
const R = w(O.clientX, O.clientY);
|
|
496
|
+
R && R.element.classList.add("is-drop-target");
|
|
497
|
+
}, $ = (T) => {
|
|
498
|
+
if (!p || !d.current || a.current === null) return;
|
|
499
|
+
T.preventDefault(), T.stopPropagation();
|
|
500
|
+
const O = T.changedTouches[0], Q = w(O.clientX, O.clientY);
|
|
501
|
+
f.current && (f.current.style.transform = "", f.current.style.zIndex = "", f.current.classList.remove("is-dragging")), g.current.forEach((R) => {
|
|
502
|
+
R && R.classList.remove("is-drop-target");
|
|
503
|
+
}), Q && Q.index !== a.current && W(a.current, Q.index), a.current = null, f.current = null, d.current = !1;
|
|
504
|
+
}, W = (T, O) => {
|
|
505
|
+
L((Q) => {
|
|
506
|
+
const R = Q.map((ae) => ({ ...ae })), [A] = R.splice(T, 1);
|
|
507
|
+
return R.splice(O, 0, A), R.forEach((ae, Z) => {
|
|
508
|
+
ae.rank = Z + 1;
|
|
509
|
+
}), te(R), R;
|
|
510
|
+
});
|
|
511
|
+
}, Y = (T) => {
|
|
512
|
+
T.preventDefault(), T.dataTransfer && (T.dataTransfer.dropEffect = "move");
|
|
513
|
+
}, K = (T) => {
|
|
514
|
+
const O = {};
|
|
515
|
+
T.reduce((Q, R) => (Q[R.id] = R.rank, Q), O), r({ value: O, questionId: l, type: h }, !0);
|
|
516
|
+
}, te = (T) => {
|
|
517
|
+
D(!1), I && K(T);
|
|
518
|
+
}, { left: le, right: fe } = s, ke = o.length, er = (T) => {
|
|
519
|
+
T.preventDefault(), T.currentTarget.classList.add("is-drop-target");
|
|
520
|
+
}, rr = (T) => {
|
|
521
|
+
T.currentTarget.classList.remove("is-drop-target");
|
|
522
|
+
}, tr = (T) => {
|
|
523
|
+
a.current = null, T.currentTarget.classList.remove("is-dragging");
|
|
524
|
+
};
|
|
525
|
+
return e("form", { className: B(i, "ul-card-rank", "fade-in-transition", I && !N && "ul-card--unfocused"), onClick: I ? () => {
|
|
526
|
+
I && M !== l && q(l);
|
|
527
|
+
} : void 0, onSubmit: U, children: [e(re, { isRequired: t == null ? void 0 : t.required, message: c, properties: t }), e(pe, { properties: t, defaultBody: () => e(ue, n ? { children: [e(ie, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", le] }) }), e("ol", { className: "ul-card-rank__list", children: C.map(({ id: T, label: O, rank: Q }) => e("li", { className: "ul-card-rank__option", children: [e("select", { "aria-label": `Rank for ${O}`, className: B("ul-card-rank__select", Q == null && "ul-card-rank__select--placeholder"), name: `rank[${T}]`, onChange: (R) => S(T, R.currentTarget.value), value: Q ?? "", children: [Q == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), P.map((R) => e("option", { className: "ul-card-rank__select-option", value: R, children: R }, `${R}-${l}`))] }), e("span", { children: O })] }, T)) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [ke, " - ", fe] }) })] }), b && e(ye, { handleSubmit: U, isSubmitDisabled: k })] }), !I && e(ce, { children: e("div", { className: "ul-card__button-wrapper", children: e(z, { disabled: k, children: me(t) }) }) })] } : { children: [e(ie, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", le] }) }), e("ol", { className: "ul-card-rank__list", onDragOver: n ? void 0 : Y, children: C.map(({ id: T, label: O, rank: Q }, R) => {
|
|
528
|
+
return e("li", { className: "ul-card-rank__option", draggable: !!y || void 0, onDragEnd: y ? tr : void 0, onDragEnter: y ? er : void 0, onDragLeave: y ? rr : void 0, onDragStart: y ? (ae = R, (Z) => {
|
|
529
|
+
a.current = ae, Z.dataTransfer && (Z.dataTransfer.effectAllowed = "move", Z.dataTransfer.setData("text/plain", String(ae)), Z.currentTarget.classList.add("is-dragging"));
|
|
530
|
+
}) : void 0, onDrop: y ? (A = R, (Z) => {
|
|
531
|
+
var he, Ue;
|
|
532
|
+
Z.preventDefault(), Z.currentTarget.classList.remove("is-drop-target");
|
|
533
|
+
const H = a.current;
|
|
534
|
+
a.current = null, (Ue = (he = Z.currentTarget.closest(".ul-card-rank__list")) == null ? void 0 : he.querySelector(".is-dragging")) == null || Ue.classList.remove("is-dragging"), H != null && H !== A && W(H, A);
|
|
535
|
+
}) : void 0, ref: (Z) => g.current[R] = Z, children: [e("select", { "aria-label": `Rank for ${O}`, className: B("ul-card-rank__select", Q == null && "ul-card-rank__select--placeholder"), name: `rank[${T}]`, onChange: (Z) => S(T, Z.currentTarget.value), value: Q ?? "", children: [Q == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), P.map((Z) => e("option", { className: "ul-card-rank__select-option", value: Z, children: Z }, `${Z}-${l}`))] }), e("span", { children: O }), !n && e("button", { "aria-label": `Drag ${O} to reorder`, className: "ul-card-rank__drag-btn", onTouchEnd: p ? $ : void 0, onTouchMove: p ? j : void 0, onTouchStart: p ? F(R) : void 0, title: "Drag to reorder", type: "button", children: e("svg", { fill: "none", height: "17", viewBox: "0 0 16 17", width: "16", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M5.75 11.625C6.37132 11.625 6.875 12.1287 6.875 12.75C6.875 13.3713 6.37132 13.875 5.75 13.875C5.12868 13.875 4.625 13.3713 4.625 12.75C4.625 12.1287 5.12868 11.625 5.75 11.625ZM10.25 11.625C10.8713 11.625 11.375 12.1287 11.375 12.75C11.375 13.3713 10.8713 13.875 10.25 13.875C9.62868 13.875 9.125 13.3713 9.125 12.75C9.125 12.1287 9.62868 11.625 10.25 11.625ZM5.75 7.375C6.37132 7.375 6.875 7.87868 6.875 8.5C6.875 9.12132 6.37132 9.625 5.75 9.625C5.12868 9.625 4.625 9.12132 4.625 8.5C4.625 7.87868 5.12868 7.375 5.75 7.375ZM10.25 7.375C10.8713 7.375 11.375 7.87868 11.375 8.5C11.375 9.12132 10.8713 9.625 10.25 9.625C9.62868 9.625 9.125 9.12132 9.125 8.5C9.125 7.87868 9.62868 7.375 10.25 7.375ZM5.75 3.125C6.37132 3.125 6.875 3.62868 6.875 4.25C6.875 4.87132 6.37132 5.375 5.75 5.375C5.12868 5.375 4.625 4.87132 4.625 4.25C4.625 3.62868 5.12868 3.125 5.75 3.125ZM10.25 3.125C10.8713 3.125 11.375 3.62868 11.375 4.25C11.375 4.87132 10.8713 5.375 10.25 5.375C9.62868 5.375 9.125 4.87132 9.125 4.25C9.125 3.62868 9.62868 3.125 10.25 3.125Z", fill: "currentColor" }) }) })] }, T);
|
|
536
|
+
var A, ae;
|
|
537
|
+
}) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [ke, " - ", fe] }) })] }), b && e(ye, { handleSubmit: U, isSubmitDisabled: k })] }), !I && e(ce, { children: e("div", { className: "ul-card__button-wrapper", children: e(z, { disabled: k, children: me(t) }) }) })] }) })] }, l);
|
|
538
|
+
}, et = /* @__PURE__ */ new Set(["open", "matrix", "multipleselect", "multiplechoice", "rankorder"]), Ae = ({ cardInstance: i, moveToNextQuestion: s, showIndividualSubmit: c, submitQuestion: r, updateCardValues: t }) => {
|
|
539
|
+
const { isLongFormSurvey: l } = G((u) => ({ isLongFormSurvey: se(u.studyType) }));
|
|
540
|
+
if (!i) return null;
|
|
541
|
+
const { name: h, type: v, props: o } = i, b = c && et.has(v), a = { className: "ul-card", next: (u, f, d = !0) => r(u, f && d), questionId: h, type: v, showIndividualSubmit: c, ...b ? { next: (u, f) => {
|
|
542
|
+
t(u.questionId, u, f ?? !0);
|
|
543
|
+
}, onSubmitButtonClick: () => s(h) } : {} }, m = (() => {
|
|
544
|
+
switch (v) {
|
|
545
|
+
case "consentlegal":
|
|
546
|
+
return e(xr, { ...a, ...o });
|
|
547
|
+
case "likert":
|
|
548
|
+
return e(_r, { ...a, ...o });
|
|
549
|
+
case "matrix":
|
|
550
|
+
return e(Lr, { ...a, ...o });
|
|
551
|
+
case "maxdiff":
|
|
552
|
+
return e(Xr, { ...a, ...o });
|
|
553
|
+
case "multiplechoice":
|
|
554
|
+
return e(Pr, { ...a, ...o });
|
|
555
|
+
case "multipleselect":
|
|
556
|
+
return e(Dr, { ...a, ...o });
|
|
557
|
+
case "nps":
|
|
558
|
+
return e(Rr, { ...a, ...o });
|
|
559
|
+
case "open":
|
|
560
|
+
return e(Mr, { ...a, ...o });
|
|
561
|
+
case "rankorder":
|
|
562
|
+
return e(Jr, { ...a, ...o });
|
|
563
|
+
case "recordedtask":
|
|
564
|
+
return e(Hr, { ...a, ...o });
|
|
565
|
+
case "texturlprompt":
|
|
566
|
+
return e(Gr, { ...a, ...o });
|
|
567
|
+
case "thanks":
|
|
568
|
+
return e(Vr, { ...a, ...o });
|
|
569
|
+
case "uploading":
|
|
570
|
+
return e(Zr, { ...a, ...o });
|
|
571
|
+
case "videovoice":
|
|
572
|
+
return e(jr, { ...a, ...o });
|
|
573
|
+
default:
|
|
574
|
+
return null;
|
|
575
|
+
}
|
|
576
|
+
})();
|
|
577
|
+
return m ? l ? e("div", { className: "ul-card-scroll-wrapper", children: m }, h) : m : null;
|
|
578
|
+
}, rt = ({ isSubmitDisabled: i = !1, onSubmit: s, buttonText: c }) => {
|
|
579
|
+
var f;
|
|
580
|
+
const { cards: r, forceBrandedLogo: t, index: l, marketingUrl: h, showSurveyBrand: v, slugName: o, surveyId: b, useMobileStyling: a } = G((d) => ({ cards: d.cards, forceBrandedLogo: d.forceBrandedLogo, index: d.index, marketingUrl: d.marketingUrl, showSurveyBrand: d.showSurveyBrand, slugName: d.slugName, surveyId: d.surveyId, useMobileStyling: d.useMobileStyling })), m = ((f = r[l]) == null ? void 0 : f.type) === "thanks", u = or({ marketingUrl: h, slugName: o, surveyId: b, forceBrandedLogo: t });
|
|
581
|
+
return e("footer", { className: B("long-form-question-footer-container", a && "long-form-question-footer-container--mobile", m && "long-form-question-footer-container-center"), children: [m && t ? e(lr, { marketingUrlLink: u }) : e("div", { className: "long-form-question-footer-container-logo", children: v ? e(dr, { forceBrandedLogo: t, marketingUrlLink: u }) : null }), !m && e("div", { className: B("ul-card__button-wrapper", "ul-card-vertical__button-wrapper", "long-form-question-footer-container-actions"), children: e(z, { className: B("long-form-button", i && "sprig-button-disabled"), disabled: i, onClick: s, children: e("span", { className: "long-form-button-text-container", children: c ?? e(cr, { stroke: "white" }) }) }) })] });
|
|
582
|
+
}, at = ({ cards: i, next: s, previousResponses: c }) => {
|
|
583
|
+
var E;
|
|
584
|
+
const [r, t] = V({}), [l, h] = V({}), v = be(() => ({ ...c, ...ur(i.map((n) => {
|
|
585
|
+
var p, y;
|
|
586
|
+
return { ...n, value: ((p = r[n.name]) == null ? void 0 : p.value) ?? null, secondaryValue: ((y = r[n.name]) == null ? void 0 : y.secondaryValue) ?? null };
|
|
587
|
+
})) }), [c, r, i]), o = pr(i, v), { isLongFormSurvey: b, focusedQuestionId: a, setFocusedQuestionId: m, update: u } = G((n) => ({ isLongFormSurvey: se(n.studyType), focusedQuestionId: n.focusedQuestionId, setFocusedQuestionId: n.setFocusedQuestionId, update: n.update })), f = ee(null), d = ee(!1), g = ee(null);
|
|
588
|
+
ne(() => {
|
|
589
|
+
u();
|
|
590
|
+
}, [u]);
|
|
591
|
+
const k = Ie((n) => {
|
|
592
|
+
var U, S;
|
|
593
|
+
d.current = !0;
|
|
594
|
+
const p = i.findIndex((w) => w.name === n);
|
|
595
|
+
if (!b || n === null || p === -1) return void (d.current = !1);
|
|
596
|
+
const y = (U = f.current) == null ? void 0 : U.querySelectorAll(".ul-card-scroll-wrapper")[p], N = (S = f.current) == null ? void 0 : S.closest(".ul-card__container");
|
|
597
|
+
if (y && N) {
|
|
598
|
+
if (y && N) {
|
|
599
|
+
const w = y.getBoundingClientRect(), F = N.getBoundingClientRect(), j = w.top - F.top + N.scrollTop, $ = j + w.height / 2, W = window.innerHeight - 157;
|
|
600
|
+
let Y;
|
|
601
|
+
w.height >= W ? Y = j : Y = $ - N.clientHeight / 2;
|
|
602
|
+
const K = N.clientHeight, te = N.scrollHeight - K, le = Math.max(0, Math.min(Y, te));
|
|
603
|
+
N.scrollTo({ top: le, behavior: "smooth" }), setTimeout(() => {
|
|
604
|
+
d.current = !1;
|
|
605
|
+
}, 500);
|
|
606
|
+
}
|
|
607
|
+
} else d.current = !1;
|
|
608
|
+
}, [b, i]);
|
|
609
|
+
function D(n, p) {
|
|
610
|
+
return n.map((y) => p[y.name]);
|
|
611
|
+
}
|
|
612
|
+
ne(() => {
|
|
613
|
+
a !== null && i.findIndex((n) => n.name === a) !== -1 || m(i[0].name);
|
|
614
|
+
}, [i, a, m]);
|
|
615
|
+
const C = (n) => {
|
|
616
|
+
if (!b) return;
|
|
617
|
+
const p = i.findIndex((y) => y.name === n) + 1;
|
|
618
|
+
if (p < i.length) {
|
|
619
|
+
const y = i[p].name;
|
|
620
|
+
m(y);
|
|
621
|
+
} else m(n);
|
|
622
|
+
};
|
|
623
|
+
ne(() => {
|
|
624
|
+
b && a !== null && (g.current !== a ? k(a) : g.current = null);
|
|
625
|
+
}, [a, b, k]);
|
|
626
|
+
const L = Ie(() => {
|
|
627
|
+
var F, j;
|
|
628
|
+
if (d.current) return;
|
|
629
|
+
const n = (F = f.current) == null ? void 0 : F.closest(".ul-card__container");
|
|
630
|
+
if (!n) return;
|
|
631
|
+
const p = (j = f.current) == null ? void 0 : j.querySelectorAll(".ul-card-scroll-wrapper");
|
|
632
|
+
if (!p || p.length === 0) return;
|
|
633
|
+
const y = n.getBoundingClientRect(), N = y.top + y.height / 2;
|
|
634
|
+
let U = 0, S = 1 / 0;
|
|
635
|
+
p.forEach(($, W) => {
|
|
636
|
+
const Y = $.getBoundingClientRect(), K = Y.top + Y.height / 2, te = Math.abs(N - K);
|
|
637
|
+
te < S && (S = te, U = W);
|
|
638
|
+
});
|
|
639
|
+
const w = i[U];
|
|
640
|
+
g.current = w.name, m(w.name);
|
|
641
|
+
}, [i, m]);
|
|
642
|
+
ne(() => {
|
|
643
|
+
var p;
|
|
644
|
+
if (!b) return;
|
|
645
|
+
const n = ((p = f.current) == null ? void 0 : p.closest(".ul-card__container")) || null;
|
|
646
|
+
return n && n.addEventListener("scroll", L, { passive: !0 }), () => {
|
|
647
|
+
n && n.removeEventListener("scroll", L);
|
|
648
|
+
};
|
|
649
|
+
}, [L, b]);
|
|
650
|
+
const P = be(() => Object.values(l).every((n, p) => {
|
|
651
|
+
var N;
|
|
652
|
+
const y = i[p];
|
|
653
|
+
return !(!(y != null && y.props) || !("properties" in y.props) || ((N = y.props.properties) == null ? void 0 : N.required) !== !1) || n;
|
|
654
|
+
}), [l, i]), I = async (n, p, y) => {
|
|
655
|
+
return h((U) => ({ ...U, [n]: y })), await (N = (U) => ({ ...U, [n]: p }), new Promise((U) => {
|
|
656
|
+
t((S) => {
|
|
657
|
+
const w = N(S);
|
|
658
|
+
return U(w), w;
|
|
659
|
+
});
|
|
660
|
+
}));
|
|
661
|
+
var N;
|
|
662
|
+
};
|
|
663
|
+
ne(() => {
|
|
664
|
+
if (!b) return;
|
|
665
|
+
const n = {};
|
|
666
|
+
i.forEach((p) => {
|
|
667
|
+
var N, U;
|
|
668
|
+
const y = p;
|
|
669
|
+
(U = (N = y.props) == null ? void 0 : N.properties) != null && U.required || (n[y.name] = { value: null, questionId: y.name, type: y.type });
|
|
670
|
+
}), t(n), h({});
|
|
671
|
+
}, [i, b]);
|
|
672
|
+
const M = async (n, p) => {
|
|
673
|
+
if (b) {
|
|
674
|
+
const y = await I(n.questionId, n, p), N = q(n.type), U = x(n.type);
|
|
675
|
+
if (N && C(n.questionId), U && p) {
|
|
676
|
+
const S = D(i, y);
|
|
677
|
+
s(S);
|
|
678
|
+
}
|
|
679
|
+
} else s([n]);
|
|
680
|
+
}, q = (n) => (/* @__PURE__ */ new Set(["nps", "likert", "multiplechoice"])).has(n), x = (n) => (/* @__PURE__ */ new Set(["videovoice", "consentlegal", "texturlprompt", "maxdiff"])).has(n), _ = ((E = i[0]) == null ? void 0 : E.type) === "thanks";
|
|
681
|
+
return b ? e("div", { className: "ul-card-list-container--longform", "data-testid": "ui-container", ref: f, children: [e(Wr, { value: c, children: o.map((n, p) => e(Ae, { cardInstance: n, moveToNextQuestion: C, showIndividualSubmit: b && i.length > 1 && p < i.length - 1, submitQuestion: M, updateCardValues: I }, (n == null ? void 0 : n.name) || p)) }), !_ && e(rt, { isSubmitDisabled: Object.keys(r).length < i.length || !P, onSubmit: function() {
|
|
682
|
+
const n = D(i, r);
|
|
683
|
+
s(n);
|
|
684
|
+
} })] }) : e(ue, { children: [e("div", { "data-testid": "ui-container", style: { display: "none" } }), o.map((n, p) => e(Ae, { cardInstance: n, moveToNextQuestion: C, showIndividualSubmit: b && i.length > 1 && p < i.length - 1, submitQuestion: M, updateCardValues: I }, (n == null ? void 0 : n.name) || p))] });
|
|
685
|
+
};
|
|
686
|
+
export {
|
|
687
|
+
at as PageCard
|
|
688
|
+
};
|