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