@lifi/widget 1.17.1 → 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 (210) 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.js +3 -3
  15. package/cjs/components/ChainSelect/ChainSelect.style.d.ts +1 -0
  16. package/cjs/components/ChainSelect/ChainSelect.style.js +2 -2
  17. package/cjs/components/ChainSelect/useChainSelect.js +2 -2
  18. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +6 -2
  19. package/cjs/components/Header/Header.d.ts +2 -1
  20. package/cjs/components/Header/Header.js +3 -2
  21. package/cjs/components/Header/Header.style.js +3 -2
  22. package/cjs/components/Header/NavigationHeader.js +4 -1
  23. package/cjs/components/Header/WalletHeader.js +1 -1
  24. package/cjs/components/Header/useHeaderActionStore.js +1 -4
  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/StepActions/StepActions.style.js +1 -1
  36. package/cjs/components/SwapButton/SwapButton.d.ts +1 -1
  37. package/cjs/components/SwapButton/SwapButton.js +4 -4
  38. package/cjs/components/SwapRouteCard/SwapRouteCard.d.ts +2 -1
  39. package/cjs/components/SwapRouteCard/SwapRouteCard.js +19 -15
  40. package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +30 -0
  41. package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +16 -3
  42. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -12
  43. package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.d.ts +1 -3
  44. package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -13
  45. package/cjs/components/SwapRouteCard/types.d.ts +6 -2
  46. package/cjs/{pages/MainPage → components/SwapRoutes}/SwapRoutes.d.ts +0 -0
  47. package/cjs/components/SwapRoutes/SwapRoutes.js +51 -0
  48. package/cjs/components/SwapRoutes/SwapRoutes.style.d.ts +43 -0
  49. package/cjs/components/SwapRoutes/SwapRoutes.style.js +47 -0
  50. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -0
  51. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +38 -0
  52. package/cjs/components/SwapRoutes/index.d.ts +2 -0
  53. package/cjs/components/SwapRoutes/index.js +18 -0
  54. package/cjs/components/Token/Token.d.ts +2 -1
  55. package/cjs/components/Token/Token.js +10 -6
  56. package/cjs/components/Token/Token.style.js +2 -0
  57. package/cjs/components/TokenList/TokenList.js +4 -1
  58. package/cjs/config/sentry.js +3 -26
  59. package/cjs/config/theme.js +20 -24
  60. package/cjs/config/version.d.ts +1 -1
  61. package/cjs/config/version.js +1 -1
  62. package/cjs/hooks/useChains.js +2 -2
  63. package/cjs/hooks/useGasSufficiency.js +14 -37
  64. package/cjs/hooks/useNavigateBack.js +13 -6
  65. package/cjs/hooks/useRouteExecution.js +5 -8
  66. package/cjs/hooks/useSwapRoutes.js +1 -4
  67. package/cjs/hooks/useTelemetry.js +3 -2
  68. package/cjs/hooks/useTokenBalances.d.ts +1 -1
  69. package/cjs/hooks/useTokenBalances.js +3 -1
  70. package/cjs/hooks/useWidgetEvents.js +2 -5
  71. package/cjs/i18n/index.js +2 -5
  72. package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +1 -0
  73. package/cjs/pages/MainPage/MainPage.js +4 -2
  74. package/cjs/pages/MainPage/MainSwapButton.js +4 -4
  75. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +4 -3
  76. package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +1 -4
  77. package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +1 -4
  78. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +2 -5
  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 +3 -5
  83. package/cjs/providers/SDKProvider/SDKProvider.js +1 -4
  84. package/cjs/providers/WalletProvider/WalletProvider.js +2 -2
  85. package/cjs/stores/chains/useChainOrder.js +1 -4
  86. package/cjs/stores/chains/useChainOrderStore.js +1 -4
  87. package/cjs/stores/index.d.ts +2 -1
  88. package/cjs/stores/index.js +2 -1
  89. package/cjs/stores/{route → routes}/index.d.ts +2 -1
  90. package/cjs/stores/{route → routes}/index.js +2 -1
  91. package/cjs/stores/{route → routes}/types.d.ts +4 -0
  92. package/cjs/stores/routes/types.js +2 -0
  93. package/cjs/stores/{route → routes}/useExecutingRoutesIds.d.ts +0 -0
  94. package/cjs/stores/{route → routes}/useExecutingRoutesIds.js +3 -6
  95. package/cjs/stores/{route/useRouteStore.d.ts → routes/useRouteExecutionStore.d.ts} +1 -1
  96. package/cjs/stores/{route/useRouteStore.js → routes/useRouteExecutionStore.js} +3 -6
  97. package/cjs/stores/routes/useSelectedRouteStore.d.ts +4 -0
  98. package/cjs/stores/routes/useSelectedRouteStore.js +12 -0
  99. package/cjs/stores/{route → routes}/useSetExecutableRoute.d.ts +0 -0
  100. package/cjs/stores/{route → routes}/useSetExecutableRoute.js +2 -2
  101. package/cjs/stores/{route → routes}/useSwapHistory.d.ts +0 -0
  102. package/cjs/stores/{route → routes}/useSwapHistory.js +3 -6
  103. package/cjs/stores/{route → routes}/utils.d.ts +0 -0
  104. package/cjs/stores/{route → routes}/utils.js +1 -4
  105. package/cjs/stores/settings/useAppearance.js +1 -4
  106. package/cjs/stores/settings/useSettings.js +1 -4
  107. package/cjs/stores/settings/useSettingsStore.js +2 -5
  108. package/cjs/types/widget.d.ts +2 -0
  109. package/cjs/utils/colors.d.ts +1 -1
  110. package/cjs/utils/format.js +1 -4
  111. package/cjs/utils/navigationRoutes.js +12 -12
  112. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -0
  113. package/components/AppContainer.d.ts +4 -5
  114. package/components/AppContainer.js +29 -28
  115. package/components/Card/Card.d.ts +1 -0
  116. package/components/Card/Card.js +13 -9
  117. package/components/ChainSelect/ChainSelect.js +1 -1
  118. package/components/ChainSelect/ChainSelect.style.d.ts +1 -0
  119. package/components/ChainSelect/ChainSelect.style.js +2 -2
  120. package/components/ChainSelect/useChainSelect.js +1 -1
  121. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +6 -2
  122. package/components/Header/Header.d.ts +2 -1
  123. package/components/Header/Header.js +1 -1
  124. package/components/Header/Header.style.js +4 -3
  125. package/components/Header/NavigationHeader.js +4 -1
  126. package/components/Header/WalletHeader.js +2 -2
  127. package/components/PoweredBy/PoweredBy.js +7 -0
  128. package/components/SendToWallet/SendToWallet.js +8 -11
  129. package/components/SendToWallet/SendToWalletButton.d.ts +2 -0
  130. package/components/SendToWallet/SendToWalletButton.js +20 -0
  131. package/components/SendToWallet/index.d.ts +1 -0
  132. package/components/SendToWallet/index.js +1 -0
  133. package/components/SendToWallet/store.d.ts +4 -0
  134. package/components/SendToWallet/store.js +10 -0
  135. package/components/SendToWallet/types.d.ts +6 -0
  136. package/{stores/route → components/SendToWallet}/types.js +0 -0
  137. package/components/StepActions/StepActions.style.js +1 -1
  138. package/components/SwapButton/SwapButton.d.ts +1 -1
  139. package/components/SwapButton/SwapButton.js +4 -3
  140. package/components/SwapRouteCard/SwapRouteCard.d.ts +2 -1
  141. package/components/SwapRouteCard/SwapRouteCard.js +19 -16
  142. package/components/SwapRouteCard/SwapRouteCard.style.d.ts +30 -0
  143. package/components/SwapRouteCard/SwapRouteCard.style.js +17 -4
  144. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -12
  145. package/components/SwapRouteCard/SwapRouteNotFoundCard.d.ts +1 -3
  146. package/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -13
  147. package/components/SwapRouteCard/types.d.ts +6 -2
  148. package/{pages/MainPage → components/SwapRoutes}/SwapRoutes.d.ts +0 -0
  149. package/components/SwapRoutes/SwapRoutes.js +47 -0
  150. package/components/SwapRoutes/SwapRoutes.style.d.ts +43 -0
  151. package/components/SwapRoutes/SwapRoutes.style.js +44 -0
  152. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -0
  153. package/components/SwapRoutes/SwapRoutesExpanded.js +34 -0
  154. package/components/SwapRoutes/index.d.ts +2 -0
  155. package/components/SwapRoutes/index.js +2 -0
  156. package/components/Token/Token.d.ts +2 -1
  157. package/components/Token/Token.js +11 -7
  158. package/components/Token/Token.style.js +2 -0
  159. package/components/TokenList/TokenList.js +4 -1
  160. package/config/theme.js +20 -24
  161. package/config/version.d.ts +1 -1
  162. package/config/version.js +1 -1
  163. package/hooks/useChains.js +1 -1
  164. package/hooks/useGasSufficiency.js +15 -35
  165. package/hooks/useNavigateBack.js +13 -6
  166. package/hooks/useRouteExecution.js +5 -5
  167. package/hooks/useTelemetry.js +3 -2
  168. package/hooks/useTokenBalances.d.ts +1 -1
  169. package/hooks/useTokenBalances.js +3 -1
  170. package/package.json +14 -14
  171. package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +1 -0
  172. package/pages/MainPage/MainPage.js +4 -2
  173. package/pages/MainPage/MainSwapButton.js +4 -3
  174. package/pages/SelectTokenPage/SelectTokenPage.js +4 -3
  175. package/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
  176. package/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -0
  177. package/pages/SwapHistoryPage/SwapHistoryPage.js +8 -5
  178. package/pages/SwapPage/SwapPage.js +5 -1
  179. package/pages/SwapRoutesPage/SwapRoutesPage.js +4 -6
  180. package/providers/WalletProvider/WalletProvider.js +1 -1
  181. package/stores/index.d.ts +2 -1
  182. package/stores/index.js +2 -1
  183. package/stores/{route → routes}/index.d.ts +2 -1
  184. package/stores/{route → routes}/index.js +2 -1
  185. package/stores/{route → routes}/types.d.ts +4 -0
  186. package/stores/routes/types.js +1 -0
  187. package/stores/{route → routes}/useExecutingRoutesIds.d.ts +0 -0
  188. package/stores/{route → routes}/useExecutingRoutesIds.js +2 -2
  189. package/stores/{route/useRouteStore.d.ts → routes/useRouteExecutionStore.d.ts} +1 -1
  190. package/stores/{route/useRouteStore.js → routes/useRouteExecutionStore.js} +1 -1
  191. package/stores/routes/useSelectedRouteStore.d.ts +4 -0
  192. package/stores/routes/useSelectedRouteStore.js +9 -0
  193. package/stores/{route → routes}/useSetExecutableRoute.d.ts +0 -0
  194. package/stores/routes/useSetExecutableRoute.js +4 -0
  195. package/stores/{route → routes}/useSwapHistory.d.ts +0 -0
  196. package/stores/{route → routes}/useSwapHistory.js +2 -2
  197. package/stores/{route → routes}/utils.d.ts +0 -0
  198. package/stores/{route → routes}/utils.js +0 -0
  199. package/stores/settings/useSettingsStore.js +1 -1
  200. package/tsconfig.cjs.tsbuildinfo +1 -1
  201. package/types/widget.d.ts +2 -0
  202. package/utils/colors.d.ts +1 -1
  203. package/utils/navigationRoutes.js +12 -12
  204. package/cjs/pages/MainPage/SwapRoutes.js +0 -43
  205. package/cjs/pages/MainPage/SwapRoutes.style.d.ts +0 -11
  206. package/cjs/pages/MainPage/SwapRoutes.style.js +0 -16
  207. package/pages/MainPage/SwapRoutes.js +0 -39
  208. package/pages/MainPage/SwapRoutes.style.d.ts +0 -11
  209. package/pages/MainPage/SwapRoutes.style.js +0 -13
  210. package/stores/route/useSetExecutableRoute.js +0 -4
