@lifi/widget 1.1.1 → 1.2.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 (138) hide show
  1. package/App.js +2 -1
  2. package/AppDrawer.d.ts +1 -1
  3. package/AppProvider.d.ts +1 -1
  4. package/AppProvider.js +7 -2
  5. package/components/Header/Header.js +1 -1
  6. package/components/Header/NavigationHeader.js +5 -3
  7. package/components/Header/WalletHeader.js +1 -1
  8. package/components/Initializer.d.ts +2 -0
  9. package/components/Initializer.js +5 -0
  10. package/components/StepToken.js +1 -1
  11. package/components/SwapButton/SwapButton.js +5 -2
  12. package/components/SwapInProgress/SwapInProgress.js +1 -1
  13. package/components/SwapRoutes/SwapRoutes.js +2 -1
  14. package/components/TextFitter/TextFitter.js +9 -5
  15. package/fonts/Inter-Black.woff +0 -0
  16. package/fonts/Inter-Black.woff2 +0 -0
  17. package/fonts/Inter-BlackItalic.woff +0 -0
  18. package/fonts/Inter-BlackItalic.woff2 +0 -0
  19. package/fonts/Inter-Bold.woff +0 -0
  20. package/fonts/Inter-Bold.woff2 +0 -0
  21. package/fonts/Inter-BoldItalic.woff +0 -0
  22. package/fonts/Inter-BoldItalic.woff2 +0 -0
  23. package/fonts/Inter-ExtraBold.woff +0 -0
  24. package/fonts/Inter-ExtraBold.woff2 +0 -0
  25. package/fonts/Inter-ExtraBoldItalic.woff +0 -0
  26. package/fonts/Inter-ExtraBoldItalic.woff2 +0 -0
  27. package/fonts/Inter-ExtraLight.woff +0 -0
  28. package/fonts/Inter-ExtraLight.woff2 +0 -0
  29. package/fonts/Inter-ExtraLightItalic.woff +0 -0
  30. package/fonts/Inter-ExtraLightItalic.woff2 +0 -0
  31. package/fonts/Inter-Italic.woff +0 -0
  32. package/fonts/Inter-Italic.woff2 +0 -0
  33. package/fonts/Inter-Light.woff +0 -0
  34. package/fonts/Inter-Light.woff2 +0 -0
  35. package/fonts/Inter-LightItalic.woff +0 -0
  36. package/fonts/Inter-LightItalic.woff2 +0 -0
  37. package/fonts/Inter-Medium.woff +0 -0
  38. package/fonts/Inter-Medium.woff2 +0 -0
  39. package/fonts/Inter-MediumItalic.woff +0 -0
  40. package/fonts/Inter-MediumItalic.woff2 +0 -0
  41. package/fonts/Inter-Regular.woff +0 -0
  42. package/fonts/Inter-Regular.woff2 +0 -0
  43. package/fonts/Inter-SemiBold.woff +0 -0
  44. package/fonts/Inter-SemiBold.woff2 +0 -0
  45. package/fonts/Inter-SemiBoldItalic.woff +0 -0
  46. package/fonts/Inter-SemiBoldItalic.woff2 +0 -0
  47. package/fonts/Inter-Thin.woff +0 -0
  48. package/fonts/Inter-Thin.woff2 +0 -0
  49. package/fonts/Inter-ThinItalic.woff +0 -0
  50. package/fonts/Inter-ThinItalic.woff2 +0 -0
  51. package/fonts/Inter-italic.var.woff2 +0 -0
  52. package/fonts/Inter-roman.var.woff2 +0 -0
  53. package/fonts/Inter.var.woff2 +0 -0
  54. package/fonts/inter.css +200 -0
  55. package/hooks/index.d.ts +1 -3
  56. package/hooks/index.js +1 -3
  57. package/hooks/useContentHeight.js +18 -10
  58. package/hooks/useHasSufficientBalance.js +1 -1
  59. package/hooks/useInitializer.d.ts +1 -0
  60. package/hooks/useInitializer.js +5 -0
  61. package/hooks/{useRouteExecution/useRouteExecution.d.ts → useRouteExecution.d.ts} +1 -1
  62. package/hooks/{useRouteExecution/useRouteExecution.js → useRouteExecution.js} +5 -5
  63. package/hooks/useSwapRoutes.js +9 -7
  64. package/hooks/useTools.d.ts +1 -0
  65. package/hooks/useTools.js +14 -0
  66. package/i18n/en/translation.json +134 -136
  67. package/i18n/index.d.ts +0 -2
  68. package/icons/LiFiFullLogo.svg +10 -0
  69. package/icons/LiFiLogo.svg +5 -0
  70. package/package.json +7 -6
  71. package/pages/SelectTokenPage/ChainSelect.js +1 -1
  72. package/pages/SettingsPage/AdvancedPreferences.js +5 -4
  73. package/pages/SettingsPage/ColorSchemeButtonGroup.js +1 -1
  74. package/pages/SettingsPage/EnabledBridgesSelect.js +11 -6
  75. package/pages/SettingsPage/EnabledExchangesSelect.js +10 -6
  76. package/pages/SettingsPage/GasPriceSelect.js +4 -4
  77. package/pages/SettingsPage/RoutePrioritySelect.js +4 -4
  78. package/pages/SettingsPage/SlippageInput.js +7 -10
  79. package/pages/SwapPage/ExecutionItem.js +1 -1
  80. package/pages/SwapPage/StatusBottomSheet.d.ts +1 -1
  81. package/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
  82. package/pages/SwapPage/StepItem.js +1 -1
  83. package/pages/SwapPage/StepTimer.js +3 -2
  84. package/pages/SwapRoutesPage/SwapRoutesPage.js +2 -1
  85. package/providers/SwapFormProvider/SwapFormProvider.d.ts +0 -3
  86. package/providers/SwapFormProvider/SwapFormProvider.js +0 -3
  87. package/providers/SwapFormProvider/types.d.ts +0 -19
  88. package/providers/SwapFormProvider/types.js +0 -9
  89. package/providers/ThemeProvider/ThemeProvider.js +1 -1
  90. package/providers/WidgetProvider/WidgetProvider.js +3 -5
  91. package/providers/WidgetProvider/types.d.ts +3 -3
  92. package/stores/index.d.ts +2 -0
  93. package/stores/index.js +2 -0
  94. package/stores/route/index.d.ts +5 -0
  95. package/stores/route/index.js +5 -0
  96. package/{hooks/useRouteExecution → stores/route}/types.d.ts +0 -0
  97. package/{hooks/useRouteExecution → stores/route}/types.js +0 -0
  98. package/stores/route/useCurrentRoute.d.ts +2 -0
  99. package/stores/route/useCurrentRoute.js +5 -0
  100. package/stores/route/useExecutingRoutes.d.ts +1 -0
  101. package/stores/route/useExecutingRoutes.js +4 -0
  102. package/{hooks/useRouteExecution → stores/route}/useRouteStore.d.ts +3 -5
  103. package/{hooks/useRouteExecution → stores/route}/useRouteStore.js +16 -26
  104. package/stores/route/useSetExecutableRoute.d.ts +1 -0
  105. package/stores/route/useSetExecutableRoute.js +4 -0
  106. package/stores/settings/index.d.ts +5 -0
  107. package/stores/settings/index.js +5 -0
  108. package/stores/settings/types.d.ts +23 -0
  109. package/stores/settings/types.js +1 -0
  110. package/stores/settings/useAppearance.d.ts +2 -0
  111. package/stores/settings/useAppearance.js +7 -0
  112. package/stores/settings/useSetSettings.d.ts +5 -0
  113. package/stores/settings/useSetSettings.js +5 -0
  114. package/stores/settings/useSettings.d.ts +2 -0
  115. package/stores/settings/useSettings.js +8 -0
  116. package/stores/settings/useSettingsStore.d.ts +25 -0
  117. package/stores/settings/useSettingsStore.js +84 -0
  118. package/types/widget.d.ts +31 -23
  119. package/utils/format.d.ts +1 -1
  120. package/utils/format.js +1 -1
  121. package/utils/routes.d.ts +1 -0
  122. package/utils/routes.js +7 -6
  123. package/hooks/useBridges.d.ts +0 -1
  124. package/hooks/useBridges.js +0 -12
  125. package/hooks/useExchanges.d.ts +0 -1
  126. package/hooks/useExchanges.js +0 -12
  127. package/hooks/useRouteExecution/index.d.ts +0 -3
  128. package/hooks/useRouteExecution/index.js +0 -3
  129. package/hooks/useSettings/index.d.ts +0 -2
  130. package/hooks/useSettings/index.js +0 -2
  131. package/hooks/useSettings/types.d.ts +0 -5
  132. package/hooks/useSettings/types.js +0 -1
  133. package/hooks/useSettings/useSettingsStore.d.ts +0 -13
  134. package/hooks/useSettings/useSettingsStore.js +0 -22
  135. package/i18n/react-i18next.d.ts +0 -9
  136. package/pages/MainPage/SendToRecipientForm.d.ts +0 -2
  137. package/pages/MainPage/SendToRecipientForm.js +0 -20
  138. package/react-app-env.d.ts +0 -1
