@sprig-technologies/sprig-browser 2.40.0 → 2.40.2
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-styles-BiL7hMhj.js +4 -0
- package/dist/conversational-styles-DlhTFTL6.cjs +1 -0
- package/dist/conversational-ui-BYWN-x1R.js +579 -0
- package/dist/conversational-ui-N_aaTzqd.cjs +1 -0
- package/dist/core-Br8FqGd4.cjs +12 -0
- package/dist/{core-CzqULo6b.js → core-Cyu7gofl.js} +451 -458
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +11 -0
- package/dist/core.js +2 -2
- package/dist/debounce-CMb8f7wh.js +9 -0
- package/dist/debounce-DsC7462b.cjs +1 -0
- package/dist/{getAttributedUrl-C1AsMcwH.cjs → getAttributedUrl-CJJ96Ihj.cjs} +6 -6
- package/dist/{getAttributedUrl-DUesmkhh.js → getAttributedUrl-C_5gL6aZ.js} +241 -244
- package/dist/index-BSk-C5b7.js +695 -0
- package/dist/index-MWKreg7C.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +2 -2
- package/dist/{metricsReporter-BChkCOLD.js → metricsReporter-B-oKhuWk.js} +1 -1
- package/dist/{metricsReporter-Bqy_vLyq.cjs → metricsReporter-Dc4CZlRc.cjs} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +134 -138
- package/dist/view-BGlLLPXB.js +1503 -0
- package/dist/view-BGzeHt4l.cjs +1 -0
- package/package.json +1 -1
- package/dist/conversational-styles-CWNea3pP.js +0 -4
- package/dist/conversational-styles-CzhxRRD3.cjs +0 -1
- package/dist/conversational-ui-D2Y5H9To.js +0 -610
- package/dist/conversational-ui-DJlCFQ-6.cjs +0 -1
- package/dist/core-CvM2f3CD.cjs +0 -12
- package/dist/index-D1_q2uph.cjs +0 -1
- package/dist/index-mshAF3wp.js +0 -709
- package/dist/view-C7XtFlCN.cjs +0 -1
- package/dist/view-afp9mz2J.js +0 -1491
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
import { a as V, h as $, u as e, c as U, b as K, f as Pe, F as ge, g as be, e as ue, _ as te, T as fe, A as nr, p as J, i as ir, m as sr, q as ar, M as le, n as lr, o as or, r as dr, s as cr, j as ur, k as pr, l as Ue } from "./view-BGlLLPXB.js";
|
|
2
|
+
import { t as ie } from "./metricsReporter-B-oKhuWk.js";
|
|
3
|
+
import { a as Ce, D as De, g as He, A as mr } from "./core-Cyu7gofl.js";
|
|
4
|
+
import { c as ee, a as ne, H as Se, M as ce, Q as de, O as he, B as z, L as ye, b as ke, S as gr, u as hr, g as br, P as vr, p as fr, v as yr, R as X, d as Sr, s as xr } from "./getAttributedUrl-C_5gL6aZ.js";
|
|
5
|
+
const kr = ({ className: n, message: i, next: c, properties: r, questionId: t, type: o }) => {
|
|
6
|
+
const { useMobileStyling: b, border: v, isLongFormSurvey: d, focusedQuestionId: h } = V((p) => ({ useMobileStyling: p.useMobileStyling, border: p.border, isLongFormSurvey: ie(p.studyType), focusedQuestionId: p.focusedQuestionId })), [a, g] = $(!1), [s, I] = $(""), [m, S] = $(!1), f = d && h === t, w = r == null ? void 0 : r.collectName, _ = (r == null ? void 0 : r.nameLabelText) || "Full Name", q = (r == null ? void 0 : r.consentText) || "I agree to the stated conditions", E = (r == null ? void 0 : r.submitButtonText) || "Submit", P = !!s.trim(), M = a && (!w || P), L = (p, T = !1) => {
|
|
7
|
+
p.preventDefault(), p.stopPropagation();
|
|
8
|
+
let u = null;
|
|
9
|
+
if (!T) {
|
|
10
|
+
if (!M) return void S(!0);
|
|
11
|
+
u = { submitted: !0 }, w && (u.name = s);
|
|
12
|
+
}
|
|
13
|
+
c({ value: u, questionId: t, type: o }, M);
|
|
14
|
+
};
|
|
15
|
+
return e("div", { className: U(n, d && !f && "ul-card--unfocused", "ul-card__consent-legal", "fade-in-transition"), children: [e(ee, { isRequired: d && (r == null ? void 0 : r.required), message: i, properties: { questionHtml: r.questionHtml } }), r != null && r.richTextBody ? e(ne, { children: e(Se, { className: "ul-rich-text-body", html: r.richTextBody, id: "ul-card__consent-legal-body-container" }) }) : null, e(ce, { embeddedType: "pdf", properties: r, children: e(de, { children: [e("div", { className: "sprig-stretch", children: [e(he, { allowTextEntry: !1, border: v, error: m && !a, id: "consent", isRadio: !1, isSelected: a, label: q, onUserInputChanged: ({ selected: p }) => {
|
|
16
|
+
p !== a && g(!a);
|
|
17
|
+
}, useMobileStyling: b }), w && e("input", { "aria-label": _, "aria-placeholder": _, className: U(K("ul-consent-legal__name-input", b)), "data-gramm": "false", maxLength: 250, name: "name", onBlur: (p) => {
|
|
18
|
+
p.currentTarget.style.borderColor = m && !P ? Ce : De;
|
|
19
|
+
}, onFocus: (p) => {
|
|
20
|
+
p.currentTarget.style.borderColor = m && !P ? Ce : v;
|
|
21
|
+
}, onInput: (p) => {
|
|
22
|
+
p.preventDefault(), p.stopPropagation(), I(p.currentTarget.value);
|
|
23
|
+
}, placeholder: _, style: m && !P ? { borderColor: Ce } : {}, tabIndex: 0, value: s })] }), e("div", { className: "ul-card__button-wrapper ul-card-vertical__button-wrapper", children: [e(z, { className: M ? "" : "sprig-button-disabled", onClick: L, children: E }), r.required === !1 && !d && e("button", { className: "ul-card-skip__button", onClick: (p) => L(p, !0), children: Pe(r) })] })] }) })] }, t);
|
|
24
|
+
}, Ir = ({ activeValue: n, border: i, icon: c, isPressed: r, onSubmit: t, range: o, scaleLabelType: b, selectedValue: v, setSelectedValue: d, setActiveValue: h, setIsPressed: a, useMobileStyling: g, value: s, viewDocument: I }) => {
|
|
25
|
+
const { isLongFormSurvey: m, enableCspTrustedTypes: S } = V((T) => ({ isLongFormSurvey: ie(T.studyType), enableCspTrustedTypes: T.enableCspTrustedTypes })), f = `option-${s}`, w = b === "number", _ = b === "star", q = b === "smiley", E = w && s === n || s === v, [P, M] = (() => {
|
|
26
|
+
const T = _ && v !== null && s <= v;
|
|
27
|
+
return _ && s <= n || q && s === n || T || s === n || s === v ? [i, r || T || s === v ? 1 : 0.3] : ["", 1];
|
|
28
|
+
})(), L = ge(() => {
|
|
29
|
+
const T = { borderColor: E ? P : "", fillOpacity: E ? "" : M, zIndex: E ? 3 : "auto", color: v === s ? "#fff" : "" };
|
|
30
|
+
return w ? { ...T, backgroundColor: v === s ? P : "" } : { ...T, color: _ || q || v === s ? P : "" };
|
|
31
|
+
}, [E, P, M, v, s, w, _, q]), p = ge(() => He((({ icon: T, scaleLabelType: u, value: y, selectedValue: x }) => {
|
|
32
|
+
if (u === "smiley" && y === x) {
|
|
33
|
+
let C = 0;
|
|
34
|
+
return T.replace(/black/g, () => ++C == 1 ? "black" : "white");
|
|
35
|
+
}
|
|
36
|
+
return T;
|
|
37
|
+
})({ icon: c, scaleLabelType: b, value: s, selectedValue: v }), S), [S, c, b, v, s]);
|
|
38
|
+
return e("button", { "aria-label": w ? void 0 : String(s), className: (() => {
|
|
39
|
+
switch (b) {
|
|
40
|
+
case "star":
|
|
41
|
+
return U(K("likert-star", g), K(`likert-star-${s}`, g));
|
|
42
|
+
case "smiley":
|
|
43
|
+
return U(K("likert-smiley", g), K(`likert-smiley-${s}`, g));
|
|
44
|
+
default:
|
|
45
|
+
return s === o ? U(K("likert-number", g), K(`likert-number-${s}`, g), K("likert-last-option", g)) : U(K("likert-number", g), K(`likert-number-${s}`, g));
|
|
46
|
+
}
|
|
47
|
+
})(), dangerouslySetInnerHTML: { __html: p }, id: f, onClick: (T) => {
|
|
48
|
+
m && (T.preventDefault(), T.stopPropagation(), d(s)), t();
|
|
49
|
+
}, onKeyDown: (T) => {
|
|
50
|
+
var x, C;
|
|
51
|
+
const u = I.querySelectorAll(`.likert-${b ?? "number"}`), y = s - 1;
|
|
52
|
+
T.key === "ArrowRight" ? (x = u[y + 1]) == null || x.focus() : T.key === "ArrowLeft" ? (C = u[y - 1]) == null || C.focus() : T.key !== "Enter" && T.key !== " " || (m && (T.preventDefault(), T.stopPropagation(), d(s)), t());
|
|
53
|
+
}, onPointerDown: () => a(!0), onPointerEnter: () => h(s), onPointerLeave: () => {
|
|
54
|
+
h(-1), a(!1);
|
|
55
|
+
}, style: L, tabIndex: 0 });
|
|
56
|
+
}, _r = ({ className: n, labels: i, message: c, next: r, properties: t, questionId: o, type: b }) => {
|
|
57
|
+
const { border: v, useMobileStyling: d, viewDocument: h, isLongFormSurvey: a, focusedQuestionId: g } = V((y) => ({ border: y.border, useMobileStyling: y.useMobileStyling, viewDocument: y.viewDocument, isLongFormSurvey: ie(y.studyType), focusedQuestionId: y.focusedQuestionId })), [s, I] = $(-1), [m, S] = $(!1), [f, w] = $(null), _ = a && g === o, q = i && i.left, E = i && i.right;
|
|
58
|
+
let P;
|
|
59
|
+
const { range: M, scaleLabelType: L, ratingIcons: p } = t;
|
|
60
|
+
M && (P = Number(M));
|
|
61
|
+
const T = P || 5, u = (y) => {
|
|
62
|
+
var x, C;
|
|
63
|
+
switch (L) {
|
|
64
|
+
case "star":
|
|
65
|
+
return (x = p[0]) == null ? void 0 : x.svg;
|
|
66
|
+
case "smiley":
|
|
67
|
+
return (C = p[y]) == null ? void 0 : C.svg;
|
|
68
|
+
default:
|
|
69
|
+
return String(y + 1);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return e("form", { className: U(n, "ul-card--likert", "fade-in-transition", a && !_ && "ul-card--unfocused"), children: [e(ee, { isRequired: a && (t == null ? void 0 : t.required), message: c, properties: t }), e(ce, { properties: t, children: e(be, { children: [e(ne, { children: [e("div", { "aria-label": `Rating (1 - ${T})`, className: "ul-card--likert__numbers", role: "radiogroup", children: [...Array(T)].map((y, x) => {
|
|
73
|
+
const C = x + 1;
|
|
74
|
+
return e(Ir, { activeValue: s, border: v, icon: u(x), isPressed: m, onSubmit: () => r({ value: C, questionId: o, type: b }, !0), range: T, scaleLabelType: L, selectedValue: f, setActiveValue: I, setIsPressed: S, setSelectedValue: w, useMobileStyling: d, value: C, viewDocument: h }, x);
|
|
75
|
+
}) }), e("div", { className: "ul-card--likert__labels", children: [e("span", { children: q }), e("span", { children: E })] })] }), !t.required && !a && e(de, { children: e("div", { className: "ul-vertical-centered-container", children: e(z, { onClick: (y) => {
|
|
76
|
+
y.preventDefault(), y.stopPropagation(), r({ value: null, questionId: o, type: b }, !0);
|
|
77
|
+
}, children: ue(t) }) }) })] }) })] }, o);
|
|
78
|
+
}, Ge = (n) => n && (n.scrollHeight > n.offsetHeight ? n : Ge(n.parentElement)), Tr = (n) => {
|
|
79
|
+
if (!n || !((c) => c instanceof HTMLElement)(n)) return 0;
|
|
80
|
+
const i = getComputedStyle(n);
|
|
81
|
+
return parseFloat(i.marginTop) + parseFloat(i.marginBottom) + (parseFloat(i.borderTopWidth) + parseFloat(i.borderBottomWidth));
|
|
82
|
+
}, Cr = ({ columns: n, onSelect: i, options: c, selectedOptions: r }) => {
|
|
83
|
+
const t = te([]), { border: o, useMobileStyling: b } = V((s) => ({ border: s.border, useMobileStyling: s.useMobileStyling })), v = c.findIndex((s) => r[s.id] === null), [d, h] = $(v), a = fe((s, I) => {
|
|
84
|
+
i(s, I);
|
|
85
|
+
const m = d + 1, S = c[m];
|
|
86
|
+
if (S && r[S.id] === null) {
|
|
87
|
+
h(m);
|
|
88
|
+
const f = t.current[d];
|
|
89
|
+
if (f != null && f.firstElementChild) {
|
|
90
|
+
const w = Ge(f), _ = f.firstElementChild, q = Tr(f) + _.clientHeight;
|
|
91
|
+
w == null || w.scrollTo(0, f.offsetTop + q);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, [i, c, r, d]), g = fe((s, I) => {
|
|
95
|
+
const m = d === s;
|
|
96
|
+
return e(nr, { animate: !0, header: I.label, isOpen: m, onClick: () => {
|
|
97
|
+
var S;
|
|
98
|
+
return h(m && !((S = window.UserLeap) != null && S.isMobileSDK) ? -1 : s);
|
|
99
|
+
}, ref: (S) => {
|
|
100
|
+
S && (t.current[s] = S);
|
|
101
|
+
}, showHeaderCheck: r[I.id] !== null, children: e("div", { style: { paddingTop: "12px" }, children: n.map((S) => e(he, { allowTextEntry: !1, ariaLabel: `${I.label}-${S.label}`, border: o, error: !1, id: `${I.id}-${S.value}`, isRadio: !0, isSelected: r[I.id] === S.value, label: S.label, onUserInputChanged: () => a(I.id, S.value), useMobileStyling: b }, S.label)) }) }, I.id);
|
|
102
|
+
}, [o, n, d, a, r, b]);
|
|
103
|
+
return e("div", { children: c.map((s, I) => g(I, s)) });
|
|
104
|
+
}, Nr = ({ columns: n, onSelect: i, options: c, selectedOptions: r }) => {
|
|
105
|
+
const { border: t, useMobileStyling: o, isLongFormSurvey: b } = V((m) => ({ border: m.border, useMobileStyling: m.useMobileStyling, isLongFormSurvey: ie(m.studyType) })), v = c.length, d = n.length, h = te(null), [a, g] = $(!1), [s, I] = $(!1);
|
|
106
|
+
return J(() => {
|
|
107
|
+
const m = h.current, S = new ResizeObserver((f) => {
|
|
108
|
+
window.requestAnimationFrame(() => {
|
|
109
|
+
m && (g(Math.round(f[0].contentRect.width) < m.scrollWidth), I(Math.round(f[0].contentRect.width) < m.scrollWidth));
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
return m && S.observe(m), () => {
|
|
113
|
+
m && S.unobserve(m);
|
|
114
|
+
};
|
|
115
|
+
}, []), e("div", { className: "ul-card--matrix_question_container", children: [e("div", { className: U("ul-card--matrix_container", a && "ul-matrix-scroll-gradient"), onScroll: () => {
|
|
116
|
+
(() => {
|
|
117
|
+
const m = h.current;
|
|
118
|
+
m && g(m.clientWidth + Math.abs(m.scrollLeft) < m.scrollWidth);
|
|
119
|
+
})();
|
|
120
|
+
}, ref: h, children: e("div", { className: U(b && "ul-card--matrix_grid_longform", "ul-card--matrix_grid"), style: `--numColumns: ${d}; --numRows: ${v + 1};`, children: [e("div", {}), " ", n.map((m) => e("div", { className: "ul-matrix-column-label", children: m.label }, m.label)), c.map((m) => e(be, { children: [e("div", { "aria-label": m.label, className: "ul-matrix-row-label", children: m.label }, m.label), e("div", { className: "ul-matrix-row-options", role: "radiogroup", children: n.map((S, f) => e("div", { className: U("ul-matrix-option-wrapper", f === d - 1 && "ul-matrix-last-option"), children: e(he, { allowTextEntry: !1, ariaLabel: `${m.label}-${S.label}`, border: t, choiceStyle: { background: "transparent", border: "none", marginBottom: "0", padding: "0" }, error: !1, id: `${m.id}-${S.value}`, isRadio: !0, isSelected: r[m.id] === S.value, onUserInputChanged: () => i(m.id, S.value), useMobileStyling: o }) }, S.value)) })] }))] }) }), (a || s) && e("button", { className: s && !a ? "ul-matrix-scroll-arrow left" : "ul-matrix-scroll-arrow", onClick: s && !a ? (m) => {
|
|
121
|
+
m.preventDefault();
|
|
122
|
+
const S = h.current;
|
|
123
|
+
if (S) {
|
|
124
|
+
const f = getComputedStyle(S).direction === "rtl";
|
|
125
|
+
S.scrollTo({ left: f ? S.scrollWidth - S.clientWidth : 0, behavior: "smooth" });
|
|
126
|
+
}
|
|
127
|
+
} : (m) => {
|
|
128
|
+
m.preventDefault();
|
|
129
|
+
const S = h.current;
|
|
130
|
+
if (S) {
|
|
131
|
+
const f = getComputedStyle(S).direction === "rtl";
|
|
132
|
+
S.scrollTo({ left: f ? S.clientWidth - S.scrollWidth : S.scrollWidth, behavior: "smooth" });
|
|
133
|
+
}
|
|
134
|
+
}, children: e(s && !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: n, message: i, next: c, options: r, properties: t, questionId: o, type: b, showIndividualSubmit: v = !1, onSubmitButtonClick: d }) => {
|
|
136
|
+
const { useMobileStyling: h, isLongFormSurvey: a, focusedQuestionId: g, setFocusedQuestionId: s } = V((L) => ({ useMobileStyling: L.useMobileStyling, isLongFormSurvey: ie(L.studyType), focusedQuestionId: L.focusedQuestionId, setFocusedQuestionId: L.setFocusedQuestionId })), I = t.matrixColumn, m = t.required, S = a && g === o, f = (L) => {
|
|
137
|
+
L.preventDefault(), L.stopPropagation(), c({ value: _, questionId: o, type: b }, !0), d && d();
|
|
138
|
+
}, w = r.reduce((L, p) => (L[p.id] = null, L), {}), [_, q] = $(w), E = (L) => m && Object.values(L).every((p) => p == null), P = (L, p) => {
|
|
139
|
+
a && c({ value: { ..._, [L]: p }, questionId: o, type: b }, !E({ ..._, [L]: p })), q((T) => ({ ...T, [L]: p }));
|
|
140
|
+
}, M = t.displayMatrixAsAccordion || h;
|
|
141
|
+
return e("form", { className: U(n, !a && "ul-card__matrix", "fade-in-transition", a && !S && "ul-card--unfocused"), id: "text-form", onClick: () => {
|
|
142
|
+
S && s(o);
|
|
143
|
+
}, onSubmit: f, children: [e(ee, { isRequired: a && (t == null ? void 0 : t.required), message: i, properties: t }), e(ce, { properties: t, children: [e(ne, { children: [e(M ? Cr : Nr, { columns: I, onSelect: P, options: r, selectedOptions: _ }), v && e(ye, { handleSubmit: f, isSubmitDisabled: E(_) })] }), !a && e(de, { children: e("div", { className: "ul-card__button-wrapper", children: e(z, { disabled: E(_), children: ue(t) }) }) })] })] }, o);
|
|
144
|
+
}, Ve = ({ className: n, message: i, onSubmit: c, options: r = [], properties: t, questionId: o, type: b, showIndividualSubmit: v = !1, onSubmitButtonClick: d }) => {
|
|
145
|
+
const { border: h, useMobileStyling: a, isLongFormSurvey: g, focusedQuestionId: s, setFocusedQuestionId: I } = V((l) => ({ border: l.border, useMobileStyling: l.useMobileStyling, isLongFormSurvey: ie(l.studyType), focusedQuestionId: l.focusedQuestionId, setFocusedQuestionId: l.setFocusedQuestionId })), m = g && s === o, S = r.reduce((l, k) => (l[k.id] = { isSelected: !1 }, l), {}), [f, w] = $(S), _ = b === "multiplechoice", q = t.required, E = r.find((l) => {
|
|
146
|
+
var k;
|
|
147
|
+
return (k = l.optionProperties) == null ? void 0 : k.noneOfTheAbove;
|
|
148
|
+
}), P = (l) => Object.entries(l).some(([k, B]) => {
|
|
149
|
+
var W;
|
|
150
|
+
const A = r.find((Z) => `${Z.id}` === k), F = B.userText === void 0 || B.userText.trim() === "";
|
|
151
|
+
return ((W = A == null ? void 0 : A.optionProperties) == null ? void 0 : W.allowsTextEntry) && F && B.isSelected;
|
|
152
|
+
}), M = (l) => Object.values(l).filter((k) => k.isSelected).length, L = t.minSelect && t.minSelect > 0 && t.maxSelectMode === ke.Range && M(f) < t.minSelect && (q || M(f) > 0), p = (l) => P(l) || q && !M(l) || !((k) => {
|
|
153
|
+
const { minSelect: B = 0, maxSelect: A = 1 / 0, maxSelectMode: F } = t, W = M(k);
|
|
154
|
+
switch (F) {
|
|
155
|
+
case ke.Maximum:
|
|
156
|
+
return W <= A;
|
|
157
|
+
case ke.Range:
|
|
158
|
+
return W === 0 || W >= B;
|
|
159
|
+
default:
|
|
160
|
+
return !0;
|
|
161
|
+
}
|
|
162
|
+
})(l), T = Object.entries(f).some(([l, k]) => {
|
|
163
|
+
var B, A;
|
|
164
|
+
return k.isSelected && ((A = (B = r.find((F) => `${F.id}` === l)) == null ? void 0 : B.optionProperties) == null ? void 0 : A.allowsTextEntry);
|
|
165
|
+
}), u = v && (!_ || T), y = (l) => {
|
|
166
|
+
D(l.id, l.selected, l.userText, l.noneOfTheAbove), l.selected && g && !_ && !m && I(o);
|
|
167
|
+
}, x = (l) => {
|
|
168
|
+
var k;
|
|
169
|
+
return (t == null ? void 0 : t.maxSelectMode) !== ke.Unlimited && M(f) === (t == null ? void 0 : t.maxSelect) && !((k = f[l]) != null && k.isSelected);
|
|
170
|
+
}, C = (l) => {
|
|
171
|
+
l.preventDefault(), l.stopPropagation(), c(f, !0), d && d();
|
|
172
|
+
}, D = (l, k, B, A) => {
|
|
173
|
+
const F = Object.assign({}, f);
|
|
174
|
+
if ((_ || A) && k) for (const Y of Object.values(F)) Y.isSelected = !1, delete Y.userText;
|
|
175
|
+
else E && !A && f[E.id].isSelected && (F[E.id].isSelected = !1);
|
|
176
|
+
F[l] = { isSelected: k, userText: B };
|
|
177
|
+
const W = _ && Object.entries(F).some(([Y, re]) => {
|
|
178
|
+
var ae, ve;
|
|
179
|
+
return re.isSelected && ((ve = (ae = r.find((xe) => `${xe.id}` === Y)) == null ? void 0 : ae.optionProperties) == null ? void 0 : ve.allowsTextEntry);
|
|
180
|
+
}), Z = !p(F);
|
|
181
|
+
g && (c(F, Z), _ && !W && Z && d && d()), w(F);
|
|
182
|
+
};
|
|
183
|
+
return e("form", { className: U(n, "ul-card--multiple", "fade-in-transition", g && !m && "ul-card--unfocused"), id: "text-form", onClick: b === "multipleselect" ? () => {
|
|
184
|
+
g && s !== o && b === "multipleselect" && I(o);
|
|
185
|
+
} : void 0, onSubmit: C, children: [e(ee, { isRequired: g && (t == null ? void 0 : t.required), message: i, properties: t }), e(ce, { properties: t, children: e(be, { children: [e(ne, { children: [t.isDropdown ? e(gr, { disabledOptions: r.filter((l) => x(l.id)), dropdownFooter: L ? e("div", { className: "ul-card__min-select-counter", style: { marginLeft: "16px" }, children: [M(f), "/", t.minSelect] }) : void 0, isMultiSelect: !_, multiselectText: t.dropdownMultiselectedText ?? "choices selected", onChange: (l) => {
|
|
186
|
+
const k = { ...f };
|
|
187
|
+
for (const B of r) l.includes(B) ? k[B.id].isSelected = !0 : k[B.id].isSelected = !1;
|
|
188
|
+
g && c(k, !p(k)), w(k);
|
|
189
|
+
}, options: r, placeholderText: t.dropdownPlaceholderText ?? (_ ? "Select choice" : "Select choice(s)"), value: r.filter((l) => f[l.id].isSelected) }) : e("div", { className: U(K("ul-card__choices", a)), role: _ ? "radiogroup" : "group", children: [r.map(({ id: l, label: k, value: B, optionProperties: A }) => {
|
|
190
|
+
var re, ae;
|
|
191
|
+
const F = `${l}`, { allowsTextEntry: W, noneOfTheAbove: Z } = { allowsTextEntry: !1, noneOfTheAbove: !1, ...A };
|
|
192
|
+
return e(he, { allowTextEntry: W, border: h, disabled: x(F), error: (Y = f, P(Y)), id: F, isRadio: _, isSelected: !!((re = f[F]) != null && re.isSelected), label: k, noneOfTheAbove: Z, onUserInputChanged: y, promptText: "Please specify", text: (ae = f[l]) == null ? void 0 : ae.userText, useMobileStyling: a, value: B }, F);
|
|
193
|
+
var Y;
|
|
194
|
+
}), !!L && e("div", { className: "ul-card__min-select-counter", children: [M(f), "/", t.minSelect] })] }), u && e(ye, { handleSubmit: C, isSubmitDisabled: p(f) })] }), !g && e(de, { children: e("div", { className: "ul-card__button-wrapper", children: e(z, { disabled: p(f), onClick: C, children: ue(t) }) }) })] }) })] }, o);
|
|
195
|
+
}, Pr = (n) => {
|
|
196
|
+
const { questionId: i, type: c, next: r, options: t } = n, { setFocusedQuestionId: o } = V((b) => ({ setFocusedQuestionId: b.setFocusedQuestionId }));
|
|
197
|
+
return e(Ve, { ...n, onSubmit: (b, v) => {
|
|
198
|
+
var I;
|
|
199
|
+
const d = Object.entries(b).find(([, m]) => m.isSelected) || [void 0, void 0], [h, a] = d, g = t.find((m) => `${m.id}` === h);
|
|
200
|
+
!((I = g == null ? void 0 : g.optionProperties) != null && I.allowsTextEntry) || a != null && a.userText && a.userText.trim() !== "" || o(i);
|
|
201
|
+
const s = a != null && a.userText ? { [h]: { userText: a.userText } } : null;
|
|
202
|
+
r({ value: g && h ? { [h]: g.value } : {}, secondaryValue: s, questionId: i, type: c }, v);
|
|
203
|
+
} });
|
|
204
|
+
}, Dr = (n) => {
|
|
205
|
+
const { questionId: i, type: c, next: r } = n;
|
|
206
|
+
return e(Ve, { ...n, onSubmit: (t, o) => {
|
|
207
|
+
const b = Object.entries(t).reduce((d, [h, a]) => (d[h] = a.isSelected, d), {}), v = Object.entries(t).reduce((d, [h, a]) => {
|
|
208
|
+
if (!a.userText) return d;
|
|
209
|
+
const g = d || {};
|
|
210
|
+
return g[h] = { userText: a.userText }, g;
|
|
211
|
+
}, null);
|
|
212
|
+
r({ value: b, secondaryValue: v, questionId: i, type: c }, o);
|
|
213
|
+
} });
|
|
214
|
+
}, Rr = ({ className: n, labels: i, message: c, properties: r, next: t, questionId: o, type: b }) => {
|
|
215
|
+
const [v, d] = $(null), { border: h, useMobileStyling: a, viewDocument: g, isLongFormSurvey: s, focusedQuestionId: I } = V((w) => ({ border: w.border, useMobileStyling: w.useMobileStyling, viewDocument: w.viewDocument, isLongFormSurvey: ie(w.studyType), focusedQuestionId: w.focusedQuestionId })), m = s && I === o, S = i && i.left, f = i && i.right;
|
|
216
|
+
return e("form", { className: U(n, "ul-card--nps", "fade-in-transition", s && !m && "ul-card--unfocused"), children: [e(ee, { isRequired: s && (r == null ? void 0 : r.required), message: c, properties: r }), e(ce, { properties: r, children: [e(ne, { children: [e("div", { className: "ul-card--nps__numbers", children: [...Array(11)].map((w, _) => e("button", { className: U(K("nps-number", a), K(`nps-number-${_}`, a)), id: `option-${_}`, onClick: (q) => {
|
|
217
|
+
s && (q.preventDefault(), q.stopPropagation(), d(_)), t({ value: _, questionId: o, type: b }, !0);
|
|
218
|
+
}, onKeyDown: (q) => {
|
|
219
|
+
var P, M;
|
|
220
|
+
const E = g.querySelectorAll("button.nps-number");
|
|
221
|
+
q.key === "ArrowRight" ? (P = E[_ + 1]) == null || P.focus() : q.key === "ArrowLeft" ? (M = E[_ - 1]) == null || M.focus() : q.key !== "Enter" && q.key !== " " || (s && (q.preventDefault(), q.stopPropagation(), d(_)), t({ value: _, questionId: o, type: b }, !0));
|
|
222
|
+
}, onPointerDown: (q) => {
|
|
223
|
+
q.currentTarget.style.zIndex = "2", q.currentTarget.style.borderColor = h;
|
|
224
|
+
}, onPointerLeave: (q) => {
|
|
225
|
+
q.currentTarget.style.zIndex = "auto", q.currentTarget.style.borderColor = De;
|
|
226
|
+
}, style: v === _ ? { backgroundColor: h, color: "#fff" } : void 0, tabIndex: 0, children: _ }, _)) }), e("div", { className: "ul-card--nps__labels", children: [e("span", { children: S }), e("span", { children: f })] })] }), !r.required && !s && e(de, { children: e("div", { className: "ul-vertical-centered-container", children: e(z, { onClick: (w) => {
|
|
227
|
+
w.preventDefault(), w.stopPropagation(), t({ value: null, questionId: o, type: b }, !0);
|
|
228
|
+
}, children: ue(r) }) }) })] })] }, o);
|
|
229
|
+
}, Mr = ({ className: n, message: i, next: c, properties: r, questionId: t, type: o, showIndividualSubmit: b = !1, onSubmitButtonClick: v }) => {
|
|
230
|
+
const { border: d, useMobileStyling: h, update: a, isLongFormSurvey: g, focusedQuestionId: s, setFocusedQuestionId: I, isPreview: m } = V((p) => ({ border: p.border, useMobileStyling: p.useMobileStyling, update: p.update, isLongFormSurvey: ie(p.studyType), focusedQuestionId: p.focusedQuestionId, setFocusedQuestionId: p.setFocusedQuestionId, isPreview: p.isPreview })), [S, f] = $(""), w = te(null), _ = g && s === t;
|
|
231
|
+
J(() => {
|
|
232
|
+
var p, T;
|
|
233
|
+
g && !m && (_ ? (p = w.current) == null || p.focus() : (T = w.current) == null || T.blur());
|
|
234
|
+
}, [g, _, m]);
|
|
235
|
+
const q = S.trim(), E = r.required === !0 && !q, P = hr(w, () => a()), M = (p) => {
|
|
236
|
+
p.preventDefault(), p.stopPropagation(), c({ value: S, questionId: t, type: o }, !r.required || q.length > 0), v && v();
|
|
237
|
+
}, L = r && r.openTextPlaceholder ? r.openTextPlaceholder : "";
|
|
238
|
+
return e("form", { className: U(n, "ul-card-text", "fade-in-transition", g && !_ && "ul-card--unfocused"), id: "text-form", onClick: () => {
|
|
239
|
+
g && s !== t && I(t);
|
|
240
|
+
}, children: [e(ee, { isRequired: g && (r == null ? void 0 : r.required), message: i, properties: r }), e(ce, { properties: r, children: e("div", { className: "ul-card-text", children: e(ne, { children: [e("div", { className: "ul-card-text__container", children: e("textarea", { "aria-describedby": "ul-caption", "aria-labelledby": "ul-question", "aria-multiline": "true", "aria-placeholder": L, className: U(K("ul-card-text__input", h)), "data-gramm": "false", maxLength: 5e3, name: "text", onBlur: (p) => {
|
|
241
|
+
p.currentTarget.style.borderColor = De;
|
|
242
|
+
}, onChange: (p) => {
|
|
243
|
+
const { value: T } = p.currentTarget;
|
|
244
|
+
if (P(), p.preventDefault(), p.stopPropagation(), f(T), g) {
|
|
245
|
+
const u = T.trim().length > 0;
|
|
246
|
+
c({ value: T, questionId: t, type: o }, u);
|
|
247
|
+
}
|
|
248
|
+
}, onFocus: (p) => {
|
|
249
|
+
p.currentTarget.style.borderColor = d, I(t);
|
|
250
|
+
}, placeholder: L, ref: w, role: "textbox", tabIndex: 0 }) }), r.footerHtml && e(Se, { className: "footer", html: r.footerHtml }), b && e(ye, { handleSubmit: M, isSubmitDisabled: E }), e(de, { children: !g && e(z, { disabled: E, onClick: M, children: ue(r) }) })] }) }) })] }, t);
|
|
251
|
+
}, we = 1, je = 2, Ze = 3, Ie = (n) => n.type === "av_permission", Fe = (n) => n.type === "screen_permission", We = (n, i) => n === void 0 ? we : n ? ((c, r) => !(Ie(r) ? r.permissionDescriptors : []).includes("camera") || c.getVideoTracks().length > 0)(n, i) ? Ze : we : je, Be = { avStream: null, currentPage: null, mediaRecordingUids: null, nextQuestion: () => {
|
|
252
|
+
}, passthroughData: void 0, recordingMediaTypes: void 0, screenPermissionRequested: !1, type: void 0 }, oe = ir((n) => ({ ...Be, reset: () => {
|
|
253
|
+
n(Be);
|
|
254
|
+
}, updatePage: (i) => {
|
|
255
|
+
n(i);
|
|
256
|
+
} }));
|
|
257
|
+
function qe({ currentPage: n, pages: i }) {
|
|
258
|
+
const { avStream: c, recordingMediaTypes: r, updatePage: t } = oe.getState(), { recorderEventEmitter: o } = V.getState();
|
|
259
|
+
o.emit("av.permission", { "permission.descriptors": n.permissionDescriptors, "stream.ready": (b, v) => {
|
|
260
|
+
if (c === b) return;
|
|
261
|
+
let d = n;
|
|
262
|
+
if (b && !n.permissionDescriptors.includes("camera")) {
|
|
263
|
+
const h = i.indexOf(n), a = v != null && v.active ? h + 2 : h + 1;
|
|
264
|
+
v != null && v.active && r && o.emit("begin.recording", { "recording.media.types": r, "start.recording.callback": (g) => t({ mediaRecordingUids: g }) }), d = i[a];
|
|
265
|
+
}
|
|
266
|
+
t({ currentPage: d, avStream: b });
|
|
267
|
+
} });
|
|
268
|
+
}
|
|
269
|
+
function Le({ status: n }) {
|
|
270
|
+
const { nextQuestion: i, passthroughData: c, mediaRecordingUids: r, reset: t } = oe.getState(), { recorderEventEmitter: o, handleUploadUpdate: b, index: v } = V.getState(), d = { value: { taskStatus: n }, type: "recordedtask", questionId: (c == null ? void 0 : c.questionId) || 1 };
|
|
271
|
+
c && o.emit("finish.task", { "begin.callback": (h) => {
|
|
272
|
+
b({ mediaRecordingUid: h, isSubmitted: !0, progressPct: 0, isComplete: !1 });
|
|
273
|
+
}, "progress.callback": (h, a) => {
|
|
274
|
+
b({ mediaRecordingUid: h, progressPct: a.detail, isSubmitted: !1, isComplete: !1 });
|
|
275
|
+
}, "upload.callback": (h) => {
|
|
276
|
+
h && b({ mediaRecordingUid: h, isComplete: !0, isSubmitted: !0, progressPct: 100 });
|
|
277
|
+
}, "passthrough.data": c, "current.index": v, "task.response": d, "task.complete.callback": (h) => {
|
|
278
|
+
d.value.taskDurationMillisecond = h, r && (d.value.mediaRecordingUids = r), t(), i(d);
|
|
279
|
+
} });
|
|
280
|
+
}
|
|
281
|
+
function Re({ pages: n, setIsRequestingPermission: i }) {
|
|
282
|
+
const { recorderEventEmitter: c, eventEmitFn: r } = V.getState(), { updatePage: t, currentPage: o, recordingMediaTypes: b, screenPermissionRequested: v } = oe.getState();
|
|
283
|
+
if (!o) return;
|
|
284
|
+
const d = n.indexOf(o);
|
|
285
|
+
switch (o.type) {
|
|
286
|
+
case "av_permission": {
|
|
287
|
+
const h = v ? d + 2 : d + 1;
|
|
288
|
+
return v && b && c.emit("begin.recording", { "recording.media.types": b, "start.recording.callback": (a) => {
|
|
289
|
+
t({ mediaRecordingUids: a });
|
|
290
|
+
} }), void t({ currentPage: n[h] });
|
|
291
|
+
}
|
|
292
|
+
case "screen_permission":
|
|
293
|
+
return void c.emit("screen.permission", { "screen.permission.requested": i, "stream.ready.callback": (h, a) => {
|
|
294
|
+
const g = a ? n[d + 1] : o;
|
|
295
|
+
a && b && c.emit("begin.recording", { "recording.media.types": b, "start.recording.callback": (s) => {
|
|
296
|
+
t({ captureStream: a, mediaRecordingUids: s });
|
|
297
|
+
} }), t({ currentPage: g, 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: n[d + 1], screenPermissionRequested: !0 });
|
|
301
|
+
case "complete_task":
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const ze = "ul-permission-graphics-container", Ye = "ul-permission-body", Ke = U(ze, "ul_recorded-task-inset-spacing"), _e = U("ul-horizontal-button-container", "ul-horizontal-button-container-left"), Xe = ({ richTextBody: n }) => e(Se, { className: "ul-rich-text-body", html: n, id: "ul-task-detail-container" }), Te = ({ required: n, skipButtonText: i, bottom: c = !1 }) => n ? null : e(z, { className: U(c && "ul-skip-button-below", "ul-button-inactive"), onClick: Le.bind(null, { status: "abandoned" }), children: i || "Skip" }), Me = (n) => {
|
|
306
|
+
const { avStream: i, captureStream: c, recordingMediaTypes: r, updatePage: t } = oe.getState(), o = (r == null ? void 0 : r.includes("audio")) || (r == null ? void 0 : r.includes("video"));
|
|
307
|
+
J(() => {
|
|
308
|
+
const b = setInterval(() => {
|
|
309
|
+
o && i && !i.active ? t({ avStream: null, currentPage: n[0] }) : c && c.active || t({ captureStream: void 0, currentPage: n[o ? 1 : 0] });
|
|
310
|
+
}, 1e3);
|
|
311
|
+
return () => clearInterval(b);
|
|
312
|
+
}, [i, c, o, n, r, t]);
|
|
313
|
+
}, Er = ({ content: n, pages: i, required: c }) => {
|
|
314
|
+
const { buttonText: r, skipButtonText: t, taskDetail: o } = n;
|
|
315
|
+
return Me(i), e("div", { className: "ul-task-page", children: [o && e(Xe, { richTextBody: o }), e("div", { className: _e, children: [e(z, { onClick: Re.bind(null, { pages: i }), children: r }), e(Te, { required: c, skipButtonText: t })] })] }, "start-task");
|
|
316
|
+
}, Ur = ({ content: n, pages: i, properties: c }) => {
|
|
317
|
+
const { buttonText: r, skipButtonText: t } = n;
|
|
318
|
+
return Me(i), e("div", { className: "ul-task-page", children: [n.taskDetail && e(Xe, { richTextBody: n.taskDetail }), e(ce, { properties: c, children: e("div", { className: _e, children: [e(z, { className: "ul-complete-task-button", onClick: Le.bind(null, { status: "completed" }), children: r }), e(z, { className: U("ul-button-inactive"), onClick: Le.bind(null, { status: "given.up" }), children: t })] }) })] }, "complete-task");
|
|
319
|
+
}, Fr = ({ content: n, pages: i, required: c }) => {
|
|
320
|
+
const { buttonText: r, skipButtonText: t } = n, [o] = V((d) => [d.tabTitle]), [b, v] = $(!1);
|
|
321
|
+
return e("div", { children: [e("div", { className: Ke, children: [e("p", { style: { marginTop: "auto" }, children: n.selectTabText }), e("div", { className: "ul-select-tab-container", children: e("p", { className: Ye, children: o }) })] }), e("div", { className: c ? "" : _e, children: [e(z, { disabled: b, onClick: Re.bind(null, { pages: i, setIsRequestingPermission: v }), children: r }), e(Te, { required: c, skipButtonText: t })] })] });
|
|
322
|
+
}, Br = ({ content: n }) => e(Se, { className: U(ze, "ul_permission_svg_container", "ul_recorded-task-inset-spacing", "ul-center-horizontally"), html: n.svg }, "ul-permission-request-graphic"), Or = ({ content: n, pages: i, required: c }) => {
|
|
323
|
+
const { permissionDeniedHeadline: r, permissionDeniedBody: t, skipButtonText: o, tryAgainButtonText: b } = n, v = Ie(i[0]) ? i[0] : null;
|
|
324
|
+
return J(() => {
|
|
325
|
+
const d = setInterval(() => {
|
|
326
|
+
v !== null && qe({ currentPage: v, pages: i });
|
|
327
|
+
}, 1e3);
|
|
328
|
+
return () => clearInterval(d);
|
|
329
|
+
}, [v, i]), 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: _e, children: [e(z, { onClick: qe.bind(null, { currentPage: v, pages: i }), children: b }), e(Te, { required: c, skipButtonText: o })] })] }) : null;
|
|
330
|
+
}, Qr = ({ stream: n }) => e("video", { autoPlay: !0, className: U("ul_recorded-task-inset-spacing"), id: "ul-record-task-video-preview", muted: !0, ref: (i) => {
|
|
331
|
+
i && (i.srcObject = n || null);
|
|
332
|
+
} }), Ar = ({ content: n, pages: i, required: c }) => {
|
|
333
|
+
const { skipButtonText: r } = n, { avStream: t } = oe.getState();
|
|
334
|
+
return Me(i), e("div", { children: [e(Qr, { stream: t }), e("div", { className: "ul-vertical-button-container-center", children: [e(z, { onClick: Re.bind(null, { pages: i }), children: n.buttonText }), e(Te, { bottom: !0, required: c, skipButtonText: r })] })] });
|
|
335
|
+
}, $r = ({ properties: n }) => {
|
|
336
|
+
const { pages: i, required: c } = n, { avStream: r, currentPage: t } = oe.getState();
|
|
337
|
+
if (t === void 0) return null;
|
|
338
|
+
switch (t == null ? void 0 : t.type) {
|
|
339
|
+
case "av_permission": {
|
|
340
|
+
const o = We(r, t);
|
|
341
|
+
return o === we ? e(Br, { content: t }) : e(o === je ? Or : Ar, { content: t, pages: i, required: c });
|
|
342
|
+
}
|
|
343
|
+
case "screen_permission":
|
|
344
|
+
return e(Fr, { content: t, pages: i, required: c });
|
|
345
|
+
case "start_task":
|
|
346
|
+
return e(Er, { content: t, pages: i, required: c });
|
|
347
|
+
case "complete_task":
|
|
348
|
+
return e(Ur, { content: t, pages: i, properties: n });
|
|
349
|
+
default:
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
}, Hr = ({ className: n, properties: i, next: c, questionId: r }) => {
|
|
353
|
+
const t = V(), { surveyId: o, responseGroupUid: b, userId: v, update: d } = t, h = oe(), { screenPermissionRequested: a } = h, g = oe((f) => f.avStream);
|
|
354
|
+
let s = oe((f) => f.currentPage);
|
|
355
|
+
s || (s = function({ pages: f, userId: w, responseGroupUid: _, surveyId: q, questionId: E, next: P }) {
|
|
356
|
+
const { updatePage: M } = oe.getState(), { eventEmitFn: L, recorderEventEmitter: p } = V.getState(), T = { questionId: E, surveyId: q, visitorId: w, responseGroupUid: _ };
|
|
357
|
+
let u = 0;
|
|
358
|
+
p.emit("recorded.task.permission.screen"), L("recorded.task.permission.screen"), p.emit("permission.status", { "permission.status.callback": (x, C, D, l) => {
|
|
359
|
+
const k = f[u], { type: B } = k, A = ["screen"];
|
|
360
|
+
if (Ie(k)) {
|
|
361
|
+
const { permissionDescriptors: F } = k, W = F == null ? void 0 : F.includes("microphone"), Z = F == null ? void 0 : F.includes("camera");
|
|
362
|
+
W && A.push("audio"), Z && A.push("video"), (x != null && x.active && !Z || x != null && x.active && C) && u++;
|
|
363
|
+
}
|
|
364
|
+
Fe(f[u]) && D && (u++, p.emit("begin.recording", { "recording.media.types": A, "start.recording.callback": (F) => M({ mediaRecordingUids: F }) })), M({ currentPage: f[u], avStream: x, screenPermissionRequested: D, nextQuestion: P, type: B, passthroughData: T, recordingMediaTypes: A, captureStream: l });
|
|
365
|
+
} });
|
|
366
|
+
const y = f[u];
|
|
367
|
+
return y.type === "av_permission" && qe({ currentPage: y, pages: f }), y;
|
|
368
|
+
}({ questionId: r, surveyId: o, next: (f) => {
|
|
369
|
+
c(f, !0);
|
|
370
|
+
}, pages: i.pages, responseGroupUid: b, userId: v }));
|
|
371
|
+
let I = s.headline, m = s.captionText;
|
|
372
|
+
const S = We(g, s);
|
|
373
|
+
return Fe(s) && a && (I = s.permissionDeniedHeadline, m = s.permissionDeniedCaptionText), Ie(s) && S === Ze && (I = s.permissionGrantedHeadline, m = s.permissionGrantedCaptionText), J(() => {
|
|
374
|
+
d();
|
|
375
|
+
}, [d]), e("div", { className: U(n, "ul-center-horizontally", "fade-in-transition"), children: [e(ee, { isRequired: i == null ? void 0 : i.required, message: I, properties: { captionText: m } }), e(ne, { children: e($r, { properties: i }) })] });
|
|
376
|
+
}, Gr = ({ richTextBody: n, plaintextBody: i }) => n ? e(Se, { className: "ul-rich-text-body", html: n, id: "ul-card__text-url-body-container" }) : i ? e("div", { className: "ul-rich-text-body", id: "ul-card__text-url-body-container", children: (i ? i.split(/\n\s*\n/g) : []).map((c, r) => e("p", { children: c }, r)) }) : null, Vr = ({ className: n, message: i, next: c, properties: r, questionId: t, type: o }) => {
|
|
377
|
+
const { visitorAttributes: b, isLongFormSurvey: v } = V((g) => ({ visitorAttributes: g.visitorAttributes, isLongFormSurvey: ie(g.studyType) })), d = (g, s = !1) => {
|
|
378
|
+
c({ value: s ? { skipped: !0 } : void 0, questionId: t, type: o }, !0);
|
|
379
|
+
}, h = br(r && r.buttonUrl, b), a = v && r.promptActionType === vr.NO_BUTTON;
|
|
380
|
+
return e("div", { className: U(n, "ul-card__text-url-prompt", "fade-in-transition"), children: [e(ee, { isRequired: v && (r == null ? void 0 : r.required), message: i, properties: { questionHtml: r.questionHtml } }), e(ne, { children: e(Gr, { plaintextBody: r == null ? void 0 : r.body, richTextBody: r == null ? void 0 : r.richTextBody }) }), e(ce, { properties: r, children: !a && e(de, { children: e("div", { className: "ul-card-button-group", children: [e("a", { className: "ul-card-text__button ul-card__text-url-prompt-button", href: h, id: "ul-card-text__button", onClick: d, onKeyPress: (g) => {
|
|
381
|
+
g.key !== "Enter" && g.key !== " " || c({ value: void 0, questionId: t, type: o }, !0);
|
|
382
|
+
}, rel: "noreferrer", role: h ? "link" : "button", tabIndex: 0, target: "_blank", children: ue(r) }), r.required === !1 && e("button", { className: "ul-card-skip__button", onClick: (g) => d(0, !0), children: Pe(r) })] }) }) })] }, t);
|
|
383
|
+
}, jr = ({ className: n, questionId: i }) => {
|
|
384
|
+
const { border: c, destroy: r, endCard: t, forceBrandedLogo: o, update: b } = V((h) => ({ border: h.border, destroy: h.destroy, endCard: h.endCard, forceBrandedLogo: h.forceBrandedLogo, update: h.update }));
|
|
385
|
+
J(() => {
|
|
386
|
+
setTimeout(() => {
|
|
387
|
+
r(mr);
|
|
388
|
+
}, o ? 4e3 : 2e3);
|
|
389
|
+
}, [r, o]);
|
|
390
|
+
const v = t && t.subheader ? e("p", { className: "ul-caption", children: t.subheader }) : null, d = t && t.headline ? t.headline : "";
|
|
391
|
+
return J(() => {
|
|
392
|
+
b();
|
|
393
|
+
}, [b]), e("div", { className: U(n, "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(ee, { message: d }), v] }) }) }, i);
|
|
394
|
+
}, pe = "ul-card-video__player_recorder", Oe = "ul-video-btn", Ne = 0, Qe = 1, Zr = ({ className: n, message: i, next: c, properties: r, questionId: t, type: o }) => {
|
|
395
|
+
const { apiURL: b, envId: v, handleUploadUpdate: d, headers: h, responseGroupUid: a, surveyId: g, update: s, viewDocument: I, visitorId: m } = V((l) => ({ apiURL: l.apiURL, envId: l.envId, handleUploadUpdate: l.handleUploadUpdate, headers: l.headers, responseGroupUid: l.responseGroupUid, surveyId: l.surveyId, update: l.update, viewDocument: l.viewDocument, visitorId: l.userId })), [S, f] = $(!1), [w, _] = $(null), [q, E] = $(null), [P, M] = $(Ne), [L, p] = $(null), [T, u] = $(null), y = r && r.videoUrl, x = fe((l) => {
|
|
396
|
+
l && p(l);
|
|
397
|
+
}, [p]);
|
|
398
|
+
J(() => {
|
|
399
|
+
const l = new ResizeObserver(() => {
|
|
400
|
+
setTimeout(s, 0);
|
|
401
|
+
});
|
|
402
|
+
return T && l.observe(T), L && l.observe(L), () => {
|
|
403
|
+
l.disconnect();
|
|
404
|
+
};
|
|
405
|
+
}, [s, T, L]);
|
|
406
|
+
const C = (l, k) => {
|
|
407
|
+
l === X.UPLOAD_STARTED ? (_(k[X.UPLOAD_ID]), E(k[X.MEDIA_RECORDING_UID]), f(!0)) : l === X.DELETE ? (_(null), E(null), f(!1)) : l === X.UPLOAD_PROGRESS ? isNaN(k[X.UPLOAD_PROGRESS_PCT]) ? d({ mediaRecordingUid: k[X.MEDIA_RECORDING_UID], isComplete: !0 }) : d({ mediaRecordingUid: k[X.MEDIA_RECORDING_UID], progressPct: k[X.UPLOAD_PROGRESS_PCT] }) : l === X.UPLOAD_FINISHED && d({ mediaRecordingUid: k[X.MEDIA_RECORDING_UID], isComplete: !0 });
|
|
408
|
+
}, D = (l) => {
|
|
409
|
+
l.preventDefault(), l.stopPropagation(), document.getElementById(pe) && xr(pe), w && q ? (d({ mediaRecordingUid: q, isSubmitted: !0 }), c({ value: { mediaRecordingUid: q }, questionId: t, type: o }, !0)) : c({ value: null, questionId: t, type: o }, !0);
|
|
410
|
+
};
|
|
411
|
+
return e("form", { className: U(n, "ul-card--video", "fade-in-transition"), id: "ul-video-interview-form", children: [e(ee, { isRequired: r == null ? void 0 : r.required, message: i, properties: r }), e(ne, { children: [e("div", { id: "ul-question-player-container", ref: x, style: { display: P === Ne ? "" : "none" }, children: [e("div", { id: pe, ref: (l) => {
|
|
412
|
+
if (l && l.children.length === 0 && !r.hideRecordedPrompt) {
|
|
413
|
+
u(l);
|
|
414
|
+
const k = yr(pe, { src: y, type: "application/x-mpegURL" }, void 0, r.mediaType === X.MEDIA_TYPE_AUDIO, b, I);
|
|
415
|
+
l.appendChild(k);
|
|
416
|
+
}
|
|
417
|
+
} }), e(ce, { properties: r, children: e("button", { className: `${Oe} ul-record-response-btn`, onClick: (l) => {
|
|
418
|
+
l.preventDefault(), l.stopPropagation(), document.getElementById(pe) && fr(pe), M(Qe);
|
|
419
|
+
} }) })] }), e("div", { style: { display: P === Qe ? "block" : "none" }, children: [e("button", { className: `${Oe} ul-back-question-btn`, onClick: (l) => {
|
|
420
|
+
l.preventDefault(), l.stopPropagation(), M(Ne);
|
|
421
|
+
}, style: { display: r.hideRecordedPrompt ? "none" : "block" } }), e("div", { id: "ul-recorder-player-container", ref: (l) => {
|
|
422
|
+
if (l && l.children.length === 0) {
|
|
423
|
+
u(l);
|
|
424
|
+
const k = Sr(pe, { surveyId: g, responseGroupUid: a, questionId: t, visitorId: m, envId: v }, b, C, void 0, { ...h, "x-ul-video-recorder-origin": "sdk" }, r.mediaType === X.MEDIA_TYPE_AUDIO, I);
|
|
425
|
+
l.appendChild(k);
|
|
426
|
+
}
|
|
427
|
+
} })] })] }), e(de, { children: [e(z, { disabled: !S, onClick: D, children: ue(r) }), e("button", { className: "ul-card-text__button ul-button-inactive ul-card-skip__button", id: "ul-card-video__skip_button", onClick: D, style: { display: r.required ? "none" : "block", ...S ? { display: "none" } : {} }, children: Pe(r) })] })] });
|
|
428
|
+
}, Wr = ({ className: n }) => {
|
|
429
|
+
const { uploadProgress: i } = V((o) => ({ uploadProgress: o.uploadProgress }));
|
|
430
|
+
let c, r;
|
|
431
|
+
Object.values(i).filter((o) => o.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.");
|
|
432
|
+
const t = Math.round(Math.min(99, ...Object.values(i).filter((o) => o.isSubmitted).map((o) => o.progressPct || 0)));
|
|
433
|
+
return e("div", { className: U(n, "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(ee, { message: `${c} (${t}% complete)` }), e("p", { className: "ul-caption", children: r })] });
|
|
434
|
+
}, Je = sr(void 0), zr = ({ value: n, children: i }) => e(Je.Provider, { value: n, children: i }), Yr = ({ isRightLabel: n, isLeftLabel: i }) => n ? le.RIGHT : i ? le.LEFT : null, Kr = "Best", Xr = "Worst", Jr = ({ className: n, labels: i, message: c, properties: r, options: t, questionId: o, type: b, next: v }) => {
|
|
435
|
+
var E, P, M, L;
|
|
436
|
+
const [d, h] = $(t.map((p, T) => ({ ...p, label: p.label === "" ? `Item ${T + 1}` : p.label, isRightLabel: !1, isLeftLabel: !1 }))), a = (() => {
|
|
437
|
+
const p = ar(Je);
|
|
438
|
+
if (p === void 0) throw new Error("usePreviousResponses must be used within a PreviousResponsesProvider");
|
|
439
|
+
return p;
|
|
440
|
+
})(), g = { padding: "24px", display: "flex", cursor: "pointer", width: "auto" }, [s, I] = $(!1);
|
|
441
|
+
J(() => {
|
|
442
|
+
const p = d.findIndex((k) => k.isRightLabel), T = d.findIndex((k) => k.isLeftLabel), u = p !== -1 && T !== -1;
|
|
443
|
+
I(u);
|
|
444
|
+
const y = !r.required || r.required && u, x = d.map((k) => ({ id: k.id, option: k.label, selected: Yr(k) })), C = Math.floor(o), D = Object.keys(a).filter((k) => k.startsWith(C.toString())).map(Number).sort((k, B) => k - B).at(-1), l = [];
|
|
445
|
+
if (typeof D == "number") {
|
|
446
|
+
const k = a[D], B = JSON.parse(k);
|
|
447
|
+
l.push(...B);
|
|
448
|
+
}
|
|
449
|
+
l.push(x), setTimeout(() => {
|
|
450
|
+
v({ value: l, questionId: o, type: b }, y, u), I(!1);
|
|
451
|
+
}, u ? 500 : 0);
|
|
452
|
+
}, [d]);
|
|
453
|
+
const { border: m, useMobileStyling: S, enableCspTrustedTypes: f } = V((p) => ({ border: p.border, useMobileStyling: p.useMobileStyling, enableCspTrustedTypes: p.enableCspTrustedTypes })), w = (p, T) => () => {
|
|
454
|
+
s || h((u) => ((y, x, C) => y.map((D) => D.id === x ? { ...D, isRightLabel: C === le.RIGHT, isLeftLabel: C === le.LEFT } : C === le.RIGHT && D.isRightLabel || C === le.LEFT && D.isLeftLabel ? { ...D, isRightLabel: !1, isLeftLabel: !1 } : D))(u, p, T));
|
|
455
|
+
}, _ = (E = r.ratingIcons) == null ? void 0 : E[0].svg, q = (P = r.ratingIcons) == null ? void 0 : P[1].svg;
|
|
456
|
+
return e("form", { className: U(n, "ul-card-maxdiff", "fade-in-transition"), children: [e(ee, { isRequired: r == null ? void 0 : r.required, message: c, properties: r }), e(ne, { children: e("div", { className: "ul-card--maxdiff__question-inner-container", children: [e("div", { className: "ul-card-maxdiff__label", children: (i == null ? void 0 : i.left) || ((M = r == null ? void 0 : r.labels) == null ? void 0 : M.left) || Kr }), e("div", { children: " " }), e("div", { className: "ul-card-maxdiff__label", children: (i == null ? void 0 : i.right) || ((L = r == null ? void 0 : r.labels) == null ? void 0 : L.right) || Xr }), d.map(({ id: p, label: T, isLeftLabel: u, isRightLabel: y }) => e(be, { children: [e("div", { className: "ul-card-maxdiff__option-control " + (q ? "smiley" : ""), children: q ? e(Ae, { ariaPressed: u, className: u ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected good" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: f, html: q, id: `smiley-good-${p}`, onClick: w(p, le.LEFT) }) : e(he, { allowTextEntry: !1, ariaLabel: `bestLabel-${T}`, border: m, choiceStyle: g, error: !1, id: `${p}`, isRadio: !0, isSelected: u, onUserInputChanged: w(p, le.LEFT), useMobileStyling: S }) }), e("div", { className: "ul-card-maxdiff__option-label", children: T }), e("div", { className: "ul-card-maxdiff__option-control " + (_ ? "smiley" : ""), children: _ ? e(Ae, { ariaPressed: y, className: y ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected bad" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: f, html: _, id: `smiley-bad-${p}`, onClick: w(p, le.RIGHT) }) : e(he, { allowTextEntry: !1, ariaLabel: `worstLabel-${T}`, border: m, choiceStyle: g, error: !1, id: `${p}`, isRadio: !0, isSelected: y, onUserInputChanged: w(p, le.RIGHT), useMobileStyling: S }) })] }))] }) })] }, o);
|
|
457
|
+
}, Ae = ({ enableCspTrustedTypes: n, ariaPressed: i, className: c, html: r, id: t, onClick: o }) => {
|
|
458
|
+
const b = ge(() => He(r, n), [n, r]);
|
|
459
|
+
return e("span", { "aria-pressed": i, className: c, dangerouslySetInnerHTML: { __html: b }, id: t, onClick: o, tabIndex: 0, type: "button" });
|
|
460
|
+
}, et = ({ className: n, labels: i, message: c, next: r, properties: t, questionId: o, type: b, onSubmitButtonClick: v, options: d, showIndividualSubmit: h = !1 }) => {
|
|
461
|
+
const a = te(null), g = te(0), s = te(0), I = te(null), m = te(!1), S = te([]), [f, w] = $(() => (t == null ? void 0 : t.required) === !0), [_, q] = $(() => d.map((N) => ({ ...N, rank: null }))), E = ge(() => Array.from({ length: d.length }, (N, O) => O + 1), [d.length]), { isLongFormSurvey: P, focusedQuestionId: M, setFocusedQuestionId: L, useMobileStyling: p, isPreview: T, headers: u } = V((N) => ({ useMobileStyling: N.useMobileStyling, isLongFormSurvey: ie(N.studyType), focusedQuestionId: N.focusedQuestionId, setFocusedQuestionId: N.setFocusedQuestionId, isPreview: N.isPreview, headers: N.headers })), y = (u == null ? void 0 : u["userleap-platform"]) === "android", x = p && !T && !y, C = !x && !y, D = P && M === o, l = (N) => {
|
|
462
|
+
N.preventDefault(), Y(_), v && v();
|
|
463
|
+
}, k = (N, O) => {
|
|
464
|
+
q((Q) => {
|
|
465
|
+
const R = parseInt(O), H = Q.map((G) => ({ ...G }));
|
|
466
|
+
H.some((G) => G.rank == null) && H.forEach((G, me) => G.rank = me + 1);
|
|
467
|
+
const se = H.findIndex((G) => G.id === N);
|
|
468
|
+
if (se === -1) return Q;
|
|
469
|
+
const j = H[se].rank;
|
|
470
|
+
return R < j ? H.forEach((G) => {
|
|
471
|
+
G.id !== N && G.rank >= R && G.rank < j && (G.rank = G.rank + 1);
|
|
472
|
+
}) : R > j && H.forEach((G) => {
|
|
473
|
+
G.id !== N && G.rank > j && G.rank <= R && (G.rank = G.rank - 1);
|
|
474
|
+
}), H[se].rank = R, H.sort((G, me) => G.rank - me.rank), re(H), H;
|
|
475
|
+
});
|
|
476
|
+
}, B = (N, O) => {
|
|
477
|
+
for (let Q = 0; Q < S.current.length; Q++) {
|
|
478
|
+
const R = S.current[Q];
|
|
479
|
+
if (!R || R === I.current) continue;
|
|
480
|
+
const H = R.getBoundingClientRect();
|
|
481
|
+
if (N >= H.left && N <= H.right && O >= H.top && O <= H.bottom) return { element: R, index: Q };
|
|
482
|
+
}
|
|
483
|
+
return null;
|
|
484
|
+
}, A = (N) => (O) => {
|
|
485
|
+
if (!x) return;
|
|
486
|
+
O.preventDefault(), O.stopPropagation(), m.current = !0, a.current = N;
|
|
487
|
+
const Q = O.touches[0];
|
|
488
|
+
g.current = Q.clientY, s.current = Q.clientY;
|
|
489
|
+
const R = O.currentTarget.closest(".ul-card-rank__option");
|
|
490
|
+
R && (I.current = R, R.classList.add("is-dragging"));
|
|
491
|
+
}, F = (N) => {
|
|
492
|
+
if (!x || !m.current || a.current === null) return;
|
|
493
|
+
N.preventDefault(), N.stopPropagation();
|
|
494
|
+
const O = N.touches[0];
|
|
495
|
+
s.current = O.clientY;
|
|
496
|
+
const Q = s.current - g.current;
|
|
497
|
+
I.current && (I.current.style.transform = `translateY(${Q}px)`, I.current.style.zIndex = "1000"), S.current.forEach((H) => {
|
|
498
|
+
H && H !== I.current && H.classList.remove("is-drop-target");
|
|
499
|
+
});
|
|
500
|
+
const R = B(O.clientX, O.clientY);
|
|
501
|
+
R && R.element.classList.add("is-drop-target");
|
|
502
|
+
}, W = (N) => {
|
|
503
|
+
if (!x || !m.current || a.current === null) return;
|
|
504
|
+
N.preventDefault(), N.stopPropagation();
|
|
505
|
+
const O = N.changedTouches[0], Q = B(O.clientX, O.clientY);
|
|
506
|
+
I.current && (I.current.style.transform = "", I.current.style.zIndex = "", I.current.classList.remove("is-dragging")), S.current.forEach((R) => {
|
|
507
|
+
R && R.classList.remove("is-drop-target");
|
|
508
|
+
}), Q && Q.index !== a.current && Z(a.current, Q.index), a.current = null, I.current = null, m.current = !1;
|
|
509
|
+
}, Z = (N, O) => {
|
|
510
|
+
q((Q) => {
|
|
511
|
+
const R = Q.map((se) => ({ ...se })), [H] = R.splice(N, 1);
|
|
512
|
+
return R.splice(O, 0, H), R.forEach((se, j) => {
|
|
513
|
+
se.rank = j + 1;
|
|
514
|
+
}), re(R), R;
|
|
515
|
+
});
|
|
516
|
+
}, Y = (N) => {
|
|
517
|
+
const O = {};
|
|
518
|
+
N.reduce((Q, R) => (Q[R.id] = R.rank, Q), O), r({ value: O, questionId: o, type: b }, !0);
|
|
519
|
+
}, re = (N) => {
|
|
520
|
+
w(!1), P && Y(N);
|
|
521
|
+
}, { left: ae, right: ve } = i, xe = d.length, er = (N) => {
|
|
522
|
+
N.preventDefault(), N.currentTarget.classList.add("is-drop-target");
|
|
523
|
+
}, rr = (N) => {
|
|
524
|
+
N.currentTarget.classList.remove("is-drop-target");
|
|
525
|
+
}, tr = (N) => {
|
|
526
|
+
a.current = null, N.currentTarget.classList.remove("is-dragging");
|
|
527
|
+
};
|
|
528
|
+
return e("form", { className: U(n, "ul-card-rank", "fade-in-transition", P && !D && "ul-card--unfocused"), onClick: P ? () => {
|
|
529
|
+
P && M !== o && L(o);
|
|
530
|
+
} : void 0, onSubmit: l, children: [e(ee, { isRequired: t == null ? void 0 : t.required, message: c, properties: t }), e(ce, { properties: t, children: e(be, y ? { children: [e(ne, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", ae] }) }), e("ol", { className: "ul-card-rank__list", children: _.map(({ id: N, label: O, rank: Q }) => e("li", { className: "ul-card-rank__option", children: [e("select", { "aria-label": `Rank for ${O}`, className: U("ul-card-rank__select", Q == null && "ul-card-rank__select--placeholder"), name: `rank[${N}]`, onChange: (R) => k(N, R.currentTarget.value), value: Q ?? "", children: [Q == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), E.map((R) => e("option", { className: "ul-card-rank__select-option", value: R, children: R }, `${R}-${o}`))] }), e("span", { children: O })] }, N)) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [xe, " - ", ve] }) })] }), h && e(ye, { handleSubmit: l, isSubmitDisabled: f })] }), !P && e(de, { children: e("div", { className: "ul-card__button-wrapper", children: e(z, { disabled: f, children: ue(t) }) }) })] } : { children: [e(ne, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", ae] }) }), e("ol", { className: "ul-card-rank__list", onDragOver: y ? void 0 : (N) => {
|
|
531
|
+
N.preventDefault(), N.dataTransfer && (N.dataTransfer.dropEffect = "move");
|
|
532
|
+
}, children: _.map(({ id: N, label: O, rank: Q }, R) => {
|
|
533
|
+
return e("li", { className: "ul-card-rank__option", draggable: !!C || void 0, onDragEnd: C ? tr : void 0, onDragEnter: C ? er : void 0, onDragLeave: C ? rr : void 0, onDragStart: C ? (se = R, (j) => {
|
|
534
|
+
a.current = se, j.dataTransfer && (j.dataTransfer.effectAllowed = "move", j.dataTransfer.setData("text/plain", String(se)), j.currentTarget.classList.add("is-dragging"));
|
|
535
|
+
}) : void 0, onDrop: C ? (H = R, (j) => {
|
|
536
|
+
var me, Ee;
|
|
537
|
+
j.preventDefault(), j.currentTarget.classList.remove("is-drop-target");
|
|
538
|
+
const G = a.current;
|
|
539
|
+
a.current = null, (Ee = (me = j.currentTarget.closest(".ul-card-rank__list")) == null ? void 0 : me.querySelector(".is-dragging")) == null || Ee.classList.remove("is-dragging"), G != null && G !== H && Z(G, H);
|
|
540
|
+
}) : void 0, ref: (j) => S.current[R] = j, children: [e("select", { "aria-label": `Rank for ${O}`, className: U("ul-card-rank__select", Q == null && "ul-card-rank__select--placeholder"), name: `rank[${N}]`, onChange: (j) => k(N, j.currentTarget.value), value: Q ?? "", children: [Q == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), E.map((j) => e("option", { className: "ul-card-rank__select-option", value: j, children: j }, `${j}-${o}`))] }), e("span", { children: O }), !y && e("button", { "aria-label": `Drag ${O} to reorder`, className: "ul-card-rank__drag-btn", onTouchEnd: x ? W : void 0, onTouchMove: x ? F : void 0, onTouchStart: x ? A(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" }) }) })] }, N);
|
|
541
|
+
var H, se;
|
|
542
|
+
}) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [xe, " - ", ve] }) })] }), h && e(ye, { handleSubmit: l, isSubmitDisabled: f })] }), !P && e(de, { children: e("div", { className: "ul-card__button-wrapper", children: e(z, { disabled: f, children: ue(t) }) }) })] }) })] }, o);
|
|
543
|
+
}, rt = /* @__PURE__ */ new Set(["open", "matrix", "multipleselect", "multiplechoice", "rankorder"]), $e = ({ cardInstance: n, moveToNextQuestion: i, showIndividualSubmit: c, submitQuestion: r, updateCardValues: t }) => {
|
|
544
|
+
const { isLongFormSurvey: o } = V((s) => ({ isLongFormSurvey: ie(s.studyType) }));
|
|
545
|
+
if (!n) return null;
|
|
546
|
+
const { name: b, type: v, props: d } = n, h = c && rt.has(v), a = { className: "ul-card", next: (s, I, m = !0) => r(s, I && m), questionId: b, type: v, showIndividualSubmit: c, ...h ? { next: (s, I) => {
|
|
547
|
+
t(s.questionId, s, I ?? !0);
|
|
548
|
+
}, onSubmitButtonClick: () => i(b) } : {} }, g = (() => {
|
|
549
|
+
switch (v) {
|
|
550
|
+
case "consentlegal":
|
|
551
|
+
return e(kr, { ...a, ...d });
|
|
552
|
+
case "likert":
|
|
553
|
+
return e(_r, { ...a, ...d });
|
|
554
|
+
case "matrix":
|
|
555
|
+
return e(Lr, { ...a, ...d });
|
|
556
|
+
case "maxdiff":
|
|
557
|
+
return e(Jr, { ...a, ...d });
|
|
558
|
+
case "multiplechoice":
|
|
559
|
+
return e(Pr, { ...a, ...d });
|
|
560
|
+
case "multipleselect":
|
|
561
|
+
return e(Dr, { ...a, ...d });
|
|
562
|
+
case "nps":
|
|
563
|
+
return e(Rr, { ...a, ...d });
|
|
564
|
+
case "open":
|
|
565
|
+
return e(Mr, { ...a, ...d });
|
|
566
|
+
case "rankorder":
|
|
567
|
+
return e(et, { ...a, ...d });
|
|
568
|
+
case "recordedtask":
|
|
569
|
+
return e(Hr, { ...a, ...d });
|
|
570
|
+
case "texturlprompt":
|
|
571
|
+
return e(Vr, { ...a, ...d });
|
|
572
|
+
case "thanks":
|
|
573
|
+
return e(jr, { ...a, ...d });
|
|
574
|
+
case "uploading":
|
|
575
|
+
return e(Wr, { ...a, ...d });
|
|
576
|
+
case "videovoice":
|
|
577
|
+
return e(Zr, { ...a, ...d });
|
|
578
|
+
default:
|
|
579
|
+
return null;
|
|
580
|
+
}
|
|
581
|
+
})();
|
|
582
|
+
return g ? o ? e("div", { className: "ul-card-scroll-wrapper", children: g }, b) : g : null;
|
|
583
|
+
}, tt = ({ isSubmitDisabled: n = !1, onSubmit: i, buttonText: c }) => {
|
|
584
|
+
var I;
|
|
585
|
+
const { cards: r, forceBrandedLogo: t, index: o, marketingUrl: b, showSurveyBrand: v, slugName: d, surveyId: h, useMobileStyling: a } = V((m) => ({ cards: m.cards, forceBrandedLogo: m.forceBrandedLogo, index: m.index, marketingUrl: m.marketingUrl, showSurveyBrand: m.showSurveyBrand, slugName: m.slugName, surveyId: m.surveyId, useMobileStyling: m.useMobileStyling })), g = ((I = r[o]) == null ? void 0 : I.type) === "thanks", s = or({ marketingUrl: b, slugName: d, surveyId: h, forceBrandedLogo: t });
|
|
586
|
+
return e("footer", { className: U("long-form-question-footer-container", a && "long-form-question-footer-container--mobile", g && "long-form-question-footer-container-center"), children: [g && t ? e(lr, { marketingUrlLink: s }) : e("div", { className: "long-form-question-footer-container-logo", children: v ? e(dr, { forceBrandedLogo: t, marketingUrlLink: s }) : null }), !g && e("div", { className: U("ul-card__button-wrapper", "ul-card-vertical__button-wrapper", "long-form-question-footer-container-actions"), children: e(z, { className: U("long-form-button", n && "sprig-button-disabled"), disabled: n, onClick: i, children: e("span", { className: "long-form-button-text-container", children: c ?? e(cr, { stroke: "white" }) }) }) })] });
|
|
587
|
+
}, lt = ({ cards: n, next: i, previousResponses: c }) => {
|
|
588
|
+
var T;
|
|
589
|
+
const [r, t] = $({}), [o, b] = $({}), v = ge(() => ({ ...c, ...ur(n.map((u) => {
|
|
590
|
+
var y, x;
|
|
591
|
+
return { ...u, value: ((y = r[u.name]) == null ? void 0 : y.value) ?? null, secondaryValue: ((x = r[u.name]) == null ? void 0 : x.secondaryValue) ?? null };
|
|
592
|
+
})) }), [c, r, n]), d = pr(n, v), { isLongFormSurvey: h, focusedQuestionId: a, setFocusedQuestionId: g } = V((u) => ({ isLongFormSurvey: ie(u.studyType), focusedQuestionId: u.focusedQuestionId, setFocusedQuestionId: u.setFocusedQuestionId })), s = te(null), I = te(!1), m = te(null), S = fe((u) => {
|
|
593
|
+
var D, l;
|
|
594
|
+
I.current = !0;
|
|
595
|
+
const y = n.findIndex((k) => k.name === u);
|
|
596
|
+
if (!h || u === null || y === -1) return void (I.current = !1);
|
|
597
|
+
const x = (D = s.current) == null ? void 0 : D.querySelectorAll(".ul-card-scroll-wrapper")[y], C = (l = s.current) == null ? void 0 : l.closest(".ul-card-main-content");
|
|
598
|
+
if (x && C) {
|
|
599
|
+
if (x && C) {
|
|
600
|
+
const k = x.getBoundingClientRect(), B = C.getBoundingClientRect(), A = k.top - B.top + C.scrollTop, F = A + k.height / 2, W = window.innerHeight - 157;
|
|
601
|
+
let Z;
|
|
602
|
+
k.height >= W ? Z = A : Z = F - C.clientHeight / 2;
|
|
603
|
+
const Y = C.clientHeight, re = C.scrollHeight - Y, ae = Math.max(0, Math.min(Z, re));
|
|
604
|
+
C.scrollTo({ top: ae, behavior: "smooth" }), setTimeout(() => {
|
|
605
|
+
I.current = !1;
|
|
606
|
+
}, 500);
|
|
607
|
+
}
|
|
608
|
+
} else I.current = !1;
|
|
609
|
+
}, [h, n]);
|
|
610
|
+
function f(u, y) {
|
|
611
|
+
return u.map((x) => {
|
|
612
|
+
const C = y[x.name], D = d.find((l) => l.name === x.name);
|
|
613
|
+
return { ...C, questionText: D ? Ue(D) : void 0 };
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
J(() => {
|
|
617
|
+
a !== null && n.findIndex((u) => u.name === a) !== -1 || g(n[0].name);
|
|
618
|
+
}, [n, a, g]);
|
|
619
|
+
const w = (u) => {
|
|
620
|
+
if (!h) return;
|
|
621
|
+
const y = n.findIndex((x) => x.name === u) + 1;
|
|
622
|
+
if (y < n.length) {
|
|
623
|
+
const x = n[y].name;
|
|
624
|
+
g(x);
|
|
625
|
+
} else g(u);
|
|
626
|
+
};
|
|
627
|
+
J(() => {
|
|
628
|
+
h && a !== null && (m.current !== a ? S(a) : m.current = null);
|
|
629
|
+
}, [a, h, S]);
|
|
630
|
+
const _ = fe(() => {
|
|
631
|
+
var B, A;
|
|
632
|
+
if (I.current) return;
|
|
633
|
+
const u = (B = s.current) == null ? void 0 : B.closest(".ul-card-main-content");
|
|
634
|
+
if (!u) return;
|
|
635
|
+
const y = (A = s.current) == null ? void 0 : A.querySelectorAll(".ul-card-scroll-wrapper");
|
|
636
|
+
if (!y || y.length === 0) return;
|
|
637
|
+
const x = u.getBoundingClientRect(), C = x.top + x.height / 2;
|
|
638
|
+
let D = 0, l = 1 / 0;
|
|
639
|
+
y.forEach((F, W) => {
|
|
640
|
+
const Z = F.getBoundingClientRect(), Y = Z.top + Z.height / 2, re = Math.abs(C - Y);
|
|
641
|
+
re < l && (l = re, D = W);
|
|
642
|
+
});
|
|
643
|
+
const k = n[D];
|
|
644
|
+
m.current = k.name, g(k.name);
|
|
645
|
+
}, [n, g]);
|
|
646
|
+
J(() => {
|
|
647
|
+
var y;
|
|
648
|
+
if (!h) return;
|
|
649
|
+
const u = ((y = s.current) == null ? void 0 : y.closest(".ul-card__container")) || null;
|
|
650
|
+
return u && u.addEventListener("scroll", _, { passive: !0 }), () => {
|
|
651
|
+
u && u.removeEventListener("scroll", _);
|
|
652
|
+
};
|
|
653
|
+
}, [_, h]);
|
|
654
|
+
const q = ge(() => Object.values(o).every((u, y) => {
|
|
655
|
+
var C;
|
|
656
|
+
const x = n[y];
|
|
657
|
+
return !(!(x != null && x.props) || !("properties" in x.props) || ((C = x.props.properties) == null ? void 0 : C.required) !== !1) || u;
|
|
658
|
+
}), [o, n]), E = async (u, y, x) => {
|
|
659
|
+
return b((D) => ({ ...D, [u]: x })), await (C = (D) => ({ ...D, [u]: y }), new Promise((D) => {
|
|
660
|
+
t((l) => {
|
|
661
|
+
const k = C(l);
|
|
662
|
+
return D(k), k;
|
|
663
|
+
});
|
|
664
|
+
}));
|
|
665
|
+
var C;
|
|
666
|
+
};
|
|
667
|
+
J(() => {
|
|
668
|
+
if (!h) return;
|
|
669
|
+
const u = {};
|
|
670
|
+
n.forEach((y) => {
|
|
671
|
+
var C, D;
|
|
672
|
+
const x = y;
|
|
673
|
+
(D = (C = x.props) == null ? void 0 : C.properties) != null && D.required || (u[x.name] = { value: null, questionId: x.name, type: x.type });
|
|
674
|
+
}), t(u), b({});
|
|
675
|
+
}, [n, h]);
|
|
676
|
+
const P = async (u, y) => {
|
|
677
|
+
if (h) {
|
|
678
|
+
const x = await E(u.questionId, u, y), C = M(u.type), D = L(u.type);
|
|
679
|
+
if (C && w(u.questionId), D && y) {
|
|
680
|
+
const l = f(n, x);
|
|
681
|
+
i(l);
|
|
682
|
+
}
|
|
683
|
+
} else {
|
|
684
|
+
const x = d.find((D) => D.name === u.questionId), C = { ...u, questionText: x ? Ue(x) : void 0 };
|
|
685
|
+
i([C]);
|
|
686
|
+
}
|
|
687
|
+
}, M = (u) => (/* @__PURE__ */ new Set(["nps", "likert", "multiplechoice"])).has(u), L = (u) => (/* @__PURE__ */ new Set(["videovoice", "consentlegal", "texturlprompt", "maxdiff"])).has(u), p = ((T = n[0]) == null ? void 0 : T.type) === "thanks";
|
|
688
|
+
return h ? e("div", { className: "ul-card-list-container--longform", "data-testid": "ui-container", ref: s, children: [e(zr, { value: c, children: d.map((u, y) => e($e, { cardInstance: u, moveToNextQuestion: w, showIndividualSubmit: h && n.length > 1 && y < n.length - 1, submitQuestion: P, updateCardValues: E }, (u == null ? void 0 : u.name) || y)) }), !p && e(tt, { isSubmitDisabled: Object.keys(r).length < n.length || !q, onSubmit: function() {
|
|
689
|
+
const u = f(n, r);
|
|
690
|
+
i(u);
|
|
691
|
+
} })] }) : e(be, { children: [e("div", { "data-testid": "ui-container", style: { display: "none" } }), d.map((u, y) => e($e, { cardInstance: u, moveToNextQuestion: w, showIndividualSubmit: h && n.length > 1 && y < n.length - 1, submitQuestion: P, updateCardValues: E }, (u == null ? void 0 : u.name) || y))] });
|
|
692
|
+
};
|
|
693
|
+
export {
|
|
694
|
+
lt as PageCard
|
|
695
|
+
};
|