@frak-labs/components 0.0.26-beta.b38eef2e → 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.DalZLwGv.js +40 -0
- 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.css +0 -14
- package/cdn/loader.js +66 -1
- 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 +116 -0
- package/dist/banner.js +405 -0
- package/dist/buttonShare.d.ts +8 -6
- package/dist/buttonShare.js +60 -101
- package/dist/buttonWallet.d.ts +10 -2
- package/dist/buttonWallet.js +79 -38
- package/dist/formatReward-_UYA3aHE.js +26 -0
- package/dist/openInApp.d.ts +4 -2
- package/dist/openInApp.js +23 -27
- package/dist/postPurchase.d.ts +122 -0
- package/dist/postPurchase.js +1744 -0
- package/dist/useLightDomStyles-Cjpf0MnX.js +41 -0
- package/dist/usePlacement-LqYjZLX_.js +248 -0
- package/dist/useReward-XF2hB_C_.js +65 -0
- package/dist/useShareModal-Bmlk3eBJ.js +53 -0
- package/package.json +29 -19
- package/cdn/ButtonShare.CSPl5Bi5.js +0 -1
- package/cdn/ButtonWallet.3Hp62hGr.js +0 -1
- package/cdn/OpenInAppButton.BTvukMkp.js +0 -1
- package/cdn/Spinner.DQogVqic.js +0 -1
- package/cdn/initFrakSdk.CMgrZQwQ.js +0 -14
- package/cdn/useClientReady.CKKC4IMk.js +0 -1
- package/dist/Spinner-Btnwk01x.js +0 -36
- package/dist/Spinner-CHZD3tMn.css +0 -1
- package/dist/buttonShare.css +0 -1
- package/dist/buttonWallet.css +0 -1
- package/dist/openInApp.css +0 -1
- package/dist/useClientReady-0vKBG0-p.js +0 -197
- package/dist/useReward-DAkT-7wT.js +0 -48
package/dist/banner.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { InteractionTypeKey } from "@frak-labs/core-sdk";
|
|
2
|
+
import * as _$preact from "preact";
|
|
3
|
+
|
|
4
|
+
//#region src/components/Banner/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The props type for {@link Banner}.
|
|
7
|
+
* @inline
|
|
8
|
+
*/
|
|
9
|
+
type BannerProps = {
|
|
10
|
+
/**
|
|
11
|
+
* Placement ID for backend-driven CSS customization.
|
|
12
|
+
*/
|
|
13
|
+
placement?: string;
|
|
14
|
+
/**
|
|
15
|
+
* CSS class names passed through to the root element (Light DOM).
|
|
16
|
+
*/
|
|
17
|
+
classname?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Filter rewards by interaction type (e.g. "purchase", "referral").
|
|
20
|
+
* When omitted, the best reward across all interaction types is shown.
|
|
21
|
+
*/
|
|
22
|
+
interaction?: InteractionTypeKey;
|
|
23
|
+
/**
|
|
24
|
+
* Override the referral banner title.
|
|
25
|
+
*/
|
|
26
|
+
referralTitle?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Override the referral banner description.
|
|
29
|
+
*/
|
|
30
|
+
referralDescription?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Override the referral banner CTA button text.
|
|
33
|
+
*/
|
|
34
|
+
referralCta?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Override the in-app browser banner title.
|
|
37
|
+
*/
|
|
38
|
+
inappTitle?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Override the in-app browser banner description.
|
|
41
|
+
*/
|
|
42
|
+
inappDescription?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Override the in-app browser banner CTA button text.
|
|
45
|
+
*/
|
|
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";
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/components/Banner/Banner.d.ts
|
|
60
|
+
/**
|
|
61
|
+
* Auto-detecting notification banner component.
|
|
62
|
+
*
|
|
63
|
+
* Renders an inline banner on the merchant page with one of two distinct
|
|
64
|
+
* visual styles depending on the detected mode:
|
|
65
|
+
*
|
|
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.
|
|
72
|
+
*
|
|
73
|
+
* In-app browser mode takes priority over referral mode.
|
|
74
|
+
* Uses Light DOM + vanilla-extract styles from `@frak-labs/design-system`.
|
|
75
|
+
*
|
|
76
|
+
* @group components
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* Basic usage (auto-detects mode):
|
|
80
|
+
* ```html
|
|
81
|
+
* <frak-banner></frak-banner>
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* With a custom class:
|
|
86
|
+
* ```html
|
|
87
|
+
* <frak-banner classname="my-custom-banner"></frak-banner>
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare function Banner({
|
|
91
|
+
placement: placementId,
|
|
92
|
+
classname,
|
|
93
|
+
interaction,
|
|
94
|
+
referralTitle: propReferralTitle,
|
|
95
|
+
referralDescription: propReferralDescription,
|
|
96
|
+
referralCta: propReferralCta,
|
|
97
|
+
inappTitle: propInappTitle,
|
|
98
|
+
inappDescription: propInappDescription,
|
|
99
|
+
inappCta: propInappCta,
|
|
100
|
+
preview,
|
|
101
|
+
previewMode
|
|
102
|
+
}: BannerProps): _$preact.JSX.Element | null;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/components/Banner/index.d.ts
|
|
105
|
+
/**
|
|
106
|
+
* Custom element interface for `<frak-banner>`.
|
|
107
|
+
* Combines standard {@link HTMLElement} with {@link BannerProps}.
|
|
108
|
+
*/
|
|
109
|
+
interface BannerElement extends HTMLElement, BannerProps {}
|
|
110
|
+
declare global {
|
|
111
|
+
interface HTMLElementTagNameMap {
|
|
112
|
+
"frak-banner": BannerElement;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
export { Banner, BannerElement };
|
package/dist/banner.js
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
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";
|
|
5
|
+
import { isInAppBrowser, redirectToExternalBrowser } from "@frak-labs/core-sdk";
|
|
6
|
+
import { REFERRAL_SUCCESS_EVENT, getMergeToken } from "@frak-labs/core-sdk/actions";
|
|
7
|
+
import { useCallback, useEffect, useMemo, useState } from "preact/hooks";
|
|
8
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
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",
|
|
15
|
+
fill: "none",
|
|
16
|
+
"aria-hidden": "true",
|
|
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
|
+
})
|
|
22
|
+
});
|
|
23
|
+
}
|
|
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",
|
|
31
|
+
fill: "none",
|
|
32
|
+
"aria-hidden": "true",
|
|
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
|
+
})
|
|
54
|
+
});
|
|
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
|
|
209
|
+
/**
|
|
210
|
+
* Auto-detecting notification banner component.
|
|
211
|
+
*
|
|
212
|
+
* Renders an inline banner on the merchant page with one of two distinct
|
|
213
|
+
* visual styles depending on the detected mode:
|
|
214
|
+
*
|
|
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.
|
|
221
|
+
*
|
|
222
|
+
* In-app browser mode takes priority over referral mode.
|
|
223
|
+
* Uses Light DOM + vanilla-extract styles from `@frak-labs/design-system`.
|
|
224
|
+
*
|
|
225
|
+
* @group components
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* Basic usage (auto-detects mode):
|
|
229
|
+
* ```html
|
|
230
|
+
* <frak-banner></frak-banner>
|
|
231
|
+
* ```
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* With a custom class:
|
|
235
|
+
* ```html
|
|
236
|
+
* <frak-banner classname="my-custom-banner"></frak-banner>
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
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";
|
|
242
|
+
const placement = usePlacement(placementId);
|
|
243
|
+
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
244
|
+
useLightDomStyles("frak-banner", placementId, placement?.components?.banner?.css, cssSource);
|
|
245
|
+
const [dismissed, setDismissed] = useState(false);
|
|
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]);
|
|
253
|
+
const { reward } = useReward(mode === "referral" && isClientReady, interaction);
|
|
254
|
+
const [prefetchedMergeToken, setPrefetchedMergeToken] = useState(null);
|
|
255
|
+
useEffect(() => {
|
|
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;
|
|
266
|
+
const handler = () => setMode("referral");
|
|
267
|
+
window.addEventListener(REFERRAL_SUCCESS_EVENT, handler);
|
|
268
|
+
return () => window.removeEventListener(REFERRAL_SUCCESS_EVENT, handler);
|
|
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]);
|
|
296
|
+
const bannerConfig = placement?.components?.banner;
|
|
297
|
+
const texts = useMemo(() => {
|
|
298
|
+
if (mode === "referral") {
|
|
299
|
+
const defaultTitle = reward ? `Earn ${reward} on purchases on this site` : "You've been referred!";
|
|
300
|
+
return {
|
|
301
|
+
title: propReferralTitle ?? bannerConfig?.referralTitle ?? defaultTitle,
|
|
302
|
+
description: propReferralDescription ?? bannerConfig?.referralDescription ?? "Earn rewards after your purchase via the Frak partner app.",
|
|
303
|
+
cta: propReferralCta ?? bannerConfig?.referralCta ?? "Got it"
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
title: propInappTitle ?? bannerConfig?.inappTitle ?? "Open in your browser",
|
|
308
|
+
description: propInappDescription ?? bannerConfig?.inappDescription ?? "For a better experience and to earn your rewards, open this page in your default browser.",
|
|
309
|
+
cta: propInappCta ?? bannerConfig?.inappCta ?? "Open browser"
|
|
310
|
+
};
|
|
311
|
+
}, [
|
|
312
|
+
mode,
|
|
313
|
+
reward,
|
|
314
|
+
bannerConfig,
|
|
315
|
+
propReferralTitle,
|
|
316
|
+
propReferralDescription,
|
|
317
|
+
propReferralCta,
|
|
318
|
+
propInappTitle,
|
|
319
|
+
propInappDescription,
|
|
320
|
+
propInappCta
|
|
321
|
+
]);
|
|
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,
|
|
331
|
+
role: "alert",
|
|
332
|
+
children: [
|
|
333
|
+
/* @__PURE__ */ jsxs("div", {
|
|
334
|
+
class: inappHeader,
|
|
335
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
336
|
+
class: `${inappIconWrapper} frak-banner__icon`,
|
|
337
|
+
children: /* @__PURE__ */ jsx(WarningIcon, {})
|
|
338
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
339
|
+
class: `${inappTitle} frak-banner__title`,
|
|
340
|
+
children: texts.title
|
|
341
|
+
})]
|
|
342
|
+
}),
|
|
343
|
+
/* @__PURE__ */ jsx("p", {
|
|
344
|
+
class: `${inappDescription} frak-banner__description`,
|
|
345
|
+
children: texts.description
|
|
346
|
+
}),
|
|
347
|
+
/* @__PURE__ */ jsxs("button", {
|
|
348
|
+
type: "button",
|
|
349
|
+
class: `${inappCta} frak-banner__cta`,
|
|
350
|
+
onClick: handleAction,
|
|
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, {})
|
|
359
|
+
})
|
|
360
|
+
]
|
|
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
|
+
});
|
|
388
|
+
}
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region src/components/Banner/index.ts
|
|
391
|
+
registerWebComponent(Banner, "frak-banner", [
|
|
392
|
+
"placement",
|
|
393
|
+
"classname",
|
|
394
|
+
"interaction",
|
|
395
|
+
"referralTitle",
|
|
396
|
+
"referralDescription",
|
|
397
|
+
"referralCta",
|
|
398
|
+
"inappTitle",
|
|
399
|
+
"inappDescription",
|
|
400
|
+
"inappCta",
|
|
401
|
+
"preview",
|
|
402
|
+
"previewMode"
|
|
403
|
+
], { shadow: false });
|
|
404
|
+
//#endregion
|
|
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
|
/**
|
|
@@ -7,6 +7,7 @@ import * as preact from "preact";
|
|
|
7
7
|
* @inline
|
|
8
8
|
*/
|
|
9
9
|
type ButtonShareProps = {
|
|
10
|
+
placement?: string;
|
|
10
11
|
/**
|
|
11
12
|
* Text to display on the button
|
|
12
13
|
* - To specify where the reward should be displayed, use the placeholder `{REWARD}`, e.g. `Share and earn up to \{REWARD\}!`
|
|
@@ -31,10 +32,10 @@ type ButtonShareProps = {
|
|
|
31
32
|
*/
|
|
32
33
|
targetInteraction?: InteractionTypeKey;
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @defaultValue `
|
|
35
|
+
* Which UI to open on click
|
|
36
|
+
* @defaultValue `"embedded-wallet"`
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
+
clickAction?: "embedded-wallet" | "share-modal" | "sharing-page";
|
|
38
39
|
};
|
|
39
40
|
//#endregion
|
|
40
41
|
//#region src/components/ButtonShare/ButtonShare.d.ts
|
|
@@ -80,13 +81,14 @@ type ButtonShareProps = {
|
|
|
80
81
|
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the estimated reward fetching
|
|
81
82
|
*/
|
|
82
83
|
declare function ButtonShare({
|
|
84
|
+
placement: placementId,
|
|
83
85
|
text,
|
|
84
86
|
classname,
|
|
85
87
|
useReward: rawUseReward,
|
|
86
88
|
noRewardText,
|
|
87
89
|
targetInteraction,
|
|
88
|
-
|
|
89
|
-
}: ButtonShareProps): preact.JSX.Element;
|
|
90
|
+
clickAction: rawClickAction
|
|
91
|
+
}: ButtonShareProps): _$preact.JSX.Element | null;
|
|
90
92
|
//#endregion
|
|
91
93
|
//#region src/components/ButtonShare/index.d.ts
|
|
92
94
|
/**
|