@lifi/widget 1.18.5 → 1.18.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AppDrawer.js +1 -1
- package/cjs/AppDrawer.js +1 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +1 -0
- package/cjs/hooks/index.js +1 -0
- package/cjs/hooks/useContentHeight.d.ts +1 -0
- package/cjs/hooks/useContentHeight.js +27 -0
- package/cjs/hooks/useScrollableContainer.d.ts +2 -0
- package/cjs/hooks/useScrollableContainer.js +19 -3
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +11 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useContentHeight.d.ts +1 -0
- package/hooks/useContentHeight.js +23 -0
- package/hooks/useScrollableContainer.d.ts +2 -0
- package/hooks/useScrollableContainer.js +16 -2
- package/package.json +2 -2
- package/pages/SelectTokenPage/SelectTokenPage.js +12 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
package/AppDrawer.js
CHANGED
|
@@ -26,7 +26,7 @@ export const AppDrawer = forwardRef(({ elementRef, open, config }, ref) => {
|
|
|
26
26
|
openDrawer,
|
|
27
27
|
closeDrawer,
|
|
28
28
|
}), [closeDrawer, openDrawer, toggleDrawer]);
|
|
29
|
-
const drawerConfig = useMemo(() => (Object.assign(Object.assign({}, config), { variant: 'drawer' })), [config]);
|
|
29
|
+
const drawerConfig = useMemo(() => (Object.assign(Object.assign({}, config), { containerStyle: Object.assign(Object.assign({}, config === null || config === void 0 ? void 0 : config.containerStyle), { height: '100%' }), variant: 'drawer' })), [config]);
|
|
30
30
|
return (_jsxs(AppProvider, Object.assign({ config: drawerConfig }, { children: [_jsxs(DrawerButton, Object.assign({ variant: "contained", onClick: toggleDrawer, open: drawerOpen, drawerProps: config === null || config === void 0 ? void 0 : config.containerStyle }, { children: [drawerOpen ? _jsx(KeyboardArrowRightIcon, {}) : _jsx(KeyboardArrowLeftIcon, {}), _jsx(DrawerButtonTypography, { children: drawerOpen ? t('button.hide') : t('button.lifiSwap') })] })), _jsx(Drawer, Object.assign({ ref: elementRef, anchor: "right", open: drawerOpen, onClose: closeDrawer, BackdropProps: {
|
|
31
31
|
sx: {
|
|
32
32
|
backgroundColor: 'rgb(0 0 0 / 48%)',
|
package/cjs/AppDrawer.js
CHANGED
|
@@ -29,7 +29,7 @@ exports.AppDrawer = (0, react_1.forwardRef)(({ elementRef, open, config }, ref)
|
|
|
29
29
|
openDrawer,
|
|
30
30
|
closeDrawer,
|
|
31
31
|
}), [closeDrawer, openDrawer, toggleDrawer]);
|
|
32
|
-
const drawerConfig = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, config), { variant: 'drawer' })), [config]);
|
|
32
|
+
const drawerConfig = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, config), { containerStyle: Object.assign(Object.assign({}, config === null || config === void 0 ? void 0 : config.containerStyle), { height: '100%' }), variant: 'drawer' })), [config]);
|
|
33
33
|
return ((0, jsx_runtime_1.jsxs)(AppProvider_1.AppProvider, Object.assign({ config: drawerConfig }, { children: [(0, jsx_runtime_1.jsxs)(AppDrawer_style_1.DrawerButton, Object.assign({ variant: "contained", onClick: toggleDrawer, open: drawerOpen, drawerProps: config === null || config === void 0 ? void 0 : config.containerStyle }, { children: [drawerOpen ? (0, jsx_runtime_1.jsx)(icons_material_1.KeyboardArrowRight, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.KeyboardArrowLeft, {}), (0, jsx_runtime_1.jsx)(AppDrawer_style_1.DrawerButtonTypography, { children: drawerOpen ? t('button.hide') : t('button.lifiSwap') })] })), (0, jsx_runtime_1.jsx)(material_1.Drawer, Object.assign({ ref: elementRef, anchor: "right", open: drawerOpen, onClose: closeDrawer, BackdropProps: {
|
|
34
34
|
sx: {
|
|
35
35
|
backgroundColor: 'rgb(0 0 0 / 48%)',
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.18.
|
|
2
|
+
export declare const version = "1.18.6";
|
package/cjs/config/version.js
CHANGED
package/cjs/hooks/index.d.ts
CHANGED
package/cjs/hooks/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./useChain"), exports);
|
|
18
18
|
__exportStar(require("./useChains"), exports);
|
|
19
|
+
__exportStar(require("./useContentHeight"), exports);
|
|
19
20
|
__exportStar(require("./useDebouncedWatch"), exports);
|
|
20
21
|
__exportStar(require("./useFeaturedTokens"), exports);
|
|
21
22
|
__exportStar(require("./useGasSufficiency"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useContentHeight: () => number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useContentHeight = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const getContentHeight = () => {
|
|
7
|
+
const headerElement = document.getElementById(utils_1.ElementId.Header);
|
|
8
|
+
const containerElement = document.getElementById(utils_1.ElementId.ScrollableContainer);
|
|
9
|
+
if (!containerElement || !headerElement) {
|
|
10
|
+
console.warn(`Can't find ${utils_1.ElementId.ScrollableContainer} or ${utils_1.ElementId.Header} id.`);
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
const { height: containerHeight } = containerElement.getBoundingClientRect();
|
|
14
|
+
const { height: headerHeight } = headerElement.getBoundingClientRect();
|
|
15
|
+
return containerHeight - headerHeight;
|
|
16
|
+
};
|
|
17
|
+
const useContentHeight = () => {
|
|
18
|
+
const [contentHeight, setContentHeight] = (0, react_1.useState)(getContentHeight);
|
|
19
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
20
|
+
if (!contentHeight) {
|
|
21
|
+
setContentHeight(getContentHeight());
|
|
22
|
+
}
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, []);
|
|
25
|
+
return contentHeight;
|
|
26
|
+
};
|
|
27
|
+
exports.useContentHeight = useContentHeight;
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useScrollableContainer = void 0;
|
|
3
|
+
exports.useScrollableOverflowHidden = exports.useScrollableContainer = exports.getScrollableContainer = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const getScrollableContainer = () => document.getElementById(utils_1.ElementId.ScrollableContainer);
|
|
7
|
+
exports.getScrollableContainer = getScrollableContainer;
|
|
6
8
|
const useScrollableContainer = () => {
|
|
7
|
-
const [containerElement, setContainerElement] = (0, react_1.useState)(
|
|
9
|
+
const [containerElement, setContainerElement] = (0, react_1.useState)(exports.getScrollableContainer);
|
|
8
10
|
(0, react_1.useLayoutEffect)(() => {
|
|
9
11
|
if (!containerElement) {
|
|
10
|
-
setContainerElement(
|
|
12
|
+
setContainerElement((0, exports.getScrollableContainer)());
|
|
11
13
|
}
|
|
12
14
|
}, [containerElement]);
|
|
13
15
|
return containerElement;
|
|
14
16
|
};
|
|
15
17
|
exports.useScrollableContainer = useScrollableContainer;
|
|
18
|
+
const useScrollableOverflowHidden = () => {
|
|
19
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
20
|
+
const element = (0, exports.getScrollableContainer)();
|
|
21
|
+
if (element) {
|
|
22
|
+
element.style.overflowY = 'hidden';
|
|
23
|
+
}
|
|
24
|
+
return () => {
|
|
25
|
+
if (element) {
|
|
26
|
+
element.style.overflowY = 'auto';
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
};
|
|
31
|
+
exports.useScrollableOverflowHidden = useScrollableOverflowHidden;
|
|
@@ -3,12 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SelectTokenPage = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
|
+
const react_1 = require("react");
|
|
6
7
|
const ChainSelect_1 = require("../../components/ChainSelect");
|
|
7
8
|
const TokenList_1 = require("../../components/TokenList");
|
|
8
9
|
const hooks_1 = require("../../hooks");
|
|
9
10
|
const SearchTokenInput_1 = require("./SearchTokenInput");
|
|
11
|
+
const minTokenListHeight = 360;
|
|
10
12
|
const SelectTokenPage = ({ formType }) => {
|
|
13
|
+
(0, hooks_1.useScrollableOverflowHidden)();
|
|
11
14
|
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
12
|
-
|
|
15
|
+
const headerRef = (0, react_1.useRef)(null);
|
|
16
|
+
const contentHeight = (0, hooks_1.useContentHeight)();
|
|
17
|
+
const [tokenListHeight, setTokenListHeight] = (0, react_1.useState)(0);
|
|
18
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
setTokenListHeight(Math.max(contentHeight - ((_b = (_a = headerRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0), minTokenListHeight));
|
|
21
|
+
}, [contentHeight]);
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Container, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ pt: 1, pb: 2, px: 3, ref: headerRef }, { children: [(0, jsx_runtime_1.jsx)(ChainSelect_1.ChainSelect, { formType: formType }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(SearchTokenInput_1.SearchTokenInput, {}) }))] })), (0, jsx_runtime_1.jsx)(TokenList_1.TokenList, { height: tokenListHeight, onClick: navigateBack, formType: formType })] })));
|
|
13
23
|
};
|
|
14
24
|
exports.SelectTokenPage = SelectTokenPage;
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.18.
|
|
2
|
+
export declare const version = "1.18.6";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.18.
|
|
2
|
+
export const version = '1.18.6';
|
package/hooks/index.d.ts
CHANGED
package/hooks/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useContentHeight: () => number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { ElementId } from '../utils';
|
|
3
|
+
const getContentHeight = () => {
|
|
4
|
+
const headerElement = document.getElementById(ElementId.Header);
|
|
5
|
+
const containerElement = document.getElementById(ElementId.ScrollableContainer);
|
|
6
|
+
if (!containerElement || !headerElement) {
|
|
7
|
+
console.warn(`Can't find ${ElementId.ScrollableContainer} or ${ElementId.Header} id.`);
|
|
8
|
+
return 0;
|
|
9
|
+
}
|
|
10
|
+
const { height: containerHeight } = containerElement.getBoundingClientRect();
|
|
11
|
+
const { height: headerHeight } = headerElement.getBoundingClientRect();
|
|
12
|
+
return containerHeight - headerHeight;
|
|
13
|
+
};
|
|
14
|
+
export const useContentHeight = () => {
|
|
15
|
+
const [contentHeight, setContentHeight] = useState(getContentHeight);
|
|
16
|
+
useLayoutEffect(() => {
|
|
17
|
+
if (!contentHeight) {
|
|
18
|
+
setContentHeight(getContentHeight());
|
|
19
|
+
}
|
|
20
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
+
}, []);
|
|
22
|
+
return contentHeight;
|
|
23
|
+
};
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { useLayoutEffect, useState } from 'react';
|
|
2
2
|
import { ElementId } from '../utils';
|
|
3
|
+
export const getScrollableContainer = () => document.getElementById(ElementId.ScrollableContainer);
|
|
3
4
|
export const useScrollableContainer = () => {
|
|
4
|
-
const [containerElement, setContainerElement] = useState(
|
|
5
|
+
const [containerElement, setContainerElement] = useState(getScrollableContainer);
|
|
5
6
|
useLayoutEffect(() => {
|
|
6
7
|
if (!containerElement) {
|
|
7
|
-
setContainerElement(
|
|
8
|
+
setContainerElement(getScrollableContainer());
|
|
8
9
|
}
|
|
9
10
|
}, [containerElement]);
|
|
10
11
|
return containerElement;
|
|
11
12
|
};
|
|
13
|
+
export const useScrollableOverflowHidden = () => {
|
|
14
|
+
useLayoutEffect(() => {
|
|
15
|
+
const element = getScrollableContainer();
|
|
16
|
+
if (element) {
|
|
17
|
+
element.style.overflowY = 'hidden';
|
|
18
|
+
}
|
|
19
|
+
return () => {
|
|
20
|
+
if (element) {
|
|
21
|
+
element.style.overflowY = 'auto';
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.6",
|
|
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",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@sentry/integrations": "^7.13.0",
|
|
51
51
|
"@sentry/react": "^7.13.0",
|
|
52
52
|
"@sentry/tracing": "^7.13.0",
|
|
53
|
-
"@tanstack/react-query": "^4.
|
|
53
|
+
"@tanstack/react-query": "^4.7.1",
|
|
54
54
|
"@tanstack/react-virtual": "^3.0.0-beta.18",
|
|
55
55
|
"big.js": "^6.2.1",
|
|
56
56
|
"i18next": "^21.9.2",
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Container } from '@mui/material';
|
|
3
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
3
4
|
import { ChainSelect } from '../../components/ChainSelect';
|
|
4
5
|
import { TokenList } from '../../components/TokenList';
|
|
5
|
-
import { useNavigateBack } from '../../hooks';
|
|
6
|
+
import { useContentHeight, useNavigateBack, useScrollableOverflowHidden, } from '../../hooks';
|
|
6
7
|
import { SearchTokenInput } from './SearchTokenInput';
|
|
8
|
+
const minTokenListHeight = 360;
|
|
7
9
|
export const SelectTokenPage = ({ formType }) => {
|
|
10
|
+
useScrollableOverflowHidden();
|
|
8
11
|
const { navigateBack } = useNavigateBack();
|
|
9
|
-
|
|
12
|
+
const headerRef = useRef(null);
|
|
13
|
+
const contentHeight = useContentHeight();
|
|
14
|
+
const [tokenListHeight, setTokenListHeight] = useState(0);
|
|
15
|
+
useLayoutEffect(() => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
setTokenListHeight(Math.max(contentHeight - ((_b = (_a = headerRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0), minTokenListHeight));
|
|
18
|
+
}, [contentHeight]);
|
|
19
|
+
return (_jsxs(Container, Object.assign({ disableGutters: true }, { children: [_jsxs(Box, Object.assign({ pt: 1, pb: 2, px: 3, ref: headerRef }, { children: [_jsx(ChainSelect, { formType: formType }), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SearchTokenInput, {}) }))] })), _jsx(TokenList, { height: tokenListHeight, onClick: navigateBack, formType: formType })] })));
|
|
10
20
|
};
|