@coinbase/cdp-react 0.0.48 → 0.0.50

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.
Files changed (34) hide show
  1. package/README.md +15 -0
  2. package/dist/chunks/lite.1fxw3LjI.js +7 -0
  3. package/dist/components/AuthButton/index.d.ts +16 -3
  4. package/dist/components/AuthButton/index.js +51 -39
  5. package/dist/components/CDPReactProvider/index.d.ts +1 -1
  6. package/dist/components/CDPReactProvider/index.js +59 -52
  7. package/dist/components/Fund/index.d.ts +1 -1
  8. package/dist/components/Fund/index.js +9 -1
  9. package/dist/components/Fund/types.d.ts +2 -1
  10. package/dist/components/FundModal/index.d.ts +13 -3
  11. package/dist/components/FundModal/index.js +93 -83
  12. package/dist/components/OAuthStatusModal/index.js +48 -46
  13. package/dist/components/SendEvmTransactionButton/index.d.ts +3 -6
  14. package/dist/components/SendEvmTransactionButton/index.js +32 -34
  15. package/dist/components/SendSolanaTransactionButton/index.d.ts +3 -6
  16. package/dist/components/SendSolanaTransactionButton/index.js +28 -30
  17. package/dist/components/SignIn/SignInAuthMethodButtons.js +30 -25
  18. package/dist/components/SignIn/hooks/useSignInWithOAuth.js +12 -12
  19. package/dist/components/SignIn/index.d.ts +2 -3
  20. package/dist/components/SignIn/index.js +32 -32
  21. package/dist/components/SignInModal/index.d.ts +11 -0
  22. package/dist/components/SignInModal/index.js +73 -51
  23. package/dist/components/SignOutButton/index.d.ts +4 -5
  24. package/dist/components/SignOutButton/index.js +23 -10
  25. package/dist/components/ui/Button/index.js +20 -18
  26. package/dist/components/ui/ButtonBase/index.d.ts +1 -0
  27. package/dist/components/ui/ButtonBase/index.js +31 -28
  28. package/dist/components/ui/Modal/index.d.ts +4 -3
  29. package/dist/components/ui/Modal/index.js +26 -22
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.js +105 -92
  32. package/dist/utils/childrenHasComponent.d.ts +2 -0
  33. package/dist/utils/childrenHasComponent.js +13 -0
  34. package/package.json +7 -5
@@ -1,82 +1,83 @@
1
1
  import { jsx as s, jsxs as o, Fragment as l } from "react/jsx-runtime";
2
2
  import "@coinbase/cdp-core";
3
3
  import { useOAuthState as O } from "@coinbase/cdp-hooks";
4
- import { useState as b, useEffect as u, useRef as S, useCallback as v } from "react";
5
- import { useProviderName as I } from "../CDPReactProvider/index.js";
6
- import { OAUTH_PROVIDER_SESSION_STORAGE_KEY as g } from "../SignIn/hooks/useSignInWithOAuth.js";
4
+ import { useState as I, useEffect as u, useRef as g, useCallback as b } from "react";
5
+ import { useProviderName as v } from "../CDPReactProvider/index.js";
6
+ import { OAUTH_PROVIDER_SESSION_STORAGE_KEY as S } from "../SignIn/hooks/useSignInWithOAuth.js";
7
7
  import { CoinbaseFooter as C } from "../ui/CoinbaseFooter/index.js";
8
8
  import { LoadingSpinner as T } from "../ui/LoadingSpinner/index.js";
9
9
  import { Modal as $, ModalContent as w, ModalTitle as E, ModalDescription as P } from "../ui/Modal/index.js";
10
10
  import { SwitchFadeTransition as R } from "../ui/SwitchFadeTransition/index.js";
11
11
  import { VisuallyHidden as f } from "../ui/VisuallyHidden/index.js";
12
12
  import { useTimer as y } from "../../hooks/useTimer.js";
13
- import { IconCheck as k } from "../../icons/IconCheck.js";
14
- import { IconGoogleColorLogo as U } from "../../icons/IconGoogleColorLogo.js";
15
- import { IconXMark as q } from "../../icons/IconXMark.js";
13
+ import { IconAppleLogo as k } from "../../icons/IconAppleLogo.js";
14
+ import { IconCheck as U } from "../../icons/IconCheck.js";
15
+ import { IconGoogleColorLogo as q } from "../../icons/IconGoogleColorLogo.js";
16
+ import { IconXMark as x } from "../../icons/IconXMark.js";
16
17
  import { capitalize as d } from "../../utils/capitalize.js";