package/App.js CHANGED
@@ -3,6 +3,7 @@ import { Route, Routes } from 'react-router-dom';
3
3
  import { AppProvider } from './AppProvider';
4
4
  import { AppContainer } from './components/AppContainer';
5
5
  import { Header } from './components/Header';
6
+ import { Initializer } from './components/Initializer';
6
7
  import { MainPage } from './pages/MainPage';
7
8
  import { SelectTokenPage } from './pages/SelectTokenPage';
8
9
  import { SelectWalletPage } from './pages/SelectWalletPage';
@@ -14,5 +15,5 @@ export const App = ({ config }) => {
14
15
  return (_jsx(AppProvider, Object.assign({ config: config }, { children: _jsx(AppDefault, {}) })));
15
16
  };
16
17
  export const AppDefault = () => {
17
- return (_jsxs(AppContainer, { children: [_jsx(Header, {}), _jsxs(Routes, { children: [_jsx(Route, { path: routes.home, element: _jsx(MainPage, {}) }), _jsx(Route, { path: routes.selectWallet, element: _jsx(SelectWalletPage, {}) }), _jsx(Route, { path: routes.settings, element: _jsx(SettingsPage, {}) }), _jsx(Route, { path: routes.fromToken, element: _jsx(SelectTokenPage, { formType: "from" }) }), _jsx(Route, { path: routes.toToken, element: _jsx(SelectTokenPage, { formType: "to" }) }), _jsx(Route, { path: routes.swapRoutes, element: _jsx(SwapRoutesPage, {}) }), _jsx(Route, { path: routes.swap, element: _jsx(SwapPage, {}) })] })] }));
18
+ return (_jsxs(AppContainer, { children: [_jsx(Header, {}), _jsxs(Routes, { children: [_jsx(Route, { path: routes.home, element: _jsx(MainPage, {}) }), _jsx(Route, { path: routes.selectWallet, element: _jsx(SelectWalletPage, {}) }), _jsx(Route, { path: routes.settings, element: _jsx(SettingsPage, {}) }), _jsx(Route, { path: routes.fromToken, element: _jsx(SelectTokenPage, { formType: "from" }) }), _jsx(Route, { path: routes.toToken, element: _jsx(SelectTokenPage, { formType: "to" }) }), _jsx(Route, { path: routes.swapRoutes, element: _jsx(SwapRoutesPage, {}) }), _jsx(Route, { path: `${routes.swapRoutes}/${routes.swap}`, element: _jsx(SwapPage, {}) }), _jsx(Route, { path: routes.swap, element: _jsx(SwapPage, {}) })] }), _jsx(Initializer, {})] }));
18
19
  };
