@frak-labs/components 1.3.4 → 1.5.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/cdn/Ambassador.CZAN1-jx.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.CVZlV54f.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/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 +17 -11
- 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/useGlobalComponents.CXuceSQ0.js +0 -1
- package/cdn/usePlacement.Cq64cZ9Q.js +0 -1
package/dist/postPurchase.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { a as useClientReady, o as registerWebComponent, r as useLang, s as openSharingPage } from "./sharedCss-SKmJGZgN.js";
|
|
2
|
-
import { i as w, n as K, t as C } from "./rewards-
|
|
3
|
-
import {
|
|
2
|
+
import { i as w, n as K, t as C } from "./rewards-BuNthAR2.js";
|
|
3
|
+
import { n as LogoFrakWithName } 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
7
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
8
|
-
import { t as cssSource$2 } from "./sharedBaseCss.css-
|
|
8
|
+
import { t as cssSource$2 } from "./sharedBaseCss.css-D2HG4Ty8.js";
|
|
9
|
+
import { t as GiftIcon } from "./GiftIcon-Csu31jtf.js";
|
|
10
|
+
import { a as resolveRewardCurrency, c as isClaimable, d as useInlineReminderRegistration, l as markClaimStarted, n as formatFiat, o as getRewardCountdown, s as useRewardSummary } from "./format-zGdbUoX_.js";
|
|
9
11
|
import { sanitizeSharingProducts, trackEvent } from "@frak-labs/core-sdk";
|
|
10
|
-
import { getMerchantInformation, getUserReferralStatus, trackPurchaseStatus } from "@frak-labs/core-sdk/actions";
|
|
12
|
+
import { getInstallUrl, getMerchantInformation, getUserReferralStatus, trackPurchaseStatus } from "@frak-labs/core-sdk/actions";
|
|
11
13
|
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
12
14
|
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
13
15
|
import { FrakRpcError, RpcErrorCodes } from "@frak-labs/frame-connector";
|
|
@@ -81,16 +83,38 @@ const cssSource$1 = `.PostPurchase_card__5fv5lh0 {
|
|
|
81
83
|
cursor: default;
|
|
82
84
|
}
|
|
83
85
|
|
|
84
|
-
.
|
|
86
|
+
.PostPurchase_claimLink__5fv5lh7 {
|
|
87
|
+
text-decoration: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.PostPurchase_claimLink__5fv5lh7:hover, .PostPurchase_claimLink__5fv5lh7:visited, .PostPurchase_claimLink__5fv5lh7:focus-visible {
|
|
91
|
+
color: var(--text-onAction__pbq4ak6);
|
|
92
|
+
text-decoration: none;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.PostPurchase_ctaSecondary__5fv5lh8 {
|
|
96
|
+
color: var(--text-primary__pbq4ak0);
|
|
97
|
+
border: 1px solid var(--border-default__pbq4akv);
|
|
98
|
+
background-color: #0000;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.PostPurchase_actions__5fv5lh9 {
|
|
102
|
+
flex-wrap: wrap;
|
|
103
|
+
align-items: center;
|
|
104
|
+
gap: 8px;
|
|
105
|
+
display: flex;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.PostPurchase_icon__5fv5lha {
|
|
85
109
|
margin: -2px 0;
|
|
86
110
|
}
|
|
87
111
|
|
|
88
|
-
.
|
|
112
|
+
.PostPurchase_giftIcon__5fv5lhb {
|
|
89
113
|
flex-shrink: 0;
|
|
90
114
|
display: block;
|
|
91
115
|
}
|
|
92
116
|
|
|
93
|
-
.
|
|
117
|
+
.PostPurchase_imageWrapper__5fv5lhc {
|
|
94
118
|
flex-shrink: 0;
|
|
95
119
|
justify-content: center;
|
|
96
120
|
align-items: center;
|
|
@@ -100,7 +124,7 @@ const cssSource$1 = `.PostPurchase_card__5fv5lh0 {
|
|
|
100
124
|
overflow: hidden;
|
|
101
125
|
}
|
|
102
126
|
|
|
103
|
-
.
|
|
127
|
+
.PostPurchase_customImage__5fv5lhd {
|
|
104
128
|
object-fit: contain;
|
|
105
129
|
width: auto;
|
|
106
130
|
max-width: 100%;
|
|
@@ -109,23 +133,130 @@ const cssSource$1 = `.PostPurchase_card__5fv5lh0 {
|
|
|
109
133
|
display: block;
|
|
110
134
|
}
|
|
111
135
|
|
|
112
|
-
.
|
|
136
|
+
.PostPurchase_frakLogo__5fv5lhe {
|
|
113
137
|
margin-left: auto;
|
|
114
138
|
display: block;
|
|
115
139
|
}
|
|
116
140
|
`;
|
|
141
|
+
// src/components/PostPurchase/PostPurchase.css.ts
|
|
142
|
+
var actions = "PostPurchase_actions__5fv5lh9";
|
|
117
143
|
var card = "PostPurchase_card__5fv5lh0";
|
|
118
144
|
var cardLayout = "PostPurchase_cardLayout__5fv5lh1";
|
|
119
145
|
var cardLeft = "PostPurchase_cardLeft__5fv5lh2";
|
|
120
146
|
var cardRight = "PostPurchase_cardRight__5fv5lh3";
|
|
147
|
+
var claimLink = "PostPurchase_claimLink__5fv5lh7";
|
|
121
148
|
var cta = "PostPurchase_cta__5fv5lh6 sharedBaseCss_buttonReset__7cswil0";
|
|
122
|
-
var
|
|
123
|
-
var
|
|
124
|
-
var
|
|
125
|
-
var
|
|
126
|
-
var
|
|
149
|
+
var ctaSecondary = "PostPurchase_ctaSecondary__5fv5lh8";
|
|
150
|
+
var customImage = "PostPurchase_customImage__5fv5lhd";
|
|
151
|
+
var frakLogo = "PostPurchase_frakLogo__5fv5lhe";
|
|
152
|
+
var giftIcon = "PostPurchase_giftIcon__5fv5lhb";
|
|
153
|
+
var icon = "PostPurchase_icon__5fv5lha";
|
|
154
|
+
var imageWrapper = "PostPurchase_imageWrapper__5fv5lhc";
|
|
127
155
|
var message = "PostPurchase_message__5fv5lh5";
|
|
128
156
|
const cssSource = cssSource$1;
|
|
157
|
+
// src/components/PostPurchase/ClaimButton.tsx
|
|
158
|
+
const SUMMARY_WAIT_MS = 1500;
|
|
159
|
+
/**
|
|
160
|
+
* Whether the referee card offers the claim button, and with which text. Unlinked
|
|
161
|
+
* visitors see it; the card waits briefly for the summary so it rarely grows a button late.
|
|
162
|
+
*/
|
|
163
|
+
function useRefereeClaim({ isPreview, isClientReady, isReferee, rewardText, lang, propText, configText }) {
|
|
164
|
+
const enabled = !isPreview && isClientReady && isReferee;
|
|
165
|
+
const { status, summary } = useRewardSummary(enabled);
|
|
166
|
+
const [timedOut, setTimedOut] = useState(false);
|
|
167
|
+
const ready = status === "ready";
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
if (!enabled || ready) return;
|
|
170
|
+
const timer = setTimeout(() => setTimedOut(true), SUMMARY_WAIT_MS);
|
|
171
|
+
return () => clearTimeout(timer);
|
|
172
|
+
}, [enabled, ready]);
|
|
173
|
+
const settledRef = useRef(false);
|
|
174
|
+
if (status === "ready") settledRef.current = true;
|
|
175
|
+
const claimable = isClaimable(summary) ? summary : null;
|
|
176
|
+
const reward = claimable ? formatFiat(claimable.pending.total, resolveRewardCurrency()) : rewardText;
|
|
177
|
+
const show = isReferee && summary?.linked !== true;
|
|
178
|
+
const defaults = componentDefaults[lang].postPurchase;
|
|
179
|
+
const fallback = reward ? defaults.claimCtaText : defaults.claimCtaNoRewardText;
|
|
180
|
+
return {
|
|
181
|
+
awaitingSummary: !isPreview && isReferee && !settledRef.current && !timedOut,
|
|
182
|
+
show,
|
|
183
|
+
claimable: claimable !== null,
|
|
184
|
+
shareClassName: show ? `${cta} ${ctaSecondary} button` : `${cta} button`,
|
|
185
|
+
text: w(propText ?? configText ?? fallback, reward),
|
|
186
|
+
daysLeft: claimable ? getRewardCountdown(claimable.pending.expiresAt)?.days : void 0,
|
|
187
|
+
locked: (claimable?.pending.lockedCount ?? 0) > 0
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/** Sends a referee with no linked wallet to the install page, carrying the order token. */
|
|
191
|
+
function ClaimButton({ claim, ...props }) {
|
|
192
|
+
return claim.show ? /* @__PURE__ */ jsx(ClaimLink, {
|
|
193
|
+
claim,
|
|
194
|
+
...props
|
|
195
|
+
}) : null;
|
|
196
|
+
}
|
|
197
|
+
function ClaimLink({ claim: { text, daysLeft, locked, claimable }, token, merchantId, placement, isPreview, isClientReady }) {
|
|
198
|
+
const [installUrl, setInstallUrl] = useState();
|
|
199
|
+
const impressionTracked = useRef(false);
|
|
200
|
+
const reminder = {
|
|
201
|
+
surface: "post_purchase",
|
|
202
|
+
placement,
|
|
203
|
+
days_left: daysLeft,
|
|
204
|
+
locked
|
|
205
|
+
};
|
|
206
|
+
useInlineReminderRegistration(!isPreview);
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
if (isPreview || !isClientReady) return;
|
|
209
|
+
let cancelled = false;
|
|
210
|
+
getInstallUrl({
|
|
211
|
+
merchantId,
|
|
212
|
+
checkoutToken: token
|
|
213
|
+
}).then((url) => {
|
|
214
|
+
if (!cancelled) setInstallUrl(url);
|
|
215
|
+
}).catch((error) => console.error("Frak install link failed", error));
|
|
216
|
+
return () => {
|
|
217
|
+
cancelled = true;
|
|
218
|
+
};
|
|
219
|
+
}, [
|
|
220
|
+
isPreview,
|
|
221
|
+
isClientReady,
|
|
222
|
+
merchantId,
|
|
223
|
+
token
|
|
224
|
+
]);
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
if (isPreview || !isClientReady || !claimable || impressionTracked.current) return;
|
|
227
|
+
impressionTracked.current = true;
|
|
228
|
+
trackEvent(window.FrakSetup?.client, "reward_reminder_impression", reminder);
|
|
229
|
+
}, [
|
|
230
|
+
isPreview,
|
|
231
|
+
isClientReady,
|
|
232
|
+
claimable,
|
|
233
|
+
reminder
|
|
234
|
+
]);
|
|
235
|
+
const handleClick = (event) => {
|
|
236
|
+
if (isPreview) return;
|
|
237
|
+
if (installUrl === void 0) {
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
markClaimStarted();
|
|
242
|
+
trackEvent(window.FrakSetup?.client, "post_purchase_clicked", {
|
|
243
|
+
placement,
|
|
244
|
+
variant: "referee",
|
|
245
|
+
action: "claim"
|
|
246
|
+
});
|
|
247
|
+
trackEvent(window.FrakSetup?.client, "reward_reminder_claim_clicked", reminder);
|
|
248
|
+
};
|
|
249
|
+
const inert = installUrl === void 0;
|
|
250
|
+
return /* @__PURE__ */ jsx("a", {
|
|
251
|
+
className: `${cta} ${claimLink} button`,
|
|
252
|
+
href: installUrl,
|
|
253
|
+
role: inert ? "link" : void 0,
|
|
254
|
+
tabIndex: inert ? 0 : void 0,
|
|
255
|
+
"aria-disabled": inert ? "true" : void 0,
|
|
256
|
+
onClick: handleClick,
|
|
257
|
+
children: text
|
|
258
|
+
});
|
|
259
|
+
}
|
|
129
260
|
// src/components/PostPurchase/PostPurchase.tsx
|
|
130
261
|
/**
|
|
131
262
|
* `onChainMetadata.domain` is a bare host and `sharing-url` defaults to `""` in
|
|
@@ -190,7 +321,7 @@ function resolvePostPurchaseContext(referralStatus, merchantInfo, currency, prod
|
|
|
190
321
|
* ></frak-post-purchase>
|
|
191
322
|
* ```
|
|
192
323
|
*/
|
|
193
|
-
function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, placement: placementId, classname = "", variant: forcedVariant, badgeText: propBadgeText, referrerText: propReferrerText, refereeText: propRefereeText, ctaText: propCtaText, preview, previewVariant, products, imageUrl: propImageUrl }) {
|
|
324
|
+
function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, placement: placementId, classname = "", variant: forcedVariant, badgeText: propBadgeText, referrerText: propReferrerText, refereeText: propRefereeText, ctaText: propCtaText, claimCtaText: propClaimCtaText, preview, previewVariant, products, imageUrl: propImageUrl }) {
|
|
194
325
|
const isPreview = !!preview;
|
|
195
326
|
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
196
327
|
const placement = usePlacement(placementId);
|
|
@@ -270,11 +401,21 @@ function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, plac
|
|
|
270
401
|
propRefereeText,
|
|
271
402
|
propCtaText
|
|
272
403
|
]);
|
|
404
|
+
const claim = useRefereeClaim({
|
|
405
|
+
isPreview,
|
|
406
|
+
isClientReady,
|
|
407
|
+
isReferee: resolvedVariant === "referee",
|
|
408
|
+
rewardText,
|
|
409
|
+
lang,
|
|
410
|
+
propText: propClaimCtaText,
|
|
411
|
+
configText: postPurchaseConfig?.claimCtaText
|
|
412
|
+
});
|
|
273
413
|
useEffect(() => {
|
|
274
414
|
if (!resolvedVariant) return;
|
|
275
415
|
if (trackedImpressionVariantRef.current === resolvedVariant) return;
|
|
276
416
|
if (!isClientReady) return;
|
|
277
417
|
if (!isPreview && (!shouldRender || isHidden)) return;
|
|
418
|
+
if (claim.awaitingSummary) return;
|
|
278
419
|
trackEvent(window.FrakSetup?.client, "post_purchase_impression", {
|
|
279
420
|
placement: placementId,
|
|
280
421
|
variant: resolvedVariant,
|
|
@@ -288,13 +429,15 @@ function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, plac
|
|
|
288
429
|
isClientReady,
|
|
289
430
|
isPreview,
|
|
290
431
|
placementId,
|
|
291
|
-
context?.reward
|
|
432
|
+
context?.reward,
|
|
433
|
+
claim.awaitingSummary
|
|
292
434
|
]);
|
|
293
435
|
const handleClick = useCallback(() => {
|
|
294
436
|
if (!resolvedVariant) return;
|
|
295
437
|
trackEvent(window.FrakSetup?.client, "post_purchase_clicked", {
|
|
296
438
|
placement: placementId,
|
|
297
|
-
variant: resolvedVariant
|
|
439
|
+
variant: resolvedVariant,
|
|
440
|
+
action: "share"
|
|
298
441
|
});
|
|
299
442
|
openSharingPage("post_purchase", void 0, placementId, {
|
|
300
443
|
link: resolvedSharingUrl,
|
|
@@ -309,7 +452,7 @@ function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, plac
|
|
|
309
452
|
token
|
|
310
453
|
]);
|
|
311
454
|
if (!resolvedVariant) return null;
|
|
312
|
-
if (!isPreview && (!shouldRender || isHidden || !context)) return null;
|
|
455
|
+
if (!isPreview && (!shouldRender || isHidden || !context || claim.awaitingSummary)) return null;
|
|
313
456
|
const cardClass = [card, classname].filter(Boolean).join(" ");
|
|
314
457
|
return /* @__PURE__ */ jsx("div", {
|
|
315
458
|
className: cardClass,
|
|
@@ -326,22 +469,32 @@ function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, plac
|
|
|
326
469
|
class: message,
|
|
327
470
|
children: texts.message
|
|
328
471
|
}),
|
|
329
|
-
/* @__PURE__ */ jsxs("
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
className:
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
472
|
+
/* @__PURE__ */ jsxs("div", {
|
|
473
|
+
class: actions,
|
|
474
|
+
children: [/* @__PURE__ */ jsx(ClaimButton, {
|
|
475
|
+
claim,
|
|
476
|
+
token,
|
|
477
|
+
merchantId,
|
|
478
|
+
placement: placementId,
|
|
479
|
+
isPreview,
|
|
480
|
+
isClientReady
|
|
481
|
+
}), /* @__PURE__ */ jsxs("button", {
|
|
482
|
+
type: "button",
|
|
483
|
+
className: claim.shareClassName,
|
|
484
|
+
disabled: !isPreview && !isClientReady,
|
|
485
|
+
onClick: isPreview ? void 0 : handleClick,
|
|
486
|
+
children: [texts.cta, /* @__PURE__ */ jsx("svg", {
|
|
487
|
+
width: "16",
|
|
488
|
+
height: "16",
|
|
489
|
+
viewBox: "0 0 16 16",
|
|
490
|
+
fill: "none",
|
|
491
|
+
"aria-hidden": "true",
|
|
492
|
+
className: `${icon} button`,
|
|
493
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
494
|
+
d: "M13.9 11.14C13.99 11.05 14.15 11.11 14.15 11.24V11.64C14.15 13.05 12.63 14.19 10.75 14.19C8.87 14.19 7.34 13.05 7.34 11.64V11.24C7.34 11.11 7.51 11.05 7.59 11.14C8.35 11.93 9.48 12.43 10.75 12.43C12.01 12.43 13.15 11.93 13.9 11.14ZM1.85 9.65C1.85 9.51 2.01 9.44 2.1 9.54C2.85 10.32 3.99 10.82 5.25 10.82C5.52 10.82 5.79 10.8 6.04 10.76C6.26 10.72 6.47 10.88 6.47 11.1V12.17C6.47 12.32 6.37 12.45 6.22 12.48C5.92 12.55 5.59 12.59 5.25 12.59C3.37 12.59 1.85 11.45 1.85 10.04V9.65ZM10.75 6.21C12.63 6.21 14.15 7.35 14.15 8.75C14.15 10.16 12.63 11.3 10.75 11.3C8.87 11.3 7.34 10.16 7.34 8.75C7.34 7.35 8.87 6.21 10.75 6.21ZM1.85 6.85C1.85 6.71 2.01 6.65 2.1 6.74C2.85 7.53 3.99 8.03 5.25 8.03C5.52 8.03 5.79 8 6.04 7.96C6.26 7.92 6.47 8.09 6.47 8.3V9.37C6.47 9.52 6.37 9.65 6.22 9.69C5.92 9.75 5.59 9.79 5.25 9.79C3.37 9.79 1.85 8.65 1.85 7.24V6.85ZM5.25 1.81C7.13 1.81 8.66 2.95 8.66 4.36C8.66 5.76 7.13 6.9 5.25 6.9C3.37 6.9 1.85 5.76 1.85 4.36C1.85 2.95 3.37 1.81 5.25 1.81Z",
|
|
495
|
+
fill: "currentColor"
|
|
496
|
+
})
|
|
497
|
+
})]
|
|
345
498
|
})]
|
|
346
499
|
})
|
|
347
500
|
]
|
|
@@ -381,6 +534,7 @@ registerWebComponent(PostPurchase, "frak-post-purchase", [
|
|
|
381
534
|
"referrerText",
|
|
382
535
|
"refereeText",
|
|
383
536
|
"ctaText",
|
|
537
|
+
"claimCtaText",
|
|
384
538
|
"products",
|
|
385
539
|
"preview",
|
|
386
540
|
"previewVariant",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { componentDefaults } from "./i18n/defaults.js";
|
|
2
|
+
import { t as fillReminderText } from "./format-zGdbUoX_.js";
|
|
3
|
+
// src/rewards/countdownLabel.ts
|
|
4
|
+
/** "Expires today", "1 day left" or "{DAYS} days left", in the component's language. */
|
|
5
|
+
function getCountdownLabel(days, lang) {
|
|
6
|
+
const copy = componentDefaults[lang].rewardReminder;
|
|
7
|
+
if (days <= 0) return copy.countdownToday;
|
|
8
|
+
if (days === 1) return copy.countdownOneDay;
|
|
9
|
+
return fillReminderText(copy.countdownDays, { days });
|
|
10
|
+
}
|
|
11
|
+
// src/rewards/previewSummary.ts
|
|
12
|
+
const DAY_MS = 864e5;
|
|
13
|
+
/** Sample pending rewards for editors: both sources non-zero, twelve days left. */
|
|
14
|
+
function getPreviewPending(now = Date.now()) {
|
|
15
|
+
return {
|
|
16
|
+
total: {
|
|
17
|
+
eurAmount: 12.5,
|
|
18
|
+
usdAmount: 13.5,
|
|
19
|
+
gbpAmount: 10.5
|
|
20
|
+
},
|
|
21
|
+
cashback: {
|
|
22
|
+
eurAmount: 10,
|
|
23
|
+
usdAmount: 10.8,
|
|
24
|
+
gbpAmount: 8.4
|
|
25
|
+
},
|
|
26
|
+
fromFriends: {
|
|
27
|
+
eurAmount: 2.5,
|
|
28
|
+
usdAmount: 2.7,
|
|
29
|
+
gbpAmount: 2.1
|
|
30
|
+
},
|
|
31
|
+
count: 2,
|
|
32
|
+
lockedCount: 0,
|
|
33
|
+
nextUnlockAt: null,
|
|
34
|
+
expiresAt: new Date(now + 12 * DAY_MS).toISOString()
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export { getCountdownLabel as n, getPreviewPending as t };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The props type for {@link RewardReminder}.
|
|
3
|
+
* @inline
|
|
4
|
+
*/
|
|
5
|
+
type RewardReminderProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Placement ID reported with the reminder's analytics events.
|
|
8
|
+
*/
|
|
9
|
+
placement?: string;
|
|
10
|
+
/**
|
|
11
|
+
* CSS class names added to the floating root element.
|
|
12
|
+
*/
|
|
13
|
+
classname?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Side of the screen. Wins over the merchant dashboard and the SDK config.
|
|
16
|
+
* @defaultValue `"left"`
|
|
17
|
+
*/
|
|
18
|
+
position?: "left" | "right";
|
|
19
|
+
/**
|
|
20
|
+
* Override the expanded card heading. Supports `{REWARD}`, `{DAYS}`, `{DATE}`, `{BRAND}`.
|
|
21
|
+
*/
|
|
22
|
+
heading?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Override the expanded card description. Supports the same placeholders.
|
|
25
|
+
*/
|
|
26
|
+
description?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Override the claim button text. Supports the same placeholders.
|
|
29
|
+
*/
|
|
30
|
+
cta?: string;
|
|
31
|
+
/**
|
|
32
|
+
* When set, renders with sample data and no fetch (e.g. in a theme editor).
|
|
33
|
+
*/
|
|
34
|
+
preview?: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Floating pill for a visitor with unclaimed rewards and no Frak wallet, expanding into a claim card.
|
|
38
|
+
* Snoozed for the browser session once dismissed.
|
|
39
|
+
*
|
|
40
|
+
* @group components
|
|
41
|
+
*/
|
|
42
|
+
export declare function RewardReminder({ placement, classname, position: positionProp, heading: headingProp, description: descriptionProp, cta: ctaProp, preview }: RewardReminderProps): import("preact").JSX.Element | null;
|
|
43
|
+
/** Custom element type for `<frak-reward-reminder>`: {@link HTMLElement} plus {@link RewardReminderProps}. */
|
|
44
|
+
export type RewardReminderElement = HTMLElement & RewardReminderProps;
|
|
45
|
+
declare global {
|
|
46
|
+
interface HTMLElementTagNameMap {
|
|
47
|
+
"frak-reward-reminder": RewardReminderElement;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export {};
|