@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.
- package/README.md +2 -2
- package/dist/assets/AmountInput.css +1 -1
- package/dist/assets/AuthButton.css +1 -1
- package/dist/assets/Button.css +1 -1
- package/dist/assets/ButtonBase.css +1 -0
- package/dist/assets/CoinbaseFooter.css +1 -0
- package/dist/assets/ExchangeAmountInput.css +1 -1
- package/dist/assets/Fund.css +1 -0
- package/dist/assets/FundAmountInput.css +1 -0
- package/dist/assets/FundErrorScreen.css +1 -0
- package/dist/assets/FundForm.css +1 -0
- package/dist/assets/FundModal.css +1 -0
- package/dist/assets/FundPaymentMethods.css +1 -0
- package/dist/assets/FundPresetAmountInputs.css +1 -0
- package/dist/assets/FundTitle.css +1 -0
- package/dist/assets/FundTransactionStatus.css +1 -0
- package/dist/assets/Input.css +1 -1
- package/dist/assets/Modal.css +1 -1
- package/dist/assets/Select.css +1 -0
- package/dist/assets/ThemeProvider.css +1 -1
- package/dist/components/Fund/FundForm.d.ts +18 -0
- package/dist/components/Fund/FundForm.js +156 -0
- package/dist/components/Fund/FundProvider.d.ts +6 -0
- package/dist/components/Fund/FundProvider.js +128 -0
- package/dist/components/Fund/FundTitle.d.ts +5 -0
- package/dist/components/Fund/FundTitle.js +17 -0
- package/dist/components/Fund/components/FundAmountInput.d.ts +5 -0
- package/dist/components/Fund/components/FundAmountInput.js +58 -0
- package/dist/components/Fund/components/FundErrorScreen.d.ts +6 -0
- package/dist/components/Fund/components/FundErrorScreen.js +118 -0
- package/dist/components/Fund/components/FundPaymentMethods.d.ts +6 -0
- package/dist/components/Fund/components/FundPaymentMethods.js +55 -0
- package/dist/components/Fund/components/FundPresetAmountInputs.d.ts +6 -0
- package/dist/components/Fund/components/FundPresetAmountInputs.js +41 -0
- package/dist/components/Fund/components/FundTransactionStatus.d.ts +8 -0
- package/dist/components/Fund/components/FundTransactionStatus.js +106 -0
- package/dist/components/Fund/hooks/useBuyUrl.d.ts +14 -0
- package/dist/components/Fund/hooks/useBuyUrl.js +65 -0
- package/dist/components/Fund/hooks/useEmitLifecycleStatus.d.ts +5 -0
- package/dist/components/Fund/hooks/useEmitLifecycleStatus.js +14 -0
- package/dist/components/Fund/hooks/useExchangeRate.d.ts +11 -0
- package/dist/components/Fund/hooks/useExchangeRate.js +62 -0
- package/dist/components/Fund/hooks/usePaymentMethods.d.ts +11 -0
- package/dist/components/Fund/hooks/usePaymentMethods.js +112 -0
- package/dist/components/Fund/hooks/usePopupMonitor.d.ts +3 -0
- package/dist/components/Fund/hooks/usePopupMonitor.js +17 -0
- package/dist/components/Fund/hooks/useSetupOnrampEventListeners.d.ts +1 -0
- package/dist/components/Fund/hooks/useSetupOnrampEventListeners.js +56 -0
- package/dist/components/Fund/index.d.ts +10 -0
- package/dist/components/Fund/index.js +30 -0
- package/dist/components/Fund/types.d.ts +218 -0
- package/dist/components/Fund/types.js +1 -0
- package/dist/components/Fund/useFundReducer.d.ts +9 -0
- package/dist/components/Fund/useFundReducer.js +104 -0
- package/dist/components/Fund/utils/buildPaymentMethods.d.ts +5 -0
- package/dist/components/Fund/utils/buildPaymentMethods.js +57 -0
- package/dist/components/Fund/utils/setupOnrampEventListeners.d.ts +9 -0
- package/dist/components/Fund/utils/setupOnrampEventListeners.js +19 -0
- package/dist/components/Fund/utils/subscribeToWindowMessage.d.ts +14 -0
- package/dist/components/Fund/utils/subscribeToWindowMessage.js +24 -0
- package/dist/components/FundModal/index.d.ts +9 -0
- package/dist/components/FundModal/index.js +92 -0
- package/dist/components/SignIn/SignInFooter.d.ts +1 -1
- package/dist/components/SignIn/SignInFooter.js +4 -15
- package/dist/components/forms/ExchangeAmountInput/index.js +93 -65
- package/dist/components/forms/ExchangeAmountInput/types.d.ts +2 -1
- package/dist/components/forms/ExchangeAmountInput/useExchangeAmountInput.js +42 -38
- package/dist/components/forms/Input/index.d.ts +6 -2
- package/dist/components/forms/Input/index.js +27 -12
- package/dist/components/forms/PhoneNumberInput/index.d.ts +2 -2
- package/dist/components/forms/Select/index.d.ts +21 -0
- package/dist/components/forms/Select/index.js +74 -0
- package/dist/components/ui/Button/index.d.ts +4 -5
- package/dist/components/ui/Button/index.js +35 -56
- package/dist/components/ui/ButtonBase/index.d.ts +8 -0
- package/dist/components/ui/ButtonBase/index.js +45 -0
- package/dist/components/ui/CoinbaseFooter/index.d.ts +2 -0
- package/dist/components/ui/CoinbaseFooter/index.js +19 -0
- package/dist/components/ui/LoadingSkeleton/index.d.ts +3 -2
- package/dist/components/ui/LoadingSkeleton/index.js +9 -15
- package/dist/components/ui/LoadingSpinner/index.d.ts +9 -2
- package/dist/components/ui/LoadingSpinner/index.js +39 -17
- package/dist/icons/IconAppleLogo.d.ts +2 -0
- package/dist/icons/IconAppleLogo.js +10 -0
- package/dist/icons/IconCheck.d.ts +2 -0
- package/dist/icons/IconCheck.js +14 -0
- package/dist/icons/IconChevronDown.d.ts +2 -0
- package/dist/icons/IconChevronDown.js +14 -0
- package/dist/icons/IconCoinbaseMark.d.ts +2 -0
- package/dist/icons/IconCoinbaseMark.js +13 -0
- package/dist/icons/IconCreditCard.d.ts +2 -0
- package/dist/icons/IconCreditCard.js +10 -0
- package/dist/icons/IconExclamationTriangle.d.ts +2 -0
- package/dist/icons/IconExclamationTriangle.js +14 -0
- package/dist/icons/index.d.ts +3 -0
- package/dist/icons/index.js +20 -14
- package/dist/index.d.ts +2 -0
- package/dist/index.js +86 -69
- package/dist/theme/theme.d.ts +120 -2
- package/dist/theme/tokens.d.ts +346 -0
- package/dist/theme/tokens.js +76 -8
- package/dist/utils/formatFiat.d.ts +1 -0
- package/dist/utils/formatFiat.js +13 -0
- package/dist/utils/openPopup.d.ts +7 -0
- package/dist/utils/openPopup.js +15 -0
- package/package.json +7 -6
- package/dist/assets/SignInFooter.css +0 -1
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ Next, you need to wrap your application with the `CDPReactProvider`.
|
|
|
48
48
|
|
|
49
49
|
Update your main application file (e.g., `main.tsx` or `App.tsx`) to include the provider:
|
|
50
50
|
|
|
51
|
-
```tsx
|
|
51
|
+
```tsx lines
|
|
52
52
|
import React from 'react';
|
|
53
53
|
import ReactDOM from 'react-dom/client';
|
|
54
54
|
import { App } from './App'; // Your main App component
|
|
@@ -87,7 +87,7 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
|
87
87
|
|
|
88
88
|
Now you can use the components from the library. Let's add the `AuthButton` component to your application. This component handles both sign-in and sign-out functionality.
|
|
89
89
|
|
|
90
|
-
```tsx
|
|
90
|
+
```tsx lines
|
|
91
91
|
// In your App.tsx or any other component
|
|
92
92
|
import { AuthButton } from '@coinbase/cdp-react/components/AuthButton';
|
|
93
93
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.AmountInput-module__amount-input___24NlC{
|
|
1
|
+
.AmountInput-module__amount-input___24NlC{box-sizing:border-box;color:var(--cdp-web-colors-page-text-default);font-family:var(--cdp-web-font-family-sans);font-size:var(--cdp-web-font-size-base);line-height:1.2;display:flex;align-items:center;justify-content:flex-start;gap:.25rem;overflow:hidden;position:relative;width:100%}.AmountInput-module__input___Af-R1{appearance:textfield;background-color:transparent;color:var(--cdp-web-colors-page-text-default);border:0;font-size:1em;font-family:var(--cdp-web-font-family-sans);font-weight:600;margin:0;outline:0;padding:0;width:1em}.AmountInput-module__input___Af-R1::placeholder{color:var(--cdp-web-colors-page-text-muted)}.AmountInput-module__amount-unit___48d60{font-size:3.75em;font-weight:600;display:flex;align-items:center;justify-content:flex-start}.AmountInput-module__amount-unit___48d60.AmountInput-module__visible___qmvT0{cursor:text;transform-origin:left center}.AmountInput-module__hidden___cO0sQ{visibility:hidden;position:absolute;pointer-events:none}.AmountInput-module__unit___-zmGz{color:var(--cdp-web-colors-page-text-muted);text-transform:uppercase}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.AuthButton-module__loading___JpDqi{border-radius:9999em;height:
|
|
1
|
+
.AuthButton-module__loading___JpDqi{border-radius:9999em;height:3em;width:7.5em}
|
package/dist/assets/Button.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.Button-module__btn___Wj6Dr{--cdp-web-button-ring-color: transparent;--cdp-web-button-ring-width: 2px;--cdp-web-button-ring-inset-color: transparent;--cdp-web-button-ring-inset-width: 2px;
|
|
1
|
+
.Button-module__btn___Wj6Dr{--cdp-web-button-ring-color: transparent;--cdp-web-button-ring-width: 2px;--cdp-web-button-ring-inset-color: transparent;--cdp-web-button-ring-inset-width: 2px;border-radius:9999em}.Button-module__link-primary___6Zgkh,.Button-module__link-secondary___S0Qdo{padding:0 .25em}.Button-module__primary___WGT--{background-color:var(--cdp-web-colors-cta-primary-bg-default);color:var(--cdp-web-colors-cta-primary-text-default)}.Button-module__primary___WGT--:hover{background-color:var(--cdp-web-colors-cta-primary-bg-hover);color:var(--cdp-web-colors-cta-primary-text-hover)}.Button-module__primary___WGT--:focus{outline:none}.Button-module__primary___WGT--:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-cta-primary-border-focus);--cdp-web-button-ring-inset-color: var(--cdp-web-colors-page-bg-default);outline:none}.Button-module__secondary___Fx0LJ{background-color:var(--cdp-web-colors-cta-secondary-bg-default);color:var(--cdp-web-colors-cta-secondary-text-default)}.Button-module__secondary___Fx0LJ:hover{background-color:var(--cdp-web-colors-cta-secondary-bg-hover);color:var(--cdp-web-colors-cta-secondary-text-hover)}.Button-module__secondary___Fx0LJ:focus{outline:none}.Button-module__secondary___Fx0LJ:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-cta-secondary-border-focus);--cdp-web-button-ring-inset-color: var(--cdp-web-colors-page-bg-default);outline:none}.Button-module__link-primary___6Zgkh,.Button-module__transparent-primary___iwWv5{background-color:transparent;color:var(--cdp-web-colors-link-primary-text-default)}.Button-module__link-primary___6Zgkh:hover,.Button-module__transparent-primary___iwWv5:hover{color:var(--cdp-web-colors-link-primary-text-hover)}.Button-module__link-primary___6Zgkh:focus,.Button-module__transparent-primary___iwWv5:focus{outline:none}.Button-module__link-primary___6Zgkh:focus-visible,.Button-module__transparent-primary___iwWv5:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-link-primary-text-default);outline:none}.Button-module__link-secondary___S0Qdo,.Button-module__transparent-secondary___GfRXu{background-color:transparent;color:var(--cdp-web-colors-link-secondary-text-default)}.Button-module__link-secondary___S0Qdo:hover,.Button-module__transparent-secondary___GfRXu:hover{color:var(--cdp-web-colors-link-secondary-text-hover)}.Button-module__link-secondary___S0Qdo:focus,.Button-module__transparent-secondary___GfRXu:focus{outline:none}.Button-module__link-secondary___S0Qdo:focus-visible,.Button-module__transparent-secondary___GfRXu:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-link-secondary-text-default);outline:none}.Button-module__control-btn___9Gkoz{--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:.5em;color:var(--cdp-web-colors-input-text-default);font-weight:400}.Button-module__control-btn___9Gkoz:focus{outline:none}.Button-module__control-btn___9Gkoz:focus-visible{--cdp-web-button-ring-inset-color: var(--cdp-web-colors-input-border-focus);--cdp-web-button-ring-inset-width: 2px;outline:none}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ButtonBase-module__btn___9S8PJ{--cdp-web-button-ring-color: transparent;--cdp-web-button-ring-width: 2px;--cdp-web-button-ring-inset-color: transparent;--cdp-web-button-ring-inset-width: 2px;box-sizing:border-box;box-shadow:inset 0 0 0 var(--cdp-web-button-ring-inset-width) var(--cdp-web-button-ring-inset-color),0 0 0 var(--cdp-web-button-ring-width) var(--cdp-web-button-ring-color);display:inline-flex;align-items:center;justify-content:center;gap:.5em;padding:1em;border:0;background-color:transparent;color:var(--cdp-web-colors-page-text-default);font-size:var(--cdp-web-font-size-base);font-family:var(--cdp-web-font-family-sans);font-weight:500;line-height:1.5;text-decoration:none;cursor:pointer;transition:all .15s ease-in-out;transition-property:color,background-color,border-color,box-shadow,transform;-webkit-user-select:none;user-select:none}.ButtonBase-module__full-width___vLJsn{display:flex;width:100%}.ButtonBase-module__size-lg___569jT{padding:1em}.ButtonBase-module__size-md___sAsBJ{padding:.75em}.ButtonBase-module__size-sm___xHCtU{padding:.5em .75em}.ButtonBase-module__size-xs___LiiO7{padding:.25em .75em}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.CoinbaseFooter-module__footer___d0ToM{color:var(--cdp-web-colors-page-text-muted);display:flex;align-items:center;justify-content:center;gap:.5em;line-height:1;padding:1em 2em 0}.CoinbaseFooter-module__text___dmxyS{display:flex;align-items:center;font-size:.75em;gap:.25em;margin:0}.CoinbaseFooter-module__icon___3-qMm{height:auto;width:.75em}.CoinbaseFooter-module__coinbase-icon___Ws6HN{height:1em;width:auto}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ExchangeAmountInput-module__flex-row___ZKB-Q{display:flex;flex-direction:row;font-size:var(--cdp-web-font-size-base);align-items:center;justify-content:flex-start}.ExchangeAmountInput-module__gap-1___vuNQW{gap:.5em}.ExchangeAmountInput-module__gap-2___4-s-b{gap:.25em}.ExchangeAmountInput-module__swap-button___i9lSz{
|
|
1
|
+
.ExchangeAmountInput-module__flex-row___ZKB-Q{display:flex;flex-direction:row;font-size:var(--cdp-web-font-size-base);align-items:center;justify-content:flex-start}.ExchangeAmountInput-module__gap-1___vuNQW{gap:.5em}.ExchangeAmountInput-module__gap-2___4-s-b{gap:.25em}.ExchangeAmountInput-module__swap-button___i9lSz{border:none;display:flex;align-items:center;justify-content:center;padding-left:.25em;padding-right:.25em;margin:0;cursor:pointer}.ExchangeAmountInput-module__icon___b5JpF{width:auto;height:1.25em}.ExchangeAmountInput-module__output-loading-skeleton___gKMEZ{padding-left:2.25em;border-radius:9999em;height:1.75em;width:max-content}.ExchangeAmountInput-module__output-loading-skeleton-placeholder___1-jT-{visibility:hidden}.ExchangeAmountInput-module__output-currency___vlpC1{text-transform:uppercase}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.Fund-module__fund___6j-Og{box-sizing:border-box;color:var(--cdp-web-colors-page-text-default);display:flex;flex-direction:column;font-family:var(--cdp-web-font-family-sans);font-size:var(--cdp-web-font-size-base);gap:1em;width:100%;max-width:28.125em;padding:.75em 2em 1em}.Fund-module__fund___6j-Og *{box-sizing:border-box}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.FundAmountInput-module__input-wrapper___6r-sX{padding-bottom:1.5em}.FundAmountInput-module__error___lMqzh{margin-top:-1.25em}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.FundErrorScreen-module__icon___Mf6ck{width:4em;height:4em;color:var(--cdp-web-colors-fg-warning)}.FundErrorScreen-module__title___8Qv6o{font-size:1.25em;font-weight:600;line-height:1.4;margin:.5em 0 .25em}.FundErrorScreen-module__body___-p-r9{color:var(--cdp-web-colors-fg-muted);line-height:1.5;margin:0 0 .25em}.FundErrorScreen-module__body___-p-r9:last-child{margin-bottom:0}.FundErrorScreen-module__docs-link___mzeH8{white-space:nowrap}.FundErrorScreen-module__keywords___u85Do span[data-part=keyword]{background-color:var(--cdp-web-colors-code-bg-default);border:1px solid var(--cdp-web-colors-code-border-default);border-radius:.25em;color:var(--cdp-web-colors-code-text-default);font-size:.875em;line-height:1;padding:.2em .25em;font-family:var(--cdp-web-font-family-mono)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.FundForm-module__view___5V1qO,.FundForm-module__form___TIzVJ{display:flex;flex-direction:column;gap:1em}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.FundModal-module__trigger___2IuXj{padding-left:2em;padding-right:2em}.FundModal-module__fund___1AmQa{height:100%;overflow:hidden}.FundModal-module__fund___1AmQa.FundModal-module__no-footer___WKV78{padding-bottom:2em}.FundModal-module__title-buttons___Lctf7{display:flex;justify-content:space-between;align-items:center}.FundModal-module__close-button___jzdFM{transform:translate(.75em);margin-left:auto;margin-right:0}.FundModal-module__close-icon___WoA4a{height:auto;width:1.5em}.FundModal-module__fund-inner___UuOq3{text-align:left}.FundModal-module__fund-inner___UuOq3.FundModal-module__tx-status___fc-3f{text-align:center}.FundModal-module__title___lNsoT{flex-grow:1}.FundModal-module__tx-status___fc-3f .FundModal-module__title___lNsoT{padding-left:3em}.FundModal-module__content___9f3ze{margin-top:1.5em}.FundModal-module__tx-status___fc-3f .FundModal-module__content___9f3ze{margin-top:4em}.FundModal-module__tx-status___fc-3f .FundModal-module__content___9f3ze p:last-child{margin-bottom:4em}.FundModal-module__tx-status___fc-3f .FundModal-module__content___9f3ze button:last-child{margin-top:4em}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.FundPaymentMethods-module__select-loading-skeleton___ZuD3n{width:100%;border-radius:.5em;height:3em}.FundPaymentMethods-module__select-item___9VyxH{display:flex;align-items:center;line-height:1.25em;gap:.5em}.FundPaymentMethods-module__select-item-icon___28unQ{display:flex;align-items:center;justify-content:center;flex-grow:0;flex-shrink:0;width:2.25em}.FundPaymentMethods-module__select-item-name___5vLc0{display:block;font-weight:600;font-size:.875em}.FundPaymentMethods-module__select-item-description___C5mTB{color:var(--cdp-web-colors-select-list-item-text-muted);display:block;font-size:.875em}.FundPaymentMethods-module__select-trigger___ypebl .FundPaymentMethods-module__select-item___9VyxH{line-height:1.5em;gap:.75em}.FundPaymentMethods-module__select-trigger___ypebl .FundPaymentMethods-module__select-item-icon___28unQ{width:auto}.FundPaymentMethods-module__select-trigger___ypebl .FundPaymentMethods-module__select-item-name___5vLc0{font-size:1em}.FundPaymentMethods-module__select-trigger___ypebl .FundPaymentMethods-module__select-item-description___C5mTB{display:none}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.FundPresetAmountInputs-module__preset-amount-inputs___Skjnm{align-items:center;display:flex;gap:.5em;justify-content:center}.FundPresetAmountInputs-module__preset-amount-input___eyNqU{flex-grow:1}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.FundTitle-module__title___K6czk{font-size:var(--cdp-web-font-size-base);font-weight:600;line-height:1.5;margin:0}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.FundTransactionStatus-module__graphic___cam38{display:flex;align-items:center;justify-content:center;position:relative}.FundTransactionStatus-module__status___2zKJu{text-align:center}.FundTransactionStatus-module__pad___-9rGO{padding:.5em}.FundTransactionStatus-module__spinner___94rMk{width:5em;height:5em;color:var(--cdp-web-colors-line-primary)}.FundTransactionStatus-module__icon___0hBQO{color:var(--cdp-web-colors-page-text-default);position:absolute;display:flex;align-items:center;justify-content:center;width:2em;height:2em;top:50%;left:50%;transform:translate(-50%,-50%)}.FundTransactionStatus-module__icon___0hBQO svg{width:100%;height:auto}.FundTransactionStatus-module__icon-success___893VG svg{color:var(--cdp-web-colors-fg-positive)}.FundTransactionStatus-module__icon-error___-aQvD svg{color:var(--cdp-web-colors-fg-negative)}.FundTransactionStatus-module__subhead___0sHIM{font-size:1.25em;line-height:1.2;font-weight:600;margin:1em 0 .25em}.FundTransactionStatus-module__description___W7kK2{font-size:1.125em;color:var(--cdp-web-colors-page-text-muted);line-height:1.5;font-weight:400;margin:0 0 1em}.FundTransactionStatus-module__description___W7kK2:last-child{margin-bottom:0}.FundTransactionStatus-module__ring___1vnCu{border-radius:9999em;border:3px solid transparent;display:block;width:4em;height:4em}.FundTransactionStatus-module__ring-success___Bxudq{border-color:var(--cdp-web-colors-line-positive)}.FundTransactionStatus-module__ring-error___WmTaE{border-color:var(--cdp-web-colors-line-negative)}
|
package/dist/assets/Input.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.Input-module__input___-mK8z{--cdp-web-input-ring-width: 1px;--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-default);box-sizing:border-box;font-family:var(--cdp-web-font-family-sans);font-size:var(--cdp-web-font-size-base);line-height:1.5;padding:1em;border-radius:.5em;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%}.Input-module__input___-mK8z::placeholder{color:var(--cdp-web-colors-input-placeholder-default)}.Input-module__input___-mK8z:focus-visible{outline:none;--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-focus);--cdp-web-input-ring-width: 2px}.Input-module__input___-mK8z[aria-invalid=true]{--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-error)}.Input-module__input___-mK8z[data-success=true]{--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-success)}
|
|
1
|
+
.Input-module__input___-mK8z{--cdp-web-input-ring-width: 1px;--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-default);box-sizing:border-box;font-family:var(--cdp-web-font-family-sans);font-size:var(--cdp-web-font-size-base);line-height:1.5;padding:1em;border-radius:.5em;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%}.Input-module__size-lg___IYoRG{padding:1em}.Input-module__size-md___8hkn5{padding:.75em}.Input-module__size-sm___cnynF{padding:.5em .75em}.Input-module__size-xs___aK-NH{padding:.25em .75em}.Input-module__input___-mK8z::placeholder{color:var(--cdp-web-colors-input-placeholder-default)}.Input-module__input___-mK8z:focus-visible{outline:none;--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-focus);--cdp-web-input-ring-width: 2px}.Input-module__input___-mK8z[aria-invalid=true]{--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-error)}.Input-module__input___-mK8z[data-success=true]{--cdp-web-input-ring-color: var(--cdp-web-colors-input-border-success)}
|
package/dist/assets/Modal.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.Modal-module__modal___MUsZA{--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 10%), 0 2px 4px -2px rgb(0 0 0 / 10%);box-sizing:border-box;box-shadow:var(--shadow-md);width:100%;max-width:28.125em;min-width:0;background:var(--cdp-web-colors-page-bg-default);border-radius:.5em;outline:1px solid var(--cdp-web-colors-page-border-default);position:relative}.Modal-module__modal___MUsZA[data-state=open]{animation:Modal-module__slide-in___p-A8u .2s ease-out,Modal-module__fade-in___NfUjS .2s ease-out}.Modal-module__modal___MUsZA[data-state=closed]{animation:Modal-module__slide-out___hrRK1 .2s ease-in,Modal-module__fade-out___LpBNV .2s ease-in}.Modal-module__overlay___-RqGQ{background:var(--cdp-web-colors-bg-overlay);box-sizing:border-box;-webkit-backdrop-filter:blur(.5em);backdrop-filter:blur(.5em);display:grid;grid-template-rows:auto 1fr;inset:0;overflow-y:auto;place-items:end center;position:fixed;z-index:
|
|
1
|
+
.Modal-module__modal___MUsZA{--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 10%), 0 2px 4px -2px rgb(0 0 0 / 10%);box-sizing:border-box;box-shadow:var(--shadow-md);width:100%;max-width:28.125em;min-width:0;background:var(--cdp-web-colors-page-bg-default);border-radius:.5em;outline:1px solid var(--cdp-web-colors-page-border-default);position:relative}.Modal-module__modal___MUsZA[data-state=open]{animation:Modal-module__slide-in___p-A8u .2s ease-out,Modal-module__fade-in___NfUjS .2s ease-out}.Modal-module__modal___MUsZA[data-state=closed]{animation:Modal-module__slide-out___hrRK1 .2s ease-in,Modal-module__fade-out___LpBNV .2s ease-in}.Modal-module__overlay___-RqGQ{background:var(--cdp-web-colors-bg-overlay);box-sizing:border-box;-webkit-backdrop-filter:blur(.5em);backdrop-filter:blur(.5em);display:grid;grid-template-rows:auto 1fr;inset:0;overflow-y:auto;place-items:end center;position:fixed;z-index:auto}.Modal-module__overlay___-RqGQ[data-state=open]{animation:Modal-module__fade-in___NfUjS .2s ease-out}.Modal-module__overlay___-RqGQ[data-state=closed]{animation:Modal-module__fade-out___LpBNV .2s ease-in}.Modal-module__spacer___dIfOA{height:1em}@keyframes Modal-module__fade-in___NfUjS{0%{opacity:0}to{opacity:1}}@keyframes Modal-module__fade-out___LpBNV{0%{opacity:1}to{opacity:0}}@keyframes Modal-module__slide-in___p-A8u{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes Modal-module__slide-out___hrRK1{0%{transform:translateY(0)}to{transform:translateY(100%)}}@media (min-width: 400px){.Modal-module__overlay___-RqGQ{padding:.5rem}}@media (min-width: 450px){.Modal-module__overlay___-RqGQ{place-items:center;padding:1rem;grid-template-rows:1fr}.Modal-module__modal___MUsZA{height:auto}.Modal-module__spacer___dIfOA{display:none}@keyframes Modal-module__slide-in___p-A8u{0%{transform:translateY(10%)}to{transform:translateY(0)}}@keyframes Modal-module__slide-out___hrRK1{0%{transform:translateY(0)}to{transform:translateY(10%)}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.Select-module__select-trigger___yqioM{--cdp-web-button-ring-inset-color: var(--cdp-web-colors-select-trigger-border-default);--cdp-web-button-ring-inset-width: 1px;background-color:var(--cdp-web-colors-select-trigger-bg-default);border-radius:.5em;color:var(--cdp-web-colors-select-trigger-text-default);font-weight:500;text-align:left;justify-content:space-between}.Select-module__select-trigger___yqioM:focus{outline:none}.Select-module__select-trigger___yqioM:focus-visible{--cdp-web-button-ring-inset-color: var(--cdp-web-colors-select-trigger-border-focus);--cdp-web-button-ring-inset-width: 2px;outline:none}.Select-module__select-icon___hE7Wy{transition:transform .2s ease-in-out}.Select-module__select-trigger___yqioM[data-state=open] .Select-module__select-icon___hE7Wy{transform:rotate(0)}.Select-module__select-trigger___yqioM[data-state=closed] .Select-module__select-icon___hE7Wy{transform:rotate(-90deg)}.Select-module__select-content___6R8J9{--shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 10%), 0 1px 2px -1px rgb(0 0 0 / 10%);background-color:var(--cdp-web-colors-select-list-bg-default);border:1px solid var(--cdp-web-colors-select-list-border-default);border-radius:.5em;box-sizing:border-box;box-shadow:var(--shadow-sm);font-size:var(--cdp-web-font-size-base);max-height:var(--radix-select-content-available-height);padding:.5em;text-align:left;width:var(--radix-select-trigger-width)}.Select-module__select-content___6R8J9[data-state=open]{animation:Select-module__slide-down-and-fade___66mDK .2s cubic-bezier(.4,0,.2,1)}.Select-module__select-content___6R8J9[data-side=top][data-state=open]{animation:Select-module__slide-up-and-fade___0H9hX .2s cubic-bezier(.4,0,.2,1)}.Select-module__select-item___12l2C{background-color:var(--cdp-web-colors-select-list-item-bg-default);border-radius:.5em;color:var(--cdp-web-colors-select-list-item-text-default);cursor:pointer;font-size:.875em;display:flex;align-items:center;justify-content:space-between;gap:.5em;padding:.5em;transition:background-color .2s cubic-bezier(.4,0,.2,1)}.Select-module__select-item___12l2C[data-highlighted]{background-color:var(--cdp-web-colors-select-list-item-bg-highlight);color:var(--cdp-web-colors-select-list-item-text-onHighlight);outline:none}.Select-module__rotate-180___KuvGV{transform:rotate(180deg)}@keyframes Select-module__slide-down-and-fade___66mDK{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}@keyframes Select-module__slide-up-and-fade___0H9hX{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@import"https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap";.ThemeProvider-module__wrapper___aXwhZ{width:100%}
|
|
1
|
+
@import"https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap";.ThemeProvider-module__wrapper___aXwhZ{width:100%}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FormHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { FundProps } from './types';
|
|
3
|
+
export declare const VIEWS: readonly ["form", "error", "transaction-status"];
|
|
4
|
+
export type View = (typeof VIEWS)[number];
|
|
5
|
+
export interface FundFormProps extends Omit<FormHTMLAttributes<HTMLFormElement>, "children"> {
|
|
6
|
+
children?: (params: {
|
|
7
|
+
view: View;
|
|
8
|
+
Content: ReactNode;
|
|
9
|
+
}) => ReactNode;
|
|
10
|
+
openIn?: FundProps["openIn"];
|
|
11
|
+
submitLabel?: FundProps["submitLabel"];
|
|
12
|
+
onPopupOpen?: (popup: Window) => void;
|
|
13
|
+
onPopupClose?: () => void;
|
|
14
|
+
unmountOnTransactionError?: boolean;
|
|
15
|
+
unmountOnTransactionSuccess?: boolean;
|
|
16
|
+
unmount?: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const FundForm: ({ className, children, onPopupClose, onPopupOpen, onSubmit, openIn, submitLabel, unmountOnTransactionError, unmountOnTransactionSuccess, unmount, ...props }: FundFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { jsx as r, jsxs as H } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as f, useState as p, useCallback as a, useEffect as h, useMemo as J } from "react";
|
|
3
|
+
import { Button as Y } from "../ui/Button/index.js";
|
|
4
|
+
import { SwitchFadeTransition as Q } from "../ui/SwitchFadeTransition/index.js";
|
|
5
|
+
import { useTimer as X } from "../../hooks/useTimer.js";
|
|
6
|
+
import { formatFiat as w } from "../../utils/formatFiat.js";
|
|
7
|
+
import { openPopup as Z } from "../../utils/openPopup.js";
|
|
8
|
+
import { FundAmountInput as O } from "./components/FundAmountInput.js";
|
|
9
|
+
import { FundErrorScreen as tt } from "./components/FundErrorScreen.js";
|
|
10
|
+
import { FundPaymentMethods as et } from "./components/FundPaymentMethods.js";
|
|
11
|
+
import { FundPresetAmountInputs as rt } from "./components/FundPresetAmountInputs.js";
|
|
12
|
+
import { FundTransactionStatus as nt } from "./components/FundTransactionStatus.js";
|
|
13
|
+
import { useFundContext as ot } from "./FundProvider.js";
|
|
14
|
+
import { usePopupMonitor as it } from "./hooks/usePopupMonitor.js";
|
|
15
|
+
import '../../assets/FundForm.css';const at = "FundForm-module__view___5V1qO", st = "FundForm-module__form___TIzVJ", B = {
|
|
16
|
+
view: at,
|
|
17
|
+
form: st
|
|
18
|
+
}, mt = ["form", "error", "transaction-status"], _t = ({
|
|
19
|
+
className: E = "",
|
|
20
|
+
children: y,
|
|
21
|
+
onPopupClose: A,
|
|
22
|
+
onPopupOpen: M,
|
|
23
|
+
onSubmit: I,
|
|
24
|
+
openIn: V,
|
|
25
|
+
submitLabel: D,
|
|
26
|
+
unmountOnTransactionError: s = !1,
|
|
27
|
+
unmountOnTransactionSuccess: m = !1,
|
|
28
|
+
unmount: u,
|
|
29
|
+
...T
|
|
30
|
+
}) => {
|
|
31
|
+
const { state: t, dispatch: N, fetchBuyUrl: P } = ot(), g = f(t.fiatAmount === void 0 ? NaN : t.fiatAmount), [$, S] = p(!1), [k, _] = p(!1), F = f(null), [j, K] = p(null), v = f(null), C = f(null), o = f(null), {
|
|
32
|
+
timeRemaining: d,
|
|
33
|
+
start: R,
|
|
34
|
+
reset: U
|
|
35
|
+
} = X(), n = a((e) => {
|
|
36
|
+
C.current !== e && (C.current = e, v.current?.transition.toggle(e));
|
|
37
|
+
}, []), l = a(() => {
|
|
38
|
+
u && (o.current === "transactionSuccess" && m || o.current === "error" && s) ? u() : n("form"), o.current = null, N({
|
|
39
|
+
type: "SET_TRANSACTION_STATUS",
|
|
40
|
+
payload: { transactionStatus: { statusName: "init", statusData: null } }
|
|
41
|
+
});
|
|
42
|
+
}, [n, N, u, m, s]), L = a(() => {
|
|
43
|
+
u && (o.current === "transactionSuccess" && m || o.current === "error" && s) ? R(3) : o.current === null && l(), A?.();
|
|
44
|
+
}, [
|
|
45
|
+
R,
|
|
46
|
+
A,
|
|
47
|
+
l,
|
|
48
|
+
u,
|
|
49
|
+
m,
|
|
50
|
+
s
|
|
51
|
+
]);
|
|
52
|
+
h(() => {
|
|
53
|
+
d !== null && d <= 0 && (l(), U());
|
|
54
|
+
}, [d, l, U]), h(() => {
|
|
55
|
+
(t.transactionStatus.statusName === "transactionSuccess" || t.transactionStatus.statusName === "error") && (o.current = t.transactionStatus.statusName);
|
|
56
|
+
}, [t.transactionStatus.statusName]), h(() => {
|
|
57
|
+
t.paymentMethodsError?.message && n("error");
|
|
58
|
+
}, [t.paymentMethodsError?.message, n]);
|
|
59
|
+
const { startPopupMonitor: b } = it(L), W = a(
|
|
60
|
+
(e) => {
|
|
61
|
+
e && (n("transaction-status"), b(e), M?.(e));
|
|
62
|
+
},
|
|
63
|
+
[M, b, n]
|
|
64
|
+
), q = a(() => {
|
|
65
|
+
(t.fiatAmount === void 0 || isNaN(t.fiatAmount)) && isNaN(g.current) || t.fiatAmount === g.current || S(!0);
|
|
66
|
+
}, [t.fiatAmount]), x = J(() => {
|
|
67
|
+
if (t.fiatAmount === void 0 || isNaN(t.fiatAmount))
|
|
68
|
+
return "Enter an amount";
|
|
69
|
+
if (t.fiatAmount < (t.selectedPaymentMethod?.minAmount ?? 0))
|
|
70
|
+
return `Minimum amount is ${w(t.selectedPaymentMethod?.minAmount ?? 0, t.fiatCurrency, t.fiatDecimalPlaces, t.locale)}`;
|
|
71
|
+
if (t.selectedPaymentMethod?.maxAmount !== void 0 && t.fiatAmount > t.selectedPaymentMethod.maxAmount)
|
|
72
|
+
return `Maximum amount is ${w(t.selectedPaymentMethod?.maxAmount, t.fiatCurrency, t.fiatDecimalPlaces, t.locale)}`;
|
|
73
|
+
}, [
|
|
74
|
+
t.fiatAmount,
|
|
75
|
+
t.fiatCurrency,
|
|
76
|
+
t.fiatDecimalPlaces,
|
|
77
|
+
t.locale,
|
|
78
|
+
t.selectedPaymentMethod?.minAmount,
|
|
79
|
+
t.selectedPaymentMethod?.maxAmount
|
|
80
|
+
]), z = a(async () => {
|
|
81
|
+
if (!(t.fiatAmount === void 0 || isNaN(t.fiatAmount) || !t.selectedPaymentMethod?.id))
|
|
82
|
+
return P(
|
|
83
|
+
{
|
|
84
|
+
paymentMethod: t.selectedPaymentMethod?.id,
|
|
85
|
+
paymentAmount: t.fiatAmount
|
|
86
|
+
},
|
|
87
|
+
(e) => {
|
|
88
|
+
K({
|
|
89
|
+
code: e?.code || "UNKNOWN_BUY_URL_ERROR",
|
|
90
|
+
message: e?.debugMessage || "Something went wrong fetching the buy url"
|
|
91
|
+
}), n("error");
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}, [t.fiatAmount, t.selectedPaymentMethod?.id, P, n]), G = async (e) => {
|
|
95
|
+
if (e.preventDefault(), x) {
|
|
96
|
+
S(!0), F.current?.focus();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
I?.(e), _(!0);
|
|
100
|
+
const c = await z();
|
|
101
|
+
if (_(!1), c)
|
|
102
|
+
if (V === "tab")
|
|
103
|
+
window.open(c, "_blank");
|
|
104
|
+
else {
|
|
105
|
+
const i = Z({ url: c, width: 460, height: 720 });
|
|
106
|
+
W(i);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return /* @__PURE__ */ r(
|
|
110
|
+
Q,
|
|
111
|
+
{
|
|
112
|
+
animateHeight: !0,
|
|
113
|
+
timeout: 250,
|
|
114
|
+
items: mt,
|
|
115
|
+
initialEntered: !0,
|
|
116
|
+
transitionRef: v,
|
|
117
|
+
children: ({ itemKey: e, ...c }) => {
|
|
118
|
+
let i = null;
|
|
119
|
+
return e === "form" && (i = /* @__PURE__ */ H("form", { className: `${B.form} ${E}`, onSubmit: G, ...T, children: [
|
|
120
|
+
/* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(
|
|
121
|
+
O,
|
|
122
|
+
{
|
|
123
|
+
ref: F,
|
|
124
|
+
error: $ ? x : void 0,
|
|
125
|
+
onBlur: q
|
|
126
|
+
}
|
|
127
|
+
) }),
|
|
128
|
+
/* @__PURE__ */ r(rt, {}),
|
|
129
|
+
/* @__PURE__ */ r(et, {}),
|
|
130
|
+
/* @__PURE__ */ r(
|
|
131
|
+
Y,
|
|
132
|
+
{
|
|
133
|
+
variant: "primary",
|
|
134
|
+
type: "submit",
|
|
135
|
+
isPending: k,
|
|
136
|
+
pendingLabel: "Getting purchase link",
|
|
137
|
+
children: D || "Deposit"
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
] })), e === "error" && (i = /* @__PURE__ */ r(tt, { error: t.paymentMethodsError || j })), e === "transaction-status" && (i = /* @__PURE__ */ r(
|
|
141
|
+
nt,
|
|
142
|
+
{
|
|
143
|
+
unmountOnSuccess: m,
|
|
144
|
+
unmountOnError: s,
|
|
145
|
+
reset: l,
|
|
146
|
+
timeRemaining: d
|
|
147
|
+
}
|
|
148
|
+
)), /* @__PURE__ */ r("div", { ...c, className: B.view, children: y ? y({ view: e, Content: i }) : i });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
export {
|
|
154
|
+
_t as FundForm,
|
|
155
|
+
mt as VIEWS
|
|
156
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { FundContextType, FundProps } from './types';
|
|
3
|
+
export declare const FundProvider: ({ children, fetchBuyOptions, fetchBuyQuote, inputType, onError, onStatus, onSuccess, ...props }: Omit<FundProps, "children"> & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const useFundContext: () => FundContextType;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import { useEvmAddress as T } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { createContext as R, useContext as U, useEffect as l, useMemo as b } from "react";
|
|
4
|
+
import { useBuyUrl as M } from "./hooks/useBuyUrl.js";
|
|
5
|
+
import { useEmitLifecycleStatus as g } from "./hooks/useEmitLifecycleStatus.js";
|
|
6
|
+
import { useExchangeRate as k } from "./hooks/useExchangeRate.js";
|
|
7
|
+
import { usePaymentMethods as H } from "./hooks/usePaymentMethods.js";
|
|
8
|
+
import { useFundReducer as N } from "./useFundReducer.js";
|
|
9
|
+
const x = {
|
|
10
|
+
country: "US",
|
|
11
|
+
cryptoCurrency: "ETH",
|
|
12
|
+
cryptoDecimalPlaces: 8,
|
|
13
|
+
fiatCurrency: "USD",
|
|
14
|
+
fiatDecimalPlaces: 2,
|
|
15
|
+
network: "base",
|
|
16
|
+
presetAmountInputs: void 0,
|
|
17
|
+
selectedInputType: "fiat",
|
|
18
|
+
transactionStatus: {
|
|
19
|
+
statusName: "init",
|
|
20
|
+
statusData: null
|
|
21
|
+
}
|
|
22
|
+
}, C = R(void 0), z = ({
|
|
23
|
+
children: c,
|
|
24
|
+
fetchBuyOptions: h,
|
|
25
|
+
fetchBuyQuote: f,
|
|
26
|
+
inputType: S,
|
|
27
|
+
onError: u,
|
|
28
|
+
onStatus: D,
|
|
29
|
+
onSuccess: F,
|
|
30
|
+
...I
|
|
31
|
+
}) => {
|
|
32
|
+
const {
|
|
33
|
+
country: t,
|
|
34
|
+
cryptoCurrency: e,
|
|
35
|
+
cryptoDecimalPlaces: a,
|
|
36
|
+
fiatCurrency: s,
|
|
37
|
+
fiatDecimalPlaces: i,
|
|
38
|
+
locale: d,
|
|
39
|
+
network: o,
|
|
40
|
+
presetAmountInputs: m,
|
|
41
|
+
subdivision: n
|
|
42
|
+
} = I, { evmAddress: w } = T(), [p, r] = N({
|
|
43
|
+
...x,
|
|
44
|
+
country: t,
|
|
45
|
+
cryptoCurrency: e,
|
|
46
|
+
cryptoDecimalPlaces: a,
|
|
47
|
+
fiatCurrency: s,
|
|
48
|
+
fiatDecimalPlaces: i,
|
|
49
|
+
locale: d,
|
|
50
|
+
network: o,
|
|
51
|
+
presetAmountInputs: m,
|
|
52
|
+
subdivision: n,
|
|
53
|
+
selectedInputType: S || x.selectedInputType
|
|
54
|
+
});
|
|
55
|
+
l(() => {
|
|
56
|
+
r({
|
|
57
|
+
type: "SYNC_WITH_PROPS",
|
|
58
|
+
payload: {
|
|
59
|
+
country: t,
|
|
60
|
+
cryptoCurrency: e,
|
|
61
|
+
cryptoDecimalPlaces: a,
|
|
62
|
+
fiatCurrency: s,
|
|
63
|
+
fiatDecimalPlaces: i,
|
|
64
|
+
locale: d,
|
|
65
|
+
network: o,
|
|
66
|
+
presetAmountInputs: m,
|
|
67
|
+
subdivision: n
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}, [
|
|
71
|
+
t,
|
|
72
|
+
e,
|
|
73
|
+
a,
|
|
74
|
+
s,
|
|
75
|
+
i,
|
|
76
|
+
d,
|
|
77
|
+
o,
|
|
78
|
+
m,
|
|
79
|
+
n,
|
|
80
|
+
r
|
|
81
|
+
]), g({
|
|
82
|
+
lifecycleStatus: p.transactionStatus,
|
|
83
|
+
onError: u,
|
|
84
|
+
onStatus: D,
|
|
85
|
+
onSuccess: F
|
|
86
|
+
});
|
|
87
|
+
const { fetchExchangeRate: y } = k({
|
|
88
|
+
cryptoCurrency: e,
|
|
89
|
+
country: t,
|
|
90
|
+
dispatch: r,
|
|
91
|
+
fetchBuyQuote: f,
|
|
92
|
+
fiatCurrency: s,
|
|
93
|
+
network: o,
|
|
94
|
+
onError: u,
|
|
95
|
+
subdivision: n
|
|
96
|
+
}), { fetchPaymentMethods: P } = H({
|
|
97
|
+
country: t,
|
|
98
|
+
cryptoCurrency: e,
|
|
99
|
+
dispatch: r,
|
|
100
|
+
fetchBuyOptions: h,
|
|
101
|
+
fiatCurrency: s,
|
|
102
|
+
network: o,
|
|
103
|
+
onError: u,
|
|
104
|
+
subdivision: n
|
|
105
|
+
}), { fetchBuyUrl: v } = M({
|
|
106
|
+
cryptoCurrency: e,
|
|
107
|
+
destinationAddress: w || void 0,
|
|
108
|
+
fiatCurrency: s,
|
|
109
|
+
fetchBuyQuote: f,
|
|
110
|
+
country: t,
|
|
111
|
+
network: o,
|
|
112
|
+
subdivision: n
|
|
113
|
+
}), A = b(() => ({ state: p, dispatch: r, fetchBuyUrl: v }), [p, r, v]);
|
|
114
|
+
return l(() => {
|
|
115
|
+
y();
|
|
116
|
+
}, [y]), l(() => {
|
|
117
|
+
P();
|
|
118
|
+
}, [P]), /* @__PURE__ */ E(C.Provider, { value: A, children: c });
|
|
119
|
+
}, G = () => {
|
|
120
|
+
const c = U(C);
|
|
121
|
+
if (!c)
|
|
122
|
+
throw new Error("useFundContext must be used within a FundProvider");
|
|
123
|
+
return c;
|
|
124
|
+
};
|
|
125
|
+
export {
|
|
126
|
+
z as FundProvider,
|
|
127
|
+
G as useFundContext
|
|
128
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ElementType, HTMLAttributes } from 'react';
|
|
2
|
+
export interface FundTitleProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
as?: ElementType;
|
|
4
|
+
}
|
|
5
|
+
export declare const FundTitle: ({ children, as: Component, className, ...props }: FundTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { useFundContext as n } from "./FundProvider.js";
|
|
4
|
+
import '../../assets/FundTitle.css';const l = "FundTitle-module__title___K6czk", c = {
|
|
5
|
+
title: l
|
|
6
|
+
}, a = ({
|
|
7
|
+
children: t,
|
|
8
|
+
as: e = "h2",
|
|
9
|
+
className: o = "",
|
|
10
|
+
...s
|
|
11
|
+
}) => {
|
|
12
|
+
const { state: r } = n();
|
|
13
|
+
return /* @__PURE__ */ i(e, { ...s, className: `${c.title} ${o}`, children: t || `Deposit ${r.cryptoCurrency.toUpperCase()}` });
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
a as FundTitle
|
|
17
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
export interface FundAmountInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "min" | "max" | "value"> {
|
|
3
|
+
error?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const FundAmountInput: import('react').ForwardRefExoticComponent<FundAmountInputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsxs as I, Fragment as _, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as x, useId as g, useCallback as i } from "react";
|
|
3
|
+
import { ExchangeAmountInput as F } from "../../forms/ExchangeAmountInput/index.js";
|
|
4
|
+
import { Error as b } from "../../ui/Error/index.js";
|
|
5
|
+
import { useFundContext as v } from "../FundProvider.js";
|
|
6
|
+
import { createSetFieldAction as a } from "../useFundReducer.js";
|
|
7
|
+
import '../../../assets/FundAmountInput.css';const C = "FundAmountInput-module__error___lMqzh", s = {
|
|
8
|
+
"input-wrapper": "FundAmountInput-module__input-wrapper___6r-sX",
|
|
9
|
+
error: C
|
|
10
|
+
}, P = x(
|
|
11
|
+
({ "aria-describedby": u, "aria-invalid": p, error: r, ...m }, d) => {
|
|
12
|
+
const { state: t, dispatch: e } = v(), c = g(), l = i(
|
|
13
|
+
(n) => {
|
|
14
|
+
e(a("cryptoAmount", n));
|
|
15
|
+
},
|
|
16
|
+
[e]
|
|
17
|
+
), y = i(
|
|
18
|
+
(n) => {
|
|
19
|
+
e(a("fiatAmount", n));
|
|
20
|
+
},
|
|
21
|
+
[e]
|
|
22
|
+
), f = i(
|
|
23
|
+
(n) => {
|
|
24
|
+
e(a("selectedInputType", n));
|
|
25
|
+
},
|
|
26
|
+
[e]
|
|
27
|
+
), A = [r ? c : void 0, u].filter(Boolean).join(" "), h = !!(r || p);
|
|
28
|
+
return /* @__PURE__ */ I(_, { children: [
|
|
29
|
+
/* @__PURE__ */ o("div", { className: s["input-wrapper"], children: /* @__PURE__ */ o(
|
|
30
|
+
F,
|
|
31
|
+
{
|
|
32
|
+
...m,
|
|
33
|
+
ref: d,
|
|
34
|
+
"aria-describedby": A || void 0,
|
|
35
|
+
"aria-invalid": h || void 0,
|
|
36
|
+
cryptoAmount: t.cryptoAmount,
|
|
37
|
+
cryptoCurrency: t.cryptoCurrency,
|
|
38
|
+
cryptoDecimalPlaces: t.cryptoDecimalPlaces,
|
|
39
|
+
exchangeRate: t.exchangeRate,
|
|
40
|
+
fiatAmount: t.fiatAmount,
|
|
41
|
+
fiatCurrency: t.fiatCurrency,
|
|
42
|
+
fiatDecimalPlaces: t.fiatDecimalPlaces,
|
|
43
|
+
inputType: t.selectedInputType,
|
|
44
|
+
isExchangeRatePending: t.isExchangeRatePending,
|
|
45
|
+
min: 0,
|
|
46
|
+
setCryptoAmount: l,
|
|
47
|
+
setFiatAmount: y,
|
|
48
|
+
setInputType: f
|
|
49
|
+
}
|
|
50
|
+
) }),
|
|
51
|
+
r && /* @__PURE__ */ o(b, { id: c, className: s.error, children: r })
|
|
52
|
+
] });
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
P.displayName = "FundAmountInput";
|
|
56
|
+
export {
|
|
57
|
+
P as FundAmountInput
|
|
58
|
+
};
|