@lifi/widget 1.0.0
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/App.d.ts +4 -0
- package/App.js +18 -0
- package/AppDrawer.d.ts +14 -0
- package/AppDrawer.js +34 -0
- package/AppDrawer.style.d.ts +49 -0
- package/AppDrawer.style.js +52 -0
- package/AppProvider.d.ts +6 -0
- package/AppProvider.js +12 -0
- package/LICENSE.md +21 -0
- package/components/AppContainer.d.ts +5 -0
- package/components/AppContainer.js +53 -0
- package/components/BottomSheet/BottomSheet.d.ts +3 -0
- package/components/BottomSheet/BottomSheet.js +42 -0
- package/components/BottomSheet/index.d.ts +2 -0
- package/components/BottomSheet/index.js +2 -0
- package/components/BottomSheet/types.d.ts +10 -0
- package/components/BottomSheet/types.js +1 -0
- package/components/Card/Card.d.ts +8 -0
- package/components/Card/Card.js +8 -0
- package/components/Card/CardContainer.d.ts +11 -0
- package/components/Card/CardContainer.js +16 -0
- package/components/Card/CardHeader.d.ts +18 -0
- package/components/Card/CardHeader.js +20 -0
- package/components/Card/CardTitle.d.ts +14 -0
- package/components/Card/CardTitle.js +9 -0
- package/components/Card/index.d.ts +4 -0
- package/components/Card/index.js +4 -0
- package/components/Header/Header.d.ts +2 -0
- package/components/Header/Header.js +17 -0
- package/components/Header/Header.style.d.ts +22 -0
- package/components/Header/Header.style.js +21 -0
- package/components/Header/NavigationHeader.d.ts +2 -0
- package/components/Header/NavigationHeader.js +46 -0
- package/components/Header/WalletHeader.d.ts +2 -0
- package/components/Header/WalletHeader.js +28 -0
- package/components/Header/index.d.ts +1 -0
- package/components/Header/index.js +1 -0
- package/components/Input.d.ts +1 -0
- package/components/Input.js +14 -0
- package/components/LiFiLogo.d.ts +5 -0
- package/components/LiFiLogo.js +7 -0
- package/components/PoweredBy.d.ts +2 -0
- package/components/PoweredBy.js +14 -0
- package/components/ProgressToNextUpdate/ProgressToNextUpdate.d.ts +7 -0
- package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +49 -0
- package/components/ProgressToNextUpdate/index.d.ts +1 -0
- package/components/ProgressToNextUpdate/index.js +1 -0
- package/components/ReverseTokensButton/ReverseTokensButton.d.ts +4 -0
- package/components/ReverseTokensButton/ReverseTokensButton.js +24 -0
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +29 -0
- package/components/ReverseTokensButton/ReverseTokensButton.style.js +14 -0
- package/components/ReverseTokensButton/index.d.ts +1 -0
- package/components/ReverseTokensButton/index.js +1 -0
- package/components/Select.d.ts +3 -0
- package/components/Select.js +27 -0
- package/components/SelectChainAndToken.d.ts +3 -0
- package/components/SelectChainAndToken.js +19 -0
- package/components/SelectTokenButton/SelectTokenButton.d.ts +5 -0
- package/components/SelectTokenButton/SelectTokenButton.js +29 -0
- package/components/SelectTokenButton/SelectTokenButton.style.d.ts +28 -0
- package/components/SelectTokenButton/SelectTokenButton.style.js +31 -0
- package/components/SelectTokenButton/index.d.ts +1 -0
- package/components/SelectTokenButton/index.js +1 -0
- package/components/StepActions/StepActions.d.ts +13 -0
- package/components/StepActions/StepActions.js +49 -0
- package/components/StepActions/StepActions.style.d.ts +20 -0
- package/components/StepActions/StepActions.style.js +56 -0
- package/components/StepActions/index.d.ts +1 -0
- package/components/StepActions/index.js +1 -0
- package/components/StepActions/types.d.ts +6 -0
- package/components/StepActions/types.js +1 -0
- package/components/StepToken.d.ts +6 -0
- package/components/StepToken.js +21 -0
- package/components/SwapButton/ButtonTooltip.d.ts +4 -0
- package/components/SwapButton/ButtonTooltip.js +3 -0
- package/components/SwapButton/SwapButton.d.ts +2 -0
- package/components/SwapButton/SwapButton.js +77 -0
- package/components/SwapButton/SwapButton.style.d.ts +65 -0
- package/components/SwapButton/SwapButton.style.js +20 -0
- package/components/SwapButton/index.d.ts +1 -0
- package/components/SwapButton/index.js +1 -0
- package/components/SwapInProgress/SwapInProgress.d.ts +3 -0
- package/components/SwapInProgress/SwapInProgress.js +22 -0
- package/components/SwapInProgress/SwapInProgress.style.d.ts +43 -0
- package/components/SwapInProgress/SwapInProgress.style.js +15 -0
- package/components/SwapInProgress/index.d.ts +1 -0
- package/components/SwapInProgress/index.js +1 -0
- package/components/SwapInput/FormPriceHelperText.d.ts +5 -0
- package/components/SwapInput/FormPriceHelperText.js +27 -0
- package/components/SwapInput/SwapInput.d.ts +3 -0
- package/components/SwapInput/SwapInput.js +43 -0
- package/components/SwapInput/SwapInput.style.d.ts +21 -0
- package/components/SwapInput/SwapInput.style.js +30 -0
- package/components/SwapInput/SwapInputAdornment.d.ts +2 -0
- package/components/SwapInput/SwapInputAdornment.js +23 -0
- package/components/SwapInput/SwapInputAdornment.style.d.ts +34 -0
- package/components/SwapInput/SwapInputAdornment.style.js +22 -0
- package/components/SwapInput/index.d.ts +1 -0
- package/components/SwapInput/index.js +1 -0
- package/components/SwapRouteCard/SwapRouteCard.d.ts +4 -0
- package/components/SwapRouteCard/SwapRouteCard.js +34 -0
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +36 -0
- package/components/SwapRouteCard/SwapRouteCard.style.js +71 -0
- package/components/SwapRouteCard/index.d.ts +1 -0
- package/components/SwapRouteCard/index.js +1 -0
- package/components/SwapRouteCard/types.d.ts +7 -0
- package/components/SwapRouteCard/types.js +1 -0
- package/components/SwapRoutes/SwapRoutes.d.ts +3 -0
- package/components/SwapRoutes/SwapRoutes.js +33 -0
- package/components/SwapRoutes/SwapRoutes.style.d.ts +11 -0
- package/components/SwapRoutes/SwapRoutes.style.js +9 -0
- package/components/SwapRoutes/SwapRoutesUpdateProgress.d.ts +3 -0
- package/components/SwapRoutes/SwapRoutesUpdateProgress.js +24 -0
- package/components/SwapRoutes/index.d.ts +1 -0
- package/components/SwapRoutes/index.js +1 -0
- package/components/Switch.d.ts +1 -0
- package/components/Switch.js +53 -0
- package/components/TextFitter/TextFitter.d.ts +3 -0
- package/components/TextFitter/TextFitter.js +44 -0
- package/components/TextFitter/index.d.ts +1 -0
- package/components/TextFitter/index.js +1 -0
- package/components/TextFitter/types.d.ts +12 -0
- package/components/TextFitter/types.js +1 -0
- package/components/TokenList/TokenList.d.ts +3 -0
- package/components/TokenList/TokenList.js +58 -0
- package/components/TokenList/TokenList.style.d.ts +32 -0
- package/components/TokenList/TokenList.style.js +22 -0
- package/components/TokenList/TokenListItem.d.ts +4 -0
- package/components/TokenList/TokenListItem.js +24 -0
- package/components/TokenList/index.d.ts +1 -0
- package/components/TokenList/index.js +1 -0
- package/components/TokenList/types.d.ts +16 -0
- package/components/TokenList/types.js +1 -0
- package/components/TokenList/utils.d.ts +15 -0
- package/components/TokenList/utils.js +10 -0
- package/config/env.d.ts +12 -0
- package/config/env.js +19 -0
- package/config/queryClient.d.ts +2 -0
- package/config/queryClient.js +25 -0
- package/config/rpcs.d.ts +1 -0
- package/config/rpcs.js +20 -0
- package/config/theme.d.ts +27 -0
- package/config/theme.js +126 -0
- package/hooks/index.d.ts +15 -0
- package/hooks/index.js +15 -0
- package/hooks/useBridges.d.ts +1 -0
- package/hooks/useBridges.js +12 -0
- package/hooks/useChain.d.ts +4 -0
- package/hooks/useChain.js +13 -0
- package/hooks/useChains.d.ts +101 -0
- package/hooks/useChains.js +39 -0
- package/hooks/useContentHeight.d.ts +1 -0
- package/hooks/useContentHeight.js +15 -0
- package/hooks/useDebouncedWatch.d.ts +1 -0
- package/hooks/useDebouncedWatch.js +27 -0
- package/hooks/useExchanges.d.ts +1 -0
- package/hooks/useExchanges.js +12 -0
- package/hooks/useHasSufficientBalance.d.ts +5 -0
- package/hooks/useHasSufficientBalance.js +59 -0
- package/hooks/useRouteExecution/index.d.ts +3 -0
- package/hooks/useRouteExecution/index.js +3 -0
- package/hooks/useRouteExecution/types.d.ts +15 -0
- package/hooks/useRouteExecution/types.js +1 -0
- package/hooks/useRouteExecution/useRouteExecution.d.ts +8 -0
- package/hooks/useRouteExecution/useRouteExecution.js +132 -0
- package/hooks/useRouteExecution/useRouteStore.d.ts +17 -0
- package/hooks/useRouteExecution/useRouteStore.js +71 -0
- package/hooks/useScrollableContainer.d.ts +2 -0
- package/hooks/useScrollableContainer.js +24 -0
- package/hooks/useSettings/index.d.ts +2 -0
- package/hooks/useSettings/index.js +2 -0
- package/hooks/useSettings/types.d.ts +5 -0
- package/hooks/useSettings/types.js +1 -0
- package/hooks/useSettings/useSettingsStore.d.ts +13 -0
- package/hooks/useSettings/useSettingsStore.js +22 -0
- package/hooks/useSwapRoutes.d.ts +8 -0
- package/hooks/useSwapRoutes.js +101 -0
- package/hooks/useToken.d.ts +4 -0
- package/hooks/useToken.js +13 -0
- package/hooks/useTokenBalance.d.ts +7 -0
- package/hooks/useTokenBalance.js +46 -0
- package/hooks/useTokenBalances.d.ts +7 -0
- package/hooks/useTokenBalances.js +54 -0
- package/hooks/useTokens.d.ts +5 -0
- package/hooks/useTokens.js +24 -0
- package/i18n/en/translation.json +138 -0
- package/i18n/index.d.ts +144 -0
- package/i18n/index.js +20 -0
- package/i18n/react-i18next.d.ts +9 -0
- package/index.d.ts +5 -0
- package/index.js +9 -0
- package/lifi.d.ts +2 -0
- package/lifi.js +10 -0
- package/package.json +55 -0
- package/pages/MainPage/MainPage.d.ts +2 -0
- package/pages/MainPage/MainPage.js +11 -0
- package/pages/MainPage/MainPage.style.d.ts +11 -0
- package/pages/MainPage/MainPage.style.js +8 -0
- package/pages/MainPage/SendToRecipientForm.d.ts +2 -0
- package/pages/MainPage/SendToRecipientForm.js +20 -0
- package/pages/MainPage/index.d.ts +1 -0
- package/pages/MainPage/index.js +1 -0
- package/pages/SelectTokenPage/ChainSelect.d.ts +2 -0
- package/pages/SelectTokenPage/ChainSelect.js +25 -0
- package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -0
- package/pages/SelectTokenPage/SearchTokenInput.js +17 -0
- package/pages/SelectTokenPage/SearchTokenInput.style.d.ts +1 -0
- package/pages/SelectTokenPage/SearchTokenInput.style.js +5 -0
- package/pages/SelectTokenPage/SelectTokenPage.d.ts +5 -0
- package/pages/SelectTokenPage/SelectTokenPage.js +16 -0
- package/pages/SelectTokenPage/index.d.ts +2 -0
- package/pages/SelectTokenPage/index.js +2 -0
- package/pages/SelectTokenPage/types.d.ts +4 -0
- package/pages/SelectTokenPage/types.js +5 -0
- package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -0
- package/pages/SelectWalletPage/SelectWalletPage.js +68 -0
- package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +46 -0
- package/pages/SelectWalletPage/SelectWalletPage.style.js +27 -0
- package/pages/SelectWalletPage/index.d.ts +1 -0
- package/pages/SelectWalletPage/index.js +1 -0
- package/pages/SettingsPage/AdvancedPreferences.d.ts +1 -0
- package/pages/SettingsPage/AdvancedPreferences.js +19 -0
- package/pages/SettingsPage/ColorSchemeButtonGroup.d.ts +2 -0
- package/pages/SettingsPage/ColorSchemeButtonGroup.js +20 -0
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +33 -0
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.js +16 -0
- package/pages/SettingsPage/EnabledBridgesSelect.d.ts +2 -0
- package/pages/SettingsPage/EnabledBridgesSelect.js +15 -0
- package/pages/SettingsPage/EnabledExchangesSelect.d.ts +2 -0
- package/pages/SettingsPage/EnabledExchangesSelect.js +15 -0
- package/pages/SettingsPage/GasPriceSelect.d.ts +1 -0
- package/pages/SettingsPage/GasPriceSelect.js +13 -0
- package/pages/SettingsPage/RoutePrioritySelect.d.ts +2 -0
- package/pages/SettingsPage/RoutePrioritySelect.js +13 -0
- package/pages/SettingsPage/SettingsPage.d.ts +1 -0
- package/pages/SettingsPage/SettingsPage.js +10 -0
- package/pages/SettingsPage/SlippageInput.d.ts +1 -0
- package/pages/SettingsPage/SlippageInput.js +28 -0
- package/pages/SettingsPage/index.d.ts +1 -0
- package/pages/SettingsPage/index.js +1 -0
- package/pages/SwapPage/CircularProgress.d.ts +4 -0
- package/pages/SwapPage/CircularProgress.js +20 -0
- package/pages/SwapPage/CircularProgress.style.d.ts +6 -0
- package/pages/SwapPage/CircularProgress.style.js +51 -0
- package/pages/SwapPage/ExecutionItem.d.ts +6 -0
- package/pages/SwapPage/ExecutionItem.js +21 -0
- package/pages/SwapPage/ExecutionItem.style.d.ts +39 -0
- package/pages/SwapPage/ExecutionItem.style.js +5 -0
- package/pages/SwapPage/StatusBottomSheet.d.ts +3 -0
- package/pages/SwapPage/StatusBottomSheet.js +79 -0
- package/pages/SwapPage/StatusBottomSheet.style.d.ts +25 -0
- package/pages/SwapPage/StatusBottomSheet.style.js +32 -0
- package/pages/SwapPage/StepDivider.d.ts +2 -0
- package/pages/SwapPage/StepDivider.js +6 -0
- package/pages/SwapPage/StepDivider.style.d.ts +11 -0
- package/pages/SwapPage/StepDivider.style.js +8 -0
- package/pages/SwapPage/StepItem.d.ts +7 -0
- package/pages/SwapPage/StepItem.js +29 -0
- package/pages/SwapPage/StepTimer.d.ts +5 -0
- package/pages/SwapPage/StepTimer.js +59 -0
- package/pages/SwapPage/SwapPage.d.ts +2 -0
- package/pages/SwapPage/SwapPage.js +22 -0
- package/pages/SwapPage/SwapPage.style.d.ts +44 -0
- package/pages/SwapPage/SwapPage.style.js +12 -0
- package/pages/SwapPage/index.d.ts +1 -0
- package/pages/SwapPage/index.js +1 -0
- package/pages/SwapPage/utils.d.ts +6 -0
- package/pages/SwapPage/utils.js +85 -0
- package/pages/SwapRoutesPage/SwapRoutesPage.d.ts +3 -0
- package/pages/SwapRoutesPage/SwapRoutesPage.js +24 -0
- package/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +11 -0
- package/pages/SwapRoutesPage/SwapRoutesPage.style.js +6 -0
- package/pages/SwapRoutesPage/index.d.ts +1 -0
- package/pages/SwapRoutesPage/index.js +1 -0
- package/providers/SwapFormProvider/SwapFormProvider.d.ts +2 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +20 -0
- package/providers/SwapFormProvider/index.d.ts +2 -0
- package/providers/SwapFormProvider/index.js +2 -0
- package/providers/SwapFormProvider/types.d.ts +44 -0
- package/providers/SwapFormProvider/types.js +24 -0
- package/providers/ThemeProvider/ThemeProvider.d.ts +2 -0
- package/providers/ThemeProvider/ThemeProvider.js +33 -0
- package/providers/ThemeProvider/index.d.ts +1 -0
- package/providers/ThemeProvider/index.js +1 -0
- package/providers/WalletProvider/WalletProvider.d.ts +4 -0
- package/providers/WalletProvider/WalletProvider.js +89 -0
- package/providers/WalletProvider/index.d.ts +2 -0
- package/providers/WalletProvider/index.js +2 -0
- package/providers/WalletProvider/types.d.ts +17 -0
- package/providers/WalletProvider/types.js +1 -0
- package/providers/WidgetProvider/WidgetProvider.d.ts +4 -0
- package/providers/WidgetProvider/WidgetProvider.js +44 -0
- package/providers/WidgetProvider/index.d.ts +2 -0
- package/providers/WidgetProvider/index.js +2 -0
- package/providers/WidgetProvider/types.d.ts +8 -0
- package/providers/WidgetProvider/types.js +1 -0
- package/react-app-env.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/widget.d.ts +41 -0
- package/types/widget.js +1 -0
- package/utils/colors.d.ts +2 -0
- package/utils/colors.js +3 -0
- package/utils/deepClone.d.ts +1 -0
- package/utils/deepClone.js +3 -0
- package/utils/elements.d.ts +4 -0
- package/utils/elements.js +5 -0
- package/utils/format.d.ts +9 -0
- package/utils/format.js +76 -0
- package/utils/input.d.ts +1 -0
- package/utils/input.js +24 -0
- package/utils/routes.d.ts +10 -0
- package/utils/routes.js +9 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StepIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
3
|
+
export declare const StepConnector: import("@emotion/styled").StyledComponent<import("@mui/material").StepConnectorProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
4
|
+
export declare const StepLabel: import("@emotion/styled").StyledComponent<import("@mui/material").StepLabelProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
5
|
+
export declare const StepContent: import("@emotion/styled").StyledComponent<import("@mui/material").StepContentProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
6
|
+
export declare const StepAvatar: import("@emotion/styled").StyledComponent<{
|
|
7
|
+
alt?: string | undefined;
|
|
8
|
+
children?: import("react").ReactNode;
|
|
9
|
+
classes?: Partial<import("@mui/material").AvatarClasses> | undefined;
|
|
10
|
+
imgProps?: (import("react").ImgHTMLAttributes<HTMLImageElement> & {
|
|
11
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
12
|
+
}) | undefined;
|
|
13
|
+
sizes?: string | undefined;
|
|
14
|
+
src?: string | undefined;
|
|
15
|
+
srcSet?: string | undefined;
|
|
16
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
17
|
+
variant?: "square" | "circular" | "rounded" | undefined;
|
|
18
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
19
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
20
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "alt" | "src" | "sizes" | "srcSet" | "imgProps"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Avatar, StepConnector as MuiStepConnector, StepContent as MuiStepContent, StepLabel as MuiStepLabel, } from '@mui/material';
|
|
2
|
+
import { stepConnectorClasses } from '@mui/material/StepConnector';
|
|
3
|
+
import { stepContentClasses } from '@mui/material/StepContent';
|
|
4
|
+
import { stepLabelClasses } from '@mui/material/StepLabel';
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
|
+
export const StepIcon = styled('span', {
|
|
7
|
+
shouldForwardProp: (prop) => !['active', 'completed', 'error'].includes(prop),
|
|
8
|
+
})(({ theme }) => ({
|
|
9
|
+
width: 12,
|
|
10
|
+
height: 12,
|
|
11
|
+
borderRadius: '50%',
|
|
12
|
+
border: `2px solid ${theme.palette.mode === 'light'
|
|
13
|
+
? theme.palette.grey[300]
|
|
14
|
+
: theme.palette.grey[800]}`,
|
|
15
|
+
}));
|
|
16
|
+
export const StepConnector = styled(MuiStepConnector, {
|
|
17
|
+
shouldForwardProp: (prop) => !['active', 'completed', 'error'].includes(prop),
|
|
18
|
+
})(({ theme }) => ({
|
|
19
|
+
marginLeft: theme.spacing(1.875),
|
|
20
|
+
[`.${stepConnectorClasses.line}`]: {
|
|
21
|
+
minHeight: 8,
|
|
22
|
+
borderLeftWidth: 2,
|
|
23
|
+
borderColor: theme.palette.mode === 'light'
|
|
24
|
+
? theme.palette.grey[300]
|
|
25
|
+
: theme.palette.grey[800],
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
export const StepLabel = styled(MuiStepLabel, {
|
|
29
|
+
shouldForwardProp: (prop) => !['active', 'completed', 'error', 'disabled'].includes(prop),
|
|
30
|
+
})(({ theme }) => ({
|
|
31
|
+
padding: 0,
|
|
32
|
+
[`.${stepLabelClasses.iconContainer}`]: {
|
|
33
|
+
paddingLeft: theme.spacing(1.25),
|
|
34
|
+
paddingRight: theme.spacing(3.25),
|
|
35
|
+
},
|
|
36
|
+
[`&.${stepLabelClasses.disabled}`]: {
|
|
37
|
+
cursor: 'inherit',
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
export const StepContent = styled(MuiStepContent, {
|
|
41
|
+
shouldForwardProp: (prop) => !['active', 'completed', 'error'].includes(prop),
|
|
42
|
+
})(({ theme }) => ({
|
|
43
|
+
borderLeft: `2px solid ${theme.palette.mode === 'light'
|
|
44
|
+
? theme.palette.grey[300]
|
|
45
|
+
: theme.palette.grey[800]}`,
|
|
46
|
+
marginLeft: theme.spacing(1.875),
|
|
47
|
+
paddingLeft: theme.spacing(3.875),
|
|
48
|
+
[`&.${stepContentClasses.last}`]: {
|
|
49
|
+
borderLeft: 'none',
|
|
50
|
+
paddingLeft: theme.spacing(4.1875),
|
|
51
|
+
},
|
|
52
|
+
}));
|
|
53
|
+
export const StepAvatar = styled(Avatar)(({ theme, variant }) => ({
|
|
54
|
+
color: variant === 'square' ? theme.palette.text.primary : theme.palette.grey[900],
|
|
55
|
+
backgroundColor: 'transparent',
|
|
56
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StepActions } from './StepActions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StepActions } from './StepActions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Avatar, Box, Typography } from '@mui/material';
|
|
14
|
+
import { formatTokenAmount } from '../utils/format';
|
|
15
|
+
import { TextFitter } from './TextFitter';
|
|
16
|
+
export const StepToken = (_a) => {
|
|
17
|
+
var { token } = _a, other = __rest(_a, ["token"]);
|
|
18
|
+
return (_jsxs(Box, Object.assign({ flex: 1 }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", flex: 1 }, { children: [_jsx(Avatar, Object.assign({ src: token.logoURI, alt: token.symbol, sx: { marginRight: 2 } }, { children: token.symbol[0] })), _jsx(TextFitter, Object.assign({ maxHeight: 32, textStyle: {
|
|
19
|
+
fontWeight: 700,
|
|
20
|
+
} }, { children: formatTokenAmount(token.amount, token.decimals) }))] })), _jsx(Typography, Object.assign({ fontSize: 14, lineHeight: 1, fontWeight: "500", color: "text.secondary", mr: 1, ml: 6 }, { children: token.symbol }))] })));
|
|
21
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip } from '@mui/material';
|
|
3
|
+
export const ButtonTooltip = ({ title, children, }) => title ? (_jsx(Tooltip, Object.assign({ title: title, placement: "top", enterDelay: 250, arrow: true }, { children: _jsx("span", { children: children }) }))) : (children);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { ChainId } from '@lifinance/sdk';
|
|
12
|
+
import { useWatch } from 'react-hook-form';
|
|
13
|
+
import { useTranslation } from 'react-i18next';
|
|
14
|
+
import { useNavigate } from 'react-router-dom';
|
|
15
|
+
import { useChains, useCurrentRoute, useHasSufficientBalance, useSetExecutableRoute, useSwapRoutes, } from '../../hooks';
|
|
16
|
+
import { SwapFormKeyHelper } from '../../providers/SwapFormProvider';
|
|
17
|
+
import { useWallet } from '../../providers/WalletProvider';
|
|
18
|
+
import { routes } from '../../utils/routes';
|
|
19
|
+
import { ButtonTooltip } from './ButtonTooltip';
|
|
20
|
+
import { Button } from './SwapButton.style';
|
|
21
|
+
export const SwapButton = () => {
|
|
22
|
+
var _a;
|
|
23
|
+
const navigate = useNavigate();
|
|
24
|
+
const { t } = useTranslation();
|
|
25
|
+
const { getChainById } = useChains();
|
|
26
|
+
const { account, switchChain } = useWallet();
|
|
27
|
+
const [currentRoute] = useCurrentRoute();
|
|
28
|
+
const setExecutableRoute = useSetExecutableRoute();
|
|
29
|
+
const { routes: swapRoutes, isLoading, isFetching } = useSwapRoutes();
|
|
30
|
+
const { hasGasBalanceOnStartChain, hasGasOnCrossChain, hasSufficientBalance, } = useHasSufficientBalance();
|
|
31
|
+
const [chainId] = useWatch({
|
|
32
|
+
name: [SwapFormKeyHelper.getChainKey('from')],
|
|
33
|
+
});
|
|
34
|
+
const isCurrentChainMatch = ((_a = getChainById(chainId || ChainId.ETH)) === null || _a === void 0 ? void 0 : _a.id) === account.chainId;
|
|
35
|
+
const handleSwapButtonClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
if (!account.isActive) {
|
|
37
|
+
navigate(routes.selectWallet);
|
|
38
|
+
}
|
|
39
|
+
else if (!isCurrentChainMatch) {
|
|
40
|
+
yield switchChain(chainId);
|
|
41
|
+
// check that the current route exists in the up to date route list
|
|
42
|
+
}
|
|
43
|
+
else if (currentRoute &&
|
|
44
|
+
(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.some((route) => route.id === currentRoute.id))) {
|
|
45
|
+
setExecutableRoute(currentRoute);
|
|
46
|
+
navigate(routes.swap, { state: { routeId: currentRoute.id } });
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const getButtonText = () => {
|
|
50
|
+
if (account.isActive) {
|
|
51
|
+
if (!isCurrentChainMatch) {
|
|
52
|
+
return t(`button.switchChain`);
|
|
53
|
+
}
|
|
54
|
+
if (!hasSufficientBalance) {
|
|
55
|
+
return t(`swap.insufficientFunds`);
|
|
56
|
+
}
|
|
57
|
+
if (!hasGasBalanceOnStartChain) {
|
|
58
|
+
return t(`swap.insufficientGasOnStartChain`);
|
|
59
|
+
}
|
|
60
|
+
if (!hasGasOnCrossChain) {
|
|
61
|
+
return t(`swap.insufficientGasOnDestinationChain`);
|
|
62
|
+
}
|
|
63
|
+
return t(`button.swap`);
|
|
64
|
+
}
|
|
65
|
+
return t(`button.connectWallet`);
|
|
66
|
+
};
|
|
67
|
+
return (_jsx(ButtonTooltip, Object.assign({ title: !hasGasOnCrossChain
|
|
68
|
+
? t(`swap.insufficientGasOnDestinationChainTooltip`)
|
|
69
|
+
: undefined }, { children: _jsx(Button, Object.assign({ variant: "contained", disableElevation: true, fullWidth: true, color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick,
|
|
70
|
+
// loading={isLoading || isFetching}
|
|
71
|
+
disabled: (!hasSufficientBalance ||
|
|
72
|
+
!hasGasBalanceOnStartChain ||
|
|
73
|
+
!hasGasOnCrossChain ||
|
|
74
|
+
isLoading ||
|
|
75
|
+
isFetching) &&
|
|
76
|
+
isCurrentChainMatch }, { children: getButtonText() })) })));
|
|
77
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
classes?: (Partial<import("@mui/material/Button").ButtonClasses> & {
|
|
4
|
+
root?: string | undefined;
|
|
5
|
+
loading?: string | undefined;
|
|
6
|
+
loadingIndicator?: string | undefined;
|
|
7
|
+
loadingIndicatorCenter?: string | undefined;
|
|
8
|
+
loadingIndicatorStart?: string | undefined;
|
|
9
|
+
loadingIndicatorEnd?: string | undefined;
|
|
10
|
+
endIconLoadingEnd?: string | undefined;
|
|
11
|
+
startIconLoadingStart?: string | undefined;
|
|
12
|
+
}) | undefined;
|
|
13
|
+
loading?: boolean | undefined;
|
|
14
|
+
loadingIndicator?: import("react").ReactNode;
|
|
15
|
+
loadingPosition?: "center" | "end" | "start" | undefined;
|
|
16
|
+
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
17
|
+
} & Omit<{
|
|
18
|
+
children?: import("react").ReactNode;
|
|
19
|
+
classes?: Partial<import("@mui/material/Button").ButtonClasses> | undefined;
|
|
20
|
+
color?: "inherit" | "success" | "error" | "primary" | "secondary" | "info" | "warning" | undefined;
|
|
21
|
+
disabled?: boolean | undefined;
|
|
22
|
+
disableElevation?: boolean | undefined;
|
|
23
|
+
disableFocusRipple?: boolean | undefined;
|
|
24
|
+
endIcon?: import("react").ReactNode;
|
|
25
|
+
fullWidth?: boolean | undefined;
|
|
26
|
+
href?: string | undefined;
|
|
27
|
+
size?: "small" | "large" | "medium" | undefined;
|
|
28
|
+
startIcon?: import("react").ReactNode;
|
|
29
|
+
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
30
|
+
variant?: "text" | "outlined" | "contained" | undefined;
|
|
31
|
+
} & Omit<{
|
|
32
|
+
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
33
|
+
centerRipple?: boolean | undefined;
|
|
34
|
+
children?: import("react").ReactNode;
|
|
35
|
+
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
36
|
+
disabled?: boolean | undefined;
|
|
37
|
+
disableRipple?: boolean | undefined;
|
|
38
|
+
disableTouchRipple?: boolean | undefined;
|
|
39
|
+
focusRipple?: boolean | undefined;
|
|
40
|
+
focusVisibleClassName?: string | undefined;
|
|
41
|
+
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
42
|
+
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
43
|
+
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
44
|
+
tabIndex?: number | undefined;
|
|
45
|
+
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
46
|
+
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
47
|
+
}, "classes">, "classes"> & Omit<{
|
|
48
|
+
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
49
|
+
centerRipple?: boolean | undefined;
|
|
50
|
+
children?: import("react").ReactNode;
|
|
51
|
+
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
52
|
+
disabled?: boolean | undefined;
|
|
53
|
+
disableRipple?: boolean | undefined;
|
|
54
|
+
disableTouchRipple?: boolean | undefined;
|
|
55
|
+
focusRipple?: boolean | undefined;
|
|
56
|
+
focusVisibleClassName?: string | undefined;
|
|
57
|
+
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
58
|
+
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
59
|
+
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
60
|
+
tabIndex?: number | undefined;
|
|
61
|
+
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
62
|
+
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
63
|
+
}, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "key" | keyof import("react").ButtonHTMLAttributes<HTMLButtonElement>> & {
|
|
64
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
65
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "color" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "href" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "size" | "startIcon" | "variant" | "loading" | "loadingIndicator" | "loadingPosition"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LoadingButton } from '@mui/lab';
|
|
2
|
+
import { loadingButtonClasses } from '@mui/lab/LoadingButton';
|
|
3
|
+
import { buttonClasses } from '@mui/material/Button';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import { getContrastAlphaColor } from '../../utils/colors';
|
|
6
|
+
export const Button = styled(LoadingButton)(({ theme }) => ({
|
|
7
|
+
textTransform: 'none',
|
|
8
|
+
borderRadius: theme.shape.borderRadiusSecondary,
|
|
9
|
+
padding: theme.spacing(1.25, 2),
|
|
10
|
+
fontSize: '1rem',
|
|
11
|
+
[`&.${buttonClasses.disabled}`]: {
|
|
12
|
+
color: getContrastAlphaColor(theme, '70%'),
|
|
13
|
+
},
|
|
14
|
+
[`&.${loadingButtonClasses.loading}`]: {
|
|
15
|
+
color: 'transparent',
|
|
16
|
+
},
|
|
17
|
+
[`.${loadingButtonClasses.loadingIndicator}`]: {
|
|
18
|
+
color: getContrastAlphaColor(theme, '70%'),
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SwapButton } from './SwapButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SwapButton } from './SwapButton';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowForward as ArrowForwardIcon, KeyboardArrowRight as KeyboardArrowRightIcon, } from '@mui/icons-material';
|
|
3
|
+
import { AvatarGroup, Box, Stack } from '@mui/material';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { useNavigate } from 'react-router-dom';
|
|
7
|
+
import { useExecutingRoutes } from '../../hooks';
|
|
8
|
+
import { routes } from '../../utils/routes';
|
|
9
|
+
import { CardTitle } from '../Card';
|
|
10
|
+
import { Card, RouteAvatar, RouteCard } from './SwapInProgress.style';
|
|
11
|
+
export const SwapInProgress = (props) => {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const navigate = useNavigate();
|
|
14
|
+
const executingRoutes = useExecutingRoutes();
|
|
15
|
+
const handleCardClick = useCallback((routeId) => {
|
|
16
|
+
navigate(routes.swap, { state: { routeId } });
|
|
17
|
+
}, [navigate]);
|
|
18
|
+
if (!(executingRoutes === null || executingRoutes === void 0 ? void 0 : executingRoutes.length)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return (_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.inProgress') }), _jsx(Stack, Object.assign({ spacing: 2, py: 2 }, { children: executingRoutes.map(({ route, status }) => (_jsx(RouteCard, { onClick: () => handleCardClick(route.id), avatar: _jsxs(AvatarGroup, Object.assign({ total: 2 }, { children: [_jsx(RouteAvatar, Object.assign({ src: route.fromToken.logoURI, alt: route.fromToken.symbol }, { children: route.fromToken.symbol[0] })), _jsx(RouteAvatar, Object.assign({ src: route.toToken.logoURI, alt: route.toToken.symbol }, { children: route.toToken.symbol[0] }))] })), action: _jsx(KeyboardArrowRightIcon, {}), title: _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: [route.fromToken.symbol, _jsx(ArrowForwardIcon, { fontSize: "small", sx: { paddingX: 0.5 } }), route.toToken.symbol] })) }, route.id))) }))] })));
|
|
22
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Card: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
component?: import("react").ElementType<any> | undefined;
|
|
5
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
6
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
7
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
8
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
9
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
10
|
+
isError?: boolean | undefined;
|
|
11
|
+
}, {}, {}>;
|
|
12
|
+
export declare const RouteCard: import("@emotion/styled").StyledComponent<{
|
|
13
|
+
action?: import("react").ReactNode;
|
|
14
|
+
avatar?: import("react").ReactNode;
|
|
15
|
+
classes?: Partial<import("@mui/material").CardHeaderClasses> | undefined;
|
|
16
|
+
disableTypography?: boolean | undefined;
|
|
17
|
+
subheader?: import("react").ReactNode;
|
|
18
|
+
subheaderTypographyProps?: import("@mui/material").TypographyProps<"span", {
|
|
19
|
+
component?: "span" | undefined;
|
|
20
|
+
}> | undefined;
|
|
21
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
22
|
+
title?: import("react").ReactNode;
|
|
23
|
+
titleTypographyProps?: import("@mui/material").TypographyProps<"span", {
|
|
24
|
+
component?: "span" | undefined;
|
|
25
|
+
}> | undefined;
|
|
26
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
27
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
28
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "title" | "action" | "sx" | "avatar" | "disableTypography" | "subheader" | "subheaderTypographyProps" | "titleTypographyProps"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
29
|
+
export declare const RouteAvatar: import("@emotion/styled").StyledComponent<{
|
|
30
|
+
alt?: string | undefined;
|
|
31
|
+
children?: import("react").ReactNode;
|
|
32
|
+
classes?: Partial<import("@mui/material").AvatarClasses> | undefined;
|
|
33
|
+
imgProps?: (import("react").ImgHTMLAttributes<HTMLImageElement> & {
|
|
34
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
35
|
+
}) | undefined;
|
|
36
|
+
sizes?: string | undefined;
|
|
37
|
+
src?: string | undefined;
|
|
38
|
+
srcSet?: string | undefined;
|
|
39
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
40
|
+
variant?: "square" | "circular" | "rounded" | undefined;
|
|
41
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
42
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
43
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "alt" | "src" | "sizes" | "srcSet" | "imgProps"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Avatar } from '@mui/material';
|
|
2
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
3
|
+
import { CardContainer, CardHeader } from '../Card';
|
|
4
|
+
export const Card = styled(CardContainer)(({ theme }) => ({
|
|
5
|
+
borderColor: alpha(theme.palette.secondary.main, 0.48),
|
|
6
|
+
background: alpha(theme.palette.secondary.main, 0.2),
|
|
7
|
+
}));
|
|
8
|
+
export const RouteCard = styled(CardHeader)(({ theme }) => ({
|
|
9
|
+
cursor: 'pointer',
|
|
10
|
+
paddingTop: 0,
|
|
11
|
+
paddingBottom: 0,
|
|
12
|
+
}));
|
|
13
|
+
export const RouteAvatar = styled(Avatar)(({ theme }) => ({
|
|
14
|
+
backgroundColor: theme.palette.background.paper,
|
|
15
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapInProgress';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapInProgress';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FormHelperText, Skeleton, Typography } from '@mui/material';
|
|
3
|
+
import { useWatch } from 'react-hook-form';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { useTokenBalance } from '../../hooks';
|
|
6
|
+
import { SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
|
|
7
|
+
import { formatTokenPrice } from '../../utils/format';
|
|
8
|
+
export const FormPriceHelperText = ({ formType, selected }) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const [amount, chainId, tokenAddress] = useWatch({
|
|
11
|
+
name: [
|
|
12
|
+
SwapFormKeyHelper.getAmountKey(formType),
|
|
13
|
+
SwapFormKeyHelper.getChainKey(formType),
|
|
14
|
+
SwapFormKeyHelper.getTokenKey(formType),
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
const { token, isLoading, isFetching } = useTokenBalance(chainId, tokenAddress);
|
|
18
|
+
const fromAmountTokenPrice = formatTokenPrice(amount, token === null || token === void 0 ? void 0 : token.priceUSD);
|
|
19
|
+
return (_jsxs(FormHelperText, Object.assign({ component: "div", sx: { display: 'flex', justifyContent: 'space-between', margin: 0 } }, { children: [_jsx(Typography, Object.assign({ color: fromAmountTokenPrice ? 'text.secondary' : 'grey.600', fontWeight: 400, fontSize: 12, marginLeft: selected ? 8 : 2, lineHeight: 1.3334, flex: 1, sx: {
|
|
20
|
+
wordBreak: 'break-word',
|
|
21
|
+
overflowWrap: 'break-word',
|
|
22
|
+
} }, { children: t(`swap.currency`, {
|
|
23
|
+
value: fromAmountTokenPrice,
|
|
24
|
+
}) })), isLoading && isFetching ? (_jsx(Skeleton, { variant: "text", width: 48, height: 16, sx: { borderRadius: 0.25 } })) : token ? (_jsx(Typography, Object.assign({ fontWeight: 400, fontSize: 12, color: "text.secondary", lineHeight: 1.3334, pl: 0.25 }, { children: t(`swap.maxAmount`, {
|
|
25
|
+
amount: token === null || token === void 0 ? void 0 : token.amount,
|
|
26
|
+
}) }))) : null] })));
|
|
27
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar } from '@mui/material';
|
|
3
|
+
import { useLayoutEffect, useRef } from 'react';
|
|
4
|
+
import { useFormContext, useWatch } from 'react-hook-form';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { useChain, useToken } from '../../hooks';
|
|
7
|
+
import { SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
|
|
8
|
+
import { formatAmount } from '../../utils/format';
|
|
9
|
+
import { fitInputText } from '../../utils/input';
|
|
10
|
+
import { CardContainer, CardTitle } from '../Card';
|
|
11
|
+
import { FormPriceHelperText } from './FormPriceHelperText';
|
|
12
|
+
import { FormControl, Input, maxInputFontSize, minInputFontSize, } from './SwapInput.style';
|
|
13
|
+
import { SwapInputAdornment } from './SwapInputAdornment';
|
|
14
|
+
export const SwapInput = ({ formType }) => {
|
|
15
|
+
const { t } = useTranslation();
|
|
16
|
+
const { setValue } = useFormContext();
|
|
17
|
+
const ref = useRef(null);
|
|
18
|
+
const amountKey = SwapFormKeyHelper.getAmountKey(formType);
|
|
19
|
+
const [amount, chainId, tokenAddress] = useWatch({
|
|
20
|
+
name: [
|
|
21
|
+
amountKey,
|
|
22
|
+
SwapFormKeyHelper.getChainKey(formType),
|
|
23
|
+
SwapFormKeyHelper.getTokenKey(formType),
|
|
24
|
+
],
|
|
25
|
+
});
|
|
26
|
+
const { chain } = useChain(chainId);
|
|
27
|
+
const { token } = useToken(chainId, tokenAddress);
|
|
28
|
+
const isSelected = !!(chain && token);
|
|
29
|
+
const handleChange = (event) => {
|
|
30
|
+
const { value } = event.target;
|
|
31
|
+
setValue(amountKey, formatAmount(value, true));
|
|
32
|
+
};
|
|
33
|
+
const handleBlur = (event) => {
|
|
34
|
+
const { value } = event.target;
|
|
35
|
+
setValue(amountKey, formatAmount(value));
|
|
36
|
+
};
|
|
37
|
+
useLayoutEffect(() => {
|
|
38
|
+
fitInputText(maxInputFontSize, minInputFontSize, ref.current);
|
|
39
|
+
}, [amount]);
|
|
40
|
+
return (_jsxs(CardContainer, { children: [_jsx(CardTitle, { children: t('swap.amount') }), _jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [_jsx(Input, { inputRef: ref, size: "small", autoComplete: "off", placeholder: "0", startAdornment: isSelected ? (_jsx(Avatar, Object.assign({ src: token.logoURI, alt: token.symbol, sx: { marginLeft: 2 } }, { children: token.symbol[0] }))) : null, endAdornment: _jsx(SwapInputAdornment, { formType: formType }), inputProps: {
|
|
41
|
+
inputMode: 'decimal',
|
|
42
|
+
}, onChange: handleChange, onBlur: handleBlur, value: amount, name: amountKey, required: true }), _jsx(FormPriceHelperText, { selected: isSelected, formType: formType })] }))] }));
|
|
43
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const maxInputFontSize = 24;
|
|
3
|
+
export declare const minInputFontSize = 14;
|
|
4
|
+
export declare const FormControl: import("@emotion/styled").StyledComponent<{
|
|
5
|
+
children?: import("react").ReactNode;
|
|
6
|
+
classes?: Partial<import("@mui/material").FormControlClasses> | undefined;
|
|
7
|
+
color?: "success" | "error" | "primary" | "secondary" | "info" | "warning" | undefined;
|
|
8
|
+
disabled?: boolean | undefined;
|
|
9
|
+
error?: boolean | undefined;
|
|
10
|
+
fullWidth?: boolean | undefined;
|
|
11
|
+
focused?: boolean | undefined;
|
|
12
|
+
hiddenLabel?: boolean | undefined;
|
|
13
|
+
margin?: "none" | "normal" | "dense" | undefined;
|
|
14
|
+
required?: boolean | undefined;
|
|
15
|
+
size?: "small" | "medium" | undefined;
|
|
16
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
17
|
+
variant?: "outlined" | "filled" | "standard" | undefined;
|
|
18
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
19
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
20
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "color" | "children" | "disabled" | "sx" | "margin" | "fullWidth" | "size" | "variant" | "error" | "required" | "focused" | "hiddenLabel"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
21
|
+
export declare const Input: import("@emotion/styled").StyledComponent<import("@mui/material").InputBaseProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FormControl as MuiFormControl, InputBase } from '@mui/material';
|
|
2
|
+
import { inputBaseClasses } from '@mui/material/InputBase';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
export const maxInputFontSize = 24;
|
|
5
|
+
export const minInputFontSize = 14;
|
|
6
|
+
export const FormControl = styled(MuiFormControl)(({ theme }) => ({
|
|
7
|
+
padding: theme.spacing(1.5, 2, 1.5, 0),
|
|
8
|
+
}));
|
|
9
|
+
export const Input = styled(InputBase)(({ theme }) => ({
|
|
10
|
+
fontSize: 24,
|
|
11
|
+
fontWeight: 700,
|
|
12
|
+
// padding: theme.spacing(2, 2, 2, 0),
|
|
13
|
+
[`.${inputBaseClasses.input}`]: {
|
|
14
|
+
height: 32,
|
|
15
|
+
padding: theme.spacing(0, 0, 0, 2),
|
|
16
|
+
},
|
|
17
|
+
'& input[type="number"]::-webkit-outer-spin-button, & input[type="number"]::-webkit-inner-spin-button': {
|
|
18
|
+
WebkitAppearance: 'none',
|
|
19
|
+
margin: 0,
|
|
20
|
+
},
|
|
21
|
+
'& input[type="number"]': {
|
|
22
|
+
MozAppearance: 'textfield',
|
|
23
|
+
},
|
|
24
|
+
[`&.${inputBaseClasses.disabled}`]: {
|
|
25
|
+
color: 'inherit',
|
|
26
|
+
},
|
|
27
|
+
[`.${inputBaseClasses.input}.${inputBaseClasses.disabled}`]: {
|
|
28
|
+
WebkitTextFillColor: 'unset',
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { InputAdornment, Skeleton } from '@mui/material';
|
|
3
|
+
import { useFormContext, useWatch } from 'react-hook-form';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { useTokenBalance } from '../../hooks';
|
|
6
|
+
import { SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
|
|
7
|
+
import { Button } from './SwapInputAdornment.style';
|
|
8
|
+
export const SwapInputAdornment = ({ formType }) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const { setValue } = useFormContext();
|
|
11
|
+
const [chainId, tokenAddress] = useWatch({
|
|
12
|
+
name: [
|
|
13
|
+
SwapFormKeyHelper.getChainKey(formType),
|
|
14
|
+
SwapFormKeyHelper.getTokenKey(formType),
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
const { token, isLoading, isFetching } = useTokenBalance(chainId, tokenAddress);
|
|
18
|
+
const handleMax = () => {
|
|
19
|
+
var _a;
|
|
20
|
+
setValue(SwapFormKeyHelper.getAmountKey(formType), (_a = token === null || token === void 0 ? void 0 : token.amount) !== null && _a !== void 0 ? _a : '');
|
|
21
|
+
};
|
|
22
|
+
return (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isLoading && isFetching ? (_jsx(Skeleton, { variant: "rectangular", width: 46, height: 20, sx: { borderRadius: 0.5 } })) : formType === 'from' && (token === null || token === void 0 ? void 0 : token.amount) ? (_jsx(Button, Object.assign({ onClick: handleMax, variant: "outlined" }, { children: t('button.max') }))) : null })));
|
|
23
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
5
|
+
color?: "inherit" | "success" | "error" | "primary" | "secondary" | "info" | "warning" | undefined;
|
|
6
|
+
disabled?: boolean | undefined;
|
|
7
|
+
disableElevation?: boolean | undefined;
|
|
8
|
+
disableFocusRipple?: boolean | undefined;
|
|
9
|
+
endIcon?: import("react").ReactNode;
|
|
10
|
+
fullWidth?: boolean | undefined;
|
|
11
|
+
href?: string | undefined;
|
|
12
|
+
size?: "small" | "large" | "medium" | undefined;
|
|
13
|
+
startIcon?: import("react").ReactNode;
|
|
14
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
15
|
+
variant?: "text" | "outlined" | "contained" | undefined;
|
|
16
|
+
} & Omit<{
|
|
17
|
+
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
18
|
+
centerRipple?: boolean | undefined;
|
|
19
|
+
children?: import("react").ReactNode;
|
|
20
|
+
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
21
|
+
disabled?: boolean | undefined;
|
|
22
|
+
disableRipple?: boolean | undefined;
|
|
23
|
+
disableTouchRipple?: boolean | undefined;
|
|
24
|
+
focusRipple?: boolean | undefined;
|
|
25
|
+
focusVisibleClassName?: string | undefined;
|
|
26
|
+
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
27
|
+
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
28
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
29
|
+
tabIndex?: number | undefined;
|
|
30
|
+
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
31
|
+
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
32
|
+
}, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "key" | keyof import("react").ButtonHTMLAttributes<HTMLButtonElement>> & {
|
|
33
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
34
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "color" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "href" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "size" | "startIcon" | "variant"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|