UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

4 lines (3 loc) 6.53 kB
import{jsxs as e,jsx as i,Fragment as n}from"react/jsx-runtime";import{styled as t}from"styled-components";import{P as o,H as r,W as l}from"./WalletLink-C9CSqqVy.mjs";import{g as d}from"./ethers-C3Y94dat.mjs";import{F as a}from"./Layouts-Bmf8DxNP.mjs";import c from"@heroicons/react/24/outline/ChevronDownIcon";import{createContext as s,useState as p,useContext as h}from"react";import{s as f,u as g}from"./context-Bycd1SKV.mjs";const m=({label:n,children:t,valueStyles:o})=>/*#__PURE__*/e(v,{children:[/*#__PURE__*/i("div",{children:n}),/*#__PURE__*/i(u,{style:{...o},children:t})]});let v=/*#__PURE__*/t.div.withConfig({displayName:"StyledDetailsRow",componentId:"sc-4ebfdd45-0"})(["display:flex;align-items:center;justify-content:space-between;width:100%;> :first-child{color:var(--privy-color-foreground-3);text-align:left;}> :last-child{color:var(--privy-color-foreground-2);text-align:right;}"]),u=/*#__PURE__*/t.div.withConfig({displayName:"ValueWrapper",componentId:"sc-4ebfdd45-1"})(["font-size:14px;line-height:100%;display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-full);background-color:var(--privy-color-background-2);padding:4px 8px;"]);const y=({gas:n,tokenPrice:t,tokenSymbol:r})=>/*#__PURE__*/e(a,{style:{paddingBottom:"12px"},children:[/*#__PURE__*/e(w,{children:[/*#__PURE__*/i(I,{children:"Est. Fees"}),/*#__PURE__*/i("div",{children:/*#__PURE__*/i(o,{weiQuantities:[BigInt(n)],tokenPrice:t,tokenSymbol:r})})]}),t&&/*#__PURE__*/i(b,{children:`${d(BigInt(n),r)}`})]}),x=({value:n,gas:t,tokenPrice:r,tokenSymbol:l})=>{let c=BigInt(n??0)+BigInt(t);/*#__PURE__*/return e(a,{children:[/*#__PURE__*/e(w,{children:[/*#__PURE__*/i(I,{children:"Total (including fees)"}),/*#__PURE__*/i("div",{children:/*#__PURE__*/i(o,{weiQuantities:[BigInt(n||0),BigInt(t)],tokenPrice:r,tokenSymbol:l})})]}),r&&/*#__PURE__*/i(b,{children:d(c,l)})]})};let w=/*#__PURE__*/t.div.withConfig({displayName:"TransactionTotalRow",componentId:"sc-f8ef9b74-0"})(["display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding-top:4px;"]),b=/*#__PURE__*/t.div.withConfig({displayName:"ValueConversionRow",componentId:"sc-f8ef9b74-1"})(["display:flex;flex-direction:row;height:12px;font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);font-weight:400;"]),I=/*#__PURE__*/t.div.withConfig({displayName:"TotalText",componentId:"sc-f8ef9b74-2"})(["font-size:14px;line-height:22.4px;font-weight:400;"]);const C=/*#__PURE__*/s(void 0),k=/*#__PURE__*/s(void 0),P=({defaultValue:e,children:n})=>{let[t,o]=p(e||null);/*#__PURE__*/return i(C.Provider,{value:{activePanel:t,togglePanel:e=>{o(t===e?null:e)}},children:/*#__PURE__*/i(j,{children:n})})},T=({value:e,children:n})=>{let{activePanel:t,togglePanel:o}=h(C),r=t===e;/*#__PURE__*/return i(k.Provider,{value:{onToggle:()=>o(e),value:e},children:/*#__PURE__*/i(D,{isActive:r?"true":"false","data-open":String(r),children:n})})},N=({children:t})=>{let{activePanel:o}=h(C),{onToggle:r,value:l}=h(k),d=o===l;/*#__PURE__*/ return e(n,{children:[/*#__PURE__*/e(B,{onClick:r,"data-open":String(d),children:[/*#__PURE__*/i(z,{children:t}),/*#__PURE__*/i(V,{isactive:d?"true":"false",children:/*#__PURE__*/i(c,{height:"16px",width:"16px",strokeWidth:"2"})})]}),/*#__PURE__*/i(W,{})]})},S=({children:e})=>{let{activePanel:n}=h(C),{value:t}=h(k);/*#__PURE__*/return i(F,{"data-open":String(n===t),children:/*#__PURE__*/i(R,{children:e})})},A=({children:e})=>{let{activePanel:n}=h(C),{value:t}=h(k);/*#__PURE__*/return i(R,{children:"function"==typeof e?e({isActive:n===t}):e})};let j=/*#__PURE__*/t.div.withConfig({displayName:"AccordionRoot",componentId:"sc-d25f9267-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;"]),B=/*#__PURE__*/t.div.withConfig({displayName:"AccordionTriggerContainer",componentId:"sc-d25f9267-1"})(["display:flex;justify-content:space-between;align-items:center;width:100%;cursor:pointer;padding-bottom:8px;"]),W=/*#__PURE__*/t.div.withConfig({displayName:"AccordionDivider",componentId:"sc-d25f9267-2"})(["width:100%;&&{border-top:1px solid;border-color:var(--privy-color-foreground-4);}padding-bottom:12px;"]),z=/*#__PURE__*/t.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-d25f9267-3"})(["font-size:14px;font-weight:500;line-height:19.6px;width:100%;padding-right:8px;"]),D=/*#__PURE__*/t.div.withConfig({displayName:"AccordionPanelContainer",componentId:"sc-d25f9267-4"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;padding:12px;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),F=/*#__PURE__*/t.div.withConfig({displayName:"AccordionContentContainer",componentId:"sc-d25f9267-5"})(["position:relative;overflow:hidden;transition:max-height 25ms ease-out;&[data-open='true']{max-height:700px;}&[data-open='false']{max-height:0;}"]),R=/*#__PURE__*/t.div.withConfig({displayName:"ContentWrapper",componentId:"sc-d25f9267-6"})(["display:flex;flex-direction:column;gap:12px;flex:1 1 auto;min-height:1px;"]),V=/*#__PURE__*/t.div.withConfig({displayName:"IconWrapper",componentId:"sc-d25f9267-7"})(["transform:",";"],(e=>"true"===e.isactive?"rotate(180deg)":"rotate(0deg)"));const Q=({from:n,to:t,txn:o,transactionInfo:d,tokenPrice:a,gas:c,tokenSymbol:s})=>{let p=BigInt(o?.value||0);/*#__PURE__*/ return i(P,{...g().render.standalone?{defaultValue:"details"}:{},children:/*#__PURE__*/e(T,{value:"details",children:[/*#__PURE__*/i(N,{children:/*#__PURE__*/e(L,{children:[/*#__PURE__*/i("div",{children:d?.title||"Details"}),/*#__PURE__*/i(E,{children:/*#__PURE__*/i(r,{weiQuantities:[p],tokenPrice:a,tokenSymbol:s})})]})}),/*#__PURE__*/e(S,{children:[/*#__PURE__*/i(m,{label:"From",children:/*#__PURE__*/i(l,{walletAddress:n,chainId:o.chainId||f,chainType:"ethereum"})}),/*#__PURE__*/i(m,{label:"To",children:/*#__PURE__*/i(l,{walletAddress:t,chainId:o.chainId||f,chainType:"ethereum"})}),d&&d.action&&/*#__PURE__*/i(m,{label:"Action",children:d.action}),c&&/*#__PURE__*/i(y,{value:o.value,gas:c,tokenPrice:a,tokenSymbol:s})]}),/*#__PURE__*/i(A,{children:({isActive:e})=>/*#__PURE__*/i(x,{value:o.value,displayFee:e,gas:c||"0x0",tokenPrice:a,tokenSymbol:s})})]})})};let L=/*#__PURE__*/t.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-2eff9f5c-0"})(["display:flex;flex-direction:row;justify-content:space-between;"]),E=/*#__PURE__*/t.div.withConfig({displayName:"TotalText",componentId:"sc-2eff9f5c-1"})(["flex-shrink:0;padding-left:8px;"]);export{Q as T};