@lifi/widget 2.9.5 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.js +2 -2
- package/AppDrawer.js +31 -19
- package/AppDrawerContext.d.ts +6 -0
- package/AppDrawerContext.js +3 -0
- package/cjs/App.js +2 -2
- package/cjs/AppDrawer.js +30 -18
- package/cjs/AppDrawerContext.d.ts +6 -0
- package/cjs/AppDrawerContext.js +7 -0
- package/cjs/components/Header/CloseDrawerButton.d.ts +3 -0
- package/cjs/components/Header/CloseDrawerButton.js +15 -0
- package/cjs/components/Header/Header.style.js +7 -4
- package/cjs/components/Header/NavigationHeader.js +9 -3
- package/cjs/components/Header/WalletHeader.js +5 -2
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/i18n/en.json +1 -0
- package/cjs/types/widget.d.ts +5 -0
- package/cjs/types/widget.js +1 -0
- package/components/Header/CloseDrawerButton.d.ts +3 -0
- package/components/Header/CloseDrawerButton.js +11 -0
- package/components/Header/Header.style.js +7 -4
- package/components/Header/NavigationHeader.js +9 -3
- package/components/Header/WalletHeader.js +5 -2
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/i18n/en.json +1 -0
- package/package.json +3 -3
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +5 -0
- package/types/widget.js +1 -0
package/App.js
CHANGED
|
@@ -11,9 +11,9 @@ import { RoutesExpanded } from './components/Routes';
|
|
|
11
11
|
import { useExpandableVariant } from './hooks';
|
|
12
12
|
import { useWidgetConfig } from './providers';
|
|
13
13
|
import { ElementId, createElementId } from './utils';
|
|
14
|
-
export const App = forwardRef(({ elementRef, open, integrator, ...other }, ref) => {
|
|
14
|
+
export const App = forwardRef(({ elementRef, open, onClose, integrator, ...other }, ref) => {
|
|
15
15
|
const config = useMemo(() => ({ integrator, ...other, ...other.config }), [integrator, other]);
|
|
16
|
-
return config?.variant !== 'drawer' ? (_jsx(AppProvider, { config: config, children: _jsx(AppDefault, {}) })) : (_jsx(AppDrawer, { ref: ref, elementRef: elementRef, integrator: integrator, config: config, open: open }));
|
|
16
|
+
return config?.variant !== 'drawer' ? (_jsx(AppProvider, { config: config, children: _jsx(AppDefault, {}) })) : (_jsx(AppDrawer, { ref: ref, elementRef: elementRef, integrator: integrator, config: config, open: open, onClose: onClose }));
|
|
17
17
|
});
|
|
18
18
|
export const AppDefault = () => {
|
|
19
19
|
const { elementId } = useWidgetConfig();
|
package/AppDrawer.js
CHANGED
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import CloseIcon from '@mui/icons-material/CloseRounded';
|
|
3
2
|
import KeyboardArrowLeftIcon from '@mui/icons-material/KeyboardArrowLeft';
|
|
4
3
|
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
|
5
4
|
import { Drawer } from '@mui/material';
|
|
6
5
|
import { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
7
6
|
import { useTranslation } from 'react-i18next';
|
|
8
7
|
import { AppDefault } from './App';
|
|
9
|
-
import {
|
|
8
|
+
import { DrawerButton, DrawerButtonTypography } from './AppDrawer.style';
|
|
9
|
+
import { DrawerContext } from './AppDrawerContext';
|
|
10
10
|
import { AppProvider } from './AppProvider';
|
|
11
11
|
import { HiddenUI } from './types';
|
|
12
|
-
export const AppDrawer = forwardRef(({ elementRef, open, integrator, config }, ref) => {
|
|
13
|
-
const openRef = useRef(open);
|
|
12
|
+
export const AppDrawer = forwardRef(({ elementRef, open, onClose, integrator, config }, ref) => {
|
|
13
|
+
const openRef = useRef(Boolean(open));
|
|
14
14
|
const [drawerOpen, setDrawerOpen] = useState(Boolean(open));
|
|
15
15
|
const toggleDrawer = useCallback(() => {
|
|
16
|
-
setDrawerOpen((open) =>
|
|
17
|
-
|
|
16
|
+
setDrawerOpen((open) => {
|
|
17
|
+
openRef.current = !open;
|
|
18
|
+
return openRef.current;
|
|
19
|
+
});
|
|
20
|
+
if (!openRef.current) {
|
|
21
|
+
onClose?.();
|
|
22
|
+
}
|
|
23
|
+
}, [onClose]);
|
|
18
24
|
const openDrawer = useCallback(() => {
|
|
19
25
|
setDrawerOpen(true);
|
|
26
|
+
openRef.current = true;
|
|
20
27
|
}, []);
|
|
21
28
|
const closeDrawer = useCallback(() => {
|
|
22
29
|
setDrawerOpen(false);
|
|
23
|
-
|
|
30
|
+
openRef.current = false;
|
|
31
|
+
onClose?.();
|
|
32
|
+
}, [onClose]);
|
|
24
33
|
useImperativeHandle(ref, () => ({
|
|
25
34
|
isOpen: () => openRef.current,
|
|
26
35
|
toggleDrawer,
|
|
@@ -35,18 +44,21 @@ export const AppDrawer = forwardRef(({ elementRef, open, integrator, config }, r
|
|
|
35
44
|
height: '100%',
|
|
36
45
|
},
|
|
37
46
|
}), [config, integrator]);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const drawerContext = useMemo(() => ({
|
|
48
|
+
closeDrawer,
|
|
49
|
+
}), [closeDrawer]);
|
|
50
|
+
return (_jsx(DrawerContext.Provider, { value: drawerContext, children: _jsxs(AppProvider, { config: widgetConfig, children: [!widgetConfig.hiddenUI?.includes(HiddenUI.DrawerButton) ? (_jsxs(DrawerButton, { variant: "contained", onClick: toggleDrawer, open: drawerOpen, drawerProps: config?.containerStyle, children: [drawerOpen ? (_jsx(KeyboardArrowRightIcon, {})) : (_jsx(KeyboardArrowLeftIcon, {})), _jsx(DrawerButtonText, { open: drawerOpen, subvariant: config?.subvariant })] })) : null, _jsx(Drawer, { ref: elementRef, anchor: "right", open: drawerOpen, onClose: closeDrawer, BackdropProps: {
|
|
51
|
+
sx: {
|
|
52
|
+
backgroundColor: 'rgb(0 0 0 / 48%)',
|
|
53
|
+
backdropFilter: 'blur(3px)',
|
|
54
|
+
},
|
|
55
|
+
}, PaperProps: {
|
|
56
|
+
sx: {
|
|
57
|
+
width: config?.containerStyle?.width ?? '100%',
|
|
58
|
+
minWidth: config?.containerStyle?.minWidth ?? 360,
|
|
59
|
+
maxWidth: config?.containerStyle?.maxWidth ?? 392,
|
|
60
|
+
},
|
|
61
|
+
}, keepMounted: true, children: _jsx(AppDefault, {}) })] }) }));
|
|
50
62
|
});
|
|
51
63
|
export const DrawerButtonText = ({ open, subvariant, }) => {
|
|
52
64
|
const { t } = useTranslation();
|
package/cjs/App.js
CHANGED
|
@@ -14,9 +14,9 @@ const Routes_1 = require("./components/Routes");
|
|
|
14
14
|
const hooks_1 = require("./hooks");
|
|
15
15
|
const providers_1 = require("./providers");
|
|
16
16
|
const utils_1 = require("./utils");
|
|
17
|
-
exports.App = (0, react_1.forwardRef)(({ elementRef, open, integrator, ...other }, ref) => {
|
|
17
|
+
exports.App = (0, react_1.forwardRef)(({ elementRef, open, onClose, integrator, ...other }, ref) => {
|
|
18
18
|
const config = (0, react_1.useMemo)(() => ({ integrator, ...other, ...other.config }), [integrator, other]);
|
|
19
|
-
return config?.variant !== 'drawer' ? ((0, jsx_runtime_1.jsx)(AppProvider_1.AppProvider, { config: config, children: (0, jsx_runtime_1.jsx)(exports.AppDefault, {}) })) : ((0, jsx_runtime_1.jsx)(AppDrawer_1.AppDrawer, { ref: ref, elementRef: elementRef, integrator: integrator, config: config, open: open }));
|
|
19
|
+
return config?.variant !== 'drawer' ? ((0, jsx_runtime_1.jsx)(AppProvider_1.AppProvider, { config: config, children: (0, jsx_runtime_1.jsx)(exports.AppDefault, {}) })) : ((0, jsx_runtime_1.jsx)(AppDrawer_1.AppDrawer, { ref: ref, elementRef: elementRef, integrator: integrator, config: config, open: open, onClose: onClose }));
|
|
20
20
|
});
|
|
21
21
|
const AppDefault = () => {
|
|
22
22
|
const { elementId } = (0, providers_1.useWidgetConfig)();
|
package/cjs/AppDrawer.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DrawerButtonText = exports.AppDrawer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const CloseRounded_1 = require("@mui/icons-material/CloseRounded");
|
|
6
5
|
const KeyboardArrowLeft_1 = require("@mui/icons-material/KeyboardArrowLeft");
|
|
7
6
|
const KeyboardArrowRight_1 = require("@mui/icons-material/KeyboardArrowRight");
|
|
8
7
|
const material_1 = require("@mui/material");
|
|
@@ -10,20 +9,30 @@ const react_1 = require("react");
|
|
|
10
9
|
const react_i18next_1 = require("react-i18next");
|
|
11
10
|
const App_1 = require("./App");
|
|
12
11
|
const AppDrawer_style_1 = require("./AppDrawer.style");
|
|
12
|
+
const AppDrawerContext_1 = require("./AppDrawerContext");
|
|
13
13
|
const AppProvider_1 = require("./AppProvider");
|
|
14
14
|
const types_1 = require("./types");
|
|
15
|
-
exports.AppDrawer = (0, react_1.forwardRef)(({ elementRef, open, integrator, config }, ref) => {
|
|
16
|
-
const openRef = (0, react_1.useRef)(open);
|
|
15
|
+
exports.AppDrawer = (0, react_1.forwardRef)(({ elementRef, open, onClose, integrator, config }, ref) => {
|
|
16
|
+
const openRef = (0, react_1.useRef)(Boolean(open));
|
|
17
17
|
const [drawerOpen, setDrawerOpen] = (0, react_1.useState)(Boolean(open));
|
|
18
18
|
const toggleDrawer = (0, react_1.useCallback)(() => {
|
|
19
|
-
setDrawerOpen((open) =>
|
|
20
|
-
|
|
19
|
+
setDrawerOpen((open) => {
|
|
20
|
+
openRef.current = !open;
|
|
21
|
+
return openRef.current;
|
|
22
|
+
});
|
|
23
|
+
if (!openRef.current) {
|
|
24
|
+
onClose?.();
|
|
25
|
+
}
|
|
26
|
+
}, [onClose]);
|
|
21
27
|
const openDrawer = (0, react_1.useCallback)(() => {
|
|
22
28
|
setDrawerOpen(true);
|
|
29
|
+
openRef.current = true;
|
|
23
30
|
}, []);
|
|
24
31
|
const closeDrawer = (0, react_1.useCallback)(() => {
|
|
25
32
|
setDrawerOpen(false);
|
|
26
|
-
|
|
33
|
+
openRef.current = false;
|
|
34
|
+
onClose?.();
|
|
35
|
+
}, [onClose]);
|
|
27
36
|
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
28
37
|
isOpen: () => openRef.current,
|
|
29
38
|
toggleDrawer,
|
|
@@ -38,18 +47,21 @@ exports.AppDrawer = (0, react_1.forwardRef)(({ elementRef, open, integrator, con
|
|
|
38
47
|
height: '100%',
|
|
39
48
|
},
|
|
40
49
|
}), [config, integrator]);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const drawerContext = (0, react_1.useMemo)(() => ({
|
|
51
|
+
closeDrawer,
|
|
52
|
+
}), [closeDrawer]);
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(AppDrawerContext_1.DrawerContext.Provider, { value: drawerContext, children: (0, jsx_runtime_1.jsxs)(AppProvider_1.AppProvider, { config: widgetConfig, children: [!widgetConfig.hiddenUI?.includes(types_1.HiddenUI.DrawerButton) ? ((0, jsx_runtime_1.jsxs)(AppDrawer_style_1.DrawerButton, { variant: "contained", onClick: toggleDrawer, open: drawerOpen, drawerProps: config?.containerStyle, children: [drawerOpen ? ((0, jsx_runtime_1.jsx)(KeyboardArrowRight_1.default, {})) : ((0, jsx_runtime_1.jsx)(KeyboardArrowLeft_1.default, {})), (0, jsx_runtime_1.jsx)(exports.DrawerButtonText, { open: drawerOpen, subvariant: config?.subvariant })] })) : null, (0, jsx_runtime_1.jsx)(material_1.Drawer, { ref: elementRef, anchor: "right", open: drawerOpen, onClose: closeDrawer, BackdropProps: {
|
|
54
|
+
sx: {
|
|
55
|
+
backgroundColor: 'rgb(0 0 0 / 48%)',
|
|
56
|
+
backdropFilter: 'blur(3px)',
|
|
57
|
+
},
|
|
58
|
+
}, PaperProps: {
|
|
59
|
+
sx: {
|
|
60
|
+
width: config?.containerStyle?.width ?? '100%',
|
|
61
|
+
minWidth: config?.containerStyle?.minWidth ?? 360,
|
|
62
|
+
maxWidth: config?.containerStyle?.maxWidth ?? 392,
|
|
63
|
+
},
|
|
64
|
+
}, keepMounted: true, children: (0, jsx_runtime_1.jsx)(App_1.AppDefault, {}) })] }) }));
|
|
53
65
|
});
|
|
54
66
|
const DrawerButtonText = ({ open, subvariant, }) => {
|
|
55
67
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDrawer = exports.DrawerContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.DrawerContext = (0, react_1.createContext)({});
|
|
6
|
+
const useDrawer = () => (0, react_1.useContext)(exports.DrawerContext);
|
|
7
|
+
exports.useDrawer = useDrawer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloseDrawerButton = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const CloseRounded_1 = require("@mui/icons-material/CloseRounded");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const IconButton_1 = require("@mui/material/IconButton");
|
|
8
|
+
const react_i18next_1 = require("react-i18next");
|
|
9
|
+
const AppDrawerContext_1 = require("../../AppDrawerContext");
|
|
10
|
+
const CloseDrawerButton = (props) => {
|
|
11
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
12
|
+
const { closeDrawer } = (0, AppDrawerContext_1.useDrawer)();
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t('button.close'), enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsx)(IconButton_1.default, { size: "medium", onClick: closeDrawer, ...props, children: (0, jsx_runtime_1.jsx)(CloseRounded_1.default, {}) }) }));
|
|
14
|
+
};
|
|
15
|
+
exports.CloseDrawerButton = CloseDrawerButton;
|
|
@@ -46,11 +46,14 @@ exports.WalletButton = (0, styles_1.styled)(material_1.Button)(({ theme }) => ({
|
|
|
46
46
|
fontSize: '24px',
|
|
47
47
|
},
|
|
48
48
|
}));
|
|
49
|
-
exports.DrawerWalletContainer = (0, styles_1.styled)(material_1.Box)(() => ({
|
|
49
|
+
exports.DrawerWalletContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
|
|
50
50
|
width: '100%',
|
|
51
51
|
display: 'flex',
|
|
52
|
-
|
|
53
|
-
'&
|
|
54
|
-
marginLeft:
|
|
52
|
+
justifyContent: 'space-between',
|
|
53
|
+
'& button:first-of-type': {
|
|
54
|
+
marginLeft: theme.spacing(-1),
|
|
55
|
+
},
|
|
56
|
+
'& button:last-of-type': {
|
|
57
|
+
marginRight: theme.spacing(-1.25),
|
|
55
58
|
},
|
|
56
59
|
}));
|
|
@@ -13,6 +13,7 @@ const providers_1 = require("../../providers");
|
|
|
13
13
|
const stores_1 = require("../../stores");
|
|
14
14
|
const types_1 = require("../../types");
|
|
15
15
|
const utils_1 = require("../../utils");
|
|
16
|
+
const CloseDrawerButton_1 = require("./CloseDrawerButton");
|
|
16
17
|
const Header_style_1 = require("./Header.style");
|
|
17
18
|
const NavigationTabs_1 = require("./NavigationTabs");
|
|
18
19
|
const WalletHeader_1 = require("./WalletHeader");
|
|
@@ -81,8 +82,13 @@ const NavigationHeader = () => {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
const showDrawerCloseButton = variant === 'drawer' &&
|
|
86
|
+
subvariant === 'split' &&
|
|
87
|
+
!hiddenUI?.includes(types_1.HiddenUI.DrawerCloseButton);
|
|
88
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, { elevation: 0, children: [utils_1.backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", edge: "start", onClick: navigateBack, children: (0, jsx_runtime_1.jsx)(ArrowBack_1.default, {}) })) : null, splitSubvariant ? ((0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1, children: !hiddenUI?.includes(types_1.HiddenUI.WalletMenu) ? ((0, jsx_runtime_1.jsx)(WalletHeader_1.WalletMenuButton, {})) : null })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true, children: title || handleHeaderTitle() })), (0, jsx_runtime_1.jsxs)(react_router_dom_1.Routes, { children: [(0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: utils_1.navigationRoutes.home, element: (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [account.isActive && !hiddenUI?.includes(types_1.HiddenUI.History) ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t(`header.transactionHistory`), enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", edge: "start", onClick: () => navigate(utils_1.navigationRoutes.transactionHistory), children: (0, jsx_runtime_1.jsx)(ReceiptLong_1.default, {}) }) })) : null, (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t(`header.settings`), enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", onClick: () => navigate(utils_1.navigationRoutes.settings), sx: {
|
|
89
|
+
marginRight: showDrawerCloseButton ? 0 : -1.25,
|
|
90
|
+
}, children: (0, jsx_runtime_1.jsx)(Settings_1.default, {}) }) }), showDrawerCloseButton ? ((0, jsx_runtime_1.jsx)(CloseDrawerButton_1.CloseDrawerButton, { sx: {
|
|
91
|
+
marginRight: -1.25,
|
|
92
|
+
} })) : null] }) }), (0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "*", element: element || (0, jsx_runtime_1.jsx)(material_1.Box, { width: 28, height: 40 }) })] })] }), splitSubvariant ? (0, jsx_runtime_1.jsx)(NavigationTabs_1.NavigationTabs, {}) : null] }));
|
|
87
93
|
};
|
|
88
94
|
exports.NavigationHeader = NavigationHeader;
|
|
@@ -13,7 +13,9 @@ const react_i18next_1 = require("react-i18next");
|
|
|
13
13
|
const react_router_dom_1 = require("react-router-dom");
|
|
14
14
|
const hooks_1 = require("../../hooks");
|
|
15
15
|
const providers_1 = require("../../providers");
|
|
16
|
+
const types_1 = require("../../types");
|
|
16
17
|
const utils_1 = require("../../utils");
|
|
18
|
+
const CloseDrawerButton_1 = require("./CloseDrawerButton");
|
|
17
19
|
const Header_style_1 = require("./Header.style");
|
|
18
20
|
const WalletMenu_1 = require("./WalletMenu");
|
|
19
21
|
const WalletHeader = () => {
|
|
@@ -22,9 +24,10 @@ const WalletHeader = () => {
|
|
|
22
24
|
exports.WalletHeader = WalletHeader;
|
|
23
25
|
const WalletMenuButton = () => {
|
|
24
26
|
const { account } = (0, providers_1.useWallet)();
|
|
25
|
-
const { variant } = (0, providers_1.useWidgetConfig)();
|
|
27
|
+
const { variant, subvariant, hiddenUI } = (0, providers_1.useWidgetConfig)();
|
|
26
28
|
if (variant === 'drawer') {
|
|
27
|
-
return ((0, jsx_runtime_1.
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)(Header_style_1.DrawerWalletContainer, { children: [account.isActive ? (0, jsx_runtime_1.jsx)(ConnectedButton, {}) : (0, jsx_runtime_1.jsx)(ConnectButton, {}), subvariant !== 'split' &&
|
|
30
|
+
!hiddenUI?.includes(types_1.HiddenUI.DrawerCloseButton) ? ((0, jsx_runtime_1.jsx)(CloseDrawerButton_1.CloseDrawerButton, {})) : null] }));
|
|
28
31
|
}
|
|
29
32
|
return account.isActive ? (0, jsx_runtime_1.jsx)(ConnectedButton, {}) : (0, jsx_runtime_1.jsx)(ConnectButton, {});
|
|
30
33
|
};
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "2.
|
|
2
|
+
export declare const version = "2.10.0";
|
package/cjs/config/version.js
CHANGED
package/cjs/i18n/en.json
CHANGED
package/cjs/types/widget.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type DisabledUIType = `${DisabledUI}`;
|
|
|
17
17
|
export declare enum HiddenUI {
|
|
18
18
|
Appearance = "appearance",
|
|
19
19
|
DrawerButton = "drawerButton",
|
|
20
|
+
DrawerCloseButton = "drawerCloseButton",
|
|
20
21
|
History = "history",
|
|
21
22
|
Language = "language",
|
|
22
23
|
PoweredBy = "poweredBy",
|
|
@@ -122,6 +123,10 @@ export interface WidgetConfig {
|
|
|
122
123
|
export type WidgetDrawerProps = {
|
|
123
124
|
elementRef?: RefObject<HTMLDivElement>;
|
|
124
125
|
open?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Make sure to make the onClose callback stable (e.g. using useCallback) to avoid causing re-renders of the entire widget
|
|
128
|
+
*/
|
|
129
|
+
onClose?(): void;
|
|
125
130
|
};
|
|
126
131
|
export interface WidgetConfigProps {
|
|
127
132
|
config: WidgetConfig;
|
package/cjs/types/widget.js
CHANGED
|
@@ -12,6 +12,7 @@ var HiddenUI;
|
|
|
12
12
|
(function (HiddenUI) {
|
|
13
13
|
HiddenUI["Appearance"] = "appearance";
|
|
14
14
|
HiddenUI["DrawerButton"] = "drawerButton";
|
|
15
|
+
HiddenUI["DrawerCloseButton"] = "drawerCloseButton";
|
|
15
16
|
HiddenUI["History"] = "history";
|
|
16
17
|
HiddenUI["Language"] = "language";
|
|
17
18
|
HiddenUI["PoweredBy"] = "poweredBy";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import CloseIcon from '@mui/icons-material/CloseRounded';
|
|
3
|
+
import { Tooltip } from '@mui/material';
|
|
4
|
+
import IconButton from '@mui/material/IconButton';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { useDrawer } from '../../AppDrawerContext';
|
|
7
|
+
export const CloseDrawerButton = (props) => {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
const { closeDrawer } = useDrawer();
|
|
10
|
+
return (_jsx(Tooltip, { title: t('button.close'), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", onClick: closeDrawer, ...props, children: _jsx(CloseIcon, {}) }) }));
|
|
11
|
+
};
|
|
@@ -43,11 +43,14 @@ export const WalletButton = styled(Button)(({ theme }) => ({
|
|
|
43
43
|
fontSize: '24px',
|
|
44
44
|
},
|
|
45
45
|
}));
|
|
46
|
-
export const DrawerWalletContainer = styled(Box)(() => ({
|
|
46
|
+
export const DrawerWalletContainer = styled(Box)(({ theme }) => ({
|
|
47
47
|
width: '100%',
|
|
48
48
|
display: 'flex',
|
|
49
|
-
|
|
50
|
-
'&
|
|
51
|
-
marginLeft:
|
|
49
|
+
justifyContent: 'space-between',
|
|
50
|
+
'& button:first-of-type': {
|
|
51
|
+
marginLeft: theme.spacing(-1),
|
|
52
|
+
},
|
|
53
|
+
'& button:last-of-type': {
|
|
54
|
+
marginRight: theme.spacing(-1.25),
|
|
52
55
|
},
|
|
53
56
|
}));
|
|
@@ -10,6 +10,7 @@ import { useWallet, useWidgetConfig } from '../../providers';
|
|
|
10
10
|
import { useHeaderStore } from '../../stores';
|
|
11
11
|
import { HiddenUI } from '../../types';
|
|
12
12
|
import { backButtonRoutes, navigationRoutes, navigationRoutesValues, } from '../../utils';
|
|
13
|
+
import { CloseDrawerButton } from './CloseDrawerButton';
|
|
13
14
|
import { HeaderAppBar } from './Header.style';
|
|
14
15
|
import { NavigationTabs } from './NavigationTabs';
|
|
15
16
|
import { WalletMenuButton } from './WalletHeader';
|
|
@@ -78,7 +79,12 @@ export const NavigationHeader = () => {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
const showDrawerCloseButton = variant === 'drawer' &&
|
|
83
|
+
subvariant === 'split' &&
|
|
84
|
+
!hiddenUI?.includes(HiddenUI.DrawerCloseButton);
|
|
85
|
+
return (_jsxs(_Fragment, { children: [_jsxs(HeaderAppBar, { elevation: 0, children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, { size: "medium", edge: "start", onClick: navigateBack, children: _jsx(ArrowBackIcon, {}) })) : null, splitSubvariant ? (_jsx(Box, { flex: 1, children: !hiddenUI?.includes(HiddenUI.WalletMenu) ? (_jsx(WalletMenuButton, {})) : null })) : (_jsx(Typography, { fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true, children: title || handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(Box, { children: [account.isActive && !hiddenUI?.includes(HiddenUI.History) ? (_jsx(Tooltip, { title: t(`header.transactionHistory`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", edge: "start", onClick: () => navigate(navigationRoutes.transactionHistory), children: _jsx(ReceiptLongIcon, {}) }) })) : null, _jsx(Tooltip, { title: t(`header.settings`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", onClick: () => navigate(navigationRoutes.settings), sx: {
|
|
86
|
+
marginRight: showDrawerCloseButton ? 0 : -1.25,
|
|
87
|
+
}, children: _jsx(SettingsIcon, {}) }) }), showDrawerCloseButton ? (_jsx(CloseDrawerButton, { sx: {
|
|
88
|
+
marginRight: -1.25,
|
|
89
|
+
} })) : null] }) }), _jsx(Route, { path: "*", element: element || _jsx(Box, { width: 28, height: 40 }) })] })] }), splitSubvariant ? _jsx(NavigationTabs, {}) : null] }));
|
|
84
90
|
};
|
|
@@ -10,7 +10,9 @@ import { useTranslation } from 'react-i18next';
|
|
|
10
10
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
11
11
|
import { useChain } from '../../hooks';
|
|
12
12
|
import { useWallet, useWidgetConfig } from '../../providers';
|
|
13
|
+
import { HiddenUI } from '../../types';
|
|
13
14
|
import { navigationRoutes, shortenAddress } from '../../utils';
|
|
15
|
+
import { CloseDrawerButton } from './CloseDrawerButton';
|
|
14
16
|
import { DrawerWalletContainer, HeaderAppBar, WalletButton, } from './Header.style';
|
|
15
17
|
import { WalletMenu } from './WalletMenu';
|
|
16
18
|
export const WalletHeader = () => {
|
|
@@ -18,9 +20,10 @@ export const WalletHeader = () => {
|
|
|
18
20
|
};
|
|
19
21
|
export const WalletMenuButton = () => {
|
|
20
22
|
const { account } = useWallet();
|
|
21
|
-
const { variant } = useWidgetConfig();
|
|
23
|
+
const { variant, subvariant, hiddenUI } = useWidgetConfig();
|
|
22
24
|
if (variant === 'drawer') {
|
|
23
|
-
return (
|
|
25
|
+
return (_jsxs(DrawerWalletContainer, { children: [account.isActive ? _jsx(ConnectedButton, {}) : _jsx(ConnectButton, {}), subvariant !== 'split' &&
|
|
26
|
+
!hiddenUI?.includes(HiddenUI.DrawerCloseButton) ? (_jsx(CloseDrawerButton, {})) : null] }));
|
|
24
27
|
}
|
|
25
28
|
return account.isActive ? _jsx(ConnectedButton, {}) : _jsx(ConnectButton, {});
|
|
26
29
|
};
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "2.
|
|
2
|
+
export declare const version = "2.10.0";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '2.
|
|
2
|
+
export const version = '2.10.0';
|
package/i18n/en.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"@ethersproject/address": "^5.7.0",
|
|
44
44
|
"@ethersproject/experimental": "^5.7.0",
|
|
45
45
|
"@ethersproject/providers": "^5.7.2",
|
|
46
|
-
"@lifi/sdk": "^2.
|
|
47
|
-
"@lifi/wallet-management": "^2.
|
|
46
|
+
"@lifi/sdk": "^2.5.0",
|
|
47
|
+
"@lifi/wallet-management": "^2.6.0",
|
|
48
48
|
"@mui/icons-material": "^5.14.14",
|
|
49
49
|
"@mui/lab": "^5.0.0-alpha.149",
|
|
50
50
|
"@mui/material": "^5.14.14",
|