@frak-labs/components 1.3.4 → 1.5.0-beta.04afaf6b
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/cdn/Ambassador.Cmb0kX5D.js +519 -0
- package/cdn/Banner.2WJ4pT6E.js +227 -0
- package/cdn/ButtonShare.DSGvJfJ-.js +1 -0
- package/cdn/{ButtonWallet.CIesaq0l.js → ButtonWallet.DHpHCl4c.js} +2 -2
- package/cdn/GiftIcon.DYg5xgHg.js +1 -0
- package/cdn/InstallQr.CHImaq56.js +1 -0
- package/cdn/{OpenInAppButton.BtXknsxK.js → OpenInAppButton.CxBzRNKw.js} +1 -1
- package/cdn/PostPurchase.C75q-9BM.js +124 -0
- package/cdn/RewardReminder.C6o8lgak.js +369 -0
- package/cdn/components.js +1 -1
- package/cdn/format.D2Ai5cCn.js +1 -0
- package/cdn/{GiftIcon.CX0gLPUJ.js → icons.CdzHzZIJ.js} +1 -1
- package/cdn/jsxRuntime.module.7FJBZ9bf.js +58 -0
- package/cdn/loader.js +20 -16
- package/cdn/mountRewardReminder.BlmSRJDe.js +1 -0
- package/cdn/previewSummary.DxyobqED.js +1 -0
- package/cdn/replay-V6FXES7X.CgBxdfNp.js +1 -0
- package/cdn/rewardSummaryStore.DyjI-vPH.js +1 -0
- package/cdn/{rewards.F9iOJSNk.js → rewards.CeNLrK54.js} +1 -1
- package/cdn/useGlobalComponents.CNnOzerU.js +1 -0
- package/cdn/{useLightDomStyles.CpiH8nO2.js → useLightDomStyles.557xWurb.js} +1 -1
- package/cdn/usePlacement.DYgmdkfr.js +1 -0
- package/cdn/{useReward.B9ibElG0.js → useReward.BzUL3ijd.js} +1 -1
- package/dist/GiftIcon-Csu31jtf.js +62 -0
- package/dist/InstallQr-kpb44cfg.js +84 -0
- package/dist/ambassador.d.ts +16 -1
- package/dist/ambassador.js +626 -191
- package/dist/banner.d.ts +20 -6
- package/dist/banner.js +237 -15
- package/dist/buttonShare.js +2 -2
- package/dist/buttonWallet.js +1 -1
- package/dist/format-zGdbUoX_.js +283 -0
- package/dist/i18n/defaults.d.ts +72 -0
- package/dist/i18n/defaults.js +108 -6
- package/dist/{GiftIcon-B9k_syq6.js → icons-iN3qH_Bv.js} +1 -61
- package/dist/postPurchase.d.ts +6 -1
- package/dist/postPurchase.js +188 -34
- package/dist/previewSummary-CMc6q8vI.js +37 -0
- package/dist/rewardReminder.d.ts +50 -0
- package/dist/rewardReminder.js +809 -0
- package/dist/{rewards-CfGynCt6.js → rewards-BuNthAR2.js} +49 -46
- package/dist/{sharedBaseCss.css-nYy9vlzH.js → sharedBaseCss.css-D2HG4Ty8.js} +1 -1
- package/dist/{useReward-DmukZKoh.js → useReward-cQ54x8q-.js} +1 -1
- package/package.json +18 -12
- package/cdn/Ambassador.tWpfYThv.js +0 -392
- package/cdn/Banner.RSZt2Kn_.js +0 -208
- package/cdn/ButtonShare.Buy6qEfW.js +0 -1
- package/cdn/PostPurchase.Btgp2kLc.js +0 -102
- package/cdn/jsxRuntime.module.CUZaa90V.js +0 -58
- package/cdn/replay-V6FXES7X.efKsNT6s.js +0 -1
- package/cdn/useGlobalComponents.CXuceSQ0.js +0 -1
- package/cdn/usePlacement.Cq64cZ9Q.js +0 -1
package/dist/banner.d.ts
CHANGED
|
@@ -49,6 +49,18 @@ type BannerProps = {
|
|
|
49
49
|
* Override the in-app browser banner CTA button text.
|
|
50
50
|
*/
|
|
51
51
|
inappCta?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Override the pending banner title. Supports `{REWARD}`, `{DAYS}`, `{DATE}`.
|
|
54
|
+
*/
|
|
55
|
+
pendingTitle?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Override the pending banner description. Supports the same placeholders.
|
|
58
|
+
*/
|
|
59
|
+
pendingDescription?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Override the pending banner CTA text. Supports the same placeholders.
|
|
62
|
+
*/
|
|
63
|
+
pendingCta?: string;
|
|
52
64
|
/**
|
|
53
65
|
* Override the image displayed on the left of the referral banner.
|
|
54
66
|
* Accepts an image URL. Falls back to the built-in gift icon when omitted.
|
|
@@ -62,10 +74,10 @@ type BannerProps = {
|
|
|
62
74
|
*/
|
|
63
75
|
preview?: string;
|
|
64
76
|
/**
|
|
65
|
-
* Which banner variant to preview: "referral" or "
|
|
77
|
+
* Which banner variant to preview: "referral", "inapp" or "pending".
|
|
66
78
|
* Only used when {@link preview} is set. Defaults to "referral".
|
|
67
79
|
*/
|
|
68
|
-
previewMode?: "referral" | "inapp";
|
|
80
|
+
previewMode?: "referral" | "inapp" | "pending";
|
|
69
81
|
/**
|
|
70
82
|
* When `true` (default `false`), the banner is allowed to switch to
|
|
71
83
|
* in-app browser mode (Instagram / Facebook WebView) and prompt the
|
|
@@ -85,8 +97,7 @@ type BannerProps = {
|
|
|
85
97
|
/**
|
|
86
98
|
* Auto-detecting notification banner component.
|
|
87
99
|
*
|
|
88
|
-
* Renders an inline banner on the merchant page with one of
|
|
89
|
-
* visual styles depending on the detected mode:
|
|
100
|
+
* Renders an inline banner on the merchant page with one of three modes:
|
|
90
101
|
*
|
|
91
102
|
* - **Referral mode** (white): Shown after a successful referral link
|
|
92
103
|
* processing. Displays a gift icon, reward copy, and a "Got it" CTA.
|
|
@@ -95,7 +106,10 @@ type BannerProps = {
|
|
|
95
106
|
* Offers an inline link to redirect to the default browser plus a
|
|
96
107
|
* close button to dismiss.
|
|
97
108
|
*
|
|
98
|
-
*
|
|
109
|
+
* - **Pending mode** (white): Shown to a visitor with unclaimed rewards and no
|
|
110
|
+
* Frak wallet yet; see {@link PendingBanner}.
|
|
111
|
+
*
|
|
112
|
+
* Priority: in-app browser, then referral, then pending.
|
|
99
113
|
* Uses Light DOM + vanilla-extract styles from `@frak-labs/design-system`.
|
|
100
114
|
*
|
|
101
115
|
* @group components
|
|
@@ -112,7 +126,7 @@ type BannerProps = {
|
|
|
112
126
|
* <frak-banner classname="my-custom-banner"></frak-banner>
|
|
113
127
|
* ```
|
|
114
128
|
*/
|
|
115
|
-
export declare function Banner({ placement: placementId, classname, interaction, products, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, imageUrl: propImageUrl, preview, previewMode, allowInappRedirect }: BannerProps): import("preact").JSX.Element | null;
|
|
129
|
+
export declare function Banner({ placement: placementId, classname, interaction, products, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, pendingTitle, pendingDescription, pendingCta, imageUrl: propImageUrl, preview, previewMode, allowInappRedirect }: BannerProps): import("preact").JSX.Element | null;
|
|
116
130
|
/**
|
|
117
131
|
* Custom element interface for `<frak-banner>`.
|
|
118
132
|
* Combines standard {@link HTMLElement} with {@link BannerProps}.
|
package/dist/banner.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { a as useClientReady, o as registerWebComponent, r as useLang } from "./sharedCss-SKmJGZgN.js";
|
|
2
|
-
import { i as w } from "./rewards-
|
|
3
|
-
import {
|
|
2
|
+
import { i as w } from "./rewards-BuNthAR2.js";
|
|
3
|
+
import { i as CloseCircleIcon, n as LogoFrakWithName, r as ExternalLinkIcon, t as WarningIcon } from "./icons-iN3qH_Bv.js";
|
|
4
4
|
import { t as useGlobalComponents } from "./useGlobalComponents-BF47jsBt.js";
|
|
5
5
|
import { t as useLightDomStyles } from "./useLightDomStyles-wGaNXHqN.js";
|
|
6
6
|
import { t as usePlacement } from "./usePlacement-Dd7itnCf.js";
|
|
7
|
-
import { t as useReward } from "./useReward-
|
|
7
|
+
import { t as useReward } from "./useReward-cQ54x8q-.js";
|
|
8
8
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
9
|
-
import { t as cssSource$4 } from "./sharedBaseCss.css-
|
|
9
|
+
import { t as cssSource$4 } from "./sharedBaseCss.css-D2HG4Ty8.js";
|
|
10
|
+
import { t as GiftIcon } from "./GiftIcon-Csu31jtf.js";
|
|
11
|
+
import { a as resolveRewardCurrency, c as isClaimable, d as useInlineReminderRegistration, f as useReminderDismissed, l as markClaimStarted, n as formatFiat, o as getRewardCountdown, p as dismissReminder, r as formatRewardDate, s as useRewardSummary, t as fillReminderText } from "./format-zGdbUoX_.js";
|
|
12
|
+
import { n as getCountdownLabel, t as getPreviewPending } from "./previewSummary-CMc6q8vI.js";
|
|
10
13
|
import { isInAppBrowser, redirectToExternalBrowser, sanitizeProductDetailsList, trackEvent } from "@frak-labs/core-sdk";
|
|
11
|
-
import { REFERRAL_SUCCESS_EVENT, getMergeToken } from "@frak-labs/core-sdk/actions";
|
|
14
|
+
import { REFERRAL_SUCCESS_EVENT, getInstallUrl, getMergeToken } from "@frak-labs/core-sdk/actions";
|
|
12
15
|
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
13
16
|
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
14
17
|
// \0ve-inline:../../packages/design-system/src/keyframes.css.ts.vanilla.js
|
|
@@ -273,7 +276,26 @@ const cssSource$1 = `.Banner_rootBase__1gnumzi0 {
|
|
|
273
276
|
display: inline-block;
|
|
274
277
|
}
|
|
275
278
|
|
|
276
|
-
.
|
|
279
|
+
.Banner_pendingCta__1gnumzi9 {
|
|
280
|
+
text-decoration: none;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.Banner_pendingBody__1gnumzia {
|
|
284
|
+
padding-right: 24px;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.Banner_pendingClose__1gnumzib {
|
|
288
|
+
color: #979797;
|
|
289
|
+
width: 24px;
|
|
290
|
+
height: 24px;
|
|
291
|
+
font-size: 18px;
|
|
292
|
+
line-height: 24px;
|
|
293
|
+
position: absolute;
|
|
294
|
+
top: 8px;
|
|
295
|
+
right: 8px;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.Banner_frakLogo__1gnumzic {
|
|
277
299
|
pointer-events: none;
|
|
278
300
|
position: absolute;
|
|
279
301
|
bottom: 12px;
|
|
@@ -281,8 +303,11 @@ const cssSource$1 = `.Banner_rootBase__1gnumzi0 {
|
|
|
281
303
|
}
|
|
282
304
|
`;
|
|
283
305
|
// src/components/Banner/Banner.css.ts
|
|
284
|
-
var frakLogo = "
|
|
306
|
+
var frakLogo = "Banner_frakLogo__1gnumzic";
|
|
285
307
|
var iconSvg = "Banner_iconSvg__1gnumzi1";
|
|
308
|
+
var pendingBody = "Banner_pendingBody__1gnumzia";
|
|
309
|
+
var pendingClose = "Banner_pendingClose__1gnumzib sharedBaseCss_buttonReset__7cswil0";
|
|
310
|
+
var pendingCta = "Banner_pendingCta__1gnumzi9 Banner_referralCta__1gnumzi8 sharedBaseCss_buttonReset__7cswil0";
|
|
286
311
|
var referral = "Banner_referral__1gnumzi2 reset_base__1831jhd0 Banner_rootBase__1gnumzi0";
|
|
287
312
|
var referralBody = "Banner_referralBody__1gnumzi5";
|
|
288
313
|
var referralCta = "Banner_referralCta__1gnumzi8 sharedBaseCss_buttonReset__7cswil0";
|
|
@@ -291,12 +316,187 @@ var referralIconWrapper = "Banner_referralIconWrapper__1gnumzi3";
|
|
|
291
316
|
var referralImage = "Banner_referralImage__1gnumzi4";
|
|
292
317
|
var referralTitle = "Banner_referralTitle__1gnumzi6 reset_base__1831jhd0";
|
|
293
318
|
const cssSource = cssSource$3 + cssSource$2 + cssSource$1;
|
|
319
|
+
// src/components/Banner/PendingBanner.tsx
|
|
320
|
+
function pickDate(date, lang) {
|
|
321
|
+
return date ? formatRewardDate(date, lang) : void 0;
|
|
322
|
+
}
|
|
323
|
+
/** Banner for a visitor with unclaimed rewards and no Frak wallet: amount, days left, link to the wallet install page. */
|
|
324
|
+
function PendingBanner({ pending, isPreview, isClientReady, placementId, classname, imageUrl, config, overrides }) {
|
|
325
|
+
const lang = useLang();
|
|
326
|
+
const [installUrl, setInstallUrl] = useState(void 0);
|
|
327
|
+
const trackedImpressionRef = useRef(false);
|
|
328
|
+
const countdown = useMemo(() => getRewardCountdown(pending.expiresAt), [pending.expiresAt]);
|
|
329
|
+
const daysLeft = countdown?.days;
|
|
330
|
+
const locked = pending.lockedCount > 0;
|
|
331
|
+
useInlineReminderRegistration(!isPreview);
|
|
332
|
+
const track = useCallback((event) => {
|
|
333
|
+
if (isPreview) return;
|
|
334
|
+
trackEvent(window.FrakSetup?.client, event, {
|
|
335
|
+
surface: "banner",
|
|
336
|
+
placement: placementId,
|
|
337
|
+
days_left: daysLeft,
|
|
338
|
+
locked
|
|
339
|
+
});
|
|
340
|
+
}, [
|
|
341
|
+
isPreview,
|
|
342
|
+
placementId,
|
|
343
|
+
daysLeft,
|
|
344
|
+
locked
|
|
345
|
+
]);
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
if (isPreview || !isClientReady) return;
|
|
348
|
+
let cancelled = false;
|
|
349
|
+
getInstallUrl().then((url) => {
|
|
350
|
+
if (!cancelled) setInstallUrl(url);
|
|
351
|
+
}).catch(() => {});
|
|
352
|
+
return () => {
|
|
353
|
+
cancelled = true;
|
|
354
|
+
};
|
|
355
|
+
}, [isPreview, isClientReady]);
|
|
356
|
+
useEffect(() => {
|
|
357
|
+
if (isPreview || !isClientReady || trackedImpressionRef.current) return;
|
|
358
|
+
trackedImpressionRef.current = true;
|
|
359
|
+
track("reward_reminder_impression");
|
|
360
|
+
}, [
|
|
361
|
+
isPreview,
|
|
362
|
+
isClientReady,
|
|
363
|
+
track
|
|
364
|
+
]);
|
|
365
|
+
const texts = (() => {
|
|
366
|
+
const defaults = componentDefaults[lang].banner;
|
|
367
|
+
const unlockAt = pending.nextUnlockAt ? new Date(pending.nextUnlockAt) : void 0;
|
|
368
|
+
const allLocked = pending.lockedCount >= pending.count && unlockAt !== void 0 && !Number.isNaN(unlockAt.getTime());
|
|
369
|
+
const values = {
|
|
370
|
+
reward: formatFiat(pending.total, resolveRewardCurrency()),
|
|
371
|
+
days: countdown?.days,
|
|
372
|
+
date: pickDate(allLocked ? unlockAt : countdown?.date, lang)
|
|
373
|
+
};
|
|
374
|
+
const defaultDescription = [allLocked ? defaults.pendingDescriptionLocked : defaults.pendingDescription, countdown && `${getCountdownLabel(countdown.days, lang)}.`].filter(Boolean).join(" ");
|
|
375
|
+
const fill = (template) => fillReminderText(template, values);
|
|
376
|
+
return {
|
|
377
|
+
title: fill(overrides.title ?? config?.pendingTitle ?? defaults.pendingTitle),
|
|
378
|
+
description: fill(overrides.description ?? config?.pendingDescription ?? defaultDescription),
|
|
379
|
+
cta: fill(overrides.cta ?? config?.pendingCta ?? defaults.pendingCta)
|
|
380
|
+
};
|
|
381
|
+
})();
|
|
382
|
+
const onClaim = useCallback((event) => {
|
|
383
|
+
if (isPreview) return;
|
|
384
|
+
if (!installUrl) {
|
|
385
|
+
event.preventDefault();
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
markClaimStarted();
|
|
389
|
+
trackEvent(window.FrakSetup?.client, "banner_resolved", {
|
|
390
|
+
placement: placementId,
|
|
391
|
+
variant: "pending",
|
|
392
|
+
outcome: "clicked"
|
|
393
|
+
});
|
|
394
|
+
track("reward_reminder_claim_clicked");
|
|
395
|
+
}, [
|
|
396
|
+
isPreview,
|
|
397
|
+
installUrl,
|
|
398
|
+
placementId,
|
|
399
|
+
track
|
|
400
|
+
]);
|
|
401
|
+
const onDismiss = useCallback(() => {
|
|
402
|
+
if (isPreview) return;
|
|
403
|
+
trackEvent(window.FrakSetup?.client, "banner_resolved", {
|
|
404
|
+
placement: placementId,
|
|
405
|
+
variant: "pending",
|
|
406
|
+
outcome: "dismissed"
|
|
407
|
+
});
|
|
408
|
+
track("reward_reminder_dismissed");
|
|
409
|
+
dismissReminder();
|
|
410
|
+
}, [
|
|
411
|
+
isPreview,
|
|
412
|
+
placementId,
|
|
413
|
+
track
|
|
414
|
+
]);
|
|
415
|
+
const inert = !isPreview && !installUrl;
|
|
416
|
+
const bannerClass = [
|
|
417
|
+
referral,
|
|
418
|
+
"frak-banner",
|
|
419
|
+
"frak-banner--pending",
|
|
420
|
+
classname
|
|
421
|
+
].filter(Boolean).join(" ");
|
|
422
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
423
|
+
class: bannerClass,
|
|
424
|
+
"aria-label": texts.title,
|
|
425
|
+
children: [
|
|
426
|
+
/* @__PURE__ */ jsx("div", {
|
|
427
|
+
class: `${referralIconWrapper} frak-banner__icon`,
|
|
428
|
+
children: imageUrl ? /* @__PURE__ */ jsx("img", {
|
|
429
|
+
src: imageUrl,
|
|
430
|
+
alt: "",
|
|
431
|
+
class: referralImage
|
|
432
|
+
}) : /* @__PURE__ */ jsx(GiftIcon, { class: iconSvg })
|
|
433
|
+
}),
|
|
434
|
+
/* @__PURE__ */ jsxs("div", {
|
|
435
|
+
class: `${referralBody} ${pendingBody} frak-banner__text`,
|
|
436
|
+
children: [
|
|
437
|
+
/* @__PURE__ */ jsx("p", {
|
|
438
|
+
class: `${referralTitle} frak-banner__title`,
|
|
439
|
+
children: texts.title
|
|
440
|
+
}),
|
|
441
|
+
/* @__PURE__ */ jsx("p", {
|
|
442
|
+
class: `${referralDescription} frak-banner__description`,
|
|
443
|
+
children: texts.description
|
|
444
|
+
}),
|
|
445
|
+
/* @__PURE__ */ jsx("a", {
|
|
446
|
+
class: `${pendingCta} frak-banner__cta`,
|
|
447
|
+
href: isPreview ? "#" : installUrl,
|
|
448
|
+
target: isPreview ? void 0 : "_blank",
|
|
449
|
+
rel: "noopener",
|
|
450
|
+
role: inert ? "link" : void 0,
|
|
451
|
+
tabIndex: inert ? 0 : void 0,
|
|
452
|
+
"aria-disabled": inert ? "true" : void 0,
|
|
453
|
+
onClick: onClaim,
|
|
454
|
+
children: texts.cta
|
|
455
|
+
})
|
|
456
|
+
]
|
|
457
|
+
}),
|
|
458
|
+
/* @__PURE__ */ jsx("button", {
|
|
459
|
+
type: "button",
|
|
460
|
+
class: `${pendingClose} frak-banner__close`,
|
|
461
|
+
"aria-label": componentDefaults[lang].banner.dismissLabel,
|
|
462
|
+
onClick: onDismiss,
|
|
463
|
+
children: "×"
|
|
464
|
+
}),
|
|
465
|
+
/* @__PURE__ */ jsx(LogoFrakWithName, {
|
|
466
|
+
class: `${frakLogo} frak-banner__logo`,
|
|
467
|
+
width: 42,
|
|
468
|
+
height: 24
|
|
469
|
+
})
|
|
470
|
+
]
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
// src/components/Banner/usePendingSummary.ts
|
|
474
|
+
/**
|
|
475
|
+
* The pending rewards the banner can show. `baseMode` is the mode already decided
|
|
476
|
+
* by the page (in-app, referral, or a previewed pending): the summary is only
|
|
477
|
+
* fetched while none applies, so the other modes keep their priority.
|
|
478
|
+
*/
|
|
479
|
+
function usePendingSummary(baseMode, canFetch) {
|
|
480
|
+
const dismissed = useReminderDismissed();
|
|
481
|
+
const { summary } = useRewardSummary(baseMode === null && canFetch);
|
|
482
|
+
return useMemo(() => {
|
|
483
|
+
if (baseMode === "pending") return getPreviewPending();
|
|
484
|
+
if (baseMode !== null || dismissed) return null;
|
|
485
|
+
return isClaimable(summary) ? summary.pending : null;
|
|
486
|
+
}, [
|
|
487
|
+
baseMode,
|
|
488
|
+
dismissed,
|
|
489
|
+
summary
|
|
490
|
+
]);
|
|
491
|
+
}
|
|
294
492
|
// src/components/Banner/Banner.tsx
|
|
493
|
+
function toPreviewMode(value) {
|
|
494
|
+
return value === "inapp" || value === "pending" ? value : "referral";
|
|
495
|
+
}
|
|
295
496
|
/**
|
|
296
497
|
* Auto-detecting notification banner component.
|
|
297
498
|
*
|
|
298
|
-
* Renders an inline banner on the merchant page with one of
|
|
299
|
-
* visual styles depending on the detected mode:
|
|
499
|
+
* Renders an inline banner on the merchant page with one of three modes:
|
|
300
500
|
*
|
|
301
501
|
* - **Referral mode** (white): Shown after a successful referral link
|
|
302
502
|
* processing. Displays a gift icon, reward copy, and a "Got it" CTA.
|
|
@@ -305,7 +505,10 @@ const cssSource = cssSource$3 + cssSource$2 + cssSource$1;
|
|
|
305
505
|
* Offers an inline link to redirect to the default browser plus a
|
|
306
506
|
* close button to dismiss.
|
|
307
507
|
*
|
|
308
|
-
*
|
|
508
|
+
* - **Pending mode** (white): Shown to a visitor with unclaimed rewards and no
|
|
509
|
+
* Frak wallet yet; see {@link PendingBanner}.
|
|
510
|
+
*
|
|
511
|
+
* Priority: in-app browser, then referral, then pending.
|
|
309
512
|
* Uses Light DOM + vanilla-extract styles from `@frak-labs/design-system`.
|
|
310
513
|
*
|
|
311
514
|
* @group components
|
|
@@ -322,19 +525,21 @@ const cssSource = cssSource$3 + cssSource$2 + cssSource$1;
|
|
|
322
525
|
* <frak-banner classname="my-custom-banner"></frak-banner>
|
|
323
526
|
* ```
|
|
324
527
|
*/
|
|
325
|
-
function Banner({ placement: placementId, classname = "", interaction, products, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, imageUrl: propImageUrl, preview, previewMode, allowInappRedirect }) {
|
|
528
|
+
function Banner({ placement: placementId, classname = "", interaction, products, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, pendingTitle, pendingDescription, pendingCta, imageUrl: propImageUrl, preview, previewMode, allowInappRedirect }) {
|
|
326
529
|
const isPreview = !!preview;
|
|
327
530
|
const lang = useLang();
|
|
328
|
-
const resolvedPreviewMode = previewMode
|
|
531
|
+
const resolvedPreviewMode = toPreviewMode(previewMode);
|
|
329
532
|
const isInappRedirectAllowed = allowInappRedirect === true || allowInappRedirect === "true";
|
|
330
533
|
const placement = usePlacement(placementId);
|
|
331
534
|
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
332
535
|
useLightDomStyles("frak-banner", placementId, placement?.components?.banner?.css, cssSource, cssSource$4);
|
|
333
536
|
const [dismissed, setDismissed] = useState(false);
|
|
334
|
-
const [
|
|
537
|
+
const [baseMode, setMode] = useState(() => {
|
|
335
538
|
if (isPreview) return resolvedPreviewMode;
|
|
336
539
|
return isInappRedirectAllowed && isInAppBrowser ? "inapp" : null;
|
|
337
540
|
});
|
|
541
|
+
const pending = usePendingSummary(baseMode, !isPreview && isClientReady && shouldRender && !isHidden);
|
|
542
|
+
const mode = baseMode ?? (pending ? "pending" : null);
|
|
338
543
|
const trackedImpressionModeRef = useRef(null);
|
|
339
544
|
useEffect(() => {
|
|
340
545
|
if (isPreview) setMode(resolvedPreviewMode);
|
|
@@ -369,11 +574,11 @@ function Banner({ placement: placementId, classname = "", interaction, products,
|
|
|
369
574
|
placementId
|
|
370
575
|
]);
|
|
371
576
|
useEffect(() => {
|
|
372
|
-
if (isPreview ||
|
|
577
|
+
if (isPreview || baseMode === "inapp") return;
|
|
373
578
|
const handler = () => setMode("referral");
|
|
374
579
|
window.addEventListener(REFERRAL_SUCCESS_EVENT, handler);
|
|
375
580
|
return () => window.removeEventListener(REFERRAL_SUCCESS_EVENT, handler);
|
|
376
|
-
}, [isPreview,
|
|
581
|
+
}, [isPreview, baseMode]);
|
|
377
582
|
const handleAction = useCallback(async () => {
|
|
378
583
|
if (isPreview) return;
|
|
379
584
|
trackEvent(window.FrakSetup?.client, "banner_resolved", {
|
|
@@ -446,6 +651,20 @@ function Banner({ placement: placementId, classname = "", interaction, products,
|
|
|
446
651
|
propInappCta
|
|
447
652
|
]);
|
|
448
653
|
if (!mode || !isPreview && (!shouldRender || isHidden || dismissed)) return null;
|
|
654
|
+
if (pending) return /* @__PURE__ */ jsx(PendingBanner, {
|
|
655
|
+
pending,
|
|
656
|
+
isPreview,
|
|
657
|
+
isClientReady,
|
|
658
|
+
placementId,
|
|
659
|
+
classname,
|
|
660
|
+
imageUrl,
|
|
661
|
+
config: bannerConfig,
|
|
662
|
+
overrides: {
|
|
663
|
+
title: pendingTitle,
|
|
664
|
+
description: pendingDescription,
|
|
665
|
+
cta: pendingCta
|
|
666
|
+
}
|
|
667
|
+
});
|
|
449
668
|
const bannerClass = [
|
|
450
669
|
referral,
|
|
451
670
|
"frak-banner",
|
|
@@ -523,6 +742,9 @@ registerWebComponent(Banner, "frak-banner", [
|
|
|
523
742
|
"inappTitle",
|
|
524
743
|
"inappDescription",
|
|
525
744
|
"inappCta",
|
|
745
|
+
"pendingTitle",
|
|
746
|
+
"pendingDescription",
|
|
747
|
+
"pendingCta",
|
|
526
748
|
"preview",
|
|
527
749
|
"previewMode",
|
|
528
750
|
"imageUrl",
|
package/dist/buttonShare.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as useClientReady, o as registerWebComponent, r as useLang, s as openSharingPage } from "./sharedCss-SKmJGZgN.js";
|
|
2
|
-
import { i as w } from "./rewards-
|
|
2
|
+
import { i as w } from "./rewards-BuNthAR2.js";
|
|
3
3
|
import { t as useGlobalComponents } from "./useGlobalComponents-BF47jsBt.js";
|
|
4
4
|
import { t as useLightDomStyles } from "./useLightDomStyles-wGaNXHqN.js";
|
|
5
5
|
import { t as usePlacement } from "./usePlacement-Dd7itnCf.js";
|
|
6
|
-
import { t as useReward } from "./useReward-
|
|
6
|
+
import { t as useReward } from "./useReward-cQ54x8q-.js";
|
|
7
7
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
8
8
|
import { sanitizeSharingProducts, trackEvent } from "@frak-labs/core-sdk";
|
|
9
9
|
import { useCallback, useEffect, useMemo, useRef } from "preact/hooks";
|
package/dist/buttonWallet.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as useClientReady, o as registerWebComponent, r as useLang, s as openSharingPage, t as buildStyleContent } from "./sharedCss-SKmJGZgN.js";
|
|
2
2
|
import { t as usePlacement } from "./usePlacement-Dd7itnCf.js";
|
|
3
|
-
import { t as useReward } from "./useReward-
|
|
3
|
+
import { t as useReward } from "./useReward-cQ54x8q-.js";
|
|
4
4
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
5
5
|
import { trackEvent } from "@frak-labs/core-sdk";
|
|
6
6
|
import { useCallback, useEffect, useRef } from "preact/hooks";
|