@lifi/widget 1.29.2 → 1.29.4
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/cjs/components/AppContainer.js +2 -2
- package/cjs/components/BottomSheet/BottomSheet.js +2 -1
- package/cjs/components/Dialog.js +2 -1
- package/cjs/components/Header/Header.js +3 -1
- package/cjs/components/SwapButton/SwapButton.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.js +10 -7
- package/cjs/hooks/useDefaultElementId.d.ts +1 -0
- package/cjs/hooks/useDefaultElementId.js +9 -0
- package/cjs/hooks/useScrollableContainer.d.ts +3 -2
- package/cjs/hooks/useScrollableContainer.js +16 -8
- package/cjs/i18n/en.json +1 -0
- package/cjs/i18n/uk.json +10 -5
- package/cjs/pages/SwapPage/SwapPage.js +4 -1
- package/cjs/providers/WidgetProvider/WidgetProvider.js +5 -3
- package/cjs/providers/WidgetProvider/types.d.ts +1 -0
- package/cjs/utils/elements.d.ts +1 -0
- package/cjs/utils/elements.js +3 -1
- package/components/AppContainer.js +3 -3
- package/components/BottomSheet/BottomSheet.js +3 -2
- package/components/Dialog.js +3 -2
- package/components/Header/Header.js +4 -2
- package/components/SwapButton/SwapButton.js +1 -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.js +11 -8
- package/hooks/useDefaultElementId.d.ts +1 -0
- package/hooks/useDefaultElementId.js +5 -0
- package/hooks/useScrollableContainer.d.ts +3 -2
- package/hooks/useScrollableContainer.js +16 -9
- package/i18n/en.json +1 -0
- package/i18n/uk.json +10 -5
- package/package.json +6 -6
- package/pages/SwapPage/SwapPage.js +5 -2
- package/providers/WidgetProvider/WidgetProvider.js +6 -4
- package/providers/WidgetProvider/types.d.ts +1 -0
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/utils/elements.d.ts +1 -0
- package/utils/elements.js +1 -0
|
@@ -50,7 +50,7 @@ exports.FlexContainer = (0, styles_1.styled)(material_1.Container)({
|
|
|
50
50
|
});
|
|
51
51
|
const AppContainer = ({ children }) => {
|
|
52
52
|
// const ref = useRef<HTMLDivElement>(null);
|
|
53
|
-
const { containerStyle, variant } = (0, providers_1.useWidgetConfig)();
|
|
54
|
-
return ((0, jsx_runtime_1.jsx)(RelativeContainer, Object.assign({ sx: containerStyle, variant: variant }, { children: (0, jsx_runtime_1.jsx)(CssBaselineContainer, Object.assign({ id: utils_1.ElementId.ScrollableContainer, variant: variant, enableColorScheme: true }, { children: (0, jsx_runtime_1.jsx)(exports.FlexContainer, Object.assign({ disableGutters: true }, { children: children })) })) })));
|
|
53
|
+
const { containerStyle, variant, elementId } = (0, providers_1.useWidgetConfig)();
|
|
54
|
+
return ((0, jsx_runtime_1.jsx)(RelativeContainer, Object.assign({ sx: containerStyle, variant: variant }, { children: (0, jsx_runtime_1.jsx)(CssBaselineContainer, Object.assign({ id: (0, utils_1.createElementId)(utils_1.ElementId.ScrollableContainer, elementId), variant: variant, enableColorScheme: true }, { children: (0, jsx_runtime_1.jsx)(exports.FlexContainer, Object.assign({ disableGutters: true }, { children: children })) })) })));
|
|
55
55
|
};
|
|
56
56
|
exports.AppContainer = AppContainer;
|
|
@@ -7,6 +7,7 @@ const react_1 = require("react");
|
|
|
7
7
|
const hooks_1 = require("../../hooks");
|
|
8
8
|
const Dialog_1 = require("../Dialog");
|
|
9
9
|
exports.BottomSheet = (0, react_1.forwardRef)(({ elementRef, children, open, onClose }, ref) => {
|
|
10
|
+
const getContainer = (0, hooks_1.useGetScrollableContainer)();
|
|
10
11
|
const openRef = (0, react_1.useRef)(open);
|
|
11
12
|
const [drawerOpen, setDrawerOpen] = (0, react_1.useState)(open);
|
|
12
13
|
const close = (0, react_1.useCallback)(() => {
|
|
@@ -22,5 +23,5 @@ exports.BottomSheet = (0, react_1.forwardRef)(({ elementRef, children, open, onC
|
|
|
22
23
|
},
|
|
23
24
|
close,
|
|
24
25
|
}), [close]);
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Drawer, Object.assign({ container:
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Drawer, Object.assign({ container: getContainer, ref: elementRef, anchor: "bottom", open: drawerOpen, onClose: close, ModalProps: Dialog_1.modalProps, PaperProps: Dialog_1.paperProps, BackdropProps: Dialog_1.backdropProps, disableAutoFocus: true }, { children: children })));
|
|
26
27
|
});
|
package/cjs/components/Dialog.js
CHANGED
|
@@ -26,6 +26,7 @@ exports.backdropProps = {
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
const Dialog = ({ children, open, onClose, }) => {
|
|
29
|
-
|
|
29
|
+
const getContainer = (0, hooks_1.useGetScrollableContainer)();
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Dialog, Object.assign({ container: getContainer, open: open, onClose: onClose, sx: exports.modalProps.sx, PaperProps: exports.paperProps, BackdropProps: exports.backdropProps }, { children: children })));
|
|
30
31
|
};
|
|
31
32
|
exports.Dialog = Dialog;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Header = exports.HeaderContainer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
+
const hooks_1 = require("../../hooks");
|
|
6
7
|
const providers_1 = require("../../providers");
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
const Header_style_1 = require("./Header.style");
|
|
@@ -10,7 +11,8 @@ const NavigationHeader_1 = require("./NavigationHeader");
|
|
|
10
11
|
const WalletHeader_1 = require("./WalletHeader");
|
|
11
12
|
const HeaderContainer = ({ children }) => {
|
|
12
13
|
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
13
|
-
|
|
14
|
+
const elementId = (0, hooks_1.useDefaultElementId)();
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(Header_style_1.Container, Object.assign({ id: (0, utils_1.createElementId)(utils_1.ElementId.Header, elementId), sticky: utils_1.stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
|
|
14
16
|
};
|
|
15
17
|
exports.HeaderContainer = HeaderContainer;
|
|
16
18
|
const Header = () => {
|
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.29.
|
|
2
|
+
export declare const version = "1.29.4";
|
package/cjs/config/version.js
CHANGED
package/cjs/hooks/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './useChain';
|
|
|
2
2
|
export * from './useChains';
|
|
3
3
|
export * from './useContentHeight';
|
|
4
4
|
export * from './useDebouncedWatch';
|
|
5
|
+
export * from './useDefaultElementId';
|
|
5
6
|
export * from './useExpandableVariant';
|
|
6
7
|
export * from './useFeaturedTokens';
|
|
7
8
|
export * from './useGasSufficiency';
|
package/cjs/hooks/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./useChain"), exports);
|
|
|
18
18
|
__exportStar(require("./useChains"), exports);
|
|
19
19
|
__exportStar(require("./useContentHeight"), exports);
|
|
20
20
|
__exportStar(require("./useDebouncedWatch"), exports);
|
|
21
|
+
__exportStar(require("./useDefaultElementId"), exports);
|
|
21
22
|
__exportStar(require("./useExpandableVariant"), exports);
|
|
22
23
|
__exportStar(require("./useFeaturedTokens"), exports);
|
|
23
24
|
__exportStar(require("./useGasSufficiency"), exports);
|
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useSetContentHeight = exports.useContentHeight = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const useDefaultElementId_1 = require("./useDefaultElementId");
|
|
6
7
|
const useScrollableContainer_1 = require("./useScrollableContainer");
|
|
7
|
-
const getContentHeight = () => {
|
|
8
|
-
const headerElement = document.getElementById(utils_1.ElementId.Header);
|
|
9
|
-
const containerElement = document.getElementById(utils_1.ElementId.ScrollableContainer);
|
|
8
|
+
const getContentHeight = (elementId) => {
|
|
9
|
+
const headerElement = document.getElementById((0, utils_1.createElementId)(utils_1.ElementId.Header, elementId));
|
|
10
|
+
const containerElement = document.getElementById((0, utils_1.createElementId)(utils_1.ElementId.ScrollableContainer, elementId));
|
|
10
11
|
if (!containerElement || !headerElement) {
|
|
11
12
|
console.warn(`Can't find ${utils_1.ElementId.ScrollableContainer} or ${utils_1.ElementId.Header} id.`);
|
|
12
13
|
return 0;
|
|
@@ -16,10 +17,11 @@ const getContentHeight = () => {
|
|
|
16
17
|
return containerHeight - headerHeight;
|
|
17
18
|
};
|
|
18
19
|
const useContentHeight = () => {
|
|
19
|
-
const
|
|
20
|
+
const elementId = (0, useDefaultElementId_1.useDefaultElementId)();
|
|
21
|
+
const [contentHeight, setContentHeight] = (0, react_1.useState)(() => getContentHeight(elementId));
|
|
20
22
|
(0, react_1.useLayoutEffect)(() => {
|
|
21
23
|
if (!contentHeight) {
|
|
22
|
-
setContentHeight(getContentHeight());
|
|
24
|
+
setContentHeight(getContentHeight(elementId));
|
|
23
25
|
}
|
|
24
26
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
27
|
}, []);
|
|
@@ -27,9 +29,10 @@ const useContentHeight = () => {
|
|
|
27
29
|
};
|
|
28
30
|
exports.useContentHeight = useContentHeight;
|
|
29
31
|
const useSetContentHeight = (ref) => {
|
|
32
|
+
const elementId = (0, useDefaultElementId_1.useDefaultElementId)();
|
|
30
33
|
(0, react_1.useLayoutEffect)(() => {
|
|
31
34
|
var _a;
|
|
32
|
-
const scrollableContainer = (0, useScrollableContainer_1.getScrollableContainer)();
|
|
35
|
+
const scrollableContainer = (0, useScrollableContainer_1.getScrollableContainer)(elementId);
|
|
33
36
|
if (!scrollableContainer ||
|
|
34
37
|
!ref.current ||
|
|
35
38
|
((_a = ref.current) === null || _a === void 0 ? void 0 : _a.clientHeight) <= (scrollableContainer === null || scrollableContainer === void 0 ? void 0 : scrollableContainer.clientHeight)) {
|
|
@@ -39,6 +42,6 @@ const useSetContentHeight = (ref) => {
|
|
|
39
42
|
return () => {
|
|
40
43
|
scrollableContainer.style.removeProperty('height');
|
|
41
44
|
};
|
|
42
|
-
}, [ref]);
|
|
45
|
+
}, [elementId, ref]);
|
|
43
46
|
};
|
|
44
47
|
exports.useSetContentHeight = useSetContentHeight;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useDefaultElementId: () => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDefaultElementId = void 0;
|
|
4
|
+
const providers_1 = require("../providers");
|
|
5
|
+
const useDefaultElementId = () => {
|
|
6
|
+
const { elementId } = (0, providers_1.useWidgetConfig)();
|
|
7
|
+
return elementId;
|
|
8
|
+
};
|
|
9
|
+
exports.useDefaultElementId = useDefaultElementId;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export declare const getScrollableContainer: () => HTMLElement | null;
|
|
2
|
-
export declare const
|
|
1
|
+
export declare const getScrollableContainer: (elementId: string) => HTMLElement | null;
|
|
2
|
+
export declare const useGetScrollableContainer: () => () => HTMLElement | null;
|
|
3
|
+
export declare const useScrollableContainer: (elementId: string) => HTMLElement | null;
|
|
3
4
|
export declare const useScrollableOverflowHidden: () => void;
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useScrollableOverflowHidden = exports.useScrollableContainer = exports.getScrollableContainer = void 0;
|
|
3
|
+
exports.useScrollableOverflowHidden = exports.useScrollableContainer = exports.useGetScrollableContainer = exports.getScrollableContainer = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
-
const
|
|
6
|
+
const useDefaultElementId_1 = require("./useDefaultElementId");
|
|
7
|
+
const getScrollableContainer = (elementId) => document.getElementById((0, utils_1.createElementId)(utils_1.ElementId.ScrollableContainer, elementId));
|
|
7
8
|
exports.getScrollableContainer = getScrollableContainer;
|
|
8
|
-
const
|
|
9
|
-
const
|
|
9
|
+
const useGetScrollableContainer = () => {
|
|
10
|
+
const elementId = (0, useDefaultElementId_1.useDefaultElementId)();
|
|
11
|
+
const getContainer = (0, react_1.useCallback)(() => (0, exports.getScrollableContainer)(elementId), [elementId]);
|
|
12
|
+
return getContainer;
|
|
13
|
+
};
|
|
14
|
+
exports.useGetScrollableContainer = useGetScrollableContainer;
|
|
15
|
+
const useScrollableContainer = (elementId) => {
|
|
16
|
+
const [containerElement, setContainerElement] = (0, react_1.useState)(() => (0, exports.getScrollableContainer)(elementId));
|
|
10
17
|
(0, react_1.useLayoutEffect)(() => {
|
|
11
18
|
if (!containerElement) {
|
|
12
|
-
setContainerElement((0, exports.getScrollableContainer)());
|
|
19
|
+
setContainerElement((0, exports.getScrollableContainer)(elementId));
|
|
13
20
|
}
|
|
14
|
-
}, [containerElement]);
|
|
21
|
+
}, [containerElement, elementId]);
|
|
15
22
|
return containerElement;
|
|
16
23
|
};
|
|
17
24
|
exports.useScrollableContainer = useScrollableContainer;
|
|
18
25
|
const useScrollableOverflowHidden = () => {
|
|
26
|
+
const elementId = (0, useDefaultElementId_1.useDefaultElementId)();
|
|
19
27
|
(0, react_1.useLayoutEffect)(() => {
|
|
20
|
-
const element = (0, exports.getScrollableContainer)();
|
|
28
|
+
const element = (0, exports.getScrollableContainer)(elementId);
|
|
21
29
|
if (element) {
|
|
22
30
|
element.style.overflowY = 'hidden';
|
|
23
31
|
}
|
|
@@ -26,6 +34,6 @@ const useScrollableOverflowHidden = () => {
|
|
|
26
34
|
element.style.overflowY = 'auto';
|
|
27
35
|
}
|
|
28
36
|
};
|
|
29
|
-
}, []);
|
|
37
|
+
}, [elementId]);
|
|
30
38
|
};
|
|
31
39
|
exports.useScrollableOverflowHidden = useScrollableOverflowHidden;
|
package/cjs/i18n/en.json
CHANGED
package/cjs/i18n/uk.json
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"okay": "Добре",
|
|
20
20
|
"removeSwap": "Видалити своп",
|
|
21
21
|
"restartSwap": "Перезапустити своп",
|
|
22
|
+
"reviewGasSwap": "Переглянути своп газу",
|
|
22
23
|
"reviewSwap": "Переглянути своп",
|
|
23
24
|
"seeDetails": "Детальніше",
|
|
24
25
|
"showAll": "Показати всі",
|
|
@@ -29,10 +30,11 @@
|
|
|
29
30
|
},
|
|
30
31
|
"format": {
|
|
31
32
|
"currency": "{{value, currency(currency: USD)}}",
|
|
32
|
-
"number": "{{value, number(maximumFractionDigits:
|
|
33
|
+
"number": "{{value, number(maximumFractionDigits: 9)}}"
|
|
33
34
|
},
|
|
34
35
|
"header": {
|
|
35
36
|
"activeSwaps": "Активні свопи",
|
|
37
|
+
"checkout": "Розрахунок",
|
|
36
38
|
"from": "Своп з",
|
|
37
39
|
"gas": "Газ",
|
|
38
40
|
"gasSwap": "Своп газу",
|
|
@@ -74,8 +76,8 @@
|
|
|
74
76
|
"message": {
|
|
75
77
|
"slippageThreshold": "Прослизання перевищує визначений поріг. Будь ласка, зробіть запит на новий маршрут, щоб отримати нову пропозицію.",
|
|
76
78
|
"transactionFailed": "Будь ласка, перевірте провідник блоків для отримання додаткової інформації.",
|
|
77
|
-
"transactionNotSent": "Транзакція не була
|
|
78
|
-
"transactionRejected": "Для завершення транзакції потрібен ваш підпис. {{amount, number(maximumFractionDigits:
|
|
79
|
+
"transactionNotSent": "Транзакція не була відправлена. {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} на {{chainName}} все ще знаходяться у вашому гаманці.",
|
|
80
|
+
"transactionRejected": "Для завершення транзакції потрібен ваш підпис. {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} на {{chainName}} залишаються у вашому гаманці.",
|
|
79
81
|
"unknown": "Будь ласка, спробуйте ще раз або зверніться до служби підтримки."
|
|
80
82
|
},
|
|
81
83
|
"title": {
|
|
@@ -115,8 +117,11 @@
|
|
|
115
117
|
"routeNotFound": "Немає доступних маршрутів"
|
|
116
118
|
}
|
|
117
119
|
},
|
|
120
|
+
"nftStepDetails": "Придбати NFT через {{tool}}",
|
|
118
121
|
"onChain": "на {{chainName}}",
|
|
119
122
|
"otherTokens": "Інші токени",
|
|
123
|
+
"ownedBy": "Власник",
|
|
124
|
+
"payWith": "Оплатити з",
|
|
120
125
|
"process": {
|
|
121
126
|
"crossChain": {
|
|
122
127
|
"actionRequired": "Будь ласка, підпишіть транзакцію",
|
|
@@ -162,7 +167,7 @@
|
|
|
162
167
|
"success": {
|
|
163
168
|
"message": {
|
|
164
169
|
"swapPartiallySuccessful": "Ми намагалися завершити своп, але {{tool}} не вистачило ліквідності токену {{tokenSymbol}}.",
|
|
165
|
-
"swapSuccessful": "Зараз
|
|
170
|
+
"swapSuccessful": "Зараз є {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} у гаманці {{walletAddress}} на чейні {{chainName}}."
|
|
166
171
|
},
|
|
167
172
|
"title": {
|
|
168
173
|
"gasSwapSuccessful": "Своп газу успішний",
|
|
@@ -183,7 +188,7 @@
|
|
|
183
188
|
},
|
|
184
189
|
"to": "До",
|
|
185
190
|
"tokenOnChain": "{{tokenSymbol}} на {{chainName}}",
|
|
186
|
-
"tokenOnChainAmount": "{{amount, number(maximumFractionDigits:
|
|
191
|
+
"tokenOnChainAmount": "{{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} на {{chainName}}",
|
|
187
192
|
"tokenSearch": "Знайдіть свій токен",
|
|
188
193
|
"valueLoss": "Втрата вартості",
|
|
189
194
|
"walletAddressOrEns": "Адреса гаманця або ім’я ENS",
|
|
@@ -30,6 +30,7 @@ const TokenValueBottomSheet_1 = require("./TokenValueBottomSheet");
|
|
|
30
30
|
const SwapPage = () => {
|
|
31
31
|
var _a;
|
|
32
32
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
33
|
+
const { variant } = (0, providers_1.useWidgetConfig)();
|
|
33
34
|
const { state } = (0, react_router_dom_1.useLocation)();
|
|
34
35
|
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
35
36
|
const tokenValueBottomSheetRef = (0, react_1.useRef)(null);
|
|
@@ -69,7 +70,9 @@ const SwapPage = () => {
|
|
|
69
70
|
const getSwapButtonText = () => {
|
|
70
71
|
switch (status) {
|
|
71
72
|
case stores_1.RouteExecutionStatus.Idle:
|
|
72
|
-
return
|
|
73
|
+
return variant !== 'refuel'
|
|
74
|
+
? t(`button.startSwap`)
|
|
75
|
+
: t(`button.startGasSwap`);
|
|
73
76
|
case stores_1.RouteExecutionStatus.Failed:
|
|
74
77
|
return t('button.tryAgain');
|
|
75
78
|
default:
|
|
@@ -19,6 +19,7 @@ const stores_1 = require("../../stores");
|
|
|
19
19
|
const utils_1 = require("../../utils");
|
|
20
20
|
const initialContext = {
|
|
21
21
|
disabledChains: [],
|
|
22
|
+
elementId: '',
|
|
22
23
|
};
|
|
23
24
|
const WidgetContext = (0, react_1.createContext)(initialContext);
|
|
24
25
|
const useWidgetConfig = () => (0, react_1.useContext)(WidgetContext);
|
|
@@ -26,6 +27,7 @@ exports.useWidgetConfig = useWidgetConfig;
|
|
|
26
27
|
const WidgetProvider = (_a) => {
|
|
27
28
|
var { children } = _a, _b = _a.config, _c = _b === void 0 ? {} : _b, { fromChain, fromToken, toChain, toToken, fromAmount } = _c, config = __rest(_c, ["fromChain", "fromToken", "toChain", "toToken", "fromAmount"]);
|
|
28
29
|
const settingsStoreContext = (0, stores_1.useSettingsStoreContext)();
|
|
30
|
+
const elementId = (0, react_1.useId)();
|
|
29
31
|
const value = (0, react_1.useMemo)(() => {
|
|
30
32
|
var _a, _b, _c, _d, _e, _f;
|
|
31
33
|
try {
|
|
@@ -54,13 +56,13 @@ const WidgetProvider = (_a) => {
|
|
|
54
56
|
: undefined, fromToken: ((_e = searchParams.fromToken) === null || _e === void 0 ? void 0 : _e.toLowerCase()) || (fromToken === null || fromToken === void 0 ? void 0 : fromToken.toLowerCase()), toToken: ((_f = searchParams.toToken) === null || _f === void 0 ? void 0 : _f.toLowerCase()) || (toToken === null || toToken === void 0 ? void 0 : toToken.toLowerCase()), fromAmount: typeof searchParams.fromAmount === 'string' &&
|
|
55
57
|
!isNaN(parseFloat(searchParams.fromAmount))
|
|
56
58
|
? (0, utils_1.formatAmount)(searchParams.fromAmount)
|
|
57
|
-
: fromAmount });
|
|
59
|
+
: fromAmount, elementId });
|
|
58
60
|
}
|
|
59
61
|
catch (e) {
|
|
60
62
|
console.warn(e);
|
|
61
|
-
return config;
|
|
63
|
+
return Object.assign(Object.assign({}, config), { elementId });
|
|
62
64
|
}
|
|
63
|
-
}, [config, fromAmount, fromChain, fromToken, toChain, toToken]);
|
|
65
|
+
}, [config, elementId, fromAmount, fromChain, fromToken, toChain, toToken]);
|
|
64
66
|
(0, react_1.useEffect)(() => {
|
|
65
67
|
(0, stores_1.setDefaultSettings)(settingsStoreContext, value);
|
|
66
68
|
}, [settingsStoreContext, value]);
|
package/cjs/utils/elements.d.ts
CHANGED
package/cjs/utils/elements.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ElementId = void 0;
|
|
3
|
+
exports.createElementId = exports.ElementId = void 0;
|
|
4
4
|
var ElementId;
|
|
5
5
|
(function (ElementId) {
|
|
6
6
|
ElementId["ScrollableContainer"] = "widget-scrollable-container";
|
|
7
7
|
ElementId["Header"] = "widget-header";
|
|
8
8
|
})(ElementId = exports.ElementId || (exports.ElementId = {}));
|
|
9
|
+
const createElementId = (ElementId, elementId) => `${ElementId}-${elementId}`;
|
|
10
|
+
exports.createElementId = createElementId;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Box, Container, ScopedCssBaseline } from '@mui/material';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { useWidgetConfig } from '../providers';
|
|
5
|
-
import { ElementId } from '../utils';
|
|
5
|
+
import { createElementId, ElementId } from '../utils';
|
|
6
6
|
export const maxHeight = 680;
|
|
7
7
|
export const AppExpandedContainer = styled(Box, {
|
|
8
8
|
shouldForwardProp: (prop) => prop !== 'variant',
|
|
@@ -47,6 +47,6 @@ export const FlexContainer = styled(Container)({
|
|
|
47
47
|
});
|
|
48
48
|
export const AppContainer = ({ children }) => {
|
|
49
49
|
// const ref = useRef<HTMLDivElement>(null);
|
|
50
|
-
const { containerStyle, variant } = useWidgetConfig();
|
|
51
|
-
return (_jsx(RelativeContainer, Object.assign({ sx: containerStyle, variant: variant }, { children: _jsx(CssBaselineContainer, Object.assign({ id: ElementId.ScrollableContainer, variant: variant, enableColorScheme: true }, { children: _jsx(FlexContainer, Object.assign({ disableGutters: true }, { children: children })) })) })));
|
|
50
|
+
const { containerStyle, variant, elementId } = useWidgetConfig();
|
|
51
|
+
return (_jsx(RelativeContainer, Object.assign({ sx: containerStyle, variant: variant }, { children: _jsx(CssBaselineContainer, Object.assign({ id: createElementId(ElementId.ScrollableContainer, elementId), variant: variant, enableColorScheme: true }, { children: _jsx(FlexContainer, Object.assign({ disableGutters: true }, { children: children })) })) })));
|
|
52
52
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Drawer } from '@mui/material';
|
|
3
3
|
import { forwardRef, useCallback, useImperativeHandle, useRef, useState, } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useGetScrollableContainer } from '../../hooks';
|
|
5
5
|
import { backdropProps, modalProps, paperProps } from '../Dialog';
|
|
6
6
|
export const BottomSheet = forwardRef(({ elementRef, children, open, onClose }, ref) => {
|
|
7
|
+
const getContainer = useGetScrollableContainer();
|
|
7
8
|
const openRef = useRef(open);
|
|
8
9
|
const [drawerOpen, setDrawerOpen] = useState(open);
|
|
9
10
|
const close = useCallback(() => {
|
|
@@ -19,5 +20,5 @@ export const BottomSheet = forwardRef(({ elementRef, children, open, onClose },
|
|
|
19
20
|
},
|
|
20
21
|
close,
|
|
21
22
|
}), [close]);
|
|
22
|
-
return (_jsx(Drawer, Object.assign({ container:
|
|
23
|
+
return (_jsx(Drawer, Object.assign({ container: getContainer, ref: elementRef, anchor: "bottom", open: drawerOpen, onClose: close, ModalProps: modalProps, PaperProps: paperProps, BackdropProps: backdropProps, disableAutoFocus: true }, { children: children })));
|
|
23
24
|
});
|
package/components/Dialog.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Dialog as MuiDialog } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { useGetScrollableContainer } from '../hooks';
|
|
4
4
|
export const modalProps = {
|
|
5
5
|
sx: {
|
|
6
6
|
position: 'absolute',
|
|
@@ -23,5 +23,6 @@ export const backdropProps = {
|
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
export const Dialog = ({ children, open, onClose, }) => {
|
|
26
|
-
|
|
26
|
+
const getContainer = useGetScrollableContainer();
|
|
27
|
+
return (_jsx(MuiDialog, Object.assign({ container: getContainer, open: open, onClose: onClose, sx: modalProps.sx, PaperProps: paperProps, BackdropProps: backdropProps }, { children: children })));
|
|
27
28
|
};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import { useDefaultElementId } from '../../hooks';
|
|
3
4
|
import { useWidgetConfig } from '../../providers';
|
|
4
|
-
import { ElementId, stickyHeaderRoutes } from '../../utils';
|
|
5
|
+
import { createElementId, ElementId, stickyHeaderRoutes } from '../../utils';
|
|
5
6
|
import { Container } from './Header.style';
|
|
6
7
|
import { NavigationHeader } from './NavigationHeader';
|
|
7
8
|
import { WalletHeader } from './WalletHeader';
|
|
8
9
|
export const HeaderContainer = ({ children }) => {
|
|
9
10
|
const { pathname } = useLocation();
|
|
10
|
-
|
|
11
|
+
const elementId = useDefaultElementId();
|
|
12
|
+
return (_jsx(Container, Object.assign({ id: createElementId(ElementId.Header, elementId), sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
|
|
11
13
|
};
|
|
12
14
|
export const Header = () => {
|
|
13
15
|
const { walletManagement } = useWidgetConfig();
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.29.
|
|
2
|
+
export declare const version = "1.29.4";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.29.
|
|
2
|
+
export const version = '1.29.4';
|
package/hooks/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './useChain';
|
|
|
2
2
|
export * from './useChains';
|
|
3
3
|
export * from './useContentHeight';
|
|
4
4
|
export * from './useDebouncedWatch';
|
|
5
|
+
export * from './useDefaultElementId';
|
|
5
6
|
export * from './useExpandableVariant';
|
|
6
7
|
export * from './useFeaturedTokens';
|
|
7
8
|
export * from './useGasSufficiency';
|
package/hooks/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './useChain';
|
|
|
2
2
|
export * from './useChains';
|
|
3
3
|
export * from './useContentHeight';
|
|
4
4
|
export * from './useDebouncedWatch';
|
|
5
|
+
export * from './useDefaultElementId';
|
|
5
6
|
export * from './useExpandableVariant';
|
|
6
7
|
export * from './useFeaturedTokens';
|
|
7
8
|
export * from './useGasSufficiency';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useLayoutEffect, useState } from 'react';
|
|
2
|
-
import { ElementId } from '../utils';
|
|
2
|
+
import { createElementId, ElementId } from '../utils';
|
|
3
|
+
import { useDefaultElementId } from './useDefaultElementId';
|
|
3
4
|
import { getScrollableContainer } from './useScrollableContainer';
|
|
4
|
-
const getContentHeight = () => {
|
|
5
|
-
const headerElement = document.getElementById(ElementId.Header);
|
|
6
|
-
const containerElement = document.getElementById(ElementId.ScrollableContainer);
|
|
5
|
+
const getContentHeight = (elementId) => {
|
|
6
|
+
const headerElement = document.getElementById(createElementId(ElementId.Header, elementId));
|
|
7
|
+
const containerElement = document.getElementById(createElementId(ElementId.ScrollableContainer, elementId));
|
|
7
8
|
if (!containerElement || !headerElement) {
|
|
8
9
|
console.warn(`Can't find ${ElementId.ScrollableContainer} or ${ElementId.Header} id.`);
|
|
9
10
|
return 0;
|
|
@@ -13,19 +14,21 @@ const getContentHeight = () => {
|
|
|
13
14
|
return containerHeight - headerHeight;
|
|
14
15
|
};
|
|
15
16
|
export const useContentHeight = () => {
|
|
16
|
-
const
|
|
17
|
+
const elementId = useDefaultElementId();
|
|
18
|
+
const [contentHeight, setContentHeight] = useState(() => getContentHeight(elementId));
|
|
17
19
|
useLayoutEffect(() => {
|
|
18
20
|
if (!contentHeight) {
|
|
19
|
-
setContentHeight(getContentHeight());
|
|
21
|
+
setContentHeight(getContentHeight(elementId));
|
|
20
22
|
}
|
|
21
23
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22
24
|
}, []);
|
|
23
25
|
return contentHeight;
|
|
24
26
|
};
|
|
25
27
|
export const useSetContentHeight = (ref) => {
|
|
28
|
+
const elementId = useDefaultElementId();
|
|
26
29
|
useLayoutEffect(() => {
|
|
27
30
|
var _a;
|
|
28
|
-
const scrollableContainer = getScrollableContainer();
|
|
31
|
+
const scrollableContainer = getScrollableContainer(elementId);
|
|
29
32
|
if (!scrollableContainer ||
|
|
30
33
|
!ref.current ||
|
|
31
34
|
((_a = ref.current) === null || _a === void 0 ? void 0 : _a.clientHeight) <= (scrollableContainer === null || scrollableContainer === void 0 ? void 0 : scrollableContainer.clientHeight)) {
|
|
@@ -35,5 +38,5 @@ export const useSetContentHeight = (ref) => {
|
|
|
35
38
|
return () => {
|
|
36
39
|
scrollableContainer.style.removeProperty('height');
|
|
37
40
|
};
|
|
38
|
-
}, [ref]);
|
|
41
|
+
}, [elementId, ref]);
|
|
39
42
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useDefaultElementId: () => string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export declare const getScrollableContainer: () => HTMLElement | null;
|
|
2
|
-
export declare const
|
|
1
|
+
export declare const getScrollableContainer: (elementId: string) => HTMLElement | null;
|
|
2
|
+
export declare const useGetScrollableContainer: () => () => HTMLElement | null;
|
|
3
|
+
export declare const useScrollableContainer: (elementId: string) => HTMLElement | null;
|
|
3
4
|
export declare const useScrollableOverflowHidden: () => void;
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import { useLayoutEffect, useState } from 'react';
|
|
2
|
-
import { ElementId } from '../utils';
|
|
3
|
-
|
|
4
|
-
export const
|
|
5
|
-
|
|
1
|
+
import { useCallback, useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { createElementId, ElementId } from '../utils';
|
|
3
|
+
import { useDefaultElementId } from './useDefaultElementId';
|
|
4
|
+
export const getScrollableContainer = (elementId) => document.getElementById(createElementId(ElementId.ScrollableContainer, elementId));
|
|
5
|
+
export const useGetScrollableContainer = () => {
|
|
6
|
+
const elementId = useDefaultElementId();
|
|
7
|
+
const getContainer = useCallback(() => getScrollableContainer(elementId), [elementId]);
|
|
8
|
+
return getContainer;
|
|
9
|
+
};
|
|
10
|
+
export const useScrollableContainer = (elementId) => {
|
|
11
|
+
const [containerElement, setContainerElement] = useState(() => getScrollableContainer(elementId));
|
|
6
12
|
useLayoutEffect(() => {
|
|
7
13
|
if (!containerElement) {
|
|
8
|
-
setContainerElement(getScrollableContainer());
|
|
14
|
+
setContainerElement(getScrollableContainer(elementId));
|
|
9
15
|
}
|
|
10
|
-
}, [containerElement]);
|
|
16
|
+
}, [containerElement, elementId]);
|
|
11
17
|
return containerElement;
|
|
12
18
|
};
|
|
13
19
|
export const useScrollableOverflowHidden = () => {
|
|
20
|
+
const elementId = useDefaultElementId();
|
|
14
21
|
useLayoutEffect(() => {
|
|
15
|
-
const element = getScrollableContainer();
|
|
22
|
+
const element = getScrollableContainer(elementId);
|
|
16
23
|
if (element) {
|
|
17
24
|
element.style.overflowY = 'hidden';
|
|
18
25
|
}
|
|
@@ -21,5 +28,5 @@ export const useScrollableOverflowHidden = () => {
|
|
|
21
28
|
element.style.overflowY = 'auto';
|
|
22
29
|
}
|
|
23
30
|
};
|
|
24
|
-
}, []);
|
|
31
|
+
}, [elementId]);
|
|
25
32
|
};
|