@frak-labs/components 1.1.0 → 1.2.0-beta.44424a2f
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/README.md +24 -2
- package/cdn/{Banner.D-DIhGBs.js → Banner.Zaqy93tl.js} +3 -3
- package/cdn/ButtonShare.rG47WQjf.js +1 -0
- package/cdn/ButtonWallet.C13UfI2G.js +40 -0
- package/cdn/{GiftIcon.DabDdDcp.js → GiftIcon.CPyeWQNR.js} +1 -1
- package/cdn/OpenInAppButton.d-omgD0k.js +1 -0
- package/cdn/PostPurchase._3t6CtvV.js +89 -0
- package/cdn/components.js +1 -1
- package/cdn/defaults.CmUvOlLQ.js +58 -0
- package/cdn/loader.js +10 -50
- package/cdn/replay-V6FXES7X.CgBxdfNp.js +1 -0
- package/cdn/rewards.0JylBHNY.js +1 -0
- package/cdn/useGlobalComponents.C7wnXWOg.js +1 -0
- package/cdn/useLightDomStyles.B7MVlVVJ.js +1 -0
- package/cdn/useReward.CaBorN5T.js +1 -0
- package/dist/{GiftIcon-BhL0bhVu.js → GiftIcon-BmGGodb2.js} +8 -8
- package/dist/banner.d.ts +3 -4
- package/dist/banner.js +11 -11
- package/dist/buttonShare.d.ts +10 -9
- package/dist/buttonShare.js +29 -16
- package/dist/buttonWallet.d.ts +7 -6
- package/dist/buttonWallet.js +53 -34
- package/dist/i18n/defaults.d.ts +2 -3
- package/dist/i18n/defaults.js +2 -2
- package/dist/openInApp.d.ts +4 -5
- package/dist/openInApp.js +6 -6
- package/dist/postPurchase.d.ts +6 -5
- package/dist/postPurchase.js +30 -13
- package/dist/rewards-DoVY1pWr.js +290 -0
- package/dist/{useGlobalComponents-CeTO2xYs.js → useGlobalComponents-Cj7uGBwD.js} +1 -1
- package/dist/{useLightDomStyles-B2U96tzU.js → useLightDomStyles-BW6DY5sC.js} +1 -1
- package/dist/{usePlacement-Bpo25qjA.js → usePlacement-iFDQqtJn.js} +17 -40
- package/dist/{useReward-Cg2wk8XI.js → useReward-k7RF3DhH.js} +2 -2
- package/package.json +14 -14
- package/cdn/ButtonShare.C1vuLCBH.js +0 -1
- package/cdn/ButtonWallet.Co2ZFqkb.js +0 -40
- package/cdn/OpenInAppButton.DAGgrKRg.js +0 -1
- package/cdn/PostPurchase.Cs1SrMme.js +0 -89
- package/cdn/defaults.DjBUlRT8.js +0 -58
- package/cdn/embeddedWallet.Bt2bp_-q.js +0 -1
- package/cdn/replay-V6FXES7X.efKsNT6s.js +0 -1
- package/cdn/rewards.BaTam2j1.js +0 -1
- package/cdn/useGlobalComponents.4DaqvbCn.js +0 -1
- package/cdn/useLightDomStyles.DNP8gafA.js +0 -1
- package/cdn/useReward.Bi4Hs7kk.js +0 -1
- package/dist/embeddedWallet-CxgyuwtP.js +0 -18
- package/dist/rewards-CDS1CYlm.js +0 -241
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "preact/hooks";
|
|
2
2
|
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
3
3
|
import { Component, Fragment as Fragment$1, createElement, options, toChildArray } from "preact";
|
|
4
|
-
//#region ../../node_modules/.bun/preact@10.29.
|
|
4
|
+
//#region ../../node_modules/.bun/preact@10.29.8/node_modules/preact/compat/dist/compat.module.js
|
|
5
5
|
function g(n, t) {
|
|
6
6
|
for (var e in t) n[e] = t[e];
|
|
7
7
|
return n;
|
|
@@ -59,12 +59,12 @@ options.unmount = function(n) {
|
|
|
59
59
|
var e = t.__c, r = this;
|
|
60
60
|
r.o ??= [], r.o.push(e);
|
|
61
61
|
var u = j(r.__v), o = !1, i = function() {
|
|
62
|
-
o || r.__z || (o = !0, e.__R = null, u ? u(
|
|
62
|
+
o || r.__z || (o = !0, e.__R = null, u ? u(f) : f());
|
|
63
63
|
};
|
|
64
64
|
e.__R = i;
|
|
65
65
|
var l = e.__P;
|
|
66
66
|
e.__P = null;
|
|
67
|
-
var
|
|
67
|
+
var f = function() {
|
|
68
68
|
if (!--r.__u) {
|
|
69
69
|
if (r.state.__a) {
|
|
70
70
|
var n = r.state.__a;
|
|
@@ -167,8 +167,8 @@ options.vnode = function(n) {
|
|
|
167
167
|
for (var i in t) {
|
|
168
168
|
var l = t[i];
|
|
169
169
|
if (!("value" === i && "defaultValue" in t && null == l || Q && "children" === i && "noscript" === e || "class" === i || "className" === i)) {
|
|
170
|
-
var
|
|
171
|
-
"defaultValue" === i && "value" in t && null == t.value ? i = "value" : "download" === i && !0 === l ? l = "" : "translate" ===
|
|
170
|
+
var f = i.toLowerCase();
|
|
171
|
+
"defaultValue" === i && "value" in t && null == t.value ? i = "value" : "download" === i && !0 === l ? l = "" : "translate" === f && "no" === l ? l = !1 : "o" === f[0] && "n" === f[1] ? "ondoubleclick" === f ? i = "ondblclick" : "onchange" !== f || "input" !== e && "textarea" !== e || X(t.type) ? "onfocus" === f ? i = "onfocusin" : "onblur" === f ? i = "onfocusout" : J.test(i) && (i = f) : f = i = "oninput" : o && G.test(i) ? i = i.replace(K, "-$&").toLowerCase() : null === l && (l = void 0), "oninput" === f && u[i = f] && (i = "oninputCapture"), u[i] = l;
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
"select" == e && (u.multiple && Array.isArray(u.value) && (u.value = toChildArray(t.children).forEach(function(n) {
|
|
@@ -182,9 +182,9 @@ var ln = options.__r;
|
|
|
182
182
|
options.__r = function(n) {
|
|
183
183
|
ln && ln(n), n.__c;
|
|
184
184
|
};
|
|
185
|
-
var
|
|
185
|
+
var fn = options.diffed;
|
|
186
186
|
options.diffed = function(n) {
|
|
187
|
-
|
|
187
|
+
fn && fn(n);
|
|
188
188
|
var t = n.props, e = n.__e;
|
|
189
189
|
null != e && "textarea" === n.type && "value" in t && t.value !== e.value && (e.value = null == t.value ? "" : t.value);
|
|
190
190
|
};
|
|
@@ -278,7 +278,7 @@ function WarningIcon(props) {
|
|
|
278
278
|
}
|
|
279
279
|
//#endregion
|
|
280
280
|
//#region src/styles/sharedBaseCss.css.ts
|
|
281
|
-
const cssSource = ".reset_base__1831jhd0 {\n margin: 0;\n padding: 0;\n border: 0;\n box-sizing: border-box;\n font-size: 100%;\n font: inherit;\n vertical-align: baseline;\n -webkit-tap-highlight-color: transparent;\n}\n.reset_focusRing__1831jhd1 {\n outline: 2px solid transparent;\n outline-offset: 2px;\n}\n.reset_focusRing__1831jhd1:focus-visible {\n outline-color: currentColor;\n}\n.reset_fieldAppearance__1831jhd2 {\n appearance: none;\n background-color: transparent;\n}\n.reset_visuallyHidden__1831jhd3 {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0;\n}\n.reset_element_ul__1831jhd4 {\n list-style: none;\n}\n.reset_element_ol__1831jhd5 {\n list-style: none;\n}\n.reset_element_button__1831jhd6 {\n cursor: pointer;\n}\n.reset_element_a__1831jhd7 {\n text-decoration: none;\n color: inherit;\n}\n.reset_element_table__1831jhdb {\n border-collapse: collapse;\n border-spacing: 0;\n}\n.reset_element_img__1831jhdc {\n display: block;\n max-width: 100%;\n}:root {\n --text-primary__pbq4ak0: #000000;\n --text-secondary__pbq4ak1: #525252;\n --text-tertiary__pbq4ak2: #a3a3a3;\n --text-disabled__pbq4ak3: #a3a3a3;\n --text-action__pbq4ak4: #0043ef;\n --text-actionHover__pbq4ak5: #0036bf;\n --text-onAction__pbq4ak6: #ffffff;\n --text-error__pbq4ak7: #e31c31;\n --text-success__pbq4ak8: #09be67;\n --text-warning__pbq4ak9: #ec7e00;\n --surface-primary__pbq4aka: #0043ef;\n --surface-secondary__pbq4akb: #f2f6fe;\n --surface-background__pbq4akc: #ffffff;\n --surface-background2__pbq4akd: #f9fafb;\n --surface-elevated__pbq4ake: #ffffff;\n --surface-muted__pbq4akf: #f7f7f7;\n --surface-tertiary__pbq4akg: #f7f7f7;\n --surface-overlay__pbq4akh: #000000b2;\n --surface-disabled__pbq4aki: #e2e2e2;\n --surface-primaryHover__pbq4akj: #0036bf;\n --surface-primaryPressed__pbq4akk: #00288f;\n --surface-secondaryHover__pbq4akl: #e5ecfd;\n --surface-secondaryPressed__pbq4akm: #ccd9fc;\n --surface-error__pbq4akn: #fce8ea;\n --surface-success__pbq4ako: #f3fcf7;\n --surface-warning__pbq4akp: #fef9f2;\n --border-subtle__pbq4akq: #f5f5f5;\n --border-focus__pbq4akr: #a3a3a3;\n --border-error__pbq4aks: #e31c31;\n --border-success__pbq4akt: #09be67;\n --border-warning__pbq4aku: #ec7e00;\n --border-default__pbq4akv: #e2e2e2;\n --icon-primary__pbq4akw: #000000;\n --icon-secondary__pbq4akx: #525252;\n --icon-tertiary__pbq4aky: #a3a3a3;\n --icon-disabled__pbq4akz: #a3a3a3;\n --icon-action__pbq4ak10: #0043ef;\n --icon-actionHover__pbq4ak11: #0036bf;\n --icon-onAction__pbq4ak12: #ffffff;\n --icon-error__pbq4ak13: #e31c31;\n --icon-success__pbq4ak14: #09be67;\n --icon-warning__pbq4ak15: #ec7e00;\n}
|
|
281
|
+
const cssSource = ".reset_base__1831jhd0 {\n margin: 0;\n padding: 0;\n border: 0;\n box-sizing: border-box;\n font-size: 100%;\n font: inherit;\n vertical-align: baseline;\n -webkit-tap-highlight-color: transparent;\n}\n.reset_focusRing__1831jhd1 {\n outline: 2px solid transparent;\n outline-offset: 2px;\n}\n.reset_focusRing__1831jhd1:focus-visible {\n outline-color: currentColor;\n}\n.reset_fieldAppearance__1831jhd2 {\n appearance: none;\n background-color: transparent;\n}\n.reset_visuallyHidden__1831jhd3 {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0;\n}\n.reset_element_ul__1831jhd4 {\n list-style: none;\n}\n.reset_element_ol__1831jhd5 {\n list-style: none;\n}\n.reset_element_button__1831jhd6 {\n cursor: pointer;\n}\n.reset_element_a__1831jhd7 {\n text-decoration: none;\n color: inherit;\n}\n.reset_element_table__1831jhdb {\n border-collapse: collapse;\n border-spacing: 0;\n}\n.reset_element_img__1831jhdc {\n display: block;\n max-width: 100%;\n}:root {\n --text-primary__pbq4ak0: #000000;\n --text-secondary__pbq4ak1: #525252;\n --text-tertiary__pbq4ak2: #a3a3a3;\n --text-disabled__pbq4ak3: #a3a3a3;\n --text-action__pbq4ak4: #0043ef;\n --text-actionHover__pbq4ak5: #0036bf;\n --text-onAction__pbq4ak6: #ffffff;\n --text-error__pbq4ak7: #e31c31;\n --text-success__pbq4ak8: #09be67;\n --text-warning__pbq4ak9: #ec7e00;\n --surface-primary__pbq4aka: #0043ef;\n --surface-secondary__pbq4akb: #f2f6fe;\n --surface-background__pbq4akc: #ffffff;\n --surface-background2__pbq4akd: #f9fafb;\n --surface-elevated__pbq4ake: #ffffff;\n --surface-muted__pbq4akf: #f7f7f7;\n --surface-tertiary__pbq4akg: #f7f7f7;\n --surface-overlay__pbq4akh: #000000b2;\n --surface-disabled__pbq4aki: #e2e2e2;\n --surface-primaryHover__pbq4akj: #0036bf;\n --surface-primaryPressed__pbq4akk: #00288f;\n --surface-secondaryHover__pbq4akl: #e5ecfd;\n --surface-secondaryPressed__pbq4akm: #ccd9fc;\n --surface-error__pbq4akn: #fce8ea;\n --surface-success__pbq4ako: #f3fcf7;\n --surface-warning__pbq4akp: #fef9f2;\n --border-subtle__pbq4akq: #f5f5f5;\n --border-focus__pbq4akr: #a3a3a3;\n --border-error__pbq4aks: #e31c31;\n --border-success__pbq4akt: #09be67;\n --border-warning__pbq4aku: #ec7e00;\n --border-default__pbq4akv: #e2e2e2;\n --icon-primary__pbq4akw: #000000;\n --icon-secondary__pbq4akx: #525252;\n --icon-tertiary__pbq4aky: #a3a3a3;\n --icon-disabled__pbq4akz: #a3a3a3;\n --icon-action__pbq4ak10: #0043ef;\n --icon-actionHover__pbq4ak11: #0036bf;\n --icon-onAction__pbq4ak12: #ffffff;\n --icon-error__pbq4ak13: #e31c31;\n --icon-success__pbq4ak14: #09be67;\n --icon-warning__pbq4ak15: #ec7e00;\n}.sharedBaseCss_buttonReset__7cswil0 {\n margin: 0;\n border: 0;\n appearance: none;\n background-color: transparent;\n box-sizing: border-box;\n font-family: inherit;\n -webkit-tap-highlight-color: transparent;\n cursor: pointer;\n outline: 2px solid transparent;\n outline-offset: 2px;\n}\n.sharedBaseCss_buttonReset__7cswil0:focus-visible {\n outline-color: currentColor;\n}";
|
|
282
282
|
//#endregion
|
|
283
283
|
//#region src/components/icons/GiftIcon.tsx
|
|
284
284
|
/**
|
package/dist/banner.d.ts
CHANGED
|
@@ -115,18 +115,17 @@ type BannerProps = {
|
|
|
115
115
|
* <frak-banner classname="my-custom-banner"></frak-banner>
|
|
116
116
|
* ```
|
|
117
117
|
*/
|
|
118
|
-
declare function Banner({ placement: placementId, classname, interaction, products, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, imageUrl: propImageUrl, preview, previewMode, allowInappRedirect }: BannerProps): import("preact").JSX.Element | null;
|
|
118
|
+
export declare function Banner({ placement: placementId, classname, interaction, products, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, imageUrl: propImageUrl, preview, previewMode, allowInappRedirect }: BannerProps): import("preact").JSX.Element | null;
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/components/Banner/index.d.ts
|
|
121
121
|
/**
|
|
122
122
|
* Custom element interface for `<frak-banner>`.
|
|
123
123
|
* Combines standard {@link HTMLElement} with {@link BannerProps}.
|
|
124
124
|
*/
|
|
125
|
-
interface BannerElement extends HTMLElement, BannerProps {}
|
|
125
|
+
export interface BannerElement extends HTMLElement, BannerProps {}
|
|
126
126
|
declare global {
|
|
127
127
|
interface HTMLElementTagNameMap {
|
|
128
128
|
"frak-banner": BannerElement;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
//#endregion
|
|
132
|
-
export { Banner, BannerElement };
|
|
131
|
+
//#endregion
|
package/dist/banner.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { t as useReward } from "./useReward-
|
|
1
|
+
import { i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
2
|
+
import { i as w } from "./rewards-DoVY1pWr.js";
|
|
3
|
+
import { t as useGlobalComponents } from "./useGlobalComponents-Cj7uGBwD.js";
|
|
4
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-BW6DY5sC.js";
|
|
5
|
+
import { t as useReward } from "./useReward-k7RF3DhH.js";
|
|
6
6
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
7
|
-
import { a as ExternalLinkIcon, i as LogoFrakWithName, n as cssSource$5, o as CloseCircleIcon, r as WarningIcon, t as GiftIcon } from "./GiftIcon-
|
|
7
|
+
import { a as ExternalLinkIcon, i as LogoFrakWithName, n as cssSource$5, o as CloseCircleIcon, r as WarningIcon, t as GiftIcon } from "./GiftIcon-BmGGodb2.js";
|
|
8
8
|
import { isInAppBrowser, redirectToExternalBrowser, sanitizeProductDetailsList, trackEvent } from "@frak-labs/core-sdk";
|
|
9
9
|
import { REFERRAL_SUCCESS_EVENT, getMergeToken } from "@frak-labs/core-sdk/actions";
|
|
10
10
|
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
@@ -40,7 +40,7 @@ const cssSource$4 = `@keyframes keyframes_fadeIn__mnqmlt0 {
|
|
|
40
40
|
//#region \0ve-inline:../../packages/design-system/src/styles/inAppBanner.css.ts.vanilla.js
|
|
41
41
|
const cssSource$3 = `.inAppBanner_container__1ibpiy70 {
|
|
42
42
|
position: fixed;
|
|
43
|
-
top: max(8px, env(safe-area-inset-top));
|
|
43
|
+
top: max(8px, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
|
|
44
44
|
left: 16px;
|
|
45
45
|
right: 16px;
|
|
46
46
|
z-index: 1000;
|
|
@@ -403,14 +403,14 @@ function Banner({ placement: placementId, classname = "", interaction, products,
|
|
|
403
403
|
if (mode === "referral") {
|
|
404
404
|
const defaultTitle = reward ? defaults.referralTitleReward : defaults.referralTitle;
|
|
405
405
|
return {
|
|
406
|
-
title:
|
|
407
|
-
description:
|
|
406
|
+
title: w(propReferralTitle ?? bannerConfig?.referralTitle ?? defaultTitle, reward),
|
|
407
|
+
description: w(propReferralDescription ?? bannerConfig?.referralDescription ?? defaults.referralDescription, reward),
|
|
408
408
|
cta: propReferralCta ?? bannerConfig?.referralCta ?? defaults.referralCta
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
411
|
return {
|
|
412
|
-
title:
|
|
413
|
-
description:
|
|
412
|
+
title: w(propInappTitle ?? bannerConfig?.inappTitle ?? defaults.inappTitle, void 0),
|
|
413
|
+
description: w(propInappDescription ?? bannerConfig?.inappDescription ?? defaults.inappDescription, void 0),
|
|
414
414
|
cta: propInappCta ?? bannerConfig?.inappCta ?? defaults.inappCta
|
|
415
415
|
};
|
|
416
416
|
}, [
|
package/dist/buttonShare.d.ts
CHANGED
|
@@ -43,15 +43,17 @@ type ButtonShareProps = {
|
|
|
43
43
|
*/
|
|
44
44
|
products?: SharingPageProduct[] | string;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Reported on the `share_button_clicked` event.
|
|
47
47
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
48
|
+
* It no longer selects anything: every click opens the full-page sharing
|
|
49
|
+
* UI. Retired values (`"share-modal"`, `"embedded-wallet"`) stay accepted
|
|
50
|
+
* because merchant configs and saved plugin markup still carry them, and
|
|
51
|
+
* the resolved value is reported as-is so a legacy config stays visible in
|
|
52
|
+
* analytics.
|
|
51
53
|
*
|
|
52
54
|
* @defaultValue `"sharing-page"`
|
|
53
55
|
*/
|
|
54
|
-
clickAction?: "
|
|
56
|
+
clickAction?: "sharing-page" | (string & {});
|
|
55
57
|
/**
|
|
56
58
|
* When set, renders the button in preview mode (e.g. Shopify/WP editor).
|
|
57
59
|
* Skips the client-ready gating so the button is always enabled visually,
|
|
@@ -114,18 +116,17 @@ type ButtonShareProps = {
|
|
|
114
116
|
* @see {@link @frak-labs/core-sdk!actions.displaySharingPage | `displaySharingPage()`} for more info about the sharing-page flow
|
|
115
117
|
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the estimated reward fetching
|
|
116
118
|
*/
|
|
117
|
-
declare function ButtonShare({ placement: placementId, text, classname, noRewardText, targetInteraction, products, clickAction: rawClickAction, preview }: ButtonShareProps): import("preact").JSX.Element | null;
|
|
119
|
+
export declare function ButtonShare({ placement: placementId, text, classname, noRewardText, targetInteraction, products, clickAction: rawClickAction, preview }: ButtonShareProps): import("preact").JSX.Element | null;
|
|
118
120
|
//#endregion
|
|
119
121
|
//#region src/components/ButtonShare/index.d.ts
|
|
120
122
|
/**
|
|
121
123
|
* Custom element interface for `<frak-button-share>`.
|
|
122
124
|
* Combines standard {@link HTMLElement} with {@link ButtonShareProps}.
|
|
123
125
|
*/
|
|
124
|
-
interface ButtonShareElement extends HTMLElement, ButtonShareProps {}
|
|
126
|
+
export interface ButtonShareElement extends HTMLElement, ButtonShareProps {}
|
|
125
127
|
declare global {
|
|
126
128
|
interface HTMLElementTagNameMap {
|
|
127
129
|
"frak-button-share": ButtonShareElement;
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
|
-
//#endregion
|
|
131
|
-
export { ButtonShare, ButtonShareElement };
|
|
132
|
+
//#endregion
|
package/dist/buttonShare.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-
|
|
2
|
-
import {
|
|
3
|
-
import { t as useGlobalComponents } from "./useGlobalComponents-
|
|
4
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
5
|
-
import {
|
|
6
|
-
import { t as useReward } from "./useReward-Cg2wk8XI.js";
|
|
1
|
+
import { c as openSharingPage, i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
2
|
+
import { i as w } from "./rewards-DoVY1pWr.js";
|
|
3
|
+
import { t as useGlobalComponents } from "./useGlobalComponents-Cj7uGBwD.js";
|
|
4
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-BW6DY5sC.js";
|
|
5
|
+
import { t as useReward } from "./useReward-k7RF3DhH.js";
|
|
7
6
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
8
7
|
import { sanitizeSharingProducts, trackEvent } from "@frak-labs/core-sdk";
|
|
9
|
-
import { useCallback, useMemo } from "preact/hooks";
|
|
8
|
+
import { useCallback, useEffect, useMemo, useRef } from "preact/hooks";
|
|
10
9
|
import { jsx } from "preact/jsx-runtime";
|
|
11
10
|
//#region src/components/ButtonShare/ButtonShare.tsx
|
|
12
11
|
/**
|
|
@@ -68,24 +67,42 @@ function ButtonShare({ placement: placementId, text, classname = "", noRewardTex
|
|
|
68
67
|
const globalComponents = useGlobalComponents();
|
|
69
68
|
const componentConfig = placement?.components?.buttonShare ?? globalComponents?.buttonShare;
|
|
70
69
|
useLightDomStyles("frak-button-share", placementId, componentConfig?.css);
|
|
71
|
-
const resolvedTargetInteraction =
|
|
70
|
+
const resolvedTargetInteraction = placement?.targetInteraction !== void 0 ? placement.targetInteraction : targetInteraction;
|
|
72
71
|
const resolvedText = componentConfig?.text ?? text ?? componentDefaults[lang].buttonShare.text;
|
|
73
72
|
const resolvedNoRewardText = componentConfig?.noRewardText ?? noRewardText;
|
|
74
|
-
const wantsReward =
|
|
75
|
-
const resolvedClickAction =
|
|
73
|
+
const wantsReward = resolvedText.includes("{REWARD}");
|
|
74
|
+
const resolvedClickAction = componentConfig?.clickAction ?? rawClickAction ?? "sharing-page";
|
|
76
75
|
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
77
76
|
const parsedProducts = useMemo(() => sanitizeSharingProducts(products), [products]);
|
|
78
77
|
const { reward } = useReward(wantsReward && isClientReady, resolvedTargetInteraction, void 0, parsedProducts);
|
|
79
78
|
const btnText = useMemo(() => {
|
|
80
79
|
if (!wantsReward) return resolvedText;
|
|
81
|
-
if (reward) return
|
|
82
|
-
return resolvedNoRewardText ??
|
|
80
|
+
if (reward) return w(resolvedText, reward);
|
|
81
|
+
return resolvedNoRewardText ?? w(resolvedText, void 0);
|
|
83
82
|
}, [
|
|
84
83
|
wantsReward,
|
|
85
84
|
resolvedText,
|
|
86
85
|
resolvedNoRewardText,
|
|
87
86
|
reward
|
|
88
87
|
]);
|
|
88
|
+
const trackedImpressionRef = useRef(false);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (isPreview || trackedImpressionRef.current) return;
|
|
91
|
+
if (!isClientReady || !shouldRender || isHidden) return;
|
|
92
|
+
trackEvent(window.FrakSetup?.client, "share_button_impression", {
|
|
93
|
+
placement: placementId,
|
|
94
|
+
target_interaction: resolvedTargetInteraction,
|
|
95
|
+
has_reward: Boolean(reward)
|
|
96
|
+
});
|
|
97
|
+
trackedImpressionRef.current = true;
|
|
98
|
+
}, [
|
|
99
|
+
isPreview,
|
|
100
|
+
isClientReady,
|
|
101
|
+
shouldRender,
|
|
102
|
+
isHidden,
|
|
103
|
+
placementId,
|
|
104
|
+
resolvedTargetInteraction
|
|
105
|
+
]);
|
|
89
106
|
const onClick = useCallback(() => {
|
|
90
107
|
if (isPreview) return;
|
|
91
108
|
trackEvent(window.FrakSetup.client, "share_button_clicked", {
|
|
@@ -94,10 +111,6 @@ function ButtonShare({ placement: placementId, text, classname = "", noRewardTex
|
|
|
94
111
|
has_reward: Boolean(reward),
|
|
95
112
|
click_action: resolvedClickAction
|
|
96
113
|
});
|
|
97
|
-
if (resolvedClickAction === "embedded-wallet") {
|
|
98
|
-
openEmbeddedWallet(resolvedTargetInteraction, placementId);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
114
|
openSharingPage(resolvedTargetInteraction, placementId, { products: parsedProducts });
|
|
102
115
|
}, [
|
|
103
116
|
isPreview,
|
package/dist/buttonWallet.d.ts
CHANGED
|
@@ -23,7 +23,9 @@ type ButtonWalletProps = {
|
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/components/ButtonWallet/ButtonWallet.d.ts
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Floating circular button that opens the Frak sharing page. The
|
|
27
|
+
* `frak-button-wallet` tag name is public API (merchant markup, Magento
|
|
28
|
+
* template), so it stays even though it no longer names the surface.
|
|
27
29
|
*
|
|
28
30
|
* @param args
|
|
29
31
|
* @returns The wallet button with `<button>` tag
|
|
@@ -60,21 +62,20 @@ type ButtonWalletProps = {
|
|
|
60
62
|
* <frak-button-wallet placement="hero-wallet"></frak-button-wallet>
|
|
61
63
|
* ```
|
|
62
64
|
*
|
|
63
|
-
* @see {@link @frak-labs/core-sdk!actions.
|
|
65
|
+
* @see {@link @frak-labs/core-sdk!actions.displaySharingPage | `displaySharingPage()`} for more info about the sharing page
|
|
64
66
|
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the estimated reward fetching
|
|
65
67
|
*/
|
|
66
|
-
declare function ButtonWallet({ placement: placementId, classname, useReward: rawUseReward, targetInteraction }: ButtonWalletProps): import("preact").JSX.Element | null;
|
|
68
|
+
export declare function ButtonWallet({ placement: placementId, classname, useReward: rawUseReward, targetInteraction }: ButtonWalletProps): import("preact").JSX.Element | null;
|
|
67
69
|
//#endregion
|
|
68
70
|
//#region src/components/ButtonWallet/index.d.ts
|
|
69
71
|
/**
|
|
70
72
|
* Custom element interface for `<frak-button-wallet>`.
|
|
71
73
|
* Combines standard {@link HTMLElement} with {@link ButtonWalletProps}.
|
|
72
74
|
*/
|
|
73
|
-
interface ButtonWalletElement extends HTMLElement, ButtonWalletProps {}
|
|
75
|
+
export interface ButtonWalletElement extends HTMLElement, ButtonWalletProps {}
|
|
74
76
|
declare global {
|
|
75
77
|
interface HTMLElementTagNameMap {
|
|
76
78
|
"frak-button-wallet": ButtonWalletElement;
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
|
-
//#endregion
|
|
80
|
-
export { ButtonWallet, ButtonWalletElement };
|
|
81
|
+
//#endregion
|
package/dist/buttonWallet.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import { i as useLang, n as buildStyleContent, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as useReward } from "./useReward-Cg2wk8XI.js";
|
|
1
|
+
import { c as openSharingPage, i as useLang, n as buildStyleContent, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
2
|
+
import { t as useReward } from "./useReward-k7RF3DhH.js";
|
|
4
3
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
5
|
-
import {
|
|
4
|
+
import { trackEvent } from "@frak-labs/core-sdk";
|
|
5
|
+
import { useCallback, useEffect, useRef } from "preact/hooks";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
7
|
-
//#region src/
|
|
8
|
-
|
|
7
|
+
//#region src/utils/browser/safeVibrate.ts
|
|
8
|
+
/**
|
|
9
|
+
* Attempt to vibrate the device
|
|
10
|
+
*/
|
|
11
|
+
function safeVibrate() {
|
|
12
|
+
if ("vibrate" in navigator) navigator.vibrate(10);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/components/ButtonWallet/assets/WalletGiftIcon.tsx
|
|
16
|
+
function WalletGiftIcon(props) {
|
|
9
17
|
return /* @__PURE__ */ jsxs("svg", {
|
|
10
18
|
fill: "none",
|
|
11
19
|
height: "1em",
|
|
@@ -22,21 +30,6 @@ function GiftIcon(props) {
|
|
|
22
30
|
});
|
|
23
31
|
}
|
|
24
32
|
//#endregion
|
|
25
|
-
//#region src/utils/browser/safeVibrate.ts
|
|
26
|
-
/**
|
|
27
|
-
* Attempt to vibrate the device
|
|
28
|
-
*/
|
|
29
|
-
function safeVibrate() {
|
|
30
|
-
if ("vibrate" in navigator) navigator.vibrate(10);
|
|
31
|
-
else console.log("Vibration not supported");
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/components/ButtonWallet/utils.ts
|
|
35
|
-
function openWalletModal(targetInteraction, placement) {
|
|
36
|
-
safeVibrate();
|
|
37
|
-
openEmbeddedWallet(targetInteraction, placement);
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
33
|
//#region src/components/ButtonWallet/ButtonWallet.tsx
|
|
41
34
|
const componentCss = `
|
|
42
35
|
.button {
|
|
@@ -79,7 +72,9 @@ const componentCss = `
|
|
|
79
72
|
}
|
|
80
73
|
`;
|
|
81
74
|
/**
|
|
82
|
-
*
|
|
75
|
+
* Floating circular button that opens the Frak sharing page. The
|
|
76
|
+
* `frak-button-wallet` tag name is public API (merchant markup, Magento
|
|
77
|
+
* template), so it stays even though it no longer names the surface.
|
|
83
78
|
*
|
|
84
79
|
* @param args
|
|
85
80
|
* @returns The wallet button with `<button>` tag
|
|
@@ -116,22 +111,48 @@ const componentCss = `
|
|
|
116
111
|
* <frak-button-wallet placement="hero-wallet"></frak-button-wallet>
|
|
117
112
|
* ```
|
|
118
113
|
*
|
|
119
|
-
* @see {@link @frak-labs/core-sdk!actions.
|
|
114
|
+
* @see {@link @frak-labs/core-sdk!actions.displaySharingPage | `displaySharingPage()`} for more info about the sharing page
|
|
120
115
|
* @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the estimated reward fetching
|
|
121
116
|
*/
|
|
122
117
|
function ButtonWallet({ placement: placementId, classname = "", useReward: rawUseReward, targetInteraction }) {
|
|
123
118
|
const lang = useLang();
|
|
124
119
|
const placement = usePlacement(placementId);
|
|
125
|
-
const resolvedTargetInteraction =
|
|
126
|
-
const shouldUseReward =
|
|
120
|
+
const resolvedTargetInteraction = placement?.targetInteraction !== void 0 ? placement.targetInteraction : targetInteraction;
|
|
121
|
+
const shouldUseReward = rawUseReward === true;
|
|
127
122
|
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
128
123
|
const { reward } = useReward(shouldUseReward && isClientReady, resolvedTargetInteraction);
|
|
129
|
-
const
|
|
124
|
+
const position = placement?.components?.buttonWallet?.position ?? window.FrakSetup?.modalWalletConfig?.metadata?.position ?? "right";
|
|
125
|
+
const trackedImpressionRef = useRef(false);
|
|
130
126
|
useEffect(() => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
127
|
+
if (trackedImpressionRef.current) return;
|
|
128
|
+
if (!isClientReady || !shouldRender || isHidden) return;
|
|
129
|
+
trackEvent(window.FrakSetup?.client, "share_button_impression", {
|
|
130
|
+
placement: placementId,
|
|
131
|
+
target_interaction: resolvedTargetInteraction,
|
|
132
|
+
has_reward: Boolean(reward)
|
|
133
|
+
});
|
|
134
|
+
trackedImpressionRef.current = true;
|
|
135
|
+
}, [
|
|
136
|
+
isClientReady,
|
|
137
|
+
shouldRender,
|
|
138
|
+
isHidden,
|
|
139
|
+
placementId,
|
|
140
|
+
resolvedTargetInteraction
|
|
141
|
+
]);
|
|
142
|
+
const onClick = useCallback(() => {
|
|
143
|
+
trackEvent(window.FrakSetup.client, "share_button_clicked", {
|
|
144
|
+
placement: placementId,
|
|
145
|
+
target_interaction: resolvedTargetInteraction,
|
|
146
|
+
has_reward: Boolean(reward),
|
|
147
|
+
click_action: "sharing-page"
|
|
148
|
+
});
|
|
149
|
+
safeVibrate();
|
|
150
|
+
openSharingPage(resolvedTargetInteraction, placementId);
|
|
151
|
+
}, [
|
|
152
|
+
placementId,
|
|
153
|
+
resolvedTargetInteraction,
|
|
154
|
+
reward
|
|
155
|
+
]);
|
|
135
156
|
if (!shouldRender || isHidden) return null;
|
|
136
157
|
const buttonClass = [
|
|
137
158
|
"button",
|
|
@@ -145,10 +166,8 @@ function ButtonWallet({ placement: placementId, classname = "", useReward: rawUs
|
|
|
145
166
|
part: "button",
|
|
146
167
|
disabled: !isClientReady,
|
|
147
168
|
class: buttonClass,
|
|
148
|
-
onClick
|
|
149
|
-
|
|
150
|
-
},
|
|
151
|
-
children: [/* @__PURE__ */ jsx(GiftIcon, {}), reward && /* @__PURE__ */ jsx("span", {
|
|
169
|
+
onClick,
|
|
170
|
+
children: [/* @__PURE__ */ jsx(WalletGiftIcon, {}), reward && /* @__PURE__ */ jsx("span", {
|
|
152
171
|
class: "reward",
|
|
153
172
|
children: reward
|
|
154
173
|
})]
|
package/dist/i18n/defaults.d.ts
CHANGED
|
@@ -50,6 +50,5 @@ type ComponentCopy = {
|
|
|
50
50
|
* the `Language` union in `@frak-labs/core-sdk` — no new dependency, no
|
|
51
51
|
* merchant action, no SDK API change.
|
|
52
52
|
*/
|
|
53
|
-
declare const componentDefaults: Record<Language, ComponentCopy>;
|
|
54
|
-
//#endregion
|
|
55
|
-
export { componentDefaults };
|
|
53
|
+
export declare const componentDefaults: Record<Language, ComponentCopy>;
|
|
54
|
+
//#endregion
|
package/dist/i18n/defaults.js
CHANGED
|
@@ -27,7 +27,7 @@ const componentDefaults = {
|
|
|
27
27
|
text: "Open in App",
|
|
28
28
|
ariaLabel: "Open in Frak Wallet app"
|
|
29
29
|
},
|
|
30
|
-
buttonWallet: { ariaLabel: "
|
|
30
|
+
buttonWallet: { ariaLabel: "Share and earn rewards" },
|
|
31
31
|
banner: {
|
|
32
32
|
referralTitleReward: "Earn {REWARD} on purchases",
|
|
33
33
|
referralTitle: "You've been referred!",
|
|
@@ -53,7 +53,7 @@ const componentDefaults = {
|
|
|
53
53
|
text: "Ouvrir dans l'app",
|
|
54
54
|
ariaLabel: "Ouvrir dans l'app Frak Wallet"
|
|
55
55
|
},
|
|
56
|
-
buttonWallet: { ariaLabel: "
|
|
56
|
+
buttonWallet: { ariaLabel: "Partagez et gagnez des récompenses" },
|
|
57
57
|
banner: {
|
|
58
58
|
referralTitleReward: "Gagnez {REWARD} sur vos achats",
|
|
59
59
|
referralTitle: "Vous avez été parrainé !",
|
package/dist/openInApp.d.ts
CHANGED
|
@@ -40,23 +40,22 @@ type OpenInAppButtonProps = {
|
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
|
-
*
|
|
43
|
+
* Using a custom class:
|
|
44
44
|
* ```html
|
|
45
45
|
* <frak-open-in-app classname="button button-primary"></frak-open-in-app>
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
|
-
declare function OpenInAppButton({ placement: placementId, text, classname }: OpenInAppButtonProps): import("preact").JSX.Element | null;
|
|
48
|
+
export declare function OpenInAppButton({ placement: placementId, text, classname }: OpenInAppButtonProps): import("preact").JSX.Element | null;
|
|
49
49
|
//#endregion
|
|
50
50
|
//#region src/components/OpenInAppButton/index.d.ts
|
|
51
51
|
/**
|
|
52
52
|
* Custom element interface for `<frak-open-in-app>`.
|
|
53
53
|
* Combines standard {@link HTMLElement} with {@link OpenInAppButtonProps}.
|
|
54
54
|
*/
|
|
55
|
-
interface OpenInAppButtonElement extends HTMLElement, OpenInAppButtonProps {}
|
|
55
|
+
export interface OpenInAppButtonElement extends HTMLElement, OpenInAppButtonProps {}
|
|
56
56
|
declare global {
|
|
57
57
|
interface HTMLElementTagNameMap {
|
|
58
58
|
"frak-open-in-app": OpenInAppButtonElement;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
|
-
export { OpenInAppButton, OpenInAppButtonElement };
|
|
61
|
+
//#endregion
|
package/dist/openInApp.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-
|
|
2
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
1
|
+
import { i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-iFDQqtJn.js";
|
|
2
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-BW6DY5sC.js";
|
|
3
3
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
4
4
|
import { DEEP_LINK_SCHEME, isMobile, trackEvent, triggerDeepLinkWithFallback } from "@frak-labs/core-sdk";
|
|
5
|
-
import { useMemo } from "preact/hooks";
|
|
6
5
|
import { jsx } from "preact/jsx-runtime";
|
|
7
6
|
//#region src/actions/openInApp.ts
|
|
8
7
|
const DEFAULT_PATH = "wallet";
|
|
@@ -19,7 +18,8 @@ function openFrakWalletApp(path = DEFAULT_PATH, placement) {
|
|
|
19
18
|
path,
|
|
20
19
|
placement
|
|
21
20
|
});
|
|
22
|
-
|
|
21
|
+
const deepLink = `${DEEP_LINK_SCHEME}${path}`;
|
|
22
|
+
triggerDeepLinkWithFallback(deepLink, { onFallback: () => {
|
|
23
23
|
if (client) trackEvent(client, "app_not_installed", {
|
|
24
24
|
path,
|
|
25
25
|
placement
|
|
@@ -29,7 +29,7 @@ function openFrakWalletApp(path = DEFAULT_PATH, placement) {
|
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/hooks/useIsMobile.ts
|
|
31
31
|
function useIsMobile() {
|
|
32
|
-
return { isMobile:
|
|
32
|
+
return { isMobile: isMobile() };
|
|
33
33
|
}
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/components/OpenInAppButton/OpenInAppButton.tsx
|
|
@@ -54,7 +54,7 @@ function useIsMobile() {
|
|
|
54
54
|
* ```
|
|
55
55
|
*
|
|
56
56
|
* @example
|
|
57
|
-
*
|
|
57
|
+
* Using a custom class:
|
|
58
58
|
* ```html
|
|
59
59
|
* <frak-open-in-app classname="button button-primary"></frak-open-in-app>
|
|
60
60
|
* ```
|
package/dist/postPurchase.d.ts
CHANGED
|
@@ -16,7 +16,9 @@ type PostPurchaseProps = {
|
|
|
16
16
|
*/
|
|
17
17
|
orderId?: string;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Opaque per-order token. Feeds purchase tracking, and travels to the
|
|
20
|
+
* sharing page so the install CTA still carries a credential when the
|
|
21
|
+
* anonymous id is unavailable.
|
|
20
22
|
*/
|
|
21
23
|
token?: string;
|
|
22
24
|
/**
|
|
@@ -119,18 +121,17 @@ type PostPurchaseProps = {
|
|
|
119
121
|
* ></frak-post-purchase>
|
|
120
122
|
* ```
|
|
121
123
|
*/
|
|
122
|
-
declare function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, placement: placementId, classname, variant: forcedVariant, badgeText: propBadgeText, referrerText: propReferrerText, refereeText: propRefereeText, ctaText: propCtaText, preview, previewVariant, products, imageUrl: propImageUrl }: PostPurchaseProps): import("preact").JSX.Element | null;
|
|
124
|
+
export declare function PostPurchase({ customerId, orderId, token, sharingUrl, merchantId, placement: placementId, classname, variant: forcedVariant, badgeText: propBadgeText, referrerText: propReferrerText, refereeText: propRefereeText, ctaText: propCtaText, preview, previewVariant, products, imageUrl: propImageUrl }: PostPurchaseProps): import("preact").JSX.Element | null;
|
|
123
125
|
//#endregion
|
|
124
126
|
//#region src/components/PostPurchase/index.d.ts
|
|
125
127
|
/**
|
|
126
128
|
* Custom element interface for `<frak-post-purchase>`.
|
|
127
129
|
* Combines standard {@link HTMLElement} with {@link PostPurchaseProps}.
|
|
128
130
|
*/
|
|
129
|
-
interface PostPurchaseElement extends HTMLElement, PostPurchaseProps {}
|
|
131
|
+
export interface PostPurchaseElement extends HTMLElement, PostPurchaseProps {}
|
|
130
132
|
declare global {
|
|
131
133
|
interface HTMLElementTagNameMap {
|
|
132
134
|
"frak-post-purchase": PostPurchaseElement;
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
|
-
//#endregion
|
|
136
|
-
export { PostPurchase, PostPurchaseElement };
|
|
137
|
+
//#endregion
|