@coinbase/cdp-react 0.0.19 → 0.0.21
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 -1
- 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 -1
- 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 -1
- package/dist/assets/PhoneNumberForm.css +1 -1
- package/dist/assets/PhoneNumberInput.css +1 -1
- package/dist/assets/SignInAuthMethodButtons.css +1 -1
- package/dist/assets/SignInModal.css +1 -1
- package/dist/assets/SuccessMessage.css +1 -1
- package/dist/assets/SwitchFadeTransition.css +1 -1
- package/dist/assets/SwitchSlideTransition.css +1 -1
- package/dist/assets/SwitchTransition.css +1 -1
- package/dist/assets/ThemeProvider.css +1 -1
- package/dist/assets/VisuallyHidden.css +1 -1
- package/dist/components/AuthButton/index.js +6 -6
- package/dist/components/SendTransactionButton/index.js +1 -1
- package/dist/components/SignIn/SignInAuthMethodButtons.js +21 -19
- package/dist/components/SignIn/SignInBackButton.js +1 -1
- package/dist/components/SignIn/SignInForm.d.ts +1 -1
- package/dist/components/SignIn/SignInForm.js +21 -15
- package/dist/components/SignIn/flows/SignInWithEmail.d.ts +1 -0
- package/dist/components/SignIn/flows/SignInWithEmail.js +68 -51
- package/dist/components/SignIn/flows/SignInWithSms.d.ts +3 -0
- package/dist/components/SignIn/flows/SignInWithSms.js +519 -502
- package/dist/components/SignInModal/index.js +48 -55
- package/dist/components/SignOutButton/index.js +1 -1
- package/dist/components/ThemeProvider/index.js +1 -1
- package/dist/components/{EmailForm → forms/EmailForm}/index.js +10 -10
- package/dist/components/forms/Field/index.js +24 -0
- package/dist/components/{Input → forms/Input}/index.js +1 -1
- package/dist/components/{Label → forms/Label}/index.js +1 -1
- package/dist/components/forms/OTP/index.js +65 -0
- package/dist/components/{OTPForm → forms/OTPForm}/index.js +28 -28
- package/dist/components/{PhoneNumberForm → forms/PhoneNumberForm}/index.js +19 -19
- package/dist/components/{PhoneNumberInput → forms/PhoneNumberInput}/index.d.ts +1 -1
- package/dist/components/forms/PhoneNumberInput/index.js +76 -0
- package/dist/components/{PhoneNumberInput → forms/PhoneNumberInput}/maskOverride.js +1 -1
- package/dist/components/{PhoneNumberInput → forms/PhoneNumberInput}/usePhoneNumberFormatter.d.ts +2 -2
- package/dist/components/{PhoneNumberInput → forms/PhoneNumberInput}/usePhoneNumberFormatter.js +1 -1
- package/dist/components/{Button → ui/Button}/index.d.ts +1 -1
- package/dist/components/{Button → ui/Button}/index.js +20 -20
- 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 +1 -1
- package/dist/components/ui/SuccessMessage/index.js +16 -0
- package/dist/components/{SwitchFadeTransition → ui/SwitchFadeTransition}/index.js +2 -2
- package/dist/components/{SwitchSlideTransition → ui/SwitchSlideTransition}/index.js +2 -2
- package/dist/components/{SwitchTransition → ui/SwitchTransition}/index.d.ts +1 -1
- package/dist/components/{SwitchTransition → ui/SwitchTransition}/index.js +27 -27
- package/dist/components/{VisuallyHidden → ui/VisuallyHidden}/index.js +2 -2
- package/dist/theme/theme.d.ts +1 -1
- package/dist/theme/tokens.d.ts +2 -2
- package/dist/theme/tokens.js +1 -1
- package/package.json +17 -5
- package/dist/assets/FlowEmailOTP.css +0 -1
- package/dist/assets/FlowPhoneNumberOTP.css +0 -1
- package/dist/components/Error/index.js +0 -16
- package/dist/components/Field/index.js +0 -24
- package/dist/components/FlowEmailOTP/index.d.ts +0 -18
- package/dist/components/FlowEmailOTP/index.js +0 -70
- package/dist/components/FlowPhoneNumberOTP/index.d.ts +0 -18
- package/dist/components/FlowPhoneNumberOTP/index.js +0 -75
- package/dist/components/LoadingSkeleton/index.js +0 -19
- package/dist/components/OTP/index.js +0 -65
- package/dist/components/PhoneNumberInput/index.js +0 -76
- package/dist/components/SuccessMessage/index.js +0 -16
- package/dist/utils/validatePhoneNumber.d.ts +0 -1
- package/dist/utils/validatePhoneNumber.js +0 -1
- /package/dist/components/{EmailForm → forms/EmailForm}/index.d.ts +0 -0
- /package/dist/components/{Field → forms/Field}/index.d.ts +0 -0
- /package/dist/components/{Input → forms/Input}/index.d.ts +0 -0
- /package/dist/components/{Label → forms/Label}/index.d.ts +0 -0
- /package/dist/components/{OTP → forms/OTP}/index.d.ts +0 -0
- /package/dist/components/{OTPForm → forms/OTPForm}/index.d.ts +0 -0
- /package/dist/components/{PhoneNumberForm → forms/PhoneNumberForm}/index.d.ts +0 -0
- /package/dist/components/{PhoneNumberInput → forms/PhoneNumberInput}/PhoneNumberMetadata.d.ts +0 -0
- /package/dist/components/{PhoneNumberInput → forms/PhoneNumberInput}/PhoneNumberMetadata.js +0 -0
- /package/dist/components/{PhoneNumberInput → forms/PhoneNumberInput}/maskOverride.d.ts +0 -0
- /package/dist/components/{Error → ui/Error}/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/{SuccessMessage → ui/SuccessMessage}/index.d.ts +0 -0
- /package/dist/components/{SwitchFadeTransition → ui/SwitchFadeTransition}/index.d.ts +0 -0
- /package/dist/components/{SwitchSlideTransition → ui/SwitchSlideTransition}/index.d.ts +0 -0
- /package/dist/components/{VisuallyHidden → ui/VisuallyHidden}/index.d.ts +0 -0
|
@@ -1,69 +1,62 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Dialog as f, DialogTrigger as I, DialogPortal as S, DialogOverlay as M, DialogContent as v, DialogClose as b, DialogTitle as D, DialogDescription as N } 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 { VisuallyHidden as
|
|
9
|
-
import { IconXMark as
|
|
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";
|
|
10
9
|
import { SignInBackButton as k } from "../SignIn/SignInBackButton.js";
|
|
11
|
-
import { SignInImage as
|
|
12
|
-
import { SignInForm as
|
|
10
|
+
import { SignInImage as x } from "../SignIn/SignInImage.js";
|
|
11
|
+
import { SignInForm as B } from "../SignIn/SignInForm.js";
|
|
13
12
|
import { SignInTitle as l } from "../SignIn/SignInTitle.js";
|
|
14
|
-
import { SignInDescription as
|
|
15
|
-
import { SignInAuthMethodButtons as
|
|
16
|
-
import { SignInFooter as
|
|
17
|
-
import '../../assets/SignInModal.css';const
|
|
18
|
-
trigger:
|
|
19
|
-
modal: V,
|
|
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,
|
|
20
18
|
"sign-in": "SignInModal-module__sign-in___n05-5",
|
|
21
19
|
"no-footer": "SignInModal-module__no-footer___meSt1",
|
|
22
20
|
"title-desc-wrapper": "SignInModal-module__title-desc-wrapper___--XLa",
|
|
23
21
|
"sign-in-form": "SignInModal-module__sign-in-form___Jzx1-",
|
|
24
22
|
"sign-in-image": "SignInModal-module__sign-in-image___DGg7B",
|
|
25
|
-
footer:
|
|
26
|
-
buttons:
|
|
23
|
+
footer: F,
|
|
24
|
+
buttons: T,
|
|
27
25
|
"back-button": "SignInModal-module__back-button___nMh2-",
|
|
28
|
-
"close-icon": "SignInModal-module__close-icon___b-gMh"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
47
|
] }),
|
|
48
|
-
/* @__PURE__ */ n("div", { className:
|
|
49
|
-
/* @__PURE__ */ n(w, {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
r === "credentials" && /* @__PURE__ */ n(F, { activeMethod: e })
|
|
56
|
-
] }) }),
|
|
57
|
-
d && /* @__PURE__ */ n(j, { className: o.footer })
|
|
58
|
-
] })
|
|
59
|
-
}
|
|
60
|
-
) })
|
|
61
|
-
] }) })
|
|
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
|
+
) })
|
|
62
55
|
] });
|
|
63
|
-
},
|
|
64
|
-
/* @__PURE__ */ n(
|
|
65
|
-
/* @__PURE__ */ n(
|
|
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" }) })
|
|
66
59
|
] });
|
|
67
60
|
export {
|
|
68
|
-
|
|
61
|
+
R as SignInModal
|
|
69
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 = {
|
|
@@ -2,14 +2,14 @@ import { jsxs as u, jsx as r } from "react/jsx-runtime";
|
|
|
2
2
|
import "@coinbase/cdp-hooks";
|
|
3
3
|
import { Form as c, FormSubmit as v } from "@radix-ui/react-form";
|
|
4
4
|
import "react";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { ServerError as E } from "
|
|
9
|
-
import { isEmailInvalid as F } from "
|
|
10
|
-
import '
|
|
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
11
|
form: x,
|
|
12
|
-
"server-error": "EmailForm-module__server-
|
|
12
|
+
"server-error": "EmailForm-module__server-error___0TSPx"
|
|
13
13
|
}, N = ({
|
|
14
14
|
className: a = "",
|
|
15
15
|
email: t,
|
|
@@ -29,7 +29,7 @@ import '../../assets/EmailForm.css';const x = "EmailForm-module__form___MD6xv",
|
|
|
29
29
|
};
|
|
30
30
|
return /* @__PURE__ */ u(c, { className: `${o.form} ${a}`, ...d, children: [
|
|
31
31
|
/* @__PURE__ */ r(
|
|
32
|
-
|
|
32
|
+
f,
|
|
33
33
|
{
|
|
34
34
|
label: "Email address",
|
|
35
35
|
name: "email",
|
|
@@ -38,7 +38,7 @@ import '../../assets/EmailForm.css';const x = "EmailForm-module__form___MD6xv",
|
|
|
38
38
|
["typeMismatch", "Use a valid email address"],
|
|
39
39
|
[F, "Use a valid email address"]
|
|
40
40
|
],
|
|
41
|
-
children:
|
|
41
|
+
children: h(
|
|
42
42
|
m !== void 0 ? {
|
|
43
43
|
...i,
|
|
44
44
|
value: t,
|
|
@@ -48,7 +48,7 @@ import '../../assets/EmailForm.css';const x = "EmailForm-module__form___MD6xv",
|
|
|
48
48
|
}
|
|
49
49
|
),
|
|
50
50
|
e && /* @__PURE__ */ r(E, { error: e, className: o["server-error"] }),
|
|
51
|
-
/* @__PURE__ */ r(v, { asChild: !0, children: /* @__PURE__ */ r(
|
|
51
|
+
/* @__PURE__ */ r(v, { asChild: !0, children: /* @__PURE__ */ r(_, { type: "submit", isPending: l, children: s }) })
|
|
52
52
|
] });
|
|
53
53
|
};
|
|
54
54
|
export {
|
|
@@ -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 })
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import '
|
|
3
|
+
import '../../../assets/Label.css';const t = "Label-module__label___jDumT", b = {
|
|
4
4
|
label: t
|
|
5
5
|
}, _ = ({
|
|
6
6
|
as: l = "label",
|
|
@@ -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
|
+
};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import "@coinbase/cdp-hooks";
|
|
3
|
-
import { Form as
|
|
3
|
+
import { Form as u, FormSubmit as h } from "@radix-ui/react-form";
|
|
4
4
|
import "react";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { VisuallyHidden as g } from "
|
|
9
|
-
import { isApiError as
|
|
10
|
-
import '
|
|
11
|
-
"otp-form": "OTPForm-module__otp-
|
|
12
|
-
"form-footer": "OTPForm-module__form-
|
|
13
|
-
"server-state-wrapper": "OTPForm-module__server-state-
|
|
14
|
-
"loading-spinner": "OTPForm-module__loading-
|
|
15
|
-
"resend-wrapper": "OTPForm-module__resend-
|
|
16
|
-
"reset-timer": "OTPForm-module__reset-
|
|
17
|
-
},
|
|
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
18
|
canResetOTP: m,
|
|
19
|
-
error:
|
|
20
|
-
isPending:
|
|
19
|
+
error: a,
|
|
20
|
+
isPending: t,
|
|
21
21
|
onOTPChange: s,
|
|
22
22
|
onResendOTP: l,
|
|
23
23
|
otp: p,
|
|
24
|
-
otpInputsRef:
|
|
25
|
-
passwordLength:
|
|
24
|
+
otpInputsRef: d,
|
|
25
|
+
passwordLength: n,
|
|
26
26
|
resendCountdown: i,
|
|
27
27
|
successMessage: _,
|
|
28
28
|
...c
|
|
29
|
-
}) => /* @__PURE__ */ r(
|
|
29
|
+
}) => /* @__PURE__ */ r(u, { ...c, children: [
|
|
30
30
|
/* @__PURE__ */ e(
|
|
31
|
-
|
|
31
|
+
v,
|
|
32
32
|
{
|
|
33
|
-
ref:
|
|
33
|
+
ref: d,
|
|
34
34
|
name: "otp",
|
|
35
35
|
"aria-label": "Enter code",
|
|
36
36
|
autoSubmit: !0,
|
|
37
|
-
passwordLength:
|
|
37
|
+
passwordLength: n || 6,
|
|
38
38
|
value: p,
|
|
39
|
-
error:
|
|
39
|
+
error: b(a) ? a.message : a,
|
|
40
40
|
onChange: (f) => f.preventDefault(),
|
|
41
41
|
onValueChange: s,
|
|
42
42
|
className: o["otp-form"],
|
|
@@ -44,14 +44,14 @@ import '../../assets/OTPForm.css';const o = {
|
|
|
44
44
|
}
|
|
45
45
|
),
|
|
46
46
|
/* @__PURE__ */ r("div", { className: o["form-footer"], children: [
|
|
47
|
-
|
|
47
|
+
t && !m && /* @__PURE__ */ e("div", { className: o["server-state-wrapper"], children: t && !m && /* @__PURE__ */ e(N, { className: o["loading-spinner"] }) }),
|
|
48
48
|
/* @__PURE__ */ r("div", { className: o["resend-wrapper"], children: [
|
|
49
|
-
m && /* @__PURE__ */ e(
|
|
50
|
-
|
|
49
|
+
m && /* @__PURE__ */ e(h, { asChild: !0, children: /* @__PURE__ */ e(
|
|
50
|
+
F,
|
|
51
51
|
{
|
|
52
52
|
type: "button",
|
|
53
53
|
onClick: l,
|
|
54
|
-
isPending:
|
|
54
|
+
isPending: t,
|
|
55
55
|
variant: "linkPrimary",
|
|
56
56
|
children: "Resend code"
|
|
57
57
|
}
|
|
@@ -72,5 +72,5 @@ import '../../assets/OTPForm.css';const o = {
|
|
|
72
72
|
] })
|
|
73
73
|
] });
|
|
74
74
|
export {
|
|
75
|
-
|
|
75
|
+
S as OTPForm
|
|
76
76
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsxs as _, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import "@coinbase/cdp-hooks";
|
|
3
|
-
import { Form as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { ServerError as C } from "
|
|
9
|
-
import { usePhoneNumberValidators as
|
|
10
|
-
import '
|
|
11
|
-
form:
|
|
12
|
-
"server-error": "PhoneNumberForm-module__server-
|
|
13
|
-
},
|
|
14
|
-
className:
|
|
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
15
|
countryCode: n = "US",
|
|
16
16
|
error: r,
|
|
17
17
|
isPending: u,
|
|
@@ -28,10 +28,10 @@ import '../../assets/PhoneNumberForm.css';const y = "PhoneNumberForm-module__for
|
|
|
28
28
|
isInvalidTooShort: f,
|
|
29
29
|
isInvalidTooLong: P,
|
|
30
30
|
isInvalidPhoneNumberError: i
|
|
31
|
-
} =
|
|
32
|
-
return /* @__PURE__ */ _(
|
|
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
33
|
/* @__PURE__ */ e(
|
|
34
|
-
|
|
34
|
+
E,
|
|
35
35
|
{
|
|
36
36
|
label: "Phone number",
|
|
37
37
|
name: "phone",
|
|
@@ -46,7 +46,7 @@ import '../../assets/PhoneNumberForm.css';const y = "PhoneNumberForm-module__for
|
|
|
46
46
|
[b, "Phone number is the wrong length"]
|
|
47
47
|
],
|
|
48
48
|
children: (m) => /* @__PURE__ */ e(
|
|
49
|
-
|
|
49
|
+
S,
|
|
50
50
|
{
|
|
51
51
|
"aria-invalid": !(m === void 0 || m.valid) || !!o,
|
|
52
52
|
autoComplete: "tel-national",
|
|
@@ -59,10 +59,10 @@ import '../../assets/PhoneNumberForm.css';const y = "PhoneNumberForm-module__for
|
|
|
59
59
|
)
|
|
60
60
|
}
|
|
61
61
|
),
|
|
62
|
-
N && /* @__PURE__ */ e(C, { error: r, className:
|
|
63
|
-
/* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(
|
|
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
64
|
] });
|
|
65
65
|
};
|
|
66
66
|
export {
|
|
67
|
-
|
|
67
|
+
G as PhoneNumberForm
|
|
68
68
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CountryCode } from 'libphonenumber-js';
|
|
2
2
|
import { InputHTMLAttributes } from 'react';
|
|
3
|
-
import { PhoneNumber } from '
|
|
3
|
+
import { PhoneNumber } from '../../../utils/parseValuesFromPhoneNumber';
|
|
4
4
|
export interface PhoneNumberInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "onChange"> {
|
|
5
5
|
onCountryCodeChange: (newCountry: CountryCode) => void;
|
|
6
6
|
countryCode?: CountryCode;
|
|
@@ -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
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "libphonenumber-js";
|
|
2
|
-
import { nonThrowingGetCountryCallingCode as e } from "
|
|
2
|
+
import { nonThrowingGetCountryCallingCode as e } from "../../../data/countries.js";
|
|
3
3
|
const n = (r) => r.startsWith("1") ? r.slice(1) : r, i = {
|
|
4
4
|
234: {
|
|
5
5
|
/**
|
package/dist/components/{PhoneNumberInput → forms/PhoneNumberInput}/usePhoneNumberFormatter.d.ts
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CountryCode } from 'libphonenumber-js';
|
|
2
2
|
export declare const usePhoneNumberFormatter: (phoneNumber: string, countryCode: CountryCode | undefined) => {
|
|
3
|
-
formatBeforePhoneNumberChange: (inputPhoneNumber: string) => import('
|
|
4
|
-
formatBeforeCountryCodeChange: (newCountryCode: CountryCode) => import('
|
|
3
|
+
formatBeforePhoneNumberChange: (inputPhoneNumber: string) => import('../../../utils/parseValuesFromPhoneNumber').PhoneNumber;
|
|
4
|
+
formatBeforeCountryCodeChange: (newCountryCode: CountryCode) => import('../../../utils/parseValuesFromPhoneNumber').PhoneNumber;
|
|
5
5
|
placeholder: string | undefined;
|
|
6
6
|
formattedDisplayNumber: string;
|
|
7
7
|
};
|
package/dist/components/{PhoneNumberInput → forms/PhoneNumberInput}/usePhoneNumberFormatter.js
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseIncompletePhoneNumber as I, getExampleNumber as l, AsYouType as K } from "libphonenumber-js";
|
|
2
2
|
import { useCallback as S, useMemo as N } from "react";
|
|
3
|
-
import { parseValuesFromPhoneNumber as B } from "
|
|
3
|
+
import { parseValuesFromPhoneNumber as B } from "../../../utils/parseValuesFromPhoneNumber.js";
|
|
4
4
|
import { getMaskOverride as L } from "./maskOverride.js";
|
|
5
5
|
import { PhoneNumberMetadata as G } from "./PhoneNumberMetadata.js";
|
|
6
6
|
const i = { AC: "40123", AD: "312345", AE: "501234567", AF: "701234567", AG: "2684641234", AI: "2642351234", AL: "672123456", AM: "77123456", AO: "923123456", AR: "91123456789", AS: "6847331234", AT: "664123456", AU: "412345678", AW: "5601234", AX: "412345678", AZ: "401234567", BA: "61123456", BB: "2462501234", BD: "1812345678", BE: "470123456", BF: "70123456", BG: "43012345", BH: "36001234", BI: "79561234", BJ: "0195123456", BL: "690001234", BM: "4413701234", BN: "7123456", BO: "71234567", BQ: "3181234", BR: "11961234567", BS: "2423591234", BT: "17123456", BW: "71123456", BY: "294911911", BZ: "6221234", CA: "5062345678", CC: "412345678", CD: "991234567", CF: "70012345", CG: "061234567", CH: "781234567", CI: "0123456789", CK: "71234", CL: "221234567", CM: "671234567", CN: "13123456789", CO: "3211234567", CR: "83123456", CU: "51234567", CV: "9911234", CW: "95181234", CX: "412345678", CY: "96123456", CZ: "601123456", DE: "15123456789", DJ: "77831001", DK: "34412345", DM: "7672251234", DO: "8092345678", DZ: "551234567", EC: "991234567", EE: "51234567", EG: "1001234567", EH: "650123456", ER: "7123456", ES: "612345678", ET: "911234567", FI: "412345678", FJ: "7012345", FK: "51234", FM: "3501234", FO: "211234", FR: "612345678", GA: "06031234", GB: "7400123456", GD: "4734031234", GE: "555123456", GF: "694201234", GG: "7781123456", GH: "231234567", GI: "57123456", GL: "221234", GM: "3012345", GN: "601123456", GP: "690001234", GQ: "222123456", GR: "6912345678", GT: "51234567", GU: "6713001234", GW: "955012345", GY: "6091234", HK: "51234567", HN: "91234567", HR: "921234567", HT: "34101234", HU: "201234567", ID: "812345678", IE: "850123456", IL: "502345678", IM: "7924123456", IN: "8123456789", IO: "3801234", IQ: "7912345678", IR: "9123456789", IS: "6111234", IT: "3123456789", JE: "7797712345", JM: "8762101234", JO: "790123456", JP: "9012345678", KE: "712123456", KG: "700123456", KH: "91234567", KI: "72001234", KM: "3212345", KN: "8697652917", KP: "1921234567", KR: "1020000000", KW: "50012345", KY: "3453231234", KZ: "7710009998", LA: "2023123456", LB: "71123456", LC: "7582845678", LI: "660234567", LK: "712345678", LR: "770123456", LS: "50123456", LT: "61234567", LU: "628123456", LV: "21234567", LY: "912345678", MA: "650123456", MC: "612345678", MD: "62112345", ME: "67622901", MF: "690001234", MG: "321234567", MH: "2351234", MK: "72345678", ML: "65012345", MM: "92123456", MN: "88123456", MO: "66123456", MP: "6702345678", MQ: "696201234", MR: "22123456", MS: "6644923456", MT: "96961234", MU: "52512345", MV: "7712345", MW: "991234567", MX: "2221234567", MY: "123456789", MZ: "821234567", NA: "811234567", NC: "751234", NE: "93123456", NF: "381234", NG: "8021234567", NI: "81234567", NL: "612345678", NO: "40612345", NP: "9841234567", NR: "5551234", NU: "8884012", NZ: "211234567", OM: "92123456", PA: "61234567", PE: "912345678", PF: "87123456", PG: "70123456", PH: "9051234567", PK: "3012345678", PL: "512345678", PM: "551234", PR: "7872345678", PS: "599123456", PT: "912345678", PW: "6201234", PY: "961456789", QA: "33123456", RE: "692123456", RO: "712034567", RS: "601234567", RU: "9123456789", RW: "720123456", SA: "512345678", SB: "7421234", SC: "2510123", SD: "911231234", SE: "701234567", SG: "81234567", SH: "51234", SI: "31234567", SJ: "41234567", SK: "912123456", SL: "25123456", SM: "66661212", SN: "701234567", SO: "71123456", SR: "7412345", SS: "977123456", ST: "9812345", SV: "70123456", SX: "7215205678", SY: "944567890", SZ: "76123456", TA: "8999", TC: "6492311234", TD: "63012345", TG: "90112345", TH: "812345678", TJ: "917123456", TK: "7290", TL: "77212345", TM: "66123456", TN: "20123456", TO: "7715123", TR: "5012345678", TT: "8682911234", TV: "901234", TW: "912345678", TZ: "621234567", UA: "501234567", UG: "712345678", US: "2015550123", UY: "94231234", UZ: "912345678", VA: "3123456789", VC: "7844301234", VE: "4121234567", VG: "2843001234", VI: "3406421234", VN: "912345678", VU: "5912345", WF: "821234", WS: "7212345", XK: "43201234", YE: "712345678", YT: "639012345", ZA: "711234567", ZM: "955123456", ZW: "712345678" }, u = (n, r) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
import { ButtonSize, ButtonVariant } from '
|
|
2
|
+
import { ButtonSize, ButtonVariant } from '../../../theme/theme';
|
|
3
3
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
4
|
isPending?: boolean;
|
|
5
5
|
pendingLabel?: ReactNode;
|