@coinbase/cdp-react 0.0.17 → 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 (135) 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 +2 -2
  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/SendTransactionButton/index.js +1 -1
  61. package/dist/components/ServerError/index.js +4 -4
  62. package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +13 -0
  63. package/dist/components/SignIn/SignInAuthMethodButtons.js +57 -0
  64. package/dist/components/SignIn/SignInBackButton.d.ts +9 -0
  65. package/dist/components/SignIn/SignInBackButton.js +38 -0
  66. package/dist/components/SignIn/SignInCredentials.d.ts +2 -0
  67. package/dist/components/SignIn/SignInCredentials.js +8 -0
  68. package/dist/components/SignIn/SignInDescription.d.ts +4 -3
  69. package/dist/components/SignIn/SignInDescription.js +16 -23
  70. package/dist/components/SignIn/SignInFooter.d.ts +2 -0
  71. package/dist/components/SignIn/SignInFooter.js +18 -0
  72. package/dist/components/SignIn/SignInForm.d.ts +12 -4
  73. package/dist/components/SignIn/SignInForm.js +25 -196
  74. package/dist/components/SignIn/SignInImage.d.ts +2 -2
  75. package/dist/components/SignIn/SignInImage.js +11 -14
  76. package/dist/components/SignIn/SignInProvider.d.ts +1 -1
  77. package/dist/components/SignIn/SignInProvider.js +24 -16
  78. package/dist/components/SignIn/SignInTitle.d.ts +4 -3
  79. package/dist/components/SignIn/SignInTitle.js +18 -13
  80. package/dist/components/SignIn/flows/SignInWithEmail.d.ts +5 -0
  81. package/dist/components/SignIn/flows/SignInWithEmail.js +71 -0
  82. package/dist/components/SignIn/flows/SignInWithSms.d.ts +5 -0
  83. package/dist/components/SignIn/flows/SignInWithSms.js +2994 -0
  84. package/dist/components/SignIn/hooks/useEmailForm.d.ts +13 -0
  85. package/dist/components/SignIn/hooks/useEmailForm.js +42 -0
  86. package/dist/components/SignIn/hooks/useOTPForm.d.ts +16 -0
  87. package/dist/components/SignIn/hooks/useOTPForm.js +59 -0
  88. package/dist/components/SignIn/hooks/usePhoneNumberForm.d.ts +13 -0
  89. package/dist/components/SignIn/hooks/usePhoneNumberForm.js +42 -0
  90. package/dist/components/SignIn/index.d.ts +5 -2
  91. package/dist/components/SignIn/index.js +42 -24
  92. package/dist/components/SignIn/types.d.ts +106 -0
  93. package/dist/components/SignIn/types.js +3 -0
  94. package/dist/components/SignIn/useSignInReducer.d.ts +1 -57
  95. package/dist/components/SignIn/useSignInReducer.js +62 -20
  96. package/dist/components/SignInModal/index.d.ts +2 -2
  97. package/dist/components/SignInModal/index.js +62 -43
  98. package/dist/components/SignOutButton/index.js +1 -1
  99. package/dist/components/SuccessMessage/index.d.ts +7 -0
  100. package/dist/components/SuccessMessage/index.js +16 -0
  101. package/dist/components/SwitchFadeTransition/index.d.ts +5 -0
  102. package/dist/components/SwitchFadeTransition/index.js +24 -0
  103. package/dist/components/SwitchSlideTransition/index.d.ts +7 -0
  104. package/dist/components/SwitchSlideTransition/index.js +27 -0
  105. package/dist/components/SwitchTransition/index.d.ts +25 -0
  106. package/dist/components/SwitchTransition/index.js +155 -0
  107. package/dist/data/countries.d.ts +12 -0
  108. package/dist/data/countries.js +25 -0
  109. package/dist/data/countryNames.d.ts +1 -0
  110. package/dist/data/countryNames.js +6 -0
  111. package/dist/hooks/usePhoneNumberValidators.d.ts +14 -0
  112. package/dist/hooks/usePhoneNumberValidators.js +36 -0
  113. package/dist/hooks/useTimer.d.ts +5 -0
  114. package/dist/hooks/useTimer.js +24 -0
  115. package/dist/icons/IconArrowLeft.d.ts +2 -0
  116. package/dist/icons/IconArrowLeft.js +14 -0
  117. package/dist/icons/IconCheckCircle.js +2 -3
  118. package/dist/icons/IconCoinbaseWordmark.js +5 -5
  119. package/dist/icons/IconEnvelope.d.ts +2 -0
  120. package/dist/icons/IconEnvelope.js +7 -0
  121. package/dist/icons/IconExclamationCircle.js +3 -4
  122. package/dist/icons/IconPhone.d.ts +2 -0
  123. package/dist/icons/IconPhone.js +7 -0
  124. package/dist/icons/IconXMark.js +6 -5
  125. package/dist/icons/index.d.ts +3 -0
  126. package/dist/icons/index.js +14 -8
  127. package/dist/index.js +66 -53
  128. package/dist/theme/theme.d.ts +11 -2
  129. package/dist/theme/tokens.d.ts +30 -6
  130. package/dist/theme/tokens.js +7 -3
  131. package/dist/utils/parseValuesFromPhoneNumber.d.ts +6 -0
  132. package/dist/utils/parseValuesFromPhoneNumber.js +16 -0
  133. package/dist/utils/validatePhoneNumber.d.ts +1 -0
  134. package/dist/utils/validatePhoneNumber.js +1 -0
  135. package/package.json +11 -7
