@coinbase/cdp-react 0.0.41 → 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.
@@ -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;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__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__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:.25rem}
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}
@@ -6,11 +6,11 @@ export interface AppConfig {
6
6
  appName?: string;
7
7
  appLogoUrl?: string;
8
8
  showCoinbaseFooter?: boolean;
9
- authMethods?: AuthMethod[];
9
+ authMethods?: [AuthMethod, ...AuthMethod[]];
10
10
  }
11
11
  export type Config = AppConfig & CDPHooksConfig;
12
12
  export type CDPReactProviderProps = {
13
13
  config: Config;
14
14
  } & ThemeProviderProps;
15
15
  export declare const CDPReactProvider: ({ children, config, theme }: CDPReactProviderProps) => import("react/jsx-runtime").JSX.Element;
16
- export declare const useAppConfig: () => AppConfig;
16
+ export declare const useAppConfig: () => Required<AppConfig>;
@@ -1,63 +1,77 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { CDPContext as A, CDPHooksProvider as O } from "@coinbase/cdp-hooks";
3
- import { createContext as b, useMemo as r, useContext as f } from "react";
4
- import { ThemeProvider as w } from "../ThemeProvider/index.js";
5
- const E = [
1
+ import { jsx as c } from "react/jsx-runtime";
2
+ import { CDPContext as L, CDPHooksProvider as O } from "@coinbase/cdp-hooks";
3
+ import { createContext as v, useMemo as f, useContext as l } from "react";
4
+ import { ThemeProvider as b } from "../ThemeProvider/index.js";
5
+ const w = (o) => {
6
+ try {
7
+ return JSON.stringify(o);
8
+ } catch {
9
+ }
10
+ return "";
11
+ }, T = [
6
12
  /** Email OTP method */
7
13
  "email",
8
14
  /** SMS OTP method */
9
15
  "sms"
10
- ], F = ({ children: o, config: e, theme: n }) => {
16
+ ], _ = ({ children: o, config: r, theme: n }) => {
11
17
  const {
12
- appName: i,
18
+ appName: a,
13
19
  appLogoUrl: s,
14
- showCoinbaseFooter: a,
15
- authMethods: p,
16
- projectId: c,
17
- useMock: C,
20
+ showCoinbaseFooter: h,
21
+ authMethods: i,
22
+ projectId: p,
23
+ useMock: e,
18
24
  debugging: u,
19
- basePath: d,
25
+ basePath: g,
20
26
  ethereum: P,
21
27
  solana: x
22
- } = e, { createOnLogin: m } = P ?? {}, { createOnLogin: g } = x ?? {}, v = r(
28
+ } = r, { createOnLogin: d } = P ?? {}, { createOnLogin: C } = x ?? {}, A = f(
23
29
  () => ({
24
- projectId: c,
25
- useMock: C,
30
+ projectId: p,
31
+ useMock: e,
26
32
  debugging: u,
27
- basePath: d,
28
- ethereum: { createOnLogin: m },
29
- solana: { createOnLogin: g }
33
+ basePath: g,
34
+ ethereum: { createOnLogin: d },
35
+ solana: { createOnLogin: C }
30
36
  }),
31
- [c, C, u, d, m, g]
32
- ), L = r(
33
- () => ({ appName: i, appLogoUrl: s, showCoinbaseFooter: a, authMethods: p }),
34
- [i, s, a, p]
35
- ), h = /* @__PURE__ */ t(M, { config: L, children: /* @__PURE__ */ t(w, { theme: n, children: o }) });
36
- return f(A) ? h : /* @__PURE__ */ t(O, { config: v, children: h });
37
- }, l = b(void 0), D = {
37
+ [p, e, u, g, d, C]
38
+ ), m = /* @__PURE__ */ c(y, { config: { appName: a, appLogoUrl: s, showCoinbaseFooter: h, authMethods: i }, children: /* @__PURE__ */ c(b, { theme: n, children: o }) });
39
+ return l(L) ? m : /* @__PURE__ */ c(O, { config: A, children: m });
40
+ }, M = v(void 0), t = {
38
41
  appName: "",
39
42
  appLogoUrl: "",
40
43
  showCoinbaseFooter: !0,
41
44
  authMethods: ["email"]
42
- }, M = ({ children: o, config: e }) => {
43
- const n = r(
44
- () => ({
45
+ }, y = ({ children: o, config: r }) => {
46
+ const {
47
+ appName: n = t.appName,
48
+ appLogoUrl: a = t.appLogoUrl,
49
+ showCoinbaseFooter: s = t.showCoinbaseFooter,
50
+ authMethods: h = t.authMethods
51
+ } = r ?? {}, i = w(h), p = f(() => {
52
+ let e = ["email"];
53
+ try {
54
+ e = JSON.parse(i);
55
+ } catch {
56
+ }
57
+ return {
45
58
  app: {
46
- ...D,
47
- ...e
59
+ appName: n,
60
+ appLogoUrl: a,
61
+ showCoinbaseFooter: s,
62
+ authMethods: Array.isArray(e) && e?.length ? e : t.authMethods
48
63
  }
49
- }),
50
- [e]
51
- );
52
- return /* @__PURE__ */ t(l.Provider, { value: n, children: o });
53
- }, N = () => {
54
- const o = f(l);
64
+ };
65
+ }, [n, a, s, i]);
66
+ return /* @__PURE__ */ c(M.Provider, { value: p, children: o });
67
+ }, j = () => {
68
+ const o = l(M);
55
69
  if (!o)
56
70
  throw new Error("useAppConfig must be used within an AppConfigProvider");
57
71
  return o.app;
58
72
  };
