@sidebandai/sideband-react 0.0.0-stage → 1.4.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +137 -2
- package/dist/SurveyRenderer-BkUNLbxJ.js +1185 -0
- package/dist/client/create-sideband-client.d.ts +2 -0
- package/dist/client/create-sideband-client.d.ts.map +1 -0
- package/dist/components/SurveyFab.d.ts +11 -0
- package/dist/components/SurveyFab.d.ts.map +1 -0
- package/dist/components/SurveyProgress.d.ts +6 -0
- package/dist/components/SurveyProgress.d.ts.map +1 -0
- package/dist/components/SurveyQuestionView.d.ts +11 -0
- package/dist/components/SurveyQuestionView.d.ts.map +1 -0
- package/dist/components/SurveyRenderer.d.ts +7 -0
- package/dist/components/SurveyRenderer.d.ts.map +1 -0
- package/dist/components/SurveySheet.d.ts +10 -0
- package/dist/components/SurveySheet.d.ts.map +1 -0
- package/dist/components/SurveySnackbar.d.ts +8 -0
- package/dist/components/SurveySnackbar.d.ts.map +1 -0
- package/dist/components/SurveyThankYou.d.ts +9 -0
- package/dist/components/SurveyThankYou.d.ts.map +1 -0
- package/dist/context/SidebandProvider.d.ts +8 -0
- package/dist/context/SidebandProvider.d.ts.map +1 -0
- package/dist/context/sideband-context.d.ts +18 -0
- package/dist/context/sideband-context.d.ts.map +1 -0
- package/dist/hooks/useSideband.d.ts +2 -0
- package/dist/hooks/useSideband.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +183 -0
- package/dist/preview.d.ts +22 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +50 -0
- package/dist/style.css +2 -0
- package/dist/style.css.d.ts +2 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +46 -4
|
@@ -0,0 +1,1185 @@
|
|
|
1
|
+
import { buildFabTitle as e, getChoiceValue as t, isPositiveSentimentChoice as n, isSystemOtherChoice as r, resolveSnackbarPresentation as i } from "@sidebandai/sideband-core";
|
|
2
|
+
import { memo as a, useCallback as o, useEffect as s, useId as c, useLayoutEffect as l, useRef as u, useState as d, useSyncExternalStore as f } from "react";
|
|
3
|
+
import { createPortal as p } from "react-dom";
|
|
4
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
5
|
+
//#region ../design-tokens/src/index.ts
|
|
6
|
+
var _ = "rgba(0, 0, 0, 0)", v = (e, t = 1) => ({
|
|
7
|
+
hex: e,
|
|
8
|
+
alpha: t
|
|
9
|
+
}), y = (e, t) => [
|
|
10
|
+
{
|
|
11
|
+
variable: `--sb-theme-choice-${e}-background`,
|
|
12
|
+
path: [
|
|
13
|
+
"choice",
|
|
14
|
+
e,
|
|
15
|
+
"background"
|
|
16
|
+
],
|
|
17
|
+
fallback: t[0]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
variable: `--sb-theme-choice-${e}-foreground`,
|
|
21
|
+
path: [
|
|
22
|
+
"choice",
|
|
23
|
+
e,
|
|
24
|
+
"foreground"
|
|
25
|
+
],
|
|
26
|
+
fallback: t[1]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
variable: `--sb-theme-choice-${e}-border`,
|
|
30
|
+
path: [
|
|
31
|
+
"choice",
|
|
32
|
+
e,
|
|
33
|
+
"border"
|
|
34
|
+
],
|
|
35
|
+
fallback: t[2]
|
|
36
|
+
}
|
|
37
|
+
], b = (e, t) => [
|
|
38
|
+
{
|
|
39
|
+
variable: `--sb-theme-button-${e}-foreground`,
|
|
40
|
+
path: [
|
|
41
|
+
"button",
|
|
42
|
+
e,
|
|
43
|
+
"foreground"
|
|
44
|
+
],
|
|
45
|
+
fallback: t[0]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
variable: `--sb-theme-button-${e}-background`,
|
|
49
|
+
path: [
|
|
50
|
+
"button",
|
|
51
|
+
e,
|
|
52
|
+
"background"
|
|
53
|
+
],
|
|
54
|
+
fallback: t[1]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
variable: `--sb-theme-button-${e}-hover-background`,
|
|
58
|
+
path: [
|
|
59
|
+
"button",
|
|
60
|
+
e,
|
|
61
|
+
"hoverBackground"
|
|
62
|
+
],
|
|
63
|
+
fallback: t[2]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
variable: `--sb-theme-button-${e}-pressed-background`,
|
|
67
|
+
path: [
|
|
68
|
+
"button",
|
|
69
|
+
e,
|
|
70
|
+
"pressedBackground"
|
|
71
|
+
],
|
|
72
|
+
fallback: t[3]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
variable: `--sb-theme-button-${e}-disabled-background`,
|
|
76
|
+
path: [
|
|
77
|
+
"button",
|
|
78
|
+
e,
|
|
79
|
+
"disabledBackground"
|
|
80
|
+
],
|
|
81
|
+
fallback: t[4]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
variable: `--sb-theme-button-${e}-disabled-foreground`,
|
|
85
|
+
path: [
|
|
86
|
+
"button",
|
|
87
|
+
e,
|
|
88
|
+
"disabledForeground"
|
|
89
|
+
],
|
|
90
|
+
fallback: t[5]
|
|
91
|
+
}
|
|
92
|
+
], x = [
|
|
93
|
+
{
|
|
94
|
+
variable: "--sb-theme-sheet-background",
|
|
95
|
+
path: ["sheet", "background"],
|
|
96
|
+
fallback: v("#FFFFFF")
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
variable: "--sb-theme-sheet-scrim",
|
|
100
|
+
path: ["sheet", "scrim"],
|
|
101
|
+
fallback: v("#000000", .5)
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
variable: "--sb-theme-sheet-divider",
|
|
105
|
+
path: ["sheet", "divider"],
|
|
106
|
+
fallback: v("#E5E5E5")
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
variable: "--sb-theme-sheet-progress-track",
|
|
110
|
+
path: ["sheet", "progressTrack"],
|
|
111
|
+
fallback: v("#000000", .12)
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
variable: "--sb-theme-sheet-progress-fill",
|
|
115
|
+
path: ["sheet", "progressFill"],
|
|
116
|
+
fallback: v("#000000")
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
variable: "--sb-theme-sheet-close-button-background",
|
|
120
|
+
path: ["sheet", "closeButtonBackground"],
|
|
121
|
+
fallback: v("#000000", 0)
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
variable: "--sb-theme-sheet-close-button-foreground",
|
|
125
|
+
path: ["sheet", "closeButtonForeground"],
|
|
126
|
+
fallback: v("#000000")
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
variable: "--sb-theme-content-heading",
|
|
130
|
+
path: ["content", "heading"],
|
|
131
|
+
fallback: v("#000000")
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
variable: "--sb-theme-content-body",
|
|
135
|
+
path: ["content", "body"],
|
|
136
|
+
fallback: v("#333030")
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
variable: "--sb-theme-content-helper",
|
|
140
|
+
path: ["content", "helper"],
|
|
141
|
+
fallback: v("#5C5C5C")
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
variable: "--sb-theme-content-error",
|
|
145
|
+
path: ["content", "error"],
|
|
146
|
+
fallback: v("#B42318")
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
variable: "--sb-theme-completion-outer-background",
|
|
150
|
+
path: ["completion", "outerBackground"],
|
|
151
|
+
fallback: v("#E8E8E8")
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
variable: "--sb-theme-completion-inner-background",
|
|
155
|
+
path: ["completion", "innerBackground"],
|
|
156
|
+
fallback: v("#000000")
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
variable: "--sb-theme-completion-glyph",
|
|
160
|
+
path: ["completion", "glyph"],
|
|
161
|
+
fallback: v("#FFFFFF")
|
|
162
|
+
},
|
|
163
|
+
...y("default", [
|
|
164
|
+
v("#FFFFFF"),
|
|
165
|
+
v("#000000"),
|
|
166
|
+
v("#DBDBDB")
|
|
167
|
+
]),
|
|
168
|
+
...y("hover", [
|
|
169
|
+
v("#F5F5F5"),
|
|
170
|
+
v("#000000"),
|
|
171
|
+
v("#DBDBDB")
|
|
172
|
+
]),
|
|
173
|
+
...y("pressed", [
|
|
174
|
+
v("#000000"),
|
|
175
|
+
v("#FFFFFF"),
|
|
176
|
+
v("#000000")
|
|
177
|
+
]),
|
|
178
|
+
...y("selected", [
|
|
179
|
+
v("#000000"),
|
|
180
|
+
v("#FFFFFF"),
|
|
181
|
+
v("#000000")
|
|
182
|
+
]),
|
|
183
|
+
...y("disabled", [
|
|
184
|
+
v("#F2F2F2"),
|
|
185
|
+
v("#8A8A8A"),
|
|
186
|
+
v("#E5E5E5")
|
|
187
|
+
]),
|
|
188
|
+
...b("primary", [
|
|
189
|
+
v("#FFFFFF"),
|
|
190
|
+
v("#121212"),
|
|
191
|
+
v("#292929"),
|
|
192
|
+
v("#000000"),
|
|
193
|
+
v("#E5E5E5"),
|
|
194
|
+
v("#8A8A8A")
|
|
195
|
+
]),
|
|
196
|
+
...b("secondary", [
|
|
197
|
+
v("#000000"),
|
|
198
|
+
v("#F2F2F2"),
|
|
199
|
+
v("#E8E8E8"),
|
|
200
|
+
v("#DBDBDB"),
|
|
201
|
+
v("#E5E5E5"),
|
|
202
|
+
v("#8A8A8A")
|
|
203
|
+
]),
|
|
204
|
+
...b("tertiary", [
|
|
205
|
+
v("#000000"),
|
|
206
|
+
v("#FFFFFF"),
|
|
207
|
+
v("#F5F5F5"),
|
|
208
|
+
v("#E8E8E8"),
|
|
209
|
+
v("#E5E5E5"),
|
|
210
|
+
v("#8A8A8A")
|
|
211
|
+
]),
|
|
212
|
+
{
|
|
213
|
+
variable: "--sb-theme-input-background",
|
|
214
|
+
path: ["input", "background"],
|
|
215
|
+
fallback: v("#FFFFFF")
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
variable: "--sb-theme-input-foreground",
|
|
219
|
+
path: ["input", "foreground"],
|
|
220
|
+
fallback: v("#000000")
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
variable: "--sb-theme-input-placeholder",
|
|
224
|
+
path: ["input", "placeholder"],
|
|
225
|
+
fallback: v("#000000", .4)
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
variable: "--sb-theme-input-border",
|
|
229
|
+
path: ["input", "border"],
|
|
230
|
+
fallback: v("#000000", .18)
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
variable: "--sb-theme-input-focused-border",
|
|
234
|
+
path: ["input", "focusedBorder"],
|
|
235
|
+
fallback: v("#000000", .7)
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
variable: "--sb-theme-input-error-border",
|
|
239
|
+
path: ["input", "errorBorder"],
|
|
240
|
+
fallback: v("#B42318")
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
variable: "--sb-theme-input-disabled-background",
|
|
244
|
+
path: ["input", "disabledBackground"],
|
|
245
|
+
fallback: v("#F2F2F2")
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
variable: "--sb-theme-input-disabled-foreground",
|
|
249
|
+
path: ["input", "disabledForeground"],
|
|
250
|
+
fallback: v("#8A8A8A")
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
variable: "--sb-theme-fab-background",
|
|
254
|
+
path: ["fab", "background"],
|
|
255
|
+
fallback: v("#000000")
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
variable: "--sb-theme-fab-foreground",
|
|
259
|
+
path: ["fab", "foreground"],
|
|
260
|
+
fallback: v("#FFFFFF")
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
variable: "--sb-theme-fab-border",
|
|
264
|
+
path: ["fab", "border"],
|
|
265
|
+
fallback: v("#FFFFFF", .15)
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
variable: "--sb-theme-fab-accent-primary",
|
|
269
|
+
path: ["fab", "accentPrimary"],
|
|
270
|
+
fallback: v("#000000")
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
variable: "--sb-theme-fab-accent-secondary",
|
|
274
|
+
path: ["fab", "accentSecondary"],
|
|
275
|
+
fallback: v("#FFFFFF")
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
variable: "--sb-theme-fab-timer-track",
|
|
279
|
+
path: ["fab", "timerTrack"],
|
|
280
|
+
fallback: v("#000000", .16)
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
variable: "--sb-theme-fab-timer-fill",
|
|
284
|
+
path: ["fab", "timerFill"],
|
|
285
|
+
fallback: v("#000000")
|
|
286
|
+
}
|
|
287
|
+
];
|
|
288
|
+
x.map((e) => e.variable), Object.fromEntries(x.map((e) => [e.variable, C(e.fallback)]));
|
|
289
|
+
function S(e) {
|
|
290
|
+
return e && typeof e == "object" && !Array.isArray(e) ? e : {};
|
|
291
|
+
}
|
|
292
|
+
function C(e, t = _) {
|
|
293
|
+
return !e || typeof e.hex != "string" || !/^#[0-9a-fA-F]{6}$/.test(e.hex) || !Number.isFinite(e.alpha) || e.alpha < 0 || e.alpha > 1 ? t : `rgba(${Number.parseInt(e.hex.slice(1, 3), 16)}, ${Number.parseInt(e.hex.slice(3, 5), 16)}, ${Number.parseInt(e.hex.slice(5, 7), 16)}, ${e.alpha})`;
|
|
294
|
+
}
|
|
295
|
+
function w(e, t) {
|
|
296
|
+
let n = e;
|
|
297
|
+
for (let e of t) n = S(n)[e];
|
|
298
|
+
return n;
|
|
299
|
+
}
|
|
300
|
+
function T(e) {
|
|
301
|
+
return Object.fromEntries(x.map((t) => [t.variable, C(w(e, t.path), C(t.fallback))]));
|
|
302
|
+
}
|
|
303
|
+
function E(e, t) {
|
|
304
|
+
return v(`#${[
|
|
305
|
+
1,
|
|
306
|
+
3,
|
|
307
|
+
5
|
|
308
|
+
].map((n) => {
|
|
309
|
+
let r = Number.parseInt(e.hex.slice(n, n + 2), 16), i = Number.parseInt(t.hex.slice(n, n + 2), 16);
|
|
310
|
+
return Math.round(r * e.alpha + i * (1 - e.alpha)).toString(16).padStart(2, "0");
|
|
311
|
+
}).join("")}`, 1);
|
|
312
|
+
}
|
|
313
|
+
function ee(e) {
|
|
314
|
+
let t = (t) => {
|
|
315
|
+
let n = x.find((e) => e.path.join(".") === t.join(".")), r = w(e, t);
|
|
316
|
+
return C(r, "") ? r : n.fallback;
|
|
317
|
+
}, n = {
|
|
318
|
+
...t(["sheet", "background"]),
|
|
319
|
+
alpha: 1
|
|
320
|
+
}, r = t(["content", "heading"]), i = t([
|
|
321
|
+
"choice",
|
|
322
|
+
"selected",
|
|
323
|
+
"background"
|
|
324
|
+
]), a = E(i, n), o = [
|
|
325
|
+
1,
|
|
326
|
+
3,
|
|
327
|
+
5
|
|
328
|
+
].map((e) => Number.parseInt(n.hex.slice(e, e + 2), 16) / 255), s = o[0] * .2126 + o[1] * .7152 + o[2] * .0722 < .5, c = n.hex.toUpperCase() === (s ? "#000000" : "#FFFFFF"), l = (e, t) => C(E({
|
|
329
|
+
...e,
|
|
330
|
+
alpha: e.alpha * t
|
|
331
|
+
}, n)), u = E({
|
|
332
|
+
...r,
|
|
333
|
+
alpha: r.alpha * (s ? c ? .15 : .08 : .14)
|
|
334
|
+
}, n), d = (e) => [
|
|
335
|
+
1,
|
|
336
|
+
3,
|
|
337
|
+
5
|
|
338
|
+
].reduce((t, n, r) => t + Number.parseInt(e.hex.slice(n, n + 2), 16) * [
|
|
339
|
+
.2126,
|
|
340
|
+
.7152,
|
|
341
|
+
.0722
|
|
342
|
+
][r], 0), f = d(u) > d(n);
|
|
343
|
+
return {
|
|
344
|
+
"--sb-snackbar-surface": C(n),
|
|
345
|
+
"--sb-snackbar-text": C(r),
|
|
346
|
+
"--sb-snackbar-border": C(v(s ? "#FFFFFF" : "#000000", s ? .1 : .05)),
|
|
347
|
+
"--sb-snackbar-normal": l(r, s ? c ? .2 : .14 : c ? .08 : .1),
|
|
348
|
+
"--sb-snackbar-hover": l(r, s ? c ? .24 : .18 : .04),
|
|
349
|
+
"--sb-snackbar-pressed": l(i, s ? c ? .28 : .24 : .2),
|
|
350
|
+
"--sb-snackbar-active": C(a),
|
|
351
|
+
"--sb-snackbar-on-active": C(t([
|
|
352
|
+
"choice",
|
|
353
|
+
"selected",
|
|
354
|
+
"foreground"
|
|
355
|
+
])),
|
|
356
|
+
"--sb-snackbar-ghost": C(u),
|
|
357
|
+
"--sb-snackbar-remaining": C(f ? u : n),
|
|
358
|
+
"--sb-snackbar-elapsed": C(f ? n : u)
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
var D = {
|
|
362
|
+
entrance: 1969.207,
|
|
363
|
+
timerEntrance: 2169.207,
|
|
364
|
+
widen: 200,
|
|
365
|
+
expand: 450
|
|
366
|
+
};
|
|
367
|
+
function O(e, t) {
|
|
368
|
+
let { viewport: n, safeArea: r = {}, compactHeight: i } = t, a = j(r.left) + 12, o = j(r.right) + 12, s = j(r.top) + 24, c = j(r.bottom) + 8, l = Math.max(0, n.width - a - o), u = Math.min(364, l), d = Math.min(376, l), f = Math.max(0, n.height - s - c), p = Math.min(t.cardHeight, f), m = P(e, {
|
|
369
|
+
viewport: n,
|
|
370
|
+
element: {
|
|
371
|
+
width: u,
|
|
372
|
+
height: i
|
|
373
|
+
},
|
|
374
|
+
safeArea: r
|
|
375
|
+
}), h = Math.max(a, Math.min(m.left, n.width - o - u)), g = Math.max(c, Math.min(n.height - m.top - i, n.height - s - i));
|
|
376
|
+
return {
|
|
377
|
+
compactWidth: u,
|
|
378
|
+
cardWidth: d,
|
|
379
|
+
compactLeft: h,
|
|
380
|
+
compactBottom: g,
|
|
381
|
+
cardHeight: p,
|
|
382
|
+
maxCardHeight: f,
|
|
383
|
+
entranceOffset: (u - i) * N(e?.anchor).x,
|
|
384
|
+
cardLeft: a + (l - d) / 2,
|
|
385
|
+
cardBottom: Math.max(c, Math.min(g, n.height - s - p)),
|
|
386
|
+
transformOrigin: m.transformOrigin
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
var k = {
|
|
390
|
+
x: 1,
|
|
391
|
+
y: 1
|
|
392
|
+
}, A = {
|
|
393
|
+
x: -16,
|
|
394
|
+
y: -24
|
|
395
|
+
};
|
|
396
|
+
function j(e) {
|
|
397
|
+
return typeof e == "number" && Number.isFinite(e) ? Math.max(0, e) : 0;
|
|
398
|
+
}
|
|
399
|
+
function M(e) {
|
|
400
|
+
return typeof e == "number" && Number.isFinite(e) ? e : 0;
|
|
401
|
+
}
|
|
402
|
+
function N(e) {
|
|
403
|
+
let t = S(e), n = typeof t.x == "number" && Number.isFinite(t.x) ? t.x : k.x, r = typeof t.y == "number" && Number.isFinite(t.y) ? t.y : k.y;
|
|
404
|
+
return {
|
|
405
|
+
x: Math.min(1, Math.max(0, n)),
|
|
406
|
+
y: Math.min(1, Math.max(0, r))
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function P(e, t) {
|
|
410
|
+
let n = S(e), r = N(n.position), i = N(n.anchor), a = S(n.offset), o = e ? M(a.x) : A.x, s = e ? M(a.y) : A.y, c = t.safeArea ?? {}, l = j(c.left), u = j(c.right), d = j(c.top), f = j(c.bottom), p = Math.max(0, j(t.viewport.width) - l - u - j(t.element.width)), m = Math.max(0, j(t.viewport.height) - d - f - j(t.element.height));
|
|
411
|
+
return {
|
|
412
|
+
left: l + r.x * p + o,
|
|
413
|
+
top: d + r.y * m + s,
|
|
414
|
+
travelX: p,
|
|
415
|
+
travelY: m,
|
|
416
|
+
position: r,
|
|
417
|
+
anchor: i,
|
|
418
|
+
transformOrigin: `${i.x * 100}% ${i.y * 100}%`
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
function F(e, t, n = "forward") {
|
|
422
|
+
let r = e === "bar" || e === "fill" ? e : "none", i = n === "reverse" ? "reverse" : "forward", a = typeof t == "number" && Number.isFinite(t) && t > 0 ? t : null;
|
|
423
|
+
return {
|
|
424
|
+
style: r,
|
|
425
|
+
direction: i,
|
|
426
|
+
durationMs: a,
|
|
427
|
+
visible: r !== "none",
|
|
428
|
+
cssVariables: {
|
|
429
|
+
"--sb-timer-style": r,
|
|
430
|
+
"--sb-timer-direction": i,
|
|
431
|
+
...a === null ? {} : { "--sb-timer-duration": `${a}ms` }
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/lib/components/SurveyFab.tsx
|
|
437
|
+
function I({ session: t, fabRef: n, onClick: r, animationState: i }) {
|
|
438
|
+
let { survey: a } = t, o = F(a.fab?.timerStyle, a.fab?.expandedTimeout), s = { ...o.cssVariables }, c = a.fab?.imageUrl, [l, u] = d(null), f = !!(c && l !== c);
|
|
439
|
+
return /* @__PURE__ */ g("button", {
|
|
440
|
+
ref: n,
|
|
441
|
+
type: "button",
|
|
442
|
+
className: `sb-fab sb-fab--expanded sb-fab--${i}`,
|
|
443
|
+
onClick: r,
|
|
444
|
+
disabled: i === "exiting",
|
|
445
|
+
"aria-hidden": i === "exiting" || void 0,
|
|
446
|
+
tabIndex: i === "exiting" ? -1 : void 0,
|
|
447
|
+
"aria-label": e(a),
|
|
448
|
+
"data-timer-style": o.style,
|
|
449
|
+
style: s,
|
|
450
|
+
children: [
|
|
451
|
+
o.visible ? /* @__PURE__ */ h("span", {
|
|
452
|
+
className: `sb-fab__timer sb-fab__timer--${o.style}`,
|
|
453
|
+
"aria-hidden": "true",
|
|
454
|
+
children: /* @__PURE__ */ h("span", { className: "sb-fab__timer-fill" })
|
|
455
|
+
}) : null,
|
|
456
|
+
/* @__PURE__ */ h("span", {
|
|
457
|
+
className: "sb-fab__badge",
|
|
458
|
+
"aria-hidden": "true",
|
|
459
|
+
children: f ? /* @__PURE__ */ h("img", {
|
|
460
|
+
className: "sb-fab__badge-image",
|
|
461
|
+
src: c,
|
|
462
|
+
alt: "",
|
|
463
|
+
onError: () => u(c ?? null)
|
|
464
|
+
}) : /* @__PURE__ */ g("span", {
|
|
465
|
+
className: "sb-fab__badge-art",
|
|
466
|
+
children: [
|
|
467
|
+
/* @__PURE__ */ h("span", { className: "sb-fab__badge-inner" }),
|
|
468
|
+
/* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--center" }),
|
|
469
|
+
/* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--amber" }),
|
|
470
|
+
/* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--mint" }),
|
|
471
|
+
/* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--rose" })
|
|
472
|
+
]
|
|
473
|
+
})
|
|
474
|
+
}),
|
|
475
|
+
/* @__PURE__ */ h("span", {
|
|
476
|
+
className: "sb-fab__label",
|
|
477
|
+
children: e(a)
|
|
478
|
+
})
|
|
479
|
+
]
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
//#endregion
|
|
483
|
+
//#region src/lib/components/SurveyProgress.tsx
|
|
484
|
+
function L({ value: e }) {
|
|
485
|
+
return /* @__PURE__ */ h("div", {
|
|
486
|
+
className: "sb-progress",
|
|
487
|
+
"aria-hidden": "true",
|
|
488
|
+
children: /* @__PURE__ */ h("span", {
|
|
489
|
+
className: "sb-progress__fill",
|
|
490
|
+
style: { "--sb-progress-value": `${Math.max(0, Math.min(1, e)) * 100}%` }
|
|
491
|
+
})
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/lib/components/SurveyQuestionView.tsx
|
|
496
|
+
var R = [];
|
|
497
|
+
function z() {
|
|
498
|
+
return /* @__PURE__ */ h("svg", {
|
|
499
|
+
viewBox: "0 0 35.5556 35.5556",
|
|
500
|
+
"aria-hidden": "true",
|
|
501
|
+
children: /* @__PURE__ */ h("path", {
|
|
502
|
+
d: "M19.436 3.05195 11.2286 11.2594c-.5481.5481-.8592 1.3037-.8592 2.0888v14.8c0 1.6297 1.3333 2.963 2.9629 2.963h13.3334c1.1851 0 2.2518-.7111 2.7259-1.7926l4.8296-11.2741c1.2445-2.9333-.9037-6.1925-4.0889-6.1925H21.762l1.4074-6.78523c.1481-.74075-.0741-1.4963-.6074-2.02963-.8741-.85926-2.2667-.85926-3.126.01481ZM4.44343 31.1112c1.62963 0 2.96296-1.3333 2.96296-2.963V16.2964c0-1.6296-1.33333-2.963-2.96296-2.963-1.62963 0-2.96296 1.3334-2.96296 2.963v11.8518c0 1.6297 1.33333 2.963 2.96296 2.963Z",
|
|
503
|
+
fill: "currentColor"
|
|
504
|
+
})
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
function B() {
|
|
508
|
+
return /* @__PURE__ */ h("svg", {
|
|
509
|
+
viewBox: "0 0 35.5556 35.5556",
|
|
510
|
+
"aria-hidden": "true",
|
|
511
|
+
children: /* @__PURE__ */ h("path", {
|
|
512
|
+
d: "m16.1165 32.5036 8.1926-8.2074c.5481-.5482.8592-1.3037.8592-2.0889v-14.8c0-1.62963-1.3333-2.96296-2.9629-2.96296H8.88686c-1.18519 0-2.25185.71111-2.71111 1.79259L1.34612 17.511c-1.25926 2.9333.88889 6.1926 4.07407 6.1926h8.37041l-1.4074 6.7852c-.1482.7407.074 1.4963.6074 2.0296.874.8593 2.2666.8593 3.1259-.0148ZM31.1091 4.44434c-1.6296 0-2.963 1.33333-2.963 2.96296v11.8519c0 1.6296 1.3334 2.9629 2.963 2.9629 1.6296 0 2.9629-1.3333 2.9629-2.9629V7.4073c0-1.62963-1.3333-2.96296-2.9629-2.96296Z",
|
|
513
|
+
fill: "currentColor"
|
|
514
|
+
})
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
function V() {
|
|
518
|
+
return /* @__PURE__ */ h("span", {
|
|
519
|
+
className: "sb-spark-ring",
|
|
520
|
+
"aria-hidden": "true",
|
|
521
|
+
children: Array.from({ length: 12 }, (e, t) => /* @__PURE__ */ h("span", {
|
|
522
|
+
className: t % 2 == 0 ? "sb-spark-ring__dot sb-spark-ring__dot--large" : "sb-spark-ring__dot",
|
|
523
|
+
style: { "--sb-spark-index": t }
|
|
524
|
+
}, t))
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
function H({ question: e, store: t, isSentiment: n }) {
|
|
528
|
+
let i = t.currentDraft(), a = t.getState(), o = !!(a?.isBusy || a?.isCompleting), s = e.answers?.find((e) => e.id === i?.answer_key);
|
|
529
|
+
return s && r(s) ? /* @__PURE__ */ h(U, {
|
|
530
|
+
store: t,
|
|
531
|
+
disabled: o,
|
|
532
|
+
placeholder: s.label,
|
|
533
|
+
autoFocus: !0,
|
|
534
|
+
ariaLabel: "Other response",
|
|
535
|
+
isOther: !0
|
|
536
|
+
}) : n ? /* @__PURE__ */ h(te, {
|
|
537
|
+
store: t,
|
|
538
|
+
disabled: o || !!a?.sentimentSelectionLocked
|
|
539
|
+
}) : e.type === "yes_no" || e.type === "multiple_choice" ? /* @__PURE__ */ h(ne, {
|
|
540
|
+
question: e,
|
|
541
|
+
store: t,
|
|
542
|
+
disabled: o
|
|
543
|
+
}) : /* @__PURE__ */ h(U, {
|
|
544
|
+
store: t,
|
|
545
|
+
disabled: o,
|
|
546
|
+
placeholder: e.free_text_placeholder ?? "Please explain more... (Optional)",
|
|
547
|
+
autoFocus: e.required,
|
|
548
|
+
ariaLabel: e.prompt
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
function te({ store: e, disabled: t }) {
|
|
552
|
+
let r = e.currentDraft();
|
|
553
|
+
return /* @__PURE__ */ h("div", {
|
|
554
|
+
className: "sb-question sb-question--sentiment",
|
|
555
|
+
children: e.sentimentChoices().map((i) => {
|
|
556
|
+
let a = n(i), o = r?.answer_key === i.id;
|
|
557
|
+
return /* @__PURE__ */ g("span", {
|
|
558
|
+
className: "sb-sentiment-control",
|
|
559
|
+
children: [o && a ? /* @__PURE__ */ h(V, {}) : null, /* @__PURE__ */ h("button", {
|
|
560
|
+
type: "button",
|
|
561
|
+
className: `sb-yesno ${o ? "sb-yesno--selected" : ""}`,
|
|
562
|
+
"data-choice-value": i.id,
|
|
563
|
+
onClick: () => void e.selectChoice(i),
|
|
564
|
+
disabled: t,
|
|
565
|
+
"aria-label": i.label,
|
|
566
|
+
"aria-pressed": o,
|
|
567
|
+
children: /* @__PURE__ */ h("span", {
|
|
568
|
+
className: "sb-yesno__icon",
|
|
569
|
+
children: h(a ? z : B, {})
|
|
570
|
+
})
|
|
571
|
+
})]
|
|
572
|
+
}, i.id);
|
|
573
|
+
})
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
function ne({ question: e, store: t, disabled: n }) {
|
|
577
|
+
let i = e.answers ?? R, a = t.currentDraft(), o = u(null), [c, l] = d(() => i.every((e) => e.label.trim().length < 20));
|
|
578
|
+
return s(() => {
|
|
579
|
+
let e = () => {
|
|
580
|
+
let e = ((o.current?.clientWidth || 328) - 8) / 2, t = document.createElement("span");
|
|
581
|
+
t.style.cssText = "position:fixed;visibility:hidden;white-space:nowrap;font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",sans-serif;font-size:16px;", document.body.appendChild(t);
|
|
582
|
+
let n = i.every((n) => {
|
|
583
|
+
t.style.fontWeight = r(n) ? "400" : "700", t.textContent = n.label.trim();
|
|
584
|
+
let i = t.getBoundingClientRect().width;
|
|
585
|
+
return (i > 0 ? i : n.label.trim().length * (r(n) ? 8 : 8.6)) + 16 + +!!r(n) < e;
|
|
586
|
+
});
|
|
587
|
+
t.remove(), l(n);
|
|
588
|
+
};
|
|
589
|
+
e(), window.addEventListener("resize", e);
|
|
590
|
+
let t = o.current, n = typeof ResizeObserver > "u" || !t ? null : new ResizeObserver(e);
|
|
591
|
+
return t && n?.observe(t), () => {
|
|
592
|
+
window.removeEventListener("resize", e), n?.disconnect();
|
|
593
|
+
};
|
|
594
|
+
}, [i]), /* @__PURE__ */ h("div", {
|
|
595
|
+
ref: o,
|
|
596
|
+
className: `sb-question sb-question--choices ${c ? "sb-question--choices-grid" : "sb-question--choices-list"}`,
|
|
597
|
+
children: /* @__PURE__ */ h("div", {
|
|
598
|
+
className: `sb-options-scroll ${(c ? Math.ceil(i.length / 2) : i.length) >= 5 ? "sb-options-scroll--scrolling" : ""}`,
|
|
599
|
+
children: i.map((e) => /* @__PURE__ */ h(re, {
|
|
600
|
+
choice: e,
|
|
601
|
+
selected: a?.answer_key === e.id,
|
|
602
|
+
disabled: n,
|
|
603
|
+
store: t
|
|
604
|
+
}, e.id))
|
|
605
|
+
})
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
function re({ choice: e, selected: n, disabled: i, store: a }) {
|
|
609
|
+
let o = r(e);
|
|
610
|
+
return /* @__PURE__ */ h("button", {
|
|
611
|
+
type: "button",
|
|
612
|
+
className: `sb-choice ${n ? "sb-choice--selected" : ""} ${o ? "sb-choice--other" : ""}`,
|
|
613
|
+
"data-choice-value": t(e),
|
|
614
|
+
onClick: () => void a.selectChoice(e),
|
|
615
|
+
disabled: i,
|
|
616
|
+
"aria-label": e.label,
|
|
617
|
+
"aria-pressed": n,
|
|
618
|
+
children: o ? /* @__PURE__ */ g("span", {
|
|
619
|
+
className: "sb-choice__other-content",
|
|
620
|
+
"aria-hidden": "true",
|
|
621
|
+
children: [/* @__PURE__ */ h("span", { className: "sb-choice__other-caret" }), /* @__PURE__ */ h("span", {
|
|
622
|
+
className: "sb-choice__other-label",
|
|
623
|
+
children: e.label
|
|
624
|
+
})]
|
|
625
|
+
}) : /* @__PURE__ */ h("span", {
|
|
626
|
+
className: "sb-choice__label",
|
|
627
|
+
children: e.label
|
|
628
|
+
})
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
function U({ store: e, disabled: t, placeholder: n, autoFocus: r, ariaLabel: i, isOther: a = !1 }) {
|
|
632
|
+
let o = u(null);
|
|
633
|
+
return s(() => {
|
|
634
|
+
r && !t && o.current?.focus({ preventScroll: !0 });
|
|
635
|
+
}, [r, t]), /* @__PURE__ */ h("div", {
|
|
636
|
+
className: `sb-question sb-question--text ${a ? "sb-question--other sb-question--other-text" : ""}`,
|
|
637
|
+
children: /* @__PURE__ */ h("div", {
|
|
638
|
+
className: "sb-textarea-shell",
|
|
639
|
+
children: /* @__PURE__ */ h("textarea", {
|
|
640
|
+
ref: o,
|
|
641
|
+
className: "sb-textarea",
|
|
642
|
+
value: e.currentText(),
|
|
643
|
+
onChange: (t) => e.setText(t.target.value),
|
|
644
|
+
disabled: t,
|
|
645
|
+
placeholder: n,
|
|
646
|
+
"aria-label": i,
|
|
647
|
+
autoFocus: r,
|
|
648
|
+
"data-autofocus": r || void 0
|
|
649
|
+
})
|
|
650
|
+
})
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
//#endregion
|
|
654
|
+
//#region src/lib/components/SurveyThankYou.tsx
|
|
655
|
+
function ie({ completion: e, store: t, isBusy: n, headingId: r, bodyId: i }) {
|
|
656
|
+
let a = u(null), [o, c] = d(!1);
|
|
657
|
+
return s(() => {
|
|
658
|
+
let e = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1, t = setTimeout(() => c(!0), e ? 0 : 890);
|
|
659
|
+
return () => clearTimeout(t);
|
|
660
|
+
}, [e.node_id]), s(() => {
|
|
661
|
+
o && a.current?.focus({ preventScroll: !0 });
|
|
662
|
+
}, [o]), /* @__PURE__ */ g("div", {
|
|
663
|
+
className: "sb-thanks",
|
|
664
|
+
children: [
|
|
665
|
+
/* @__PURE__ */ h("div", {
|
|
666
|
+
className: "sb-thanks__icon-shell",
|
|
667
|
+
"aria-hidden": "true",
|
|
668
|
+
children: /* @__PURE__ */ h("div", {
|
|
669
|
+
className: "sb-thanks__icon-core",
|
|
670
|
+
children: /* @__PURE__ */ h("svg", {
|
|
671
|
+
viewBox: "0 0 36 28",
|
|
672
|
+
children: /* @__PURE__ */ h("path", {
|
|
673
|
+
d: "M11.2619 21.3151 2.86082 12.914 0 15.7546l11.2619 11.262 24.176-24.17593L32.5972 0 11.2619 21.3151Z",
|
|
674
|
+
fill: "currentColor"
|
|
675
|
+
})
|
|
676
|
+
})
|
|
677
|
+
})
|
|
678
|
+
}),
|
|
679
|
+
/* @__PURE__ */ g("div", {
|
|
680
|
+
className: "sb-thanks__copy",
|
|
681
|
+
"aria-hidden": !o,
|
|
682
|
+
children: [/* @__PURE__ */ h("h2", {
|
|
683
|
+
ref: a,
|
|
684
|
+
id: r,
|
|
685
|
+
tabIndex: -1,
|
|
686
|
+
children: e.title
|
|
687
|
+
}), e.body ? /* @__PURE__ */ h("p", {
|
|
688
|
+
id: i,
|
|
689
|
+
children: e.body
|
|
690
|
+
}) : null]
|
|
691
|
+
}),
|
|
692
|
+
e.actions.length ? /* @__PURE__ */ h("div", {
|
|
693
|
+
className: "sb-thanks__actions",
|
|
694
|
+
"aria-hidden": !o,
|
|
695
|
+
children: e.actions.map((e) => /* @__PURE__ */ h("button", {
|
|
696
|
+
type: "button",
|
|
697
|
+
className: `sb-button sb-button--${e.style === "primary" || e.style === "secondary" ? e.style : "tertiary"}`,
|
|
698
|
+
onClick: () => void t.handleCompletionAction(e),
|
|
699
|
+
disabled: n || !o,
|
|
700
|
+
children: e.label
|
|
701
|
+
}, e.id))
|
|
702
|
+
}) : null
|
|
703
|
+
]
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
//#endregion
|
|
707
|
+
//#region src/lib/components/SurveySheet.tsx
|
|
708
|
+
var W = a(function({ session: e, store: t, modal: n, rootRef: r, interactive: i = !0 }) {
|
|
709
|
+
let a = e.currentNodeId ? e.survey.questions[e.currentNodeId] : void 0, o = !!(a && t.isSentimentStep()), l = a?.answers?.find((e) => e.id === t.currentDraft()?.answer_key), d = l?.comment?.trim() || null, f = l?.id === "system_other", p = u(null), _ = c();
|
|
710
|
+
s(() => {
|
|
711
|
+
if (!i) return;
|
|
712
|
+
let e = (e) => {
|
|
713
|
+
if (e.key === "Escape" && t.closeSurvey(), !n || e.key !== "Tab" || !p.current) return;
|
|
714
|
+
let r = Array.from(p.current.querySelectorAll("button:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])"));
|
|
715
|
+
if (!r.length) {
|
|
716
|
+
e.preventDefault(), p.current.querySelector("[tabindex=\"-1\"]")?.focus();
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
let i = document.activeElement, a = r.indexOf(i), o = e.shiftKey ? a <= 0 ? r.length - 1 : a - 1 : a === r.length - 1 ? 0 : a + 1;
|
|
720
|
+
e.preventDefault(), r[o]?.focus();
|
|
721
|
+
};
|
|
722
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
723
|
+
}, [
|
|
724
|
+
i,
|
|
725
|
+
n,
|
|
726
|
+
e.completion,
|
|
727
|
+
t
|
|
728
|
+
]);
|
|
729
|
+
let v = e.completion ? `sb-completion-${_}` : `sb-question-${_}`, y = `sb-completion-body-${_}`;
|
|
730
|
+
return /* @__PURE__ */ g("div", {
|
|
731
|
+
ref: r,
|
|
732
|
+
className: `sb-sheet-root ${e.isCompleting ? "sb-sheet-root--completing" : ""}`,
|
|
733
|
+
children: [/* @__PURE__ */ h("button", {
|
|
734
|
+
type: "button",
|
|
735
|
+
tabIndex: -1,
|
|
736
|
+
className: "sb-sheet-root__overlay",
|
|
737
|
+
onClick: () => void t.closeSurvey(),
|
|
738
|
+
"aria-label": "Dismiss survey"
|
|
739
|
+
}), /* @__PURE__ */ h("div", {
|
|
740
|
+
ref: p,
|
|
741
|
+
className: `sb-sheet ${e.completion ? "sb-sheet--thanks" : ""} ${o ? "sb-sheet--sentiment" : ""}`,
|
|
742
|
+
role: "dialog",
|
|
743
|
+
...n ? { "aria-modal": !0 } : {},
|
|
744
|
+
"aria-labelledby": v,
|
|
745
|
+
"aria-describedby": e.completion?.body ? y : void 0,
|
|
746
|
+
"aria-busy": e.isCompleting || void 0,
|
|
747
|
+
children: e.completion ? /* @__PURE__ */ h(ie, {
|
|
748
|
+
completion: e.completion,
|
|
749
|
+
store: t,
|
|
750
|
+
isBusy: e.isBusy,
|
|
751
|
+
headingId: v,
|
|
752
|
+
bodyId: y
|
|
753
|
+
}) : a ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ g("div", {
|
|
754
|
+
className: "sb-sheet__header",
|
|
755
|
+
children: [o ? null : /* @__PURE__ */ h(L, { value: t.progress() }), /* @__PURE__ */ h("button", {
|
|
756
|
+
type: "button",
|
|
757
|
+
className: "sb-sheet__close",
|
|
758
|
+
onClick: () => void t.closeSurvey(),
|
|
759
|
+
"aria-label": "Close survey",
|
|
760
|
+
children: /* @__PURE__ */ h("svg", {
|
|
761
|
+
viewBox: "0 0 24 24",
|
|
762
|
+
"aria-hidden": "true",
|
|
763
|
+
children: /* @__PURE__ */ h("path", {
|
|
764
|
+
d: "M6.4 6.4 17.6 17.6M17.6 6.4 6.4 17.6",
|
|
765
|
+
fill: "none",
|
|
766
|
+
stroke: "currentColor",
|
|
767
|
+
strokeWidth: "2",
|
|
768
|
+
strokeLinecap: "round"
|
|
769
|
+
})
|
|
770
|
+
})
|
|
771
|
+
})]
|
|
772
|
+
}), /* @__PURE__ */ g("div", {
|
|
773
|
+
className: "sb-sheet__stage",
|
|
774
|
+
children: [/* @__PURE__ */ g("div", {
|
|
775
|
+
className: `sb-sheet__body ${o ? "sb-sheet__body--sentiment" : "sb-sheet__body--question"}`,
|
|
776
|
+
children: [/* @__PURE__ */ g("div", {
|
|
777
|
+
className: `sb-sheet__copy ${o && d ? "sb-sheet__copy--acknowledgement" : ""}`,
|
|
778
|
+
children: [o && !d ? /* @__PURE__ */ h("p", {
|
|
779
|
+
className: "sb-sheet__eyebrow",
|
|
780
|
+
children: e.survey.title
|
|
781
|
+
}) : null, /* @__PURE__ */ h("h2", {
|
|
782
|
+
id: v,
|
|
783
|
+
tabIndex: -1,
|
|
784
|
+
"aria-live": o && d ? "polite" : void 0,
|
|
785
|
+
children: o && d ? d : a.prompt
|
|
786
|
+
})]
|
|
787
|
+
}), /* @__PURE__ */ h(H, {
|
|
788
|
+
question: a,
|
|
789
|
+
store: t,
|
|
790
|
+
isSentiment: o
|
|
791
|
+
}, a.node_id)]
|
|
792
|
+
}), t.shouldShowContinue() ? /* @__PURE__ */ g("div", {
|
|
793
|
+
className: "sb-sheet__footer",
|
|
794
|
+
children: [d ? /* @__PURE__ */ h("p", {
|
|
795
|
+
className: "sb-sheet__answer-comment",
|
|
796
|
+
role: "status",
|
|
797
|
+
children: d
|
|
798
|
+
}) : /* @__PURE__ */ h("span", { className: "sb-sheet__footer-spacer" }), /* @__PURE__ */ h("button", {
|
|
799
|
+
type: "button",
|
|
800
|
+
className: `sb-next ${l ? "sb-next--acknowledging" : ""}`,
|
|
801
|
+
onClick: () => void t.advance(),
|
|
802
|
+
disabled: e.isBusy || e.isCompleting || !t.canContinue(),
|
|
803
|
+
"aria-label": "Continue",
|
|
804
|
+
children: /* @__PURE__ */ h("svg", {
|
|
805
|
+
viewBox: "0 0 14 14",
|
|
806
|
+
"aria-hidden": "true",
|
|
807
|
+
children: /* @__PURE__ */ h("path", {
|
|
808
|
+
d: "M6.66667 0 5.49167 1.175l4.65 4.65833H0V7.5h10.1417l-4.65 4.6583 1.175 1.175L13.3333 6.66667 6.66667 0Z",
|
|
809
|
+
fill: "currentColor"
|
|
810
|
+
})
|
|
811
|
+
})
|
|
812
|
+
}, l?.id ?? "unselected")]
|
|
813
|
+
}) : null]
|
|
814
|
+
}, `${a.node_id}:${f ? "text" : "options"}`)] }) : null
|
|
815
|
+
})]
|
|
816
|
+
});
|
|
817
|
+
}), ae = typeof window > "u" ? s : l, G = () => window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1;
|
|
818
|
+
function oe({ session: e, store: t, placement: r, modal: a }) {
|
|
819
|
+
let o = u(null), [c, l] = d("entering"), { presentationId: f, survey: p, snackbar: m, isOpen: _ } = e, v = _ && (c === "entering" || c === "compact") ? "widening" : c, y = p.questions[p.root_node_id], b = i(y, p.fab), x = p.fab?.timerStyle ?? "none", [S, C] = d(!1);
|
|
820
|
+
s(() => {
|
|
821
|
+
let e = setTimeout(() => {
|
|
822
|
+
l("compact"), t.confirmPresentation("expanded_fab", f), t.confirmFabEntranceCompleted(f);
|
|
823
|
+
}, G() ? 0 : x === "none" ? D.entrance : D.timerEntrance);
|
|
824
|
+
return () => clearTimeout(e);
|
|
825
|
+
}, [
|
|
826
|
+
f,
|
|
827
|
+
t,
|
|
828
|
+
x
|
|
829
|
+
]), s(() => {
|
|
830
|
+
if (!_) return;
|
|
831
|
+
let e = G(), n = setTimeout(() => l("expanding"), e ? 0 : D.widen), r = setTimeout(() => {
|
|
832
|
+
l("ready"), t.confirmPresentation("sheet", f), t.confirmSnackbarContentReady(f), o.current?.querySelector(".sb-sheet h2")?.focus({ preventScroll: !0 });
|
|
833
|
+
}, e ? 0 : D.widen + D.expand);
|
|
834
|
+
return () => {
|
|
835
|
+
clearTimeout(n), clearTimeout(r);
|
|
836
|
+
};
|
|
837
|
+
}, [
|
|
838
|
+
_,
|
|
839
|
+
f,
|
|
840
|
+
t
|
|
841
|
+
]), ae(() => {
|
|
842
|
+
let e = o.current;
|
|
843
|
+
if (!e) return;
|
|
844
|
+
let t = () => {
|
|
845
|
+
let t = e.parentElement, n = window.visualViewport, a = r === "inline" ? t.clientWidth : n?.width || window.innerWidth, o = r === "inline" ? t.clientHeight : n?.height || window.innerHeight, s = t.querySelector(".sb-safe-area-probe"), c = s ? getComputedStyle(s) : null, l = (e) => Number.parseFloat(e ?? "") || 0, u = e.querySelector(".sb-snackbar-compact"), d = e.querySelector(".sb-sheet"), f = i(y, p.fab).placement, m = {
|
|
846
|
+
viewport: {
|
|
847
|
+
width: a,
|
|
848
|
+
height: o
|
|
849
|
+
},
|
|
850
|
+
safeArea: r === "inline" ? {} : {
|
|
851
|
+
left: l(c?.paddingLeft),
|
|
852
|
+
right: l(c?.paddingRight),
|
|
853
|
+
top: l(c?.paddingTop),
|
|
854
|
+
bottom: l(c?.paddingBottom)
|
|
855
|
+
},
|
|
856
|
+
compactHeight: 64,
|
|
857
|
+
cardHeight: d?.offsetHeight || 0
|
|
858
|
+
};
|
|
859
|
+
e.style.setProperty("--sb-snackbar-compact-width", `${O(f, m).compactWidth}px`);
|
|
860
|
+
let h = Number.parseFloat(getComputedStyle(u).height) || u.offsetHeight || 64, g = O(f, {
|
|
861
|
+
...m,
|
|
862
|
+
compactHeight: h
|
|
863
|
+
});
|
|
864
|
+
r === "fixed" ? (e.style.left = `${n?.offsetLeft ?? 0}px`, e.style.top = `${n?.offsetTop ?? 0}px`, e.style.width = `${a}px`, e.style.height = `${o}px`) : (e.style.left = "0px", e.style.top = "0px", e.style.width = "100%", e.style.height = "100%");
|
|
865
|
+
let _ = v === "widening" || v === "expanding" || v === "ready", b = v === "expanding" || v === "ready", x = {
|
|
866
|
+
left: _ ? g.cardLeft : g.compactLeft,
|
|
867
|
+
bottom: _ ? g.cardBottom : g.compactBottom,
|
|
868
|
+
width: _ ? g.cardWidth : g.compactWidth,
|
|
869
|
+
height: b ? g.cardHeight : h,
|
|
870
|
+
"compact-height": h,
|
|
871
|
+
"card-width": g.cardWidth,
|
|
872
|
+
"compact-width": g.compactWidth,
|
|
873
|
+
"entrance-offset": g.entranceOffset,
|
|
874
|
+
"max-height": g.maxCardHeight
|
|
875
|
+
};
|
|
876
|
+
for (let [t, n] of Object.entries(x)) e.style.setProperty(`--sb-snackbar-${t}`, `${n}px`);
|
|
877
|
+
e.querySelector(".sb-snackbar-shell").style.transformOrigin = g.transformOrigin;
|
|
878
|
+
};
|
|
879
|
+
t();
|
|
880
|
+
let n = typeof ResizeObserver > "u" ? null : new ResizeObserver(t), a = e.querySelector(".sb-snackbar-compact");
|
|
881
|
+
n?.observe(a);
|
|
882
|
+
let s = e.querySelector(".sb-sheet");
|
|
883
|
+
return s && n?.observe(s), r === "inline" && n?.observe(e.parentElement), window.addEventListener("resize", t), window.visualViewport?.addEventListener("resize", t), window.visualViewport?.addEventListener("scroll", t), () => {
|
|
884
|
+
n?.disconnect(), window.removeEventListener("resize", t), window.visualViewport?.removeEventListener("resize", t), window.visualViewport?.removeEventListener("scroll", t);
|
|
885
|
+
};
|
|
886
|
+
}, [
|
|
887
|
+
r,
|
|
888
|
+
v,
|
|
889
|
+
p,
|
|
890
|
+
y,
|
|
891
|
+
_
|
|
892
|
+
]), s(() => {
|
|
893
|
+
if (_) return;
|
|
894
|
+
let e = (e) => {
|
|
895
|
+
e.key === "Escape" && o.current?.contains(document.activeElement) && t.closeSurvey();
|
|
896
|
+
};
|
|
897
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
898
|
+
}, [_, t]);
|
|
899
|
+
let w = m?.selectedKey, T = e.fabEntranceCompleted && m?.phase === "question", E = m?.deadline != null, k = {
|
|
900
|
+
...ee(p.theme),
|
|
901
|
+
"--sb-snackbar-duration": `${p.fab?.expandedTimeout ?? 0}ms`,
|
|
902
|
+
"--sb-snackbar-fraction": m?.frozenFraction ?? 1
|
|
903
|
+
}, A = x === "none" ? null : /* @__PURE__ */ h("span", {
|
|
904
|
+
className: `sb-snackbar-timer sb-snackbar-timer--${x}`,
|
|
905
|
+
"aria-hidden": "true",
|
|
906
|
+
children: /* @__PURE__ */ h("span", { className: "sb-snackbar-timer-fill" })
|
|
907
|
+
});
|
|
908
|
+
return /* @__PURE__ */ g("div", {
|
|
909
|
+
ref: o,
|
|
910
|
+
className: "sb-snackbar-root",
|
|
911
|
+
style: k,
|
|
912
|
+
"data-stage": v,
|
|
913
|
+
"data-expanded": _,
|
|
914
|
+
"data-counting": E,
|
|
915
|
+
"data-frozen": m?.frozenFraction != null,
|
|
916
|
+
children: [/* @__PURE__ */ h("button", {
|
|
917
|
+
className: "sb-snackbar-overlay",
|
|
918
|
+
type: "button",
|
|
919
|
+
tabIndex: -1,
|
|
920
|
+
"aria-hidden": "true",
|
|
921
|
+
disabled: v !== "ready",
|
|
922
|
+
onClick: () => void t.closeSurvey()
|
|
923
|
+
}), /* @__PURE__ */ g("div", {
|
|
924
|
+
className: "sb-snackbar-shell",
|
|
925
|
+
children: [/* @__PURE__ */ g("div", {
|
|
926
|
+
className: "sb-snackbar-surface",
|
|
927
|
+
children: [/* @__PURE__ */ g("div", {
|
|
928
|
+
className: "sb-snackbar-compact",
|
|
929
|
+
role: "group",
|
|
930
|
+
"aria-label": y.prompt,
|
|
931
|
+
"aria-hidden": _ || v === "entering",
|
|
932
|
+
inert: _ || v === "entering",
|
|
933
|
+
children: [
|
|
934
|
+
x === "fill" ? A : null,
|
|
935
|
+
/* @__PURE__ */ g("span", {
|
|
936
|
+
className: "sb-snackbar-artwork",
|
|
937
|
+
"aria-hidden": "true",
|
|
938
|
+
children: [/* @__PURE__ */ g("span", {
|
|
939
|
+
className: "sb-fab__badge-art",
|
|
940
|
+
children: [
|
|
941
|
+
/* @__PURE__ */ h("span", { className: "sb-fab__badge-inner" }),
|
|
942
|
+
/* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--center" }),
|
|
943
|
+
/* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--amber" }),
|
|
944
|
+
/* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--mint" }),
|
|
945
|
+
/* @__PURE__ */ h("span", { className: "sb-fab__glyph sb-fab__glyph--rose" })
|
|
946
|
+
]
|
|
947
|
+
}), b.imageUrl && !S ? /* @__PURE__ */ h("img", {
|
|
948
|
+
src: b.imageUrl,
|
|
949
|
+
alt: "",
|
|
950
|
+
onError: () => C(!0)
|
|
951
|
+
}) : null]
|
|
952
|
+
}),
|
|
953
|
+
/* @__PURE__ */ g("p", {
|
|
954
|
+
className: "sb-snackbar-prompt",
|
|
955
|
+
children: [y.prompt, x === "bar" ? A : null]
|
|
956
|
+
}),
|
|
957
|
+
/* @__PURE__ */ h("div", {
|
|
958
|
+
className: "sb-snackbar-answers",
|
|
959
|
+
children: (y.answers ?? []).map((e) => /* @__PURE__ */ h("button", {
|
|
960
|
+
className: "sb-snackbar-answer",
|
|
961
|
+
type: "button",
|
|
962
|
+
"aria-label": e.label,
|
|
963
|
+
"aria-pressed": w === e.id,
|
|
964
|
+
disabled: !T,
|
|
965
|
+
onClick: () => t.answerSnackbar(f, e.id),
|
|
966
|
+
children: n(e) ? /* @__PURE__ */ h(z, {}) : /* @__PURE__ */ h(B, {})
|
|
967
|
+
}, e.id))
|
|
968
|
+
})
|
|
969
|
+
]
|
|
970
|
+
}), _ ? /* @__PURE__ */ h("div", {
|
|
971
|
+
className: "sb-snackbar-card",
|
|
972
|
+
inert: v !== "ready",
|
|
973
|
+
"aria-hidden": v !== "ready",
|
|
974
|
+
children: /* @__PURE__ */ h(W, {
|
|
975
|
+
session: e,
|
|
976
|
+
store: t,
|
|
977
|
+
modal: a,
|
|
978
|
+
interactive: v === "ready"
|
|
979
|
+
})
|
|
980
|
+
}) : null]
|
|
981
|
+
}), /* @__PURE__ */ h("button", {
|
|
982
|
+
className: "sb-snackbar-close",
|
|
983
|
+
type: "button",
|
|
984
|
+
"aria-label": "Close survey",
|
|
985
|
+
disabled: _,
|
|
986
|
+
onClick: () => void t.closeSurvey(),
|
|
987
|
+
children: /* @__PURE__ */ h("svg", {
|
|
988
|
+
viewBox: "0 0 24 24",
|
|
989
|
+
"aria-hidden": "true",
|
|
990
|
+
children: /* @__PURE__ */ h("path", {
|
|
991
|
+
d: "m6 6 12 12M18 6 6 18",
|
|
992
|
+
fill: "none",
|
|
993
|
+
stroke: "currentColor",
|
|
994
|
+
strokeWidth: "2"
|
|
995
|
+
})
|
|
996
|
+
})
|
|
997
|
+
})]
|
|
998
|
+
})]
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
//#endregion
|
|
1002
|
+
//#region src/lib/components/SurveyRenderer.tsx
|
|
1003
|
+
var K = typeof window > "u" ? s : l, q = 1969.207, se = 2169.207, J = 856.839, Y = 450;
|
|
1004
|
+
function X(e) {
|
|
1005
|
+
let t = Number.parseFloat(e);
|
|
1006
|
+
return Number.isFinite(t) ? Math.max(0, t) : 0;
|
|
1007
|
+
}
|
|
1008
|
+
function ce(e) {
|
|
1009
|
+
let t = 0;
|
|
1010
|
+
for (let n of e) t += /[MW@#%&]/.test(n) ? 11 : /[ilI1.,' ]/.test(n) ? 4 : 7.5;
|
|
1011
|
+
return Math.ceil(t);
|
|
1012
|
+
}
|
|
1013
|
+
function Z() {
|
|
1014
|
+
return typeof window < "u" && (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1);
|
|
1015
|
+
}
|
|
1016
|
+
function Q(e) {
|
|
1017
|
+
if (!e) return null;
|
|
1018
|
+
let { pulse_id: t, version: n, impression_id: r } = e.survey;
|
|
1019
|
+
return typeof r == "string" ? `${t}:${n}:${r}` : `${t}:${n}`;
|
|
1020
|
+
}
|
|
1021
|
+
function $(e) {
|
|
1022
|
+
if (!e) return;
|
|
1023
|
+
let t = getComputedStyle(e), n = Number.parseFloat(t.width) || e.offsetWidth || 86, r = Number.parseFloat(e.style.getPropertyValue("--sb-fab-expanded-width")) || n, i = Number.parseFloat(e.style.getPropertyValue("--sb-fab-anchor-offset")) || 0, a = r === 60 ? 0 : i / (r - 60), o = e.querySelector(".sb-fab__label"), s = e.querySelector(".sb-fab__timer");
|
|
1024
|
+
e.style.setProperty("--sb-fab-exit-width", `${n}px`), e.style.setProperty("--sb-fab-exit-offset", `${(r - n) * a}px`), e.style.setProperty("--sb-fab-exit-scale", t.getPropertyValue("scale") || "1"), e.style.setProperty("--sb-fab-exit-label-opacity", o ? getComputedStyle(o).opacity : "0"), e.style.setProperty("--sb-fab-exit-timer-opacity", s ? getComputedStyle(s).opacity : "0");
|
|
1025
|
+
}
|
|
1026
|
+
function le({ session: e, store: t, fabRef: n, onClick: r }) {
|
|
1027
|
+
let [i, a] = d(e), [o, c] = d(null), l = Q(e), u = e?.survey.fab, f = (u?.timerStyle === "bar" || u?.timerStyle === "fill") && typeof u.expandedTimeout == "number" && Number.isFinite(u.expandedTimeout) && u.expandedTimeout > 0, p = e ?? i;
|
|
1028
|
+
return K(() => {
|
|
1029
|
+
e && a(e);
|
|
1030
|
+
}, [e]), K(() => {
|
|
1031
|
+
!e && i && $(n.current);
|
|
1032
|
+
}, [
|
|
1033
|
+
n,
|
|
1034
|
+
i,
|
|
1035
|
+
e
|
|
1036
|
+
]), s(() => {
|
|
1037
|
+
if (!l) return;
|
|
1038
|
+
let e = Z(), n = setTimeout(() => {
|
|
1039
|
+
t.confirmPresentation("expanded_fab"), t.confirmFabEntranceCompleted();
|
|
1040
|
+
}, e ? 0 : q), r = setTimeout(() => c(l), e ? 0 : f ? se : q);
|
|
1041
|
+
return () => {
|
|
1042
|
+
clearTimeout(n), clearTimeout(r);
|
|
1043
|
+
};
|
|
1044
|
+
}, [
|
|
1045
|
+
f,
|
|
1046
|
+
l,
|
|
1047
|
+
t
|
|
1048
|
+
]), s(() => {
|
|
1049
|
+
if (e || !i) return;
|
|
1050
|
+
let t = setTimeout(() => a(null), Z() ? 0 : J);
|
|
1051
|
+
return () => clearTimeout(t);
|
|
1052
|
+
}, [i, e]), p ? /* @__PURE__ */ h(I, {
|
|
1053
|
+
session: p,
|
|
1054
|
+
fabRef: n,
|
|
1055
|
+
onClick: r,
|
|
1056
|
+
animationState: e ? o === l ? "visible" : "entering" : "exiting"
|
|
1057
|
+
}) : null;
|
|
1058
|
+
}
|
|
1059
|
+
function ue({ session: e, store: t, modal: n }) {
|
|
1060
|
+
let [r, i] = d(e), a = u(null), o = e ?? r;
|
|
1061
|
+
return K(() => {
|
|
1062
|
+
e && i(e);
|
|
1063
|
+
}, [e]), K(() => {
|
|
1064
|
+
let t = a.current;
|
|
1065
|
+
!t || e || (t.classList.add("sb-sheet-root--exiting"), t.setAttribute("aria-hidden", "true"), t.querySelectorAll("button").forEach((e) => {
|
|
1066
|
+
e.disabled = !0;
|
|
1067
|
+
}));
|
|
1068
|
+
}, [e]), s(() => {
|
|
1069
|
+
if (e || !r) return;
|
|
1070
|
+
let t = setTimeout(() => i(null), Z() ? 0 : Y);
|
|
1071
|
+
return () => clearTimeout(t);
|
|
1072
|
+
}, [r, e]), o ? /* @__PURE__ */ h(W, {
|
|
1073
|
+
session: o,
|
|
1074
|
+
store: t,
|
|
1075
|
+
modal: n,
|
|
1076
|
+
rootRef: a
|
|
1077
|
+
}, Q(o)) : null;
|
|
1078
|
+
}
|
|
1079
|
+
function de({ store: e, portal: t = !0, placement: n = "fixed" }) {
|
|
1080
|
+
let r = f(o((t) => e.subscribe(t), [e]), o(() => e.getSnapshot(), [e]), o(() => e.getServerSnapshot(), [e])).state, i = u(null), a = u(null), c = u(null), l = u(null), d = r ? r.completion ? "completion" : r.isOpen ? `sheet:${r.currentNodeId}` : `fab:${r.fabState}` : "none";
|
|
1081
|
+
K(() => {
|
|
1082
|
+
if (!r || !i.current) return;
|
|
1083
|
+
let e = T(r.survey.theme);
|
|
1084
|
+
for (let [t, n] of Object.entries(e)) i.current.style.setProperty(t, n);
|
|
1085
|
+
}, [r]), s(() => {
|
|
1086
|
+
let t = e.getState();
|
|
1087
|
+
if (!t) {
|
|
1088
|
+
let e = i.current?.querySelector(".sb-fab--exiting") ? J : Y, t = setTimeout(() => {
|
|
1089
|
+
let e = l.current;
|
|
1090
|
+
e?.isConnected ? e.focus() : e && i.current?.focus(), l.current = null;
|
|
1091
|
+
}, Z() ? 0 : e);
|
|
1092
|
+
return () => clearTimeout(t);
|
|
1093
|
+
}
|
|
1094
|
+
if (t.isOpen || t.completion) {
|
|
1095
|
+
if (!l.current && document.activeElement instanceof HTMLElement && (l.current = document.activeElement), t.snackbar?.phase === "awaitingReady") return;
|
|
1096
|
+
e.confirmPresentation("sheet"), (i.current?.querySelector("textarea[data-autofocus=\"true\"]") ?? i.current?.querySelector(".sb-sheet__body h2"))?.focus({ preventScroll: !0 });
|
|
1097
|
+
}
|
|
1098
|
+
t.snackbar && !l.current && document.activeElement instanceof HTMLElement && (l.current = document.activeElement);
|
|
1099
|
+
}, [d, e]), K(() => {
|
|
1100
|
+
let e = a.current, t = i.current;
|
|
1101
|
+
if (!e || !t || !r || r.fabState !== "expanded" || r.isOpen) return;
|
|
1102
|
+
let o = () => {
|
|
1103
|
+
let e = a.current;
|
|
1104
|
+
if (!e || !c.current) return;
|
|
1105
|
+
let i = window.visualViewport, o = n === "inline" ? t.getBoundingClientRect() : null, s = n === "inline" ? t.clientWidth || o.width : i?.width && i.width > 0 ? i.width : window.innerWidth, l = n === "inline" ? t.clientHeight || o.height : i?.height && i.height > 0 ? i.height : window.innerHeight, u = e.getBoundingClientRect(), d = getComputedStyle(c.current), f = {
|
|
1106
|
+
top: X(d.paddingTop),
|
|
1107
|
+
right: X(d.paddingRight),
|
|
1108
|
+
bottom: X(d.paddingBottom),
|
|
1109
|
+
left: X(d.paddingLeft)
|
|
1110
|
+
}, p = Math.max(0, s - f.left - f.right), m = e.querySelector(".sb-fab__label"), h = m ? m.scrollWidth || m.getBoundingClientRect().width || ce(m.textContent ?? "") : 0, g = Math.min(p, Math.max(86, 86 + Math.ceil(h))), _ = e.offsetHeight || u.height || 60;
|
|
1111
|
+
e.style.setProperty("--sb-fab-expanded-width", `${g}px`), e.style.setProperty("--sb-fab-label-width", `${Math.max(0, g - 86)}px`);
|
|
1112
|
+
let v = Math.max(0, Math.min(1, r.survey.fab?.placement?.anchor.x ?? 1));
|
|
1113
|
+
e.style.setProperty("--sb-fab-anchor-offset", `${(g - 60) * v}px`);
|
|
1114
|
+
let y = P(r.survey.fab?.placement, {
|
|
1115
|
+
viewport: {
|
|
1116
|
+
width: s,
|
|
1117
|
+
height: l
|
|
1118
|
+
},
|
|
1119
|
+
element: {
|
|
1120
|
+
width: g,
|
|
1121
|
+
height: _
|
|
1122
|
+
},
|
|
1123
|
+
safeArea: f
|
|
1124
|
+
}), b = n === "inline" ? 0 : i?.offsetLeft ?? 0, x = n === "inline" ? 0 : i?.offsetTop ?? 0;
|
|
1125
|
+
e.style.left = `${y.left + b}px`, e.style.top = `${y.top + x}px`, e.style.right = "auto", e.style.bottom = "auto", e.style.transformOrigin = y.transformOrigin;
|
|
1126
|
+
};
|
|
1127
|
+
if (o(), n === "inline") {
|
|
1128
|
+
let e = typeof ResizeObserver > "u" ? null : new ResizeObserver(o);
|
|
1129
|
+
return e?.observe(t), window.addEventListener("resize", o), window.addEventListener("orientationchange", o), () => {
|
|
1130
|
+
e?.disconnect(), window.removeEventListener("resize", o), window.removeEventListener("orientationchange", o);
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
return window.addEventListener("resize", o), window.addEventListener("orientationchange", o), window.visualViewport?.addEventListener("resize", o), window.visualViewport?.addEventListener("scroll", o), () => {
|
|
1134
|
+
window.removeEventListener("resize", o), window.removeEventListener("orientationchange", o), window.visualViewport?.removeEventListener("resize", o), window.visualViewport?.removeEventListener("scroll", o);
|
|
1135
|
+
};
|
|
1136
|
+
}, [n, r]), s(() => {
|
|
1137
|
+
if (!t || !r || !r.isOpen && !r.completion || !i.current) return;
|
|
1138
|
+
let e = i.current, n = Array.from(document.body.children).filter((t) => t !== e).map((e) => ({
|
|
1139
|
+
child: e,
|
|
1140
|
+
ariaHidden: e.getAttribute("aria-hidden"),
|
|
1141
|
+
inert: e.inert
|
|
1142
|
+
}));
|
|
1143
|
+
for (let { child: e } of n) e.setAttribute("aria-hidden", "true"), e.inert = !0;
|
|
1144
|
+
return () => {
|
|
1145
|
+
for (let e of n) e.ariaHidden === null ? e.child.removeAttribute("aria-hidden") : e.child.setAttribute("aria-hidden", e.ariaHidden), e.child.inert = e.inert;
|
|
1146
|
+
};
|
|
1147
|
+
}, [
|
|
1148
|
+
t,
|
|
1149
|
+
d,
|
|
1150
|
+
r
|
|
1151
|
+
]);
|
|
1152
|
+
let m = /* @__PURE__ */ g("div", {
|
|
1153
|
+
ref: i,
|
|
1154
|
+
className: `sb-root sb-root--${n}`,
|
|
1155
|
+
tabIndex: -1,
|
|
1156
|
+
children: [
|
|
1157
|
+
/* @__PURE__ */ h("div", {
|
|
1158
|
+
ref: c,
|
|
1159
|
+
className: "sb-safe-area-probe"
|
|
1160
|
+
}),
|
|
1161
|
+
r?.snackbar ? /* @__PURE__ */ h(oe, {
|
|
1162
|
+
session: r,
|
|
1163
|
+
store: e,
|
|
1164
|
+
placement: n,
|
|
1165
|
+
modal: t
|
|
1166
|
+
}, r.presentationId) : null,
|
|
1167
|
+
/* @__PURE__ */ h(le, {
|
|
1168
|
+
session: r && !r.snackbar && !r.isOpen && !r.completion && r.fabState === "expanded" ? r : null,
|
|
1169
|
+
store: e,
|
|
1170
|
+
fabRef: a,
|
|
1171
|
+
onClick: () => {
|
|
1172
|
+
$(a.current), l.current = a.current, e.openSurvey();
|
|
1173
|
+
}
|
|
1174
|
+
}),
|
|
1175
|
+
/* @__PURE__ */ h(ue, {
|
|
1176
|
+
session: r && !r.snackbar && (r.isOpen || r.completion) ? r : null,
|
|
1177
|
+
store: e,
|
|
1178
|
+
modal: t
|
|
1179
|
+
})
|
|
1180
|
+
]
|
|
1181
|
+
});
|
|
1182
|
+
return t && typeof document < "u" ? p(m, document.body) : m;
|
|
1183
|
+
}
|
|
1184
|
+
//#endregion
|
|
1185
|
+
export { de as t };
|