@coinbase/cdp-react 0.0.23 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +2 -2
  2. package/dist/assets/AmountInput.css +1 -1
  3. package/dist/assets/AuthButton.css +1 -1
  4. package/dist/assets/Button.css +1 -1
  5. package/dist/assets/ButtonBase.css +1 -0
  6. package/dist/assets/CoinbaseFooter.css +1 -0
  7. package/dist/assets/ExchangeAmountInput.css +1 -1
  8. package/dist/assets/Fund.css +1 -0
  9. package/dist/assets/FundAmountInput.css +1 -0
  10. package/dist/assets/FundErrorScreen.css +1 -0
  11. package/dist/assets/FundForm.css +1 -0
  12. package/dist/assets/FundModal.css +1 -0
  13. package/dist/assets/FundPaymentMethods.css +1 -0
  14. package/dist/assets/FundPresetAmountInputs.css +1 -0
  15. package/dist/assets/FundTitle.css +1 -0
  16. package/dist/assets/FundTransactionStatus.css +1 -0
  17. package/dist/assets/Input.css +1 -1
  18. package/dist/assets/Modal.css +1 -1
  19. package/dist/assets/Select.css +1 -0
  20. package/dist/assets/ThemeProvider.css +1 -1
  21. package/dist/components/Fund/FundForm.d.ts +18 -0
  22. package/dist/components/Fund/FundForm.js +156 -0
  23. package/dist/components/Fund/FundProvider.d.ts +6 -0
  24. package/dist/components/Fund/FundProvider.js +128 -0
  25. package/dist/components/Fund/FundTitle.d.ts +5 -0
  26. package/dist/components/Fund/FundTitle.js +17 -0
  27. package/dist/components/Fund/components/FundAmountInput.d.ts +5 -0
  28. package/dist/components/Fund/components/FundAmountInput.js +58 -0
  29. package/dist/components/Fund/components/FundErrorScreen.d.ts +6 -0
  30. package/dist/components/Fund/components/FundErrorScreen.js +118 -0
  31. package/dist/components/Fund/components/FundPaymentMethods.d.ts +6 -0
  32. package/dist/components/Fund/components/FundPaymentMethods.js +55 -0
  33. package/dist/components/Fund/components/FundPresetAmountInputs.d.ts +6 -0
  34. package/dist/components/Fund/components/FundPresetAmountInputs.js +41 -0
  35. package/dist/components/Fund/components/FundTransactionStatus.d.ts +8 -0
  36. package/dist/components/Fund/components/FundTransactionStatus.js +106 -0
  37. package/dist/components/Fund/hooks/useBuyUrl.d.ts +14 -0
  38. package/dist/components/Fund/hooks/useBuyUrl.js +65 -0
  39. package/dist/components/Fund/hooks/useEmitLifecycleStatus.d.ts +5 -0
  40. package/dist/components/Fund/hooks/useEmitLifecycleStatus.js +14 -0
  41. package/dist/components/Fund/hooks/useExchangeRate.d.ts +11 -0
  42. package/dist/components/Fund/hooks/useExchangeRate.js +62 -0
  43. package/dist/components/Fund/hooks/usePaymentMethods.d.ts +11 -0
  44. package/dist/components/Fund/hooks/usePaymentMethods.js +112 -0
  45. package/dist/components/Fund/hooks/usePopupMonitor.d.ts +3 -0
  46. package/dist/components/Fund/hooks/usePopupMonitor.js +17 -0
  47. package/dist/components/Fund/hooks/useSetupOnrampEventListeners.d.ts +1 -0
  48. package/dist/components/Fund/hooks/useSetupOnrampEventListeners.js +56 -0
  49. package/dist/components/Fund/index.d.ts +10 -0
  50. package/dist/components/Fund/index.js +30 -0
  51. package/dist/components/Fund/types.d.ts +218 -0
  52. package/dist/components/Fund/types.js +1 -0
  53. package/dist/components/Fund/useFundReducer.d.ts +9 -0
  54. package/dist/components/Fund/useFundReducer.js +104 -0
  55. package/dist/components/Fund/utils/buildPaymentMethods.d.ts +5 -0
  56. package/dist/components/Fund/utils/buildPaymentMethods.js +57 -0
  57. package/dist/components/Fund/utils/setupOnrampEventListeners.d.ts +9 -0
  58. package/dist/components/Fund/utils/setupOnrampEventListeners.js +19 -0
  59. package/dist/components/Fund/utils/subscribeToWindowMessage.d.ts +14 -0
  60. package/dist/components/Fund/utils/subscribeToWindowMessage.js +24 -0
  61. package/dist/components/FundModal/index.d.ts +9 -0
  62. package/dist/components/FundModal/index.js +92 -0
  63. package/dist/components/SignIn/SignInFooter.d.ts +1 -1
  64. package/dist/components/SignIn/SignInFooter.js +4 -15
  65. package/dist/components/forms/ExchangeAmountInput/index.js +93 -65
  66. package/dist/components/forms/ExchangeAmountInput/types.d.ts +2 -1
  67. package/dist/components/forms/ExchangeAmountInput/useExchangeAmountInput.js +42 -38
  68. package/dist/components/forms/Input/index.d.ts +6 -2
  69. package/dist/components/forms/Input/index.js +27 -12
  70. package/dist/components/forms/PhoneNumberInput/index.d.ts +2 -2
  71. package/dist/components/forms/Select/index.d.ts +21 -0
  72. package/dist/components/forms/Select/index.js +74 -0
  73. package/dist/components/ui/Button/index.d.ts +4 -5
  74. package/dist/components/ui/Button/index.js +35 -56
  75. package/dist/components/ui/ButtonBase/index.d.ts +8 -0
  76. package/dist/components/ui/ButtonBase/index.js +45 -0
  77. package/dist/components/ui/CoinbaseFooter/index.d.ts +2 -0
  78. package/dist/components/ui/CoinbaseFooter/index.js +19 -0
  79. package/dist/components/ui/LoadingSkeleton/index.d.ts +3 -2
  80. package/dist/components/ui/LoadingSkeleton/index.js +9 -15
  81. package/dist/components/ui/LoadingSpinner/index.d.ts +9 -2
  82. package/dist/components/ui/LoadingSpinner/index.js +39 -17
  83. package/dist/icons/IconAppleLogo.d.ts +2 -0
  84. package/dist/icons/IconAppleLogo.js +10 -0
  85. package/dist/icons/IconCheck.d.ts +2 -0
  86. package/dist/icons/IconCheck.js +14 -0
  87. package/dist/icons/IconChevronDown.d.ts +2 -0
  88. package/dist/icons/IconChevronDown.js +14 -0
  89. package/dist/icons/IconCoinbaseMark.d.ts +2 -0
  90. package/dist/icons/IconCoinbaseMark.js +13 -0
  91. package/dist/icons/IconCreditCard.d.ts +2 -0
  92. package/dist/icons/IconCreditCard.js +10 -0
  93. package/dist/icons/IconExclamationTriangle.d.ts +2 -0
  94. package/dist/icons/IconExclamationTriangle.js +14 -0
  95. package/dist/icons/index.d.ts +3 -0
  96. package/dist/icons/index.js +20 -14
  97. package/dist/index.d.ts +2 -0
  98. package/dist/index.js +86 -69
  99. package/dist/theme/theme.d.ts +120 -2
  100. package/dist/theme/tokens.d.ts +346 -0
  101. package/dist/theme/tokens.js +76 -8
  102. package/dist/utils/formatFiat.d.ts +1 -0
  103. package/dist/utils/formatFiat.js +13 -0
  104. package/dist/utils/openPopup.d.ts +7 -0
  105. package/dist/utils/openPopup.js +15 -0
  106. package/package.json +7 -6
  107. package/dist/assets/SignInFooter.css +0 -1
