@privy-io/react-auth
Version:
React client for the Privy Auth API
10 lines (9 loc) • 8.09 kB
JavaScript
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("styled-components"),n=require("./useActiveWallet-BOX8xCn9.js"),o=require("./ModalHeader-DB7Tbjwz.js"),t=require("./index-CRFXS9pP.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=/*#__PURE__*/a(r);const c=/*#__PURE__*/i.styled.div.withConfig({displayName:"ScreenRoot",componentId:"sc-2e815abe-0"})(["--screen-space:16px;--screen-space-lg:calc(var(--screen-space) * 1.5);position:relative;overflow:hidden;margin:0 calc(-1 * var(--screen-space));height:100%;border-radius:var(--privy-border-radius-lg);"]),s=/*#__PURE__*/i.styled.div.withConfig({displayName:"ScreenRootInner",componentId:"sc-2e815abe-1"})(["display:flex;flex-direction:column;gap:calc(var(--screen-space) * 1.5);width:100%;background:var(--privy-color-background);padding:0 var(--screen-space-lg) var(--screen-space);height:100%;border-radius:var(--privy-border-radius-lg);"]),d=/*#__PURE__*/i.styled.div.withConfig({displayName:"HeaderContainer",componentId:"sc-2e815abe-2"})(["position:relative;display:flex;flex-direction:column;"]),p=/*#__PURE__*/i.styled(o.ModalHeader).withConfig({displayName:"StyledModalHeader",componentId:"sc-2e815abe-3"})(["margin:0 -8px;"]),g=/*#__PURE__*/i.styled.div.withConfig({displayName:"BodyContainer",componentId:"sc-2e815abe-4"})(["flex:1 1 auto;display:flex;flex-direction:column;overflow-y:auto;padding:3px;margin:-3px;&::-webkit-scrollbar{display:none;}scrollbar-gutter:stable both-edges;scrollbar-width:none;-ms-overflow-style:none;"," background-repeat:no-repeat;background-size:100% 32px,100% 16px;background-attachment:local,scroll;"],(({$colorScheme:e})=>"light"===e?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0)),h=/*#__PURE__*/i.styled.div.withConfig({displayName:"FooterContainer",componentId:"sc-2e815abe-5"})(["display:flex;flex-direction:column;gap:var(--screen-space-lg);"]);let u=/*#__PURE__*/i.styled.div.withConfig({displayName:"CenteredHeader",componentId:"sc-2e815abe-6"})(["text-align:center;display:flex;flex-direction:column;align-items:center;gap:var(--screen-space);"]),y=/*#__PURE__*/i.styled.div.withConfig({displayName:"TitleContainer",componentId:"sc-2e815abe-7"})(["display:flex;flex-direction:column;gap:4px;"]),v=/*#__PURE__*/i.styled.h3.withConfig({displayName:"HeaderTitle",componentId:"sc-2e815abe-8"})(["&&{font-size:20px;line-height:32px;font-weight:500;color:var(--privy-color-foreground);margin:0;}"]),x=/*#__PURE__*/i.styled.p.withConfig({displayName:"HeaderSubtitle",componentId:"sc-2e815abe-9"})(["&&{margin:0;font-size:16px;font-weight:300;line-height:24px;color:var(--privy-color-foreground);}"]),f=/*#__PURE__*/i.styled.div.withConfig({displayName:"IconContainer",componentId:"sc-2e815abe-10"})(["background:",";border-radius:50%;width:64px;height:64px;display:flex;align-items:center;justify-content:center;"],(({$variant:e})=>{switch(e){case"success":return"var(--privy-color-success-bg, #EAFCEF)";case"warning":return"var(--privy-color-warn, #FEF3C7)";case"error":return"var(--privy-color-error-bg, #FEE2E2)";case"loading":case"logo":return"transparent";default:return"var(--privy-color-background-2)"}})),m=/*#__PURE__*/i.styled.div.withConfig({displayName:"LogoContainer",componentId:"sc-2e815abe-11"})(["display:flex;align-items:center;justify-content:center;margin-bottom:var(--screen-space);img,svg{max-height:90px;max-width:180px;}"]),b=/*#__PURE__*/i.styled.div.withConfig({displayName:"LoadingWithIconContainer",componentId:"sc-2e815abe-12"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > :first-child{position:relative;}> div > :last-child{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);}"]);const w=({children:r,...i})=>/*#__PURE__*/e.jsx(c,{children:/*#__PURE__*/e.jsx(s,{...i,children:r})});let j=/*#__PURE__*/i.styled.div.withConfig({displayName:"ProgressBarContainer",componentId:"sc-2e815abe-13"})(["position:absolute;top:0;left:calc(-1 * var(--screen-space-lg));width:calc(100% + calc(var(--screen-space-lg) * 2));height:4px;background:var(--privy-color-background-2);border-top-left-radius:inherit;border-top-right-radius:inherit;overflow:hidden;"]),C=/*#__PURE__*/i.styled(o.BlobbyFooter).withConfig({displayName:"StyledBlobbyFooter",componentId:"sc-2e815abe-14"})(["padding:0;&& a{padding:0;color:var(--privy-color-foreground-3);}"]),k=/*#__PURE__*/i.styled.div.withConfig({displayName:"ProgressBarFill",componentId:"sc-2e815abe-15"})(["height:100%;width:","%;background:var(--privy-color-foreground-3);border-radius:2px;transition:width 300ms ease-in-out;"],(({pct:e})=>e)),I=({step:r})=>r?/*#__PURE__*/e.jsx(j,{children:/*#__PURE__*/e.jsx(k,{pct:Math.min(100,r.current/r.total*100)})}):null;w.Header=({title:r,subtitle:i,icon:n,iconVariant:o,iconLoadingStatus:t,showBack:a,onBack:l,showInfo:c,onInfo:s,showClose:g,onClose:h,step:f,...m})=>/*#__PURE__*/e.jsxs(d,{...m,children:[/*#__PURE__*/e.jsx(p,{backFn:a?l:void 0,infoFn:c?s:void 0,onClose:g?h:void 0,closeable:g}),(n||o||r||i)&&/*#__PURE__*/e.jsxs(u,{children:[n||o?/*#__PURE__*/e.jsx(w.Icon,{icon:n,variant:o,loadingStatus:t}):null,/*#__PURE__*/e.jsxs(y,{children:[r&&/*#__PURE__*/e.jsx(v,{children:r}),i&&/*#__PURE__*/e.jsx(x,{children:i})]})]}),f&&/*#__PURE__*/e.jsx(I,{step:f})]}),w.Body=/*#__PURE__*/l.default.forwardRef((({children:r,...i},n)=>/*#__PURE__*/e.jsx(g,{ref:n,...i,children:r}))),w.Body.displayName="Screen.Body",w.Footer=({children:r,...i})=>/*#__PURE__*/e.jsx(h,{id:"privy-content-footer-container",...i,children:r}),w.Actions=({children:r,...i})=>/*#__PURE__*/e.jsx(N,{...i,children:r}),w.HelpText=({children:r,...i})=>/*#__PURE__*/e.jsx(E,{...i,children:r}),w.Watermark=()=>/*#__PURE__*/e.jsx(C,{}),w.Icon=({icon:r,variant:i="subtle",loadingStatus:o})=>"logo"===i&&r?"string"==typeof r?/*#__PURE__*/e.jsx(m,{children:/*#__PURE__*/e.jsx("img",{src:r,alt:""})}):/*#__PURE__*/l.default.isValidElement(r)?/*#__PURE__*/e.jsx(m,{children:r}):
/*#__PURE__*/e.jsx(m,{children:/*#__PURE__*/l.default.createElement(r)}):"loading"===i?r?
/*#__PURE__*/e.jsx(b,{children:/*#__PURE__*/e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:[/*#__PURE__*/e.jsx(n.ConnectionLoader,{success:o?.success,fail:o?.fail}),"string"==typeof r?
/*#__PURE__*/e.jsx("span",{style:{background:`url('${r}') 0 0 / contain`,height:"38px",width:"38px",borderRadius:"6px",margin:"auto",backgroundSize:"contain"}}):/*#__PURE__*/l.default.isValidElement(r)?
/*#__PURE__*/l.default.cloneElement(r,{style:{width:"38px",height:"38px"}}):
/*#__PURE__*/l.default.createElement(r,{style:{width:"38px",height:"38px"}})]})}):
/*#__PURE__*/e.jsx(f,{$variant:i,children:/*#__PURE__*/e.jsx(t.NeutralSpinner,{size:"64px"})}):/*#__PURE__*/e.jsx(f,{$variant:i,children:r&&("string"==typeof r?
/*#__PURE__*/e.jsx("img",{src:r,alt:"",style:{width:"32px",height:"32px",borderRadius:"6px"}}):/*#__PURE__*/l.default.isValidElement(r)?r:
/*#__PURE__*/l.default.createElement(r,{width:32,height:32,stroke:(()=>{switch(i){case"success":return"var(--privy-color-icon-success)";case"warning":return"var(--privy-color-icon-warning)";case"error":return"var(--privy-color-icon-error)";default:return"var(--privy-color-icon-muted)"}})(),strokeWidth:2}))});let N=/*#__PURE__*/i.styled.div.withConfig({displayName:"ActionsContainer",componentId:"sc-2e815abe-16"})(["width:100%;display:flex;flex-direction:column;gap:calc(var(--screen-space) / 2);"]),E=/*#__PURE__*/i.styled.p.withConfig({displayName:"HelpTextContainer",componentId:"sc-2e815abe-17"})(["&&{margin:0;width:100%;text-align:center;color:var(--privy-color-foreground-3);font-size:14px;line-height:22px;& a{color:var(--privy-color-accent);}}"]);exports.Screen=w;