@mrrocket/sdk 0.18.0 → 0.21.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/CHANGELOG.md +23 -0
- package/README.md +24 -1
- package/dist/api-client.d.ts +28 -4
- package/dist/api-client.js +30 -13
- package/dist/api-client.js.map +1 -1
- package/dist/browser/mrrocket-flows.js +8 -3
- package/dist/browser/mrrocket-messenger.js +38 -5
- package/dist/browser/mrrocket.js +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/client.d.ts +6 -1
- package/dist/client.js +22 -4
- package/dist/client.js.map +1 -1
- package/dist/core.d.ts +5 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/feedback.js +161 -119
- package/dist/feedback.js.map +1 -1
- package/dist/flows-ui.d.ts +1 -1
- package/dist/flows-ui.js +100 -72
- package/dist/flows-ui.js.map +1 -1
- package/dist/flows-web.js +2 -1
- package/dist/flows-web.js.map +1 -1
- package/dist/flows.d.ts +38 -6
- package/dist/flows.js +51 -17
- package/dist/flows.js.map +1 -1
- package/dist/i18n.d.ts +22 -0
- package/dist/i18n.js +74 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/messenger-ui.d.ts +9 -3
- package/dist/messenger-ui.js +324 -152
- package/dist/messenger-ui.js.map +1 -1
- package/dist/messenger.d.ts +3 -1
- package/dist/messenger.js +3 -2
- package/dist/messenger.js.map +1 -1
- package/dist/paywall.js +2 -1
- package/dist/paywall.js.map +1 -1
- package/dist/react-native/index.d.cts +66 -8
- package/dist/react-native/index.d.ts +66 -8
- package/dist/react-native/index.js +615 -334
- package/dist/react-native/index.js.map +1 -1
- package/dist/server.d.ts +4 -2
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/styles-css.d.ts +1 -1
- package/dist/styles-css.js +35 -2
- package/dist/styles-css.js.map +1 -1
- package/dist/survey.js +18 -14
- package/dist/survey.js.map +1 -1
- package/dist/ui.d.ts +2 -0
- package/dist/ui.js +15 -12
- package/dist/ui.js.map +1 -1
- package/package.json +6 -3
package/dist/flows-ui.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/flows-ui.ts
|
|
2
2
|
import { playFinish } from "./finish-web.js";
|
|
3
|
-
import { answerOk, discounted, mediaOf, money, offerButton, videoEmbed } from "./flows.js";
|
|
3
|
+
import { OTHER_PREFIX, answerOk, forMonths, monthsWord, scaleOf, discounted, mediaOf, money, offerButton, videoEmbed } from "./flows.js";
|
|
4
|
+
import { onWords, t, tf, wordsLang } from "./i18n.js";
|
|
4
5
|
import { FLOW_ICONS, iconOf } from "./icons.js";
|
|
5
6
|
var STYLE_ID = "ckf-styles";
|
|
6
7
|
var FLOWS_CSS = `
|
|
@@ -30,6 +31,11 @@ var FLOWS_CSS = `
|
|
|
30
31
|
.ckf-radio{width:16px;height:16px;flex:none;border-radius:50%;border:1.5px solid var(--ckf-line);display:inline-flex;align-items:center;justify-content:center}
|
|
31
32
|
.ckf-opt[aria-checked=true] .ckf-radio{border-color:var(--ckf-accent)}
|
|
32
33
|
.ckf-opt[aria-checked=true] .ckf-radio::after{content:"";width:8px;height:8px;border-radius:50%;background:var(--ckf-accent)}
|
|
34
|
+
.ckf-scale{display:flex;gap:4px}
|
|
35
|
+
.ckf-num{flex:1;min-width:0;height:38px;padding:0;border:1px solid var(--ckf-line);border-radius:8px;background:var(--ckf-bg);cursor:pointer;font-weight:500}
|
|
36
|
+
.ckf-num:hover{background:var(--ckf-soft)}
|
|
37
|
+
.ckf-num[aria-checked=true]{border-color:var(--ckf-accent);background:var(--ckf-accent);color:var(--ckf-accent-ink)}
|
|
38
|
+
.ckf-ends{display:flex;justify-content:space-between;gap:12px;margin-top:6px}
|
|
33
39
|
.ckf-box{border-radius:10px;background:var(--ckf-soft);padding:12px;display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}
|
|
34
40
|
.ckf-big{font-size:22px;font-weight:650;font-variant-numeric:tabular-nums}
|
|
35
41
|
.ckf-strike{color:var(--ckf-muted);text-decoration:line-through;font-variant-numeric:tabular-nums}
|
|
@@ -75,7 +81,7 @@ var FLOWS_CSS = `
|
|
|
75
81
|
.ckf-banner>span{flex:1;min-width:0;display:flex;flex-direction:column}
|
|
76
82
|
.ckf-banner .ckf-btn{height:32px}
|
|
77
83
|
.ckf-pw{max-width:420px;gap:14px}
|
|
78
|
-
.ckf-root[data-still] :is(.ckf-scrim,.ckf-card){animation:none}
|
|
84
|
+
.ckf-root[data-still] :is(.ckf-scrim,.ckf-card,.ckf-banner){animation:none}
|
|
79
85
|
.ckf-li{display:flex;gap:10px;align-items:flex-start;margin:0}
|
|
80
86
|
.ckf-li::before{content:"\u2713";flex:none;width:20px;height:20px;border-radius:50%;background:color-mix(in srgb,var(--ckf-accent) 14%,var(--ckf-bg));color:var(--ckf-accent);font-size:12px;font-weight:700;display:inline-flex;align-items:center;justify-content:center}
|
|
81
87
|
.ckf-quote{margin:0;padding:12px 14px;border-radius:12px;background:var(--ckf-soft)}
|
|
@@ -114,10 +120,11 @@ var button = (label, kind, onClick, opts = {}) => h(
|
|
|
114
120
|
var closeButton = (label, onClick) => h("button", { type: "button", className: "ckf-x", "aria-label": label, "data-ckf-id": "x", onClick: () => onClick() }, "\xD7");
|
|
115
121
|
var dots = (step, steps) => steps > 1 ? h(
|
|
116
122
|
"span",
|
|
117
|
-
{ className: "ckf-dots", role: "img", "aria-label":
|
|
123
|
+
{ className: "ckf-dots", role: "img", "aria-label": tf("Step {n} of {total}", { n: step, total: steps }) },
|
|
118
124
|
...Array.from({ length: steps }, (_, i) => h("span", { className: "ckf-dot", "data-on": i < step }))
|
|
119
125
|
) : h("span");
|
|
120
126
|
var screenKey = (v) => v.type === "cancel" ? `c:${v.screen}:${v.round ?? 1}` : v.type === "step" ? `s:${v.step.id}` : v.type === "checklist" ? `l:${v.flow.id}` : `m:${v.message.id}`;
|
|
127
|
+
var surfaceKey = (v) => v.type === "cancel" ? "c" : v.type === "step" && (v.step.kind === "question" || v.step.kind === "modal") ? `d:${v.flow.id}` : screenKey(v);
|
|
121
128
|
var rootFor = (theme) => {
|
|
122
129
|
if (!document.getElementById(STYLE_ID)) {
|
|
123
130
|
const style = document.createElement("style");
|
|
@@ -130,6 +137,11 @@ var rootFor = (theme) => {
|
|
|
130
137
|
document.body.appendChild(root);
|
|
131
138
|
return root;
|
|
132
139
|
};
|
|
140
|
+
var setRootLang = (root) => {
|
|
141
|
+
const lang = wordsLang();
|
|
142
|
+
if (lang) root.setAttribute("lang", lang);
|
|
143
|
+
else root.removeAttribute("lang");
|
|
144
|
+
};
|
|
133
145
|
var iconEl = (icon, className) => {
|
|
134
146
|
const i = iconOf(icon);
|
|
135
147
|
if (!i) return false;
|
|
@@ -156,6 +168,7 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
156
168
|
const root = rootFor(theme);
|
|
157
169
|
let played = "";
|
|
158
170
|
let lastKey = "";
|
|
171
|
+
let lastSurface = "";
|
|
159
172
|
let returnFocus = null;
|
|
160
173
|
let comment = "";
|
|
161
174
|
let placed = null;
|
|
@@ -165,7 +178,7 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
165
178
|
const body = [];
|
|
166
179
|
if (v.screen === "survey") {
|
|
167
180
|
body.push(
|
|
168
|
-
h("h2", { className: "ckf-h", id: titleId }, v.flow.question || "Why are you leaving?"),
|
|
181
|
+
h("h2", { className: "ckf-h", id: titleId }, v.flow.question || t("Why are you leaving?")),
|
|
169
182
|
h(
|
|
170
183
|
"div",
|
|
171
184
|
{ className: "ckf-opts", role: "radiogroup", "aria-labelledby": titleId },
|
|
@@ -188,8 +201,8 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
188
201
|
h(
|
|
189
202
|
"div",
|
|
190
203
|
{ className: "ckf-btns" },
|
|
191
|
-
button("Continue", "primary", ctl.cancel.next, { disabled: !v.reason, id: "go" }),
|
|
192
|
-
button("Never mind, keep my plan", "quiet", ctl.cancel.close)
|
|
204
|
+
button(t("Continue"), "primary", ctl.cancel.next, { disabled: !v.reason, id: "go" }),
|
|
205
|
+
button(t("Never mind, keep my plan"), "quiet", ctl.cancel.close)
|
|
193
206
|
)
|
|
194
207
|
);
|
|
195
208
|
} else if (v.screen === "followup" && v.followUp) {
|
|
@@ -211,14 +224,15 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
211
224
|
onClick: () => ctl.cancel.answer(a)
|
|
212
225
|
},
|
|
213
226
|
h("span", { className: "ckf-radio" }),
|
|
214
|
-
a
|
|
227
|
+
// The label in the visitor's language; what is recorded stays `a`.
|
|
228
|
+
f.answerLabels?.[i] || a
|
|
215
229
|
)
|
|
216
230
|
)
|
|
217
231
|
);
|
|
218
232
|
else {
|
|
219
233
|
const text = h("textarea", {
|
|
220
234
|
className: "ckf-text",
|
|
221
|
-
placeholder: "Your answer (optional)",
|
|
235
|
+
placeholder: t("Your answer (optional)"),
|
|
222
236
|
"aria-labelledby": titleId,
|
|
223
237
|
maxlength: "500",
|
|
224
238
|
"data-ckf-id": "answer",
|
|
@@ -229,14 +243,14 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
229
243
|
}
|
|
230
244
|
const label = v.flow.reasons.find((r) => r.id === v.reason)?.label;
|
|
231
245
|
body.push(
|
|
232
|
-
label ? h("p", { className: "ckf-small" },
|
|
246
|
+
label ? h("p", { className: "ckf-small" }, tf("You said: {label}", { label })) : false,
|
|
233
247
|
h("h2", { className: "ckf-h", id: titleId }, f.question),
|
|
234
248
|
field,
|
|
235
249
|
h(
|
|
236
250
|
"div",
|
|
237
251
|
{ className: "ckf-btns" },
|
|
238
|
-
button("Continue", "primary", ctl.cancel.next, { id: "go" }),
|
|
239
|
-
button("Never mind, keep my plan", "quiet", ctl.cancel.close)
|
|
252
|
+
button(t("Continue"), "primary", ctl.cancel.next, { id: "go" }),
|
|
253
|
+
button(t("Never mind, keep my plan"), "quiet", ctl.cancel.close)
|
|
240
254
|
)
|
|
241
255
|
);
|
|
242
256
|
} else if (v.screen === "offer" && v.offer) {
|
|
@@ -252,48 +266,48 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
252
266
|
h(
|
|
253
267
|
"span",
|
|
254
268
|
{ className: "ckf-small" },
|
|
255
|
-
`/${v.price.interval
|
|
269
|
+
`/${v.price.interval === "year" ? t("year") : t("month")}${o.months ? ` ${forMonths(o.months)}` : ""}`
|
|
256
270
|
)
|
|
257
271
|
) : h(
|
|
258
272
|
"div",
|
|
259
273
|
{ className: "ckf-box" },
|
|
260
|
-
h("span", { className: "ckf-big" },
|
|
261
|
-
o.months ? h("span", { className: "ckf-small" },
|
|
274
|
+
h("span", { className: "ckf-big" }, tf("{percent}% off", { percent: o.percent })),
|
|
275
|
+
o.months ? h("span", { className: "ckf-small" }, forMonths(o.months)) : false
|
|
262
276
|
);
|
|
263
277
|
if (o.kind === "pause" && o.months)
|
|
264
278
|
detail = h(
|
|
265
279
|
"div",
|
|
266
280
|
{ className: "ckf-box" },
|
|
267
|
-
h("span", {},
|
|
281
|
+
h("span", {}, tf("Pause for up to {months}. Your data stays.", { months: monthsWord(o.months) }))
|
|
268
282
|
);
|
|
269
283
|
if (o.kind === "downgrade" && o.planName) detail = h("div", { className: "ckf-box" }, h("b", {}, o.planName));
|
|
270
284
|
const text = o.kind === "contact" ? h("textarea", {
|
|
271
285
|
className: "ckf-text",
|
|
272
|
-
placeholder: "What would make you stay?",
|
|
273
|
-
"aria-label": "Your message",
|
|
286
|
+
placeholder: t("What would make you stay?"),
|
|
287
|
+
"aria-label": t("Your message"),
|
|
274
288
|
maxlength: "500",
|
|
275
289
|
"data-ckf-id": "comment",
|
|
276
290
|
onInput: (e) => comment = e.target.value
|
|
277
291
|
}) : null;
|
|
278
292
|
if (text) text.value = comment;
|
|
279
293
|
body.push(
|
|
280
|
-
label ? h("p", { className: "ckf-small" },
|
|
294
|
+
label ? h("p", { className: "ckf-small" }, tf("You said: {label}", { label })) : false,
|
|
281
295
|
h("h2", { className: "ckf-h", id: titleId }, o.headline),
|
|
282
296
|
detail,
|
|
283
297
|
text ?? false,
|
|
284
298
|
h(
|
|
285
299
|
"div",
|
|
286
300
|
{ className: "ckf-btns" },
|
|
287
|
-
button(busy ? "One moment\u2026" : offerButton(o), "primary", () => ctl.cancel.accept(comment), { disabled: busy, id: "go" }),
|
|
288
|
-
button("No thanks, continue cancelling", "quiet", ctl.cancel.decline, { disabled: busy })
|
|
301
|
+
button(busy ? t("One moment\u2026") : offerButton(o), "primary", () => ctl.cancel.accept(comment), { disabled: busy, id: "go" }),
|
|
302
|
+
button(t("No thanks, continue cancelling"), "quiet", ctl.cancel.decline, { disabled: busy })
|
|
289
303
|
)
|
|
290
304
|
);
|
|
291
305
|
} else {
|
|
292
306
|
const plain = v.steps === 1;
|
|
293
307
|
const text = plain ? null : h("textarea", {
|
|
294
308
|
className: "ckf-text",
|
|
295
|
-
placeholder: "Anything else we should know? (optional)",
|
|
296
|
-
"aria-label": "Anything else we should know? (optional)",
|
|
309
|
+
placeholder: t("Anything else we should know? (optional)"),
|
|
310
|
+
"aria-label": t("Anything else we should know? (optional)"),
|
|
297
311
|
maxlength: "500",
|
|
298
312
|
"data-ckf-id": "comment",
|
|
299
313
|
onInput: (e) => comment = e.target.value
|
|
@@ -306,8 +320,8 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
306
320
|
h(
|
|
307
321
|
"div",
|
|
308
322
|
{ className: "ckf-btns" },
|
|
309
|
-
button(busy ? "One moment\u2026" : v.flow.confirm.button, "danger", () => ctl.cancel.confirm(comment), { disabled: busy, id: "go" }),
|
|
310
|
-
button("Keep my plan", "secondary", ctl.cancel.close, { disabled: busy })
|
|
323
|
+
button(busy ? t("One moment\u2026") : v.flow.confirm.button, "danger", () => ctl.cancel.confirm(comment), { disabled: busy, id: "go" }),
|
|
324
|
+
button(t("Keep my plan"), "secondary", ctl.cancel.close, { disabled: busy })
|
|
311
325
|
)
|
|
312
326
|
);
|
|
313
327
|
}
|
|
@@ -317,7 +331,7 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
317
331
|
h(
|
|
318
332
|
"div",
|
|
319
333
|
{ className: "ckf-card", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId },
|
|
320
|
-
h("div", { className: "ckf-top" }, dots(v.step, v.steps), closeButton("Close", ctl.cancel.close)),
|
|
334
|
+
h("div", { className: "ckf-top" }, dots(v.step, v.steps), closeButton(t("Close"), ctl.cancel.close)),
|
|
321
335
|
...body,
|
|
322
336
|
v.error ? h("p", { className: "ckf-err", role: "alert" }, v.error) : false
|
|
323
337
|
)
|
|
@@ -331,7 +345,7 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
331
345
|
return v.kind === "iframe" ? h(
|
|
332
346
|
"div",
|
|
333
347
|
{ className: "ckf-video" },
|
|
334
|
-
h("iframe", { src: v.src, title: m.alt || "Video", allow: "fullscreen; picture-in-picture", allowfullscreen: true, loading: "lazy", referrerpolicy: "strict-origin-when-cross-origin" })
|
|
348
|
+
h("iframe", { src: v.src, title: m.alt || t("Video"), allow: "fullscreen; picture-in-picture", allowfullscreen: true, loading: "lazy", referrerpolicy: "strict-origin-when-cross-origin" })
|
|
335
349
|
) : h("video", { className: "ckf-media", src: v.src, controls: true, playsinline: true, preload: "metadata", "aria-label": m.alt || void 0, onLoadedmetadata: () => follow() });
|
|
336
350
|
};
|
|
337
351
|
const questionCard = (v) => {
|
|
@@ -340,47 +354,51 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
340
354
|
const titleId = "ckf-title";
|
|
341
355
|
const ok = answerOk(q, v.answer);
|
|
342
356
|
let field = false;
|
|
343
|
-
|
|
344
|
-
field = h(
|
|
345
|
-
"div",
|
|
346
|
-
{ className: "ckf-opts", role: "radiogroup", "aria-labelledby": titleId },
|
|
347
|
-
...(q.options ?? []).map(
|
|
348
|
-
(o) => h(
|
|
349
|
-
"button",
|
|
350
|
-
{
|
|
351
|
-
type: "button",
|
|
352
|
-
role: "radio",
|
|
353
|
-
className: "ckf-opt",
|
|
354
|
-
"aria-checked": String(v.answer === o.id),
|
|
355
|
-
"data-ckf-id": `q:${o.id}`,
|
|
356
|
-
onClick: () => ctl.onboarding.answer(o.id)
|
|
357
|
-
},
|
|
358
|
-
h("span", { className: "ckf-radio" }),
|
|
359
|
-
o.label
|
|
360
|
-
)
|
|
361
|
-
)
|
|
362
|
-
);
|
|
363
|
-
else if (q) {
|
|
357
|
+
const textField = (hint, value, write) => {
|
|
364
358
|
const input = h("input", {
|
|
365
359
|
type: "text",
|
|
366
360
|
className: "ckf-input",
|
|
367
|
-
placeholder:
|
|
361
|
+
placeholder: hint,
|
|
368
362
|
"aria-labelledby": titleId,
|
|
369
363
|
maxlength: "500",
|
|
370
364
|
"data-ckf-id": "answer",
|
|
371
|
-
onInput: (e) =>
|
|
365
|
+
onInput: (e) => write(e.target.value),
|
|
372
366
|
onKeydown: (e) => e.key === "Enter" && ctl.onboarding.next()
|
|
373
367
|
});
|
|
374
|
-
input.value =
|
|
375
|
-
|
|
376
|
-
}
|
|
368
|
+
input.value = value;
|
|
369
|
+
return input;
|
|
370
|
+
};
|
|
371
|
+
const picked = (on, id, label, press) => h("button", { type: "button", role: "radio", className: "ckf-opt", "aria-checked": String(on), "data-ckf-id": `q:${id}`, onClick: press }, h("span", { className: "ckf-radio" }), label);
|
|
372
|
+
if (q?.type === "choice") {
|
|
373
|
+
const other = !!q.other && !!v.answer?.startsWith(OTHER_PREFIX);
|
|
374
|
+
field = h(
|
|
375
|
+
"div",
|
|
376
|
+
{ className: "ckf-opts", role: "radiogroup", "aria-labelledby": titleId },
|
|
377
|
+
...(q.options ?? []).map((o) => picked(v.answer === o.id, o.id, o.label, () => ctl.onboarding.answer(o.id))),
|
|
378
|
+
q.other ? picked(other, "other", q.otherLabel || t("Other"), () => other || ctl.onboarding.answer(OTHER_PREFIX)) : false,
|
|
379
|
+
other ? textField(t("Your answer"), v.answer.slice(OTHER_PREFIX.length), (t2) => ctl.onboarding.answer(OTHER_PREFIX + t2)) : false
|
|
380
|
+
);
|
|
381
|
+
} else if (q?.type === "scale")
|
|
382
|
+
field = h(
|
|
383
|
+
"div",
|
|
384
|
+
{},
|
|
385
|
+
h(
|
|
386
|
+
"div",
|
|
387
|
+
{ className: "ckf-scale", role: "radiogroup", "aria-labelledby": titleId },
|
|
388
|
+
...scaleOf(q).map(
|
|
389
|
+
(n) => h("button", { type: "button", role: "radio", className: "ckf-num", "aria-checked": String(v.answer === String(n)), "data-ckf-id": `q:${n}`, onClick: () => ctl.onboarding.answer(String(n)) }, String(n))
|
|
390
|
+
)
|
|
391
|
+
),
|
|
392
|
+
q.lowLabel || q.highLabel ? h("div", { className: "ckf-ends ckf-small" }, h("span", {}, q.lowLabel || ""), h("span", {}, q.highLabel || "")) : false
|
|
393
|
+
);
|
|
394
|
+
else if (q) field = textField(q.placeholder || t("Your answer"), v.answer ?? "", (t2) => ctl.onboarding.answer(t2));
|
|
377
395
|
return h(
|
|
378
396
|
"div",
|
|
379
397
|
{ className: "ckf-scrim" },
|
|
380
398
|
h(
|
|
381
399
|
"div",
|
|
382
400
|
{ className: "ckf-card", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId },
|
|
383
|
-
h("div", { className: "ckf-top" }, dots(v.index + 1, v.total), closeButton("Close", ctl.onboarding.dismiss)),
|
|
401
|
+
h("div", { className: "ckf-top" }, dots(v.index + 1, v.total), closeButton(t("Close"), ctl.onboarding.dismiss)),
|
|
384
402
|
v.index === 0 ? iconEl(v.flow.icon, "ckf-hic") : false,
|
|
385
403
|
h("h2", { className: "ckf-h", id: titleId }, s.title),
|
|
386
404
|
s.body ? h("p", { className: "ckf-p" }, s.body) : false,
|
|
@@ -388,8 +406,9 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
388
406
|
h(
|
|
389
407
|
"div",
|
|
390
408
|
{ className: "ckf-row" },
|
|
391
|
-
v.back ? button("Back", "quiet", ctl.onboarding.back) : false,
|
|
392
|
-
button(
|
|
409
|
+
v.back ? button(t("Back"), "quiet", ctl.onboarding.back) : false,
|
|
410
|
+
q?.optional ? button(q.skipLabel || t("Skip"), "quiet", ctl.onboarding.skip) : false,
|
|
411
|
+
button(s.button || (v.last ? t("Done") : t("Continue")), "primary", ctl.onboarding.next, { disabled: !ok, id: "go" })
|
|
393
412
|
)
|
|
394
413
|
)
|
|
395
414
|
);
|
|
@@ -403,14 +422,14 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
403
422
|
h(
|
|
404
423
|
"div",
|
|
405
424
|
{ className: "ckf-top" },
|
|
406
|
-
v.total > 1 ? h("p", { className: "ckf-small" },
|
|
407
|
-
closeButton("Close the tour", ctl.onboarding.dismiss)
|
|
425
|
+
v.total > 1 ? h("p", { className: "ckf-small" }, tf("Step {n} of {total}", { n: v.index + 1, total: v.total })) : h("span"),
|
|
426
|
+
closeButton(t("Close the tour"), ctl.onboarding.dismiss)
|
|
408
427
|
),
|
|
409
428
|
s.kind === "modal" ? iconEl(v.flow.icon, "ckf-hic") : false,
|
|
410
429
|
media(s),
|
|
411
430
|
h("h2", { className: "ckf-h", id: "ckf-title" }, s.title),
|
|
412
431
|
s.body ? h("p", { className: "ckf-p" }, s.body) : false,
|
|
413
|
-
h("div", { className: "ckf-row" }, button(s.button || (v.last ? "Done" : "Next"), "primary", ctl.onboarding.next, { id: "go" }))
|
|
432
|
+
h("div", { className: "ckf-row" }, button(s.button || (v.last ? t("Done") : t("Next")), "primary", ctl.onboarding.next, { id: "go" }))
|
|
414
433
|
);
|
|
415
434
|
if (s.kind === "modal") return h("div", { className: "ckf-scrim" }, card);
|
|
416
435
|
const target = s.target ? findTarget(s.target) : null;
|
|
@@ -424,10 +443,10 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
424
443
|
}
|
|
425
444
|
return float;
|
|
426
445
|
};
|
|
427
|
-
const findTarget = (
|
|
428
|
-
const named = () => document.querySelector(`[data-ck-target="${CSS.escape(
|
|
429
|
-
if (!/^[#.[]|[\s>:=]/.test(
|
|
430
|
-
return safeQuery(
|
|
446
|
+
const findTarget = (t2) => {
|
|
447
|
+
const named = () => document.querySelector(`[data-ck-target="${CSS.escape(t2)}"]`);
|
|
448
|
+
if (!/^[#.[]|[\s>:=]/.test(t2)) return named();
|
|
449
|
+
return safeQuery(t2) ?? named();
|
|
431
450
|
};
|
|
432
451
|
const safeQuery = (sel) => {
|
|
433
452
|
try {
|
|
@@ -474,9 +493,9 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
474
493
|
"div",
|
|
475
494
|
{ className: "ckf-top" },
|
|
476
495
|
h("h2", { className: "ckf-h", id: "ckf-title" }, v.flow.name),
|
|
477
|
-
closeButton("Hide the checklist", ctl.onboarding.dismiss)
|
|
496
|
+
closeButton(t("Hide the checklist"), ctl.onboarding.dismiss)
|
|
478
497
|
),
|
|
479
|
-
h("p", { className: "ckf-small" },
|
|
498
|
+
h("p", { className: "ckf-small" }, tf("{done} of {total} done", { done, total: v.items.length })),
|
|
480
499
|
h(
|
|
481
500
|
"div",
|
|
482
501
|
{ className: "ckf-bar", role: "progressbar", "aria-valuemin": "0", "aria-valuemax": String(v.items.length), "aria-valuenow": String(done) },
|
|
@@ -497,7 +516,7 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
497
516
|
{
|
|
498
517
|
type: "button",
|
|
499
518
|
className: "ckf-check",
|
|
500
|
-
"aria-label":
|
|
519
|
+
"aria-label": tf("Start \u201C{title}\u201D", { title: step.title }),
|
|
501
520
|
"data-ckf-id": `t:${step.id}`,
|
|
502
521
|
onClick: () => ctl.onboarding.open(step.id)
|
|
503
522
|
},
|
|
@@ -509,7 +528,7 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
509
528
|
{
|
|
510
529
|
type: "button",
|
|
511
530
|
className: "ckf-check",
|
|
512
|
-
"aria-label":
|
|
531
|
+
"aria-label": tf("Mark \u201C{title}\u201D done", { title: step.title }),
|
|
513
532
|
"data-ckf-id": `i:${step.id}`,
|
|
514
533
|
onClick: () => ctl.onboarding.check(step.id)
|
|
515
534
|
},
|
|
@@ -529,7 +548,7 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
529
548
|
{ className: "ckf-banner", role: "status" },
|
|
530
549
|
h("span", {}, h("b", {}, m.title), m.body ? h("span", { className: "ckf-small" }, m.body) : false),
|
|
531
550
|
action,
|
|
532
|
-
closeButton("Dismiss", ctl.message.dismiss)
|
|
551
|
+
closeButton(t("Dismiss"), ctl.message.dismiss)
|
|
533
552
|
);
|
|
534
553
|
return h(
|
|
535
554
|
"div",
|
|
@@ -537,7 +556,7 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
537
556
|
h(
|
|
538
557
|
"div",
|
|
539
558
|
{ className: "ckf-card", role: "dialog", "aria-modal": "true", "aria-labelledby": "ckf-title" },
|
|
540
|
-
h("div", { className: "ckf-top" }, h("span"), closeButton("Dismiss", ctl.message.dismiss)),
|
|
559
|
+
h("div", { className: "ckf-top" }, h("span"), closeButton(t("Dismiss"), ctl.message.dismiss)),
|
|
541
560
|
h("h2", { className: "ckf-h", id: "ckf-title" }, m.title),
|
|
542
561
|
m.body ? h("p", { className: "ckf-p" }, m.body) : false,
|
|
543
562
|
action ? h("div", { className: "ckf-row" }, action) : false
|
|
@@ -546,6 +565,7 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
546
565
|
};
|
|
547
566
|
const draw = () => {
|
|
548
567
|
const v = ctl.view();
|
|
568
|
+
setRootLang(root);
|
|
549
569
|
const accent = theme.accent ?? ctl.accent?.();
|
|
550
570
|
if (accent) root.style.setProperty("--ckf-accent", accent);
|
|
551
571
|
const fin = ctl.finale?.();
|
|
@@ -560,6 +580,9 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
560
580
|
if (key !== lastKey && !key.startsWith("c:")) comment = "";
|
|
561
581
|
if (!key) comment = "";
|
|
562
582
|
placed = null;
|
|
583
|
+
const surface = v ? surfaceKey(v) : "";
|
|
584
|
+
root.toggleAttribute("data-still", !!surface && surface === lastSurface);
|
|
585
|
+
lastSurface = surface;
|
|
563
586
|
root.replaceChildren(
|
|
564
587
|
...v ? [v.type === "cancel" ? cancelCard(v) : v.type === "step" ? stepCard(v) : v.type === "checklist" ? checklist(v) : message(v)] : []
|
|
565
588
|
);
|
|
@@ -589,9 +612,11 @@ var mountFlows = (ctl, theme = {}) => {
|
|
|
589
612
|
window.addEventListener("resize", follow);
|
|
590
613
|
window.addEventListener("scroll", follow, { passive: true, capture: true });
|
|
591
614
|
const off = ctl.subscribe(draw);
|
|
615
|
+
const offWords = onWords(draw);
|
|
592
616
|
draw();
|
|
593
617
|
return () => {
|
|
594
618
|
off();
|
|
619
|
+
offWords();
|
|
595
620
|
document.removeEventListener("keydown", onKey);
|
|
596
621
|
window.removeEventListener("resize", follow);
|
|
597
622
|
window.removeEventListener("scroll", follow, { capture: true });
|
|
@@ -606,6 +631,7 @@ var mountPaywall = (host, theme = {}) => {
|
|
|
606
631
|
let returnFocus = null;
|
|
607
632
|
const draw = () => {
|
|
608
633
|
const v = host.view();
|
|
634
|
+
setRootLang(root);
|
|
609
635
|
const key = v ? `${v.paywall.id}:${v.index}` : "";
|
|
610
636
|
if (key && !lastKey && document.activeElement instanceof HTMLElement) returnFocus = document.activeElement;
|
|
611
637
|
if (!v) {
|
|
@@ -619,7 +645,7 @@ var mountPaywall = (host, theme = {}) => {
|
|
|
619
645
|
const p = v.page;
|
|
620
646
|
const plans = p.kind === "plans" ? h(
|
|
621
647
|
"div",
|
|
622
|
-
{ className: "ckf-opts", role: "radiogroup", "aria-label": "Plans" },
|
|
648
|
+
{ className: "ckf-opts", role: "radiogroup", "aria-label": t("Plans") },
|
|
623
649
|
...v.plans.map(
|
|
624
650
|
(plan) => h(
|
|
625
651
|
"button",
|
|
@@ -644,7 +670,7 @@ var mountPaywall = (host, theme = {}) => {
|
|
|
644
670
|
h(
|
|
645
671
|
"div",
|
|
646
672
|
{ className: "ckf-card ckf-pw", role: "dialog", "aria-modal": "true", "aria-labelledby": "ckf-title" },
|
|
647
|
-
h("div", { className: "ckf-top" }, dots(v.index + 1, v.total), closeButton("Close", host.close)),
|
|
673
|
+
h("div", { className: "ckf-top" }, dots(v.index + 1, v.total), closeButton(t("Close"), host.close)),
|
|
648
674
|
h("h2", { className: "ckf-h", id: "ckf-title" }, p.title),
|
|
649
675
|
p.body ? h("p", { className: "ckf-p" }, p.body) : false,
|
|
650
676
|
p.kind === "benefits" && p.items?.length ? h("div", { className: "ckf-opts" }, ...p.items.map((i) => h("p", { className: "ckf-li" }, i))) : false,
|
|
@@ -654,11 +680,11 @@ var mountPaywall = (host, theme = {}) => {
|
|
|
654
680
|
h(
|
|
655
681
|
"div",
|
|
656
682
|
{ className: "ckf-btns" },
|
|
657
|
-
button(v.busy ? "One moment\u2026" : p.button || "Continue", "primary", host.next, {
|
|
683
|
+
button(v.busy ? t("One moment\u2026") : p.button || t("Continue"), "primary", host.next, {
|
|
658
684
|
disabled: v.busy || p.kind === "plans" && !v.plan,
|
|
659
685
|
id: "go"
|
|
660
686
|
}),
|
|
661
|
-
v.index ? button("Back", "quiet", host.back, { disabled: v.busy }) : false
|
|
687
|
+
v.index ? button(t("Back"), "quiet", host.back, { disabled: v.busy }) : false
|
|
662
688
|
)
|
|
663
689
|
)
|
|
664
690
|
)
|
|
@@ -672,9 +698,11 @@ var mountPaywall = (host, theme = {}) => {
|
|
|
672
698
|
};
|
|
673
699
|
document.addEventListener("keydown", onKey);
|
|
674
700
|
const off = host.subscribe(draw);
|
|
701
|
+
const offWords = onWords(draw);
|
|
675
702
|
draw();
|
|
676
703
|
return () => {
|
|
677
704
|
off();
|
|
705
|
+
offWords();
|
|
678
706
|
document.removeEventListener("keydown", onKey);
|
|
679
707
|
root.remove();
|
|
680
708
|
};
|