@lifi/widget 2.0.0-beta.4 → 2.0.0-beta.6

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 (85) hide show
  1. package/AppDrawer.js +2 -1
  2. package/AppProvider.js +1 -1
  3. package/README.md +11 -12
  4. package/cjs/AppDrawer.js +2 -1
  5. package/cjs/AppProvider.js +1 -1
  6. package/cjs/components/ChainSelect/useChainSelect.js +6 -0
  7. package/cjs/components/Header/Header.js +2 -2
  8. package/cjs/components/Header/Header.style.js +3 -0
  9. package/cjs/components/Header/NavigationHeader.js +7 -4
  10. package/cjs/components/Header/NavigationTabs.d.ts +1 -0
  11. package/cjs/components/Header/NavigationTabs.js +26 -0
  12. package/cjs/components/Header/NavigationTabs.style.d.ts +101 -0
  13. package/cjs/components/Header/NavigationTabs.style.js +61 -0
  14. package/cjs/components/Header/WalletHeader.d.ts +1 -0
  15. package/cjs/components/Header/WalletHeader.js +15 -8
  16. package/cjs/components/Header/useHeaderActionStore.js +0 -1
  17. package/cjs/components/SelectTokenButton/SelectTokenButton.js +5 -2
  18. package/cjs/components/SwapRouteCard/SwapRouteCard.js +14 -5
  19. package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  20. package/cjs/config/version.d.ts +1 -1
  21. package/cjs/config/version.js +1 -1
  22. package/cjs/hooks/index.d.ts +2 -1
  23. package/cjs/hooks/index.js +2 -1
  24. package/cjs/hooks/useContentHeight.js +3 -5
  25. package/cjs/hooks/useInitializer.js +0 -1
  26. package/cjs/hooks/useSwapOnly.d.ts +1 -0
  27. package/cjs/hooks/useSwapOnly.js +9 -0
  28. package/cjs/hooks/useSwapRoutes.js +3 -1
  29. package/cjs/i18n/en.json +3 -2
  30. package/cjs/i18n/pt.json +19 -4
  31. package/cjs/i18n/uk.json +20 -5
  32. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +3 -1
  33. package/cjs/pages/SwapPage/SwapPage.js +4 -1
  34. package/cjs/providers/SwapFormProvider/FormUpdater.js +3 -0
  35. package/cjs/stores/StoreProvider.d.ts +2 -2
  36. package/cjs/stores/StoreProvider.js +3 -2
  37. package/cjs/stores/routes/RouteExecutionStore.js +0 -1
  38. package/cjs/stores/settings/index.d.ts +1 -0
  39. package/cjs/stores/settings/index.js +1 -0
  40. package/cjs/stores/settings/types.d.ts +11 -0
  41. package/cjs/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  42. package/cjs/stores/settings/useSplitSubvariantStore.js +44 -0
  43. package/cjs/types/widget.d.ts +5 -1
  44. package/cjs/types/widget.js +3 -3
  45. package/components/ChainSelect/useChainSelect.js +7 -1
  46. package/components/Header/Header.js +3 -3
  47. package/components/Header/Header.style.js +3 -0
  48. package/components/Header/NavigationHeader.js +7 -4
  49. package/components/Header/NavigationTabs.d.ts +1 -0
  50. package/components/Header/NavigationTabs.js +22 -0
  51. package/components/Header/NavigationTabs.style.d.ts +101 -0
  52. package/components/Header/NavigationTabs.style.js +58 -0
  53. package/components/Header/WalletHeader.d.ts +1 -0
  54. package/components/Header/WalletHeader.js +12 -6
  55. package/components/Header/useHeaderActionStore.js +0 -1
  56. package/components/SelectTokenButton/SelectTokenButton.js +6 -3
  57. package/components/SwapRouteCard/SwapRouteCard.js +15 -6
  58. package/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  59. package/config/version.d.ts +1 -1
  60. package/config/version.js +1 -1
  61. package/hooks/index.d.ts +2 -1
  62. package/hooks/index.js +2 -1
  63. package/hooks/useContentHeight.js +4 -6
  64. package/hooks/useInitializer.js +0 -1
  65. package/hooks/useSwapOnly.d.ts +1 -0
  66. package/hooks/useSwapOnly.js +5 -0
  67. package/hooks/useSwapRoutes.js +3 -1
  68. package/i18n/en.json +3 -2
  69. package/i18n/pt.json +19 -4
  70. package/i18n/uk.json +20 -5
  71. package/package.json +8 -8
  72. package/pages/SelectTokenPage/SelectTokenPage.js +4 -2
  73. package/pages/SwapPage/SwapPage.js +4 -1
  74. package/providers/SwapFormProvider/FormUpdater.js +3 -0
  75. package/stores/StoreProvider.d.ts +2 -2
  76. package/stores/StoreProvider.js +3 -2
  77. package/stores/routes/RouteExecutionStore.js +0 -1
  78. package/stores/settings/index.d.ts +1 -0
  79. package/stores/settings/index.js +1 -0
  80. package/stores/settings/types.d.ts +11 -0
  81. package/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  82. package/stores/settings/useSplitSubvariantStore.js +37 -0
  83. package/tsconfig.cjs.tsbuildinfo +1 -1
  84. package/types/widget.d.ts +5 -1
  85. package/types/widget.js +3 -3