59
73
  export {
60
- E as AUTH_METHODS,
61
- F as CDPReactProvider,
62
- N as useAppConfig
74
+ T as AUTH_METHODS,
75
+ _ as CDPReactProvider,
76
+ j as useAppConfig
63
77
  };
@@ -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: !0,
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 _, jsx as e } from "react/jsx-runtime";
1
+ import { jsxs as u, jsx as e } from "react/jsx-runtime";
2
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",
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: u,
18
- onCountryCodeChange: l,
19
- onPhoneNumberChange: a,
20
- phoneNumber: h,
21
- submitLabel: d = "Continue",
22
- ...p
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: 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,
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: o,
44
+ inlineError: i,
39
45
  validators: [
40
46
  ["valueMissing", "Phone number is required"],
41
47
  ["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"]
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: (m) => /* @__PURE__ */ e(
49
- S,
54
+ children: (l) => /* @__PURE__ */ e(
55
+ y,
50
56
  {
51
- "aria-invalid": !(m === void 0 || m.valid) || !!o,
57
+ "aria-invalid": !(l === void 0 || l.valid) || !!i,
52
58
  autoComplete: "tel-national",
53
- phoneNumber: h,
54
- onPhoneNumberChange: a,
55
- countryCode: n,
56
- onCountryCodeChange: l,
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
- 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 }) })
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
- G as PhoneNumberForm
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: (newCountry: CountryCode) => void;
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: ({ autoComplete, className, countryCode, onCountryCodeChange, onPhoneNumberChange, phoneNumber, ...props }: PhoneNumberInputProps) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const PhoneNumberInput: import('react').ForwardRefExoticComponent<PhoneNumberInputProps & import('react').RefAttributes<HTMLInputElement>>;
@@ -1,76 +1,100 @@
1
- import { jsxs as o, jsx as c } from "react/jsx-runtime";
1
+ import { jsxs as _, jsx as i } from "react/jsx-runtime";
2
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 = {
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
- invalid: j,
11
- success: V,
12
- input: z,
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
- }, 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: [
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
- a.callingCode
95
+ u.callingCode
72
96
  ] })
