@lifi/widget 1.18.7 → 1.18.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/SwapRoutes/SwapRoutes.js +2 -12
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +6 -4
- package/cjs/components/SwapRoutes/useSetSelectedRoute.d.ts +2 -0
- package/cjs/components/SwapRoutes/useSetSelectedRoute.js +13 -0
- package/cjs/components/TokenList/TokenList.js +2 -2
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useDebouncedWatch.js +1 -4
- package/cjs/hooks/useSwapRoutes.js +1 -1
- package/cjs/pages/MainPage/MainPage.js +3 -1
- package/components/SwapRoutes/SwapRoutes.js +2 -12
- package/components/SwapRoutes/SwapRoutesExpanded.js +6 -4
- package/components/SwapRoutes/useSetSelectedRoute.d.ts +2 -0
- package/components/SwapRoutes/useSetSelectedRoute.js +9 -0
- package/components/TokenList/TokenList.js +2 -2
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useDebouncedWatch.js +1 -4
- package/hooks/useSwapRoutes.js +1 -1
- package/package.json +1 -1
- package/pages/MainPage/MainPage.js +3 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
|
@@ -4,7 +4,6 @@ exports.SwapRoutes = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
|
-
const react_1 = require("react");
|
|
8
7
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
8
|
const react_i18next_1 = require("react-i18next");
|
|
10
9
|
const react_router_dom_1 = require("react-router-dom");
|
|
@@ -12,22 +11,16 @@ const Card_1 = require("../../components/Card");
|
|
|
12
11
|
const ProgressToNextUpdate_1 = require("../../components/ProgressToNextUpdate");
|
|
13
12
|
const SwapRouteCard_1 = require("../../components/SwapRouteCard");
|
|
14
13
|
const hooks_1 = require("../../hooks");
|
|
15
|
-
const providers_1 = require("../../providers");
|
|
16
|
-
const stores_1 = require("../../stores");
|
|
17
14
|
const utils_1 = require("../../utils");
|
|
18
15
|
const SwapRoutes_style_1 = require("./SwapRoutes.style");
|
|
16
|
+
const useSetSelectedRoute_1 = require("./useSetSelectedRoute");
|
|
19
17
|
const SwapRoutes = (props) => {
|
|
20
18
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
21
|
-
const { variant } = (0, providers_1.useWidgetConfig)();
|
|
22
19
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
23
20
|
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
24
|
-
const setSelectedRoute = (0, stores_1.useSelectedRouteStore)((state) => state.setSelectedRoute);
|
|
25
21
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
26
22
|
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
27
|
-
(0,
|
|
28
|
-
setSelectedRoute(!isFetching ? currentRoute : undefined);
|
|
29
|
-
return () => setSelectedRoute(undefined);
|
|
30
|
-
}, [currentRoute, isFetching, setSelectedRoute]);
|
|
23
|
+
(0, useSetSelectedRoute_1.useSetSelectedRoute)(currentRoute, isFetching);
|
|
31
24
|
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
32
25
|
return null;
|
|
33
26
|
}
|
|
@@ -35,9 +28,6 @@ const SwapRoutes = (props) => {
|
|
|
35
28
|
navigate(utils_1.navigationRoutes.swapRoutes);
|
|
36
29
|
};
|
|
37
30
|
const routeNotFound = !currentRoute && !isLoading && !isFetching;
|
|
38
|
-
if (variant === 'expandable') {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
31
|
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.routes') }), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
42
32
|
position: 'absolute',
|
|
43
33
|
top: 8,
|
|
@@ -13,13 +13,16 @@ const utils_1 = require("../../utils");
|
|
|
13
13
|
const ProgressToNextUpdate_1 = require("../ProgressToNextUpdate");
|
|
14
14
|
const SwapRouteCard_1 = require("../SwapRouteCard");
|
|
15
15
|
const SwapRoutes_style_1 = require("./SwapRoutes.style");
|
|
16
|
+
const useSetSelectedRoute_1 = require("./useSetSelectedRoute");
|
|
16
17
|
const SwapRoutesExpanded = () => {
|
|
17
18
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
18
|
-
const { containerStyle } = (0, providers_1.useWidgetConfig)();
|
|
19
19
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
20
|
-
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
21
|
-
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
22
20
|
const setExecutableRoute = (0, stores_1.useSetExecutableRoute)();
|
|
21
|
+
const { containerStyle } = (0, providers_1.useWidgetConfig)();
|
|
22
|
+
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
23
|
+
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
24
|
+
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
25
|
+
(0, useSetSelectedRoute_1.useSetSelectedRoute)(currentRoute, isFetching);
|
|
23
26
|
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
24
27
|
const cleanedPathname = pathname.endsWith('/')
|
|
25
28
|
? pathname.slice(0, -1)
|
|
@@ -34,7 +37,6 @@ const SwapRoutesExpanded = () => {
|
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
};
|
|
37
|
-
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
38
40
|
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched) && !hasPath;
|
|
39
41
|
const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
|
|
40
42
|
return ((0, jsx_runtime_1.jsx)(SwapRoutes_style_1.CollapseContainer, { children: (0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ appear: true, timeout: 225, in: expanded, orientation: "horizontal" }, { children: (0, jsx_runtime_1.jsx)(material_1.Grow, Object.assign({ appear: true, timeout: 225, in: expanded }, { children: (0, jsx_runtime_1.jsx)(SwapRoutes_style_1.Container, Object.assign({ sx: containerStyle }, { children: (0, jsx_runtime_1.jsxs)(SwapRoutes_style_1.ScrollableContainer, { children: [(0, jsx_runtime_1.jsxs)(SwapRoutes_style_1.Header, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 18, fontWeight: "700", flex: 1, noWrap: true }, { children: t('swap.routes') })), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3 }, { children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { variant: "stretched" }, index)))) : (routes === null || routes === void 0 ? void 0 : routes.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, variant: "stretched", expanded: (routes === null || routes === void 0 ? void 0 : routes.length) <= 2 }, route.id)))) }))] }) })) })) })) }));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSetSelectedRoute = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const stores_1 = require("../../stores");
|
|
6
|
+
const useSetSelectedRoute = (currentRoute, isFetching) => {
|
|
7
|
+
const setSelectedRoute = (0, stores_1.useSelectedRouteStore)((state) => state.setSelectedRoute);
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
setSelectedRoute(!isFetching ? currentRoute : undefined);
|
|
10
|
+
return () => setSelectedRoute(undefined);
|
|
11
|
+
}, [currentRoute, isFetching, setSelectedRoute]);
|
|
12
|
+
};
|
|
13
|
+
exports.useSetSelectedRoute = useSetSelectedRoute;
|
|
@@ -17,7 +17,7 @@ const TokenList = ({ formType, height, onClick, }) => {
|
|
|
17
17
|
const [selectedChainId] = (0, react_hook_form_1.useWatch)({
|
|
18
18
|
name: [providers_1.SwapFormKeyHelper.getChainKey(formType)],
|
|
19
19
|
});
|
|
20
|
-
const [tokenSearchFilter] = (0, hooks_1.useDebouncedWatch)([providers_1.SwapFormKey.TokenSearchFilter],
|
|
20
|
+
const [tokenSearchFilter] = (0, hooks_1.useDebouncedWatch)([providers_1.SwapFormKey.TokenSearchFilter], 320);
|
|
21
21
|
const { tokens: chainTokens, tokensWithBalance, isLoading: isTokensLoading, isBalanceLoading, featuredTokens, } = (0, hooks_1.useTokenBalances)(selectedChainId);
|
|
22
22
|
let filteredTokens = ((_a = tokensWithBalance !== null && tokensWithBalance !== void 0 ? tokensWithBalance : chainTokens) !== null && _a !== void 0 ? _a : []);
|
|
23
23
|
const searchFilter = (_b = tokenSearchFilter === null || tokenSearchFilter === void 0 ? void 0 : tokenSearchFilter.toUpperCase()) !== null && _b !== void 0 ? _b : '';
|
|
@@ -27,7 +27,7 @@ const TokenList = ({ formType, height, onClick, }) => {
|
|
|
27
27
|
token.address.toUpperCase().includes(searchFilter))
|
|
28
28
|
: filteredTokens;
|
|
29
29
|
const tokenSearchEnabled = !isTokensLoading &&
|
|
30
|
-
|
|
30
|
+
!filteredTokens.length &&
|
|
31
31
|
!!tokenSearchFilter &&
|
|
32
32
|
!!selectedChainId;
|
|
33
33
|
const { token: searchedToken, isLoading: isSearchedTokenLoading } = (0, hooks_1.useTokenSearch)(tokenSearchFilter, selectedChainId, tokenSearchEnabled);
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.18.
|
|
2
|
+
export declare const version = "1.18.8";
|
package/cjs/config/version.js
CHANGED
|
@@ -15,10 +15,7 @@ const useDebouncedWatch = (name, delay) => {
|
|
|
15
15
|
const hasWatchedValue = Array.isArray(watchedValue)
|
|
16
16
|
? watchedValue.some((value) => value)
|
|
17
17
|
: Boolean(watchedValue);
|
|
18
|
-
|
|
19
|
-
? debouncedValueRef.current.some((value) => value)
|
|
20
|
-
: Boolean(debouncedValueRef.current);
|
|
21
|
-
if (hasWatchedValue && hasDebouncedValue) {
|
|
18
|
+
if (hasWatchedValue) {
|
|
22
19
|
const handler = setTimeout(() => {
|
|
23
20
|
setDebouncedValue(watchedValue);
|
|
24
21
|
}, delay);
|
|
@@ -38,7 +38,7 @@ const useSwapRoutes = () => {
|
|
|
38
38
|
providers_1.SwapFormKey.ToAddress,
|
|
39
39
|
],
|
|
40
40
|
});
|
|
41
|
-
const [fromTokenAmount] = (0, _1.useDebouncedWatch)([providers_1.SwapFormKey.FromAmount],
|
|
41
|
+
const [fromTokenAmount] = (0, _1.useDebouncedWatch)([providers_1.SwapFormKey.FromAmount], 320);
|
|
42
42
|
const { token } = (0, _1.useToken)(fromChainId, fromTokenAddress);
|
|
43
43
|
const isEnabled =
|
|
44
44
|
// Boolean(account.address) &&
|
|
@@ -9,9 +9,11 @@ const SelectChainAndToken_1 = require("../../components/SelectChainAndToken");
|
|
|
9
9
|
const SendToWallet_1 = require("../../components/SendToWallet");
|
|
10
10
|
const SwapInput_1 = require("../../components/SwapInput");
|
|
11
11
|
const SwapRoutes_1 = require("../../components/SwapRoutes");
|
|
12
|
+
const providers_1 = require("../../providers");
|
|
12
13
|
const MainPage_style_1 = require("./MainPage.style");
|
|
13
14
|
const MainSwapButton_1 = require("./MainSwapButton");
|
|
14
15
|
const MainPage = () => {
|
|
15
|
-
|
|
16
|
+
const { variant } = (0, providers_1.useWidgetConfig)();
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)(MainPage_style_1.FormContainer, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsx)(ActiveSwaps_1.ActiveSwaps, { mx: 3, mt: 1, mb: 2 }), (0, jsx_runtime_1.jsx)(SelectChainAndToken_1.SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mx: 3, mb: 3 }, { children: (0, jsx_runtime_1.jsx)(SwapInput_1.SwapInput, { formType: "from" }) })), variant !== 'expandable' ? (0, jsx_runtime_1.jsx)(SwapRoutes_1.SwapRoutes, { mx: 3, mb: 3 }) : null, (0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { mx: 3, mb: 3 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mx: 3, mb: 1 }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWallet, { mb: 3 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { display: 'flex' } }, { children: [(0, jsx_runtime_1.jsx)(MainSwapButton_1.MainSwapButton, {}), (0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWalletButton, {})] }))] }))] })));
|
|
16
18
|
};
|
|
17
19
|
exports.MainPage = MainPage;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { KeyboardArrowRight as KeyboardArrowRightIcon } from '@mui/icons-material';
|
|
3
3
|
import { Box, IconButton } from '@mui/material';
|
|
4
|
-
import { useEffect } from 'react';
|
|
5
4
|
import { useFormState } from 'react-hook-form';
|
|
6
5
|
import { useTranslation } from 'react-i18next';
|
|
7
6
|
import { useNavigate } from 'react-router-dom';
|
|
@@ -9,22 +8,16 @@ import { Card, CardTitle } from '../../components/Card';
|
|
|
9
8
|
import { ProgressToNextUpdate } from '../../components/ProgressToNextUpdate';
|
|
10
9
|
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../../components/SwapRouteCard';
|
|
11
10
|
import { useSwapRoutes } from '../../hooks';
|
|
12
|
-
import { useWidgetConfig } from '../../providers';
|
|
13
|
-
import { useSelectedRouteStore } from '../../stores';
|
|
14
11
|
import { navigationRoutes } from '../../utils';
|
|
15
12
|
import { Stack } from './SwapRoutes.style';
|
|
13
|
+
import { useSetSelectedRoute } from './useSetSelectedRoute';
|
|
16
14
|
export const SwapRoutes = (props) => {
|
|
17
15
|
const { t } = useTranslation();
|
|
18
|
-
const { variant } = useWidgetConfig();
|
|
19
16
|
const navigate = useNavigate();
|
|
20
17
|
const { isValid, isValidating } = useFormState();
|
|
21
|
-
const setSelectedRoute = useSelectedRouteStore((state) => state.setSelectedRoute);
|
|
22
18
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
23
19
|
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
24
|
-
|
|
25
|
-
setSelectedRoute(!isFetching ? currentRoute : undefined);
|
|
26
|
-
return () => setSelectedRoute(undefined);
|
|
27
|
-
}, [currentRoute, isFetching, setSelectedRoute]);
|
|
20
|
+
useSetSelectedRoute(currentRoute, isFetching);
|
|
28
21
|
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
29
22
|
return null;
|
|
30
23
|
}
|
|
@@ -32,9 +25,6 @@ export const SwapRoutes = (props) => {
|
|
|
32
25
|
navigate(navigationRoutes.swapRoutes);
|
|
33
26
|
};
|
|
34
27
|
const routeNotFound = !currentRoute && !isLoading && !isFetching;
|
|
35
|
-
if (variant === 'expandable') {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
28
|
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
29
|
position: 'absolute',
|
|
40
30
|
top: 8,
|
|
@@ -10,13 +10,16 @@ import { navigationRoutes, navigationRoutesValues } from '../../utils';
|
|
|
10
10
|
import { ProgressToNextUpdate } from '../ProgressToNextUpdate';
|
|
11
11
|
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../SwapRouteCard';
|
|
12
12
|
import { CollapseContainer, Container, Header, ScrollableContainer, } from './SwapRoutes.style';
|
|
13
|
+
import { useSetSelectedRoute } from './useSetSelectedRoute';
|
|
13
14
|
export const SwapRoutesExpanded = () => {
|
|
14
15
|
const { t } = useTranslation();
|
|
15
|
-
const { containerStyle } = useWidgetConfig();
|
|
16
16
|
const navigate = useNavigate();
|
|
17
|
-
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
18
|
-
const { isValid, isValidating } = useFormState();
|
|
19
17
|
const setExecutableRoute = useSetExecutableRoute();
|
|
18
|
+
const { containerStyle } = useWidgetConfig();
|
|
19
|
+
const { isValid, isValidating } = useFormState();
|
|
20
|
+
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
21
|
+
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
22
|
+
useSetSelectedRoute(currentRoute, isFetching);
|
|
20
23
|
const { pathname } = useLocation();
|
|
21
24
|
const cleanedPathname = pathname.endsWith('/')
|
|
22
25
|
? pathname.slice(0, -1)
|
|
@@ -31,7 +34,6 @@ export const SwapRoutesExpanded = () => {
|
|
|
31
34
|
});
|
|
32
35
|
}
|
|
33
36
|
};
|
|
34
|
-
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
35
37
|
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched) && !hasPath;
|
|
36
38
|
const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
|
|
37
39
|
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: "stretched" }, index)))) : (routes === null || routes === void 0 ? void 0 : routes.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, variant: "stretched", expanded: (routes === null || routes === void 0 ? void 0 : routes.length) <= 2 }, route.id)))) }))] }) })) })) })) }));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useSelectedRouteStore } from '../../stores';
|
|
3
|
+
export const useSetSelectedRoute = (currentRoute, isFetching) => {
|
|
4
|
+
const setSelectedRoute = useSelectedRouteStore((state) => state.setSelectedRoute);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
setSelectedRoute(!isFetching ? currentRoute : undefined);
|
|
7
|
+
return () => setSelectedRoute(undefined);
|
|
8
|
+
}, [currentRoute, isFetching, setSelectedRoute]);
|
|
9
|
+
};
|
|
@@ -14,7 +14,7 @@ export const TokenList = ({ formType, height, onClick, }) => {
|
|
|
14
14
|
const [selectedChainId] = useWatch({
|
|
15
15
|
name: [SwapFormKeyHelper.getChainKey(formType)],
|
|
16
16
|
});
|
|
17
|
-
const [tokenSearchFilter] = useDebouncedWatch([SwapFormKey.TokenSearchFilter],
|
|
17
|
+
const [tokenSearchFilter] = useDebouncedWatch([SwapFormKey.TokenSearchFilter], 320);
|
|
18
18
|
const { tokens: chainTokens, tokensWithBalance, isLoading: isTokensLoading, isBalanceLoading, featuredTokens, } = useTokenBalances(selectedChainId);
|
|
19
19
|
let filteredTokens = ((_a = tokensWithBalance !== null && tokensWithBalance !== void 0 ? tokensWithBalance : chainTokens) !== null && _a !== void 0 ? _a : []);
|
|
20
20
|
const searchFilter = (_b = tokenSearchFilter === null || tokenSearchFilter === void 0 ? void 0 : tokenSearchFilter.toUpperCase()) !== null && _b !== void 0 ? _b : '';
|
|
@@ -24,7 +24,7 @@ export const TokenList = ({ formType, height, onClick, }) => {
|
|
|
24
24
|
token.address.toUpperCase().includes(searchFilter))
|
|
25
25
|
: filteredTokens;
|
|
26
26
|
const tokenSearchEnabled = !isTokensLoading &&
|
|
27
|
-
|
|
27
|
+
!filteredTokens.length &&
|
|
28
28
|
!!tokenSearchFilter &&
|
|
29
29
|
!!selectedChainId;
|
|
30
30
|
const { token: searchedToken, isLoading: isSearchedTokenLoading } = useTokenSearch(tokenSearchFilter, selectedChainId, tokenSearchEnabled);
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.18.
|
|
2
|
+
export declare const version = "1.18.8";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.18.
|
|
2
|
+
export const version = '1.18.8';
|
|
@@ -12,10 +12,7 @@ export const useDebouncedWatch = (name, delay) => {
|
|
|
12
12
|
const hasWatchedValue = Array.isArray(watchedValue)
|
|
13
13
|
? watchedValue.some((value) => value)
|
|
14
14
|
: Boolean(watchedValue);
|
|
15
|
-
|
|
16
|
-
? debouncedValueRef.current.some((value) => value)
|
|
17
|
-
: Boolean(debouncedValueRef.current);
|
|
18
|
-
if (hasWatchedValue && hasDebouncedValue) {
|
|
15
|
+
if (hasWatchedValue) {
|
|
19
16
|
const handler = setTimeout(() => {
|
|
20
17
|
setDebouncedValue(watchedValue);
|
|
21
18
|
}, delay);
|
package/hooks/useSwapRoutes.js
CHANGED
|
@@ -35,7 +35,7 @@ export const useSwapRoutes = () => {
|
|
|
35
35
|
SwapFormKey.ToAddress,
|
|
36
36
|
],
|
|
37
37
|
});
|
|
38
|
-
const [fromTokenAmount] = useDebouncedWatch([SwapFormKey.FromAmount],
|
|
38
|
+
const [fromTokenAmount] = useDebouncedWatch([SwapFormKey.FromAmount], 320);
|
|
39
39
|
const { token } = useToken(fromChainId, fromTokenAddress);
|
|
40
40
|
const isEnabled =
|
|
41
41
|
// Boolean(account.address) &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.8",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -6,8 +6,10 @@ import { SelectChainAndToken } from '../../components/SelectChainAndToken';
|
|
|
6
6
|
import { SendToWallet, SendToWalletButton, } from '../../components/SendToWallet';
|
|
7
7
|
import { SwapInput } from '../../components/SwapInput';
|
|
8
8
|
import { SwapRoutes } from '../../components/SwapRoutes';
|
|
9
|
+
import { useWidgetConfig } from '../../providers';
|
|
9
10
|
import { FormContainer } from './MainPage.style';
|
|
10
11
|
import { MainSwapButton } from './MainSwapButton';
|
|
11
12
|
export const MainPage = () => {
|
|
12
|
-
|
|
13
|
+
const { variant } = useWidgetConfig();
|
|
14
|
+
return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(ActiveSwaps, { mx: 3, mt: 1, mb: 2 }), _jsx(SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 3 }, { children: _jsx(SwapInput, { formType: "from" }) })), variant !== 'expandable' ? _jsx(SwapRoutes, { mx: 3, mb: 3 }) : null, _jsx(GasSufficiencyMessage, { mx: 3, mb: 3 }), _jsxs(Box, Object.assign({ mx: 3, mb: 1 }, { children: [_jsx(SendToWallet, { mb: 3 }), _jsxs(Box, Object.assign({ sx: { display: 'flex' } }, { children: [_jsx(MainSwapButton, {}), _jsx(SendToWalletButton, {})] }))] }))] })));
|
|
13
15
|
};
|