@frak-labs/components 0.0.26-beta.d04602ec → 0.0.26-beta.eb3cff34
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.Ws9o79lU.js +64 -0
- package/cdn/ButtonShare.BDS1fgma.js +1 -0
- package/cdn/ButtonWallet.Be1UyRm8.js +40 -0
- package/cdn/OpenInAppButton.Diqt07eo.js +1 -0
- package/cdn/PostPurchase.DqFhm-Jn.js +52 -0
- package/cdn/components.js +1 -1
- package/cdn/formatReward.CXxVsWN3.js +1 -0
- package/cdn/loader.js +3 -55
- package/cdn/sprinkles.css.ts.vanilla.BtFkD4B3.js +1175 -0
- package/cdn/useGlobalComponents.BRe8dKO7.js +1 -0
- package/cdn/useLightDomStyles.ZFa154u8.js +1 -0
- package/cdn/usePlacement.B7jMsQvP.js +58 -0
- package/cdn/useReward.qEKeySJG.js +1 -0
- package/cdn/useShareModal.B--64ELG.js +1 -0
- package/dist/GiftIcon-4sr9xXyq.js +1501 -0
- package/dist/banner.d.ts +24 -11
- package/dist/banner.js +347 -103
- package/dist/buttonShare.d.ts +2 -2
- package/dist/buttonShare.js +11 -14
- package/dist/buttonWallet.d.ts +2 -2
- package/dist/buttonWallet.js +3 -7
- package/dist/{formatReward-6JQldDEC.js → formatReward-Bub6Z6eY.js} +8 -3
- package/dist/openInApp.d.ts +2 -2
- package/dist/openInApp.js +3 -9
- package/dist/postPurchase.d.ts +8 -2
- package/dist/postPurchase.js +1464 -31
- package/dist/useGlobalComponents-Cmfszr7v.js +21 -0
- package/dist/{useLightDomStyles-DukxuNnJ.js → useLightDomStyles-hgYYZsTy.js} +2 -5
- package/dist/{usePlacement-BbMuz8_A.js → usePlacement-LqYjZLX_.js} +1 -93
- package/dist/{useReward-CI2yRrCj.js → useReward-DU3_yP8Q.js} +2 -4
- package/dist/{useShareModal-DHlayNqk.js → useShareModal-DgEf5WWG.js} +1 -3
- package/package.json +13 -9
- package/cdn/Banner.BfkMel9Q.js +0 -1
- package/cdn/ButtonShare.BM9Inhmf.js +0 -1
- package/cdn/ButtonWallet.B7UmJcbb.js +0 -40
- package/cdn/OpenInAppButton.B4mrsz6L.js +0 -1
- package/cdn/PostPurchase.BIc0C4Ma.js +0 -1
- package/cdn/formatReward.C8hlSKRj.js +0 -1
- package/cdn/jsxRuntime.module.5UNmmhNi.js +0 -138
- package/cdn/useLightDomStyles.D895e4W1.js +0 -1
- package/cdn/useReward.DEU0AF3P.js +0 -1
- package/cdn/useShareModal.CN9_P7Sl.js +0 -1
package/dist/banner.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InteractionTypeKey } from "@frak-labs/core-sdk";
|
|
2
|
-
import * as preact from "preact";
|
|
2
|
+
import * as _$preact from "preact";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Banner/types.d.ts
|
|
5
5
|
/**
|
|
@@ -44,23 +44,34 @@ type BannerProps = {
|
|
|
44
44
|
* Override the in-app browser banner CTA button text.
|
|
45
45
|
*/
|
|
46
46
|
inappCta?: string;
|
|
47
|
+
/**
|
|
48
|
+
* When set, forces the banner to render in preview mode (e.g. in Shopify theme editor).
|
|
49
|
+
* Bypasses normal event/browser detection and shows static content.
|
|
50
|
+
*/
|
|
51
|
+
preview?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Which banner variant to preview: "referral" or "inapp".
|
|
54
|
+
* Only used when {@link preview} is set. Defaults to "referral".
|
|
55
|
+
*/
|
|
56
|
+
previewMode?: "referral" | "inapp";
|
|
47
57
|
};
|
|
48
58
|
//#endregion
|
|
49
59
|
//#region src/components/Banner/Banner.d.ts
|
|
50
60
|
/**
|
|
51
61
|
* Auto-detecting notification banner component.
|
|
52
62
|
*
|
|
53
|
-
* Renders an inline banner on the merchant page
|
|
54
|
-
*
|
|
63
|
+
* Renders an inline banner on the merchant page with one of two distinct
|
|
64
|
+
* visual styles depending on the detected mode:
|
|
55
65
|
*
|
|
56
|
-
* - **Referral mode
|
|
57
|
-
* Displays reward
|
|
58
|
-
* - **In-app browser mode
|
|
59
|
-
* media in-app browser (Instagram, Facebook).
|
|
60
|
-
* default browser
|
|
66
|
+
* - **Referral mode** (white): Shown after a successful referral link
|
|
67
|
+
* processing. Displays a gift icon, reward copy, and a "Got it" CTA.
|
|
68
|
+
* - **In-app browser mode** (dark transparent): Shown when the page is
|
|
69
|
+
* opened inside a social media in-app browser (Instagram, Facebook).
|
|
70
|
+
* Offers an inline link to redirect to the default browser plus a
|
|
71
|
+
* close button to dismiss.
|
|
61
72
|
*
|
|
62
73
|
* In-app browser mode takes priority over referral mode.
|
|
63
|
-
* Uses Light DOM
|
|
74
|
+
* Uses Light DOM + vanilla-extract styles from `@frak-labs/design-system`.
|
|
64
75
|
*
|
|
65
76
|
* @group components
|
|
66
77
|
*
|
|
@@ -85,8 +96,10 @@ declare function Banner({
|
|
|
85
96
|
referralCta: propReferralCta,
|
|
86
97
|
inappTitle: propInappTitle,
|
|
87
98
|
inappDescription: propInappDescription,
|
|
88
|
-
inappCta: propInappCta
|
|
89
|
-
|
|
99
|
+
inappCta: propInappCta,
|
|
100
|
+
preview,
|
|
101
|
+
previewMode
|
|
102
|
+
}: BannerProps): _$preact.JSX.Element | null;
|
|
90
103
|
//#endregion
|
|
91
104
|
//#region src/components/Banner/index.d.ts
|
|
92
105
|
/**
|
package/dist/banner.js
CHANGED
|
@@ -1,83 +1,264 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, t as usePlacement } from "./usePlacement-LqYjZLX_.js";
|
|
2
|
+
import { t as useGlobalComponents } from "./useGlobalComponents-Cmfszr7v.js";
|
|
3
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-hgYYZsTy.js";
|
|
4
|
+
import { t as useReward } from "./useReward-DU3_yP8Q.js";
|
|
5
|
+
import { a as CloseCircleIcon, c as cssSource$5, i as ExternalLinkIcon, n as WarningIcon, o as cssSource$6, s as cssSource$4, t as GiftIcon } from "./GiftIcon-4sr9xXyq.js";
|
|
4
6
|
import { isInAppBrowser, redirectToExternalBrowser } from "@frak-labs/core-sdk";
|
|
5
|
-
import { REFERRAL_SUCCESS_EVENT } from "@frak-labs/core-sdk/actions";
|
|
7
|
+
import { REFERRAL_SUCCESS_EVENT, getMergeToken } from "@frak-labs/core-sdk/actions";
|
|
6
8
|
import { useCallback, useEffect, useMemo, useState } from "preact/hooks";
|
|
7
9
|
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
//#region \0ve-inline:../../packages/design-system/src/styles/inAppBanner.css.ts.vanilla.js
|
|
11
|
+
const cssSource$3 = `@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
|
+
cssSource$4 + cssSource$3;
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region ../../packages/design-system/src/components/InAppBanner/index.tsx
|
|
123
|
+
function InAppBanner({ title: title$1, description: description$1, cta: cta$1, dismissLabel, onAction, onDismiss, className, classNames }) {
|
|
124
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
125
|
+
className: `${container}${className ? ` ${className}` : ""}`,
|
|
126
|
+
role: "alert",
|
|
22
127
|
children: [
|
|
23
|
-
/* @__PURE__ */
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
128
|
+
/* @__PURE__ */ jsxs("div", {
|
|
129
|
+
className: header,
|
|
130
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
131
|
+
className: `${iconWrapper}${classNames?.icon ? ` ${classNames.icon}` : ""}`,
|
|
132
|
+
children: /* @__PURE__ */ jsx(WarningIcon, {
|
|
133
|
+
width: 20,
|
|
134
|
+
height: 20
|
|
135
|
+
})
|
|
136
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
137
|
+
className: `${title}${classNames?.title ? ` ${classNames.title}` : ""}`,
|
|
138
|
+
children: title$1
|
|
139
|
+
})]
|
|
29
140
|
}),
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
141
|
+
/* @__PURE__ */ jsxs("div", {
|
|
142
|
+
className: body,
|
|
143
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
144
|
+
className: `${description}${classNames?.description ? ` ${classNames.description}` : ""}`,
|
|
145
|
+
children: description$1
|
|
146
|
+
}), /* @__PURE__ */ jsxs("button", {
|
|
147
|
+
type: "button",
|
|
148
|
+
className: `${cta}${classNames?.cta ? ` ${classNames.cta}` : ""}`,
|
|
149
|
+
onClick: onAction,
|
|
150
|
+
children: [cta$1, /* @__PURE__ */ jsx(ExternalLinkIcon, {
|
|
151
|
+
width: 14,
|
|
152
|
+
height: 14
|
|
153
|
+
})]
|
|
154
|
+
})]
|
|
37
155
|
}),
|
|
38
|
-
/* @__PURE__ */ jsx("
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return /* @__PURE__ */ jsxs("svg", {
|
|
48
|
-
viewBox: "0 0 24 24",
|
|
49
|
-
fill: "none",
|
|
50
|
-
stroke: "currentColor",
|
|
51
|
-
"stroke-width": "1.5",
|
|
52
|
-
"stroke-linecap": "round",
|
|
53
|
-
"stroke-linejoin": "round",
|
|
54
|
-
"aria-hidden": "true",
|
|
55
|
-
children: [
|
|
56
|
-
/* @__PURE__ */ jsx("path", { d: "M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6" }),
|
|
57
|
-
/* @__PURE__ */ jsx("polyline", { points: "15 3 21 3 21 9" }),
|
|
58
|
-
/* @__PURE__ */ jsx("line", {
|
|
59
|
-
x1: "10",
|
|
60
|
-
y1: "14",
|
|
61
|
-
x2: "21",
|
|
62
|
-
y2: "3"
|
|
156
|
+
/* @__PURE__ */ jsx("button", {
|
|
157
|
+
type: "button",
|
|
158
|
+
className: `${closeButton}${classNames?.close ? ` ${classNames.close}` : ""}`,
|
|
159
|
+
onClick: onDismiss,
|
|
160
|
+
"aria-label": dismissLabel,
|
|
161
|
+
children: /* @__PURE__ */ jsx(CloseCircleIcon, {
|
|
162
|
+
width: 16,
|
|
163
|
+
height: 16
|
|
164
|
+
})
|
|
63
165
|
})
|
|
64
166
|
]
|
|
65
167
|
});
|
|
66
168
|
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region \0ve-inline:src/components/Banner/Banner.css.ts.vanilla.js
|
|
171
|
+
const cssSource$1 = `@keyframes Banner_fadeIn__1gnumzi0 {
|
|
172
|
+
from {
|
|
173
|
+
opacity: 0;
|
|
174
|
+
transform: translateY(-4px);
|
|
175
|
+
}
|
|
176
|
+
to {
|
|
177
|
+
opacity: 1;
|
|
178
|
+
transform: translateY(0);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
.Banner_rootBase__1gnumzi1 {
|
|
182
|
+
position: relative;
|
|
183
|
+
display: flex;
|
|
184
|
+
animation: Banner_fadeIn__1gnumzi0 300ms ease-out;
|
|
185
|
+
}
|
|
186
|
+
.Banner_iconSvg__1gnumzi2 {
|
|
187
|
+
width: 100%;
|
|
188
|
+
height: 100%;
|
|
189
|
+
}
|
|
190
|
+
.Banner_referral__1gnumzi3 {
|
|
191
|
+
flex-direction: row;
|
|
192
|
+
align-items: center;
|
|
193
|
+
gap: 16px;
|
|
194
|
+
padding: 16px;
|
|
195
|
+
background-color: #ffffff;
|
|
196
|
+
color: var(--text-primary__pbq4ak0);
|
|
197
|
+
}
|
|
198
|
+
.Banner_referralIconWrapper__1gnumzi4 {
|
|
199
|
+
flex-shrink: 0;
|
|
200
|
+
align-self: flex-start;
|
|
201
|
+
width: 40px;
|
|
202
|
+
height: 40px;
|
|
203
|
+
}
|
|
204
|
+
.Banner_referralBody__1gnumzi5 {
|
|
205
|
+
flex: 1;
|
|
206
|
+
min-width: 0;
|
|
207
|
+
}
|
|
208
|
+
.Banner_referralTitle__1gnumzi6 {
|
|
209
|
+
font-size: 16px;
|
|
210
|
+
font-weight: 600;
|
|
211
|
+
color: var(--text-primary__pbq4ak0);
|
|
212
|
+
line-height: 22px;
|
|
213
|
+
}
|
|
214
|
+
.Banner_referralDescription__1gnumzi7 {
|
|
215
|
+
margin-bottom: 8px;
|
|
216
|
+
font-size: 14px;
|
|
217
|
+
color: #979797;
|
|
218
|
+
line-height: 22px;
|
|
219
|
+
}
|
|
220
|
+
.Banner_referralCta__1gnumzi8 {
|
|
221
|
+
display: inline-block;
|
|
222
|
+
padding: 8px 16px;
|
|
223
|
+
border: 1px solid #000000;
|
|
224
|
+
border-radius: 9999px;
|
|
225
|
+
color: var(--text-primary__pbq4ak0);
|
|
226
|
+
font-size: 10px;
|
|
227
|
+
font-weight: 700;
|
|
228
|
+
line-height: 12px;
|
|
229
|
+
text-transform: uppercase;
|
|
230
|
+
}
|
|
231
|
+
.Banner_referralCta__1gnumzi8:focus-visible {
|
|
232
|
+
outline: 2px solid #000000;
|
|
233
|
+
outline-offset: 2px;
|
|
234
|
+
}`;
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/components/Banner/Banner.css.ts
|
|
237
|
+
var iconSvg = "Banner_iconSvg__1gnumzi2";
|
|
238
|
+
var referral = "Banner_referral__1gnumzi3 reset_base__1831jhd0 Banner_rootBase__1gnumzi1";
|
|
239
|
+
var referralBody = "Banner_referralBody__1gnumzi5";
|
|
240
|
+
var referralCta = "Banner_referralCta__1gnumzi8 reset_element_button__1831jhd6 reset_fieldAppearance__1831jhd2 reset_focusRing__1831jhd1";
|
|
241
|
+
var referralDescription = "Banner_referralDescription__1gnumzi7 reset_base__1831jhd0";
|
|
242
|
+
var referralIconWrapper = "Banner_referralIconWrapper__1gnumzi4";
|
|
243
|
+
var referralTitle = "Banner_referralTitle__1gnumzi6 reset_base__1831jhd0";
|
|
244
|
+
const cssSource = cssSource$5 + cssSource$4 + cssSource$6 + cssSource$1;
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/components/Banner/Banner.tsx
|
|
67
247
|
/**
|
|
68
248
|
* Auto-detecting notification banner component.
|
|
69
249
|
*
|
|
70
|
-
* Renders an inline banner on the merchant page
|
|
71
|
-
*
|
|
250
|
+
* Renders an inline banner on the merchant page with one of two distinct
|
|
251
|
+
* visual styles depending on the detected mode:
|
|
72
252
|
*
|
|
73
|
-
* - **Referral mode
|
|
74
|
-
* Displays reward
|
|
75
|
-
* - **In-app browser mode
|
|
76
|
-
* media in-app browser (Instagram, Facebook).
|
|
77
|
-
* default browser
|
|
253
|
+
* - **Referral mode** (white): Shown after a successful referral link
|
|
254
|
+
* processing. Displays a gift icon, reward copy, and a "Got it" CTA.
|
|
255
|
+
* - **In-app browser mode** (dark transparent): Shown when the page is
|
|
256
|
+
* opened inside a social media in-app browser (Instagram, Facebook).
|
|
257
|
+
* Offers an inline link to redirect to the default browser plus a
|
|
258
|
+
* close button to dismiss.
|
|
78
259
|
*
|
|
79
260
|
* In-app browser mode takes priority over referral mode.
|
|
80
|
-
* Uses Light DOM
|
|
261
|
+
* Uses Light DOM + vanilla-extract styles from `@frak-labs/design-system`.
|
|
81
262
|
*
|
|
82
263
|
* @group components
|
|
83
264
|
*
|
|
@@ -93,24 +274,65 @@ function BrowserIcon() {
|
|
|
93
274
|
* <frak-banner classname="my-custom-banner"></frak-banner>
|
|
94
275
|
* ```
|
|
95
276
|
*/
|
|
96
|
-
function Banner({ placement: placementId, classname = "", interaction, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta }) {
|
|
277
|
+
function Banner({ placement: placementId, classname = "", interaction, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, preview, previewMode }) {
|
|
278
|
+
const isPreview = !!preview;
|
|
279
|
+
const resolvedPreviewMode = previewMode === "inapp" ? "inapp" : "referral";
|
|
97
280
|
const placement = usePlacement(placementId);
|
|
98
281
|
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
99
|
-
useLightDomStyles("frak-banner", placementId, placement?.components?.banner?.css,
|
|
282
|
+
useLightDomStyles("frak-banner", placementId, placement?.components?.banner?.css, cssSource);
|
|
100
283
|
const [dismissed, setDismissed] = useState(false);
|
|
101
|
-
const [mode, setMode] = useState(() =>
|
|
284
|
+
const [mode, setMode] = useState(() => {
|
|
285
|
+
if (isPreview) return resolvedPreviewMode;
|
|
286
|
+
return isInAppBrowser ? "inapp" : null;
|
|
287
|
+
});
|
|
288
|
+
useEffect(() => {
|
|
289
|
+
if (isPreview) setMode(resolvedPreviewMode);
|
|
290
|
+
}, [isPreview, resolvedPreviewMode]);
|
|
102
291
|
const { reward } = useReward(mode === "referral" && isClientReady, interaction);
|
|
292
|
+
const [prefetchedMergeToken, setPrefetchedMergeToken] = useState(null);
|
|
293
|
+
useEffect(() => {
|
|
294
|
+
const client = window.FrakSetup?.client;
|
|
295
|
+
if (mode !== "inapp" || isPreview || !isClientReady || !client) return;
|
|
296
|
+
getMergeToken(client).then((token) => setPrefetchedMergeToken(token)).catch(() => {});
|
|
297
|
+
}, [
|
|
298
|
+
mode,
|
|
299
|
+
isPreview,
|
|
300
|
+
isClientReady
|
|
301
|
+
]);
|
|
103
302
|
useEffect(() => {
|
|
104
|
-
if (mode === "inapp") return;
|
|
303
|
+
if (isPreview || mode === "inapp") return;
|
|
105
304
|
const handler = () => setMode("referral");
|
|
106
305
|
window.addEventListener(REFERRAL_SUCCESS_EVENT, handler);
|
|
107
306
|
return () => window.removeEventListener(REFERRAL_SUCCESS_EVENT, handler);
|
|
108
|
-
}, [mode]);
|
|
109
|
-
const handleAction = useCallback(() => {
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
307
|
+
}, [isPreview, mode]);
|
|
308
|
+
const handleAction = useCallback(async () => {
|
|
309
|
+
if (isPreview) return;
|
|
310
|
+
if (mode === "referral") {
|
|
311
|
+
setDismissed(true);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
let mergeToken = prefetchedMergeToken;
|
|
315
|
+
if (!mergeToken && window.FrakSetup?.client) try {
|
|
316
|
+
mergeToken = await getMergeToken(window.FrakSetup?.client);
|
|
317
|
+
} catch {}
|
|
318
|
+
let targetUrl = window.location.href;
|
|
319
|
+
if (mergeToken) {
|
|
320
|
+
const url = new URL(targetUrl);
|
|
321
|
+
url.searchParams.set("fmt", mergeToken);
|
|
322
|
+
targetUrl = url.toString();
|
|
323
|
+
}
|
|
324
|
+
redirectToExternalBrowser(targetUrl);
|
|
325
|
+
}, [
|
|
326
|
+
isPreview,
|
|
327
|
+
mode,
|
|
328
|
+
prefetchedMergeToken
|
|
329
|
+
]);
|
|
330
|
+
const handleDismiss = useCallback(() => {
|
|
331
|
+
if (isPreview) return;
|
|
332
|
+
setDismissed(true);
|
|
333
|
+
}, [isPreview]);
|
|
334
|
+
const globalComponents = useGlobalComponents();
|
|
335
|
+
const bannerConfig = placement?.components?.banner ?? globalComponents?.banner;
|
|
114
336
|
const texts = useMemo(() => {
|
|
115
337
|
if (mode === "referral") {
|
|
116
338
|
const defaultTitle = reward ? `Earn ${reward} on purchases on this site` : "You've been referred!";
|
|
@@ -136,39 +358,60 @@ function Banner({ placement: placementId, classname = "", interaction, referralT
|
|
|
136
358
|
propInappDescription,
|
|
137
359
|
propInappCta
|
|
138
360
|
]);
|
|
139
|
-
if (!shouldRender || isHidden || dismissed
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
361
|
+
if (!mode || !isPreview && (!shouldRender || isHidden || dismissed)) return null;
|
|
362
|
+
const bannerClass = [
|
|
363
|
+
referral,
|
|
364
|
+
"frak-banner",
|
|
365
|
+
`frak-banner--${mode}`,
|
|
366
|
+
classname
|
|
367
|
+
].filter(Boolean).join(" ");
|
|
368
|
+
if (mode === "inapp") return /* @__PURE__ */ jsx(InAppBanner, {
|
|
369
|
+
title: texts.title,
|
|
370
|
+
description: texts.description,
|
|
371
|
+
cta: texts.cta,
|
|
372
|
+
dismissLabel: "Dismiss",
|
|
373
|
+
onAction: handleAction,
|
|
374
|
+
onDismiss: handleDismiss,
|
|
375
|
+
className: [
|
|
376
|
+
"frak-banner",
|
|
377
|
+
"frak-banner--inapp",
|
|
144
378
|
classname
|
|
145
379
|
].filter(Boolean).join(" "),
|
|
380
|
+
classNames: {
|
|
381
|
+
icon: "frak-banner__icon",
|
|
382
|
+
title: "frak-banner__title",
|
|
383
|
+
description: "frak-banner__description",
|
|
384
|
+
cta: "frak-banner__cta",
|
|
385
|
+
close: "frak-banner__close"
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
389
|
+
class: bannerClass,
|
|
146
390
|
role: "alert",
|
|
147
|
-
children: [
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
class: "banner__title",
|
|
391
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
392
|
+
class: `${referralIconWrapper} frak-banner__icon`,
|
|
393
|
+
children: /* @__PURE__ */ jsx(GiftIcon, { class: iconSvg })
|
|
394
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
395
|
+
class: `${referralBody} frak-banner__text`,
|
|
396
|
+
children: [
|
|
397
|
+
/* @__PURE__ */ jsx("p", {
|
|
398
|
+
class: `${referralTitle} frak-banner__title`,
|
|
156
399
|
children: texts.title
|
|
157
|
-
}),
|
|
158
|
-
|
|
400
|
+
}),
|
|
401
|
+
/* @__PURE__ */ jsx("p", {
|
|
402
|
+
class: `${referralDescription} frak-banner__description`,
|
|
159
403
|
children: texts.description
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
]
|
|
404
|
+
}),
|
|
405
|
+
/* @__PURE__ */ jsx("button", {
|
|
406
|
+
type: "button",
|
|
407
|
+
class: `${referralCta} frak-banner__cta`,
|
|
408
|
+
onClick: handleAction,
|
|
409
|
+
children: texts.cta
|
|
410
|
+
})
|
|
411
|
+
]
|
|
412
|
+
})]
|
|
169
413
|
});
|
|
170
414
|
}
|
|
171
|
-
|
|
172
415
|
//#endregion
|
|
173
416
|
//#region src/components/Banner/index.ts
|
|
174
417
|
registerWebComponent(Banner, "frak-banner", [
|
|
@@ -180,8 +423,9 @@ registerWebComponent(Banner, "frak-banner", [
|
|
|
180
423
|
"referralCta",
|
|
181
424
|
"inappTitle",
|
|
182
425
|
"inappDescription",
|
|
183
|
-
"inappCta"
|
|
426
|
+
"inappCta",
|
|
427
|
+
"preview",
|
|
428
|
+
"previewMode"
|
|
184
429
|
], { shadow: false });
|
|
185
|
-
|
|
186
430
|
//#endregion
|
|
187
|
-
export { Banner };
|
|
431
|
+
export { Banner };
|
package/dist/buttonShare.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InteractionTypeKey } from "@frak-labs/core-sdk";
|
|
2
|
-
import * as preact from "preact";
|
|
2
|
+
import * as _$preact from "preact";
|
|
3
3
|
|
|
4
4
|
//#region src/components/ButtonShare/types.d.ts
|
|
5
5
|
/**
|
|
@@ -88,7 +88,7 @@ declare function ButtonShare({
|
|
|
88
88
|
noRewardText,
|
|
89
89
|
targetInteraction,
|
|
90
90
|
clickAction: rawClickAction
|
|
91
|
-
}: ButtonShareProps): preact.JSX.Element | null;
|
|
91
|
+
}: ButtonShareProps): _$preact.JSX.Element | null;
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/components/ButtonShare/index.d.ts
|
|
94
94
|
/**
|
package/dist/buttonShare.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, s as openEmbeddedWallet, t as usePlacement } from "./usePlacement-LqYjZLX_.js";
|
|
2
|
+
import { t as useGlobalComponents } from "./useGlobalComponents-Cmfszr7v.js";
|
|
3
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-hgYYZsTy.js";
|
|
4
|
+
import { t as applyRewardPlaceholder } from "./formatReward-Bub6Z6eY.js";
|
|
5
|
+
import { t as useReward } from "./useReward-DU3_yP8Q.js";
|
|
6
|
+
import { t as useShareModal } from "./useShareModal-DgEf5WWG.js";
|
|
5
7
|
import { trackEvent } from "@frak-labs/core-sdk";
|
|
6
8
|
import { displaySharingPage } from "@frak-labs/core-sdk/actions";
|
|
7
9
|
import { useCallback, useMemo, useState } from "preact/hooks";
|
|
8
10
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
9
|
-
|
|
10
11
|
//#region src/utils/sharingPage.ts
|
|
11
12
|
async function openSharingPage(targetInteraction, placement) {
|
|
12
13
|
if (!window.FrakSetup?.client) {
|
|
@@ -15,7 +16,6 @@ async function openSharingPage(targetInteraction, placement) {
|
|
|
15
16
|
}
|
|
16
17
|
await displaySharingPage(window.FrakSetup.client, { metadata: { ...targetInteraction && { targetInteraction } } }, placement);
|
|
17
18
|
}
|
|
18
|
-
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/hooks/useCopyToClipboard.ts
|
|
21
21
|
function useCopyToClipboard(options = {}) {
|
|
@@ -57,7 +57,6 @@ function useCopyToClipboard(options = {}) {
|
|
|
57
57
|
copied
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
|
|
61
60
|
//#endregion
|
|
62
61
|
//#region src/components/ButtonShare/components/ErrorMessage.tsx
|
|
63
62
|
const styles = {
|
|
@@ -168,7 +167,6 @@ function ErrorMessage({ debugInfo }) {
|
|
|
168
167
|
]
|
|
169
168
|
});
|
|
170
169
|
}
|
|
171
|
-
|
|
172
170
|
//#endregion
|
|
173
171
|
//#region src/components/ButtonShare/ButtonShare.tsx
|
|
174
172
|
/**
|
|
@@ -214,7 +212,8 @@ function ErrorMessage({ debugInfo }) {
|
|
|
214
212
|
*/
|
|
215
213
|
function ButtonShare({ placement: placementId, text = "Share and earn!", classname = "", useReward: rawUseReward, noRewardText, targetInteraction, clickAction: rawClickAction }) {
|
|
216
214
|
const placement = usePlacement(placementId);
|
|
217
|
-
const
|
|
215
|
+
const globalComponents = useGlobalComponents();
|
|
216
|
+
const componentConfig = placement?.components?.buttonShare ?? globalComponents?.buttonShare;
|
|
218
217
|
useLightDomStyles("frak-button-share", placementId, componentConfig?.css);
|
|
219
218
|
const resolvedTargetInteraction = useMemo(() => placement?.targetInteraction !== void 0 ? placement.targetInteraction : targetInteraction, [placement?.targetInteraction, targetInteraction]);
|
|
220
219
|
const resolvedText = componentConfig?.text ?? text;
|
|
@@ -226,8 +225,8 @@ function ButtonShare({ placement: placementId, text = "Share and earn!", classna
|
|
|
226
225
|
const { handleShare, isError, debugInfo } = useShareModal(resolvedTargetInteraction, placementId);
|
|
227
226
|
const btnText = useMemo(() => {
|
|
228
227
|
if (!shouldUseReward) return resolvedText;
|
|
229
|
-
if (!reward) return resolvedNoRewardText ?? resolvedText
|
|
230
|
-
return resolvedText.includes("{REWARD}") ? resolvedText
|
|
228
|
+
if (!reward) return resolvedNoRewardText ?? applyRewardPlaceholder(resolvedText, void 0);
|
|
229
|
+
return resolvedText.includes("{REWARD}") ? applyRewardPlaceholder(resolvedText, reward) : `${resolvedText} ${reward}`;
|
|
231
230
|
}, [
|
|
232
231
|
shouldUseReward,
|
|
233
232
|
resolvedText,
|
|
@@ -259,7 +258,6 @@ function ButtonShare({ placement: placementId, text = "Share and earn!", classna
|
|
|
259
258
|
children: btnText
|
|
260
259
|
}), isError && /* @__PURE__ */ jsx(ErrorMessage, { debugInfo })] });
|
|
261
260
|
}
|
|
262
|
-
|
|
263
261
|
//#endregion
|
|
264
262
|
//#region src/components/ButtonShare/index.ts
|
|
265
263
|
registerWebComponent(ButtonShare, "frak-button-share", [
|
|
@@ -271,6 +269,5 @@ registerWebComponent(ButtonShare, "frak-button-share", [
|
|
|
271
269
|
"noRewardText",
|
|
272
270
|
"targetInteraction"
|
|
273
271
|
], { shadow: false });
|
|
274
|
-
|
|
275
272
|
//#endregion
|
|
276
|
-
export { ButtonShare };
|
|
273
|
+
export { ButtonShare };
|
package/dist/buttonWallet.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InteractionTypeKey } from "@frak-labs/core-sdk";
|
|
2
|
-
import * as preact from "preact";
|
|
2
|
+
import * as _$preact from "preact";
|
|
3
3
|
|
|
4
4
|
//#region src/components/ButtonWallet/types.d.ts
|
|
5
5
|
/**
|
|
@@ -70,7 +70,7 @@ declare function ButtonWallet({
|
|
|
70
70
|
classname,
|
|
71
71
|
useReward: rawUseReward,
|
|
72
72
|
targetInteraction
|
|
73
|
-
}: ButtonWalletProps): preact.JSX.Element | null;
|
|
73
|
+
}: ButtonWalletProps): _$preact.JSX.Element | null;
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/components/ButtonWallet/index.d.ts
|
|
76
76
|
/**
|