@coinbase/cdp-react 0.0.18 → 0.0.19

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 (133) hide show
  1. package/dist/assets/Button.css +1 -1
  2. package/dist/assets/EmailForm.css +1 -0
  3. package/dist/assets/Error.css +1 -1
  4. package/dist/assets/Field.css +1 -1
  5. package/dist/assets/FlowEmailOTP.css +1 -0
  6. package/dist/assets/FlowPhoneNumberOTP.css +1 -0
  7. package/dist/assets/Input.css +1 -1
  8. package/dist/assets/Label.css +1 -0
  9. package/dist/assets/OTP.css +1 -1
  10. package/dist/assets/OTPForm.css +1 -0
  11. package/dist/assets/PhoneNumberForm.css +1 -0
  12. package/dist/assets/PhoneNumberInput.css +1 -0
  13. package/dist/assets/SignIn.css +1 -1
  14. package/dist/assets/SignInAuthMethodButtons.css +1 -0
  15. package/dist/assets/SignInBackButton.css +1 -0
  16. package/dist/assets/SignInCredentials.css +1 -0
  17. package/dist/assets/SignInDescription.css +1 -1
  18. package/dist/assets/SignInFooter.css +1 -0
  19. package/dist/assets/SignInForm.css +1 -1
  20. package/dist/assets/SignInImage.css +1 -1
  21. package/dist/assets/SignInModal.css +1 -1
  22. package/dist/assets/SignInTitle.css +1 -1
  23. package/dist/assets/SuccessMessage.css +1 -0
  24. package/dist/assets/SwitchFadeTransition.css +1 -0
  25. package/dist/assets/SwitchSlideTransition.css +1 -0
  26. package/dist/assets/SwitchTransition.css +1 -0
  27. package/dist/assets/ThemeProvider.css +1 -1
  28. package/dist/chunks/index.BzllgVaP.js +12 -0
  29. package/dist/components/AuthButton/index.js +1 -1
  30. package/dist/components/Button/index.d.ts +2 -1
  31. package/dist/components/Button/index.js +47 -22
  32. package/dist/components/CDPReactProvider/index.d.ts +3 -0
  33. package/dist/components/CDPReactProvider/index.js +20 -13
  34. package/dist/components/EmailForm/index.d.ts +11 -0
  35. package/dist/components/EmailForm/index.js +56 -0
  36. package/dist/components/Error/index.d.ts +2 -2
  37. package/dist/components/Error/index.js +11 -11
  38. package/dist/components/Field/index.d.ts +2 -1
  39. package/dist/components/Field/index.js +20 -18
  40. package/dist/components/FlowEmailOTP/index.d.ts +18 -0
  41. package/dist/components/FlowEmailOTP/index.js +70 -0
  42. package/dist/components/FlowPhoneNumberOTP/index.d.ts +18 -0
  43. package/dist/components/FlowPhoneNumberOTP/index.js +75 -0
  44. package/dist/components/Label/index.d.ts +7 -0
  45. package/dist/components/Label/index.js +13 -0
  46. package/dist/components/OTP/index.d.ts +3 -0
  47. package/dist/components/OTP/index.js +48 -33
  48. package/dist/components/OTPForm/index.d.ts +16 -0
  49. package/dist/components/OTPForm/index.js +76 -0
  50. package/dist/components/PhoneNumberForm/index.d.ts +14 -0
  51. package/dist/components/PhoneNumberForm/index.js +68 -0
  52. package/dist/components/PhoneNumberInput/PhoneNumberMetadata.d.ts +2 -0
  53. package/dist/components/PhoneNumberInput/PhoneNumberMetadata.js +5 -0
  54. package/dist/components/PhoneNumberInput/index.d.ts +10 -0
  55. package/dist/components/PhoneNumberInput/index.js +76 -0
  56. package/dist/components/PhoneNumberInput/maskOverride.d.ts +8 -0
  57. package/dist/components/PhoneNumberInput/maskOverride.js +61 -0
  58. package/dist/components/PhoneNumberInput/usePhoneNumberFormatter.d.ts +7 -0
  59. package/dist/components/PhoneNumberInput/usePhoneNumberFormatter.js +52 -0
  60. package/dist/components/ServerError/index.js +4 -4
  61. package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +13 -0
  62. package/dist/components/SignIn/SignInAuthMethodButtons.js +57 -0
  63. package/dist/components/SignIn/SignInBackButton.d.ts +9 -0
  64. package/dist/components/SignIn/SignInBackButton.js +38 -0
  65. package/dist/components/SignIn/SignInCredentials.d.ts +2 -0
  66. package/dist/components/SignIn/SignInCredentials.js +8 -0
  67. package/dist/components/SignIn/SignInDescription.d.ts +4 -3
  68. package/dist/components/SignIn/SignInDescription.js +16 -23
  69. package/dist/components/SignIn/SignInFooter.d.ts +2 -0
  70. package/dist/components/SignIn/SignInFooter.js +18 -0
  71. package/dist/components/SignIn/SignInForm.d.ts +12 -4
  72. package/dist/components/SignIn/SignInForm.js +25 -196
  73. package/dist/components/SignIn/SignInImage.d.ts +2 -2
  74. package/dist/components/SignIn/SignInImage.js +11 -14
  75. package/dist/components/SignIn/SignInProvider.d.ts +1 -1
  76. package/dist/components/SignIn/SignInProvider.js +24 -16
  77. package/dist/components/SignIn/SignInTitle.d.ts +4 -3
  78. package/dist/components/SignIn/SignInTitle.js +18 -13
  79. package/dist/components/SignIn/flows/SignInWithEmail.d.ts +5 -0
  80. package/dist/components/SignIn/flows/SignInWithEmail.js +71 -0
  81. package/dist/components/SignIn/flows/SignInWithSms.d.ts +5 -0
  82. package/dist/components/SignIn/flows/SignInWithSms.js +2994 -0
  83. package/dist/components/SignIn/hooks/useEmailForm.d.ts +13 -0
  84. package/dist/components/SignIn/hooks/useEmailForm.js +42 -0
  85. package/dist/components/SignIn/hooks/useOTPForm.d.ts +16 -0
  86. package/dist/components/SignIn/hooks/useOTPForm.js +59 -0
  87. package/dist/components/SignIn/hooks/usePhoneNumberForm.d.ts +13 -0
  88. package/dist/components/SignIn/hooks/usePhoneNumberForm.js +42 -0
  89. package/dist/components/SignIn/index.d.ts +5 -2
  90. package/dist/components/SignIn/index.js +42 -24
  91. package/dist/components/SignIn/types.d.ts +106 -0
  92. package/dist/components/SignIn/types.js +3 -0
  93. package/dist/components/SignIn/useSignInReducer.d.ts +1 -57
  94. package/dist/components/SignIn/useSignInReducer.js +62 -20
  95. package/dist/components/SignInModal/index.d.ts +2 -2
  96. package/dist/components/SignInModal/index.js +62 -43
  97. package/dist/components/SuccessMessage/index.d.ts +7 -0
  98. package/dist/components/SuccessMessage/index.js +16 -0
  99. package/dist/components/SwitchFadeTransition/index.d.ts +5 -0
  100. package/dist/components/SwitchFadeTransition/index.js +24 -0
  101. package/dist/components/SwitchSlideTransition/index.d.ts +7 -0
  102. package/dist/components/SwitchSlideTransition/index.js +27 -0
  103. package/dist/components/SwitchTransition/index.d.ts +25 -0
  104. package/dist/components/SwitchTransition/index.js +155 -0
  105. package/dist/data/countries.d.ts +12 -0
  106. package/dist/data/countries.js +25 -0
  107. package/dist/data/countryNames.d.ts +1 -0
  108. package/dist/data/countryNames.js +6 -0
  109. package/dist/hooks/usePhoneNumberValidators.d.ts +14 -0
  110. package/dist/hooks/usePhoneNumberValidators.js +36 -0
  111. package/dist/hooks/useTimer.d.ts +5 -0
  112. package/dist/hooks/useTimer.js +24 -0
  113. package/dist/icons/IconArrowLeft.d.ts +2 -0
  114. package/dist/icons/IconArrowLeft.js +14 -0
  115. package/dist/icons/IconCheckCircle.js +2 -3
  116. package/dist/icons/IconCoinbaseWordmark.js +5 -5
  117. package/dist/icons/IconEnvelope.d.ts +2 -0
  118. package/dist/icons/IconEnvelope.js +7 -0
  119. package/dist/icons/IconExclamationCircle.js +3 -4
  120. package/dist/icons/IconPhone.d.ts +2 -0
  121. package/dist/icons/IconPhone.js +7 -0
  122. package/dist/icons/IconXMark.js +6 -5
  123. package/dist/icons/index.d.ts +3 -0
  124. package/dist/icons/index.js +14 -8
  125. package/dist/index.js +66 -53
  126. package/dist/theme/theme.d.ts +11 -2
  127. package/dist/theme/tokens.d.ts +30 -6
  128. package/dist/theme/tokens.js +7 -3
  129. package/dist/utils/parseValuesFromPhoneNumber.d.ts +6 -0
  130. package/dist/utils/parseValuesFromPhoneNumber.js +16 -0
  131. package/dist/utils/validatePhoneNumber.d.ts +1 -0
  132. package/dist/utils/validatePhoneNumber.js +1 -0
  133. package/package.json +11 -7
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ import { AuthMethod } from '../CDPReactProvider/CDPReactProvider';
3
+ export interface SignInAuthMethodButtonProps {
4
+ key: AuthMethod;
5
+ label: string;
6
+ ariaLabel?: string;
7
+ icon: ReactNode;
8
+ onClick: () => void;
9
+ }
10
+ export interface SignInAuthMethodButtonsProps {
11
+ activeMethod?: AuthMethod;
12
+ }
13
+ export declare const SignInAuthMethodButtons: ({ activeMethod }: SignInAuthMethodButtonsProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,57 @@
1
+ import { jsx as n, jsxs as i } from "react/jsx-runtime";
2
+ import { useMemo as c } from "react";
3
+ import { Button as d } from "../Button/index.js";
4
+ import { useAppConfig as m } from "../CDPReactProvider/index.js";
5
+ import { useSignInContext as p } from "./SignInProvider.js";
6
+ import { IconEnvelope as _ } from "../../icons/IconEnvelope.js";
7
+ import { IconPhone as b } from "../../icons/IconPhone.js";
8
+ import '../../assets/SignInAuthMethodButtons.css';const f = "SignInAuthMethodButtons-module__divider___zphEh", e = {
9
+ "auth-method-buttons": "SignInAuthMethodButtons-module__auth-method-buttons___jYEH7",
10
+ "auth-btn-icon": "SignInAuthMethodButtons-module__auth-btn-icon___VjvFY",
11
+ "auth-btn-label": "SignInAuthMethodButtons-module__auth-btn-label___mEWd3",
12
+ divider: f
13
+ }, r = {
14
+ email: {
15
+ label: "Continue with email",
16
+ icon: /* @__PURE__ */ n(_, {})
17
+ },
18
+ sms: {
19
+ label: "Continue with phone",
20
+ icon: /* @__PURE__ */ n(b, {})
21
+ }
22
+ }, B = ({ activeMethod: l }) => {
23
+ const { authMethods: a } = m(), { dispatch: u } = p(), o = c(() => (a || ["email"]).map((t) => {
24
+ if (!r[t])
25
+ return null;
26
+ const { label: s, icon: h } = r[t];
27
+ return {
28
+ key: t,
29
+ label: s,
30
+ icon: h,
31
+ onClick: () => u({ type: "SET_AUTH_METHOD", payload: { authMethod: t } })
32
+ };
33
+ }).filter((t) => t !== null), [a, u]);
34
+ return !o.length || o.length === 1 && o[0].key === l ? null : /* @__PURE__ */ i("div", { className: e["auth-method-buttons"], children: [
35
+ /* @__PURE__ */ i("div", { className: e.divider, children: [
36
+ /* @__PURE__ */ n("hr", {}),
37
+ /* @__PURE__ */ n("span", { children: "or" })
38
+ ] }),
39
+ o.map((t) => t.key === l ? null : /* @__PURE__ */ i(
40
+ d,
41
+ {
42
+ "aria-label": t.ariaLabel,
43
+ type: "button",
44
+ variant: "secondary",
45
+ onClick: t.onClick,
46
+ children: [
47
+ /* @__PURE__ */ n("span", { className: e["auth-btn-icon"], children: t.icon }),
48
+ /* @__PURE__ */ n("span", { className: e["auth-btn-label"], children: t.label })
49
+ ]
50
+ },
51
+ t.key
52
+ ))
53
+ ] });
54
+ };
55
+ export {
56
+ B as SignInAuthMethodButtons
57
+ };
@@ -0,0 +1,9 @@
1
+ import { HTMLAttributes } from 'react';
2
+ import { ButtonSize, ButtonVariant } from '../../theme/theme';
3
+ import { SignInState } from './types';
4
+ export interface SignInBackButtonProps extends HTMLAttributes<HTMLButtonElement> {
5
+ step?: SignInState["step"];
6
+ size?: ButtonSize;
7
+ variant?: ButtonVariant;
8
+ }
9
+ export declare const SignInBackButton: ({ step: stepFromProps, children, onClick, size, variant, ["aria-label"]: ariaLabel, ...props }: SignInBackButtonProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,38 @@
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { useMemo as f } from "react";
3
+ import { Button as S } from "../Button/index.js";
4
+ import { IconArrowLeft as d } from "../../icons/IconArrowLeft.js";
5
+ import "../../theme/theme.js";
6
+ import { useSignInContext as B } from "./SignInProvider.js";
7
+ import "@coinbase/cdp-hooks";
8
+ import "../CDPReactProvider/index.js";
9
+ import '../../assets/SignInBackButton.css';const _ = "SignInBackButton-module__icon___stNFS", k = {
10
+ icon: _
11
+ }, T = ({
12
+ step: t,
13
+ children: i,
14
+ onClick: r,
15
+ size: e = "md",
16
+ variant: c = "transparentSecondary",
17
+ ["aria-label"]: s = "Back",
18
+ ...a
19
+ }) => {
20
+ const { state: o, dispatch: m } = B(), p = f(() => t || o.step, [t, o.step]), l = (u) => {
21
+ r?.(u), m({ type: "RESET_STATE" });
22
+ };
23
+ return p !== "verification" ? null : /* @__PURE__ */ n(
24
+ S,
25
+ {
26
+ type: "button",
27
+ "aria-label": s,
28
+ onClick: l,
29
+ size: e,
30
+ variant: c,
31
+ ...a,
32
+ children: i || /* @__PURE__ */ n(d, { className: k.icon })
33
+ }
34
+ );
35
+ };
36
+ export {
37
+ T as SignInBackButton
38
+ };
@@ -0,0 +1,2 @@
1
+ import { HTMLAttributes } from 'react';
2
+ export declare const SignInCredentials: ({ children, ...props }: HTMLAttributes<HTMLSpanElement>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import "react";
3
+ import '../../assets/SignInCredentials.css';const t = "SignInCredentials-module__credentials___LE04y", r = {
4
+ credentials: t
5
+ }, l = ({ children: e, ...n }) => /* @__PURE__ */ s("span", { className: r.credentials, ...n, children: e });
6
+ export {
7
+ l as SignInCredentials
8
+ };
@@ -1,5 +1,6 @@
1
1
  import { ElementType, HTMLAttributes } from 'react';
2
- export type SignInDescriptionProps = {
2
+ import { SignInTitleAndDescriptionProps } from './types';
3
+ export interface SignInDescriptionProps extends SignInTitleAndDescriptionProps, HTMLAttributes<HTMLElement> {
3
4
  as?: ElementType;
4
- } & HTMLAttributes<HTMLElement>;
5
- export declare const SignInDescription: ({ as: Component, children, className, ...props }: SignInDescriptionProps) => import("react/jsx-runtime").JSX.Element;
5
+ }
6
+ export declare const SignInDescription: ({ as: Component, authMethod: authMethodFromProps, children, className, step: stepFromProps, ...props }: SignInDescriptionProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,29 +1,22 @@
1
- import { jsxs as t, Fragment as i, jsx as e } from "react/jsx-runtime";
1
+ import { jsx as i } from "react/jsx-runtime";
2
2
  import "react";
3
- import { useSignInContext as l } from "./SignInProvider.js";
4
- import '../../assets/SignInDescription.css';const u = "SignInDescription-module__description___jZLc6", a = "SignInDescription-module__medium___NGpLf", o = {
5
- description: u,
6
- medium: a
7
- }, _ = () => /* @__PURE__ */ e(i, { children: "We’ll send you a verification code via email." }), g = ({ email: n }) => /* @__PURE__ */ t(i, { children: [
8
- "We’ve sent a 6 digit code to ",
9
- /* @__PURE__ */ e("span", { className: o.medium, children: n }),
10
- "."
11
- ] }), D = () => /* @__PURE__ */ e(i, { children: "You’ve successfully signed in." }), v = ({
3
+ import { a as d } from "../../chunks/index.BzllgVaP.js";
4
+ import { useSignInContext as h } from "./SignInProvider.js";
5
+ import "@coinbase/cdp-hooks";
6
+ import "../CDPReactProvider/index.js";
7
+ import '../../assets/SignInDescription.css';const u = "SignInDescription-module__description___jZLc6", _ = {
8
+ description: u
9
+ }, M = ({
12
10
  as: n = "p",
13
- children: c,
14
- className: r = "",
15
- ...m
11
+ authMethod: e,
12
+ children: t,
13
+ className: p = "",
14
+ step: r,
15
+ ...c
16
16
  }) => {
17
- const { state: d } = l(), { step: s, email: p } = d;
18
- return /* @__PURE__ */ t(n, { className: `${o.description} ${r}`, ...m, children: [
19
- c,
20
- !c && /* @__PURE__ */ t(i, { children: [
21
- s === "otp" && /* @__PURE__ */ e(g, { email: p }),
22
- s === "success" && /* @__PURE__ */ e(D, {}),
23
- s === "email" && /* @__PURE__ */ e(_, {})
24
- ] })
25
- ] });
17
+ const { state: o } = h(), m = r || o.step, s = e || o.authMethod, a = d[s].description;
18
+ return /* @__PURE__ */ i(n, { className: `${_.description} ${p}`, ...c, children: t || /* @__PURE__ */ i(a, { step: m, authMethod: s }) });
26
19
  };
27
20
  export {
28
- v as SignInDescription
21
+ M as SignInDescription
29
22
  };
@@ -0,0 +1,2 @@
1
+ import { HTMLAttributes } from 'react';
2
+ export declare const SignInFooter: ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsxs as e, jsx as o } from "react/jsx-runtime";
2
+ import "react";
3
+ import { IconCoinbaseWordmark as c } from "../../icons/IconCoinbaseWordmark.js";
4
+ import { IconLock as s } from "../../icons/IconLock.js";
5
+ import '../../assets/SignInFooter.css';const t = "SignInFooter-module__footer___DLNrl", a = "SignInFooter-module__icon___hFhfx", n = {
6
+ footer: t,
7
+ icon: a,
8
+ "coinbase-icon": "SignInFooter-module__coinbase-icon___NeFOp"
9
+ }, f = ({ className: r = "", ...i }) => /* @__PURE__ */ e("div", { className: `${n.footer} ${r}`, ...i, children: [
10
+ /* @__PURE__ */ o(s, { className: n.icon }),
11
+ /* @__PURE__ */ e("p", { children: [
12
+ /* @__PURE__ */ o("span", { children: "Secured by " }),
13
+ /* @__PURE__ */ o(c, { className: n["coinbase-icon"], "aria-label": "Coinbase" })
14
+ ] })
15
+ ] });
16
+ export {
17
+ f as SignInFooter
18
+ };
@@ -1,6 +1,14 @@
1
- import { ElementType, HTMLAttributes } from 'react';
2
- export type SignInFormProps = {
1
+ import { ElementType, HTMLAttributes, ReactNode } from 'react';
2
+ import { AuthMethod } from '../CDPReactProvider/CDPReactProvider';
3
+ import { SignInState } from './types';
4
+ export interface SignInFormProps extends Omit<HTMLAttributes<HTMLElement>, "children"> {
3
5
  as?: ElementType;
4
6
  onSuccess?: () => void;
5
- } & HTMLAttributes<HTMLElement>;
6
- export declare const SignInForm: ({ as: Component, className, onSuccess, ...props }: SignInFormProps) => import("react/jsx-runtime").JSX.Element;
7
+ step?: SignInState["step"];
8
+ children?: (props: {
9
+ step: SignInState["step"];
10
+ authMethod: AuthMethod;
11
+ Form: ReactNode;
12
+ }) => ReactNode;
13
+ }
14
+ export declare const SignInForm: ({ onSuccess, step: stepFromProps, children }: SignInFormProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,202 +1,31 @@
1
- import { jsxs as i, jsx as o, Fragment as A } from "react/jsx-runtime";
2
- import { useSignInWithEmail as U, useVerifyEmailOTP as V } from "@coinbase/cdp-hooks";
3
- import { Form as P, FormSubmit as R } from "@radix-ui/react-form";
4
- import { useState as v, useEffect as y, useRef as B } from "react";
5
- import { Button as C } from "../Button/index.js";
6
- import { useAppConfig as k } from "../CDPReactProvider/index.js";
7
- import { Field as x } from "../Field/index.js";
8
- import { OTP as q } from "../OTP/index.js";
9
- import { ServerError as O } from "../ServerError/index.js";
10
- import { IconCoinbaseWordmark as D } from "../../icons/IconCoinbaseWordmark.js";
11
- import { IconLock as W } from "../../icons/IconLock.js";
12
- import { isApiError as T } from "../../utils/isApiError.js";
13
- import { isEmailInvalid as Q } from "../../utils/isEmailInvalid.js";
14
- import { useSignInContext as E } from "./SignInProvider.js";
15
- import { withValidityState as Z } from "../Input/index.js";
16
- import { LoadingSpinner as $ } from "../LoadingSpinner/index.js";
17
- import { VisuallyHidden as j } from "../VisuallyHidden/index.js";
18
- import '../../assets/SignInForm.css';const J = "SignInForm-module__form___8Mc3V", G = "SignInForm-module__footer___6Lo9w", H = "SignInForm-module__hr___fOcy4", X = "SignInForm-module__icon___qkJnq", n = {
19
- "form-wrapper": "SignInForm-module__form-wrapper___SlQkZ",
20
- form: J,
21
- "form-footer": "SignInForm-module__form-footer___PqM2J",
22
- "server-state-wrapper": "SignInForm-module__server-state-wrapper___QVsXy",
23
- "loading-spinner": "SignInForm-module__loading-spinner___W6gZo",
24
- "server-error": "SignInForm-module__server-error___dD9VE",
25
- "resend-wrapper": "SignInForm-module__resend-wrapper___ODSQA",
26
- "reset-timer": "SignInForm-module__reset-timer___Ms2YZ",
27
- footer: G,
28
- "coinbase-icon": "SignInForm-module__coinbase-icon___vGv7u",
29
- hr: H,
30
- icon: X
31
- }, Y = ({ submit: _ }) => {
32
- const { state: s, dispatch: d } = E(), e = () => d({ type: "CLEAR_ERROR" }), u = (p) => (p.preventDefault(), _(s.email));
33
- return /* @__PURE__ */ i(
34
- P,
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { useRef as s, useLayoutEffect as l } from "react";
3
+ import { useAppConfig as g } from "../CDPReactProvider/index.js";
4
+ import { SwitchFadeTransition as M } from "../SwitchFadeTransition/index.js";
5
+ import { a as w } from "../../chunks/index.BzllgVaP.js";
6
+ import { useSignInContext as _ } from "./SignInProvider.js";
7
+ import "@coinbase/cdp-hooks";
8
+ import '../../assets/SignInForm.css';const F = {
9
+ "auth-method-wrapper": "SignInForm-module__auth-method-wrapper___uIOAB"
10
+ }, E = ({ onSuccess: a, step: u, children: h }) => {
11
+ const { state: t } = _(), { authMethods: m } = g(), p = u || t.step, o = s(t.authMethod), r = s(null);
12
+ return l(() => {
13
+ o.current !== t.authMethod && (r.current?.transition.toggle(t.authMethod), o.current = t.authMethod);
14
+ }, [t.authMethod]), /* @__PURE__ */ e(
15
+ M,
35
16
  {
36
- className: n.form,
37
- onClearServerErrors: e,
38
- onSubmit: u,
39
- children: [
40
- /* @__PURE__ */ o(
41
- x,
42
- {
43
- label: "Email address",
44
- name: "email",
45
- validators: [
46
- ["valueMissing", "Email is required"],
47
- ["typeMismatch", "Use a valid email address"],
48
- [Q, "Use a valid email address"]
49
- ],
50
- children: Z({
51
- autoComplete: "email",
52
- type: "email",
53
- placeholder: "name@example.com",
54
- required: !0,
55
- value: s.email,
56
- onChange: (p) => {
57
- d({ type: "SET_EMAIL", payload: { email: p.target.value } });
58
- }
59
- })
60
- }
61
- ),
62
- s.error && /* @__PURE__ */ o(O, { error: s.error, className: n["server-error"] }),
63
- /* @__PURE__ */ o(R, { asChild: !0, children: /* @__PURE__ */ o(C, { type: "submit", isPending: s.isPending, children: "Continue with email" }) })
64
- ]
65
- }
66
- );
67
- }, z = ({
68
- reset: _,
69
- resetCountdown: s,
70
- submit: d
71
- }) => {
72
- const { state: e, dispatch: u } = E(), p = () => u({ type: "CLEAR_ERROR" }), l = B([]), f = (c) => (c.preventDefault(), d(e.otp)), h = () => {
73
- _(), l.current[0]?.focus();
74
- };
75
- return y(() => {
76
- e.step === "otp" && l.current[0]?.focus();
77
- }, [e.step]), /* @__PURE__ */ i(
78
- P,
79
- {
80
- className: `${n.form}`,
81
- onClearServerErrors: p,
82
- onSubmit: f,
83
- children: [
84
- /* @__PURE__ */ o(
85
- q,
86
- {
87
- ref: l,
88
- name: "otp",
89
- "aria-label": "Six-digit Verification Code",
90
- passwordLength: 6,
91
- value: e.otp,
92
- onChange: (c) => c.preventDefault(),
93
- onValueChange: (c) => {
94
- u({ type: "SET_OTP", payload: { otp: c } });
95
- },
96
- autoSubmit: !0
97
- }
98
- ),
99
- /* @__PURE__ */ i("div", { className: n["form-footer"], children: [
100
- (e.isPending && !e.canResetOTP || e.error) && /* @__PURE__ */ i("div", { className: n["server-state-wrapper"], children: [
101
- e.isPending && !e.canResetOTP && /* @__PURE__ */ o($, { className: n["loading-spinner"] }),
102
- e.error && /* @__PURE__ */ o(O, { error: e.error, className: n["server-error"] })
103
- ] }),
104
- /* @__PURE__ */ i("div", { className: n["resend-wrapper"], children: [
105
- e.canResetOTP && /* @__PURE__ */ o(R, { asChild: !0, children: /* @__PURE__ */ o(
106
- C,
107
- {
108
- type: "button",
109
- onClick: h,
110
- isPending: e.isPending,
111
- variant: "linkPrimary",
112
- children: "Resend code"
113
- }
114
- ) }),
115
- !e.canResetOTP && /* @__PURE__ */ o("div", { className: n["reset-timer"], children: /* @__PURE__ */ i("p", { children: [
116
- "Resend code in ",
117
- /* @__PURE__ */ i("span", { "aria-hidden": "true", children: [
118
- s,
119
- "s"
120
- ] }),
121
- /* @__PURE__ */ i(j, { children: [
122
- s,
123
- " ",
124
- s === 1 ? "second" : "seconds"
125
- ] })
126
- ] }) })
127
- ] })
128
- ] })
129
- ]
130
- }
131
- );
132
- }, he = ({
133
- as: _ = "div",
134
- className: s = "",
135
- onSuccess: d,
136
- ...e
137
- }) => {
138
- const l = "An error occurred while signing in. Please try again.", [f, h] = v(0), [c, S] = v(!1), { signInWithEmail: w } = U(), { verifyEmailOTP: b } = V(), { state: a, dispatch: m } = E(), { showCoinbaseFooter: F } = k(), L = (t) => {
139
- h(t), S(!0);
140
- };
141
- y(() => {
142
- if (!c)
143
- return;
144
- const t = setInterval(() => {
145
- h((r) => r > 1 ? r - 1 : (S(!1), 0));
146
- }, 1e3);
147
- return () => clearInterval(t);
148
- }, [c]), y(() => {
149
- f === 0 && a.step === "otp" && !a.canResetOTP && m({ type: "ALLOW_RESET_OTP" });
150
- }, [f, a.step, a.canResetOTP, m]);
151
- const I = async (t) => {
152
- if (!a.isPending) {
153
- m({ type: "SUBMIT_EMAIL", payload: { email: t } });
154
- try {
155
- const { flowId: r } = await w({
156
- email: t
157
- });
158
- m({ type: "SUBMIT_EMAIL_SUCCESS", payload: { flowId: r } }), L(60);
159
- } catch (r) {
160
- const g = T(r) ? r : r instanceof Error && r.message || l;
161
- m({ type: "SUBMIT_EMAIL_FAILURE", payload: { error: g } }), console.error(r);
17
+ animateHeight: !0,
18
+ timeout: 250,
19
+ items: m || ["email"],
20
+ initialEntered: !0,
21
+ transitionRef: r,
22
+ children: ({ itemKey: n, ...c }) => {
23
+ const d = w[n].forms;
24
+ return /* @__PURE__ */ e("div", { ...c, className: F["auth-method-wrapper"], children: /* @__PURE__ */ e(d, { step: p, onSuccess: a, children: ({ step: f, Form: i }) => h?.({ step: f, authMethod: n, Form: i }) || i }) });
162
25
  }
163
26
  }
164
- }, M = async (t) => {
165
- if (!a.isPending) {
166
- if (t.length !== 6) {
167
- m({ type: "SET_OTP", payload: { otp: t } });
168
- return;
169
- }
170
- m({ type: "SUBMIT_OTP", payload: { otp: t } });
171
- try {
172
- await b({
173
- flowId: a.flowId,
174
- otp: t
175
- }), m({ type: "SUBMIT_OTP_SUCCESS", payload: { otp: t } }), d?.();
176
- } catch (r) {
177
- const g = T(r) ? r : r instanceof Error && r.message || l;
178
- m({ type: "SUBMIT_OTP_FAILURE", payload: { error: g } }), console.error(r);
179
- }
180
- }
181
- }, N = () => {
182
- m({ type: "RESET_OTP" }), S(!1), I(a.email);
183
- };
184
- return /* @__PURE__ */ i(_, { className: `${n["form-wrapper"]} ${s}`, ...e, children: [
185
- a.step === "email" && /* @__PURE__ */ o(Y, { submit: I }),
186
- a.step === "otp" && /* @__PURE__ */ o(z, { submit: M, reset: N, resetCountdown: f }),
187
- F && /* @__PURE__ */ i(A, { children: [
188
- /* @__PURE__ */ o("hr", { className: n.hr }),
189
- /* @__PURE__ */ i("div", { className: n.footer, children: [
190
- /* @__PURE__ */ o(W, { className: n.icon }),
191
- /* @__PURE__ */ i("p", { children: [
192
- "Secured by",
193
- " ",
194
- /* @__PURE__ */ o(D, { className: n["coinbase-icon"], "aria-label": "Coinbase" })
195
- ] })
196
- ] })
197
- ] })
198
- ] });
27
+ );
199
28
  };
200
29
  export {
201
- he as SignInForm
30
+ E as SignInForm
202
31
  };
@@ -1,6 +1,6 @@
1
- export type SignInImageProps = {
1
+ export interface SignInImageProps {
2
2
  className?: string;
3
3
  alt?: string;
4
4
  src?: string;
5
- };
5
+ }
6
6
  export declare const SignInImage: ({ className, alt, src }: SignInImageProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,23 +1,20 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
- import { useAppConfig as p } from "../CDPReactProvider/index.js";
3
- import { IconCheckCircle as a } from "../../icons/IconCheckCircle.js";
4
- import { useSignInContext as _ } from "./SignInProvider.js";
5
- import '../../assets/SignInImage.css';const f = "SignInImage-module__logo___rlzt-", i = {
6
- logo: f,
7
- "success-icon": "SignInImage-module__success-icon___avUF9"
8
- }, l = (o) => /^https?:\/\//.test(o), S = ({ className: o = "", alt: r, src: t }) => {
9
- const { state: g } = _(), { step: n } = g, s = p(), m = s.logoUrl && l(s.logoUrl) ? s.logoUrl : void 0, c = t && l(t) ? t : m, u = r || s.name;
10
- return n !== "success" && c ? /* @__PURE__ */ e(
2
+ import { useAppConfig as m } from "../CDPReactProvider/index.js";
3
+ import '../../assets/SignInImage.css';const p = "SignInImage-module__logo___rlzt-", c = {
4
+ logo: p
5
+ }, n = (t) => /^https?:\/\//.test(t), f = ({ className: t = "", alt: s, src: l }) => {
6
+ const o = m(), r = o.logoUrl && n(o.logoUrl) ? o.logoUrl : void 0, g = l && n(l) ? l : r, i = s || o.name;
7
+ return g ? /* @__PURE__ */ e(
11
8
  "img",
12
9
  {
13
- src: c,
14
- alt: u || "",
15
- className: `${i.logo} ${o}`,
10
+ src: g,
11
+ alt: i || "",
12
+ className: `${c.logo} ${t}`,
16
13
  width: 64,
17
14
  height: 64
18
15
  }
19
- ) : n === "success" ? /* @__PURE__ */ e(a, { className: `${i["success-icon"]} ${o}` }) : null;
16
+ ) : null;
20
17
  };
21
18
  export {
22
- S as SignInImage
19
+ f as SignInImage
23
20
  };
@@ -1,5 +1,5 @@
1
1
  import { Dispatch, ReactNode } from 'react';
2
- import { SignInAction, SignInState } from './useSignInReducer';
2
+ import { SignInAction, SignInState } from './types';
3
3
  export declare const SignInContext: import('react').Context<{
4
4
  state: SignInState;
5
5
  dispatch: Dispatch<SignInAction>;
@@ -1,29 +1,37 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { createContext as a, useContext as c, useMemo as u } from "react";
3
- import { useSignInReducer as d } from "./useSignInReducer.js";
4
- const o = {
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { createContext as u, useContext as c, useMemo as m } from "react";
3
+ import { useAppConfig as d } from "../CDPReactProvider/index.js";
4
+ import "@coinbase/cdp-hooks";
5
+ import { useSignInReducer as p } from "./useSignInReducer.js";
6
+ const n = {
7
+ authMethod: "email",
8
+ canResetOTP: !1,
5
9
  email: "",
6
10
  error: null,
7
11
  flowId: "",
8
- canResetOTP: !1,
9
12
  isPending: !1,
13
+ isSuccess: !1,
10
14
  otp: "",
11
- step: "email"
12
- }, r = a({
13
- state: o,
15
+ phoneNumber: "",
16
+ step: "credentials"
17
+ }, s = u({
18
+ state: n,
14
19
  dispatch: () => {
15
20
  }
16
- }), p = () => {
17
- const t = c(r);
21
+ }), S = () => {
22
+ const t = c(s);
18
23
  if (!t)
19
24
  throw new Error("useSignInContext must be used within a SignInProvider");
20
25
  return t;
21
- }, x = ({ children: t }) => {
22
- const [e, n] = d(o), s = u(() => ({ state: e, dispatch: n }), [e, n]);
23
- return /* @__PURE__ */ i(r.Provider, { value: s, children: t });
26
+ }, I = ({ children: t }) => {
27
+ const { authMethods: r } = d(), [e, o] = p({
28
+ ...n,
29
+ authMethod: r?.[0] || "email"
30
+ }), i = m(() => ({ state: e, dispatch: o }), [e, o]);
31
+ return /* @__PURE__ */ a(s.Provider, { value: i, children: t });
24
32
  };
25
33
  export {
26
- r as SignInContext,
27
- x as SignInProvider,
28
- p as useSignInContext
34
+ s as SignInContext,
35
+ I as SignInProvider,
36
+ S as useSignInContext
29
37
  };
@@ -1,5 +1,6 @@
1
1
  import { ElementType, HTMLAttributes } from 'react';
2
- export type SignInTitleProps = {
2
+ import { SignInTitleAndDescriptionProps } from './types';
3
+ export interface SignInTitleProps extends SignInTitleAndDescriptionProps, HTMLAttributes<HTMLElement> {
3
4
  as?: ElementType;
4
- } & HTMLAttributes<HTMLElement>;
5
- export declare const SignInTitle: ({ as: Component, children, className, ...props }: SignInTitleProps) => import("react/jsx-runtime").JSX.Element;
5
+ }
6
+ export declare const SignInTitle: ({ as: Component, children, className, authMethod: authMethodFromProps, step: stepFromProps, ...props }: SignInTitleProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,17 +1,22 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { useMemo as c } from "react";
3
- import { useSignInContext as a } from "./SignInProvider.js";
4
- import '../../assets/SignInTitle.css';const u = "SignInTitle-module__heading___QJ071", m = {
5
- heading: u
6
- }, p = ({
7
- as: t = "h2",
8
- children: n,
9
- className: s = "",
10
- ...i
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import "react";
3
+ import { a as c } from "../../chunks/index.BzllgVaP.js";
4
+ import { useSignInContext as d } from "./SignInProvider.js";
5
+ import "@coinbase/cdp-hooks";
6
+ import "../CDPReactProvider/index.js";
7
+ import '../../assets/SignInTitle.css';const l = "SignInTitle-module__heading___QJ071", g = {
8
+ heading: l
9
+ }, S = ({
10
+ as: s = "h2",
11
+ children: t,
12
+ className: i = "",
13
+ authMethod: a,
14
+ step: h,
15
+ ...m
11
16
  }) => {
12
- const { state: e } = a(), o = c(() => e.step === "success" ? "Success" : e.step === "otp" ? "Enter verification code" : "Sign in", [e.step]);
13
- return /* @__PURE__ */ r(t, { className: `${m.heading} ${s}`, ...i, children: n || o });
17
+ const { state: o } = d(), r = h || o.step, e = a || o.authMethod, p = c[e].title;
18
+ return /* @__PURE__ */ n(s, { className: `${g.heading} ${i}`, ...m, children: t || /* @__PURE__ */ n(p, { step: r, authMethod: e }) });
14
19
  };
15
20
  export {
16
- p as SignInTitle
21
+ S as SignInTitle
17
22
  };
@@ -0,0 +1,5 @@
1
+ import { SignInFlowProps, SignInTitleAndDescriptionProps, SignInFlowConfig } from '../types';
2
+ export declare const SignInWithEmail: ({ step: stepFromProps, onSuccess, children }: SignInFlowProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const SignInWithEmailTitle: ({ step }: SignInTitleAndDescriptionProps) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const SignInWithEmailDescription: ({ step }: SignInTitleAndDescriptionProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const config: SignInFlowConfig;