@coinbase/cdp-react 0.0.18 → 0.0.20
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/dist/assets/Button.css +1 -1
- package/dist/assets/EmailForm.css +1 -0
- package/dist/assets/Error.css +1 -1
- package/dist/assets/Field.css +1 -1
- package/dist/assets/Input.css +1 -1
- package/dist/assets/Label.css +1 -0
- package/dist/assets/LoadingSkeleton.css +1 -1
- package/dist/assets/LoadingSpinner.css +1 -1
- package/dist/assets/Modal.css +1 -0
- package/dist/assets/OTP.css +1 -1
- package/dist/assets/OTPForm.css +1 -0
- package/dist/assets/PhoneNumberForm.css +1 -0
- package/dist/assets/PhoneNumberInput.css +1 -0
- package/dist/assets/SignIn.css +1 -1
- package/dist/assets/SignInAuthMethodButtons.css +1 -0
- package/dist/assets/SignInBackButton.css +1 -0
- package/dist/assets/SignInCredentials.css +1 -0
- package/dist/assets/SignInDescription.css +1 -1
- package/dist/assets/SignInFooter.css +1 -0
- package/dist/assets/SignInForm.css +1 -1
- package/dist/assets/SignInImage.css +1 -1
- package/dist/assets/SignInModal.css +1 -1
- package/dist/assets/SignInTitle.css +1 -1
- package/dist/assets/SuccessMessage.css +1 -0
- package/dist/assets/SwitchFadeTransition.css +1 -0
- package/dist/assets/SwitchSlideTransition.css +1 -0
- package/dist/assets/SwitchTransition.css +1 -0
- package/dist/assets/ThemeProvider.css +1 -1
- package/dist/assets/VisuallyHidden.css +1 -1
- package/dist/chunks/index.BzllgVaP.js +12 -0
- package/dist/components/AuthButton/index.js +7 -7
- package/dist/components/CDPReactProvider/index.d.ts +3 -0
- package/dist/components/CDPReactProvider/index.js +20 -13
- package/dist/components/SendTransactionButton/index.js +1 -1
- package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +13 -0
- package/dist/components/SignIn/SignInAuthMethodButtons.js +59 -0
- package/dist/components/SignIn/SignInBackButton.d.ts +9 -0
- package/dist/components/SignIn/SignInBackButton.js +38 -0
- package/dist/components/SignIn/SignInCredentials.d.ts +2 -0
- package/dist/components/SignIn/SignInCredentials.js +8 -0
- package/dist/components/SignIn/SignInDescription.d.ts +4 -3
- package/dist/components/SignIn/SignInDescription.js +16 -23
- package/dist/components/SignIn/SignInFooter.d.ts +2 -0
- package/dist/components/SignIn/SignInFooter.js +18 -0
- package/dist/components/SignIn/SignInForm.d.ts +12 -4
- package/dist/components/SignIn/SignInForm.js +30 -195
- package/dist/components/SignIn/SignInImage.d.ts +2 -2
- package/dist/components/SignIn/SignInImage.js +11 -14
- package/dist/components/SignIn/SignInProvider.d.ts +1 -1
- package/dist/components/SignIn/SignInProvider.js +24 -16
- package/dist/components/SignIn/SignInTitle.d.ts +4 -3
- package/dist/components/SignIn/SignInTitle.js +18 -13
- package/dist/components/SignIn/flows/SignInWithEmail.d.ts +6 -0
- package/dist/components/SignIn/flows/SignInWithEmail.js +88 -0
- package/dist/components/SignIn/flows/SignInWithSms.d.ts +8 -0
- package/dist/components/SignIn/flows/SignInWithSms.js +3011 -0
- package/dist/components/SignIn/hooks/useEmailForm.d.ts +13 -0
- package/dist/components/SignIn/hooks/useEmailForm.js +42 -0
- package/dist/components/SignIn/hooks/useOTPForm.d.ts +16 -0
- package/dist/components/SignIn/hooks/useOTPForm.js +59 -0
- package/dist/components/SignIn/hooks/usePhoneNumberForm.d.ts +13 -0
- package/dist/components/SignIn/hooks/usePhoneNumberForm.js +42 -0
- package/dist/components/SignIn/index.d.ts +5 -2
- package/dist/components/SignIn/index.js +42 -24
- package/dist/components/SignIn/types.d.ts +106 -0
- package/dist/components/SignIn/types.js +3 -0
- package/dist/components/SignIn/useSignInReducer.d.ts +1 -57
- package/dist/components/SignIn/useSignInReducer.js +62 -20
- package/dist/components/SignInModal/index.d.ts +2 -2
- package/dist/components/SignInModal/index.js +56 -44
- package/dist/components/SignOutButton/index.js +1 -1
- package/dist/components/ThemeProvider/index.js +1 -1
- package/dist/components/forms/EmailForm/index.d.ts +11 -0
- package/dist/components/forms/EmailForm/index.js +56 -0
- package/dist/components/{Field → forms/Field}/index.d.ts +2 -1
- package/dist/components/forms/Field/index.js +24 -0
- package/dist/components/{Input → forms/Input}/index.js +1 -1
- package/dist/components/forms/Label/index.d.ts +7 -0
- package/dist/components/forms/Label/index.js +13 -0
- package/dist/components/{OTP → forms/OTP}/index.d.ts +3 -0
- package/dist/components/forms/OTP/index.js +65 -0
- package/dist/components/forms/OTPForm/index.d.ts +16 -0
- package/dist/components/forms/OTPForm/index.js +76 -0
- package/dist/components/forms/PhoneNumberForm/index.d.ts +14 -0
- package/dist/components/forms/PhoneNumberForm/index.js +68 -0
- package/dist/components/forms/PhoneNumberInput/PhoneNumberMetadata.d.ts +2 -0
- package/dist/components/forms/PhoneNumberInput/PhoneNumberMetadata.js +5 -0
- package/dist/components/forms/PhoneNumberInput/index.d.ts +10 -0
- package/dist/components/forms/PhoneNumberInput/index.js +76 -0
- package/dist/components/forms/PhoneNumberInput/maskOverride.d.ts +8 -0
- package/dist/components/forms/PhoneNumberInput/maskOverride.js +61 -0
- package/dist/components/forms/PhoneNumberInput/usePhoneNumberFormatter.d.ts +7 -0
- package/dist/components/forms/PhoneNumberInput/usePhoneNumberFormatter.js +52 -0
- package/dist/components/{Button → ui/Button}/index.d.ts +2 -1
- package/dist/components/ui/Button/index.js +75 -0
- package/dist/components/{Error → ui/Error}/index.d.ts +2 -2
- package/dist/components/ui/Error/index.js +16 -0
- package/dist/components/ui/LoadingSkeleton/index.js +19 -0
- package/dist/components/{LoadingSpinner → ui/LoadingSpinner}/index.js +6 -6
- package/dist/components/ui/Modal/index.d.ts +11 -0
- package/dist/components/ui/Modal/index.js +27 -0
- package/dist/components/{ServerError → ui/ServerError}/index.js +4 -4
- package/dist/components/ui/SuccessMessage/index.d.ts +7 -0
- package/dist/components/ui/SuccessMessage/index.js +16 -0
- package/dist/components/ui/SwitchFadeTransition/index.d.ts +5 -0
- package/dist/components/ui/SwitchFadeTransition/index.js +24 -0
- package/dist/components/ui/SwitchSlideTransition/index.d.ts +7 -0
- package/dist/components/ui/SwitchSlideTransition/index.js +27 -0
- package/dist/components/ui/SwitchTransition/index.d.ts +25 -0
- package/dist/components/ui/SwitchTransition/index.js +155 -0
- package/dist/components/{VisuallyHidden → ui/VisuallyHidden}/index.js +2 -2
- package/dist/data/countries.d.ts +12 -0
- package/dist/data/countries.js +25 -0
- package/dist/data/countryNames.d.ts +1 -0
- package/dist/data/countryNames.js +6 -0
- package/dist/hooks/usePhoneNumberValidators.d.ts +14 -0
- package/dist/hooks/usePhoneNumberValidators.js +36 -0
- package/dist/hooks/useTimer.d.ts +5 -0
- package/dist/hooks/useTimer.js +24 -0
- package/dist/icons/IconArrowLeft.d.ts +2 -0
- package/dist/icons/IconArrowLeft.js +14 -0
- package/dist/icons/IconCheckCircle.js +2 -3
- package/dist/icons/IconCoinbaseWordmark.js +5 -5
- package/dist/icons/IconEnvelope.d.ts +2 -0
- package/dist/icons/IconEnvelope.js +7 -0
- package/dist/icons/IconExclamationCircle.js +3 -4
- package/dist/icons/IconPhone.d.ts +2 -0
- package/dist/icons/IconPhone.js +7 -0
- package/dist/icons/IconXMark.js +6 -5
- package/dist/icons/index.d.ts +3 -0
- package/dist/icons/index.js +14 -8
- package/dist/index.js +66 -53
- package/dist/theme/theme.d.ts +11 -2
- package/dist/theme/tokens.d.ts +30 -6
- package/dist/theme/tokens.js +7 -3
- package/dist/utils/parseValuesFromPhoneNumber.d.ts +6 -0
- package/dist/utils/parseValuesFromPhoneNumber.js +16 -0
- package/package.json +23 -7
- package/dist/components/Button/index.js +0 -50
- package/dist/components/Error/index.js +0 -16
- package/dist/components/Field/index.js +0 -22
- package/dist/components/LoadingSkeleton/index.js +0 -19
- package/dist/components/OTP/index.js +0 -50
- /package/dist/components/{Input → forms/Input}/index.d.ts +0 -0
- /package/dist/components/{LoadingSkeleton → ui/LoadingSkeleton}/index.d.ts +0 -0
- /package/dist/components/{LoadingSpinner → ui/LoadingSpinner}/index.d.ts +0 -0
- /package/dist/components/{ServerError → ui/ServerError}/index.d.ts +0 -0
- /package/dist/components/{VisuallyHidden → ui/VisuallyHidden}/index.d.ts +0 -0
|
@@ -1,50 +1,62 @@
|
|
|
1
|
-
import { jsxs as o, jsx as
|
|
2
|
-
import { Dialog as m, DialogTrigger as g, DialogPortal as _, DialogOverlay as d, DialogContent as c, DialogClose as p, DialogTitle as I, DialogDescription as u } from "@radix-ui/react-dialog";
|
|
1
|
+
import { jsxs as o, jsx as n, Fragment as m } from "react/jsx-runtime";
|
|
3
2
|
import "react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import "
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { SignInForm as
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
import { useAppConfig as f } from "../CDPReactProvider/index.js";
|
|
4
|
+
import { SignIn as u } from "../SignIn/index.js";
|
|
5
|
+
import { Button as c } from "../ui/Button/index.js";
|
|
6
|
+
import { Modal as I, ModalTrigger as S, ModalContent as M, ModalClose as b, ModalTitle as v, ModalDescription as C } from "../ui/Modal/index.js";
|
|
7
|
+
import { VisuallyHidden as t } from "../ui/VisuallyHidden/index.js";
|
|
8
|
+
import { IconXMark as N } from "../../icons/IconXMark.js";
|
|
9
|
+
import { SignInBackButton as k } from "../SignIn/SignInBackButton.js";
|
|
10
|
+
import { SignInImage as x } from "../SignIn/SignInImage.js";
|
|
11
|
+
import { SignInForm as B } from "../SignIn/SignInForm.js";
|
|
12
|
+
import { SignInTitle as l } from "../SignIn/SignInTitle.js";
|
|
13
|
+
import { SignInDescription as a } from "../SignIn/SignInDescription.js";
|
|
14
|
+
import { SignInAuthMethodButtons as w } from "../SignIn/SignInAuthMethodButtons.js";
|
|
15
|
+
import { SignInFooter as y } from "../SignIn/SignInFooter.js";
|
|
16
|
+
import '../../assets/SignInModal.css';const D = "SignInModal-module__trigger___IcJ8x", F = "SignInModal-module__footer___6qEo2", T = "SignInModal-module__buttons___jhaVn", i = {
|
|
17
|
+
trigger: D,
|
|
16
18
|
"sign-in": "SignInModal-module__sign-in___n05-5",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"sign-in-description": "SignInModal-module__sign-in-description___-Oi9q",
|
|
19
|
+
"no-footer": "SignInModal-module__no-footer___meSt1",
|
|
20
|
+
"title-desc-wrapper": "SignInModal-module__title-desc-wrapper___--XLa",
|
|
20
21
|
"sign-in-form": "SignInModal-module__sign-in-form___Jzx1-",
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
22
|
+
"sign-in-image": "SignInModal-module__sign-in-image___DGg7B",
|
|
23
|
+
footer: F,
|
|
24
|
+
buttons: T,
|
|
25
|
+
"back-button": "SignInModal-module__back-button___nMh2-",
|
|
26
|
+
"close-icon": "SignInModal-module__close-icon___b-gMh"
|
|
27
|
+
}, R = ({ children: _, open: g, setIsOpen: p, onSuccess: s }) => {
|
|
28
|
+
const { showCoinbaseFooter: d } = f();
|
|
29
|
+
return /* @__PURE__ */ o(I, { open: g, onOpenChange: p, children: [
|
|
30
|
+
/* @__PURE__ */ n(S, { asChild: !0, children: _ || /* @__PURE__ */ n(c, { variant: "primary", className: i.trigger, children: "Sign in" }) }),
|
|
31
|
+
/* @__PURE__ */ n(M, { children: /* @__PURE__ */ n(
|
|
32
|
+
u,
|
|
33
|
+
{
|
|
34
|
+
onSuccess: s,
|
|
35
|
+
className: `${i["sign-in"]} ${d ? "" : i["no-footer"]}`,
|
|
36
|
+
children: /* @__PURE__ */ o(m, { children: [
|
|
37
|
+
/* @__PURE__ */ n(j, {}),
|
|
38
|
+
/* @__PURE__ */ o("div", { className: i.buttons, children: [
|
|
39
|
+
/* @__PURE__ */ n(k, { className: i["back-button"] }),
|
|
40
|
+
/* @__PURE__ */ n(b, { asChild: !0, children: /* @__PURE__ */ n(c, { "aria-label": "Close", size: "md", variant: "transparentSecondary", children: /* @__PURE__ */ n(N, { className: i["close-icon"] }) }) })
|
|
41
|
+
] }),
|
|
42
|
+
/* @__PURE__ */ n("div", { className: i["sign-in-image"], children: /* @__PURE__ */ n(x, {}) }),
|
|
43
|
+
/* @__PURE__ */ n(B, { onSuccess: s, children: ({ authMethod: r, step: e, Form: h }) => /* @__PURE__ */ o(m, { children: [
|
|
44
|
+
/* @__PURE__ */ o("div", { className: i["title-desc-wrapper"], children: [
|
|
45
|
+
e === "verification" ? /* @__PURE__ */ n(t, { as: "div", children: /* @__PURE__ */ n(l, {}) }) : /* @__PURE__ */ n(l, {}),
|
|
46
|
+
e === "credentials" ? /* @__PURE__ */ n(t, { as: "div", children: /* @__PURE__ */ n(a, { authMethod: r }) }) : /* @__PURE__ */ n(a, { authMethod: r })
|
|
47
|
+
] }),
|
|
48
|
+
/* @__PURE__ */ n("div", { className: i["sign-in-form"], children: h }),
|
|
49
|
+
e === "credentials" && /* @__PURE__ */ n(w, { activeMethod: r })
|
|
50
|
+
] }) }),
|
|
51
|
+
d && /* @__PURE__ */ n(y, { className: i.footer })
|
|
52
|
+
] })
|
|
53
|
+
}
|
|
54
|
+
) })
|
|
46
55
|
] });
|
|
47
|
-
}
|
|
56
|
+
}, j = () => /* @__PURE__ */ o(t, { children: [
|
|
57
|
+
/* @__PURE__ */ n(v, { asChild: !0, children: /* @__PURE__ */ n(l, { as: "span" }) }),
|
|
58
|
+
/* @__PURE__ */ n(C, { asChild: !0, children: /* @__PURE__ */ n(a, { as: "span" }) })
|
|
59
|
+
] });
|
|
48
60
|
export {
|
|
49
|
-
|
|
61
|
+
R as SignInModal
|
|
50
62
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import { useSignOut as r } from "@coinbase/cdp-hooks";
|
|
3
3
|
import "react";
|
|
4
|
-
import { Button as m } from "../Button/index.js";
|
|
4
|
+
import { Button as m } from "../ui/Button/index.js";
|
|
5
5
|
import "../../theme/theme.js";
|
|
6
6
|
import '../../assets/SignOutButton.css';const e = {
|
|
7
7
|
"sign-out-button": "SignOutButton-module__sign-out-button___qiybe"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as p,
|
|
2
|
+
import { createContext as p, useContext as u, useMemo as s } from "react";
|
|
3
3
|
import { theme as n } from "../../theme/theme.js";
|
|
4
4
|
import { themeToCssVariables as l } from "../../theme/utils.js";
|
|
5
5
|
import '../../assets/ThemeProvider.css';const w = "ThemeProvider-module__wrapper___aXwhZ", d = {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { APIError } from '@coinbase/cdp-hooks';
|
|
2
|
+
import { FormHTMLAttributes } from 'react';
|
|
3
|
+
export interface EmailFormProps extends Omit<FormHTMLAttributes<HTMLFormElement>, "children"> {
|
|
4
|
+
email?: string;
|
|
5
|
+
error?: string | APIError;
|
|
6
|
+
isPending?: boolean;
|
|
7
|
+
onClearServerErrors?: () => void;
|
|
8
|
+
onEmailChange?: (value: string) => void;
|
|
9
|
+
submitLabel?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const EmailForm: ({ className, email, error, onEmailChange, isPending, submitLabel, ...props }: EmailFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsxs as u, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import "@coinbase/cdp-hooks";
|
|
3
|
+
import { Form as c, FormSubmit as v } from "@radix-ui/react-form";
|
|
4
|
+
import "react";
|
|
5
|
+
import { Field as f } from "../Field/index.js";
|
|
6
|
+
import { withValidityState as h } from "../Input/index.js";
|
|
7
|
+
import { Button as _ } from "../../ui/Button/index.js";
|
|
8
|
+
import { ServerError as E } from "../../ui/ServerError/index.js";
|
|
9
|
+
import { isEmailInvalid as F } from "../../../utils/isEmailInvalid.js";
|
|
10
|
+
import '../../../assets/EmailForm.css';const x = "EmailForm-module__form___L0wVX", o = {
|
|
11
|
+
form: x,
|
|
12
|
+
"server-error": "EmailForm-module__server-error___0TSPx"
|
|
13
|
+
}, N = ({
|
|
14
|
+
className: a = "",
|
|
15
|
+
email: t,
|
|
16
|
+
error: e,
|
|
17
|
+
onEmailChange: m,
|
|
18
|
+
isPending: l,
|
|
19
|
+
submitLabel: s = "Continue",
|
|
20
|
+
...d
|
|
21
|
+
}) => {
|
|
22
|
+
const i = {
|
|
23
|
+
autoComplete: "email",
|
|
24
|
+
type: "email",
|
|
25
|
+
placeholder: "name@example.com",
|
|
26
|
+
required: !0
|
|
27
|
+
}, n = (p) => {
|
|
28
|
+
m?.(p.target.value?.trim());
|
|
29
|
+
};
|
|
30
|
+
return /* @__PURE__ */ u(c, { className: `${o.form} ${a}`, ...d, children: [
|
|
31
|
+
/* @__PURE__ */ r(
|
|
32
|
+
f,
|
|
33
|
+
{
|
|
34
|
+
label: "Email address",
|
|
35
|
+
name: "email",
|
|
36
|
+
validators: [
|
|
37
|
+
["valueMissing", "Email is required"],
|
|
38
|
+
["typeMismatch", "Use a valid email address"],
|
|
39
|
+
[F, "Use a valid email address"]
|
|
40
|
+
],
|
|
41
|
+
children: h(
|
|
42
|
+
m !== void 0 ? {
|
|
43
|
+
...i,
|
|
44
|
+
value: t,
|
|
45
|
+
onChange: n
|
|
46
|
+
} : i
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
e && /* @__PURE__ */ r(E, { error: e, className: o["server-error"] }),
|
|
51
|
+
/* @__PURE__ */ r(v, { asChild: !0, children: /* @__PURE__ */ r(_, { type: "submit", isPending: l, children: s }) })
|
|
52
|
+
] });
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
N as EmailForm
|
|
56
|
+
};
|
|
@@ -3,9 +3,10 @@ import { CSSProperties, JSX, ReactNode } from 'react';
|
|
|
3
3
|
export interface FormFieldProps {
|
|
4
4
|
children?: FormValidityStateProps["children"];
|
|
5
5
|
className?: string;
|
|
6
|
+
inlineError?: string;
|
|
6
7
|
label: string;
|
|
7
8
|
name: string;
|
|
8
9
|
style?: CSSProperties;
|
|
9
10
|
validators?: [FormMessageProps["match"], ReactNode][];
|
|
10
11
|
}
|
|
11
|
-
export declare const Field: ({ children, className, label, name, style, validators, }: FormFieldProps) => JSX.Element;
|
|
12
|
+
export declare const Field: ({ children, className, inlineError, label, name, style, validators, }: FormFieldProps) => JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsxs as n, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { FormField as F, FormLabel as f, FormValidityState as u, FormControl as C, FormMessage as d } from "@radix-ui/react-form";
|
|
3
|
+
import "react";
|
|
4
|
+
import { Label as _ } from "../Label/index.js";
|
|
5
|
+
import { Error as o } from "../../ui/Error/index.js";
|
|
6
|
+
import '../../../assets/Field.css';const b = {
|
|
7
|
+
"field-wrapper": "Field-module__field-wrapper___SCcbl"
|
|
8
|
+
}, S = ({
|
|
9
|
+
children: l,
|
|
10
|
+
className: t = "",
|
|
11
|
+
inlineError: i,
|
|
12
|
+
label: m,
|
|
13
|
+
name: a,
|
|
14
|
+
style: s,
|
|
15
|
+
validators: p
|
|
16
|
+
}) => /* @__PURE__ */ n(F, { name: a, className: `${t} ${b["field-wrapper"]}`, style: s, children: [
|
|
17
|
+
/* @__PURE__ */ r(f, { asChild: !0, children: /* @__PURE__ */ r(_, { children: m }) }),
|
|
18
|
+
/* @__PURE__ */ r(u, { children: (e) => l && /* @__PURE__ */ r(C, { asChild: !0, children: l(e) }) }),
|
|
19
|
+
p?.map(([e, c], h) => /* @__PURE__ */ r(d, { match: e, asChild: !0, children: /* @__PURE__ */ r(o, { children: c }) }, h)),
|
|
20
|
+
i && /* @__PURE__ */ r(d, { asChild: !0, children: /* @__PURE__ */ r(o, { children: i }) })
|
|
21
|
+
] });
|
|
22
|
+
export {
|
|
23
|
+
S as Field
|
|
24
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import "@radix-ui/react-form";
|
|
3
3
|
import { forwardRef as p } from "react";
|
|
4
|
-
import '
|
|
4
|
+
import '../../../assets/Input.css';const u = "Input-module__input___-mK8z", e = {
|
|
5
5
|
input: u
|
|
6
6
|
}, r = p(
|
|
7
7
|
({ className: i = "", ...n }, t) => /* @__PURE__ */ a("input", { ref: t, className: `${e.input} ${i}`, ...n })
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
interface LabelProps extends HTMLAttributes<HTMLLabelElement> {
|
|
3
|
+
as?: ElementType;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare const Label: ({ as: Component, children, className, ...props }: LabelProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import '../../../assets/Label.css';const t = "Label-module__label___jDumT", b = {
|
|
4
|
+
label: t
|
|
5
|
+
}, _ = ({
|
|
6
|
+
as: l = "label",
|
|
7
|
+
children: e,
|
|
8
|
+
className: a = "",
|
|
9
|
+
...s
|
|
10
|
+
}) => /* @__PURE__ */ o(l, { className: `${b.label} ${a}`, ...s, children: e });
|
|
11
|
+
export {
|
|
12
|
+
_ as Label
|
|
13
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { OneTimePasswordFieldProps } from '@radix-ui/react-one-time-password-field';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
type OTPProps = {
|
|
3
4
|
error?: string | null;
|
|
5
|
+
successMessage?: string | null;
|
|
6
|
+
label?: ReactNode;
|
|
4
7
|
passwordLength?: number;
|
|
5
8
|
} & OneTimePasswordFieldProps;
|
|
6
9
|
export declare const OTP: import('react').ForwardRefExoticComponent<Omit<OTPProps, "ref"> & import('react').RefAttributes<HTMLInputElement[]>>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsxs as f, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { OneTimePasswordField as T, OneTimePasswordFieldInput as y, OneTimePasswordFieldHiddenInput as I } from "@radix-ui/react-one-time-password-field";
|
|
3
|
+
import { forwardRef as N, useId as s, useMemo as v, useRef as w, useEffect as $ } from "react";
|
|
4
|
+
import { Input as j } from "../Input/index.js";
|
|
5
|
+
import { Label as R } from "../Label/index.js";
|
|
6
|
+
import { Error as F } from "../../ui/Error/index.js";
|
|
7
|
+
import { SuccessMessage as x } from "../../ui/SuccessMessage/index.js";
|
|
8
|
+
import '../../../assets/OTP.css';const A = "OTP-module__otp___UjnM8", B = "OTP-module__input___Vbd5m", E = "OTP-module__label___cK41n", o = {
|
|
9
|
+
otp: A,
|
|
10
|
+
"group-container": "OTP-module__group-container___hNqnB",
|
|
11
|
+
"input-container": "OTP-module__input-container___snmj7",
|
|
12
|
+
input: B,
|
|
13
|
+
label: E
|
|
14
|
+
}, q = N(
|
|
15
|
+
({ error: n, successMessage: i, passwordLength: d = 6, className: b = "", label: l, ...m }, r) => {
|
|
16
|
+
const c = s(), p = s(), _ = s(), h = v(() => {
|
|
17
|
+
if (n)
|
|
18
|
+
return c;
|
|
19
|
+
if (i)
|
|
20
|
+
return p;
|
|
21
|
+
}, [n, c, i, p]), u = w(/* @__PURE__ */ new Map()), O = (e, a) => {
|
|
22
|
+
e ? u.current.set(a, e) : u.current.delete(a);
|
|
23
|
+
};
|
|
24
|
+
return $(() => {
|
|
25
|
+
const e = Array.from(u.current.values());
|
|
26
|
+
typeof r == "function" ? r(e) : r && (r.current = e);
|
|
27
|
+
}, [d, r]), /* @__PURE__ */ f("div", { className: `${o.otp} ${b}`, children: [
|
|
28
|
+
l && /* @__PURE__ */ t(R, { as: "p", id: _, className: o.label, "data-part": "label", children: l }),
|
|
29
|
+
/* @__PURE__ */ f(
|
|
30
|
+
T,
|
|
31
|
+
{
|
|
32
|
+
...m,
|
|
33
|
+
className: o["group-container"],
|
|
34
|
+
"data-part": "input-group",
|
|
35
|
+
"aria-invalid": !!n,
|
|
36
|
+
"aria-describedby": h,
|
|
37
|
+
"aria-labelledby": l ? _ : void 0,
|
|
38
|
+
style: {
|
|
39
|
+
"--cdp-web-otp-input-width": `${Math.floor(100 / d)}%`
|
|
40
|
+
},
|
|
41
|
+
children: [
|
|
42
|
+
Array.from({ length: d }, (e, a) => /* @__PURE__ */ t("div", { className: o["input-container"], "data-part": "input-container", children: /* @__PURE__ */ t(y, { asChild: !0, children: /* @__PURE__ */ t(
|
|
43
|
+
j,
|
|
44
|
+
{
|
|
45
|
+
name: `${m.name || "otp"}-${a}`,
|
|
46
|
+
ref: (P) => O(P, a),
|
|
47
|
+
className: o.input,
|
|
48
|
+
"aria-invalid": !!n,
|
|
49
|
+
"data-part": "input",
|
|
50
|
+
"data-success": !!i
|
|
51
|
+
}
|
|
52
|
+
) }) }, a)),
|
|
53
|
+
/* @__PURE__ */ t(I, {})
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
!!n && /* @__PURE__ */ t(F, { id: c, "data-part": "error", children: n }),
|
|
58
|
+
!!i && /* @__PURE__ */ t(x, { id: p, "data-part": "success", children: i })
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
q.displayName = "OTP";
|
|
63
|
+
export {
|
|
64
|
+
q as OTP
|
|
65
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { APIError } from '@coinbase/cdp-hooks';
|
|
2
|
+
import { FormHTMLAttributes, Ref } from 'react';
|
|
3
|
+
export interface OTPFormProps extends Omit<FormHTMLAttributes<HTMLFormElement>, "children"> {
|
|
4
|
+
canResetOTP?: boolean;
|
|
5
|
+
error?: string | APIError;
|
|
6
|
+
isPending?: boolean;
|
|
7
|
+
onClearServerErrors?: () => void;
|
|
8
|
+
onOTPChange?: (value: string) => void;
|
|
9
|
+
onResendOTP?: () => void;
|
|
10
|
+
otp?: string;
|
|
11
|
+
otpInputsRef?: Ref<HTMLInputElement[]>;
|
|
12
|
+
passwordLength?: number;
|
|
13
|
+
resendCountdown?: number | null;
|
|
14
|
+
successMessage?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const OTPForm: ({ canResetOTP, error, isPending, onOTPChange, onResendOTP, otp, otpInputsRef, passwordLength, resendCountdown, successMessage, ...props }: OTPFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import "@coinbase/cdp-hooks";
|
|
3
|
+
import { Form as u, FormSubmit as h } from "@radix-ui/react-form";
|
|
4
|
+
import "react";
|
|
5
|
+
import { OTP as v } from "../OTP/index.js";
|
|
6
|
+
import { Button as F } from "../../ui/Button/index.js";
|
|
7
|
+
import { LoadingSpinner as N } from "../../ui/LoadingSpinner/index.js";
|
|
8
|
+
import { VisuallyHidden as g } from "../../ui/VisuallyHidden/index.js";
|
|
9
|
+
import { isApiError as b } from "../../../utils/isApiError.js";
|
|
10
|
+
import '../../../assets/OTPForm.css';const o = {
|
|
11
|
+
"otp-form": "OTPForm-module__otp-form___G1-63",
|
|
12
|
+
"form-footer": "OTPForm-module__form-footer___ybmdd",
|
|
13
|
+
"server-state-wrapper": "OTPForm-module__server-state-wrapper___R5j5k",
|
|
14
|
+
"loading-spinner": "OTPForm-module__loading-spinner___8N9XU",
|
|
15
|
+
"resend-wrapper": "OTPForm-module__resend-wrapper___aZUAz",
|
|
16
|
+
"reset-timer": "OTPForm-module__reset-timer___7ElWj"
|
|
17
|
+
}, S = ({
|
|
18
|
+
canResetOTP: m,
|
|
19
|
+
error: a,
|
|
20
|
+
isPending: t,
|
|
21
|
+
onOTPChange: s,
|
|
22
|
+
onResendOTP: l,
|
|
23
|
+
otp: p,
|
|
24
|
+
otpInputsRef: d,
|
|
25
|
+
passwordLength: n,
|
|
26
|
+
resendCountdown: i,
|
|
27
|
+
successMessage: _,
|
|
28
|
+
...c
|
|
29
|
+
}) => /* @__PURE__ */ r(u, { ...c, children: [
|
|
30
|
+
/* @__PURE__ */ e(
|
|
31
|
+
v,
|
|
32
|
+
{
|
|
33
|
+
ref: d,
|
|
34
|
+
name: "otp",
|
|
35
|
+
"aria-label": "Enter code",
|
|
36
|
+
autoSubmit: !0,
|
|
37
|
+
passwordLength: n || 6,
|
|
38
|
+
value: p,
|
|
39
|
+
error: b(a) ? a.message : a,
|
|
40
|
+
onChange: (f) => f.preventDefault(),
|
|
41
|
+
onValueChange: s,
|
|
42
|
+
className: o["otp-form"],
|
|
43
|
+
successMessage: _
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ r("div", { className: o["form-footer"], children: [
|
|
47
|
+
t && !m && /* @__PURE__ */ e("div", { className: o["server-state-wrapper"], children: t && !m && /* @__PURE__ */ e(N, { className: o["loading-spinner"] }) }),
|
|
48
|
+
/* @__PURE__ */ r("div", { className: o["resend-wrapper"], children: [
|
|
49
|
+
m && /* @__PURE__ */ e(h, { asChild: !0, children: /* @__PURE__ */ e(
|
|
50
|
+
F,
|
|
51
|
+
{
|
|
52
|
+
type: "button",
|
|
53
|
+
onClick: l,
|
|
54
|
+
isPending: t,
|
|
55
|
+
variant: "linkPrimary",
|
|
56
|
+
children: "Resend code"
|
|
57
|
+
}
|
|
58
|
+
) }),
|
|
59
|
+
!m && i !== null && /* @__PURE__ */ e("div", { className: o["reset-timer"], children: /* @__PURE__ */ r("p", { children: [
|
|
60
|
+
"Resend code in ",
|
|
61
|
+
/* @__PURE__ */ r("span", { "aria-hidden": "true", children: [
|
|
62
|
+
i,
|
|
63
|
+
"s"
|
|
64
|
+
] }),
|
|
65
|
+
/* @__PURE__ */ r(g, { children: [
|
|
66
|
+
i,
|
|
67
|
+
" ",
|
|
68
|
+
i === 1 ? "second" : "seconds"
|
|
69
|
+
] })
|
|
70
|
+
] }) })
|
|
71
|
+
] })
|
|
72
|
+
] })
|
|
73
|
+
] });
|
|
74
|
+
export {
|
|
75
|
+
S as OTPForm
|
|
76
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { APIError } from '@coinbase/cdp-hooks';
|
|
2
|
+
import { FormHTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
import { PhoneNumberInputProps } from '../PhoneNumberInput/PhoneNumberInput';
|
|
4
|
+
export interface PhoneNumberFormProps extends Omit<FormHTMLAttributes<HTMLFormElement>, "children"> {
|
|
5
|
+
countryCode: PhoneNumberInputProps["countryCode"];
|
|
6
|
+
error?: string | APIError;
|
|
7
|
+
isPending?: boolean;
|
|
8
|
+
onClearServerErrors?: () => void;
|
|
9
|
+
onCountryCodeChange: PhoneNumberInputProps["onCountryCodeChange"];
|
|
10
|
+
onPhoneNumberChange: PhoneNumberInputProps["onPhoneNumberChange"];
|
|
11
|
+
phoneNumber: PhoneNumberInputProps["phoneNumber"];
|
|
12
|
+
submitLabel?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare const PhoneNumberForm: ({ className, countryCode, error, isPending, onCountryCodeChange, onPhoneNumberChange, phoneNumber, submitLabel, ...props }: PhoneNumberFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsxs as _, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import "@coinbase/cdp-hooks";
|
|
3
|
+
import { Form as g, FormSubmit as F } from "@radix-ui/react-form";
|
|
4
|
+
import { useMemo as I } from "react";
|
|
5
|
+
import { Field as E } from "../Field/index.js";
|
|
6
|
+
import { PhoneNumberInput as S } from "../PhoneNumberInput/index.js";
|
|
7
|
+
import { Button as x } from "../../ui/Button/index.js";
|
|
8
|
+
import { ServerError as C } from "../../ui/ServerError/index.js";
|
|
9
|
+
import { usePhoneNumberValidators as M } from "../../../hooks/usePhoneNumberValidators.js";
|
|
10
|
+
import '../../../assets/PhoneNumberForm.css';const U = "PhoneNumberForm-module__form___ExO8G", s = {
|
|
11
|
+
form: U,
|
|
12
|
+
"server-error": "PhoneNumberForm-module__server-error___AQcMg"
|
|
13
|
+
}, G = ({
|
|
14
|
+
className: t = "",
|
|
15
|
+
countryCode: n = "US",
|
|
16
|
+
error: r,
|
|
17
|
+
isPending: u,
|
|
18
|
+
onCountryCodeChange: l,
|
|
19
|
+
onPhoneNumberChange: a,
|
|
20
|
+
phoneNumber: h,
|
|
21
|
+
submitLabel: d = "Continue",
|
|
22
|
+
...p
|
|
23
|
+
}) => {
|
|
24
|
+
const {
|
|
25
|
+
isInvalidCountry: v,
|
|
26
|
+
isInvalidLength: b,
|
|
27
|
+
isInvalidNumber: c,
|
|
28
|
+
isInvalidTooShort: f,
|
|
29
|
+
isInvalidTooLong: P,
|
|
30
|
+
isInvalidPhoneNumberError: i
|
|
31
|
+
} = M({ countryCode: n }), o = I(() => r && i(r) ? "Use a valid phone number" : "", [r, i]), N = !!r && !o;
|
|
32
|
+
return /* @__PURE__ */ _(g, { className: `${s.form} ${t}`, ...p, children: [
|
|
33
|
+
/* @__PURE__ */ e(
|
|
34
|
+
E,
|
|
35
|
+
{
|
|
36
|
+
label: "Phone number",
|
|
37
|
+
name: "phone",
|
|
38
|
+
inlineError: o,
|
|
39
|
+
validators: [
|
|
40
|
+
["valueMissing", "Phone number is required"],
|
|
41
|
+
["typeMismatch", "Use a valid phone number"],
|
|
42
|
+
[c, "Use a valid phone number"],
|
|
43
|
+
[v, "Country is not supported"],
|
|
44
|
+
[f, "Phone number is too short"],
|
|
45
|
+
[P, "Phone number is too long"],
|
|
46
|
+
[b, "Phone number is the wrong length"]
|
|
47
|
+
],
|
|
48
|
+
children: (m) => /* @__PURE__ */ e(
|
|
49
|
+
S,
|
|
50
|
+
{
|
|
51
|
+
"aria-invalid": !(m === void 0 || m.valid) || !!o,
|
|
52
|
+
autoComplete: "tel-national",
|
|
53
|
+
phoneNumber: h,
|
|
54
|
+
onPhoneNumberChange: a,
|
|
55
|
+
countryCode: n,
|
|
56
|
+
onCountryCodeChange: l,
|
|
57
|
+
required: !0
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
N && /* @__PURE__ */ e(C, { error: r, className: s["server-error"] }),
|
|
63
|
+
/* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(x, { type: "submit", isPending: u, children: d }) })
|
|
64
|
+
] });
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
G as PhoneNumberForm
|
|
68
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CountryCode } from 'libphonenumber-js';
|
|
2
|
+
import { InputHTMLAttributes } from 'react';
|
|
3
|
+
import { PhoneNumber } from '../../../utils/parseValuesFromPhoneNumber';
|
|
4
|
+
export interface PhoneNumberInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "onChange"> {
|
|
5
|
+
onCountryCodeChange: (newCountry: CountryCode) => void;
|
|
6
|
+
countryCode?: CountryCode;
|
|
7
|
+
onPhoneNumberChange: (phoneNumber: PhoneNumber) => void;
|
|
8
|
+
phoneNumber: PhoneNumber;
|
|
9
|
+
}
|
|
10
|
+
export declare const PhoneNumberInput: ({ autoComplete, className, countryCode, onCountryCodeChange, onPhoneNumberChange, phoneNumber, ...props }: PhoneNumberInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsxs as o, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import "libphonenumber-js";
|
|
3
|
+
import { useCallback as f, useEffect as y } from "react";
|
|
4
|
+
import { Input as C } from "../Input/index.js";
|
|
5
|
+
import { VisuallyHidden as x } from "../../ui/VisuallyHidden/index.js";
|
|
6
|
+
import { countries as D } from "../../../data/countries.js";
|
|
7
|
+
import { usePhoneNumberFormatter as $ } from "./usePhoneNumberFormatter.js";
|
|
8
|
+
import '../../../assets/PhoneNumberInput.css';const j = "PhoneNumberInput-module__invalid___zDA2p", V = "PhoneNumberInput-module__success___uPjMx", z = "PhoneNumberInput-module__input___H-XG-", l = {
|
|
9
|
+
"phone-number-input": "PhoneNumberInput-module__phone-number-input___mYty2",
|
|
10
|
+
invalid: j,
|
|
11
|
+
success: V,
|
|
12
|
+
input: z,
|
|
13
|
+
"country-calling-code": "PhoneNumberInput-module__country-calling-code___N6zDW"
|
|
14
|
+
}, G = ({
|
|
15
|
+
autoComplete: a = "tel-national",
|
|
16
|
+
className: h = "",
|
|
17
|
+
countryCode: s = "US",
|
|
18
|
+
onCountryCodeChange: r,
|
|
19
|
+
onPhoneNumberChange: i,
|
|
20
|
+
phoneNumber: u,
|
|
21
|
+
...t
|
|
22
|
+
}) => {
|
|
23
|
+
const {
|
|
24
|
+
formatBeforePhoneNumberChange: m,
|
|
25
|
+
formatBeforeCountryCodeChange: d,
|
|
26
|
+
placeholder: v,
|
|
27
|
+
formattedDisplayNumber: b
|
|
28
|
+
} = $(u.value, s), g = f(
|
|
29
|
+
(e) => {
|
|
30
|
+
let n = e.target.value.replace(/\D/g, "");
|
|
31
|
+
n === u.value && (n = n.slice(0, -1));
|
|
32
|
+
const P = m(n);
|
|
33
|
+
i?.(P);
|
|
34
|
+
},
|
|
35
|
+
[m, i, u]
|
|
36
|
+
), _ = f(
|
|
37
|
+
(e) => {
|
|
38
|
+
const n = d(e);
|
|
39
|
+
r(e), i?.(n);
|
|
40
|
+
},
|
|
41
|
+
[d, r, i]
|
|
42
|
+
), p = D.find((e) => e.code === s), N = t["aria-invalid"] && t["aria-invalid"] !== "false", I = t["data-success"] && t["data-success"] !== "false";
|
|
43
|
+
return y(() => {
|
|
44
|
+
_(s);
|
|
45
|
+
}, [s, _]), /* @__PURE__ */ o(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
className: `${l["phone-number-input"]} ${N ? l.invalid : ""} ${I ? l.success : ""} ${h}`,
|
|
49
|
+
children: [
|
|
50
|
+
p && /* @__PURE__ */ c(B, { country: p }),
|
|
51
|
+
/* @__PURE__ */ c(
|
|
52
|
+
C,
|
|
53
|
+
{
|
|
54
|
+
...t,
|
|
55
|
+
className: l.input,
|
|
56
|
+
autoComplete: a,
|
|
57
|
+
onChange: g,
|
|
58
|
+
placeholder: v,
|
|
59
|
+
type: "tel",
|
|
60
|
+
value: b
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}, B = ({ country: a }) => /* @__PURE__ */ o("span", { className: l["country-calling-code"], children: [
|
|
67
|
+
/* @__PURE__ */ c("span", { "aria-hidden": "true", children: a.flag }),
|
|
68
|
+
/* @__PURE__ */ c(x, { children: a.name }),
|
|
69
|
+
/* @__PURE__ */ o("span", { children: [
|
|
70
|
+
"+",
|
|
71
|
+
a.callingCode
|
|
72
|
+
] })
|
|
73
|
+
] });
|
|
74
|
+
export {
|
|
75
|
+
G as PhoneNumberInput
|
|
76
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CountryCode } from 'libphonenumber-js';
|
|
2
|
+
type MaskFormatOverride = {
|
|
3
|
+
prefix?: string;
|
|
4
|
+
maxLength?: number;
|
|
5
|
+
normalizer?: (value: string) => string;
|
|
6
|
+
};
|
|
7
|
+
export declare const getMaskOverride: (countryCode?: CountryCode) => MaskFormatOverride;
|
|
8
|
+
export {};
|