package/AppDrawer.d.ts CHANGED
@@ -3,7 +3,7 @@ import { RefObject } from 'react';
3
3
  import { WidgetConfig } from './types';
4
4
  export declare type AppDrawerProps = DrawerProps & {
5
5
  elementRef?: RefObject<HTMLDivElement>;
6
- config: WidgetConfig;
6
+ config?: WidgetConfig;
7
7
  };
8
8
  export interface AppDrawerBase {
9
9
  isOpen(): void;
package/AppProvider.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { WidgetConfig } from '.';
3
3
  export interface AppProps {
4
- config: WidgetConfig;
4
+ config?: WidgetConfig;
5
5
  }
6
6
  export declare const AppProvider: React.FC<PropsWithChildren<AppProps>>;
package/AppProvider.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* eslint-disable camelcase */
3
+ /* eslint-disable react/jsx-pascal-case */
4
+ import { Fragment } from 'react';
2
5
  import { QueryClientProvider } from 'react-query';
3
- import { MemoryRouter } from 'react-router-dom';
6
+ import { MemoryRouter, useInRouterContext } from 'react-router-dom';
4
7
  import { queryClient } from './config/queryClient';
5
8
  import { SwapFormProvider } from './providers/SwapFormProvider';
6
9
  import { ThemeProvider } from './providers/ThemeProvider';
@@ -8,5 +11,7 @@ import { WalletProvider } from './providers/WalletProvider';
8
11
  import { WidgetProvider } from './providers/WidgetProvider';
9
12
  const QueryProvider = QueryClientProvider;
10
13
  export const AppProvider = ({ children, config, }) => {
11
- return (_jsx(WidgetProvider, Object.assign({ config: config }, { children: _jsx(ThemeProvider, { children: _jsx(QueryProvider, Object.assign({ client: queryClient }, { children: _jsx(MemoryRouter, { children: _jsx(WalletProvider, { children: _jsx(SwapFormProvider, { children: children }) }) }) })) }) })));
14
+ const inRouterContext = useInRouterContext();
15
+ const Router = inRouterContext ? Fragment : MemoryRouter;
16
+ return (_jsx(WidgetProvider, Object.assign({ config: config }, { children: _jsx(ThemeProvider, { children: _jsx(QueryProvider, Object.assign({ client: queryClient }, { children: _jsx(Router, { children: _jsx(WalletProvider, { children: _jsx(SwapFormProvider, { children: children }) }) }) })) }) })));
12
17
  };
@@ -12,6 +12,6 @@ const stickyHeaderRoutes = [
12
12
  ];
13
13
  const HeaderContainer = ({ children }) => {
14
14
  const { pathname } = useLocation();
15
- return (_jsx(Container, Object.assign({ id: ElementId.Header, sticky: stickyHeaderRoutes.includes(pathname) }, { children: children })));
15
+ return (_jsx(Container, Object.assign({ id: ElementId.Header, sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
16
16
  };
17
17
  export const Header = () => (_jsxs(HeaderContainer, { children: [_jsx(WalletHeader, {}), _jsx(NavigationHeader, {})] }));
@@ -3,7 +3,7 @@ import { ArrowBack as ArrowBackIcon, Settings as SettingsIcon, } from '@mui/icon
3
3
  import { Box, IconButton, Typography } from '@mui/material';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
6
- import { routes } from '../../utils/routes';
6
+ import { routes, routesValues } from '../../utils/routes';
7
7
  import { SwapRoutesUpdateProgress } from '../SwapRoutes/SwapRoutesUpdateProgress';
8
8
  import { HeaderAppBar } from './Header.style';
9
9
  const backButtonRoutes = [
@@ -17,6 +17,8 @@ const backButtonRoutes = [
17
17
  export const NavigationHeader = () => {
18
18
  const { t } = useTranslation();
19
19
  const { pathname } = useLocation();
20
+ const path = pathname.substring(pathname.lastIndexOf('/') + 1);
21
+ const hasPath = routesValues.includes(path);
20
22
  const navigate = useNavigate();
21
23
  const handleSettings = () => {
22
24
  navigate(routes.settings);
@@ -25,7 +27,7 @@ export const NavigationHeader = () => {
25
27
  navigate(-1);
26
28
  };
27
29
  const handleHeaderTitle = () => {
28
- switch (pathname) {
30
+ switch (path) {
29
31
  case routes.selectWallet:
30
32
  return t(`header.selectWallet`);
31
33
  case routes.settings:
@@ -42,5 +44,5 @@ export const NavigationHeader = () => {
42
44
  return t(`header.swap`);
43
45
  }
44
46
  };
45
- return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(pathname) ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: handleBack }, { children: _jsx(ArrowBackIcon, {}) }))) : null, _jsx(Typography, Object.assign({ fontSize: pathname === '/' ? 32 : 24, align: pathname === '/' ? 'left' : 'center', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: routes.swapRoutes, element: _jsx(SwapRoutesUpdateProgress, { size: "medium", edge: "end", sx: { marginRight: -1 } }) }), _jsx(Route, { path: routes.home, element: _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: handleSettings }, { children: _jsx(SettingsIcon, {}) })) }), _jsx(Route, { path: "/:empty", element: _jsx(Box, { width: 36, height: 48 }) })] })] })));
47
+ return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: handleBack }, { children: _jsx(ArrowBackIcon, {}) }))) : null, _jsx(Typography, Object.assign({ fontSize: hasPath ? 24 : 32, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: routes.swapRoutes, element: _jsx(SwapRoutesUpdateProgress, { size: "medium", edge: "end", sx: { marginRight: -1 } }) }), _jsx(Route, { path: routes.home, element: _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: handleSettings }, { children: _jsx(SettingsIcon, {}) })) }), _jsx(Route, { path: "/:empty", element: _jsx(Box, { width: 28, height: 48 }) })] })] })));
46
48
  };
