@lifi/widget 1.27.2 → 1.28.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/AppRoutes.js +15 -33
- package/README.md +1 -1
- package/cjs/AppRoutes.js +15 -33
- package/cjs/components/ContractComponent/ContractComponent.d.ts +3 -0
- package/cjs/components/ContractComponent/ContractComponent.js +14 -0
- package/cjs/components/ContractComponent/index.d.ts +1 -0
- package/cjs/components/ContractComponent/index.js +17 -0
- package/cjs/components/Header/NavigationHeader.js +10 -2
- package/cjs/components/Header/WalletHeader.js +1 -1
- package/cjs/components/NFT/NFT.d.ts +4 -0
- package/cjs/components/NFT/NFT.js +41 -0
- package/cjs/components/NFT/NFT.style.d.ts +16 -0
- package/cjs/components/NFT/NFT.style.js +11 -0
- package/cjs/components/NFT/index.d.ts +2 -0
- package/cjs/components/NFT/index.js +18 -0
- package/cjs/components/NFT/types.d.ts +15 -0
- package/cjs/components/NFT/types.js +2 -0
- package/cjs/components/Select.d.ts +1 -1
- package/cjs/components/SelectChainAndToken.js +12 -2
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +5 -2
- package/cjs/components/StepActions/StepActions.d.ts +6 -7
- package/cjs/components/StepActions/StepActions.js +41 -12
- package/cjs/components/StepActions/types.d.ts +5 -0
- package/cjs/components/SwapInput/SwapInput.d.ts +2 -1
- package/cjs/components/SwapInput/SwapInput.js +15 -3
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +3 -1
- package/cjs/components/Token/Token.d.ts +1 -1
- package/cjs/components/Token/Token.js +12 -12
- package/cjs/components/TokenAvatar/TokenAvatar.d.ts +5 -3
- package/cjs/components/TokenAvatar/TokenAvatar.js +10 -9
- package/cjs/components/TokenList/TokenList.style.js +6 -0
- package/cjs/components/TokenList/VirtualizedTokenList.js +4 -2
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useSwapRoutes.d.ts +5 -2
- package/cjs/hooks/useSwapRoutes.js +64 -14
- package/cjs/hooks/useToken.d.ts +1 -1
- package/cjs/hooks/useTokenSearch.d.ts +1 -1
- package/cjs/i18n/en.json +9 -5
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +4 -1
- package/cjs/pages/MainPage/MainPage.js +5 -1
- package/cjs/providers/SwapFormProvider/types.d.ts +10 -0
- package/cjs/providers/SwapFormProvider/types.js +5 -0
- package/cjs/stores/chains/useChainOrderStore.d.ts +1 -1
- package/cjs/stores/routes/useRouteExecutionStore.d.ts +1 -1
- package/cjs/stores/settings/useSettingsStore.d.ts +1 -1
- package/cjs/types/widget.d.ts +9 -4
- package/cjs/types/widget.js +2 -0
- package/components/ContractComponent/ContractComponent.d.ts +3 -0
- package/components/ContractComponent/ContractComponent.js +10 -0
- package/components/ContractComponent/index.d.ts +1 -0
- package/components/ContractComponent/index.js +1 -0
- package/components/Header/NavigationHeader.js +12 -4
- package/components/Header/WalletHeader.js +1 -1
- package/components/NFT/NFT.d.ts +4 -0
- package/components/NFT/NFT.js +37 -0
- package/components/NFT/NFT.style.d.ts +16 -0
- package/components/NFT/NFT.style.js +8 -0
- package/components/NFT/index.d.ts +2 -0
- package/components/NFT/index.js +2 -0
- package/components/NFT/types.d.ts +15 -0
- package/components/NFT/types.js +1 -0
- package/components/Select.d.ts +1 -1
- package/components/SelectChainAndToken.js +12 -2
- package/components/SelectTokenButton/SelectTokenButton.js +5 -2
- package/components/StepActions/StepActions.d.ts +6 -7
- package/components/StepActions/StepActions.js +40 -12
- package/components/StepActions/types.d.ts +5 -0
- package/components/SwapInput/SwapInput.d.ts +2 -1
- package/components/SwapInput/SwapInput.js +15 -3
- package/components/SwapRouteCard/SwapRouteCard.js +3 -1
- package/components/Token/Token.d.ts +1 -1
- package/components/Token/Token.js +13 -13
- package/components/TokenAvatar/TokenAvatar.d.ts +5 -3
- package/components/TokenAvatar/TokenAvatar.js +10 -9
- package/components/TokenList/TokenList.style.js +6 -0
- package/components/TokenList/VirtualizedTokenList.js +4 -2
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useSwapRoutes.d.ts +5 -2
- package/hooks/useSwapRoutes.js +64 -14
- package/hooks/useToken.d.ts +1 -1
- package/hooks/useTokenSearch.d.ts +1 -1
- package/i18n/en.json +9 -5
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +15 -13
- package/pages/MainPage/MainPage.js +5 -1
- package/providers/SwapFormProvider/types.d.ts +10 -0
- package/providers/SwapFormProvider/types.js +5 -0
- package/stores/chains/useChainOrderStore.d.ts +1 -1
- package/stores/routes/useRouteExecutionStore.d.ts +1 -1
- package/stores/settings/useSettingsStore.d.ts +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +9 -4
- package/types/widget.js +2 -0
package/AppRoutes.js
CHANGED
|
@@ -34,20 +34,14 @@ export const AppRoutes = () => {
|
|
|
34
34
|
path: navigationRoutes.toTokenNative,
|
|
35
35
|
element: _jsx(SelectChainPage, { formType: "to", selectNativeToken: true }),
|
|
36
36
|
},
|
|
37
|
-
|
|
38
|
-
navigationRoutes.fromChain
|
|
39
|
-
`${navigationRoutes.fromToken}/${navigationRoutes.fromChain}`,
|
|
40
|
-
].map((path) => ({
|
|
41
|
-
path,
|
|
37
|
+
{
|
|
38
|
+
path: `${navigationRoutes.fromToken}?/${navigationRoutes.fromChain}`,
|
|
42
39
|
element: _jsx(SelectChainPage, { formType: "from" }),
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
navigationRoutes.toChain
|
|
46
|
-
`${navigationRoutes.toToken}/${navigationRoutes.toChain}`,
|
|
47
|
-
].map((path) => ({
|
|
48
|
-
path,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
path: `${navigationRoutes.toToken}?/${navigationRoutes.toChain}`,
|
|
49
43
|
element: _jsx(SelectChainPage, { formType: "to" }),
|
|
50
|
-
}
|
|
44
|
+
},
|
|
51
45
|
{
|
|
52
46
|
path: navigationRoutes.swapRoutes,
|
|
53
47
|
element: _jsx(SwapRoutesPage, {}),
|
|
@@ -60,30 +54,18 @@ export const AppRoutes = () => {
|
|
|
60
54
|
path: navigationRoutes.swapHistory,
|
|
61
55
|
element: _jsx(SwapHistoryPage, {}),
|
|
62
56
|
},
|
|
63
|
-
|
|
64
|
-
`${navigationRoutes.swapHistory}
|
|
65
|
-
`${navigationRoutes.swapExecution}/${navigationRoutes.swapDetails}`,
|
|
66
|
-
`${navigationRoutes.swapRoutes}/${navigationRoutes.swapExecution}/${navigationRoutes.swapDetails}`,
|
|
67
|
-
].map((path) => ({
|
|
68
|
-
path,
|
|
57
|
+
{
|
|
58
|
+
path: `${navigationRoutes.swapHistory}?/${navigationRoutes.swapRoutes}?/${navigationRoutes.swapExecution}?/${navigationRoutes.swapDetails}`,
|
|
69
59
|
element: _jsx(SwapDetailsPage, {}),
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
navigationRoutes.selectWallet
|
|
73
|
-
`${navigationRoutes.swapExecution}/${navigationRoutes.selectWallet}`,
|
|
74
|
-
`${navigationRoutes.swapRoutes}/${navigationRoutes.swapExecution}/${navigationRoutes.selectWallet}`,
|
|
75
|
-
].map((path) => ({
|
|
76
|
-
path,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
path: `${navigationRoutes.swapRoutes}?/${navigationRoutes.swapExecution}?/${navigationRoutes.selectWallet}`,
|
|
77
63
|
element: _jsx(SelectWalletPage, {}),
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
navigationRoutes.swapExecution
|
|
81
|
-
`${navigationRoutes.swapRoutes}/${navigationRoutes.swapExecution}`,
|
|
82
|
-
`${navigationRoutes.activeSwaps}/${navigationRoutes.swapExecution}`,
|
|
83
|
-
].map((path) => ({
|
|
84
|
-
path,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
path: `${navigationRoutes.swapRoutes}?/${navigationRoutes.activeSwaps}?/${navigationRoutes.swapExecution}`,
|
|
85
67
|
element: _jsx(SwapPage, {}),
|
|
86
|
-
}
|
|
68
|
+
},
|
|
87
69
|
{
|
|
88
70
|
path: '*',
|
|
89
71
|
element: _jsx(NotFound, {}),
|
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ export const WidgetPage = () => {
|
|
|
74
74
|
|
|
75
75
|
## Examples
|
|
76
76
|
|
|
77
|
-
Visit our [playground](https://
|
|
77
|
+
Visit our [playground](https://playground.li.fi) to see how you can customize your [LI.FI Widget](https://www.npmjs.com/package/@lifi/widget) experience.
|
|
78
78
|
|
|
79
79
|
## Documentation
|
|
80
80
|
|
package/cjs/AppRoutes.js
CHANGED
|
@@ -37,20 +37,14 @@ const AppRoutes = () => {
|
|
|
37
37
|
path: utils_1.navigationRoutes.toTokenNative,
|
|
38
38
|
element: (0, jsx_runtime_1.jsx)(SelectChainPage_1.SelectChainPage, { formType: "to", selectNativeToken: true }),
|
|
39
39
|
},
|
|
40
|
-
|
|
41
|
-
utils_1.navigationRoutes.fromChain
|
|
42
|
-
`${utils_1.navigationRoutes.fromToken}/${utils_1.navigationRoutes.fromChain}`,
|
|
43
|
-
].map((path) => ({
|
|
44
|
-
path,
|
|
40
|
+
{
|
|
41
|
+
path: `${utils_1.navigationRoutes.fromToken}?/${utils_1.navigationRoutes.fromChain}`,
|
|
45
42
|
element: (0, jsx_runtime_1.jsx)(SelectChainPage_1.SelectChainPage, { formType: "from" }),
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
utils_1.navigationRoutes.toChain
|
|
49
|
-
`${utils_1.navigationRoutes.toToken}/${utils_1.navigationRoutes.toChain}`,
|
|
50
|
-
].map((path) => ({
|
|
51
|
-
path,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
path: `${utils_1.navigationRoutes.toToken}?/${utils_1.navigationRoutes.toChain}`,
|
|
52
46
|
element: (0, jsx_runtime_1.jsx)(SelectChainPage_1.SelectChainPage, { formType: "to" }),
|
|
53
|
-
}
|
|
47
|
+
},
|
|
54
48
|
{
|
|
55
49
|
path: utils_1.navigationRoutes.swapRoutes,
|
|
56
50
|
element: (0, jsx_runtime_1.jsx)(SwapRoutesPage_1.SwapRoutesPage, {}),
|
|
@@ -63,30 +57,18 @@ const AppRoutes = () => {
|
|
|
63
57
|
path: utils_1.navigationRoutes.swapHistory,
|
|
64
58
|
element: (0, jsx_runtime_1.jsx)(SwapHistoryPage_1.SwapHistoryPage, {}),
|
|
65
59
|
},
|
|
66
|
-
|
|
67
|
-
`${utils_1.navigationRoutes.swapHistory}
|
|
68
|
-
`${utils_1.navigationRoutes.swapExecution}/${utils_1.navigationRoutes.swapDetails}`,
|
|
69
|
-
`${utils_1.navigationRoutes.swapRoutes}/${utils_1.navigationRoutes.swapExecution}/${utils_1.navigationRoutes.swapDetails}`,
|
|
70
|
-
].map((path) => ({
|
|
71
|
-
path,
|
|
60
|
+
{
|
|
61
|
+
path: `${utils_1.navigationRoutes.swapHistory}?/${utils_1.navigationRoutes.swapRoutes}?/${utils_1.navigationRoutes.swapExecution}?/${utils_1.navigationRoutes.swapDetails}`,
|
|
72
62
|
element: (0, jsx_runtime_1.jsx)(SwapDetailsPage_1.SwapDetailsPage, {}),
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
utils_1.navigationRoutes.selectWallet
|
|
76
|
-
`${utils_1.navigationRoutes.swapExecution}/${utils_1.navigationRoutes.selectWallet}`,
|
|
77
|
-
`${utils_1.navigationRoutes.swapRoutes}/${utils_1.navigationRoutes.swapExecution}/${utils_1.navigationRoutes.selectWallet}`,
|
|
78
|
-
].map((path) => ({
|
|
79
|
-
path,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
path: `${utils_1.navigationRoutes.swapRoutes}?/${utils_1.navigationRoutes.swapExecution}?/${utils_1.navigationRoutes.selectWallet}`,
|
|
80
66
|
element: (0, jsx_runtime_1.jsx)(SelectWalletPage_1.SelectWalletPage, {}),
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
utils_1.navigationRoutes.swapExecution
|
|
84
|
-
`${utils_1.navigationRoutes.swapRoutes}/${utils_1.navigationRoutes.swapExecution}`,
|
|
85
|
-
`${utils_1.navigationRoutes.activeSwaps}/${utils_1.navigationRoutes.swapExecution}`,
|
|
86
|
-
].map((path) => ({
|
|
87
|
-
path,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
path: `${utils_1.navigationRoutes.swapRoutes}?/${utils_1.navigationRoutes.activeSwaps}?/${utils_1.navigationRoutes.swapExecution}`,
|
|
88
70
|
element: (0, jsx_runtime_1.jsx)(SwapPage_1.SwapPage, {}),
|
|
89
|
-
}
|
|
71
|
+
},
|
|
90
72
|
{
|
|
91
73
|
path: '*',
|
|
92
74
|
element: (0, jsx_runtime_1.jsx)(NotFound_1.NotFound, {}),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContractComponent = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const providers_1 = require("../../providers");
|
|
6
|
+
const Card_1 = require("../Card");
|
|
7
|
+
const ContractComponent = (props) => {
|
|
8
|
+
const { contractComponent } = (0, providers_1.useWidgetConfig)();
|
|
9
|
+
if (!contractComponent) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(Card_1.Card, Object.assign({ flex: 1 }, props, { children: contractComponent })));
|
|
13
|
+
};
|
|
14
|
+
exports.ContractComponent = ContractComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ContractComponent';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ContractComponent"), exports);
|
|
@@ -47,8 +47,16 @@ const NavigationHeader = () => {
|
|
|
47
47
|
return t(`header.swap`);
|
|
48
48
|
case utils_1.navigationRoutes.swapDetails:
|
|
49
49
|
return t(`header.swapDetails`);
|
|
50
|
-
default:
|
|
51
|
-
|
|
50
|
+
default: {
|
|
51
|
+
switch (variant) {
|
|
52
|
+
case 'nft':
|
|
53
|
+
return t(`header.checkout`);
|
|
54
|
+
case 'refuel':
|
|
55
|
+
return t(`header.gas`);
|
|
56
|
+
default:
|
|
57
|
+
return t(`header.swap`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
52
60
|
}
|
|
53
61
|
};
|
|
54
62
|
return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: [utils_1.backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "start", onClick: navigateBack }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ArrowBack, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: 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)(jsx_runtime_1.Fragment, { children: [account.isActive ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`header.swapHistory`), enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "start", onClick: () => navigate(utils_1.navigationRoutes.swapHistory) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ReceiptLongRounded, {}) })) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`header.settings`), enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", onClick: () => navigate(utils_1.navigationRoutes.settings), sx: {
|
|
@@ -66,5 +66,5 @@ const ConnectedButton = () => {
|
|
|
66
66
|
});
|
|
67
67
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Header_style_1.WalletButton, Object.assign({ endIcon: (0, jsx_runtime_1.jsx)(icons_material_1.ExpandMore, {}), startIcon: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: chain === null || chain === void 0 ? void 0 : chain.logoURI, alt: chain === null || chain === void 0 ? void 0 : chain.key, sx: { width: 24, height: 24 } }, { children: chain === null || chain === void 0 ? void 0 : chain.name[0] })), sx: {
|
|
68
68
|
marginRight: -1.25,
|
|
69
|
-
}, onClick: handleClick }, { children: walletAddress })), (0, jsx_runtime_1.jsxs)(Menu_1.Menu, Object.assign({ elevation: 2, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose }, { children: [(0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ onClick: handleCopyAddress, disableRipple: true
|
|
69
|
+
}, onClick: handleClick }, { children: walletAddress })), (0, jsx_runtime_1.jsxs)(Menu_1.Menu, Object.assign({ elevation: 2, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose }, { children: [(0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ onClick: handleCopyAddress, disableRipple: true }, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.ContentCopy, {}), t(`button.copyAddress`)] })), (0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ onClick: handleDisconnect, disableRipple: true }, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.PowerSettingsNewRounded, {}), t(`button.disconnectWallet`)] }))] }))] }));
|
|
70
70
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.NFT = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const material_1 = require("@mui/material");
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
19
|
+
const react_i18next_1 = require("react-i18next");
|
|
20
|
+
const providers_1 = require("../../providers");
|
|
21
|
+
const Token_1 = require("../Token");
|
|
22
|
+
const NFT_style_1 = require("./NFT.style");
|
|
23
|
+
const NFT = (_a) => {
|
|
24
|
+
var { imageUrl, isLoading, collectonName, assetName, owner, token, contract } = _a, props = __rest(_a, ["imageUrl", "isLoading", "collectonName", "assetName", "owner", "token", "contract"]);
|
|
25
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
26
|
+
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
27
|
+
(0, react_1.useEffect)(() => {
|
|
28
|
+
if (token) {
|
|
29
|
+
setValue(providers_1.SwapFormKey.ToChain, token.chainId);
|
|
30
|
+
setValue(providers_1.SwapFormKey.ToToken, token.address);
|
|
31
|
+
setValue(providers_1.SwapFormKey.ToAmount, token.amount);
|
|
32
|
+
}
|
|
33
|
+
if (contract) {
|
|
34
|
+
setValue(providers_1.SwapFormKey.ToContractAddress, contract.address);
|
|
35
|
+
setValue(providers_1.SwapFormKey.ToContractCallData, contract.callData);
|
|
36
|
+
setValue(providers_1.SwapFormKey.ToContractGasLimit, contract.gasLimit);
|
|
37
|
+
}
|
|
38
|
+
}, [contract, setValue, token]);
|
|
39
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ p: 2 }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex" }, { children: [isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 96, height: 96, variant: "rectangular", sx: { borderRadius: 1 } })) : ((0, jsx_runtime_1.jsx)(NFT_style_1.PreviewAvatar, { src: imageUrl })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ ml: 2 }, { children: [isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 144, height: 21, variant: "text" })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.secondary" }, { children: collectonName }))), isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 112, height: 27, variant: "text" })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 18, fontWeight: 600 }, { children: assetName }))), isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 128, height: 21, variant: "text" })) : owner ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.secondary" }, { children: [t('swap.ownedBy'), ' ', (0, jsx_runtime_1.jsx)(material_1.Link, Object.assign({ href: owner.url, target: "_blank", underline: "none", color: "primary" }, { children: owner.name }))] }))) : null] }))] })), (0, jsx_runtime_1.jsx)(Token_1.Token, { token: token, isLoading: isLoading, mt: 2 })] })));
|
|
40
|
+
};
|
|
41
|
+
exports.NFT = NFT;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const PreviewAvatar: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
alt?: string | undefined;
|
|
4
|
+
children?: import("react").ReactNode;
|
|
5
|
+
classes?: Partial<import("@mui/material").AvatarClasses> | undefined;
|
|
6
|
+
imgProps?: (import("react").ImgHTMLAttributes<HTMLImageElement> & {
|
|
7
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
8
|
+
}) | undefined;
|
|
9
|
+
sizes?: string | undefined;
|
|
10
|
+
src?: string | undefined;
|
|
11
|
+
srcSet?: string | undefined;
|
|
12
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
13
|
+
variant?: "square" | "circular" | "rounded" | undefined;
|
|
14
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
15
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
16
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "alt" | "imgProps" | "sizes" | "src" | "srcSet"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PreviewAvatar = void 0;
|
|
4
|
+
const material_1 = require("@mui/material");
|
|
5
|
+
const styles_1 = require("@mui/material/styles");
|
|
6
|
+
exports.PreviewAvatar = (0, styles_1.styled)(material_1.Avatar)(({ theme }) => ({
|
|
7
|
+
background: theme.palette.background.paper,
|
|
8
|
+
width: 96,
|
|
9
|
+
height: 96,
|
|
10
|
+
borderRadius: theme.shape.borderRadius,
|
|
11
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./NFT"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TokenAmount } from '@lifi/sdk';
|
|
2
|
+
import type { WidgetContract } from '../../types';
|
|
3
|
+
export interface NFTProps {
|
|
4
|
+
imageUrl?: string;
|
|
5
|
+
collectonName?: string;
|
|
6
|
+
assetName?: string;
|
|
7
|
+
isLoading?: boolean;
|
|
8
|
+
owner?: NFTOwner;
|
|
9
|
+
token?: TokenAmount;
|
|
10
|
+
contract?: WidgetContract;
|
|
11
|
+
}
|
|
12
|
+
export interface NFTOwner {
|
|
13
|
+
name?: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const Select: import("@emotion/styled").StyledComponent<import("@mui/material").SelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
1
|
+
export declare const Select: import("@emotion/styled").StyledComponent<(import("@mui/material").SelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) & {
|
|
2
2
|
dense?: boolean | undefined;
|
|
3
3
|
}, {}, {}>;
|
|
@@ -22,7 +22,17 @@ const SelectChainAndToken = (props) => {
|
|
|
22
22
|
const disabledReverse = variant === 'refuel' ||
|
|
23
23
|
(disabledUI === null || disabledUI === void 0 ? void 0 : disabledUI.includes(types_1.DisabledUI.FromToken)) ||
|
|
24
24
|
(disabledUI === null || disabledUI === void 0 ? void 0 : disabledUI.includes(types_1.DisabledUI.ToToken));
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const nftVariant = variant === 'nft';
|
|
26
|
+
const isCompact = fromChain &&
|
|
27
|
+
toChain &&
|
|
28
|
+
fromToken &&
|
|
29
|
+
toToken &&
|
|
30
|
+
!prefersNarrowView &&
|
|
31
|
+
!nftVariant;
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { display: 'flex', flexDirection: isCompact ? 'row' : 'column' } }, props, { children: [(0, jsx_runtime_1.jsx)(SelectTokenButton_1.SelectTokenButton, { formType: "from", compact: isCompact }), !nftVariant ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: {
|
|
33
|
+
display: 'flex',
|
|
34
|
+
justifyContent: 'center',
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
}, m: !disabledReverse ? -1.125 : 1 }, { children: !disabledReverse ? ((0, jsx_runtime_1.jsx)(ReverseTokensButton_1.ReverseTokensButton, { vertical: !isCompact })) : null }))) : null, !nftVariant ? ((0, jsx_runtime_1.jsx)(SelectTokenButton_1.SelectTokenButton, { formType: "to", compact: isCompact })) : null] })));
|
|
27
37
|
};
|
|
28
38
|
exports.SelectChainAndToken = SelectChainAndToken;
|
|
@@ -31,9 +31,12 @@ const SelectTokenButton = ({ formType, compact }) => {
|
|
|
31
31
|
};
|
|
32
32
|
const isSelected = !!(chain && token);
|
|
33
33
|
const onClick = !(disabledUI === null || disabledUI === void 0 ? void 0 : disabledUI.includes(tokenKey)) ? handleClick : undefined;
|
|
34
|
-
const
|
|
34
|
+
const defaultPlaceholder = formType === 'to' && variant === 'refuel'
|
|
35
35
|
? t(`header.selectChain`)
|
|
36
36
|
: t(`swap.selectChainAndToken`);
|
|
37
|
-
|
|
37
|
+
const cardTitle = formType === 'from' && variant === 'nft'
|
|
38
|
+
? t(`swap.payWith`)
|
|
39
|
+
: t(`swap.${formType}`);
|
|
40
|
+
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({ flex: 1, onClick: onClick }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: cardTitle }), chainId && tokenAddress && (isChainLoading || isTokenLoading) ? ((0, jsx_runtime_1.jsx)(SelectTokenButton_style_1.SelectTokenCardHeader, { avatar: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "circular", width: 32, height: 32 }), title: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 64, height: 24 }), subheader: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 64, height: 16 }), compact: compact })) : ((0, jsx_runtime_1.jsx)(SelectTokenButton_style_1.SelectTokenCardHeader, { avatar: isSelected ? ((0, jsx_runtime_1.jsx)(TokenAvatar_1.TokenAvatar, { token: token, chain: chain })) : ((0, jsx_runtime_1.jsx)(TokenAvatar_1.TokenAvatarDefault, {})), title: isSelected ? token.symbol : defaultPlaceholder, subheader: isSelected ? t(`swap.onChain`, { chainName: chain.name }) : null, selected: isSelected, compact: compact }))] })));
|
|
38
41
|
};
|
|
39
42
|
exports.SelectTokenButton = SelectTokenButton;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Step } from '@lifi/sdk';
|
|
3
|
-
import type {
|
|
3
|
+
import type { WidgetVariant } from '../../types';
|
|
4
|
+
import type { StepActionsProps, StepDetailsLabelProps } from './types';
|
|
4
5
|
export declare const StepActions: React.FC<StepActionsProps>;
|
|
5
6
|
export declare const StepDetailsContent: React.FC<{
|
|
6
7
|
step: Step;
|
|
8
|
+
variant?: WidgetVariant;
|
|
7
9
|
}>;
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare const SwapStepDetailsLabel: React.FC<{
|
|
12
|
-
step: Step;
|
|
13
|
-
}>;
|
|
10
|
+
export declare const CustomStepDetailsLabel: React.FC<StepDetailsLabelProps>;
|
|
11
|
+
export declare const CrossStepDetailsLabel: React.FC<Omit<StepDetailsLabelProps, 'variant'>>;
|
|
12
|
+
export declare const SwapStepDetailsLabel: React.FC<Omit<StepDetailsLabelProps, 'variant'>>;
|
|
@@ -11,25 +11,43 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.SwapStepDetailsLabel = exports.CrossStepDetailsLabel = exports.StepDetailsContent = exports.StepActions = void 0;
|
|
14
|
+
exports.SwapStepDetailsLabel = exports.CrossStepDetailsLabel = exports.CustomStepDetailsLabel = exports.StepDetailsContent = exports.StepActions = void 0;
|
|
15
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
const icons_material_1 = require("@mui/icons-material");
|
|
17
17
|
const material_1 = require("@mui/material");
|
|
18
18
|
const react_i18next_1 = require("react-i18next");
|
|
19
19
|
const hooks_1 = require("../../hooks");
|
|
20
20
|
const icons_1 = require("../../icons");
|
|
21
|
+
const providers_1 = require("../../providers");
|
|
21
22
|
const utils_1 = require("../../utils");
|
|
22
23
|
const SmallAvatar_1 = require("../SmallAvatar");
|
|
23
24
|
const StepActions_style_1 = require("./StepActions.style");
|
|
24
25
|
const StepActions = (_a) => {
|
|
25
|
-
var _b;
|
|
26
|
+
var _b, _c;
|
|
26
27
|
var { step, dense } = _a, other = __rest(_a, ["step", "dense"]);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const { variant, contractTool } = (0, providers_1.useWidgetConfig)();
|
|
29
|
+
const StepDetailsLabel = step.tool === 'custom' && variant === 'nft'
|
|
30
|
+
? exports.CustomStepDetailsLabel
|
|
31
|
+
: step.type === 'cross' ||
|
|
32
|
+
(step.type === 'lifi' &&
|
|
33
|
+
step.includedSteps.some((step) => step.type === 'cross'))
|
|
34
|
+
? exports.CrossStepDetailsLabel
|
|
35
|
+
: exports.SwapStepDetailsLabel;
|
|
32
36
|
const isFullView = !dense && ((_b = step.includedSteps) === null || _b === void 0 ? void 0 : _b.length) > 1;
|
|
37
|
+
const customStep = variant === 'nft'
|
|
38
|
+
? (_c = step.includedSteps) === null || _c === void 0 ? void 0 : _c.find((step) => step.type === 'custom')
|
|
39
|
+
: undefined;
|
|
40
|
+
if (customStep && contractTool) {
|
|
41
|
+
const toolDetails = {
|
|
42
|
+
key: contractTool.name,
|
|
43
|
+
name: contractTool.name,
|
|
44
|
+
logoURI: contractTool.logoURI,
|
|
45
|
+
};
|
|
46
|
+
customStep.toolDetails = toolDetails;
|
|
47
|
+
if (!isFullView) {
|
|
48
|
+
step.toolDetails = toolDetails;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
33
51
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
34
52
|
const StepIconComponent = ({ icon }) => {
|
|
35
53
|
var _a;
|
|
@@ -40,19 +58,30 @@ const StepActions = (_a) => {
|
|
|
40
58
|
};
|
|
41
59
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({}, other, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' }, mb: isFullView ? 1.5 : 0 }, { children: [(0, jsx_runtime_1.jsx)(StepActions_style_1.StepAvatar, Object.assign({ variant: "circular", src: step.type !== 'lifi' ? step.toolDetails.logoURI : undefined, alt: step.toolDetails.name }, { children: step.type === 'lifi' ? (0, jsx_runtime_1.jsx)(icons_1.LiFiToolLogo, {}) : step.toolDetails.name[0] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ ml: 2, fontSize: 18, fontWeight: "500", textTransform: "capitalize" }, { children: step.type === 'lifi'
|
|
42
60
|
? 'LI.FI Smart Contract'
|
|
43
|
-
: step.toolDetails.name }))] })), isFullView ? ((0, jsx_runtime_1.jsx)(material_1.Stepper, Object.assign({ orientation: "vertical", connector: (0, jsx_runtime_1.jsx)(StepActions_style_1.StepConnector, {}), activeStep: -1 }, { children: step.includedSteps.map((step) => ((0, jsx_runtime_1.jsxs)(material_1.Step, Object.assign({ expanded: true }, { children: [(0, jsx_runtime_1.jsx)(StepActions_style_1.StepLabel, Object.assign({ StepIconComponent: StepIconComponent }, { children: step.type === 'cross' || step.type === 'lifi' ? ((0, jsx_runtime_1.jsx)(exports.CrossStepDetailsLabel, { step: step })) : ((0, jsx_runtime_1.jsx)(exports.SwapStepDetailsLabel, { step: step })) })), (0, jsx_runtime_1.jsx)(StepActions_style_1.StepContent, { children: (0, jsx_runtime_1.jsx)(exports.StepDetailsContent, { step: step }) })] }), step.id))) }))) : ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ ml: 6 }, { children: [(0, jsx_runtime_1.jsx)(StepDetailsLabel, { step: step }), (0, jsx_runtime_1.jsx)(exports.StepDetailsContent, { step: step })] })))] })));
|
|
61
|
+
: step.toolDetails.name }))] })), isFullView ? ((0, jsx_runtime_1.jsx)(material_1.Stepper, Object.assign({ orientation: "vertical", connector: (0, jsx_runtime_1.jsx)(StepActions_style_1.StepConnector, {}), activeStep: -1 }, { children: step.includedSteps.map((step, i) => ((0, jsx_runtime_1.jsxs)(material_1.Step, Object.assign({ expanded: true }, { children: [(0, jsx_runtime_1.jsx)(StepActions_style_1.StepLabel, Object.assign({ StepIconComponent: StepIconComponent }, { children: step.type === 'custom' && variant === 'nft' ? ((0, jsx_runtime_1.jsx)(exports.CustomStepDetailsLabel, { step: step, variant: variant })) : step.type === 'cross' || step.type === 'lifi' ? ((0, jsx_runtime_1.jsx)(exports.CrossStepDetailsLabel, { step: step })) : ((0, jsx_runtime_1.jsx)(exports.SwapStepDetailsLabel, { step: step })) })), (0, jsx_runtime_1.jsx)(StepActions_style_1.StepContent, { children: (0, jsx_runtime_1.jsx)(exports.StepDetailsContent, { step: step, variant: variant }) })] }), step.id))) }))) : ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ ml: 6 }, { children: [(0, jsx_runtime_1.jsx)(StepDetailsLabel, { step: step, variant: variant === 'nft' ? variant : undefined }), (0, jsx_runtime_1.jsx)(exports.StepDetailsContent, { step: step, variant: variant })] })))] })));
|
|
44
62
|
};
|
|
45
63
|
exports.StepActions = StepActions;
|
|
46
|
-
const StepDetailsContent = ({ step }) => {
|
|
64
|
+
const StepDetailsContent = ({ step, variant }) => {
|
|
47
65
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
48
66
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
49
67
|
return ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ fontSize: 12, fontWeight: "500", color: "text.secondary", alignItems: "center", display: "flex" }, { children: [t('format.number', {
|
|
50
68
|
value: (0, utils_1.formatTokenAmount)(step.estimate.fromAmount, step.action.fromToken.decimals),
|
|
51
|
-
}), ' ', step.action.fromToken.symbol, (
|
|
52
|
-
|
|
53
|
-
|
|
69
|
+
}), ' ', step.action.fromToken.symbol, !((step.type === 'custom' || step.tool === 'custom') &&
|
|
70
|
+
variant === 'nft') ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.ArrowForward, { sx: { fontSize: 18, paddingX: 0.5 } }), t('format.number', {
|
|
71
|
+
value: (0, utils_1.formatTokenAmount)((_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toAmount) !== null && _b !== void 0 ? _b : step.estimate.toAmount, (_e = (_d = (_c = step.execution) === null || _c === void 0 ? void 0 : _c.toToken) === null || _d === void 0 ? void 0 : _d.decimals) !== null && _e !== void 0 ? _e : step.action.toToken.decimals),
|
|
72
|
+
}), ' ', (_h = (_g = (_f = step.execution) === null || _f === void 0 ? void 0 : _f.toToken) === null || _g === void 0 ? void 0 : _g.symbol) !== null && _h !== void 0 ? _h : step.action.toToken.symbol] })) : null] })));
|
|
54
73
|
};
|
|
55
74
|
exports.StepDetailsContent = StepDetailsContent;
|
|
75
|
+
const CustomStepDetailsLabel = ({ step, variant, }) => {
|
|
76
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
77
|
+
if (!variant) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 12, fontWeight: "500", color: "text.secondary" }, { children: t(`swap.${variant}StepDetails`, {
|
|
81
|
+
tool: step.toolDetails.name,
|
|
82
|
+
}) })));
|
|
83
|
+
};
|
|
84
|
+
exports.CustomStepDetailsLabel = CustomStepDetailsLabel;
|
|
56
85
|
const CrossStepDetailsLabel = ({ step }) => {
|
|
57
86
|
var _a, _b;
|
|
58
87
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { Step } from '@lifi/sdk';
|
|
2
2
|
import type { BoxProps } from '@mui/material';
|
|
3
|
+
import type { WidgetVariant } from '../../types';
|
|
3
4
|
export interface StepActionsProps extends BoxProps {
|
|
4
5
|
step: Step;
|
|
5
6
|
dense?: boolean;
|
|
6
7
|
}
|
|
8
|
+
export interface StepDetailsLabelProps {
|
|
9
|
+
step: Step;
|
|
10
|
+
variant?: Extract<WidgetVariant, 'nft'>;
|
|
11
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import type { BoxProps } from '@mui/material';
|
|
2
3
|
import type { SwapFormTypeProps } from '../../providers';
|
|
3
|
-
export declare const SwapInput: React.FC<SwapFormTypeProps>;
|
|
4
|
+
export declare const SwapInput: React.FC<SwapFormTypeProps & BoxProps>;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.SwapInput = void 0;
|
|
4
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -14,7 +25,8 @@ const FormPriceHelperText_1 = require("./FormPriceHelperText");
|
|
|
14
25
|
const SwapInput_style_1 = require("./SwapInput.style");
|
|
15
26
|
const SwapInputEndAdornment_1 = require("./SwapInputEndAdornment");
|
|
16
27
|
const SwapInputStartAdornment_1 = require("./SwapInputStartAdornment");
|
|
17
|
-
const SwapInput = (
|
|
28
|
+
const SwapInput = (_a) => {
|
|
29
|
+
var { formType } = _a, props = __rest(_a, ["formType"]);
|
|
18
30
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
19
31
|
const amountKey = providers_1.SwapFormKeyHelper.getAmountKey(formType);
|
|
20
32
|
const { field: { onChange, onBlur, value }, } = (0, react_hook_form_1.useController)({
|
|
@@ -34,8 +46,8 @@ const SwapInput = ({ formType }) => {
|
|
|
34
46
|
onBlur();
|
|
35
47
|
};
|
|
36
48
|
const disabled = disabledUI === null || disabledUI === void 0 ? void 0 : disabledUI.includes(types_1.DisabledUI.FromAmount);
|
|
37
|
-
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.fromAmount') }), (0, jsx_runtime_1.jsxs)(SwapInput_style_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(SwapInput_style_1.Input, { inputRef: ref, size: "small", autoComplete: "off", placeholder: "0", startAdornment: (0, jsx_runtime_1.jsx)(SwapInputStartAdornment_1.SwapInputStartAdornment, { formType: formType }), endAdornment: !disabled ? ((0, jsx_runtime_1.jsx)(SwapInputEndAdornment_1.SwapInputEndAdornment, { formType: formType })) : undefined, inputProps: {
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.fromAmount') }), (0, jsx_runtime_1.jsxs)(SwapInput_style_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(SwapInput_style_1.Input, { inputRef: ref, size: "small", autoComplete: "off", placeholder: "0", startAdornment: (0, jsx_runtime_1.jsx)(SwapInputStartAdornment_1.SwapInputStartAdornment, { formType: formType }), endAdornment: !disabled ? ((0, jsx_runtime_1.jsx)(SwapInputEndAdornment_1.SwapInputEndAdornment, { formType: formType })) : undefined, inputProps: {
|
|
38
50
|
inputMode: 'decimal',
|
|
39
|
-
}, onChange: handleChange, onBlur: handleBlur, value: value, name: amountKey, disabled: disabled, required: true }), (0, jsx_runtime_1.jsx)(FormPriceHelperText_1.FormPriceHelperText, { formType: formType })] })), (0, jsx_runtime_1.jsx)(FitInputText_1.FitInputText, { ref: ref, formType: formType })] }));
|
|
51
|
+
}, onChange: handleChange, onBlur: handleBlur, value: value, name: amountKey, disabled: disabled, required: true }), (0, jsx_runtime_1.jsx)(FormPriceHelperText_1.FormPriceHelperText, { formType: formType })] })), (0, jsx_runtime_1.jsx)(FitInputText_1.FitInputText, { ref: ref, formType: formType })] })));
|
|
40
52
|
};
|
|
41
53
|
exports.SwapInput = SwapInput;
|
|
@@ -37,7 +37,9 @@ const SwapRouteCard = (_a) => {
|
|
|
37
37
|
e.stopPropagation();
|
|
38
38
|
setCardExpanded((expanded) => !expanded);
|
|
39
39
|
};
|
|
40
|
-
const
|
|
40
|
+
const token = widgetVariant === 'nft'
|
|
41
|
+
? Object.assign(Object.assign({}, route.fromToken), { amount: route.fromAmount }) : Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount });
|
|
42
|
+
const cardContent = ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ flex: 1 }, { children: [widgetVariant !== 'refuel' && !useRecommendedRoute ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2 }, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.Label, Object.assign({ active: active !== null && active !== void 0 ? active : label !== alternativeTag }, { children: label })), variant === 'stretched' ? ((0, jsx_runtime_1.jsx)(exports.SwapRouteCardEssentials, { route: route })) : null] }))) : null, (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(Token_1.Token, { token: token, step: variant === 'stretched' ? route.steps[0] : undefined, disableDescription: variant === 'dense' && widgetVariant !== 'refuel' }), variant === 'stretched' && !expanded ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconButton, Object.assign({ onClick: handleExpand, size: "small" }, { children: cardExpanded ? (0, jsx_runtime_1.jsx)(icons_material_1.ExpandLess, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.ExpandMore, {}) }))) : null] })), (0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true }, { children: route.steps.map((step) => ((0, jsx_runtime_1.jsx)(StepActions_1.StepActions, { step: step, mt: 2 }, step.id))) })), variant !== 'stretched' ? ((0, jsx_runtime_1.jsx)(exports.SwapRouteCardEssentials, { route: route, dense: true })) : null] })));
|
|
41
43
|
return widgetVariant === 'refuel' ? (cardContent) : ((0, jsx_runtime_1.jsx)(Card_1.Card, Object.assign({ dense: variant === 'dense', variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true }, other, { children: cardContent })));
|
|
42
44
|
};
|
|
43
45
|
exports.SwapRouteCard = SwapRouteCard;
|