@@ -0,0 +1,101 @@
1
+ /// <reference types="react" />
2
+ export declare const NavbarTabs: import("@emotion/styled").StyledComponent<{
3
+ action?: import("react").Ref<import("@mui/material").TabsActions> | undefined;
4
+ allowScrollButtonsMobile?: boolean | undefined;
5
+ 'aria-label'?: string | undefined;
6
+ 'aria-labelledby'?: string | undefined;
7
+ centered?: boolean | undefined;
8
+ children?: import("react").ReactNode;
9
+ classes?: Partial<import("@mui/material").TabsClasses> | undefined;
10
+ slots?: {
11
+ StartScrollButtonIcon?: import("react").ElementType<any> | undefined;
12
+ EndScrollButtonIcon?: import("react").ElementType<any> | undefined;
13
+ } | undefined;
14
+ slotProps?: {
15
+ startScrollButtonIcon?: import("@mui/base").SlotComponentProps<import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
16
+ muiName: string;
17
+ }, import("@mui/material").TabsStartScrollButtonIconSlotPropsOverrides, import("@mui/material").TabsOwnerState> | undefined;
18
+ endScrollButtonIcon?: import("@mui/base").SlotComponentProps<import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
19
+ muiName: string;
20
+ }, import("@mui/material").TabsEndScrollButtonIconSlotPropsOverrides, import("@mui/material").TabsOwnerState> | undefined;
21
+ } | undefined;
22
+ indicatorColor?: import("@mui/types").OverridableStringUnion<"primary" | "secondary", import("@mui/material").TabsPropsIndicatorColorOverrides> | undefined;
23
+ onChange?: ((event: import("react").SyntheticEvent<Element, Event>, value: any) => void) | undefined;
24
+ orientation?: "horizontal" | "vertical" | undefined;
25
+ ScrollButtonComponent?: import("react").ElementType<any> | undefined;
26
+ scrollButtons?: boolean | "auto" | undefined;
27
+ selectionFollowsFocus?: boolean | undefined;
28
+ TabIndicatorProps?: (import("react").HTMLAttributes<HTMLDivElement> & {
29
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
30
+ }) | undefined;
31
+ TabScrollButtonProps?: Partial<import("@mui/material").TabScrollButtonProps> | undefined;
32
+ textColor?: "inherit" | "primary" | "secondary" | undefined;
33
+ value?: any;
34
+ variant?: "fullWidth" | "standard" | "scrollable" | undefined;
35
+ visibleScrollbar?: boolean | undefined;
36
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
37
+ } & import("@mui/material/OverridableComponent").CommonProps & Omit<{
38
+ action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
39
+ centerRipple?: boolean | undefined;
40
+ children?: import("react").ReactNode;
41
+ classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
42
+ disabled?: boolean | undefined;
43
+ disableRipple?: boolean | undefined;
44
+ disableTouchRipple?: boolean | undefined;
45
+ focusRipple?: boolean | undefined;
46
+ focusVisibleClassName?: string | undefined;
47
+ LinkComponent?: import("react").ElementType<any> | undefined;
48
+ onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
49
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
50
+ tabIndex?: number | undefined;
51
+ TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
52
+ touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
53
+ } & Omit<{
54
+ action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
55
+ centerRipple?: boolean | undefined;
56
+ children?: import("react").ReactNode;
57
+ classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
58
+ disabled?: boolean | undefined;
59
+ disableRipple?: boolean | undefined;
60
+ disableTouchRipple?: boolean | undefined;
61
+ focusRipple?: boolean | undefined;
62
+ focusVisibleClassName?: string | undefined;
63
+ LinkComponent?: import("react").ElementType<any> | undefined;
64
+ onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
65
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
66
+ tabIndex?: number | undefined;
67
+ TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
68
+ touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
69
+ }, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
70
+ ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
71
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef">, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "aria-label" | "aria-labelledby" | "onChange" | "action" | "sx" | "variant" | "value" | "slotProps" | "slots" | "orientation" | "allowScrollButtonsMobile" | "centered" | "indicatorColor" | "ScrollButtonComponent" | "scrollButtons" | "selectionFollowsFocus" | "TabIndicatorProps" | "TabScrollButtonProps" | "textColor" | "visibleScrollbar"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
72
+ export declare const NavbarTab: import("@emotion/styled").StyledComponent<{
73
+ children?: null | undefined;
74
+ classes?: Partial<import("@mui/material").TabClasses> | undefined;
75
+ disabled?: boolean | undefined;
76
+ disableFocusRipple?: boolean | undefined;
77
+ icon?: string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
78
+ iconPosition?: "bottom" | "top" | "end" | "start" | undefined;
79
+ label?: import("react").ReactNode;
80
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
81
+ value?: any;
82
+ wrapped?: boolean | undefined;
83
+ } & Omit<{
84
+ action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
85
+ centerRipple?: boolean | undefined;
86
+ children?: import("react").ReactNode;
87
+ classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
88
+ disabled?: boolean | undefined;
89
+ disableRipple?: boolean | undefined;
90
+ disableTouchRipple?: boolean | undefined;
91
+ focusRipple?: boolean | undefined;
92
+ focusVisibleClassName?: string | undefined;
93
+ LinkComponent?: import("react").ElementType<any> | undefined;
94
+ onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
95
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
96
+ tabIndex?: number | undefined;
97
+ TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
98
+ touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
99
+ }, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
100
+ ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
101
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | "label" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "value" | "icon" | "iconPosition" | "wrapped"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -0,0 +1,58 @@
1
+ import { Tab, Tabs, tabClasses, tabsClasses } from '@mui/material';
2
+ import { alpha, styled } from '@mui/material/styles';
3
+ export const NavbarTabs = styled(Tabs)(({ theme }) => ({
4
+ backgroundColor: theme.palette.mode === 'dark'
5
+ ? theme.palette.common.white
6
+ : alpha(theme.palette.common.black, 0.04),
7
+ borderRadius: theme.shape.borderRadius,
8
+ padding: theme.spacing(0.5),
9
+ flex: 1,
10
+ display: 'flex',
11
+ alignItems: 'center',
12
+ height: 56,
13
+ [`.${tabsClasses.flexContainer}`]: {
14
+ alignItems: 'center',
15
+ },
16
+ [`.${tabsClasses.scroller}`]: {
17
+ overflow: 'initial !important',
18
+ },
19
+ [`.${tabsClasses.indicator}`]: {
20
+ position: 'absolute',
21
+ top: '50%',
22
+ transform: 'translateY(-50%)',
23
+ height: 48,
24
+ backgroundColor: theme.palette.mode === 'dark'
25
+ ? theme.palette.common.black
26
+ : theme.palette.common.white,
27
+ borderRadius: theme.shape.borderRadiusSecondary,
28
+ boxShadow: `0px 2px 4px ${alpha(theme.palette.common.black, 0.04)}`,
29
+ },
30
+ }));
31
+ export const NavbarTab = styled(Tab, {
32
+ shouldForwardProp: (prop) => prop !== 'isDarkMode',
33
+ })(({ theme }) => ({
34
+ zIndex: 1,
35
+ display: 'flex',
36
+ flex: 1,
37
+ justifyContent: 'center',
38
+ alignItems: 'center',
39
+ flexDirection: 'row',
40
+ textTransform: 'none',
41
+ height: 48,
42
+ minHeight: 48,
43
+ fontSize: '1rem',
44
+ fontWeight: 700,
45
+ color: theme.palette.mode === 'dark'
46
+ ? theme.palette.common.white
47
+ : theme.palette.common.black,
48
+ textDecoration: 'none',
49
+ [`&.${tabClasses.selected}`]: {
50
+ color: theme.palette.mode === 'dark'
51
+ ? theme.palette.common.white
52
+ : theme.palette.common.black,
53
+ backgroundColor: 'transparent',
54
+ },
55
+ [`.${tabClasses.iconWrapper}`]: {
56
+ margin: theme.spacing(0, 1, 0, 0),
57
+ },
58
+ }));
@@ -1,2 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  export declare const WalletHeader: React.FC;
3
+ export declare const WalletMenuButton: React.FC;
@@ -14,28 +14,33 @@ import { navigationRoutes, shortenWalletAddress } from '../../utils';
14
14
  import { HeaderAppBar, WalletButton } from './Header.style';
