@frak-labs/components 1.2.0 → 1.2.1-beta.24294996
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.DdAIrKFw.js → Banner.Zaqy93tl.js} +3 -3
- package/cdn/ButtonShare.rG47WQjf.js +1 -0
- package/cdn/ButtonWallet.C13UfI2G.js +40 -0
- package/cdn/OpenInAppButton.d-omgD0k.js +1 -0
- package/cdn/PostPurchase._3t6CtvV.js +89 -0
- package/cdn/components.js +1 -1
- package/cdn/loader.js +8 -52
- package/cdn/replay-V6FXES7X.CgBxdfNp.js +1 -0
- package/cdn/{useLightDomStyles.BLyrWEBn.js → useLightDomStyles.B7MVlVVJ.js} +1 -1
- package/dist/{GiftIcon-DI0rUKHp.js → GiftIcon-BmGGodb2.js} +1 -1
- package/dist/banner.d.ts +3 -4
- package/dist/banner.js +5 -5
- package/dist/buttonShare.d.ts +3 -4
- package/dist/buttonShare.js +25 -7
- package/dist/buttonWallet.d.ts +6 -10
- package/dist/buttonWallet.js +38 -43
- package/dist/i18n/defaults.d.ts +2 -3
- package/dist/openInApp.d.ts +4 -5
- package/dist/openInApp.js +4 -5
- package/dist/postPurchase.d.ts +3 -4
- package/dist/postPurchase.js +4 -4
- package/dist/{useGlobalComponents-DFv33ujB.js → useGlobalComponents-Cj7uGBwD.js} +1 -1
- package/dist/{useLightDomStyles-B_IbOqJZ.js → useLightDomStyles-BW6DY5sC.js} +1 -1
- package/dist/{usePlacement-DtwWaLHO.js → usePlacement-iFDQqtJn.js} +14 -39
- package/package.json +14 -14
- package/cdn/ButtonShare.BMW4Spt5.js +0 -1
- package/cdn/ButtonWallet.DL64Gv3j.js +0 -40
- package/cdn/OpenInAppButton.DYfr8q7L.js +0 -1
- package/cdn/PostPurchase.dHmBw1iX.js +0 -89
- package/cdn/replay-V6FXES7X.efKsNT6s.js +0 -1
package/README.md
CHANGED
|
@@ -4,12 +4,12 @@ Those components are meant to be used to interact with the [Frak Wallet](https:/
|
|
|
4
4
|
|
|
5
5
|
They are built as [Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components), so you can use them in any web project, no matter the framework you are using.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
See the documentation for usage:
|
|
8
8
|
- [Components](https://docs.frak.id/components)
|
|
9
9
|
- [Share Button usage](https://docs.frak.id/components/share-button)
|
|
10
10
|
- [Wallet Button usage](https://docs.frak.id/components/wallet-button)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
How it works under the hood: [Under the hood](https://docs.frak.id/wallet-sdk/under-the-hood).
|
|
13
13
|
|
|
14
14
|
## Setup
|
|
15
15
|
|
|
@@ -88,3 +88,25 @@ Button with custom class:
|
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
**Note:** This component only renders on mobile devices. On desktop, it returns null.
|
|
91
|
+
|
|
92
|
+
## Sample usage for Post Purchase
|
|
93
|
+
|
|
94
|
+
Rendered on the order-confirmation page, it tracks the purchase and offers the buyer the sharing page:
|
|
95
|
+
|
|
96
|
+
```html
|
|
97
|
+
<frak-post-purchase customer-id="1234" order-id="5678" token="checkout-token"></frak-post-purchase>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Sample usage for Banner
|
|
101
|
+
|
|
102
|
+
A banner that switches between the referral and in-app-browser messages on its own:
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<frak-banner></frak-banner>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Banner with custom copy:
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<frak-banner referral-title="You were referred!" referral-cta="Claim"></frak-banner>
|
|
112
|
+
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{O as e,S as t,a as n,f as r,m as i,p as a,s as o}from"./loader.js";import{a as s,d as c,f as l,h as u,l as d,m as f,n as ee,p,s as
|
|
1
|
+
import{O as e,S as t,a as n,f as r,m as i,p as a,s as o}from"./loader.js";import{a as s,d as c,f as l,h as u,l as d,m as f,n as ee,p,s as m,t as h,u as g}from"./defaults.CmUvOlLQ.js";import{i as _}from"./rewards.0JylBHNY.js";import{a as v,i as y,n as b,r as x,t as S}from"./GiftIcon.CPyeWQNR.js";import{t as C}from"./useGlobalComponents.C7wnXWOg.js";import{t as te}from"./useLightDomStyles.B7MVlVVJ.js";import{t as ne}from"./useReward.CaBorN5T.js";var w=`inAppBanner_body__1ibpiy74`,T=`inAppBanner_closeButton__1ibpiy77`,E=`inAppBanner_container__1ibpiy70`,D=`inAppBanner_cta__1ibpiy76`,O=`inAppBanner_description__1ibpiy75`,k=`inAppBanner_header__1ibpiy71`,A=`inAppBanner_iconWrapper__1ibpiy72`,j=`inAppBanner_title__1ibpiy73`;function re({title:e,description:t,cta:n,dismissLabel:r,onAction:i,onDismiss:a,className:o,classNames:s}){return f(`div`,{className:`${E}${o?` ${o}`:``}`,role:`alert`,children:[f(`div`,{className:k,children:[f(`span`,{className:`${A}${s?.icon?` ${s.icon}`:``}`,children:f(b,{width:20,height:20})}),f(`p`,{className:`${j}${s?.title?` ${s.title}`:``}`,children:e})]}),f(`div`,{className:w,children:[f(`p`,{className:`${O}${s?.description?` ${s.description}`:``}`,children:t}),f(`button`,{type:`button`,className:`${D}${s?.cta?` ${s.cta}`:``}`,onClick:i,children:[n,f(y,{width:14,height:14})]})]}),f(`button`,{type:`button`,className:`${T}${s?.close?` ${s.close}`:``}`,onClick:a,"aria-label":r,children:f(v,{width:16,height:16})})]})}var ie=`Banner_frakLogo__1gnumzi9`,ae=`Banner_iconSvg__1gnumzi1`,oe=`Banner_referral__1gnumzi2 reset_base__1831jhd0 Banner_rootBase__1gnumzi0`,se=`Banner_referralBody__1gnumzi5`,ce=`Banner_referralCta__1gnumzi8 sharedBaseCss_buttonReset__7cswil0`,le=`Banner_referralDescription__1gnumzi7 reset_base__1831jhd0`,ue=`Banner_referralIconWrapper__1gnumzi3`,de=`Banner_referralImage__1gnumzi4`,fe=`Banner_referralTitle__1gnumzi6 reset_base__1831jhd0`;function M({placement:u,classname:v=``,interaction:y,products:b,referralTitle:w,referralDescription:T,referralCta:E,inappTitle:D,inappDescription:O,inappCta:k,imageUrl:A,preview:j,previewMode:M,allowInappRedirect:N}){let P=!!j,F=s(),I=M===`inapp`?`inapp`:`referral`,L=N===!0||N===`true`,R=ee(u),{shouldRender:z,isHidden:B,isClientReady:V}=m();te(`frak-banner`,u,R?.components?.banner?.css,`@keyframes keyframes_fadeIn__mnqmlt0 {
|
|
2
2
|
from {
|
|
3
3
|
opacity: 0;
|
|
4
4
|
}
|
|
@@ -25,7 +25,7 @@ import{O as e,S as t,a as n,f as r,m as i,p as a,s as o}from"./loader.js";import
|
|
|
25
25
|
}
|
|
26
26
|
}.inAppBanner_container__1ibpiy70 {
|
|
27
27
|
position: fixed;
|
|
28
|
-
top: max(8px, env(safe-area-inset-top));
|
|
28
|
+
top: max(8px, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
|
|
29
29
|
left: 16px;
|
|
30
30
|
right: 16px;
|
|
31
31
|
z-index: 1000;
|
|
@@ -180,4 +180,4 @@ import{O as e,S as t,a as n,f as r,m as i,p as a,s as o}from"./loader.js";import
|
|
|
180
180
|
right: 16px;
|
|
181
181
|
bottom: 12px;
|
|
182
182
|
pointer-events: none;
|
|
183
|
-
}`,e);let[H,U]=c(!1),[W,G]=c(()=>P?I:L&&r?`inapp`:null),K=d(null);l(()=>{P&&G(I)},[P,I]);let pe=
|
|
183
|
+
}`,e);let[H,U]=c(!1),[W,G]=c(()=>P?I:L&&r?`inapp`:null),K=d(null);l(()=>{P&&G(I)},[P,I]);let pe=g(()=>a(b),[b]),{reward:q}=ne(W===`referral`&&V,y,`referee`,pe),[J,Y]=c(null);l(()=>{let e=window.FrakSetup?.client;W===`inapp`&&!P&&V&&e&&o(e).then(e=>Y(e)).catch(()=>{})},[W,P,V]),l(()=>{P||!W||H||K.current!==W&&V&&(t(window.FrakSetup?.client,`banner_impression`,{placement:u,variant:W,has_reward:W===`referral`?!!q:void 0}),K.current=W)},[W,H,V,P,u]),l(()=>{if(P||W===`inapp`)return;let e=()=>G(`referral`);return window.addEventListener(n,e),()=>window.removeEventListener(n,e)},[P,W]);let X=p(async()=>{if(P)return;if(t(window.FrakSetup?.client,`banner_resolved`,{placement:u,variant:W??`referral`,outcome:`clicked`}),W===`referral`){U(!0);return}let e=J;if(!e&&window.FrakSetup?.client)try{e=await o(window.FrakSetup?.client)}catch{}let n=window.location.href;if(e){let t=new URL(n);t.searchParams.set(`fmt`,e),n=t.toString()}i(n)},[P,W,J,u]),me=p(()=>{P||(t(window.FrakSetup?.client,`banner_resolved`,{placement:u,variant:W??`referral`,outcome:`dismissed`}),U(!0))},[P,W,u]),he=C(),Z=R?.components?.banner??he?.banner,Q=A??Z?.imageUrl,$=g(()=>{let e=h[F].banner;if(W===`referral`){let t=q?e.referralTitleReward:e.referralTitle;return{title:_(w??Z?.referralTitle??t,q),description:_(T??Z?.referralDescription??e.referralDescription,q),cta:E??Z?.referralCta??e.referralCta}}return{title:_(D??Z?.inappTitle??e.inappTitle,void 0),description:_(O??Z?.inappDescription??e.inappDescription,void 0),cta:k??Z?.inappCta??e.inappCta}},[F,W,q,Z,w,T,E,D,O,k]);if(!W||!P&&(!z||B||H))return null;let ge=[oe,`frak-banner`,`frak-banner--${W}`,v].filter(Boolean).join(` `);return W===`inapp`?f(re,{title:$.title,description:$.description,cta:$.cta,dismissLabel:h[F].banner.dismissLabel,onAction:X,onDismiss:me,className:[`frak-banner`,`frak-banner--inapp`,v].filter(Boolean).join(` `),classNames:{icon:`frak-banner__icon`,title:`frak-banner__title`,description:`frak-banner__description`,cta:`frak-banner__cta`,close:`frak-banner__close`}}):f(`div`,{class:ge,role:`alert`,children:[f(`div`,{class:`${ue} frak-banner__icon`,children:Q?f(`img`,{src:Q,alt:``,class:de}):f(S,{class:ae})}),f(`div`,{class:`${se} frak-banner__text`,children:[f(`p`,{class:`${fe} frak-banner__title`,children:$.title}),f(`p`,{class:`${le} frak-banner__description`,children:$.description}),f(`button`,{type:`button`,class:`${ce} frak-banner__cta`,onClick:X,children:$.cta})]}),f(x,{class:`${ie} frak-banner__logo`,width:42,height:24})]})}u(M,`frak-banner`,[`placement`,`classname`,`interaction`,`products`,`referralTitle`,`referralDescription`,`referralCta`,`inappTitle`,`inappDescription`,`inappCta`,`preview`,`previewMode`,`imageUrl`,`allowInappRedirect`],{shadow:!1});export{M as Banner};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,l as t,r as n}from"./loader.js";import{a as r,f as i,h as a,l as o,m as s,n as c,p as l,s as u,t as d,u as f}from"./defaults.CmUvOlLQ.js";import{i as p}from"./rewards.0JylBHNY.js";import{t as m}from"./useGlobalComponents.C7wnXWOg.js";import{t as h}from"./useLightDomStyles.B7MVlVVJ.js";import{t as g}from"./useReward.CaBorN5T.js";function _({placement:a,text:_,classname:v=``,noRewardText:y,targetInteraction:b,products:x,clickAction:S,preview:C}){let w=!!C,T=r(),E=c(a),D=m(),O=E?.components?.buttonShare??D?.buttonShare;h(`frak-button-share`,a,O?.css);let k=E?.targetInteraction===void 0?b:E.targetInteraction,A=O?.text??_??d[T].buttonShare.text,j=O?.noRewardText??y,M=A.includes(`{REWARD}`),N=O?.clickAction??S??`sharing-page`,{shouldRender:P,isHidden:F,isClientReady:I}=u(),L=f(()=>t(x),[x]),{reward:R}=g(M&&I,k,void 0,L),z=f(()=>M?R?p(A,R):j??p(A,void 0):A,[M,A,j,R]),B=o(!1);i(()=>{w||B.current||I&&P&&!F&&(e(window.FrakSetup?.client,`share_button_impression`,{placement:a,target_interaction:k,has_reward:!!R}),B.current=!0)},[w,I,P,F,a,k]);let V=l(()=>{w||(e(window.FrakSetup.client,`share_button_clicked`,{placement:a,target_interaction:k,has_reward:!!R,click_action:N}),n(k,a,{products:L}))},[w,N,k,a,R,L]);if(!w&&(!P||F))return null;let H=[`button`,`button__fadeIn`,v].filter(Boolean).join(` `);return s(`button`,{type:`button`,disabled:!w&&!I,class:H,onClick:V,children:z})}a(_,`frak-button-share`,[`text`,`placement`,`classname`,`clickAction`,`noRewardText`,`targetInteraction`,`products`,`preview`],{shadow:!1});export{_ as ButtonShare};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import{S as e,r as t}from"./loader.js";import{a as n,f as r,g as i,h as a,l as o,m as s,n as c,p as l,r as u,s as d,t as f}from"./defaults.CmUvOlLQ.js";import{t as p}from"./useReward.CaBorN5T.js";function m(){`vibrate`in navigator&&navigator.vibrate(10)}function h(e){return s(`svg`,{fill:`none`,height:`1em`,viewBox:`0 0 28 28`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[s(`title`,{children:`Gift icon`}),s(`path`,{d:`m23.14 14v11.43h-18.29v-11.43m9.14 11.43v-17.14m0 0h-5.14c-0.76 0-1.48-0.3-2.02-0.84s-0.84-1.26-0.84-2.020.3-1.480.84-2.02 1.26-0.84 2.02-0.84c4 0 5.14 5.71 5.14 5.71zm0 0h5.14c0.76 0 1.48-0.3 2.02-0.84s0.84-1.260.84-2.02-0.3-1.48-0.84-2.02-1.26-0.84-2.02-0.84c-4 0-5.14 5.71-5.14 5.71zm-11.43 0h22.86v5.71h-22.86z`,stroke:`#fff`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]})}function g({placement:a,classname:g=``,useReward:_,targetInteraction:v}){let y=n(),b=c(a),x=b?.targetInteraction===void 0?v:b.targetInteraction,S=_===!0,{shouldRender:C,isHidden:w,isClientReady:T}=d(),{reward:E}=p(S&&T,x),D=b?.components?.buttonWallet?.position??window.FrakSetup?.modalWalletConfig?.metadata?.position??`right`,O=o(!1);r(()=>{O.current||T&&C&&!w&&(e(window.FrakSetup?.client,`share_button_impression`,{placement:a,target_interaction:x,has_reward:!!E}),O.current=!0)},[T,C,w,a,x]);let k=l(()=>{e(window.FrakSetup.client,`share_button_clicked`,{placement:a,target_interaction:x,has_reward:!!E,click_action:`sharing-page`}),m(),t(x,a)},[a,x,E]);if(!C||w)return null;let A=[`button`,`button__fadeIn`,D===`left`?`button__left`:`button__right`,g].filter(Boolean).join(` `);return s(i,{children:[s(`style`,{children:u(`
|
|
2
|
+
.button {
|
|
3
|
+
all: unset;
|
|
4
|
+
position: fixed;
|
|
5
|
+
bottom: 20px;
|
|
6
|
+
z-index: 2000000;
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
align-items: center;
|
|
10
|
+
background-color: #3e557e;
|
|
11
|
+
width: 45px;
|
|
12
|
+
height: 45px;
|
|
13
|
+
border-radius: 50%;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
text-align: center;
|
|
16
|
+
font-size: 24px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.button__left {
|
|
20
|
+
left: 20px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.button__right {
|
|
24
|
+
right: 20px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.reward {
|
|
28
|
+
position: absolute;
|
|
29
|
+
top: -4px;
|
|
30
|
+
right: 27px;
|
|
31
|
+
padding: 2px 3px;
|
|
32
|
+
border-radius: 5px;
|
|
33
|
+
background: #ff3f3f;
|
|
34
|
+
font-size: 9px;
|
|
35
|
+
color: #fff;
|
|
36
|
+
font-weight: 600;
|
|
37
|
+
white-space: nowrap;
|
|
38
|
+
line-height: 9px;
|
|
39
|
+
}
|
|
40
|
+
`,b?.components?.buttonWallet?.css)}),s(`button`,{type:`button`,"aria-label":f[y].buttonWallet.ariaLabel,part:`button`,disabled:!T,class:A,onClick:k,children:[s(h,{}),E&&s(`span`,{class:`reward`,children:E})]})]})}a(g,`frak-button-wallet`,[`placement`,`classname`,`useReward`,`targetInteraction`],{shadow:!0});export{g as ButtonWallet};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,g as t,h as n,u as r}from"./loader.js";import{a as i,h as a,m as o,n as s,s as c,t as l}from"./defaults.CmUvOlLQ.js";import{t as u}from"./useLightDomStyles.B7MVlVVJ.js";function d(n=`wallet`,i){let a=window.FrakSetup?.client;a&&e(a,`open_in_app_clicked`,{path:n,placement:i});let o=`${t}${n}`;r(o,{onFallback:()=>{a&&e(a,`app_not_installed`,{path:n,placement:i})}})}function f(){return{isMobile:n()}}function p({placement:e,text:t,classname:n=``}){let r=i(),a=s(e),{shouldRender:p,isHidden:m,isClientReady:h}=c(),{isMobile:g}=f();u(`frak-open-in-app`,e,a?.components?.openInApp?.css);let _=a?.components?.openInApp?.text??t??l[r].openInApp.text;if(!g||!p||m)return null;let v=()=>{d(void 0,e)},y=[`button`,`button__fadeIn`,n].filter(Boolean).join(` `);return o(`button`,{type:`button`,"aria-label":l[r].openInApp.ariaLabel,disabled:!h,class:y,onClick:v,children:_})}a(p,`frak-open-in-app`,[`text`,`placement`,`classname`],{shadow:!1});export{p as OpenInAppButton};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import{O as e,S as t,T as n,c as r,i,l as a,o,r as s,w as ee}from"./loader.js";import{a as c,d as l,f as u,h as d,l as te,m as f,n as ne,p as re,s as ie,t as p,u as m}from"./defaults.CmUvOlLQ.js";import{i as h,n as g,t as ae}from"./rewards.0JylBHNY.js";import{r as _,t as v}from"./GiftIcon.CPyeWQNR.js";import{t as y}from"./useGlobalComponents.C7wnXWOg.js";import{t as b}from"./useLightDomStyles.B7MVlVVJ.js";var x=`PostPurchase_card__5fv5lh0`,oe=`PostPurchase_cardLayout__5fv5lh1`,se=`PostPurchase_cardLeft__5fv5lh2`,ce=`PostPurchase_cardRight__5fv5lh3`,le=`PostPurchase_cta__5fv5lh6 sharedBaseCss_buttonReset__7cswil0`,ue=`PostPurchase_customImage__5fv5lha`,de=`PostPurchase_frakLogo__5fv5lhb`,fe=`PostPurchase_giftIcon__5fv5lh8`,pe=`PostPurchase_icon__5fv5lh7`,me=`PostPurchase_imageWrapper__5fv5lh9`,he=`PostPurchase_message__5fv5lh5`;function ge(e){let t=e?.trim();if(!t)return;let n=/^https?:\/\//i.test(t)?t:`https://${t}`;try{return new URL(n).toString()}catch{return}}function _e(e,t,n,r){let i=e?.isReferred?`referee`:`referrer`,a=g(t.rewards,{targetInteraction:`purchase`,currency:n,audience:i,products:r});if(!a)return null;let{campaign:o}=a,s=e?.isReferred&&o.referee?`referee`:`referrer`;return{variant:s,reward:s===`referee`?o.referee:o.referrer,merchantDomain:t.onChainMetadata.domain}}function S({customerId:d,orderId:g,token:S,sharingUrl:ve,merchantId:C,placement:w,classname:T=``,variant:E,badgeText:D,referrerText:O,refereeText:k,ctaText:A,preview:j,previewVariant:M,products:N,imageUrl:P}){let F=!!j,{shouldRender:I,isHidden:L,isClientReady:R}=ie(),z=ne(w),B=c(),V=m(()=>a(N),[N]);b(`frak-post-purchase`,w,z?.components?.postPurchase?.css,`.PostPurchase_card__5fv5lh0 {
|
|
2
|
+
padding: 16px;
|
|
3
|
+
border-radius: 12px;
|
|
4
|
+
background-color: var(--surface-background__pbq4akc);
|
|
5
|
+
border: 1px solid var(--border-default__pbq4akv);
|
|
6
|
+
}
|
|
7
|
+
.PostPurchase_cardLayout__5fv5lh1 {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
align-items: center;
|
|
11
|
+
gap: 32px;
|
|
12
|
+
}
|
|
13
|
+
.PostPurchase_cardLeft__5fv5lh2 {
|
|
14
|
+
flex-grow: 1;
|
|
15
|
+
min-width: 0;
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
gap: 8px;
|
|
19
|
+
}
|
|
20
|
+
.PostPurchase_cardRight__5fv5lh3 {
|
|
21
|
+
flex-shrink: 0;
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
align-items: flex-end;
|
|
25
|
+
gap: 8px;
|
|
26
|
+
text-align: right;
|
|
27
|
+
}
|
|
28
|
+
.PostPurchase_badge__5fv5lh4 {
|
|
29
|
+
align-self: flex-start;
|
|
30
|
+
background-color: #FFF534;
|
|
31
|
+
border-radius: 4px;
|
|
32
|
+
padding: 4px 8px;
|
|
33
|
+
font-size: 12px;
|
|
34
|
+
font-weight: 600;
|
|
35
|
+
line-height: 12px;
|
|
36
|
+
color: var(--text-primary__pbq4ak0);
|
|
37
|
+
}
|
|
38
|
+
.PostPurchase_message__5fv5lh5 {
|
|
39
|
+
margin: 0;
|
|
40
|
+
font-size: 16px;
|
|
41
|
+
line-height: 22px;
|
|
42
|
+
color: var(--text-primary__pbq4ak0);
|
|
43
|
+
font-weight: 600;
|
|
44
|
+
}
|
|
45
|
+
.PostPurchase_cta__5fv5lh6 {
|
|
46
|
+
display: inline-flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
gap: 4px;
|
|
50
|
+
padding: 12px 16px;
|
|
51
|
+
border-radius: 9999px;
|
|
52
|
+
background-color: var(--text-primary__pbq4ak0);
|
|
53
|
+
color: var(--text-onAction__pbq4ak6);
|
|
54
|
+
font-size: 12px;
|
|
55
|
+
font-weight: bold;
|
|
56
|
+
text-transform: uppercase;
|
|
57
|
+
}
|
|
58
|
+
.PostPurchase_cta__5fv5lh6:disabled {
|
|
59
|
+
opacity: 0.7;
|
|
60
|
+
cursor: default;
|
|
61
|
+
}
|
|
62
|
+
.PostPurchase_icon__5fv5lh7 {
|
|
63
|
+
margin: -2px 0;
|
|
64
|
+
}
|
|
65
|
+
.PostPurchase_giftIcon__5fv5lh8 {
|
|
66
|
+
display: block;
|
|
67
|
+
flex-shrink: 0;
|
|
68
|
+
}
|
|
69
|
+
.PostPurchase_imageWrapper__5fv5lh9 {
|
|
70
|
+
flex-shrink: 0;
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
width: 80px;
|
|
75
|
+
height: 80px;
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
}
|
|
78
|
+
.PostPurchase_customImage__5fv5lha {
|
|
79
|
+
max-width: 100%;
|
|
80
|
+
max-height: 100%;
|
|
81
|
+
width: auto;
|
|
82
|
+
height: auto;
|
|
83
|
+
object-fit: contain;
|
|
84
|
+
display: block;
|
|
85
|
+
}
|
|
86
|
+
.PostPurchase_frakLogo__5fv5lhb {
|
|
87
|
+
display: block;
|
|
88
|
+
margin-left: auto;
|
|
89
|
+
}`,e);let[H,ye]=l(null),[U,W]=l(!1);u(()=>{F||R&&d&&g&&S&&i({customerId:d,orderId:g,token:S,merchantId:C}).catch(()=>{})},[F,R,d,g,S,C]),u(()=>{if(F||!R||U)return;let e=window.FrakSetup?.client;e&&Promise.all([o(e),r(e)]).then(([e,t])=>{W(!0),ye({referralStatus:e,merchantInfo:t})}).catch(e=>{if(e instanceof n&&e.code===ee.configError){W(!0);return}console.warn(`[Frak] Post-purchase context error`,e)})},[F,R,U]);let G=m(()=>H?_e(H.referralStatus,H.merchantInfo,window.FrakSetup?.client?.config?.metadata?.currency,V):null,[H,V]),K=te(null),q=E??G?.variant??(F?M??`referrer`:void 0),J=ge(ve??G?.merchantDomain),Y=m(()=>{if(!G?.reward)return;let e=window.FrakSetup?.client?.config?.metadata?.currency;return ae(G.reward,e)},[G?.reward]),be=y(),X=z?.components?.postPurchase??be?.postPurchase,Z=D??X?.badgeText,Q=P??X?.imageUrl,$=m(()=>{let e=p[B].postPurchase;return{message:q===`referee`?Y?h(k??X?.refereeText??e.refereeText,Y):k??X?.refereeNoRewardText??e.refereeNoRewardText:Y?h(O??X?.referrerText??e.referrerText,Y):O??X?.referrerNoRewardText??e.referrerNoRewardText,cta:Y?h(A??X?.ctaText??e.ctaText,Y):A??X?.ctaNoRewardText??e.ctaNoRewardText}},[B,q,Y,X,O,k,A]);u(()=>{q&&K.current!==q&&R&&(F||I&&!L)&&(t(window.FrakSetup?.client,`post_purchase_impression`,{placement:w,variant:q,has_reward:!!G?.reward}),K.current=q)},[q,I,L,R,F,w,G?.reward]);let xe=re(()=>{q&&(t(window.FrakSetup?.client,`post_purchase_clicked`,{placement:w,variant:q}),s(void 0,w,{link:J,products:V,checkoutToken:S}))},[q,w,J,V,S]);if(!q||!F&&(!I||L||!G))return null;let Se=[x,T].filter(Boolean).join(` `);return f(`div`,{className:Se,children:f(`div`,{class:oe,children:[f(`div`,{class:se,children:[Z&&f(`span`,{class:`PostPurchase_badge__5fv5lh4`,children:Z}),f(`p`,{class:he,children:$.message}),f(`button`,{type:`button`,className:`${le} button`,disabled:!F&&!R,onClick:F?void 0:xe,children:[$.cta,f(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`${pe} button`,children:f(`path`,{d:`M13.9 11.14C13.99 11.05 14.15 11.11 14.15 11.24V11.64C14.15 13.05 12.63 14.19 10.75 14.19C8.87 14.19 7.34 13.05 7.34 11.64V11.24C7.34 11.11 7.51 11.05 7.59 11.14C8.35 11.93 9.48 12.43 10.75 12.43C12.01 12.43 13.15 11.93 13.9 11.14ZM1.85 9.65C1.85 9.51 2.01 9.44 2.1 9.54C2.85 10.32 3.99 10.82 5.25 10.82C5.52 10.82 5.79 10.8 6.04 10.76C6.26 10.72 6.47 10.88 6.47 11.1V12.17C6.47 12.32 6.37 12.45 6.22 12.48C5.92 12.55 5.59 12.59 5.25 12.59C3.37 12.59 1.85 11.45 1.85 10.04V9.65ZM10.75 6.21C12.63 6.21 14.15 7.35 14.15 8.75C14.15 10.16 12.63 11.3 10.75 11.3C8.87 11.3 7.34 10.16 7.34 8.75C7.34 7.35 8.87 6.21 10.75 6.21ZM1.85 6.85C1.85 6.71 2.01 6.65 2.1 6.74C2.85 7.53 3.99 8.03 5.25 8.03C5.52 8.03 5.79 8 6.04 7.96C6.26 7.92 6.47 8.09 6.47 8.3V9.37C6.47 9.52 6.37 9.65 6.22 9.69C5.92 9.75 5.59 9.79 5.25 9.79C3.37 9.79 1.85 8.65 1.85 7.24V6.85ZM5.25 1.81C7.13 1.81 8.66 2.95 8.66 4.36C8.66 5.76 7.13 6.9 5.25 6.9C3.37 6.9 1.85 5.76 1.85 4.36C1.85 2.95 3.37 1.81 5.25 1.81Z`,fill:`currentColor`})})]})]}),f(`div`,{class:ce,children:[Q?f(`span`,{class:me,children:f(`img`,{src:Q,alt:``,class:ue})}):f(v,{className:fe,width:80,height:80}),f(_,{className:de,width:42,height:24})]})]})})}d(S,`frak-post-purchase`,[`customerId`,`orderId`,`token`,`sharingUrl`,`merchantId`,`placement`,`classname`,`variant`,`badgeText`,`referrerText`,`refereeText`,`ctaText`,`products`,`preview`,`previewVariant`,`imageUrl`],{shadow:!1});export{S as PostPurchase};
|
package/cdn/components.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import(`https://cdn.jsdelivr.net/npm/@frak-labs/components@
|
|
1
|
+
import(`https://cdn.jsdelivr.net/npm/@frak-labs/components@beta/cdn/loader.js?v=1789481987437`);
|