@lifi/widget 1.18.8 → 1.19.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.js +3 -3
- package/cjs/App.js +3 -3
- package/cjs/components/ActiveSwaps/ActiveSwaps.js +1 -1
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +0 -14
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +1 -9
- package/cjs/components/AppContainer.d.ts +11 -1
- package/cjs/components/AppContainer.js +3 -6
- package/cjs/components/BottomSheet/BottomSheet.js +9 -32
- package/cjs/components/BottomSheet/types.d.ts +2 -2
- package/cjs/components/Card/Card.js +1 -1
- package/cjs/components/Card/CardHeader.d.ts +1 -1
- package/cjs/components/ChainSelect/ChainSelect.js +1 -1
- package/cjs/components/ChainSelect/useChainSelect.js +2 -4
- package/cjs/components/Dialog.d.ts +22 -1
- package/cjs/components/Dialog.js +23 -20
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +19 -22
- package/cjs/components/Header/NavigationHeader.js +1 -1
- package/cjs/components/Header/WalletHeader.js +2 -2
- package/cjs/components/PoweredBy/PoweredBy.js +1 -1
- package/cjs/components/ProgressToNextUpdate/ProgressToNextUpdate.js +1 -1
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.js +6 -6
- package/cjs/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
- package/cjs/components/SendToWallet/SendToWallet.d.ts +1 -0
- package/cjs/components/SendToWallet/SendToWallet.js +10 -5
- package/cjs/components/SendToWallet/SendToWalletButton.js +2 -2
- package/cjs/components/Step/StepProcess.js +1 -1
- package/cjs/components/SwapButton/SwapButton.js +4 -4
- package/cjs/components/SwapButton/types.d.ts +2 -0
- package/cjs/components/SwapInput/SwapInput.js +6 -2
- package/cjs/components/SwapInput/SwapInputAdornment.js +4 -2
- package/cjs/components/SwapInput/SwapInputAdornment.style.js +1 -13
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +8 -4
- package/cjs/components/SwapRoutes/SwapRoutes.js +4 -4
- package/cjs/components/SwapRoutes/SwapRoutes.style.d.ts +14 -14
- package/cjs/components/SwapRoutes/SwapRoutes.style.js +13 -13
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +1 -0
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +17 -12
- package/cjs/components/SwapRoutes/useSetRecommendedRoute.d.ts +2 -0
- package/cjs/components/SwapRoutes/useSetRecommendedRoute.js +13 -0
- package/cjs/components/Token/Token.js +5 -5
- package/cjs/components/Token/Token.style.d.ts +10 -0
- package/cjs/components/Token/Token.style.js +13 -7
- package/cjs/components/TokenList/TokenList.js +10 -7
- package/cjs/config/theme.js +22 -8
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +1 -0
- package/cjs/hooks/index.js +1 -0
- package/cjs/hooks/useExpandableVariant.d.ts +1 -0
- package/cjs/hooks/useExpandableVariant.js +14 -0
- package/cjs/hooks/useGasSufficiency.d.ts +3 -2
- package/cjs/hooks/useGasSufficiency.js +50 -26
- package/cjs/hooks/useSwapRoutes.js +4 -2
- package/cjs/hooks/useToken.js +5 -2
- package/cjs/hooks/useTokenBalance.js +15 -10
- package/cjs/hooks/useTokenSearch.d.ts +1 -3
- package/cjs/hooks/useTokenSearch.js +3 -5
- package/cjs/i18n/en/translation.json +9 -8
- package/cjs/i18n/index.d.ts +6 -5
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -4
- package/cjs/pages/MainPage/MainPage.js +3 -3
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +1 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
- package/cjs/pages/SwapPage/StatusBottomSheet.js +4 -4
- package/cjs/pages/SwapPage/SwapPage.js +4 -4
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +3 -2
- package/cjs/providers/SwapFormProvider/URLSearchParamsBuilder.d.ts +1 -0
- package/cjs/providers/SwapFormProvider/URLSearchParamsBuilder.js +46 -0
- package/cjs/providers/SwapFormProvider/types.d.ts +4 -4
- package/cjs/providers/SwapFormProvider/types.js +2 -2
- package/cjs/providers/WalletProvider/WalletFormUpdate.d.ts +5 -0
- package/cjs/providers/WalletProvider/WalletFormUpdate.js +64 -0
- package/cjs/providers/WalletProvider/WalletProvider.js +3 -58
- package/cjs/providers/WidgetProvider/WidgetProvider.js +12 -5
- package/cjs/stores/routes/index.d.ts +1 -1
- package/cjs/stores/routes/index.js +1 -1
- package/cjs/stores/routes/types.d.ts +4 -4
- package/cjs/stores/routes/useRecommendedRouteStore.d.ts +4 -0
- package/cjs/stores/routes/{useSelectedRouteStore.js → useRecommendedRouteStore.js} +4 -4
- package/cjs/stores/routes/useRouteExecutionStore.js +10 -2
- package/cjs/stores/settings/useSettingsStore.js +5 -2
- package/cjs/types/widget.d.ts +1 -0
- package/components/ActiveSwaps/ActiveSwaps.js +3 -3
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +0 -14
- package/components/ActiveSwaps/ActiveSwaps.style.js +1 -9
- package/components/AppContainer.d.ts +11 -1
- package/components/AppContainer.js +2 -4
- package/components/BottomSheet/BottomSheet.js +9 -32
- package/components/BottomSheet/types.d.ts +2 -2
- package/components/Card/Card.js +1 -1
- package/components/Card/CardHeader.d.ts +1 -1
- package/components/ChainSelect/ChainSelect.js +1 -1
- package/components/ChainSelect/useChainSelect.js +2 -4
- package/components/Dialog.d.ts +22 -1
- package/components/Dialog.js +22 -19
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +21 -24
- package/components/Header/NavigationHeader.js +2 -2
- package/components/Header/WalletHeader.js +2 -2
- package/components/PoweredBy/PoweredBy.js +1 -1
- package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.js +6 -6
- package/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
- package/components/SendToWallet/SendToWallet.d.ts +1 -0
- package/components/SendToWallet/SendToWallet.js +9 -5
- package/components/SendToWallet/SendToWalletButton.js +2 -2
- package/components/Step/StepProcess.js +1 -1
- package/components/SwapButton/SwapButton.js +4 -4
- package/components/SwapButton/types.d.ts +2 -0
- package/components/SwapInput/SwapInput.js +6 -2
- package/components/SwapInput/SwapInputAdornment.js +4 -2
- package/components/SwapInput/SwapInputAdornment.style.js +2 -14
- package/components/SwapRouteCard/SwapRouteCard.js +9 -5
- package/components/SwapRoutes/SwapRoutes.js +4 -4
- package/components/SwapRoutes/SwapRoutes.style.d.ts +14 -14
- package/components/SwapRoutes/SwapRoutes.style.js +13 -13
- package/components/SwapRoutes/SwapRoutesExpanded.d.ts +1 -0
- package/components/SwapRoutes/SwapRoutesExpanded.js +16 -12
- package/components/SwapRoutes/useSetRecommendedRoute.d.ts +2 -0
- package/components/SwapRoutes/useSetRecommendedRoute.js +9 -0
- package/components/Token/Token.js +7 -7
- package/components/Token/Token.style.d.ts +10 -0
- package/components/Token/Token.style.js +12 -6
- package/components/TokenList/TokenList.js +10 -7
- package/config/theme.js +22 -8
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useExpandableVariant.d.ts +1 -0
- package/hooks/useExpandableVariant.js +10 -0
- package/hooks/useGasSufficiency.d.ts +3 -2
- package/hooks/useGasSufficiency.js +50 -26
- package/hooks/useSwapRoutes.js +4 -2
- package/hooks/useToken.js +5 -2
- package/hooks/useTokenBalance.js +15 -10
- package/hooks/useTokenSearch.d.ts +1 -3
- package/hooks/useTokenSearch.js +3 -5
- package/i18n/en/translation.json +9 -8
- package/i18n/index.d.ts +6 -5
- package/package.json +11 -11
- package/pages/ActiveSwapsPage/ActiveSwapsPage.js +24 -7
- package/pages/MainPage/MainPage.js +3 -3
- package/pages/SelectWalletPage/SelectWalletPage.js +1 -1
- package/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
- package/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
- package/pages/SwapPage/StatusBottomSheet.js +4 -4
- package/pages/SwapPage/SwapPage.js +5 -5
- package/providers/SwapFormProvider/SwapFormProvider.js +4 -3
- package/providers/SwapFormProvider/URLSearchParamsBuilder.d.ts +1 -0
- package/providers/SwapFormProvider/URLSearchParamsBuilder.js +42 -0
- package/providers/SwapFormProvider/types.d.ts +4 -4
- package/providers/SwapFormProvider/types.js +2 -2
- package/providers/WalletProvider/WalletFormUpdate.d.ts +5 -0
- package/providers/WalletProvider/WalletFormUpdate.js +60 -0
- package/providers/WalletProvider/WalletProvider.js +5 -60
- package/providers/WidgetProvider/WidgetProvider.js +12 -5
- package/stores/routes/index.d.ts +1 -1
- package/stores/routes/index.js +1 -1
- package/stores/routes/types.d.ts +4 -4
- package/stores/routes/useRecommendedRouteStore.d.ts +4 -0
- package/stores/routes/useRecommendedRouteStore.js +9 -0
- package/stores/routes/useRouteExecutionStore.js +10 -2
- package/stores/settings/useSettingsStore.js +5 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +1 -0
- package/cjs/components/SwapRoutes/useSetSelectedRoute.d.ts +0 -2
- package/cjs/components/SwapRoutes/useSetSelectedRoute.js +0 -13
- package/cjs/stores/routes/useSelectedRouteStore.d.ts +0 -4
- package/components/SwapRoutes/useSetSelectedRoute.d.ts +0 -2
- package/components/SwapRoutes/useSetSelectedRoute.js +0 -9
- package/stores/routes/useSelectedRouteStore.d.ts +0 -4
- package/stores/routes/useSelectedRouteStore.js +0 -9
|
@@ -11,35 +11,32 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { WarningAmber as WarningIcon } from '@mui/icons-material';
|
|
14
|
-
import { Box, Typography } from '@mui/material';
|
|
14
|
+
import { Box, Collapse, Typography } from '@mui/material';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { useGasSufficiency } from '../../hooks';
|
|
17
|
-
import {
|
|
17
|
+
import { useRecommendedRouteStore } from '../../stores';
|
|
18
18
|
import { CardTitle } from '../Card';
|
|
19
19
|
import { MessageCard } from './GasSufficiencyMessage.style';
|
|
20
20
|
export const GasSufficiencyMessage = (_a) => {
|
|
21
21
|
var { route } = _a, props = __rest(_a, ["route"]);
|
|
22
22
|
const { t } = useTranslation();
|
|
23
|
-
const
|
|
24
|
-
const { insufficientFunds, insufficientGas } = useGasSufficiency(route !== null && route !== void 0 ? route :
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}) }), index));
|
|
43
|
-
})
|
|
44
|
-
: null] })] })));
|
|
23
|
+
const recommendedRoute = useRecommendedRouteStore((state) => state.recommendedRoute);
|
|
24
|
+
const { insufficientFunds, insufficientGas } = useGasSufficiency(route !== null && route !== void 0 ? route : recommendedRoute);
|
|
25
|
+
return (_jsx(Collapse, Object.assign({ timeout: 225, in: Boolean(insufficientFunds || (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)), unmountOnExit: true, mountOnEnter: true, appear: true }, { children: _jsx(Box, Object.assign({}, props, { children: _jsxs(MessageCard, { children: [_jsx(WarningIcon, { sx: {
|
|
26
|
+
marginTop: 2,
|
|
27
|
+
marginLeft: 2,
|
|
28
|
+
} }), _jsxs(Box, { children: [(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? (_jsx(CardTitle, { children: t(`swap.warning.title.insufficientGas`) })) : null, insufficientFunds ? (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? 0 : 2, pt: (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? 1 : 2 }, { children: insufficientFunds
|
|
29
|
+
? t(`swap.warning.message.insufficientFunds`)
|
|
30
|
+
: null }))) : null, (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pt: 1 }, { children: t(`swap.warning.message.insufficientGas`) }))) : null, (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)
|
|
31
|
+
? insufficientGas.map((item, index) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
return (_jsx(Typography
|
|
34
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
35
|
+
, Object.assign({ variant: "body2", px: 2, pb: insufficientGas.length - 1 === index ? 2 : 0, pt: 0.5 }, { children: t(`swap.tokenOnChainAmount`, {
|
|
36
|
+
amount: (_a = item.insufficientAmount) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
37
|
+
tokenSymbol: item.token.symbol,
|
|
38
|
+
chainName: (_b = item.chain) === null || _b === void 0 ? void 0 : _b.name,
|
|
39
|
+
}) }), index));
|
|
40
|
+
})
|
|
41
|
+
: null] })] }) })) })));
|
|
45
42
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ArrowBack as ArrowBackIcon, History as HistoryIcon, SettingsOutlined as SettingsIcon, } from '@mui/icons-material';
|
|
3
|
-
import { Box, IconButton, Typography } from '@mui/material';
|
|
3
|
+
import { Box, IconButton, Tooltip, Typography } from '@mui/material';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { Route, Routes, useLocation } from 'react-router-dom';
|
|
6
6
|
import { useNavigateBack } from '../../hooks';
|
|
@@ -46,5 +46,5 @@ export const NavigationHeader = () => {
|
|
|
46
46
|
return t(`header.swap`);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, Object.assign({ size: "medium",
|
|
49
|
+
return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, Object.assign({ size: "medium", edge: "start", onClick: navigateBack }, { children: _jsx(ArrowBackIcon, {}) }))) : null, _jsx(Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive ? (_jsx(Tooltip, Object.assign({ title: t(`header.swapHistory`), enterDelay: 400, enterNextDelay: 400, arrow: true }, { children: _jsx(IconButton, Object.assign({ size: "medium", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory) }, { children: _jsx(HistoryIcon, {}) })) }))) : null, _jsx(Tooltip, Object.assign({ title: t(`header.settings`), enterDelay: 400, enterNextDelay: 400, arrow: true }, { children: _jsx(IconButton, Object.assign({ size: "medium", edge: "end", onClick: () => navigate(navigationRoutes.settings) }, { children: _jsx(SettingsIcon, {}) })) }))] }) }), _jsx(Route, { path: "*", element: element || _jsx(Box, { width: 28, height: 40 }) })] })] })));
|
|
50
50
|
};
|
|
@@ -23,7 +23,7 @@ export const WalletHeader = () => {
|
|
|
23
23
|
display: 'flex',
|
|
24
24
|
flex: 1,
|
|
25
25
|
flexDirection: 'column',
|
|
26
|
-
}, mr: 0.5 }, { children: [_jsx(Typography, Object.assign({ variant: "caption", align: "right" }, { children: t(`header.walletConnected`) })), _jsx(Typography, Object.assign({ variant: "body2", align: "right", fontWeight: "600" }, { children: walletAddress }))] })), _jsx(IconButton, Object.assign({ size: "medium",
|
|
26
|
+
}, mr: 0.5 }, { children: [_jsx(Typography, Object.assign({ variant: "caption", align: "right" }, { children: t(`header.walletConnected`) })), _jsx(Typography, Object.assign({ variant: "body2", align: "right", fontWeight: "600" }, { children: walletAddress }))] })), _jsx(IconButton, Object.assign({ size: "medium", edge: "end", onClick: disconnect }, { children: _jsx(LogoutIcon, {}) }))] })) : (_jsxs(_Fragment, { children: [_jsx(Typography, Object.assign({ variant: "body2", align: "right", fontWeight: "600", flex: 1, mr: 0.5 }, { children: t(`header.connectWallet`) })), _jsx(ConnectButton, {})] })) })));
|
|
27
27
|
};
|
|
28
28
|
const ConnectButton = () => {
|
|
29
29
|
const { pathname } = useLocation();
|
|
@@ -37,5 +37,5 @@ const ConnectButton = () => {
|
|
|
37
37
|
}
|
|
38
38
|
navigate(navigationRoutes.selectWallet);
|
|
39
39
|
});
|
|
40
|
-
return (_jsx(IconButton, Object.assign({ size: "medium",
|
|
40
|
+
return (_jsx(IconButton, Object.assign({ size: "medium", edge: "end", onClick: !pathname.includes(navigationRoutes.selectWallet) ? connect : undefined }, { children: _jsx(WalletOutlinedIcon, {}) })));
|
|
41
41
|
};
|
|
@@ -15,5 +15,5 @@ export const PoweredBy = () => {
|
|
|
15
15
|
display: 'flex',
|
|
16
16
|
alignItems: 'flex-end',
|
|
17
17
|
justifyContent: 'flex-end',
|
|
18
|
-
} }, { children: _jsx(Tooltip, Object.assign({ title: `v${version}`, placement: "top", enterDelay:
|
|
18
|
+
} }, { children: _jsx(Tooltip, Object.assign({ title: `v${version}`, placement: "top", enterDelay: 3000, arrow: true }, { children: _jsxs(Link, Object.assign({ href: "https://li.fi", target: "_blank", underline: "none", color: "text.primary" }, { children: [_jsx(Typography, Object.assign({ color: "text.secondary", fontSize: 12, px: 0.5 }, { children: "Powered by" })), _jsx(LiFiLogo, { variant: "full", style: { height: 16, width: 42 } })] })) })) })));
|
|
19
19
|
};
|
|
@@ -39,7 +39,7 @@ export const ProgressToNextUpdate = (_a) => {
|
|
|
39
39
|
}, [isLoading]);
|
|
40
40
|
return (_jsx(IconButton, Object.assign({ onClick: onClick, disabled: isLoading }, other, { children: _jsx(Tooltip, Object.assign({ title: t('tooltip.progressToNextUpdate', {
|
|
41
41
|
value: getSecondsToUpdate(updatedAt, timeToUpdate),
|
|
42
|
-
}), placement: "top", enterDelay:
|
|
42
|
+
}), placement: "top", enterDelay: 400, enterNextDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ sx: {
|
|
43
43
|
display: 'grid',
|
|
44
44
|
position: 'relative',
|
|
45
45
|
placeItems: 'center',
|
|
@@ -12,11 +12,11 @@ export const ReverseTokensButton = ({ vertical, }) => {
|
|
|
12
12
|
SwapFormKey.ToChain,
|
|
13
13
|
SwapFormKey.ToToken,
|
|
14
14
|
]);
|
|
15
|
-
setValue(SwapFormKey.FromAmount, '');
|
|
16
|
-
setValue(SwapFormKey.FromChain, toChain);
|
|
17
|
-
setValue(SwapFormKey.FromToken, toToken);
|
|
18
|
-
setValue(SwapFormKey.ToChain, fromChain);
|
|
19
|
-
setValue(SwapFormKey.ToToken, fromToken);
|
|
15
|
+
setValue(SwapFormKey.FromAmount, '', { shouldTouch: true });
|
|
16
|
+
setValue(SwapFormKey.FromChain, toChain, { shouldTouch: true });
|
|
17
|
+
setValue(SwapFormKey.FromToken, toToken, { shouldTouch: true });
|
|
18
|
+
setValue(SwapFormKey.ToChain, fromChain, { shouldTouch: true });
|
|
19
|
+
setValue(SwapFormKey.ToToken, fromToken, { shouldTouch: true });
|
|
20
20
|
};
|
|
21
|
-
return (_jsx(IconButton, Object.assign({ onClick: handleClick, size: "small"
|
|
21
|
+
return (_jsx(IconButton, Object.assign({ onClick: handleClick, size: "small" }, { children: vertical ? _jsx(SwapVertIcon, {}) : _jsx(SwapHorizIcon, {}) })));
|
|
22
22
|
};
|
|
@@ -15,7 +15,7 @@ export declare const SelectTokenCardHeader: import("@emotion/styled").StyledComp
|
|
|
15
15
|
}> | undefined;
|
|
16
16
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
17
17
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
18
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "title" | "action" | "sx" | "
|
|
18
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "title" | "action" | "sx" | "disableTypography" | "avatar" | "subheader" | "subheaderTypographyProps" | "titleTypographyProps"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
19
19
|
selected?: boolean | undefined;
|
|
20
20
|
compact?: boolean | undefined;
|
|
21
21
|
}, {}, {}>;
|
|
@@ -11,18 +11,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
import { isAddress } from '@ethersproject/address';
|
|
12
12
|
import { Collapse, FormHelperText } from '@mui/material';
|
|
13
13
|
import { forwardRef, useEffect } from 'react';
|
|
14
|
-
import { useFormContext } from 'react-hook-form';
|
|
14
|
+
import { useFormContext, useFormState } from 'react-hook-form';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { SwapFormKey, useWallet } from '../../providers';
|
|
17
17
|
import { Card, CardTitle } from '../Card';
|
|
18
18
|
import { FormControl, Input } from './SendToWallet.style';
|
|
19
19
|
import { useSendToWalletStore } from './store';
|
|
20
20
|
export const SendToWallet = forwardRef((props, ref) => {
|
|
21
|
-
var _a;
|
|
22
21
|
const { t } = useTranslation();
|
|
23
22
|
const showSendToWallet = useSendToWalletStore((state) => state.showSendToWallet);
|
|
24
23
|
const { account, provider } = useWallet();
|
|
25
|
-
const { register, trigger
|
|
24
|
+
const { register, trigger } = useFormContext();
|
|
26
25
|
useEffect(() => {
|
|
27
26
|
trigger(SwapFormKey.ToAddress);
|
|
28
27
|
}, [account.chainId, trigger]);
|
|
@@ -36,11 +35,16 @@ export const SendToWallet = forwardRef((props, ref) => {
|
|
|
36
35
|
return (isAddress(address || value) ||
|
|
37
36
|
t('swap.error.title.walletAddressInvalid'));
|
|
38
37
|
}
|
|
39
|
-
catch (
|
|
38
|
+
catch (_a) {
|
|
40
39
|
return t('swap.error.title.walletEnsAddressInvalid');
|
|
41
40
|
}
|
|
42
41
|
}),
|
|
43
42
|
onBlur: () => trigger(SwapFormKey.ToAddress),
|
|
44
43
|
});
|
|
45
|
-
return (_jsx(Collapse, Object.assign({ timeout: 225,
|
|
44
|
+
return (_jsx(Collapse, Object.assign({ timeout: 225, in: showSendToWallet, mountOnEnter: true, unmountOnExit: true }, { children: _jsxs(Card, Object.assign({}, props, { ref: ref }, { children: [_jsx(CardTitle, { children: t('swap.sendToWallet') }), _jsxs(FormControl, Object.assign({ fullWidth: true, sx: { paddingTop: '6px', paddingBottom: '5px' } }, { children: [_jsx(Input, { ref: inputRef, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns'), autoFocus: true }), _jsx(SendToWalletFormHelperText, {})] }))] })) })));
|
|
46
45
|
});
|
|
46
|
+
export const SendToWalletFormHelperText = () => {
|
|
47
|
+
var _a;
|
|
48
|
+
const { errors } = useFormState();
|
|
49
|
+
return (_jsx(FormHelperText, Object.assign({ error: !!errors.toAddress }, { children: (_a = errors.toAddress) === null || _a === void 0 ? void 0 : _a.message })));
|
|
50
|
+
};
|
|
@@ -17,11 +17,11 @@ export const SendToWalletButton = () => {
|
|
|
17
17
|
}
|
|
18
18
|
const handleClick = () => {
|
|
19
19
|
if (showSendToWallet) {
|
|
20
|
-
setValue(SwapFormKey.ToAddress, '');
|
|
20
|
+
setValue(SwapFormKey.ToAddress, '', { shouldTouch: true });
|
|
21
21
|
}
|
|
22
22
|
toggleSendToWallet();
|
|
23
23
|
};
|
|
24
|
-
return (_jsx(Tooltip, Object.assign({ title: t('swap.sendToWallet'), placement: "bottom-end", enterDelay:
|
|
24
|
+
return (_jsx(Tooltip, Object.assign({ title: t('swap.sendToWallet'), placement: "bottom-end", enterDelay: 400, enterNextDelay: 400, arrow: true }, { children: _jsx(Button, Object.assign({ variant: showSendToWallet ? 'contained' : 'text', onClick: handleClick, sx: {
|
|
25
25
|
minWidth: 48,
|
|
26
26
|
marginLeft: 1,
|
|
27
27
|
} }, { children: _jsx(WalletOutlinedIcon, {}) })) })));
|
|
@@ -13,5 +13,5 @@ export const StepProcess = ({ step, process }) => {
|
|
|
13
13
|
display: 'flex',
|
|
14
14
|
flex: 1,
|
|
15
15
|
justifyContent: 'flex-end',
|
|
16
|
-
} }, { children: _jsx(LinkButton, Object.assign({ size: "small",
|
|
16
|
+
} }, { children: _jsx(LinkButton, Object.assign({ size: "small", edge: "end", LinkComponent: Link, href: process.txLink, target: "_blank", rel: "nofollow noreferrer" }, { children: _jsx(LinkIcon, {}) })) }))) : null] })), message ? (_jsx(Typography, Object.assign({ ml: 6, fontSize: 14, fontWeight: 500, color: "text.secondary" }, { children: message }))) : null] })));
|
|
17
17
|
};
|
|
@@ -8,19 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import {
|
|
11
|
+
import { LoadingButton } from '@mui/lab';
|
|
12
12
|
import { forwardRef } from 'react';
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
14
|
import { useNavigate } from 'react-router-dom';
|
|
15
15
|
import { useGasSufficiency } from '../../hooks';
|
|
16
16
|
import { useWallet, useWidgetConfig } from '../../providers';
|
|
17
17
|
import { navigationRoutes } from '../../utils';
|
|
18
|
-
export const SwapButton = forwardRef(({ onClick, currentRoute, text, disable }, ref) => {
|
|
18
|
+
export const SwapButton = forwardRef(({ onClick, currentRoute, text, disable, enableLoading, loading }, ref) => {
|
|
19
19
|
const { t } = useTranslation();
|
|
20
20
|
const navigate = useNavigate();
|
|
21
21
|
const config = useWidgetConfig();
|
|
22
22
|
const { account, connect } = useWallet();
|
|
23
|
-
const { insufficientFunds, insufficientGas } = useGasSufficiency(currentRoute);
|
|
23
|
+
const { insufficientFunds, insufficientGas, isLoading: isGasSufficiencyLoading, } = useGasSufficiency(currentRoute);
|
|
24
24
|
const handleSwapButtonClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
25
|
if (!account.isActive) {
|
|
26
26
|
if (config.walletManagement) {
|
|
@@ -43,5 +43,5 @@ export const SwapButton = forwardRef(({ onClick, currentRoute, text, disable },
|
|
|
43
43
|
}
|
|
44
44
|
return t(`button.connectWallet`);
|
|
45
45
|
};
|
|
46
|
-
return (_jsx(
|
|
46
|
+
return (_jsx(LoadingButton, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick, disabled: insufficientFunds || !!(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) || disable, loading: enableLoading && (loading || isGasSufficiencyLoading), loadingPosition: "center", fullWidth: true, ref: ref }, { children: getButtonText() })));
|
|
47
47
|
});
|
|
@@ -27,11 +27,15 @@ export const SwapInput = ({ formType }) => {
|
|
|
27
27
|
const isSelected = !!(chain && token);
|
|
28
28
|
const handleChange = (event) => {
|
|
29
29
|
const { value } = event.target;
|
|
30
|
-
|
|
30
|
+
const formattedAmount = formatAmount(value, true);
|
|
31
|
+
setValue(amountKey, formattedAmount, {
|
|
32
|
+
shouldTouch: true,
|
|
33
|
+
});
|
|
31
34
|
};
|
|
32
35
|
const handleBlur = (event) => {
|
|
33
36
|
const { value } = event.target;
|
|
34
|
-
|
|
37
|
+
const formattedAmount = formatAmount(value);
|
|
38
|
+
setValue(amountKey, formattedAmount);
|
|
35
39
|
};
|
|
36
40
|
useLayoutEffect(() => {
|
|
37
41
|
fitInputText(maxInputFontSize, minInputFontSize, ref.current);
|
|
@@ -17,7 +17,9 @@ export const SwapInputAdornment = ({ formType }) => {
|
|
|
17
17
|
const { token, isLoading } = useTokenAddressBalance(chainId, tokenAddress);
|
|
18
18
|
const handleMax = () => {
|
|
19
19
|
var _a;
|
|
20
|
-
setValue(SwapFormKeyHelper.getAmountKey(formType), (_a = token === null || token === void 0 ? void 0 : token.amount) !== null && _a !== void 0 ? _a : ''
|
|
20
|
+
setValue(SwapFormKeyHelper.getAmountKey(formType), (_a = token === null || token === void 0 ? void 0 : token.amount) !== null && _a !== void 0 ? _a : '', {
|
|
21
|
+
shouldTouch: true,
|
|
22
|
+
});
|
|
21
23
|
};
|
|
22
|
-
return (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isLoading && tokenAddress ? (_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
|
|
24
|
+
return (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isLoading && tokenAddress ? (_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 }, { children: t('button.max') }))) : null })));
|
|
23
25
|
};
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import { Button as MuiButton } from '@mui/material';
|
|
2
|
-
import {
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
3
|
export const Button = styled(MuiButton)(({ theme }) => ({
|
|
4
|
-
|
|
5
|
-
? theme.palette.grey[300]
|
|
6
|
-
: theme.palette.grey[800],
|
|
7
|
-
color: theme.palette.text.secondary,
|
|
8
|
-
padding: theme.spacing(0.125, 1, 0.375, 1),
|
|
4
|
+
padding: theme.spacing(0.5, 1, 0.625, 1),
|
|
9
5
|
lineHeight: 1,
|
|
10
6
|
fontSize: '0.875rem',
|
|
11
7
|
minWidth: 'unset',
|
|
12
|
-
'&:hover': {
|
|
13
|
-
color: theme.palette.mode === 'light'
|
|
14
|
-
? theme.palette.primary.main
|
|
15
|
-
: theme.palette.text.primary,
|
|
16
|
-
borderColor: theme.palette.mode === 'light'
|
|
17
|
-
? lighten(theme.palette.primary.main, 0.5)
|
|
18
|
-
: theme.palette.text.secondary,
|
|
19
|
-
},
|
|
20
8
|
}));
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { AccessTime as AccessTimeIcon, EvStationOutlined as EvStationIcon, ExpandLess as ExpandLessIcon, ExpandMore as ExpandMoreIcon, LayersOutlined as LayersIcon, } from '@mui/icons-material';
|
|
14
|
-
import { Box, Collapse, Typography } from '@mui/material';
|
|
14
|
+
import { Box, Collapse, Tooltip, Typography } from '@mui/material';
|
|
15
15
|
import { useState } from 'react';
|
|
16
16
|
import { useTranslation } from 'react-i18next';
|
|
17
17
|
import { Card } from '../Card';
|
|
@@ -31,12 +31,16 @@ export const SwapRouteCard = (_a) => {
|
|
|
31
31
|
e.stopPropagation();
|
|
32
32
|
setCardExpanded((expanded) => !expanded);
|
|
33
33
|
};
|
|
34
|
-
return (_jsxs(Card, Object.assign({ dense: variant === 'dense', variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2 }, { children: [_jsx(Label, Object.assign({ active: active !== null && active !== void 0 ? active : label !== alternativeTag }, { children: label })), variant === 'stretched' ? (_jsx(SwapRouteCardEssentials, { route: route })) : null] })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center" }, { children: [_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), step: variant === 'stretched' ? route.steps[0] : undefined }), variant === 'stretched' && !expanded ? (_jsx(IconButton, Object.assign({ onClick: handleExpand, size: "small" }, { children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) }))) : null] })), _jsx(Collapse, Object.assign({
|
|
34
|
+
return (_jsxs(Card, Object.assign({ dense: variant === 'dense', variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2 }, { children: [_jsx(Label, Object.assign({ active: active !== null && active !== void 0 ? active : label !== alternativeTag }, { children: label })), variant === 'stretched' ? (_jsx(SwapRouteCardEssentials, { route: route })) : null] })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center" }, { children: [_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), step: variant === 'stretched' ? route.steps[0] : undefined }), variant === 'stretched' && !expanded ? (_jsx(IconButton, Object.assign({ onClick: handleExpand, size: "small" }, { children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) }))) : null] })), _jsx(Collapse, Object.assign({ timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true }, { children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) })), variant !== 'stretched' ? (_jsx(SwapRouteCardEssentials, { route: route, dense: true })) : null] })));
|
|
35
35
|
};
|
|
36
36
|
export const SwapRouteCardEssentials = ({ route, dense }) => {
|
|
37
37
|
var _a;
|
|
38
38
|
const { t } = useTranslation();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const executionTimeMinutes = Math.ceil(route.steps
|
|
40
|
+
.map((step) => step.estimate.executionDuration)
|
|
41
|
+
.reduce((duration, x) => duration + x, 0) / 60);
|
|
42
|
+
const gasCostUSD = parseFloat((_a = route.gasCostUSD) !== null && _a !== void 0 ? _a : '') || 0.01;
|
|
43
|
+
return (_jsxs(Box, Object.assign({ display: "flex", justifyContent: dense ? 'space-between' : 'flex-end', flex: 1, pl: dense ? 0 : 2, mt: dense ? 2 : 0 }, { children: [_jsx(Tooltip, Object.assign({ title: t(`tooltip.estimatedNetworkFee`), placement: "top", enterDelay: 400, enterNextDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", mr: dense ? 0 : 2 }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(EvStationIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t(`swap.currency`, { value: gasCostUSD }) }))] })) })), _jsx(Tooltip, Object.assign({ title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, enterNextDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", mr: dense ? 0 : 2 }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(AccessTimeIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t('swap.estimatedTime', {
|
|
44
|
+
value: executionTimeMinutes,
|
|
45
|
+
}) }))] })) })), !dense ? (_jsx(Tooltip, Object.assign({ title: t(`tooltip.numberOfSteps`), placement: "top", enterDelay: 400, enterNextDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center" }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(LayersIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: route.steps.length }))] })) }))) : null] })));
|
|
42
46
|
};
|
|
@@ -10,14 +10,14 @@ import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '..
|
|
|
10
10
|
import { useSwapRoutes } from '../../hooks';
|
|
11
11
|
import { navigationRoutes } from '../../utils';
|
|
12
12
|
import { Stack } from './SwapRoutes.style';
|
|
13
|
-
import {
|
|
13
|
+
import { useSetRecommendedRoute } from './useSetRecommendedRoute';
|
|
14
14
|
export const SwapRoutes = (props) => {
|
|
15
15
|
const { t } = useTranslation();
|
|
16
16
|
const navigate = useNavigate();
|
|
17
17
|
const { isValid, isValidating } = useFormState();
|
|
18
18
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
19
19
|
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
20
|
-
|
|
20
|
+
useSetRecommendedRoute(currentRoute, isFetching);
|
|
21
21
|
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
@@ -30,8 +30,8 @@ export const SwapRoutes = (props) => {
|
|
|
30
30
|
top: 8,
|
|
31
31
|
right: 8,
|
|
32
32
|
} }), _jsxs(Box, Object.assign({ sx: { display: 'flex' } }, { children: [_jsx(Stack, Object.assign({ direction: "row", spacing: 2, my: 2, ml: 2, mr: routeNotFound ? 2 : 1, sx: {
|
|
33
|
-
|
|
33
|
+
borderRightWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
|
|
34
34
|
? 1
|
|
35
35
|
: 0,
|
|
36
|
-
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, {})) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense" })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium",
|
|
36
|
+
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, {})) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense" })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", disabled: isValidating || !isValid }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })));
|
|
37
37
|
};
|
|
@@ -1,14 +1,4 @@
|
|
|
1
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") | "divider" | "spacing"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
12
2
|
export declare const CollapseContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
13
3
|
children?: import("react").ReactNode;
|
|
14
4
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -25,14 +15,14 @@ export declare const ScrollableContainer: import("@emotion/styled").StyledCompon
|
|
|
25
15
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
26
16
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
27
17
|
}, 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>, {}, {}>;
|
|
28
|
-
export declare const Container: import("@emotion/styled").StyledComponent<
|
|
18
|
+
export declare const Container: import("@emotion/styled").StyledComponent<{
|
|
29
19
|
children?: import("react").ReactNode;
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
classes?: Partial<import("@mui/material").ScopedCssBaselineClasses> | undefined;
|
|
21
|
+
enableColorScheme?: boolean | undefined;
|
|
32
22
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
33
23
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
34
24
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
35
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "
|
|
25
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "enableColorScheme"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
36
26
|
export declare const Header: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
37
27
|
children?: import("react").ReactNode;
|
|
38
28
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -41,3 +31,13 @@ export declare const Header: import("@emotion/styled").StyledComponent<import("@
|
|
|
41
31
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
42
32
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
43
33
|
}, 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>, {}, {}>;
|
|
34
|
+
export declare const Stack: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
35
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
36
|
+
children?: import("react").ReactNode;
|
|
37
|
+
direction?: import("@mui/system").ResponsiveStyleValue<"row" | "column" | "column-reverse" | "row-reverse"> | undefined;
|
|
38
|
+
spacing?: import("@mui/system").ResponsiveStyleValue<string | number> | undefined;
|
|
39
|
+
divider?: import("react").ReactNode;
|
|
40
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | 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" | "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") | "divider" | "spacing"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import { Box, Stack as MuiStack } from '@mui/material';
|
|
1
|
+
import { Box, ScopedCssBaseline, Stack as MuiStack } from '@mui/material';
|
|
2
2
|
import { alpha, styled } from '@mui/material/styles';
|
|
3
3
|
import { maxHeight } from '../AppContainer';
|
|
4
|
-
export const Stack = styled(MuiStack)(({ theme }) => ({
|
|
5
|
-
alignItems: 'stretch',
|
|
6
|
-
display: 'flex',
|
|
7
|
-
flex: 1,
|
|
8
|
-
flexWrap: 'nowrap',
|
|
9
|
-
overflow: 'hidden',
|
|
10
|
-
borderRight: `solid ${theme.palette.mode === 'light'
|
|
11
|
-
? theme.palette.grey[300]
|
|
12
|
-
: theme.palette.grey[800]}`,
|
|
13
|
-
width: 'calc(100% - 48px)',
|
|
14
|
-
}));
|
|
15
4
|
export const CollapseContainer = styled(Box)(({ theme }) => ({
|
|
16
5
|
height: maxHeight,
|
|
17
6
|
}));
|
|
@@ -22,7 +11,7 @@ export const ScrollableContainer = styled(Box)({
|
|
|
22
11
|
display: 'flex',
|
|
23
12
|
flexDirection: 'column',
|
|
24
13
|
});
|
|
25
|
-
export const Container = styled(
|
|
14
|
+
export const Container = styled(ScopedCssBaseline)(({ theme }) => ({
|
|
26
15
|
backgroundColor: theme.palette.background.default,
|
|
27
16
|
overflow: 'auto',
|
|
28
17
|
width: 436,
|
|
@@ -42,3 +31,14 @@ export const Header = styled(Box)(({ theme }) => ({
|
|
|
42
31
|
top: 0,
|
|
43
32
|
zIndex: 1200,
|
|
44
33
|
}));
|
|
34
|
+
export const Stack = styled(MuiStack)(({ theme }) => ({
|
|
35
|
+
alignItems: 'stretch',
|
|
36
|
+
display: 'flex',
|
|
37
|
+
flex: 1,
|
|
38
|
+
flexWrap: 'nowrap',
|
|
39
|
+
overflow: 'hidden',
|
|
40
|
+
borderRight: `solid ${theme.palette.mode === 'light'
|
|
41
|
+
? theme.palette.grey[300]
|
|
42
|
+
: theme.palette.grey[800]}`,
|
|
43
|
+
width: 'calc(100% - 48px)',
|
|
44
|
+
}));
|
|
@@ -2,16 +2,26 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Collapse, Grow, Stack, Typography } from '@mui/material';
|
|
3
3
|
import { useFormState } from 'react-hook-form';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import {
|
|
5
|
+
import { useNavigate, useRoutes } from 'react-router-dom';
|
|
6
6
|
import { useSwapRoutes } from '../../hooks';
|
|
7
7
|
import { useWidgetConfig } from '../../providers';
|
|
8
8
|
import { useSetExecutableRoute } from '../../stores';
|
|
9
|
-
import { navigationRoutes
|
|
9
|
+
import { navigationRoutes } from '../../utils';
|
|
10
10
|
import { ProgressToNextUpdate } from '../ProgressToNextUpdate';
|
|
11
11
|
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../SwapRouteCard';
|
|
12
12
|
import { CollapseContainer, Container, Header, ScrollableContainer, } from './SwapRoutes.style';
|
|
13
|
-
import {
|
|
13
|
+
import { useSetRecommendedRoute } from './useSetRecommendedRoute';
|
|
14
|
+
const timeout = { enter: 225, exit: 225, appear: 0 };
|
|
14
15
|
export const SwapRoutesExpanded = () => {
|
|
16
|
+
const element = useRoutes([
|
|
17
|
+
{
|
|
18
|
+
path: '/',
|
|
19
|
+
element: null,
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
return (_jsx(CollapseContainer, { children: _jsx(Collapse, Object.assign({ timeout: timeout, in: !!element, orientation: "horizontal" }, { children: _jsx(Grow, Object.assign({ timeout: timeout, in: !!element, mountOnEnter: true, unmountOnExit: true }, { children: _jsx("div", { children: _jsx(SwapRoutesExpandedElement, {}) }) })) })) }));
|
|
23
|
+
};
|
|
24
|
+
export const SwapRoutesExpandedElement = () => {
|
|
15
25
|
const { t } = useTranslation();
|
|
16
26
|
const navigate = useNavigate();
|
|
17
27
|
const setExecutableRoute = useSetExecutableRoute();
|
|
@@ -19,13 +29,7 @@ export const SwapRoutesExpanded = () => {
|
|
|
19
29
|
const { isValid, isValidating } = useFormState();
|
|
20
30
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
21
31
|
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
22
|
-
|
|
23
|
-
const { pathname } = useLocation();
|
|
24
|
-
const cleanedPathname = pathname.endsWith('/')
|
|
25
|
-
? pathname.slice(0, -1)
|
|
26
|
-
: pathname;
|
|
27
|
-
const path = cleanedPathname.substring(cleanedPathname.lastIndexOf('/') + 1);
|
|
28
|
-
const hasPath = navigationRoutesValues.includes(path);
|
|
32
|
+
useSetRecommendedRoute(currentRoute, isFetching);
|
|
29
33
|
const handleRouteClick = (route) => {
|
|
30
34
|
if (isValid && !isValidating) {
|
|
31
35
|
setExecutableRoute(route);
|
|
@@ -34,7 +38,7 @@ export const SwapRoutesExpanded = () => {
|
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
40
|
};
|
|
37
|
-
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched)
|
|
41
|
+
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
|
|
38
42
|
const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
|
|
39
|
-
return (_jsx(
|
|
43
|
+
return (_jsx(Collapse, Object.assign({ timeout: timeout.enter, in: expanded, orientation: "horizontal" }, { children: _jsx(Grow, Object.assign({ timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true }, { children: _jsx(Container, Object.assign({ sx: containerStyle, enableColorScheme: true }, { children: _jsxs(ScrollableContainer, { children: [_jsxs(Header, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "700", flex: 1, noWrap: true }, { children: t('swap.routes') })), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), _jsx(Stack, Object.assign({ direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, { variant: "stretched" }, index)))) : (routes === null || routes === void 0 ? void 0 : routes.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, variant: "stretched", expanded: (routes === null || routes === void 0 ? void 0 : routes.length) <= 2 }, route.id)))) }))] }) })) })) })));
|
|
40
44
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useRecommendedRouteStore } from '../../stores';
|
|
3
|
+
export const useSetRecommendedRoute = (currentRoute, isFetching) => {
|
|
4
|
+
const setRecommendedRoute = useRecommendedRouteStore((state) => state.setRecommendedRoute);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
setRecommendedRoute(!isFetching ? currentRoute : undefined);
|
|
7
|
+
return () => setRecommendedRoute(undefined);
|
|
8
|
+
}, [currentRoute, isFetching, setRecommendedRoute]);
|
|
9
|
+
};
|