@lifi/widget 3.7.0-beta.7 → 3.7.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/AppProvider.tsx +6 -4
- package/AppRoutes.tsx +14 -2
- package/CHANGELOG.md +22 -0
- package/_esm/AppProvider.js +3 -2
- package/_esm/AppProvider.js.map +1 -1
- package/_esm/AppRoutes.js +9 -2
- package/_esm/AppRoutes.js.map +1 -1
- package/_esm/components/ActiveTransactions/ActiveTransactions.style.js +1 -1
- package/_esm/components/ActiveTransactions/ActiveTransactions.style.js.map +1 -1
- package/_esm/components/AmountInput/AmountInputEndAdornment.js +3 -1
- package/_esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
- package/_esm/components/AppContainer.js +10 -5
- package/_esm/components/AppContainer.js.map +1 -1
- package/_esm/components/Avatar/AccountAvatar.d.ts +1 -1
- package/_esm/components/Avatar/AccountAvatar.js +1 -1
- package/_esm/components/Avatar/AccountAvatar.js.map +1 -1
- package/_esm/components/Avatar/Avatar.d.ts +0 -1
- package/_esm/components/Avatar/Avatar.js +4 -7
- package/_esm/components/Avatar/Avatar.js.map +1 -1
- package/_esm/components/Avatar/Avatar.style.d.ts +3 -6
- package/_esm/components/Avatar/Avatar.style.js +6 -19
- package/_esm/components/Avatar/Avatar.style.js.map +1 -1
- package/_esm/components/Avatar/TokenAvatar.js +1 -1
- package/_esm/components/Avatar/TokenAvatar.js.map +1 -1
- package/_esm/components/BaseTransactionButton/BaseTransactionButton.js +5 -3
- package/_esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
- package/_esm/components/ChainSelect/useChainSelect.js +1 -5
- package/_esm/components/ChainSelect/useChainSelect.js.map +1 -1
- package/_esm/components/FeeBreakdownTooltip.js +1 -4
- package/_esm/components/FeeBreakdownTooltip.js.map +1 -1
- package/_esm/components/FullPageContainer.d.ts +2 -0
- package/_esm/components/FullPageContainer.js +9 -0
- package/_esm/components/FullPageContainer.js.map +1 -0
- package/_esm/components/Header/EVMDisconnectIconButton.d.ts +4 -0
- package/_esm/components/Header/EVMDisconnectIconButton.js +12 -0
- package/_esm/components/Header/EVMDisconnectIconButton.js.map +1 -0
- package/_esm/components/Header/Header.js +23 -3
- package/_esm/components/Header/Header.js.map +1 -1
- package/_esm/components/Header/NavigationHeader.js +1 -1
- package/_esm/components/Header/NavigationHeader.js.map +1 -1
- package/_esm/components/Header/SVMDisconnectIconButton.d.ts +1 -0
- package/_esm/components/Header/SVMDisconnectIconButton.js +12 -0
- package/_esm/components/Header/SVMDisconnectIconButton.js.map +1 -0
- package/_esm/components/Header/WalletHeader.js +9 -5
- package/_esm/components/Header/WalletHeader.js.map +1 -1
- package/_esm/components/Header/WalletMenu.js +18 -10
- package/_esm/components/Header/WalletMenu.js.map +1 -1
- package/_esm/components/Header/WalletMenu.style.js +1 -5
- package/_esm/components/Header/WalletMenu.style.js.map +1 -1
- package/_esm/components/PageContainer.d.ts +2 -1
- package/_esm/components/PageContainer.js.map +1 -1
- package/_esm/components/PageEntered.d.ts +1 -0
- package/_esm/components/PageEntered.js +13 -0
- package/_esm/components/PageEntered.js.map +1 -0
- package/_esm/components/Routes/RoutesExpanded.js +1 -1
- package/_esm/components/Routes/RoutesExpanded.js.map +1 -1
- package/_esm/components/Search/SearchInput.d.ts +11 -0
- package/_esm/components/Search/SearchInput.js +21 -0
- package/_esm/components/Search/SearchInput.js.map +1 -0
- package/_esm/components/Search/SearchInput.style.d.ts +12 -0
- package/_esm/components/Search/SearchInput.style.js +38 -0
- package/_esm/components/Search/SearchInput.style.js.map +1 -0
- package/_esm/components/Search/SearchNotFound.d.ts +6 -0
- package/_esm/components/Search/SearchNotFound.js +5 -0
- package/_esm/components/Search/SearchNotFound.js.map +1 -0
- package/_esm/components/Search/SearchNotFound.style.d.ts +14 -0
- package/_esm/components/Search/SearchNotFound.style.js +29 -0
- package/_esm/components/Search/SearchNotFound.style.js.map +1 -0
- package/_esm/components/SendToWallet/SendToWalletButton.js +1 -1
- package/_esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/_esm/components/Skeleton/WidgetSkeleton.js +3 -4
- package/_esm/components/Skeleton/WidgetSkeleton.js.map +1 -1
- package/_esm/components/Skeleton/WidgetSkeleton.style.d.ts +3 -0
- package/_esm/components/Skeleton/WidgetSkeleton.style.js +20 -1
- package/_esm/components/Skeleton/WidgetSkeleton.style.js.map +1 -1
- package/_esm/components/SmallAvatar.d.ts +10 -0
- package/_esm/components/SmallAvatar.js +19 -0
- package/_esm/components/SmallAvatar.js.map +1 -0
- package/_esm/components/StepActions/StepActions.js +1 -1
- package/_esm/components/StepActions/StepActions.js.map +1 -1
- package/_esm/components/Tabs/Tabs.style.d.ts +1 -1
- package/_esm/components/Token/Token.js +1 -1
- package/_esm/components/Token/Token.js.map +1 -1
- package/_esm/components/TokenList/TokenList.js +2 -5
- package/_esm/components/TokenList/TokenList.js.map +1 -1
- package/_esm/components/TokenList/TokenListItem.js +5 -11
- package/_esm/components/TokenList/TokenListItem.js.map +1 -1
- package/_esm/components/TokenList/TokenNotFound.js +5 -13
- package/_esm/components/TokenList/TokenNotFound.js.map +1 -1
- package/_esm/components/TokenList/VirtualizedTokenList.js +1 -1
- package/_esm/components/TokenList/VirtualizedTokenList.js.map +1 -1
- package/_esm/components/TokenList/types.d.ts +3 -3
- package/_esm/components/TokenRate/TokenRate.js +2 -2
- package/_esm/components/TokenRate/TokenRate.js.map +1 -1
- package/_esm/config/version.d.ts +1 -1
- package/_esm/config/version.js +1 -1
- package/_esm/config/version.js.map +1 -1
- package/_esm/hooks/useAccount.d.ts +45 -0
- package/_esm/hooks/useAccount.js +56 -0
- package/_esm/hooks/useAccount.js.map +1 -0
- package/_esm/hooks/useAvailableChains.d.ts +1 -2
- package/_esm/hooks/useAvailableChains.js +8 -9
- package/_esm/hooks/useAvailableChains.js.map +1 -1
- package/_esm/hooks/useChains.d.ts +3 -4
- package/_esm/hooks/useChains.js +3 -5
- package/_esm/hooks/useChains.js.map +1 -1
- package/_esm/hooks/useFromTokenSufficiency.js +1 -1
- package/_esm/hooks/useFromTokenSufficiency.js.map +1 -1
- package/_esm/hooks/useGasSufficiency.js +3 -3
- package/_esm/hooks/useGasSufficiency.js.map +1 -1
- package/_esm/hooks/useProcessMessage.js +0 -4
- package/_esm/hooks/useProcessMessage.js.map +1 -1
- package/_esm/hooks/useRouteExecution.js +1 -1
- package/_esm/hooks/useRouteExecution.js.map +1 -1
- package/_esm/hooks/useRoutes.js +3 -2
- package/_esm/hooks/useRoutes.js.map +1 -1
- package/_esm/hooks/useScrollableContainer.d.ts +0 -1
- package/_esm/hooks/useScrollableContainer.js +1 -2
- package/_esm/hooks/useScrollableContainer.js.map +1 -1
- package/_esm/hooks/useSetContentHeight.js +9 -6
- package/_esm/hooks/useSetContentHeight.js.map +1 -1
- package/_esm/hooks/useTokenBalance.js +1 -1
- package/_esm/hooks/useTokenBalance.js.map +1 -1
- package/_esm/hooks/useTokenBalances.js +1 -1
- package/_esm/hooks/useTokenBalances.js.map +1 -1
- package/_esm/hooks/useTokens.js +1 -1
- package/_esm/hooks/useTokens.js.map +1 -1
- package/_esm/hooks/useTransactionDetails.js +1 -1
- package/_esm/hooks/useTransactionDetails.js.map +1 -1
- package/_esm/hooks/useTransactionHistory.js +1 -1
- package/_esm/hooks/useTransactionHistory.js.map +1 -1
- package/_esm/hooks/useWallets.d.ts +6 -0
- package/_esm/hooks/useWallets.js +80 -0
- package/_esm/hooks/useWallets.js.map +1 -0
- package/_esm/i18n/en.json +11 -4
- package/_esm/index.d.ts +2 -0
- package/_esm/index.js +2 -0
- package/_esm/index.js.map +1 -1
- package/_esm/pages/RoutesPage/RoutesPage.js +1 -1
- package/_esm/pages/RoutesPage/RoutesPage.js.map +1 -1
- package/_esm/pages/SelectChainPage/SelectChainPage.js +27 -8
- package/_esm/pages/SelectChainPage/SelectChainPage.js.map +1 -1
- package/_esm/pages/SelectEnabledToolsPage.js +38 -16
- package/_esm/pages/SelectEnabledToolsPage.js.map +1 -1
- package/_esm/pages/SelectTokenPage/SearchTokenInput.js +2 -12
- package/_esm/pages/SelectTokenPage/SearchTokenInput.js.map +1 -1
- package/_esm/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/_esm/pages/SelectTokenPage/SelectTokenPage.js.map +1 -1
- package/_esm/pages/SelectTokenPage/useTokenListHeight.js +8 -14
- package/_esm/pages/SelectTokenPage/useTokenListHeight.js.map +1 -1
- package/_esm/pages/SelectWalletPage/EVMListItemButton.d.ts +9 -0
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js +39 -0
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js.map +1 -0
- package/_esm/pages/SelectWalletPage/SVMListItemButton.d.ts +6 -0
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js +32 -0
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js.map +1 -0
- package/_esm/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -0
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js +41 -0
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js.map +1 -0
- package/_esm/pages/SendToWallet/ConnectedWalletsPage.js +1 -1
- package/_esm/pages/SendToWallet/ConnectedWalletsPage.js.map +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.js +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
- package/_esm/pages/TransactionPage/StatusBottomSheet.js +5 -5
- package/_esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
- package/_esm/providers/I18nProvider/types.d.ts +2 -2
- package/_esm/providers/WalletProvider/SDKProviders.js +7 -15
- package/_esm/providers/WalletProvider/SDKProviders.js.map +1 -1
- package/_esm/providers/WalletProvider/WalletProvider.d.ts +0 -1
- package/_esm/providers/WalletProvider/WalletProvider.js +1 -14
- package/_esm/providers/WalletProvider/WalletProvider.js.map +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.d.ts +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js +3 -8
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js.map +1 -1
- package/_esm/providers/WidgetProvider/WidgetProvider.js +1 -2
- package/_esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
- package/_esm/providers/WidgetProvider/types.d.ts +2 -0
- package/_esm/stores/form/FormUpdater.js +1 -1
- package/_esm/stores/form/FormUpdater.js.map +1 -1
- package/_esm/stores/form/types.d.ts +4 -4
- package/_esm/stores/header/types.d.ts +2 -0
- package/_esm/stores/header/useHeaderStore.d.ts +7 -1
- package/_esm/stores/header/useHeaderStore.js +26 -2
- package/_esm/stores/header/useHeaderStore.js.map +1 -1
- package/_esm/stores/routes/useExecutingRoutesIds.js +1 -1
- package/_esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
- package/_esm/stores/settings/types.d.ts +1 -1
- package/_esm/stores/settings/useSettingsStore.js +22 -9
- package/_esm/stores/settings/useSettingsStore.js.map +1 -1
- package/_esm/themes/createTheme.js +1 -2
- package/_esm/themes/createTheme.js.map +1 -1
- package/_esm/types/events.d.ts +6 -6
- package/_esm/types/events.js +3 -2
- package/_esm/types/events.js.map +1 -1
- package/_esm/utils/chainType.js +3 -2
- package/_esm/utils/chainType.js.map +1 -1
- package/_esm/utils/converters.js +2 -1
- package/_esm/utils/converters.js.map +1 -1
- package/_esm/utils/elements.d.ts +5 -2
- package/_esm/utils/elements.js +6 -1
- package/_esm/utils/elements.js.map +1 -1
- package/_esm/utils/fees.js +5 -9
- package/_esm/utils/fees.js.map +1 -1
- package/_esm/utils/format.js +1 -1
- package/_esm/utils/format.js.map +1 -1
- package/_esm/utils/navigationRoutes.d.ts +3 -1
- package/_esm/utils/navigationRoutes.js +3 -0
- package/_esm/utils/navigationRoutes.js.map +1 -1
- package/_esm/utils/svm.d.ts +1 -0
- package/_esm/utils/svm.js +11 -0
- package/_esm/utils/svm.js.map +1 -0
- package/_esm/utils/wallet.js +1 -1
- package/components/ActiveTransactions/ActiveTransactions.style.ts +1 -1
- package/components/AmountInput/AmountInputEndAdornment.tsx +5 -1
- package/components/AppContainer.tsx +15 -10
- package/components/Avatar/AccountAvatar.tsx +2 -2
- package/components/Avatar/Avatar.style.tsx +7 -20
- package/components/Avatar/Avatar.tsx +4 -12
- package/components/Avatar/TokenAvatar.tsx +1 -1
- package/components/BaseTransactionButton/BaseTransactionButton.tsx +5 -3
- package/components/ChainSelect/useChainSelect.ts +1 -10
- package/components/FeeBreakdownTooltip.tsx +1 -4
- package/components/FullPageContainer.tsx +14 -0
- package/components/Header/EVMDisconnectIconButton.tsx +24 -0
- package/components/Header/Header.tsx +28 -3
- package/components/Header/NavigationHeader.tsx +1 -1
- package/components/Header/SVMDisconnectIconButton.tsx +19 -0
- package/components/Header/WalletHeader.tsx +12 -11
- package/components/Header/WalletMenu.style.tsx +1 -5
- package/components/Header/WalletMenu.tsx +32 -22
- package/components/PageContainer.ts +2 -1
- package/components/PageEntered.ts +14 -0
- package/components/Routes/RoutesExpanded.tsx +2 -1
- package/components/Search/SearchInput.style.tsx +46 -0
- package/components/Search/SearchInput.tsx +57 -0
- package/components/Search/SearchNotFound.style.tsx +36 -0
- package/components/Search/SearchNotFound.tsx +23 -0
- package/components/SendToWallet/SendToWalletButton.tsx +1 -1
- package/components/Skeleton/WidgetSkeleton.style.tsx +21 -1
- package/components/Skeleton/WidgetSkeleton.tsx +10 -9
- package/components/SmallAvatar.tsx +25 -0
- package/components/StepActions/StepActions.tsx +1 -1
- package/components/Token/Token.tsx +1 -1
- package/components/TokenList/TokenList.tsx +2 -9
- package/components/TokenList/TokenListItem.tsx +7 -15
- package/components/TokenList/TokenNotFound.tsx +7 -27
- package/components/TokenList/VirtualizedTokenList.tsx +1 -1
- package/components/TokenList/types.ts +3 -3
- package/components/TokenRate/TokenRate.tsx +2 -2
- package/config/version.ts +1 -1
- package/hooks/useAccount.ts +109 -0
- package/hooks/useAvailableChains.ts +10 -9
- package/hooks/useChains.ts +3 -6
- package/hooks/useFromTokenSufficiency.ts +1 -1
- package/hooks/useGasSufficiency.ts +3 -5
- package/hooks/useProcessMessage.ts +0 -4
- package/hooks/useRouteExecution.ts +1 -1
- package/hooks/useRoutes.ts +3 -2
- package/hooks/useScrollableContainer.ts +1 -6
- package/hooks/useSetContentHeight.ts +10 -6
- package/hooks/useTokenBalance.ts +1 -1
- package/hooks/useTokenBalances.ts +1 -1
- package/hooks/useTokens.ts +1 -2
- package/hooks/useTransactionDetails.ts +1 -1
- package/hooks/useTransactionHistory.ts +1 -1
- package/hooks/useWallets.ts +147 -0
- package/i18n/en.json +11 -4
- package/index.ts +2 -0
- package/package.json +4 -3
- package/pages/RoutesPage/RoutesPage.tsx +1 -1
- package/pages/SelectChainPage/SelectChainPage.tsx +62 -23
- package/pages/SelectEnabledToolsPage.tsx +94 -37
- package/pages/SelectTokenPage/SearchTokenInput.tsx +8 -26
- package/pages/SelectTokenPage/SelectTokenPage.tsx +3 -3
- package/pages/SelectTokenPage/useTokenListHeight.ts +14 -21
- package/pages/SelectWalletPage/EVMListItemButton.tsx +74 -0
- package/pages/SelectWalletPage/SVMListItemButton.tsx +47 -0
- package/pages/SelectWalletPage/SelectWalletPage.tsx +90 -0
- package/pages/SendToWallet/ConnectedWalletsPage.tsx +2 -2
- package/pages/SendToWallet/SendToWalletPage.tsx +1 -1
- package/pages/TransactionPage/StatusBottomSheet.tsx +6 -8
- package/providers/I18nProvider/types.ts +2 -2
- package/providers/WalletProvider/SDKProviders.tsx +7 -25
- package/providers/WalletProvider/WalletProvider.tsx +3 -24
- package/providers/WalletProvider/useHasExternalWalletProvider.ts +5 -11
- package/providers/WidgetProvider/WidgetProvider.tsx +1 -2
- package/providers/WidgetProvider/types.ts +2 -0
- package/stores/form/FormUpdater.tsx +1 -1
- package/stores/form/types.ts +4 -4
- package/stores/header/types.ts +2 -0
- package/stores/header/useHeaderStore.tsx +40 -2
- package/stores/routes/useExecutingRoutesIds.ts +1 -1
- package/stores/settings/types.ts +1 -1
- package/stores/settings/useSettingsStore.ts +30 -9
- package/themes/createTheme.ts +1 -3
- package/types/events.ts +5 -5
- package/utils/chainType.ts +3 -2
- package/utils/converters.ts +2 -1
- package/utils/elements.ts +21 -1
- package/utils/fees.ts +13 -15
- package/utils/format.ts +1 -1
- package/utils/navigationRoutes.ts +7 -1
- package/utils/svm.ts +10 -0
- package/utils/wallet.ts +1 -1
- package/_esm/components/Avatar/SmallAvatar.d.ts +0 -4
- package/_esm/components/Avatar/SmallAvatar.js +0 -12
- package/_esm/components/Avatar/SmallAvatar.js.map +0 -1
- package/_esm/components/Header/DisconnectIconButton.d.ts +0 -4
- package/_esm/components/Header/DisconnectIconButton.js +0 -12
- package/_esm/components/Header/DisconnectIconButton.js.map +0 -1
- package/_esm/hooks/useHeaderHeight.d.ts +0 -6
- package/_esm/hooks/useHeaderHeight.js +0 -23
- package/_esm/hooks/useHeaderHeight.js.map +0 -1
- package/_esm/providers/WalletProvider/UTXOBaseProvider.d.ts +0 -2
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js +0 -17
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js.map +0 -1
- package/_esm/providers/WalletProvider/UTXOExternalContext.d.ts +0 -1
- package/_esm/providers/WalletProvider/UTXOExternalContext.js +0 -3
- package/_esm/providers/WalletProvider/UTXOExternalContext.js.map +0 -1
- package/_esm/providers/WalletProvider/UTXOProvider.d.ts +0 -3
- package/_esm/providers/WalletProvider/UTXOProvider.js +0 -18
- package/_esm/providers/WalletProvider/UTXOProvider.js.map +0 -1
- package/components/Avatar/SmallAvatar.tsx +0 -16
- package/components/Header/DisconnectIconButton.tsx +0 -18
- package/hooks/useHeaderHeight.ts +0 -27
- package/providers/WalletProvider/UTXOBaseProvider.tsx +0 -28
- package/providers/WalletProvider/UTXOExternalContext.ts +0 -3
- package/providers/WalletProvider/UTXOProvider.tsx +0 -26
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
AvatarGroup,
|
|
4
4
|
Box,
|
|
5
5
|
Avatar as MuiAvatar,
|
|
6
|
+
Skeleton,
|
|
6
7
|
avatarClasses,
|
|
7
8
|
badgeClasses,
|
|
8
9
|
styled,
|
|
@@ -13,20 +14,17 @@ export const AvatarMasked = styled(MuiAvatar)(({ theme }) => ({
|
|
|
13
14
|
mask: avatarMask16,
|
|
14
15
|
}));
|
|
15
16
|
|
|
17
|
+
export const AvatarSkeleton = styled(Skeleton)(({ theme }) => ({
|
|
18
|
+
mask: avatarMask16,
|
|
19
|
+
}));
|
|
20
|
+
|
|
16
21
|
export const TokenAvatarGroup = styled(AvatarGroup)(({ theme }) => ({
|
|
17
22
|
[`& .${badgeClasses.badge}:last-child .${avatarClasses.root}`]: {
|
|
18
|
-
boxSizing: 'border-box',
|
|
19
|
-
},
|
|
20
|
-
[`& .${avatarClasses.root}`]: {
|
|
21
|
-
border: 'none',
|
|
22
|
-
marginLeft: 0,
|
|
23
|
-
},
|
|
24
|
-
[`& .${badgeClasses.root}:first-child`]: {
|
|
25
23
|
marginLeft: theme.spacing(-1),
|
|
26
|
-
|
|
24
|
+
boxSizing: 'border-box',
|
|
27
25
|
},
|
|
28
26
|
[`& .${badgeClasses.root}:last-child`]: {
|
|
29
|
-
|
|
27
|
+
marginLeft: theme.spacing(1),
|
|
30
28
|
},
|
|
31
29
|
}));
|
|
32
30
|
|
|
@@ -59,14 +57,3 @@ export const AvatarDefaultBadge = styled(Box)(({ theme }) => {
|
|
|
59
57
|
width: 16,
|
|
60
58
|
};
|
|
61
59
|
});
|
|
62
|
-
|
|
63
|
-
export const AvatarSkeletonContainer = styled(Box)(({ theme }) => ({
|
|
64
|
-
background: theme.palette.background.paper,
|
|
65
|
-
borderRadius: '50%',
|
|
66
|
-
}));
|
|
67
|
-
|
|
68
|
-
export const AvatarSkeletonMaskedContainer = styled(Box)(({ theme }) => ({
|
|
69
|
-
background: theme.palette.background.paper,
|
|
70
|
-
borderRadius: '50%',
|
|
71
|
-
mask: avatarMask16,
|
|
72
|
-
}));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { SxProps, Theme } from '@mui/material';
|
|
2
|
-
import { Badge
|
|
2
|
+
import { Badge } from '@mui/material';
|
|
3
|
+
import { SmallAvatarSkeleton } from '../SmallAvatar.js';
|
|
3
4
|
import {
|
|
4
5
|
AvatarDefault,
|
|
5
6
|
AvatarDefaultBadge,
|
|
6
|
-
|
|
7
|
+
AvatarSkeleton,
|
|
7
8
|
} from './Avatar.style.js';
|
|
8
|
-
import { SmallAvatarSkeleton } from './SmallAvatar.js';
|
|
9
9
|
|
|
10
10
|
export const AvatarBadgedDefault: React.FC<{
|
|
11
11
|
sx?: SxProps<Theme>;
|
|
@@ -32,15 +32,7 @@ export const AvatarBadgedSkeleton: React.FC<{
|
|
|
32
32
|
badgeContent={<SmallAvatarSkeleton />}
|
|
33
33
|
sx={sx}
|
|
34
34
|
>
|
|
35
|
-
<AvatarSkeleton />
|
|
35
|
+
<AvatarSkeleton width={40} height={40} variant="circular" />
|
|
36
36
|
</Badge>
|
|
37
37
|
);
|
|
38
38
|
};
|
|
39
|
-
|
|
40
|
-
export const AvatarSkeleton = () => {
|
|
41
|
-
return (
|
|
42
|
-
<AvatarSkeletonMaskedContainer>
|
|
43
|
-
<Skeleton width={40} height={40} variant="circular" />
|
|
44
|
-
</AvatarSkeletonMaskedContainer>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
@@ -3,9 +3,9 @@ import type { SxProps, Theme } from '@mui/material';
|
|
|
3
3
|
import { Badge } from '@mui/material';
|
|
4
4
|
import { useChain } from '../../hooks/useChain.js';
|
|
5
5
|
import { useToken } from '../../hooks/useToken.js';
|
|
6
|
+
import { SmallAvatar } from '../SmallAvatar.js';
|
|
6
7
|
import { AvatarBadgedSkeleton } from './Avatar.js';
|
|
7
8
|
import { AvatarDefaultBadge, AvatarMasked } from './Avatar.style.js';
|
|
8
|
-
import { SmallAvatar } from './SmallAvatar.js';
|
|
9
9
|
|
|
10
10
|
export const TokenAvatar: React.FC<{
|
|
11
11
|
token?: StaticToken;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { useAccount, useWalletMenu } from '@lifi/wallet-management';
|
|
2
1
|
import { LoadingButton } from '@mui/lab';
|
|
3
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { useNavigate } from 'react-router-dom';
|
|
4
|
+
import { useAccount } from '../../hooks/useAccount.js';
|
|
4
5
|
import { useChain } from '../../hooks/useChain.js';
|
|
5
6
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
6
7
|
import { useFieldValues } from '../../stores/form/useFieldValues.js';
|
|
8
|
+
import { navigationRoutes } from '../../utils/navigationRoutes.js';
|
|
7
9
|
import type { BaseTransactionButtonProps } from './types.js';
|
|
8
10
|
|
|
9
11
|
export const BaseTransactionButton: React.FC<BaseTransactionButtonProps> = ({
|
|
@@ -13,8 +15,8 @@ export const BaseTransactionButton: React.FC<BaseTransactionButtonProps> = ({
|
|
|
13
15
|
loading,
|
|
14
16
|
}) => {
|
|
15
17
|
const { t } = useTranslation();
|
|
18
|
+
const navigate = useNavigate();
|
|
16
19
|
const { walletConfig } = useWidgetConfig();
|
|
17
|
-
const { openWalletMenu } = useWalletMenu();
|
|
18
20
|
const [fromChainId] = useFieldValues('fromChain');
|
|
19
21
|
const { chain } = useChain(fromChainId);
|
|
20
22
|
const { account } = useAccount({ chainType: chain?.chainType });
|
|
@@ -25,7 +27,7 @@ export const BaseTransactionButton: React.FC<BaseTransactionButtonProps> = ({
|
|
|
25
27
|
} else if (walletConfig?.onConnect) {
|
|
26
28
|
walletConfig.onConnect();
|
|
27
29
|
} else {
|
|
28
|
-
|
|
30
|
+
navigate(navigationRoutes.selectWallet);
|
|
29
31
|
}
|
|
30
32
|
};
|
|
31
33
|
|
|
@@ -2,7 +2,6 @@ import type { EVMChain } from '@lifi/sdk';
|
|
|
2
2
|
import { useChains } from '../../hooks/useChains.js';
|
|
3
3
|
import { useSwapOnly } from '../../hooks/useSwapOnly.js';
|
|
4
4
|
import { useToAddressReset } from '../../hooks/useToAddressReset.js';
|
|
5
|
-
import { useHasExternalWalletProvider } from '../../providers/WalletProvider/useHasExternalWalletProvider.js';
|
|
6
5
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
7
6
|
import { useChainOrder } from '../../stores/chains/useChainOrder.js';
|
|
8
7
|
import type { FormType } from '../../stores/form/types.js';
|
|
@@ -16,15 +15,7 @@ export const useChainSelect = (formType: FormType) => {
|
|
|
16
15
|
const chainKey = FormKeyHelper.getChainKey(formType);
|
|
17
16
|
const { onChange } = useFieldController({ name: chainKey });
|
|
18
17
|
const { setFieldValue, getFieldValues } = useFieldActions();
|
|
19
|
-
const {
|
|
20
|
-
useHasExternalWalletProvider();
|
|
21
|
-
const { chains, isLoading, getChainById } = useChains(
|
|
22
|
-
formType,
|
|
23
|
-
formType === 'from' && hasExternalProvider
|
|
24
|
-
? availableChainTypes
|
|
25
|
-
: undefined,
|
|
26
|
-
);
|
|
27
|
-
|
|
18
|
+
const { chains, isLoading, getChainById } = useChains(formType);
|
|
28
19
|
const [chainOrder, setChainOrder] = useChainOrder(formType);
|
|
29
20
|
const swapOnly = useSwapOnly();
|
|
30
21
|
const { tryResetToAddress } = useToAddressReset();
|
|
@@ -54,10 +54,7 @@ export const getFeeBreakdownTypography = (
|
|
|
54
54
|
key={`${fee.token.address}${index}`}
|
|
55
55
|
>
|
|
56
56
|
{t(`format.currency`, { value: fee.amountUSD })} (
|
|
57
|
-
{
|
|
58
|
-
value: parseFloat(formatUnits(fee.amount, fee.token.decimals)),
|
|
59
|
-
maximumFractionDigits: Math.min(fee.token.decimals, 9),
|
|
60
|
-
})}{' '}
|
|
57
|
+
{parseFloat(formatUnits(fee.amount, fee.token.decimals))?.toFixed(9)}{' '}
|
|
61
58
|
{fee.token.symbol})
|
|
62
59
|
</Typography>
|
|
63
60
|
));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { styled } from '@mui/material';
|
|
2
|
+
import type { PageContainerProps } from './PageContainer.js';
|
|
3
|
+
import { PageContainer } from './PageContainer.js';
|
|
4
|
+
|
|
5
|
+
// In max height and default layout
|
|
6
|
+
// the PageContainer collapses to use the minimum space need to display its child components whereas
|
|
7
|
+
// the FullPageContainer expands and fills the available vertical space provide by the max-height
|
|
8
|
+
// See the CssBaselineContainer component styles in AppContainer.tsx for usage of full-page-container
|
|
9
|
+
export const FullPageContainer = styled((props: PageContainerProps) => (
|
|
10
|
+
<PageContainer
|
|
11
|
+
{...props}
|
|
12
|
+
className={`${props.className} full-page-container`}
|
|
13
|
+
/>
|
|
14
|
+
))``;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PowerSettingsNewRounded } from '@mui/icons-material';
|
|
2
|
+
import { IconButton } from '@mui/material';
|
|
3
|
+
import type { Connector } from 'wagmi';
|
|
4
|
+
import { useDisconnect } from 'wagmi';
|
|
5
|
+
|
|
6
|
+
export const EVMDisconnectIconButton = ({
|
|
7
|
+
connector,
|
|
8
|
+
}: {
|
|
9
|
+
connector?: Connector;
|
|
10
|
+
}) => {
|
|
11
|
+
const { disconnect } = useDisconnect();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<IconButton
|
|
15
|
+
size="medium"
|
|
16
|
+
onClick={(e) => {
|
|
17
|
+
e.stopPropagation();
|
|
18
|
+
disconnect({ connector });
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
<PowerSettingsNewRounded />
|
|
22
|
+
</IconButton>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { useLayoutEffect, useRef } from 'react';
|
|
2
3
|
import { useLocation } from 'react-router-dom';
|
|
3
4
|
import { useDefaultElementId } from '../../hooks/useDefaultElementId.js';
|
|
4
|
-
import {
|
|
5
|
+
import { useSetHeaderHeight } from '../../stores/header/useHeaderStore.js';
|
|
5
6
|
import { ElementId, createElementId } from '../../utils/elements.js';
|
|
6
7
|
import { stickyHeaderRoutes } from '../../utils/navigationRoutes.js';
|
|
7
8
|
import { Container } from './Header.style.js';
|
|
@@ -11,13 +12,37 @@ import { WalletHeader } from './WalletHeader.js';
|
|
|
11
12
|
export const HeaderContainer: FC<PropsWithChildren<{}>> = ({ children }) => {
|
|
12
13
|
const { pathname } = useLocation();
|
|
13
14
|
const elementId = useDefaultElementId();
|
|
14
|
-
const
|
|
15
|
+
const headerRef = useRef<HTMLDivElement>(null);
|
|
16
|
+
const { setHeaderHeight } = useSetHeaderHeight();
|
|
17
|
+
|
|
18
|
+
useLayoutEffect(() => {
|
|
19
|
+
const handleHeaderResize = () => {
|
|
20
|
+
const height = headerRef.current?.getBoundingClientRect().height;
|
|
21
|
+
|
|
22
|
+
if (height) {
|
|
23
|
+
setHeaderHeight(height);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let resizeObserver: ResizeObserver;
|
|
28
|
+
|
|
29
|
+
if (headerRef.current) {
|
|
30
|
+
resizeObserver = new ResizeObserver(handleHeaderResize);
|
|
31
|
+
resizeObserver.observe(headerRef.current);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
if (resizeObserver) {
|
|
36
|
+
resizeObserver.disconnect();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, [headerRef, setHeaderHeight]);
|
|
15
40
|
|
|
16
41
|
return (
|
|
17
42
|
<Container
|
|
18
43
|
id={createElementId(ElementId.Header, elementId)}
|
|
19
44
|
sticky={stickyHeaderRoutes.some((route) => pathname.includes(route))}
|
|
20
|
-
|
|
45
|
+
ref={headerRef}
|
|
21
46
|
>
|
|
22
47
|
{children}
|
|
23
48
|
</Container>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useAccount } from '@lifi/wallet-management';
|
|
2
1
|
import { Box, Typography } from '@mui/material';
|
|
3
2
|
import { Route, Routes, useLocation } from 'react-router-dom';
|
|
3
|
+
import { useAccount } from '../../hooks/useAccount.js';
|
|
4
4
|
import { useNavigateBack } from '../../hooks/useNavigateBack.js';
|
|
5
5
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
6
6
|
import { useHeaderStore } from '../../stores/header/useHeaderStore.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PowerSettingsNewRounded } from '@mui/icons-material';
|
|
2
|
+
import { IconButton } from '@mui/material';
|
|
3
|
+
import { useWallet } from '@solana/wallet-adapter-react';
|
|
4
|
+
|
|
5
|
+
export const SVMDisconnectIconButton = () => {
|
|
6
|
+
const { disconnect } = useWallet();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<IconButton
|
|
10
|
+
size="medium"
|
|
11
|
+
onClick={(e) => {
|
|
12
|
+
e.stopPropagation();
|
|
13
|
+
disconnect();
|
|
14
|
+
}}
|
|
15
|
+
>
|
|
16
|
+
<PowerSettingsNewRounded />
|
|
17
|
+
</IconButton>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
getConnectorIcon,
|
|
4
|
-
useAccount,
|
|
5
|
-
useWalletMenu,
|
|
6
|
-
} from '@lifi/wallet-management';
|
|
1
|
+
import { getConnectorIcon } from '@lifi/wallet-management';
|
|
7
2
|
import { ExpandMore, Wallet } from '@mui/icons-material';
|
|
8
3
|
import { Avatar, Badge } from '@mui/material';
|
|
9
4
|
import { useState } from 'react';
|
|
10
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
7
|
+
import type { Account } from '../../hooks/useAccount.js';
|
|
8
|
+
import { useAccount } from '../../hooks/useAccount.js';
|
|
11
9
|
import { useChain } from '../../hooks/useChain.js';
|
|
12
10
|
import { useHasExternalWalletProvider } from '../../providers/WalletProvider/useHasExternalWalletProvider.js';
|
|
13
11
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
14
12
|
import { HiddenUI } from '../../types/widget.js';
|
|
13
|
+
import { navigationRoutes } from '../../utils/navigationRoutes.js';
|
|
15
14
|
import { shortenAddress } from '../../utils/wallet.js';
|
|
16
|
-
import { SmallAvatar } from '../
|
|
15
|
+
import { SmallAvatar } from '../SmallAvatar.js';
|
|
17
16
|
import { CloseDrawerButton } from './CloseDrawerButton.js';
|
|
18
17
|
import {
|
|
19
18
|
DrawerWalletContainer,
|
|
@@ -71,16 +70,16 @@ export const WalletMenuButton: React.FC = () => {
|
|
|
71
70
|
|
|
72
71
|
const ConnectButton = () => {
|
|
73
72
|
const { t } = useTranslation();
|
|
73
|
+
const { pathname } = useLocation();
|
|
74
74
|
const { walletConfig, subvariant, variant } = useWidgetConfig();
|
|
75
|
-
const
|
|
75
|
+
const navigate = useNavigate();
|
|
76
76
|
const connect = async () => {
|
|
77
77
|
if (walletConfig?.onConnect) {
|
|
78
78
|
walletConfig.onConnect();
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
navigate(navigationRoutes.selectWallet);
|
|
82
82
|
};
|
|
83
|
-
|
|
84
83
|
return (
|
|
85
84
|
<WalletButton
|
|
86
85
|
subvariant={subvariant}
|
|
@@ -92,7 +91,9 @@ const ConnectButton = () => {
|
|
|
92
91
|
<Wallet sx={{ marginLeft: -0.25 }} />
|
|
93
92
|
) : undefined
|
|
94
93
|
}
|
|
95
|
-
onClick={
|
|
94
|
+
onClick={
|
|
95
|
+
!pathname.includes(navigationRoutes.selectWallet) ? connect : undefined
|
|
96
|
+
}
|
|
96
97
|
>
|
|
97
98
|
{t(`button.connectWallet`)}
|
|
98
99
|
</WalletButton>
|
|
@@ -17,15 +17,11 @@ export const WalletMenuContainer = styled(MuiMenu)(({ theme }) => ({
|
|
|
17
17
|
},
|
|
18
18
|
[`& .${menuItemClasses.root}`]: {
|
|
19
19
|
borderRadius: theme.shape.borderRadiusSecondary,
|
|
20
|
-
padding: theme.spacing(1,
|
|
20
|
+
padding: theme.spacing(1, 2, 1, 1),
|
|
21
21
|
[`& .${svgIconClasses.root}`]: {
|
|
22
22
|
fontSize: 20,
|
|
23
23
|
color: theme.palette.text.primary,
|
|
24
24
|
},
|
|
25
|
-
':hover': {
|
|
26
|
-
background: 'none',
|
|
27
|
-
cursor: 'default',
|
|
28
|
-
},
|
|
29
25
|
},
|
|
30
26
|
},
|
|
31
27
|
}));
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
useAccount,
|
|
4
|
-
useWalletMenu,
|
|
5
|
-
} from '@lifi/wallet-management';
|
|
1
|
+
import { ChainType } from '@lifi/sdk';
|
|
2
|
+
import { getConnectorIcon } from '@lifi/wallet-management';
|
|
6
3
|
import {
|
|
7
4
|
ContentCopyRounded,
|
|
8
5
|
OpenInNewRounded,
|
|
@@ -17,20 +14,25 @@ import {
|
|
|
17
14
|
MenuItem,
|
|
18
15
|
} from '@mui/material';
|
|
19
16
|
import { useTranslation } from 'react-i18next';
|
|
17
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
18
|
+
import { useAccount } from '../../hooks/useAccount.js';
|
|
20
19
|
import { useAvailableChains } from '../../hooks/useAvailableChains.js';
|
|
21
20
|
import { useExplorer } from '../../hooks/useExplorer.js';
|
|
21
|
+
import { navigationRoutes } from '../../utils/navigationRoutes.js';
|
|
22
22
|
import { shortenAddress } from '../../utils/wallet.js';
|
|
23
23
|
import { AvatarMasked } from '../Avatar/Avatar.style.js';
|
|
24
|
-
import { SmallAvatar } from '../
|
|
25
|
-
import {
|
|
24
|
+
import { SmallAvatar } from '../SmallAvatar.js';
|
|
25
|
+
import { EVMDisconnectIconButton } from './EVMDisconnectIconButton.js';
|
|
26
|
+
import { SVMDisconnectIconButton } from './SVMDisconnectIconButton.js';
|
|
26
27
|
|
|
27
28
|
export const WalletMenu = ({ onClose }: { onClose: () => void }) => {
|
|
28
29
|
const { t } = useTranslation();
|
|
30
|
+
const navigate = useNavigate();
|
|
31
|
+
const { pathname } = useLocation();
|
|
29
32
|
const { accounts } = useAccount();
|
|
30
33
|
const { getChainById } = useAvailableChains();
|
|
31
|
-
const { openWalletMenu } = useWalletMenu();
|
|
32
34
|
const connect = async () => {
|
|
33
|
-
|
|
35
|
+
navigate(navigationRoutes.selectWallet);
|
|
34
36
|
onClose();
|
|
35
37
|
};
|
|
36
38
|
const { getAddressLink } = useExplorer();
|
|
@@ -47,7 +49,7 @@ export const WalletMenu = ({ onClose }: { onClose: () => void }) => {
|
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
return (
|
|
50
|
-
<MenuItem key={account.address}
|
|
52
|
+
<MenuItem key={account.address}>
|
|
51
53
|
<Box flex={1} display="flex" alignItems="center">
|
|
52
54
|
{chain?.logoURI ? (
|
|
53
55
|
<Badge
|
|
@@ -80,7 +82,7 @@ export const WalletMenu = ({ onClose }: { onClose: () => void }) => {
|
|
|
80
82
|
)}
|
|
81
83
|
{walletAddress}
|
|
82
84
|
</Box>
|
|
83
|
-
<Box ml={
|
|
85
|
+
<Box ml={1}>
|
|
84
86
|
<IconButton size="medium" onClick={handleCopyAddress}>
|
|
85
87
|
<ContentCopyRounded />
|
|
86
88
|
</IconButton>
|
|
@@ -97,22 +99,30 @@ export const WalletMenu = ({ onClose }: { onClose: () => void }) => {
|
|
|
97
99
|
>
|
|
98
100
|
<OpenInNewRounded />
|
|
99
101
|
</IconButton>
|
|
100
|
-
|
|
102
|
+
{account.chainType === ChainType.EVM ? (
|
|
103
|
+
<EVMDisconnectIconButton connector={account.connector} />
|
|
104
|
+
) : account.chainType === ChainType.SVM ? (
|
|
105
|
+
<SVMDisconnectIconButton />
|
|
106
|
+
) : null}
|
|
101
107
|
</Box>
|
|
102
108
|
</MenuItem>
|
|
103
109
|
);
|
|
104
110
|
})}
|
|
105
111
|
</Box>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
{!pathname.includes(navigationRoutes.selectWallet) ? (
|
|
113
|
+
<Button
|
|
114
|
+
onClick={connect}
|
|
115
|
+
fullWidth
|
|
116
|
+
startIcon={<PowerSettingsNewRounded />}
|
|
117
|
+
sx={{
|
|
118
|
+
marginTop: 1,
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
{accounts.length > 1
|
|
122
|
+
? t(`button.changeWallet`)
|
|
123
|
+
: t(`button.connectWallet`)}
|
|
124
|
+
</Button>
|
|
125
|
+
) : null}
|
|
116
126
|
</>
|
|
117
127
|
);
|
|
118
128
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { ContainerProps } from '@mui/material';
|
|
1
2
|
import { Container, styled } from '@mui/material';
|
|
2
3
|
|
|
3
|
-
export interface PageContainerProps {
|
|
4
|
+
export interface PageContainerProps extends ContainerProps {
|
|
4
5
|
halfGutters?: boolean;
|
|
5
6
|
topGutters?: boolean;
|
|
6
7
|
bottomGutters?: boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import { useWidgetEvents } from '../hooks/useWidgetEvents.js';
|
|
4
|
+
import { WidgetEvent } from '../types/events.js';
|
|
5
|
+
|
|
6
|
+
export function PageEntered() {
|
|
7
|
+
const location = useLocation();
|
|
8
|
+
const emitter = useWidgetEvents();
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
emitter.emit(WidgetEvent.PageEntered, location.pathname);
|
|
12
|
+
}, [emitter, location.pathname]);
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
/* eslint-disable react/no-array-index-key */
|
|
1
2
|
import type { Route } from '@lifi/sdk';
|
|
2
|
-
import { useAccount } from '@lifi/wallet-management';
|
|
3
3
|
import { Collapse, Grow, Stack, Typography } from '@mui/material';
|
|
4
4
|
import { useEffect, useRef } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import type { RouteObject } from 'react-router-dom';
|
|
7
7
|
import { useRoutes as useDOMRoutes, useNavigate } from 'react-router-dom';
|
|
8
|
+
import { useAccount } from '../../hooks/useAccount.js';
|
|
8
9
|
import { useRoutes } from '../../hooks/useRoutes.js';
|
|
9
10
|
import { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js';
|
|
10
11
|
import { useWidgetEvents } from '../../hooks/useWidgetEvents.js';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Box, List, styled } from '@mui/material';
|
|
2
|
+
import { Input as InputBase } from '../../components/Input.js';
|
|
3
|
+
|
|
4
|
+
export const Input = styled(InputBase)(({ theme }) => ({
|
|
5
|
+
paddingRight: theme.spacing(1.5),
|
|
6
|
+
}));
|
|
7
|
+
|
|
8
|
+
interface SearchStickyContainerProps {
|
|
9
|
+
headerHeight: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const searchContainerHeight = 64;
|
|
13
|
+
|
|
14
|
+
// When the widget is in Full Height layout mode in order to appear "sticky the StickySearchInputContainer needs to use
|
|
15
|
+
// position fixed in the same way as the header (see Header.tsx). The headerHeight value here is used as the top value
|
|
16
|
+
// to ensure that this container positioned correctly beneath the header
|
|
17
|
+
export const StickySearchInputContainer = styled(Box, {
|
|
18
|
+
shouldForwardProp: (prop) => prop !== 'headerHeight',
|
|
19
|
+
})<SearchStickyContainerProps>(({ theme, headerHeight }) => ({
|
|
20
|
+
position: 'sticky',
|
|
21
|
+
top: headerHeight,
|
|
22
|
+
zIndex: 1,
|
|
23
|
+
height: searchContainerHeight,
|
|
24
|
+
paddingBottom: theme.spacing(2),
|
|
25
|
+
paddingLeft: theme.spacing(3),
|
|
26
|
+
paddingRight: theme.spacing(3),
|
|
27
|
+
backgroundColor: theme.palette.background.default,
|
|
28
|
+
...(theme.header?.position === 'fixed'
|
|
29
|
+
? {
|
|
30
|
+
position: 'fixed',
|
|
31
|
+
minWidth: theme.breakpoints.values.xs,
|
|
32
|
+
maxWidth: theme.breakpoints.values.sm,
|
|
33
|
+
width: '100%',
|
|
34
|
+
}
|
|
35
|
+
: {}),
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
// When in Full Height layout mode, as the StickySearchInputContainer (see above) uses fixed position, the list element needs to provide
|
|
39
|
+
// additional paddingTop in order to be positioned correctly.
|
|
40
|
+
export const SearchList = styled(List)(({ theme }) => ({
|
|
41
|
+
paddingTop:
|
|
42
|
+
theme.header?.position === 'fixed' ? `${searchContainerHeight}px` : 0,
|
|
43
|
+
paddingLeft: theme.spacing(1.5),
|
|
44
|
+
paddingRight: theme.spacing(1.5),
|
|
45
|
+
paddingBottom: theme.spacing(1.5),
|
|
46
|
+
}));
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Search } from '@mui/icons-material';
|
|
2
|
+
import { FormControl, InputAdornment } from '@mui/material';
|
|
3
|
+
import type { FocusEventHandler, FormEventHandler } from 'react';
|
|
4
|
+
import { InputCard } from '../../components/Card/InputCard.js';
|
|
5
|
+
import { useHeaderHeight } from '../../stores/header/useHeaderStore.js';
|
|
6
|
+
import { Input, StickySearchInputContainer } from './SearchInput.style.js';
|
|
7
|
+
|
|
8
|
+
interface SearchInputProps {
|
|
9
|
+
name?: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
onChange?: FormEventHandler<HTMLInputElement>;
|
|
13
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const SearchInput = ({
|
|
17
|
+
name,
|
|
18
|
+
placeholder,
|
|
19
|
+
onChange,
|
|
20
|
+
onBlur,
|
|
21
|
+
value,
|
|
22
|
+
}: SearchInputProps) => {
|
|
23
|
+
return (
|
|
24
|
+
<InputCard>
|
|
25
|
+
<FormControl fullWidth>
|
|
26
|
+
<Input
|
|
27
|
+
size="small"
|
|
28
|
+
placeholder={placeholder}
|
|
29
|
+
endAdornment={
|
|
30
|
+
<InputAdornment position="end">
|
|
31
|
+
<Search />
|
|
32
|
+
</InputAdornment>
|
|
33
|
+
}
|
|
34
|
+
inputProps={{
|
|
35
|
+
inputMode: 'search',
|
|
36
|
+
onChange,
|
|
37
|
+
onBlur,
|
|
38
|
+
name,
|
|
39
|
+
value,
|
|
40
|
+
maxLength: 128,
|
|
41
|
+
}}
|
|
42
|
+
autoComplete="off"
|
|
43
|
+
/>
|
|
44
|
+
</FormControl>
|
|
45
|
+
</InputCard>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const StickySearchInput = ({ ...rest }: SearchInputProps) => {
|
|
50
|
+
const { headerHeight } = useHeaderHeight();
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<StickySearchInputContainer headerHeight={headerHeight}>
|
|
54
|
+
<SearchInput {...rest} />
|
|
55
|
+
</StickySearchInputContainer>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { BoxProps } from '@mui/material';
|
|
2
|
+
import { Box, styled, Typography } from '@mui/material';
|
|
3
|
+
import { searchContainerHeight } from './SearchInput.style.js';
|
|
4
|
+
|
|
5
|
+
interface NotFoundContainerProps extends BoxProps {
|
|
6
|
+
adjustForStickySearchInput?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const NotFoundContainer = styled(Box, {
|
|
10
|
+
shouldForwardProp: (prop) => prop !== 'adjustForStickySearchInput',
|
|
11
|
+
})<NotFoundContainerProps>(({ theme, adjustForStickySearchInput }) => ({
|
|
12
|
+
display: 'flex',
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
flexDirection: 'column',
|
|
16
|
+
flex: 1,
|
|
17
|
+
padding: theme.spacing(3),
|
|
18
|
+
...(adjustForStickySearchInput && theme.header?.position === 'fixed'
|
|
19
|
+
? { paddingTop: `calc(${searchContainerHeight}px + ${theme.spacing(3)})` }
|
|
20
|
+
: {}),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
export const NotFoundMessage = styled(Typography)(({ theme }) => ({
|
|
24
|
+
fontSize: 14,
|
|
25
|
+
color: theme.palette.text.secondary,
|
|
26
|
+
textAlign: 'center',
|
|
27
|
+
flex: 1,
|
|
28
|
+
marginTop: theme.spacing(2),
|
|
29
|
+
paddingLeft: theme.spacing(2),
|
|
30
|
+
paddingRight: theme.spacing(2),
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
export const NotFoundIconContainer = styled(Typography)(({ theme }) => ({
|
|
34
|
+
fontSize: 48,
|
|
35
|
+
lineHeight: 1,
|
|
36
|
+
}));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SearchOff } from '@mui/icons-material';
|
|
2
|
+
import {
|
|
3
|
+
NotFoundContainer,
|
|
4
|
+
NotFoundIconContainer,
|
|
5
|
+
NotFoundMessage,
|
|
6
|
+
} from './SearchNotFound.style.js';
|
|
7
|
+
|
|
8
|
+
interface SearchNotFoundProps {
|
|
9
|
+
message: string;
|
|
10
|
+
adjustForStickySearchInput?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const SearchNotFound = ({
|
|
14
|
+
message,
|
|
15
|
+
adjustForStickySearchInput,
|
|
16
|
+
}: SearchNotFoundProps) => (
|
|
17
|
+
<NotFoundContainer adjustForStickySearchInput={adjustForStickySearchInput}>
|
|
18
|
+
<NotFoundIconContainer>
|
|
19
|
+
<SearchOff fontSize="inherit" />
|
|
20
|
+
</NotFoundIconContainer>
|
|
21
|
+
<NotFoundMessage>{message}</NotFoundMessage>
|
|
22
|
+
</NotFoundContainer>
|
|
23
|
+
);
|