73
97
  ] });
74
98
  export {
75
- G as PhoneNumberInput
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 h, Fragment as G } from "react/jsx-runtime";
2
- import { useRef as R, useId as H, useState as _, useImperativeHandle as J, useLayoutEffect as j, useEffect as P } from "react";
3
- import { useTransitionMap as Q } from "react-transition-state";
4
- import '../../../assets/SwitchTransition.css';const U = {
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
- }, V = (b) => {
6
+ }, W = (v) => {
7
7
  const {
8
8
  children: n,
9
- index: d,
10
- itemKey: r,
11
- initialEntered: l,
12
- setItem: u,
13
- deleteItem: f,
14
- stateMap: v,
15
- transitionName: y,
16
- parentKey: p
17
- } = b;
18
- P(() => (u(r, { initialEntered: l }), () => {
19
- f(r);
20
- }), [r, l, u, f]);
21
- const { isEnter: m, isMounted: I, isResolved: w, status: x } = v.get(r) || {};
22
- return I ? n({
23
- "data-index": d,
24
- inert: !m,
25
- itemKey: r,
26
- "data-transition": y,
27
- "data-status": x,
28
- "data-is-enter": m,
29
- "data-is-resolved": w,
30
- "data-parent": p
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
- }, Z = ({
33
- allowMultiple: b,
32
+ }, k = ({
33
+ allowMultiple: v,
34
34
  animateHeight: n,
35
- autoFocus: d,
36
- initialEntered: r,
37
- as: l = "div",
38
- children: u,
39
- className: f = "",
40
- enter: v,
41
- exit: y,
42
- items: p,
43
- mountOnEnter: m,
44
- onStateChange: I,
45
- preEnter: w,
46
- preExit: x,
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: T,
49
+ transitionName: $,
50
50
  transitionRef: z,
51
51
  unmountOnExit: L,
52
- ...$
52
+ ...E
53
53
  }) => {
54
- const N = R(p[0]), O = H(), s = $.id || O, [E, A] = _(null), [S, C] = _(null), g = R(null), o = Q({
55
- allowMultiple: b,
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: m,
57
+ mountOnEnter: h,
58
58
  unmountOnExit: L,
59
- preEnter: w,
60
- preExit: x,
61
- enter: v,
62
- exit: y,
59
+ preEnter: x,
60
+ preExit: g,
61
+ enter: y,
62
+ exit: I,
63
63
  timeout: e,
64
- onStateChange: I
64
+ onStateChange: w
65
65
  });
66
- J(z, () => ({
67
- transition: n || d ? {
68
- ...o,
66
+ P(z, () => ({
67
+ transition: n || r ? {
68
+ ...a,
69
69
  toggle: (t) => {
70
- o.toggle(t), A(t);
70
+ a.toggle(t), A(t);
71
71
  }
72
- } : o
72
+ } : a
73
73
  })), j(() => {
74
74
  if (!n)
75
75
  return;
76
76
  let t = null;
77
- const i = g.current;
78
- if (!i)
77
+ const s = T.current;
78
+ if (!s)
79
79
  return;
80
- const c = setTimeout(() => {
81
- const a = i.querySelector(
82
- `[data-is-enter="true"][data-parent="${s}"]`
80
+ const d = setTimeout(() => {
81
+ const c = s.querySelector(
82
+ `[data-is-enter="true"][data-parent="${o}"]`
83
83
  );
84
- if (!a)
84
+ if (!c)
85
85
  return;
86
- const M = a?.scrollHeight ?? null;
87
- M !== null && C(M), t = new ResizeObserver((B) => {
86
+ const l = c?.scrollHeight ?? null;
87
+ l !== null && K(l), t = new ResizeObserver((B) => {
88
88
  for (const D of B) {
89
- const F = D.contentRect.height;
90
- C(F);
89
+ const G = D.contentRect.height;
90
+ K(G);
91
91
  }
92
- }), t.observe(a);
92
+ }), t.observe(c);
93
93
  }, 0);
94
94
  return () => {
95
- c && clearTimeout(c), t?.disconnect();
95
+ d && clearTimeout(d), t?.disconnect();
96
96
  };
97
- }, [n, E, s]), j(() => {
98
- if (!d)
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 i = setTimeout(() => {
104
- const c = g.current?.querySelector(
105
- `[data-is-enter="true"][data-parent="${s}"]`
103
+ const s = setTimeout(() => {
104
+ const d = T.current?.querySelector(
105
+ `[data-is-enter="true"][data-parent="${o}"]`
106
106
  );
107
- if (!c)
107
+ if (!d)
108
108
  return;
109
- const a = c.querySelector(
110
- 'input, textarea, select, button, [tabindex]:not([tabindex="-1"])'
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
- i && clearTimeout(i);
113
+ s && clearTimeout(s);
116
114
  };
117
- }, [d, E, s, e]);
118
- const K = /* @__PURE__ */ h(G, { children: p.map((t, i) => /* @__PURE__ */ h(
119
- V,
115
+ }, [r, S, o, e]);
116
+ const M = /* @__PURE__ */ b(H, { children: m.map((t, s) => /* @__PURE__ */ b(
117
+ W,
120
118
  {
121
- index: i,
119
+ index: s,
122
120
  itemKey: t,
123
- setItem: o.setItem,
124
- deleteItem: o.deleteItem,
125
- stateMap: o.stateMap,
126
- initialEntered: r ? N.current === t : void 0,
127
- transitionName: T,
128
- parentKey: s,
129
- children: u
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__ */ h(
134
- l,
131
+ return /* @__PURE__ */ b(
132
+ u,
135
133
  {
136
- ...$,
137
- id: s,
138
- ref: g,
139
- "data-transition": T || void 0,
134
+ ...E,
135
+ id: o,
136
+ ref: T,
137
+ "data-transition": $ || void 0,
140
138
  "data-animate-height": n,
141
- className: `${U["transition-wrapper"]} ${f}`,
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 && S ? `${S}px` : void 0
145
+ "--cdp-web-transition-height": n && C ? `${C}px` : void 0
148
146
  },
149
- children: n ? /* @__PURE__ */ h("div", { children: K }) : K
147
+ children: n ? /* @__PURE__ */ b("div", { children: M }) : M
150
148
  }
151
149
  );
152
150
  };
153
151
  export {
154
- Z as SwitchTransition
152
+ k as SwitchTransition
155
153
  };
@@ -1,17 +1,26 @@
1
- import { getCountries as e, getCountryCallingCode as a } from "libphonenumber-js";
1
+ import { getCountries as a, getCountryCallingCode as C } from "libphonenumber-js";
2
2
  import { countryNames as r } from "./countryNames.js";
3
- const l = ["CU", "ET", "IR", "KP", "KZ", "MM", "RU", "SY"], i = "US", o = {
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 a(n);
16
+ return C(n);
8
17
  } catch {
9
18
  return;
10
19
  }
11
- }, u = e().map((n) => {
12
- const t = l.includes(n);
20
+ }, u = a().map((n) => {
21
+ const t = e.includes(n);
13
22
  return {
14
- callingCode: a(n),
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
- l as OFAC_BLOCKED_COUNTRIES,
31
+ e as OFAC_BLOCKED_COUNTRIES,
23
32
  u as countries,
24
33
  s as nonThrowingGetCountryCallingCode
25
34
  };
@@ -1,6 +1,15 @@
1
- const t = {
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
- t as countryNames
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.41",
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.41",
18
- "@coinbase/cdp-hooks": "^0.0.41"
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-core": "^0.0.41",
49
- "@coinbase/cdp-hooks": "^0.0.41"
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": "65 KB"
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",