@@ -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;
@@ -0,0 +1,71 @@
1
+ import { jsx as p, jsxs as o, Fragment as r } from "react/jsx-runtime";
2
+ import { useSignInWithEmail as x, useVerifyEmailOTP as y } from "@coinbase/cdp-hooks";
3
+ import { useRef as f, useLayoutEffect as D } from "react";
4
+ import { FlowEmailOTP as F } from "../../FlowEmailOTP/index.js";
5
+ import "react-transition-state";
6
+ import { useEmailForm as j } from "../hooks/useEmailForm.js";
7
+ import { useOTPForm as L } from "../hooks/useOTPForm.js";
8
+ import { SignInCredentials as H } from "../SignInCredentials.js";
9
+ import { useSignInContext as g } from "../SignInProvider.js";
10
+ import "../../CDPReactProvider/index.js";
11
+ const M = ({ step: i, onSuccess: s, children: S }) => {
12
+ const a = f(null), h = 6, { state: e } = g(), { signInWithEmail: E } = x(), { verifyEmailOTP: P } = y(), c = i || e.step, n = c === "credentials" ? "email" : "otp", m = f(n), { setEmail: T, submitEmail: l } = j({
13
+ submit: (t) => E({ email: t })
14
+ }), { resendCountdown: O, resetOTP: v, setOTP: I, startResendTimer: b, submitOtp: w } = L({
15
+ passwordLength: h,
16
+ submit: (t) => P({ flowId: e.flowId, otp: t })
17
+ }), u = () => {
18
+ b(60);
19
+ }, R = () => {
20
+ v(), l({ email: e.email, onSuccess: u });
21
+ }, W = (t) => {
22
+ t.preventDefault(), l({ email: e.email, onSuccess: u });
23
+ }, C = (t) => {
24
+ t.preventDefault(), w({ otp: e.otp, onSuccess: s });
25
+ };
26
+ return D(() => {
27
+ m.current !== n && (a.current?.transition.toggle(n), m.current = n);
28
+ }, [n]), /* @__PURE__ */ p(
29
+ F,
30
+ {
31
+ animateHeight: !1,
32
+ canResetOTP: e.canResetOTP,
33
+ email: e.email,
34
+ error: e.error || "",
35
+ isPending: e.isPending,
36
+ onEmailChange: T,
37
+ onOTPChange: I,
38
+ onResendOTP: R,
39
+ onSubmitEmail: W,
40
+ onSubmitOTP: C,
41
+ otp: e.otp,
42
+ resendCountdown: O,
43
+ step: n,
44
+ successMessage: e.isSuccess ? "Success!" : void 0,
45
+ transitionRef: a,
46
+ children: ({ step: t, Form: d }) => S?.({ step: c, Form: d }) || d
47
+ }
48
+ );
49
+ }, V = ({ step: i }) => /* @__PURE__ */ o(r, { children: [
50
+ i === "credentials" && "Sign in",
51
+ i === "verification" && "Enter verification code"
52
+ ] }), _ = ({ step: i }) => {
53
+ const { state: s } = g();
54
+ return /* @__PURE__ */ o(r, { children: [
55
+ i === "credentials" && "We’ll send you a verification code via email.",
56
+ i === "verification" && /* @__PURE__ */ o(r, { children: [
57
+ "Enter the 6 digit code sent to ",
58
+ /* @__PURE__ */ p(H, { children: s.email })
59
+ ] })
60
+ ] });
61
+ }, U = {
62
+ description: _,
63
+ forms: M,
64
+ title: V
65
+ };
66
+ export {
67
+ M as SignInWithEmail,
68
+ _ as SignInWithEmailDescription,
69
+ V as SignInWithEmailTitle,
70
+ U as config
71
+ };
@@ -0,0 +1,5 @@
1
+ import { SignInFlowProps, SignInTitleAndDescriptionProps, SignInFlowConfig } from '../types';
2
+ export declare const SignInWithSms: ({ step: stepFromProps, onSuccess, children }: SignInFlowProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const SignInWithSmsTitle: ({ step }: SignInTitleAndDescriptionProps) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const SignInWithSmsDescription: ({ step }: SignInTitleAndDescriptionProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const config: SignInFlowConfig;