15
15
  import { WalletMenu } from './WalletMenu';
16
16
  export const WalletHeader = () => {
17
+ return (_jsx(HeaderAppBar, { elevation: 0, sx: { justifyContent: 'flex-end' }, children: _jsx(WalletMenuButton, {}) }));
18
+ };
19
+ export const WalletMenuButton = () => {
17
20
  const { account } = useWallet();
18
- return (_jsx(HeaderAppBar, { elevation: 0, sx: { justifyContent: 'flex-end' }, children: account.isActive ? _jsx(ConnectedButton, {}) : _jsx(ConnectButton, {}) }));
21
+ return account.isActive ? _jsx(ConnectedButton, {}) : _jsx(ConnectButton, {});
19
22
  };
20
23
  const ConnectButton = () => {
21
24
  const { t } = useTranslation();
22
25
  const { pathname } = useLocation();
23
- const config = useWidgetConfig();
26
+ const { walletManagement, subvariant } = useWidgetConfig();
24
27
  const { connect: connectWallet } = useWallet();
25
28
  const navigate = useNavigate();
26
29
  const connect = async () => {
27
- if (config.walletManagement) {
30
+ if (walletManagement) {
28
31
  await connectWallet();
29
32
  return;
30
33
  }
31
34
  navigate(navigationRoutes.selectWallet);
32
35
  };
33
- return (_jsx(WalletButton, { endIcon: _jsx(WalletIcon, {}), onClick: !pathname.includes(navigationRoutes.selectWallet) ? connect : undefined, sx: {
34
- marginRight: -1.25,
36
+ return (_jsx(WalletButton, { endIcon: subvariant !== 'split' ? _jsx(WalletIcon, {}) : undefined, startIcon: subvariant === 'split' ? _jsx(WalletIcon, {}) : undefined, onClick: !pathname.includes(navigationRoutes.selectWallet) ? connect : undefined, sx: {
37
+ marginRight: subvariant === 'split' ? 0 : -1.25,
38
+ marginLeft: subvariant === 'split' ? -1.25 : 0,
35
39
  }, children: t(`button.connectWallet`) }));
36
40
  };
37
41
  const ConnectedButton = () => {
38
42
  const { t } = useTranslation();
43
+ const { subvariant } = useWidgetConfig();
39
44
  const { account, disconnect } = useWallet();
40
45
  const walletAddress = shortenWalletAddress(account.address);
41
46
  const { chain } = useChain(account.chainId);
@@ -55,7 +60,8 @@ const ConnectedButton = () => {
55
60
  handleClose();
56
61
  };
57
62
  return (_jsxs(_Fragment, { children: [_jsx(WalletButton, { endIcon: _jsx(ExpandMoreIcon, {}), startIcon: _jsx(Avatar, { src: chain?.logoURI, alt: chain?.key, sx: { width: 24, height: 24 }, children: chain?.name[0] }), sx: {
58
- marginRight: -1.25,
63
+ marginRight: subvariant === 'split' ? 0 : -1.25,
64
+ marginLeft: subvariant === 'split' ? -1 : 0,
59
65
  }, onClick: handleClick, children: walletAddress }), _jsxs(WalletMenu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, children: [_jsxs(MenuItem, { onClick: handleCopyAddress, children: [_jsx(ContentCopyIcon, {}), t(`button.copyAddress`)] }), _jsxs(MenuItem, { component: "a", onClick: handleClose, href: `${chain?.metamask.blockExplorerUrls[0]}address/${account.address}`, target: "_blank", children: [_jsx(OpenInNewIcon, {}), t(`button.viewOnExplorer`)] }), _jsx(Button, { onClick: handleDisconnect, fullWidth: true, startIcon: _jsx(PowerSettingsNewIcon, {}), sx: {
60
66
  marginTop: 1,
61
67
  }, children: t(`button.disconnect`) })] })] }));
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-underscore-dangle */
2
1
  import { create } from 'zustand';
3
2
  export const useHeaderActionStore = create((set, get) => ({
4
3
  setAction: (element) => {
@@ -3,7 +3,7 @@ import { Skeleton } from '@mui/material';
3
3
  import { useWatch } from 'react-hook-form';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { useNavigate } from 'react-router-dom';
6
- import { useChain, useToken } from '../../hooks';
6
+ import { useChain, useSwapOnly, useToken } from '../../hooks';
7
7
  import { SwapFormKeyHelper, useWidgetConfig } from '../../providers';
8
8
  import { navigationRoutes } from '../../utils';
9
9
  import { Card, CardTitle } from '../Card';
@@ -13,6 +13,7 @@ export const SelectTokenButton = ({ formType, compact }) => {
13
13
  const { t } = useTranslation();
14
14
  const navigate = useNavigate();
15
15
  const { disabledUI, variant } = useWidgetConfig();
16
+ const swapOnly = useSwapOnly();
16
17
  const tokenKey = SwapFormKeyHelper.getTokenKey(formType);
17
18
  const [chainId, tokenAddress] = useWatch({
18
19
  name: [SwapFormKeyHelper.getChainKey(formType), tokenKey],
@@ -29,8 +30,10 @@ export const SelectTokenButton = ({ formType, compact }) => {
29
30
  const isSelected = !!(chain && token);
30
31
  const onClick = !disabledUI?.includes(tokenKey) ? handleClick : undefined;
31
32
  const defaultPlaceholder = formType === 'to' && variant === 'refuel'
32
- ? t(`header.selectChain`)
33
- : t(`swap.selectChainAndToken`);
33
+ ? t('swap.selectChain')
34
+ : formType === 'to' && swapOnly
35
+ ? t('swap.selectToken')
36
+ : t('swap.selectChainAndToken');
34
37
  const cardTitle = formType === 'from' && variant === 'nft'
35
38
  ? t(`header.payWith`)
36
39
  : t(`swap.${formType}`);
@@ -3,7 +3,7 @@ import ExpandLessIcon from '@mui/icons-material/ExpandLess';
3
3
  import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
4
4
  import VerifiedUserIcon from '@mui/icons-material/VerifiedUser';
5
5
  import { Box, Collapse, Tooltip, Typography } from '@mui/material';
6
- import { useState } from 'react';
6
+ import { Fragment, useState } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { useWidgetConfig } from '../../providers';
9
9
  import { Card, CardIconButton, CardLabel, CardLabelTypography } from '../Card';
@@ -22,11 +22,20 @@ export const SwapRouteCard = ({ route, active, variant = 'default', expanded, ..
22
22
  const token = widgetVariant === 'nft'
23
23
  ? { ...route.fromToken, amount: route.fromAmount }
24
24
  : { ...route.toToken, amount: route.toAmount };
25
- const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' && (insurable || route.tags?.length) ? (_jsxs(Box, { display: "flex", alignItems: "center", mb: 2, children: [insurable ? (_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [_jsx(Typography, { fontSize: 12, children: t('swap.insurance.insure') }), _jsxs(Box, { sx: {
26
- listStyleType: 'disc',
27
- pl: 2,
28
- }, children: [_jsx(Typography, { fontSize: 12, display: "list-item", children: t('swap.insurance.bridgeExploits') }), _jsx(Typography, { fontSize: 12, display: "list-item", children: t('swap.insurance.slippageError') })] })] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(CardLabel, { type: route.tags?.length && !cardExpanded
25
+ const RecommendedTagTooltip = route.tags?.[0] === 'RECOMMENDED' ? RecommendedTooltip : Fragment;
26
+ const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' && (insurable || route.tags?.length) ? (_jsxs(Box, { display: "flex", alignItems: "center", mb: 2, children: [insurable ? (_jsx(InsuranceTooltip, { children: _jsxs(CardLabel, { type: route.tags?.length && !cardExpanded
29
27
  ? 'insurance-icon'
30
- : 'insurance', children: [_jsx(VerifiedUserIcon, { fontSize: "inherit" }), cardExpanded || !route.tags?.length ? (_jsx(CardLabelTypography, { type: "icon", children: t(`swap.tags.insurable`) })) : null] }) })) : null, route.tags?.length ? (_jsx(CardLabel, { type: active ? 'active' : undefined, children: _jsx(CardLabelTypography, { children: t(`swap.tags.${route.tags[0].toLowerCase()}`) }) })) : null] })) : null, _jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "start", children: [_jsx(Token, { token: token, step: !cardExpanded ? route.steps[0] : undefined }), !expanded ? (_jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) })) : null] }), _jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) }), _jsx(SwapRouteCardEssentials, { route: route })] }));
28
+ : 'insurance', children: [_jsx(VerifiedUserIcon, { fontSize: "inherit" }), cardExpanded || !route.tags?.length ? (_jsx(CardLabelTypography, { type: "icon", children: t(`swap.tags.insurable`) })) : null] }) })) : null, route.tags?.length ? (_jsx(RecommendedTagTooltip, { children: _jsx(CardLabel, { type: active ? 'active' : undefined, children: _jsx(CardLabelTypography, { children: t(`swap.tags.${route.tags[0].toLowerCase()}`) }) }) })) : null] })) : null, _jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "start", children: [_jsx(Token, { token: token, step: !cardExpanded ? route.steps[0] : undefined }), !expanded ? (_jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) })) : null] }), _jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) }), _jsx(SwapRouteCardEssentials, { route: route })] }));
31
29
  return widgetVariant === 'refuel' || variant === 'cardless' ? (cardContent) : (_jsx(Card, { variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true, ...other, children: cardContent }));