@@ -17,26 +17,26 @@ exports.navigationRoutes = {
17
17
  };
18
18
  exports.navigationRoutesValues = Object.values(exports.navigationRoutes);
19
19
  exports.stickyHeaderRoutes = [
20
- exports.navigationRoutes.selectWallet,
20
+ exports.navigationRoutes.activeSwaps,
21
21
  exports.navigationRoutes.fromChain,
22
- exports.navigationRoutes.toChain,
22
+ exports.navigationRoutes.selectWallet,
23
23
  exports.navigationRoutes.settings,
24
- exports.navigationRoutes.swapRoutes,
24
+ exports.navigationRoutes.swapDetails,
25
25
  exports.navigationRoutes.swapExecution,
26
26
  exports.navigationRoutes.swapHistory,
27
- exports.navigationRoutes.activeSwaps,
28
- exports.navigationRoutes.swapDetails,
27
+ exports.navigationRoutes.swapRoutes,
28
+ exports.navigationRoutes.toChain,
29
29
  ];
30
30
  exports.backButtonRoutes = [
31
+ exports.navigationRoutes.activeSwaps,
32
+ exports.navigationRoutes.fromChain,
33
+ exports.navigationRoutes.fromToken,
31
34
  exports.navigationRoutes.selectWallet,
32
35
  exports.navigationRoutes.settings,
36
+ exports.navigationRoutes.swapDetails,
37
+ exports.navigationRoutes.swapExecution,
33
38
  exports.navigationRoutes.swapHistory,
34
- exports.navigationRoutes.activeSwaps,
35
- exports.navigationRoutes.fromToken,
36
- exports.navigationRoutes.toToken,
37
- exports.navigationRoutes.fromChain,
38
- exports.navigationRoutes.toChain,
39
39
  exports.navigationRoutes.swapRoutes,
40
- exports.navigationRoutes.swapExecution,
41
- exports.navigationRoutes.swapDetails,
40
+ exports.navigationRoutes.toChain,
41
+ exports.navigationRoutes.toToken,
42
42
  ];
