@lifi/widget 1.10.0 → 1.10.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.js CHANGED
@@ -7,6 +7,7 @@ import { AppDefault } from './App';
7
7
  import { DrawerButton, DrawerButtonTypography } from './AppDrawer.style';
8
8
  import { AppProvider } from './AppProvider';
9
9
  export const AppDrawer = forwardRef(({ elementRef, open, config }, ref) => {
10
+ var _a, _b, _c, _d, _e, _f;
10
11
  const { t } = useTranslation();
11
12
  const openRef = useRef(open);
12
13
  const [drawerOpen, setDrawerOpen] = useState(open);
@@ -25,10 +26,16 @@ export const AppDrawer = forwardRef(({ elementRef, open, config }, ref) => {
25
26
  openDrawer,
26
27
  closeDrawer,
27
28
  }), [closeDrawer, openDrawer, toggleDrawer]);
28
- return (_jsxs(AppProvider, Object.assign({ config: config }, { children: [_jsxs(DrawerButton, Object.assign({ variant: "contained", onClick: toggleDrawer, open: drawerOpen, disableElevation: true }, { 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: {
29
+ return (_jsxs(AppProvider, Object.assign({ config: config }, { children: [_jsxs(DrawerButton, Object.assign({ variant: "contained", onClick: toggleDrawer, open: drawerOpen, drawerProps: config === null || config === void 0 ? void 0 : config.containerStyle, disableElevation: true }, { 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: {
29
30
  sx: {
30
31
  backgroundColor: 'rgb(0 0 0 / 48%)',
31
32
  backdropFilter: 'blur(3px)',
32
33
  },
34
+ }, PaperProps: {
35
+ sx: {
36
+ width: (_b = (_a = config === null || config === void 0 ? void 0 : config.containerStyle) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : '100%',
37
+ minWidth: (_d = (_c = config === null || config === void 0 ? void 0 : config.containerStyle) === null || _c === void 0 ? void 0 : _c.minWidth) !== null && _d !== void 0 ? _d : 375,
38
+ maxWidth: (_f = (_e = config === null || config === void 0 ? void 0 : config.containerStyle) === null || _e === void 0 ? void 0 : _e.maxWidth) !== null && _f !== void 0 ? _f : 392,
39
+ },
33
40
  }, keepMounted: true }, { children: _jsx(AppDefault, {}) }))] })));
34
41
  });
@@ -33,6 +33,10 @@ export declare const DrawerButton: import("@emotion/styled").StyledComponent<{
33
33
  ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
34
34
  }, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "color" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "href" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "size" | "startIcon" | "variant"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
35
35
  open?: boolean | undefined;
36
+ drawerProps?: {
37
+ width?: string | number | undefined;
38
+ maxWidth?: string | number | undefined;
39
+ } | undefined;
36
40
  }, {}, {}>;
37
41
  export declare const DrawerButtonTypography: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
38
42
  align?: "inherit" | "left" | "right" | "center" | "justify" | undefined;
@@ -1,8 +1,23 @@
1
1
  import { Button, Typography } from '@mui/material';
2
2
  import { styled } from '@mui/material/styles';
3
+ const getButtonTransformWidth = (drawerWidth, drawerMaxWidth) => {
4
+ if (typeof drawerWidth === 'number') {
5
+ return `${drawerWidth}px`;
6
+ }
7
+ if (typeof drawerWidth === 'string' && !drawerWidth.includes('%')) {
8
+ return drawerWidth;
9
+ }
10
+ if (typeof drawerMaxWidth === 'number') {
11
+ return `${drawerMaxWidth}px`;
12
+ }
13
+ if (typeof drawerMaxWidth === 'string' && !drawerMaxWidth.includes('%')) {
14
+ return drawerMaxWidth;
15
+ }
16
+ return '392px';
17
+ };
3
18
  export const DrawerButton = styled(Button, {
4
- shouldForwardProp: (prop) => prop !== 'open',
5
- })(({ theme, open }) => ({
19
+ shouldForwardProp: (prop) => !['open', 'drawerProps'].includes(prop),
20
+ })(({ theme, open, drawerProps }) => ({
6
21
  background: theme.palette.mode === 'light'
7
22
  ? theme.palette.common.black
8
23
  : theme.palette.common.white,
@@ -20,7 +35,9 @@ export const DrawerButton = styled(Button, {
20
35
  position: 'absolute',
21
36
  right: 0,
22
37
  top: 'calc(50% - 74px)',
23
- transform: `translate3d(calc(${open ? '392px' : '0px'} * -1), 0, 0)`,
38
+ transform: `translate3d(calc(${open
39
+ ? getButtonTransformWidth(drawerProps === null || drawerProps === void 0 ? void 0 : drawerProps.width, drawerProps === null || drawerProps === void 0 ? void 0 : drawerProps.maxWidth)
40
+ : '0px'} * -1), 0, 0)`,
24
41
  transition: theme.transitions.create(['transform'], {
25
42
  duration: theme.transitions.duration.enteringScreen,
26
43
  easing: theme.transitions.easing.easeOut,
@@ -26,7 +26,7 @@ export const StepActions = (_a) => {
26
26
  const isFullView = !dense && ((_b = step.includedSteps) === null || _b === void 0 ? void 0 : _b.length) > 1;
27
27
  return (_jsxs(Box, Object.assign({}, other, { children: [_jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' }, mb: isFullView ? 1 : 0 }, { children: [_jsx(StepAvatar, Object.assign({ variant: step.type === 'lifi' ? 'square' : 'circular', src: step.type !== 'lifi' ? step.toolDetails.logoURI : undefined, alt: step.toolDetails.name }, { children: step.type === 'lifi' ? _jsx(LiFiLogo, {}) : step.toolDetails.name[0] })), _jsx(Typography, Object.assign({ ml: 2, fontSize: 18, fontWeight: "500", textTransform: "capitalize" }, { children: step.type === 'lifi'
28
28
  ? 'LI.FI Smart Contract'
29
- : step.toolDetails.name }))] })), isFullView ? (_jsx(Stepper, Object.assign({ orientation: "vertical", connector: _jsx(StepConnector, {}), activeStep: -1 }, { children: step.includedSteps.map((step) => (_jsxs(MuiStep, Object.assign({ expanded: true }, { children: [_jsx(StepLabel, Object.assign({ StepIconComponent: StepIcon }, { children: _jsx(StepDetailsLabel, { step: step }) })), _jsx(StepContent, { children: _jsx(StepDetailsContent, { step: step }) })] }), step.id))) }))) : (_jsxs(Box, Object.assign({ ml: 6 }, { children: [_jsx(StepDetailsLabel, { step: step }), _jsx(StepDetailsContent, { step: step })] })))] })));
29
+ : step.toolDetails.name }))] })), isFullView ? (_jsx(Stepper, Object.assign({ orientation: "vertical", connector: _jsx(StepConnector, {}), activeStep: -1 }, { children: step.includedSteps.map((step) => (_jsxs(MuiStep, Object.assign({ expanded: true }, { children: [_jsx(StepLabel, Object.assign({ StepIconComponent: StepIcon }, { children: step.type === 'cross' || step.type === 'lifi' ? (_jsx(CrossStepDetailsLabel, { step: step })) : (_jsx(SwapStepDetailsLabel, { step: step })) })), _jsx(StepContent, { children: _jsx(StepDetailsContent, { step: step }) })] }), step.id))) }))) : (_jsxs(Box, Object.assign({ ml: 6 }, { children: [_jsx(StepDetailsLabel, { step: step }), _jsx(StepDetailsContent, { step: step })] })))] })));
30
30
  };
