@lifi/widget 1.21.0 → 1.22.1
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/AppDrawer.style.d.ts +1 -1
- package/AppProvider.js +2 -4
- package/AppRoutes.js +4 -0
- package/cjs/AppDrawer.style.d.ts +1 -1
- package/cjs/AppProvider.js +1 -3
- package/cjs/AppRoutes.js +4 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
- package/cjs/components/BottomSheet/BottomSheet.d.ts +1 -1
- package/cjs/components/ChainSelect/ChainSelect.js +1 -3
- package/cjs/components/ChainSelect/useChainSelect.d.ts +1 -1
- package/cjs/components/Header/Header.style.d.ts +34 -1
- package/cjs/components/Header/Header.style.js +19 -1
- package/cjs/components/Header/NavigationHeader.js +6 -2
- package/cjs/components/Header/WalletHeader.js +34 -9
- package/cjs/components/Menu.d.ts +1 -0
- package/cjs/components/Menu.js +24 -0
- package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/cjs/components/SelectChainAndToken.js +6 -1
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +11 -6
- package/cjs/components/SelectTokenButton/SelectTokenButton.style.js +2 -1
- package/cjs/components/SendToWallet/SendToWallet.js +5 -0
- package/cjs/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/cjs/components/SendToWallet/SendToWalletButton.js +5 -1
- package/cjs/components/Step/StepProcess.style.d.ts +2 -2
- package/cjs/components/Step/StepTimer.js +1 -1
- package/cjs/components/StepActions/StepActions.js +6 -1
- package/cjs/components/SwapButton/SwapButton.js +9 -4
- package/cjs/components/SwapInput/FormPriceHelperText.js +4 -4
- package/cjs/components/SwapInput/SwapInput.js +5 -2
- package/cjs/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +5 -3
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +3 -1
- package/cjs/components/SwapRoutes/SwapRoutes.js +8 -3
- package/cjs/components/Token/Token.js +6 -5
- package/cjs/components/TokenAvatar/TokenAvatar.d.ts +11 -1
- package/cjs/components/TokenAvatar/TokenAvatar.js +14 -3
- package/cjs/components/TokenList/TokenList.js +2 -23
- package/cjs/components/TokenList/TokenListItem.d.ts +2 -1
- package/cjs/components/TokenList/TokenListItem.js +12 -6
- package/cjs/components/TokenList/index.d.ts +1 -0
- package/cjs/components/TokenList/index.js +1 -0
- package/cjs/components/TokenList/types.d.ts +6 -0
- package/cjs/components/TokenList/useTokenSelect.d.ts +2 -0
- package/cjs/components/TokenList/useTokenSelect.js +33 -0
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useChain.d.ts +2 -2
- package/cjs/hooks/useChains.d.ts +2 -2
- package/cjs/hooks/useExpandableVariant.js +3 -5
- package/cjs/hooks/useProcessMessage.d.ts +2 -2
- package/cjs/hooks/useSwapRoutes.js +11 -7
- package/cjs/i18n/de.json +199 -0
- package/cjs/i18n/en.json +162 -151
- package/cjs/i18n/es.json +200 -0
- package/cjs/i18n/fr.json +199 -0
- package/cjs/i18n/index.d.ts +8 -200
- package/cjs/i18n/index.js +15 -19
- package/cjs/i18n/it.json +199 -0
- package/cjs/i18n/uk.json +200 -0
- package/cjs/i18n/zh.json +199 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +2 -2
- package/cjs/pages/SelectChainPage/SelectChainPage.js +13 -9
- package/cjs/pages/SelectChainPage/types.d.ts +4 -0
- package/cjs/pages/SelectChainPage/types.js +2 -0
- package/cjs/pages/SelectNativeTokenPage/SelectNativeTokenPage.d.ts +3 -0
- package/cjs/pages/SelectNativeTokenPage/SelectNativeTokenPage.js +21 -0
- package/cjs/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.d.ts +21 -0
- package/cjs/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.js +20 -0
- package/cjs/pages/SelectNativeTokenPage/index.d.ts +1 -0
- package/cjs/pages/SelectNativeTokenPage/index.js +17 -0
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/cjs/pages/SettingsPage/LanguageSelect.d.ts +2 -0
- package/cjs/pages/SettingsPage/LanguageSelect.js +38 -0
- package/cjs/pages/SettingsPage/SettingsPage.js +2 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.js +6 -0
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +4 -2
- package/cjs/pages/SwapHistoryPage/SwapHistoryItem.js +4 -2
- package/cjs/pages/SwapPage/StatusBottomSheet.js +3 -3
- package/cjs/pages/SwapPage/SwapPage.js +1 -3
- package/cjs/pages/SwapPage/TokenValueBottomSheet.js +1 -1
- package/cjs/providers/I18nProvider/I18nProvider.d.ts +2 -0
- package/cjs/providers/I18nProvider/I18nProvider.js +62 -0
- package/cjs/providers/I18nProvider/index.d.ts +2 -0
- package/cjs/providers/I18nProvider/index.js +18 -0
- package/cjs/providers/I18nProvider/types.d.ts +16 -0
- package/cjs/providers/I18nProvider/types.js +2 -0
- package/cjs/providers/WidgetProvider/utils.d.ts +1 -1
- package/cjs/providers/WidgetProvider/utils.js +4 -4
- package/cjs/providers/index.d.ts +1 -0
- package/cjs/providers/index.js +1 -0
- package/cjs/stores/settings/types.d.ts +1 -0
- package/cjs/stores/settings/useSettingsStore.d.ts +2 -0
- package/cjs/types/widget.d.ts +24 -7
- package/cjs/types/widget.js +8 -0
- package/cjs/utils/deepMerge.d.ts +1 -0
- package/cjs/utils/deepMerge.js +18 -0
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.js +1 -0
- package/cjs/utils/input.js +3 -1
- package/cjs/utils/navigationRoutes.d.ts +8 -7
- package/cjs/utils/navigationRoutes.js +10 -7
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
- package/components/BottomSheet/BottomSheet.d.ts +1 -1
- package/components/ChainSelect/ChainSelect.js +1 -3
- package/components/ChainSelect/useChainSelect.d.ts +1 -1
- package/components/Header/Header.style.d.ts +34 -1
- package/components/Header/Header.style.js +19 -1
- package/components/Header/NavigationHeader.js +7 -3
- package/components/Header/WalletHeader.js +37 -12
- package/components/Menu.d.ts +1 -0
- package/components/Menu.js +21 -0
- package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/components/SelectChainAndToken.js +7 -2
- package/components/SelectTokenButton/SelectTokenButton.js +12 -7
- package/components/SelectTokenButton/SelectTokenButton.style.js +2 -1
- package/components/SendToWallet/SendToWallet.js +6 -1
- package/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/components/SendToWallet/SendToWalletButton.js +6 -2
- package/components/Step/StepProcess.style.d.ts +2 -2
- package/components/Step/StepTimer.js +1 -1
- package/components/StepActions/StepActions.js +6 -1
- package/components/SwapButton/SwapButton.js +9 -4
- package/components/SwapInput/FormPriceHelperText.js +4 -4
- package/components/SwapInput/SwapInput.js +6 -3
- package/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/components/SwapRouteCard/SwapRouteCard.js +5 -3
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +3 -1
- package/components/SwapRoutes/SwapRoutes.js +8 -3
- package/components/Token/Token.js +7 -6
- package/components/TokenAvatar/TokenAvatar.d.ts +11 -1
- package/components/TokenAvatar/TokenAvatar.js +11 -2
- package/components/TokenList/TokenList.js +4 -25
- package/components/TokenList/TokenListItem.d.ts +2 -1
- package/components/TokenList/TokenListItem.js +10 -5
- package/components/TokenList/index.d.ts +1 -0
- package/components/TokenList/index.js +1 -0
- package/components/TokenList/types.d.ts +6 -0
- package/components/TokenList/useTokenSelect.d.ts +2 -0
- package/components/TokenList/useTokenSelect.js +29 -0
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useChain.d.ts +2 -2
- package/hooks/useChains.d.ts +2 -2
- package/hooks/useExpandableVariant.js +3 -5
- package/hooks/useProcessMessage.d.ts +2 -2
- package/hooks/useSwapRoutes.js +12 -8
- package/i18n/de.json +199 -0
- package/i18n/en.json +162 -151
- package/i18n/es.json +200 -0
- package/i18n/fr.json +199 -0
- package/i18n/index.d.ts +8 -200
- package/i18n/index.js +8 -18
- package/i18n/it.json +199 -0
- package/i18n/uk.json +200 -0
- package/i18n/zh.json +199 -0
- package/package.json +19 -18
- package/pages/SelectChainPage/SelectChainPage.d.ts +2 -2
- package/pages/SelectChainPage/SelectChainPage.js +13 -9
- package/pages/SelectChainPage/types.d.ts +4 -0
- package/pages/SelectChainPage/types.js +1 -0
- package/pages/SelectNativeTokenPage/SelectNativeTokenPage.d.ts +3 -0
- package/pages/SelectNativeTokenPage/SelectNativeTokenPage.js +17 -0
- package/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.d.ts +21 -0
- package/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.js +17 -0
- package/pages/SelectNativeTokenPage/index.d.ts +1 -0
- package/pages/SelectNativeTokenPage/index.js +1 -0
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SettingsPage/LanguageSelect.d.ts +2 -0
- package/pages/SettingsPage/LanguageSelect.js +34 -0
- package/pages/SettingsPage/SettingsPage.js +2 -1
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -1
- package/pages/SettingsPage/ShowDestinationWallet.js +6 -0
- package/pages/SwapDetailsPage/SwapDetailsPage.js +4 -2
- package/pages/SwapHistoryPage/SwapHistoryItem.js +4 -2
- package/pages/SwapPage/StatusBottomSheet.js +3 -3
- package/pages/SwapPage/SwapPage.js +1 -3
- package/pages/SwapPage/TokenValueBottomSheet.js +1 -1
- package/providers/I18nProvider/I18nProvider.d.ts +2 -0
- package/providers/I18nProvider/I18nProvider.js +58 -0
- package/providers/I18nProvider/index.d.ts +2 -0
- package/providers/I18nProvider/index.js +2 -0
- package/providers/I18nProvider/types.d.ts +16 -0
- package/providers/I18nProvider/types.js +1 -0
- package/providers/WidgetProvider/utils.d.ts +1 -1
- package/providers/WidgetProvider/utils.js +4 -4
- package/providers/index.d.ts +1 -0
- package/providers/index.js +1 -0
- package/stores/settings/types.d.ts +1 -0
- package/stores/settings/useSettingsStore.d.ts +2 -0
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +24 -7
- package/types/widget.js +7 -1
- package/utils/deepMerge.d.ts +1 -0
- package/utils/deepMerge.js +14 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/input.js +3 -1
- package/utils/navigationRoutes.d.ts +8 -7
- package/utils/navigationRoutes.js +10 -7
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
3
|
-
export declare const SelectChainPage: React.FC<
|
|
2
|
+
import type { SelectChainPageProps } from './types';
|
|
3
|
+
export declare const SelectChainPage: React.FC<SelectChainPageProps>;
|
|
@@ -9,21 +9,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { Avatar, Container, List, ListItemAvatar } from '@mui/material';
|
|
12
|
-
import { useLocation } from 'react-router-dom';
|
|
13
12
|
import { useChainSelect } from '../../components/ChainSelect';
|
|
13
|
+
import { useTokenSelect } from '../../components/TokenList';
|
|
14
14
|
import { useNavigateBack } from '../../hooks';
|
|
15
15
|
import { ListItemButton, ListItemText } from './SelectChainPage.style';
|
|
16
|
-
export const SelectChainPage = ({ formType, }) => {
|
|
16
|
+
export const SelectChainPage = ({ formType, selectNativeToken, }) => {
|
|
17
17
|
const { navigateBack } = useNavigateBack();
|
|
18
|
-
const {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const { chains, setCurrentChain } = useChainSelect(formType);
|
|
19
|
+
const selectToken = useTokenSelect(formType, navigateBack);
|
|
20
|
+
const handleClick = (chain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
if (selectNativeToken) {
|
|
22
|
+
selectToken(chain.nativeToken.address, chain.id);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
setCurrentChain(chain.id);
|
|
26
|
+
navigateBack();
|
|
27
|
+
}
|
|
24
28
|
});
|
|
25
29
|
return (_jsx(Container, Object.assign({ disableGutters: true }, { children: _jsx(List, Object.assign({ sx: {
|
|
26
30
|
paddingLeft: 1.5,
|
|
27
31
|
paddingRight: 1.5,
|
|
28
|
-
} }, { children: chains === null || chains === void 0 ? void 0 : chains.map((chain) => (_jsxs(ListItemButton, Object.assign({ onClick: () => handleClick(chain
|
|
32
|
+
} }, { children: chains === null || chains === void 0 ? void 0 : chains.map((chain) => (_jsxs(ListItemButton, Object.assign({ onClick: () => handleClick(chain), disableRipple: true }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: chain.logoURI, alt: chain.name }, { children: chain.name[0] })) }), _jsx(ListItemText, { primary: chain.name })] }), chain.id))) })) })));
|
|
29
33
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Container, List, ListItemAvatar } from '@mui/material';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { TokenAvatar } from '../../components/TokenAvatar';
|
|
5
|
+
import { useTokenSelect } from '../../components/TokenList';
|
|
6
|
+
import { useChains, useNavigateBack } from '../../hooks';
|
|
7
|
+
import { ListItemButton, ListItemText } from './SelectNativeTokenPage.style';
|
|
8
|
+
export const SelectNativeTokenPage = ({ formType, }) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const { navigateBack } = useNavigateBack();
|
|
11
|
+
const { chains } = useChains();
|
|
12
|
+
const selectToken = useTokenSelect(formType, navigateBack);
|
|
13
|
+
return (_jsx(Container, Object.assign({ disableGutters: true }, { children: _jsx(List, Object.assign({ sx: {
|
|
14
|
+
paddingLeft: 1.5,
|
|
15
|
+
paddingRight: 1.5,
|
|
16
|
+
} }, { children: chains === null || chains === void 0 ? void 0 : chains.map((chain) => (_jsxs(ListItemButton, Object.assign({ onClick: () => selectToken(chain.nativeToken.address, chain.id), disableRipple: true }, { children: [_jsx(ListItemAvatar, { children: _jsx(TokenAvatar, { token: chain.nativeToken, chain: chain }) }), _jsx(ListItemText, { primary: chain.nativeToken.symbol, secondary: t('swap.onChain', { chainName: chain.name }) })] }), chain.id))) })) })));
|
|
17
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ListItemButton: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemButtonBaseProps & Omit<{
|
|
3
|
+
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
4
|
+
centerRipple?: boolean | undefined;
|
|
5
|
+
children?: import("react").ReactNode;
|
|
6
|
+
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
7
|
+
disabled?: boolean | undefined;
|
|
8
|
+
disableRipple?: boolean | undefined;
|
|
9
|
+
disableTouchRipple?: boolean | undefined;
|
|
10
|
+
focusRipple?: boolean | undefined;
|
|
11
|
+
focusVisibleClassName?: string | undefined;
|
|
12
|
+
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
13
|
+
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
14
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
15
|
+
tabIndex?: number | undefined;
|
|
16
|
+
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
17
|
+
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
18
|
+
}, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
19
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
20
|
+
}, "className" | "style" | "classes" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "autoFocus" | "dense" | "divider" | "selected" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
21
|
+
export declare const ListItemText: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemTextProps<import("react").ElementType<any>, import("react").ElementType<any>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ListItemButton as MuiListItemButton, ListItemText as MuiListItemText, } from '@mui/material';
|
|
2
|
+
import { listItemTextClasses } from '@mui/material/ListItemText';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { getContrastAlphaColor } from '../../utils';
|
|
5
|
+
export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
|
|
6
|
+
borderRadius: theme.shape.borderRadiusSecondary,
|
|
7
|
+
paddingLeft: theme.spacing(1.5),
|
|
8
|
+
height: 56,
|
|
9
|
+
'&:hover': {
|
|
10
|
+
backgroundColor: getContrastAlphaColor(theme, '4%'),
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
export const ListItemText = styled(MuiListItemText)(({ theme }) => ({
|
|
14
|
+
[`.${listItemTextClasses.primary}`]: {
|
|
15
|
+
fontWeight: 400,
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SelectNativeTokenPage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SelectNativeTokenPage';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const ToggleButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ToggleButtonClasses> | undefined;
|
|
5
|
-
color?: "
|
|
5
|
+
color?: "error" | "success" | "warning" | "primary" | "secondary" | "info" | "standard" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
fullWidth?: boolean | undefined;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { KeyboardArrowDown as KeyboardArrowDownIcon } from '@mui/icons-material';
|
|
3
|
+
import { FormControl, MenuItem } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Card, CardTitle } from '../../components/Card';
|
|
6
|
+
import { Select } from '../../components/Select';
|
|
7
|
+
import { useWidgetConfig } from '../../providers';
|
|
8
|
+
import { useSettings, useSettingsStore } from '../../stores';
|
|
9
|
+
export const LanguageSelect = () => {
|
|
10
|
+
var _a;
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
const { languages, disableI18n } = useWidgetConfig();
|
|
13
|
+
const { i18n } = useTranslation();
|
|
14
|
+
const setValue = useSettingsStore((state) => state.setValue);
|
|
15
|
+
const { language } = useSettings(['language']);
|
|
16
|
+
if (disableI18n) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const handleChangeLanguage = (event) => {
|
|
20
|
+
const language = event.target.value;
|
|
21
|
+
setValue('language', language);
|
|
22
|
+
i18n.changeLanguage(language);
|
|
23
|
+
};
|
|
24
|
+
const filteredLanguages = Object.keys(i18n.store.data).sort();
|
|
25
|
+
if (filteredLanguages.length <= 1) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const value = filteredLanguages.includes(language || i18n.resolvedLanguage)
|
|
29
|
+
? language || i18n.resolvedLanguage
|
|
30
|
+
: (languages === null || languages === void 0 ? void 0 : languages.default) || ((_a = languages === null || languages === void 0 ? void 0 : languages.allow) === null || _a === void 0 ? void 0 : _a[0]);
|
|
31
|
+
return (_jsxs(Card, Object.assign({ mb: 2 }, { children: [_jsx(CardTitle, { children: t(`language.title`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ MenuProps: { elevation: 2 }, value: value, onChange: handleChangeLanguage, IconComponent: KeyboardArrowDownIcon, dense: true }, { children: filteredLanguages.map((lng) => {
|
|
32
|
+
return (_jsx(MenuItem, Object.assign({ value: lng }, { children: t('language.name', { lng }) }), lng));
|
|
33
|
+
}) })) }))] })));
|
|
34
|
+
};
|
|
@@ -3,9 +3,10 @@ import { Box, Container } from '@mui/material';
|
|
|
3
3
|
import { AdvancedPreferences } from './AdvancedPreferences';
|
|
4
4
|
import { ColorSchemeButtonGroup } from './ColorSchemeButtonGroup';
|
|
5
5
|
import { GasPriceSelect } from './GasPriceSelect';
|
|
6
|
+
import { LanguageSelect } from './LanguageSelect';
|
|
6
7
|
import { RoutePrioritySelect } from './RoutePrioritySelect';
|
|
7
8
|
import { ShowDestinationWallet } from './ShowDestinationWallet';
|
|
8
9
|
import { SlippageInput } from './SlippageInput';
|
|
9
10
|
export const SettingsPage = () => {
|
|
10
|
-
return (_jsxs(Container, Object.assign({ disableGutters: true }, { children: [_jsxs(Box, Object.assign({ px: 3, pt: 1 }, { children: [_jsx(ColorSchemeButtonGroup, {}), _jsx(RoutePrioritySelect, {}), _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' }, mt: 2 }, { children: [_jsx(Box, Object.assign({ pr: 2, flex: 1 }, { children: _jsx(SlippageInput, {}) })), _jsx(GasPriceSelect, {})] }))] })), _jsx(ShowDestinationWallet, {}), _jsx(AdvancedPreferences, {})] })));
|
|
11
|
+
return (_jsxs(Container, Object.assign({ disableGutters: true }, { children: [_jsxs(Box, Object.assign({ px: 3, pt: 1 }, { children: [_jsx(ColorSchemeButtonGroup, {}), _jsx(LanguageSelect, {}), _jsx(RoutePrioritySelect, {}), _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' }, mt: 2 }, { children: [_jsx(Box, Object.assign({ pr: 2, flex: 1 }, { children: _jsx(SlippageInput, {}) })), _jsx(GasPriceSelect, {})] }))] })), _jsx(ShowDestinationWallet, {}), _jsx(AdvancedPreferences, {})] })));
|
|
11
12
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const ShowDestinationWallet: () => JSX.Element;
|
|
2
|
+
export declare const ShowDestinationWallet: () => JSX.Element | null;
|
|
@@ -2,11 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Box, Typography } from '@mui/material';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { Switch } from '../../components/Switch';
|
|
5
|
+
import { useWidgetConfig } from '../../providers';
|
|
5
6
|
import { useSettings, useSettingsStore } from '../../stores';
|
|
7
|
+
import { DisabledUI } from '../../types';
|
|
6
8
|
export const ShowDestinationWallet = () => {
|
|
7
9
|
const { t } = useTranslation();
|
|
10
|
+
const { disabledUI } = useWidgetConfig();
|
|
8
11
|
const setValue = useSettingsStore((state) => state.setValue);
|
|
9
12
|
const { showDestinationWallet } = useSettings(['showDestinationWallet']);
|
|
13
|
+
if (disabledUI === null || disabledUI === void 0 ? void 0 : disabledUI.includes(DisabledUI.ToAddress)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
10
16
|
const onChange = (_, checked) => {
|
|
11
17
|
setValue('showDestinationWallet', checked);
|
|
12
18
|
};
|
|
@@ -24,7 +24,7 @@ import { useRouteExecutionStore } from '../../stores';
|
|
|
24
24
|
import { Container } from './SwapDetailsPage.style';
|
|
25
25
|
export const SwapDetailsPage = () => {
|
|
26
26
|
var _a, _b;
|
|
27
|
-
const { t } = useTranslation();
|
|
27
|
+
const { t, i18n } = useTranslation();
|
|
28
28
|
const { navigateBack } = useNavigateBack();
|
|
29
29
|
const { state } = useLocation();
|
|
30
30
|
const [routeExecution, deleteRoute] = useRouteExecutionStore((store) => [store.routes[state === null || state === void 0 ? void 0 : state.routeId], store.deleteRoute], shallow);
|
|
@@ -50,7 +50,9 @@ export const SwapDetailsPage = () => {
|
|
|
50
50
|
display: 'flex',
|
|
51
51
|
flex: 1,
|
|
52
52
|
justifyContent: 'space-between',
|
|
53
|
-
}, pb: 1 }, { children: [_jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(
|
|
53
|
+
}, pb: 1 }, { children: [_jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(i18n.language, { dateStyle: 'long' }).format(startedAt) })), _jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(i18n.language, {
|
|
54
|
+
timeStyle: 'short',
|
|
55
|
+
}).format(startedAt) }))] })), routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.steps.map((step, index, steps) => {
|
|
54
56
|
var _a, _b;
|
|
55
57
|
return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: index === 0
|
|
56
58
|
? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
|
|
@@ -7,7 +7,7 @@ import { Token, TokenDivider } from '../../components/Token';
|
|
|
7
7
|
import { navigationRoutes } from '../../utils';
|
|
8
8
|
export const SwapHistoryItem = ({ route }) => {
|
|
9
9
|
var _a, _b, _c, _d, _e;
|
|
10
|
-
const {
|
|
10
|
+
const { i18n } = useTranslation();
|
|
11
11
|
const navigate = useNavigate();
|
|
12
12
|
const handleClick = () => {
|
|
13
13
|
navigate(navigationRoutes.swapDetails, {
|
|
@@ -19,5 +19,7 @@ export const SwapHistoryItem = ({ route }) => {
|
|
|
19
19
|
display: 'flex',
|
|
20
20
|
flex: 1,
|
|
21
21
|
justifyContent: 'space-between',
|
|
22
|
-
}, pt: 1.75, px: 2 }, { children: [_jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(
|
|
22
|
+
}, pt: 1.75, px: 2 }, { children: [_jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(i18n.language, { dateStyle: 'long' }).format(startedAt) })), _jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(i18n.language, {
|
|
23
|
+
timeStyle: 'short',
|
|
24
|
+
}).format(startedAt) }))] })), _jsxs(Box, Object.assign({ py: 1 }, { children: [_jsx(Token, { token: Object.assign(Object.assign({}, route.fromToken), { amount: route.fromAmount }), px: 2, pt: 1, connected: true }), _jsx(TokenDivider, {}), _jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_e = (_d = (_c = route.steps.at(-1)) === null || _c === void 0 ? void 0 : _c.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : route.toAmount }), px: 2, pt: 0.5, pb: 1 })] }))] })));
|
|
23
25
|
};
|
|
@@ -43,8 +43,8 @@ export const StatusBottomSheet = ({ status, route, }) => {
|
|
|
43
43
|
let message;
|
|
44
44
|
switch (status) {
|
|
45
45
|
case 'success':
|
|
46
|
-
title = t('swap.success.title.
|
|
47
|
-
message = t('swap.success.message.
|
|
46
|
+
title = t('swap.success.title.swapSuccessful');
|
|
47
|
+
message = t('swap.success.message.swapSuccessful', {
|
|
48
48
|
amount: token === null || token === void 0 ? void 0 : token.amount,
|
|
49
49
|
tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
|
|
50
50
|
chainName: (_a = getChainById(route.toChainId)) === null || _a === void 0 ? void 0 : _a.name,
|
|
@@ -76,5 +76,5 @@ export const StatusBottomSheet = ({ status, route, }) => {
|
|
|
76
76
|
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.open();
|
|
77
77
|
}
|
|
78
78
|
}, [refetch, refetchNewBalance, status]);
|
|
79
|
-
return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsxs(Box, Object.assign({ p: 3 }, { children: [_jsxs(IconContainer, { children: [_jsxs(IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? _jsx(InfoIcon, { color: "primary" }) : null, status === 'success' ? _jsx(DoneIcon, { color: "success" }) : null, status === 'error' ? _jsx(WarningIcon, { color: "error" }) : null] })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? (_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_g = (_e = (_d = (_c = route.steps.at(-1)) === null || _c === void 0 ? void 0 : _c.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : (_f = route.steps.at(-1)) === null || _f === void 0 ? void 0 : _f.estimate.toAmount) !== null && _g !== void 0 ? _g : route.toAmount }), py: 1 })) : null] }), _jsx(Typography, Object.assign({ py: 1 }, { children: message })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsxs(Button, Object.assign({ variant: "contained", fullWidth: true, onClick: status === 'success' ? handleDone : handleClose }, { children: [status === 'idle' ? t('button.
|
|
79
|
+
return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsxs(Box, Object.assign({ p: 3 }, { children: [_jsxs(IconContainer, { children: [_jsxs(IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? _jsx(InfoIcon, { color: "primary" }) : null, status === 'success' ? _jsx(DoneIcon, { color: "success" }) : null, status === 'error' ? _jsx(WarningIcon, { color: "error" }) : null] })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? (_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_g = (_e = (_d = (_c = route.steps.at(-1)) === null || _c === void 0 ? void 0 : _c.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : (_f = route.steps.at(-1)) === null || _f === void 0 ? void 0 : _f.estimate.toAmount) !== null && _g !== void 0 ? _g : route.toAmount }), py: 1 })) : null] }), _jsx(Typography, Object.assign({ py: 1 }, { children: message })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsxs(Button, Object.assign({ variant: "contained", fullWidth: true, onClick: status === 'success' ? handleDone : handleClose }, { children: [status === 'idle' ? t('button.ok') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.seeDetails') : null] })) })), status === 'success' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "text", fullWidth: true, onClick: handleSeeDetails }, { children: t('button.seeDetails') })) }))) : null] })) })));
|
|
80
80
|
};
|
|
@@ -28,9 +28,7 @@ export const SwapPage = () => {
|
|
|
28
28
|
const { state } = useLocation();
|
|
29
29
|
const { navigateBack } = useNavigateBack();
|
|
30
30
|
const tokenValueBottomSheetRef = useRef(null);
|
|
31
|
-
const { setValue
|
|
32
|
-
// formState: { isValid, isValidating },
|
|
33
|
-
} = useFormContext();
|
|
31
|
+
const { setValue } = useFormContext();
|
|
34
32
|
const { route, status, executeRoute, restartRoute, deleteRoute } = useRouteExecution(state === null || state === void 0 ? void 0 : state.routeId);
|
|
35
33
|
const handleExecuteRoute = useCallback(() => {
|
|
36
34
|
var _a, _b;
|
|
@@ -19,7 +19,7 @@ const TokenValueBottomSheetContent = ({ route, onCancel, onContinue, }) => {
|
|
|
19
19
|
const { t } = useTranslation();
|
|
20
20
|
const ref = useRef();
|
|
21
21
|
useSetContentHeight(ref);
|
|
22
|
-
return (_jsxs(Box, Object.assign({ p: 3, ref: ref }, { children: [_jsxs(IconContainer, { children: [_jsx(IconCircle, Object.assign({ status: "warning", mb: 1 }, { children: _jsx(WarningIcon, { color: "warning" }) })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: t('swap.warning.title.highValueLoss') }))] }), _jsx(Typography, Object.assign({ py: 1 }, { children: t('swap.warning.message.highValueLoss') })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 1 }, { children: [_jsx(Typography, { children: t('swap.swapping') }), _jsx(Typography, Object.assign({ fontWeight: 600 }, { children: t('
|
|
22
|
+
return (_jsxs(Box, Object.assign({ p: 3, ref: ref }, { children: [_jsxs(IconContainer, { children: [_jsx(IconCircle, Object.assign({ status: "warning", mb: 1 }, { children: _jsx(WarningIcon, { color: "warning" }) })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: t('swap.warning.title.highValueLoss') }))] }), _jsx(Typography, Object.assign({ py: 1 }, { children: t('swap.warning.message.highValueLoss') })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 1 }, { children: [_jsx(Typography, { children: t('swap.swapping') }), _jsx(Typography, Object.assign({ fontWeight: 600 }, { children: t('format.currency', { value: route.fromAmountUSD }) }))] })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 0.25 }, { children: [_jsx(Typography, { children: t('swap.gasCost') }), _jsx(Typography, Object.assign({ fontWeight: 600 }, { children: t('format.currency', { value: route.gasCostUSD }) }))] })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 0.25 }, { children: [_jsx(Typography, { children: t('swap.receiving') }), _jsx(Typography, Object.assign({ fontWeight: 600 }, { children: t('format.currency', { value: route.toAmountUSD }) }))] })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 0.25 }, { children: [_jsx(Typography, { children: t('swap.valueLoss') }), _jsxs(Typography, Object.assign({ fontWeight: 600 }, { children: [Big(route.toAmountUSD || 0)
|
|
23
23
|
.div(Big(route.fromAmountUSD || 0).plus(Big(route.gasCostUSD || 0)))
|
|
24
24
|
.minus(1)
|
|
25
25
|
.mul(100)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import i18next from 'i18next';
|
|
3
|
+
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { I18nextProvider, initReactI18next } from 'react-i18next';
|
|
6
|
+
import * as supportedLanguages from '../../i18n';
|
|
7
|
+
import { useSettings } from '../../stores';
|
|
8
|
+
import { deepMerge } from '../../utils';
|
|
9
|
+
import { isItemAllowed, useWidgetConfig } from '../WidgetProvider';
|
|
10
|
+
export const I18nProvider = ({ children, }) => {
|
|
11
|
+
const { languageResources, languages, disableI18n } = useWidgetConfig();
|
|
12
|
+
const { language } = useSettings(['language']);
|
|
13
|
+
const i18n = useMemo(() => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
let resources = Object.keys(supportedLanguages)
|
|
16
|
+
.filter((lng) => isItemAllowed(lng, languages))
|
|
17
|
+
.reduce((resources, lng) => {
|
|
18
|
+
resources[lng] = {
|
|
19
|
+
translation: (languageResources === null || languageResources === void 0 ? void 0 : languageResources[lng])
|
|
20
|
+
? deepMerge(supportedLanguages[lng], languageResources[lng])
|
|
21
|
+
: supportedLanguages[lng],
|
|
22
|
+
};
|
|
23
|
+
return resources;
|
|
24
|
+
}, {});
|
|
25
|
+
if (languageResources) {
|
|
26
|
+
resources = Object.keys(languageResources).reduce((resources, lng) => {
|
|
27
|
+
if (!resources[lng]) {
|
|
28
|
+
resources[lng] = {
|
|
29
|
+
translation: languageResources[lng],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return resources;
|
|
33
|
+
}, resources);
|
|
34
|
+
}
|
|
35
|
+
let i18n = i18next.createInstance({
|
|
36
|
+
lng: (languages === null || languages === void 0 ? void 0 : languages.default) || language,
|
|
37
|
+
fallbackLng: resources.en
|
|
38
|
+
? 'en'
|
|
39
|
+
: (languages === null || languages === void 0 ? void 0 : languages.default) ||
|
|
40
|
+
((_a = languages === null || languages === void 0 ? void 0 : languages.allow) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
41
|
+
((_b = Object.keys(resources)) === null || _b === void 0 ? void 0 : _b[0]),
|
|
42
|
+
lowerCaseLng: true,
|
|
43
|
+
interpolation: {
|
|
44
|
+
escapeValue: false,
|
|
45
|
+
},
|
|
46
|
+
resources,
|
|
47
|
+
detection: {
|
|
48
|
+
caches: [],
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
if (!language && !(languages === null || languages === void 0 ? void 0 : languages.default) && !disableI18n) {
|
|
52
|
+
i18n = i18n.use(LanguageDetector);
|
|
53
|
+
}
|
|
54
|
+
i18n.use(initReactI18next).init();
|
|
55
|
+
return i18n;
|
|
56
|
+
}, [disableI18n, language, languageResources, languages]);
|
|
57
|
+
return _jsx(I18nextProvider, Object.assign({ i18n: i18n }, { children: children }));
|
|
58
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type * as languages from '../../i18n';
|
|
2
|
+
export declare type PartialResource<T> = T extends object ? {
|
|
3
|
+
[P in keyof T]?: PartialResource<T[P]>;
|
|
4
|
+
} : T;
|
|
5
|
+
export declare type LanguageKey = keyof typeof languages;
|
|
6
|
+
export declare type LanguageResources = {
|
|
7
|
+
[language in LanguageKey]?: PartialResource<typeof languages.en>;
|
|
8
|
+
} | {
|
|
9
|
+
[language: string]: PartialResource<typeof languages.en>;
|
|
10
|
+
};
|
|
11
|
+
export declare type LanguageTranslationResource = {
|
|
12
|
+
[namespace in 'translation']: PartialResource<typeof languages.en>;
|
|
13
|
+
};
|
|
14
|
+
export declare type LanguageTranslationResources = {
|
|
15
|
+
[language: string]: LanguageTranslationResource;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export const isItemAllowed = (
|
|
1
|
+
export const isItemAllowed = (itemId, items,
|
|
2
2
|
/** @deprecated Remove in the next major release */
|
|
3
3
|
disabledChains) => {
|
|
4
4
|
var _a, _b;
|
|
5
|
-
if ((_a =
|
|
6
|
-
return
|
|
5
|
+
if ((_a = items === null || items === void 0 ? void 0 : items.allow) === null || _a === void 0 ? void 0 : _a.length) {
|
|
6
|
+
return items.allow.includes(itemId);
|
|
7
7
|
}
|
|
8
|
-
return !((disabledChains === null || disabledChains === void 0 ? void 0 : disabledChains.includes(
|
|
8
|
+
return !((disabledChains === null || disabledChains === void 0 ? void 0 : disabledChains.includes(itemId)) || ((_b = items === null || items === void 0 ? void 0 : items.deny) === null || _b === void 0 ? void 0 : _b.includes(itemId)));
|
|
9
9
|
};
|
package/providers/index.d.ts
CHANGED
package/providers/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<Omit
|
|
|
10
10
|
advancedPreferences: boolean;
|
|
11
11
|
appearance: import("../..").Appearance;
|
|
12
12
|
gasPrice: string;
|
|
13
|
+
language?: string | undefined;
|
|
13
14
|
routePriority: "RECOMMENDED" | "FASTEST" | "CHEAPEST" | "SAFEST";
|
|
14
15
|
showDestinationWallet: boolean;
|
|
15
16
|
slippage: string;
|
|
@@ -29,6 +30,7 @@ export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<Omit
|
|
|
29
30
|
advancedPreferences: boolean;
|
|
30
31
|
appearance: import("../..").Appearance;
|
|
31
32
|
gasPrice: string;
|
|
33
|
+
language?: string | undefined;
|
|
32
34
|
routePriority: "RECOMMENDED" | "FASTEST" | "CHEAPEST" | "SAFEST";
|
|
33
35
|
showDestinationWallet: boolean;
|
|
34
36
|
slippage: string;
|