@frak-labs/components 1.4.0 → 1.5.0
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/Ambassador.CZAN1-jx.js +519 -0
- package/cdn/Banner.2WJ4pT6E.js +227 -0
- package/cdn/{ButtonShare.C7A2tEvB.js → ButtonShare.DSGvJfJ-.js} +1 -1
- package/cdn/{ButtonWallet.Cg2OK1di.js → ButtonWallet.DHpHCl4c.js} +2 -2
- package/cdn/GiftIcon.DYg5xgHg.js +1 -0
- package/cdn/InstallQr.CHImaq56.js +1 -0
- package/cdn/{OpenInAppButton.Djz_cb9Y.js → OpenInAppButton.CxBzRNKw.js} +1 -1
- package/cdn/PostPurchase.CVZlV54f.js +124 -0
- package/cdn/RewardReminder.C6o8lgak.js +369 -0
- package/cdn/components.js +1 -1
- package/cdn/format.D2Ai5cCn.js +1 -0
- package/cdn/{GiftIcon.CW1SwrXH.js → icons.CdzHzZIJ.js} +1 -1
- package/cdn/jsxRuntime.module.7FJBZ9bf.js +58 -0
- package/cdn/loader.js +20 -16
- package/cdn/mountRewardReminder.BlmSRJDe.js +1 -0
- package/cdn/previewSummary.DxyobqED.js +1 -0
- package/cdn/rewardSummaryStore.DyjI-vPH.js +1 -0
- package/cdn/{rewards.t-rH9M3s.js → rewards.CeNLrK54.js} +1 -1
- package/cdn/useGlobalComponents.CNnOzerU.js +1 -0
- package/cdn/{useLightDomStyles.B72V1WPK.js → useLightDomStyles.557xWurb.js} +1 -1
- package/cdn/usePlacement.DYgmdkfr.js +1 -0
- package/cdn/{useReward.D2kXQbtD.js → useReward.BzUL3ijd.js} +1 -1
- package/dist/GiftIcon-Csu31jtf.js +62 -0
- package/dist/InstallQr-kpb44cfg.js +84 -0
- package/dist/ambassador.d.ts +16 -1
- package/dist/ambassador.js +534 -178
- package/dist/banner.d.ts +20 -6
- package/dist/banner.js +235 -13
- package/dist/format-zGdbUoX_.js +283 -0
- package/dist/i18n/defaults.d.ts +72 -0
- package/dist/i18n/defaults.js +108 -6
- package/dist/{GiftIcon-B9k_syq6.js → icons-iN3qH_Bv.js} +1 -61
- package/dist/postPurchase.d.ts +6 -1
- package/dist/postPurchase.js +187 -33
- package/dist/previewSummary-CMc6q8vI.js +37 -0
- package/dist/rewardReminder.d.ts +50 -0
- package/dist/rewardReminder.js +809 -0
- package/dist/{sharedBaseCss.css-nYy9vlzH.js → sharedBaseCss.css-D2HG4Ty8.js} +1 -1
- package/package.json +17 -11
- package/cdn/Ambassador.BDu4aVZ9.js +0 -392
- package/cdn/Banner.BqfCxKs3.js +0 -208
- package/cdn/PostPurchase.DIZneqoT.js +0 -102
- package/cdn/jsxRuntime.module.DWH-kRVd.js +0 -58
- package/cdn/useGlobalComponents.DVgSWfOp.js +0 -1
- package/cdn/usePlacement.DEOEf5_6.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as e,S as t,T as n,w as r,x as i}from"./loader.js";function a(e){return Array.isArray(e)?e:e.conditions}function o(e){if(typeof e==`number`)return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function s(e,t,n){let r=[];for(let i of a(e))if(`logic`in i)r.push(...s(i,t,n));else if(i.field===t&&n.has(i.operator)){let e=o(i.value);e!=null&&r.push(e)}return r}const c=/* @__PURE__ */ new Set([`gt`,`gte`,`between`]),l=/* @__PURE__ */ new Set([`gt`,`gte`]);function u(e){let t=s(e,`purchase.amount`,c);return t.length>0?Math.min(...t):void 0}function d(e){let t=s(e,`time.timestamp`,l);if(t.length!==0)return/* @__PURE__ */ new Date(Math.min(...t)*1e3)}function f(e,t){switch(e.payoutType){case`fixed`:return e.amount[t];case`percentage`:return e.maxAmount?.[t]??0;case`tiered`:return e.tiers.reduce((e,n)=>`amount`in n?Math.max(e,n.amount[t]):e,0)}}function p(e){return e.payoutType===`percentage`?e.percent:e.payoutType===`tiered`?e.tiers.reduce((e,t)=>`percent`in t?Math.max(e,t.percent):e,0):0}function m(e,t){let n=f(e,t);return n>0?n:p(e)*1e-6}function h(e,r){let a=n(r),o=i(a);switch(e.payoutType){case`fixed`:return t(Math.round(e.amount[o]),a);case`percentage`:return`${e.percent} %`;case`tiered`:{let n=f(e,o);if(n>0)return t(Math.round(n),a);let r=p(e);return r>0?`${r} %`:t(0,a)}}}function g(t,a){let o=n(a),s=i(o);switch(t.payoutType){case`fixed`:return e(Math.round(t.amount[s]),o);case`percentage`:return r(t.percent);case`tiered`:{let n=f(t,s);if(n>0)return e(Math.round(n),o);let i=p(t);return i>0?r(i):e(0,o)}}}function _(e,t){if(!(!e||m(e,i(n(t)))<=0))return h(e,t)}function v(e,t){return t?e.replaceAll(`{REWARD}`,t):e.replaceAll(`{REWARD}`,``)}const y=/* @__PURE__ */ new Set([`eq`,`neq`,`gt`,`gte`,`lt`,`lte`,`between`]),b=/* @__PURE__ */ new Set([`contains`,`starts_with`,`ends_with`]);function x(e){return`logic`in e&&`conditions`in e}function S(e,t){return e[t]}function C(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function w(e,t){let n=C(e),r=C(t);return n!==void 0&&r!==void 0?n-r:String(e).localeCompare(String(t))}function T(e,t,n){if(!Array.isArray(n))return e===`not_in`;if(t==null)return;let r=n.includes(t);return e===`in`?r:!r}function E(e,t,n,r){switch(e){case`eq`:return t===n;case`neq`:return t!==n;case`gt`:return w(t,n)>0;case`gte`:return w(t,n)>=0;case`lt`:return w(t,n)<0;case`lte`:return w(t,n)<=0;case`between`:return r==null||Array.isArray(r)?void 0:w(t,n)>=0&&w(t,r)<=0}}function D(e,t,n){if(typeof t==`string`&&typeof n==`string`)return e===`contains`?t.includes(n):e===`starts_with`?t.startsWith(n):t.endsWith(n)}function O(e,t){let n=S(t,e.field),{operator:r,value:i,valueTo:a}=e;if(r===`exists`)return n!=null;if(r===`not_exists`)return n==null;if(r===`in`||r===`not_in`)return T(r,n,i);if(!(Array.isArray(i)||n==null||i==null)){if(y.has(r))return E(r,n,i,a);if(b.has(r))return D(r,n,i)}}function k(e,t){if(x(e)){let n=e.conditions.map(e=>k(e,t));return e.logic===`all`?n.every(Boolean):e.logic===`any`?n.some(Boolean):e.logic!==`none`||!n.some(Boolean)}return O(e,t)??!0}function A(e,t){return e?Array.isArray(e)?e.every(e=>k(e,t)):k(e,t):!0}function j(e,t){return e.expiresAt!=null&&new Date(e.expiresAt).getTime()<=t}function M(e,t){let n=d(e.conditions);return n==null||n.getTime()<=t}function N(e,t){return t===`referee`?e.referee:e.referrer}function P(e,t,n){let r=N(e,n);return r?m(r,t):0}function F(e,t){if(!t||t.length===0||!e.productScope)return;let n=t.filter(t=>A(e.productScope,t));return n.length>0?n:void 0}function I(e,t){return!t||t.length===0||!e.productScope||t.some(t=>A(e.productScope,t))}function L(e,t={}){let r=(t.now??/* @__PURE__ */ new Date).getTime(),a=t.audience??`referrer`,o=i(n(t.currency)),s=(t.targetInteraction?e.filter(e=>e.interactionTypeKey===t.targetInteraction):e).filter(e=>!j(e,r)),c=s.filter(e=>M(e,r));if(c.length>0){let e=c.reduce((e,n)=>{let r=I(e,t.products),i=I(n,t.products);return r===i?P(n,o,a)>P(e,o,a)?n:e:i?n:e});return{campaign:e,status:`live`,matchedProducts:F(e,t.products)}}let l=s.map(e=>({campaign:e,startsAt:d(e.conditions)})).filter(e=>e.startsAt!=null);if(l.length===0)return;let u=l.reduce((e,n)=>{let r=I(e.campaign,t.products),i=I(n.campaign,t.products);return r===i?n.startsAt.getTime()<e.startsAt.getTime()?n:e:i?n:e});return{campaign:u.campaign,status:`upcoming`,startsAt:u.startsAt,matchedProducts:F(u.campaign,t.products)}}function R(e,n={}){let r=L(e,n);if(!r)return;let i=N(r.campaign,n.audience??`referrer`);if(!i)return;let a=_(i,n.currency);if(!a)return;let o=u(r.campaign.conditions),s=o==null?void 0:t(o,n.currency),c=r.campaign.defaultLockupSeconds,l=c&&c>0?Math.round(c/86400):void 0;return{formatted:a,parts:g(i,n.currency),payoutType:i.payoutType,minPurchaseAmount:s,lockupDurationDays:l,referrerReward:r.campaign.referrer,refereeReward:r.campaign.referee,minPurchaseValue:o??void 0,isProductScoped:r.campaign.productScope!=null,matchedProducts:r.matchedProducts}}export{v as i,L as n,R as r,_ as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as e}from"./loader.js";import{o as t,s as n}from"./jsxRuntime.module.7FJBZ9bf.js";function r(){return n(t,()=>e.getConfig().components)}export{r as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{m as e}from"./jsxRuntime.module.7FJBZ9bf.js";import{N as t}from"./loader.js";function n(n,r,i,a,o){e(()=>{o&&t.injectBase(`shared`,o),t.injectBase(n,a??`
|
|
2
2
|
:where(frak-button-share, frak-open-in-app) {
|
|
3
3
|
display: contents;
|
|
4
4
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as e}from"./loader.js";import{h as t,o as n,s as r}from"./jsxRuntime.module.7FJBZ9bf.js";function i(t){return e.getConfig().placements?.[t]}function a(e){let a=t(()=>e?i(e):void 0,[e]);return r(n,a)}export{a as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{s as e}from"./loader.js";import{r as t}from"./rewards.CeNLrK54.js";import{f as n,m as r}from"./jsxRuntime.module.7FJBZ9bf.js";function i(i,a,o,s){let[c,l]=n(void 0),[u,d]=n(!1);return r(()=>{if(!i)return;let n=window.FrakSetup?.client;n&&e(n).then(e=>{let r=t(e.rewards,{currency:n.config.metadata?.currency,targetInteraction:a,audience:o,products:s});d(r!==void 0),r&&r.payoutType!==`percentage`&&l(r.formatted)}).catch(()=>{})},[i,a,o,s]),{reward:c,hasReward:u}}export{i as t};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
2
|
+
// src/components/icons/GiftIcon.tsx
|
|
3
|
+
/**
|
|
4
|
+
* Gift icon with yellow accent circle and present box.
|
|
5
|
+
* Used by the referral banner, the post-purchase card and the reminder pill.
|
|
6
|
+
*/
|
|
7
|
+
function GiftIcon({ ink = "#222222", ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
9
|
+
viewBox: "0 0 100 100",
|
|
10
|
+
fill: "none",
|
|
11
|
+
"aria-hidden": "true",
|
|
12
|
+
...props,
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ jsx("circle", {
|
|
15
|
+
cx: "38",
|
|
16
|
+
cy: "28",
|
|
17
|
+
r: "23",
|
|
18
|
+
fill: "#FFF533"
|
|
19
|
+
}),
|
|
20
|
+
/* @__PURE__ */ jsx("path", {
|
|
21
|
+
d: "M50 38C30 10 12 30 50 38Z",
|
|
22
|
+
stroke: ink,
|
|
23
|
+
"stroke-width": "4",
|
|
24
|
+
"stroke-linecap": "round",
|
|
25
|
+
"stroke-linejoin": "round"
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ jsx("path", {
|
|
28
|
+
d: "M50 38C70 10 88 30 50 38Z",
|
|
29
|
+
stroke: ink,
|
|
30
|
+
"stroke-width": "4",
|
|
31
|
+
"stroke-linecap": "round",
|
|
32
|
+
"stroke-linejoin": "round"
|
|
33
|
+
}),
|
|
34
|
+
/* @__PURE__ */ jsx("rect", {
|
|
35
|
+
x: "10",
|
|
36
|
+
y: "38",
|
|
37
|
+
width: "80",
|
|
38
|
+
height: "16",
|
|
39
|
+
rx: "2",
|
|
40
|
+
stroke: ink,
|
|
41
|
+
"stroke-width": "4"
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ jsx("path", {
|
|
44
|
+
d: "M15 54V89C15 90.6 16.4 92 18 92H82C83.6 92 85 90.6 85 89V54",
|
|
45
|
+
stroke: ink,
|
|
46
|
+
"stroke-width": "4",
|
|
47
|
+
"stroke-linecap": "round",
|
|
48
|
+
"stroke-linejoin": "round"
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ jsx("line", {
|
|
51
|
+
x1: "50",
|
|
52
|
+
y1: "54",
|
|
53
|
+
x2: "50",
|
|
54
|
+
y2: "92",
|
|
55
|
+
stroke: ink,
|
|
56
|
+
"stroke-width": "4",
|
|
57
|
+
"stroke-linecap": "round"
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export { GiftIcon as t };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { useEffect, useState } from "preact/hooks";
|
|
2
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
3
|
+
// src/components/Ambassador/InstallQr.tsx
|
|
4
|
+
const WIDE_QUERY = "(min-width: 768px)";
|
|
5
|
+
const QUIET_ZONE = 4;
|
|
6
|
+
const ECC = "low";
|
|
7
|
+
/** Whether the viewport is wide enough for a QR, and its module grid once the lazy encoder has run. */
|
|
8
|
+
function useInstallQr(url) {
|
|
9
|
+
const [query] = useState(readWideQuery);
|
|
10
|
+
const [wide, setWide] = useState(() => query?.matches ?? false);
|
|
11
|
+
const [grid, setGrid] = useState(null);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!query) return;
|
|
14
|
+
const onChange = (event) => setWide(event.matches);
|
|
15
|
+
query.addEventListener("change", onChange);
|
|
16
|
+
return () => query.removeEventListener("change", onChange);
|
|
17
|
+
}, [query]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!wide || !url) return;
|
|
20
|
+
let cancelled = false;
|
|
21
|
+
import("qr").then(({ encodeQR }) => {
|
|
22
|
+
if (cancelled) return;
|
|
23
|
+
setGrid(encodeQR(url, "raw", {
|
|
24
|
+
border: QUIET_ZONE,
|
|
25
|
+
ecc: ECC
|
|
26
|
+
}));
|
|
27
|
+
}).catch(() => {});
|
|
28
|
+
return () => {
|
|
29
|
+
cancelled = true;
|
|
30
|
+
};
|
|
31
|
+
}, [wide, url]);
|
|
32
|
+
return {
|
|
33
|
+
wide,
|
|
34
|
+
grid: wide && url ? grid : null
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function QrSvg({ grid, label, class: className }) {
|
|
38
|
+
const edge = grid.length;
|
|
39
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
40
|
+
class: className,
|
|
41
|
+
width: 200,
|
|
42
|
+
height: 200,
|
|
43
|
+
viewBox: `0 0 ${edge} ${edge}`,
|
|
44
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
45
|
+
role: "img",
|
|
46
|
+
"aria-label": label,
|
|
47
|
+
focusable: "false",
|
|
48
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
49
|
+
width: edge,
|
|
50
|
+
height: edge,
|
|
51
|
+
fill: "#fff"
|
|
52
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
53
|
+
d: modulesPath(grid),
|
|
54
|
+
fill: "#000"
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function InstallQr({ url, label, caption, class: className, captionClass }) {
|
|
59
|
+
const { grid } = useInstallQr(url);
|
|
60
|
+
if (!grid) return null;
|
|
61
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
62
|
+
class: className,
|
|
63
|
+
children: [/* @__PURE__ */ jsx(QrSvg, {
|
|
64
|
+
grid,
|
|
65
|
+
label
|
|
66
|
+
}), /* @__PURE__ */ jsx("figcaption", {
|
|
67
|
+
class: captionClass,
|
|
68
|
+
children: caption
|
|
69
|
+
})]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function readWideQuery() {
|
|
73
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return null;
|
|
74
|
+
return window.matchMedia(WIDE_QUERY);
|
|
75
|
+
}
|
|
76
|
+
function modulesPath(grid) {
|
|
77
|
+
let path = "";
|
|
78
|
+
for (let row = 0; row < grid.length; row++) {
|
|
79
|
+
const cells = grid[row];
|
|
80
|
+
for (let col = 0; col < cells.length; col++) if (cells[col]) path += `M${col},${row}h1v1h-1z`;
|
|
81
|
+
}
|
|
82
|
+
return path;
|
|
83
|
+
}
|
|
84
|
+
export { QrSvg as n, useInstallQr as r, InstallQr as t };
|
package/dist/ambassador.d.ts
CHANGED
|
@@ -95,7 +95,10 @@ type AmbassadorProps = {
|
|
|
95
95
|
referralLede?: string;
|
|
96
96
|
/** Override the referral block's share-button label. */
|
|
97
97
|
referralCtaLabel?: string;
|
|
98
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Override the store block heading. While a reward waits to be claimed it
|
|
100
|
+
* defaults to "Claim your {REWARD} in the app"; the block is hidden for linked visitors.
|
|
101
|
+
*/
|
|
99
102
|
storeHeading?: string;
|
|
100
103
|
/** Override the store block lede under the heading. */
|
|
101
104
|
storeLede?: string;
|
|
@@ -137,6 +140,18 @@ type AmbassadorProps = {
|
|
|
137
140
|
attributionBeforeLink?: string;
|
|
138
141
|
/** Override the attribution anchor's text. */
|
|
139
142
|
attributionLinkText?: string;
|
|
143
|
+
/** Override the eyebrow of the "Your rewards" section shown to a visitor with an unclaimed reward. */
|
|
144
|
+
myRewardsEyebrow?: string;
|
|
145
|
+
/** Override the heading of the section shown to a linked visitor. Use `{BRAND}` for the merchant name. */
|
|
146
|
+
myRewardsLinkedHeading?: string;
|
|
147
|
+
/** Override the claim button label. `{REWARD}` marks the pending amount. */
|
|
148
|
+
myRewardsClaimCtaLabel?: string;
|
|
149
|
+
/** Override the share button label under the claim button. */
|
|
150
|
+
myRewardsShareCtaLabel?: string;
|
|
151
|
+
/** Override the label of the button opening the Frak wallet, shown to a linked visitor. */
|
|
152
|
+
myRewardsWalletCtaLabel?: string;
|
|
153
|
+
/** Override the share button label shown to a linked visitor. */
|
|
154
|
+
myRewardsShareAgainCtaLabel?: string;
|
|
140
155
|
};
|
|
141
156
|
/**
|
|
142
157
|
* Full-page ambassador: hero, reward, explainer, win-win, referral, store, FAQ;
|