@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.
- package/cdn/Banner.Ws9o79lU.js +64 -0
- package/cdn/ButtonShare.BDS1fgma.js +1 -0
- package/cdn/ButtonWallet.Be1UyRm8.js +40 -0
- package/cdn/OpenInAppButton.Diqt07eo.js +1 -0
- package/cdn/PostPurchase.DqFhm-Jn.js +52 -0
- package/cdn/components.js +1 -1
- package/cdn/formatReward.CXxVsWN3.js +1 -0
- package/cdn/loader.js +3 -55
- package/cdn/sprinkles.css.ts.vanilla.BtFkD4B3.js +1175 -0
- package/cdn/useGlobalComponents.BRe8dKO7.js +1 -0
- package/cdn/useLightDomStyles.ZFa154u8.js +1 -0
- package/cdn/usePlacement.B7jMsQvP.js +58 -0
- package/cdn/useReward.qEKeySJG.js +1 -0
- package/cdn/useShareModal.B--64ELG.js +1 -0
- package/dist/GiftIcon-4sr9xXyq.js +1501 -0
- package/dist/banner.d.ts +54 -11
- package/dist/banner.js +370 -110
- package/dist/buttonShare.d.ts +2 -2
- package/dist/buttonShare.js +11 -14
- package/dist/buttonWallet.d.ts +2 -2
- package/dist/buttonWallet.js +3 -7
- package/dist/{formatReward-6JQldDEC.js → formatReward-Bub6Z6eY.js} +8 -3
- package/dist/openInApp.d.ts +2 -2
- package/dist/openInApp.js +3 -9
- package/dist/postPurchase.d.ts +27 -3
- package/dist/postPurchase.js +1472 -33
- package/dist/useGlobalComponents-Cmfszr7v.js +21 -0
- package/dist/{useLightDomStyles-DukxuNnJ.js → useLightDomStyles-hgYYZsTy.js} +2 -5
- package/dist/{usePlacement-BbMuz8_A.js → usePlacement-LqYjZLX_.js} +1 -93
- package/dist/{useReward-CI2yRrCj.js → useReward-DU3_yP8Q.js} +2 -4
- package/dist/{useShareModal-DHlayNqk.js → useShareModal-DgEf5WWG.js} +1 -3
- package/package.json +13 -9
- package/cdn/Banner.D-DB7VwI.js +0 -1
- package/cdn/ButtonShare.BM9Inhmf.js +0 -1
- package/cdn/ButtonWallet.B7UmJcbb.js +0 -40
- package/cdn/OpenInAppButton.B4mrsz6L.js +0 -1
- package/cdn/PostPurchase.CMa-59qR.js +0 -1
- package/cdn/formatReward.C8hlSKRj.js +0 -1
- package/cdn/jsxRuntime.module.5UNmmhNi.js +0 -138
- package/cdn/useLightDomStyles.D895e4W1.js +0 -1
- package/cdn/useReward.DEU0AF3P.js +0 -1
- package/cdn/useShareModal.CN9_P7Sl.js +0 -1
package/dist/buttonShare.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, s as openEmbeddedWallet, 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 applyRewardPlaceholder } from "./formatReward-Bub6Z6eY.js";
|
|
5
|
+
import { t as useReward } from "./useReward-DU3_yP8Q.js";
|
|
6
|
+
import { t as useShareModal } from "./useShareModal-DgEf5WWG.js";
|
|
5
7
|
import { trackEvent } from "@frak-labs/core-sdk";
|
|
6
8
|
import { displaySharingPage } from "@frak-labs/core-sdk/actions";
|
|
7
9
|
import { useCallback, useMemo, useState } from "preact/hooks";
|
|
8
10
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
9
|
-
|
|
10
11
|
//#region src/utils/sharingPage.ts
|
|
11
12
|
async function openSharingPage(targetInteraction, placement) {
|
|
12
13
|
if (!window.FrakSetup?.client) {
|
|
@@ -15,7 +16,6 @@ async function openSharingPage(targetInteraction, placement) {
|
|
|
15
16
|
}
|
|
16
17
|
await displaySharingPage(window.FrakSetup.client, { metadata: { ...targetInteraction && { targetInteraction } } }, placement);
|
|
17
18
|
}
|
|
18
|
-
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/hooks/useCopyToClipboard.ts
|
|
21
21
|
function useCopyToClipboard(options = {}) {
|
|
@@ -57,7 +57,6 @@ function useCopyToClipboard(options = {}) {
|
|
|
57
57
|
copied
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
|
|
61
60
|
//#endregion
|
|
62
61
|
//#region src/components/ButtonShare/components/ErrorMessage.tsx
|
|
63
62
|
const styles = {
|
|
@@ -168,7 +167,6 @@ function ErrorMessage({ debugInfo }) {
|
|
|
168
167
|
]
|
|
169
168
|
});
|
|
170
169
|
}
|
|
171
|
-
|
|
172
170
|
//#endregion
|
|
173
171
|
//#region src/components/ButtonShare/ButtonShare.tsx
|
|
174
172
|
/**
|
|
@@ -214,7 +212,8 @@ function ErrorMessage({ debugInfo }) {
|
|
|
214
212
|
*/
|
|
215
213
|
function ButtonShare({ placement: placementId, text = "Share and earn!", classname = "", useReward: rawUseReward, noRewardText, targetInteraction, clickAction: rawClickAction }) {
|
|
216
214
|
const placement = usePlacement(placementId);
|
|
217
|
-
const
|
|
215
|
+
const globalComponents = useGlobalComponents();
|
|
216
|
+
const componentConfig = placement?.components?.buttonShare ?? globalComponents?.buttonShare;
|
|
218
217
|
useLightDomStyles("frak-button-share", placementId, componentConfig?.css);
|
|
219
218
|
const resolvedTargetInteraction = useMemo(() => placement?.targetInteraction !== void 0 ? placement.targetInteraction : targetInteraction, [placement?.targetInteraction, targetInteraction]);
|
|
220
219
|
const resolvedText = componentConfig?.text ?? text;
|
|
@@ -226,8 +225,8 @@ function ButtonShare({ placement: placementId, text = "Share and earn!", classna
|
|
|
226
225
|
const { handleShare, isError, debugInfo } = useShareModal(resolvedTargetInteraction, placementId);
|
|
227
226
|
const btnText = useMemo(() => {
|
|
228
227
|
if (!shouldUseReward) return resolvedText;
|
|
229
|
-
if (!reward) return resolvedNoRewardText ?? resolvedText
|
|
230
|
-
return resolvedText.includes("{REWARD}") ? resolvedText
|
|
228
|
+
if (!reward) return resolvedNoRewardText ?? applyRewardPlaceholder(resolvedText, void 0);
|
|
229
|
+
return resolvedText.includes("{REWARD}") ? applyRewardPlaceholder(resolvedText, reward) : `${resolvedText} ${reward}`;
|
|
231
230
|
}, [
|
|
232
231
|
shouldUseReward,
|
|
233
232
|
resolvedText,
|
|
@@ -259,7 +258,6 @@ function ButtonShare({ placement: placementId, text = "Share and earn!", classna
|
|
|
259
258
|
children: btnText
|
|
260
259
|
}), isError && /* @__PURE__ */ jsx(ErrorMessage, { debugInfo })] });
|
|
261
260
|
}
|
|
262
|
-
|
|
263
261
|
//#endregion
|
|
264
262
|
//#region src/components/ButtonShare/index.ts
|
|
265
263
|
registerWebComponent(ButtonShare, "frak-button-share", [
|
|
@@ -271,6 +269,5 @@ registerWebComponent(ButtonShare, "frak-button-share", [
|
|
|
271
269
|
"noRewardText",
|
|
272
270
|
"targetInteraction"
|
|
273
271
|
], { shadow: false });
|
|
274
|
-
|
|
275
272
|
//#endregion
|
|
276
|
-
export { ButtonShare };
|
|
273
|
+
export { ButtonShare };
|
package/dist/buttonWallet.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InteractionTypeKey } from "@frak-labs/core-sdk";
|
|
2
|
-
import * as preact from "preact";
|
|
2
|
+
import * as _$preact from "preact";
|
|
3
3
|
|
|
4
4
|
//#region src/components/ButtonWallet/types.d.ts
|
|
5
5
|
/**
|
|
@@ -70,7 +70,7 @@ declare function ButtonWallet({
|
|
|
70
70
|
classname,
|
|
71
71
|
useReward: rawUseReward,
|
|
72
72
|
targetInteraction
|
|
73
|
-
}: ButtonWalletProps): preact.JSX.Element | null;
|
|
73
|
+
}: ButtonWalletProps): _$preact.JSX.Element | null;
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/components/ButtonWallet/index.d.ts
|
|
76
76
|
/**
|
package/dist/buttonWallet.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as useReward } from "./useReward-
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, n as buildStyleContent, o as openWalletModal, t as usePlacement } from "./usePlacement-LqYjZLX_.js";
|
|
2
|
+
import { t as useReward } from "./useReward-DU3_yP8Q.js";
|
|
3
3
|
import { trackEvent } from "@frak-labs/core-sdk";
|
|
4
4
|
import { useEffect, useMemo, useState } from "preact/hooks";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
6
|
-
|
|
7
6
|
//#region src/components/ButtonWallet/assets/GiftIcon.tsx
|
|
8
7
|
function GiftIcon(props) {
|
|
9
8
|
return /* @__PURE__ */ jsxs("svg", {
|
|
@@ -21,7 +20,6 @@ function GiftIcon(props) {
|
|
|
21
20
|
})]
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
//#endregion
|
|
26
24
|
//#region src/components/ButtonWallet/ButtonWallet.tsx
|
|
27
25
|
const componentCss = `
|
|
@@ -140,7 +138,6 @@ function ButtonWallet({ placement: placementId, classname = "", useReward: rawUs
|
|
|
140
138
|
})]
|
|
141
139
|
})] });
|
|
142
140
|
}
|
|
143
|
-
|
|
144
141
|
//#endregion
|
|
145
142
|
//#region src/components/ButtonWallet/index.ts
|
|
146
143
|
registerWebComponent(ButtonWallet, "frak-button-wallet", [
|
|
@@ -149,6 +146,5 @@ registerWebComponent(ButtonWallet, "frak-button-wallet", [
|
|
|
149
146
|
"useReward",
|
|
150
147
|
"targetInteraction"
|
|
151
148
|
], { shadow: true });
|
|
152
|
-
|
|
153
149
|
//#endregion
|
|
154
|
-
export { ButtonWallet };
|
|
150
|
+
export { ButtonWallet };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { formatAmount, getCurrencyAmountKey, getSupportedCurrency } from "@frak-labs/core-sdk";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/formatReward.ts
|
|
4
3
|
/**
|
|
5
4
|
* Format an {@link EstimatedReward} into a human-readable string.
|
|
@@ -23,6 +22,12 @@ function formatEstimatedReward(reward, currency, basketAmount) {
|
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Replace the `{REWARD}` placeholder in a text string with a reward value.
|
|
27
|
+
* If no reward is provided, returns the text with `{REWARD}` stripped.
|
|
28
|
+
*/
|
|
29
|
+
function applyRewardPlaceholder(text, reward) {
|
|
30
|
+
return reward ? text.replace("{REWARD}", reward) : text.replace("{REWARD}", "");
|
|
31
|
+
}
|
|
27
32
|
//#endregion
|
|
28
|
-
export { formatEstimatedReward as t };
|
|
33
|
+
export { formatEstimatedReward as n, applyRewardPlaceholder as t };
|
package/dist/openInApp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as preact from "preact";
|
|
1
|
+
import * as _$preact from "preact";
|
|
2
2
|
|
|
3
3
|
//#region src/components/OpenInAppButton/types.d.ts
|
|
4
4
|
/**
|
|
@@ -49,7 +49,7 @@ declare function OpenInAppButton({
|
|
|
49
49
|
placement: placementId,
|
|
50
50
|
text,
|
|
51
51
|
classname
|
|
52
|
-
}: OpenInAppButtonProps): preact.JSX.Element | null;
|
|
52
|
+
}: OpenInAppButtonProps): _$preact.JSX.Element | null;
|
|
53
53
|
//#endregion
|
|
54
54
|
//#region src/components/OpenInAppButton/index.d.ts
|
|
55
55
|
/**
|
package/dist/openInApp.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
1
|
+
import { a as registerWebComponent, i as useClientReady, t as usePlacement } from "./usePlacement-LqYjZLX_.js";
|
|
2
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-hgYYZsTy.js";
|
|
3
3
|
import { DEEP_LINK_SCHEME, trackEvent, triggerDeepLinkWithFallback } from "@frak-labs/core-sdk";
|
|
4
4
|
import { useMemo } from "preact/hooks";
|
|
5
5
|
import { jsx } from "preact/jsx-runtime";
|
|
6
|
-
|
|
7
6
|
//#region src/utils/isMobile.ts
|
|
8
7
|
/**
|
|
9
8
|
* Check if the current device is a mobile device
|
|
@@ -20,13 +19,11 @@ function isMobile() {
|
|
|
20
19
|
if (/Macintosh/i.test(navigator.userAgent) && navigator.maxTouchPoints > 1) return true;
|
|
21
20
|
return false;
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
//#endregion
|
|
25
23
|
//#region src/hooks/useIsMobile.ts
|
|
26
24
|
function useIsMobile() {
|
|
27
25
|
return { isMobile: useMemo(() => isMobile(), []) };
|
|
28
26
|
}
|
|
29
|
-
|
|
30
27
|
//#endregion
|
|
31
28
|
//#region src/utils/openInApp.ts
|
|
32
29
|
const DEFAULT_PATH = "wallet";
|
|
@@ -46,7 +43,6 @@ function openFrakWalletApp(path = DEFAULT_PATH) {
|
|
|
46
43
|
if (client) trackEvent(client, "app_not_installed");
|
|
47
44
|
} });
|
|
48
45
|
}
|
|
49
|
-
|
|
50
46
|
//#endregion
|
|
51
47
|
//#region src/components/OpenInAppButton/OpenInAppButton.tsx
|
|
52
48
|
/**
|
|
@@ -99,7 +95,6 @@ function OpenInAppButton({ placement: placementId, text = "Open in App", classna
|
|
|
99
95
|
children: resolvedText
|
|
100
96
|
});
|
|
101
97
|
}
|
|
102
|
-
|
|
103
98
|
//#endregion
|
|
104
99
|
//#region src/components/OpenInAppButton/index.ts
|
|
105
100
|
registerWebComponent(OpenInAppButton, "frak-open-in-app", [
|
|
@@ -107,6 +102,5 @@ registerWebComponent(OpenInAppButton, "frak-open-in-app", [
|
|
|
107
102
|
"placement",
|
|
108
103
|
"classname"
|
|
109
104
|
], { shadow: false });
|
|
110
|
-
|
|
111
105
|
//#endregion
|
|
112
|
-
export { OpenInAppButton };
|
|
106
|
+
export { OpenInAppButton };
|
package/dist/postPurchase.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as preact from "preact";
|
|
1
|
+
import * as _$preact from "preact";
|
|
2
2
|
|
|
3
3
|
//#region src/components/PostPurchase/types.d.ts
|
|
4
4
|
/**
|
|
@@ -41,6 +41,26 @@ type PostPurchaseProps = {
|
|
|
41
41
|
* Force a display variant instead of relying on the backend evaluation.
|
|
42
42
|
*/
|
|
43
43
|
variant?: "referrer" | "referee";
|
|
44
|
+
/**
|
|
45
|
+
* Label for the pill badge displayed above the message.
|
|
46
|
+
* When omitted (and no placement config provides one), the badge is hidden.
|
|
47
|
+
*/
|
|
48
|
+
badgeText?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Override the message shown to referrers.
|
|
51
|
+
* Use `{REWARD}` as placeholder for the reward amount.
|
|
52
|
+
*/
|
|
53
|
+
referrerText?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Override the message shown to referees.
|
|
56
|
+
* Use `{REWARD}` as placeholder for the reward amount.
|
|
57
|
+
*/
|
|
58
|
+
refereeText?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Override the CTA button text.
|
|
61
|
+
* Use `{REWARD}` as placeholder for the reward amount.
|
|
62
|
+
*/
|
|
63
|
+
ctaText?: string;
|
|
44
64
|
};
|
|
45
65
|
//#endregion
|
|
46
66
|
//#region src/components/PostPurchase/PostPurchase.d.ts
|
|
@@ -80,8 +100,12 @@ declare function PostPurchase({
|
|
|
80
100
|
merchantId,
|
|
81
101
|
placement: placementId,
|
|
82
102
|
classname,
|
|
83
|
-
variant: forcedVariant
|
|
84
|
-
|
|
103
|
+
variant: forcedVariant,
|
|
104
|
+
badgeText: propBadgeText,
|
|
105
|
+
referrerText: propReferrerText,
|
|
106
|
+
refereeText: propRefereeText,
|
|
107
|
+
ctaText: propCtaText
|
|
108
|
+
}: PostPurchaseProps): _$preact.JSX.Element | null;
|
|
85
109
|
//#endregion
|
|
86
110
|
//#region src/components/PostPurchase/index.d.ts
|
|
87
111
|
/**
|