@frak-labs/components 0.0.26-beta.1c24fe7c → 0.0.26-beta.21f77a40

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 (39) hide show
  1. package/cdn/Banner.BfA_VDsk.js +132 -0
  2. package/cdn/ButtonShare.Dl8hptWq.js +1 -0
  3. package/cdn/{ButtonWallet.B7UmJcbb.js → ButtonWallet.Boy4WanE.js} +2 -2
  4. package/cdn/OpenInAppButton.BBj09SVF.js +1 -0
  5. package/cdn/PostPurchase.Dm7hQC-m.js +47 -0
  6. package/cdn/components.js +1 -1
  7. package/cdn/formatReward.D0OKqV7x.js +1 -0
  8. package/cdn/jsxRuntime.module.D7jbXhdY.js +58 -0
  9. package/cdn/loader.js +26 -26
  10. package/cdn/sprinkles.css.ts.vanilla.BtNHSSRm.js +1175 -0
  11. package/cdn/useLightDomStyles.x0mCz8nV.js +1 -0
  12. package/cdn/useReward.BnRGyYMM.js +1 -0
  13. package/cdn/useShareModal.DsoI-v9u.js +1 -0
  14. package/dist/GiftIcon-BrNVWoWm.js +1246 -0
  15. package/dist/banner.d.ts +54 -11
  16. package/dist/banner.js +337 -103
  17. package/dist/buttonShare.d.ts +2 -2
  18. package/dist/buttonShare.js +8 -13
  19. package/dist/buttonWallet.d.ts +2 -2
  20. package/dist/buttonWallet.js +3 -7
  21. package/dist/{formatReward-6JQldDEC.js → formatReward-DglcX-Xj.js} +8 -3
  22. package/dist/openInApp.d.ts +2 -2
  23. package/dist/openInApp.js +3 -9
  24. package/dist/postPurchase.d.ts +27 -3
  25. package/dist/postPurchase.js +1638 -32
  26. package/dist/{useLightDomStyles-DukxuNnJ.js → useLightDomStyles-Cjpf0MnX.js} +2 -5
  27. package/dist/{usePlacement-BbMuz8_A.js → usePlacement-LqYjZLX_.js} +1 -93
  28. package/dist/{useReward-CI2yRrCj.js → useReward-Cup3DU1-.js} +2 -4
  29. package/dist/{useShareModal-DHlayNqk.js → useShareModal-Bmlk3eBJ.js} +1 -3
  30. package/package.json +13 -9
  31. package/cdn/Banner.D-DB7VwI.js +0 -1
  32. package/cdn/ButtonShare.BM9Inhmf.js +0 -1
  33. package/cdn/OpenInAppButton.B4mrsz6L.js +0 -1
  34. package/cdn/PostPurchase.CMa-59qR.js +0 -1
  35. package/cdn/formatReward.C8hlSKRj.js +0 -1
  36. package/cdn/jsxRuntime.module.5UNmmhNi.js +0 -138
  37. package/cdn/useLightDomStyles.D895e4W1.js +0 -1
  38. package/cdn/useReward.DEU0AF3P.js +0 -1
  39. 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,226 @@
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 useLightDomStyles } from "./useLightDomStyles-Cjpf0MnX.js";
3
+ import { t as useReward } from "./useReward-Cup3DU1-.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
- //#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",
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
- children: [
23
- /* @__PURE__ */ jsx("rect", {
24
- x: "3",
25
- y: "11",
26
- width: "18",
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
- * External link icon for in-app browser mode.
45
- */
46
- function BrowserIcon() {
47
- return /* @__PURE__ */ jsxs("svg", {
48
- viewBox: "0 0 24 24",
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
- 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"
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 that auto-detects which
71
- * message to display:
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**: 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.
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 to inherit merchant page styles.
223
+ * Uses Light DOM + vanilla-extract styles from `@frak-labs/design-system`.
81
224
  *
82
225
  * @group components
83
226
  *
@@ -93,79 +236,170 @@ function BrowserIcon() {
93
236
  * <frak-banner classname="my-custom-banner"></frak-banner>
94
237
  * ```
95
238
  */
96
- function Banner({ placement: placementId, classname = "", interaction }) {
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, bannerBaseCss);
244
+ useLightDomStyles("frak-banner", placementId, placement?.components?.banner?.css, cssSource);
100
245
  const [dismissed, setDismissed] = useState(false);
101
- const [mode, setMode] = useState(() => isInAppBrowser ? "inapp" : null);
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
- if (mode === "inapp") return;
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 (mode === "referral") setDismissed(true);
111
- else redirectToExternalBrowser(window.location.href);
112
- }, [mode]);
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") {
116
299
  const defaultTitle = reward ? `Earn ${reward} on purchases on this site` : "You've been referred!";
117
300
  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"
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"
121
304
  };
122
305
  }
123
306
  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"
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"
127
310
  };
128
311
  }, [
129
312
  mode,
130
313
  reward,
131
- bannerConfig
314
+ bannerConfig,
315
+ propReferralTitle,
316
+ propReferralDescription,
317
+ propReferralCta,
318
+ propInappTitle,
319
+ propInappDescription,
320
+ propInappCta
132
321
  ]);
133
- if (!shouldRender || isHidden || dismissed || !mode) return null;
134
- return /* @__PURE__ */ jsxs("div", {
135
- class: [
136
- "banner",
137
- "banner__fadeIn",
138
- classname
139
- ].filter(Boolean).join(" "),
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,
140
331
  role: "alert",
141
332
  children: [
142
- /* @__PURE__ */ jsx("div", {
143
- class: "banner__icon",
144
- children: mode === "referral" ? /* @__PURE__ */ jsx(RewardIcon, {}) : /* @__PURE__ */ jsx(BrowserIcon, {})
145
- }),
146
333
  /* @__PURE__ */ jsxs("div", {
147
- class: "banner__content",
148
- children: [/* @__PURE__ */ jsx("p", {
149
- class: "banner__title",
150
- children: texts.title
334
+ class: inappHeader,
335
+ children: [/* @__PURE__ */ jsx("span", {
336
+ class: `${inappIconWrapper} frak-banner__icon`,
337
+ children: /* @__PURE__ */ jsx(WarningIcon, {})
151
338
  }), /* @__PURE__ */ jsx("p", {
152
- class: "banner__description",
153
- children: texts.description
339
+ class: `${inappTitle} frak-banner__title`,
340
+ children: texts.title
154
341
  })]
155
342
  }),
156
- /* @__PURE__ */ jsx("button", {
343
+ /* @__PURE__ */ jsx("p", {
344
+ class: `${inappDescription} frak-banner__description`,
345
+ children: texts.description
346
+ }),
347
+ /* @__PURE__ */ jsxs("button", {
157
348
  type: "button",
158
- class: "banner__cta",
349
+ class: `${inappCta} frak-banner__cta`,
159
350
  onClick: handleAction,
160
- 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, {})
161
359
  })
162
360
  ]
163
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
+ });
164
388
  }
165
-
166
389
  //#endregion
167
390
  //#region src/components/Banner/index.ts
168
- registerWebComponent(Banner, "frak-banner", ["placement", "classname"], { shadow: false });
169
-
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 });
170
404
  //#endregion
171
- export { Banner };
405
+ 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
  /**
@@ -1,12 +1,12 @@
1
- import { a as useClientReady, c as openEmbeddedWallet, 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";
4
- import { t as useShareModal } from "./useShareModal-DHlayNqk.js";
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 applyRewardPlaceholder } from "./formatReward-DglcX-Xj.js";
4
+ import { t as useReward } from "./useReward-Cup3DU1-.js";
5
+ import { t as useShareModal } from "./useShareModal-Bmlk3eBJ.js";
5
6
  import { trackEvent } from "@frak-labs/core-sdk";
6
7
  import { displaySharingPage } from "@frak-labs/core-sdk/actions";
7
8
  import { useCallback, useMemo, useState } from "preact/hooks";
8
9
  import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
9
-
10
10
  //#region src/utils/sharingPage.ts
11
11
  async function openSharingPage(targetInteraction, placement) {
12
12
  if (!window.FrakSetup?.client) {
@@ -15,7 +15,6 @@ async function openSharingPage(targetInteraction, placement) {
15
15
  }
16
16
  await displaySharingPage(window.FrakSetup.client, { metadata: { ...targetInteraction && { targetInteraction } } }, placement);
17
17
  }
18
-
19
18
  //#endregion
20
19
  //#region src/hooks/useCopyToClipboard.ts
21
20
  function useCopyToClipboard(options = {}) {
@@ -57,7 +56,6 @@ function useCopyToClipboard(options = {}) {
57
56
  copied
58
57
  };
59
58
  }
60
-
61
59
  //#endregion
62
60
  //#region src/components/ButtonShare/components/ErrorMessage.tsx
63
61
  const styles = {
@@ -168,7 +166,6 @@ function ErrorMessage({ debugInfo }) {
168
166
  ]
169
167
  });
170
168
  }
171
-
172
169
  //#endregion
173
170
  //#region src/components/ButtonShare/ButtonShare.tsx
174
171
  /**
@@ -226,8 +223,8 @@ function ButtonShare({ placement: placementId, text = "Share and earn!", classna
226
223
  const { handleShare, isError, debugInfo } = useShareModal(resolvedTargetInteraction, placementId);
227
224
  const btnText = useMemo(() => {
228
225
  if (!shouldUseReward) return resolvedText;
229
- if (!reward) return resolvedNoRewardText ?? resolvedText.replace("{REWARD}", "");
230
- return resolvedText.includes("{REWARD}") ? resolvedText.replace("{REWARD}", reward) : `${resolvedText} ${reward}`;
226
+ if (!reward) return resolvedNoRewardText ?? applyRewardPlaceholder(resolvedText, void 0);
227
+ return resolvedText.includes("{REWARD}") ? applyRewardPlaceholder(resolvedText, reward) : `${resolvedText} ${reward}`;
231
228
  }, [
232
229
  shouldUseReward,
233
230
  resolvedText,
@@ -259,7 +256,6 @@ function ButtonShare({ placement: placementId, text = "Share and earn!", classna
259
256
  children: btnText
260
257
  }), isError && /* @__PURE__ */ jsx(ErrorMessage, { debugInfo })] });
261
258
  }
262
-
263
259
  //#endregion
264
260
  //#region src/components/ButtonShare/index.ts
265
261
  registerWebComponent(ButtonShare, "frak-button-share", [
@@ -271,6 +267,5 @@ registerWebComponent(ButtonShare, "frak-button-share", [
271
267
  "noRewardText",
272
268
  "targetInteraction"
273
269
  ], { shadow: false });
274
-
275
270
  //#endregion
276
- export { ButtonShare };
271
+ export { ButtonShare };