17
- import '../../assets/OAuthStatusModal.css';const x = "OAuthStatusModal-module__status___vU6x7", G = "OAuthStatusModal-module__graphic___2fKoa", H = "OAuthStatusModal-module__pad___oooMz", K = "OAuthStatusModal-module__spinner___Q3dYq", j = "OAuthStatusModal-module__icon___Lj5Gf", D = "OAuthStatusModal-module__subhead___Pg9GI", F = "OAuthStatusModal-module__description___0qOZY", L = "OAuthStatusModal-module__ring___mKwSb", Y = "OAuthStatusModal-module__invisible___IeRd0", t = {
18
+ import '../../assets/OAuthStatusModal.css';const G = "OAuthStatusModal-module__status___vU6x7", H = "OAuthStatusModal-module__graphic___2fKoa", K = "OAuthStatusModal-module__pad___oooMz", L = "OAuthStatusModal-module__spinner___Q3dYq", j = "OAuthStatusModal-module__icon___Lj5Gf", D = "OAuthStatusModal-module__subhead___Pg9GI", F = "OAuthStatusModal-module__description___0qOZY", Y = "OAuthStatusModal-module__ring___mKwSb", z = "OAuthStatusModal-module__invisible___IeRd0", t = {
18
19
  "oauth-status-modal": "OAuthStatusModal-module__oauth-status-modal___I69Ii",
19
20
  "transition-wrapper": "OAuthStatusModal-module__transition-wrapper___TmPRh",
20
- status: x,
21
- graphic: G,
22
- pad: H,
23
- spinner: K,
21
+ status: G,
22
+ graphic: H,
23
+ pad: K,
24
+ spinner: L,
24
25
  icon: j,
25
26
  "icon-success": "OAuthStatusModal-module__icon-success___gqMWr",
26
27
  "icon-error": "OAuthStatusModal-module__icon-error___psI7m",
27
28
  subhead: D,
28
29
  description: F,
29
- ring: L,
30
+ ring: Y,
30
31
  "ring-success": "OAuthStatusModal-module__ring-success___unyM9",
31
32
  "ring-error": "OAuthStatusModal-module__ring-error___OsgqU",
32
- invisible: Y
33
- }, z = ["pending", "success", "error"], pt = () => {
34
- const [n, e] = b(!1), { oauthState: a } = O(), r = I();
33
+ invisible: z
34
+ }, V = ["pending", "success", "error"], St = () => {
35
+ const [n, e] = I(!1), { oauthState: r } = O(), a = v();
35
36
  return u(() => {
36
- if (a?.status === "pending") {
37
- const c = sessionStorage.getItem(g);
38
- if (c === null || c !== r)
37
+ if (r?.status === "pending" || r?.status === "error" || r?.status === "success") {
38
+ const c = sessionStorage.getItem(S);
39
+ if (c === null || c !== a)
39
40
  return;
40
- sessionStorage.removeItem(g), e(!0);
41
+ sessionStorage.removeItem(S), e(!0);
41
42
  }
42
- }, [a, r]), /* @__PURE__ */ s($, { open: n, onOpenChange: e, children: /* @__PURE__ */ o(w, { children: [
43
+ }, [r?.status, a]), /* @__PURE__ */ s($, { open: n, onOpenChange: e, children: /* @__PURE__ */ o(w, { children: [
43
44
  /* @__PURE__ */ s(f, { children: /* @__PURE__ */ s(E, { children: "OAuth Status" }) }),
44
45
  /* @__PURE__ */ s(f, { children: /* @__PURE__ */ o(P, { children: [
45
46
  "Sign in with ",
46
- d(r),
47
+ d(a),
47
48
  " ",
48
- a?.status ? `${a?.status === "success" ? "successful" : a?.status === "error" ? "failed" : "pending"}` : ""
49
+ r?.status ? `${r?.status === "success" ? "successful" : r?.status === "error" ? "failed" : "pending"}` : ""
49
50
  ] }) }),
50
- /* @__PURE__ */ s(V, { handleClose: () => e(!1) })
51
+ /* @__PURE__ */ s(W, { handleClose: () => e(!1) })
51
52
  ] }) });
52
- }, V = ({ handleClose: n }) => {
53
- const { oauthState: e } = O(), a = e?.providerType || "google", { timeRemaining: r, start: c, reset: m } = y(), _ = S(null), h = S(null), A = 250, p = v((i) => {
53
+ }, W = ({ handleClose: n }) => {
54
+ const { oauthState: e } = O(), r = e?.providerType || "google", { timeRemaining: a, start: c, reset: m } = y(), _ = g(null), h = g(null), A = 250, p = b((i) => {
54
55
  h.current === i || i === void 0 || (h.current = i, _.current?.transition.toggle(i));
55
56
  }, []);
56
57
  return u(() => {
57
58
  p(e?.status), e?.status === "success" && c(3);
58
59
  }, [e?.status, p, c]), u(() => {
59
- r !== null && r <= 0 && (m(), n());
60
- }, [r, m, n]), /* @__PURE__ */ o("div", { className: t["oauth-status-modal"], children: [
60
+ a !== null && a <= 0 && (m(), n());
61
+ }, [a, m, n]), /* @__PURE__ */ o("div", { className: t["oauth-status-modal"], children: [
61
62
  /* @__PURE__ */ s(
62
63
  R,
63
64
  {
64
65
  animateHeight: !1,
65
66
  timeout: A,
66
- items: z,
67
- initialEntered: !0,
67
+ items: V,
68
+ initialEntered: !1,
68
69
  transitionRef: _,
69
70
  className: t["transition-wrapper"],
70
71
  children: ({ itemKey: i, ...M }) => {
71
- const N = X[i];
72
- return /* @__PURE__ */ s("div", { ...M, className: t.status, children: /* @__PURE__ */ s(N, { timeRemaining: r, provider: a }) });
72
+ const N = Z[i];
73
+ return /* @__PURE__ */ s("div", { ...M, className: t.status, children: /* @__PURE__ */ s(N, { timeRemaining: a, provider: r }) });
73
74
  }
74
75
  }
75
76
  ),
76
77
  /* @__PURE__ */ s(C, {})
77
78
  ] });
78
- }, W = ({ provider: n }) => {
79
- const e = Z[n];
79
+ }, J = ({ provider: n }) => {
80
+ const e = B[n];
80
81
  return /* @__PURE__ */ o(l, { children: [
81
82
  /* @__PURE__ */ o("div", { className: t.graphic, children: [
82
83
  /* @__PURE__ */ s(
@@ -96,10 +97,10 @@ import '../../assets/OAuthStatusModal.css';const x = "OAuthStatusModal-module__s
96
97
  ] }),
97
98
  /* @__PURE__ */ s("p", { className: t.description, children: "Just a moment..." })
98
99
  ] });
99
- }, J = ({ timeRemaining: n, provider: e }) => /* @__PURE__ */ o(l, { children: [
100
+ }, Q = ({ timeRemaining: n, provider: e }) => /* @__PURE__ */ o(l, { children: [
100
101
  /* @__PURE__ */ o("div", { className: t.graphic, children: [
101
102
  /* @__PURE__ */ s("span", { className: `${t.ring} ${t["ring-success"]}` }),
102
- /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-success"]}`, children: /* @__PURE__ */ s(k, {}) })
103
+ /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-success"]}`, children: /* @__PURE__ */ s(U, {}) })
103
104
  ] }),
104
105
  /* @__PURE__ */ o("p", { className: t.subhead, children: [
105
106
  "Signed in with ",
@@ -109,22 +110,23 @@ import '../../assets/OAuthStatusModal.css';const x = "OAuthStatusModal-module__s
109
110
  "This window will automatically close in ",
110
111
  n ?? "soon"
111
112
  ] })
112
- ] }), Q = () => /* @__PURE__ */ o(l, { children: [
113
+ ] }), X = () => /* @__PURE__ */ o(l, { children: [
113
114
  /* @__PURE__ */ o("div", { className: `${t.graphic} ${t.pad}`, children: [
114
115
  /* @__PURE__ */ s("span", { className: `${t.ring} ${t["ring-error"]}` }),
115
- /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-error"]}`, children: /* @__PURE__ */ s(q, {}) })
116
+ /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-error"]}`, children: /* @__PURE__ */ s(x, {}) })
116
117
  ] }),
117
118
  /* @__PURE__ */ s("p", { className: t.subhead, children: "Sign in failed" }),
118
119
  /* @__PURE__ */ s("p", { className: t.description, children: "Something went wrong. Please try again." })
119
- ] }), X = {
120
- pending: W,
121
- success: J,
122
- error: Q
123
- }, Z = {
124
- google: U
120
+ ] }), Z = {
121
+ pending: J,
122
+ success: Q,
123
+ error: X
124
+ }, B = {
125
+ google: q,
126
+ apple: k
125
127
  };
126
128
  export {
127
- pt as OAuthStatusModal,
128
- V as OAuthStatusModalContent,
129
- pt as default
129
+ St as OAuthStatusModal,
130
+ W as OAuthStatusModalContent,
131
+ St as default
130
132
  };
@@ -1,13 +1,10 @@
1
1
  import { APIError, SendEvmTransactionOptions } from '@coinbase/cdp-hooks';
2
- import { ButtonHTMLAttributes, ReactNode } from 'react';
3
- import { ButtonVariant } from '../../theme/theme';
4
- export interface SendEvmTransactionButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onError"> {
2
+ import { ButtonProps } from '../ui/Button';
3
+ export interface SendEvmTransactionButtonProps extends Omit<ButtonProps, "onError"> {
5
4
  account: SendEvmTransactionOptions["evmAccount"];
6
5
  network: SendEvmTransactionOptions["network"];
7
6
  onError?: (error: APIError | Error) => void;
8
7
  onSuccess?: (hash: string) => void;
9
- pendingLabel?: ReactNode;
10
8
  transaction: SendEvmTransactionOptions["transaction"];
11
- variant?: ButtonVariant;
12
9
  }
13
- export declare const SendEvmTransactionButton: ({ account, children, className, network, onClick, onError, onSuccess, pendingLabel, transaction, variant, ...props }: SendEvmTransactionButtonProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const SendEvmTransactionButton: ({ account, children, className, network, onClick, onError, onSuccess, pendingLabel, transaction, ...props }: SendEvmTransactionButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,64 +1,62 @@
1
- import { jsx as S } from "react/jsx-runtime";
2
- import { useSendEvmTransaction as b, APIError as y } from "@coinbase/cdp-hooks";
3
- import { useState as T, useCallback as _ } from "react";
1
+ import { jsx as E } from "react/jsx-runtime";
2
+ import { useSendEvmTransaction as S, APIError as b } from "@coinbase/cdp-hooks";
3
+ import { c as T } from "../../chunks/lite.1fxw3LjI.js";
4
+ import { useState as _, useCallback as y } from "react";
4
5
  import { Button as w } from "../ui/Button/index.js";
5
- import "../../theme/theme.js";
6
- import { getMessageFromUnknownError as B } from "../../utils/getMessageFromUnknownError.js";
7
- import '../../assets/SendEvmTransactionButton.css';const P = {
6
+ import { getMessageFromUnknownError as x } from "../../utils/getMessageFromUnknownError.js";
7
+ import '../../assets/SendEvmTransactionButton.css';const B = {
8
8
  "send-evm-transaction-button": "SendEvmTransactionButton-module__send-evm-transaction-button___74m57"
9
9
  }, q = ({
10
- account: e,
11
- children: f,
12
- className: l = "",
13
- network: s,
10
+ account: s,
11
+ children: l,
12
+ className: u = "",
13
+ network: e,
14
14
  onClick: o,
15
15
  onError: a,
16
16
  onSuccess: i,
17
- pendingLabel: u,
17
+ pendingLabel: p,
18
18
  transaction: r,
19
- variant: p = "primary",
20
- ...g
19
+ ...m
21
20
  }) => {
22
- const [v, m] = T(!1), { sendEvmTransaction: c } = b(), h = _(
23
- async (d) => {
24
- d.preventDefault(), o?.(d);
21
+ const [g, c] = _(!1), { sendEvmTransaction: d } = S(), h = y(
22
+ async (f) => {
23
+ f.preventDefault(), o?.(f);
25
24
  try {
26
- if (!e || !s || !r) {
25
+ if (!s || !e || !r) {
27
26
  const n = [];
28
- throw e || n.push("account"), s || n.push("network"), r || n.push("transaction"), new Error(`Missing required parameters: ${n.join(", ")}`);
27
+ throw s || n.push("account"), e || n.push("network"), r || n.push("transaction"), new Error(`Missing required parameters: ${n.join(", ")}`);
29
28
  }
30
- m(!0);
31
- const { transactionHash: t } = await c({
29
+ c(!0);
30
+ const { transactionHash: t } = await d({
32
31
  transaction: r,
33
- evmAccount: e,
34
- network: s
32
+ evmAccount: s,
33
+ network: e
35
34
  });
36
35
  i?.(t);
37
36
  } catch (t) {
38
37
  let n;
39
- if (t instanceof y || t instanceof Error)
38
+ if (t instanceof b || t instanceof Error)
40
39
  n = t;
41
40
  else {
42
- const E = B(t);
43
- n = new Error(E);
41
+ const v = x(t);
42
+ n = new Error(v);
44
43
  }
45
44
  a?.(n);
46
45
  } finally {
47
- m(!1);
46
+ c(!1);
48
47
  }
49
48
  },
50
- [e, s, o, a, i, c, r]
49
+ [s, e, o, a, i, d, r]
51
50
  );
52
- return /* @__PURE__ */ S(
51
+ return /* @__PURE__ */ E(
53
52
  w,
54
53
  {
55
- className: `${P["send-evm-transaction-button"]} ${l}`,
56
- isPending: v,
57
- pendingLabel: u || "Sending transaction...",
54
+ className: m.asChild ? "" : T(B["send-evm-transaction-button"], u),
55
+ isPending: g,
56
+ pendingLabel: p || "Sending transaction...",
58
57
  onClick: h,
59
- variant: p,
60
- ...g,
61
- children: f || "Send transaction"
58
+ ...m,
59
+ children: l || "Send transaction"
62
60
  }
63
61
  );
64
62
  };
@@ -1,13 +1,10 @@
1
1
  import { APIError, SendSolanaTransactionOptions } from '@coinbase/cdp-hooks';
2
- import { ButtonHTMLAttributes, ReactNode } from 'react';
3
- import { ButtonVariant } from '../../theme/theme';
4
- export interface SendSolanaTransactionButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onError"> {
2
+ import { ButtonProps } from '../ui/Button';
3
+ export interface SendSolanaTransactionButtonProps extends Omit<ButtonProps, "onError"> {
5
4
  account: SendSolanaTransactionOptions["solanaAccount"];
6
5
  network: SendSolanaTransactionOptions["network"];
7
6
  onError?: (error: APIError | Error) => void;
8
7
  onSuccess?: (signature: string) => void;
9
- pendingLabel?: ReactNode;
10
8
  transaction: SendSolanaTransactionOptions["transaction"];
11
- variant?: ButtonVariant;
12
9
  }
13
- export declare const SendSolanaTransactionButton: ({ account, children, className, network, onClick, onError, onSuccess, pendingLabel, transaction, variant, ...props }: SendSolanaTransactionButtonProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const SendSolanaTransactionButton: ({ account, children, className, network, onClick, onError, onSuccess, pendingLabel, transaction, ...props }: SendSolanaTransactionButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,34 +1,33 @@
1
- import { jsx as y } from "react/jsx-runtime";
1
+ import { jsx as b } from "react/jsx-runtime";
2
2
  import { useSendSolanaTransaction as T, APIError as _ } from "@coinbase/cdp-hooks";
3
- import { useState as w, useCallback as B } from "react";
4
- import { Button as E } from "../ui/Button/index.js";
5
- import "../../theme/theme.js";
6
- import { getMessageFromUnknownError as x } from "../../utils/getMessageFromUnknownError.js";
3
+ import { c as w } from "../../chunks/lite.1fxw3LjI.js";
4
+ import { useState as x, useCallback as y } from "react";
5
+ import { Button as B } from "../ui/Button/index.js";
6
+ import { getMessageFromUnknownError as E } from "../../utils/getMessageFromUnknownError.js";
7
7
  import '../../assets/SendSolanaTransactionButton.css';const P = {
8
8
  "send-solana-transaction-button": "SendSolanaTransactionButton-module__send-solana-transaction-button___OxwvB"
9
9
  }, q = ({
10
10
  account: t,
11
- children: d,
12
- className: f = "",
11
+ children: f,
12
+ className: u = "",
13
13
  network: s,
14
- onClick: r,
15
- onError: e,
14
+ onClick: e,
15
+ onError: r,
16
16
  onSuccess: i,
17
- pendingLabel: u,
17
+ pendingLabel: p,
18
18
  transaction: o,
19
- variant: p = "primary",
20
- ...S
19
+ ...l
21
20
  }) => {
22
- const [g, l] = w(!1), { sendSolanaTransaction: c } = T(), h = B(
21
+ const [S, c] = x(!1), { sendSolanaTransaction: d } = T(), g = y(
23
22
  async (m) => {
24
- m.preventDefault(), r?.(m);
23
+ m.preventDefault(), e?.(m);
25
24
  try {
26
25
  if (!t || !s || !o) {
27
26
  const n = [];
28
27
  throw t || n.push("account"), s || n.push("network"), o || n.push("transaction"), new Error(`Missing required parameters: ${n.join(", ")}`);
29
28
  }
30
- l(!0);
31
- const { transactionSignature: a } = await c({
29
+ c(!0);
30
+ const { transactionSignature: a } = await d({
32
31
  transaction: o,
33
32
  solanaAccount: t,
34
33
  network: s
@@ -39,26 +38,25 @@ import '../../assets/SendSolanaTransactionButton.css';const P = {
39
38
  if (a instanceof _ || a instanceof Error)
40
39
  n = a;
41
40
  else {
42
- const b = x(a);
43
- n = new Error(b);
41
+ const h = E(a);
42
+ n = new Error(h);
44
43
  }
45
- e?.(n);
44
+ r?.(n);
46
45
  } finally {
47
- l(!1);
46
+ c(!1);
48
47
  }
49
48
  },
50
- [t, s, r, e, i, c, o]
49
+ [t, s, e, r, i, d, o]
51
50
  );
52
- return /* @__PURE__ */ y(
53
- E,
51
+ return /* @__PURE__ */ b(
52
+ B,
54
53
  {
55
- className: `${P["send-solana-transaction-button"]} ${f}`,
56
- isPending: g,
57
- pendingLabel: u || "Sending transaction...",
58
- onClick: h,
59
- variant: p,
60
- ...S,
61
- children: d || "Send transaction"
54
+ className: l.asChild ? "" : w(P["send-solana-transaction-button"], u),
55
+ isPending: S,
56
+ pendingLabel: p || "Sending transaction...",
57
+ onClick: g,
58
+ ...l,
59
+ children: f || "Send transaction"
62
60
  }
63
61
  );
64
62
  };
@@ -2,63 +2,68 @@ import { jsx as n, jsxs as r } from "react/jsx-runtime";
2
2
  import { useCallback as I, useMemo as v } from "react";
3
3
  import { useAppConfig as y } from "../CDPReactProvider/index.js";
4
4
  import { useSignInWithOAuth as S } from "./hooks/useSignInWithOAuth.js";
5
- import { useSignInContext as M } from "./SignInProvider.js";
6
- import { Button as C } from "../ui/Button/index.js";
5
+ import { useSignInContext as C } from "./SignInProvider.js";
6
+ import { Button as M } from "../ui/Button/index.js";
7
7
  import { ServerError as k } from "../ui/ServerError/index.js";
8
- import { IconEnvelope as B } from "../../icons/IconEnvelope.js";
9
- import { IconGoogleLogo as E } from "../../icons/IconGoogleLogo.js";
10
- import { IconPhone as P } from "../../icons/IconPhone.js";
8
+ import { IconAppleLogo as B } from "../../icons/IconAppleLogo.js";
9
+ import { IconEnvelope as E } from "../../icons/IconEnvelope.js";
10
+ import { IconGoogleLogo as P } from "../../icons/IconGoogleLogo.js";
11
+ import { IconPhone as O } from "../../icons/IconPhone.js";
11
12
  import { toOAuthProviderType as _ } from "../../utils/toOAuthProviderType.js";
12
- import '../../assets/SignInAuthMethodButtons.css';const O = "SignInAuthMethodButtons-module__divider___zphEh", o = {
13
+ import '../../assets/SignInAuthMethodButtons.css';const N = "SignInAuthMethodButtons-module__divider___zphEh", o = {
13
14
  "auth-method-buttons": "SignInAuthMethodButtons-module__auth-method-buttons___jYEH7",
14
15
  "auth-btn": "SignInAuthMethodButtons-module__auth-btn___o1a09",
15
16
  "auth-btn-icon": "SignInAuthMethodButtons-module__auth-btn-icon___VjvFY",
16
17
  "auth-btn-label": "SignInAuthMethodButtons-module__auth-btn-label___mEWd3",
17
- divider: O
18
+ divider: N
18
19
  }, b = {
19
20
  email: {
20
21
  label: "Continue with email",
21
- icon: /* @__PURE__ */ n(B, {})
22
+ icon: /* @__PURE__ */ n(E, {})
22
23
  },
23
24
  sms: {
24
25
  label: "Continue with phone",
25
- icon: /* @__PURE__ */ n(P, {})
26
+ icon: /* @__PURE__ */ n(O, {})
26
27
  },
27
28
  "oauth:google": {
28
29
  label: "Continue with Google",
29
- icon: /* @__PURE__ */ n(E, {})
30
+ icon: /* @__PURE__ */ n(P, {})
31
+ },
32
+ "oauth:apple": {
33
+ label: "Continue with Apple",
34
+ icon: /* @__PURE__ */ n(B, {})
30
35
  }
31
- }, z = ({ activeMethod: u }) => {
36
+ }, U = ({ activeMethod: u }) => {
32
37
  const { authMethods: a } = y(), {
33
- signInWithOAuth: s,
34
- isPending: l,
38
+ signInWithOAuth: l,
39
+ isPending: s,
35
40
  error: h,
36
41
  oauthProvider: c
37
- } = S(), d = I(
42
+ } = S(), p = I(
38
43
  async (t) => {
39
- const e = _(t);
40
- e && s(e);
44
+ const i = _(t);
45
+ i && l(i);
41
46
  },
42
- [s]
43
- ), { dispatch: m } = M(), i = v(() => (a || ["email"]).map((t) => {
47
+ [l]
48
+ ), { dispatch: d } = C(), e = v(() => (a || ["email"]).map((t) => {
44
49
  if (!b[t])
45
50
  return null;
46
- const { label: e, icon: g } = b[t], p = t.startsWith("oauth:"), f = p ? () => d(t) : () => m({ type: "SET_AUTH_METHOD", payload: { authMethod: t } }), A = p && c.current === _(t) && l;
51
+ const { label: i, icon: g } = b[t], m = t.startsWith("oauth:"), f = m ? () => p(t) : () => d({ type: "SET_AUTH_METHOD", payload: { authMethod: t } }), A = m && c.current === _(t) && s;
47
52
  return {
48
53
  key: t,
49
- label: e,
54
+ label: i,
50
55
  icon: g,
51
56
  onClick: f,
52
57
  isPending: A
53
58
  };
54
- }).filter((t) => t !== null), [a, m, d, l, c]);
55
- return !i.length || i.length === 1 && i[0].key === u ? null : /* @__PURE__ */ r("div", { className: o["auth-method-buttons"], children: [
59
+ }).filter((t) => t !== null), [a, d, p, s, c]);
60
+ return !e.length || e.length === 1 && e[0].key === u ? null : /* @__PURE__ */ r("div", { className: o["auth-method-buttons"], children: [
56
61
  /* @__PURE__ */ r("div", { className: o.divider, children: [
57
62
  /* @__PURE__ */ n("hr", {}),
58
63
  /* @__PURE__ */ n("span", { children: "or" })
59
64
  ] }),
60
- i.map((t) => t.key === u ? null : /* @__PURE__ */ r(
61
- C,
65
+ e.map((t) => t.key === u ? null : /* @__PURE__ */ r(
66
+ M,
62
67
  {
63
68
  "aria-label": t.ariaLabel,
64
69
  className: o["auth-btn"],
@@ -77,5 +82,5 @@ import '../../assets/SignInAuthMethodButtons.css';const O = "SignInAuthMethodBut
77
82
  ] });
78
83
  };
79
84
  export {
80
- z as SignInAuthMethodButtons
85
+ U as SignInAuthMethodButtons
81
86
  };
@@ -1,26 +1,26 @@
1
- import { useSignInWithOAuth as h } from "@coinbase/cdp-hooks";
1
+ import { useSignInWithOAuth as l } from "@coinbase/cdp-hooks";
2
2
  import { useState as c, useRef as m, useCallback as I } from "react";
3
3
  import { useProviderName as f } from "../../CDPReactProvider/index.js";
4
4
  import { isApiError as A } from "../../../utils/isApiError.js";
5
5
  const O = "cdp-react-sign-in-with-oauth-provider-name", W = () => {
6
- const { signInWithOAuth: e } = h(), [r, s] = c(!1), [g, o] = c(null), i = f(), a = m(null), u = "An error occurred while signing in. Please try again.";
6
+ const { signInWithOAuth: t } = l(), [n, e] = c(!1), [g, s] = c(null), o = f(), i = m(null), a = "An error occurred while signing in. Please try again.";
7
7
  return {
8
8
  signInWithOAuth: I(
9
- async (t) => {
10
- if (!r) {
11
- a.current = t, s(!0), o(null);
9
+ async (u) => {
10
+ if (!n) {
11
+ i.current = u, e(!0), s(null);
12
12
  try {
13
- await e(t === "apple" ? "google" : t), sessionStorage.setItem(O, i);
14
- } catch (n) {
15
- const l = A(n) ? n : n instanceof Error && n.message || u;
16
- o(l), s(!1), console.error(n);
13
+ await t(u), sessionStorage.setItem(O, o);
14
+ } catch (r) {
15
+ const h = A(r) ? r : r instanceof Error && r.message || a;
16
+ s(h), e(!1), console.error(r);
17
17
  }
18
18
  }
19
19
  },
20
- [r, e, i]
20
+ [n, t, o]
21
21
  ),
22
- oauthProvider: a,
23
- isPending: r,
22
+ oauthProvider: i,
23
+ isPending: n,
24
24
  error: g
25
25
  };
26
26
  };
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
2
  import { SignInAuthMethodButtons, SignInAuthMethodButtonsProps } from './SignInAuthMethodButtons';
3
3
  import { SignInBackButton, SignInBackButtonProps } from './SignInBackButton';
4
4
  import { SignInDescription, SignInDescriptionProps } from './SignInDescription';
@@ -8,9 +8,8 @@ import { SignInImage, SignInImageProps } from './SignInImage';
8
8
  import { useSignInContext } from './SignInProvider';
9
9
  import { SignInTitle, SignInTitleProps } from './SignInTitle';
10
10
  import { SignInState, SignInAction } from './types';
11
- export interface SignInProps {
11
+ export interface SignInProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
12
12
  children?: ReactNode | ((state: SignInState) => ReactNode);
13
- className?: string;
14
13
  onSuccess?: () => void;
15
14
  }
16
15
  export declare const SignIn: (props: SignInProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,48 +1,48 @@
1
1
  import { jsx as n, jsxs as t, Fragment as s } from "react/jsx-runtime";
2
2
  import "react";
3
- import { useAppConfig as l } from "../CDPReactProvider/index.js";
4
- import { SignInAuthMethodButtons as d } from "./SignInAuthMethodButtons.js";
5
- import { SignInBackButton as f } from "./SignInBackButton.js";
6
- import { SignInDescription as u } from "./SignInDescription.js";
7
- import { SignInFooter as I } from "./SignInFooter.js";
8
- import { SignInForm as S } from "./SignInForm.js";
9
- import { SignInImage as b } from "./SignInImage.js";
10
- import { SignInProvider as k, useSignInContext as w } from "./SignInProvider.js";
11
- import { SignInTitle as h } from "./SignInTitle.js";
3
+ import { useAppConfig as d } from "../CDPReactProvider/index.js";
4
+ import { SignInAuthMethodButtons as f } from "./SignInAuthMethodButtons.js";
5
+ import { SignInBackButton as u } from "./SignInBackButton.js";
6
+ import { SignInDescription as I } from "./SignInDescription.js";
7
+ import { SignInFooter as S } from "./SignInFooter.js";
8
+ import { SignInForm as b } from "./SignInForm.js";
9
+ import { SignInImage as k } from "./SignInImage.js";
10
+ import { SignInProvider as w, useSignInContext as h } from "./SignInProvider.js";
11
+ import { SignInTitle as v } from "./SignInTitle.js";
12
12
  import "@coinbase/cdp-hooks";
13
- import '../../assets/SignIn.css';const v = "SignIn-module__footer___3Gkbc", o = {
13
+ import '../../assets/SignIn.css';const F = "SignIn-module__footer___3Gkbc", o = {
14
14
  "sign-in": "SignIn-module__sign-in___cYpee",
15
15
  "title-desc-wrapper": "SignIn-module__title-desc-wrapper___VpPcA",
16
16
  "back-button": "SignIn-module__back-button___bmE-y",
17
17
  "back-button-wrapper": "SignIn-module__back-button-wrapper___Q9FA1",
18
- footer: v
19
- }, F = ({ className: r = "", children: i, onSuccess: p }) => {
20
- const { state: a } = w(), { showCoinbaseFooter: _ } = l(), c = typeof i == "function" ? i(a) : i;
21
- return /* @__PURE__ */ t("div", { className: `${o["sign-in"]} ${r}`, children: [
18
+ footer: F
19
+ }, N = ({ className: r = "", children: i, onSuccess: p, ...a }) => {
20
+ const { state: _ } = h(), { showCoinbaseFooter: g } = d(), c = typeof i == "function" ? i(_) : i;
21
+ return /* @__PURE__ */ t("div", { className: `${o["sign-in"]} ${r}`, ...a, children: [
22
22
  c,
23
23
  !c && /* @__PURE__ */ t(s, { children: [
24
- /* @__PURE__ */ n("div", { className: o["back-button-wrapper"], children: /* @__PURE__ */ n(f, { className: o["back-button"] }) }),
25
- /* @__PURE__ */ n(b, {}),
26
- /* @__PURE__ */ n(S, { onSuccess: p, children: ({ authMethod: e, step: m, Form: g }) => /* @__PURE__ */ t(s, { children: [
24
+ /* @__PURE__ */ n("div", { className: o["back-button-wrapper"], children: /* @__PURE__ */ n(u, { className: o["back-button"] }) }),
25
+ /* @__PURE__ */ n(k, {}),
26
+ /* @__PURE__ */ n(b, { onSuccess: p, children: ({ authMethod: e, step: m, Form: l }) => /* @__PURE__ */ t(s, { children: [
27
27
  /* @__PURE__ */ t("div", { className: o["title-desc-wrapper"], children: [
28
- /* @__PURE__ */ n(h, { step: m, authMethod: e }),
29
- /* @__PURE__ */ n(u, { step: m, authMethod: e })
28
+ /* @__PURE__ */ n(v, { step: m, authMethod: e }),
29
+ /* @__PURE__ */ n(I, { step: m, authMethod: e })
30
30
  ] }),
31
- g,
32
- m === "credentials" && /* @__PURE__ */ n(d, { activeMethod: e })
31
+ l,
32
+ m === "credentials" && /* @__PURE__ */ n(f, { activeMethod: e })
33
33
  ] }) }),
34
- _ && /* @__PURE__ */ n(I, { className: o.footer })
34
+ g && /* @__PURE__ */ n(S, { className: o.footer })
35
35
  ] })
36
36
  ] });
37
- }, Q = (r) => /* @__PURE__ */ n(k, { children: /* @__PURE__ */ n(F, { ...r }) });
37
+ }, T = (r) => /* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(N, { ...r }) });
38
38
  export {
39
- Q as SignIn,
40
- d as SignInAuthMethodButtons,
41
- f as SignInBackButton,
42
- u as SignInDescription,
43
- I as SignInFooter,
44
- S as SignInForm,
45
- b as SignInImage,
46
- h as SignInTitle,
47
- w as useSignInContext
39
+ T as SignIn,
40
+ f as SignInAuthMethodButtons,
41
+ u as SignInBackButton,
42
+ I as SignInDescription,
43
+ S as SignInFooter,
44
+ b as SignInForm,
45
+ k as SignInImage,
46
+ v as SignInTitle,
47
+ h as useSignInContext
48
48
  };