@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.
- package/App.js +6 -86
- package/AppDrawer.js +3 -2
- package/AppRoutes.d.ts +2 -0
- package/AppRoutes.js +85 -0
- package/cjs/App.js +5 -85
- package/cjs/AppDrawer.js +2 -1
- package/cjs/AppRoutes.d.ts +2 -0
- package/cjs/AppRoutes.js +89 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -0
- package/cjs/components/AppContainer.d.ts +4 -5
- package/cjs/components/AppContainer.js +30 -29
- package/cjs/components/Card/Card.d.ts +1 -0
- package/cjs/components/Card/Card.js +13 -9
- package/cjs/components/ChainSelect/ChainSelect.js +3 -3
- package/cjs/components/ChainSelect/ChainSelect.style.d.ts +1 -0
- package/cjs/components/ChainSelect/ChainSelect.style.js +2 -2
- package/cjs/components/ChainSelect/useChainSelect.js +2 -2
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +6 -2
- package/cjs/components/Header/Header.d.ts +2 -1
- package/cjs/components/Header/Header.js +3 -2
- package/cjs/components/Header/Header.style.js +3 -2
- package/cjs/components/Header/NavigationHeader.js +4 -1
- package/cjs/components/Header/WalletHeader.js +1 -1
- package/cjs/components/Header/useHeaderActionStore.js +1 -4
- package/cjs/components/PoweredBy/PoweredBy.js +7 -0
- package/cjs/components/SendToWallet/SendToWallet.js +6 -10
- package/cjs/components/SendToWallet/SendToWalletButton.d.ts +2 -0
- package/cjs/components/SendToWallet/SendToWalletButton.js +24 -0
- package/cjs/components/SendToWallet/index.d.ts +1 -0
- package/cjs/components/SendToWallet/index.js +1 -0
- package/cjs/components/SendToWallet/store.d.ts +4 -0
- package/cjs/components/SendToWallet/store.js +13 -0
- package/cjs/components/SendToWallet/types.d.ts +6 -0
- package/cjs/{stores/route → components/SendToWallet}/types.js +0 -0
- package/cjs/components/StepActions/StepActions.style.js +1 -1
- package/cjs/components/SwapButton/SwapButton.d.ts +1 -1
- package/cjs/components/SwapButton/SwapButton.js +4 -4
- package/cjs/components/SwapRouteCard/SwapRouteCard.d.ts +2 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +19 -15
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +30 -0
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +16 -3
- package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -12
- package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.d.ts +1 -3
- package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -13
- package/cjs/components/SwapRouteCard/types.d.ts +6 -2
- package/cjs/{pages/MainPage → components/SwapRoutes}/SwapRoutes.d.ts +0 -0
- package/cjs/components/SwapRoutes/SwapRoutes.js +51 -0
- package/cjs/components/SwapRoutes/SwapRoutes.style.d.ts +43 -0
- package/cjs/components/SwapRoutes/SwapRoutes.style.js +47 -0
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -0
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +38 -0
- package/cjs/components/SwapRoutes/index.d.ts +2 -0
- package/cjs/components/SwapRoutes/index.js +18 -0
- package/cjs/components/Token/Token.d.ts +2 -1
- package/cjs/components/Token/Token.js +10 -6
- package/cjs/components/Token/Token.style.js +2 -0
- package/cjs/components/TokenList/TokenList.js +4 -1
- package/cjs/config/sentry.js +3 -26
- package/cjs/config/theme.js +20 -24
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useChains.js +2 -2
- package/cjs/hooks/useGasSufficiency.js +14 -37
- package/cjs/hooks/useNavigateBack.js +13 -6
- package/cjs/hooks/useRouteExecution.js +5 -8
- package/cjs/hooks/useSwapRoutes.js +1 -4
- package/cjs/hooks/useTelemetry.js +3 -2
- package/cjs/hooks/useTokenBalances.d.ts +1 -1
- package/cjs/hooks/useTokenBalances.js +3 -1
- package/cjs/hooks/useWidgetEvents.js +2 -5
- package/cjs/i18n/index.js +2 -5
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +1 -0
- package/cjs/pages/MainPage/MainPage.js +4 -2
- package/cjs/pages/MainPage/MainSwapButton.js +4 -4
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +4 -3
- package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +1 -4
- package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +1 -4
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +2 -5
- package/cjs/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -0
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +8 -5
- package/cjs/pages/SwapPage/SwapPage.js +5 -1
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +3 -5
- package/cjs/providers/SDKProvider/SDKProvider.js +1 -4
- package/cjs/providers/WalletProvider/WalletProvider.js +2 -2
- package/cjs/stores/chains/useChainOrder.js +1 -4
- package/cjs/stores/chains/useChainOrderStore.js +1 -4
- package/cjs/stores/index.d.ts +2 -1
- package/cjs/stores/index.js +2 -1
- package/cjs/stores/{route → routes}/index.d.ts +2 -1
- package/cjs/stores/{route → routes}/index.js +2 -1
- package/cjs/stores/{route → routes}/types.d.ts +4 -0
- package/cjs/stores/routes/types.js +2 -0
- package/cjs/stores/{route → routes}/useExecutingRoutesIds.d.ts +0 -0
- package/cjs/stores/{route → routes}/useExecutingRoutesIds.js +3 -6
- package/cjs/stores/{route/useRouteStore.d.ts → routes/useRouteExecutionStore.d.ts} +1 -1
- package/cjs/stores/{route/useRouteStore.js → routes/useRouteExecutionStore.js} +3 -6
- package/cjs/stores/routes/useSelectedRouteStore.d.ts +4 -0
- package/cjs/stores/routes/useSelectedRouteStore.js +12 -0
- package/cjs/stores/{route → routes}/useSetExecutableRoute.d.ts +0 -0
- package/cjs/stores/{route → routes}/useSetExecutableRoute.js +2 -2
- package/cjs/stores/{route → routes}/useSwapHistory.d.ts +0 -0
- package/cjs/stores/{route → routes}/useSwapHistory.js +3 -6
- package/cjs/stores/{route → routes}/utils.d.ts +0 -0
- package/cjs/stores/{route → routes}/utils.js +1 -4
- package/cjs/stores/settings/useAppearance.js +1 -4
- package/cjs/stores/settings/useSettings.js +1 -4
- package/cjs/stores/settings/useSettingsStore.js +2 -5
- package/cjs/types/widget.d.ts +2 -0
- package/cjs/utils/colors.d.ts +1 -1
- package/cjs/utils/format.js +1 -4
- package/cjs/utils/navigationRoutes.js +12 -12
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -0
- package/components/AppContainer.d.ts +4 -5
- package/components/AppContainer.js +29 -28
- package/components/Card/Card.d.ts +1 -0
- package/components/Card/Card.js +13 -9
- package/components/ChainSelect/ChainSelect.js +1 -1
- package/components/ChainSelect/ChainSelect.style.d.ts +1 -0
- package/components/ChainSelect/ChainSelect.style.js +2 -2
- package/components/ChainSelect/useChainSelect.js +1 -1
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +6 -2
- package/components/Header/Header.d.ts +2 -1
- package/components/Header/Header.js +1 -1
- package/components/Header/Header.style.js +4 -3
- package/components/Header/NavigationHeader.js +4 -1
- package/components/Header/WalletHeader.js +2 -2
- package/components/PoweredBy/PoweredBy.js +7 -0
- package/components/SendToWallet/SendToWallet.js +8 -11
- package/components/SendToWallet/SendToWalletButton.d.ts +2 -0
- package/components/SendToWallet/SendToWalletButton.js +20 -0
- package/components/SendToWallet/index.d.ts +1 -0
- package/components/SendToWallet/index.js +1 -0
- package/components/SendToWallet/store.d.ts +4 -0
- package/components/SendToWallet/store.js +10 -0
- package/components/SendToWallet/types.d.ts +6 -0
- package/{stores/route → components/SendToWallet}/types.js +0 -0
- package/components/StepActions/StepActions.style.js +1 -1
- package/components/SwapButton/SwapButton.d.ts +1 -1
- package/components/SwapButton/SwapButton.js +4 -3
- package/components/SwapRouteCard/SwapRouteCard.d.ts +2 -1
- package/components/SwapRouteCard/SwapRouteCard.js +19 -16
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +30 -0
- package/components/SwapRouteCard/SwapRouteCard.style.js +17 -4
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -12
- package/components/SwapRouteCard/SwapRouteNotFoundCard.d.ts +1 -3
- package/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -13
- package/components/SwapRouteCard/types.d.ts +6 -2
- package/{pages/MainPage → components/SwapRoutes}/SwapRoutes.d.ts +0 -0
- package/components/SwapRoutes/SwapRoutes.js +47 -0
- package/components/SwapRoutes/SwapRoutes.style.d.ts +43 -0
- package/components/SwapRoutes/SwapRoutes.style.js +44 -0
- package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -0
- package/components/SwapRoutes/SwapRoutesExpanded.js +34 -0
- package/components/SwapRoutes/index.d.ts +2 -0
- package/components/SwapRoutes/index.js +2 -0
- package/components/Token/Token.d.ts +2 -1
- package/components/Token/Token.js +11 -7
- package/components/Token/Token.style.js +2 -0
- package/components/TokenList/TokenList.js +4 -1
- package/config/theme.js +20 -24
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useChains.js +1 -1
- package/hooks/useGasSufficiency.js +15 -35
- package/hooks/useNavigateBack.js +13 -6
- package/hooks/useRouteExecution.js +5 -5
- package/hooks/useTelemetry.js +3 -2
- package/hooks/useTokenBalances.d.ts +1 -1
- package/hooks/useTokenBalances.js +3 -1
- package/package.json +14 -14
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +1 -0
- package/pages/MainPage/MainPage.js +4 -2
- package/pages/MainPage/MainSwapButton.js +4 -3
- package/pages/SelectTokenPage/SelectTokenPage.js +4 -3
- package/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
- package/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -0
- package/pages/SwapHistoryPage/SwapHistoryPage.js +8 -5
- package/pages/SwapPage/SwapPage.js +5 -1
- package/pages/SwapRoutesPage/SwapRoutesPage.js +4 -6
- package/providers/WalletProvider/WalletProvider.js +1 -1
- package/stores/index.d.ts +2 -1
- package/stores/index.js +2 -1
- package/stores/{route → routes}/index.d.ts +2 -1
- package/stores/{route → routes}/index.js +2 -1
- package/stores/{route → routes}/types.d.ts +4 -0
- package/stores/routes/types.js +1 -0
- package/stores/{route → routes}/useExecutingRoutesIds.d.ts +0 -0
- package/stores/{route → routes}/useExecutingRoutesIds.js +2 -2
- package/stores/{route/useRouteStore.d.ts → routes/useRouteExecutionStore.d.ts} +1 -1
- package/stores/{route/useRouteStore.js → routes/useRouteExecutionStore.js} +1 -1
- package/stores/routes/useSelectedRouteStore.d.ts +4 -0
- package/stores/routes/useSelectedRouteStore.js +9 -0
- package/stores/{route → routes}/useSetExecutableRoute.d.ts +0 -0
- package/stores/routes/useSetExecutableRoute.js +4 -0
- package/stores/{route → routes}/useSwapHistory.d.ts +0 -0
- package/stores/{route → routes}/useSwapHistory.js +2 -2
- package/stores/{route → routes}/utils.d.ts +0 -0
- package/stores/{route → routes}/utils.js +0 -0
- package/stores/settings/useSettingsStore.js +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +2 -0
- package/utils/colors.d.ts +1 -1
- package/utils/navigationRoutes.js +12 -12
- package/cjs/pages/MainPage/SwapRoutes.js +0 -43
- package/cjs/pages/MainPage/SwapRoutes.style.d.ts +0 -11
- package/cjs/pages/MainPage/SwapRoutes.style.js +0 -16
- package/pages/MainPage/SwapRoutes.js +0 -39
- package/pages/MainPage/SwapRoutes.style.d.ts +0 -11
- package/pages/MainPage/SwapRoutes.style.js +0 -13
- package/stores/route/useSetExecutableRoute.js +0 -4
|
@@ -14,3 +14,33 @@ export declare const Label: import("@emotion/styled").StyledComponent<import("@m
|
|
|
14
14
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
15
15
|
active?: boolean | undefined;
|
|
16
16
|
}, {}, {}>;
|
|
17
|
+
export declare const IconButton: import("@emotion/styled").StyledComponent<{
|
|
18
|
+
children?: import("react").ReactNode;
|
|
19
|
+
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
20
|
+
color?: "inherit" | "default" | "primary" | "secondary" | "error" | "warning" | "info" | "success" | undefined;
|
|
21
|
+
disabled?: boolean | undefined;
|
|
22
|
+
disableFocusRipple?: boolean | undefined;
|
|
23
|
+
edge?: false | "end" | "start" | undefined;
|
|
24
|
+
size?: "small" | "medium" | "large" | undefined;
|
|
25
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
26
|
+
} & Omit<{
|
|
27
|
+
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
28
|
+
centerRipple?: boolean | undefined;
|
|
29
|
+
children?: import("react").ReactNode;
|
|
30
|
+
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
31
|
+
disabled?: boolean | undefined;
|
|
32
|
+
disableRipple?: boolean | undefined;
|
|
33
|
+
disableTouchRipple?: boolean | undefined;
|
|
34
|
+
focusRipple?: boolean | undefined;
|
|
35
|
+
focusVisibleClassName?: string | undefined;
|
|
36
|
+
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
37
|
+
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
38
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
39
|
+
tabIndex?: number | undefined;
|
|
40
|
+
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
41
|
+
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
42
|
+
}, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "key" | keyof import("react").ButtonHTMLAttributes<HTMLButtonElement>> & {
|
|
43
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
44
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "color" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "size" | "edge"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
45
|
+
active?: boolean | undefined;
|
|
46
|
+
}, {}, {}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Typography } from '@mui/material';
|
|
2
|
-
import { styled } from '@mui/material/styles';
|
|
1
|
+
import { IconButton as MuiIconButton, Typography } from '@mui/material';
|
|
2
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
3
3
|
import { getContrastTextColor } from '../../utils';
|
|
4
4
|
export const Label = styled(Typography, {
|
|
5
5
|
shouldForwardProp: (prop) => prop !== 'active',
|
|
@@ -9,8 +9,8 @@ export const Label = styled(Typography, {
|
|
|
9
9
|
borderColor: active
|
|
10
10
|
? theme.palette.secondary.main
|
|
11
11
|
: theme.palette.mode === 'light'
|
|
12
|
-
? theme.palette.grey[
|
|
13
|
-
: theme.palette.grey[
|
|
12
|
+
? theme.palette.grey[300]
|
|
13
|
+
: theme.palette.grey[700],
|
|
14
14
|
borderRadius: theme.shape.borderRadiusSecondary,
|
|
15
15
|
color: active
|
|
16
16
|
? getContrastTextColor(theme, theme.palette.secondary.main)
|
|
@@ -25,3 +25,16 @@ export const Label = styled(Typography, {
|
|
|
25
25
|
display: 'inline-flex',
|
|
26
26
|
userSelect: 'none',
|
|
27
27
|
}));
|
|
28
|
+
export const IconButton = styled(MuiIconButton, {
|
|
29
|
+
shouldForwardProp: (prop) => prop !== 'active',
|
|
30
|
+
})(({ theme, active }) => {
|
|
31
|
+
const backgroundColor = theme.palette.mode === 'light'
|
|
32
|
+
? theme.palette.common.black
|
|
33
|
+
: theme.palette.common.white;
|
|
34
|
+
return {
|
|
35
|
+
backgroundColor: alpha(backgroundColor, 0.04),
|
|
36
|
+
'&:hover': {
|
|
37
|
+
backgroundColor: alpha(backgroundColor, 0.08),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
});
|
|
@@ -13,16 +13,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { Box, Skeleton } from '@mui/material';
|
|
14
14
|
import { Card } from '../Card';
|
|
15
15
|
export const SwapRouteCardSkeleton = (_a) => {
|
|
16
|
-
var {
|
|
17
|
-
return (_jsxs(Card, Object.assign({ dense: dense, indented: true }, other, { children: [_jsx(Skeleton, { variant: "rectangular", width:
|
|
18
|
-
display: 'flex',
|
|
19
|
-
alignItems: 'center',
|
|
20
|
-
} }, { children: [_jsx(Box, Object.assign({ mr: 2 }, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }) })), _jsx(Skeleton, { variant: "text", width: 96, height: 32 })] })), _jsx(Box, Object.assign({ ml: 6 }, { children: _jsx(Skeleton, { variant: "text", width: 102, height: 16, sx: { borderRadius: 0.5 } }) }))] })), _jsxs(Box, Object.assign({ sx: {
|
|
21
|
-
display: 'flex',
|
|
22
|
-
justifyContent: 'space-between',
|
|
23
|
-
} }, { children: [_jsxs(Box, { children: [_jsx(Skeleton, { variant: "text", width: 56, height: 20 }), _jsx(Skeleton, { variant: "text", width: 52, height: 16 })] }), _jsxs(Box, Object.assign({ sx: {
|
|
24
|
-
display: 'flex',
|
|
25
|
-
alignItems: 'flex-end',
|
|
26
|
-
flexDirection: 'column',
|
|
27
|
-
} }, { children: [_jsx(Skeleton, { variant: "text", width: 40, height: 20 }), _jsx(Skeleton, { variant: "text", width: 48, height: 16 })] }))] }))] })));
|
|
16
|
+
var { variant } = _a, other = __rest(_a, ["variant"]);
|
|
17
|
+
return (_jsxs(Card, Object.assign({ dense: variant === 'dense', indented: true }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center" }, { children: [_jsx(Skeleton, { variant: "rectangular", width: 118, height: 24, sx: { borderRadius: 0.5 } }), variant === 'extended' ? (_jsxs(Box, Object.assign({ display: "flex" }, { children: [_jsx(Skeleton, { variant: "text", width: 52, height: 24, sx: { marginRight: 2 } }), _jsx(Skeleton, { variant: "text", width: 44, height: 24, sx: { marginRight: 2 } }), _jsx(Skeleton, { variant: "text", width: 32, height: 24 })] }))) : null] })), _jsxs(Box, Object.assign({ mt: 2 }, { children: [_jsxs(Box, Object.assign({ display: "flex", alignItems: "center" }, { children: [_jsx(Box, Object.assign({ mr: 2 }, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }) })), _jsx(Skeleton, { variant: "text", width: 96, height: 32 })] })), _jsxs(Box, Object.assign({ ml: 6, display: "flex", alignItems: "center" }, { children: [_jsx(Skeleton, { variant: "text", width: 102, height: 16, sx: { borderRadius: 0.5 } }), variant === 'extended' ? (_jsx(Skeleton, { variant: "text", width: 72, height: 16, sx: { marginLeft: 1 } })) : null] }))] })), variant !== 'extended' ? (_jsxs(Box, Object.assign({ mt: 2, display: "flex", justifyContent: "space-between" }, { children: [_jsx(Skeleton, { variant: "text", width: 48, height: 24 }), _jsx(Skeleton, { variant: "text", width: 48, height: 24 })] }))) : null] })));
|
|
28
18
|
};
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
import type { SwapRouteCardSkeletonProps } from './types';
|
|
4
|
-
export declare const SwapRouteNotFoundCard: React.FC<SwapRouteCardSkeletonProps & BoxProps>;
|
|
2
|
+
export declare const SwapRouteNotFoundCard: React.FC;
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
2
|
import { Route as RouteIcon } from '@mui/icons-material';
|
|
14
3
|
import { Box, Typography } from '@mui/material';
|
|
15
4
|
import { useTranslation } from 'react-i18next';
|
|
16
|
-
export const SwapRouteNotFoundCard = (
|
|
17
|
-
var { dense } = _a, other = __rest(_a, ["dense"]);
|
|
5
|
+
export const SwapRouteNotFoundCard = () => {
|
|
18
6
|
const { t } = useTranslation();
|
|
19
7
|
return (_jsxs(Box, Object.assign({ sx: {
|
|
20
8
|
display: 'flex',
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Route } from '@lifi/sdk';
|
|
2
2
|
export interface SwapRouteCardProps {
|
|
3
3
|
route: Route;
|
|
4
|
-
|
|
4
|
+
variant?: 'default' | 'extended' | 'dense';
|
|
5
5
|
active?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface SwapRouteCardEssentialsProps {
|
|
8
|
+
route: Route;
|
|
8
9
|
dense?: boolean;
|
|
9
10
|
}
|
|
11
|
+
export interface SwapRouteCardSkeletonProps {
|
|
12
|
+
variant?: 'default' | 'extended' | 'dense';
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { KeyboardArrowRight as KeyboardArrowRightIcon } from '@mui/icons-material';
|
|
3
|
+
import { Box, IconButton } from '@mui/material';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { useFormState } from 'react-hook-form';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { useNavigate } from 'react-router-dom';
|
|
8
|
+
import { Card, CardTitle } from '../../components/Card';
|
|
9
|
+
import { ProgressToNextUpdate } from '../../components/ProgressToNextUpdate';
|
|
10
|
+
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../../components/SwapRouteCard';
|
|
11
|
+
import { useSwapRoutes } from '../../hooks';
|
|
12
|
+
import { useWidgetConfig } from '../../providers';
|
|
13
|
+
import { useSelectedRouteStore } from '../../stores';
|
|
14
|
+
import { navigationRoutes } from '../../utils';
|
|
15
|
+
import { Stack } from './SwapRoutes.style';
|
|
16
|
+
export const SwapRoutes = (props) => {
|
|
17
|
+
const { t } = useTranslation();
|
|
18
|
+
const { variant } = useWidgetConfig();
|
|
19
|
+
const navigate = useNavigate();
|
|
20
|
+
const { isValid, isValidating } = useFormState();
|
|
21
|
+
const setSelectedRoute = useSelectedRouteStore((state) => state.setSelectedRoute);
|
|
22
|
+
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
23
|
+
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setSelectedRoute(!isFetching ? currentRoute : undefined);
|
|
26
|
+
return () => setSelectedRoute(undefined);
|
|
27
|
+
}, [currentRoute, isFetching, setSelectedRoute]);
|
|
28
|
+
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const handleCardClick = () => {
|
|
32
|
+
navigate(navigationRoutes.swapRoutes);
|
|
33
|
+
};
|
|
34
|
+
const routeNotFound = !currentRoute && !isLoading && !isFetching;
|
|
35
|
+
if (variant === 'expandable') {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return (_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
top: 8,
|
|
41
|
+
right: 8,
|
|
42
|
+
} }), _jsxs(Box, Object.assign({ sx: { display: 'flex' } }, { children: [_jsx(Stack, Object.assign({ direction: "row", spacing: 2, my: 2, ml: 2, mr: routeNotFound ? 2 : 1, sx: {
|
|
43
|
+
borderWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
|
|
44
|
+
? 1
|
|
45
|
+
: 0,
|
|
46
|
+
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, {})) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense" })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes", disabled: isValidating || !isValid }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })));
|
|
47
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Stack: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
3
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
4
|
+
children?: import("react").ReactNode;
|
|
5
|
+
direction?: import("@mui/system").ResponsiveStyleValue<"row" | "column" | "column-reverse" | "row-reverse"> | undefined;
|
|
6
|
+
spacing?: import("@mui/system").ResponsiveStyleValue<string | number> | undefined;
|
|
7
|
+
divider?: import("react").ReactNode;
|
|
8
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
9
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
10
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
11
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | "direction" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "divider" | "spacing"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
12
|
+
export declare const CollapseContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
13
|
+
children?: import("react").ReactNode;
|
|
14
|
+
component?: import("react").ElementType<any> | undefined;
|
|
15
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
16
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
17
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
18
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
19
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
20
|
+
export declare const ScrollableContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
21
|
+
children?: import("react").ReactNode;
|
|
22
|
+
component?: import("react").ElementType<any> | undefined;
|
|
23
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
24
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
25
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
26
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
27
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
28
|
+
export declare const Container: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
29
|
+
children?: import("react").ReactNode;
|
|
30
|
+
component?: import("react").ElementType<any> | undefined;
|
|
31
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
32
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
33
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
34
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
35
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
36
|
+
export declare const Header: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
37
|
+
children?: import("react").ReactNode;
|
|
38
|
+
component?: import("react").ElementType<any> | undefined;
|
|
39
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
40
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
41
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
42
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
43
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Box, Stack as MuiStack } from '@mui/material';
|
|
2
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
3
|
+
import { maxHeight } from '../AppContainer';
|
|
4
|
+
export const Stack = styled(MuiStack)(({ theme }) => ({
|
|
5
|
+
alignItems: 'stretch',
|
|
6
|
+
display: 'flex',
|
|
7
|
+
flex: 1,
|
|
8
|
+
flexWrap: 'nowrap',
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
borderRight: `solid ${theme.palette.mode === 'light'
|
|
11
|
+
? theme.palette.grey[300]
|
|
12
|
+
: theme.palette.grey[800]}`,
|
|
13
|
+
width: 'calc(100% - 48px)',
|
|
14
|
+
}));
|
|
15
|
+
export const CollapseContainer = styled(Box)(({ theme }) => ({
|
|
16
|
+
height: maxHeight,
|
|
17
|
+
}));
|
|
18
|
+
export const ScrollableContainer = styled(Box)({
|
|
19
|
+
overflowY: 'auto',
|
|
20
|
+
height: '100%',
|
|
21
|
+
flex: 1,
|
|
22
|
+
display: 'flex',
|
|
23
|
+
flexDirection: 'column',
|
|
24
|
+
});
|
|
25
|
+
export const Container = styled(Box)(({ theme }) => ({
|
|
26
|
+
backgroundColor: theme.palette.background.default,
|
|
27
|
+
overflow: 'auto',
|
|
28
|
+
width: 436,
|
|
29
|
+
maxHeight,
|
|
30
|
+
marginLeft: theme.spacing(3),
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'column',
|
|
33
|
+
}));
|
|
34
|
+
export const Header = styled(Box)(({ theme }) => ({
|
|
35
|
+
backgroundColor: alpha(theme.palette.background.default, 0.84),
|
|
36
|
+
backdropFilter: 'blur(12px)',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
justifyContent: 'space-between',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
padding: theme.spacing(1.5, 3),
|
|
41
|
+
position: 'sticky',
|
|
42
|
+
top: 0,
|
|
43
|
+
zIndex: 1200,
|
|
44
|
+
}));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Collapse, Grow, Stack, Typography } from '@mui/material';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
5
|
+
import { useSwapRoutes } from '../../hooks';
|
|
6
|
+
import { useWidgetConfig } from '../../providers';
|
|
7
|
+
import { useSetExecutableRoute } from '../../stores';
|
|
8
|
+
import { navigationRoutes, navigationRoutesValues } from '../../utils';
|
|
9
|
+
import { ProgressToNextUpdate } from '../ProgressToNextUpdate';
|
|
10
|
+
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../SwapRouteCard';
|
|
11
|
+
import { CollapseContainer, Container, Header, ScrollableContainer, } from './SwapRoutes.style';
|
|
12
|
+
export const SwapRoutesExpanded = () => {
|
|
13
|
+
const { t } = useTranslation();
|
|
14
|
+
const { containerStyle } = useWidgetConfig();
|
|
15
|
+
const navigate = useNavigate();
|
|
16
|
+
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
17
|
+
const setExecutableRoute = useSetExecutableRoute();
|
|
18
|
+
const { pathname } = useLocation();
|
|
19
|
+
const cleanedPathname = pathname.endsWith('/')
|
|
20
|
+
? pathname.slice(0, -1)
|
|
21
|
+
: pathname;
|
|
22
|
+
const path = cleanedPathname.substring(cleanedPathname.lastIndexOf('/') + 1);
|
|
23
|
+
const hasPath = navigationRoutesValues.includes(path);
|
|
24
|
+
const handleRouteClick = (route) => {
|
|
25
|
+
setExecutableRoute(route);
|
|
26
|
+
navigate(navigationRoutes.swapExecution, {
|
|
27
|
+
state: { routeId: route.id },
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
31
|
+
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched) && !hasPath;
|
|
32
|
+
const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
|
|
33
|
+
return (_jsx(CollapseContainer, { children: _jsx(Collapse, Object.assign({ appear: true, timeout: 225, in: expanded, orientation: "horizontal" }, { children: _jsx(Grow, Object.assign({ appear: true, timeout: 225, in: expanded }, { children: _jsx(Container, Object.assign({ sx: containerStyle }, { children: _jsxs(ScrollableContainer, { children: [_jsxs(Header, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "700", flex: 1, noWrap: true }, { children: t('swap.routes') })), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), _jsx(Stack, Object.assign({ direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, { variant: "extended" }, index)))) : (routes === null || routes === void 0 ? void 0 : routes.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, variant: "extended" }, route.id)))) }))] }) })) })) })) }));
|
|
34
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { TokenAmount } from '@lifi/sdk';
|
|
2
|
+
import type { Step, TokenAmount } from '@lifi/sdk';
|
|
3
3
|
import type { BoxProps } from '@mui/material';
|
|
4
4
|
export declare const Token: React.FC<{
|
|
5
5
|
token: TokenAmount;
|
|
6
6
|
connected?: boolean;
|
|
7
|
+
step?: Step;
|
|
7
8
|
} & BoxProps>;
|
|
@@ -10,22 +10,26 @@ 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 } from '@mui/material';
|
|
13
|
+
import { Box, Typography } from '@mui/material';
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
15
|
import { useChains } from '../../hooks';
|
|
16
16
|
import { formatTokenAmount } from '../../utils';
|
|
17
|
+
import { SmallAvatar } from '../SmallAvatar';
|
|
17
18
|
import { TextFitter } from '../TextFitter';
|
|
18
19
|
import { TokenAvatar } from '../TokenAvatar';
|
|
19
20
|
import { TextSecondary } from './Token.style';
|
|
20
21
|
export const Token = (_a) => {
|
|
21
22
|
var _b;
|
|
22
|
-
var { token, connected } = _a, other = __rest(_a, ["token", "connected"]);
|
|
23
|
+
var { token, connected, step } = _a, other = __rest(_a, ["token", "connected", "step"]);
|
|
23
24
|
const { t } = useTranslation();
|
|
24
25
|
const { getChainById } = useChains();
|
|
25
|
-
return (_jsxs(Box, Object.assign({ flex: 1 }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", flex: 1 }, { children: [_jsx(TokenAvatar, { token: token, sx: { marginRight: 2 } }), _jsx(TextFitter, Object.assign({ height:
|
|
26
|
+
return (_jsxs(Box, Object.assign({ flex: 1 }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", flex: 1, alignItems: "center" }, { children: [_jsx(TokenAvatar, { token: token, sx: { marginRight: 2 } }), _jsx(TextFitter, Object.assign({ height: 30, textStyle: {
|
|
26
27
|
fontWeight: 700,
|
|
27
|
-
} }, { children: formatTokenAmount(token.amount, token.decimals) }))] })), _jsx(TextSecondary, Object.assign({ connected: connected }, { children: t(`swap.tokenOnChain`, {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
} }, { children: formatTokenAmount(token.amount, token.decimals) }))] })), _jsxs(Box, Object.assign({ display: "flex" }, { children: [_jsx(TextSecondary, Object.assign({ connected: connected }, { children: t(`swap.tokenOnChain`, {
|
|
29
|
+
tokenSymbol: token.symbol,
|
|
30
|
+
chainName: (_b = getChainById(token.chainId)) === null || _b === void 0 ? void 0 : _b.name,
|
|
31
|
+
}) })), step ? (_jsxs(Box, Object.assign({ display: "flex", alignItems: "flex-end", height: 12, mt: 0.5 }, { children: [_jsx(Typography, Object.assign({ fontSize: 12, lineHeight: 1, fontWeight: 500, color: "text.secondary", px: 1 }, { children: "\u2022" })), _jsx(Box, Object.assign({ pr: 0.75 }, { children: _jsx(SmallAvatar, Object.assign({ src: step.toolDetails.logoURI, alt: step.toolDetails.name, sx: {
|
|
32
|
+
border: 0,
|
|
33
|
+
marginBottom: -0.25,
|
|
34
|
+
} }, { children: step.toolDetails.name[0] })) })), _jsx(Typography, Object.assign({ fontSize: 12, lineHeight: 1, fontWeight: 500, color: "text.secondary" }, { children: step.toolDetails.name }))] }))) : null] }))] })));
|
|
31
35
|
};
|
|
@@ -18,6 +18,8 @@ export const TextSecondary = styled(Typography, {
|
|
|
18
18
|
padding: connected
|
|
19
19
|
? theme.spacing(0, 0, 0, 3.875)
|
|
20
20
|
: theme.spacing(0, 0, 0, 0),
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'flex-start',
|
|
21
23
|
}));
|
|
22
24
|
export const TokenDivider = styled(Box)(({ theme }) => ({
|
|
23
25
|
height: 12,
|
|
@@ -23,7 +23,10 @@ export const TokenList = ({ formType, height, onClick, }) => {
|
|
|
23
23
|
token.symbol.toUpperCase().includes(searchFilter) ||
|
|
24
24
|
token.address.toUpperCase().includes(searchFilter))
|
|
25
25
|
: filteredTokens;
|
|
26
|
-
const tokenSearchEnabled = !
|
|
26
|
+
const tokenSearchEnabled = !isTokensLoading &&
|
|
27
|
+
!!filteredTokens.length &&
|
|
28
|
+
!!tokenSearchFilter &&
|
|
29
|
+
!!selectedChainId;
|
|
27
30
|
const { token: searchedToken, isLoading: isSearchedTokenLoading } = useTokenSearch(tokenSearchFilter, selectedChainId, tokenSearchEnabled);
|
|
28
31
|
const isLoading = isTokensLoading || (tokenSearchEnabled && isSearchedTokenLoading);
|
|
29
32
|
const tokens = filteredTokens.length
|
package/config/theme.js
CHANGED
|
@@ -25,6 +25,17 @@ const palette = {
|
|
|
25
25
|
main: '#297EFF',
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
|
+
const paletteLight = {
|
|
29
|
+
text: {
|
|
30
|
+
primary: '#000000',
|
|
31
|
+
secondary: '#747474',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const paletteDark = {
|
|
35
|
+
background: {
|
|
36
|
+
paper: '#212121',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
28
39
|
const shape = {
|
|
29
40
|
borderRadius: 12,
|
|
30
41
|
borderRadiusSecondary: 6,
|
|
@@ -44,27 +55,7 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
44
55
|
main: (_m = (_l = (_k = theme.palette) === null || _k === void 0 ? void 0 : _k.secondary) === null || _l === void 0 ? void 0 : _l.main) !== null && _m !== void 0 ? _m : palette.secondary.main,
|
|
45
56
|
light: lighten((_q = (_p = (_o = theme.palette) === null || _o === void 0 ? void 0 : _o.secondary) === null || _p === void 0 ? void 0 : _p.main) !== null && _q !== void 0 ? _q : palette.secondary.main, 0.5),
|
|
46
57
|
dark: darken((_t = (_s = (_r = theme.palette) === null || _r === void 0 ? void 0 : _r.secondary) === null || _s === void 0 ? void 0 : _s.main) !== null && _t !== void 0 ? _t : palette.secondary.main, 0.2),
|
|
47
|
-
} }), (mode === 'light'
|
|
48
|
-
? {
|
|
49
|
-
text: {
|
|
50
|
-
primary: '#000',
|
|
51
|
-
secondary: '#52575b',
|
|
52
|
-
},
|
|
53
|
-
grey: {
|
|
54
|
-
100: '#F4F5F6',
|
|
55
|
-
200: '#EFF1F2',
|
|
56
|
-
300: '#E3E7E9',
|
|
57
|
-
400: '#C6C9CD',
|
|
58
|
-
500: '#AEB3B7',
|
|
59
|
-
600: '#798086',
|
|
60
|
-
700: '#57595C',
|
|
61
|
-
},
|
|
62
|
-
}
|
|
63
|
-
: {
|
|
64
|
-
background: {
|
|
65
|
-
paper: '#212121',
|
|
66
|
-
},
|
|
67
|
-
})),
|
|
58
|
+
} }), (mode === 'light' ? paletteLight : paletteDark)),
|
|
68
59
|
shape: Object.assign(Object.assign({}, shape), theme.shape),
|
|
69
60
|
breakpoints: {
|
|
70
61
|
values: {
|
|
@@ -96,6 +87,11 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
96
87
|
cursor: 'not-allowed',
|
|
97
88
|
pointerEvents: 'auto',
|
|
98
89
|
},
|
|
90
|
+
}, text: {
|
|
91
|
+
backgroundColor: alpha(primaryMainColor, 0.08),
|
|
92
|
+
'&:hover': {
|
|
93
|
+
backgroundColor: alpha(primaryMainColor, 0.12),
|
|
94
|
+
},
|
|
99
95
|
}, contained: {
|
|
100
96
|
'&:hover': {
|
|
101
97
|
color: getContrastRatio(common.white, primaryMainColor) >= 3
|
|
@@ -118,10 +114,10 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
118
114
|
},
|
|
119
115
|
},
|
|
120
116
|
text: {
|
|
121
|
-
|
|
117
|
+
backgroundColor: paletteDark.background.paper,
|
|
118
|
+
color: common.white,
|
|
122
119
|
'&:hover': {
|
|
123
|
-
backgroundColor:
|
|
124
|
-
borderColor: primaryLightColor,
|
|
120
|
+
backgroundColor: lighten(paletteDark.background.paper, 0.02),
|
|
125
121
|
},
|
|
126
122
|
},
|
|
127
123
|
}
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.18.0";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.18.0';
|
package/hooks/useChains.js
CHANGED
|
@@ -11,7 +11,7 @@ import { useQuery } from '@tanstack/react-query';
|
|
|
11
11
|
import { useCallback } from 'react';
|
|
12
12
|
import { useFormContext } from 'react-hook-form';
|
|
13
13
|
import { isItemAllowed, SwapFormKey, useLiFi, useWidgetConfig, } from '../providers';
|
|
14
|
-
import { useChainOrderStore } from '../stores
|
|
14
|
+
import { useChainOrderStore } from '../stores';
|
|
15
15
|
export const useChains = () => {
|
|
16
16
|
const { disabledChains, chains } = useWidgetConfig();
|
|
17
17
|
const lifi = useLiFi();
|
|
@@ -9,27 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import Big from 'big.js';
|
|
11
11
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { SwapFormKey, SwapFormKeyHelper, useLiFi, useWallet, } from '../providers';
|
|
12
|
+
import { useChains } from '.';
|
|
13
|
+
import { useLiFi, useWallet } from '../providers';
|
|
15
14
|
import { useTokenBalances } from './useTokenBalances';
|
|
16
15
|
export const useGasSufficiency = (route) => {
|
|
17
16
|
const lifi = useLiFi();
|
|
18
17
|
const { account } = useWallet();
|
|
19
|
-
const [fromChainId, toChainId, fromToken] = useWatch({
|
|
20
|
-
name: [
|
|
21
|
-
SwapFormKeyHelper.getChainKey('from'),
|
|
22
|
-
SwapFormKeyHelper.getChainKey('to'),
|
|
23
|
-
SwapFormKey.FromToken,
|
|
24
|
-
],
|
|
25
|
-
});
|
|
26
|
-
const fromAmount = useDebouncedWatch(SwapFormKey.FromAmount, 250);
|
|
27
18
|
const { getChainById } = useChains();
|
|
28
|
-
const { tokensWithBalance: fromChainTokenBalances } = useTokenBalances(fromChainId);
|
|
19
|
+
const { tokensWithBalance: fromChainTokenBalances } = useTokenBalances(route === null || route === void 0 ? void 0 : route.fromChainId);
|
|
29
20
|
const [insufficientGas, setInsufficientGas] = useState();
|
|
30
21
|
const checkInsufficientGas = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
var _a;
|
|
32
|
-
if (!account.isActive || !route
|
|
22
|
+
var _a, _b;
|
|
23
|
+
if (!account.isActive || !route) {
|
|
33
24
|
setInsufficientGas(undefined);
|
|
34
25
|
return;
|
|
35
26
|
}
|
|
@@ -53,16 +44,15 @@ export const useGasSufficiency = (route) => {
|
|
|
53
44
|
}
|
|
54
45
|
return groupedGasCosts;
|
|
55
46
|
}, {});
|
|
56
|
-
if (gasCosts[fromChainId]
|
|
57
|
-
route.
|
|
58
|
-
gasCosts[fromChainId].tokenAmount = (_a = gasCosts[fromChainId]) === null || _a === void 0 ? void 0 : _a.gasAmount.plus(Big(fromAmount));
|
|
47
|
+
if (route.fromToken.address === ((_a = gasCosts[route.fromChainId]) === null || _a === void 0 ? void 0 : _a.token.address)) {
|
|
48
|
+
gasCosts[route.fromChainId].tokenAmount = (_b = gasCosts[route.fromChainId]) === null || _b === void 0 ? void 0 : _b.gasAmount.plus(Big(route.fromAmount).div(Math.pow(10, route.fromToken.decimals)));
|
|
59
49
|
}
|
|
60
50
|
const tokenBalances = yield lifi.getTokenBalances(account.address, Object.values(gasCosts).map((item) => item.token));
|
|
61
51
|
if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
|
|
62
52
|
setInsufficientGas(undefined);
|
|
63
53
|
return;
|
|
64
54
|
}
|
|
65
|
-
[fromChainId, toChainId].forEach((chainId) => {
|
|
55
|
+
[route.fromChainId, route.toChainId].forEach((chainId) => {
|
|
66
56
|
var _a, _b, _c, _d, _e, _f;
|
|
67
57
|
if (gasCosts[chainId]) {
|
|
68
58
|
const gasTokenBalance = Big((_b = (_a = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
|
|
@@ -78,27 +68,17 @@ export const useGasSufficiency = (route) => {
|
|
|
78
68
|
});
|
|
79
69
|
const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
|
|
80
70
|
setInsufficientGas(gasCostResult);
|
|
81
|
-
}), [
|
|
82
|
-
account.address,
|
|
83
|
-
account.isActive,
|
|
84
|
-
fromAmount,
|
|
85
|
-
fromChainId,
|
|
86
|
-
getChainById,
|
|
87
|
-
lifi,
|
|
88
|
-
route,
|
|
89
|
-
toChainId,
|
|
90
|
-
]);
|
|
71
|
+
}), [account.address, account.isActive, getChainById, lifi, route]);
|
|
91
72
|
const insufficientFunds = useMemo(() => {
|
|
92
73
|
var _a, _b;
|
|
93
|
-
if (!account.isActive ||
|
|
94
|
-
!fromToken ||
|
|
95
|
-
!fromAmount ||
|
|
96
|
-
!fromChainTokenBalances) {
|
|
74
|
+
if (!account.isActive || !fromChainTokenBalances || !route) {
|
|
97
75
|
return false;
|
|
98
76
|
}
|
|
99
|
-
const balance = Big((_b = (_a = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === fromToken)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
|
|
100
|
-
return Big(fromAmount)
|
|
101
|
-
|
|
77
|
+
const balance = Big((_b = (_a = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === (route === null || route === void 0 ? void 0 : route.fromToken.address))) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
|
|
78
|
+
return Big(route.fromAmount)
|
|
79
|
+
.div(Math.pow(10, route.fromToken.decimals))
|
|
80
|
+
.gt(balance);
|
|
81
|
+
}, [account.isActive, fromChainTokenBalances, route]);
|
|
102
82
|
useEffect(() => {
|
|
103
83
|
checkInsufficientGas();
|
|
104
84
|
}, [checkInsufficientGas]);
|