@frak-labs/components 0.0.26-beta.1c24fe7c → 0.0.26-beta.214097b3

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.
Files changed (42) hide show
  1. package/cdn/Banner.Ws9o79lU.js +64 -0
  2. package/cdn/ButtonShare.BDS1fgma.js +1 -0
  3. package/cdn/ButtonWallet.Be1UyRm8.js +40 -0
  4. package/cdn/OpenInAppButton.Diqt07eo.js +1 -0
  5. package/cdn/PostPurchase.DqFhm-Jn.js +52 -0
  6. package/cdn/components.js +1 -1
  7. package/cdn/formatReward.CXxVsWN3.js +1 -0
  8. package/cdn/loader.js +3 -55
  9. package/cdn/sprinkles.css.ts.vanilla.BtFkD4B3.js +1175 -0
  10. package/cdn/useGlobalComponents.BRe8dKO7.js +1 -0
  11. package/cdn/useLightDomStyles.ZFa154u8.js +1 -0
  12. package/cdn/usePlacement.B7jMsQvP.js +58 -0
  13. package/cdn/useReward.qEKeySJG.js +1 -0
  14. package/cdn/useShareModal.B--64ELG.js +1 -0
  15. package/dist/GiftIcon-4sr9xXyq.js +1501 -0
  16. package/dist/banner.d.ts +54 -11
  17. package/dist/banner.js +370 -110
  18. package/dist/buttonShare.d.ts +2 -2
  19. package/dist/buttonShare.js +11 -14
  20. package/dist/buttonWallet.d.ts +2 -2
  21. package/dist/buttonWallet.js +3 -7
  22. package/dist/{formatReward-6JQldDEC.js → formatReward-Bub6Z6eY.js} +8 -3
  23. package/dist/openInApp.d.ts +2 -2
  24. package/dist/openInApp.js +3 -9
  25. package/dist/postPurchase.d.ts +27 -3
  26. package/dist/postPurchase.js +1472 -33
  27. package/dist/useGlobalComponents-Cmfszr7v.js +21 -0
  28. package/dist/{useLightDomStyles-DukxuNnJ.js → useLightDomStyles-hgYYZsTy.js} +2 -5
  29. package/dist/{usePlacement-BbMuz8_A.js → usePlacement-LqYjZLX_.js} +1 -93
  30. package/dist/{useReward-CI2yRrCj.js → useReward-DU3_yP8Q.js} +2 -4
  31. package/dist/{useShareModal-DHlayNqk.js → useShareModal-DgEf5WWG.js} +1 -3
  32. package/package.json +13 -9
  33. package/cdn/Banner.D-DB7VwI.js +0 -1
  34. package/cdn/ButtonShare.BM9Inhmf.js +0 -1
  35. package/cdn/ButtonWallet.B7UmJcbb.js +0 -40
  36. package/cdn/OpenInAppButton.B4mrsz6L.js +0 -1
  37. package/cdn/PostPurchase.CMa-59qR.js +0 -1
  38. package/cdn/formatReward.C8hlSKRj.js +0 -1
  39. package/cdn/jsxRuntime.module.5UNmmhNi.js +0 -138
  40. package/cdn/useLightDomStyles.D895e4W1.js +0 -1
  41. package/cdn/useReward.DEU0AF3P.js +0 -1
  42. 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
  /**
@@ -20,23 +20,58 @@ type BannerProps = {
20
20
  * When omitted, the best reward across all interaction types is shown.
21
21
  */
22
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";
23
57
  };
24
58
  //#endregion
25
59
  //#region src/components/Banner/Banner.d.ts
