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