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