@@ -24,5 +24,5 @@ const ConnectButton = () => {
24
24
  const connect = () => {
25
25
  navigate(routes.selectWallet);
26
26
  };
27
- return (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "disconnect", edge: "end", onClick: pathname !== routes.selectWallet ? connect : undefined }, { children: _jsx(AccountBalanceWalletIcon, {}) })));
27
+ return (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "disconnect", edge: "end", onClick: !pathname.includes(routes.selectWallet) ? connect : undefined }, { children: _jsx(AccountBalanceWalletIcon, {}) })));
28
28
  };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const Initializer: React.FC;
@@ -0,0 +1,5 @@
1
+ import { useInitializer } from '../hooks/useInitializer';
2
+ export const Initializer = () => {
3
+ useInitializer();
4
+ return null;
5
+ };
@@ -15,7 +15,7 @@ import { formatTokenAmount } from '../utils/format';
15
15
  import { TextFitter } from './TextFitter';
16
16
  export const StepToken = (_a) => {
17
17
  var { token } = _a, other = __rest(_a, ["token"]);
18
- return (_jsxs(Box, Object.assign({ flex: 1 }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", flex: 1 }, { children: [_jsx(Avatar, Object.assign({ src: token.logoURI, alt: token.symbol, sx: { marginRight: 2 } }, { children: token.symbol[0] })), _jsx(TextFitter, Object.assign({ maxHeight: 32, textStyle: {
18
+ return (_jsxs(Box, Object.assign({ flex: 1 }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", flex: 1 }, { children: [_jsx(Avatar, Object.assign({ src: token.logoURI, alt: token.symbol, sx: { marginRight: 2 } }, { children: token.symbol[0] })), _jsx(TextFitter, Object.assign({ height: 32, textStyle: {
19
19
  fontWeight: 700,
20
20
  } }, { children: formatTokenAmount(token.amount, token.decimals) }))] })), _jsx(Typography, Object.assign({ fontSize: 14, lineHeight: 1, fontWeight: "500", color: "text.secondary", mr: 1, ml: 6 }, { children: token.symbol }))] })));
