@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.
Files changed (211) hide show
  1. package/App.js +6 -86
  2. package/AppDrawer.js +3 -2
  3. package/AppRoutes.d.ts +2 -0
  4. package/AppRoutes.js +85 -0
  5. package/cjs/App.js +5 -85
  6. package/cjs/AppDrawer.js +2 -1
  7. package/cjs/AppRoutes.d.ts +2 -0
  8. package/cjs/AppRoutes.js +89 -0
  9. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -0
  10. package/cjs/components/AppContainer.d.ts +4 -5
  11. package/cjs/components/AppContainer.js +30 -29
  12. package/cjs/components/Card/Card.d.ts +1 -0
  13. package/cjs/components/Card/Card.js +13 -9
  14. package/cjs/components/ChainSelect/ChainSelect.d.ts +1 -0
  15. package/cjs/components/ChainSelect/ChainSelect.js +3 -3
  16. package/cjs/components/ChainSelect/ChainSelect.style.d.ts +1 -0
  17. package/cjs/components/ChainSelect/ChainSelect.style.js +2 -2
  18. package/cjs/components/ChainSelect/useChainSelect.js +2 -2
  19. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +6 -2
  20. package/cjs/components/Header/Header.d.ts +2 -1
  21. package/cjs/components/Header/Header.js +3 -2
  22. package/cjs/components/Header/Header.style.js +3 -2
  23. package/cjs/components/Header/NavigationHeader.js +4 -1
  24. package/cjs/components/Header/WalletHeader.js +1 -1
  25. package/cjs/components/PoweredBy/PoweredBy.js +7 -0
  26. package/cjs/components/SendToWallet/SendToWallet.js +6 -10
  27. package/cjs/components/SendToWallet/SendToWalletButton.d.ts +2 -0
  28. package/cjs/components/SendToWallet/SendToWalletButton.js +24 -0
  29. package/cjs/components/SendToWallet/index.d.ts +1 -0
  30. package/cjs/components/SendToWallet/index.js +1 -0
  31. package/cjs/components/SendToWallet/store.d.ts +4 -0
  32. package/cjs/components/SendToWallet/store.js +13 -0
  33. package/cjs/components/SendToWallet/types.d.ts +6 -0
  34. package/cjs/{stores/route → components/SendToWallet}/types.js +0 -0
  35. package/cjs/components/Step/CircularProgress.d.ts +1 -0
  36. package/cjs/components/StepActions/StepActions.style.js +1 -1
  37. package/cjs/components/SwapButton/ButtonTooltip.d.ts +1 -0
  38. package/cjs/components/SwapButton/SwapButton.d.ts +1 -1
  39. package/cjs/components/SwapButton/SwapButton.js +4 -4
  40. package/cjs/components/SwapInput/SwapInputAdornment.d.ts +1 -0
  41. package/cjs/components/SwapRouteCard/SwapRouteCard.d.ts +2 -1
  42. package/cjs/components/SwapRouteCard/SwapRouteCard.js +19 -15
  43. package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +30 -0
  44. package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +16 -3
  45. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -12
  46. package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.d.ts +1 -3
  47. package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -13
  48. package/cjs/components/SwapRouteCard/types.d.ts +6 -2
  49. package/cjs/{pages/MainPage → components/SwapRoutes}/SwapRoutes.d.ts +0 -0
  50. package/cjs/components/SwapRoutes/SwapRoutes.js +51 -0
  51. package/cjs/components/SwapRoutes/SwapRoutes.style.d.ts +43 -0
  52. package/cjs/components/SwapRoutes/SwapRoutes.style.js +47 -0
  53. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -0
  54. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +38 -0
  55. package/cjs/components/SwapRoutes/index.d.ts +2 -0
  56. package/cjs/components/SwapRoutes/index.js +18 -0
  57. package/cjs/components/Token/Token.d.ts +2 -1
  58. package/cjs/components/Token/Token.js +10 -6
  59. package/cjs/components/Token/Token.style.js +2 -0
  60. package/cjs/config/theme.js +20 -24
  61. package/cjs/config/version.d.ts +1 -1
  62. package/cjs/config/version.js +1 -1
  63. package/cjs/hooks/useChains.js +2 -2
  64. package/cjs/hooks/useNavigateBack.js +13 -6
  65. package/cjs/hooks/useRouteExecution.js +4 -4
  66. package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +1 -0
  67. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -0
  68. package/cjs/pages/MainPage/MainPage.js +4 -2
  69. package/cjs/pages/MainPage/MainSwapButton.js +4 -4
  70. package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -0
  71. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +4 -3
  72. package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -0
  73. package/cjs/pages/SettingsPage/AdvancedPreferences.d.ts +1 -0
  74. package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +1 -0
  75. package/cjs/pages/SettingsPage/SettingsPage.d.ts +1 -0
  76. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -0
  77. package/cjs/pages/SettingsPage/SlippageInput.d.ts +1 -0
  78. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
  79. package/cjs/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -0
  80. package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +8 -5
  81. package/cjs/pages/SwapPage/SwapPage.js +5 -1
  82. package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
  83. package/cjs/providers/WalletProvider/WalletProvider.js +2 -2
  84. package/cjs/stores/index.d.ts +2 -1
  85. package/cjs/stores/index.js +2 -1
  86. package/cjs/stores/{route → routes}/index.d.ts +2 -1
  87. package/cjs/stores/{route → routes}/index.js +2 -1
  88. package/cjs/stores/{route → routes}/types.d.ts +4 -0
  89. package/cjs/stores/routes/types.js +2 -0
  90. package/cjs/stores/{route → routes}/useExecutingRoutesIds.d.ts +0 -0
  91. package/cjs/stores/{route → routes}/useExecutingRoutesIds.js +2 -2
  92. package/cjs/stores/{route/useRouteStore.d.ts → routes/useRouteExecutionStore.d.ts} +1 -1
  93. package/cjs/stores/{route/useRouteStore.js → routes/useRouteExecutionStore.js} +2 -2
  94. package/cjs/stores/routes/useSelectedRouteStore.d.ts +4 -0
  95. package/cjs/stores/routes/useSelectedRouteStore.js +12 -0
  96. package/cjs/stores/{route → routes}/useSetExecutableRoute.d.ts +0 -0
  97. package/cjs/stores/{route → routes}/useSetExecutableRoute.js +2 -2
  98. package/cjs/stores/{route → routes}/useSwapHistory.d.ts +0 -0
  99. package/cjs/stores/{route → routes}/useSwapHistory.js +2 -2
  100. package/cjs/stores/{route → routes}/utils.d.ts +0 -0
  101. package/cjs/stores/{route → routes}/utils.js +0 -0
  102. package/cjs/stores/settings/useSettingsStore.js +1 -1
  103. package/cjs/types/widget.d.ts +2 -0
  104. package/cjs/utils/colors.d.ts +1 -1
  105. package/cjs/utils/navigationRoutes.js +12 -12
  106. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -0
  107. package/components/AppContainer.d.ts +4 -5
  108. package/components/AppContainer.js +29 -28
  109. package/components/Card/Card.d.ts +1 -0
  110. package/components/Card/Card.js +13 -9
  111. package/components/ChainSelect/ChainSelect.d.ts +1 -0
  112. package/components/ChainSelect/ChainSelect.js +1 -1
  113. package/components/ChainSelect/ChainSelect.style.d.ts +1 -0
  114. package/components/ChainSelect/ChainSelect.style.js +2 -2
  115. package/components/ChainSelect/useChainSelect.js +1 -1
  116. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +6 -2
  117. package/components/Header/Header.d.ts +2 -1
  118. package/components/Header/Header.js +1 -1
  119. package/components/Header/Header.style.js +4 -3
  120. package/components/Header/NavigationHeader.js +4 -1
  121. package/components/Header/WalletHeader.js +2 -2
  122. package/components/PoweredBy/PoweredBy.js +7 -0
  123. package/components/SendToWallet/SendToWallet.js +8 -11
  124. package/components/SendToWallet/SendToWalletButton.d.ts +2 -0
  125. package/components/SendToWallet/SendToWalletButton.js +20 -0
  126. package/components/SendToWallet/index.d.ts +1 -0
  127. package/components/SendToWallet/index.js +1 -0
  128. package/components/SendToWallet/store.d.ts +4 -0
  129. package/components/SendToWallet/store.js +10 -0
  130. package/components/SendToWallet/types.d.ts +6 -0
  131. package/{stores/route → components/SendToWallet}/types.js +0 -0
  132. package/components/Step/CircularProgress.d.ts +1 -0
  133. package/components/StepActions/StepActions.style.js +1 -1
  134. package/components/SwapButton/ButtonTooltip.d.ts +1 -0
  135. package/components/SwapButton/SwapButton.d.ts +1 -1
  136. package/components/SwapButton/SwapButton.js +4 -3
  137. package/components/SwapInput/SwapInputAdornment.d.ts +1 -0
  138. package/components/SwapRouteCard/SwapRouteCard.d.ts +2 -1
  139. package/components/SwapRouteCard/SwapRouteCard.js +19 -16
  140. package/components/SwapRouteCard/SwapRouteCard.style.d.ts +30 -0
  141. package/components/SwapRouteCard/SwapRouteCard.style.js +17 -4
  142. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -12
  143. package/components/SwapRouteCard/SwapRouteNotFoundCard.d.ts +1 -3
  144. package/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -13
  145. package/components/SwapRouteCard/types.d.ts +6 -2
  146. package/{pages/MainPage → components/SwapRoutes}/SwapRoutes.d.ts +0 -0
  147. package/components/SwapRoutes/SwapRoutes.js +47 -0
  148. package/components/SwapRoutes/SwapRoutes.style.d.ts +43 -0
  149. package/components/SwapRoutes/SwapRoutes.style.js +44 -0
  150. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -0
  151. package/components/SwapRoutes/SwapRoutesExpanded.js +34 -0
  152. package/components/SwapRoutes/index.d.ts +2 -0
  153. package/components/SwapRoutes/index.js +2 -0
  154. package/components/Token/Token.d.ts +2 -1
  155. package/components/Token/Token.js +11 -7
  156. package/components/Token/Token.style.js +2 -0
  157. package/config/theme.js +20 -24
  158. package/config/version.d.ts +1 -1
  159. package/config/version.js +1 -1
  160. package/hooks/useChains.js +1 -1
  161. package/hooks/useNavigateBack.js +13 -6
  162. package/hooks/useRouteExecution.js +5 -5
  163. package/package.json +11 -11
  164. package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +1 -0
  165. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -0
  166. package/pages/MainPage/MainPage.js +4 -2
  167. package/pages/MainPage/MainSwapButton.js +4 -3
  168. package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -0
  169. package/pages/SelectTokenPage/SelectTokenPage.js +4 -3
  170. package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -0
  171. package/pages/SettingsPage/AdvancedPreferences.d.ts +1 -0
  172. package/pages/SettingsPage/GasPriceSelect.d.ts +1 -0
  173. package/pages/SettingsPage/SettingsPage.d.ts +1 -0
  174. package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -0
  175. package/pages/SettingsPage/SlippageInput.d.ts +1 -0
  176. package/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
  177. package/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -0
  178. package/pages/SwapHistoryPage/SwapHistoryPage.js +8 -5
  179. package/pages/SwapPage/SwapPage.js +5 -1
  180. package/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
  181. package/providers/WalletProvider/WalletProvider.js +1 -1
  182. package/stores/index.d.ts +2 -1
  183. package/stores/index.js +2 -1
  184. package/stores/{route → routes}/index.d.ts +2 -1
  185. package/stores/{route → routes}/index.js +2 -1
  186. package/stores/{route → routes}/types.d.ts +4 -0
  187. package/stores/routes/types.js +1 -0
  188. package/stores/{route → routes}/useExecutingRoutesIds.d.ts +0 -0
  189. package/stores/{route → routes}/useExecutingRoutesIds.js +2 -2
  190. package/stores/{route/useRouteStore.d.ts → routes/useRouteExecutionStore.d.ts} +1 -1
  191. package/stores/{route/useRouteStore.js → routes/useRouteExecutionStore.js} +1 -1
  192. package/stores/routes/useSelectedRouteStore.d.ts +4 -0
  193. package/stores/routes/useSelectedRouteStore.js +9 -0
  194. package/stores/{route → routes}/useSetExecutableRoute.d.ts +0 -0
  195. package/stores/routes/useSetExecutableRoute.js +4 -0
  196. package/stores/{route → routes}/useSwapHistory.d.ts +0 -0
  197. package/stores/{route → routes}/useSwapHistory.js +2 -2
  198. package/stores/{route → routes}/utils.d.ts +0 -0
  199. package/stores/{route → routes}/utils.js +0 -0
  200. package/stores/settings/useSettingsStore.js +1 -1
  201. package/tsconfig.cjs.tsbuildinfo +1 -1
  202. package/types/widget.d.ts +2 -0
  203. package/utils/colors.d.ts +1 -1
  204. package/utils/navigationRoutes.js +12 -12
  205. package/cjs/pages/MainPage/SwapRoutes.js +0 -43
  206. package/cjs/pages/MainPage/SwapRoutes.style.d.ts +0 -11
  207. package/cjs/pages/MainPage/SwapRoutes.style.js +0 -16
  208. package/pages/MainPage/SwapRoutes.js +0 -39
  209. package/pages/MainPage/SwapRoutes.style.d.ts +0 -11
  210. package/pages/MainPage/SwapRoutes.style.js +0 -13
  211. 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
