@coinbase/cdp-react 0.0.49 → 0.0.51
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 +15 -0
- package/dist/chunks/lite.1fxw3LjI.js +7 -0
- package/dist/components/AuthButton/index.d.ts +16 -3
- package/dist/components/AuthButton/index.js +51 -39
- package/dist/components/CDPReactProvider/index.d.ts +1 -1
- package/dist/components/CDPReactProvider/index.js +59 -52
- package/dist/components/Fund/index.d.ts +1 -1
- package/dist/components/Fund/index.js +9 -1
- package/dist/components/Fund/types.d.ts +2 -1
- package/dist/components/FundModal/index.d.ts +13 -3
- package/dist/components/FundModal/index.js +93 -83
- package/dist/components/OAuthStatusModal/index.js +39 -37
- package/dist/components/SendEvmTransactionButton/index.d.ts +3 -6
- package/dist/components/SendEvmTransactionButton/index.js +32 -34
- package/dist/components/SendSolanaTransactionButton/index.d.ts +3 -6
- package/dist/components/SendSolanaTransactionButton/index.js +28 -30
- package/dist/components/SignIn/SignInAuthMethodButtons.js +30 -25
- package/dist/components/SignIn/hooks/useSignInWithOAuth.js +12 -12
- package/dist/components/SignIn/index.d.ts +2 -3
- package/dist/components/SignIn/index.js +32 -32
- package/dist/components/SignInModal/index.d.ts +11 -0
- package/dist/components/SignInModal/index.js +73 -51
- package/dist/components/SignOutButton/index.d.ts +4 -5
- package/dist/components/SignOutButton/index.js +23 -10
- package/dist/components/ui/Button/index.js +20 -18
- package/dist/components/ui/ButtonBase/index.d.ts +1 -0
- package/dist/components/ui/ButtonBase/index.js +31 -28
- package/dist/components/ui/Modal/index.d.ts +4 -3
- package/dist/components/ui/Modal/index.js +26 -22
- package/dist/index.d.ts +2 -0
- package/dist/index.js +105 -92
- package/dist/utils/childrenHasComponent.d.ts +2 -0
- package/dist/utils/childrenHasComponent.js +13 -0
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -81,6 +81,21 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
|
81
81
|
);
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
#### Analytics Opt-Out
|
|
85
|
+
|
|
86
|
+
By default the SDK will emit usage analytics to help us improve the SDK. If you would like to opt-out, you can do so by setting the `disableAnalytics` configuration option to `true`.
|
|
87
|
+
|
|
88
|
+
```tsx lines
|
|
89
|
+
<CDPReactProvider
|
|
90
|
+
config={{
|
|
91
|
+
projectId: "your-project-id",
|
|
92
|
+
disableAnalytics: true,
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
<App />
|
|
96
|
+
</CDPReactProvider>
|
|
97
|
+
```
|
|
98
|
+
|
|
84
99
|
### Render a Component
|
|
85
100
|
|
|
86
101
|
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.
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
import { HTMLAttributes } from 'react';
|
|
2
|
-
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { SignInModalProps } from '../SignInModal';
|
|
3
|
+
import { SignOutButtonProps } from '../SignOutButton';
|
|
4
|
+
export type AuthButtonSlots = {
|
|
5
|
+
placeholder?: (props: Pick<HTMLAttributes<HTMLDivElement>, "className">) => ReactNode;
|
|
6
|
+
signOutButton?: (props: Pick<SignOutButtonProps, "onSuccess">) => ReactNode;
|
|
7
|
+
signInModal?: (props: Pick<SignInModalProps, "open" | "setIsOpen" | "onSuccess">) => ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export interface AuthButtonProps extends AuthButtonSlots {
|
|
10
|
+
children?: (props: {
|
|
11
|
+
[key in keyof AuthButtonSlots as Capitalize<key>]: ReactNode;
|
|
12
|
+
} & {
|
|
13
|
+
isInitialized: boolean;
|
|
14
|
+
isSignedIn: boolean;
|
|
15
|
+
}) => ReactNode;
|
|
3
16
|
closeOnSuccessDelay?: null | number;
|
|
4
17
|
onSignInSuccess?: () => void;
|
|
5
18
|
onSignInSuccessTransitionEnd?: () => void;
|
|
6
19
|
onSignOutSuccess?: () => void;
|
|
7
20
|
}
|
|
8
|
-
export declare const AuthButton: ({ closeOnSuccessDelay, onSignInSuccess, onSignInSuccessTransitionEnd, onSignOutSuccess, ...props }: AuthButtonProps & HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const AuthButton: ({ children, closeOnSuccessDelay, onSignInSuccess, onSignInSuccessTransitionEnd, onSignOutSuccess, placeholder, signInModal, signOutButton, ...props }: AuthButtonProps & Omit<HTMLAttributes<HTMLDivElement>, "children">) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,58 +1,70 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useIsInitialized as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { SignInModal as
|
|
5
|
-
import { SignOutButton as
|
|
6
|
-
import { LoadingSkeleton as
|
|
7
|
-
import '../../assets/AuthButton.css';const
|
|
8
|
-
loading:
|
|
9
|
-
},
|
|
1
|
+
import { jsx as u, jsxs as k, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import { useIsInitialized as z, useIsSignedIn as D } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useState as f, useRef as M, useCallback as A, useEffect as m } from "react";
|
|
4
|
+
import { SignInModal as N } from "../SignInModal/index.js";
|
|
5
|
+
import { SignOutButton as $ } from "../SignOutButton/index.js";
|
|
6
|
+
import { LoadingSkeleton as b } from "../ui/LoadingSkeleton/index.js";
|
|
7
|
+
import '../../assets/AuthButton.css';const q = "AuthButton-module__loading___JpDqi", C = {
|
|
8
|
+
loading: q
|
|
9
|
+
}, G = ({
|
|
10
|
+
children: d,
|
|
10
11
|
closeOnSuccessDelay: S = 800,
|
|
11
12
|
onSignInSuccess: g,
|
|
12
|
-
onSignInSuccessTransitionEnd:
|
|
13
|
-
onSignOutSuccess:
|
|
14
|
-
|
|
13
|
+
onSignInSuccessTransitionEnd: h,
|
|
14
|
+
onSignOutSuccess: p,
|
|
15
|
+
placeholder: I,
|
|
16
|
+
signInModal: O,
|
|
17
|
+
signOutButton: T,
|
|
18
|
+
...j
|
|
15
19
|
}) => {
|
|
16
|
-
const { isInitialized:
|
|
17
|
-
g?.(),
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
if (
|
|
20
|
+
const { isInitialized: n } = z(), { isSignedIn: r } = D(), [l, s] = f(r), [e, c] = f(!1), [i, a] = f(void 0), o = M(!1), _ = A(() => {
|
|
21
|
+
g?.(), a(S);
|
|
22
|
+
}, [S, g]), v = A(() => {
|
|
23
|
+
p?.(), s(!1);
|
|
24
|
+
}, [p]);
|
|
25
|
+
m(() => {
|
|
26
|
+
if (i === void 0)
|
|
23
27
|
return;
|
|
24
|
-
if (
|
|
28
|
+
if (i === null) {
|
|
25
29
|
o.current = !0;
|
|
26
30
|
return;
|
|
27
31
|
}
|
|
28
|
-
const
|
|
29
|
-
o.current = !0,
|
|
30
|
-
},
|
|
32
|
+
const t = setTimeout(() => {
|
|
33
|
+
o.current = !0, c(!1), a(void 0);
|
|
34
|
+
}, i);
|
|
31
35
|
return () => {
|
|
32
|
-
|
|
36
|
+
t && clearTimeout(t);
|
|
33
37
|
};
|
|
34
|
-
}, [
|
|
35
|
-
if (
|
|
38
|
+
}, [i]), m(() => {
|
|
39
|
+
if (e)
|
|
36
40
|
return;
|
|
37
|
-
let
|
|
38
|
-
return o.current && (
|
|
39
|
-
|
|
41
|
+
let t = null;
|
|
42
|
+
return o.current && (t = setTimeout(() => {
|
|
43
|
+
h?.(), o.current = !1, s(!0);
|
|
40
44
|
}, 200)), () => {
|
|
41
|
-
|
|
45
|
+
t && clearTimeout(t);
|
|
42
46
|
};
|
|
43
|
-
}, [
|
|
44
|
-
if (
|
|
47
|
+
}, [e, h]), m(() => {
|
|
48
|
+
if (r) {
|
|
45
49
|
if (o.current)
|
|
46
50
|
return;
|
|
47
|
-
|
|
51
|
+
e ? a((t) => t === void 0 ? 0 : t) : s(!0);
|
|
48
52
|
} else
|
|
49
53
|
s(!1);
|
|
50
|
-
}, [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
}, [r, e]);
|
|
55
|
+
const B = I ? I({ className: C.loading }) : /* @__PURE__ */ u(b, { className: C.loading }), w = T ? T({ onSuccess: v }) : /* @__PURE__ */ u($, { onSuccess: v }), x = O ? O({ open: e, setIsOpen: c, onSuccess: _ }) : /* @__PURE__ */ u(N, { open: e, setIsOpen: c, onSuccess: _ });
|
|
56
|
+
return /* @__PURE__ */ u("div", { ...j, children: d ? d({
|
|
57
|
+
isInitialized: n,
|
|
58
|
+
isSignedIn: l,
|
|
59
|
+
Placeholder: B,
|
|
60
|
+
SignOutButton: w,
|
|
61
|
+
SignInModal: x
|
|
62
|
+
}) : /* @__PURE__ */ k(y, { children: [
|
|
63
|
+
!n && B,
|
|
64
|
+
n && l && w,
|
|
65
|
+
n && !l && x
|
|
66
|
+
] }) });
|
|
55
67
|
};
|
|
56
68
|
export {
|
|
57
|
-
|
|
69
|
+
G as AuthButton
|
|
58
70
|
};
|
|
@@ -15,6 +15,6 @@ export type CDPReactProviderProps = {
|
|
|
15
15
|
config: Config;
|
|
16
16
|
name?: string;
|
|
17
17
|
} & ThemeProviderProps;
|
|
18
|
-
export declare const CDPReactProvider: ({ children, config, name, theme }: CDPReactProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const CDPReactProvider: ({ children, className, config, name, style, theme, }: CDPReactProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
19
|
export declare const useAppConfig: () => Required<AppConfig>;
|
|
20
20
|
export declare const useProviderName: () => string;
|
|
@@ -1,95 +1,102 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { OAuth2ProviderType as
|
|
3
|
-
import { lazy as
|
|
4
|
-
import { ThemeProvider as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as c, jsxs as N } from "react/jsx-runtime";
|
|
2
|
+
import { OAuth2ProviderType as T, CDPContext as D, CDPHooksProvider as H } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { lazy as S, createContext as U, useContext as m, useMemo as P } from "react";
|
|
4
|
+
import { ThemeProvider as _ } from "../ThemeProvider/index.js";
|
|
5
|
+
const E = S(() => import("../OAuthStatusModal/index.js")), j = (o) => {
|
|
6
6
|
try {
|
|
7
7
|
return JSON.stringify(o);
|
|
8
8
|
} catch {
|
|
9
9
|
}
|
|
10
10
|
return "";
|
|
11
|
-
},
|
|
11
|
+
}, F = Object.keys(T).map((o) => `oauth:${o}`), k = [
|
|
12
12
|
/** Email OTP method */
|
|
13
13
|
"email",
|
|
14
14
|
/** SMS OTP method */
|
|
15
15
|
"sms"
|
|
16
|
-
],
|
|
16
|
+
], $ = [...k, ...F], q = ({
|
|
17
|
+
children: o,
|
|
18
|
+
className: r = "",
|
|
19
|
+
config: n,
|
|
20
|
+
name: s,
|
|
21
|
+
style: a,
|
|
22
|
+
theme: i
|
|
23
|
+
}) => {
|
|
17
24
|
const {
|
|
18
|
-
appName:
|
|
25
|
+
appName: h,
|
|
19
26
|
appLogoUrl: p,
|
|
20
27
|
showCoinbaseFooter: u,
|
|
21
|
-
authMethods:
|
|
22
|
-
projectId:
|
|
23
|
-
useMock:
|
|
24
|
-
debugging:
|
|
25
|
-
basePath:
|
|
26
|
-
ethereum:
|
|
27
|
-
solana:
|
|
28
|
-
} = n, { createOnLogin:
|
|
28
|
+
authMethods: t,
|
|
29
|
+
projectId: d,
|
|
30
|
+
useMock: C,
|
|
31
|
+
debugging: l,
|
|
32
|
+
basePath: f,
|
|
33
|
+
ethereum: v,
|
|
34
|
+
solana: x
|
|
35
|
+
} = n, { createOnLogin: A } = v ?? {}, { createOnLogin: O } = x ?? {}, L = P(
|
|
29
36
|
() => ({
|
|
30
|
-
projectId:
|
|
31
|
-
useMock:
|
|
32
|
-
debugging:
|
|
33
|
-
basePath:
|
|
34
|
-
ethereum: { createOnLogin:
|
|
35
|
-
solana: { createOnLogin:
|
|
37
|
+
projectId: d,
|
|
38
|
+
useMock: C,
|
|
39
|
+
debugging: l,
|
|
40
|
+
basePath: f,
|
|
41
|
+
ethereum: { createOnLogin: A },
|
|
42
|
+
solana: { createOnLogin: O }
|
|
36
43
|
}),
|
|
37
|
-
[
|
|
38
|
-
),
|
|
44
|
+
[d, C, l, f, A, O]
|
|
45
|
+
), w = { appName: h, appLogoUrl: p, showCoinbaseFooter: u, authMethods: t }, y = t?.some((b) => b.startsWith("oauth:")), M = /* @__PURE__ */ c(J, { name: s, config: w, children: /* @__PURE__ */ N(_, { className: r, style: a, theme: i, children: [
|
|
39
46
|
o,
|
|
40
|
-
|
|
47
|
+
y && /* @__PURE__ */ c(E, {})
|
|
41
48
|
] }) });
|
|
42
|
-
return m(
|
|
43
|
-
}, g =
|
|
49
|
+
return m(D) ? M : /* @__PURE__ */ c(H, { config: L, children: M });
|
|
50
|
+
}, g = U(
|
|
44
51
|
void 0
|
|
45
|
-
),
|
|
52
|
+
), e = {
|
|
46
53
|
appName: "",
|
|
47
54
|
appLogoUrl: "",
|
|
48
55
|
showCoinbaseFooter: !0,
|
|
49
56
|
authMethods: ["email"]
|
|
50
|
-
},
|
|
57
|
+
}, J = ({
|
|
51
58
|
children: o,
|
|
52
|
-
config:
|
|
53
|
-
name:
|
|
59
|
+
config: r,
|
|
60
|
+
name: n
|
|
54
61
|
}) => {
|
|
55
62
|
const {
|
|
56
|
-
appName:
|
|
57
|
-
appLogoUrl:
|
|
58
|
-
showCoinbaseFooter:
|
|
59
|
-
authMethods:
|
|
60
|
-
} =
|
|
63
|
+
appName: s = e.appName,
|
|
64
|
+
appLogoUrl: a = e.appLogoUrl,
|
|
65
|
+
showCoinbaseFooter: i = e.showCoinbaseFooter,
|
|
66
|
+
authMethods: h = e.authMethods
|
|
67
|
+
} = r ?? {}, p = j(h), u = P(() => {
|
|
61
68
|
let t = ["email"];
|
|
62
69
|
try {
|
|
63
|
-
t = JSON.parse(
|
|
70
|
+
t = JSON.parse(p);
|
|
64
71
|
} catch {
|
|
65
72
|
}
|
|
66
73
|
return {
|
|
67
74
|
app: {
|
|
68
|
-
appName:
|
|
69
|
-
appLogoUrl:
|
|
70
|
-
showCoinbaseFooter:
|
|
71
|
-
authMethods: Array.isArray(t) && t?.length ? t :
|
|
75
|
+
appName: s,
|
|
76
|
+
appLogoUrl: a,
|
|
77
|
+
showCoinbaseFooter: i,
|
|
78
|
+
authMethods: Array.isArray(t) && t?.length ? t : e.authMethods
|
|
72
79
|
},
|
|
73
|
-
name:
|
|
80
|
+
name: n
|
|
74
81
|
};
|
|
75
|
-
}, [a, i, p,
|
|
76
|
-
return /* @__PURE__ */
|
|
77
|
-
},
|
|
82
|
+
}, [s, a, i, p, n]);
|
|
83
|
+
return /* @__PURE__ */ c(g.Provider, { value: u, children: o });
|
|
84
|
+
}, B = () => {
|
|
78
85
|
const o = m(g);
|
|
79
86
|
if (!o)
|
|
80
87
|
throw new Error("useAppConfig must be used within an AppConfigProvider");
|
|
81
88
|
return o.app;
|
|
82
|
-
},
|
|
89
|
+
}, G = () => {
|
|
83
90
|
const o = m(g);
|
|
84
91
|
if (!o)
|
|
85
92
|
throw new Error("useProviderName must be used within an AppConfigProvider");
|
|
86
93
|
return o.name ?? "";
|
|
87
94
|
};
|
|
88
95
|
export {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
$ as ALL_AUTH_METHODS,
|
|
97
|
+
k as AUTH_METHODS,
|
|
98
|
+
q as CDPReactProvider,
|
|
99
|
+
F as OAUTH_METHODS,
|
|
100
|
+
B as useAppConfig,
|
|
101
|
+
G as useProviderName
|
|
95
102
|
};
|
|
@@ -5,6 +5,6 @@ import { useFundContext } from './FundProvider';
|
|
|
5
5
|
import { FundTitle, FundTitleProps } from './FundTitle';
|
|
6
6
|
import { FetchBuyUrlParams } from './hooks/useBuyUrl';
|
|
7
7
|
import { CamelToSnakeCase, CamelToSnakeCaseNested, FundAction, FetchBuyOptions, FetchBuyQuote, FundPaymentMethod, FundPresetAmountInputs, FundProps, FundState, FundStateError, FundStateProps, FundContextType, FundLifecycleStatus, OnrampAmount, OnrampBuyQuoteResponse, OnrampBuyOptionsResponse, OnrampBuyOptionsSnakeCaseResponse, OnrampBuyQuoteSnakeCaseResponse, OnrampError, OnrampNetwork, OnrampPaymentCurrency, OnrampPaymentMethodLimit, OnrampPurchaseCurrency, OnrampSuccessEventData } from './types';
|
|
8
|
-
declare const Fund: ({ className, children, openIn, submitLabel, title, ...props }: FundProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare const Fund: ({ className, children, openIn, style, submitLabel, title, ...props }: FundProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
declare const FundFooter: (props: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export { Fund, FundFooter, FundForm, FundTitle, useFundContext, type CamelToSnakeCase, type CamelToSnakeCaseNested, type FundAction, type FetchBuyOptions, type FetchBuyQuote, type FetchBuyUrlParams, type FundContextType, type FundFormProps, type FundLifecycleStatus, type FundPaymentMethod, type FundPresetAmountInputs, type FundProps, type FundState, type FundStateError, type FundStateProps, type FundTitleProps, type InputType, type OnrampAmount, type OnrampBuyQuoteResponse, type OnrampBuyOptionsResponse, type OnrampBuyOptionsSnakeCaseResponse, type OnrampBuyQuoteSnakeCaseResponse, type OnrampError, type OnrampNetwork, type OnrampPaymentCurrency, type OnrampPaymentMethodLimit, type OnrampPurchaseCurrency, type OnrampSuccessEventData, };
|
|
@@ -8,7 +8,15 @@ import { FundTitle as _ } from "./FundTitle.js";
|
|
|
8
8
|
import { useSetupOnrampEventListeners as b } from "./hooks/useSetupOnrampEventListeners.js";
|
|
9
9
|
import '../../assets/Fund.css';const x = "Fund-module__fund___6j-Og", g = {
|
|
10
10
|
fund: x
|
|
11
|
-
}, L = ({
|
|
11
|
+
}, L = ({
|
|
12
|
+
className: o = "",
|
|
13
|
+
children: r,
|
|
14
|
+
openIn: e,
|
|
15
|
+
style: s,
|
|
16
|
+
submitLabel: u,
|
|
17
|
+
title: n,
|
|
18
|
+
...i
|
|
19
|
+
}) => /* @__PURE__ */ t(l, { ...i, children: /* @__PURE__ */ t("div", { className: `${g.fund} ${o}`, style: s, children: /* @__PURE__ */ t(h, { openIn: e, submitLabel: u, title: n, children: r }) }) }), h = ({
|
|
12
20
|
children: o,
|
|
13
21
|
openIn: r,
|
|
14
22
|
submitLabel: e,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatch, ReactNode } from 'react';
|
|
1
|
+
import { CSSProperties, Dispatch, ReactNode } from 'react';
|
|
2
2
|
import { InputType } from '../forms/ExchangeAmountInput/types';
|
|
3
3
|
import { FetchBuyUrlParams } from './hooks/useBuyUrl';
|
|
4
4
|
export type CamelToSnakeCase<T extends string> = T extends `${infer A}${infer B}` ? B extends Uncapitalize<B> ? `${A}${CamelToSnakeCase<B>}` : `${Uncapitalize<A>}_${CamelToSnakeCase<Uncapitalize<B>>}` : T;
|
|
@@ -111,6 +111,7 @@ export interface FundProps extends FundStateProps, FundLifecycleEvents {
|
|
|
111
111
|
inputType?: InputType;
|
|
112
112
|
openIn?: "popup" | "tab";
|
|
113
113
|
redirectUrl?: string;
|
|
114
|
+
style?: CSSProperties;
|
|
114
115
|
submitLabel?: ReactNode;
|
|
115
116
|
title?: ReactNode;
|
|
116
117
|
}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { FundProps } from '../Fund';
|
|
3
|
-
|
|
3
|
+
import { ButtonProps } from '../ui/Button';
|
|
4
|
+
import { ModalContentProps } from '../ui/Modal';
|
|
5
|
+
interface FundModalTriggerProps extends Partial<Pick<ButtonProps, "className" | "fullWidth" | "size" | "style" | "variant">> {
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
interface FundModalContentProps extends ModalContentProps {
|
|
10
|
+
}
|
|
11
|
+
interface FundModalProps extends Omit<FundProps, "children"> {
|
|
4
12
|
children?: ReactNode;
|
|
5
13
|
open?: boolean;
|
|
6
14
|
setIsOpen?: (value: boolean) => void;
|
|
7
15
|
}
|
|
8
|
-
declare const
|
|
9
|
-
|
|
16
|
+
declare const FundModalTrigger: ({ children, className, label, ...props }: FundModalTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare const FundModalContent: (props: FundModalContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
declare const FundModal: ({ children, open, setIsOpen, ...fundProps }: FundModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export { FundModal, FundModalContent, FundModalTrigger, type FundModalProps, type FundModalContentProps, type FundModalTriggerProps, };
|
|
@@ -1,93 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { jsx as o, jsxs as i, Fragment as M } from "react/jsx-runtime";
|
|
2
|
+
import { c as x } from "../../chunks/lite.1fxw3LjI.js";
|
|
3
|
+
import { createContext as w, useState as j, useCallback as F, useMemo as A, useId as $, useContext as z } from "react";
|
|
4
|
+
import { useAppConfig as S } from "../CDPReactProvider/index.js";
|
|
5
|
+
import { Fund as V, FundFooter as k } from "../Fund/index.js";
|
|
6
|
+
import { Button as v } from "../ui/Button/index.js";
|
|
7
|
+
import { Modal as D, ModalContent as H, ModalTitle as L, ModalClose as R, ModalTrigger as U } from "../ui/Modal/index.js";
|
|
8
|
+
import { VisuallyHidden as C } from "../ui/VisuallyHidden/index.js";
|
|
9
|
+
import { IconXMark as W } from "../../icons/IconXMark.js";
|
|
10
|
+
import { childrenHasComponent as g } from "../../utils/childrenHasComponent.js";
|
|
11
|
+
import { FundTitle as _ } from "../Fund/FundTitle.js";
|
|
12
|
+
import { FundForm as X } from "../Fund/FundForm.js";
|
|
13
|
+
import '../../assets/FundModal.css';const q = "FundModal-module__trigger___2IuXj", B = "FundModal-module__fund___1AmQa", E = "FundModal-module__title___lNsoT", K = "FundModal-module__content___9f3ze", t = {
|
|
14
|
+
trigger: q,
|
|
15
|
+
fund: B,
|
|
14
16
|
"no-footer": "FundModal-module__no-footer___WKV78",
|
|
15
17
|
"title-buttons": "FundModal-module__title-buttons___Lctf7",
|
|
16
18
|
"close-button": "FundModal-module__close-button___jzdFM",
|
|
17
19
|
"close-icon": "FundModal-module__close-icon___WoA4a",
|
|
18
20
|
"fund-inner": "FundModal-module__fund-inner___UuOq3",
|
|
19
21
|
"tx-status": "FundModal-module__tx-status___fc-3f",
|
|
20
|
-
title:
|
|
21
|
-
content:
|
|
22
|
+
title: E,
|
|
23
|
+
content: K,
|
|
22
24
|
"error-view": "FundModal-module__error-view___hR1A0"
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
...
|
|
31
|
-
}) => {
|
|
32
|
-
const { showCoinbaseFooter:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
25
|
+
}, N = w(null), y = () => {
|
|
26
|
+
const n = z(N);
|
|
27
|
+
if (!n)
|
|
28
|
+
throw new Error("useFundModalContext must be used within a FundModal");
|
|
29
|
+
return n;
|
|
30
|
+
}, b = ({ children: n, className: l = "", label: e, ...s }) => {
|
|
31
|
+
const { cryptoCurrency: r } = y();
|
|
32
|
+
return /* @__PURE__ */ o(U, { asChild: !0, children: n || /* @__PURE__ */ o(v, { variant: "primary", className: x(t.trigger, l), ...s, children: e || `Deposit ${r.toUpperCase()}` }) });
|
|
33
|
+
}, f = (n) => {
|
|
34
|
+
const { showCoinbaseFooter: l } = S(), e = $(), { unmount: s, ...r } = y(), { openIn: m, submitLabel: u, title: a } = r;
|
|
35
|
+
return /* @__PURE__ */ o(H, { "aria-describedby": void 0, ...n, children: /* @__PURE__ */ o(
|
|
36
|
+
V,
|
|
37
|
+
{
|
|
38
|
+
className: x(t.fund, l ? "" : t["no-footer"]),
|
|
39
|
+
...r,
|
|
40
|
+
children: /* @__PURE__ */ i(M, { children: [
|
|
41
|
+
/* @__PURE__ */ o(C, { children: /* @__PURE__ */ o(L, { asChild: !0, children: /* @__PURE__ */ o(_, { as: "span", children: a }) }) }),
|
|
42
|
+
/* @__PURE__ */ o(
|
|
43
|
+
X,
|
|
44
|
+
{
|
|
45
|
+
"aria-labelledby": e,
|
|
46
|
+
openIn: m,
|
|
47
|
+
unmountOnTransactionSuccess: !0,
|
|
48
|
+
unmount: s,
|
|
49
|
+
submitLabel: u,
|
|
50
|
+
children: ({ view: d, Content: c }) => /* @__PURE__ */ i(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
className: `${t["fund-inner"]} ${d === "transaction-status" ? t["tx-status"] : ""} ${d === "error" ? t["error-view"] : ""}`,
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ i("div", { className: t["title-buttons"], children: [
|
|
56
|
+
d === "error" ? /* @__PURE__ */ o(C, { children: /* @__PURE__ */ o(_, { id: e, children: a }) }) : /* @__PURE__ */ o(_, { className: t.title, id: e, children: a }),
|
|
57
|
+
/* @__PURE__ */ o(R, { asChild: !0, children: /* @__PURE__ */ o(
|
|
58
|
+
v,
|
|
59
|
+
{
|
|
60
|
+
className: t["close-button"],
|
|
61
|
+
"aria-label": "Close",
|
|
62
|
+
size: "md",
|
|
63
|
+
variant: "transparentSecondary",
|
|
64
|
+
children: /* @__PURE__ */ o(W, { className: t["close-icon"] })
|
|
65
|
+
}
|
|
66
|
+
) })
|
|
67
|
+
] }),
|
|
68
|
+
/* @__PURE__ */ o("div", { className: t.content, children: c })
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
l && /* @__PURE__ */ o(k, {})
|
|
75
|
+
] })
|
|
76
|
+
}
|
|
77
|
+
) });
|
|
78
|
+
}, so = ({ children: n, open: l, setIsOpen: e, ...s }) => {
|
|
79
|
+
const r = l !== void 0, [m, u] = j(!1), a = r ? l : m, d = F(
|
|
80
|
+
(p) => r ? e?.(p) : u(p),
|
|
81
|
+
[r, e, u]
|
|
82
|
+
), c = F(() => {
|
|
83
|
+
d(!1);
|
|
84
|
+
}, [d]), T = A(
|
|
85
|
+
() => ({
|
|
86
|
+
unmount: c,
|
|
87
|
+
...s
|
|
88
|
+
}),
|
|
89
|
+
[c, s]
|
|
90
|
+
), I = n ? g(n, b) : !1, h = n ? g(n, f) : !1, O = !I && !h;
|
|
91
|
+
return /* @__PURE__ */ o(N.Provider, { value: T, children: /* @__PURE__ */ o(D, { open: a, onOpenChange: d, children: O ? /* @__PURE__ */ i(M, { children: [
|
|
92
|
+
/* @__PURE__ */ o(b, { children: n }),
|
|
93
|
+
/* @__PURE__ */ o(f, {})
|
|
94
|
+
] }) : /* @__PURE__ */ i(M, { children: [
|
|
95
|
+
n,
|
|
96
|
+
!h && /* @__PURE__ */ o(f, {})
|
|
97
|
+
] }) }) });
|
|
90
98
|
};
|
|
91
99
|
export {
|
|
92
|
-
|
|
100
|
+
so as FundModal,
|
|
101
|
+
f as FundModalContent,
|
|
102
|
+
b as FundModalTrigger
|
|
93
103
|
};
|