@frak-labs/components 0.0.26-beta.9d5371b4 → 0.0.26-beta.bbbb3d22
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.BrrxJ-YP.js +132 -0
- package/cdn/ButtonShare.D6sav-O3.js +1 -0
- package/cdn/{ButtonWallet.B7UmJcbb.js → ButtonWallet.DalZLwGv.js} +2 -2
- package/cdn/OpenInAppButton.BBj09SVF.js +1 -0
- package/cdn/PostPurchase.CXHETVu7.js +47 -0
- package/cdn/components.js +1 -1
- package/cdn/formatReward.CU8k_jx9.js +1 -0
- package/cdn/jsxRuntime.module.D7jbXhdY.js +58 -0
- package/cdn/loader.js +26 -26
- package/cdn/sprinkles.css.ts.vanilla.BtNHSSRm.js +1175 -0
- package/cdn/useLightDomStyles.x0mCz8nV.js +1 -0
- package/cdn/useReward.Cbh2WzQ3.js +1 -0
- package/cdn/useShareModal.DsoI-v9u.js +1 -0
- package/dist/GiftIcon-BrNVWoWm.js +1246 -0
- package/dist/banner.d.ts +24 -11
- package/dist/banner.js +314 -96
- package/dist/buttonShare.d.ts +2 -2
- package/dist/buttonShare.js +5 -11
- package/dist/buttonWallet.d.ts +2 -2
- package/dist/buttonWallet.js +3 -7
- package/dist/{formatReward-6JQldDEC.js → formatReward-_UYA3aHE.js} +1 -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 +1623 -25
- package/dist/{useLightDomStyles-DukxuNnJ.js → useLightDomStyles-Cjpf0MnX.js} +2 -5
- package/dist/{usePlacement-BbMuz8_A.js → usePlacement-LqYjZLX_.js} +1 -93
- package/dist/{useReward-CI2yRrCj.js → useReward-XF2hB_C_.js} +2 -4
- package/dist/{useShareModal-DHlayNqk.js → useShareModal-Bmlk3eBJ.js} +1 -3
- package/package.json +13 -9
- package/cdn/Banner.BfkMel9Q.js +0 -1
- package/cdn/ButtonShare.BM9Inhmf.js +0 -1
- 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,226 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
3
|
-
import { t as useReward } from "./useReward-
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, t as usePlacement } from "./usePlacement-LqYjZLX_.js";
|
|
2
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-Cjpf0MnX.js";
|
|
3
|
+
import { t as useReward } from "./useReward-XF2hB_C_.js";
|
|
4
|
+
import { i as cssSource$2, n as cssSource$4, r as cssSource$3, t as GiftIcon } from "./GiftIcon-BrNVWoWm.js";
|
|
4
5
|
import { isInAppBrowser, redirectToExternalBrowser } from "@frak-labs/core-sdk";
|
|
5
|
-
import { REFERRAL_SUCCESS_EVENT } from "@frak-labs/core-sdk/actions";
|
|
6
|
+
import { REFERRAL_SUCCESS_EVENT, getMergeToken } from "@frak-labs/core-sdk/actions";
|
|
6
7
|
import { useCallback, useEffect, useMemo, useState } from "preact/hooks";
|
|
7
8
|
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return /* @__PURE__ */ jsxs("svg", {
|
|
15
|
-
viewBox: "0 0 24 24",
|
|
9
|
+
//#region src/components/icons/CloseIcon.tsx
|
|
10
|
+
function CloseIcon(props) {
|
|
11
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
12
|
+
width: "15",
|
|
13
|
+
height: "15",
|
|
14
|
+
viewBox: "0 0 15 15",
|
|
16
15
|
fill: "none",
|
|
17
|
-
stroke: "currentColor",
|
|
18
|
-
"stroke-width": "1.5",
|
|
19
|
-
"stroke-linecap": "round",
|
|
20
|
-
"stroke-linejoin": "round",
|
|
21
16
|
"aria-hidden": "true",
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
height: "11",
|
|
28
|
-
rx: "1"
|
|
29
|
-
}),
|
|
30
|
-
/* @__PURE__ */ jsx("path", { d: "M12 11v11" }),
|
|
31
|
-
/* @__PURE__ */ jsx("rect", {
|
|
32
|
-
x: "5",
|
|
33
|
-
y: "7",
|
|
34
|
-
width: "14",
|
|
35
|
-
height: "4",
|
|
36
|
-
rx: "1"
|
|
37
|
-
}),
|
|
38
|
-
/* @__PURE__ */ jsx("path", { d: "M12 7c0 0-1.5-4-4.5-4S5 5 7.5 7" }),
|
|
39
|
-
/* @__PURE__ */ jsx("path", { d: "M12 7c0 0 1.5-4 4.5-4S19 5 16.5 7" })
|
|
40
|
-
]
|
|
17
|
+
...props,
|
|
18
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
19
|
+
d: "M7.33301 0C11.383 0 14.6668 3.28307 14.667 7.33301C14.667 11.3831 11.3831 14.667 7.33301 14.667C3.28307 14.6668 0 11.383 0 7.33301C0.000175746 3.28318 3.28318 0.000175742 7.33301 0ZM10.3896 4.27734C10.151 4.0388 9.76303 4.03775 9.52441 4.27637L7.33301 6.46777L5.14258 4.27637C4.90397 4.03776 4.51601 4.03882 4.27734 4.27734C4.03869 4.516 4.03771 4.90392 4.27637 5.14258L6.4668 7.33398L4.27637 9.52441C4.03807 9.76306 4.03891 10.1511 4.27734 10.3896C4.51589 10.6282 4.9039 10.629 5.14258 10.3906L7.33301 8.2002L9.52344 10.3906C9.76198 10.629 10.15 10.6279 10.3887 10.3896C10.6273 10.151 10.6283 9.76209 10.3896 9.52344L8.2002 7.33398L10.3906 5.14258C10.6293 4.90392 10.6283 4.516 10.3896 4.27734Z",
|
|
20
|
+
fill: "currentColor"
|
|
21
|
+
})
|
|
41
22
|
});
|
|
42
23
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/components/icons/ExternalLinkIcon.tsx
|
|
26
|
+
function ExternalLinkIcon(props) {
|
|
27
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
28
|
+
width: "12",
|
|
29
|
+
height: "12",
|
|
30
|
+
viewBox: "0 0 12 12",
|
|
49
31
|
fill: "none",
|
|
50
|
-
stroke: "currentColor",
|
|
51
|
-
"stroke-width": "1.5",
|
|
52
|
-
"stroke-linecap": "round",
|
|
53
|
-
"stroke-linejoin": "round",
|
|
54
32
|
"aria-hidden": "true",
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
33
|
+
...props,
|
|
34
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
35
|
+
d: "M5.45508 0C5.75614 0.000209333 6 0.244788 6 0.545898C5.99979 0.846831 5.75601 1.09159 5.45508 1.0918H4.36426C3.05445 1.0918 2.27964 1.35707 1.81836 1.81836C1.35714 2.27966 1.0918 3.05454 1.0918 4.36426V7.63672C1.09186 8.94625 1.35713 9.72139 1.81836 10.1826C2.2797 10.6436 3.05488 10.9092 4.36426 10.9092H7.63672C8.94628 10.9091 9.72135 10.6438 10.1826 10.1826C10.6438 9.72139 10.9091 8.94625 10.9092 7.63672V6.5459C10.9092 6.24466 11.1538 6 11.4551 6C11.7561 6.00028 12 6.24483 12 6.5459V7.63672C11.9999 9.05391 11.72 10.1882 10.9541 10.9541C10.1882 11.7199 9.05394 12 7.63672 12H4.36426C2.94714 12 1.81283 11.7197 1.04688 10.9541C0.280997 10.1882 6.04321e-05 9.05391 0 7.63672V4.36426C0 2.94692 0.28099 1.81283 1.04688 1.04688C1.81284 0.280915 2.94686 0 4.36426 0H5.45508ZM11.4541 0C11.7553 2.20143e-05 11.999 0.244672 11.999 0.545898V3.16406C11.9988 3.46509 11.7552 3.70896 11.4541 3.70898C11.1532 3.70873 10.9084 3.46495 10.9082 3.16406V1.8623L6.93066 5.83984C6.71766 6.05283 6.37218 6.05283 6.15918 5.83984C5.94657 5.62681 5.94632 5.28124 6.15918 5.06836L10.1357 1.0918H8.83594C8.53504 1.09154 8.29025 0.846803 8.29004 0.545898C8.29004 0.244816 8.53491 0.000254588 8.83594 0H11.4541Z",
|
|
36
|
+
fill: "currentColor"
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/components/icons/WarningIcon.tsx
|
|
42
|
+
function WarningIcon(props) {
|
|
43
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
44
|
+
width: "16",
|
|
45
|
+
height: "16",
|
|
46
|
+
viewBox: "0 0 16 16",
|
|
47
|
+
fill: "none",
|
|
48
|
+
"aria-hidden": "true",
|
|
49
|
+
...props,
|
|
50
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
51
|
+
d: "M8 0C12.4183 0 16 3.58172 16 8C16 12.4183 12.4183 16 8 16C3.58172 16 0 12.4183 0 8C0 3.58172 3.58172 0 8 0ZM8 1.5C4.41015 1.5 1.5 4.41015 1.5 8C1.5 11.5899 4.41015 14.5 8 14.5C11.5899 14.5 14.5 11.5899 14.5 8C14.5 4.41015 11.5899 1.5 8 1.5ZM8.10352 10.207C8.82025 10.2071 9.23531 10.6346 9.23535 11.3262C9.23535 12.0304 8.82028 12.4579 8.10352 12.458C7.36167 12.4579 6.97168 12.0304 6.97168 11.3262C6.97172 10.6346 7.36171 10.2072 8.10352 10.207ZM8.84766 3.54102C9.01311 3.54121 9.14736 3.67535 9.14746 3.84082V4.74805L8.84375 8.37012C8.83069 8.52552 8.6999 8.64551 8.54395 8.64551H7.62891C7.47133 8.64523 7.34074 8.52251 7.33008 8.36523L7.08496 4.74805V3.84082C7.08507 3.67533 7.2193 3.54119 7.38477 3.54102H8.84766Z",
|
|
52
|
+
fill: "currentColor"
|
|
53
|
+
})
|
|
65
54
|
});
|
|
66
55
|
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region \0ve-inline:src/components/Banner/Banner.css.ts.vanilla.js
|
|
58
|
+
const cssSource$1 = `@keyframes Banner_fadeIn__1gnumzi0 {
|
|
59
|
+
from {
|
|
60
|
+
opacity: 0;
|
|
61
|
+
transform: translateY(-4px);
|
|
62
|
+
}
|
|
63
|
+
to {
|
|
64
|
+
opacity: 1;
|
|
65
|
+
transform: translateY(0);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
.Banner_rootBase__1gnumzi1 {
|
|
69
|
+
position: relative;
|
|
70
|
+
display: flex;
|
|
71
|
+
animation: Banner_fadeIn__1gnumzi0 300ms ease-out;
|
|
72
|
+
}
|
|
73
|
+
.Banner_iconSvg__1gnumzi2 {
|
|
74
|
+
width: 100%;
|
|
75
|
+
height: 100%;
|
|
76
|
+
}
|
|
77
|
+
.Banner_referral__1gnumzi3 {
|
|
78
|
+
flex-direction: row;
|
|
79
|
+
align-items: center;
|
|
80
|
+
gap: 16px;
|
|
81
|
+
padding: 16px;
|
|
82
|
+
background-color: #ffffff;
|
|
83
|
+
color: var(--text-primary__pbq4ak0);
|
|
84
|
+
}
|
|
85
|
+
.Banner_referralIconWrapper__1gnumzi4 {
|
|
86
|
+
flex-shrink: 0;
|
|
87
|
+
align-self: flex-start;
|
|
88
|
+
width: 40px;
|
|
89
|
+
height: 40px;
|
|
90
|
+
}
|
|
91
|
+
.Banner_referralBody__1gnumzi5 {
|
|
92
|
+
flex: 1;
|
|
93
|
+
min-width: 0;
|
|
94
|
+
}
|
|
95
|
+
.Banner_referralTitle__1gnumzi6 {
|
|
96
|
+
font-size: 16px;
|
|
97
|
+
font-weight: 600;
|
|
98
|
+
color: var(--text-primary__pbq4ak0);
|
|
99
|
+
line-height: 22px;
|
|
100
|
+
}
|
|
101
|
+
.Banner_referralDescription__1gnumzi7 {
|
|
102
|
+
margin-bottom: 8px;
|
|
103
|
+
font-size: 14px;
|
|
104
|
+
color: #979797;
|
|
105
|
+
line-height: 22px;
|
|
106
|
+
}
|
|
107
|
+
.Banner_referralCta__1gnumzi8 {
|
|
108
|
+
display: inline-block;
|
|
109
|
+
padding: 8px 16px;
|
|
110
|
+
border: 1px solid #000000;
|
|
111
|
+
border-radius: 9999px;
|
|
112
|
+
color: var(--text-primary__pbq4ak0);
|
|
113
|
+
font-size: 10px;
|
|
114
|
+
font-weight: 700;
|
|
115
|
+
line-height: 12px;
|
|
116
|
+
text-transform: uppercase;
|
|
117
|
+
}
|
|
118
|
+
.Banner_referralCta__1gnumzi8:focus-visible {
|
|
119
|
+
outline: 2px solid #000000;
|
|
120
|
+
outline-offset: 2px;
|
|
121
|
+
}
|
|
122
|
+
.Banner_inapp__1gnumzi9 {
|
|
123
|
+
flex-direction: column;
|
|
124
|
+
gap: 4px;
|
|
125
|
+
padding: 12px 16px;
|
|
126
|
+
padding-right: 32px;
|
|
127
|
+
border-radius: 12px;
|
|
128
|
+
background-color: #000000CC;
|
|
129
|
+
backdrop-filter: blur(12px);
|
|
130
|
+
-webkit-backdrop-filter: blur(12px);
|
|
131
|
+
color: #ffffff;
|
|
132
|
+
}
|
|
133
|
+
.Banner_inappHeader__1gnumzia {
|
|
134
|
+
display: flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
gap: 8px;
|
|
137
|
+
}
|
|
138
|
+
.Banner_inappIconWrapper__1gnumzib {
|
|
139
|
+
flex-shrink: 0;
|
|
140
|
+
width: 20px;
|
|
141
|
+
height: 20px;
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
justify-content: center;
|
|
145
|
+
color: #ffffff;
|
|
146
|
+
}
|
|
147
|
+
.Banner_inappTitle__1gnumzic {
|
|
148
|
+
font-size: 16px;
|
|
149
|
+
font-weight: 500;
|
|
150
|
+
line-height: 26px;
|
|
151
|
+
color: var(--text-onAction__pbq4ak6);
|
|
152
|
+
}
|
|
153
|
+
.Banner_inappDescription__1gnumzid {
|
|
154
|
+
font-size: 14px;
|
|
155
|
+
color: var(--text-onAction__pbq4ak6);
|
|
156
|
+
line-height: 22px;
|
|
157
|
+
opacity: 0.96;
|
|
158
|
+
}
|
|
159
|
+
.Banner_inappCta__1gnumzie {
|
|
160
|
+
display: inline-flex;
|
|
161
|
+
align-items: center;
|
|
162
|
+
gap: 4px;
|
|
163
|
+
color: #2BB2FF;
|
|
164
|
+
font-size: 14px;
|
|
165
|
+
font-weight: 600;
|
|
166
|
+
text-decoration: underline;
|
|
167
|
+
text-underline-offset: 2px;
|
|
168
|
+
}
|
|
169
|
+
.Banner_inappCta__1gnumzie:focus-visible {
|
|
170
|
+
outline: 2px solid #2BB2FF;
|
|
171
|
+
outline-offset: 2px;
|
|
172
|
+
border-radius: 4px;
|
|
173
|
+
}
|
|
174
|
+
.Banner_inappClose__1gnumzif {
|
|
175
|
+
position: absolute;
|
|
176
|
+
top: 8px;
|
|
177
|
+
right: 8px;
|
|
178
|
+
width: 28px;
|
|
179
|
+
height: 28px;
|
|
180
|
+
display: flex;
|
|
181
|
+
align-items: center;
|
|
182
|
+
justify-content: center;
|
|
183
|
+
border-radius: 9999px;
|
|
184
|
+
color: rgba(255, 255, 255, 0.6);
|
|
185
|
+
}
|
|
186
|
+
.Banner_inappClose__1gnumzif:focus-visible {
|
|
187
|
+
outline: 2px solid #ffffff;
|
|
188
|
+
outline-offset: 2px;
|
|
189
|
+
}`;
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/components/Banner/Banner.css.ts
|
|
192
|
+
var iconSvg = "Banner_iconSvg__1gnumzi2";
|
|
193
|
+
var inapp = "Banner_inapp__1gnumzi9 reset_base__1831jhd0 Banner_rootBase__1gnumzi1";
|
|
194
|
+
var inappClose = "Banner_inappClose__1gnumzif reset_element_button__1831jhd6 reset_fieldAppearance__1831jhd2 reset_focusRing__1831jhd1";
|
|
195
|
+
var inappCta = "Banner_inappCta__1gnumzie reset_element_button__1831jhd6 reset_fieldAppearance__1831jhd2 reset_focusRing__1831jhd1";
|
|
196
|
+
var inappDescription = "Banner_inappDescription__1gnumzid reset_base__1831jhd0";
|
|
197
|
+
var inappHeader = "Banner_inappHeader__1gnumzia";
|
|
198
|
+
var inappIconWrapper = "Banner_inappIconWrapper__1gnumzib";
|
|
199
|
+
var inappTitle = "Banner_inappTitle__1gnumzic reset_base__1831jhd0";
|
|
200
|
+
var referral = "Banner_referral__1gnumzi3 reset_base__1831jhd0 Banner_rootBase__1gnumzi1";
|
|
201
|
+
var referralBody = "Banner_referralBody__1gnumzi5";
|
|
202
|
+
var referralCta = "Banner_referralCta__1gnumzi8 reset_element_button__1831jhd6 reset_fieldAppearance__1831jhd2 reset_focusRing__1831jhd1";
|
|
203
|
+
var referralDescription = "Banner_referralDescription__1gnumzi7 reset_base__1831jhd0";
|
|
204
|
+
var referralIconWrapper = "Banner_referralIconWrapper__1gnumzi4";
|
|
205
|
+
var referralTitle = "Banner_referralTitle__1gnumzi6 reset_base__1831jhd0";
|
|
206
|
+
const cssSource = cssSource$2 + cssSource$3 + cssSource$4 + cssSource$1;
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/components/Banner/Banner.tsx
|
|
67
209
|
/**
|
|
68
210
|
* Auto-detecting notification banner component.
|
|
69
211
|
*
|
|
70
|
-
* Renders an inline banner on the merchant page
|
|
71
|
-
*
|
|
212
|
+
* Renders an inline banner on the merchant page with one of two distinct
|
|
213
|
+
* visual styles depending on the detected mode:
|
|
72
214
|
*
|
|
73
|
-
* - **Referral mode
|
|
74
|
-
* Displays reward
|
|
75
|
-
* - **In-app browser mode
|
|
76
|
-
* media in-app browser (Instagram, Facebook).
|
|
77
|
-
* default browser
|
|
215
|
+
* - **Referral mode** (white): Shown after a successful referral link
|
|
216
|
+
* processing. Displays a gift icon, reward copy, and a "Got it" CTA.
|
|
217
|
+
* - **In-app browser mode** (dark transparent): Shown when the page is
|
|
218
|
+
* opened inside a social media in-app browser (Instagram, Facebook).
|
|
219
|
+
* Offers an inline link to redirect to the default browser plus a
|
|
220
|
+
* close button to dismiss.
|
|
78
221
|
*
|
|
79
222
|
* In-app browser mode takes priority over referral mode.
|
|
80
|
-
* Uses Light DOM
|
|
223
|
+
* Uses Light DOM + vanilla-extract styles from `@frak-labs/design-system`.
|
|
81
224
|
*
|
|
82
225
|
* @group components
|
|
83
226
|
*
|
|
@@ -93,23 +236,63 @@ function BrowserIcon() {
|
|
|
93
236
|
* <frak-banner classname="my-custom-banner"></frak-banner>
|
|
94
237
|
* ```
|
|
95
238
|
*/
|
|
96
|
-
function Banner({ placement: placementId, classname = "", interaction, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta }) {
|
|
239
|
+
function Banner({ placement: placementId, classname = "", interaction, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, preview, previewMode }) {
|
|
240
|
+
const isPreview = !!preview;
|
|
241
|
+
const resolvedPreviewMode = previewMode === "inapp" ? "inapp" : "referral";
|
|
97
242
|
const placement = usePlacement(placementId);
|
|
98
243
|
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
99
|
-
useLightDomStyles("frak-banner", placementId, placement?.components?.banner?.css,
|
|
244
|
+
useLightDomStyles("frak-banner", placementId, placement?.components?.banner?.css, cssSource);
|
|
100
245
|
const [dismissed, setDismissed] = useState(false);
|
|
101
|
-
const [mode, setMode] = useState(() =>
|
|
246
|
+
const [mode, setMode] = useState(() => {
|
|
247
|
+
if (isPreview) return resolvedPreviewMode;
|
|
248
|
+
return isInAppBrowser ? "inapp" : null;
|
|
249
|
+
});
|
|
250
|
+
useEffect(() => {
|
|
251
|
+
if (isPreview) setMode(resolvedPreviewMode);
|
|
252
|
+
}, [isPreview, resolvedPreviewMode]);
|
|
102
253
|
const { reward } = useReward(mode === "referral" && isClientReady, interaction);
|
|
254
|
+
const [prefetchedMergeToken, setPrefetchedMergeToken] = useState(null);
|
|
103
255
|
useEffect(() => {
|
|
104
|
-
|
|
256
|
+
const client = window.FrakSetup?.client;
|
|
257
|
+
if (mode !== "inapp" || isPreview || !isClientReady || !client) return;
|
|
258
|
+
getMergeToken(client).then((token) => setPrefetchedMergeToken(token)).catch(() => {});
|
|
259
|
+
}, [
|
|
260
|
+
mode,
|
|
261
|
+
isPreview,
|
|
262
|
+
isClientReady
|
|
263
|
+
]);
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
if (isPreview || mode === "inapp") return;
|
|
105
266
|
const handler = () => setMode("referral");
|
|
106
267
|
window.addEventListener(REFERRAL_SUCCESS_EVENT, handler);
|
|
107
268
|
return () => window.removeEventListener(REFERRAL_SUCCESS_EVENT, handler);
|
|
108
|
-
}, [mode]);
|
|
109
|
-
const handleAction = useCallback(() => {
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
269
|
+
}, [isPreview, mode]);
|
|
270
|
+
const handleAction = useCallback(async () => {
|
|
271
|
+
if (isPreview) return;
|
|
272
|
+
if (mode === "referral") {
|
|
273
|
+
setDismissed(true);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
let mergeToken = prefetchedMergeToken;
|
|
277
|
+
if (!mergeToken && window.FrakSetup?.client) try {
|
|
278
|
+
mergeToken = await getMergeToken(window.FrakSetup?.client);
|
|
279
|
+
} catch {}
|
|
280
|
+
let targetUrl = window.location.href;
|
|
281
|
+
if (mergeToken) {
|
|
282
|
+
const url = new URL(targetUrl);
|
|
283
|
+
url.searchParams.set("fmt", mergeToken);
|
|
284
|
+
targetUrl = url.toString();
|
|
285
|
+
}
|
|
286
|
+
redirectToExternalBrowser(targetUrl);
|
|
287
|
+
}, [
|
|
288
|
+
isPreview,
|
|
289
|
+
mode,
|
|
290
|
+
prefetchedMergeToken
|
|
291
|
+
]);
|
|
292
|
+
const handleDismiss = useCallback(() => {
|
|
293
|
+
if (isPreview) return;
|
|
294
|
+
setDismissed(true);
|
|
295
|
+
}, [isPreview]);
|
|
113
296
|
const bannerConfig = placement?.components?.banner;
|
|
114
297
|
const texts = useMemo(() => {
|
|
115
298
|
if (mode === "referral") {
|
|
@@ -136,39 +319,73 @@ function Banner({ placement: placementId, classname = "", interaction, referralT
|
|
|
136
319
|
propInappDescription,
|
|
137
320
|
propInappCta
|
|
138
321
|
]);
|
|
139
|
-
if (!shouldRender || isHidden || dismissed
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
322
|
+
if (!mode || !isPreview && (!shouldRender || isHidden || dismissed)) return null;
|
|
323
|
+
const bannerClass = [
|
|
324
|
+
mode === "inapp" ? inapp : referral,
|
|
325
|
+
"frak-banner",
|
|
326
|
+
`frak-banner--${mode}`,
|
|
327
|
+
classname
|
|
328
|
+
].filter(Boolean).join(" ");
|
|
329
|
+
if (mode === "inapp") return /* @__PURE__ */ jsxs("div", {
|
|
330
|
+
class: bannerClass,
|
|
146
331
|
role: "alert",
|
|
147
332
|
children: [
|
|
148
|
-
/* @__PURE__ */ jsx("div", {
|
|
149
|
-
class: "banner__icon",
|
|
150
|
-
children: mode === "referral" ? /* @__PURE__ */ jsx(RewardIcon, {}) : /* @__PURE__ */ jsx(BrowserIcon, {})
|
|
151
|
-
}),
|
|
152
333
|
/* @__PURE__ */ jsxs("div", {
|
|
153
|
-
class:
|
|
154
|
-
children: [/* @__PURE__ */ jsx("
|
|
155
|
-
class:
|
|
156
|
-
children:
|
|
334
|
+
class: inappHeader,
|
|
335
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
336
|
+
class: `${inappIconWrapper} frak-banner__icon`,
|
|
337
|
+
children: /* @__PURE__ */ jsx(WarningIcon, {})
|
|
157
338
|
}), /* @__PURE__ */ jsx("p", {
|
|
158
|
-
class:
|
|
159
|
-
children: texts.
|
|
339
|
+
class: `${inappTitle} frak-banner__title`,
|
|
340
|
+
children: texts.title
|
|
160
341
|
})]
|
|
161
342
|
}),
|
|
162
|
-
/* @__PURE__ */ jsx("
|
|
343
|
+
/* @__PURE__ */ jsx("p", {
|
|
344
|
+
class: `${inappDescription} frak-banner__description`,
|
|
345
|
+
children: texts.description
|
|
346
|
+
}),
|
|
347
|
+
/* @__PURE__ */ jsxs("button", {
|
|
163
348
|
type: "button",
|
|
164
|
-
class:
|
|
349
|
+
class: `${inappCta} frak-banner__cta`,
|
|
165
350
|
onClick: handleAction,
|
|
166
|
-
children: texts.cta
|
|
351
|
+
children: [texts.cta, /* @__PURE__ */ jsx(ExternalLinkIcon, {})]
|
|
352
|
+
}),
|
|
353
|
+
/* @__PURE__ */ jsx("button", {
|
|
354
|
+
type: "button",
|
|
355
|
+
class: `${inappClose} frak-banner__close`,
|
|
356
|
+
onClick: handleDismiss,
|
|
357
|
+
"aria-label": "Dismiss",
|
|
358
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
167
359
|
})
|
|
168
360
|
]
|
|
169
361
|
});
|
|
362
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
363
|
+
class: bannerClass,
|
|
364
|
+
role: "alert",
|
|
365
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
366
|
+
class: `${referralIconWrapper} frak-banner__icon`,
|
|
367
|
+
children: /* @__PURE__ */ jsx(GiftIcon, { class: iconSvg })
|
|
368
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
369
|
+
class: `${referralBody} frak-banner__text`,
|
|
370
|
+
children: [
|
|
371
|
+
/* @__PURE__ */ jsx("p", {
|
|
372
|
+
class: `${referralTitle} frak-banner__title`,
|
|
373
|
+
children: texts.title
|
|
374
|
+
}),
|
|
375
|
+
/* @__PURE__ */ jsx("p", {
|
|
376
|
+
class: `${referralDescription} frak-banner__description`,
|
|
377
|
+
children: texts.description
|
|
378
|
+
}),
|
|
379
|
+
/* @__PURE__ */ jsx("button", {
|
|
380
|
+
type: "button",
|
|
381
|
+
class: `${referralCta} frak-banner__cta`,
|
|
382
|
+
onClick: handleAction,
|
|
383
|
+
children: texts.cta
|
|
384
|
+
})
|
|
385
|
+
]
|
|
386
|
+
})]
|
|
387
|
+
});
|
|
170
388
|
}
|
|
171
|
-
|
|
172
389
|
//#endregion
|
|
173
390
|
//#region src/components/Banner/index.ts
|
|
174
391
|
registerWebComponent(Banner, "frak-banner", [
|
|
@@ -180,8 +397,9 @@ registerWebComponent(Banner, "frak-banner", [
|
|
|
180
397
|
"referralCta",
|
|
181
398
|
"inappTitle",
|
|
182
399
|
"inappDescription",
|
|
183
|
-
"inappCta"
|
|
400
|
+
"inappCta",
|
|
401
|
+
"preview",
|
|
402
|
+
"previewMode"
|
|
184
403
|
], { shadow: false });
|
|
185
|
-
|
|
186
404
|
//#endregion
|
|
187
|
-
export { Banner };
|
|
405
|
+
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,11 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
3
|
-
import { t as useReward } from "./useReward-
|
|
4
|
-
import { t as useShareModal } from "./useShareModal-
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, s as openEmbeddedWallet, t as usePlacement } from "./usePlacement-LqYjZLX_.js";
|
|
2
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-Cjpf0MnX.js";
|
|
3
|
+
import { t as useReward } from "./useReward-XF2hB_C_.js";
|
|
4
|
+
import { t as useShareModal } from "./useShareModal-Bmlk3eBJ.js";
|
|
5
5
|
import { trackEvent } from "@frak-labs/core-sdk";
|
|
6
6
|
import { displaySharingPage } from "@frak-labs/core-sdk/actions";
|
|
7
7
|
import { useCallback, useMemo, useState } from "preact/hooks";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
9
|
-
|
|
10
9
|
//#region src/utils/sharingPage.ts
|
|
11
10
|
async function openSharingPage(targetInteraction, placement) {
|
|
12
11
|
if (!window.FrakSetup?.client) {
|
|
@@ -15,7 +14,6 @@ async function openSharingPage(targetInteraction, placement) {
|
|
|
15
14
|
}
|
|
16
15
|
await displaySharingPage(window.FrakSetup.client, { metadata: { ...targetInteraction && { targetInteraction } } }, placement);
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
//#endregion
|
|
20
18
|
//#region src/hooks/useCopyToClipboard.ts
|
|
21
19
|
function useCopyToClipboard(options = {}) {
|
|
@@ -57,7 +55,6 @@ function useCopyToClipboard(options = {}) {
|
|
|
57
55
|
copied
|
|
58
56
|
};
|
|
59
57
|
}
|
|
60
|
-
|
|
61
58
|
//#endregion
|
|
62
59
|
//#region src/components/ButtonShare/components/ErrorMessage.tsx
|
|
63
60
|
const styles = {
|
|
@@ -168,7 +165,6 @@ function ErrorMessage({ debugInfo }) {
|
|
|
168
165
|
]
|
|
169
166
|
});
|
|
170
167
|
}
|
|
171
|
-
|
|
172
168
|
//#endregion
|
|
173
169
|
//#region src/components/ButtonShare/ButtonShare.tsx
|
|
174
170
|
/**
|
|
@@ -259,7 +255,6 @@ function ButtonShare({ placement: placementId, text = "Share and earn!", classna
|
|
|
259
255
|
children: btnText
|
|
260
256
|
}), isError && /* @__PURE__ */ jsx(ErrorMessage, { debugInfo })] });
|
|
261
257
|
}
|
|
262
|
-
|
|
263
258
|
//#endregion
|
|
264
259
|
//#region src/components/ButtonShare/index.ts
|
|
265
260
|
registerWebComponent(ButtonShare, "frak-button-share", [
|
|
@@ -271,6 +266,5 @@ registerWebComponent(ButtonShare, "frak-button-share", [
|
|
|
271
266
|
"noRewardText",
|
|
272
267
|
"targetInteraction"
|
|
273
268
|
], { shadow: false });
|
|
274
|
-
|
|
275
269
|
//#endregion
|
|
276
|
-
export { ButtonShare };
|
|
270
|
+
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
|
/**
|
package/dist/buttonWallet.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as useReward } from "./useReward-
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, n as buildStyleContent, o as openWalletModal, t as usePlacement } from "./usePlacement-LqYjZLX_.js";
|
|
2
|
+
import { t as useReward } from "./useReward-XF2hB_C_.js";
|
|
3
3
|
import { trackEvent } from "@frak-labs/core-sdk";
|
|
4
4
|
import { useEffect, useMemo, useState } from "preact/hooks";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
6
|
-
|
|
7
6
|
//#region src/components/ButtonWallet/assets/GiftIcon.tsx
|
|
8
7
|
function GiftIcon(props) {
|
|
9
8
|
return /* @__PURE__ */ jsxs("svg", {
|
|
@@ -21,7 +20,6 @@ function GiftIcon(props) {
|
|
|
21
20
|
})]
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
//#endregion
|
|
26
24
|
//#region src/components/ButtonWallet/ButtonWallet.tsx
|
|
27
25
|
const componentCss = `
|
|
@@ -140,7 +138,6 @@ function ButtonWallet({ placement: placementId, classname = "", useReward: rawUs
|
|
|
140
138
|
})]
|
|
141
139
|
})] });
|
|
142
140
|
}
|
|
143
|
-
|
|
144
141
|
//#endregion
|
|
145
142
|
//#region src/components/ButtonWallet/index.ts
|
|
146
143
|
registerWebComponent(ButtonWallet, "frak-button-wallet", [
|
|
@@ -149,6 +146,5 @@ registerWebComponent(ButtonWallet, "frak-button-wallet", [
|
|
|
149
146
|
"useReward",
|
|
150
147
|
"targetInteraction"
|
|
151
148
|
], { shadow: true });
|
|
152
|
-
|
|
153
149
|
//#endregion
|
|
154
|
-
export { ButtonWallet };
|
|
150
|
+
export { ButtonWallet };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { formatAmount, getCurrencyAmountKey, getSupportedCurrency } from "@frak-labs/core-sdk";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/formatReward.ts
|
|
4
3
|
/**
|
|
5
4
|
* Format an {@link EstimatedReward} into a human-readable string.
|
|
@@ -23,6 +22,5 @@ function formatEstimatedReward(reward, currency, basketAmount) {
|
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
//#endregion
|
|
28
|
-
export { formatEstimatedReward as t };
|
|
26
|
+
export { formatEstimatedReward as t };
|