@frak-labs/components 1.0.3-beta.9d4f564a → 1.0.3-beta.a0c06742
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/Banner.B1y3jwHv.js +178 -0
- package/cdn/ButtonShare.DNELNwqD.js +1 -0
- package/cdn/ButtonWallet.BUUPX0gO.js +40 -0
- package/cdn/GiftIcon.eRNTGQ_r.js +1 -0
- package/cdn/OpenInAppButton.Dgb-qhM8.js +1 -0
- package/cdn/PostPurchase.C3IH-LUy.js +89 -0
- package/cdn/components.js +1 -0
- package/cdn/formatReward.B1ZyoceC.js +1 -0
- package/cdn/loader.css +0 -0
- package/cdn/loader.js +154 -0
- package/cdn/replay-V6FXES7X.CNozpSRg.js +1 -0
- package/cdn/sharingPage.Dt8QZhlR.js +1 -0
- package/cdn/useGlobalComponents.TG9kIYSc.js +1 -0
- package/cdn/useLightDomStyles.tjNBKcOr.js +1 -0
- package/cdn/usePlacement.BgMXY5CX.js +58 -0
- package/cdn/useReward.B530suzR.js +1 -0
- package/dist/GiftIcon-BIp9FTJs.js +338 -0
- package/dist/banner.d.ts +124 -0
- package/dist/banner.js +494 -0
- package/dist/buttonShare.d.ts +118 -0
- package/dist/buttonShare.js +122 -0
- package/dist/buttonWallet.d.ts +87 -0
- package/dist/buttonWallet.js +148 -0
- package/dist/formatReward-Cf2KpA3x.js +33 -0
- package/dist/openInApp.d.ts +66 -0
- package/dist/openInApp.js +93 -0
- package/dist/postPurchase.d.ts +160 -0
- package/dist/postPurchase.js +411 -0
- package/dist/sharingPage-D6fQEXV9.js +15 -0
- package/dist/useGlobalComponents-mSs9unyN.js +21 -0
- package/dist/useLightDomStyles-DVe5UDg6.js +48 -0
- package/dist/usePlacement-DzEuVg_u.js +253 -0
- package/dist/useReward-ClVShg45.js +65 -0
- package/package.json +3 -3
package/dist/banner.js
ADDED
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, t as usePlacement } from "./usePlacement-DzEuVg_u.js";
|
|
2
|
+
import { t as useGlobalComponents } from "./useGlobalComponents-mSs9unyN.js";
|
|
3
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-DVe5UDg6.js";
|
|
4
|
+
import { t as useReward } from "./useReward-ClVShg45.js";
|
|
5
|
+
import { a as ExternalLinkIcon, i as LogoFrakWithName, n as cssSource$3, o as CloseCircleIcon, r as WarningIcon, t as GiftIcon } from "./GiftIcon-BIp9FTJs.js";
|
|
6
|
+
import { isInAppBrowser, redirectToExternalBrowser, trackEvent } from "@frak-labs/core-sdk";
|
|
7
|
+
import { REFERRAL_SUCCESS_EVENT, getMergeToken } from "@frak-labs/core-sdk/actions";
|
|
8
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
9
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
10
|
+
//#region \0ve-inline:../../packages/design-system/src/styles/inAppBanner.css.ts.vanilla.js
|
|
11
|
+
const cssSource$2 = `@keyframes inAppBanner_fadeIn__1ibpiy70 {
|
|
12
|
+
from {
|
|
13
|
+
opacity: 0;
|
|
14
|
+
transform: translateY(-4px);
|
|
15
|
+
}
|
|
16
|
+
to {
|
|
17
|
+
opacity: 1;
|
|
18
|
+
transform: translateY(0);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
.inAppBanner_container__1ibpiy71 {
|
|
22
|
+
position: fixed;
|
|
23
|
+
top: max(8px, env(safe-area-inset-top));
|
|
24
|
+
left: 16px;
|
|
25
|
+
right: 16px;
|
|
26
|
+
z-index: 1000;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
gap: 4px;
|
|
30
|
+
padding: 12px 16px;
|
|
31
|
+
padding-right: 32px;
|
|
32
|
+
border-radius: 12px;
|
|
33
|
+
background-color: #000000CC;
|
|
34
|
+
backdrop-filter: blur(12px);
|
|
35
|
+
-webkit-backdrop-filter: blur(12px);
|
|
36
|
+
color: #ffffff;
|
|
37
|
+
animation: inAppBanner_fadeIn__1ibpiy70 300ms ease-out;
|
|
38
|
+
}
|
|
39
|
+
.inAppBanner_header__1ibpiy72 {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
gap: 8px;
|
|
43
|
+
}
|
|
44
|
+
.inAppBanner_iconWrapper__1ibpiy73 {
|
|
45
|
+
flex-shrink: 0;
|
|
46
|
+
width: 20px;
|
|
47
|
+
height: 20px;
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
color: #ffffff;
|
|
52
|
+
}
|
|
53
|
+
.inAppBanner_title__1ibpiy74 {
|
|
54
|
+
margin: 0;
|
|
55
|
+
padding: 0;
|
|
56
|
+
font-size: 16px;
|
|
57
|
+
font-weight: 500;
|
|
58
|
+
line-height: 26px;
|
|
59
|
+
color: var(--text-onAction__pbq4ak6);
|
|
60
|
+
}
|
|
61
|
+
.inAppBanner_body__1ibpiy75 {
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-wrap: wrap;
|
|
64
|
+
align-items: baseline;
|
|
65
|
+
gap: 0 4px;
|
|
66
|
+
}
|
|
67
|
+
.inAppBanner_description__1ibpiy76 {
|
|
68
|
+
margin: 0;
|
|
69
|
+
padding: 0;
|
|
70
|
+
font-size: 14px;
|
|
71
|
+
color: var(--text-onAction__pbq4ak6);
|
|
72
|
+
line-height: 22px;
|
|
73
|
+
opacity: 0.96;
|
|
74
|
+
}
|
|
75
|
+
.inAppBanner_cta__1ibpiy77 {
|
|
76
|
+
all: unset;
|
|
77
|
+
display: inline-flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
gap: 4px;
|
|
80
|
+
color: #2BB2FF;
|
|
81
|
+
font-size: 14px;
|
|
82
|
+
font-weight: 600;
|
|
83
|
+
text-decoration: underline;
|
|
84
|
+
text-underline-offset: 2px;
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
}
|
|
87
|
+
.inAppBanner_cta__1ibpiy77:focus-visible {
|
|
88
|
+
outline: 2px solid #2BB2FF;
|
|
89
|
+
outline-offset: 2px;
|
|
90
|
+
border-radius: 4px;
|
|
91
|
+
}
|
|
92
|
+
.inAppBanner_closeButton__1ibpiy78 {
|
|
93
|
+
all: unset;
|
|
94
|
+
position: absolute;
|
|
95
|
+
top: 8px;
|
|
96
|
+
right: 8px;
|
|
97
|
+
width: 28px;
|
|
98
|
+
height: 28px;
|
|
99
|
+
display: flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: center;
|
|
102
|
+
border-radius: 9999px;
|
|
103
|
+
color: rgba(255, 255, 255, 0.6);
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
}
|
|
106
|
+
.inAppBanner_closeButton__1ibpiy78:focus-visible {
|
|
107
|
+
outline: 2px solid #ffffff;
|
|
108
|
+
outline-offset: 2px;
|
|
109
|
+
}`;
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region ../../packages/design-system/src/styles/inAppBanner.css.ts
|
|
112
|
+
var body = "inAppBanner_body__1ibpiy75";
|
|
113
|
+
var closeButton = "inAppBanner_closeButton__1ibpiy78";
|
|
114
|
+
var container = "inAppBanner_container__1ibpiy71";
|
|
115
|
+
var cta = "inAppBanner_cta__1ibpiy77";
|
|
116
|
+
var description = "inAppBanner_description__1ibpiy76";
|
|
117
|
+
var header = "inAppBanner_header__1ibpiy72";
|
|
118
|
+
var iconWrapper = "inAppBanner_iconWrapper__1ibpiy73";
|
|
119
|
+
var title = "inAppBanner_title__1ibpiy74";
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region ../../packages/design-system/src/components/InAppBanner/index.tsx
|
|
122
|
+
function InAppBanner({ title: title$1, description: description$1, cta: cta$1, dismissLabel, onAction, onDismiss, className, classNames }) {
|
|
123
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
124
|
+
className: `${container}${className ? ` ${className}` : ""}`,
|
|
125
|
+
role: "alert",
|
|
126
|
+
children: [
|
|
127
|
+
/* @__PURE__ */ jsxs("div", {
|
|
128
|
+
className: header,
|
|
129
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
130
|
+
className: `${iconWrapper}${classNames?.icon ? ` ${classNames.icon}` : ""}`,
|
|
131
|
+
children: /* @__PURE__ */ jsx(WarningIcon, {
|
|
132
|
+
width: 20,
|
|
133
|
+
height: 20
|
|
134
|
+
})
|
|
135
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
136
|
+
className: `${title}${classNames?.title ? ` ${classNames.title}` : ""}`,
|
|
137
|
+
children: title$1
|
|
138
|
+
})]
|
|
139
|
+
}),
|
|
140
|
+
/* @__PURE__ */ jsxs("div", {
|
|
141
|
+
className: body,
|
|
142
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
143
|
+
className: `${description}${classNames?.description ? ` ${classNames.description}` : ""}`,
|
|
144
|
+
children: description$1
|
|
145
|
+
}), /* @__PURE__ */ jsxs("button", {
|
|
146
|
+
type: "button",
|
|
147
|
+
className: `${cta}${classNames?.cta ? ` ${classNames.cta}` : ""}`,
|
|
148
|
+
onClick: onAction,
|
|
149
|
+
children: [cta$1, /* @__PURE__ */ jsx(ExternalLinkIcon, {
|
|
150
|
+
width: 14,
|
|
151
|
+
height: 14
|
|
152
|
+
})]
|
|
153
|
+
})]
|
|
154
|
+
}),
|
|
155
|
+
/* @__PURE__ */ jsx("button", {
|
|
156
|
+
type: "button",
|
|
157
|
+
className: `${closeButton}${classNames?.close ? ` ${classNames.close}` : ""}`,
|
|
158
|
+
onClick: onDismiss,
|
|
159
|
+
"aria-label": dismissLabel,
|
|
160
|
+
children: /* @__PURE__ */ jsx(CloseCircleIcon, {
|
|
161
|
+
width: 16,
|
|
162
|
+
height: 16
|
|
163
|
+
})
|
|
164
|
+
})
|
|
165
|
+
]
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region \0ve-inline:src/components/Banner/Banner.css.ts.vanilla.js
|
|
170
|
+
const cssSource$1 = `@keyframes Banner_fadeIn__1gnumzi0 {
|
|
171
|
+
from {
|
|
172
|
+
opacity: 0;
|
|
173
|
+
transform: translateY(-4px);
|
|
174
|
+
}
|
|
175
|
+
to {
|
|
176
|
+
opacity: 1;
|
|
177
|
+
transform: translateY(0);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
.Banner_rootBase__1gnumzi1 {
|
|
181
|
+
position: relative;
|
|
182
|
+
display: flex;
|
|
183
|
+
animation: Banner_fadeIn__1gnumzi0 300ms ease-out;
|
|
184
|
+
}
|
|
185
|
+
.Banner_iconSvg__1gnumzi2 {
|
|
186
|
+
width: 100%;
|
|
187
|
+
height: 100%;
|
|
188
|
+
}
|
|
189
|
+
.Banner_referral__1gnumzi3 {
|
|
190
|
+
flex-direction: row;
|
|
191
|
+
align-items: center;
|
|
192
|
+
gap: 16px;
|
|
193
|
+
padding: 16px;
|
|
194
|
+
background-color: #ffffff;
|
|
195
|
+
color: var(--text-primary__pbq4ak0);
|
|
196
|
+
border: 1px solid var(--border-default__pbq4akv);
|
|
197
|
+
border-radius: 12px;
|
|
198
|
+
}
|
|
199
|
+
.Banner_referralIconWrapper__1gnumzi4 {
|
|
200
|
+
flex-shrink: 0;
|
|
201
|
+
align-self: flex-start;
|
|
202
|
+
display: flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
justify-content: center;
|
|
205
|
+
width: 40px;
|
|
206
|
+
height: 40px;
|
|
207
|
+
overflow: hidden;
|
|
208
|
+
}
|
|
209
|
+
.Banner_referralImage__1gnumzi5 {
|
|
210
|
+
max-width: 100%;
|
|
211
|
+
max-height: 100%;
|
|
212
|
+
width: auto;
|
|
213
|
+
height: auto;
|
|
214
|
+
object-fit: contain;
|
|
215
|
+
display: block;
|
|
216
|
+
}
|
|
217
|
+
.Banner_referralBody__1gnumzi6 {
|
|
218
|
+
flex: 1;
|
|
219
|
+
min-width: 0;
|
|
220
|
+
}
|
|
221
|
+
.Banner_referralTitle__1gnumzi7 {
|
|
222
|
+
font-size: 16px;
|
|
223
|
+
font-weight: 600;
|
|
224
|
+
color: var(--text-primary__pbq4ak0);
|
|
225
|
+
line-height: 22px;
|
|
226
|
+
}
|
|
227
|
+
.Banner_referralDescription__1gnumzi8 {
|
|
228
|
+
margin-bottom: 8px;
|
|
229
|
+
font-size: 14px;
|
|
230
|
+
color: #979797;
|
|
231
|
+
line-height: 22px;
|
|
232
|
+
}
|
|
233
|
+
.Banner_referralCta__1gnumzi9 {
|
|
234
|
+
display: inline-block;
|
|
235
|
+
padding: 8px 16px;
|
|
236
|
+
border: 1px solid #000000;
|
|
237
|
+
border-radius: 9999px;
|
|
238
|
+
color: var(--text-primary__pbq4ak0);
|
|
239
|
+
font-size: 10px;
|
|
240
|
+
font-weight: 700;
|
|
241
|
+
line-height: 12px;
|
|
242
|
+
text-transform: uppercase;
|
|
243
|
+
}
|
|
244
|
+
.Banner_frakLogo__1gnumzia {
|
|
245
|
+
position: absolute;
|
|
246
|
+
right: 16px;
|
|
247
|
+
bottom: 12px;
|
|
248
|
+
pointer-events: none;
|
|
249
|
+
}`;
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region src/components/Banner/Banner.css.ts
|
|
252
|
+
var frakLogo = "Banner_frakLogo__1gnumzia";
|
|
253
|
+
var iconSvg = "Banner_iconSvg__1gnumzi2";
|
|
254
|
+
var referral = "Banner_referral__1gnumzi3 reset_base__1831jhd0 Banner_rootBase__1gnumzi1";
|
|
255
|
+
var referralBody = "Banner_referralBody__1gnumzi6";
|
|
256
|
+
var referralCta = "Banner_referralCta__1gnumzi9 sharedBaseCss_buttonReset__7cswil0";
|
|
257
|
+
var referralDescription = "Banner_referralDescription__1gnumzi8 reset_base__1831jhd0";
|
|
258
|
+
var referralIconWrapper = "Banner_referralIconWrapper__1gnumzi4";
|
|
259
|
+
var referralImage = "Banner_referralImage__1gnumzi5";
|
|
260
|
+
var referralTitle = "Banner_referralTitle__1gnumzi7 reset_base__1831jhd0";
|
|
261
|
+
const cssSource = cssSource$2 + cssSource$1;
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/components/Banner/Banner.tsx
|
|
264
|
+
/**
|
|
265
|
+
* Auto-detecting notification banner component.
|
|
266
|
+
*
|
|
267
|
+
* Renders an inline banner on the merchant page with one of two distinct
|
|
268
|
+
* visual styles depending on the detected mode:
|
|
269
|
+
*
|
|
270
|
+
* - **Referral mode** (white): Shown after a successful referral link
|
|
271
|
+
* processing. Displays a gift icon, reward copy, and a "Got it" CTA.
|
|
272
|
+
* - **In-app browser mode** (dark transparent): Shown when the page is
|
|
273
|
+
* opened inside a social media in-app browser (Instagram, Facebook).
|
|
274
|
+
* Offers an inline link to redirect to the default browser plus a
|
|
275
|
+
* close button to dismiss.
|
|
276
|
+
*
|
|
277
|
+
* In-app browser mode takes priority over referral mode.
|
|
278
|
+
* Uses Light DOM + vanilla-extract styles from `@frak-labs/design-system`.
|
|
279
|
+
*
|
|
280
|
+
* @group components
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* Basic usage (auto-detects mode):
|
|
284
|
+
* ```html
|
|
285
|
+
* <frak-banner></frak-banner>
|
|
286
|
+
* ```
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* With a custom class:
|
|
290
|
+
* ```html
|
|
291
|
+
* <frak-banner classname="my-custom-banner"></frak-banner>
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
function Banner({ placement: placementId, classname = "", interaction, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, imageUrl, preview, previewMode }) {
|
|
295
|
+
const isPreview = !!preview;
|
|
296
|
+
const resolvedPreviewMode = previewMode === "inapp" ? "inapp" : "referral";
|
|
297
|
+
const placement = usePlacement(placementId);
|
|
298
|
+
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
299
|
+
useLightDomStyles("frak-banner", placementId, placement?.components?.banner?.css, cssSource, cssSource$3);
|
|
300
|
+
const [dismissed, setDismissed] = useState(false);
|
|
301
|
+
const [mode, setMode] = useState(() => {
|
|
302
|
+
if (isPreview) return resolvedPreviewMode;
|
|
303
|
+
return isInAppBrowser ? "inapp" : null;
|
|
304
|
+
});
|
|
305
|
+
const trackedImpressionModeRef = useRef(null);
|
|
306
|
+
useEffect(() => {
|
|
307
|
+
if (isPreview) setMode(resolvedPreviewMode);
|
|
308
|
+
}, [isPreview, resolvedPreviewMode]);
|
|
309
|
+
const { reward } = useReward(mode === "referral" && isClientReady, interaction);
|
|
310
|
+
const [prefetchedMergeToken, setPrefetchedMergeToken] = useState(null);
|
|
311
|
+
useEffect(() => {
|
|
312
|
+
const client = window.FrakSetup?.client;
|
|
313
|
+
if (mode !== "inapp" || isPreview || !isClientReady || !client) return;
|
|
314
|
+
getMergeToken(client).then((token) => setPrefetchedMergeToken(token)).catch(() => {});
|
|
315
|
+
}, [
|
|
316
|
+
mode,
|
|
317
|
+
isPreview,
|
|
318
|
+
isClientReady
|
|
319
|
+
]);
|
|
320
|
+
useEffect(() => {
|
|
321
|
+
if (isPreview || !mode || dismissed) return;
|
|
322
|
+
if (trackedImpressionModeRef.current === mode) return;
|
|
323
|
+
if (!isClientReady) return;
|
|
324
|
+
trackEvent(window.FrakSetup?.client, "banner_impression", {
|
|
325
|
+
placement: placementId,
|
|
326
|
+
variant: mode,
|
|
327
|
+
has_reward: mode === "referral" ? Boolean(reward) : void 0
|
|
328
|
+
});
|
|
329
|
+
trackedImpressionModeRef.current = mode;
|
|
330
|
+
}, [
|
|
331
|
+
mode,
|
|
332
|
+
dismissed,
|
|
333
|
+
isClientReady,
|
|
334
|
+
isPreview,
|
|
335
|
+
placementId
|
|
336
|
+
]);
|
|
337
|
+
useEffect(() => {
|
|
338
|
+
if (isPreview || mode === "inapp") return;
|
|
339
|
+
const handler = () => setMode("referral");
|
|
340
|
+
window.addEventListener(REFERRAL_SUCCESS_EVENT, handler);
|
|
341
|
+
return () => window.removeEventListener(REFERRAL_SUCCESS_EVENT, handler);
|
|
342
|
+
}, [isPreview, mode]);
|
|
343
|
+
const handleAction = useCallback(async () => {
|
|
344
|
+
if (isPreview) return;
|
|
345
|
+
trackEvent(window.FrakSetup?.client, "banner_resolved", {
|
|
346
|
+
placement: placementId,
|
|
347
|
+
variant: mode ?? "referral",
|
|
348
|
+
outcome: "clicked"
|
|
349
|
+
});
|
|
350
|
+
if (mode === "referral") {
|
|
351
|
+
setDismissed(true);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
let mergeToken = prefetchedMergeToken;
|
|
355
|
+
if (!mergeToken && window.FrakSetup?.client) try {
|
|
356
|
+
mergeToken = await getMergeToken(window.FrakSetup?.client);
|
|
357
|
+
} catch {}
|
|
358
|
+
let targetUrl = window.location.href;
|
|
359
|
+
if (mergeToken) {
|
|
360
|
+
const url = new URL(targetUrl);
|
|
361
|
+
url.searchParams.set("fmt", mergeToken);
|
|
362
|
+
targetUrl = url.toString();
|
|
363
|
+
}
|
|
364
|
+
redirectToExternalBrowser(targetUrl);
|
|
365
|
+
}, [
|
|
366
|
+
isPreview,
|
|
367
|
+
mode,
|
|
368
|
+
prefetchedMergeToken,
|
|
369
|
+
placementId
|
|
370
|
+
]);
|
|
371
|
+
const handleDismiss = useCallback(() => {
|
|
372
|
+
if (isPreview) return;
|
|
373
|
+
trackEvent(window.FrakSetup?.client, "banner_resolved", {
|
|
374
|
+
placement: placementId,
|
|
375
|
+
variant: mode ?? "referral",
|
|
376
|
+
outcome: "dismissed"
|
|
377
|
+
});
|
|
378
|
+
setDismissed(true);
|
|
379
|
+
}, [
|
|
380
|
+
isPreview,
|
|
381
|
+
mode,
|
|
382
|
+
placementId
|
|
383
|
+
]);
|
|
384
|
+
const globalComponents = useGlobalComponents();
|
|
385
|
+
const bannerConfig = placement?.components?.banner ?? globalComponents?.banner;
|
|
386
|
+
const texts = useMemo(() => {
|
|
387
|
+
if (mode === "referral") {
|
|
388
|
+
const defaultTitle = reward ? `Earn ${reward} on purchases on this site` : "You've been referred!";
|
|
389
|
+
return {
|
|
390
|
+
title: propReferralTitle ?? bannerConfig?.referralTitle ?? defaultTitle,
|
|
391
|
+
description: propReferralDescription ?? bannerConfig?.referralDescription ?? "Earn rewards after your purchase via the Frak partner app.",
|
|
392
|
+
cta: propReferralCta ?? bannerConfig?.referralCta ?? "Got it"
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
return {
|
|
396
|
+
title: propInappTitle ?? bannerConfig?.inappTitle ?? "Open in your browser",
|
|
397
|
+
description: propInappDescription ?? bannerConfig?.inappDescription ?? "For a better experience and to earn your rewards, open this page in your default browser.",
|
|
398
|
+
cta: propInappCta ?? bannerConfig?.inappCta ?? "Open browser"
|
|
399
|
+
};
|
|
400
|
+
}, [
|
|
401
|
+
mode,
|
|
402
|
+
reward,
|
|
403
|
+
bannerConfig,
|
|
404
|
+
propReferralTitle,
|
|
405
|
+
propReferralDescription,
|
|
406
|
+
propReferralCta,
|
|
407
|
+
propInappTitle,
|
|
408
|
+
propInappDescription,
|
|
409
|
+
propInappCta
|
|
410
|
+
]);
|
|
411
|
+
if (!mode || !isPreview && (!shouldRender || isHidden || dismissed)) return null;
|
|
412
|
+
const bannerClass = [
|
|
413
|
+
referral,
|
|
414
|
+
"frak-banner",
|
|
415
|
+
`frak-banner--${mode}`,
|
|
416
|
+
classname
|
|
417
|
+
].filter(Boolean).join(" ");
|
|
418
|
+
if (mode === "inapp") return /* @__PURE__ */ jsx(InAppBanner, {
|
|
419
|
+
title: texts.title,
|
|
420
|
+
description: texts.description,
|
|
421
|
+
cta: texts.cta,
|
|
422
|
+
dismissLabel: "Dismiss",
|
|
423
|
+
onAction: handleAction,
|
|
424
|
+
onDismiss: handleDismiss,
|
|
425
|
+
className: [
|
|
426
|
+
"frak-banner",
|
|
427
|
+
"frak-banner--inapp",
|
|
428
|
+
classname
|
|
429
|
+
].filter(Boolean).join(" "),
|
|
430
|
+
classNames: {
|
|
431
|
+
icon: "frak-banner__icon",
|
|
432
|
+
title: "frak-banner__title",
|
|
433
|
+
description: "frak-banner__description",
|
|
434
|
+
cta: "frak-banner__cta",
|
|
435
|
+
close: "frak-banner__close"
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
439
|
+
class: bannerClass,
|
|
440
|
+
role: "alert",
|
|
441
|
+
children: [
|
|
442
|
+
/* @__PURE__ */ jsx("div", {
|
|
443
|
+
class: `${referralIconWrapper} frak-banner__icon`,
|
|
444
|
+
children: imageUrl ? /* @__PURE__ */ jsx("img", {
|
|
445
|
+
src: imageUrl,
|
|
446
|
+
alt: "",
|
|
447
|
+
class: referralImage
|
|
448
|
+
}) : /* @__PURE__ */ jsx(GiftIcon, { class: iconSvg })
|
|
449
|
+
}),
|
|
450
|
+
/* @__PURE__ */ jsxs("div", {
|
|
451
|
+
class: `${referralBody} frak-banner__text`,
|
|
452
|
+
children: [
|
|
453
|
+
/* @__PURE__ */ jsx("p", {
|
|
454
|
+
class: `${referralTitle} frak-banner__title`,
|
|
455
|
+
children: texts.title
|
|
456
|
+
}),
|
|
457
|
+
/* @__PURE__ */ jsx("p", {
|
|
458
|
+
class: `${referralDescription} frak-banner__description`,
|
|
459
|
+
children: texts.description
|
|
460
|
+
}),
|
|
461
|
+
/* @__PURE__ */ jsx("button", {
|
|
462
|
+
type: "button",
|
|
463
|
+
class: `${referralCta} frak-banner__cta`,
|
|
464
|
+
onClick: handleAction,
|
|
465
|
+
children: texts.cta
|
|
466
|
+
})
|
|
467
|
+
]
|
|
468
|
+
}),
|
|
469
|
+
/* @__PURE__ */ jsx(LogoFrakWithName, {
|
|
470
|
+
class: `${frakLogo} frak-banner__logo`,
|
|
471
|
+
width: 42,
|
|
472
|
+
height: 24
|
|
473
|
+
})
|
|
474
|
+
]
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region src/components/Banner/index.ts
|
|
479
|
+
registerWebComponent(Banner, "frak-banner", [
|
|
480
|
+
"placement",
|
|
481
|
+
"classname",
|
|
482
|
+
"interaction",
|
|
483
|
+
"referralTitle",
|
|
484
|
+
"referralDescription",
|
|
485
|
+
"referralCta",
|
|
486
|
+
"inappTitle",
|
|
487
|
+
"inappDescription",
|
|
488
|
+
"inappCta",
|
|
489
|
+
"preview",
|
|
490
|
+
"previewMode",
|
|
491
|
+
"imageUrl"
|
|
492
|
+
], { shadow: false });
|
|
493
|
+
//#endregion
|
|
494
|
+
export { Banner };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { InteractionTypeKey } from "@frak-labs/core-sdk";
|
|
2
|
+
import * as _$preact from "preact";
|
|
3
|
+
|
|
4
|
+
//#region src/components/ButtonShare/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The props type for {@link ButtonShare}.
|
|
7
|
+
* @inline
|
|
8
|
+
*/
|
|
9
|
+
type ButtonShareProps = {
|
|
10
|
+
placement?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Text to display on the button
|
|
13
|
+
* - To specify where the reward should be displayed, use the placeholder `{REWARD}`, e.g. `Share and earn up to \{REWARD\}!`
|
|
14
|
+
* @defaultValue `"Share and earn!"`
|
|
15
|
+
*/
|
|
16
|
+
text?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Classname to apply to the button
|
|
19
|
+
*/
|
|
20
|
+
classname?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Do we display the reward on the share modal?
|
|
23
|
+
* @defaultValue `false`
|
|
24
|
+
*/
|
|
25
|
+
useReward?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Fallback text if the reward isn't found
|
|
28
|
+
*/
|
|
29
|
+
noRewardText?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Target interaction behind this sharing action (will be used to get the right reward to display)
|
|
32
|
+
*/
|
|
33
|
+
targetInteraction?: InteractionTypeKey;
|
|
34
|
+
/**
|
|
35
|
+
* Which UI to open on click.
|
|
36
|
+
*
|
|
37
|
+
* Legacy values (e.g. `"share-modal"`) are accepted at runtime and
|
|
38
|
+
* gracefully route to the full-page sharing UI — the modal-flow
|
|
39
|
+
* share path was retired in favour of `displaySharingPage`.
|
|
40
|
+
*
|
|
41
|
+
* @defaultValue `"sharing-page"`
|
|
42
|
+
*/
|
|
43
|
+
clickAction?: "embedded-wallet" | "sharing-page";
|
|
44
|
+
/**
|
|
45
|
+
* When set, renders the button in preview mode (e.g. Shopify/WP editor).
|
|
46
|
+
* Skips the client-ready gating so the button is always enabled visually,
|
|
47
|
+
* and no-ops the click handler so merchants can see the final layout with
|
|
48
|
+
* their configured copy even when no Frak client is initialized.
|
|
49
|
+
*/
|
|
50
|
+
preview?: string;
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/components/ButtonShare/ButtonShare.d.ts
|
|
54
|
+
/**
|
|
55
|
+
* Button to share the current page
|
|
56
|
+
*
|
|
57
|
+
* @param args
|
|
58
|
+
* @returns The share button with `<button>` tag
|
|
59
|
+
*
|
|
60
|
+
* @group components
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* Basic usage:
|
|
64
|
+
* ```html
|
|
65
|
+
* <frak-button-share></frak-button-share>
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* Using a custom text:
|
|
70
|
+
* ```html
|
|
71
|
+
* <frak-button-share text="Share and earn!"></frak-button-share>
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* Using a custom class:
|
|
76
|
+
* ```html
|
|
77
|
+
* <frak-button-share classname="button button-primary"></frak-button-share>
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* Using reward information and fallback text:
|
|
82
|
+
* ```html
|
|
83
|
+
* <frak-button-share use-reward text="Share and earn up to {REWARD}!" no-reward-text="Share and earn!"></frak-button-share>
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* Using reward information for specific reward and fallback text:
|
|
88
|
+
* ```html
|
|
89
|
+
* <frak-button-share use-reward text="Share and earn up to {REWARD}!" no-reward-text="Share and earn!" target-interaction="custom.customerMeeting"></frak-button-share>
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @see {@link @frak-labs/core-sdk!actions.displaySharingPage | `displaySharingPage()`} for more info about the sharing-page flow
|
|
93
|
+
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the estimated reward fetching
|
|
94
|
+
*/
|
|
95
|
+
declare function ButtonShare({
|
|
96
|
+
placement: placementId,
|
|
97
|
+
text,
|
|
98
|
+
classname,
|
|
99
|
+
useReward: rawUseReward,
|
|
100
|
+
noRewardText,
|
|
101
|
+
targetInteraction,
|
|
102
|
+
clickAction: rawClickAction,
|
|
103
|
+
preview
|
|
104
|
+
}: ButtonShareProps): _$preact.JSX.Element | null;
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/components/ButtonShare/index.d.ts
|
|
107
|
+
/**
|
|
108
|
+
* Custom element interface for `<frak-button-share>`.
|
|
109
|
+
* Combines standard {@link HTMLElement} with {@link ButtonShareProps}.
|
|
110
|
+
*/
|
|
111
|
+
interface ButtonShareElement extends HTMLElement, ButtonShareProps {}
|
|
112
|
+
declare global {
|
|
113
|
+
interface HTMLElementTagNameMap {
|
|
114
|
+
"frak-button-share": ButtonShareElement;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { ButtonShare, ButtonShareElement };
|