@frak-labs/components
Version:
Frak Wallet components, helping any person to interact with the Frak wallet.
1 lines • 4.71 kB
JavaScript
export const __webpack_ids__=["766"];export const __webpack_modules__={"./src/components/ButtonShare/index.ts":function(e,t,o){o.r(t),o.d(t,{ButtonShare:()=>S});var n=o("./src/utils/registerWebComponent.ts"),r=o("../../node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js"),a=o("../../node_modules/class-variance-authority/dist/index.mjs");let i="spinner__leaf-xtOJmT",s=({ref:e,className:t,...o})=>(0,r.BX)("span",{...o,ref:e,className:(0,a.cx)("spinner-KHk8mw"),children:[(0,r.tZ)("span",{className:i}),(0,r.tZ)("span",{className:i}),(0,r.tZ)("span",{className:i}),(0,r.tZ)("span",{className:i}),(0,r.tZ)("span",{className:i}),(0,r.tZ)("span",{className:i}),(0,r.tZ)("span",{className:i}),(0,r.tZ)("span",{className:i})]});s.displayName="Spinner";var l=o("./src/hooks/useClientReady.ts"),c=o("./src/hooks/useReward.ts"),d=o("../core/dist/actions.js"),p=o("../../node_modules/preact/hooks/dist/hooks.module.js");let u={marginTop:"16px",padding:"16px",backgroundColor:"#FEE2E2",border:"1px solid #FCA5A5",borderRadius:"4px",color:"#991B1B"},m={display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px"},f={margin:0,fontSize:"16px",fontWeight:500},h={fontSize:"14px",lineHeight:"1.5",margin:"0 0 12px 0"},x={color:"#991B1B",textDecoration:"underline",textUnderlineOffset:"2px"},b={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 y({debugInfo:e}){let[t,o]=(0,p.eJ)(!1);return(0,r.BX)("div",{children:[(0,r.tZ)("button",{type:"button",style:b,onClick:()=>o(!t),children:"Ouvrir les informations"}),t&&(0,r.tZ)("textarea",{style:{display:"block",width:"100%",height:"200px",fontSize:"12px"},children:e})]})}function g({debugInfo:e}){let{copied:t,copy:o}=function(e={}){let{successDuration:t=2e3}=e,[o,n]=(0,p.eJ)(!1);return{copy:(0,p.I4)(async e=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(e),n(!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"),n(!0)}catch(e){return console.error("Failed to copy text:",e),!1}finally{t.remove()}}return setTimeout(()=>{n(!1)},t),!0}catch(e){return console.error("Failed to copy text:",e),!1}},[t]),copied:o}}();return(0,r.BX)("div",{style:u,children:[(0,r.tZ)("div",{style:m,children:(0,r.tZ)("h3",{style:f,children:"Oups ! Nous avons rencontr\xe9 un petit probl\xe8me"})}),(0,r.BX)("p",{style:h,children:["Impossible d'ouvrir le menu de partage pour le moment. Si le probl\xe8me persiste, copiez les informations ci-dessous et collez-les dans votre mail \xe0"," ",(0,r.tZ)("a",{href:"mailto:help@frak-labs.com?subject=Debug",style:x,children:"help@frak-labs.com"})," ",(0,r.tZ)("br",{}),"Merci pour votre retour, nous traitons votre demande dans les plus brefs d\xe9lais."]}),(0,r.tZ)("button",{type:"button",onClick:()=>o(e??""),style:b,children:t?"Informations copi\xe9es !":"Copier les informations de d\xe9bogage"}),(0,r.tZ)(y,{debugInfo:e})]})}var w=o("./src/utils/setup.ts"),k=o("../core/dist/index.js");async function v(){if(!window.FrakSetup?.client)throw Error("Frak client not found");await (0,d.s9)(window.FrakSetup.client,window.FrakSetup?.modalWalletConfig??{})}function S({text:e="Share and earn!",classname:t="",useReward:o,noRewardText:n,targetInteraction:i,showWallet:d}){let u=(0,p.Ye)(()=>void 0!==o,[o]),m=(0,p.Ye)(()=>void 0!==d,[d]),{isClientReady:f}=(0,l.t)(),{reward:h}=(0,c.w)(u&&f,i),{handleShare:x,isError:b,debugInfo:y}=function(e){let[t,o]=(0,p.eJ)(void 0),[n,r]=(0,p.eJ)(!1);return{handleShare:(0,p.I4)(async()=>{if(!window.FrakSetup?.client){console.error("Frak client not found"),o(k.oC.empty().formatDebugInfo("Frak client not found")),r(!0);return}let t=(0,w.Gt)();if(!t)throw Error("modalBuilderSteps not found");try{await t.sharing(window.FrakSetup?.modalShareConfig??{}).display(t=>({...t,targetInteraction:e}))}catch(e){if(e instanceof k.u&&e.code===k.ss.clientAborted){console.debug("User aborted the modal");return}o(window.FrakSetup.client.debugInfo.formatDebugInfo(e)),r(!0),console.error("Error while opening the modal",e)}},[e]),isError:n,debugInfo:t}}(i),S=(0,p.Ye)(()=>u?h?e.includes("{REWARD}")?e.replace("{REWARD}",h):`${e} ${h}`:n??e.replace("{REWARD}",""):e,[u,e,n,h]),Z=(0,p.I4)(async()=>await (m?v():x()),[m,x]);return(0,r.BX)(r.HY,{children:[(0,r.BX)("button",{type:"button",className:(0,a.cx)("buttonShare-F23Y9m",t,"override"),onClick:Z,children:[!f&&(0,r.tZ)(s,{})," ",S]}),b&&(0,r.tZ)(g,{debugInfo:y})]})}(0,n.A)(S,"frak-button-share",["text"],{shadow:!1})}};