@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,22 @@
|
|
|
1
|
+
import { Button as MuiButton } from '@mui/material';
|
|
2
|
+
import { lighten, styled } from '@mui/material/styles';
|
|
3
|
+
export const Button = styled(MuiButton)(({ theme }) => ({
|
|
4
|
+
textTransform: 'none',
|
|
5
|
+
borderRadius: theme.shape.borderRadiusSecondary,
|
|
6
|
+
borderColor: theme.palette.mode === 'light'
|
|
7
|
+
? theme.palette.grey[300]
|
|
8
|
+
: theme.palette.grey[800],
|
|
9
|
+
color: theme.palette.text.secondary,
|
|
10
|
+
padding: theme.spacing(0.125, 1, 0.375, 1),
|
|
11
|
+
lineHeight: 1,
|
|
12
|
+
fontSize: '0.875rem',
|
|
13
|
+
minWidth: 'unset',
|
|
14
|
+
'&:hover': {
|
|
15
|
+
color: theme.palette.mode === 'light'
|
|
16
|
+
? theme.palette.primary.main
|
|
17
|
+
: theme.palette.text.primary,
|
|
18
|
+
borderColor: theme.palette.mode === 'light'
|
|
19
|
+
? lighten(theme.palette.primary.main, 0.5)
|
|
20
|
+
: theme.palette.text.secondary,
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapInput';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapInput';
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { Check as CheckIcon } from '@mui/icons-material';
|
|
14
|
+
import { Box, Typography } from '@mui/material';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { StepActions } from '../StepActions';
|
|
17
|
+
import { StepToken } from '../StepToken';
|
|
18
|
+
import { Card, Check, Label } from './SwapRouteCard.style';
|
|
19
|
+
export const SwapRouteCard = (_a) => {
|
|
20
|
+
var { route, active, dense } = _a, other = __rest(_a, ["route", "active", "dense"]);
|
|
21
|
+
const { t } = useTranslation();
|
|
22
|
+
return (_jsx(Card, Object.assign({ active: active, dense: dense }, other, { children: _jsxs(Box, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
justifyContent: 'space-between',
|
|
26
|
+
}, mb: 2 }, { children: [_jsx(Label, { children: "GENERAL" }), active ? (_jsx(Check, { children: _jsx(CheckIcon, { fontSize: "inherit" }) })) : null] })), _jsx(StepToken, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), mb: 2 }), !dense
|
|
27
|
+
? route.steps.map((step) => (_jsx(StepActions, { step: step, mb: 2 }, step.id)))
|
|
28
|
+
: null, _jsxs(Box, Object.assign({ sx: {
|
|
29
|
+
display: 'flex',
|
|
30
|
+
justifyContent: 'space-between',
|
|
31
|
+
} }, { children: [_jsxs(Box, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "500" }, { children: t(`swap.currency`, { value: route.gasCostUSD }) })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary" }, { children: t(`swap.gas`) }))] }), _jsxs(Box, { children: [_jsxs(Typography, Object.assign({ fontSize: 18, fontWeight: "500", display: "flex", justifyContent: "flex-end" }, { children: ["~", (route.steps
|
|
32
|
+
.map((step) => step.estimate.executionDuration)
|
|
33
|
+
.reduce((cumulated, x) => cumulated + x) / 60).toFixed(0)] })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", textAlign: "end" }, { children: t(`swap.minutes`) }))] })] }))] }) })));
|
|
34
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
active?: boolean | undefined;
|
|
11
|
+
blur?: boolean | undefined;
|
|
12
|
+
dense?: boolean | undefined;
|
|
13
|
+
}, {}, {}>;
|
|
14
|
+
export declare const Label: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
15
|
+
align?: "inherit" | "left" | "right" | "center" | "justify" | undefined;
|
|
16
|
+
children?: import("react").ReactNode;
|
|
17
|
+
classes?: Partial<import("@mui/material").TypographyClasses> | undefined;
|
|
18
|
+
gutterBottom?: boolean | undefined;
|
|
19
|
+
noWrap?: boolean | undefined;
|
|
20
|
+
paragraph?: boolean | undefined;
|
|
21
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
22
|
+
variant?: "button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline" | "@supports (font-variation-settings: normal)" | undefined;
|
|
23
|
+
variantMapping?: Partial<Record<"button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline" | "@supports (font-variation-settings: normal)", string>> | undefined;
|
|
24
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof import("react").HTMLAttributes<HTMLSpanElement>> & {
|
|
25
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
|
|
26
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | ("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") | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
27
|
+
active?: boolean | undefined;
|
|
28
|
+
}, {}, {}>;
|
|
29
|
+
export declare const Check: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
30
|
+
children?: import("react").ReactNode;
|
|
31
|
+
component?: import("react").ElementType<any> | undefined;
|
|
32
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
33
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
34
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
35
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
36
|
+
}, 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>, {}, {}>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Box, Typography } from '@mui/material';
|
|
2
|
+
import { darken, styled } from '@mui/material/styles';
|
|
3
|
+
export const Card = styled(Box, {
|
|
4
|
+
shouldForwardProp: (prop) => !['dense', 'active', 'blur'].includes(prop),
|
|
5
|
+
})(({ theme, active, blur, dense }) => ({
|
|
6
|
+
backgroundColor: theme.palette.background.paper,
|
|
7
|
+
padding: theme.spacing(2),
|
|
8
|
+
border: `1px solid ${active
|
|
9
|
+
? theme.palette.mode === 'light'
|
|
10
|
+
? theme.palette.common.black
|
|
11
|
+
: theme.palette.grey[700]
|
|
12
|
+
: theme.palette.mode === 'light'
|
|
13
|
+
? theme.palette.grey[300]
|
|
14
|
+
: theme.palette.grey[800]}`,
|
|
15
|
+
borderRadius: dense
|
|
16
|
+
? theme.shape.borderRadiusSecondary
|
|
17
|
+
: theme.shape.borderRadius,
|
|
18
|
+
boxSizing: 'border-box',
|
|
19
|
+
userSelect: blur ? 'none' : 'auto',
|
|
20
|
+
'&:hover': {
|
|
21
|
+
cursor: blur || !dense ? 'pointer' : 'default',
|
|
22
|
+
backgroundColor: blur || !dense
|
|
23
|
+
? darken(theme.palette.background.paper, 0.02)
|
|
24
|
+
: theme.palette.background.paper,
|
|
25
|
+
},
|
|
26
|
+
'& > div': {
|
|
27
|
+
filter: blur ? 'blur(3px)' : 'none',
|
|
28
|
+
},
|
|
29
|
+
transition: theme.transitions.create(['background-color'], {
|
|
30
|
+
duration: theme.transitions.duration.enteringScreen,
|
|
31
|
+
easing: theme.transitions.easing.easeOut,
|
|
32
|
+
}),
|
|
33
|
+
}));
|
|
34
|
+
export const Label = styled(Typography, {
|
|
35
|
+
shouldForwardProp: (prop) => prop !== 'active',
|
|
36
|
+
})(({ theme, active }) => ({
|
|
37
|
+
backgroundColor: active
|
|
38
|
+
? theme.palette.primary.main
|
|
39
|
+
: theme.palette.background.paper,
|
|
40
|
+
border: '1px solid',
|
|
41
|
+
borderColor: active
|
|
42
|
+
? theme.palette.primary.main
|
|
43
|
+
: theme.palette.mode === 'light'
|
|
44
|
+
? theme.palette.common.black
|
|
45
|
+
: theme.palette.grey[300],
|
|
46
|
+
borderRadius: theme.shape.borderRadius / 2,
|
|
47
|
+
color: active
|
|
48
|
+
? theme.palette.common.white
|
|
49
|
+
: theme.palette.mode === 'light'
|
|
50
|
+
? theme.palette.common.black
|
|
51
|
+
: theme.palette.grey[300],
|
|
52
|
+
padding: theme.spacing(0.5, 0.75),
|
|
53
|
+
fontSize: 12,
|
|
54
|
+
lineHeight: 1.2,
|
|
55
|
+
fontWeight: '600',
|
|
56
|
+
height: 24,
|
|
57
|
+
letterSpacing: '0.05rem',
|
|
58
|
+
textTransform: 'uppercase',
|
|
59
|
+
display: 'inline-flex',
|
|
60
|
+
userSelect: 'none',
|
|
61
|
+
}));
|
|
62
|
+
export const Check = styled(Box)(({ theme }) => ({
|
|
63
|
+
backgroundColor: theme.palette.primary.main,
|
|
64
|
+
borderRadius: '50%',
|
|
65
|
+
color: theme.palette.common.white,
|
|
66
|
+
width: 24,
|
|
67
|
+
height: 24,
|
|
68
|
+
display: 'grid',
|
|
69
|
+
placeItems: 'center',
|
|
70
|
+
fontSize: '1rem',
|
|
71
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapRouteCard';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapRouteCard';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable react/no-array-index-key */
|
|
3
|
+
import { KeyboardArrowRight as KeyboardArrowRightIcon } from '@mui/icons-material';
|
|
4
|
+
import { Box, IconButton, Skeleton } from '@mui/material';
|
|
5
|
+
import { useCallback } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { useNavigate } from 'react-router-dom';
|
|
8
|
+
import { useCurrentRoute, useSwapRoutes } from '../../hooks';
|
|
9
|
+
import { routes } from '../../utils/routes';
|
|
10
|
+
import { CardContainer, CardTitle } from '../Card';
|
|
11
|
+
import { SwapRouteCard } from '../SwapRouteCard';
|
|
12
|
+
import { Stack } from './SwapRoutes.style';
|
|
13
|
+
import { SwapRoutesUpdateProgress } from './SwapRoutesUpdateProgress';
|
|
14
|
+
export const SwapRoutes = (props) => {
|
|
15
|
+
const { t } = useTranslation();
|
|
16
|
+
const navigate = useNavigate();
|
|
17
|
+
const [currentRoute] = useCurrentRoute();
|
|
18
|
+
const { routes: swapRoutes, isLoading, isFetching } = useSwapRoutes();
|
|
19
|
+
const handleCardClick = useCallback(() => {
|
|
20
|
+
navigate(routes.swapRoutes);
|
|
21
|
+
}, [navigate]);
|
|
22
|
+
if (!(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return (_jsxs(CardContainer, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(SwapRoutesUpdateProgress, { sx: {
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
top: 8,
|
|
28
|
+
right: 8,
|
|
29
|
+
} }), _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: [_jsx(Stack, Object.assign({ direction: "row", py: 2, pl: 2, pr: 1 }, { children: isLoading || isFetching || !currentRoute ? (_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 181, sx: (theme) => ({
|
|
30
|
+
borderRadius: theme.shape.borderRadiusSecondary / theme.shape.borderRadius,
|
|
31
|
+
minWidth: '100%',
|
|
32
|
+
}) })) : (_jsx(SwapRouteCard, { minWidth: "100%", route: currentRoute, active: true, dense: true }, currentRoute.id)) })), _jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes" }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))] }))] })));
|
|
33
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Stack: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
3
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
4
|
+
children?: import("react").ReactNode;
|
|
5
|
+
direction?: import("@mui/system").ResponsiveStyleValue<"row" | "column" | "column-reverse" | "row-reverse"> | undefined;
|
|
6
|
+
spacing?: import("@mui/system").ResponsiveStyleValue<string | number> | undefined;
|
|
7
|
+
divider?: import("react").ReactNode;
|
|
8
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
9
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
10
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
11
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | "direction" | ("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") | "spacing" | "divider"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
13
|
+
/* eslint-disable react/no-array-index-key */
|
|
14
|
+
import { Box } from '@mui/material';
|
|
15
|
+
import { useSwapRoutes } from '../../hooks';
|
|
16
|
+
import { ProgressToNextUpdate } from '../ProgressToNextUpdate';
|
|
17
|
+
export const SwapRoutesUpdateProgress = (_a) => {
|
|
18
|
+
var { sx } = _a, other = __rest(_a, ["sx"]);
|
|
19
|
+
const { isLoading, isFetching, dataUpdatedAt, refetchTime, refetch } = useSwapRoutes();
|
|
20
|
+
if (isLoading) {
|
|
21
|
+
return _jsx(Box, { width: 24, height: 24, sx: sx });
|
|
22
|
+
}
|
|
23
|
+
return (_jsx(ProgressToNextUpdate, Object.assign({ updatedAt: dataUpdatedAt, timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: sx }, other)));
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapRoutes';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapRoutes';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Switch: import("@emotion/styled").StyledComponent<import("@mui/material").SwitchProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Switch as MuiSwitch } from '@mui/material';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
import { switchClasses } from '@mui/material/Switch';
|
|
4
|
+
export const Switch = styled(MuiSwitch)(({ theme }) => ({
|
|
5
|
+
width: 42,
|
|
6
|
+
height: 24,
|
|
7
|
+
padding: 0,
|
|
8
|
+
[`.${switchClasses.switchBase}`]: {
|
|
9
|
+
padding: 0,
|
|
10
|
+
margin: theme.spacing(0.25),
|
|
11
|
+
transitionDuration: theme.transitions.duration.standard,
|
|
12
|
+
[`&.${switchClasses.checked}`]: {
|
|
13
|
+
transform: 'translateX(18px)',
|
|
14
|
+
color: theme.palette.common.white,
|
|
15
|
+
[`& + .${switchClasses.track}`]: {
|
|
16
|
+
backgroundColor: theme.palette.primary.main,
|
|
17
|
+
opacity: 1,
|
|
18
|
+
border: 0,
|
|
19
|
+
},
|
|
20
|
+
[`&.${switchClasses.disabled} + .${switchClasses.track}`]: {
|
|
21
|
+
opacity: 0.5,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
[`&.Mui-focusVisible .${switchClasses.thumb}`]: {
|
|
25
|
+
color: theme.palette.primary.main,
|
|
26
|
+
border: '6px solid',
|
|
27
|
+
borderColor: theme.palette.common.white,
|
|
28
|
+
},
|
|
29
|
+
[`&.${switchClasses.disabled} .${switchClasses.thumb}`]: {
|
|
30
|
+
color: theme.palette.mode === 'light'
|
|
31
|
+
? theme.palette.grey[100]
|
|
32
|
+
: theme.palette.grey[600],
|
|
33
|
+
},
|
|
34
|
+
[`&.${switchClasses.disabled} + .${switchClasses.track}`]: {
|
|
35
|
+
opacity: theme.palette.mode === 'light' ? 0.7 : 0.3,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
[`.${switchClasses.thumb}`]: {
|
|
39
|
+
boxSizing: 'border-box',
|
|
40
|
+
width: 20,
|
|
41
|
+
height: 20,
|
|
42
|
+
},
|
|
43
|
+
[`.${switchClasses.track}`]: {
|
|
44
|
+
borderRadius: 24 / 2,
|
|
45
|
+
backgroundColor: theme.palette.mode === 'light'
|
|
46
|
+
? theme.palette.grey[400]
|
|
47
|
+
: theme.palette.grey[800],
|
|
48
|
+
opacity: 1,
|
|
49
|
+
transition: theme.transitions.create(['background-color'], {
|
|
50
|
+
duration: theme.transitions.duration.standard,
|
|
51
|
+
}),
|
|
52
|
+
},
|
|
53
|
+
}));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from '@mui/material/styles';
|
|
3
|
+
import { useCallback, useLayoutEffect, useRef, useState, } from 'react';
|
|
4
|
+
const initialState = {
|
|
5
|
+
x: 0,
|
|
6
|
+
y: 0,
|
|
7
|
+
width: 0,
|
|
8
|
+
height: 0,
|
|
9
|
+
};
|
|
10
|
+
export const TextFitter = ({ children, width = '100%', height, maxHeight, preserveAspectRatio = 'xMinYMid meet', textStyle, svgStyle, cropTop, cropBottom, onFit, }) => {
|
|
11
|
+
const theme = useTheme();
|
|
12
|
+
const textRef = useRef(null);
|
|
13
|
+
const [viewBox, setViewBox] = useState(initialState);
|
|
14
|
+
const [textRect, setTextRect] = useState(initialState);
|
|
15
|
+
const calculateBox = useCallback(() => {
|
|
16
|
+
if (!textRef.current) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const box = textRef.current.getBBox();
|
|
20
|
+
if (cropTop) {
|
|
21
|
+
box.y += box.height * cropTop;
|
|
22
|
+
box.height -= box.height * cropTop;
|
|
23
|
+
}
|
|
24
|
+
if (cropBottom) {
|
|
25
|
+
box.height -= box.height * cropBottom;
|
|
26
|
+
}
|
|
27
|
+
setViewBox(box);
|
|
28
|
+
setTextRect(textRef.current.getBoundingClientRect());
|
|
29
|
+
onFit === null || onFit === void 0 ? void 0 : onFit();
|
|
30
|
+
}, [cropBottom, cropTop, onFit]);
|
|
31
|
+
useLayoutEffect(() => {
|
|
32
|
+
calculateBox();
|
|
33
|
+
}, [calculateBox, children]);
|
|
34
|
+
useLayoutEffect(() => {
|
|
35
|
+
if (document.fonts) {
|
|
36
|
+
document.fonts.ready.then(() => {
|
|
37
|
+
calculateBox();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}, [calculateBox]);
|
|
41
|
+
return (_jsx("svg", Object.assign({ style: svgStyle, viewBox: `${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}`, width: width, height: textRect.height && maxHeight && textRect.height >= maxHeight
|
|
42
|
+
? maxHeight
|
|
43
|
+
: height, preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary }, { children: _jsx("text", Object.assign({ x: 0, y: 0, style: textStyle, ref: textRef }, { children: children })) })));
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TextFitter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TextFitter';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export interface TextFitterProps {
|
|
3
|
+
textStyle?: CSSProperties;
|
|
4
|
+
svgStyle?: CSSProperties;
|
|
5
|
+
onFit?(): void;
|
|
6
|
+
maxHeight?: string | number;
|
|
7
|
+
height?: string | number;
|
|
8
|
+
width?: string | number;
|
|
9
|
+
preserveAspectRatio?: string;
|
|
10
|
+
cropTop?: number;
|
|
11
|
+
cropBottom?: number;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, List, Typography } from '@mui/material';
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { useFormContext, useWatch } from 'react-hook-form';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { useVirtual } from 'react-virtual';
|
|
7
|
+
import { useDebouncedWatch, useTokenBalances } from '../../hooks';
|
|
8
|
+
import { SwapFormKey, SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
|
|
9
|
+
import { useWallet } from '../../providers/WalletProvider';
|
|
10
|
+
import { TokenListItem, TokenListItemSkeleton } from './TokenListItem';
|
|
11
|
+
import { createTokenAmountSkeletons, skeletonKey } from './utils';
|
|
12
|
+
export const TokenList = ({ formType, height, onClick, }) => {
|
|
13
|
+
const { t } = useTranslation();
|
|
14
|
+
const { account } = useWallet();
|
|
15
|
+
const { setValue } = useFormContext();
|
|
16
|
+
const [selectedChainId] = useWatch({
|
|
17
|
+
name: [SwapFormKeyHelper.getChainKey(formType)],
|
|
18
|
+
});
|
|
19
|
+
const [searchTokensFilter] = useDebouncedWatch([SwapFormKey.SearchTokensFilter], 250);
|
|
20
|
+
const { tokens, isLoading, isFetching } = useTokenBalances(selectedChainId);
|
|
21
|
+
const chainTokens = useMemo(() => {
|
|
22
|
+
var _a;
|
|
23
|
+
let chainTokens = tokens !== null && tokens !== void 0 ? tokens : [];
|
|
24
|
+
const searchFilter = (_a = searchTokensFilter === null || searchTokensFilter === void 0 ? void 0 : searchTokensFilter.toUpperCase()) !== null && _a !== void 0 ? _a : '';
|
|
25
|
+
chainTokens = isLoading
|
|
26
|
+
? createTokenAmountSkeletons()
|
|
27
|
+
: searchTokensFilter
|
|
28
|
+
? chainTokens.filter((token) => token.name.toUpperCase().includes(searchFilter) ||
|
|
29
|
+
token.symbol.toUpperCase().includes(searchFilter) ||
|
|
30
|
+
token.address.toUpperCase().includes(searchFilter))
|
|
31
|
+
: chainTokens;
|
|
32
|
+
return chainTokens;
|
|
33
|
+
}, [isLoading, searchTokensFilter, tokens]);
|
|
34
|
+
const parentRef = useRef(null);
|
|
35
|
+
const { virtualItems, totalSize, scrollToIndex } = useVirtual({
|
|
36
|
+
size: chainTokens.length,
|
|
37
|
+
parentRef,
|
|
38
|
+
overscan: 3,
|
|
39
|
+
paddingEnd: 12,
|
|
40
|
+
estimateSize: useCallback(() => 64, []),
|
|
41
|
+
keyExtractor: (index) => { var _a; return (_a = chainTokens[index].address) !== null && _a !== void 0 ? _a : index; },
|
|
42
|
+
});
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
scrollToIndex(0);
|
|
45
|
+
}, [scrollToIndex, selectedChainId]);
|
|
46
|
+
const handleTokenClick = useCallback((tokenAddress) => {
|
|
47
|
+
setValue(SwapFormKeyHelper.getTokenKey(formType), tokenAddress);
|
|
48
|
+
setValue(SwapFormKeyHelper.getAmountKey(formType), '');
|
|
49
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
50
|
+
}, [formType, onClick, setValue]);
|
|
51
|
+
return (_jsxs(Box, Object.assign({ ref: parentRef, style: { height, overflow: 'auto' } }, { children: [!virtualItems.length ? (_jsx(Typography, Object.assign({ variant: "body1", align: "center", py: 2, px: 3 }, { children: t('swap.couldntFindTokens') }))) : null, _jsx(List, Object.assign({ style: { height: totalSize }, disablePadding: true }, { children: virtualItems.map((item) => {
|
|
52
|
+
const token = chainTokens[item.index];
|
|
53
|
+
if (token.name.includes(skeletonKey)) {
|
|
54
|
+
return (_jsx(TokenListItemSkeleton, { size: item.size, start: item.start }, item.key));
|
|
55
|
+
}
|
|
56
|
+
return (_jsx(TokenListItem, { onClick: handleTokenClick, size: item.size, start: item.start, token: token, showBalance: account.isActive }, item.key));
|
|
57
|
+
}) }))] })));
|
|
58
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ListItemButton: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemButtonBaseProps & Omit<{
|
|
3
|
+
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
4
|
+
centerRipple?: boolean | undefined;
|
|
5
|
+
children?: import("react").ReactNode;
|
|
6
|
+
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
7
|
+
disabled?: boolean | undefined;
|
|
8
|
+
disableRipple?: boolean | undefined;
|
|
9
|
+
disableTouchRipple?: boolean | undefined;
|
|
10
|
+
focusRipple?: boolean | undefined;
|
|
11
|
+
focusVisibleClassName?: string | undefined;
|
|
12
|
+
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
13
|
+
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
14
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
15
|
+
tabIndex?: number | undefined;
|
|
16
|
+
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
17
|
+
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
18
|
+
}, "classes"> & 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
|
+
}, "className" | "style" | "classes" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "autoFocus" | "dense" | "selected" | "disableGutters" | "divider"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
21
|
+
export declare const ListItem: import("@emotion/styled").StyledComponent<{
|
|
22
|
+
button?: false | undefined;
|
|
23
|
+
} & import("@mui/material").ListItemBaseProps & {
|
|
24
|
+
components?: {
|
|
25
|
+
Root?: import("react").ElementType<any> | undefined;
|
|
26
|
+
} | undefined;
|
|
27
|
+
componentsProps?: {
|
|
28
|
+
root?: (import("react").HTMLAttributes<HTMLDivElement> & import("@mui/material").ListItemComponentsPropsOverrides) | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "key" | keyof import("react").LiHTMLAttributes<HTMLLIElement>> & {
|
|
31
|
+
ref?: ((instance: HTMLLIElement | null) => void) | import("react").RefObject<HTMLLIElement> | null | undefined;
|
|
32
|
+
}, "button" | "className" | "style" | "classes" | "children" | "disabled" | "sx" | "alignItems" | "autoFocus" | "dense" | "components" | "componentsProps" | "selected" | "disableGutters" | "divider" | "ContainerComponent" | "ContainerProps" | "disablePadding" | "secondaryAction"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ListItem as MuiListItem, ListItemButton as MuiListItemButton, } from '@mui/material';
|
|
2
|
+
import { listItemSecondaryActionClasses } from '@mui/material/ListItemSecondaryAction';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { getContrastAlphaColor } from '../../utils/colors';
|
|
5
|
+
export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
|
|
6
|
+
borderRadius: theme.shape.borderRadiusSecondary,
|
|
7
|
+
paddingLeft: theme.spacing(2),
|
|
8
|
+
height: 64,
|
|
9
|
+
'&:hover': {
|
|
10
|
+
backgroundColor: getContrastAlphaColor(theme, '4%'),
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
export const ListItem = styled(MuiListItem)(({ theme }) => ({
|
|
14
|
+
position: 'absolute',
|
|
15
|
+
top: 0,
|
|
16
|
+
left: 0,
|
|
17
|
+
width: '100%',
|
|
18
|
+
padding: theme.spacing(0.5, 3),
|
|
19
|
+
[`.${listItemSecondaryActionClasses.root}`]: {
|
|
20
|
+
right: theme.spacing(5),
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar, Box, ListItemAvatar, ListItemText, Skeleton, Typography, } from '@mui/material';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { formatTokenPrice } from '../../utils/format';
|
|
6
|
+
import { ListItem, ListItemButton } from './TokenList.style';
|
|
7
|
+
export const TokenListItem = memo(({ onClick, size, start, token, showBalance }) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const handleClick = () => onClick === null || onClick === void 0 ? void 0 : onClick(token.address);
|
|
11
|
+
const tokenPrice = formatTokenPrice(token.amount, token.priceUSD);
|
|
12
|
+
return (_jsx(ListItem, Object.assign({ disablePadding: true, style: {
|
|
13
|
+
height: `${size}px`,
|
|
14
|
+
transform: `translateY(${start}px)`,
|
|
15
|
+
} }, { children: _jsxs(ListItemButton, Object.assign({ onClick: handleClick, dense: true, disableRipple: true }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: token.logoURI, alt: token.symbol }, { children: token.symbol[0] })) }), _jsx(ListItemText, { primary: token.symbol, secondary: token.name }), showBalance ? (_jsxs(Box, Object.assign({ sx: { textAlign: 'right' } }, { children: [_jsx(Typography, Object.assign({ variant: "body1", noWrap: true }, { children: (_a = token.amount) !== null && _a !== void 0 ? _a : '0' })), tokenPrice ? (_jsx(Typography, Object.assign({ fontWeight: 400, fontSize: 12, color: "text.secondary", "data-price": token.priceUSD }, { children: t(`swap.currency`, {
|
|
16
|
+
value: tokenPrice,
|
|
17
|
+
}) }))) : null] }))) : null] })) })));
|
|
18
|
+
});
|
|
19
|
+
export const TokenListItemSkeleton = ({ size, start, }) => {
|
|
20
|
+
return (_jsxs(ListItem, Object.assign({ secondaryAction: _jsx(Skeleton, { variant: "text", width: 60, height: 24 }), disablePadding: true, style: {
|
|
21
|
+
height: `${size}px`,
|
|
22
|
+
transform: `translateY(${start}px)`,
|
|
23
|
+
} }, { children: [_jsx(ListItemAvatar, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32, sx: { marginLeft: 2, marginRight: 2 } }) }), _jsx(ListItemText, { primary: _jsx(Skeleton, { variant: "text", width: 48, height: 20 }), secondary: _jsx(Skeleton, { variant: "text", width: 128, height: 20 }) })] })));
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TokenList';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TokenList';
|