@coinbase/cdp-react 0.0.98 → 0.0.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AuthButton/index.d.ts +102 -0
- package/dist/components/CDPReactProvider/index.d.ts +114 -0
- package/dist/components/CopyAddress/index.d.ts +29 -0
- package/dist/components/CopyEvmKeyButton/index.d.ts +77 -0
- package/dist/components/CopySolanaKeyButton/index.d.ts +73 -0
- package/dist/components/EnrollMfa/EnrollMfaDescription.d.ts +21 -0
- package/dist/components/EnrollMfa/EnrollMfaFlow.d.ts +27 -0
- package/dist/components/EnrollMfa/EnrollMfaFlowBackButton.d.ts +19 -0
- package/dist/components/EnrollMfa/EnrollMfaFlowProvider.d.ts +52 -0
- package/dist/components/EnrollMfa/EnrollMfaFooter.d.ts +18 -0
- package/dist/components/EnrollMfa/EnrollMfaImage.d.ts +24 -0
- package/dist/components/EnrollMfa/EnrollMfaItem.d.ts +21 -0
- package/dist/components/EnrollMfa/EnrollMfaItems.d.ts +17 -0
- package/dist/components/EnrollMfa/EnrollMfaProvider.d.ts +35 -0
- package/dist/components/EnrollMfa/EnrollMfaTitle.d.ts +21 -0
- package/dist/components/EnrollMfa/index.d.ts +65 -0
- package/dist/components/EnrollMfa/methods/sms.d.ts +25 -0
- package/dist/components/EnrollMfa/methods/totp.d.ts +25 -0
- package/dist/components/EnrollMfa/types.d.ts +48 -0
- package/dist/components/EnrollMfa/useEnrollMfaReducer.d.ts +6 -0
- package/dist/components/EnrollMfaModal/index.d.ts +111 -0
- package/dist/components/ExportWallet/index.d.ts +163 -0
- package/dist/components/ExportWalletModal/index.d.ts +173 -0
- package/dist/components/Fund/FundForm.d.ts +18 -0
- package/dist/components/Fund/FundProvider.d.ts +17 -0
- package/dist/components/Fund/FundTitle.d.ts +12 -0
- package/dist/components/Fund/components/FundAmountInput.d.ts +13 -0
- package/dist/components/Fund/components/FundErrorScreen.d.ts +7 -0
- package/dist/components/Fund/components/FundPaymentMethods.d.ts +7 -0
- package/dist/components/Fund/components/FundPresetAmountInputs.d.ts +7 -0
- package/dist/components/Fund/components/FundTransactionStatus.d.ts +6 -0
- package/dist/components/Fund/hooks/useBuyUrl.d.ts +23 -0
- package/dist/components/Fund/hooks/useEmitLifecycleStatus.d.ts +12 -0
- package/dist/components/Fund/hooks/useExchangeRate.d.ts +17 -0
- package/dist/components/Fund/hooks/usePaymentMethods.d.ts +16 -0
- package/dist/components/Fund/hooks/usePopupMonitor.d.ts +9 -0
- package/dist/components/Fund/hooks/useSetupOnrampEventListeners.d.ts +6 -0
- package/dist/components/Fund/index.d.ts +87 -0
- package/dist/components/Fund/types.d.ts +137 -0
- package/dist/components/Fund/useFundReducer.d.ts +15 -0
- package/dist/components/Fund/utils/buildPaymentMethods.d.ts +15 -0
- package/dist/components/Fund/utils/setupOnrampEventListeners.d.ts +10 -0
- package/dist/components/Fund/utils/subscribeToWindowMessage.d.ts +27 -0
- package/dist/components/FundModal/index.d.ts +106 -0
- package/dist/components/LinkAuth/LinkAuthFlow.d.ts +25 -0
- package/dist/components/LinkAuth/LinkAuthFlowBackButton.d.ts +19 -0
- package/dist/components/LinkAuth/LinkAuthFlowProvider.d.ts +60 -0
- package/dist/components/LinkAuth/LinkAuthItem.d.ts +23 -0
- package/dist/components/LinkAuth/LinkAuthItems.d.ts +17 -0
- package/dist/components/LinkAuth/LinkAuthItems.js +30 -30
- package/dist/components/LinkAuth/LinkAuthProvider.d.ts +31 -0
- package/dist/components/LinkAuth/LinkAuthTitle.d.ts +17 -0
- package/dist/components/LinkAuth/index.d.ts +170 -0
- package/dist/components/LinkAuth/types.d.ts +31 -0
- package/dist/components/LinkAuth/utils.d.ts +12 -0
- package/dist/components/LinkAuthModal/index.d.ts +112 -0
- package/dist/components/OAuthStatusModal/index.d.ts +24 -0
- package/dist/components/SendEvmTransactionButton/index.d.ts +27 -0
- package/dist/components/SendSolanaTransactionButton/index.d.ts +27 -0
- package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +26 -0
- package/dist/components/SignIn/SignInBackButton.d.ts +40 -0
- package/dist/components/SignIn/SignInCredentials.d.ts +13 -0
- package/dist/components/SignIn/SignInDescription.d.ts +35 -0
- package/dist/components/SignIn/SignInFooter.d.ts +27 -0
- package/dist/components/SignIn/SignInForm.d.ts +39 -0
- package/dist/components/SignIn/SignInImage.d.ts +38 -0
- package/dist/components/SignIn/SignInProvider.d.ts +54 -0
- package/dist/components/SignIn/SignInTitle.d.ts +35 -0
- package/dist/components/SignIn/flows/SignInWithEmail.d.ts +26 -0
- package/dist/components/SignIn/flows/SignInWithOAuth.d.ts +19 -0
- package/dist/components/SignIn/flows/SignInWithSms.d.ts +26 -0
- package/dist/components/SignIn/hooks/useEmailForm.d.ts +7 -0
- package/dist/components/SignIn/hooks/useOTPForm.d.ts +8 -0
- package/dist/components/SignIn/hooks/usePhoneNumberForm.d.ts +7 -0
- package/dist/components/SignIn/hooks/useSignInWithOAuth.d.ts +8 -0
- package/dist/components/SignIn/index.d.ts +124 -0
- package/dist/components/SignIn/types.d.ts +37 -0
- package/dist/components/SignIn/useSignInReducer.d.ts +9 -0
- package/dist/components/SignInModal/index.d.ts +123 -0
- package/dist/components/SignOutButton/index.d.ts +39 -0
- package/dist/components/ThemeProvider/index.d.ts +70 -0
- package/dist/components/VerifyMfa/VerifyMfaDescription.d.ts +24 -0
- package/dist/components/VerifyMfa/VerifyMfaFlow.d.ts +30 -0
- package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.d.ts +19 -0
- package/dist/components/VerifyMfa/VerifyMfaFlowProvider.d.ts +51 -0
- package/dist/components/VerifyMfa/VerifyMfaFooter.d.ts +18 -0
- package/dist/components/VerifyMfa/VerifyMfaImage.d.ts +23 -0
- package/dist/components/VerifyMfa/VerifyMfaItem.d.ts +20 -0
- package/dist/components/VerifyMfa/VerifyMfaItems.d.ts +18 -0
- package/dist/components/VerifyMfa/VerifyMfaProvider.d.ts +40 -0
- package/dist/components/VerifyMfa/VerifyMfaTitle.d.ts +24 -0
- package/dist/components/VerifyMfa/index.d.ts +55 -0
- package/dist/components/VerifyMfa/methods/sms.d.ts +29 -0
- package/dist/components/VerifyMfa/methods/totp.d.ts +29 -0
- package/dist/components/VerifyMfa/types.d.ts +33 -0
- package/dist/components/VerifyMfa/useVerifyMfaReducer.d.ts +7 -0
- package/dist/components/VerifyMfaInline/index.d.ts +212 -0
- package/dist/components/VerifyMfaModal/index.d.ts +114 -0
- package/dist/components/forms/AmountInput/index.d.ts +16 -0
- package/dist/components/forms/AmountInput/types.d.ts +9 -0
- package/dist/components/forms/AmountInput/useAmountInput.d.ts +14 -0
- package/dist/components/forms/AmountInput/useInputScale.d.ts +12 -0
- package/dist/components/forms/AmountInput/useNumberParseAndFormat.d.ts +20 -0
- package/dist/components/forms/CountrySelect/index.d.ts +9 -0
- package/dist/components/forms/EmailForm/index.d.ts +17 -0
- package/dist/components/forms/ExchangeAmountInput/index.d.ts +19 -0
- package/dist/components/forms/ExchangeAmountInput/types.d.ts +12 -0
- package/dist/components/forms/ExchangeAmountInput/useExchangeAmountInput.d.ts +17 -0
- package/dist/components/forms/Field/index.d.ts +15 -0
- package/dist/components/forms/Input/index.d.ts +15 -0
- package/dist/components/forms/Label/index.d.ts +8 -0
- package/dist/components/forms/OTP/index.d.ts +6 -0
- package/dist/components/forms/OTPForm/index.d.ts +20 -0
- package/dist/components/forms/PhoneNumberForm/index.d.ts +27 -0
- package/dist/components/forms/PhoneNumberInput/index.d.ts +16 -0
- package/dist/components/forms/PhoneNumberInput/maskOverride.d.ts +6 -0
- package/dist/components/forms/PhoneNumberInput/usePhoneNumberFormatter.d.ts +7 -0
- package/dist/components/forms/Select/index.d.ts +30 -0
- package/dist/components/ui/Badge/index.d.ts +19 -0
- package/dist/components/ui/Banner/index.d.ts +25 -0
- package/dist/components/ui/Button/index.d.ts +50 -0
- package/dist/components/ui/ButtonBase/index.d.ts +20 -0
- package/dist/components/ui/CoinbaseFooter/index.d.ts +16 -0
- package/dist/components/ui/CopyTextField/index.d.ts +35 -0
- package/dist/components/ui/Error/index.d.ts +14 -0
- package/dist/components/ui/IframeButton/index.d.ts +17 -0
- package/dist/components/ui/LoadingSkeleton/index.d.ts +22 -0
- package/dist/components/ui/LoadingSpinner/index.d.ts +11 -0
- package/dist/components/ui/Modal/index.d.ts +82 -0
- package/dist/components/ui/QRCode/QRCodeSvg.d.ts +35 -0
- package/dist/components/ui/QRCode/index.d.ts +7 -0
- package/dist/components/ui/QRCode/useCorners.d.ts +9 -0
- package/dist/components/ui/QRCode/useDotsPath.d.ts +18 -0
- package/dist/components/ui/QRCode/useLogo.d.ts +18 -0
- package/dist/components/ui/QRCode/useMatrix.d.ts +7 -0
- package/dist/components/ui/ServerError/index.d.ts +6 -0
- package/dist/components/ui/SuccessMessage/index.d.ts +14 -0
- package/dist/components/ui/SwitchFadeTransition/index.d.ts +15 -0
- package/dist/components/ui/SwitchSlideTransition/index.d.ts +16 -0
- package/dist/components/ui/SwitchTransition/index.d.ts +42 -0
- package/dist/components/ui/ToggleListItem/index.d.ts +31 -0
- package/dist/components/ui/VisuallyHidden/index.d.ts +18 -0
- package/dist/data/countries.d.ts +15 -0
- package/dist/data/countryNames.d.ts +4 -0
- package/dist/hooks/useKeyExportPostMessage.d.ts +25 -0
- package/dist/hooks/usePhoneNumberState.d.ts +47 -0
- package/dist/hooks/usePhoneNumberValidators.d.ts +8 -0
- package/dist/hooks/useTimeout.d.ts +18 -0
- package/dist/hooks/useTimer.d.ts +6 -0
- package/dist/hooks/useTransitionMap.d.ts +22 -0
- package/dist/hooks/useVerifyMfaModal.d.ts +78 -0
- package/dist/icons/IconAppleLogo.d.ts +22 -0
- package/dist/icons/IconArrowLeft.d.ts +22 -0
- package/dist/icons/IconArrowsUpDown.d.ts +22 -0
- package/dist/icons/IconCheck.d.ts +22 -0
- package/dist/icons/IconCheckCircle.d.ts +21 -0
- package/dist/icons/IconChevronDown.d.ts +22 -0
- package/dist/icons/IconCoinbaseMark.d.ts +22 -0
- package/dist/icons/IconCoinbaseWordmark.d.ts +22 -0
- package/dist/icons/IconCopy.d.ts +22 -0
- package/dist/icons/IconCreditCard.d.ts +22 -0
- package/dist/icons/IconCurrencies.d.ts +22 -0
- package/dist/icons/IconEnvelope.d.ts +22 -0
- package/dist/icons/IconExclamationCircle.d.ts +22 -0
- package/dist/icons/IconExclamationTriangle.d.ts +22 -0
- package/dist/icons/IconGoogleColorLogo.d.ts +22 -0
- package/dist/icons/IconGoogleLogo.d.ts +22 -0
- package/dist/icons/IconLock.d.ts +22 -0
- package/dist/icons/IconMinus.d.ts +21 -0
- package/dist/icons/IconPhone.d.ts +22 -0
- package/dist/icons/IconPinCode.d.ts +22 -0
- package/dist/icons/IconPlus.d.ts +21 -0
- package/dist/icons/IconShield.d.ts +22 -0
- package/dist/icons/IconSmartPhone.d.ts +22 -0
- package/dist/icons/IconTelegramLogo.d.ts +22 -0
- package/dist/icons/IconXLogo.d.ts +22 -0
- package/dist/icons/IconXMark.d.ts +22 -0
- package/dist/icons/SvgIcon.d.ts +6 -0
- package/dist/theme/cssVariables.d.ts +10 -0
- package/dist/theme/theme.d.ts +246 -0
- package/dist/theme/tokens.d.ts +54 -0
- package/dist/theme/utils.d.ts +63 -0
- package/dist/types/secureIframe.d.ts +3 -0
- package/dist/utils/capitalize.d.ts +8 -0
- package/dist/utils/childrenHasComponent.d.ts +10 -0
- package/dist/utils/clamp.d.ts +10 -0
- package/dist/utils/formatFiat.d.ts +11 -0
- package/dist/utils/formatPhoneNumber.d.ts +8 -0
- package/dist/utils/getMessageFromUnknownError.d.ts +9 -0
- package/dist/utils/isApiError.d.ts +21 -0
- package/dist/utils/isEmailInvalid.d.ts +15 -0
- package/dist/utils/openPopup.d.ts +15 -0
- package/dist/utils/parseValuesFromPhoneNumber.d.ts +16 -0
- package/dist/utils/sendIframeMessage.d.ts +8 -0
- package/dist/utils/toOAuthProviderType.d.ts +8 -0
- package/dist/utils/transition.d.ts +41 -0
- package/dist/version.d.ts +5 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
|
@@ -1,40 +1,252 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import { ButtonSize, ButtonVariant } from '../../theme/theme';
|
|
3
|
+
/**
|
|
4
|
+
* The views of the inline MFA flow.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link VerifyMfaInline}
|
|
7
|
+
*/
|
|
3
8
|
type VerifyMfaInlineView = "verify" | "content";
|
|
9
|
+
/**
|
|
10
|
+
* The direction of the transition animation.
|
|
11
|
+
*/
|
|
4
12
|
type VerifyMfaInlineDirection = "left" | "right";
|
|
13
|
+
/**
|
|
14
|
+
* The context value for the VerifyMfaInline component.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link useVerifyMfaInlineContext}
|
|
17
|
+
*/
|
|
5
18
|
interface VerifyMfaInlineContextValue {
|
|
19
|
+
/** The current view of the inline MFA flow. */
|
|
6
20
|
view: VerifyMfaInlineView;
|
|
21
|
+
/** A function to go to the verify view. */
|
|
7
22
|
goToVerify: () => void;
|
|
23
|
+
/** A function to go to the content view. Optionally specify animation direction. */
|
|
8
24
|
goToContent: (direction?: VerifyMfaInlineDirection) => void;
|
|
25
|
+
/** A function to go back to the previous view. */
|
|
9
26
|
goBack: () => void;
|
|
10
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* A hook to get the VerifyMfaInline context value.
|
|
30
|
+
*
|
|
31
|
+
* @returns {VerifyMfaInlineContextValue} The link auth flow context value.
|
|
32
|
+
*
|
|
33
|
+
* @see {@link VerifyMfaInline}
|
|
34
|
+
*
|
|
35
|
+
* @group Hooks
|
|
36
|
+
*/
|
|
11
37
|
declare const useVerifyMfaInlineContext: () => VerifyMfaInlineContextValue;
|
|
38
|
+
/**
|
|
39
|
+
* Props for the VerifyMfaInline component.
|
|
40
|
+
*
|
|
41
|
+
* @see {@link VerifyMfaInline}
|
|
42
|
+
*/
|
|
12
43
|
interface VerifyMfaInlineProps extends HTMLAttributes<HTMLDivElement> {
|
|
44
|
+
/**
|
|
45
|
+
* The component children. Should include VerifyMfaInlineFlow.
|
|
46
|
+
* Can optionally include VerifyMfaInlineBackButton outside the Flow.
|
|
47
|
+
*/
|
|
13
48
|
children: ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* If true, forces MFA verification before showing content.
|
|
51
|
+
* Use this when you want users to verify BEFORE seeing the content.
|
|
52
|
+
*
|
|
53
|
+
* If false (default), content is shown first and MFA is triggered
|
|
54
|
+
* automatically when a protected action is called.
|
|
55
|
+
*
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
14
58
|
verifyFirst?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Called when MFA verification completes successfully.
|
|
61
|
+
*/
|
|
15
62
|
onVerified?: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Called when MFA verification is cancelled.
|
|
65
|
+
* If provided, a back/cancel action in the verify view will trigger this
|
|
66
|
+
* and transition back to content.
|
|
67
|
+
*/
|
|
16
68
|
onCancel?: () => void;
|
|
69
|
+
/**
|
|
70
|
+
* The delay in milliseconds before transitioning to content after successful verification.
|
|
71
|
+
* This allows users to see the success state before the transition.
|
|
72
|
+
*
|
|
73
|
+
* @default 500
|
|
74
|
+
*/
|
|
17
75
|
successDelay?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Additional class name for the container.
|
|
78
|
+
*/
|
|
18
79
|
className?: string;
|
|
19
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Props for VerifyMfaInlineFlow component.
|
|
83
|
+
*
|
|
84
|
+
* @see {@link VerifyMfaInlineFlow}
|
|
85
|
+
*/
|
|
20
86
|
interface VerifyMfaInlineFlowProps {
|
|
87
|
+
/**
|
|
88
|
+
* The content to display. Can be:
|
|
89
|
+
* - A ReactNode: Used as the protected content (shown after MFA verification)
|
|
90
|
+
* - A render function: Receives `{ view, Content }` for full control over rendering
|
|
91
|
+
*
|
|
92
|
+
* When using a render function:
|
|
93
|
+
* - `view` is the current view ("verify" or "content")
|
|
94
|
+
* - `Content` is the default UI for that view (MFA form for "verify", null for "content")
|
|
95
|
+
*/
|
|
21
96
|
children: ReactNode | ((props: {
|
|
97
|
+
/** The verify view. */
|
|
22
98
|
view: "verify";
|
|
99
|
+
/** The default content for for the "verify" view (i.e. the default MFA verification UI). */
|
|
23
100
|
Content: ReactNode;
|
|
24
101
|
} | {
|
|
102
|
+
/** The content view. */
|
|
25
103
|
view: "content";
|
|
104
|
+
/** There is no default content for the "content" view (consumer provides content). */
|
|
26
105
|
Content: null;
|
|
27
106
|
}) => ReactNode);
|
|
107
|
+
/**
|
|
108
|
+
* Additional class name for the transition container.
|
|
109
|
+
*/
|
|
28
110
|
className?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Whether to animate the height during transitions.
|
|
113
|
+
*
|
|
114
|
+
* @default true
|
|
115
|
+
*/
|
|
29
116
|
animateHeight?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Whether to auto focus forms.
|
|
119
|
+
*
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
30
122
|
autoFocus?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* The type of transition to use between views.
|
|
125
|
+
* - "slide": Slides content left/right (default)
|
|
126
|
+
* - "fade": Fades content in/out
|
|
127
|
+
*
|
|
128
|
+
* @default "slide"
|
|
129
|
+
*/
|
|
31
130
|
transition?: "slide" | "fade";
|
|
32
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Props for VerifyMfaInlineBackButton component.
|
|
134
|
+
*
|
|
135
|
+
* @see {@link VerifyMfaInlineBackButton}
|
|
136
|
+
*/
|
|
33
137
|
interface VerifyMfaInlineBackButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
138
|
+
/** The size of the button. */
|
|
34
139
|
size?: ButtonSize;
|
|
140
|
+
/** The variant of the button. */
|
|
35
141
|
variant?: ButtonVariant;
|
|
36
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Back button for navigating within the MFA verification flow or back to content.
|
|
145
|
+
*
|
|
146
|
+
* In `verifyFirst` mode, it only renders when the inner MFA flow has back navigation.
|
|
147
|
+
*
|
|
148
|
+
* Otherwise, it renders on the verify view and navigates back to content when the
|
|
149
|
+
* inner MFA flow can't go back.
|
|
150
|
+
*
|
|
151
|
+
* @param {VerifyMfaInlineBackButtonProps} props - The props for the component.
|
|
152
|
+
* @returns The back button, or null when there is nothing to navigate back to.
|
|
153
|
+
*
|
|
154
|
+
* @group Components
|
|
155
|
+
*/
|
|
37
156
|
declare const VerifyMfaInlineBackButton: ({ children, onClick, size, variant, ["aria-label"]: ariaLabel, className, ...props }: VerifyMfaInlineBackButtonProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
157
|
+
/**
|
|
158
|
+
* The transition component for the inline MFA flow.
|
|
159
|
+
* Place this inside VerifyMfaInline, alongside VerifyMfaInlineBackButton if needed.
|
|
160
|
+
*
|
|
161
|
+
* @param props - The props for the VerifyMfaInlineFlow component.
|
|
162
|
+
* @param props.children - The protected content or a render function for full control.
|
|
163
|
+
* @param props.className - Additional class name.
|
|
164
|
+
* @param props.animateHeight - Whether to animate height during transitions.
|
|
165
|
+
* @param props.autoFocus - Whether to auto focus forms.
|
|
166
|
+
* @param props.transition - The type of transition animation ("slide" or "fade").
|
|
167
|
+
* @returns The rendered transition component.
|
|
168
|
+
*
|
|
169
|
+
* @group Components
|
|
170
|
+
*
|
|
171
|
+
* @see {@link VerifyMfaInline}
|
|
172
|
+
*/
|
|
38
173
|
declare const VerifyMfaInlineFlow: ({ children, className, animateHeight, autoFocus, transition, }: VerifyMfaInlineFlowProps) => import("react/jsx-runtime").JSX.Element;
|
|
174
|
+
/**
|
|
175
|
+
* A wrapper component that provides context and coordination for inline MFA verification.
|
|
176
|
+
* Use with VerifyMfaInlineFlow and optionally VerifyMfaInlineBackButton.
|
|
177
|
+
*
|
|
178
|
+
* By default, shows content first and automatically transitions to MFA verification
|
|
179
|
+
* when a protected action (like signing or exporting) is called. After verification,
|
|
180
|
+
* the action completes automatically.
|
|
181
|
+
*
|
|
182
|
+
* Use `verifyFirst` prop to force MFA verification before showing content.
|
|
183
|
+
*
|
|
184
|
+
* @param props - The props for the VerifyMfaInline component.
|
|
185
|
+
* @param props.children - Should include VerifyMfaInlineFlow and optionally VerifyMfaInlineBackButton.
|
|
186
|
+
* @param props.verifyFirst - If true, forces MFA verification before showing content.
|
|
187
|
+
* @param props.onVerified - Called when MFA verification completes.
|
|
188
|
+
* @param props.onCancel - Called when MFA verification is cancelled.
|
|
189
|
+
* @param props.className - Additional class name for the container.
|
|
190
|
+
* @param props.successDelay - The delay in milliseconds before transitioning to content after successful verification.
|
|
191
|
+
* @returns The rendered component.
|
|
192
|
+
*
|
|
193
|
+
* @group Components
|
|
194
|
+
*
|
|
195
|
+
* @document ./README.md
|
|
196
|
+
*
|
|
197
|
+
* @see {@link VerifyMfaInlineBackButton}
|
|
198
|
+
* @see {@link VerifyMfaInlineFlow}
|
|
199
|
+
* @see {@link useVerifyMfaInlineContext}
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```tsx lines
|
|
203
|
+
* // Simple usage: Just the flow
|
|
204
|
+
* function ExportWalletModal({ address }) {
|
|
205
|
+
* return (
|
|
206
|
+
* <Modal>
|
|
207
|
+
* <VerifyMfaInline verifyFirst>
|
|
208
|
+
* <VerifyMfaInlineFlow>
|
|
209
|
+
* <ExportWallet address={address} skipMfa />
|
|
210
|
+
* </VerifyMfaInlineFlow>
|
|
211
|
+
* </VerifyMfaInline>
|
|
212
|
+
* </Modal>
|
|
213
|
+
* );
|
|
214
|
+
* }
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```tsx lines
|
|
219
|
+
* // With back button outside the transition
|
|
220
|
+
* function CustomModal() {
|
|
221
|
+
* return (
|
|
222
|
+
* <Modal>
|
|
223
|
+
* <VerifyMfaInline>
|
|
224
|
+
* <VerifyMfaInlineBackButton />
|
|
225
|
+
* <VerifyMfaInlineFlow transition="fade">
|
|
226
|
+
* <MyProtectedContent />
|
|
227
|
+
* </VerifyMfaInlineFlow>
|
|
228
|
+
* </VerifyMfaInline>
|
|
229
|
+
* </Modal>
|
|
230
|
+
* );
|
|
231
|
+
* }
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```tsx lines
|
|
236
|
+
* // With render function for full control
|
|
237
|
+
* function AdvancedModal() {
|
|
238
|
+
* return (
|
|
239
|
+
* <VerifyMfaInline verifyFirst>
|
|
240
|
+
* <VerifyMfaInlineBackButton />
|
|
241
|
+
* <VerifyMfaInlineFlow>
|
|
242
|
+
* {({ view, Content }) => (
|
|
243
|
+
* view === "verify" ? <div>{Content}</div> : <MyProtectedContent />
|
|
244
|
+
* )}
|
|
245
|
+
* </VerifyMfaInlineFlow>
|
|
246
|
+
* </VerifyMfaInline>
|
|
247
|
+
* );
|
|
248
|
+
* }
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
39
251
|
declare const VerifyMfaInline: ({ children, verifyFirst, onVerified, onCancel, successDelay, className, ...props }: VerifyMfaInlineProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
252
|
export { VerifyMfaInline, VerifyMfaInlineBackButton, VerifyMfaInlineFlow, useVerifyMfaInlineContext, type VerifyMfaInlineBackButtonProps, type VerifyMfaInlineContextValue, type VerifyMfaInlineDirection, type VerifyMfaInlineFlowProps, type VerifyMfaInlineProps, type VerifyMfaInlineView, };
|
|
@@ -2,22 +2,136 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { ButtonProps } from '../ui/Button';
|
|
3
3
|
import { ModalContentProps } from '../ui/Modal';
|
|
4
4
|
import { VerifyMfaProps } from '../VerifyMfa';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the verify MFA modal trigger button
|
|
7
|
+
*
|
|
8
|
+
* @see {@link VerifyMfaModalTrigger}
|
|
9
|
+
*/
|
|
5
10
|
interface VerifyMfaModalTriggerProps extends Partial<Pick<ButtonProps, "className" | "fullWidth" | "size" | "style" | "variant">> {
|
|
11
|
+
/** If provided, will render the children instead of the default trigger button. */
|
|
6
12
|
children?: ReactNode;
|
|
13
|
+
/** The label to display on the trigger button. */
|
|
7
14
|
label?: ReactNode;
|
|
8
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Props for the VerifyMfaModal component.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link VerifyMfaModal}
|
|
20
|
+
*/
|
|
9
21
|
interface VerifyMfaModalProps {
|
|
22
|
+
/** If provided, will render the children instead of the default trigger button. */
|
|
10
23
|
children?: ReactNode;
|
|
24
|
+
/** Whether the modal is open. Note: if you set this, you must also set `setIsOpen`. */
|
|
11
25
|
open?: boolean;
|
|
26
|
+
/** A function to set the modal's open state. Note: if you set this, you must also set `open`. */
|
|
12
27
|
setIsOpen?: (value: boolean) => void;
|
|
28
|
+
/** A function to call when the verification is canceled. */
|
|
13
29
|
onCancel?: () => void;
|
|
30
|
+
/** A function to call when the verification errors. */
|
|
14
31
|
onError?: (error: Error) => void;
|
|
32
|
+
/** A function to call when MFA is successful verified. */
|
|
15
33
|
onSuccess?: (mfaCode: string) => void;
|
|
16
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Props for the VerifyMfaModalContent component.
|
|
37
|
+
*
|
|
38
|
+
* @see {@link VerifyMfaModalContent}
|
|
39
|
+
*/
|
|
17
40
|
interface VerifyMfaModalContentProps extends Omit<ModalContentProps, "children"> {
|
|
41
|
+
/** The children of the component. Leave empty to use the default verification UI. */
|
|
18
42
|
children?: VerifyMfaProps["children"];
|
|
19
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* A trigger button that opens the verify MFA modal.
|
|
46
|
+
*
|
|
47
|
+
* @param {VerifyMfaModalTriggerProps} props - The props for the VerifyMfaModalTrigger component.
|
|
48
|
+
* @param {ReactNode} [props.children] - The children to render inside the trigger button.
|
|
49
|
+
* @param {ReactNode} [props.label] - The label to display on the trigger button.
|
|
50
|
+
* @returns {JSX.Element} The VerifyMfaModalTrigger component.
|
|
51
|
+
*
|
|
52
|
+
* @group Components
|
|
53
|
+
*/
|
|
20
54
|
declare const VerifyMfaModalTrigger: ({ children, className, label, ...props }: VerifyMfaModalTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* The verify MFA modal content.
|
|
57
|
+
*
|
|
58
|
+
* @param {VerifyMfaModalContentProps} props - The props for the VerifyMfaModalContent component.
|
|
59
|
+
* @returns {JSX.Element} The VerifyMfaModalContent component.
|
|
60
|
+
*
|
|
61
|
+
* @group Components
|
|
62
|
+
*/
|
|
21
63
|
declare const VerifyMfaModalContent: ({ children, ...props }: VerifyMfaModalContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
/**
|
|
65
|
+
* A verify MFA modal component that wraps the {@link VerifyMfa} component.
|
|
66
|
+
*
|
|
67
|
+
* @param {VerifyMfaModalProps} props - The props for the VerifyMfaModal component.
|
|
68
|
+
* @returns {JSX.Element} The VerifyMfaModal component.
|
|
69
|
+
*
|
|
70
|
+
* @see {@link VerifyMfaModalTrigger} for the trigger button.
|
|
71
|
+
* @see {@link VerifyMfaModalContent} for the modal content.
|
|
72
|
+
*
|
|
73
|
+
* @group Components
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx lines
|
|
77
|
+
* // Render the VerifyMfaModal component with a custom success handler
|
|
78
|
+
* function App() {
|
|
79
|
+
* const handleSuccess = (mfaCode: string) => {
|
|
80
|
+
* console.log(`Successfully verified`, mfaCode);
|
|
81
|
+
* };
|
|
82
|
+
*
|
|
83
|
+
* return (
|
|
84
|
+
* <CDPReactProvider config={config}>
|
|
85
|
+
* <VerifyMfaModal onSuccess={handleSuccess} />
|
|
86
|
+
* </CDPReactProvider>
|
|
87
|
+
* );
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```tsx lines
|
|
93
|
+
* // Render the VerifyMfaModal component with a custom trigger button
|
|
94
|
+
* function App() {
|
|
95
|
+
* return (
|
|
96
|
+
* <CDPReactProvider config={config}>
|
|
97
|
+
* <VerifyMfaModal>
|
|
98
|
+
* <button type="button">Verify</button>
|
|
99
|
+
* </VerifyMfaModal>
|
|
100
|
+
* </CDPReactProvider>
|
|
101
|
+
* );
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx lines
|
|
107
|
+
* // Render the VerifyMfaModal component with a custom trigger button label
|
|
108
|
+
* function App() {
|
|
109
|
+
* return (
|
|
110
|
+
* <CDPReactProvider config={config}>
|
|
111
|
+
* <VerifyMfaModal>
|
|
112
|
+
* <VerifyMfaModalTrigger variant="secondary" label="Verify" />
|
|
113
|
+
* </VerifyMfaModal>
|
|
114
|
+
* </CDPReactProvider>
|
|
115
|
+
* );
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```tsx lines
|
|
121
|
+
* // Render the VerifyMfaModal with controlled open state
|
|
122
|
+
* function App() {
|
|
123
|
+
* const [isOpen, setIsOpen] = useState(false);
|
|
124
|
+
*
|
|
125
|
+
* return (
|
|
126
|
+
* <CDPReactProvider config={config}>
|
|
127
|
+
* <VerifyMfaModal open={isOpen} setIsOpen={setIsOpen}>
|
|
128
|
+
* <VerifyMfaModalTrigger />
|
|
129
|
+
* <VerifyMfaModalContent />
|
|
130
|
+
* </VerifyMfaModal>
|
|
131
|
+
* </CDPReactProvider>
|
|
132
|
+
* );
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
22
136
|
declare const VerifyMfaModal: ({ children, open, setIsOpen, onCancel, onError, onSuccess, }: VerifyMfaModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
137
|
export { VerifyMfaModal, VerifyMfaModalContent, VerifyMfaModalTrigger, type VerifyMfaModalProps, type VerifyMfaModalContentProps, type VerifyMfaModalTriggerProps, };
|
|
@@ -1,3 +1,19 @@
|
|
|
1
1
|
import { InputHTMLAttributes } from 'react';
|
|
2
2
|
import { AmountInputProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The AmountInput component
|
|
5
|
+
*
|
|
6
|
+
* @param {AmountInputProps} props - The props for the AmountInput component
|
|
7
|
+
* @param {number} props.amount - The amount to display
|
|
8
|
+
* @param {string} [props.className] - The class name for the input
|
|
9
|
+
* @param {string} props.unit - The unit to display
|
|
10
|
+
* @param {number} [props.decimalPlaces] - The number of decimal places to display (default 2)
|
|
11
|
+
* @param {string} [props.locale] - The locale in BCP 47 format (e.g. "en-US").
|
|
12
|
+
* @param {number} [props.max] - The maximum value for the input
|
|
13
|
+
* @param {number} [props.min] - The minimum value for the input
|
|
14
|
+
* @param {Function} props.setAmount - A function to set the amount
|
|
15
|
+
* @param {Function} props.onBlur - A function to call when the input is blurred
|
|
16
|
+
* @param {Function} props.onPaste - A function to call when a value is pasted
|
|
17
|
+
* @param {string} [props.placeholder] - The placeholder for the input
|
|
18
|
+
*/
|
|
3
19
|
export declare const AmountInput: import('react').ForwardRefExoticComponent<AmountInputProps & Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "inputMode" | "onChange" | "max" | "min"> & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { ChangeEvent, ClipboardEvent, FocusEvent, InputEvent, InputHTMLAttributes } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The props for the AmountInput component
|
|
4
|
+
*/
|
|
2
5
|
export interface AmountInputProps {
|
|
3
6
|
amount: number | undefined;
|
|
4
7
|
unit?: string;
|
|
@@ -8,7 +11,13 @@ export interface AmountInputProps {
|
|
|
8
11
|
min?: number;
|
|
9
12
|
setAmount: (amount: number) => void;
|
|
10
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The parameters for the useAmountInput hook
|
|
16
|
+
*/
|
|
11
17
|
export type UseAmoutInputParams = Pick<AmountInputProps, "amount" | "decimalPlaces" | "locale" | "max" | "min" | "setAmount"> & Pick<InputHTMLAttributes<HTMLInputElement>, "onBlur" | "onPaste">;
|
|
18
|
+
/**
|
|
19
|
+
* The return value of the useAmountInput hook
|
|
20
|
+
*/
|
|
12
21
|
export interface UseAmoutInputReturn {
|
|
13
22
|
handleBeforeInput: (e: InputEvent<HTMLInputElement>) => void;
|
|
14
23
|
handleBlur: (e: FocusEvent<HTMLInputElement>) => void;
|
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
import { UseAmoutInputParams, UseAmoutInputReturn } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The hook for the AmountInput component
|
|
4
|
+
*
|
|
5
|
+
* @param {UseAmoutInputParams} params - The parameters for the useAmountInput hook
|
|
6
|
+
* @param {number} params.amount - The amount to display
|
|
7
|
+
* @param {number} params.decimalPlaces - The number of decimal places to display
|
|
8
|
+
* @param {string} [params.locale] - The locale to use
|
|
9
|
+
* @param {number} [params.max] - The maximum value
|
|
10
|
+
* @param {number} [params.min] - The minimum value
|
|
11
|
+
* @param {(e: FocusEvent<HTMLInputElement>) => void} [params.onBlur] - A function to call when the input is blurred
|
|
12
|
+
* @param {(e: ClipboardEvent<HTMLInputElement>) => void} [params.onPaste] - A function to call when the input is pasted
|
|
13
|
+
* @param {(value: number) => void} [params.setAmount] - The function to set the amount value
|
|
14
|
+
* @returns {UseAmoutInputReturn} - The number value, input value, and handlers for the input
|
|
15
|
+
*/
|
|
2
16
|
export declare const useAmountInput: ({ amount, decimalPlaces, locale, max, min, setAmount, onBlur, onPaste, }: UseAmoutInputParams) => UseAmoutInputReturn;
|
|
@@ -7,6 +7,18 @@ interface UseInputScaleParams {
|
|
|
7
7
|
inputRef: RefObject<HTMLInputElement | null>;
|
|
8
8
|
scaleWrapperRef: RefObject<HTMLElement | null>;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* The parameters for the useInputScale hook
|
|
12
|
+
*
|
|
13
|
+
* @param {UseInputScaleParams} params - The parameters for the useInputScale hook
|
|
14
|
+
* @param {number} [params.minScale] - The minimum scale to apply to the input.
|
|
15
|
+
* @param {RefObject<HTMLInputElement>} params.containerRef - The ref to the container (for the max available width)
|
|
16
|
+
* @param {RefObject<HTMLInputElement>} params.measureRef - The ref to the element to measure (the value + currency width)
|
|
17
|
+
* @param {RefObject<HTMLInputElement>} params.inputRef - The ref to the input element
|
|
18
|
+
* @param {RefObject<HTMLInputElement>} params.scaleWrapperRef - The ref to the wrapper that will be scaled to fit the container
|
|
19
|
+
* @param {RefObject<HTMLInputElement>} params.valueRef - The ref to the value element (the amount)
|
|
20
|
+
* @returns {number} The scale value to apply to ensure the content fits within the container
|
|
21
|
+
*/
|
|
10
22
|
export declare const useInputScale: ({ minScale, containerRef, measureRef, inputRef, scaleWrapperRef, valueRef, }: UseInputScaleParams) => {
|
|
11
23
|
updateScale: () => void;
|
|
12
24
|
};
|
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { NumberParser, NumberFormatter } from '@internationalized/number';
|
|
2
|
+
/**
|
|
3
|
+
* The parameters for the useNumberParseAndFormat hook
|
|
4
|
+
*/
|
|
2
5
|
export interface UseNumberParseAndFormatParams {
|
|
6
|
+
/** An input value from which to detect the numbering system. If not provided, the numbering system will be detected from the locale. */
|
|
3
7
|
inputValue?: string;
|
|
8
|
+
/** The locale in BCP 47 format (e.g. "en-US") */
|
|
4
9
|
locale?: string;
|
|
10
|
+
/** The options for the NumberFormatter */
|
|
5
11
|
options?: Intl.NumberFormatOptions;
|
|
6
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* The return type of the useNumberParseAndFormat hook
|
|
15
|
+
*/
|
|
7
16
|
export interface UseNumberParseAndFormatReturn {
|
|
17
|
+
/** The NumberParser instance */
|
|
8
18
|
parser: NumberParser;
|
|
19
|
+
/** The NumberFormatter instance */
|
|
9
20
|
formatter: NumberFormatter;
|
|
10
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* The useNumberParseAndFormat hook
|
|
24
|
+
*
|
|
25
|
+
* @param {UseNumberParseAndFormatParams} [params] - The parameters for the useNumberParseAndFormat hook
|
|
26
|
+
* @param {string} [params.inputValue] - An input value from which to detect the numbering system. If not provided, the numbering system will be detected from the locale.
|
|
27
|
+
* @param {string} [params.locale] - The locale in BCP 47 format (e.g. "en-US").
|
|
28
|
+
* @param {Intl.NumberFormatOptions} [params.options] - The options for the NumberFormatter.
|
|
29
|
+
* @returns {UseNumberParseAndFormatReturn} The formatter and parser instances
|
|
30
|
+
*/
|
|
11
31
|
export declare const useNumberParseAndFormat: (params?: UseNumberParseAndFormatParams) => UseNumberParseAndFormatReturn;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { CountryCode } from '../../../data/countries';
|
|
2
2
|
import { InputSize } from '../../../theme/theme';
|
|
3
|
+
/**
|
|
4
|
+
* CountrySelect component props
|
|
5
|
+
*/
|
|
3
6
|
export interface CountrySelectProps {
|
|
4
7
|
className?: string;
|
|
5
8
|
size?: InputSize;
|
|
@@ -7,4 +10,10 @@ export interface CountrySelectProps {
|
|
|
7
10
|
value?: CountryCode;
|
|
8
11
|
onValueChange?: (value: CountryCode) => void;
|
|
9
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* CountrySelect component.
|
|
15
|
+
*
|
|
16
|
+
* @param {CountrySelectProps} props - The props for the CountrySelect component.
|
|
17
|
+
* @returns {JSX.Element} The CountrySelect component.
|
|
18
|
+
*/
|
|
10
19
|
export declare const CountrySelect: ({ className, size, defaultValue, value, onValueChange, }: CountrySelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { APIError } from '@coinbase/cdp-hooks';
|
|
2
2
|
import { FormHTMLAttributes } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* The props for the EmailForm component.
|
|
5
|
+
*/
|
|
3
6
|
export interface EmailFormProps extends Omit<FormHTMLAttributes<HTMLFormElement>, "children"> {
|
|
4
7
|
email?: string;
|
|
5
8
|
error?: string | APIError;
|
|
@@ -8,4 +11,18 @@ export interface EmailFormProps extends Omit<FormHTMLAttributes<HTMLFormElement>
|
|
|
8
11
|
onEmailChange?: (value: string) => void;
|
|
9
12
|
submitLabel?: string;
|
|
10
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* A form for signing in with an email address.
|
|
16
|
+
*
|
|
17
|
+
* @param {EmailFormProps} props - The props for the component.
|
|
18
|
+
* @param {string} [props.className] - The class name to apply to the form.
|
|
19
|
+
* @param {string} [props.email] - The value of the email input.
|
|
20
|
+
* @param {string} [props.error] - A (server) error message to display.
|
|
21
|
+
* @param {boolean} [props.isPending] - Whether the form is pending.
|
|
22
|
+
* @param {() => void} [props.onClearServerErrors] - A function to clear server errors.
|
|
23
|
+
* @param {(value: string) => void} [props.onEmailChange] - A function to handle email input value changes.
|
|
24
|
+
* @param {string} [props.submitLabel] - The label for the submit button.
|
|
25
|
+
* @param {FormEventHandler<HTMLFormElement>} [props.onSubmit] - A function to handle form submission.
|
|
26
|
+
* @returns {JSX.Element} The EmailForm component.
|
|
27
|
+
*/
|
|
11
28
|
export declare const EmailForm: ({ className, email, error, onEmailChange, isPending, submitLabel, ...props }: EmailFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
1
|
import { InputHTMLAttributes } from 'react';
|
|
2
2
|
import { ExchangeAmountInputProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* ExchangeAmountInput component
|
|
5
|
+
*
|
|
6
|
+
* @param {ExchangeAmountInputProps} props - The props for the ExchangeAmountInput component
|
|
7
|
+
* @param {string} props.cryptoAmount - The amount in crypto
|
|
8
|
+
* @param {string} props.cryptoCurrency - The currency of the crypto value
|
|
9
|
+
* @param {number} [props.cryptoDecimalPlaces] - The number of decimal places for the crypto amount (default 8)
|
|
10
|
+
* @param {string} props.exchangeRate - The exchange rate
|
|
11
|
+
* @param {string} props.fiatAmount - The amount in fiat
|
|
12
|
+
* @param {string} props.fiatCurrency - The currency of the fiat value
|
|
13
|
+
* @param {number} [props.fiatDecimalPlaces] - The number of decimal places for the fiat amount (defualt 2)
|
|
14
|
+
* @param {InputType} props.inputType - The type of input (crypto or fiat)
|
|
15
|
+
* @param {boolean} [props.isExchangeRatePending] - Whether the exchange rate is pending
|
|
16
|
+
* @param {string} [props.locale] - The locale in BCP 47 format (e.g. "en-US").
|
|
17
|
+
* @param {Function} props.setCryptoAmount - The function to set the crypto amount
|
|
18
|
+
* @param {Function} props.setFiatAmount - The function to set the fiat amount
|
|
19
|
+
* @param {Function} props.setInputType - The function to set the input type
|
|
20
|
+
* @returns {JSX.Element} The AmountInput component
|
|
21
|
+
*/
|
|
3
22
|
export declare const ExchangeAmountInput: import('react').ForwardRefExoticComponent<ExchangeAmountInputProps & Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "inputMode" | "onChange" | "max" | "min"> & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { AmountInputProps } from '../AmountInput/types';
|
|
2
|
+
/**
|
|
3
|
+
* The type of input (crypto or fiat)
|
|
4
|
+
*/
|
|
2
5
|
export type InputType = "crypto" | "fiat";
|
|
6
|
+
/**
|
|
7
|
+
* The props for the ExchangeAmountInput component
|
|
8
|
+
*/
|
|
3
9
|
export type ExchangeAmountInputProps = {
|
|
4
10
|
cryptoAmount: AmountInputProps["amount"];
|
|
5
11
|
cryptoDecimalPlaces?: AmountInputProps["decimalPlaces"];
|
|
@@ -17,7 +23,13 @@ export type ExchangeAmountInputProps = {
|
|
|
17
23
|
setFiatAmount: AmountInputProps["setAmount"];
|
|
18
24
|
setInputType: (inputType: InputType) => void;
|
|
19
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* The parameters for the useExchangeAmountInput hook
|
|
28
|
+
*/
|
|
20
29
|
export type UseExchangeAmountInputParams = Omit<ExchangeAmountInputProps, "max" | "min" | "setInputType">;
|
|
30
|
+
/**
|
|
31
|
+
* The return value of the useExchangeAmountInput hook
|
|
32
|
+
*/
|
|
21
33
|
export interface UseExchangeAmountInputReturn {
|
|
22
34
|
formatInputValue: (value: number) => string;
|
|
23
35
|
formatOutputValue: (value: number) => string;
|
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
import { UseExchangeAmountInputParams, UseExchangeAmountInputReturn } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The hook for the ExchangeAmountInput component
|
|
4
|
+
*
|
|
5
|
+
* @param {UseExchangeAmountInputParams} params - The parameters for the useExchangeAmountInput hook
|
|
6
|
+
* @param {string} params.cryptoAmount - The amount in crypto
|
|
7
|
+
* @param {string} params.cryptoCurrency - The currency of the crypto value
|
|
8
|
+
* @param {number} [params.cryptoDecimalPlaces] - The number of decimal places for the crypto amount (default 8)
|
|
9
|
+
* @param {string} params.exchangeRate - The exchange rate
|
|
10
|
+
* @param {string} params.fiatAmount - The amount in fiat
|
|
11
|
+
* @param {string} params.fiatCurrency - The currency of the fiat value
|
|
12
|
+
* @param {number} [params.fiatDecimalPlaces] - The number of decimal places for the fiat amount (defualt 2)
|
|
13
|
+
* @param {InputType} params.inputType - The type of input (crypto or fiat)
|
|
14
|
+
* @param {string} [params.locale] - The locale in BCP 47 format (e.g. "en-US").
|
|
15
|
+
* @param {Function} params.setCryptoAmount - The function to set the crypto amount
|
|
16
|
+
* @param {Function} params.setFiatAmount - The function to set the fiat amount
|
|
17
|
+
* @returns {UseExchangeAmountInputReturn} - The active and inactive values, the active and inactive currencies, the active and inactive decimal places, and the functions to handle changing values.
|
|
18
|
+
*/
|
|
2
19
|
export declare const useExchangeAmountInput: ({ cryptoAmount, cryptoCurrency, cryptoDecimalPlaces, exchangeRate, fiatAmount, fiatCurrency, fiatDecimalPlaces, inputType, locale, setFiatAmount, setCryptoAmount, }: UseExchangeAmountInputParams) => UseExchangeAmountInputReturn;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { FormMessageProps, FormValidityStateProps } from '@radix-ui/react-form';
|
|
2
2
|
import { CSSProperties, JSX, ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* The props for the Field component.
|
|
5
|
+
*
|
|
6
|
+
* @interface FormFieldProps
|
|
7
|
+
* @augments {HTMLAttributes<HTMLDivElement>}
|
|
8
|
+
* @property {string} label - The label for the input.
|
|
9
|
+
* @property {string} name - The name of the input.
|
|
10
|
+
* @property {FormMessageProps["match"]} validators - The validators for the input.
|
|
11
|
+
*/
|
|
3
12
|
export interface FormFieldProps {
|
|
4
13
|
children?: FormValidityStateProps["children"];
|
|
5
14
|
className?: string;
|
|
@@ -9,4 +18,10 @@ export interface FormFieldProps {
|
|
|
9
18
|
style?: CSSProperties;
|
|
10
19
|
validators?: [FormMessageProps["match"], ReactNode][];
|
|
11
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* A themed form field component with a label and validation messages.
|
|
23
|
+
*
|
|
24
|
+
* @param {FormFieldProps} props - The props for the component.
|
|
25
|
+
* @returns {JSX.Element} The Input component.
|
|
26
|
+
*/
|
|
12
27
|
export declare const Field: ({ children, className, inlineError, label, name, style, validators, }: FormFieldProps) => JSX.Element;
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { FormValidityStateProps } from '@radix-ui/react-form';
|
|
2
2
|
import { InputHTMLAttributes } from 'react';
|
|
3
3
|
import { InputSize } from '../../../theme/theme';
|
|
4
|
+
/**
|
|
5
|
+
* The props for the Input component.
|
|
6
|
+
*/
|
|
4
7
|
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
5
8
|
size?: InputSize;
|
|
6
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* A themed input component with a label.
|
|
12
|
+
*
|
|
13
|
+
* @param {InputHTMLAttributes<HTMLInputElement>} props - The props for the input.
|
|
14
|
+
* @returns {JSX.Element} The Input component.
|
|
15
|
+
*/
|
|
7
16
|
export declare const Input: import('react').ForwardRefExoticComponent<InputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
17
|
+
/**
|
|
18
|
+
* A higher-order component that adds validity state to the input.
|
|
19
|
+
*
|
|
20
|
+
* @param props - The props for the input.
|
|
21
|
+
* @returns {JSX.Element} The Input component.
|
|
22
|
+
*/
|
|
8
23
|
export declare const withValidityState: (props: InputProps) => FormValidityStateProps["children"];
|