@lifi/widget 1.17.2 → 1.18.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 +6 -86
- package/AppDrawer.js +3 -2
- package/AppRoutes.d.ts +2 -0
- package/AppRoutes.js +85 -0
- package/cjs/App.js +5 -85
- package/cjs/AppDrawer.js +2 -1
- package/cjs/AppRoutes.d.ts +2 -0
- package/cjs/AppRoutes.js +89 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -0
- package/cjs/components/AppContainer.d.ts +4 -5
- package/cjs/components/AppContainer.js +30 -29
- package/cjs/components/Card/Card.d.ts +1 -0
- package/cjs/components/Card/Card.js +13 -9
- package/cjs/components/ChainSelect/ChainSelect.d.ts +1 -0
- package/cjs/components/ChainSelect/ChainSelect.js +3 -3
- package/cjs/components/ChainSelect/ChainSelect.style.d.ts +1 -0
- package/cjs/components/ChainSelect/ChainSelect.style.js +2 -2
- package/cjs/components/ChainSelect/useChainSelect.js +2 -2
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +6 -2
- package/cjs/components/Header/Header.d.ts +2 -1
- package/cjs/components/Header/Header.js +3 -2
- package/cjs/components/Header/Header.style.js +3 -2
- package/cjs/components/Header/NavigationHeader.js +4 -1
- package/cjs/components/Header/WalletHeader.js +1 -1
- package/cjs/components/PoweredBy/PoweredBy.js +7 -0
- package/cjs/components/SendToWallet/SendToWallet.js +6 -10
- package/cjs/components/SendToWallet/SendToWalletButton.d.ts +2 -0
- package/cjs/components/SendToWallet/SendToWalletButton.js +24 -0
- package/cjs/components/SendToWallet/index.d.ts +1 -0
- package/cjs/components/SendToWallet/index.js +1 -0
- package/cjs/components/SendToWallet/store.d.ts +4 -0
- package/cjs/components/SendToWallet/store.js +13 -0
- package/cjs/components/SendToWallet/types.d.ts +6 -0
- package/cjs/{stores/route → components/SendToWallet}/types.js +0 -0
- package/cjs/components/Step/CircularProgress.d.ts +1 -0
- package/cjs/components/StepActions/StepActions.style.js +1 -1
- package/cjs/components/SwapButton/ButtonTooltip.d.ts +1 -0
- package/cjs/components/SwapButton/SwapButton.d.ts +1 -1
- package/cjs/components/SwapButton/SwapButton.js +4 -4
- package/cjs/components/SwapInput/SwapInputAdornment.d.ts +1 -0
- package/cjs/components/SwapRouteCard/SwapRouteCard.d.ts +2 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +19 -15
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +30 -0
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +16 -3
- package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -12
- package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.d.ts +1 -3
- package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -13
- package/cjs/components/SwapRouteCard/types.d.ts +6 -2
- package/cjs/{pages/MainPage → components/SwapRoutes}/SwapRoutes.d.ts +0 -0
- package/cjs/components/SwapRoutes/SwapRoutes.js +51 -0
- package/cjs/components/SwapRoutes/SwapRoutes.style.d.ts +43 -0
- package/cjs/components/SwapRoutes/SwapRoutes.style.js +47 -0
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -0
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +38 -0
- package/cjs/components/SwapRoutes/index.d.ts +2 -0
- package/cjs/components/SwapRoutes/index.js +18 -0
- package/cjs/components/Token/Token.d.ts +2 -1
- package/cjs/components/Token/Token.js +10 -6
- package/cjs/components/Token/Token.style.js +2 -0
- package/cjs/config/theme.js +20 -24
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useChains.js +2 -2
- package/cjs/hooks/useNavigateBack.js +13 -6
- package/cjs/hooks/useRouteExecution.js +4 -4
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +1 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -0
- package/cjs/pages/MainPage/MainPage.js +4 -2
- package/cjs/pages/MainPage/MainSwapButton.js +4 -4
- package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -0
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +4 -3
- package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -0
- package/cjs/pages/SettingsPage/AdvancedPreferences.d.ts +1 -0
- package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +1 -0
- package/cjs/pages/SettingsPage/SettingsPage.d.ts +1 -0
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -0
- package/cjs/pages/SettingsPage/SlippageInput.d.ts +1 -0
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
- package/cjs/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -0
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +8 -5
- package/cjs/pages/SwapPage/SwapPage.js +5 -1
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/cjs/providers/WalletProvider/WalletProvider.js +2 -2
- package/cjs/stores/index.d.ts +2 -1
- package/cjs/stores/index.js +2 -1
- package/cjs/stores/{route → routes}/index.d.ts +2 -1
- package/cjs/stores/{route → routes}/index.js +2 -1
- package/cjs/stores/{route → routes}/types.d.ts +4 -0
- package/cjs/stores/routes/types.js +2 -0
- package/cjs/stores/{route → routes}/useExecutingRoutesIds.d.ts +0 -0
- package/cjs/stores/{route → routes}/useExecutingRoutesIds.js +2 -2
- package/cjs/stores/{route/useRouteStore.d.ts → routes/useRouteExecutionStore.d.ts} +1 -1
- package/cjs/stores/{route/useRouteStore.js → routes/useRouteExecutionStore.js} +2 -2
- package/cjs/stores/routes/useSelectedRouteStore.d.ts +4 -0
- package/cjs/stores/routes/useSelectedRouteStore.js +12 -0
- package/cjs/stores/{route → routes}/useSetExecutableRoute.d.ts +0 -0
- package/cjs/stores/{route → routes}/useSetExecutableRoute.js +2 -2
- package/cjs/stores/{route → routes}/useSwapHistory.d.ts +0 -0
- package/cjs/stores/{route → routes}/useSwapHistory.js +2 -2
- package/cjs/stores/{route → routes}/utils.d.ts +0 -0
- package/cjs/stores/{route → routes}/utils.js +0 -0
- package/cjs/stores/settings/useSettingsStore.js +1 -1
- package/cjs/types/widget.d.ts +2 -0
- package/cjs/utils/colors.d.ts +1 -1
- package/cjs/utils/navigationRoutes.js +12 -12
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -0
- package/components/AppContainer.d.ts +4 -5
- package/components/AppContainer.js +29 -28
- package/components/Card/Card.d.ts +1 -0
- package/components/Card/Card.js +13 -9
- package/components/ChainSelect/ChainSelect.d.ts +1 -0
- package/components/ChainSelect/ChainSelect.js +1 -1
- package/components/ChainSelect/ChainSelect.style.d.ts +1 -0
- package/components/ChainSelect/ChainSelect.style.js +2 -2
- package/components/ChainSelect/useChainSelect.js +1 -1
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +6 -2
- package/components/Header/Header.d.ts +2 -1
- package/components/Header/Header.js +1 -1
- package/components/Header/Header.style.js +4 -3
- package/components/Header/NavigationHeader.js +4 -1
- package/components/Header/WalletHeader.js +2 -2
- package/components/PoweredBy/PoweredBy.js +7 -0
- package/components/SendToWallet/SendToWallet.js +8 -11
- package/components/SendToWallet/SendToWalletButton.d.ts +2 -0
- package/components/SendToWallet/SendToWalletButton.js +20 -0
- package/components/SendToWallet/index.d.ts +1 -0
- package/components/SendToWallet/index.js +1 -0
- package/components/SendToWallet/store.d.ts +4 -0
- package/components/SendToWallet/store.js +10 -0
- package/components/SendToWallet/types.d.ts +6 -0
- package/{stores/route → components/SendToWallet}/types.js +0 -0
- package/components/Step/CircularProgress.d.ts +1 -0
- package/components/StepActions/StepActions.style.js +1 -1
- package/components/SwapButton/ButtonTooltip.d.ts +1 -0
- package/components/SwapButton/SwapButton.d.ts +1 -1
- package/components/SwapButton/SwapButton.js +4 -3
- package/components/SwapInput/SwapInputAdornment.d.ts +1 -0
- package/components/SwapRouteCard/SwapRouteCard.d.ts +2 -1
- package/components/SwapRouteCard/SwapRouteCard.js +19 -16
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +30 -0
- package/components/SwapRouteCard/SwapRouteCard.style.js +17 -4
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -12
- package/components/SwapRouteCard/SwapRouteNotFoundCard.d.ts +1 -3
- package/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -13
- package/components/SwapRouteCard/types.d.ts +6 -2
- package/{pages/MainPage → components/SwapRoutes}/SwapRoutes.d.ts +0 -0
- package/components/SwapRoutes/SwapRoutes.js +47 -0
- package/components/SwapRoutes/SwapRoutes.style.d.ts +43 -0
- package/components/SwapRoutes/SwapRoutes.style.js +44 -0
- package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -0
- package/components/SwapRoutes/SwapRoutesExpanded.js +34 -0
- package/components/SwapRoutes/index.d.ts +2 -0
- package/components/SwapRoutes/index.js +2 -0
- package/components/Token/Token.d.ts +2 -1
- package/components/Token/Token.js +11 -7
- package/components/Token/Token.style.js +2 -0
- package/config/theme.js +20 -24
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useChains.js +1 -1
- package/hooks/useNavigateBack.js +13 -6
- package/hooks/useRouteExecution.js +5 -5
- package/package.json +11 -11
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +1 -0
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -0
- package/pages/MainPage/MainPage.js +4 -2
- package/pages/MainPage/MainSwapButton.js +4 -3
- package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -0
- package/pages/SelectTokenPage/SelectTokenPage.js +4 -3
- package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -0
- package/pages/SettingsPage/AdvancedPreferences.d.ts +1 -0
- package/pages/SettingsPage/GasPriceSelect.d.ts +1 -0
- package/pages/SettingsPage/SettingsPage.d.ts +1 -0
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -0
- package/pages/SettingsPage/SlippageInput.d.ts +1 -0
- package/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
- package/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -0
- package/pages/SwapHistoryPage/SwapHistoryPage.js +8 -5
- package/pages/SwapPage/SwapPage.js +5 -1
- package/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/providers/WalletProvider/WalletProvider.js +1 -1
- package/stores/index.d.ts +2 -1
- package/stores/index.js +2 -1
- package/stores/{route → routes}/index.d.ts +2 -1
- package/stores/{route → routes}/index.js +2 -1
- package/stores/{route → routes}/types.d.ts +4 -0
- package/stores/routes/types.js +1 -0
- package/stores/{route → routes}/useExecutingRoutesIds.d.ts +0 -0
- package/stores/{route → routes}/useExecutingRoutesIds.js +2 -2
- package/stores/{route/useRouteStore.d.ts → routes/useRouteExecutionStore.d.ts} +1 -1
- package/stores/{route/useRouteStore.js → routes/useRouteExecutionStore.js} +1 -1
- package/stores/routes/useSelectedRouteStore.d.ts +4 -0
- package/stores/routes/useSelectedRouteStore.js +9 -0
- package/stores/{route → routes}/useSetExecutableRoute.d.ts +0 -0
- package/stores/routes/useSetExecutableRoute.js +4 -0
- package/stores/{route → routes}/useSwapHistory.d.ts +0 -0
- package/stores/{route → routes}/useSwapHistory.js +2 -2
- package/stores/{route → routes}/utils.d.ts +0 -0
- package/stores/{route → routes}/utils.js +0 -0
- package/stores/settings/useSettingsStore.js +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +2 -0
- package/utils/colors.d.ts +1 -1
- package/utils/navigationRoutes.js +12 -12
- package/cjs/pages/MainPage/SwapRoutes.js +0 -43
- package/cjs/pages/MainPage/SwapRoutes.style.d.ts +0 -11
- package/cjs/pages/MainPage/SwapRoutes.style.js +0 -16
- package/pages/MainPage/SwapRoutes.js +0 -39
- package/pages/MainPage/SwapRoutes.style.d.ts +0 -11
- package/pages/MainPage/SwapRoutes.style.js +0 -13
- package/stores/route/useSetExecutableRoute.js +0 -4
|
@@ -9,27 +9,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { isAddress } from '@ethersproject/address';
|
|
12
|
-
import { FormHelperText } from '@mui/material';
|
|
13
|
-
import { useEffect } from 'react';
|
|
12
|
+
import { Collapse, FormHelperText } from '@mui/material';
|
|
13
|
+
import { forwardRef, useEffect } from 'react';
|
|
14
14
|
import { useFormContext } from 'react-hook-form';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { SwapFormKey, useWallet } from '../../providers';
|
|
17
|
-
import { useSettings } from '../../stores';
|
|
18
17
|
import { Card, CardTitle } from '../Card';
|
|
19
18
|
import { FormControl, Input } from './SendToWallet.style';
|
|
20
|
-
|
|
19
|
+
import { useSendToWalletStore } from './store';
|
|
20
|
+
export const SendToWallet = forwardRef((props, ref) => {
|
|
21
21
|
var _a;
|
|
22
22
|
const { t } = useTranslation();
|
|
23
|
-
const
|
|
23
|
+
const showSendToWallet = useSendToWalletStore((state) => state.showSendToWallet);
|
|
24
24
|
const { account, provider } = useWallet();
|
|
25
25
|
const { register, trigger, formState: { errors }, } = useFormContext();
|
|
26
26
|
useEffect(() => {
|
|
27
27
|
trigger(SwapFormKey.ToAddress);
|
|
28
28
|
}, [account.chainId, trigger]);
|
|
29
|
-
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const { onChange, onBlur, name, ref } = register(SwapFormKey.ToAddress, {
|
|
29
|
+
const { onChange, onBlur, name, ref: inputRef, } = register(SwapFormKey.ToAddress, {
|
|
33
30
|
validate: (value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
31
|
try {
|
|
35
32
|
if (!value) {
|
|
@@ -45,5 +42,5 @@ export const SendToWallet = (props) => {
|
|
|
45
42
|
}),
|
|
46
43
|
onBlur: () => trigger(SwapFormKey.ToAddress),
|
|
47
44
|
});
|
|
48
|
-
return (_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.sendToWallet') }), _jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [_jsx(Input, { ref:
|
|
49
|
-
};
|
|
45
|
+
return (_jsx(Collapse, Object.assign({ timeout: 225, in: showSendToWallet }, { 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') }), _jsx(FormHelperText, Object.assign({ error: !!errors.toAddress }, { children: (_a = errors.toAddress) === null || _a === void 0 ? void 0 : _a.message }))] }))] })) })));
|
|
46
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { WalletOutlined as WalletOutlinedIcon } from '@mui/icons-material';
|
|
3
|
+
import { Button, Tooltip } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { useWallet } from '../../providers';
|
|
6
|
+
import { useSettings } from '../../stores';
|
|
7
|
+
import { useSendToWalletStore } from './store';
|
|
8
|
+
export const SendToWalletButton = () => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const { account } = useWallet();
|
|
11
|
+
const { showDestinationWallet } = useSettings(['showDestinationWallet']);
|
|
12
|
+
const { showSendToWallet, toggleSendToWallet } = useSendToWalletStore();
|
|
13
|
+
if (!showDestinationWallet || !account.isActive) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return (_jsx(Tooltip, Object.assign({ title: t('swap.sendToWallet'), placement: "bottom-end", enterDelay: 500, enterNextDelay: 500, arrow: true }, { children: _jsx(Button, Object.assign({ variant: showSendToWallet ? 'contained' : 'text', onClick: toggleSendToWallet, sx: {
|
|
17
|
+
minWidth: 48,
|
|
18
|
+
marginLeft: 1,
|
|
19
|
+
} }, { children: _jsx(WalletOutlinedIcon, {}) })) })));
|
|
20
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SendToWalletStore } from './types';
|
|
2
|
+
export declare const useSendToWalletStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<SendToWalletStore>, "setState"> & {
|
|
3
|
+
setState(nextStateOrUpdater: SendToWalletStore | Partial<SendToWalletStore> | ((state: import("immer/dist/internal").WritableDraft<SendToWalletStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
4
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import create from 'zustand';
|
|
2
|
+
import { immer } from 'zustand/middleware/immer';
|
|
3
|
+
export const useSendToWalletStore = create()(immer((set) => ({
|
|
4
|
+
showSendToWallet: false,
|
|
5
|
+
toggleSendToWallet: () => {
|
|
6
|
+
set((state) => {
|
|
7
|
+
state.showSendToWallet = !state.showSendToWallet;
|
|
8
|
+
});
|
|
9
|
+
},
|
|
10
|
+
})));
|
|
File without changes
|
|
@@ -51,6 +51,6 @@ export const StepContent = styled(MuiStepContent, {
|
|
|
51
51
|
},
|
|
52
52
|
}));
|
|
53
53
|
export const StepAvatar = styled(Avatar)(({ theme, variant }) => ({
|
|
54
|
-
color:
|
|
54
|
+
color: theme.palette.text.primary,
|
|
55
55
|
backgroundColor: 'transparent',
|
|
56
56
|
}));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { SwapButtonProps } from './types';
|
|
3
|
-
export declare const SwapButton:
|
|
3
|
+
export declare const SwapButton: import("react").ForwardRefExoticComponent<SwapButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -9,12 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { Button } from '@mui/material';
|
|
12
|
+
import { forwardRef } from 'react';
|
|
12
13
|
import { useTranslation } from 'react-i18next';
|
|
13
14
|
import { useNavigate } from 'react-router-dom';
|
|
14
15
|
import { useGasSufficiency } from '../../hooks';
|
|
15
16
|
import { useWallet, useWidgetConfig } from '../../providers';
|
|
16
17
|
import { navigationRoutes } from '../../utils';
|
|
17
|
-
export const SwapButton = ({ onClick, currentRoute, text, disable,
|
|
18
|
+
export const SwapButton = forwardRef(({ onClick, currentRoute, text, disable }, ref) => {
|
|
18
19
|
const { t } = useTranslation();
|
|
19
20
|
const navigate = useNavigate();
|
|
20
21
|
const config = useWidgetConfig();
|
|
@@ -42,5 +43,5 @@ export const SwapButton = ({ onClick, currentRoute, text, disable, }) => {
|
|
|
42
43
|
}
|
|
43
44
|
return t(`button.connectWallet`);
|
|
44
45
|
};
|
|
45
|
-
return (_jsx(Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick, disabled: insufficientFunds || !!(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) || disable, fullWidth: true }, { children: getButtonText() })));
|
|
46
|
-
};
|
|
46
|
+
return (_jsx(Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick, disabled: insufficientFunds || !!(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) || disable, fullWidth: true, ref: ref }, { children: getButtonText() })));
|
|
47
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { BoxProps } from '@mui/material';
|
|
3
|
-
import type { SwapRouteCardProps } from './types';
|
|
3
|
+
import type { SwapRouteCardEssentialsProps, SwapRouteCardProps } from './types';
|
|
4
4
|
export declare const SwapRouteCard: React.FC<SwapRouteCardProps & BoxProps>;
|
|
5
|
+
export declare const SwapRouteCardEssentials: React.FC<SwapRouteCardEssentialsProps>;
|
|
@@ -10,30 +10,33 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import {
|
|
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';
|
|
15
|
+
import { useState } from 'react';
|
|
14
16
|
import { useTranslation } from 'react-i18next';
|
|
15
17
|
import { Card } from '../Card';
|
|
16
18
|
import { StepActions } from '../StepActions';
|
|
17
19
|
import { Token } from '../Token';
|
|
18
|
-
import { Label } from './SwapRouteCard.style';
|
|
20
|
+
import { IconButton, Label } from './SwapRouteCard.style';
|
|
19
21
|
export const SwapRouteCard = (_a) => {
|
|
20
|
-
var _b
|
|
21
|
-
var { route, active,
|
|
22
|
+
var _b;
|
|
23
|
+
var { route, active, variant = 'default' } = _a, other = __rest(_a, ["route", "active", "variant"]);
|
|
22
24
|
const { t } = useTranslation();
|
|
25
|
+
const [expanded, setExpanded] = useState(variant === 'default');
|
|
23
26
|
const alternativeTag = t(`swap.tags.ALTERNATIVE`);
|
|
24
27
|
const label = ((_b = route.tags) === null || _b === void 0 ? void 0 : _b.length)
|
|
25
28
|
? t(`swap.tags.${route.tags[0]}`)
|
|
26
29
|
: alternativeTag;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
const handleExpand = (e) => {
|
|
31
|
+
e.stopPropagation();
|
|
32
|
+
setExpanded((expanded) => !expanded);
|
|
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 === 'extended' ? (_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 === 'extended' ? route.steps[0] : undefined }), variant === 'extended' ? (_jsx(IconButton, Object.assign({ onClick: handleExpand, size: "small" }, { children: expanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) }))) : null] })), _jsx(Collapse, Object.assign({ mountOnEnter: true, unmountOnExit: true, in: expanded }, { children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) })), variant !== 'extended' ? (_jsx(SwapRouteCardEssentials, { route: route, dense: true })) : null] })));
|
|
35
|
+
};
|
|
36
|
+
export const SwapRouteCardEssentials = ({ route, dense }) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const { t } = useTranslation();
|
|
39
|
+
return (_jsxs(Box, Object.assign({ display: "flex", justifyContent: dense ? 'space-between' : 'flex-end', flex: 1, pl: dense ? 0 : 2, mt: dense ? 2 : 0 }, { children: [_jsxs(Box, Object.assign({ display: "flex", alignItems: "center", pr: 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: (_a = route.gasCostUSD) !== null && _a !== void 0 ? _a : 0 }) }))] })), _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", pr: 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: `${(route.steps
|
|
40
|
+
.map((step) => step.estimate.executionDuration)
|
|
41
|
+
.reduce((duration, x) => duration + x) / 60).toFixed(0)}m` }))] })), !dense ? (_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] })));
|
|
39
42
|
};
|
|
@@ -14,3 +14,33 @@ export declare const Label: import("@emotion/styled").StyledComponent<import("@m
|
|
|
14
14
|
}, 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> & {
|
|
15
15
|
active?: boolean | undefined;
|
|
16
16
|
}, {}, {}>;
|
|
17
|
+
export declare const IconButton: import("@emotion/styled").StyledComponent<{
|
|
18
|
+
children?: import("react").ReactNode;
|
|
19
|
+
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
20
|
+
color?: "inherit" | "default" | "primary" | "secondary" | "error" | "warning" | "info" | "success" | undefined;
|
|
21
|
+
disabled?: boolean | undefined;
|
|
22
|
+
disableFocusRipple?: boolean | undefined;
|
|
23
|
+
edge?: false | "end" | "start" | undefined;
|
|
24
|
+
size?: "small" | "medium" | "large" | undefined;
|
|
25
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
26
|
+
} & Omit<{
|
|
27
|
+
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
28
|
+
centerRipple?: boolean | undefined;
|
|
29
|
+
children?: import("react").ReactNode;
|
|
30
|
+
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
31
|
+
disabled?: boolean | undefined;
|
|
32
|
+
disableRipple?: boolean | undefined;
|
|
33
|
+
disableTouchRipple?: boolean | undefined;
|
|
34
|
+
focusRipple?: boolean | undefined;
|
|
35
|
+
focusVisibleClassName?: string | undefined;
|
|
36
|
+
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
37
|
+
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
38
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
39
|
+
tabIndex?: number | undefined;
|
|
40
|
+
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
41
|
+
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
42
|
+
}, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "key" | keyof import("react").ButtonHTMLAttributes<HTMLButtonElement>> & {
|
|
43
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
44
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "color" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "size" | "edge"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
45
|
+
active?: boolean | undefined;
|
|
46
|
+
}, {}, {}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Typography } from '@mui/material';
|
|
2
|
-
import { styled } from '@mui/material/styles';
|
|
1
|
+
import { IconButton as MuiIconButton, Typography } from '@mui/material';
|
|
2
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
3
3
|
import { getContrastTextColor } from '../../utils';
|
|
4
4
|
export const Label = styled(Typography, {
|
|
5
5
|
shouldForwardProp: (prop) => prop !== 'active',
|
|
@@ -9,8 +9,8 @@ export const Label = styled(Typography, {
|
|
|
9
9
|
borderColor: active
|
|
10
10
|
? theme.palette.secondary.main
|
|
11
11
|
: theme.palette.mode === 'light'
|
|
12
|
-
? theme.palette.grey[
|
|
13
|
-
: theme.palette.grey[
|
|
12
|
+
? theme.palette.grey[300]
|
|
13
|
+
: theme.palette.grey[700],
|
|
14
14
|
borderRadius: theme.shape.borderRadiusSecondary,
|
|
15
15
|
color: active
|
|
16
16
|
? getContrastTextColor(theme, theme.palette.secondary.main)
|
|
@@ -25,3 +25,16 @@ export const Label = styled(Typography, {
|
|
|
25
25
|
display: 'inline-flex',
|
|
26
26
|
userSelect: 'none',
|
|
27
27
|
}));
|
|
28
|
+
export const IconButton = styled(MuiIconButton, {
|
|
29
|
+
shouldForwardProp: (prop) => prop !== 'active',
|
|
30
|
+
})(({ theme, active }) => {
|
|
31
|
+
const backgroundColor = theme.palette.mode === 'light'
|
|
32
|
+
? theme.palette.common.black
|
|
33
|
+
: theme.palette.common.white;
|
|
34
|
+
return {
|
|
35
|
+
backgroundColor: alpha(backgroundColor, 0.04),
|
|
36
|
+
'&:hover': {
|
|
37
|
+
backgroundColor: alpha(backgroundColor, 0.08),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
});
|
|
@@ -13,16 +13,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { Box, Skeleton } from '@mui/material';
|
|
14
14
|
import { Card } from '../Card';
|
|
15
15
|
export const SwapRouteCardSkeleton = (_a) => {
|
|
16
|
-
var {
|
|
17
|
-
return (_jsxs(Card, Object.assign({ dense: dense, indented: true }, other, { children: [_jsx(Skeleton, { variant: "rectangular", width:
|
|
18
|
-
display: 'flex',
|
|
19
|
-
alignItems: 'center',
|
|
20
|
-
} }, { children: [_jsx(Box, Object.assign({ mr: 2 }, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }) })), _jsx(Skeleton, { variant: "text", width: 96, height: 32 })] })), _jsx(Box, Object.assign({ ml: 6 }, { children: _jsx(Skeleton, { variant: "text", width: 102, height: 16, sx: { borderRadius: 0.5 } }) }))] })), _jsxs(Box, Object.assign({ sx: {
|
|
21
|
-
display: 'flex',
|
|
22
|
-
justifyContent: 'space-between',
|
|
23
|
-
} }, { children: [_jsxs(Box, { children: [_jsx(Skeleton, { variant: "text", width: 56, height: 20 }), _jsx(Skeleton, { variant: "text", width: 52, height: 16 })] }), _jsxs(Box, Object.assign({ sx: {
|
|
24
|
-
display: 'flex',
|
|
25
|
-
alignItems: 'flex-end',
|
|
26
|
-
flexDirection: 'column',
|
|
27
|
-
} }, { children: [_jsx(Skeleton, { variant: "text", width: 40, height: 20 }), _jsx(Skeleton, { variant: "text", width: 48, height: 16 })] }))] }))] })));
|
|
16
|
+
var { variant } = _a, other = __rest(_a, ["variant"]);
|
|
17
|
+
return (_jsxs(Card, Object.assign({ dense: variant === 'dense', indented: true }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center" }, { children: [_jsx(Skeleton, { variant: "rectangular", width: 118, height: 24, sx: { borderRadius: 0.5 } }), variant === 'extended' ? (_jsxs(Box, Object.assign({ display: "flex" }, { children: [_jsx(Skeleton, { variant: "text", width: 52, height: 24, sx: { marginRight: 2 } }), _jsx(Skeleton, { variant: "text", width: 44, height: 24, sx: { marginRight: 2 } }), _jsx(Skeleton, { variant: "text", width: 32, height: 24 })] }))) : null] })), _jsxs(Box, Object.assign({ mt: 2 }, { children: [_jsxs(Box, Object.assign({ display: "flex", alignItems: "center" }, { children: [_jsx(Box, Object.assign({ mr: 2 }, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }) })), _jsx(Skeleton, { variant: "text", width: 96, height: 32 })] })), _jsxs(Box, Object.assign({ ml: 6, display: "flex", alignItems: "center" }, { children: [_jsx(Skeleton, { variant: "text", width: 102, height: 16, sx: { borderRadius: 0.5 } }), variant === 'extended' ? (_jsx(Skeleton, { variant: "text", width: 72, height: 16, sx: { marginLeft: 1 } })) : null] }))] })), variant !== 'extended' ? (_jsxs(Box, Object.assign({ mt: 2, display: "flex", justifyContent: "space-between" }, { children: [_jsx(Skeleton, { variant: "text", width: 48, height: 24 }), _jsx(Skeleton, { variant: "text", width: 48, height: 24 })] }))) : null] })));
|
|
28
18
|
};
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
import type { SwapRouteCardSkeletonProps } from './types';
|
|
4
|
-
export declare const SwapRouteNotFoundCard: React.FC<SwapRouteCardSkeletonProps & BoxProps>;
|
|
2
|
+
export declare const SwapRouteNotFoundCard: React.FC;
|
|
@@ -1,20 +1,8 @@
|
|
|
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
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
2
|
import { Route as RouteIcon } from '@mui/icons-material';
|
|
14
3
|
import { Box, Typography } from '@mui/material';
|
|
15
4
|
import { useTranslation } from 'react-i18next';
|
|
16
|
-
export const SwapRouteNotFoundCard = (
|
|
17
|
-
var { dense } = _a, other = __rest(_a, ["dense"]);
|
|
5
|
+
export const SwapRouteNotFoundCard = () => {
|
|
18
6
|
const { t } = useTranslation();
|
|
19
7
|
return (_jsxs(Box, Object.assign({ sx: {
|
|
20
8
|
display: 'flex',
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Route } from '@lifi/sdk';
|
|
2
2
|
export interface SwapRouteCardProps {
|
|
3
3
|
route: Route;
|
|
4
|
-
|
|
4
|
+
variant?: 'default' | 'extended' | 'dense';
|
|
5
5
|
active?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface SwapRouteCardEssentialsProps {
|
|
8
|
+
route: Route;
|
|
8
9
|
dense?: boolean;
|
|
9
10
|
}
|
|
11
|
+
export interface SwapRouteCardSkeletonProps {
|
|
12
|
+
variant?: 'default' | 'extended' | 'dense';
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { KeyboardArrowRight as KeyboardArrowRightIcon } from '@mui/icons-material';
|
|
3
|
+
import { Box, IconButton } from '@mui/material';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { useFormState } from 'react-hook-form';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { useNavigate } from 'react-router-dom';
|
|
8
|
+
import { Card, CardTitle } from '../../components/Card';
|
|
9
|
+
import { ProgressToNextUpdate } from '../../components/ProgressToNextUpdate';
|
|
10
|
+
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../../components/SwapRouteCard';
|
|
11
|
+
import { useSwapRoutes } from '../../hooks';
|
|
12
|
+
import { useWidgetConfig } from '../../providers';
|
|
13
|
+
import { useSelectedRouteStore } from '../../stores';
|
|
14
|
+
import { navigationRoutes } from '../../utils';
|
|
15
|
+
import { Stack } from './SwapRoutes.style';
|
|
16
|
+
export const SwapRoutes = (props) => {
|
|
17
|
+
const { t } = useTranslation();
|
|
18
|
+
const { variant } = useWidgetConfig();
|
|
19
|
+
const navigate = useNavigate();
|
|
20
|
+
const { isValid, isValidating } = useFormState();
|
|
21
|
+
const setSelectedRoute = useSelectedRouteStore((state) => state.setSelectedRoute);
|
|
22
|
+
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
23
|
+
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setSelectedRoute(!isFetching ? currentRoute : undefined);
|
|
26
|
+
return () => setSelectedRoute(undefined);
|
|
27
|
+
}, [currentRoute, isFetching, setSelectedRoute]);
|
|
28
|
+
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const handleCardClick = () => {
|
|
32
|
+
navigate(navigationRoutes.swapRoutes);
|
|
33
|
+
};
|
|
34
|
+
const routeNotFound = !currentRoute && !isLoading && !isFetching;
|
|
35
|
+
if (variant === 'expandable') {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return (_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
top: 8,
|
|
41
|
+
right: 8,
|
|
42
|
+
} }), _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: {
|
|
43
|
+
borderWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
|
|
44
|
+
? 1
|
|
45
|
+
: 0,
|
|
46
|
+
} }, { 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", "aria-label": "swap-routes", disabled: isValidating || !isValid }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })));
|
|
47
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
export declare const CollapseContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
13
|
+
children?: import("react").ReactNode;
|
|
14
|
+
component?: import("react").ElementType<any> | undefined;
|
|
15
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
16
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
17
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
18
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
19
|
+
}, 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>, {}, {}>;
|
|
20
|
+
export declare const ScrollableContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
21
|
+
children?: import("react").ReactNode;
|
|
22
|
+
component?: import("react").ElementType<any> | undefined;
|
|
23
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
24
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
25
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
26
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
27
|
+
}, 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<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
29
|
+
children?: import("react").ReactNode;
|
|
30
|
+
component?: import("react").ElementType<any> | undefined;
|
|
31
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
32
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
33
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
34
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
35
|
+
}, 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>, {}, {}>;
|
|
36
|
+
export declare const Header: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
37
|
+
children?: import("react").ReactNode;
|
|
38
|
+
component?: import("react").ElementType<any> | undefined;
|
|
39
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
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" | ("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,44 @@
|
|
|
1
|
+
import { Box, Stack as MuiStack } from '@mui/material';
|
|
2
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
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
|
+
export const CollapseContainer = styled(Box)(({ theme }) => ({
|
|
16
|
+
height: maxHeight,
|
|
17
|
+
}));
|
|
18
|
+
export const ScrollableContainer = styled(Box)({
|
|
19
|
+
overflowY: 'auto',
|
|
20
|
+
height: '100%',
|
|
21
|
+
flex: 1,
|
|
22
|
+
display: 'flex',
|
|
23
|
+
flexDirection: 'column',
|
|
24
|
+
});
|
|
25
|
+
export const Container = styled(Box)(({ theme }) => ({
|
|
26
|
+
backgroundColor: theme.palette.background.default,
|
|
27
|
+
overflow: 'auto',
|
|
28
|
+
width: 436,
|
|
29
|
+
maxHeight,
|
|
30
|
+
marginLeft: theme.spacing(3),
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'column',
|
|
33
|
+
}));
|
|
34
|
+
export const Header = styled(Box)(({ theme }) => ({
|
|
35
|
+
backgroundColor: alpha(theme.palette.background.default, 0.84),
|
|
36
|
+
backdropFilter: 'blur(12px)',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
justifyContent: 'space-between',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
padding: theme.spacing(1.5, 3),
|
|
41
|
+
position: 'sticky',
|
|
42
|
+
top: 0,
|
|
43
|
+
zIndex: 1200,
|
|
44
|
+
}));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Collapse, Grow, Stack, Typography } from '@mui/material';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
5
|
+
import { useSwapRoutes } from '../../hooks';
|
|
6
|
+
import { useWidgetConfig } from '../../providers';
|
|
7
|
+
import { useSetExecutableRoute } from '../../stores';
|
|
8
|
+
import { navigationRoutes, navigationRoutesValues } from '../../utils';
|
|
9
|
+
import { ProgressToNextUpdate } from '../ProgressToNextUpdate';
|
|
10
|
+
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../SwapRouteCard';
|
|
11
|
+
import { CollapseContainer, Container, Header, ScrollableContainer, } from './SwapRoutes.style';
|
|
12
|
+
export const SwapRoutesExpanded = () => {
|
|
13
|
+
const { t } = useTranslation();
|
|
14
|
+
const { containerStyle } = useWidgetConfig();
|
|
15
|
+
const navigate = useNavigate();
|
|
16
|
+
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
17
|
+
const setExecutableRoute = useSetExecutableRoute();
|
|
18
|
+
const { pathname } = useLocation();
|
|
19
|
+
const cleanedPathname = pathname.endsWith('/')
|
|
20
|
+
? pathname.slice(0, -1)
|
|
21
|
+
: pathname;
|
|
22
|
+
const path = cleanedPathname.substring(cleanedPathname.lastIndexOf('/') + 1);
|
|
23
|
+
const hasPath = navigationRoutesValues.includes(path);
|
|
24
|
+
const handleRouteClick = (route) => {
|
|
25
|
+
setExecutableRoute(route);
|
|
26
|
+
navigate(navigationRoutes.swapExecution, {
|
|
27
|
+
state: { routeId: route.id },
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
31
|
+
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched) && !hasPath;
|
|
32
|
+
const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
|
|
33
|
+
return (_jsx(CollapseContainer, { children: _jsx(Collapse, Object.assign({ appear: true, timeout: 225, in: expanded, orientation: "horizontal" }, { children: _jsx(Grow, Object.assign({ appear: true, timeout: 225, in: expanded }, { children: _jsx(Container, Object.assign({ sx: containerStyle }, { 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: "extended" }, index)))) : (routes === null || routes === void 0 ? void 0 : routes.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, variant: "extended" }, route.id)))) }))] }) })) })) })) }));
|
|
34
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { TokenAmount } from '@lifi/sdk';
|
|
2
|
+
import type { Step, TokenAmount } from '@lifi/sdk';
|
|
3
3
|
import type { BoxProps } from '@mui/material';
|
|
4
4
|
export declare const Token: React.FC<{
|
|
5
5
|
token: TokenAmount;
|
|
6
6
|
connected?: boolean;
|
|
7
|
+
step?: Step;
|
|
7
8
|
} & BoxProps>;
|