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