26
60
  /**
27
61
  * Auto-detecting notification banner component.
28
62
  *
29
- * Renders an inline banner on the merchant page that auto-detects which
30
- * message to display:
63
+ * Renders an inline banner on the merchant page with one of two distinct
64
+ * visual styles depending on the detected mode:
31
65
  *
32
- * - **Referral mode**: Shown after successful referral link processing.
33
- * Displays reward info and a dismiss button ("Got it").
34
- * - **In-app browser mode**: Shown when the page is opened inside a social
35
- * media in-app browser (Instagram, Facebook). Offers a redirect to the
36
- * 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.
37
72
  *
38
73
  * In-app browser mode takes priority over referral mode.
39
- * Uses Light DOM to inherit merchant page styles.
74
+ * Uses Light DOM + vanilla-extract styles from `@frak-labs/design-system`.
40
75
  *
41
76
  * @group components
42
77
  *
@@ -55,8 +90,16 @@ type BannerProps = {
55
90
  declare function Banner({
56
91
  placement: placementId,
57
92
  classname,
58
- interaction
59
- }: BannerProps): preact.JSX.Element | null;
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;
60
103
  //#endregion
61
104
  //#region src/components/Banner/index.d.ts
62
105
  /**
package/dist/banner.js CHANGED
@@ -1,83 +1,264 @@
1
- import { a as useClientReady, n as bannerBaseCss, o as registerWebComponent, t as usePlacement } from "./usePlacement-BbMuz8_A.js";
2
- import { t as useLightDomStyles } from "./useLightDomStyles-DukxuNnJ.js";
3
- import { t as useReward } from "./useReward-CI2yRrCj.js";
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
- //#region src/components/Banner/Banner.tsx
10
- /**
11
- * Reward/gift icon for referral mode.
12
- */
13
- function RewardIcon() {
14
- return /* @__PURE__ */ jsxs("svg", {
15
- viewBox: "0 0 24 24",
16
- fill: "none",
17
- stroke: "currentColor",
18
- "stroke-width": "1.5",
19
- "stroke-linecap": "round",
20
- "stroke-linejoin": "round",
21
- "aria-hidden": "true",
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__ */ jsx("rect", {
24
- x: "3",
25
- y: "11",
26
- width: "18",
27
- height: "11",
28
- rx: "1"
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__ */ jsx("path", { d: "M12 11v11" }),
31
- /* @__PURE__ */ jsx("rect", {
32
- x: "5",
33
- y: "7",
34
- width: "14",
35
- height: "4",
36
- rx: "1"
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("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
- ]
41
- });
42
- }
43
- /**
44
- * External link icon for in-app browser mode.
45
- */
46
- function BrowserIcon() {
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 that auto-detects which
71
- * message to display:
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**: Shown after successful referral link processing.
74
- * Displays reward info and a dismiss button ("Got it").
75
- * - **In-app browser mode**: Shown when the page is opened inside a social
76
- * media in-app browser (Instagram, Facebook). Offers a redirect to the
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 to inherit merchant page styles.
261
+ * Uses Light DOM + vanilla-extract styles from `@frak-labs/design-system`.
81
262
  *
82
263
  * @group components
83
264
  *
@@ -93,79 +274,158 @@ function BrowserIcon() {
93
274
  * <frak-banner classname="my-custom-banner"></frak-banner>
94
275
  * ```
95
276
  */
96
- function Banner({ placement: placementId, classname = "", interaction }) {
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, bannerBaseCss);
282
+ useLightDomStyles("frak-banner", placementId, placement?.components?.banner?.css, cssSource);
100
283
  const [dismissed, setDismissed] = useState(false);
101
- const [mode, setMode] = useState(() => isInAppBrowser ? "inapp" : null);
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 (mode === "referral") setDismissed(true);
111
- else redirectToExternalBrowser(window.location.href);
112
- }, [mode]);
113
- const bannerConfig = placement?.components?.banner;
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!";
117
339
  return {
118
- title: bannerConfig?.referralTitle ?? defaultTitle,
119
- description: bannerConfig?.referralDescription ?? "Earn rewards after your purchase via the Frak partner app.",
120
- cta: bannerConfig?.referralCta ?? "Got it"
340
+ title: propReferralTitle ?? bannerConfig?.referralTitle ?? defaultTitle,
341
+ description: propReferralDescription ?? bannerConfig?.referralDescription ?? "Earn rewards after your purchase via the Frak partner app.",
342
+ cta: propReferralCta ?? bannerConfig?.referralCta ?? "Got it"
121
343
  };
122
344
  }
123
345
  return {
124
- title: bannerConfig?.inappTitle ?? "Open in your browser",
125
- description: bannerConfig?.inappDescription ?? "For a better experience and to earn your rewards, open this page in your default browser.",
126
- cta: bannerConfig?.inappCta ?? "Open browser"
346
+ title: propInappTitle ?? bannerConfig?.inappTitle ?? "Open in your browser",
347
+ description: propInappDescription ?? bannerConfig?.inappDescription ?? "For a better experience and to earn your rewards, open this page in your default browser.",
348
+ cta: propInappCta ?? bannerConfig?.inappCta ?? "Open browser"
127
349
  };
128
350
  }, [
129
351
  mode,
130
352
  reward,
131
- bannerConfig
353
+ bannerConfig,
354
+ propReferralTitle,
355
+ propReferralDescription,
356
+ propReferralCta,
357
+ propInappTitle,
358
+ propInappDescription,
359
+ propInappCta
132
360
  ]);
133
- if (!shouldRender || isHidden || dismissed || !mode) return null;
134
- return /* @__PURE__ */ jsxs("div", {
135
- class: [
136
- "banner",
137
- "banner__fadeIn",
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",
138
378
  classname
139
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,
140
390
  role: "alert",
141
- children: [
142
- /* @__PURE__ */ jsx("div", {
143
- class: "banner__icon",
144
- children: mode === "referral" ? /* @__PURE__ */ jsx(RewardIcon, {}) : /* @__PURE__ */ jsx(BrowserIcon, {})
145
- }),
146
- /* @__PURE__ */ jsxs("div", {
147
- class: "banner__content",
148
- children: [/* @__PURE__ */ jsx("p", {
149
- 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`,
150
399
  children: texts.title
151
- }), /* @__PURE__ */ jsx("p", {
152
- class: "banner__description",
400
+ }),
401
+ /* @__PURE__ */ jsx("p", {
402
+ class: `${referralDescription} frak-banner__description`,
153
403
  children: texts.description
154
- })]
155
- }),
156
- /* @__PURE__ */ jsx("button", {
157
- type: "button",
158
- class: "banner__cta",
159
- onClick: handleAction,
160
- children: texts.cta
161
- })
162
- ]
404
+ }),
405
+ /* @__PURE__ */ jsx("button", {
406
+ type: "button",
407
+ class: `${referralCta} frak-banner__cta`,
408
+ onClick: handleAction,
409
+ children: texts.cta
410
+ })
411
+ ]
412
+ })]
163
413
  });
164
414
  }
165
-
166
415
  //#endregion
167
416
  //#region src/components/Banner/index.ts
168
- registerWebComponent(Banner, "frak-banner", ["placement", "classname"], { shadow: false });
169
-
417
+ registerWebComponent(Banner, "frak-banner", [
418
+ "placement",
419
+ "classname",
420
+ "interaction",
421
+ "referralTitle",
422
+ "referralDescription",
423
+ "referralCta",
424
+ "inappTitle",
425
+ "inappDescription",
426
+ "inappCta",
427
+ "preview",
428
+ "previewMode"
429
+ ], { shadow: false });
170
430
  //#endregion
171
- export { Banner };
431
+ export { Banner };
@@ -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
  /**