- export const SendToWallet = (props) => {
19
+ import { useSendToWalletStore } from './store';
20
+ export const SendToWallet = forwardRef((props, ref) => {
21
21
  var _a;
22
22
  const { t } = useTranslation();
23
- const { showDestinationWallet } = useSettings(['showDestinationWallet']);
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
- if (!showDestinationWallet) {
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: ref, 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 }))] }))] })));
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,2 @@
1
+ /// <reference types="react" />
2
+ export declare const SendToWalletButton: React.FC;
@@ -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
+ };
@@ -1 +1,2 @@
1
1
  export * from './SendToWallet';
2
+ export * from './SendToWalletButton';
@@ -1 +1,2 @@
1
1
  export * from './SendToWallet';
2
+ export * from './SendToWalletButton';
@@ -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
+ })));
@@ -0,0 +1,6 @@
1
+ export interface SendToWalletState {
2
+ showSendToWallet: boolean;
3
+ }
4
+ export interface SendToWalletStore extends SendToWalletState {
5
+ toggleSendToWallet(): void;
6
+ }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { Status } from '@lifi/sdk';
2
3
  export declare function CircularProgress({ status }: {
3
4
  status: Status;
@@ -51,6 +51,6 @@ export const StepContent = styled(MuiStepContent, {
51
51
  },
52
52
  }));