21
21
  };
@@ -12,9 +12,10 @@ import { ChainId } from '@lifinance/sdk';
12
12
  import { useWatch } from 'react-hook-form';
13
13
  import { useTranslation } from 'react-i18next';
14
14
  import { useNavigate } from 'react-router-dom';
15
- import { useChains, useCurrentRoute, useHasSufficientBalance, useSetExecutableRoute, useSwapRoutes, } from '../../hooks';
15
+ import { useChains, useHasSufficientBalance, useSwapRoutes } from '../../hooks';
16
16
  import { SwapFormKeyHelper } from '../../providers/SwapFormProvider';
17
17
  import { useWallet } from '../../providers/WalletProvider';
18
+ import { useCurrentRoute, useSetExecutableRoute } from '../../stores';
18
19
  import { routes } from '../../utils/routes';
19
20
  import { ButtonTooltip } from './ButtonTooltip';
20
21
  import { Button } from './SwapButton.style';
@@ -43,7 +44,9 @@ export const SwapButton = () => {
43
44
  else if (currentRoute &&
44
45
  (swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.some((route) => route.id === currentRoute.id))) {
45
46
  setExecutableRoute(currentRoute);
46
- navigate(routes.swap, { state: { routeId: currentRoute.id } });
47
+ navigate(routes.swap, {
48
+ state: { routeId: currentRoute.id },
49
+ });
47
50
  }
48
51
  });
