@tiendanube/live-state 1.1.0 → 1.2.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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +93 -82
- package/dist/index.js.map +1 -1
- package/dist/src/components/LiveStateMessage.d.ts +9 -0
- package/dist/src/components/LiveStateMessage.d.ts.map +1 -0
- package/dist/src/components/{LiveStateInfo.d.ts → LiveStatePromo.d.ts} +6 -6
- package/dist/src/components/LiveStatePromo.d.ts.map +1 -0
- package/dist/src/components/LiveStateRenderer.d.ts +2 -10
- package/dist/src/components/LiveStateRenderer.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +6 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +1 -0
- package/dist/testing.js.map +1 -1
- package/package.json +5 -3
- package/dist/src/components/LiveStateAlert.d.ts +0 -24
- package/dist/src/components/LiveStateAlert.d.ts.map +0 -1
- package/dist/src/components/LiveStateInfo.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { jsx as D, jsxs as O } from "react/jsx-runtime";
|
|
|
5
5
|
import { Alert as ee, Box as k, Button as te, Card as ne, Icon as re, Link as ie, Text as A } from "@nimbus-ds/components";
|
|
6
6
|
import { CloseIcon as ae, MoneyIcon as oe } from "@nimbus-ds/icons";
|
|
7
7
|
//#region node_modules/@tanstack/query-core/build/modern/queryObserver.js
|
|
8
|
-
var
|
|
8
|
+
var se = class extends n {
|
|
9
9
|
constructor(e, t) {
|
|
10
10
|
super(), this.options = t, this.#e = e, this.#s = null, this.#o = h(), this.bindMethods(), this.setOptions(t);
|
|
11
11
|
}
|
|
@@ -28,16 +28,16 @@ var j = class extends n {
|
|
|
28
28
|
this.refetch = this.refetch.bind(this);
|
|
29
29
|
}
|
|
30
30
|
onSubscribe() {
|
|
31
|
-
this.listeners.size === 1 && (this.#t.addObserver(this),
|
|
31
|
+
this.listeners.size === 1 && (this.#t.addObserver(this), j(this.#t, this.options) ? this.#h() : this.updateResult(), this.#y());
|
|
32
32
|
}
|
|
33
33
|
onUnsubscribe() {
|
|
34
34
|
this.hasListeners() || this.destroy();
|
|
35
35
|
}
|
|
36
36
|
shouldFetchOnReconnect() {
|
|
37
|
-
return
|
|
37
|
+
return M(this.#t, this.options, this.options.refetchOnReconnect);
|
|
38
38
|
}
|
|
39
39
|
shouldFetchOnWindowFocus() {
|
|
40
|
-
return
|
|
40
|
+
return M(this.#t, this.options, this.options.refetchOnWindowFocus);
|
|
41
41
|
}
|
|
42
42
|
destroy() {
|
|
43
43
|
this.listeners = /* @__PURE__ */ new Set(), this.#b(), this.#x(), this.#t.removeObserver(this);
|
|
@@ -51,13 +51,13 @@ var j = class extends n {
|
|
|
51
51
|
observer: this
|
|
52
52
|
});
|
|
53
53
|
let r = this.hasListeners();
|
|
54
|
-
r &&
|
|
54
|
+
r && N(this.#t, n, this.options, t) && this.#h(), this.updateResult(), r && (this.#t !== n || y(this.options.enabled, this.#t) !== y(t.enabled, this.#t) || S(this.options.staleTime, this.#t) !== S(t.staleTime, this.#t)) && this.#g();
|
|
55
55
|
let i = this.#_();
|
|
56
56
|
r && (this.#t !== n || y(this.options.enabled, this.#t) !== y(t.enabled, this.#t) || i !== this.#p) && this.#v(i);
|
|
57
57
|
}
|
|
58
58
|
getOptimisticResult(e) {
|
|
59
59
|
let t = this.#e.getQueryCache().build(this.#e, e), n = this.createResult(t, e);
|
|
60
|
-
return
|
|
60
|
+
return le(this, n) && (this.#r = n, this.#a = this.options, this.#i = this.#t.state), n;
|
|
61
61
|
}
|
|
62
62
|
getCurrentResult() {
|
|
63
63
|
return this.#r;
|
|
@@ -118,7 +118,7 @@ var j = class extends n {
|
|
|
118
118
|
createResult(e, t) {
|
|
119
119
|
let n = this.#t, i = this.options, a = this.#r, s = this.#i, c = this.#a, l = e === n ? this.#n : e.state, { state: u } = e, d = { ...u }, f = !1, p;
|
|
120
120
|
if (t._optimisticResults) {
|
|
121
|
-
let r = this.hasListeners(), a = !r &&
|
|
121
|
+
let r = this.hasListeners(), a = !r && j(e, t), s = r && N(e, n, t, i);
|
|
122
122
|
(a || s) && (d = {
|
|
123
123
|
...d,
|
|
124
124
|
...o(u.data, e.options)
|
|
@@ -161,7 +161,7 @@ var j = class extends n {
|
|
|
161
161
|
isPaused: d.fetchStatus === "paused",
|
|
162
162
|
isPlaceholderData: f,
|
|
163
163
|
isRefetchError: S && w,
|
|
164
|
-
isStale:
|
|
164
|
+
isStale: P(e, t),
|
|
165
165
|
refetch: this.refetch,
|
|
166
166
|
promise: this.#o,
|
|
167
167
|
isEnabled: y(t.enabled, e) !== !1
|
|
@@ -219,35 +219,35 @@ var j = class extends n {
|
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
|
-
function
|
|
222
|
+
function ce(e, t) {
|
|
223
223
|
return y(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && y(t.retryOnMount, e) === !1);
|
|
224
224
|
}
|
|
225
|
-
function
|
|
226
|
-
return
|
|
225
|
+
function j(e, t) {
|
|
226
|
+
return ce(e, t) || e.state.data !== void 0 && M(e, t, t.refetchOnMount);
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function M(e, t, n) {
|
|
229
229
|
if (y(t.enabled, e) !== !1 && S(t.staleTime, e) !== "static") {
|
|
230
230
|
let r = typeof n == "function" ? n(e) : n;
|
|
231
|
-
return r === "always" || r !== !1 &&
|
|
231
|
+
return r === "always" || r !== !1 && P(e, t);
|
|
232
232
|
}
|
|
233
233
|
return !1;
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
return (e !== t || y(r.enabled, e) === !1) && (!n.suspense || e.state.status !== "error") &&
|
|
235
|
+
function N(e, t, n, r) {
|
|
236
|
+
return (e !== t || y(r.enabled, e) === !1) && (!n.suspense || e.state.status !== "error") && P(e, n);
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function P(e, t) {
|
|
239
239
|
return y(t.enabled, e) !== !1 && e.isStaleByTime(S(t.staleTime, e));
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function le(e, t) {
|
|
242
242
|
return !a(e.getCurrentResult(), t);
|
|
243
243
|
}
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js
|
|
246
|
-
var
|
|
247
|
-
|
|
246
|
+
var F = C.createContext(!1), ue = () => C.useContext(F);
|
|
247
|
+
F.Provider;
|
|
248
248
|
//#endregion
|
|
249
249
|
//#region node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js
|
|
250
|
-
function
|
|
250
|
+
function de() {
|
|
251
251
|
let e = !1;
|
|
252
252
|
return {
|
|
253
253
|
clearReset: () => {
|
|
@@ -259,7 +259,7 @@ function ue() {
|
|
|
259
259
|
isReset: () => e
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
|
-
var
|
|
262
|
+
var I = C.createContext(de()), L = () => C.useContext(I), R = (e, t, n) => {
|
|
263
263
|
let r = n?.state.error && typeof e.throwOnError == "function" ? x(e.throwOnError, [n.state.error, n]) : e.throwOnError;
|
|
264
264
|
(e.suspense || e.experimental_prefetchInRender || r) && (t.isReset() || (e.retryOnMount = !1));
|
|
265
265
|
}, z = (e) => {
|
|
@@ -276,9 +276,9 @@ var de = C.createContext(ue()), L = () => C.useContext(de), R = (e, t, n) => {
|
|
|
276
276
|
});
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region node_modules/@tanstack/react-query/build/modern/useBaseQuery.js
|
|
279
|
-
function
|
|
279
|
+
function me(e, t, n) {
|
|
280
280
|
if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e))) throw Error("Bad argument type. Starting with v5, only the \"Object\" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object");
|
|
281
|
-
let r =
|
|
281
|
+
let r = ue(), i = L(), a = d(n), o = a.defaultQueryOptions(e);
|
|
282
282
|
a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);
|
|
283
283
|
let l = a.getQueryCache().get(o.queryHash);
|
|
284
284
|
process.env.NODE_ENV !== "production" && (o.queryFn || console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)), o._optimisticResults = r ? "isRestoring" : "optimistic", V(o), R(o, i, l), z(i);
|
|
@@ -302,27 +302,27 @@ function U(e, t, n) {
|
|
|
302
302
|
}
|
|
303
303
|
//#endregion
|
|
304
304
|
//#region node_modules/@tanstack/react-query/build/modern/useQuery.js
|
|
305
|
-
function
|
|
306
|
-
return
|
|
305
|
+
function he(e, t) {
|
|
306
|
+
return me(e, se, t);
|
|
307
307
|
}
|
|
308
308
|
//#endregion
|
|
309
309
|
//#region src/utils/query.ts
|
|
310
|
-
var
|
|
311
|
-
async function
|
|
310
|
+
var U = ["live-state"];
|
|
311
|
+
async function ge(e) {
|
|
312
312
|
await _.prefetchQuery({
|
|
313
|
-
queryKey:
|
|
313
|
+
queryKey: U,
|
|
314
314
|
queryFn: ({ signal: t }) => e({ signal: t }),
|
|
315
315
|
staleTime: 6e4
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
|
-
async function
|
|
319
|
-
await _.invalidateQueries({ queryKey:
|
|
318
|
+
async function _e() {
|
|
319
|
+
await _.invalidateQueries({ queryKey: U });
|
|
320
320
|
}
|
|
321
321
|
//#endregion
|
|
322
322
|
//#region src/hooks/useLiveState.ts
|
|
323
|
-
function
|
|
324
|
-
let { fetcher: e, mockData: t, refetchInterval: n, log: r } = p(), i = t !== void 0, { data: a, error: o, isLoading: s, refetch: c } =
|
|
325
|
-
queryKey:
|
|
323
|
+
function ve() {
|
|
324
|
+
let { fetcher: e, mockData: t, refetchInterval: n, log: r } = p(), i = t !== void 0, { data: a, error: o, isLoading: s, refetch: c } = he({
|
|
325
|
+
queryKey: U,
|
|
326
326
|
queryFn: ({ signal: t }) => e({ signal: t }),
|
|
327
327
|
enabled: !i,
|
|
328
328
|
staleTime: 6e4,
|
|
@@ -357,7 +357,7 @@ function _e() {
|
|
|
357
357
|
}
|
|
358
358
|
//#endregion
|
|
359
359
|
//#region src/hooks/useTrackEvent.ts
|
|
360
|
-
function
|
|
360
|
+
function W() {
|
|
361
361
|
let { onEvent: e, disabled: t, log: n } = p();
|
|
362
362
|
return w((r, a) => {
|
|
363
363
|
e?.(r, a), t || i(r, a, n);
|
|
@@ -369,10 +369,10 @@ function G() {
|
|
|
369
369
|
}
|
|
370
370
|
//#endregion
|
|
371
371
|
//#region src/utils/closable-storage.ts
|
|
372
|
-
var
|
|
373
|
-
function
|
|
372
|
+
var G = "@tiendanube/live-state:closable", K = G;
|
|
373
|
+
function q() {
|
|
374
374
|
try {
|
|
375
|
-
let e = localStorage.getItem(
|
|
375
|
+
let e = localStorage.getItem(K);
|
|
376
376
|
if (!e) return {};
|
|
377
377
|
let t = JSON.parse(e);
|
|
378
378
|
if (typeof t != "object" || !t) return {};
|
|
@@ -396,21 +396,21 @@ function J() {
|
|
|
396
396
|
return {};
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function J(e) {
|
|
400
400
|
try {
|
|
401
|
-
localStorage.setItem(
|
|
401
|
+
localStorage.setItem(K, JSON.stringify(e));
|
|
402
402
|
} catch {}
|
|
403
403
|
}
|
|
404
404
|
//#endregion
|
|
405
405
|
//#region src/hooks/useClosable.ts
|
|
406
|
-
function
|
|
406
|
+
function ye({ context: e, id: t, maxCloseTimes: n = 3, expiresIn: r }) {
|
|
407
407
|
let [i, a] = E(null);
|
|
408
408
|
return T(() => {
|
|
409
409
|
if (!t) {
|
|
410
410
|
a(!0);
|
|
411
411
|
return;
|
|
412
412
|
}
|
|
413
|
-
let i =
|
|
413
|
+
let i = q(), o = i[e]?.[t];
|
|
414
414
|
if (!o) {
|
|
415
415
|
a(!0);
|
|
416
416
|
return;
|
|
@@ -418,7 +418,7 @@ function ve({ context: e, id: t, maxCloseTimes: n = 3, expiresIn: r }) {
|
|
|
418
418
|
let { count: s, closedAt: c } = o;
|
|
419
419
|
if (r != null && c > 0 && Date.now() - c > r) {
|
|
420
420
|
let n = { ...i };
|
|
421
|
-
n[e] && (delete n[e][t],
|
|
421
|
+
n[e] && (delete n[e][t], J(n)), a(!0);
|
|
422
422
|
return;
|
|
423
423
|
}
|
|
424
424
|
a(s < n);
|
|
@@ -431,8 +431,8 @@ function ve({ context: e, id: t, maxCloseTimes: n = 3, expiresIn: r }) {
|
|
|
431
431
|
isVisible: i,
|
|
432
432
|
close: w(() => {
|
|
433
433
|
if (a(!1), !t) return;
|
|
434
|
-
let n =
|
|
435
|
-
|
|
434
|
+
let n = q(), r = n[e]?.[t]?.count ?? 0;
|
|
435
|
+
J({
|
|
436
436
|
...n,
|
|
437
437
|
[e]: {
|
|
438
438
|
...n[e] ?? {},
|
|
@@ -447,7 +447,7 @@ function ve({ context: e, id: t, maxCloseTimes: n = 3, expiresIn: r }) {
|
|
|
447
447
|
}
|
|
448
448
|
//#endregion
|
|
449
449
|
//#region src/utils/cta.ts
|
|
450
|
-
function
|
|
450
|
+
function Y(e, t) {
|
|
451
451
|
let n = m(t);
|
|
452
452
|
try {
|
|
453
453
|
switch (e.type) {
|
|
@@ -473,25 +473,25 @@ function X(e, t) {
|
|
|
473
473
|
}
|
|
474
474
|
//#endregion
|
|
475
475
|
//#region src/utils/sanitize.ts
|
|
476
|
-
var
|
|
476
|
+
var be = new Set([
|
|
477
477
|
"strong",
|
|
478
478
|
"em",
|
|
479
479
|
"b",
|
|
480
480
|
"i",
|
|
481
481
|
"br",
|
|
482
482
|
"span"
|
|
483
|
-
]),
|
|
484
|
-
function xe(e) {
|
|
485
|
-
return e.replace(be, "").replace(/<([a-zA-Z][a-zA-Z0-9]*)\s[^>]*>/g, "<$1>").replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)[^>]*>/g, (e, t) => ye.has(t.toLowerCase()) ? e : "");
|
|
486
|
-
}
|
|
483
|
+
]), xe = /<(script|style|iframe|object|embed|form|input|button|textarea|select|link|meta|head|body|html|svg|math)[\s\S]*?<\/\1\s*>|<(script|style|iframe|object|embed|form|input|button|textarea|select|link|meta|head|body|html|svg|math)[^>]*\/?>/gi;
|
|
487
484
|
function Se(e) {
|
|
485
|
+
return e.replace(xe, "").replace(/<([a-zA-Z][a-zA-Z0-9]*)\s[^>]*>/g, "<$1>").replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)[^>]*>/g, (e, t) => be.has(t.toLowerCase()) ? e : "");
|
|
486
|
+
}
|
|
487
|
+
function Ce(e) {
|
|
488
488
|
return /<[a-zA-Z][^>]*>/.test(e);
|
|
489
489
|
}
|
|
490
490
|
//#endregion
|
|
491
491
|
//#region src/components/RichText.tsx
|
|
492
|
-
function
|
|
493
|
-
if (
|
|
494
|
-
let n =
|
|
492
|
+
function X({ content: e, ...t }) {
|
|
493
|
+
if (Ce(e)) {
|
|
494
|
+
let n = Se(e);
|
|
495
495
|
return /* @__PURE__ */ D(A, {
|
|
496
496
|
...t,
|
|
497
497
|
children: /* @__PURE__ */ D("span", { dangerouslySetInnerHTML: { __html: n } })
|
|
@@ -503,16 +503,21 @@ function Z({ content: e, ...t }) {
|
|
|
503
503
|
});
|
|
504
504
|
}
|
|
505
505
|
//#endregion
|
|
506
|
-
//#region src/components/
|
|
507
|
-
|
|
508
|
-
|
|
506
|
+
//#region src/components/LiveStateMessage.tsx
|
|
507
|
+
var we = {
|
|
508
|
+
alert: "danger",
|
|
509
|
+
warning: "warning",
|
|
510
|
+
info: "primary"
|
|
511
|
+
};
|
|
512
|
+
function Z({ data: e, trackingConfig: t, onClose: n, onCtaClick: r }) {
|
|
513
|
+
let i = W(), { log: a } = p(), o = we[e.type] ?? "danger", s = w(() => u({
|
|
509
514
|
context: e.context,
|
|
510
515
|
campaignId: e.campaignId,
|
|
511
516
|
group: e.group,
|
|
512
517
|
...e.metadata,
|
|
513
518
|
...t.properties
|
|
514
519
|
}), [e, t.properties]), c = w(() => {
|
|
515
|
-
i(g(t.prefix, t.page, e.context, "click"), s()), r ? r(e.cta) :
|
|
520
|
+
i(g(t.prefix, t.page, e.context, "click"), s()), r ? r(e.cta) : Y(e.cta, a);
|
|
516
521
|
}, [
|
|
517
522
|
e,
|
|
518
523
|
t,
|
|
@@ -534,6 +539,7 @@ function Q({ data: e, trackingConfig: t, onClose: n, onCtaClick: r }) {
|
|
|
534
539
|
}, []), /* @__PURE__ */ D(ee, {
|
|
535
540
|
appearance: o,
|
|
536
541
|
title: e.title,
|
|
542
|
+
"data-testid": "live-state-message",
|
|
537
543
|
onRemove: n ? l : void 0,
|
|
538
544
|
children: /* @__PURE__ */ O(k, {
|
|
539
545
|
display: "flex",
|
|
@@ -544,7 +550,7 @@ function Q({ data: e, trackingConfig: t, onClose: n, onCtaClick: r }) {
|
|
|
544
550
|
children: [/* @__PURE__ */ D(k, {
|
|
545
551
|
flex: "1 1 auto",
|
|
546
552
|
minWidth: "220px",
|
|
547
|
-
children: /* @__PURE__ */ D(
|
|
553
|
+
children: /* @__PURE__ */ D(X, { content: e.message })
|
|
548
554
|
}), /* @__PURE__ */ D(k, {
|
|
549
555
|
display: "flex",
|
|
550
556
|
justifyContent: "flex-end",
|
|
@@ -552,6 +558,7 @@ function Q({ data: e, trackingConfig: t, onClose: n, onCtaClick: r }) {
|
|
|
552
558
|
children: /* @__PURE__ */ D(te, {
|
|
553
559
|
appearance: "primary",
|
|
554
560
|
onClick: c,
|
|
561
|
+
"data-testid": "live-state-message-cta-button",
|
|
555
562
|
children: e.cta.label
|
|
556
563
|
})
|
|
557
564
|
})]
|
|
@@ -559,8 +566,8 @@ function Q({ data: e, trackingConfig: t, onClose: n, onCtaClick: r }) {
|
|
|
559
566
|
});
|
|
560
567
|
}
|
|
561
568
|
//#endregion
|
|
562
|
-
//#region src/components/
|
|
563
|
-
var
|
|
569
|
+
//#region src/components/LiveStatePromo.tsx
|
|
570
|
+
var Q = {
|
|
564
571
|
blue: {
|
|
565
572
|
background: "#0050C3",
|
|
566
573
|
icon: "#FFFFFF"
|
|
@@ -571,7 +578,7 @@ var Ce = {
|
|
|
571
578
|
}
|
|
572
579
|
};
|
|
573
580
|
function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r, isMobile: i, onCtaClick: a }) {
|
|
574
|
-
let o =
|
|
581
|
+
let o = W(), { log: s } = p(), c = e.variant || n, l = Q[c], [d, f] = E(() => window.innerWidth < 750);
|
|
575
582
|
T(() => {
|
|
576
583
|
let e = () => f(window.innerWidth < 750);
|
|
577
584
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
@@ -583,7 +590,7 @@ function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r,
|
|
|
583
590
|
...e.metadata,
|
|
584
591
|
...t.properties
|
|
585
592
|
}), [e, t.properties]), _ = w(() => {
|
|
586
|
-
o(g(t.prefix, t.page, e.context, "click"), h()), a ? a(e.cta) :
|
|
593
|
+
o(g(t.prefix, t.page, e.context, "click"), h()), a ? a(e.cta) : Y(e.cta, s);
|
|
587
594
|
}, [
|
|
588
595
|
e,
|
|
589
596
|
t,
|
|
@@ -607,7 +614,7 @@ function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r,
|
|
|
607
614
|
as: "a",
|
|
608
615
|
textDecoration: "none",
|
|
609
616
|
onClick: _,
|
|
610
|
-
"data-testid": "live-state-cta-link",
|
|
617
|
+
"data-testid": "live-state-promo-cta-link",
|
|
611
618
|
children: /* @__PURE__ */ D(A, {
|
|
612
619
|
color: "primary-interactive",
|
|
613
620
|
fontSize: "base",
|
|
@@ -618,6 +625,7 @@ function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r,
|
|
|
618
625
|
display: "flex",
|
|
619
626
|
flexDirection: "row",
|
|
620
627
|
justifyContent: "space-between",
|
|
628
|
+
"data-testid": "live-state-promo",
|
|
621
629
|
children: [/* @__PURE__ */ O(k, {
|
|
622
630
|
display: "flex",
|
|
623
631
|
gap: "4",
|
|
@@ -643,11 +651,11 @@ function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r,
|
|
|
643
651
|
}), /* @__PURE__ */ O(k, {
|
|
644
652
|
display: "grid",
|
|
645
653
|
gap: "2",
|
|
646
|
-
children: [/* @__PURE__ */ O(k, { children: [/* @__PURE__ */ D(
|
|
654
|
+
children: [/* @__PURE__ */ O(k, { children: [/* @__PURE__ */ D(X, {
|
|
647
655
|
content: e.title,
|
|
648
656
|
fontSize: "base",
|
|
649
657
|
color: "neutral-textHigh"
|
|
650
|
-
}), /* @__PURE__ */ D(
|
|
658
|
+
}), /* @__PURE__ */ D(X, {
|
|
651
659
|
content: e.message,
|
|
652
660
|
fontSize: "base",
|
|
653
661
|
color: "neutral-textLow"
|
|
@@ -685,32 +693,35 @@ function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r,
|
|
|
685
693
|
}
|
|
686
694
|
//#endregion
|
|
687
695
|
//#region src/components/LiveStateRenderer.tsx
|
|
688
|
-
function
|
|
689
|
-
let { log: s, onNavigate: c } = p(), l = o ?? c, { isVisible: u, close: d } =
|
|
696
|
+
function Te({ data: e, loading: t, trackingConfig: n, allowedContexts: r, defaultVariant: i, isMobile: a, onCtaClick: o }) {
|
|
697
|
+
let { log: s, onNavigate: c } = p(), l = o ?? c, { isVisible: u, close: d } = ye({
|
|
690
698
|
context: e?.context ?? "",
|
|
691
699
|
id: e?.campaignId,
|
|
692
700
|
maxCloseTimes: e?.metadata?.maxCloseTimes,
|
|
693
701
|
expiresIn: e?.metadata?.expiresIn
|
|
694
702
|
});
|
|
695
703
|
if (t || !e) return null;
|
|
696
|
-
if (!e.context || !e.type || !e.title || !e.message || !e.cta?.label || !e.cta?.url || !e.cta?.type) return s("warn", "Invalid payload, missing required fields", { data: e }), null;
|
|
704
|
+
if (!e.context || !e.model || !e.type || !e.title || !e.message || !e.cta?.label || !e.cta?.url || !e.cta?.type) return s("warn", "Invalid payload, missing required fields", { data: e }), null;
|
|
697
705
|
if (r && !r.includes(e.context) || u === null || !u) return null;
|
|
698
706
|
let f = e.closable ? d : void 0;
|
|
699
|
-
return
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
707
|
+
return {
|
|
708
|
+
message: /* @__PURE__ */ D(Z, {
|
|
709
|
+
data: e,
|
|
710
|
+
onClose: f,
|
|
711
|
+
trackingConfig: n,
|
|
712
|
+
onCtaClick: l
|
|
713
|
+
}),
|
|
714
|
+
promo: /* @__PURE__ */ D($, {
|
|
715
|
+
data: e,
|
|
716
|
+
onClose: f,
|
|
717
|
+
trackingConfig: n,
|
|
718
|
+
defaultVariant: i,
|
|
719
|
+
isMobile: a,
|
|
720
|
+
onCtaClick: l
|
|
721
|
+
})
|
|
722
|
+
}[e.model];
|
|
712
723
|
}
|
|
713
724
|
//#endregion
|
|
714
|
-
export {
|
|
725
|
+
export { G as LIVE_STATE_STORAGE_KEY, Z as LiveStateMessage, $ as LiveStatePromo, v as LiveStateProvider, Te as LiveStateRenderer, Y as handleCtaClick, _e as invalidateLiveState, ge as prefetchLiveState, i as trackEvent, ve as useLiveState, W as useTrackEvent };
|
|
715
726
|
|
|
716
727
|
//# sourceMappingURL=index.js.map
|