@@ -8,6 +8,7 @@ export declare const ProgressCard: import("@emotion/styled").StyledComponent<imp
8
8
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
9
9
  }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
10
10
  variant?: ("default" | "error" | "selected") | undefined;
11
+ selectionColor?: "primary" | "secondary" | undefined;
11
12
  dense?: boolean | undefined;
12
13
  indented?: boolean | undefined;
13
14
  onClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
@@ -1,4 +1,5 @@
1
- import type { PropsWithChildren, RefObject } from 'react';
1
+ import type { PropsWithChildren } from 'react';
2
+ export declare const maxHeight = 680;
2
3
  export declare const FlexContainer: import("@emotion/styled").StyledComponent<{
3
4
  children?: import("react").ReactNode;
4
5
  classes?: Partial<import("@mui/material").ContainerClasses> | undefined;
@@ -7,9 +8,7 @@ export declare const FlexContainer: import("@emotion/styled").StyledComponent<{
7
8
  maxWidth?: false | import("@mui/material").Breakpoint | undefined;
8
9
  sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
9
10
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
10
- ref?: RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
11
+ ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
11
12
  }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "maxWidth" | "fixed" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
12
13
  export declare const AppContainer: React.FC<PropsWithChildren<{}>>;
13
- export declare const ScrollToLocation: React.FC<{
14
- elementRef: RefObject<HTMLElement>;
15
- }>;
14
+ export declare const AppExpandedContainer: React.FC<PropsWithChildren<{}>>;
@@ -1,54 +1,55 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Box, Container, ScopedCssBaseline } from '@mui/material';
3
3
  import { styled } from '@mui/material/styles';