53
53
  export const StepAvatar = styled(Avatar)(({ theme, variant }) => ({
54
- color: variant === 'square' ? theme.palette.text.primary : theme.palette.grey[900],
54
+ color: theme.palette.text.primary,
55
55
  backgroundColor: 'transparent',
56
56
  }));
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const ButtonTooltip: ({ title, children, }: {
2
3
  title?: string | undefined;
3
4
  children: JSX.Element;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { SwapButtonProps } from './types';
3
- export declare const SwapButton: React.FC<SwapButtonProps>;
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,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import type { SwapFormTypeProps } from '../../providers';
2
3
  export declare const SwapInputAdornment: ({ formType }: SwapFormTypeProps) => JSX.Element;
@@ -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 { Box, Typography } from '@mui/material';
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, _c;
21
- var { route, active, dense } = _a, other = __rest(_a, ["route", "active", "dense"]);
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
- return (_jsxs(Card, Object.assign({ dense: dense, indented: true }, other, { children: [_jsx(Box, Object.assign({ sx: {
28
- display: 'flex',
29
- alignItems: 'center',
30
- justifyContent: 'space-between',
31
- }, mb: 2 }, { children: _jsx(Label, Object.assign({ active: active !== null && active !== void 0 ? active : label !== alternativeTag }, { children: label })) })), _jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), mb: 2 }), !dense
32
- ? route.steps.map((step) => (_jsx(StepActions, { step: step, mb: 2 }, step.id)))
33
- : null, _jsxs(Box, Object.assign({ sx: {
34
- display: 'flex',
35
- justifyContent: 'space-between',
36
- } }, { children: [_jsxs(Box, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "500", lineHeight: 1, pt: 0.25 }, { children: t(`swap.currency`, { value: (_c = route.gasCostUSD) !== null && _c !== void 0 ? _c : 0 }) })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", lineHeight: 1, mt: 0.5 }, { children: t(`swap.gas`) }))] }), _jsxs(Box, { children: [_jsxs(Typography, Object.assign({ fontSize: 18, fontWeight: "500", display: "flex", justifyContent: "flex-end", lineHeight: 1, pt: 0.25 }, { children: ["~", (route.steps
37
- .map((step) => step.estimate.executionDuration)
38
- .reduce((duration, x) => duration + x) / 60).toFixed(0)] })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", textAlign: "end", lineHeight: 1, mt: 0.5 }, { children: t(`swap.minutes`) }))] })] }))] })));
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[500]
13
- : theme.palette.grey[600],
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 { dense } = _a, other = __rest(_a, ["dense"]);
17
- return (_jsxs(Card, Object.assign({ dense: dense, indented: true }, other, { children: [_jsx(Skeleton, { variant: "rectangular", width: 120, height: 24, sx: { borderRadius: 0.5 } }), _jsxs(Box, Object.assign({ my: 2 }, { children: [_jsxs(Box, Object.assign({ sx: {
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
- import type { BoxProps } from '@mui/material';
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 = (_a) => {
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
- dense?: boolean;
4
+ variant?: 'default' | 'extended' | 'dense';
5
5
  active?: boolean;
6
6
  }
7
- export interface SwapRouteCardSkeletonProps {
7
+ export interface SwapRouteCardEssentialsProps {
8
+ route: Route;
8
9
  dense?: boolean;
9
10
  }
11
+ export interface SwapRouteCardSkeletonProps {
12
+ variant?: 'default' | 'extended' | 'dense';
13
+ }
@@ -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,2 @@
1
+ /// <reference types="react" />
2
+ export declare const SwapRoutesExpanded: () => JSX.Element;
@@ -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
+ };
@@ -0,0 +1,2 @@
1
+ export * from './SwapRoutes';
2
+ export * from './SwapRoutesExpanded';
@@ -0,0 +1,2 @@
1
+ export * from './SwapRoutes';
2
+ export * from './SwapRoutesExpanded';
@@ -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>;