@frak-labs/components 0.0.26-beta.b38eef2e → 0.0.26-beta.c7fe645d

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.
Files changed (42) hide show
  1. package/cdn/Banner.BMHoJgnV.js +1 -0
  2. package/cdn/ButtonShare.C9bOZeuc.js +1 -0
  3. package/cdn/ButtonWallet.CABXtQ4V.js +40 -0
  4. package/cdn/OpenInAppButton.BmF8AXhC.js +1 -0
  5. package/cdn/PostPurchase.DRJyOBDO.js +2362 -0
  6. package/cdn/components.js +1 -1
  7. package/cdn/formatReward.DXMr8a-D.js +1 -0
  8. package/cdn/jsxRuntime.module.C6YjWAqO.js +138 -0
  9. package/cdn/loader.css +0 -14
  10. package/cdn/loader.js +66 -1
  11. package/cdn/useLightDomStyles.bAfmSfzH.js +1 -0
  12. package/cdn/useReward.DDCWUZkL.js +1 -0
  13. package/cdn/useShareModal.CeIpyobm.js +1 -0
  14. package/dist/banner.d.ts +115 -0
  15. package/dist/banner.js +195 -0
  16. package/dist/buttonShare.d.ts +8 -6
  17. package/dist/buttonShare.js +60 -101
  18. package/dist/buttonWallet.d.ts +10 -2
  19. package/dist/buttonWallet.js +79 -38
  20. package/dist/formatReward-_UYA3aHE.js +26 -0
  21. package/dist/openInApp.d.ts +4 -2
  22. package/dist/openInApp.js +23 -27
  23. package/dist/postPurchase.d.ts +122 -0
  24. package/dist/postPurchase.js +2995 -0
  25. package/dist/useLightDomStyles-utGwQ5Gs.js +41 -0
  26. package/dist/usePlacement-BKWDIvXP.js +329 -0
  27. package/dist/useReward-XF2hB_C_.js +65 -0
  28. package/dist/useShareModal-Bmlk3eBJ.js +53 -0
  29. package/package.json +27 -17
  30. package/cdn/ButtonShare.CSPl5Bi5.js +0 -1
  31. package/cdn/ButtonWallet.3Hp62hGr.js +0 -1
  32. package/cdn/OpenInAppButton.BTvukMkp.js +0 -1
  33. package/cdn/Spinner.DQogVqic.js +0 -1
  34. package/cdn/initFrakSdk.CMgrZQwQ.js +0 -14
  35. package/cdn/useClientReady.CKKC4IMk.js +0 -1
  36. package/dist/Spinner-Btnwk01x.js +0 -36
  37. package/dist/Spinner-CHZD3tMn.css +0 -1
  38. package/dist/buttonShare.css +0 -1
  39. package/dist/buttonWallet.css +0 -1
  40. package/dist/openInApp.css +0 -1
  41. package/dist/useClientReady-0vKBG0-p.js +0 -197
  42. package/dist/useReward-DAkT-7wT.js +0 -48
