@coinbase/cdp-react 0.0.0 → 0.0.1
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.
- package/README.md +99 -0
- package/dist/assets/Button.css +1 -0
- package/dist/assets/Error.css +1 -0
- package/dist/assets/Field.css +1 -0
- package/dist/assets/Input.css +1 -0
- package/dist/assets/LoadingSpinner.css +1 -0
- package/dist/assets/OTP.css +1 -0
- package/dist/assets/SignIn.css +1 -0
- package/dist/assets/SignInModal.css +1 -0
- package/dist/assets/SignOutButton.css +1 -0
- package/dist/assets/ThemeProvider.css +1 -0
- package/dist/assets/VisuallyHidden.css +1 -0
- package/dist/chunks/SignIn.module.Dl3CqKQ_.js +20 -0
- package/dist/components/AuthButton/index.d.ts +1 -0
- package/dist/components/AuthButton/index.js +20 -0
- package/dist/components/Button/index.d.ts +8 -0
- package/dist/components/Button/index.js +28 -0
- package/dist/components/CDPReactProvider/index.d.ts +11 -0
- package/dist/components/CDPReactProvider/index.js +20 -0
- package/dist/components/Error/index.d.ts +7 -0
- package/dist/components/Error/index.js +16 -0
- package/dist/components/Field/index.d.ts +11 -0
- package/dist/components/Field/index.js +22 -0
- package/dist/components/Input/index.d.ts +4 -0
- package/dist/components/Input/index.js +17 -0
- package/dist/components/LoadingSpinner/index.d.ts +3 -0
- package/dist/components/LoadingSpinner/index.js +31 -0
- package/dist/components/OTP/index.d.ts +7 -0
- package/dist/components/OTP/index.js +42 -0
- package/dist/components/ServerError/index.d.ts +8 -0
- package/dist/components/ServerError/index.js +14 -0
- package/dist/components/SignIn/SignInDescription.d.ts +5 -0
- package/dist/components/SignIn/SignInDescription.js +27 -0
- package/dist/components/SignIn/SignInForm.d.ts +6 -0
- package/dist/components/SignIn/SignInForm.js +177 -0
- package/dist/components/SignIn/SignInImage.d.ts +6 -0
- package/dist/components/SignIn/SignInImage.js +21 -0
- package/dist/components/SignIn/SignInProvider.d.ts +13 -0
- package/dist/components/SignIn/SignInProvider.js +29 -0
- package/dist/components/SignIn/SignInTitle.d.ts +5 -0
- package/dist/components/SignIn/SignInTitle.js +16 -0
- package/dist/components/SignIn/index.d.ts +14 -0
- package/dist/components/SignIn/index.js +28 -0
- package/dist/components/SignIn/useSignInReducer.d.ts +58 -0
- package/dist/components/SignIn/useSignInReducer.js +49 -0
- package/dist/components/SignInModal/index.d.ts +8 -0
- package/dist/components/SignInModal/index.js +50 -0
- package/dist/components/SignOutButton/index.d.ts +8 -0
- package/dist/components/SignOutButton/index.js +16 -0
- package/dist/components/ThemeProvider/index.d.ts +15 -0
- package/dist/components/ThemeProvider/index.js +33 -0
- package/dist/components/VisuallyHidden/index.d.ts +10 -0
- package/dist/components/VisuallyHidden/index.js +17 -0
- package/dist/icons/IconCheckCircle.d.ts +2 -0
- package/dist/icons/IconCheckCircle.js +15 -0
- package/dist/icons/IconCoinbaseWordmark.d.ts +2 -0
- package/dist/icons/IconCoinbaseWordmark.js +16 -0
- package/dist/icons/IconExclamationCircle.d.ts +2 -0
- package/dist/icons/IconExclamationCircle.js +15 -0
- package/dist/icons/IconLock.d.ts +2 -0
- package/dist/icons/IconLock.js +13 -0
- package/dist/icons/IconXMark.d.ts +2 -0
- package/dist/icons/IconXMark.js +13 -0
- package/dist/icons/SvgIcon.d.ts +4 -0
- package/dist/icons/SvgIcon.js +19 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +10 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +48 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.js +10 -0
- package/dist/theme/theme.d.ts +37 -0
- package/dist/theme/theme.js +6 -0
- package/dist/theme/tokens.d.ts +50 -0
- package/dist/theme/tokens.js +63 -0
- package/dist/theme/utils.d.ts +11 -0
- package/dist/theme/utils.js +18 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/isApiError.d.ts +6 -0
- package/dist/utils/isApiError.js +4 -0
- package/dist/utils/isEmailInvalid.d.ts +1 -0
- package/dist/utils/isEmailInvalid.js +4 -0
- package/package.json +108 -6
- package/index.js +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
This package contains ready-made, customizable React UI components that wrap
|
|
2
|
+
the CDP frontend SDK.
|
|
3
|
+
|
|
4
|
+
## Components
|
|
5
|
+
|
|
6
|
+
- {@link SignInModal | `SignInModal`} - a button that triggers a modal with the sign-in flow
|
|
7
|
+
- {@link SignIn | `SignIn`} - the forms for the sign in flow, a logo, heading, and description text
|
|
8
|
+
- {@link SignOutButton | `SignOutButton`} - a sign out button
|
|
9
|
+
- {@link AuthButton | `AuthButton`} - the `SignOutButton` when logged in, and the `SignInModal` when logged out
|
|
10
|
+
|
|
11
|
+
## Quickstart
|
|
12
|
+
|
|
13
|
+
This guide will help you get started with `@coinbase/cdp-react`. You'll learn how to install the package, set up the provider, and render your first component.
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
First, add the package to your project using your preferred package manager.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# With pnpm
|
|
21
|
+
pnpm add @coinbase/cdp-react @coinbase/cdp-core @coinbase/cdp-hooks
|
|
22
|
+
|
|
23
|
+
# With yarn
|
|
24
|
+
yarn add @coinbase/cdp-react @coinbase/cdp-core @coinbase/cdp-hooks
|
|
25
|
+
|
|
26
|
+
# With npm
|
|
27
|
+
npm install @coinbase/cdp-react @coinbase/cdp-core @coinbase/cdp-hooks
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Gather your CDP Project information
|
|
31
|
+
|
|
32
|
+
1. Sign in or create an account on the [CDP Portal](https://portal.cdp.coinbase.com)
|
|
33
|
+
2. On your dashboard, select a project from the dropdown at the at the top, and copy the Project ID
|
|
34
|
+
|
|
35
|
+
### Setup Provider
|
|
36
|
+
|
|
37
|
+
Next, you need to wrap your application with the `CDPReactProvider`.
|
|
38
|
+
|
|
39
|
+
`CDPReactProvider` provides the necessary context for hooks and components to work correctly. It also provides access to config data and theming.
|
|
40
|
+
|
|
41
|
+
Update your main application file (e.g., `main.tsx` or `App.tsx`) to include the provider:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import React from 'react';
|
|
45
|
+
import ReactDOM from 'react-dom/client';
|
|
46
|
+
import { App } from './App'; // Your main App component
|
|
47
|
+
import { CDPReactProvider, type Theme } from '@coinbase/cdp-react';
|
|
48
|
+
|
|
49
|
+
// Your CDP config
|
|
50
|
+
const cdpConfig = {
|
|
51
|
+
projectId: "your-project-id", // Copy your Project ID here.
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Global config for your dapp
|
|
55
|
+
const appConfig = {
|
|
56
|
+
name: "My app", // the name of your application
|
|
57
|
+
logoUrl: "https://picsum.photos/64", // logo will be displayed in select components
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
// You can customize the theme by overriding theme variables
|
|
62
|
+
const themeOverrides: Partial<Theme> = {
|
|
63
|
+
"colors-background": "black";
|
|
64
|
+
"colors-backgroundOverlay": "rgba(0,0,0,0.5)",
|
|
65
|
+
"colors-text": "white";
|
|
66
|
+
"colors-textSecondary": "#999999";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
70
|
+
<React.StrictMode>
|
|
71
|
+
<CDPReactProvider config={cdpConfig} app={appConfig} theme={themeOverrides}>
|
|
72
|
+
<App />
|
|
73
|
+
</CDPReactProvider>
|
|
74
|
+
</React.StrictMode>,
|
|
75
|
+
);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Render a Component
|
|
79
|
+
|
|
80
|
+
Now you can use the components from the library. Let's add the `AuthButton` component to your application. This component handles both sign-in and sign-out functionality.
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
// In your App.tsx or any other component
|
|
84
|
+
import { AuthButton } from '@coinbase/cdp-react/components/AuthButton';
|
|
85
|
+
|
|
86
|
+
function App() {
|
|
87
|
+
return (
|
|
88
|
+
<div>
|
|
89
|
+
<h1>Welcome</h1>
|
|
90
|
+
<AuthButton />
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default App;
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
That's it! You've successfully installed `@coinbase/cdp-react`, set up the provider, and rendered your first component.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.Button-module__btn___Fx11X{--cdp-web-button-ring-color: transparent;--cdp-web-button-ring-width: 2px;--cdp-web-button-ring-inset-color: transparent;--cdp-web-button-ring-inset-width: 2px;box-shadow:inset 0 0 0 var(--cdp-web-button-ring-inset-width) var(--cdp-web-button-ring-inset-color),0 0 0 var(--cdp-web-button-ring-width) var(--cdp-web-button-ring-color);display:inline-flex;align-items:center;justify-content:center;gap:.5em;padding:1em;border-radius:9999em;border:0;background-color:transparent;color:var(--cdp-web-colors-text);font-size:1em;font-weight:500;line-height:1.5;text-decoration:none;cursor:pointer;transition:all .15s ease-in-out;-webkit-user-select:none;user-select:none}.Button-module__primary___s1sM6{background-color:var(--cdp-web-colors-primary);color:var(--cdp-web-colors-primaryText)}.Button-module__primary___s1sM6:hover{background-color:var(--cdp-web-colors-primaryHoverBackground);color:var(--cdp-web-colors-primaryHoverText)}.Button-module__primary___s1sM6:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-primaryFocusRing);--cdp-web-button-ring-inset-color: var(--cdp-web-colors-background);outline:none}.Button-module__secondary___R0waJ{background-color:var(--cdp-web-colors-secondary);color:var(--cdp-web-colors-secondaryText)}.Button-module__secondary___R0waJ:hover{background-color:var(--cdp-web-colors-secondaryHoverBackground);color:var(--cdp-web-colors-secondaryHoverText)}.Button-module__secondary___R0waJ:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-secondaryFocusRing);--cdp-web-button-ring-inset-color: var(--cdp-web-colors-background);outline:none}.Button-module__transparentPrimary___o7JPs{background-color:transparent;color:var(--cdp-web-colors-linkText)}.Button-module__transparentPrimary___o7JPs:hover{color:var(--cdp-web-colors-linkHover)}.Button-module__transparentPrimary___o7JPs:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-linkText);outline:none}.Button-module__transparentSecondary___4ehOz{background-color:transparent;color:var(--cdp-web-colors-linkSecondaryText)}.Button-module__transparentSecondary___4ehOz:hover{color:var(--cdp-web-colors-linkSecondaryHover)}.Button-module__transparentSecondary___4ehOz:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-linkSecondaryText);outline:none}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.Error-module__error___mRFLG{color:var(--cdp-web-colors-error);font-size:.875em;line-height:1.43;display:flex;align-items:center;gap:.25em;margin:0}.Error-module__icon___web4F{width:1em;height:1em}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.Field-module__fieldWrapper___K-oJB{display:flex;flex-direction:column;gap:.375em}.Field-module__label___LAQio{font-size:.875em;line-height:1.43;font-weight:500;color:var(--cdp-web-colors-inputLabel)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.Input-module__input___WjT81{--cdp-web-input-ring-width: 1px;--cdp-web-input-ring-color: var(--cdp-web-colors-inputBorder);font-size:1em;padding:.75em;border-radius:.5em;border:1px solid transparent;background-color:var(--cdp-web-colors-inputBackground);box-shadow:0 0 0 var(--cdp-web-input-ring-width) var(--cdp-web-input-ring-color);color:var(--cdp-web-colors-inputText);transition:all .15s ease-in-out;width:100%}.Input-module__input___WjT81::placeholder{color:var(--cdp-web-colors-inputPlaceholder)}.Input-module__input___WjT81:focus-visible{outline:none;--cdp-web-input-ring-color: var(--cdp-web-colors-inputFocusBorder);--cdp-web-input-ring-width: 2px}.Input-module__input___WjT81[aria-invalid=true]{--cdp-web-input-ring-color: var(--cdp-web-colors-error)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.LoadingSpinner-module__spinner___X3Bl3{transform-origin:center;animation:LoadingSpinner-module__spinner___X3Bl3 2s linear infinite}.LoadingSpinner-module__spinnerCircle___ZQ0yQ{stroke-linecap:round;animation:LoadingSpinner-module__spinnerCircle___ZQ0yQ 1.5s ease-in-out infinite}@keyframes LoadingSpinner-module__spinner___X3Bl3{to{transform:rotate(360deg)}}@keyframes LoadingSpinner-module__spinnerCircle___ZQ0yQ{0%{stroke-dasharray:0 150;stroke-dashoffset:0}47.5%{stroke-dasharray:42 150;stroke-dashoffset:-16}95%,to{stroke-dasharray:42 150;stroke-dashoffset:-59}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.OTP-module__groupContainer___cVyAa{display:flex;gap:.5em}.OTP-module__inputContainer___39Wld{width:var(--cdp-web-otp-input-width)}.OTP-module__input___MEBPV{text-align:center}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.SignIn-module__signIn___cS7KU{border-radius:.75em;font:var(--cdp-web-fontSizeBase) / 1.5 var(--cdp-web-fontFamily-sans);background-color:var(--cdp-web-colors-background);color:var(--cdp-web-colors-text);display:flex;flex-direction:column;gap:1em;max-width:38.25em;padding:1em 2em;width:100%}.SignIn-module__heading___nzF-H{font-size:1.75em;line-height:1.29;margin:0}.SignIn-module__description___6bRpF{color:var(--cdp-web-colors-textSecondary);margin:0}.SignIn-module__medium___rfGKj{font-weight:500}.SignIn-module__form___MXCq6{display:flex;flex-direction:column;gap:1em}.SignIn-module__logo___9j5Y-{display:block;margin:0;width:64px;height:64px;border-radius:9999em;object-fit:cover}.SignIn-module__formFooter___Rasrs{display:flex;flex-flow:column nowrap;align-items:stretch;justify-content:center;gap:.5em;min-height:1.5em}.SignIn-module__serverStateWrapper___GML6w{min-height:1.5em}.SignIn-module__loadingSpinner___JnMDX{color:var(--cdp-web-colors-linkText);display:block;margin:0 auto}.SignIn-module__formFooter___Rasrs button{width:100%}.SignIn-module__serverError___p4Z3K{justify-content:center}.SignIn-module__resetTimer___s-bUu{color:var(--cdp-web-colors-textSecondary);font-size:.875em;font-weight:500;line-height:1em;padding:1.5em 0;text-align:center}.SignIn-module__resetTimer___s-bUu p{margin:0}.SignIn-module__successIcon___2a7me{color:var(--cdp-web-colors-success);display:block;height:4em;width:4em}.SignIn-module__footer___3Gkbc{color:var(--cdp-web-colors-textSecondary);display:flex;align-items:center;justify-content:center;gap:.5em;font-size:.75em;line-height:1;padding:.5em 2em 1em}.SignIn-module__coinbaseIcon___cOnQb{color:var(--cdp-web-colors-linkText);height:1em;width:auto}.SignIn-module__footer___3Gkbc p{display:flex;align-items:center;gap:.25em;margin:0}.SignIn-module__hr___WFRgK{border:0;border-top:1px solid var(--cdp-web-colors-border);width:100%}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.SignInModal-module__trigger___IcJ8x{padding-left:2em;padding-right:2em}.SignInModal-module__modal___PErrT{--shadow-md: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);box-shadow:var(--shadow-md);width:100%;max-width:38.25em;background:var(--cdp-web-colors-background);border-radius:.5em;outline:1px solid var(--cdp-web-colors-border);position:relative}.SignInModal-module__modal___PErrT[data-state=open]{animation:SignInModal-module__slideIn___7GyWR .2s ease-out,SignInModal-module__fadeIn___-TaAT .2s ease-out}.SignInModal-module__modal___PErrT[data-state=closed]{animation:SignInModal-module__slideOut___Ntrrb .2s ease-in,SignInModal-module__fadeOut___bzuhB .2s ease-in}.SignInModal-module__signIn___hQuJk{height:100%}.SignInModal-module__signInForm___6-UdI,.SignInModal-module__signInForm___6-UdI form{flex-grow:1}.SignInModal-module__signInTitle___AF-XA,.SignInModal-module__signInDescription___SZjXu{text-align:center}.SignInModal-module__signInImage___hMBda{display:flex;justify-content:center;align-items:center;flex-grow:1;margin:2em 0}.SignInModal-module__closeWrapper___cx8Zq{display:flex;justify-content:flex-end;align-items:center}.SignInModal-module__closeButton___yf-ZW{position:relative;left:1em;width:3em}.SignInModal-module__closeButton___yf-ZW svg{height:1em;width:1em}.SignInModal-module__overlay___-0rmi{background:var(--cdp-web-colors-backgroundOverlay);-webkit-backdrop-filter:blur(.5em);backdrop-filter:blur(.5em);display:grid;grid-template-rows:auto 1fr;inset:0;overflow-y:auto;place-items:end center;position:fixed;z-index:1000}.SignInModal-module__overlay___-0rmi[data-state=open]{animation:SignInModal-module__fadeIn___-TaAT .2s ease-out}.SignInModal-module__overlay___-0rmi[data-state=closed]{animation:SignInModal-module__fadeOut___bzuhB .2s ease-in}.SignInModal-module__spacer___x-lRH{height:1em}@keyframes SignInModal-module__fadeIn___-TaAT{0%{opacity:0}to{opacity:1}}@keyframes SignInModal-module__fadeOut___bzuhB{0%{opacity:1}to{opacity:0}}@keyframes SignInModal-module__slideIn___7GyWR{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes SignInModal-module__slideOut___Ntrrb{0%{transform:translateY(0)}to{transform:translateY(100%)}}@media (min-width: 400px){.SignInModal-module__overlay___-0rmi{padding:.5rem}}@media (min-width: 600px){.SignInModal-module__overlay___-0rmi{place-items:center;padding:1rem;grid-template-rows:1fr}.SignInModal-module__modal___PErrT{height:auto}.SignInModal-module__spacer___x-lRH{display:none}.SignInModal-module__signIn___hQuJk{padding-left:0;padding-right:0}.SignInModal-module__closeWrapper___cx8Zq,.SignInModal-module__signInImage___hMBda,.SignInModal-module__signInTitle___AF-XA,.SignInModal-module__signInDescription___SZjXu,.SignInModal-module__signInForm___6-UdI>form,.SignInModal-module__signInForm___6-UdI>div{padding-left:2.5em;padding-right:2.5em}.SignInModal-module__signInImage___hMBda{align-self:flex-start;margin:0}.SignInModal-module__signInTitle___AF-XA,.SignInModal-module__signInDescription___SZjXu{text-align:left}@keyframes SignInModal-module__slideIn___7GyWR{0%{transform:translateY(10%)}to{transform:translateY(0)}}@keyframes SignInModal-module__slideOut___Ntrrb{0%{transform:translateY(0)}to{transform:translateY(10%)}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.SignOutButton-module__signOutButton___WNhmy{padding-left:2em;padding-right:2em}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ThemeProvider-module__wrapper___aXwhZ{width:100%}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.VisuallyHidden-module__visuallyHidden___KiAzg{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import '../assets/SignIn.css';const n = "SignIn-module__signIn___cS7KU", _ = "SignIn-module__heading___nzF-H", o = "SignIn-module__description___6bRpF", e = "SignIn-module__medium___rfGKj", r = "SignIn-module__form___MXCq6", s = "SignIn-module__logo___9j5Y-", i = "SignIn-module__formFooter___Rasrs", c = "SignIn-module__serverStateWrapper___GML6w", t = "SignIn-module__loadingSpinner___JnMDX", m = "SignIn-module__serverError___p4Z3K", g = "SignIn-module__resetTimer___s-bUu", d = "SignIn-module__successIcon___2a7me", I = "SignIn-module__footer___3Gkbc", l = "SignIn-module__coinbaseIcon___cOnQb", u = "SignIn-module__hr___WFRgK", S = {
|
|
2
|
+
signIn: n,
|
|
3
|
+
heading: _,
|
|
4
|
+
description: o,
|
|
5
|
+
medium: e,
|
|
6
|
+
form: r,
|
|
7
|
+
logo: s,
|
|
8
|
+
formFooter: i,
|
|
9
|
+
serverStateWrapper: c,
|
|
10
|
+
loadingSpinner: t,
|
|
11
|
+
serverError: m,
|
|
12
|
+
resetTimer: g,
|
|
13
|
+
successIcon: d,
|
|
14
|
+
footer: I,
|
|
15
|
+
coinbaseIcon: l,
|
|
16
|
+
hr: u
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
S as s
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AuthButton: () => import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useIsSignedIn as m, useEvmAddress as f } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useState as n } from "react";
|
|
4
|
+
import { SignInModal as h } from "../SignInModal/index.js";
|
|
5
|
+
import { SignOutButton as l } from "../SignOutButton/index.js";
|
|
6
|
+
const A = () => {
|
|
7
|
+
const o = m(), i = f(), u = o && !!i, [r, t] = n(u), [c, e] = n(!1), S = () => {
|
|
8
|
+
setTimeout(() => {
|
|
9
|
+
e(!1);
|
|
10
|
+
}, 300), setTimeout(() => {
|
|
11
|
+
t(!0);
|
|
12
|
+
}, 500);
|
|
13
|
+
}, d = () => {
|
|
14
|
+
t(!1);
|
|
15
|
+
};
|
|
16
|
+
return r ? /* @__PURE__ */ s("div", { children: /* @__PURE__ */ s(l, { onSuccess: d }) }) : /* @__PURE__ */ s(h, { open: c, setIsOpen: e, onSuccess: S });
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
A as AuthButton
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { ButtonVariant } from '../../theme/theme';
|
|
3
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
isPending?: boolean;
|
|
5
|
+
pendingLabel?: ReactNode;
|
|
6
|
+
variant?: ButtonVariant;
|
|
7
|
+
}
|
|
8
|
+
export declare const Button: import('react').ForwardRefExoticComponent<ButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as r, jsxs as i, Fragment as d } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as p } from "react";
|
|
3
|
+
import "../../theme/theme.js";
|
|
4
|
+
import { LoadingSpinner as c } from "../LoadingSpinner/index.js";
|
|
5
|
+
import { VisuallyHidden as u } from "../VisuallyHidden/index.js";
|
|
6
|
+
import '../../assets/Button.css';const y = "Button-module__btn___Fx11X", l = "Button-module__primary___s1sM6", B = "Button-module__secondary___R0waJ", f = "Button-module__transparentPrimary___o7JPs", b = "Button-module__transparentSecondary___4ehOz", n = {
|
|
7
|
+
btn: y,
|
|
8
|
+
primary: l,
|
|
9
|
+
secondary: B,
|
|
10
|
+
transparentPrimary: f,
|
|
11
|
+
transparentSecondary: b
|
|
12
|
+
}, h = p(
|
|
13
|
+
({
|
|
14
|
+
children: t,
|
|
15
|
+
className: o = "",
|
|
16
|
+
isPending: a,
|
|
17
|
+
pendingLabel: e = "Loading...",
|
|
18
|
+
variant: s = "primary",
|
|
19
|
+
...m
|
|
20
|
+
}, _) => /* @__PURE__ */ r("button", { className: `${n.btn} ${n[s]} ${o}`, ref: _, ...m, children: a ? /* @__PURE__ */ i(d, { children: [
|
|
21
|
+
/* @__PURE__ */ r(c, { "aria-hidden": "true", className: n.spinner }),
|
|
22
|
+
/* @__PURE__ */ r(u, { children: e })
|
|
23
|
+
] }) : t })
|
|
24
|
+
);
|
|
25
|
+
h.displayName = "Button";
|
|
26
|
+
export {
|
|
27
|
+
h as Button
|
|
28
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CDPHooksProviderProps } from '@coinbase/cdp-hooks';
|
|
2
|
+
import { ThemeProviderProps } from '../ThemeProvider';
|
|
3
|
+
export interface AppConfig {
|
|
4
|
+
name: string;
|
|
5
|
+
logoUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
export type CDPReactProviderProps = CDPHooksProviderProps & ThemeProviderProps & {
|
|
8
|
+
app?: AppConfig;
|
|
9
|
+
};
|
|
10
|
+
export declare const CDPReactProvider: ({ children, config, theme, app }: CDPReactProviderProps) => import("react").JSX.Element;
|
|
11
|
+
export declare const useAppConfig: () => AppConfig;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { CDPContext as s, CDPHooksProvider as C } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { createContext as d, useContext as i, useMemo as m } from "react";
|
|
4
|
+
import { ThemeProvider as u } from "../ThemeProvider/index.js";
|
|
5
|
+
const l = ({ children: o, config: e, theme: r, app: c }) => {
|
|
6
|
+
const n = /* @__PURE__ */ t(f, { app: c, children: /* @__PURE__ */ t(u, { theme: r, children: o }) });
|
|
7
|
+
return i(s) ? n : /* @__PURE__ */ t(C, { config: e, children: n });
|
|
8
|
+
}, p = d(void 0), f = ({ children: o, app: e }) => {
|
|
9
|
+
const r = m(() => ({ app: e || { name: "", logoUrl: "" } }), [e]);
|
|
10
|
+
return /* @__PURE__ */ t(p.Provider, { value: r, children: o });
|
|
11
|
+
}, g = () => {
|
|
12
|
+
const o = i(p);
|
|
13
|
+
if (!o)
|
|
14
|
+
throw new Error("useAppConfig must be used within an AppConfigProvider");
|
|
15
|
+
return o.app;
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
l as CDPReactProvider,
|
|
19
|
+
g as useAppConfig
|
|
20
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsxs as n, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as i } from "react";
|
|
3
|
+
import { IconExclamationCircle as t } from "../../icons/IconExclamationCircle.js";
|
|
4
|
+
import '../../assets/Error.css';const a = "Error-module__error___mRFLG", _ = "Error-module__icon___web4F", o = {
|
|
5
|
+
error: a,
|
|
6
|
+
icon: _
|
|
7
|
+
}, l = i(
|
|
8
|
+
({ children: e, id: s, className: c = "" }, m) => /* @__PURE__ */ n("p", { id: s, className: `${o.error} ${c}`, ref: m, children: [
|
|
9
|
+
/* @__PURE__ */ r(t, { className: o.icon }),
|
|
10
|
+
/* @__PURE__ */ r("span", { children: e })
|
|
11
|
+
] })
|
|
12
|
+
);
|
|
13
|
+
l.displayName = "Error";
|
|
14
|
+
export {
|
|
15
|
+
l as Error
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FormMessageProps, FormValidityStateProps } from '@radix-ui/react-form';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
export interface FormFieldProps {
|
|
4
|
+
children?: FormValidityStateProps["children"];
|
|
5
|
+
className?: string;
|
|
6
|
+
label: string;
|
|
7
|
+
name: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
validators?: [FormMessageProps["match"], ReactNode][];
|
|
10
|
+
}
|
|
11
|
+
export declare const Field: ({ children, className, label, name, style, validators, }: FormFieldProps) => JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsxs as c, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { FormField as n, FormLabel as _, FormValidityState as F, FormControl as f, FormMessage as h } from "@radix-ui/react-form";
|
|
3
|
+
import "react";
|
|
4
|
+
import { Error as b } from "../Error/index.js";
|
|
5
|
+
import '../../assets/Field.css';const u = "Field-module__fieldWrapper___K-oJB", W = "Field-module__label___LAQio", o = {
|
|
6
|
+
fieldWrapper: u,
|
|
7
|
+
label: W
|
|
8
|
+
}, L = ({
|
|
9
|
+
children: l,
|
|
10
|
+
className: i = "",
|
|
11
|
+
label: a,
|
|
12
|
+
name: d,
|
|
13
|
+
style: m,
|
|
14
|
+
validators: s
|
|
15
|
+
}) => /* @__PURE__ */ c(n, { name: d, className: `${i} ${o.fieldWrapper}`, style: m, children: [
|
|
16
|
+
/* @__PURE__ */ e(_, { className: o.label, children: a }),
|
|
17
|
+
/* @__PURE__ */ e(F, { children: (r) => l && /* @__PURE__ */ e(f, { asChild: !0, children: l(r) }) }),
|
|
18
|
+
s?.map(([r, t], p) => /* @__PURE__ */ e(h, { match: r, asChild: !0, children: /* @__PURE__ */ e(b, { children: t }) }, p))
|
|
19
|
+
] });
|
|
20
|
+
export {
|
|
21
|
+
L as Field
|
|
22
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FormValidityStateProps } from '@radix-ui/react-form';
|
|
2
|
+
import { InputHTMLAttributes } from 'react';
|
|
3
|
+
export declare const Input: import('react').ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & import('react').RefAttributes<HTMLInputElement>>;
|
|
4
|
+
export declare const withValidityState: (props: InputHTMLAttributes<HTMLInputElement>) => FormValidityStateProps["children"];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import "@radix-ui/react-form";
|
|
3
|
+
import { forwardRef as p } from "react";
|
|
4
|
+
import '../../assets/Input.css';const u = "Input-module__input___WjT81", e = {
|
|
5
|
+
input: u
|
|
6
|
+
}, r = p(
|
|
7
|
+
({ className: i = "", ...n }, t) => /* @__PURE__ */ a("input", { ref: t, className: `${e.input} ${i}`, ...n })
|
|
8
|
+
);
|
|
9
|
+
r.displayName = "Input";
|
|
10
|
+
const m = (i) => (t) => {
|
|
11
|
+
const o = t === void 0 || t.valid ? void 0 : !0;
|
|
12
|
+
return /* @__PURE__ */ a(r, { ...i, "aria-invalid": o });
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
r as Input,
|
|
16
|
+
m as withValidityState
|
|
17
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import '../../assets/LoadingSpinner.css';const r = "LoadingSpinner-module__spinner___X3Bl3", s = "LoadingSpinner-module__spinnerCircle___ZQ0yQ", e = {
|
|
3
|
+
spinner: r,
|
|
4
|
+
spinnerCircle: s
|
|
5
|
+
}, o = ({ className: i }) => /* @__PURE__ */ n(
|
|
6
|
+
"svg",
|
|
7
|
+
{
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9
|
+
viewBox: "0 0 24 24",
|
|
10
|
+
role: "img",
|
|
11
|
+
"aria-label": "loading",
|
|
12
|
+
width: "24",
|
|
13
|
+
height: "24",
|
|
14
|
+
stroke: "currentColor",
|
|
15
|
+
className: i,
|
|
16
|
+
children: /* @__PURE__ */ n("g", { className: e.spinner, children: /* @__PURE__ */ n(
|
|
17
|
+
"circle",
|
|
18
|
+
{
|
|
19
|
+
className: e.spinnerCircle,
|
|
20
|
+
cx: "12",
|
|
21
|
+
cy: "12",
|
|
22
|
+
r: "9.5",
|
|
23
|
+
fill: "none",
|
|
24
|
+
strokeWidth: "3"
|
|
25
|
+
}
|
|
26
|
+
) })
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
export {
|
|
30
|
+
o as LoadingSpinner
|
|
31
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OneTimePasswordFieldProps } from '@radix-ui/react-one-time-password-field';
|
|
2
|
+
type OTPProps = {
|
|
3
|
+
error?: string | null;
|
|
4
|
+
passwordLength?: number;
|
|
5
|
+
} & OneTimePasswordFieldProps;
|
|
6
|
+
export declare const OTP: import('react').ForwardRefExoticComponent<Omit<OTPProps, "ref"> & import('react').RefAttributes<HTMLInputElement[]>>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsxs as d, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { OneTimePasswordField as f, OneTimePasswordFieldInput as _, OneTimePasswordFieldHiddenInput as C } from "@radix-ui/react-one-time-password-field";
|
|
3
|
+
import { forwardRef as P, useId as h, useRef as y, useEffect as O } from "react";
|
|
4
|
+
import { Input as T } from "../Input/index.js";
|
|
5
|
+
import { Error as I } from "../Error/index.js";
|
|
6
|
+
import '../../assets/OTP.css';const v = "OTP-module__groupContainer___cVyAa", w = "OTP-module__inputContainer___39Wld", N = "OTP-module__input___MEBPV", u = {
|
|
7
|
+
groupContainer: v,
|
|
8
|
+
inputContainer: w,
|
|
9
|
+
input: N
|
|
10
|
+
}, R = P(
|
|
11
|
+
({ error: r, passwordLength: o = 6, className: l = "", ...p }, n) => {
|
|
12
|
+
const a = h(), s = y(/* @__PURE__ */ new Map()), c = (e, t) => {
|
|
13
|
+
e ? s.current.set(t, e) : s.current.delete(t);
|
|
14
|
+
};
|
|
15
|
+
return O(() => {
|
|
16
|
+
const e = Array.from(s.current.values());
|
|
17
|
+
typeof n == "function" ? n(e) : n && (n.current = e);
|
|
18
|
+
}, [o, n]), /* @__PURE__ */ d("div", { className: l, children: [
|
|
19
|
+
/* @__PURE__ */ d(
|
|
20
|
+
f,
|
|
21
|
+
{
|
|
22
|
+
...p,
|
|
23
|
+
className: u.groupContainer,
|
|
24
|
+
"aria-invalid": !!r,
|
|
25
|
+
"aria-describedby": r ? a : void 0,
|
|
26
|
+
style: {
|
|
27
|
+
"--cdp-web-otp-input-width": `${Math.floor(100 / o)}%`
|
|
28
|
+
},
|
|
29
|
+
children: [
|
|
30
|
+
Array.from({ length: o }, (e, t) => /* @__PURE__ */ i("div", { className: u.inputContainer, children: /* @__PURE__ */ i(_, { asChild: !0, children: /* @__PURE__ */ i(T, { ref: (m) => c(m, t), className: u.input }) }) }, t)),
|
|
31
|
+
/* @__PURE__ */ i(C, {})
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
r && /* @__PURE__ */ i(I, { id: a, children: r })
|
|
36
|
+
] });
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
R.displayName = "OTP";
|
|
40
|
+
export {
|
|
41
|
+
R as OTP
|
|
42
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ApiError } from '../../utils/isApiError';
|
|
2
|
+
interface Props {
|
|
3
|
+
error: string | ApiError;
|
|
4
|
+
id?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const ServerError: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<HTMLDivElement>>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { isApiError as p } from "../../utils/isApiError.js";
|
|
4
|
+
import { Error as f } from "../Error/index.js";
|
|
5
|
+
const a = t(
|
|
6
|
+
({ error: r, id: o, className: e = "" }, m) => {
|
|
7
|
+
const s = p(r) ? r.errorMessage : r;
|
|
8
|
+
return /* @__PURE__ */ i(f, { ref: m, id: o, className: e, children: s });
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
a.displayName = "ServerError";
|
|
12
|
+
export {
|
|
13
|
+
a as ServerError
|
|
14
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ElementType, HTMLAttributes } from 'react';
|
|
2
|
+
export type SignInDescriptionProps = {
|
|
3
|
+
as?: ElementType;
|
|
4
|
+
} & HTMLAttributes<HTMLElement>;
|
|
5
|
+
export declare const SignInDescription: ({ as: Component, children, className, ...props }: SignInDescriptionProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsxs as t, Fragment as s, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { s as c } from "../../chunks/SignIn.module.Dl3CqKQ_.js";
|
|
4
|
+
import { useSignInContext as p } from "./SignInProvider.js";
|
|
5
|
+
const d = () => /* @__PURE__ */ e(s, { children: "We’ll send you a verification code via email." }), u = ({ email: i }) => /* @__PURE__ */ t(s, { children: [
|
|
6
|
+
"We’ve sent a 6 digit code to ",
|
|
7
|
+
/* @__PURE__ */ e("span", { className: c.medium, children: i }),
|
|
8
|
+
"."
|
|
9
|
+
] }), f = () => /* @__PURE__ */ e(s, { children: "You’ve successfully signed in." }), D = ({
|
|
10
|
+
as: i = "p",
|
|
11
|
+
children: r,
|
|
12
|
+
className: o = "",
|
|
13
|
+
...a
|
|
14
|
+
}) => {
|
|
15
|
+
const { state: l } = p(), { step: n, email: m } = l;
|
|
16
|
+
return /* @__PURE__ */ t(i, { className: `${c.description} ${o}`, ...a, children: [
|
|
17
|
+
r,
|
|
18
|
+
!r && /* @__PURE__ */ t(s, { children: [
|
|
19
|
+
n === "otp" && /* @__PURE__ */ e(u, { email: m }),
|
|
20
|
+
n === "success" && /* @__PURE__ */ e(f, {}),
|
|
21
|
+
n === "email" && /* @__PURE__ */ e(d, {})
|
|
22
|
+
] })
|
|
23
|
+
] });
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
D as SignInDescription
|
|
27
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ElementType, HTMLAttributes } from 'react';
|
|
2
|
+
export type SignInFormProps = {
|
|
3
|
+
as?: ElementType;
|
|
4
|
+
onSuccess?: () => void;
|
|
5
|
+
} & HTMLAttributes<HTMLElement>;
|
|
6
|
+
export declare const SignInForm: ({ as: Component, className, onSuccess, ...props }: SignInFormProps) => import("react").JSX.Element;
|