@@ -0,0 +1,92 @@
1
+ import { jsxs as t, jsx as o, Fragment as x } from "react/jsx-runtime";
2
+ import { useId as O, useState as v, useCallback as h } from "react";
3
+ import { useAppConfig as T } from "../CDPReactProvider/index.js";
4
+ import { unstable_Fund as j, unstable_FundFooter as I } from "../Fund/index.js";
5
+ import { Button as p } from "../ui/Button/index.js";
6
+ import { Modal as $, ModalTrigger as z, ModalContent as A, ModalTitle as S, ModalClose as k } from "../ui/Modal/index.js";
7
+ import { VisuallyHidden as M } from "../ui/VisuallyHidden/index.js";
8
+ import { IconXMark as U } from "../../icons/IconXMark.js";
9
+ import { FundTitle as a } from "../Fund/FundTitle.js";
10
+ import { FundForm as V } from "../Fund/FundForm.js";
11
+ import '../../assets/FundModal.css';const W = "FundModal-module__trigger___2IuXj", X = "FundModal-module__fund___1AmQa", q = "FundModal-module__title___lNsoT", B = "FundModal-module__content___9f3ze", n = {
12
+ trigger: W,
13
+ fund: X,
14
+ "no-footer": "FundModal-module__no-footer___WKV78",
15
+ "title-buttons": "FundModal-module__title-buttons___Lctf7",
16
+ "close-button": "FundModal-module__close-button___jzdFM",
17
+ "close-icon": "FundModal-module__close-icon___WoA4a",
18
+ "fund-inner": "FundModal-module__fund-inner___UuOq3",
19
+ "tx-status": "FundModal-module__tx-status___fc-3f",
20
+ title: q,
21
+ content: B
22
+ }, Y = ({
23
+ children: b,
24
+ open: i,
25
+ setIsOpen: c,
26
+ openIn: u,
27
+ submitLabel: _,
28
+ title: d,
29
+ ...m
30
+ }) => {
31
+ const { showCoinbaseFooter: f } = T(), l = O(), r = i !== void 0, [g, F] = v(!1), C = r ? i : g, s = h(
32
+ (e) => r ? c?.(e) : F(e),
33
+ [r, c, F]
34
+ ), N = h(() => {
35
+ s(!1);
36
+ }, [s]);
37
+ return /* @__PURE__ */ t($, { open: C, onOpenChange: s, children: [
38
+ /* @__PURE__ */ o(z, { asChild: !0, children: b || /* @__PURE__ */ t(p, { variant: "primary", className: n.trigger, children: [
39
+ "Deposit ",
40
+ m.cryptoCurrency.toUpperCase()
41
+ ] }) }),
42
+ /* @__PURE__ */ o(A, { "aria-describedby": void 0, children: /* @__PURE__ */ o(
43
+ j,
44
+ {
45
+ className: `${n.fund} ${f ? "" : n["no-footer"]}`,
46
+ openIn: u,
47
+ submitLabel: _,
48
+ title: d,
49
+ ...m,
50
+ children: /* @__PURE__ */ t(x, { children: [
51
+ /* @__PURE__ */ o(M, { children: /* @__PURE__ */ o(S, { asChild: !0, children: /* @__PURE__ */ o(a, { as: "span", children: d }) }) }),
52
+ /* @__PURE__ */ o(
53
+ V,
54
+ {
55
+ "aria-labelledby": l,
56
+ openIn: u,
57
+ unmountOnTransactionSuccess: !0,
58
+ unmount: N,
59
+ submitLabel: _,
60
+ children: ({ view: e, Content: y }) => /* @__PURE__ */ t(
61
+ "div",
62
+ {
63
+ className: `${n["fund-inner"]} ${e === "transaction-status" ? n["tx-status"] : ""}`,
64
+ children: [
65
+ /* @__PURE__ */ t("div", { className: n["title-buttons"], children: [
66
+ e === "error" ? /* @__PURE__ */ o(M, { children: /* @__PURE__ */ o(a, { id: l, children: d }) }) : /* @__PURE__ */ o(a, { className: n.title, id: l, children: d }),
67
+ /* @__PURE__ */ o(k, { asChild: !0, children: /* @__PURE__ */ o(
68
+ p,
69
+ {
70
+ className: n["close-button"],
71
+ "aria-label": "Close",
72
+ size: "md",
73
+ variant: "transparentSecondary",
74
+ children: /* @__PURE__ */ o(U, { className: n["close-icon"] })
75
+ }
76
+ ) })
77
+ ] }),
78
+ /* @__PURE__ */ o("div", { className: n.content, children: y })
79
+ ]
80
+ }
81
+ )
82
+ }
83
+ ),
84
+ f && /* @__PURE__ */ o(I, {})
85
+ ] })
86
+ }
87
+ ) })
88
+ ] });
89
+ };
90
+ export {
91
+ Y as unstable_FundModal
92
+ };
@@ -1,2 +1,2 @@
1
1
  import { HTMLAttributes } from 'react';
