UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

4 lines (3 loc) 7.11 kB
"use strict";var e=require("react/jsx-runtime"),i=require("styled-components"),t=require("./WalletLink-GY0_Tmtg.js"),n=require("./ethers-DZGJ4Y5i.js"),o=require("./Layouts-dRL0OSpp.js"),r=require("@heroicons/react/24/outline/ChevronDownIcon"),l=require("react"),d=require("./context-DFq1obBO.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=/*#__PURE__*/s(r);const c=({label:i,children:t,valueStyles:n})=>/*#__PURE__*/e.jsxs(p,{children:[/*#__PURE__*/e.jsx("div",{children:i}),/*#__PURE__*/e.jsx(x,{style:{...n},children:t})]});let p=/*#__PURE__*/i.styled.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;}"]),x=/*#__PURE__*/i.styled.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 h=({gas:i,tokenPrice:r,tokenSymbol:l})=>/*#__PURE__*/e.jsxs(o.FlexContainer,{style:{paddingBottom:"12px"},children:[/*#__PURE__*/e.jsxs(u,{children:[/*#__PURE__*/e.jsx(y,{children:"Est. Fees"}),/*#__PURE__*/e.jsx("div",{children:/*#__PURE__*/e.jsx(t.PriceDisplay,{weiQuantities:[BigInt(i)],tokenPrice:r,tokenSymbol:l})})]}),r&&/*#__PURE__*/e.jsx(g,{children:`${n.getNativeCurrencyFromWei(BigInt(i),l)}`})]}),f=({value:i,gas:r,tokenPrice:l,tokenSymbol:d})=>{let s=BigInt(i??0)+BigInt(r);/*#__PURE__*/return e.jsxs(o.FlexContainer,{children:[/*#__PURE__*/e.jsxs(u,{children:[/*#__PURE__*/e.jsx(y,{children:"Total (including fees)"}),/*#__PURE__*/e.jsx("div",{children:/*#__PURE__*/e.jsx(t.PriceDisplay,{weiQuantities:[BigInt(i||0),BigInt(r)],tokenPrice:l,tokenSymbol:d})})]}),l&&/*#__PURE__*/e.jsx(g,{children:n.getNativeCurrencyFromWei(s,d)})]})};let u=/*#__PURE__*/i.styled.div.withConfig({displayName:"TransactionTotalRow",componentId:"sc-f8ef9b74-0"})(["display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding-top:4px;"]),g=/*#__PURE__*/i.styled.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;"]),y=/*#__PURE__*/i.styled.div.withConfig({displayName:"TotalText",componentId:"sc-f8ef9b74-2"})(["font-size:14px;line-height:22.4px;font-weight:400;"]);const v=/*#__PURE__*/l.createContext(void 0),m=/*#__PURE__*/l.createContext(void 0),j=({defaultValue:i,children:t})=>{let[n,o]=l.useState(i||null);/*#__PURE__*/return e.jsx(v.Provider,{value:{activePanel:n,togglePanel:e=>{o(n===e?null:e)}},children:/*#__PURE__*/e.jsx(k,{children:t})})},w=({value:i,children:t})=>{let{activePanel:n,togglePanel:o}=l.useContext(v),r=n===i;/*#__PURE__*/return e.jsx(m.Provider,{value:{onToggle:()=>o(i),value:i},children:/*#__PURE__*/e.jsx(T,{isActive:r?"true":"false","data-open":String(r),children:t})})},C=({children:i})=>{let{activePanel:t}=l.useContext(v),{onToggle:n,value:o}=l.useContext(m),r=t===o;/*#__PURE__*/ return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(N,{onClick:n,"data-open":String(r),children:[/*#__PURE__*/e.jsx(A,{children:i}),/*#__PURE__*/e.jsx(W,{isactive:r?"true":"false",children:/*#__PURE__*/e.jsx(a.default,{height:"16px",width:"16px",strokeWidth:"2"})})]}),/*#__PURE__*/e.jsx(P,{})]})},I=({children:i})=>{let{activePanel:t}=l.useContext(v),{value:n}=l.useContext(m);/*#__PURE__*/return e.jsx(S,{"data-open":String(t===n),children:/*#__PURE__*/e.jsx(D,{children:i})})},b=({children:i})=>{let{activePanel:t}=l.useContext(v),{value:n}=l.useContext(m);/*#__PURE__*/return e.jsx(D,{children:"function"==typeof i?i({isActive:t===n}):i})};let k=/*#__PURE__*/i.styled.div.withConfig({displayName:"AccordionRoot",componentId:"sc-d25f9267-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;"]),N=/*#__PURE__*/i.styled.div.withConfig({displayName:"AccordionTriggerContainer",componentId:"sc-d25f9267-1"})(["display:flex;justify-content:space-between;align-items:center;width:100%;cursor:pointer;padding-bottom:8px;"]),P=/*#__PURE__*/i.styled.div.withConfig({displayName:"AccordionDivider",componentId:"sc-d25f9267-2"})(["width:100%;&&{border-top:1px solid;border-color:var(--privy-color-foreground-4);}padding-bottom:12px;"]),A=/*#__PURE__*/i.styled.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-d25f9267-3"})(["font-size:14px;font-weight:500;line-height:19.6px;width:100%;padding-right:8px;"]),T=/*#__PURE__*/i.styled.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);}"]),S=/*#__PURE__*/i.styled.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;}"]),D=/*#__PURE__*/i.styled.div.withConfig({displayName:"ContentWrapper",componentId:"sc-d25f9267-6"})(["display:flex;flex-direction:column;gap:12px;flex:1 1 auto;min-height:1px;"]),W=/*#__PURE__*/i.styled.div.withConfig({displayName:"IconWrapper",componentId:"sc-d25f9267-7"})(["transform:",";"],(e=>"true"===e.isactive?"rotate(180deg)":"rotate(0deg)"));let q=/*#__PURE__*/i.styled.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-2eff9f5c-0"})(["display:flex;flex-direction:row;justify-content:space-between;"]),B=/*#__PURE__*/i.styled.div.withConfig({displayName:"TotalText",componentId:"sc-2eff9f5c-1"})(["flex-shrink:0;padding-left:8px;"]);exports.TransactionDetails=({from:i,to:n,txn:o,transactionInfo:r,tokenPrice:l,gas:s,tokenSymbol:a})=>{let p=BigInt(o?.value||0);/*#__PURE__*/ return e.jsx(j,{...d.useAppConfig().render.standalone?{defaultValue:"details"}:{},children:/*#__PURE__*/e.jsxs(w,{value:"details",children:[/*#__PURE__*/e.jsx(C,{children:/*#__PURE__*/e.jsxs(q,{children:[/*#__PURE__*/e.jsx("div",{children:r?.title||"Details"}),/*#__PURE__*/e.jsx(B,{children:/*#__PURE__*/e.jsx(t.HeaderPriceDisplay,{weiQuantities:[p],tokenPrice:l,tokenSymbol:a})})]})}),/*#__PURE__*/e.jsxs(I,{children:[/*#__PURE__*/e.jsx(c,{label:"From",children:/*#__PURE__*/e.jsx(t.WalletLink,{walletAddress:i,chainId:o.chainId||d.CHAIN_ID_MAINNET,chainType:"ethereum"})}),/*#__PURE__*/e.jsx(c,{label:"To",children:/*#__PURE__*/e.jsx(t.WalletLink,{walletAddress:n,chainId:o.chainId||d.CHAIN_ID_MAINNET,chainType:"ethereum"})}),r&&r.action&&/*#__PURE__*/e.jsx(c,{label:"Action",children:r.action}),s&&/*#__PURE__*/e.jsx(h,{value:o.value,gas:s,tokenPrice:l,tokenSymbol:a})]}),/*#__PURE__*/e.jsx(b,{children:({isActive:i})=>/*#__PURE__*/e.jsx(f,{value:o.value,displayFee:i,gas:s||"0x0",tokenPrice:l,tokenSymbol:a})})]})})};