32
30
  };
31
+ const InsuranceTooltip = ({ children, }) => {
32
+ const { t } = useTranslation();
33
+ return (_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [_jsx(Typography, { fontSize: 12, fontWeight: "500", children: t('swap.insurance.insure') }), _jsxs(Box, { sx: {
34
+ listStyleType: 'disc',
35
+ pl: 2,
36
+ }, children: [_jsx(Typography, { fontSize: 12, fontWeight: "500", display: "list-item", children: t('swap.insurance.bridgeExploits') }), _jsx(Typography, { fontSize: 12, fontWeight: "500", display: "list-item", children: t('swap.insurance.slippageError') })] })] }), placement: "top", enterDelay: 400, arrow: true, children: children }));
37
+ };
38
+ const RecommendedTooltip = ({ children, }) => {
39
+ const { t } = useTranslation();
40
+ return (_jsx(Tooltip, { title: t('tooltip.recommended'), placement: "top", enterDelay: 400, arrow: true, children: children }));
41
+ };
@@ -15,7 +15,7 @@ export const SwapRouteCardEssentials = ({ route, dense }) => {
15
15
  const gasCostUSD = parseFloat(route.gasCostUSD ?? '') || 0.01;
16
16
  const gasCosts = getGasCostsBreakdown(route);
17
17
  const feeCosts = getFeeCostsBreakdown(route, false);
18
- return (_jsxs(Box, { display: "flex", justifyContent: 'space-between', flex: 1, mt: 2, children: [_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas, index) => (_jsxs(Typography, { fontSize: 12, children: [gas.amount?.toFixed(9), " ", gas.token.symbol, " (", t(`format.currency`, { value: gas.amountUSD }), ")"] }, `${gas.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(EvStationIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, { value: gasCostUSD }) })] }) }), _jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.additionalProviderFee`), feeCosts.map((fee, index) => (_jsxs(Typography, { fontSize: 12, children: [fee.amount?.toFixed(9), " ", fee.token.symbol, " (", t(`format.currency`, { value: fee.amountUSD }), ")"] }, `${fee.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(MonetizationOnIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, {
18
+ return (_jsxs(Box, { display: "flex", justifyContent: 'space-between', flex: 1, mt: 2, children: [_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas, index) => (_jsxs(Typography, { fontSize: 12, fontWeight: "500", children: [gas.amount?.toFixed(9), " ", gas.token.symbol, " (", t(`format.currency`, { value: gas.amountUSD }), ")"] }, `${gas.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(EvStationIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, { value: gasCostUSD }) })] }) }), _jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.additionalProviderFee`), feeCosts.map((fee, index) => (_jsxs(Typography, { fontSize: 12, fontWeight: "500", children: [fee.amount?.toFixed(9), " ", fee.token.symbol, " (", t(`format.currency`, { value: fee.amountUSD }), ")"] }, `${fee.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(MonetizationOnIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, {
19
19
  value: feeCosts.reduce((sum, feeCost) => sum + feeCost.amountUSD, 0),
20
20
  }) })] }) }), _jsx(Tooltip, { title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(AccessTimeIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t('swap.estimatedTime', {
21
21
  value: executionTimeMinutes,
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "2.0.0-beta.4";
2
+ export declare const version = "2.0.0-beta.6";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '2.0.0-beta.4';
2
+ export const version = '2.0.0-beta.6';
package/hooks/index.d.ts CHANGED
@@ -15,12 +15,13 @@ export * from './useNavigateBack';
15
15
  export * from './useProcessMessage';
16
16
  export * from './useRouteExecution';
17
17
  export * from './useScrollableContainer';
18
+ export * from './useSwapOnly';
18
19
  export * from './useSwapRoutes';
19
20
  export * from './useToken';
20
21
  export * from './useTokenAddressBalance';
21
22
  export * from './useTokenBalance';
22
23
  export * from './useTokenBalances';
23
- export * from './useTokens';
24
24
  export * from './useTokenSearch';
25
+ export * from './useTokens';
25
26
  export * from './useTools';
26
27
  export * from './useWidgetEvents';
package/hooks/index.js CHANGED
@@ -15,12 +15,13 @@ export * from './useNavigateBack';
15
15
  export * from './useProcessMessage';
16
16
  export * from './useRouteExecution';
17
17
  export * from './useScrollableContainer';
18
+ export * from './useSwapOnly';
18
19
  export * from './useSwapRoutes';
19
20
  export * from './useToken';
20
21
  export * from './useTokenAddressBalance';
21
22
  export * from './useTokenBalance';
22
23
  export * from './useTokenBalances';
23
- export * from './useTokens';
24
24
  export * from './useTokenSearch';
25
+ export * from './useTokens';
25
26
  export * from './useTools';
26
27
  export * from './useWidgetEvents';
@@ -1,10 +1,10 @@
1
1
  import { useLayoutEffect, useState } from 'react';
2
- import { createElementId, ElementId } from '../utils';
2
+ import { ElementId, createElementId } from '../utils';
3
3
  import { useDefaultElementId } from './useDefaultElementId';
4
4
  import { getScrollableContainer } from './useScrollableContainer';
5
5
  const getContentHeight = (elementId) => {
6
- const headerElement = document.getElementById(createElementId(ElementId.Header, elementId));
7
6
  const containerElement = document.getElementById(createElementId(ElementId.ScrollableContainer, elementId));
7
+ const headerElement = document.getElementById(createElementId(ElementId.Header, elementId));
8
8
  if (!containerElement || !headerElement) {
9
9
  console.warn(`Can't find ${ElementId.ScrollableContainer} or ${ElementId.Header} id.`);
10
10
  return 0;
@@ -15,11 +15,9 @@ const getContentHeight = (elementId) => {
15
15
  };
16
16
  export const useContentHeight = () => {
17
17
  const elementId = useDefaultElementId();
18
- const [contentHeight, setContentHeight] = useState(() => getContentHeight(elementId));
18
+ const [contentHeight, setContentHeight] = useState(0);
19
19
  useLayoutEffect(() => {
20
- if (!contentHeight) {
21
- setContentHeight(getContentHeight(elementId));
22
- }
20
+ setContentHeight(getContentHeight(elementId));
23
21
  // eslint-disable-next-line react-hooks/exhaustive-deps
24
22
  }, []);
25
23
  return contentHeight;
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-underscore-dangle */
2
1
  import { checkPackageUpdates } from '@lifi/sdk';
3
2
  import { useEffect } from 'react';
4
3
  import { name, version } from '../config/version';
@@ -0,0 +1 @@
1
+ export declare const useSwapOnly: () => boolean;
@@ -0,0 +1,5 @@
1
+ import { useSplitSubvariantStore } from '../stores';
2
+ export const useSwapOnly = () => {
3
+ const state = useSplitSubvariantStore((state) => state.state);
4
+ return state === 'swap';
5
+ };
@@ -7,12 +7,14 @@ import { v4 as uuidv4 } from 'uuid';
7
7
  import { useDebouncedWatch, useGasRefuel, useToken } from '.';
8
8
  import { SwapFormKey, useLiFi, useWallet, useWidgetConfig } from '../providers';
9
9
  import { useSettings } from '../stores';
10
+ import { useSwapOnly } from './useSwapOnly';
10
11
  const refetchTime = 60000;
11
12
  export const useSwapRoutes = ({ onSettled, insurableRoute, } = {}) => {
12
13
  const lifi = useLiFi();
13
14
  const { variant, sdkConfig, insurance, contractTool } = useWidgetConfig();
14
15
  const { account, provider } = useWallet();
15
16
  const queryClient = useQueryClient();
17
+ const swapOnly = useSwapOnly();
16
18
  const { slippage, enabledBridges, enabledAutoRefuel, enabledExchanges, routePriority, } = useSettings([
17
19
  'slippage',
18
20
  'routePriority',
@@ -63,7 +65,7 @@ export const useSwapRoutes = ({ onSettled, insurableRoute, } = {}) => {
63
65
  toContractCallData,
64
66
  toContractGasLimit,
65
67
  slippage,
66
- enabledBridges,
68
+ swapOnly ? [] : enabledBridges,
67
69
  enabledExchanges,
68
70
  routePriority,
69
71
  variant,
package/i18n/en.json CHANGED
@@ -176,9 +176,9 @@
176
176
  "rateChange": "Rate change",
177
177
  "receiving": "Receiving",
178
178
  "refuelStepDetails": "Get gas via {{tool}}",
179
- "selectChain": "Chain",
179
+ "selectChain": "Select chain",
180
180
  "selectChainAndToken": "Select chain and token",
181
- "selectToken": "Token",
181
+ "selectToken": "Select token",
182
182
  "sendToAddress": "Send to {{address}}",
183
183
  "sendToWallet": "Send to a different wallet",
184
184
  "sentToAddress": "Sent to {{address}}",
@@ -251,6 +251,7 @@
251
251
  },
252
252
  "numberOfSteps": "A number of swap steps. Each step can contain 1-2 transactions that require a signature.",
253
253
  "progressToNextUpdate": "Displayed data will auto-refresh after {{value}} seconds. Click here to update manually.",
254
+ "recommended": "A cheap route that balances complexity and ease of use.",
254
255
  "settingsModified": "Settings (modified)"
255
256
  },
256
257
  "wallet": {
package/i18n/pt.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "button": {
3
3
  "auto": "Automático",
4
+ "buy": "Comprar",
5
+ "buyNow": "Comprar agora",
4
6
  "cancel": "Cancelar",
5
7
  "connectWallet": "Conectar carteira",
6
8
  "contactSupport": "Falar com o suporte",
@@ -23,6 +25,7 @@
23
25
  "resetSettings": "Redefinir as configurações",
24
26
  "restartSwap": "Reiniciar a conversão",
25
27
  "reviewGasSwap": "Rever o gás de conversão",
28
+ "reviewPurchase": "Revisar compra",
26
29
  "reviewSwap": "Rever conversão",
27
30
  "seeDetails": "Ver detalhes",
28
31
  "showAll": "Mostrar tudo",
@@ -39,10 +42,14 @@
39
42
  },
40
43
  "header": {
41
44
  "activeSwaps": "Conversões ativas",
45
+ "bridge": "Ponte",
42
46
  "checkout": "Finalizar",
43
47
  "from": "Converter a partir de",
44
48
  "gas": "Gás",
45
49
  "gasSwap": "Conversão de gás",
50
+ "payWith": "Pagar com",
51
+ "purchase": "Compra",
52
+ "purchaseDetails": "Detalhes da compra",
46
53
  "routes": "Você recebe",
47
54
  "selectChain": "Selecionar uma rede",
48
55
  "selectWallet": "Selecionar sua carteira",
@@ -75,6 +82,7 @@
75
82
  "currentAmount": "Quantidade atual",
76
83
  "error": {
77
84
  "message": {
85
+ "allowanceRequired": "A quantidade a ser transferida para {{tokenSymbol}} excede a sua permissão atual. Por favor, aumente a sua permissão e tente novamente.",
78
86
  "slippageThreshold": "A derrapagem é maior do que o limite definido. Solicite uma nova rota para obter uma nova cotação.",
79
87
  "transactionFailed": "Por favor, verifique o explorador de blocos para mais informações.",
80
88
  "transactionNotSent": "A transação não foi enviada. {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} na {{chainName}} permanece na sua carteira.",
@@ -82,6 +90,7 @@
82
90
  "unknown": "Por favor, tente novamente ou fale com o suporte."
83
91
  },
84
92
  "title": {
93
+ "allowanceRequired": "Permissão insuficiente",
85
94
  "balanceIsTooLow": "O saldo é muito baixo",
86
95
  "chainSwitch": "Necessário mudança de rede",
87
96
  "failed": "Conversão falhou",
@@ -131,7 +140,6 @@
131
140
  "onChain": "em {{nome da rede}}",
132
141
  "otherTokens": "Outros tokens",
133
142
  "ownedBy": "Possuído por",
134
- "payWith": "Pagar com",
135
143
  "process": {
136
144
  "crossChain": {
137
145
  "actionRequired": "Por favor, assine a transação",
@@ -139,6 +147,9 @@
139
147
  "pending": "Aguardando a transação da ponte",
140
148
  "started": "Preparando a transação da ponte"
141
149
  },
150
+ "nft": {
151
+ "done": "NFT comprado"
152
+ },
142
153
  "receivingChain": {
143
154
  "done": "Ponte concluída",
144
155
  "partial": "Ponte parcialmente concluída",
@@ -165,24 +176,27 @@
165
176
  "rateChange": "Alterar taxa",
166
177
  "receiving": "Recebendo",
167
178
  "refuelStepDetails": "Obter gás via {{tool}}",
168
- "routes": "Você recebe",
169
- "selectChain": "Rede",
179
+ "selectChain": "Selecione a rede",
170
180
  "selectChainAndToken": "Selecione a rede e o token",
171
- "selectToken": "Token",
181
+ "selectToken": "Selecione o Token",
172
182
  "sendToAddress": "Enviar para",
173
183
  "sendToWallet": "Enviar para uma carteira diferente",
174
184
  "sentToAddress": "Enviar para",
175
185
  "stepBridge": "Ponte",
186
+ "stepBridgeAndBuy": "Transfira e compre",
176
187
  "stepDetails": "{{tool}} via LI.FI",
177
188
  "stepSwap": "Conversão",
178
189
  "stepSwapAndBridge": "Converter e enviar pela ponte",
190
+ "stepSwapAndBuy": "Converta e compre",
179
191
  "success": {
180
192
  "message": {
181
193
  "swapPartiallySuccessful": "Tentamos completar a conversão, mas a {{tool}} ficou sem liquidez para o token {{tokenSymbol}}.",
194
+ "purchaseSuccessful": "Agora você tem {{assetName}} na carteira {{walletAddress}} na cadeia {{chainName}}",
182
195
  "swapSuccessful": "Agora há {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} na carteira {{walletAddress}} na rede {{chainName}}."
183
196
  },
184
197
  "title": {
185
198
  "gasSwapSuccessful": "Conversão de gás bem sucedida",
199
+ "purchaseSuccessful": "Compra efetuada com sucesso",
186
200
  "refundIssued": "Reembolso emitido",
187
201
  "swapPartiallySuccessful": "Conversão parcialmente bem sucedida",
188
202
  "swapSuccessful": "Conversão bem sucedida"
@@ -237,6 +251,7 @@
237
251
  },
238
252
  "numberOfSteps": "Um número de passos para a conversão. Cada etapa pode conter 1-2 transações que requerem uma assinatura.",
239
253
  "progressToNextUpdate": "Os dados exibidos serão atualizados automaticamente após {{value}} segundos. Clique aqui para atualizar manualmente.",
254
+ "recommended": "Uma rota econômica que equilibra complexidade e facilidade de uso.",
240
255
  "settingsModified": "Configurações (modificado)"
241
256
  },
242
257
  "wallet": {