@@ -0,0 +1 @@
1
+ import{f as e,m as t,p as n}from"./loader.js";import{c as r,d as i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./jsxRuntime.module.C6YjWAqO.js";import{t as f}from"./useLightDomStyles.bAfmSfzH.js";import{t as p}from"./useReward.DDCWUZkL.js";function m(){return u(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:[u(`rect`,{x:`3`,y:`11`,width:`18`,height:`11`,rx:`1`}),u(`path`,{d:`M12 11v11`}),u(`rect`,{x:`5`,y:`7`,width:`14`,height:`4`,rx:`1`}),u(`path`,{d:`M12 7c0 0-1.5-4-4.5-4S5 5 7.5 7`}),u(`path`,{d:`M12 7c0 0 1.5-4 4.5-4S19 5 16.5 7`})]})}function h(){return u(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:[u(`path`,{d:`M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6`}),u(`polyline`,{points:`15 3 21 3 21 9`}),u(`line`,{x1:`10`,y1:`14`,x2:`21`,y2:`3`})]})}function g({placement:i,classname:g=``,interaction:_,referralTitle:v,referralDescription:y,referralCta:b,inappTitle:x,inappDescription:S,inappCta:C,preview:w,previewMode:T}){let E=!!w,D=T===`inapp`?`inapp`:`referral`,O=o(i),{shouldRender:k,isHidden:A,isClientReady:j}=s();f(`frak-banner`,i,O?.components?.banner?.css,c);let[M,N]=r(!1),[P,F]=r(()=>E?D:t?`inapp`:null);d(()=>{E&&F(D)},[E,D]);let{reward:I}=p(P===`referral`&&j,_);d(()=>{if(E||P===`inapp`)return;let t=()=>F(`referral`);return window.addEventListener(e,t),()=>window.removeEventListener(e,t)},[E,P]);let L=a(()=>{E||(P===`referral`?N(!0):n(window.location.href))},[E,P]),R=O?.components?.banner,z=l(()=>{if(P===`referral`){let e=I?`Earn ${I} on purchases on this site`:`You've been referred!`;return{title:v??R?.referralTitle??e,description:y??R?.referralDescription??`Earn rewards after your purchase via the Frak partner app.`,cta:b??R?.referralCta??`Got it`}}return{title:x??R?.inappTitle??`Open in your browser`,description:S??R?.inappDescription??`For a better experience and to earn your rewards, open this page in your default browser.`,cta:C??R?.inappCta??`Open browser`}},[P,I,R,v,y,b,x,S,C]);return!E&&(!k||A||M||!P)?null:u(`div`,{class:[`frak-banner`,`frak-banner__fadeIn`,g].filter(Boolean).join(` `),role:`alert`,children:[u(`div`,{class:`frak-banner__icon`,children:u(P===`referral`?m:h,{})}),u(`div`,{class:`frak-banner__content`,children:[u(`p`,{class:`frak-banner__title`,children:z.title}),u(`p`,{class:`frak-banner__description`,children:z.description})]}),u(`button`,{type:`button`,class:`frak-banner__cta`,onClick:L,children:z.cta})]})}i(g,`frak-banner`,[`placement`,`classname`,`interaction`,`referralTitle`,`referralDescription`,`referralCta`,`inappTitle`,`inappDescription`,`inappCta`,`preview`,`previewMode`],{shadow:!1});export{g as Banner};
@@ -0,0 +1 @@
1
+ import{S as e,d as t,o as n}from"./loader.js";import{c as r,d as i,l as a,m as o,n as s,o as c,s as l,t as u}from"./jsxRuntime.module.C6YjWAqO.js";import{t as d}from"./useLightDomStyles.bAfmSfzH.js";import{t as f}from"./useReward.DDCWUZkL.js";import{t as p}from"./useShareModal.CeIpyobm.js";async function m(e,n){if(!window.FrakSetup?.client){console.error(`Frak client not found`);return}await t(window.FrakSetup.client,{metadata:{...e&&{targetInteraction:e}}},n)}function h(e={}){let{successDuration:t=2e3}=e,[n,i]=r(!1);return{copy:a(async e=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(e),i(!0);else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();try{document.execCommand(`copy`),i(!0)}catch(e){return console.error(`Failed to copy text:`,e),!1}finally{t.remove()}}return setTimeout(()=>{i(!1)},t),!0}catch(e){return console.error(`Failed to copy text:`,e),!1}},[t]),copied:n}}const g={errorContainer:{marginTop:`16px`,padding:`16px`,backgroundColor:`#FEE2E2`,border:`1px solid #FCA5A5`,borderRadius:`4px`,color:`#991B1B`},header:{display:`flex`,alignItems:`center`,gap:`8px`,marginBottom:`12px`},title:{margin:0,fontSize:`16px`,fontWeight:500},message:{fontSize:`14px`,lineHeight:`1.5`,margin:`0 0 12px 0`},link:{color:`#991B1B`,textDecoration:`underline`,textUnderlineOffset:`2px`},copyButton:{display:`inline-flex`,alignItems:`center`,gap:`8px`,marginBottom:`10px`,padding:`8px 12px`,backgroundColor:`white`,border:`1px solid #D1D5DB`,borderRadius:`4px`,color:`black`,fontSize:`14px`,fontWeight:500}};function _({debugInfo:e}){let[t,n]=r(!1);return u(`div`,{children:[u(`button`,{type:`button`,style:g.copyButton,onClick:()=>n(!t),children:`Ouvrir les informations`}),t&&u(`textarea`,{style:{display:`block`,width:`100%`,height:`200px`,fontSize:`12px`},children:e})]})}function v({debugInfo:e}){let{copied:t,copy:n}=h();return u(`div`,{style:g.errorContainer,children:[u(`div`,{style:g.header,children:u(`h3`,{style:g.title,children:`Oups ! Nous avons rencontré un petit problème`})}),u(`p`,{style:g.message,children:[`Impossible d'ouvrir le menu de partage pour le moment. Si le problème persiste, copiez les informations ci-dessous et collez-les dans votre mail à`,` `,u(`a`,{href:`mailto:help@frak-labs.com?subject=Debug`,style:g.link,children:`help@frak-labs.com`}),` `,u(`br`,{}),`Merci pour votre retour, nous traitons votre demande dans les plus brefs délais.`]}),u(`button`,{type:`button`,onClick:()=>n(e??``),style:g.copyButton,children:t?`Informations copiées !`:`Copier les informations de débogage`}),u(_,{debugInfo:e})]})}function y({placement:t,text:r=`Share and earn!`,classname:i=``,useReward:h,noRewardText:g,targetInteraction:_,clickAction:y}){let b=s(t),x=b?.components?.buttonShare;d(`frak-button-share`,t,x?.css);let S=l(()=>b?.targetInteraction===void 0?_:b.targetInteraction,[b?.targetInteraction,_]),C=x?.text??r,w=x?.noRewardText??g,T=l(()=>x?.useReward??h===!0,[x?.useReward,h]),E=l(()=>x?.clickAction??y??`sharing-page`,[x?.clickAction,y]),{shouldRender:D,isHidden:O,isClientReady:k}=c(),{reward:A}=f(T&&k,S),{handleShare:j,isError:M,debugInfo:N}=p(S,t),P=l(()=>T?A?C.includes(`{REWARD}`)?C.replace(`{REWARD}`,A):`${C} ${A}`:w??C.replace(`{REWARD}`,``):C,[T,C,w,A]),F=a(async()=>{e(window.FrakSetup.client,`share_button_clicked`),E===`embedded-wallet`?n(S,t):E===`share-modal`?await j():m(S,t)},[E,j,S,t]);if(!D||O)return null;let I=[`button`,`button__fadeIn`,i].filter(Boolean).join(` `);return u(o,{children:[u(`button`,{type:`button`,disabled:!k,class:I,onClick:F,children:P}),M&&u(v,{debugInfo:N})]})}i(y,`frak-button-share`,[`text`,`placement`,`classname`,`clickAction`,`useReward`,`noRewardText`,`targetInteraction`],{shadow:!1});export{y as ButtonShare};
@@ -0,0 +1,40 @@
1
+ import{S as e,a as t}from"./loader.js";import{c as n,d as r,i,m as a,n as o,o as s,s as c,t as l,u}from"./jsxRuntime.module.C6YjWAqO.js";import{t as d}from"./useReward.DDCWUZkL.js";function f(e){return l(`svg`,{fill:`none`,height:`1em`,viewBox:`0 0 28 28`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[l(`title`,{children:`Gift icon`}),l(`path`,{d:`m23.1427 13.9999v11.4285h-18.2857v-11.4285m9.1429 11.4285v-17.14282m0 0h-5.1429c-.75776 0-1.48448-.30102-2.0203-.83684s-.83684-1.26255-.83684-2.02031.30102-1.48448.83684-2.0203 1.26254-.83684 2.0203-.83684c4 0 5.1429 5.71429 5.1429 5.71429zm0 0h5.1428c.7578 0 1.4845-.30102 2.0203-.83684s.8369-1.26255.8369-2.02031-.3011-1.48448-.8369-2.0203-1.2625-.83684-2.0203-.83684c-4 0-5.1428 5.71429-5.1428 5.71429zm-11.42861 0h22.85711v5.71432h-22.85711z`,stroke:`#fff`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]})}function p({placement:r,classname:p=``,useReward:m,targetInteraction:h}){let g=o(r),_=c(()=>g?.targetInteraction===void 0?h:g.targetInteraction,[g?.targetInteraction,h]),v=c(()=>m===!0,[m]),{shouldRender:y,isHidden:b,isClientReady:x}=s(),{reward:S}=d(v&&x,_),[C,w]=n(`right`);if(u(()=>{let e=g?.components?.buttonWallet?.position,t=window.FrakSetup?.modalWalletConfig?.metadata?.position;w(e??t??`right`)},[g?.components?.buttonWallet?.position]),!y||b)return null;let T=[`button`,`button__fadeIn`,C===`left`?`button__left`:`button__right`,p].filter(Boolean).join(` `);return l(a,{children:[l(`style`,{children:i(`
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
+ `,g?.components?.buttonWallet?.css)}),l(`button`,{type:`button`,"aria-label":`Open wallet`,part:`button`,disabled:!x,class:T,onClick:()=>{e(window.FrakSetup.client,`wallet_button_clicked`),t(_,r)},children:[l(f,{}),S&&l(`span`,{class:`reward`,children:S})]})]})}r(p,`frak-button-wallet`,[`placement`,`classname`,`useReward`,`targetInteraction`],{shadow:!0});export{p as ButtonWallet};
@@ -0,0 +1 @@
1
+ import{S as e,g as t,y as n}from"./loader.js";import{d as r,n as i,o as a,s as o,t as s}from"./jsxRuntime.module.C6YjWAqO.js";import{t as c}from"./useLightDomStyles.bAfmSfzH.js";function l(){return typeof navigator>`u`?!1:!!(/iPhone|iPad|iPod|Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||/Macintosh/i.test(navigator.userAgent)&&navigator.maxTouchPoints>1)}function u(){return{isMobile:o(()=>l(),[])}}function d(r=`wallet`){let i=window.FrakSetup?.client;i&&e(i,`open_in_app_clicked`),t(`${n}${r}`,{onFallback:()=>{i&&e(i,`app_not_installed`)}})}function f({placement:e,text:t=`Open in App`,classname:n=``}){let r=i(e),{shouldRender:o,isHidden:l,isClientReady:f}=a(),{isMobile:p}=u();c(`frak-open-in-app`,e,r?.components?.openInApp?.css);let m=r?.components?.openInApp?.text??t;if(!p||!o||l)return null;let h=()=>{d()},g=[`button`,`button__fadeIn`,n].filter(Boolean).join(` `);return s(`button`,{type:`button`,"aria-label":`Open in Frak Wallet app`,disabled:!f,class:g,onClick:h,children:m})}r(f,`frak-open-in-app`,[`text`,`placement`,`classname`],{shadow:!1});export{f as OpenInAppButton};