4
- import { useLayoutEffect, useRef } from 'react';
5
- import { useLocation } from 'react-router-dom';
6
4
  import { useWidgetConfig } from '../providers';
7
5
  import { ElementId } from '../utils';
8
- const CssBaselineContainer = styled(ScopedCssBaseline)(({ theme }) => ({
9
- // height: '100%',
6
+ export const maxHeight = 680;
7
+ const ExpandedContainer = styled(Box, {
8
+ shouldForwardProp: (prop) => prop !== 'variant',
9
+ })(({ variant }) => ({
10
10
  display: 'flex',
11
+ justifyContent: 'center',
12
+ alignItems: 'start',
11
13
  flex: 1,
12
- flexDirection: 'column',
13
- overflowX: 'clip',
14
- marginRight: 0,
15
- width: '100%',
14
+ height: variant === 'drawer' ? 'none' : maxHeight,
16
15
  }));
17
- const RelativeContainer = styled(Box)(({ theme }) => ({
16
+ const RelativeContainer = styled(Box, {
17
+ shouldForwardProp: (prop) => prop !== 'variant',
18
+ })(({ theme, variant }) => ({
18
19
  position: 'relative',
19
20
  width: '100%',
20
21
  minWidth: 375,
21
22
  maxWidth: 392,
23
+ maxHeight: variant === 'drawer' ? 'none' : maxHeight,
22
24
  background: theme.palette.background.default,
23
25
  overflow: 'auto',
24
26
  flex: 1,
25
27
  boxSizing: 'border-box',
26
28
  zIndex: 0,
27
29
  }));
28
- const ScrollableContainer = styled(Box)({
29
- // position: 'fixed',
30
+ const CssBaselineContainer = styled(ScopedCssBaseline, {
31
+ shouldForwardProp: (prop) => prop !== 'variant',
32
+ })(({ variant }) => ({
33
+ display: 'flex',
34
+ flex: 1,
35
+ flexDirection: 'column',
36
+ overflowX: 'clip',
37
+ margin: 0,
38
+ width: '100%',
39
+ maxHeight: variant === 'drawer' ? 'none' : maxHeight,
30
40
  overflowY: 'auto',
31
41
  height: '100%',
32
- flex: 1,
33
- display: 'flex',
34
- });
42
+ }));
35
43
  export const FlexContainer = styled(Container)({
36
44
  display: 'flex',
37
- flexBasis: 'auto',
38
45
  flexDirection: 'column',
39
- flexShrink: 0,
40
- flexGrow: 1,
46
+ flex: 1,
41
47
  });
42
48
  export const AppContainer = ({ children }) => {
43
- const ref = useRef(null);
44
- const { containerStyle } = useWidgetConfig();
45
- return (_jsxs(RelativeContainer, Object.assign({ sx: containerStyle }, { children: [_jsx(ScrollableContainer, Object.assign({ id: ElementId.ScrollableContainer, ref: ref }, { children: _jsx(CssBaselineContainer, Object.assign({ enableColorScheme: true }, { children: _jsx(FlexContainer, Object.assign({ disableGutters: true }, { children: children })) })) })), _jsx(ScrollToLocation, { elementRef: ref })] })));
49
+ // const ref = useRef<HTMLDivElement>(null);
50
+ const { containerStyle, variant } = useWidgetConfig();
51
+ return (_jsx(RelativeContainer, Object.assign({ sx: containerStyle, variant: variant }, { children: _jsx(CssBaselineContainer, Object.assign({ id: ElementId.ScrollableContainer, variant: variant, enableColorScheme: true }, { children: _jsx(FlexContainer, Object.assign({ disableGutters: true }, { children: children })) })) })));
46
52
  };
47
- export const ScrollToLocation = ({ elementRef }) => {
48
- const { pathname } = useLocation();
49
- useLayoutEffect(() => {
50
- var _a;
51
- (_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
52
- }, [elementRef, pathname]);
53
- return null;
53
+ export const AppExpandedContainer = ({ children, }) => {
54
+ return _jsx(ExpandedContainer, { children: children });
54
55
  };
@@ -10,6 +10,7 @@ export declare const Card: import("@emotion/styled").StyledComponent<import("@mu
10
10
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
11
11
  }, 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<Theme> & {
12
12
  variant?: CardVariant | undefined;
13
+ selectionColor?: "primary" | "secondary" | undefined;
13
14
  dense?: boolean | undefined;
14
15
  indented?: boolean | undefined;
15
16
  onClick?: MouseEventHandler<HTMLDivElement> | undefined;
@@ -1,21 +1,25 @@
1
1
  import { Box } from '@mui/material';
2
2
  import { alpha, darken, lighten, styled } from '@mui/material/styles';
3
- const getBackgroundColor = (theme, variant) => variant === 'selected'
4
- ? theme.palette.mode === 'light'
5
- ? alpha(theme.palette.primary.main, 0.04)
6
- : alpha(theme.palette.primary.main, 0.42)
3
+ const getBackgroundColor = (theme, variant, selectionColor) => variant === 'selected'
4
+ ? selectionColor === 'primary'
5
+ ? theme.palette.mode === 'light'
6
+ ? alpha(theme.palette.primary.main, 0.04)
7
+ : alpha(theme.palette.primary.main, 0.42)
8
+ : alpha(theme.palette.secondary.main, 0.08)
7
9
  : theme.palette.background.paper;
8
10
  export const Card = styled(Box, {
9
- shouldForwardProp: (prop) => !['dense', 'variant', 'indented'].includes(prop),
10
- })(({ theme, variant, dense, indented, onClick }) => {
11
- const backgroundColor = getBackgroundColor(theme, variant);
11
+ shouldForwardProp: (prop) => !['dense', 'variant', 'indented', 'selectionColor'].includes(prop),
12
+ })(({ theme, variant, selectionColor = 'primary', dense, indented, onClick, }) => {
13
+ const backgroundColor = getBackgroundColor(theme, variant, selectionColor);
12
14
  return {
13
15
  backgroundColor,
14
16
  border: `1px solid`,
15
17
  borderColor: variant === 'error'
16
18
  ? theme.palette.error.main
17
19
  : variant === 'selected'
18
- ? theme.palette.primary.main
20
+ ? selectionColor === 'primary'
21
+ ? theme.palette.primary.main
22
+ : alpha(theme.palette.secondary.main, 0.48)
19
23
  : theme.palette.mode === 'light'
20
24
  ? theme.palette.grey[300]
21
25
  : theme.palette.grey[800],
@@ -32,7 +36,7 @@ export const Card = styled(Box, {
32
36
  ? theme.palette.mode === 'light'
33
37
  ? darken(backgroundColor, 0.02)
34
38
  : lighten(backgroundColor, 0.02)
35
- : theme.palette.background.paper,
39
+ : backgroundColor,
36
40
  },
37
41
  transition: theme.transitions.create(['background-color'], {
38
42
  duration: theme.transitions.duration.enteringScreen,
@@ -3,7 +3,7 @@ import { Avatar, Box, Skeleton, Typography } from '@mui/material';
3
3
  import { useWatch } from 'react-hook-form';
4
4
  import { useNavigate } from 'react-router-dom';
5
5
  import { SwapFormKeyHelper } from '../../providers';
6
- import { maxChainToOrder } from '../../stores/chains';
6
+ import { maxChainToOrder } from '../../stores';
7
7
  import { navigationRoutes } from '../../utils';
8
8
  import { ChainCard, ChainContainer } from './ChainSelect.style';
9
9
  import { useChainSelect } from './useChainSelect';
@@ -8,6 +8,7 @@ export declare const ChainCard: import("@emotion/styled").StyledComponent<import
8
8
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
9
9
  }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
10
10
  variant?: ("default" | "error" | "selected") | undefined;
11
+ selectionColor?: "primary" | "secondary" | undefined;
11
12
  dense?: boolean | undefined;
12
13
  indented?: boolean | undefined;
13
14
  onClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
@@ -4,12 +4,12 @@ import { Card } from '../../components/Card';
4
4
  export const ChainCard = styled(Card)({
5
5
  display: 'grid',
6
6
  placeItems: 'center',
7
- minWidth: 56,
7
+ minWidth: 52,
8
8
  height: 56,
9
9
  });
10
10
  export const ChainContainer = styled(Box)(({ theme }) => ({
11
11
  display: 'grid',
12
- gridTemplateColumns: 'repeat(auto-fit, minmax(56px, 1fr))',
12
+ gridTemplateColumns: 'repeat(auto-fit, minmax(52px, 1fr))',
13
13
  gridAutoRows: '56px',
14
14
  justifyContent: 'space-between',
15
15
  gap: theme.spacing(1.5),
@@ -1,7 +1,7 @@
1
1
  import { useFormContext } from 'react-hook-form';
2
2
  import { useChains } from '../../hooks';
3
3
  import { SwapFormKey, SwapFormKeyHelper } from '../../providers';
4
- import { useChainOrder } from '../../stores/chains';
4
+ import { useChainOrder } from '../../stores';
5
5
  export const useChainSelect = (formType) => {
6
6
  const { setValue } = useFormContext();
7
7
  const { chains, isLoading } = useChains();
@@ -14,12 +14,14 @@ import { WarningAmber as WarningIcon } from '@mui/icons-material';
14
14
  import { Box, Typography } from '@mui/material';
15
15
  import { useTranslation } from 'react-i18next';
16
16
  import { useGasSufficiency } from '../../hooks';
17
+ import { useSelectedRouteStore } from '../../stores';
17
18
  import { CardTitle } from '../Card';
18
19
  import { MessageCard } from './GasSufficiencyMessage.style';
19
20
  export const GasSufficiencyMessage = (_a) => {
20
21
  var { route } = _a, props = __rest(_a, ["route"]);
21
22
  const { t } = useTranslation();
22
- const { insufficientFunds, insufficientGas } = useGasSufficiency(route);
23
+ const selectedRoute = useSelectedRouteStore((state) => state.selectedRoute);
24
+ const { insufficientFunds, insufficientGas } = useGasSufficiency(route !== null && route !== void 0 ? route : selectedRoute);
23
25
  if (!insufficientFunds && !(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)) {
24
26
  return null;
25
27
  }
@@ -31,7 +33,9 @@ export const GasSufficiencyMessage = (_a) => {
31
33
  : null }))) : null, (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pt: 1 }, { children: t(`swap.warning.message.insufficientGas`) }))) : null, (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)
32
34
  ? insufficientGas.map((item, index) => {
33
35
  var _a, _b;
34
- return (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: insufficientGas.length - 1 === index ? 2 : 0, pt: 0.5 }, { children: t(`swap.tokenOnChainAmount`, {
36
+ return (_jsx(Typography
37
+ // eslint-disable-next-line react/no-array-index-key
38
+ , Object.assign({ variant: "body2", px: 2, pb: insufficientGas.length - 1 === index ? 2 : 0, pt: 0.5 }, { children: t(`swap.tokenOnChainAmount`, {
35
39
  amount: (_a = item.insufficientAmount) === null || _a === void 0 ? void 0 : _a.toString(),
36
40
  tokenSymbol: item.token.symbol,
37
41
  chainName: (_b = item.chain) === null || _b === void 0 ? void 0 : _b.name,
@@ -1,2 +1,3 @@
1
- import type { FC } from 'react';
1
+ import type { FC, PropsWithChildren } from 'react';
2
+ export declare const HeaderContainer: FC<PropsWithChildren<{}>>;
2
3
  export declare const Header: FC;
@@ -5,7 +5,7 @@ import { ElementId, stickyHeaderRoutes } from '../../utils';
5
5
  import { Container } from './Header.style';
6
6
  import { NavigationHeader } from './NavigationHeader';
7
7
  import { WalletHeader } from './WalletHeader';
8
- const HeaderContainer = ({ children }) => {
8
+ export const HeaderContainer = ({ children }) => {
9
9
  const { pathname } = useLocation();
10
10
  return (_jsx(Container, Object.assign({ id: ElementId.Header, sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
11
11
  };
@@ -1,7 +1,7 @@
1
1
  import { AppBar, Box } from '@mui/material';
2
- import { styled } from '@mui/material/styles';
2
+ import { alpha, styled } from '@mui/material/styles';
3
3
  export const HeaderAppBar = styled(AppBar)(({ theme }) => ({
4
- backgroundColor: theme.palette.background.default,
4
+ backgroundColor: 'transparent',
5
5
  color: theme.palette.text.primary,
6
6
  flexDirection: 'row',
7
7
  alignItems: 'center',
@@ -16,7 +16,8 @@ export const HeaderAppBar = styled(AppBar)(({ theme }) => ({
16
16
  export const Container = styled(Box, {
17
17
  shouldForwardProp: (prop) => prop !== 'sticky',
18
18
  })(({ theme, sticky }) => ({
19
- backgroundColor: theme.palette.background.default,
19
+ backgroundColor: alpha(theme.palette.background.default, 0.84),
20
+ backdropFilter: 'blur(12px)',
20
21
  position: sticky ? 'sticky' : 'relative',
21
22
  top: 0,
22
23
  zIndex: 1200,
@@ -14,7 +14,10 @@ export const NavigationHeader = () => {
14
14
  const { account } = useWallet();
15
15
  const { element } = useHeaderActionStore();
16
16
  const { pathname } = useLocation();
17
- const path = pathname.substring(pathname.lastIndexOf('/') + 1);
17
+ const cleanedPathname = pathname.endsWith('/')
18
+ ? pathname.slice(0, -1)
19
+ : pathname;
20
+ const path = cleanedPathname.substring(cleanedPathname.lastIndexOf('/') + 1);
18
21
  const hasPath = navigationRoutesValues.includes(path);
19
22
  const handleHeaderTitle = () => {
20
23
  switch (path) {
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
- import { AccountBalanceWalletOutlined as AccountBalanceWalletIcon, Logout as LogoutIcon, } from '@mui/icons-material';
11
+ import { Logout as LogoutIcon, WalletOutlined as WalletOutlinedIcon, } from '@mui/icons-material';
12
12
  import { Box, IconButton, Typography } from '@mui/material';
13
13
  import { useTranslation } from 'react-i18next';
14
14
  import { useLocation, useNavigate } from 'react-router-dom';
@@ -39,5 +39,5 @@ const ConnectButton = () => {
39
39
  }
40
40
  navigate(navigationRoutes.selectWallet);
41
41
  });
42
- return (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "disconnect", edge: "end", onClick: !pathname.includes(navigationRoutes.selectWallet) ? connect : undefined }, { children: _jsx(AccountBalanceWalletIcon, {}) })));
42
+ return (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "disconnect", edge: "end", onClick: !pathname.includes(navigationRoutes.selectWallet) ? connect : undefined }, { children: _jsx(WalletOutlinedIcon, {}) })));
43
43
  };
@@ -1,9 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Tooltip, Typography } from '@mui/material';
3
+ import { useLocation } from 'react-router-dom';
3
4
  import { version } from '../../config/version';
5
+ import { navigationRoutes } from '../../utils';
4
6
  import { LiFiLogo } from '../LiFiLogo';
5
7
  import { Link } from './PoweredBy.style';
6
8
  export const PoweredBy = () => {
9
+ const { pathname } = useLocation();
10
+ if (pathname.includes(navigationRoutes.fromToken) ||
11
+ pathname.includes(navigationRoutes.toToken)) {
12
+ return null;
13
+ }
7
14
  return (_jsx(Box, Object.assign({ px: 3, pt: 2, pb: 2, sx: {
8
15
  display: 'flex',
9
16
  alignItems: 'flex-end',
@@ -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
+ }
@@ -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,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,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
  };