49
52
  const getButtonText = () => {
@@ -4,7 +4,7 @@ import { AvatarGroup, Box, Stack } from '@mui/material';
4
4
  import { useCallback } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { useNavigate } from 'react-router-dom';
7
- import { useExecutingRoutes } from '../../hooks';
7
+ import { useExecutingRoutes } from '../../stores';
8
8
  import { routes } from '../../utils/routes';
9
9
  import { CardTitle } from '../Card';
10
10
  import { Card, RouteAvatar, RouteCard } from './SwapInProgress.style';
@@ -5,7 +5,8 @@ import { Box, IconButton, Skeleton } from '@mui/material';
5
5
  import { useCallback } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { useNavigate } from 'react-router-dom';
8
- import { useCurrentRoute, useSwapRoutes } from '../../hooks';
8
+ import { useSwapRoutes } from '../../hooks';
9
+ import { useCurrentRoute } from '../../stores';
9
10
  import { routes } from '../../utils/routes';
10
11
  import { CardContainer, CardTitle } from '../Card';
11
12
  import { SwapRouteCard } from '../SwapRouteCard';
@@ -11,7 +11,7 @@ export const TextFitter = ({ children, width = '100%', height, maxHeight, preser
11
11
  const theme = useTheme();
12
12
  const textRef = useRef(null);
13
13
  const [viewBox, setViewBox] = useState(initialState);
14
- const [textRect, setTextRect] = useState(initialState);
14
+ // const [textRect, setTextRect] = useState<Partial<DOMRect>>(initialState);
15
15
  const calculateBox = useCallback(() => {
16
16
  if (!textRef.current) {
17
17
  return;
@@ -25,7 +25,7 @@ export const TextFitter = ({ children, width = '100%', height, maxHeight, preser
25
25
  box.height -= box.height * cropBottom;
26
26
  }
27
27
  setViewBox(box);
28
- setTextRect(textRef.current.getBoundingClientRect());
28
+ // setTextRect(textRef.current.getBoundingClientRect());
29
29
  onFit === null || onFit === void 0 ? void 0 : onFit();
30
30
  }, [cropBottom, cropTop, onFit]);
31
31
  useLayoutEffect(() => {
@@ -38,7 +38,11 @@ export const TextFitter = ({ children, width = '100%', height, maxHeight, preser
38
38
  });
39
39
  }
40
40
  }, [calculateBox]);
41
- return (_jsx("svg", Object.assign({ style: svgStyle, viewBox: `${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}`, width: width, height: textRect.height && maxHeight && textRect.height >= maxHeight
42
- ? maxHeight
43
- : height, preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary }, { children: _jsx("text", Object.assign({ x: 0, y: 0, style: textStyle, ref: textRef }, { children: children })) })));
41
+ return (_jsx("svg", Object.assign({ style: svgStyle, viewBox: `${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}`, width: width, height: height,
42
+ // height={
43
+ // textRect.height && maxHeight && textRect.height >= maxHeight
44
+ // ? maxHeight
45
+ // : height
46
+ // }
47
+ preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary }, { children: _jsx("text", Object.assign({ x: 0, y: 0, style: textStyle, ref: textRef }, { children: children })) })));
44
48
  };
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,200 @@
1
+ @font-face {
2
+ font-family: 'Inter';
3
+ font-style: normal;
4
+ font-weight: 100;
5
+ font-display: swap;
6
+ src: url("Inter-Thin.woff2?v=3.19") format("woff2"),
7
+ url("Inter-Thin.woff?v=3.19") format("woff");
8
+ }
9
+ @font-face {
10
+ font-family: 'Inter';
11
+ font-style: italic;
12
+ font-weight: 100;
13
+ font-display: swap;
14
+ src: url("Inter-ThinItalic.woff2?v=3.19") format("woff2"),
15
+ url("Inter-ThinItalic.woff?v=3.19") format("woff");
16
+ }
17
+
18
+ @font-face {
19
+ font-family: 'Inter';
20
+ font-style: normal;
21
+ font-weight: 200;
22
+ font-display: swap;
23
+ src: url("Inter-ExtraLight.woff2?v=3.19") format("woff2"),
24
+ url("Inter-ExtraLight.woff?v=3.19") format("woff");
25
+ }
26
+ @font-face {
27
+ font-family: 'Inter';
28
+ font-style: italic;
29
+ font-weight: 200;
30
+ font-display: swap;
31
+ src: url("Inter-ExtraLightItalic.woff2?v=3.19") format("woff2"),
32
+ url("Inter-ExtraLightItalic.woff?v=3.19") format("woff");
33
+ }
34
+
35
+ @font-face {
36
+ font-family: 'Inter';
37
+ font-style: normal;
38
+ font-weight: 300;
39
+ font-display: swap;
40
+ src: url("Inter-Light.woff2?v=3.19") format("woff2"),
41
+ url("Inter-Light.woff?v=3.19") format("woff");
42
+ }
43
+ @font-face {
44
+ font-family: 'Inter';
45
+ font-style: italic;
46
+ font-weight: 300;
47
+ font-display: swap;
48
+ src: url("Inter-LightItalic.woff2?v=3.19") format("woff2"),
49
+ url("Inter-LightItalic.woff?v=3.19") format("woff");
50
+ }
51
+
52
+ @font-face {
53
+ font-family: 'Inter';
54
+ font-style: normal;
55
+ font-weight: 400;
56
+ font-display: swap;
57
+ src: url("Inter-Regular.woff2?v=3.19") format("woff2"),
58
+ url("Inter-Regular.woff?v=3.19") format("woff");
59
+ }
60
+ @font-face {
61
+ font-family: 'Inter';
62
+ font-style: italic;
63
+ font-weight: 400;
64
+ font-display: swap;
65
+ src: url("Inter-Italic.woff2?v=3.19") format("woff2"),
66
+ url("Inter-Italic.woff?v=3.19") format("woff");
67
+ }
68
+
69
+ @font-face {
70
+ font-family: 'Inter';
71
+ font-style: normal;
72
+ font-weight: 500;
73
+ font-display: swap;
74
+ src: url("Inter-Medium.woff2?v=3.19") format("woff2"),
75
+ url("Inter-Medium.woff?v=3.19") format("woff");
76
+ }
77
+ @font-face {
78
+ font-family: 'Inter';
79
+ font-style: italic;
80
+ font-weight: 500;
81
+ font-display: swap;
82
+ src: url("Inter-MediumItalic.woff2?v=3.19") format("woff2"),
83
+ url("Inter-MediumItalic.woff?v=3.19") format("woff");
84
+ }
85
+
86
+ @font-face {
87
+ font-family: 'Inter';
88
+ font-style: normal;
89
+ font-weight: 600;
90
+ font-display: swap;
91
+ src: url("Inter-SemiBold.woff2?v=3.19") format("woff2"),
92
+ url("Inter-SemiBold.woff?v=3.19") format("woff");
93
+ }
94
+ @font-face {
95
+ font-family: 'Inter';
96
+ font-style: italic;
97
+ font-weight: 600;
98
+ font-display: swap;
99
+ src: url("Inter-SemiBoldItalic.woff2?v=3.19") format("woff2"),
100
+ url("Inter-SemiBoldItalic.woff?v=3.19") format("woff");
101
+ }
102
+
103
+ @font-face {
104
+ font-family: 'Inter';
105
+ font-style: normal;
106
+ font-weight: 700;
107
+ font-display: swap;
108
+ src: url("Inter-Bold.woff2?v=3.19") format("woff2"),
109
+ url("Inter-Bold.woff?v=3.19") format("woff");
110
+ }
111
+ @font-face {
112
+ font-family: 'Inter';
113
+ font-style: italic;
114
+ font-weight: 700;
115
+ font-display: swap;
116
+ src: url("Inter-BoldItalic.woff2?v=3.19") format("woff2"),
117
+ url("Inter-BoldItalic.woff?v=3.19") format("woff");
118
+ }
119
+
120
+ @font-face {
121
+ font-family: 'Inter';
122
+ font-style: normal;
123
+ font-weight: 800;
124
+ font-display: swap;
125
+ src: url("Inter-ExtraBold.woff2?v=3.19") format("woff2"),
126
+ url("Inter-ExtraBold.woff?v=3.19") format("woff");
127
+ }
128
+ @font-face {
129
+ font-family: 'Inter';
130
+ font-style: italic;
131
+ font-weight: 800;
132
+ font-display: swap;
133
+ src: url("Inter-ExtraBoldItalic.woff2?v=3.19") format("woff2"),
134
+ url("Inter-ExtraBoldItalic.woff?v=3.19") format("woff");
135
+ }
136
+
137
+ @font-face {
138
+ font-family: 'Inter';
139
+ font-style: normal;
140
+ font-weight: 900;
141
+ font-display: swap;
142
+ src: url("Inter-Black.woff2?v=3.19") format("woff2"),
143
+ url("Inter-Black.woff?v=3.19") format("woff");
144
+ }
145
+ @font-face {
146
+ font-family: 'Inter';
147
+ font-style: italic;
148
+ font-weight: 900;
149
+ font-display: swap;
150
+ src: url("Inter-BlackItalic.woff2?v=3.19") format("woff2"),
151
+ url("Inter-BlackItalic.woff?v=3.19") format("woff");
152
+ }
153
+
154
+ /* -------------------------------------------------------
155
+ Variable font.
156
+ Usage:
157
+
158
+ html { font-family: 'Inter', sans-serif; }
159
+ @supports (font-variation-settings: normal) {
160
+ html { font-family: 'Inter var', sans-serif; }
161
+ }
162
+ */
163
+ @font-face {
164
+ font-family: 'Inter var';
165
+ font-weight: 100 900;
166
+ font-display: swap;
167
+ font-style: normal;
168
+ font-named-instance: 'Regular';
169
+ src: url("Inter-roman.var.woff2?v=3.19") format("woff2");
170
+ }
171
+ @font-face {
172
+ font-family: 'Inter var';
173
+ font-weight: 100 900;
174
+ font-display: swap;
175
+ font-style: italic;
176
+ font-named-instance: 'Italic';
177
+ src: url("Inter-italic.var.woff2?v=3.19") format("woff2");
178
+ }
179
+
180
+
181
+ /* --------------------------------------------------------------------------
182
+ [EXPERIMENTAL] Multi-axis, single variable font.
183
+
184
+ Slant axis is not yet widely supported (as of February 2019) and thus this
185
+ multi-axis single variable font is opt-in rather than the default.
186
+
187
+ When using this, you will probably need to set font-variation-settings
188
+ explicitly, e.g.
189
+
190
+ * { font-variation-settings: "slnt" 0deg }
191
+ .italic { font-variation-settings: "slnt" 10deg }
192
+
193
+ */
194
+ @font-face {
195
+ font-family: 'Inter var experimental';
196
+ font-weight: 100 900;
197
+ font-display: swap;
198
+ font-style: oblique 0deg 10deg;
199
+ src: url("Inter.var.woff2?v=3.19") format("woff2");
200
+ }
package/hooks/index.d.ts CHANGED
@@ -1,15 +1,13 @@
1
- export * from './useBridges';
2
1
  export * from './useChain';
3
2
  export * from './useChains';
4
3
  export * from './useContentHeight';
5
4
  export * from './useDebouncedWatch';
6
- export * from './useExchanges';
7
5
  export * from './useHasSufficientBalance';
8
6
  export * from './useRouteExecution';
9
7
  export * from './useScrollableContainer';
10
- export * from './useSettings';
11
8
  export * from './useSwapRoutes';
12
9
  export * from './useToken';
13
10
  export * from './useTokenBalance';
14
11
  export * from './useTokenBalances';
15
12
  export * from './useTokens';
13
+ export * from './useTools';
package/hooks/index.js CHANGED
@@ -1,15 +1,13 @@
1
- export * from './useBridges';
2
1
  export * from './useChain';
3
2
  export * from './useChains';
4
3
  export * from './useContentHeight';
5
4
  export * from './useDebouncedWatch';
6
- export * from './useExchanges';
7
5
  export * from './useHasSufficientBalance';
8
6
  export * from './useRouteExecution';
9
7
  export * from './useScrollableContainer';
10
- export * from './useSettings';
11
8
  export * from './useSwapRoutes';
12
9
  export * from './useToken';
13
10
  export * from './useTokenBalance';
14
11
  export * from './useTokenBalances';
15
12
  export * from './useTokens';
13
+ export * from './useTools';
@@ -1,15 +1,23 @@
1
- import { useState } from 'react';
1
+ import { useLayoutEffect, useState } from 'react';
2
2
  import { ElementId } from '../utils/elements';
3
+ const getContentHeight = () => {
4
+ const headerElement = document.getElementById(ElementId.Header);
5
+ const containerElement = document.getElementById(ElementId.ScrollableContainer);
6
+ if (!containerElement || !headerElement) {
7
+ console.warn(`Can't find ${ElementId.ScrollableContainer} or ${ElementId.Header} id.`);
8
+ return 0;
9
+ }
10
+ const { height: containerHeight } = containerElement.getBoundingClientRect();
11
+ const { height: headerHeight } = headerElement.getBoundingClientRect();
12
+ return containerHeight - headerHeight;
13
+ };
3
14
  export const useContentHeight = () => {
4
- const [contentHeight] = useState(() => {
5
- const headerElement = document.getElementById(ElementId.Header);
6
- const containerElement = document.getElementById(ElementId.ScrollableContainer);
7
- if (!containerElement || !headerElement) {
8
- throw Error(`Can't find ${ElementId.ScrollableContainer} or ${ElementId.Header} id.`);
15
+ const [contentHeight, setContentHeight] = useState(getContentHeight);
16
+ useLayoutEffect(() => {
17
+ if (!contentHeight) {
18
+ setContentHeight(getContentHeight());
9
19
  }
10
- const { height: containerHeight } = containerElement.getBoundingClientRect();
11
- const { height: headerHeight } = headerElement.getBoundingClientRect();
12
- return containerHeight - headerHeight;
13
- });
20
+ // eslint-disable-next-line react-hooks/exhaustive-deps
21
+ }, []);
14
22
  return contentHeight;
15
23
  };
@@ -3,7 +3,7 @@ import Big from 'big.js';
3
3
  import { useMemo } from 'react';
4
4
  import { useWatch } from 'react-hook-form';
5
5
  import { SwapFormKeyHelper } from '../providers/SwapFormProvider';
6
- import { useCurrentRoute } from './useRouteExecution';
6
+ import { useCurrentRoute } from '../stores';
7
7
  import { useTokenBalances } from './useTokenBalances';
8
8
  export const useHasSufficientBalance = () => {
9
9
  var _a;
@@ -0,0 +1 @@
1
+ export declare const useInitializer: () => void;
@@ -0,0 +1,5 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ import { useTools } from './useTools';
3
+ export const useInitializer = () => {
4
+ useTools();
5
+ };
@@ -4,5 +4,5 @@ export declare const useRouteExecution: (routeId: string) => {
4
4
  restartRoute: () => void;
5
5
  removeRoute: () => void;
6
6
  route: Route;
7
- status: import("./types").RouteExecutionStatus;
7
+ status: import("../stores").RouteExecutionStatus;
8
8
  };
@@ -10,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { useCallback, useEffect } from 'react';
11
11
  import { useMutation } from 'react-query';
12
12
  import shallow from 'zustand/shallow';
13
- import { LiFi } from '../../lifi';
14
- import { useWallet } from '../../providers/WalletProvider';
15
- import { deepClone } from '../../utils/deepClone';
16
- import { useRouteStore } from './useRouteStore';
13
+ import { LiFi } from '../lifi';
14
+ import { useWallet } from '../providers/WalletProvider';
15
+ import { useRouteStore } from '../stores';
16
+ import { deepClone } from '../utils/deepClone';
17
17
  export const useRouteExecution = (routeId) => {
18
18
  const { account, switchChain } = useWallet();
19
- const { route, status } = useRouteStore((state) => state.routes[routeId]);
19
+ const { route, status } = useRouteStore((state) => { var _a; return (_a = state.routes[routeId]) !== null && _a !== void 0 ? _a : {}; });
20
20
  const [updateRoute, restartRoute, removeRoute] = useRouteStore((state) => [state.updateRoute, state.restartRoute, state.removeRoute], shallow);
21
21
  const updateCallback = (updatedRoute) => {
22
22
  console.log('Route updated.', updatedRoute);