@lifi/widget 1.26.0 → 1.26.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.
@@ -6,12 +6,13 @@ const material_1 = require("@mui/material");
6
6
  const react_1 = require("react");
7
7
  const hooks_1 = require("../../hooks");
8
8
  const Dialog_1 = require("../Dialog");
9
- exports.BottomSheet = (0, react_1.forwardRef)(({ elementRef, children, open }, ref) => {
9
+ exports.BottomSheet = (0, react_1.forwardRef)(({ elementRef, children, open, onClose }, ref) => {
10
10
  const openRef = (0, react_1.useRef)(open);
11
11
  const [drawerOpen, setDrawerOpen] = (0, react_1.useState)(open);
12
12
  const close = (0, react_1.useCallback)(() => {
13
13
  setDrawerOpen(false);
14
14
  openRef.current = false;
15
+ onClose === null || onClose === void 0 ? void 0 : onClose();
15
16
  }, []);
16
17
  (0, react_1.useImperativeHandle)(ref, () => ({
17
18
  isOpen: () => openRef.current,
@@ -1,7 +1,8 @@
1
1
  import type { DrawerProps } from '@mui/material';
2
2
  import type { RefObject } from 'react';
3
- export type BottomSheetProps = DrawerProps & {
3
+ export type BottomSheetProps = Omit<DrawerProps, 'onClose'> & {
4
4
  elementRef?: RefObject<HTMLDivElement>;
5
+ onClose?(): void;
5
6
  };
6
7
  export interface BottomSheetBase {
7
8
  isOpen(): void;
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.26.0";
2
+ export declare const version = "1.26.1";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/widget';
5
- exports.version = '1.26.0';
5
+ exports.version = '1.26.1';
@@ -20,11 +20,11 @@ exports.ExchangeRateBottomSheet = (0, react_1.forwardRef)(({ onContinue, onCance
20
20
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(true);
21
21
  onContinue === null || onContinue === void 0 ? void 0 : onContinue();
22
22
  };
23
- const handleCancel = () => {
23
+ const handleCancel = (0, react_1.useCallback)(() => {
24
24
  var _a;
25
25
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(false);
26
26
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
27
- };
27
+ }, []);
28
28
  (0, react_1.useImperativeHandle)(ref, () => ({
29
29
  isOpen: () => { var _a; return (_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.isOpen(); },
30
30
  open: (resolver, data) => {
@@ -39,7 +39,7 @@ exports.ExchangeRateBottomSheet = (0, react_1.forwardRef)(({ onContinue, onCance
39
39
  (_b = bottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.close();
40
40
  },
41
41
  }), []);
42
- return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: bottomSheetRef }, { children: (0, jsx_runtime_1.jsx)(ExchangeRateBottomSheetContent, { data: data, onContinue: handleContinue, onCancel: handleCancel }) })));
42
+ return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: bottomSheetRef, onClose: handleCancel }, { children: (0, jsx_runtime_1.jsx)(ExchangeRateBottomSheetContent, { data: data, onContinue: handleContinue, onCancel: handleCancel }) })));
43
43
  });
44
44
  const ExchangeRateBottomSheetContent = ({ data, onCancel, onContinue }) => {
45
45
  const { t } = (0, react_i18next_1.useTranslation)();
@@ -11,12 +11,12 @@ const BottomSheet_1 = require("../../components/BottomSheet");
11
11
  const hooks_1 = require("../../hooks");
12
12
  const StatusBottomSheet_style_1 = require("./StatusBottomSheet.style");
13
13
  exports.TokenValueBottomSheet = (0, react_1.forwardRef)(({ route, onContinue, onCancel }, ref) => {
14
- const handleCancel = () => {
14
+ const handleCancel = (0, react_1.useCallback)(() => {
15
15
  var _a;
16
16
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
17
17
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
18
- };
19
- return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref }, { children: (0, jsx_runtime_1.jsx)(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
18
+ }, []);
19
+ return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref, onClose: handleCancel }, { children: (0, jsx_runtime_1.jsx)(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
20
20
  });
21
21
  const TokenValueBottomSheetContent = ({ route, onCancel, onContinue, }) => {
22
22
  const { t } = (0, react_i18next_1.useTranslation)();
@@ -1,14 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Drawer } from '@mui/material';
3
- import { forwardRef, useCallback, useImperativeHandle, useRef, useState, } from 'react';
3
+ import { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';
4
4
  import { getScrollableContainer } from '../../hooks';
5
5
  import { backdropProps, modalProps, paperProps } from '../Dialog';
6
- export const BottomSheet = forwardRef(({ elementRef, children, open }, ref) => {
6
+ export const BottomSheet = forwardRef(({ elementRef, children, open, onClose }, ref) => {
7
7
  const openRef = useRef(open);
8
8
  const [drawerOpen, setDrawerOpen] = useState(open);
9
9
  const close = useCallback(() => {
10
10
  setDrawerOpen(false);
11
11
  openRef.current = false;
12
+ onClose === null || onClose === void 0 ? void 0 : onClose();
12
13
  }, []);
13
14
  useImperativeHandle(ref, () => ({
14
15
  isOpen: () => openRef.current,
@@ -1,7 +1,8 @@
1
1
  import type { DrawerProps } from '@mui/material';
2
2
  import type { RefObject } from 'react';
3
- export type BottomSheetProps = DrawerProps & {
3
+ export type BottomSheetProps = Omit<DrawerProps, 'onClose'> & {
4
4
  elementRef?: RefObject<HTMLDivElement>;
5
+ onClose?(): void;
5
6
  };
6
7
  export interface BottomSheetBase {
7
8
  isOpen(): void;
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.26.0";
2
+ export declare const version = "1.26.1";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '1.26.0';
2
+ export const version = '1.26.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.26.0",
3
+ "version": "1.26.1",
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",
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { WarningRounded as WarningIcon } from '@mui/icons-material';
3
3
  import { Box, Button, Typography } from '@mui/material';
4
4
  import Big from 'big.js';
5
- import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
5
+ import { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { BottomSheet } from '../../components/BottomSheet';
8
8
  import { useSetContentHeight } from '../../hooks';
@@ -17,11 +17,11 @@ export const ExchangeRateBottomSheet = forwardRef(({ onContinue, onCancel }, ref
17
17
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(true);
18
18
  onContinue === null || onContinue === void 0 ? void 0 : onContinue();
19
19
  };
20
- const handleCancel = () => {
20
+ const handleCancel = useCallback(() => {
21
21
  var _a;
22
22
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(false);
23
23
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
24
- };
24
+ }, []);
25
25
  useImperativeHandle(ref, () => ({
26
26
  isOpen: () => { var _a; return (_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.isOpen(); },
27
27
  open: (resolver, data) => {
@@ -36,7 +36,7 @@ export const ExchangeRateBottomSheet = forwardRef(({ onContinue, onCancel }, ref
36
36
  (_b = bottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.close();
37
37
  },
38
38
  }), []);
39
- return (_jsx(BottomSheet, Object.assign({ ref: bottomSheetRef }, { children: _jsx(ExchangeRateBottomSheetContent, { data: data, onContinue: handleContinue, onCancel: handleCancel }) })));
39
+ return (_jsx(BottomSheet, Object.assign({ ref: bottomSheetRef, onClose: handleCancel }, { children: _jsx(ExchangeRateBottomSheetContent, { data: data, onContinue: handleContinue, onCancel: handleCancel }) })));
40
40
  });
41
41
  const ExchangeRateBottomSheetContent = ({ data, onCancel, onContinue }) => {
42
42
  const { t } = useTranslation();
@@ -2,18 +2,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { WarningRounded as WarningIcon } from '@mui/icons-material';
3
3
  import { Box, Button, Typography } from '@mui/material';
4
4
  import Big from 'big.js';
5
- import { forwardRef, useRef } from 'react';
5
+ import { forwardRef, useCallback, useRef } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { BottomSheet } from '../../components/BottomSheet';
8
8
  import { useSetContentHeight } from '../../hooks';
9
9
  import { IconCircle, IconContainer } from './StatusBottomSheet.style';
10
10
  export const TokenValueBottomSheet = forwardRef(({ route, onContinue, onCancel }, ref) => {
11
- const handleCancel = () => {
11
+ const handleCancel = useCallback(() => {
12
12
  var _a;
13
13
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
14
14
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
15
- };
16
- return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsx(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
15
+ }, []);
16
+ return (_jsx(BottomSheet, Object.assign({ ref: ref, onClose: handleCancel }, { children: _jsx(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
17
17
  });
18
18
  const TokenValueBottomSheetContent = ({ route, onCancel, onContinue, }) => {
19
19
  const { t } = useTranslation();