@coinbase/cdp-react 0.0.42 → 0.0.43
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/CountrySelect.css +1 -0
- package/dist/assets/PhoneNumberForm.css +1 -1
- package/dist/assets/PhoneNumberInput.css +1 -1
- package/dist/components/SignIn/flows/SignInWithSms.js +1 -1
- package/dist/components/forms/CountrySelect/index.d.ts +10 -0
- package/dist/components/forms/CountrySelect/index.js +57 -0
- package/dist/components/forms/PhoneNumberForm/index.d.ts +2 -1
- package/dist/components/forms/PhoneNumberForm/index.js +54 -47
- package/dist/components/forms/PhoneNumberInput/index.d.ts +4 -2
- package/dist/components/forms/PhoneNumberInput/index.js +92 -68
- package/dist/components/forms/PhoneNumberInput/maskOverride.js +10 -0
- package/dist/components/ui/SwitchTransition/index.d.ts +2 -2
- package/dist/components/ui/SwitchTransition/index.js +98 -100
- package/dist/data/countries.js +16 -7
- package/dist/data/countryNames.js +11 -2
- package/package.json +8 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.CountrySelect-module__country-select-trigger___xGSAp{--cdp-web-button-ring-inset-color: var(--cdp-web-colors-input-border-default);--cdp-web-button-ring-inset-width: 1px;background-color:var(--cdp-web-colors-input-bg-default);border-radius:var(--cdp-web-borderRadius-input);color:var(--cdp-web-colors-input-text-default);font-family:var(--cdp-web-font-family-input);font-weight:500;text-align:left;justify-content:space-between}.CountrySelect-module__select-icon___wEQVx{transform:rotate(180deg);transition:transform .15s ease-in-out}.CountrySelect-module__country-select-trigger___xGSAp[data-state=open] .CountrySelect-module__select-icon___wEQVx{transform:rotate(0)}.CountrySelect-module__country-select-trigger___xGSAp:focus{outline:none}.CountrySelect-module__country-select-trigger___xGSAp:focus-visible{--cdp-web-button-ring-inset-color: var(--cdp-web-colors-input-border-focus);--cdp-web-button-ring-inset-width: 2px;outline:none}.CountrySelect-module__country-select-content___WSd9-{width:auto}.CountrySelect-module__country-select-item___Mr6JZ{display:flex;align-items:center;gap:.25em}.CountrySelect-module__flag___bNBsn{transform:translateY(.05em)}.CountrySelect-module__country-select-content___WSd9- .CountrySelect-module__country-select-item___Mr6JZ{gap:.5em}.CountrySelect-module__country-calling-code___d61ih{color:var(--cdp-web-colors-select-list-item-text-muted)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.PhoneNumberForm-module__form___ExO8G{display:flex;flex-direction:column;gap:1em}.PhoneNumberForm-module__server-error___AQcMg{justify-content:center}
|
|
1
|
+
.PhoneNumberForm-module__form___ExO8G{display:flex;flex-direction:column;gap:1em}.PhoneNumberForm-module__server-error___AQcMg{justify-content:center}.PhoneNumberForm-module__phone-number-fieldset___0TsSH{border:0;padding:0;margin:0;min-width:0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.PhoneNumberInput-module__phone-number-input___mYty2{--cdp-web-input-ring-width: 1px;--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-default);box-sizing:border-box;display:flex;align-items:stretch;font-family:var(--cdp-web-font-family-input);font-size:var(--cdp-web-font-size-base);line-height:1.5;padding-left:1em;border-radius:var(--cdp-web-borderRadius-input);border:0;background-color:var(--cdp-web-colors-input-bg-default);box-shadow:0 0 0 var(--cdp-web-input-ring-width) var(--cdp-web-input-ring-color) inset;
|
|
1
|
+
.PhoneNumberInput-module__phone-number-input___mYty2{--cdp-web-input-ring-width: 1px;--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-default);box-sizing:border-box;display:flex;gap:.5em;align-items:stretch;font-family:var(--cdp-web-font-family-input);font-size:var(--cdp-web-font-size-base);line-height:1.5;color:var(--cdp-web-colors-input-text-default);transition:box-shadow .15s ease-in-out;width:100%}.PhoneNumberInput-module__phone-number-input___mYty2.PhoneNumberInput-module__inline-country-calling-code___FFgtI{padding-left:1em;border-radius:var(--cdp-web-borderRadius-input);border:0;background-color:var(--cdp-web-colors-input-bg-default);box-shadow:0 0 0 var(--cdp-web-input-ring-width) var(--cdp-web-input-ring-color) inset;gap:0}.PhoneNumberInput-module__phone-number-input___mYty2.PhoneNumberInput-module__invalid___zDA2p,.PhoneNumberInput-module__phone-number-input___mYty2:focus-within.PhoneNumberInput-module__invalid___zDA2p{--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-error)}.PhoneNumberInput-module__phone-number-input___mYty2.PhoneNumberInput-module__success___uPjMx{--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-success)}.PhoneNumberInput-module__phone-number-input___mYty2:focus-within{--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-focus);--cdp-web-input-ring-width: 2px}.PhoneNumberInput-module__phone-number-input___mYty2.PhoneNumberInput-module__inline-country-calling-code___FFgtI .PhoneNumberInput-module__input___H-XG-{--cdp-web-input-ring-width: 0px;background-color:transparent;padding-left:.75em}.PhoneNumberInput-module__country-calling-code___N6zDW{display:flex;align-items:center;gap:.25em}
|
|
@@ -2942,7 +2942,7 @@ const Sd = ["phoneNumber", "otp"], Fd = ({ step: e, onSuccess: r, children: t })
|
|
|
2942
2942
|
}, [f]), /* @__PURE__ */ S(
|
|
2943
2943
|
be,
|
|
2944
2944
|
{
|
|
2945
|
-
autoFocus:
|
|
2945
|
+
autoFocus: "input[type='tel']",
|
|
2946
2946
|
animateHeight: !1,
|
|
2947
2947
|
items: Sd,
|
|
2948
2948
|
initialEntered: !0,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CountryCode } from '../../../data/countries';
|
|
2
|
+
import { InputSize } from '../../../theme/theme';
|
|
3
|
+
export interface CountrySelectProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
size?: InputSize;
|
|
6
|
+
defaultValue?: CountryCode;
|
|
7
|
+
value?: CountryCode;
|
|
8
|
+
onValueChange?: (value: CountryCode) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const CountrySelect: ({ className, size, defaultValue, value, onValueChange, }: CountrySelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsxs as l, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { SelectValue as m, SelectIcon as u } from "@radix-ui/react-select";
|
|
3
|
+
import { Select as _, SelectTrigger as y, SelectContent as g, SelectItem as h } from "../Select/index.js";
|
|
4
|
+
import { ButtonBase as p } from "../../ui/ButtonBase/index.js";
|
|
5
|
+
import { VisuallyHidden as C } from "../../ui/VisuallyHidden/index.js";
|
|
6
|
+
import { countries as s } from "../../../data/countries.js";
|
|
7
|
+
import { IconChevronDown as S } from "../../../icons/IconChevronDown.js";
|
|
8
|
+
import "../../../theme/theme.js";
|
|
9
|
+
import '../../../assets/CountrySelect.css';const f = "CountrySelect-module__flag___bNBsn", c = {
|
|
10
|
+
"country-select-trigger": "CountrySelect-module__country-select-trigger___xGSAp",
|
|
11
|
+
"select-icon": "CountrySelect-module__select-icon___wEQVx",
|
|
12
|
+
"country-select-content": "CountrySelect-module__country-select-content___WSd9-",
|
|
13
|
+
"country-select-item": "CountrySelect-module__country-select-item___Mr6JZ",
|
|
14
|
+
flag: f,
|
|
15
|
+
"country-calling-code": "CountrySelect-module__country-calling-code___d61ih"
|
|
16
|
+
}, N = s.sort((r, o) => r.name.localeCompare(o.name)), v = ({
|
|
17
|
+
className: r = "",
|
|
18
|
+
size: o,
|
|
19
|
+
defaultValue: a,
|
|
20
|
+
value: i,
|
|
21
|
+
onValueChange: d
|
|
22
|
+
}) => {
|
|
23
|
+
const n = s.find((t) => t.code === (i ?? a));
|
|
24
|
+
return /* @__PURE__ */ l(
|
|
25
|
+
_,
|
|
26
|
+
{
|
|
27
|
+
name: "country-code",
|
|
28
|
+
defaultValue: a,
|
|
29
|
+
value: i,
|
|
30
|
+
onValueChange: d,
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ e(y, { "aria-label": "Country / region", placeholder: "+1", children: /* @__PURE__ */ l(p, { className: `${c["country-select-trigger"]} ${r}`, size: o, children: [
|
|
33
|
+
/* @__PURE__ */ e(m, { "aria-label": n?.name ?? "Select a country", children: n && /* @__PURE__ */ l("span", { className: c["country-select-item"], children: [
|
|
34
|
+
/* @__PURE__ */ e("span", { "aria-hidden": "true", className: c.flag, children: n.flag }),
|
|
35
|
+
/* @__PURE__ */ e(C, { children: n.name }),
|
|
36
|
+
/* @__PURE__ */ l("span", { children: [
|
|
37
|
+
"+",
|
|
38
|
+
n.callingCode
|
|
39
|
+
] })
|
|
40
|
+
] }) }),
|
|
41
|
+
/* @__PURE__ */ e(u, { asChild: !0, children: /* @__PURE__ */ e(S, { className: c["select-icon"] }) })
|
|
42
|
+
] }) }),
|
|
43
|
+
/* @__PURE__ */ e(g, { className: c["country-select-content"], children: N.map((t) => /* @__PURE__ */ e(h, { indicator: !0, value: t.code, children: /* @__PURE__ */ l("span", { className: c["country-select-item"], children: [
|
|
44
|
+
/* @__PURE__ */ e("span", { "aria-hidden": "true", className: c.flag, children: t.flag }),
|
|
45
|
+
/* @__PURE__ */ e("span", { children: t.name }),
|
|
46
|
+
/* @__PURE__ */ l("span", { className: c["country-calling-code"], children: [
|
|
47
|
+
"+",
|
|
48
|
+
t.callingCode
|
|
49
|
+
] })
|
|
50
|
+
] }) }, t.code)) })
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
v as CountrySelect
|
|
57
|
+
};
|
|
@@ -3,6 +3,7 @@ import { FormHTMLAttributes, ReactNode } from 'react';
|
|
|
3
3
|
import { PhoneNumberInputProps } from '../PhoneNumberInput/PhoneNumberInput';
|
|
4
4
|
export interface PhoneNumberFormProps extends Omit<FormHTMLAttributes<HTMLFormElement>, "children"> {
|
|
5
5
|
countryCode: PhoneNumberInputProps["countryCode"];
|
|
6
|
+
countryOptions?: PhoneNumberInputProps["countryOptions"];
|
|
6
7
|
error?: string | APIError;
|
|
7
8
|
isPending?: boolean;
|
|
8
9
|
onClearServerErrors?: () => void;
|
|
@@ -11,4 +12,4 @@ export interface PhoneNumberFormProps extends Omit<FormHTMLAttributes<HTMLFormEl
|
|
|
11
12
|
phoneNumber: PhoneNumberInputProps["phoneNumber"];
|
|
12
13
|
submitLabel?: ReactNode;
|
|
13
14
|
}
|
|
14
|
-
export declare const PhoneNumberForm: ({ className, countryCode, error, isPending, onCountryCodeChange, onPhoneNumberChange, phoneNumber, submitLabel, ...props }: PhoneNumberFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const PhoneNumberForm: ({ className, countryCode, countryOptions, error, isPending, onCountryCodeChange, onPhoneNumberChange, phoneNumber, submitLabel, ...props }: PhoneNumberFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,68 +1,75 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as u, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import "@coinbase/cdp-hooks";
|
|
3
|
-
import { Form as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import { Field as
|
|
6
|
-
import { PhoneNumberInput as
|
|
7
|
-
import { Button as
|
|
8
|
-
import { ServerError as
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
import { Form as I, FormSubmit as S } from "@radix-ui/react-form";
|
|
4
|
+
import { useMemo as C, Fragment as E } from "react";
|
|
5
|
+
import { Field as x } from "../Field/index.js";
|
|
6
|
+
import { PhoneNumberInput as y } from "../PhoneNumberInput/index.js";
|
|
7
|
+
import { Button as M } from "../../ui/Button/index.js";
|
|
8
|
+
import { ServerError as U } from "../../ui/ServerError/index.js";
|
|
9
|
+
import { VisuallyHidden as w } from "../../ui/VisuallyHidden/index.js";
|
|
10
|
+
import { usePhoneNumberValidators as T } from "../../../hooks/usePhoneNumberValidators.js";
|
|
11
|
+
import '../../../assets/PhoneNumberForm.css';const j = "PhoneNumberForm-module__form___ExO8G", m = {
|
|
12
|
+
form: j,
|
|
13
|
+
"server-error": "PhoneNumberForm-module__server-error___AQcMg",
|
|
14
|
+
"phone-number-fieldset": "PhoneNumberForm-module__phone-number-fieldset___0TsSH"
|
|
15
|
+
}, q = ({ children: n }) => /* @__PURE__ */ u("fieldset", { className: m["phone-number-fieldset"], children: [
|
|
16
|
+
/* @__PURE__ */ e("legend", { children: /* @__PURE__ */ e(w, { children: "International phone number" }) }),
|
|
17
|
+
n
|
|
18
|
+
] }), D = ({
|
|
19
|
+
className: n = "",
|
|
20
|
+
countryCode: t = "US",
|
|
21
|
+
countryOptions: o = !0,
|
|
16
22
|
error: r,
|
|
17
|
-
isPending:
|
|
18
|
-
onCountryCodeChange:
|
|
19
|
-
onPhoneNumberChange:
|
|
20
|
-
phoneNumber:
|
|
21
|
-
submitLabel:
|
|
22
|
-
...
|
|
23
|
+
isPending: h,
|
|
24
|
+
onCountryCodeChange: a,
|
|
25
|
+
onPhoneNumberChange: d,
|
|
26
|
+
phoneNumber: p,
|
|
27
|
+
submitLabel: b = "Continue",
|
|
28
|
+
...v
|
|
23
29
|
}) => {
|
|
24
30
|
const {
|
|
25
|
-
isInvalidCountry:
|
|
26
|
-
isInvalidLength:
|
|
27
|
-
isInvalidNumber:
|
|
28
|
-
isInvalidTooShort:
|
|
29
|
-
isInvalidTooLong:
|
|
30
|
-
isInvalidPhoneNumberError:
|
|
31
|
-
} =
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
-
/* @__PURE__ */ e(
|
|
34
|
-
|
|
31
|
+
isInvalidCountry: f,
|
|
32
|
+
isInvalidLength: c,
|
|
33
|
+
isInvalidNumber: _,
|
|
34
|
+
isInvalidTooShort: P,
|
|
35
|
+
isInvalidTooLong: N,
|
|
36
|
+
isInvalidPhoneNumberError: s
|
|
37
|
+
} = T({ countryCode: t }), i = C(() => r && s(r) ? "Use a valid phone number" : "", [r, s]), g = !!r && !i, F = (typeof o == "boolean" ? o : o.length > 0) ? q : E;
|
|
38
|
+
return /* @__PURE__ */ u(I, { className: `${m.form} ${n}`, ...v, children: [
|
|
39
|
+
/* @__PURE__ */ e(F, { children: /* @__PURE__ */ e(
|
|
40
|
+
x,
|
|
35
41
|
{
|
|
36
42
|
label: "Phone number",
|
|
37
43
|
name: "phone",
|
|
38
|
-
inlineError:
|
|
44
|
+
inlineError: i,
|
|
39
45
|
validators: [
|
|
40
46
|
["valueMissing", "Phone number is required"],
|
|
41
47
|
["typeMismatch", "Use a valid phone number"],
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
48
|
+
[_, "Use a valid phone number"],
|
|
49
|
+
[f, "Country is not supported"],
|
|
50
|
+
[P, "Phone number is too short"],
|
|
51
|
+
[N, "Phone number is too long"],
|
|
52
|
+
[c, "Phone number is the wrong length"]
|
|
47
53
|
],
|
|
48
|
-
children: (
|
|
49
|
-
|
|
54
|
+
children: (l) => /* @__PURE__ */ e(
|
|
55
|
+
y,
|
|
50
56
|
{
|
|
51
|
-
"aria-invalid": !(
|
|
57
|
+
"aria-invalid": !(l === void 0 || l.valid) || !!i,
|
|
52
58
|
autoComplete: "tel-national",
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
countryOptions: o,
|
|
60
|
+
phoneNumber: p,
|
|
61
|
+
onPhoneNumberChange: d,
|
|
62
|
+
countryCode: t,
|
|
63
|
+
onCountryCodeChange: a,
|
|
57
64
|
required: !0
|
|
58
65
|
}
|
|
59
66
|
)
|
|
60
67
|
}
|
|
61
|
-
),
|
|
62
|
-
|
|
63
|
-
/* @__PURE__ */ e(
|
|
68
|
+
) }),
|
|
69
|
+
g && /* @__PURE__ */ e(U, { error: r, className: m["server-error"] }),
|
|
70
|
+
/* @__PURE__ */ e(S, { asChild: !0, children: /* @__PURE__ */ e(M, { type: "submit", isPending: h, children: b }) })
|
|
64
71
|
] });
|
|
65
72
|
};
|
|
66
73
|
export {
|
|
67
|
-
|
|
74
|
+
D as PhoneNumberForm
|
|
68
75
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CountryCode } from 'libphonenumber-js';
|
|
2
2
|
import { InputProps } from '../Input/Input';
|
|
3
|
+
import { CountryOption } from '../../../data/countries';
|
|
3
4
|
import { PhoneNumber } from '../../../utils/parseValuesFromPhoneNumber';
|
|
4
5
|
export interface PhoneNumberInputProps extends Omit<InputProps, "value" | "onChange"> {
|
|
5
|
-
onCountryCodeChange
|
|
6
|
+
onCountryCodeChange?: (newCountry: CountryCode) => void;
|
|
6
7
|
countryCode?: CountryCode;
|
|
8
|
+
countryOptions?: boolean | CountryOption[];
|
|
7
9
|
onPhoneNumberChange: (phoneNumber: PhoneNumber) => void;
|
|
8
10
|
phoneNumber: PhoneNumber;
|
|
9
11
|
}
|
|
10
|
-
export declare const PhoneNumberInput: (
|
|
12
|
+
export declare const PhoneNumberInput: import('react').ForwardRefExoticComponent<PhoneNumberInputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,76 +1,100 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as _, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import "libphonenumber-js";
|
|
3
|
-
import { useCallback as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
3
|
+
import { forwardRef as R, useRef as S, useCallback as d, useMemo as w, useEffect as z } from "react";
|
|
4
|
+
import { CountrySelect as B } from "../CountrySelect/index.js";
|
|
5
|
+
import { Input as H } from "../Input/index.js";
|
|
6
|
+
import { VisuallyHidden as M } from "../../ui/VisuallyHidden/index.js";
|
|
7
|
+
import { countries as W } from "../../../data/countries.js";
|
|
8
|
+
import { usePhoneNumberFormatter as k } from "./usePhoneNumberFormatter.js";
|
|
9
|
+
import '../../../assets/PhoneNumberInput.css';const A = "PhoneNumberInput-module__invalid___zDA2p", E = "PhoneNumberInput-module__success___uPjMx", G = "PhoneNumberInput-module__input___H-XG-", l = {
|
|
9
10
|
"phone-number-input": "PhoneNumberInput-module__phone-number-input___mYty2",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
"inline-country-calling-code": "PhoneNumberInput-module__inline-country-calling-code___FFgtI",
|
|
12
|
+
invalid: A,
|
|
13
|
+
success: E,
|
|
14
|
+
input: G,
|
|
13
15
|
"country-calling-code": "PhoneNumberInput-module__country-calling-code___N6zDW"
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
16
|
+
}, T = R(
|
|
17
|
+
({
|
|
18
|
+
autoComplete: u = "tel-national",
|
|
19
|
+
className: h = "",
|
|
20
|
+
countryCode: n = "US",
|
|
21
|
+
countryOptions: p = !0,
|
|
22
|
+
onCountryCodeChange: g,
|
|
23
|
+
onPhoneNumberChange: c,
|
|
24
|
+
phoneNumber: f,
|
|
25
|
+
...a
|
|
26
|
+
}, o) => {
|
|
27
|
+
const b = S(null), C = d(
|
|
28
|
+
(e) => {
|
|
29
|
+
b.current = e, o && (typeof o == "function" ? o(e) : o.current = e);
|
|
30
|
+
},
|
|
31
|
+
[o]
|
|
32
|
+
), {
|
|
33
|
+
formatBeforePhoneNumberChange: v,
|
|
34
|
+
formatBeforeCountryCodeChange: N,
|
|
35
|
+
placeholder: P,
|
|
36
|
+
formattedDisplayNumber: V
|
|
37
|
+
} = k(f.value, n), j = d(
|
|
38
|
+
(e) => {
|
|
39
|
+
let t = e.target.value.replace(/\D/g, "");
|
|
40
|
+
t === f.value && (t = t.slice(0, -1));
|
|
41
|
+
const F = v(t);
|
|
42
|
+
c?.(F);
|
|
43
|
+
},
|
|
44
|
+
[v, c, f]
|
|
45
|
+
), r = d(
|
|
46
|
+
(e) => {
|
|
47
|
+
const t = N(e);
|
|
48
|
+
g?.(e), c?.(t);
|
|
49
|
+
},
|
|
50
|
+
[N, g, c]
|
|
51
|
+
), x = d(
|
|
52
|
+
(e) => {
|
|
53
|
+
r(e), setTimeout(() => {
|
|
54
|
+
b.current?.focus();
|
|
55
|
+
}, 0);
|
|
56
|
+
},
|
|
57
|
+
[r]
|
|
58
|
+
), s = typeof p == "boolean" ? p : p.length > 0, m = !s && n ? W.find((e) => e.code === n) : void 0, y = a["aria-invalid"] && a["aria-invalid"] !== "false", I = a["data-success"] && a["data-success"] !== "false", D = w(() => {
|
|
59
|
+
const e = [l["phone-number-input"], h];
|
|
60
|
+
return y && e.push(l.invalid), I && e.push(l.success), !s && m && e.push(l["inline-country-calling-code"]), e.join(" ");
|
|
61
|
+
}, [y, I, h, m, s]);
|
|
62
|
+
return z(() => {
|
|
63
|
+
r(n);
|
|
64
|
+
}, [n, r]), /* @__PURE__ */ _("div", { className: D, children: [
|
|
65
|
+
!s && m && /* @__PURE__ */ i(U, { country: m }),
|
|
66
|
+
s && /* @__PURE__ */ i(
|
|
67
|
+
B,
|
|
68
|
+
{
|
|
69
|
+
defaultValue: n,
|
|
70
|
+
onValueChange: x
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
/* @__PURE__ */ i(
|
|
74
|
+
H,
|
|
75
|
+
{
|
|
76
|
+
...a,
|
|
77
|
+
ref: C,
|
|
78
|
+
className: l.input,
|
|
79
|
+
autoComplete: u,
|
|
80
|
+
onChange: j,
|
|
81
|
+
placeholder: P,
|
|
82
|
+
type: "tel",
|
|
83
|
+
value: V
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
] });
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
T.displayName = "PhoneNumberInput";
|
|
90
|
+
const U = ({ country: u }) => /* @__PURE__ */ _("span", { className: l["country-calling-code"], children: [
|
|
91
|
+
/* @__PURE__ */ i("span", { "aria-hidden": "true", children: u.flag }),
|
|
92
|
+
/* @__PURE__ */ i(M, { children: u.name }),
|
|
93
|
+
/* @__PURE__ */ _("span", { children: [
|
|
70
94
|
"+",
|
|
71
|
-
|
|
95
|
+
u.callingCode
|
|
72
96
|
] })
|
|
73
97
|
] });
|
|
74
98
|
export {
|
|
75
|
-
|
|
99
|
+
T as PhoneNumberInput
|
|
76
100
|
};
|
|
@@ -49,6 +49,16 @@ const n = (r) => r.startsWith("1") ? r.slice(1) : r, i = {
|
|
|
49
49
|
*/
|
|
50
50
|
prefix: "0",
|
|
51
51
|
maxLength: 11
|
|
52
|
+
},
|
|
53
|
+
91: {
|
|
54
|
+
/**
|
|
55
|
+
* India phone number validation:
|
|
56
|
+
*
|
|
57
|
+
* Indian phone numbers must be exactly 10 digits (excluding country code).
|
|
58
|
+
* libphonenumber-js allows 8-12 digits, but Indian mobile numbers are always 10 digits.
|
|
59
|
+
* This override ensures the input is limited to exactly 10 digits.
|
|
60
|
+
*/
|
|
61
|
+
maxLength: 10
|
|
52
62
|
}
|
|
53
63
|
}, a = (r) => {
|
|
54
64
|
if (!r)
|
|
@@ -3,9 +3,9 @@ import { TransitionMapOptions, TransitionMapResult, TransitionState } from 'reac
|
|
|
3
3
|
export interface SwitchTransitionRef<T extends Key> {
|
|
4
4
|
transition: TransitionMapResult<T>;
|
|
5
5
|
}
|
|
6
|
-
export interface SwitchTransitionProps<T extends Key> extends Omit<HTMLAttributes<HTMLElement>, "children">, TransitionMapOptions<T> {
|
|
6
|
+
export interface SwitchTransitionProps<T extends Key> extends Omit<HTMLAttributes<HTMLElement>, "children" | "autoFocus">, TransitionMapOptions<T> {
|
|
7
7
|
animateHeight?: boolean;
|
|
8
|
-
autoFocus?: boolean;
|
|
8
|
+
autoFocus?: boolean | string;
|
|
9
9
|
as?: ElementType;
|
|
10
10
|
children: (props: {
|
|
11
11
|
"data-index": number;
|
|
@@ -1,155 +1,153 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as R, useId as
|
|
3
|
-
import { useTransitionMap as
|
|
4
|
-
import '../../../assets/SwitchTransition.css';const
|
|
1
|
+
import { jsx as b, Fragment as H } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as R, useId as J, useState as _, useImperativeHandle as P, useLayoutEffect as j, useEffect as Q } from "react";
|
|
3
|
+
import { useTransitionMap as U } from "react-transition-state";
|
|
4
|
+
import '../../../assets/SwitchTransition.css';const V = {
|
|
5
5
|
"transition-wrapper": "SwitchTransition-module__transition-wrapper___jrI35"
|
|
6
|
-
},
|
|
6
|
+
}, W = (v) => {
|
|
7
7
|
const {
|
|
8
8
|
children: n,
|
|
9
|
-
index:
|
|
10
|
-
itemKey:
|
|
11
|
-
initialEntered:
|
|
12
|
-
setItem:
|
|
13
|
-
deleteItem:
|
|
14
|
-
stateMap:
|
|
15
|
-
transitionName:
|
|
16
|
-
parentKey:
|
|
17
|
-
} =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}), [
|
|
21
|
-
const { isEnter:
|
|
22
|
-
return
|
|
23
|
-
"data-index":
|
|
24
|
-
inert: !
|
|
25
|
-
itemKey:
|
|
26
|
-
"data-transition":
|
|
27
|
-
"data-status":
|
|
28
|
-
"data-is-enter":
|
|
29
|
-
"data-is-resolved":
|
|
30
|
-
"data-parent":
|
|
9
|
+
index: r,
|
|
10
|
+
itemKey: i,
|
|
11
|
+
initialEntered: u,
|
|
12
|
+
setItem: f,
|
|
13
|
+
deleteItem: p,
|
|
14
|
+
stateMap: y,
|
|
15
|
+
transitionName: I,
|
|
16
|
+
parentKey: m
|
|
17
|
+
} = v;
|
|
18
|
+
Q(() => (f(i, { initialEntered: u }), () => {
|
|
19
|
+
p(i);
|
|
20
|
+
}), [i, u, f, p]);
|
|
21
|
+
const { isEnter: h, isMounted: w, isResolved: x, status: g } = y.get(i) || {};
|
|
22
|
+
return w ? n({
|
|
23
|
+
"data-index": r,
|
|
24
|
+
inert: !h,
|
|
25
|
+
itemKey: i,
|
|
26
|
+
"data-transition": I,
|
|
27
|
+
"data-status": g,
|
|
28
|
+
"data-is-enter": h,
|
|
29
|
+
"data-is-resolved": x,
|
|
30
|
+
"data-parent": m
|
|
31
31
|
}) : null;
|
|
32
|
-
},
|
|
33
|
-
allowMultiple:
|
|
32
|
+
}, k = ({
|
|
33
|
+
allowMultiple: v,
|
|
34
34
|
animateHeight: n,
|
|
35
|
-
autoFocus:
|
|
36
|
-
initialEntered:
|
|
37
|
-
as:
|
|
38
|
-
children:
|
|
39
|
-
className:
|
|
40
|
-
enter:
|
|
41
|
-
exit:
|
|
42
|
-
items:
|
|
43
|
-
mountOnEnter:
|
|
44
|
-
onStateChange:
|
|
45
|
-
preEnter:
|
|
46
|
-
preExit:
|
|
35
|
+
autoFocus: r,
|
|
36
|
+
initialEntered: i,
|
|
37
|
+
as: u = "div",
|
|
38
|
+
children: f,
|
|
39
|
+
className: p = "",
|
|
40
|
+
enter: y,
|
|
41
|
+
exit: I,
|
|
42
|
+
items: m,
|
|
43
|
+
mountOnEnter: h,
|
|
44
|
+
onStateChange: w,
|
|
45
|
+
preEnter: x,
|
|
46
|
+
preExit: g,
|
|
47
47
|
style: q,
|
|
48
48
|
timeout: e = 200,
|
|
49
|
-
transitionName:
|
|
49
|
+
transitionName: $,
|
|
50
50
|
transitionRef: z,
|
|
51
51
|
unmountOnExit: L,
|
|
52
|
-
|
|
52
|
+
...E
|
|
53
53
|
}) => {
|
|
54
|
-
const N = R(
|
|
55
|
-
allowMultiple:
|
|
54
|
+
const N = R(m[0]), O = J(), o = E.id || O, [S, A] = _(null), [C, K] = _(null), T = R(null), a = U({
|
|
55
|
+
allowMultiple: v,
|
|
56
56
|
initialEntered: !1,
|
|
57
|
-
mountOnEnter:
|
|
57
|
+
mountOnEnter: h,
|
|
58
58
|
unmountOnExit: L,
|
|
59
|
-
preEnter:
|
|
60
|
-
preExit:
|
|
61
|
-
enter:
|
|
62
|
-
exit:
|
|
59
|
+
preEnter: x,
|
|
60
|
+
preExit: g,
|
|
61
|
+
enter: y,
|
|
62
|
+
exit: I,
|
|
63
63
|
timeout: e,
|
|
64
|
-
onStateChange:
|
|
64
|
+
onStateChange: w
|
|
65
65
|
});
|
|
66
|
-
|
|
67
|
-
transition: n ||
|
|
68
|
-
...
|
|
66
|
+
P(z, () => ({
|
|
67
|
+
transition: n || r ? {
|
|
68
|
+
...a,
|
|
69
69
|
toggle: (t) => {
|
|
70
|
-
|
|
70
|
+
a.toggle(t), A(t);
|
|
71
71
|
}
|
|
72
|
-
} :
|
|
72
|
+
} : a
|
|
73
73
|
})), j(() => {
|
|
74
74
|
if (!n)
|
|
75
75
|
return;
|
|
76
76
|
let t = null;
|
|
77
|
-
const
|
|
78
|
-
if (!
|
|
77
|
+
const s = T.current;
|
|
78
|
+
if (!s)
|
|
79
79
|
return;
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
`[data-is-enter="true"][data-parent="${
|
|
80
|
+
const d = setTimeout(() => {
|
|
81
|
+
const c = s.querySelector(
|
|
82
|
+
`[data-is-enter="true"][data-parent="${o}"]`
|
|
83
83
|
);
|
|
84
|
-
if (!
|
|
84
|
+
if (!c)
|
|
85
85
|
return;
|
|
86
|
-
const
|
|
87
|
-
|
|
86
|
+
const l = c?.scrollHeight ?? null;
|
|
87
|
+
l !== null && K(l), t = new ResizeObserver((B) => {
|
|
88
88
|
for (const D of B) {
|
|
89
|
-
const
|
|
90
|
-
|
|
89
|
+
const G = D.contentRect.height;
|
|
90
|
+
K(G);
|
|
91
91
|
}
|
|
92
|
-
}), t.observe(
|
|
92
|
+
}), t.observe(c);
|
|
93
93
|
}, 0);
|
|
94
94
|
return () => {
|
|
95
|
-
|
|
95
|
+
d && clearTimeout(d), t?.disconnect();
|
|
96
96
|
};
|
|
97
|
-
}, [n,
|
|
98
|
-
if (!
|
|
97
|
+
}, [n, S, o]), j(() => {
|
|
98
|
+
if (!r)
|
|
99
99
|
return;
|
|
100
100
|
const t = typeof e == "number" ? e : e.enter;
|
|
101
101
|
if (t === void 0)
|
|
102
102
|
return;
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
`[data-is-enter="true"][data-parent="${
|
|
103
|
+
const s = setTimeout(() => {
|
|
104
|
+
const d = T.current?.querySelector(
|
|
105
|
+
`[data-is-enter="true"][data-parent="${o}"]`
|
|
106
106
|
);
|
|
107
|
-
if (!
|
|
107
|
+
if (!d)
|
|
108
108
|
return;
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
);
|
|
112
|
-
a && a.focus();
|
|
109
|
+
const c = typeof r == "string" ? r : 'input, textarea, select, button, [tabindex]:not([tabindex="-1"])', l = d.querySelector(c);
|
|
110
|
+
l && l.focus();
|
|
113
111
|
}, t);
|
|
114
112
|
return () => {
|
|
115
|
-
|
|
113
|
+
s && clearTimeout(s);
|
|
116
114
|
};
|
|
117
|
-
}, [
|
|
118
|
-
const
|
|
119
|
-
|
|
115
|
+
}, [r, S, o, e]);
|
|
116
|
+
const M = /* @__PURE__ */ b(H, { children: m.map((t, s) => /* @__PURE__ */ b(
|
|
117
|
+
W,
|
|
120
118
|
{
|
|
121
|
-
index:
|
|
119
|
+
index: s,
|
|
122
120
|
itemKey: t,
|
|
123
|
-
setItem:
|
|
124
|
-
deleteItem:
|
|
125
|
-
stateMap:
|
|
126
|
-
initialEntered:
|
|
127
|
-
transitionName:
|
|
128
|
-
parentKey:
|
|
129
|
-
children:
|
|
121
|
+
setItem: a.setItem,
|
|
122
|
+
deleteItem: a.deleteItem,
|
|
123
|
+
stateMap: a.stateMap,
|
|
124
|
+
initialEntered: i ? N.current === t : void 0,
|
|
125
|
+
transitionName: $,
|
|
126
|
+
parentKey: o,
|
|
127
|
+
children: f
|
|
130
128
|
},
|
|
131
129
|
t
|
|
132
130
|
)) });
|
|
133
|
-
return /* @__PURE__ */
|
|
134
|
-
|
|
131
|
+
return /* @__PURE__ */ b(
|
|
132
|
+
u,
|
|
135
133
|
{
|
|
136
|
-
|
|
137
|
-
id:
|
|
138
|
-
ref:
|
|
139
|
-
"data-transition":
|
|
134
|
+
...E,
|
|
135
|
+
id: o,
|
|
136
|
+
ref: T,
|
|
137
|
+
"data-transition": $ || void 0,
|
|
140
138
|
"data-animate-height": n,
|
|
141
|
-
className: `${
|
|
139
|
+
className: `${V["transition-wrapper"]} ${p}`,
|
|
142
140
|
style: {
|
|
143
141
|
...q,
|
|
144
142
|
"--cdp-web-transition-enter-timeout": typeof e == "object" ? `${e.enter ?? 200}ms` : void 0,
|
|
145
143
|
"--cdp-web-transition-exit-timeout": typeof e == "object" ? `${e.exit ?? 200}ms` : void 0,
|
|
146
144
|
"--cdp-web-transition-timeout": typeof e == "number" ? `${e}ms` : void 0,
|
|
147
|
-
"--cdp-web-transition-height": n &&
|
|
145
|
+
"--cdp-web-transition-height": n && C ? `${C}px` : void 0
|
|
148
146
|
},
|
|
149
|
-
children: n ? /* @__PURE__ */
|
|
147
|
+
children: n ? /* @__PURE__ */ b("div", { children: M }) : M
|
|
150
148
|
}
|
|
151
149
|
);
|
|
152
150
|
};
|
|
153
151
|
export {
|
|
154
|
-
|
|
152
|
+
k as SwitchTransition
|
|
155
153
|
};
|
package/dist/data/countries.js
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import { getCountries as
|
|
1
|
+
import { getCountries as a, getCountryCallingCode as C } from "libphonenumber-js";
|
|
2
2
|
import { countryNames as r } from "./countryNames.js";
|
|
3
|
-
const
|
|
3
|
+
const e = ["CU", "ET", "IR", "KP", "KZ", "MM", "RU", "SY"], i = "US", o = {
|
|
4
|
+
AE: "🇦🇪",
|
|
5
|
+
BR: "🇧🇷",
|
|
6
|
+
CA: "🇨🇦",
|
|
7
|
+
CO: "🇨🇴",
|
|
8
|
+
GB: "🇬🇧",
|
|
9
|
+
IN: "🇮🇳",
|
|
10
|
+
KE: "🇰🇪",
|
|
11
|
+
MX: "🇲🇽",
|
|
12
|
+
PH: "🇵🇭",
|
|
4
13
|
US: "🇺🇸"
|
|
5
14
|
}, s = (n) => {
|
|
6
15
|
try {
|
|
7
|
-
return
|
|
16
|
+
return C(n);
|
|
8
17
|
} catch {
|
|
9
18
|
return;
|
|
10
19
|
}
|
|
11
|
-
}, u =
|
|
12
|
-
const t =
|
|
20
|
+
}, u = a().map((n) => {
|
|
21
|
+
const t = e.includes(n);
|
|
13
22
|
return {
|
|
14
|
-
callingCode:
|
|
23
|
+
callingCode: C(n),
|
|
15
24
|
code: n,
|
|
16
25
|
flag: t || !o[n] ? "" : o[n],
|
|
17
26
|
name: t || !r[`language${n}`] ? "" : r[`language${n}`]
|
|
@@ -19,7 +28,7 @@ const l = ["CU", "ET", "IR", "KP", "KZ", "MM", "RU", "SY"], i = "US", o = {
|
|
|
19
28
|
}).filter((n) => !!n.flag && !!n.name);
|
|
20
29
|
export {
|
|
21
30
|
i as DEFAULT_COUNTRY_CODE,
|
|
22
|
-
|
|
31
|
+
e as OFAC_BLOCKED_COUNTRIES,
|
|
23
32
|
u as countries,
|
|
24
33
|
s as nonThrowingGetCountryCallingCode
|
|
25
34
|
};
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a = {
|
|
2
|
+
languageAE: "United Arab Emirates",
|
|
3
|
+
languageBR: "Brazil",
|
|
4
|
+
languageCA: "Canada",
|
|
5
|
+
languageCO: "Colombia",
|
|
6
|
+
languageGB: "United Kingdom",
|
|
7
|
+
languageIN: "India",
|
|
8
|
+
languageKE: "Kenya",
|
|
9
|
+
languageMX: "Mexico",
|
|
10
|
+
languagePH: "Philippines",
|
|
2
11
|
languageUS: "United States"
|
|
3
12
|
};
|
|
4
13
|
export {
|
|
5
|
-
|
|
14
|
+
a as countryNames
|
|
6
15
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.43",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@internationalized/number": "3.6.4",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"react": ">=18.2.0",
|
|
17
|
-
"@coinbase/cdp-core": "^0.0.
|
|
18
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
17
|
+
"@coinbase/cdp-core": "^0.0.43",
|
|
18
|
+
"@coinbase/cdp-hooks": "^0.0.43"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@size-limit/preset-big-lib": "^11.2.0",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"vite": "^7.0.4",
|
|
46
46
|
"vite-plugin-dts": "^4.5.4",
|
|
47
47
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
48
|
-
"@coinbase/cdp-
|
|
49
|
-
"@coinbase/cdp-
|
|
48
|
+
"@coinbase/cdp-hooks": "^0.0.43",
|
|
49
|
+
"@coinbase/cdp-core": "^0.0.43"
|
|
50
50
|
},
|
|
51
51
|
"size-limit": [
|
|
52
52
|
{
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"path": "./dist/components/SignIn/index.js",
|
|
62
62
|
"import": "{ SignIn }",
|
|
63
63
|
"running": false,
|
|
64
|
-
"limit": "
|
|
64
|
+
"limit": "80 KB"
|
|
65
65
|
}
|
|
66
66
|
],
|
|
67
67
|
"files": [
|
|
@@ -119,7 +119,8 @@
|
|
|
119
119
|
"types": "./dist/theme/*.d.ts",
|
|
120
120
|
"default": "./dist/theme/*.js"
|
|
121
121
|
}
|
|
122
|
-
}
|
|
122
|
+
},
|
|
123
|
+
"./package.json": "./package.json"
|
|
123
124
|
},
|
|
124
125
|
"scripts": {
|
|
125
126
|
"build": "pnpm run check:types && vite build",
|