@tiendanube/live-state 1.0.1 → 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/{LiveStateProvider-BEiLZeen.js → LiveStateProvider--BHGXDwQ.js} +10 -10
- package/dist/{LiveStateProvider-BEiLZeen.js.map → LiveStateProvider--BHGXDwQ.js.map} +1 -1
- package/dist/{LiveStateProvider-B_uOhVFY.cjs → LiveStateProvider-B0jRdNna.cjs} +2 -2
- package/dist/{LiveStateProvider-B_uOhVFY.cjs.map → LiveStateProvider-B0jRdNna.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +96 -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/components/RichText.d.ts.map +1 -1
- package/dist/src/hooks/useLiveState.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/providers/LiveStateProvider.d.ts +1 -1
- package/dist/src/providers/LiveStateProvider.d.ts.map +1 -1
- package/dist/src/query-client.d.ts +9 -8
- package/dist/src/query-client.d.ts.map +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +6 -24
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/utils/query.d.ts +19 -15
- package/dist/src/utils/query.d.ts.map +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +2 -1
- package/dist/testing.js.map +1 -1
- package/package.json +7 -5
- 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
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as e, S as t, T as n, _ as r, a as i, b as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, v as y, w as b, x, y as S } from "./LiveStateProvider
|
|
1
|
+
import { C as e, S as t, T as n, _ as r, a as i, b as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, v as y, w as b, x, y as S } from "./LiveStateProvider--BHGXDwQ.js";
|
|
2
2
|
import * as C from "react";
|
|
3
3
|
import { useCallback as w, useEffect as T, useState as E } from "react";
|
|
4
4
|
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,24 +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
|
|
312
|
-
await
|
|
313
|
-
queryKey:
|
|
310
|
+
var U = ["live-state"];
|
|
311
|
+
async function ge(e) {
|
|
312
|
+
await _.prefetchQuery({
|
|
313
|
+
queryKey: U,
|
|
314
314
|
queryFn: ({ signal: t }) => e({ signal: t }),
|
|
315
315
|
staleTime: 6e4
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
|
+
async function _e() {
|
|
319
|
+
await _.invalidateQueries({ queryKey: U });
|
|
320
|
+
}
|
|
318
321
|
//#endregion
|
|
319
322
|
//#region src/hooks/useLiveState.ts
|
|
320
|
-
function
|
|
321
|
-
let { fetcher: e, mockData: t, refetchInterval: n, log: r } = p(), i = t !== void 0, { data: a, error: o, isLoading: s, refetch: c } =
|
|
322
|
-
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,
|
|
323
326
|
queryFn: ({ signal: t }) => e({ signal: t }),
|
|
324
327
|
enabled: !i,
|
|
325
328
|
staleTime: 6e4,
|
|
@@ -354,7 +357,7 @@ function ge() {
|
|
|
354
357
|
}
|
|
355
358
|
//#endregion
|
|
356
359
|
//#region src/hooks/useTrackEvent.ts
|
|
357
|
-
function
|
|
360
|
+
function W() {
|
|
358
361
|
let { onEvent: e, disabled: t, log: n } = p();
|
|
359
362
|
return w((r, a) => {
|
|
360
363
|
e?.(r, a), t || i(r, a, n);
|
|
@@ -366,10 +369,10 @@ function G() {
|
|
|
366
369
|
}
|
|
367
370
|
//#endregion
|
|
368
371
|
//#region src/utils/closable-storage.ts
|
|
369
|
-
var
|
|
370
|
-
function
|
|
372
|
+
var G = "@tiendanube/live-state:closable", K = G;
|
|
373
|
+
function q() {
|
|
371
374
|
try {
|
|
372
|
-
let e = localStorage.getItem(
|
|
375
|
+
let e = localStorage.getItem(K);
|
|
373
376
|
if (!e) return {};
|
|
374
377
|
let t = JSON.parse(e);
|
|
375
378
|
if (typeof t != "object" || !t) return {};
|
|
@@ -393,21 +396,21 @@ function J() {
|
|
|
393
396
|
return {};
|
|
394
397
|
}
|
|
395
398
|
}
|
|
396
|
-
function
|
|
399
|
+
function J(e) {
|
|
397
400
|
try {
|
|
398
|
-
localStorage.setItem(
|
|
401
|
+
localStorage.setItem(K, JSON.stringify(e));
|
|
399
402
|
} catch {}
|
|
400
403
|
}
|
|
401
404
|
//#endregion
|
|
402
405
|
//#region src/hooks/useClosable.ts
|
|
403
|
-
function
|
|
406
|
+
function ye({ context: e, id: t, maxCloseTimes: n = 3, expiresIn: r }) {
|
|
404
407
|
let [i, a] = E(null);
|
|
405
408
|
return T(() => {
|
|
406
409
|
if (!t) {
|
|
407
410
|
a(!0);
|
|
408
411
|
return;
|
|
409
412
|
}
|
|
410
|
-
let i =
|
|
413
|
+
let i = q(), o = i[e]?.[t];
|
|
411
414
|
if (!o) {
|
|
412
415
|
a(!0);
|
|
413
416
|
return;
|
|
@@ -415,7 +418,7 @@ function _e({ context: e, id: t, maxCloseTimes: n = 3, expiresIn: r }) {
|
|
|
415
418
|
let { count: s, closedAt: c } = o;
|
|
416
419
|
if (r != null && c > 0 && Date.now() - c > r) {
|
|
417
420
|
let n = { ...i };
|
|
418
|
-
n[e] && (delete n[e][t],
|
|
421
|
+
n[e] && (delete n[e][t], J(n)), a(!0);
|
|
419
422
|
return;
|
|
420
423
|
}
|
|
421
424
|
a(s < n);
|
|
@@ -428,8 +431,8 @@ function _e({ context: e, id: t, maxCloseTimes: n = 3, expiresIn: r }) {
|
|
|
428
431
|
isVisible: i,
|
|
429
432
|
close: w(() => {
|
|
430
433
|
if (a(!1), !t) return;
|
|
431
|
-
let n =
|
|
432
|
-
|
|
434
|
+
let n = q(), r = n[e]?.[t]?.count ?? 0;
|
|
435
|
+
J({
|
|
433
436
|
...n,
|
|
434
437
|
[e]: {
|
|
435
438
|
...n[e] ?? {},
|
|
@@ -444,7 +447,7 @@ function _e({ context: e, id: t, maxCloseTimes: n = 3, expiresIn: r }) {
|
|
|
444
447
|
}
|
|
445
448
|
//#endregion
|
|
446
449
|
//#region src/utils/cta.ts
|
|
447
|
-
function
|
|
450
|
+
function Y(e, t) {
|
|
448
451
|
let n = m(t);
|
|
449
452
|
try {
|
|
450
453
|
switch (e.type) {
|
|
@@ -470,25 +473,25 @@ function X(e, t) {
|
|
|
470
473
|
}
|
|
471
474
|
//#endregion
|
|
472
475
|
//#region src/utils/sanitize.ts
|
|
473
|
-
var
|
|
476
|
+
var be = new Set([
|
|
474
477
|
"strong",
|
|
475
478
|
"em",
|
|
476
479
|
"b",
|
|
477
480
|
"i",
|
|
478
481
|
"br",
|
|
479
482
|
"span"
|
|
480
|
-
]),
|
|
481
|
-
function
|
|
482
|
-
return e.replace(
|
|
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;
|
|
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 : "");
|
|
483
486
|
}
|
|
484
|
-
function
|
|
487
|
+
function Ce(e) {
|
|
485
488
|
return /<[a-zA-Z][^>]*>/.test(e);
|
|
486
489
|
}
|
|
487
490
|
//#endregion
|
|
488
491
|
//#region src/components/RichText.tsx
|
|
489
|
-
function
|
|
490
|
-
if (
|
|
491
|
-
let n =
|
|
492
|
+
function X({ content: e, ...t }) {
|
|
493
|
+
if (Ce(e)) {
|
|
494
|
+
let n = Se(e);
|
|
492
495
|
return /* @__PURE__ */ D(A, {
|
|
493
496
|
...t,
|
|
494
497
|
children: /* @__PURE__ */ D("span", { dangerouslySetInnerHTML: { __html: n } })
|
|
@@ -500,16 +503,21 @@ function Z({ content: e, ...t }) {
|
|
|
500
503
|
});
|
|
501
504
|
}
|
|
502
505
|
//#endregion
|
|
503
|
-
//#region src/components/
|
|
504
|
-
|
|
505
|
-
|
|
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({
|
|
506
514
|
context: e.context,
|
|
507
515
|
campaignId: e.campaignId,
|
|
508
516
|
group: e.group,
|
|
509
517
|
...e.metadata,
|
|
510
518
|
...t.properties
|
|
511
519
|
}), [e, t.properties]), c = w(() => {
|
|
512
|
-
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);
|
|
513
521
|
}, [
|
|
514
522
|
e,
|
|
515
523
|
t,
|
|
@@ -531,6 +539,7 @@ function Q({ data: e, trackingConfig: t, onClose: n, onCtaClick: r }) {
|
|
|
531
539
|
}, []), /* @__PURE__ */ D(ee, {
|
|
532
540
|
appearance: o,
|
|
533
541
|
title: e.title,
|
|
542
|
+
"data-testid": "live-state-message",
|
|
534
543
|
onRemove: n ? l : void 0,
|
|
535
544
|
children: /* @__PURE__ */ O(k, {
|
|
536
545
|
display: "flex",
|
|
@@ -541,7 +550,7 @@ function Q({ data: e, trackingConfig: t, onClose: n, onCtaClick: r }) {
|
|
|
541
550
|
children: [/* @__PURE__ */ D(k, {
|
|
542
551
|
flex: "1 1 auto",
|
|
543
552
|
minWidth: "220px",
|
|
544
|
-
children: /* @__PURE__ */ D(
|
|
553
|
+
children: /* @__PURE__ */ D(X, { content: e.message })
|
|
545
554
|
}), /* @__PURE__ */ D(k, {
|
|
546
555
|
display: "flex",
|
|
547
556
|
justifyContent: "flex-end",
|
|
@@ -549,6 +558,7 @@ function Q({ data: e, trackingConfig: t, onClose: n, onCtaClick: r }) {
|
|
|
549
558
|
children: /* @__PURE__ */ D(te, {
|
|
550
559
|
appearance: "primary",
|
|
551
560
|
onClick: c,
|
|
561
|
+
"data-testid": "live-state-message-cta-button",
|
|
552
562
|
children: e.cta.label
|
|
553
563
|
})
|
|
554
564
|
})]
|
|
@@ -556,8 +566,8 @@ function Q({ data: e, trackingConfig: t, onClose: n, onCtaClick: r }) {
|
|
|
556
566
|
});
|
|
557
567
|
}
|
|
558
568
|
//#endregion
|
|
559
|
-
//#region src/components/
|
|
560
|
-
var
|
|
569
|
+
//#region src/components/LiveStatePromo.tsx
|
|
570
|
+
var Q = {
|
|
561
571
|
blue: {
|
|
562
572
|
background: "#0050C3",
|
|
563
573
|
icon: "#FFFFFF"
|
|
@@ -568,7 +578,7 @@ var Se = {
|
|
|
568
578
|
}
|
|
569
579
|
};
|
|
570
580
|
function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r, isMobile: i, onCtaClick: a }) {
|
|
571
|
-
let o =
|
|
581
|
+
let o = W(), { log: s } = p(), c = e.variant || n, l = Q[c], [d, f] = E(() => window.innerWidth < 750);
|
|
572
582
|
T(() => {
|
|
573
583
|
let e = () => f(window.innerWidth < 750);
|
|
574
584
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
@@ -580,7 +590,7 @@ function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r,
|
|
|
580
590
|
...e.metadata,
|
|
581
591
|
...t.properties
|
|
582
592
|
}), [e, t.properties]), _ = w(() => {
|
|
583
|
-
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);
|
|
584
594
|
}, [
|
|
585
595
|
e,
|
|
586
596
|
t,
|
|
@@ -604,7 +614,7 @@ function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r,
|
|
|
604
614
|
as: "a",
|
|
605
615
|
textDecoration: "none",
|
|
606
616
|
onClick: _,
|
|
607
|
-
"data-testid": "live-state-cta-link",
|
|
617
|
+
"data-testid": "live-state-promo-cta-link",
|
|
608
618
|
children: /* @__PURE__ */ D(A, {
|
|
609
619
|
color: "primary-interactive",
|
|
610
620
|
fontSize: "base",
|
|
@@ -615,6 +625,7 @@ function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r,
|
|
|
615
625
|
display: "flex",
|
|
616
626
|
flexDirection: "row",
|
|
617
627
|
justifyContent: "space-between",
|
|
628
|
+
"data-testid": "live-state-promo",
|
|
618
629
|
children: [/* @__PURE__ */ O(k, {
|
|
619
630
|
display: "flex",
|
|
620
631
|
gap: "4",
|
|
@@ -640,11 +651,11 @@ function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r,
|
|
|
640
651
|
}), /* @__PURE__ */ O(k, {
|
|
641
652
|
display: "grid",
|
|
642
653
|
gap: "2",
|
|
643
|
-
children: [/* @__PURE__ */ O(k, { children: [/* @__PURE__ */ D(
|
|
654
|
+
children: [/* @__PURE__ */ O(k, { children: [/* @__PURE__ */ D(X, {
|
|
644
655
|
content: e.title,
|
|
645
656
|
fontSize: "base",
|
|
646
657
|
color: "neutral-textHigh"
|
|
647
|
-
}), /* @__PURE__ */ D(
|
|
658
|
+
}), /* @__PURE__ */ D(X, {
|
|
648
659
|
content: e.message,
|
|
649
660
|
fontSize: "base",
|
|
650
661
|
color: "neutral-textLow"
|
|
@@ -682,32 +693,35 @@ function $({ data: e, trackingConfig: t, defaultVariant: n = "blue", onClose: r,
|
|
|
682
693
|
}
|
|
683
694
|
//#endregion
|
|
684
695
|
//#region src/components/LiveStateRenderer.tsx
|
|
685
|
-
function
|
|
686
|
-
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({
|
|
687
698
|
context: e?.context ?? "",
|
|
688
699
|
id: e?.campaignId,
|
|
689
700
|
maxCloseTimes: e?.metadata?.maxCloseTimes,
|
|
690
701
|
expiresIn: e?.metadata?.expiresIn
|
|
691
702
|
});
|
|
692
703
|
if (t || !e) return null;
|
|
693
|
-
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;
|
|
694
705
|
if (r && !r.includes(e.context) || u === null || !u) return null;
|
|
695
706
|
let f = e.closable ? d : void 0;
|
|
696
|
-
return
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
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];
|
|
709
723
|
}
|
|
710
724
|
//#endregion
|
|
711
|
-
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 };
|
|
712
726
|
|
|
713
727
|
//# sourceMappingURL=index.js.map
|