@frak-labs/components 1.2.0 → 1.2.1
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.Rl1oR1D4.js +89 -0
- package/cdn/components.js +1 -1
- package/cdn/loader.js +8 -52
- 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 +13 -13
- 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
|
@@ -1,89 +0,0 @@
|
|
|
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{r as h,t as g}from"./GiftIcon.CPyeWQNR.js";import{t as ae}from"./useGlobalComponents.C7wnXWOg.js";import{t as _}from"./useLightDomStyles.BLyrWEBn.js";import{i as v,n as y,t as b}from"./rewards.0JylBHNY.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=y(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:y,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]);_(`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||!y||!S||i({customerId:d,orderId:y,token:S,merchantId:C}).catch(()=>{})},[F,R,d,y,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}})},[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 b(G.reward,e)},[G?.reward]),be=ae(),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?v(k??X?.refereeText??e.refereeText,Y):k??X?.refereeNoRewardText??e.refereeNoRewardText:Y?v(O??X?.referrerText??e.referrerText,Y):O??X?.referrerNoRewardText??e.referrerNoRewardText,cta:Y?v(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(g,{className:fe,width:80,height:80}),f(h,{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};
|