31
31
  export const StepDetailsContent = ({ step }) => {
32
32
  return (_jsxs(Typography, Object.assign({ fontSize: 12, fontWeight: "500", color: "text.secondary", alignItems: "center", display: "flex" }, { children: [formatTokenAmount(step.estimate.fromAmount, step.action.fromToken.decimals), ' ', step.action.fromToken.symbol, _jsx(ArrowForwardIcon, { sx: { fontSize: 18, paddingX: 0.5 } }), formatTokenAmount(step.estimate.toAmount, step.action.toToken.decimals), ' ', step.action.toToken.symbol] })));
@@ -42,8 +42,11 @@ export const CrossStepDetailsLabel = ({ step }) => {
42
42
  }) })));
43
43
  };
44
44
  export const SwapStepDetailsLabel = ({ step }) => {
45
+ var _a;
45
46
  const { t } = useTranslation();
47
+ const { getChainById } = useChains();
46
48
  return (_jsx(Typography, Object.assign({ fontSize: 12, fontWeight: "500", color: "text.secondary" }, { children: t('swap.swapStepDetails', {
47
- value: step.toolDetails.name,
49
+ chain: (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name,
50
+ tool: step.toolDetails.name,
48
51
  }) })));
49
52
  };
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.10.0";
2
+ export declare const version = "1.10.1";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '1.10.0';
2
+ export const version = '1.10.1';
@@ -52,7 +52,7 @@
52
52
  "estimatedTime": "~{{value}} min.",
53
53
  "networkIsBusy": "Network is busy...",
54
54
  "crossStepDetails": "Bridge {{from}} to {{to}} via {{tool}}",
55
- "swapStepDetails": "Swap on {{value}}",
55
+ "swapStepDetails": "Swap on {{chain}} via {{tool}}",
56
56
  "tags": {
57
57
  "recommended": "Recommended",
58
58
  "fastest": "Fast",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.10.0",
3
+ "version": "1.10.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
  "sideEffects": false,
6
6
  "main": "./index.js",