2
- export declare const SignInFooter: ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const SignInFooter: (props: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
@@ -1,18 +1,7 @@
1
- import { jsxs as e, jsx as o } from "react/jsx-runtime";
1
+ import { jsx as r } from "react/jsx-runtime";
2
2
  import "react";
3
- import { IconCoinbaseWordmark as c } from "../../icons/IconCoinbaseWordmark.js";
4
- import { IconLock as s } from "../../icons/IconLock.js";
5
- import '../../assets/SignInFooter.css';const t = "SignInFooter-module__footer___DLNrl", a = "SignInFooter-module__icon___hFhfx", n = {
6
- footer: t,
7
- icon: a,
8
- "coinbase-icon": "SignInFooter-module__coinbase-icon___NeFOp"
9
- }, f = ({ className: r = "", ...i }) => /* @__PURE__ */ e("div", { className: `${n.footer} ${r}`, ...i, children: [
10
- /* @__PURE__ */ o(s, { className: n.icon }),
11
- /* @__PURE__ */ e("p", { children: [
12
- /* @__PURE__ */ o("span", { children: "Secured by " }),
13
- /* @__PURE__ */ o(c, { className: n["coinbase-icon"], "aria-label": "Coinbase" })
14
- ] })
15
- ] });
3
+ import { CoinbaseFooter as t } from "../ui/CoinbaseFooter/index.js";
4
+ const n = (o) => /* @__PURE__ */ r(t, { ...o });
16
5
  export {
17
- f as SignInFooter
6
+ n as SignInFooter
18
7
  };
@@ -1,87 +1,115 @@
1
- import { jsxs as o, Fragment as C, jsx as n } from "react/jsx-runtime";
2
- import { forwardRef as L, useCallback as z } from "react";
3
- import { AmountInput as D } from "../AmountInput/index.js";
4
- import { DEFAULT_LOCALE as F } from "../../../data/locale.js";
5
- import { IconArrowsUpDown as V } from "../../../icons/IconArrowsUpDown.js";
6
- import { useExchangeAmountInput as j } from "./useExchangeAmountInput.js";
7
- import '../../../assets/ExchangeAmountInput.css';const k = "ExchangeAmountInput-module__icon___b5JpF", t = {
1
+ import { jsxs as u, Fragment as $, jsx as n } from "react/jsx-runtime";
2
+ import { forwardRef as v, useCallback as C } from "react";
3
+ import { AmountInput as L } from "../AmountInput/index.js";
4
+ import { Button as z } from "../../ui/Button/index.js";
5
+ import { LoadingSkeleton as j } from "../../ui/LoadingSkeleton/index.js";
6
+ import { DEFAULT_LOCALE as D } from "../../../data/locale.js";
7
+ import { IconArrowsUpDown as F } from "../../../icons/IconArrowsUpDown.js";
8
+ import { useExchangeAmountInput as S } from "./useExchangeAmountInput.js";
9
+ import '../../../assets/ExchangeAmountInput.css';const V = "ExchangeAmountInput-module__icon___b5JpF", t = {
8
10
  "flex-row": "ExchangeAmountInput-module__flex-row___ZKB-Q",
9
11
  "gap-1": "ExchangeAmountInput-module__gap-1___vuNQW",
10
12
  "gap-2": "ExchangeAmountInput-module__gap-2___4-s-b",
11
13
  "swap-button": "ExchangeAmountInput-module__swap-button___i9lSz",
12
- icon: k
13
- }, v = L(
14
+ icon: V,
15
+ "output-loading-skeleton": "ExchangeAmountInput-module__output-loading-skeleton___gKMEZ",
16
+ "output-loading-skeleton-placeholder": "ExchangeAmountInput-module__output-loading-skeleton-placeholder___1-jT-",
17
+ "output-currency": "ExchangeAmountInput-module__output-currency___vlpC1"
18
+ }, B = v(
14
19
  ({
15
- cryptoAmount: c,
16
- cryptoCurrency: u,
17
- cryptoDecimalPlaces: s,
18
- fiatAmount: l,
19
- fiatCurrency: e,
20
- fiatDecimalPlaces: r,
21
- exchangeRate: i,
22
- inputType: a,
23
- locale: p = F,
24
- setCryptoAmount: _,
25
- setFiatAmount: d,
26
- setInputType: m,
27
- ...g
28
- }, h) => {
29
- const f = a === "fiat" ? `switch input to ${u}` : `switch input to ${e}`, {
30
- inputValue: x,
31
- inputCurrency: w,
32
- inputDecimalPlaces: A,
33
- formatOutputValue: b,
34
- outputValue: E,
35
- outputCurrency: I,
36
- handleChange: N
37
- } = j({
38
- cryptoAmount: c,
39
- cryptoCurrency: u,
40
- cryptoDecimalPlaces: s,
41
- exchangeRate: i,
42
- fiatAmount: l,
43
- fiatCurrency: e,
44
- fiatDecimalPlaces: r,
45
- inputType: a,
46
- locale: p,
47
- setCryptoAmount: _,
48
- setFiatAmount: d
49
- }), $ = z(() => {
50
- m(a === "fiat" ? "crypto" : "fiat");
51
- }, [a, m]);
52
- return /* @__PURE__ */ o(C, { children: [
20
+ cryptoAmount: i,
21
+ cryptoCurrency: l,
22
+ cryptoDecimalPlaces: _,
23
+ fiatAmount: d,
24
+ fiatCurrency: p,
25
+ fiatDecimalPlaces: g,
26
+ exchangeRate: a,
27
+ inputType: o,
28
+ isExchangeRatePending: h,
29
+ locale: c = D,
30
+ setCryptoAmount: x,
31
+ setFiatAmount: f,
32
+ setInputType: r,
33
+ ...A
34
+ }, E) => {
35
+ const w = o === "fiat" ? `switch input to ${l}` : `switch input to ${p}`, {
36
+ inputValue: I,
37
+ inputCurrency: N,
38
+ inputDecimalPlaces: b,
39
+ formatOutputValue: s,
40
+ outputValue: e,
41
+ outputCurrency: m,
42
+ handleChange: k
43
+ } = S({
44
+ cryptoAmount: i,
45
+ cryptoCurrency: l,
46
+ cryptoDecimalPlaces: _,
47
+ exchangeRate: a,
48
+ fiatAmount: d,
49
+ fiatCurrency: p,
50
+ fiatDecimalPlaces: g,
51
+ inputType: o,
52
+ locale: c,
53
+ setCryptoAmount: x,
54
+ setFiatAmount: f
55
+ }), y = C(() => {
56
+ r(o === "fiat" ? "crypto" : "fiat");
57
+ }, [o, r]);
58
+ return /* @__PURE__ */ u($, { children: [
53
59
  /* @__PURE__ */ n(
54
- D,
60
+ L,
55
61
  {
56
- ref: h,
57
- amount: x,
58
- unit: w,
59
- decimalPlaces: A,
60
- locale: p,
61
- setAmount: N,
62
- ...g
62
+ ref: E,
63
+ amount: I,
64
+ unit: N,
65
+ decimalPlaces: b,
66
+ locale: c,
67
+ setAmount: k,
68
+ ...A
63
69
  }
64
70
  ),
65
- /* @__PURE__ */ o("span", { className: `${t["flex-row"]} ${t["gap-1"]}`, children: [
71
+ !a && h && /* @__PURE__ */ n(j, { className: t["output-loading-skeleton"], children: /* @__PURE__ */ u("span", { className: t["output-loading-skeleton-placeholder"], children: [
72
+ s(e ?? 0),
73
+ " ",
74
+ m
75
+ ] }) }),
76
+ a && /* @__PURE__ */ u("span", { className: `${t["flex-row"]} ${t["gap-1"]}`, children: [
66
77
  /* @__PURE__ */ n(
67
- "button",
78
+ z,
68
79
  {
69
- "aria-label": f,
80
+ "aria-label": w,
70
81
  className: t["swap-button"],
71
- onClick: $,
82
+ onClick: y,
72
83
  type: "button",
73
- children: /* @__PURE__ */ n(V, { className: t.icon })
84
+ size: "xs",
85
+ variant: "transparentSecondary",
86
+ children: /* @__PURE__ */ n(F, { className: t.icon })
74
87
  }
75
88
  ),
76
- /* @__PURE__ */ o("span", { className: `${t["flex-row"]} ${t["gap-2"]}`, children: [
77
- /* @__PURE__ */ n("span", { "data-part": "amount-input-unsized-value", children: b(E ?? 0) }),
78
- /* @__PURE__ */ n("span", { "data-part": "amount-input-unsized-currency", children: I })
89
+ /* @__PURE__ */ u("span", { className: `${t["flex-row"]} ${t["gap-2"]}`, children: [
90
+ /* @__PURE__ */ n(
91
+ "span",
92
+ {
93
+ "data-part": "amount-output-unsized-value",
94
+ "data-testid": "exchange-amount-output-value",
95
+ children: s(isNaN(e ?? 0) ? 0 : e ?? 0)
96
+ }
97
+ ),
98
+ /* @__PURE__ */ n(
99
+ "span",
100
+ {
101
+ "data-part": "amount-output-unsized-currency",
102
+ "data-testid": "exchange-amount-output-currency",
103
+ className: t["output-currency"],
104
+ children: m
105
+ }
106
+ )
79
107
  ] })
80
108
  ] })
81
109
  ] });
82
110
  }
83
111
  );
84
- v.displayName = "ExchangeAmountInput";
112
+ B.displayName = "ExchangeAmountInput";
85
113
  export {
86
- v as ExchangeAmountInput
114
+ B as ExchangeAmountInput
87
115
  };
@@ -4,11 +4,12 @@ export type ExchangeAmountInputProps = {
4
4
  cryptoAmount: AmountInputProps["amount"];
5
5
  cryptoDecimalPlaces?: AmountInputProps["decimalPlaces"];
6
6
  cryptoCurrency: NonNullable<AmountInputProps["unit"]>;
7
- exchangeRate: string;
7
+ exchangeRate?: number;
8
8
  fiatAmount: AmountInputProps["amount"];
9
9
  fiatCurrency: NonNullable<AmountInputProps["unit"]>;
10
10
  fiatDecimalPlaces?: AmountInputProps["decimalPlaces"];
11
11
  inputType: InputType;
12
+ isExchangeRatePending?: boolean;
12
13
  locale?: string;
13
14
  max?: number;
14
15
  min?: number;
@@ -1,10 +1,10 @@
1
- import { Big as h } from "big.js";
1
+ import { Big as B } from "big.js";
2
2
  import { useCallback as u, useMemo as _ } from "react";
3
3
  import { useNumberParseAndFormat as I } from "../AmountInput/useNumberParseAndFormat.js";
4
4
  import { DEFAULT_LOCALE as k } from "../../../data/locale.js";
5
5
  const O = (f) => {
6
6
  try {
7
- return h(f);
7
+ return B(f);
8
8
  } catch {
9
9
  return null;
10
10
  }
@@ -12,87 +12,91 @@ const O = (f) => {
12
12
  cryptoAmount: f,
13
13
  cryptoCurrency: F,
14
14
  cryptoDecimalPlaces: n = 8,
15
- exchangeRate: a,
16
- fiatAmount: N,
17
- fiatCurrency: V,
15
+ exchangeRate: m,
16
+ fiatAmount: V,
17
+ fiatCurrency: h,
18
18
  fiatDecimalPlaces: i = 2,
19
19
  inputType: o,
20
20
  locale: E = k,
21
- setFiatAmount: m,
21
+ setFiatAmount: s,
22
22
  setCryptoAmount: d
23
23
  }) => {
24
- const x = u(
24
+ const L = u(
25
25
  (r) => {
26
- m(r);
26
+ s(r);
27
27
  const t = O(r);
28
28
  if (r === 0 || isNaN(r) || t === null) {
29
- d(0);
29
+ d(NaN);
30
30
  return;
31
31
  }
32
- const s = t.times(a).round(n, h.roundDown);
33
- d(s.eq(0) ? 0 : +s.toFixed());
32
+ const N = t.times(m ?? 0);
33
+ d(
34
+ N.eq(0) ? 0 : +N.toFixed(n, B.roundDown)
35
+ );
34
36
  },
35
- [a, m, d, n]
36
- ), L = u(
37
+ [m, s, d, n]
38
+ ), b = u(
37
39
  (r) => {
38
40
  d(r);
39
41
  const t = O(r);
40
42
  if (r === 0 || isNaN(r) || t === null) {
41
- m(0);
43
+ s(NaN);
42
44
  return;
43
45
  }
44
- const s = t.div(a).round(i, h.roundDown);
45
- m(s.eq(0) ? 0 : +s.toFixed());
46
+ const N = m ? t.div(m) : B(0);
47
+ s(
48
+ N.eq(0) ? 0 : +N.toFixed(i, B.roundDown)
49
+ );
46
50
  },
47
- [a, m, d, i]
48
- ), b = u(
51
+ [m, s, d, i]
52
+ ), q = u(
49
53
  (r, t) => {
50
- o === "fiat" ? x(r) : L(r), t?.(r);
54
+ o === "fiat" ? L(r) : b(r), t?.(r);
51
55
  },
52
- [x, L, o]
53
- ), { formatter: g } = I({
56
+ [L, b, o]
57
+ ), { formatter: a } = I({
54
58
  inputValue: "",
55
59
  locale: E,
56
60
  options: {
57
61
  maximumFractionDigits: i,
58
62
  minimumFractionDigits: 0
59
63
  }
60
- }), { formatter: B } = I({
64
+ }), { formatter: g } = I({
61
65
  inputValue: "",
62
66
  locale: E,
63
67
  options: {
64
68
  maximumFractionDigits: n,
65
69
  minimumFractionDigits: 0
66
70
  }
67
- }), q = u(
68
- (r) => o === "fiat" ? g.format(r) : B.format(r),
69
- [B, g, o]
70
- ), w = u(
71
- (r) => o === "fiat" ? B.format(r) : g.format(r),
72
- [B, g, o]
71
+ }), w = u(
72
+ (r) => o === "fiat" ? a.format(r) : g.format(r),
73
+ [g, a, o]
74
+ ), x = u(
75
+ (r) => o === "fiat" ? g.format(r) : a.format(r),
76
+ [g, a, o]
73
77
  );
74
78
  return _(
75
79
  () => ({
76
- inputCurrency: o === "fiat" ? V : F,
80
+ inputCurrency: o === "fiat" ? h : F,
77
81
  inputDecimalPlaces: o === "fiat" ? i : n,
78
- inputValue: o === "fiat" ? N : f,
79
- formatInputValue: q,
80
- formatOutputValue: w,
81
- handleChange: b,
82
- outputCurrency: o === "fiat" ? F : V,
82
+ inputValue: o === "fiat" ? V : f,
83
+ formatInputValue: w,
84
+ formatOutputValue: x,
85
+ handleChange: q,
86
+ outputCurrency: o === "fiat" ? F : h,
83
87
  outputDecimalPlaces: o === "fiat" ? n : i,
84
- outputValue: o === "fiat" ? f : N
88
+ outputValue: o === "fiat" ? f : V
85
89
  }),
86
90
  [
87
91
  f,
88
92
  F,
89
93
  n,
90
- N,
91
94
  V,
95
+ h,
92
96
  i,
93
- q,
94
97
  w,
95
- b,
98
+ x,
99
+ q,
96
100
  o
97
101
  ]
98
102
  );
@@ -1,4 +1,8 @@
1
1
  import { FormValidityStateProps } from '@radix-ui/react-form';
2
2
  import { InputHTMLAttributes } from 'react';
3
- export declare const Input: import('react').ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & import('react').RefAttributes<HTMLInputElement>>;
4
- export declare const withValidityState: (props: InputHTMLAttributes<HTMLInputElement>) => FormValidityStateProps["children"];
3
+ import { InputSize } from '../../../theme/theme';
4
+ export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
5
+ size?: InputSize;
6
+ }
7
+ export declare const Input: import('react').ForwardRefExoticComponent<InputProps & import('react').RefAttributes<HTMLInputElement>>;
8
+ export declare const withValidityState: (props: InputProps) => FormValidityStateProps["children"];
@@ -1,17 +1,32 @@
1
- import { jsx as a } from "react/jsx-runtime";
1
+ import { jsx as m } from "react/jsx-runtime";
2
2
  import "@radix-ui/react-form";
3
- import { forwardRef as p } from "react";
4
- import '../../../assets/Input.css';const u = "Input-module__input___-mK8z", e = {
5
- input: u
6
- }, r = p(
7
- ({ className: i = "", ...n }, t) => /* @__PURE__ */ a("input", { ref: t, className: `${e.input} ${i}`, ...n })
3
+ import { forwardRef as p, useMemo as l } from "react";
4
+ import '../../../assets/Input.css';const d = "Input-module__input___-mK8z", t = {
5
+ input: d,
6
+ "size-lg": "Input-module__size-lg___IYoRG",
7
+ "size-md": "Input-module__size-md___8hkn5",
8
+ "size-sm": "Input-module__size-sm___cnynF",
9
+ "size-xs": "Input-module__size-xs___aK-NH"
10
+ }, o = p(
11
+ ({ className: e = "", size: s = "md", ...i }, n) => {
12
+ const _ = l(() => {
13
+ const u = [t.input], a = {
14
+ lg: t["size-lg"],
15
+ md: t["size-md"],
16
+ sm: t["size-sm"],
17
+ xs: t["size-xs"]
18
+ };
19
+ return s && u.push(a[s]), u.join(" ");
20
+ }, [s]);
21
+ return /* @__PURE__ */ m("input", { ref: n, className: `${_} ${e}`, ...i });
22
+ }
8
23
  );
9
- r.displayName = "Input";
10
- const m = (i) => (t) => {
11
- const o = t === void 0 || t.valid ? void 0 : !0;
12
- return /* @__PURE__ */ a(r, { ...i, "aria-invalid": o });
24
+ o.displayName = "Input";
25
+ const I = (e) => (i) => {
26
+ const n = i === void 0 || i.valid ? void 0 : !0;
27
+ return /* @__PURE__ */ m(o, { ...e, "aria-invalid": n });
13
28
  };
14
29
  export {
15
- r as Input,
16
- m as withValidityState
30
+ o as Input,
31
+ I as withValidityState
17
32
  };
@@ -1,7 +1,7 @@
1
1
  import { CountryCode } from 'libphonenumber-js';
2
- import { InputHTMLAttributes } from 'react';
2
+ import { InputProps } from '../Input/Input';
3
3
  import { PhoneNumber } from '../../../utils/parseValuesFromPhoneNumber';
4
- export interface PhoneNumberInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "onChange"> {
4
+ export interface PhoneNumberInputProps extends Omit<InputProps, "value" | "onChange"> {
5
5
  onCountryCodeChange: (newCountry: CountryCode) => void;
6
6
  countryCode?: CountryCode;
7
7
  onPhoneNumberChange: (phoneNumber: PhoneNumber) => void;
@@ -0,0 +1,21 @@
1
+ import { SelectProps as SelectPropsPrimitive, SelectContentProps as SelectContentPropsPrimitive, SelectItemProps as SelectItemPropsPrimitive, SelectTriggerProps as SelectTriggerPropsPrimitive, SelectValueProps } from '@radix-ui/react-select';
2
+ import { ReactNode } from 'react';
3
+ import { InputSize } from '../../../theme/theme';
4
+ export interface SelectProps extends SelectPropsPrimitive {
5
+ className?: string;
6
+ }
7
+ export interface SelectTriggerProps extends SelectTriggerPropsPrimitive {
8
+ className?: string;
9
+ placeholder?: SelectValueProps["placeholder"];
10
+ size?: InputSize;
11
+ }
12
+ export interface SelectContentProps extends SelectContentPropsPrimitive {
13
+ className?: string;
14
+ }
15
+ export interface SelectItemProps extends SelectItemPropsPrimitive {
16
+ indicator?: boolean | ReactNode;
17
+ }
18
+ export declare const Select: ({ children, ...props }: SelectProps) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const SelectTrigger: import('react').ForwardRefExoticComponent<SelectTriggerProps & import('react').RefAttributes<HTMLButtonElement>>;
20
+ export declare const SelectContent: import('react').ForwardRefExoticComponent<SelectContentProps & import('react').RefAttributes<HTMLDivElement>>;
21
+ export declare const SelectItem: import('react').ForwardRefExoticComponent<SelectItemProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,74 @@
1
+ import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
+ import { SelectTrigger as u, SelectValue as p, SelectIcon as h, SelectPortal as f, SelectContent as g, SelectScrollUpButton as C, SelectViewport as I, SelectScrollDownButton as N, SelectItem as $, SelectItemText as y, SelectItemIndicator as T, Select as w } from "@radix-ui/react-select";
3
+ import { forwardRef as a } from "react";
4
+ import { useTheme as x } from "../../ThemeProvider/index.js";
5
+ import { ButtonBase as B } from "../../ui/ButtonBase/index.js";
6
+ import { IconCheck as V } from "../../../icons/IconCheck.js";
7
+ import { IconChevronDown as m } from "../../../icons/IconChevronDown.js";
8
+ import "../../../theme/theme.js";
9
+ import '../../../assets/Select.css';const o = {
10
+ "select-trigger": "Select-module__select-trigger___yqioM",
11
+ "select-icon": "Select-module__select-icon___hE7Wy",
12
+ "select-content": "Select-module__select-content___6R8J9",
13
+ "select-item": "Select-module__select-item___12l2C",
14
+ "rotate-180": "Select-module__rotate-180___KuvGV"
15
+ }, K = ({ children: l, ...t }) => /* @__PURE__ */ e(w, { ...t, children: l }), b = a(
16
+ ({ children: l, className: t = "", placeholder: c = "Select an option", size: r = "md", ...s }, n) => /* @__PURE__ */ e(u, { ...s, asChild: !0, children: l || /* @__PURE__ */ i(
17
+ B,
18
+ {
19
+ className: `${o["select-trigger"]} ${t}`,
20
+ fullWidth: !0,
21
+ ref: n,
22
+ size: r,
23
+ children: [
24
+ /* @__PURE__ */ e(p, { placeholder: c }),
25
+ /* @__PURE__ */ e(h, { asChild: !0, children: /* @__PURE__ */ e(m, { className: o["select-icon"] }) })
26
+ ]
27
+ }
28
+ ) })
29
+ );
30
+ b.displayName = "SelectTrigger";
31
+ const j = a(
32
+ ({
33
+ children: l,
34
+ className: t = "",
35
+ style: c,
36
+ position: r = "popper",
37
+ side: s = "bottom",
38
+ sideOffset: n = 1,
39
+ ..._
40
+ }, d) => {
41
+ const { cssVariables: S } = x();
42
+ return /* @__PURE__ */ e(f, { children: /* @__PURE__ */ i(
43
+ g,
44
+ {
45
+ position: r,
46
+ side: s,
47
+ sideOffset: n,
48
+ className: `${o["select-content"]} ${t}`,
49
+ ref: d,
50
+ style: c ? { ...S, ...c } : S,
51
+ ..._,
52
+ children: [
53
+ /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(m, { className: o["rotate-180"] }) }),
54
+ /* @__PURE__ */ e(I, { children: l }),
55
+ /* @__PURE__ */ e(N, { children: /* @__PURE__ */ e(m, {}) })
56
+ ]
57
+ }
58
+ ) });
59
+ }
60
+ );
61
+ j.displayName = "SelectContent";
62
+ const v = a(
63
+ ({ children: l, indicator: t, ...c }, r) => /* @__PURE__ */ i($, { ...c, ref: r, className: o["select-item"], children: [
64
+ /* @__PURE__ */ e(y, { children: l }),
65
+ t && /* @__PURE__ */ e(T, { asChild: !0, children: typeof t == "boolean" ? /* @__PURE__ */ e(V, {}) : t })
66
+ ] })
67
+ );
68
+ v.displayName = "SelectItem";
69
+ export {
70
+ K as Select,
71
+ j as SelectContent,
72
+ v as SelectItem,
73
+ b as SelectTrigger
74
+ };
@@ -1,9 +1,8 @@
1
- import { ButtonHTMLAttributes, ReactNode } from 'react';
2
- import { ButtonSize, ButtonVariant } from '../../../theme/theme';
3
- export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4
- isPending?: boolean;
1
+ import { ReactNode } from 'react';
2
+ import { ButtonBaseProps } from '../ButtonBase';
3
+ import { ButtonVariant } from '../../../theme/theme';
4
+ export interface ButtonProps extends ButtonBaseProps {
5
5
  pendingLabel?: ReactNode;
6
- size?: ButtonSize;
7
6
  variant?: ButtonVariant;
8
7
  }
9
8
  export declare const Button: import('react').ForwardRefExoticComponent<ButtonProps & import('react').RefAttributes<HTMLButtonElement>>;